diff --git a/ajax/libs/winjs/3.0.1/css/ui-dark.css b/ajax/libs/winjs/3.0.1/css/ui-dark.css new file mode 100644 index 000000000..3cbdda6b6 --- /dev/null +++ b/ajax/libs/winjs/3.0.1/css/ui-dark.css @@ -0,0 +1,7969 @@ +/* Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. */ +@keyframes WinJS-node-inserted { + from { + outline-color: #000; + } + to { + outline-color: #001; + } +} +@keyframes WinJS-opacity-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes WinJS-opacity-out { + from { + opacity: 1; + } + to { + opacity: 0; + } +} +@keyframes WinJS-scale-up { + from { + transform: scale(0.85); + } + to { + transform: scale(1); + } +} +@keyframes WinJS-scale-down { + from { + transform: scale(1); + } + to { + transform: scale(0.85); + } +} +@keyframes WinJS-default-remove { + from { + transform: translateX(11px); + } + to { + transform: none; + } +} +@keyframes WinJS-default-remove-rtl { + from { + transform: translateX(-11px); + } + to { + transform: none; + } +} +@keyframes WinJS-default-apply { + from { + transform: none; + } + to { + transform: translateX(11px); + } +} +@keyframes WinJS-default-apply-rtl { + from { + transform: none; + } + to { + transform: translateX(-11px); + } +} +@keyframes WinJS-showEdgeUI { + from { + transform: translateY(-70px); + } + to { + transform: none; + } +} +@keyframes WinJS-showPanel { + from { + transform: translateX(364px); + } + to { + transform: none; + } +} +@keyframes WinJS-showPanel-rtl { + from { + transform: translateX(-364px); + } + to { + transform: none; + } +} +@keyframes WinJS-hideEdgeUI { + from { + transform: none; + } + to { + transform: translateY(-70px); + } +} +@keyframes WinJS-hidePanel { + from { + transform: none; + } + to { + transform: translateX(364px); + } +} +@keyframes WinJS-hidePanel-rtl { + from { + transform: none; + } + to { + transform: translateX(-364px); + } +} +@keyframes WinJS-showPopup { + from { + transform: translateY(50px); + } + to { + transform: none; + } +} +@keyframes WinJS-dragSourceEnd { + from { + transform: translateX(11px) scale(1.05); + } + to { + transform: none; + } +} +@keyframes WinJS-dragSourceEnd-rtl { + from { + transform: translateX(-11px) scale(1.05); + } + to { + transform: none; + } +} +@keyframes WinJS-enterContent { + from { + transform: translateX(40px); + } + to { + transform: none; + } +} +@keyframes WinJS-enterContent-rtl { + from { + transform: translateX(-40px); + } + to { + transform: none; + } +} +@keyframes WinJS-exit { + from { + transform: none; + } + to { + transform: none; + } +} +@keyframes WinJS-enterPage { + from { + transform: translateX(100px); + } + to { + transform: none; + } +} +@keyframes WinJS-enterPage-rtl { + from { + transform: translateX(-100px); + } + to { + transform: none; + } +} +@keyframes WinJS-updateBadge { + from { + transform: translateY(24px); + } + to { + transform: none; + } +} +@-webkit-keyframes WinJS-node-inserted { + from { + outline-color: #000; + } + to { + outline-color: #001; + } +} +@-webkit-keyframes -webkit-WinJS-opacity-in { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@-webkit-keyframes -webkit-WinJS-opacity-out { + from { + opacity: 1; + } + to { + opacity: 0; + } +} +@-webkit-keyframes -webkit-WinJS-scale-up { + from { + -webkit-transform: scale(0.85); + } + to { + -webkit-transform: scale(1); + } +} +@-webkit-keyframes -webkit-WinJS-scale-down { + from { + -webkit-transform: scale(1); + } + to { + -webkit-transform: scale(0.85); + } +} +@-webkit-keyframes -webkit-WinJS-default-remove { + from { + -webkit-transform: translateX(11px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-default-remove-rtl { + from { + -webkit-transform: translateX(-11px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-default-apply { + from { + -webkit-transform: none; + } + to { + -webkit-transform: translateX(11px); + } +} +@-webkit-keyframes -webkit-WinJS-default-apply-rtl { + from { + -webkit-transform: none; + } + to { + -webkit-transform: translateX(-11px); + } +} +@-webkit-keyframes -webkit-WinJS-showEdgeUI { + from { + -webkit-transform: translateY(-70px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-showPanel { + from { + -webkit-transform: translateX(364px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-showPanel-rtl { + from { + -webkit-transform: translateX(-364px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-hideEdgeUI { + from { + -webkit-transform: none; + } + to { + -webkit-transform: translateY(-70px); + } +} +@-webkit-keyframes -webkit-WinJS-hidePanel { + from { + -webkit-transform: none; + } + to { + -webkit-transform: translateX(364px); + } +} +@-webkit-keyframes -webkit-WinJS-hidePanel-rtl { + from { + -webkit-transform: none; + } + to { + -webkit-transform: translateX(-364px); + } +} +@-webkit-keyframes -webkit-WinJS-showPopup { + from { + -webkit-transform: translateY(50px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-dragSourceEnd { + from { + -webkit-transform: translateX(11px) scale(1.05); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-dragSourceEnd-rtl { + from { + -webkit-transform: translateX(-11px) scale(1.05); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-enterContent { + from { + -webkit-transform: translateX(40px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-enterContent-rtl { + from { + -webkit-transform: translateX(-40px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-exit { + from { + -webkit-transform: none; + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-enterPage { + from { + -webkit-transform: translateX(100px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-enterPage-rtl { + from { + -webkit-transform: translateX(-100px); + } + to { + -webkit-transform: none; + } +} +@-webkit-keyframes -webkit-WinJS-updateBadge { + from { + -webkit-transform: translateY(24px); + } + to { + -webkit-transform: none; + } +} +@font-face { + font-family: "Segoe UI Command"; + src: local("Segoe UI Symbol"); + font-weight: normal; + font-style: normal; +} +@font-face { + font-family: "Symbols"; + src: url(../fonts/Symbols.ttf); +} +.win-type-xx-large { + font-size: 42pt; + font-weight: 200; + line-height: 1.1429; + letter-spacing: 0px; +} +.win-type-x-large { + font-size: 20pt; + font-weight: 200; + line-height: 1.2; +} +.win-type-large { + font-size: 11pt; + font-weight: 600; + line-height: 1.3636; +} +.win-type-medium { + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +.win-type-small { + font-size: 11pt; + font-weight: 300; + line-height: 1.3636; +} +.win-type-x-small { + font-size: 11pt; + font-weight: 300; + line-height: 1.3636; +} +.win-type-xx-small { + font-size: 9pt; + font-weight: 400; + line-height: 1.6667; +} +@font-face { + font-family: "Segoe"; + font-weight: 200; + src: local("Segoe UI Light"); +} +@font-face { + font-family: "Segoe"; + font-weight: 300; + src: local("Segoe UI Semilight"); +} +@font-face { + font-family: "Segoe"; + font-weight: 400; + src: local("Segoe UI"); +} +@font-face { + font-family: "Segoe"; + font-weight: 600; + src: local("Segoe UI Semibold"); +} +@font-face { + font-family: "Segoe"; + font-weight: 700; + src: local("Segoe UI Bold"); +} +@font-face { + font-family: "Segoe"; + font-style: italic; + font-weight: 400; + src: local("Segoe UI Italic"); +} +@font-face { + font-family: "Segoe"; + font-style: italic; + font-weight: 700; + src: local("Segoe UI Bold Italic"); +} +@font-face { + font-family: "Microsoft Yahei UI"; + font-weight: 200; + src: local("Microsoft Yahei UI Light"); +} +@font-face { + font-family: "Microsoft Yahei UI"; + font-weight: 300; + src: local("Microsoft Yahei UI"); +} +@font-face { + font-family: "Microsoft Yahei UI"; + font-weight: 500; + src: local("Microsoft Yahei UI"); +} +@font-face { + font-family: "Microsoft Yahei UI"; + font-weight: 600; + src: local("Microsoft Yahei UI Bold"); +} +@font-face { + font-family: "Microsoft JhengHei UI"; + font-weight: 200; + src: local("Microsoft JhengHei UI Light"); +} +@font-face { + font-family: "Microsoft JhengHei UI"; + font-weight: 300; + src: local("Microsoft JhengHei UI"); +} +@font-face { + font-family: "Microsoft JhengHei UI"; + font-weight: 500; + src: local("Microsoft JhengHei UI"); +} +@font-face { + font-family: "Microsoft JhengHei UI"; + font-weight: 600; + src: local("Microsoft JhengHei UI Bold"); +} +body:-ms-lang(am, ti), +.win-type-xx-large:-ms-lang(am, ti), +.win-type-x-large:-ms-lang(am, ti), +.win-type-large:-ms-lang(am, ti), +.win-type-medium:-ms-lang(am, ti), +.win-type-small:-ms-lang(am, ti), +.win-type-x-small:-ms-lang(am, ti), +.win-type-xx-small:-ms-lang(am, ti), +input:-ms-lang(am, ti), +textarea:-ms-lang(am, ti), +.win-textarea:-ms-lang(am, ti), +button:-ms-lang(am, ti), +select:-ms-lang(am, ti), +option:-ms-lang(am, ti) { + font-family: "Ebrima", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-xx-large:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-x-large:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-large:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-medium:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-small:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-x-small:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-type-xx-small:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +input:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +textarea:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +.win-textarea:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +button:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +select:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), +option:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te) { + font-family: "Nirmala UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(chr-CHER-US), +.win-type-xx-large:-ms-lang(chr-CHER-US), +.win-type-x-large:-ms-lang(chr-CHER-US), +.win-type-large:-ms-lang(chr-CHER-US), +.win-type-medium:-ms-lang(chr-CHER-US), +.win-type-small:-ms-lang(chr-CHER-US), +.win-type-x-small:-ms-lang(chr-CHER-US), +.win-type-xx-small:-ms-lang(chr-CHER-US), +input:-ms-lang(chr-CHER-US), +textarea:-ms-lang(chr-CHER-US), +.win-textarea:-ms-lang(chr-CHER-US), +button:-ms-lang(chr-CHER-US), +select:-ms-lang(chr-CHER-US), +option:-ms-lang(chr-CHER-US) { + font-family: "Gadugi", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(ja), +.win-type-xx-large:-ms-lang(ja), +.win-type-x-large:-ms-lang(ja), +.win-type-large:-ms-lang(ja), +.win-type-medium:-ms-lang(ja), +.win-type-small:-ms-lang(ja), +.win-type-x-small:-ms-lang(ja), +.win-type-xx-small:-ms-lang(ja), +input:-ms-lang(ja), +textarea:-ms-lang(ja), +.win-textarea:-ms-lang(ja), +button:-ms-lang(ja), +select:-ms-lang(ja), +option:-ms-lang(ja) { + font-family: "Meiryo UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(km, lo, th, bug-Bugi), +.win-type-xx-large:-ms-lang(km, lo, th, bug-Bugi), +.win-type-x-large:-ms-lang(km, lo, th, bug-Bugi), +.win-type-large:-ms-lang(km, lo, th, bug-Bugi), +.win-type-medium:-ms-lang(km, lo, th, bug-Bugi), +.win-type-small:-ms-lang(km, lo, th, bug-Bugi), +.win-type-x-small:-ms-lang(km, lo, th, bug-Bugi), +.win-type-xx-small:-ms-lang(km, lo, th, bug-Bugi), +input:-ms-lang(km, lo, th, bug-Bugi), +textarea:-ms-lang(km, lo, th, bug-Bugi), +.win-textarea:-ms-lang(km, lo, th, bug-Bugi), +button:-ms-lang(km, lo, th, bug-Bugi), +select:-ms-lang(km, lo, th, bug-Bugi), +option:-ms-lang(km, lo, th, bug-Bugi) { + font-family: "Leelawadee UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(ko), +.win-type-xx-large:-ms-lang(ko), +.win-type-x-large:-ms-lang(ko), +.win-type-large:-ms-lang(ko), +.win-type-medium:-ms-lang(ko), +.win-type-small:-ms-lang(ko), +.win-type-x-small:-ms-lang(ko), +.win-type-xx-small:-ms-lang(ko), +input:-ms-lang(ko), +textarea:-ms-lang(ko), +.win-textarea:-ms-lang(ko), +button:-ms-lang(ko), +select:-ms-lang(ko), +option:-ms-lang(ko) { + font-family: "Malgun Gothic", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(jv-Java), +.win-type-xx-large:-ms-lang(jv-Java), +.win-type-x-large:-ms-lang(jv-Java), +.win-type-large:-ms-lang(jv-Java), +.win-type-medium:-ms-lang(jv-Java), +.win-type-small:-ms-lang(jv-Java), +.win-type-x-small:-ms-lang(jv-Java), +.win-type-xx-small:-ms-lang(jv-Java), +input:-ms-lang(jv-Java), +textarea:-ms-lang(jv-Java), +.win-textarea:-ms-lang(jv-Java), +button:-ms-lang(jv-Java), +select:-ms-lang(jv-Java), +option:-ms-lang(jv-Java) { + font-family: "Javanese Text", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(cop-Copt), +.win-type-xx-large:-ms-lang(cop-Copt), +.win-type-x-large:-ms-lang(cop-Copt), +.win-type-large:-ms-lang(cop-Copt), +.win-type-medium:-ms-lang(cop-Copt), +.win-type-small:-ms-lang(cop-Copt), +.win-type-x-small:-ms-lang(cop-Copt), +.win-type-xx-small:-ms-lang(cop-Copt), +input:-ms-lang(cop-Copt), +textarea:-ms-lang(cop-Copt), +.win-textarea:-ms-lang(cop-Copt), +button:-ms-lang(cop-Copt), +select:-ms-lang(cop-Copt), +option:-ms-lang(cop-Copt) { + font-family: "Segoe UI Symbol", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-xx-large:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-x-large:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-large:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-medium:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-small:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-x-small:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-type-xx-small:-ms-lang(zh-CN, zh-Hans, zh-SG), +input:-ms-lang(zh-CN, zh-Hans, zh-SG), +textarea:-ms-lang(zh-CN, zh-Hans, zh-SG), +.win-textarea:-ms-lang(zh-CN, zh-Hans, zh-SG), +button:-ms-lang(zh-CN, zh-Hans, zh-SG), +select:-ms-lang(zh-CN, zh-Hans, zh-SG), +option:-ms-lang(zh-CN, zh-Hans, zh-SG) { + font-family: "Microsoft YaHei UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +body:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-xx-large:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-x-large:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-large:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-medium:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-small:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-x-small:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-type-xx-small:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +input:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +textarea:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +.win-textarea:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +button:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +select:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), +option:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO) { + font-family: "Microsoft JhengHei UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe UI Symbol", "Symbols", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; +} +html, +body { + width: 100%; + height: 100%; + margin: 0px; + cursor: default; + -moz-user-select: none; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -ms-user-select: none; + -ms-scroll-translation: vertical-to-horizontal; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} +html { + overflow: hidden; +} +html:lang(ar), +html:lang(dv), +html:lang(fa), +html:lang(he), +html:lang(ku-Arab), +html:lang(pa-Arab), +html:lang(prs), +html:lang(ps), +html:lang(sd-Arab), +html:lang(syr), +html:lang(ug), +html:lang(ur), +html:lang(qps-plocm) { + direction: rtl; +} +body { + -ms-content-zooming: none; + font-size: 11pt; + font-weight: 300; + line-height: 1.3636; +} +iframe { + border: 0; +} +body, +button, +input, +textarea, +.win-textarea, +select, +option { + letter-spacing: 0.02em; +} +body, +.win-type-xx-large, +.win-type-x-large, +.win-type-large, +.win-type-medium, +.win-type-small, +.win-type-x-small, +.win-type-xx-small, +input, +textarea, +.win-textarea, +button, +select, +option { + font-family: "Segoe", "sans-serif", "Segoe UI Symbol", "Symbols"; +} +button::-moz-focus-inner, +input::-moz-focus-inner { + padding: 0; + border: 0; +} +input[type=text], +input[type=password], +input[type=email], +input[type=number], +input[type=tel], +input[type=url], +input[type=search] { + -ms-user-select: element; + border-style: solid; + border-width: 2px; + margin: 4px 0px; + width: 260px; + min-width: 64px; + min-height: 28px; + background-clip: border-box; + padding: 0 8px; + outline: 0; + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +input::-ms-value { + margin: 0; +} +input[type=radio] { + width: 23px; + height: 23px; + margin-left: -1px; + margin-right: 4px; + margin-bottom: -2px; +} +input[type=radio]:lang(ar), +input[type=radio]:lang(dv), +input[type=radio]:lang(fa), +input[type=radio]:lang(he), +input[type=radio]:lang(ku-Arab), +input[type=radio]:lang(pa-Arab), +input[type=radio]:lang(prs), +input[type=radio]:lang(ps), +input[type=radio]:lang(sd-Arab), +input[type=radio]:lang(syr), +input[type=radio]:lang(ug), +input[type=radio]:lang(ur), +input[type=radio]:lang(qps-plocm) { + margin-left: 4px; + margin-right: -1px; +} +input[type=checkbox] { + width: 21px; + height: 21px; + margin-right: 5px; +} +input[type=checkbox]:lang(ar), +input[type=checkbox]:lang(dv), +input[type=checkbox]:lang(fa), +input[type=checkbox]:lang(he), +input[type=checkbox]:lang(ku-Arab), +input[type=checkbox]:lang(pa-Arab), +input[type=checkbox]:lang(prs), +input[type=checkbox]:lang(ps), +input[type=checkbox]:lang(sd-Arab), +input[type=checkbox]:lang(syr), +input[type=checkbox]:lang(ug), +input[type=checkbox]:lang(ur), +input[type=checkbox]:lang(qps-plocm) { + margin-left: 5px; + margin-right: 0px; +} +input::-ms-check { + border-style: solid; + display: inline-block; + border-width: 2px; + background-clip: border-box; +} +textarea, +.win-textarea { + -ms-user-select: element; + border-style: solid; + border-width: 2px; + margin: 4px 0px; + padding: 4px 8px; + padding-right: 17px; + min-width: 64px; + min-height: 39px; + background-clip: border-box; + overflow-y: scroll; + word-wrap: break-word; + outline: 0; + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +textarea:lang(ar), +.win-textarea:lang(ar), +textarea:lang(dv), +.win-textarea:lang(dv), +textarea:lang(fa), +.win-textarea:lang(fa), +textarea:lang(he), +.win-textarea:lang(he), +textarea:lang(ku-Arab), +.win-textarea:lang(ku-Arab), +textarea:lang(pa-Arab), +.win-textarea:lang(pa-Arab), +textarea:lang(prs), +.win-textarea:lang(prs), +textarea:lang(ps), +.win-textarea:lang(ps), +textarea:lang(sd-Arab), +.win-textarea:lang(sd-Arab), +textarea:lang(syr), +.win-textarea:lang(syr), +textarea:lang(ug), +.win-textarea:lang(ug), +textarea:lang(ur), +.win-textarea:lang(ur), +textarea:lang(qps-plocm), +.win-textarea:lang(qps-plocm) { + padding-right: 8px; + padding-left: 17px; +} +button, +input[type=button], +input[type=reset], +input[type=submit], +button[type=submit] { + border-style: solid; + background-clip: padding-box; + margin: 0px; + min-height: 32px; + min-width: 90px; + padding: 4px 8px; + border-width: 2px; + font-size: 11pt; + font-weight: 600; + line-height: 1.3636; +} +input[type=submit], +button[type=submit] { + background-clip: border-box; +} +input::-ms-clear, +input::-ms-reveal { + margin-right: -8px; + margin-left: 2px; +} +input:lang(ar)::-ms-clear, +input:lang(dv)::-ms-clear, +input:lang(fa)::-ms-clear, +input:lang(he)::-ms-clear, +input:lang(ku-Arab)::-ms-clear, +input:lang(pa-Arab)::-ms-clear, +input:lang(prs)::-ms-clear, +input:lang(ps)::-ms-clear, +input:lang(sd-Arab)::-ms-clear, +input:lang(syr)::-ms-clear, +input:lang(ug)::-ms-clear, +input:lang(ur)::-ms-clear, +input:lang(qps-plocm)::-ms-clear, +input:lang(ar)::-ms-reveal, +input:lang(dv)::-ms-reveal, +input:lang(fa)::-ms-reveal, +input:lang(he)::-ms-reveal, +input:lang(ku-Arab)::-ms-reveal, +input:lang(pa-Arab)::-ms-reveal, +input:lang(prs)::-ms-reveal, +input:lang(ps)::-ms-reveal, +input:lang(sd-Arab)::-ms-reveal, +input:lang(syr)::-ms-reveal, +input:lang(ug)::-ms-reveal, +input:lang(ur)::-ms-reveal, +input:lang(qps-plocm)::-ms-reveal { + margin-left: -8px; + margin-right: 2px; +} +input[type=file] { + border: none; + min-width: 100px; + min-height: 20px; + width: 340px; + height: 32px; + padding: 0px; + margin: 7px 8px 21px 8px; + background-clip: padding-box; +} +input[type=file]::-ms-value { + margin: 0; + border-width: 2px; + border-style: solid; + border-right-style: none; + border-radius: 0; + background-clip: border-box; + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +input[type=file]:lang(ar)::-ms-value, +input[type=file]:lang(dv)::-ms-value, +input[type=file]:lang(fa)::-ms-value, +input[type=file]:lang(he)::-ms-value, +input[type=file]:lang(ku-Arab)::-ms-value, +input[type=file]:lang(pa-Arab)::-ms-value, +input[type=file]:lang(prs)::-ms-value, +input[type=file]:lang(ps)::-ms-value, +input[type=file]:lang(sd-Arab)::-ms-value, +input[type=file]:lang(syr)::-ms-value, +input[type=file]:lang(ug)::-ms-value, +input[type=file]:lang(ur)::-ms-value, +input[type=file]:lang(qps-plocm)::-ms-value { + border-left-style: none; + border-right-style: solid; +} +input[type=file]::-ms-browse { + margin: 0; + padding: 0 18px; + border-width: 2px; + border-style: solid; + background-clip: padding-box; + font-size: 11pt; + font-weight: 600; + line-height: 1.3636; +} +select { + min-width: 80px; + min-height: 32px; + border-width: 2px; + border-style: solid; + background-clip: border-box; + margin: 4px 0px; + outline: 0; + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +select::-ms-value { + padding: 4px 8px; + margin: 0px; +} +select::-ms-expand { + border: 0px; + padding-left: 6px; + padding-right: 6px; +} +progress { + width: 180px; + height: 6px; + border-style: none; +} +progress.win-medium { + width: 280px; +} +progress.win-large { + width: 100%; +} +progress::-ms-fill { + border-style: none; +} +progress:indeterminate { + height: 4px; + padding: 1px 0px; +} +progress.win-paused:not(:indeterminate) { + animation-name: win-progress-fade-out; + animation-duration: 3s; + animation-timing-function: cubic-bezier(0.03, 0.76, 0.31, 1); + opacity: 0.5; +} +progress.win-error::-ms-fill { + opacity: 0; +} +progress.win-ring:indeterminate::-ms-fill { + animation-name: -ms-ring; +} +progress.win-ring { + width: 20px; + height: 20px; +} +progress.win-medium.win-ring { + width: 40px; + height: 40px; +} +progress.win-large.win-ring { + width: 60px; + height: 60px; +} +@keyframes win-progress-fade-out { + from { + opacity: 1.0; + } + to { + opacity: 0.5; + } +} +input[type=range] { + width: 280px; + height: auto; + padding: 17px 0px 32px 0px; + -webkit-appearance: none; +} +input[type=range]:focus { + outline: none; +} +input[type=range]::-ms-track { + padding: 0px; + width: auto; + height: 11px; + border-style: none; +} +input[type=range]::-webkit-slider-runnable-track { + height: 11px; +} +input[type=range]::-moz-range-track { + height: 11px; + border: none; +} +input[type=range]::-ms-thumb { + width: 11px; + height: 11px; + border-style: none; +} +input[type=range]::-webkit-slider-thumb { + -webkit-appearance: none; + height: 11px; + width: 11px; +} +input[type=range]::-moz-range-thumb { + width: 11px; + height: 11px; + border-radius: 0; + border: none; +} +input[type=range]::-ms-ticks-before, +input[type=range]::-ms-ticks-after { + width: 100%; + height: 5px; + display: none; +} +input[type=range]:disabled::-ms-fill-lower { + margin-right: 5px; +} +input[type=range]:disabled::-ms-fill-upper { + margin-left: 6px; +} +input[type=range]:disabled:lang(ar)::-ms-fill-lower, +input[type=range]:disabled:lang(dv)::-ms-fill-lower, +input[type=range]:disabled:lang(fa)::-ms-fill-lower, +input[type=range]:disabled:lang(he)::-ms-fill-lower, +input[type=range]:disabled:lang(ku-Arab)::-ms-fill-lower, +input[type=range]:disabled:lang(pa-Arab)::-ms-fill-lower, +input[type=range]:disabled:lang(prs)::-ms-fill-lower, +input[type=range]:disabled:lang(ps)::-ms-fill-lower, +input[type=range]:disabled:lang(sd-Arab)::-ms-fill-lower, +input[type=range]:disabled:lang(syr)::-ms-fill-lower, +input[type=range]:disabled:lang(ug)::-ms-fill-lower, +input[type=range]:disabled:lang(ur)::-ms-fill-lower, +input[type=range]:disabled:lang(qps-plocm)::-ms-fill-lower { + margin-right: 0; + margin-left: 5px; +} +input[type=range]:disabled:lang(ar)::-ms-fill-upper, +input[type=range]:disabled:lang(dv)::-ms-fill-upper, +input[type=range]:disabled:lang(fa)::-ms-fill-upper, +input[type=range]:disabled:lang(he)::-ms-fill-upper, +input[type=range]:disabled:lang(ku-Arab)::-ms-fill-upper, +input[type=range]:disabled:lang(pa-Arab)::-ms-fill-upper, +input[type=range]:disabled:lang(prs)::-ms-fill-upper, +input[type=range]:disabled:lang(ps)::-ms-fill-upper, +input[type=range]:disabled:lang(sd-Arab)::-ms-fill-upper, +input[type=range]:disabled:lang(syr)::-ms-fill-upper, +input[type=range]:disabled:lang(ug)::-ms-fill-upper, +input[type=range]:disabled:lang(ur)::-ms-fill-upper, +input[type=range]:disabled:lang(qps-plocm)::-ms-fill-upper { + margin-left: 0; + margin-right: 6px; +} +input[type=range].win-vertical { + width: auto; + height: 191px; + padding: 0px 17px; + writing-mode: bt-lr; +} +input[type=range].win-vertical::-ms-track { + width: 11px; + height: auto; +} +input[type=range].win-vertical:disabled::-ms-fill-lower { + margin-right: 0; + margin-top: 6px; +} +input[type=range].win-vertical:disabled::-ms-fill-upper { + margin-left: 0; + margin-bottom: 5px; +} +input[type=range].win-vertical::-ms-ticks-before, +input[type=range].win-vertical::-ms-ticks-after { + width: 5px; + height: 100%; + display: none; +} +input[type=range].win-vertical:disabled:lang(ar)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(dv)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(fa)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(he)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(ku-Arab)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(pa-Arab)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(prs)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(ps)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(sd-Arab)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(syr)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(ug)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(ur)::-ms-fill-lower, +input[type=range].win-vertical:disabled:lang(qps-plocm)::-ms-fill-lower { + margin-left: 0; +} +input[type=range].win-vertical:disabled:lang(ar)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(dv)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(fa)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(he)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(ku-Arab)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(pa-Arab)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(prs)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(ps)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(sd-Arab)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(syr)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(ug)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(ur)::-ms-fill-upper, +input[type=range].win-vertical:disabled:lang(qps-plocm)::-ms-fill-upper { + margin-right: 0; +} +input[type=range].win-vertical:lang(ar), +input[type=range].win-vertical:lang(dv), +input[type=range].win-vertical:lang(fa), +input[type=range].win-vertical:lang(he), +input[type=range].win-vertical:lang(ku-Arab), +input[type=range].win-vertical:lang(pa-Arab), +input[type=range].win-vertical:lang(prs), +input[type=range].win-vertical:lang(ps), +input[type=range].win-vertical:lang(sd-Arab), +input[type=range].win-vertical:lang(syr), +input[type=range].win-vertical:lang(ug), +input[type=range].win-vertical:lang(ur), +input[type=range].win-vertical:lang(qps-plocm) { + writing-mode: bt-rl; +} +a { + text-decoration: none; + cursor: default; +} +img { + border-style: none; +} +form { + margin: 0px; + padding: 0px; +} +legend { + margin: 0px 0px 10px 0px; + padding: 0px; + color: inherit; + font-size: 11pt; + font-weight: 300; + line-height: 1.3636; +} +code, +pre, +samp { + font-family: "Consolas"; + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +caption, +figcaption, +small { + font-size: 9pt; + font-weight: 400; + line-height: 1.6667; +} +.win-type-ellipsis { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +h1.win-type-ellipsis, +.win-type-xx-large.win-type-ellipsis { + line-height: 1.4286; +} +h2.win-type-ellipsis, +.win-type-x-large.win-type-ellipsis { + line-height: 1.5; +} +dt, +th { + font-size: 11pt; + font-weight: 700; + line-height: 1.3636; +} +abbr, +acronym, +address, +blockquote, +cite, +dl, +dd, +li, +ol, +p, +q, +td, +tr { + font-weight: 300; +} +b, +strong { + font-weight: 700; +} +em { + font-style: italic; +} +.win-scrollview { + overflow-x: auto; + overflow-y: hidden; + height: 400px; + width: 100%; +} +h1, +h2, +h3, +h4, +h5, +h6 { + margin-top: 0px; + margin-bottom: 0px; +} +h1 { + font-size: 42pt; + font-weight: 200; + line-height: 1.1429; + letter-spacing: 0px; +} +h2 { + font-size: 20pt; + font-weight: 200; + line-height: 1.2; +} +h3 { + font-size: 11pt; + font-weight: 600; + line-height: 1.3636; +} +h4 { + font-size: 11pt; + font-weight: 400; + line-height: 1.3636; +} +h5 { + font-size: 11pt; + font-weight: 300; + line-height: 1.3636; +} +h6 { + font-size: 9pt; + font-weight: 400; + line-height: 1.6667; +} +@media (-ms-high-contrast) { + .win-type-interactive { + color: WindowText; + } + .win-type-interactive:hover, + .win-type-interactive:hover:active { + color: -ms-hotlight; + } + .win-type-interactive:-ms-keyboard-active { + color: -ms-hotlight; + } + /* + Text selection high contrast color. + */ + ::selection, + select:focus::-ms-value { + background-color: Highlight; + color: HighlightText; + } + /* + Button + */ + button, + input[type=button], + input[type=reset], + input[type=file]::-ms-browse { + background-color: ButtonFace; + border-color: ButtonText; + color: ButtonText; + } + button[type=submit], + input[type=submit] { + background-color: Highlight; + border-color: ButtonText; + color: HighlightText; + } + button:hover:active, + button[type=submit]:hover:active, + input[type=button]:hover:active, + input[type=submit]:hover:active, + input[type=reset]:hover:active, + input[type=file]::-ms-browse:hover:active { + background-clip: border-box; + background-color: ButtonText; + border-color: transparent; + color: ButtonFace; + } + button:disabled, + button[type=submit]:disabled, + input[type=button]:disabled, + input[type=submit]:disabled, + input[type=reset]:disabled, + input[type=file]:disabled::-ms-browse, + button:disabled:active, + button[type=submit]:disabled:active, + input[type=button]:disabled:active, + input[type=submit]:disabled:active, + input[type=reset]:disabled:active, + input[type=file]:disabled::-ms-browse:active { + background-color: ButtonFace; + border-color: GrayText; + color: GrayText; + } + button:-ms-keyboard-active, + button[type=submit]:-ms-keyboard-active, + input[type=button]:-ms-keyboard-active, + input[type=submit]:-ms-keyboard-active, + input[type=reset]:-ms-keyboard-active { + background-clip: border-box; + background-color: ButtonText; + border-color: transparent; + color: ButtonFace; + } + button:hover, + input[type=button]:hover, + input[type=reset]:hover, + input::-ms-clear:hover, + input::-ms-reveal:hover, + input[type=file]::-ms-browse:hover { + background-color: Highlight; + border-color: ButtonText; + color: HighlightText; + } + input::-ms-clear:hover:active, + input::-ms-reveal:hover:active { + background-clip: border-box; + background-color: ButtonText; + border-color: transparent; + color: ButtonFace; + } + input:disabled::-ms-clear, + input:disabled::-ms-reveal, + select:disabled::-ms-expand { + background-color: ButtonFace; + border-color: GrayText; + color: GrayText; + } + input::-ms-clear, + input::-ms-reveal, + select::-ms-expand { + background-color: ButtonFace; + border-color: ButtonText; + color: ButtonText; + } + /* + Select + */ + select:active:not(:disabled)::-ms-expand { + color: ButtonFace; + background-color: ButtonText; + } + option:checked, + select:focus::-ms-value { + color: HighlightText; + background-color: Highlight; + } + select:active:not(:disabled)::-ms-value, + option:hover:active, + option:checked:hover:active { + color: ButtonFace; + background-color: ButtonText; + } + option:checked:disabled, + option:checked:disabled:active, + optgroup:disabled option:checked, + optgroup:disabled option:checked:active, + select:disabled option:checked, + select:disabled option:checked:active, + select:disabled:focus::-ms-value { + color: ButtonFace; + background-color: GrayText; + } + /* + Link high contrast colors. + */ + a { + color: -ms-hotlight; + } + a[disabled] { + color: GrayText; + } + /* + Text input, checkbox, radio, and select high contrast colors. + */ + input:hover::-ms-check { + /* only checkbox and radio have hover state */ + background-color: Highlight; + color: HighlightText; + } + input[type=text], + input[type=password], + input[type=email], + input[type=number], + input[type=tel], + input[type=url], + input[type=search], + textarea, + .win-textarea, + select, + input::-ms-check { + background-color: ButtonFace; + border-color: ButtonText; + color: ButtonText; + } + input:hover:active::-ms-check { + /* only checkbox and radio have active state */ + background-clip: border-box; + background-color: ButtonText; + border-color: transparent; + color: ButtonFace; + } + input[type=text]:disabled, + input[type=password]:disabled, + input[type=email]:disabled, + input[type=number]:disabled, + input[type=tel]:disabled, + input[type=url]:disabled, + input[type=search]:disabled, + input[type=file]::-ms-value, + textarea:disabled, + .win-textarea:disabled, + select:disabled, + input:disabled::-ms-check, + input:disabled:active::-ms-check { + border-color: GrayText; + color: ButtonText; + background-color: ButtonFace; + } + input[type]:-ms-input-placeholder, + textarea:-ms-input-placeholder { + color: GrayText; + } + input[type]::-webkit-input-placeholder, + textarea::-webkit-input-placeholder { + color: GrayText; + } + input[type]::-moz-input-placeholder, + textarea::-moz-input-placeholder { + color: GrayText; + } + input:disabled::-ms-check, + input:disabled:active::-ms-check, + select:disabled::-ms-value { + color: GrayText; + } + input:-ms-keyboard-active::-ms-check { + /* only checkbox and radio have active state */ + background-clip: border-box; + background-color: ButtonText; + border-color: transparent; + color: ButtonFace; + } + /* + Progress high contrast colors. + */ + progress { + border: 1px solid ButtonText; + background-color: ButtonFace; + color: Highlight; + } + progress:indeterminate { + border: transparent; + } + progress::-ms-fill { + border-right: 1px solid ButtonText; + background-color: Highlight; + } + progress.win-paused:not(:indeterminate)::-ms-fill { + background-color: GrayText; + } + progress.win-paused:not(:indeterminate) { + opacity: 1.0; + } + /* + Slider + */ + input[type=range]::-ms-track { + border: 1px solid ButtonText; + background-color: ButtonFace; + color: transparent; + } + input[type=range]:disabled::-ms-track { + border-color: GrayText; + } + input[type=range]::-ms-fill-lower { + background-color: Highlight; + } + input[type=range]:disabled::-ms-fill-lower { + background-color: transparent; + } + input[type=range]::-ms-ticks-before, + input[type=range]::-ms-ticks-after { + color: ButtonText; + } + input[type=range]:disabled::-ms-ticks-before, + input[type=range]:disabled::-ms-ticks-after { + color: GrayText; + } + input[type=range]::-ms-thumb { + background-color: ButtonText; + border-left: 1px solid HighlightText; + border-right: 1px solid HighlightText; + } + input[type=range].win-vertical::-ms-thumb { + border-left-style: none; + border-right-style: none; + border-top: 1px solid HighlightText; + border-bottom: 1px solid HighlightText; + } + input[type=range]:active::-ms-thumb { + background-color: HighlightText; + border-color: ButtonText; + } + input[type=range]:disabled::-ms-thumb, + input[type=range]:disabled:active::-ms-thumb { + background-color: GrayText; + border-color: GrayText; + } + input[type=range]:hover::-ms-thumb { + background-color: Highlight; + } +} +.win-toggleswitch { + outline: 0; +} +.win-toggleswitch .win-toggleswitch-header { + max-width: 470px; + font-size: 12pt; + width: 22em; + margin-bottom: 7px; + margin-top: 10px; + font-weight: 300; +} +.win-toggleswitch .win-toggleswitch-values { + display: inline-block; + vertical-align: top; +} +.win-toggleswitch .win-toggleswitch-value { + min-width: 65px; + margin-right: 20px; + height: 19px; + line-height: 19px; + vertical-align: top; + font-weight: 600; +} +.win-toggleswitch .win-toggleswitch-description { + font-size: 12pt; + width: 22em; + margin-top: 28px; + display: none; +} +.win-toggleswitch .win-toggleswitch-clickregion { + display: inline-block; + touch-action: none; + -ms-user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; +} +.win-toggleswitch .win-toggleswitch-track { + position: relative; + display: inline-block; + width: 50px; + height: 19px; + border-style: solid; + border-width: 2px; + box-sizing: border-box; +} +.win-toggleswitch .win-toggleswitch-fill { + position: absolute; + top: 1px; + display: inline-block; + height: 13px; + box-sizing: border-box; + -webkit-transition: width 0.1s; + transition: width 0.1s; +} +.win-toggleswitch .win-toggleswitch-fill-lower { + left: 1px; +} +.win-toggleswitch .win-toggleswitch-fill-upper { + right: 1px; +} +.win-toggleswitch .win-toggleswitch-thumb { + position: absolute; + top: 0; + margin-top: -2px; + margin-left: -2px; + display: inline-block; + width: 12px; + height: 19px; + -webkit-transition: left 0.1s; + transition: left 0.1s; +} +.win-toggleswitch:focus .win-toggleswitch-track { + outline-width: 1px; + outline-style: dotted; +} +.win-toggleswitch.win-toggleswitch-dragging .win-toggleswitch-fill, +.win-toggleswitch.win-toggleswitch-dragging .win-toggleswitch-thumb { + -webkit-transition: none; + transition: none; +} +.win-toggleswitch.win-toggleswitch-off .win-toggleswitch-value-on { + height: 0; + visibility: hidden; +} +.win-toggleswitch.win-toggleswitch-on .win-toggleswitch-value-off { + height: 0; + visibility: hidden; +} +.win-toggleswitch.win-toggleswitch-on .win-toggleswitch-fill-lower { + width: 35px; +} +.win-toggleswitch.win-toggleswitch-on .win-toggleswitch-fill-upper { + width: 0; +} +.win-toggleswitch.win-toggleswitch-on .win-toggleswitch-thumb { + left: 38px; +} +.win-toggleswitch.win-toggleswitch-off .win-toggleswitch-fill-lower { + width: 0; +} +.win-toggleswitch.win-toggleswitch-off .win-toggleswitch-fill-upper { + width: 35px; +} +.win-toggleswitch.win-toggleswitch-off .win-toggleswitch-thumb { + left: 0; +} +.win-toggleswitch:lang(ar), +.win-toggleswitch:lang(dv), +.win-toggleswitch:lang(fa), +.win-toggleswitch:lang(he), +.win-toggleswitch:lang(ku-Arab), +.win-toggleswitch:lang(pa-Arab), +.win-toggleswitch:lang(prs), +.win-toggleswitch:lang(ps), +.win-toggleswitch:lang(sd-Arab), +.win-toggleswitch:lang(syr), +.win-toggleswitch:lang(ug), +.win-toggleswitch:lang(ur), +.win-toggleswitch:lang(qps-plocm) { + direction: rtl; +} +.win-toggleswitch:lang(ar).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(dv).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(fa).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(he).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(prs).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ps).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(syr).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ug).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ur).win-toggleswitch-on .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-on .win-toggleswitch-fill-lower { + width: 0; +} +.win-toggleswitch:lang(ar).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(dv).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(fa).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(he).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(prs).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ps).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(syr).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ug).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ur).win-toggleswitch-on .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-on .win-toggleswitch-fill-upper { + width: 35px; +} +.win-toggleswitch:lang(ar).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(dv).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(fa).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(he).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(prs).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(ps).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(syr).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(ug).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(ur).win-toggleswitch-on .win-toggleswitch-thumb, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-on .win-toggleswitch-thumb { + left: 0; +} +.win-toggleswitch:lang(ar).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(dv).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(fa).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(he).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(prs).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ps).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(syr).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ug).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(ur).win-toggleswitch-off .win-toggleswitch-fill-lower, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-off .win-toggleswitch-fill-lower { + width: 35px; +} +.win-toggleswitch:lang(ar).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(dv).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(fa).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(he).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(prs).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ps).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(syr).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ug).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(ur).win-toggleswitch-off .win-toggleswitch-fill-upper, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-off .win-toggleswitch-fill-upper { + width: 0; +} +.win-toggleswitch:lang(ar).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(dv).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(fa).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(he).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(ku-Arab).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(pa-Arab).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(prs).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(ps).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(sd-Arab).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(syr).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(ug).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(ur).win-toggleswitch-off .win-toggleswitch-thumb, +.win-toggleswitch:lang(qps-plocm).win-toggleswitch-off .win-toggleswitch-thumb { + left: 38px; +} +.win-hub { + height: 100%; + width: 100%; + position: relative; +} +.win-hub-progress { + position: absolute; + top: 10px; + width: 100%; + z-index: 1; +} +.win-hub-viewport { + height: 100%; + width: 100%; + /* Allow win-hub-surface margin/padding right to work */ + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + -ms-flex: 0 0 auto; + -webkit-flex: 0 0 auto; + flex: 0 0 auto; + -ms-scroll-snap-type: proximity; +} +.win-hub-horizontal .win-hub-viewport { + overflow-x: auto; + overflow-y: hidden; +} +.win-hub-vertical .win-hub-viewport { + position: relative; + overflow-y: auto; + overflow-x: hidden; + -ms-flex-direction: column; + -webkit-flex-direction: column; + flex-direction: column; +} +.win-hub-surface { + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + -ms-flex: 0 0 auto; + -webkit-flex: 0 0 auto; + flex: 0 0 auto; +} +.win-hub-vertical .win-hub-surface { + width: 100%; + padding: 15px 0; + -ms-flex-direction: column; + -webkit-flex-direction: column; + flex-direction: column; +} +.win-hub-horizontal .win-hub-surface { + height: 100%; + padding: 0 80px; +} +.win-hub-section { + display: -ms-flexbox; + display: -webkit-flex; + display: flex; + -ms-flex-direction: column; + -webkit-flex-direction: column; + flex-direction: column; + padding: 0 40px; +} +.win-hub-horizontal .win-hub-section { + height: 100%; +} +.win-hub-horizontal .win-hub-section-header { + margin-top: 129px; +} +.win-hub-vertical .win-hub-section { + width: calc(100% - 80px); + padding: 14px 40px; +} +.win-hub-vertical .win-hub-section-header { + margin-top: 1px; +} +.win-hub-section-header { + -ms-flex: 0 0 auto; + -webkit-flex: 0 0 auto; + flex: 0 0 auto; + margin: 4px 0; + font-size: 20pt; + text-align: left; +} +.win-hub-section-header:lang(ar), +.win-hub-section-header:lang(dv), +.win-hub-section-header:lang(fa), +.win-hub-section-header:lang(he), +.win-hub-section-header:lang(ku-Arab), +.win-hub-section-header:lang(pa-Arab), +.win-hub-section-header:lang(prs), +.win-hub-section-header:lang(ps), +.win-hub-section-header:lang(sd-Arab), +.win-hub-section-header:lang(syr), +.win-hub-section-header:lang(ug), +.win-hub-section-header:lang(ur), +.win-hub-section-header:lang(qps-plocm) { + text-align: right; +} +button.win-hub-section-header-tabstop, +html.win-hoverable button.win-hub-section-header-tabstop:hover, +button.win-hub-section-header-tabstop:hover:active { + background-color: transparent; + border: 0; + padding: 0 3px 0 0; + min-height: 0; + min-width: 0; + max-width: calc(100% - 3px); + font-size: 20pt; +} +button.win-hub-section-header-tabstop:lang(ar), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(ar), +button.win-hub-section-header-tabstop:hover:active:lang(ar), +button.win-hub-section-header-tabstop:lang(dv), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(dv), +button.win-hub-section-header-tabstop:hover:active:lang(dv), +button.win-hub-section-header-tabstop:lang(fa), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(fa), +button.win-hub-section-header-tabstop:hover:active:lang(fa), +button.win-hub-section-header-tabstop:lang(he), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(he), +button.win-hub-section-header-tabstop:hover:active:lang(he), +button.win-hub-section-header-tabstop:lang(ku-Arab), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(ku-Arab), +button.win-hub-section-header-tabstop:hover:active:lang(ku-Arab), +button.win-hub-section-header-tabstop:lang(pa-Arab), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(pa-Arab), +button.win-hub-section-header-tabstop:hover:active:lang(pa-Arab), +button.win-hub-section-header-tabstop:lang(prs), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(prs), +button.win-hub-section-header-tabstop:hover:active:lang(prs), +button.win-hub-section-header-tabstop:lang(ps), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(ps), +button.win-hub-section-header-tabstop:hover:active:lang(ps), +button.win-hub-section-header-tabstop:lang(sd-Arab), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(sd-Arab), +button.win-hub-section-header-tabstop:hover:active:lang(sd-Arab), +button.win-hub-section-header-tabstop:lang(syr), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(syr), +button.win-hub-section-header-tabstop:hover:active:lang(syr), +button.win-hub-section-header-tabstop:lang(ug), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(ug), +button.win-hub-section-header-tabstop:hover:active:lang(ug), +button.win-hub-section-header-tabstop:lang(ur), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(ur), +button.win-hub-section-header-tabstop:hover:active:lang(ur), +button.win-hub-section-header-tabstop:lang(qps-plocm), +html.win-hoverable button.win-hub-section-header-tabstop:hover:lang(qps-plocm), +button.win-hub-section-header-tabstop:hover:active:lang(qps-plocm) { + padding: 0 0 0 3px; +} +button.win-hub-section-header-tabstop:focus { + outline: none; +} +button.win-hub-section-header-tabstop:-ms-keyboard-active { + background-color: transparent; +} +.win-hub-section-header-wrapper { + display: -ms-inline-flexbox; + display: -webkit-inline-flex; + display: inline-flex; + -ms-flex-direction: row; + -webkit-flex-direction: row; + flex-direction: row; + width: 100%; + outline: none; +} +.win-hub-section-header-content { + display: inline-block; + -ms-flex: 1 1 auto; + -webkit-flex: 1 1 auto; + flex: 1 1 auto; +} +.win-hub-section-header-chevron { + display: none; +} +.win-hub-section-header-interactive .win-hub-section-header-chevron { + -ms-flex: 0 0 auto; + -webkit-flex: 0 0 auto; + flex: 0 0 auto; + display: inline-block; + margin-left: 7px; +} +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(ar), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(dv), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(fa), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(he), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(ku-Arab), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(pa-Arab), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(prs), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(ps), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(sd-Arab), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(syr), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(ug), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(ur), +.win-hub-section-header-interactive .win-hub-section-header-chevron:lang(qps-plocm) { + margin-left: 0; + margin-right: 7px; +} +.win-hub-section-header-chevron::before { + font-family: "Segoe UI Symbol", "Symbols"; + content: "\E26B"; +} +.win-hub-section-header-chevron:lang(ar), +.win-hub-section-header-chevron:lang(dv), +.win-hub-section-header-chevron:lang(fa), +.win-hub-section-header-chevron:lang(he), +.win-hub-section-header-chevron:lang(ku-Arab), +.win-hub-section-header-chevron:lang(pa-Arab), +.win-hub-section-header-chevron:lang(prs), +.win-hub-section-header-chevron:lang(ps), +.win-hub-section-header-chevron:lang(sd-Arab), +.win-hub-section-header-chevron:lang(syr), +.win-hub-section-header-chevron:lang(ug), +.win-hub-section-header-chevron:lang(ur), +.win-hub-section-header-chevron:lang(qps-plocm) { + font-family: "Segoe UI Symbol", "Symbols"; + content: "\E26C"; +} +.win-hub-section-content { + -ms-flex: 1 1 auto; + -webkit-flex: 1 1 auto; + flex: 1 1 auto; +} +.win-hub-horizontal .win-hub-section-content { + height: calc(100% - 44px); +} +.win-hub-vertical .win-hub-section-content { + width: 100%; +} +@media (-ms-high-contrast) { + button.win-hub-section-header-tabstop, + html.win-hoverable button.win-hub-section-header-tabstop:hover, + button.win-hub-section-header-tabstop:hover:active { + background-color: transparent; + color: WindowText; + } + button.win-hub-section-header-tabstop:-ms-keyboard-active { + color: WindowText; + } + html.win-hoverable button.win-hub-section-header-tabstop.win-hub-section-header-interactive:hover, + button.win-hub-section-header-tabstop.win-hub-section-header-interactive:hover:active { + color: -ms-hotlight; + } + button.win-hub-section-header-tabstop.win-hub-section-header-interactive:-ms-keyboard-active { + color: -ms-hotlight; + } +} +body > .win-navigation-backbutton { + position: absolute; + top: 50px; + left: 20px; +} +.win-backbutton, +.win-back { + display: inline-block; + min-width: 0; + min-height: 0; + background-clip: border-box; + box-sizing: border-box; + border-radius: 50%; + border-width: 2px; + border-style: solid; + padding: 0; + text-align: center; + width: 41px; + height: 41px; + font-size: 14pt; + line-height: 37px; + vertical-align: baseline; +} +html.win-hoverable .win-backbutton:hover, +.win-backbutton:hover:active { + border-width: 2px; + border-style: solid; + border-radius: 50%; +} +.win-backbutton::before, +.win-back::before { + font-family: "Segoe UI Symbol", "Symbols"; + font-weight: normal; + content: "\E0D5"; + vertical-align: 50%; +} +.win-backbutton:lang(ar)::before, +.win-backbutton:lang(dv)::before, +.win-backbutton:lang(fa)::before, +.win-backbutton:lang(he)::before, +.win-backbutton:lang(ku-Arab)::before, +.win-backbutton:lang(pa-Arab)::before, +.win-backbutton:lang(prs)::before, +.win-backbutton:lang(ps)::before, +.win-backbutton:lang(sd-Arab)::before, +.win-backbutton:lang(syr)::before, +.win-backbutton:lang(ug)::before, +.win-backbutton:lang(ur)::before, +.win-backbutton:lang(qps-plocm)::before, +.win-back:lang(ar)::before, +.win-back:lang(dv)::before, +.win-back:lang(fa)::before, +.win-back:lang(he)::before, +.win-back:lang(ku-Arab)::before, +.win-back:lang(pa-Arab)::before, +.win-back:lang(prs)::before, +.win-back:lang(ps)::before, +.win-back:lang(sd-Arab)::before, +.win-back:lang(syr)::before, +.win-back:lang(ug)::before, +.win-back:lang(ur)::before, +.win-back:lang(qps-plocm)::before { + content: "\E0AE"; +} +.win-backbutton:disabled, +.win-backbutton:disabled:active, +.win-navigation-backbutton:disabled, +.win-navigation-backbutton:disabled:active { + visibility: hidden; +} +button.win-navigation-backbutton, +button.win-navigation-backbutton:active, +html.win-hoverable button.win-navigation-backbutton:hover, +button.win-navigation-backbutton:active:hover { + display: inline-block; + padding: 2px; + min-height: 0px; + min-width: 0px; + height: 45px; + width: 45px; +} +button.win-navigation-backbutton, +button.win-navigation-backbutton:active, +html.win-hoverable button.win-navigation-backbutton:enabled:hover, +button.win-navigation-backbutton:enabled:hover:active { + background-color: transparent; + border: none; +} +@media (-ms-high-contrast) { + button.win-navigation-backbutton, + button.win-navigation-backbutton:active, + html.win-hoverable button.win-navigation-backbutton:enabled:hover, + button.win-navigation-backbutton:enabled:hover:active { + /* Overwrite default background and border styles from BackButton control's ]]> + /// The BackButton control itself + /// The Back Arrow glyph + /// + /// + /// + BackButton: _Base.Namespace._lazy(function () { + // Statics + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/backbuttonarialabel").value; }, + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; } + }; + + var BackButton = _Base.Class.define(function BackButton_ctor(element, options) { + /// + /// + /// Creates a new BackButton control + /// + /// + /// The DOM element that will host the control. If this parameter is null, this constructor creates one for you. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to + /// one of the control's properties or events. + /// + /// + /// A BackButton control. + /// + /// + /// + + // Check to make sure we weren't duplicated + if (element && element.winControl) { + throw new _ErrorFromName("WinJS.UI.BackButton.DuplicateConstruction", strings.duplicateConstruction); + } + + this._element = element || _Global.document.createElement("button"); + options = options || {}; + + this._initializeButton(); // This will also set the aria-label and tooltip + + this._disposed = false; + + // Remember ourselves + this._element.winControl = this; + + _Control.setOptions(this, options); + + // Add event handlers for this back button instance + this._buttonClickHandler = this._handleBackButtonClick.bind(this); + this._element.addEventListener('click', this._buttonClickHandler, false); + this._navigatedHandler = this._handleNavigatedEvent.bind(this); + Navigation.addEventListener('navigated', this._navigatedHandler, false); + + // Increment reference count / manage add global event handlers + singleton.addRef(); + }, { + + /// + element: { + get: function () { + return this._element; + } + }, + + dispose: function () { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; // Mark this control as disposed. + + // Remove 'navigated' eventhandler for this BackButton + Navigation.removeEventListener('navigated', this._navigatedHandler, false); + + singleton.release(); // Decrement reference count. + + }, + + refresh: function () { + /// + /// + /// Sets the 'disabled' attribute to correct the value based on the current navigation history stack. + /// + /// + /// + if (Navigation.canGoBack) { + this._element.disabled = false; + } else { + this._element.disabled = true; + } + }, + + _initializeButton: function () { + //Final EN-US HTML should be: + // + //Button will automatically be disabled if WinJS.Navigation.history.canGoBack is false. + + // Verify the HTML is a button + if (this._element.tagName !== "BUTTON") { + throw new _ErrorFromName("WinJS.UI.BackButton.BadButtonElement", strings.badButtonElement); + } + + // Attach our css classes + _ElementUtilities.addClass(this._element, navigationBackButtonClass); + + // Attach disposable class. + _ElementUtilities.addClass(this._element, "win-disposable"); + + // Create inner glyph element + this._element.innerHTML = ''; + + // Set the 'disabled' property to the correct value based on the current navigation history stack. + this.refresh(); + + // Set Aria-label and native tooltip to the same localized string equivalent of "Back" + this._element.setAttribute("aria-label", strings.ariaLabel); + this._element.setAttribute("title", strings.ariaLabel); + + // Explicitly set type attribute to avoid the default '; + this._headerTabStopElement = this._headerElement.firstElementChild; + // The purpose of headerWrapperElement is to lay out its children in a flexbox. Ideally, this flexbox would + // be on headerTabStopElement. However, firefox lays out flexboxes with display:flex differently. + // Firefox bug 1014285 (Button with display:inline-flex doesn't layout properly) + // https://bugzilla.mozilla.org/show_bug.cgi?id=1014285 + this._headerWrapperElement = this._headerTabStopElement.firstElementChild; + this._headerContentElement = this._headerWrapperElement.firstElementChild; + this._headerChevronElement = this._headerWrapperElement.lastElementChild; + element.appendChild(this._headerElement); + + this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._headerElement); + + this._contentElement = _Global.document.createElement("DIV"); + this._contentElement.className = HubSection._ClassName.hubSectionContent; + this._contentElement.style.visibility = "hidden"; + element.appendChild(this._contentElement); + + // Reparent any existing elements inside the new hub section content element. + var elementToMove = this.element.firstChild; + while (elementToMove !== this._headerElement) { + var nextElement = elementToMove.nextSibling; + this._contentElement.appendChild(elementToMove); + elementToMove = nextElement; + } + + this._processors = [ControlProcessor.processAll]; + + _Control.setOptions(this, options); + }, { + /// + element: { + get: function () { + return this._element; + } + }, + /// + /// Gets or sets a value that specifies whether the header is static. Set this value to true to disable clicks and other interactions. + /// + /// + isHeaderStatic: { + get: function () { + return this._isHeaderStatic; + }, + set: function (value) { + this._isHeaderStatic = value; + if (!this._isHeaderStatic) { + this._headerTabStopElement.setAttribute("role", "link"); + _ElementUtilities.addClass(this._headerTabStopElement, HubSection._ClassName.hubSectionInteractive); + } else { + this._headerTabStopElement.setAttribute("role", "heading"); + _ElementUtilities.removeClass(this._headerTabStopElement, HubSection._ClassName.hubSectionInteractive); + } + } + }, + /// + /// Gets the DOM element that hosts the HubSection's content. + /// + /// + contentElement: { + get: function () { + return this._contentElement; + } + }, + /// + /// Get or set the HubSection's header. After you set this property, the Hub renders the header again. + /// + /// + header: { + get: function () { + return this._header; + }, + set: function (value) { + // Render again even if it is equal to itself. + this._header = value; + this._renderHeader(); + } + }, + _setHeaderTemplate: function HubSection_setHeaderTemplate(template) { + this._template = _ElementUtilities._syncRenderer(template); + this._renderHeader(); + }, + _renderHeader: function HubSection_renderHeader() { + if (this._template) { + _Dispose._disposeElement(this._headerContentElement); + _ElementUtilities.empty(this._headerContentElement); + this._template(this, this._headerContentElement); + } + }, + _process: function HubSection_process() { + var that = this; + + this._processed = (this._processors || []).reduce(function (promise, processor) { + return promise.then(function () { + return processor(that.contentElement); + }); + }, this._processed || Promise.as()); + this._processors = null; + + return this._processed; + }, + dispose: function HubSection_dispose() { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + this._processors = null; + + _Dispose._disposeElement(this._headerContentElement); + _Dispose.disposeSubTree(this.contentElement); + } + }, { + // Names of classes used by the HubSection. + _ClassName: { + hubSection: "win-hub-section", + hubSectionHeader: "win-hub-section-header", + hubSectionHeaderTabStop: "win-hub-section-header-tabstop", + hubSectionHeaderWrapper: "win-hub-section-header-wrapper", + hubSectionInteractive: "win-hub-section-header-interactive", + hubSectionHeaderContent: "win-hub-section-header-content", + hubSectionHeaderChevron: "win-hub-section-header-chevron", + hubSectionContent: "win-hub-section-content" + }, + _Constants: { + ellipsisTypeClassName: "win-type-ellipsis", + xLargeTypeClassName: "win-type-x-large" + }, + isDeclarativeControlContainer: _BaseUtils.markSupportedForProcessing(function (section, callback) { + if (callback === ControlProcessor.processAll) { + return; + } + + section._processors = section._processors || []; + section._processors.push(callback); + + // Once processed the first time synchronously queue up new processors as they come in + if (section._processed) { + section._process(); + } + }) + }); + + return HubSection; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/Hub',[ + '../Core/_Global', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Events', + '../Core/_Log', + '../Core/_Resources', + '../Core/_WriteProfilerMark', + '../Animations', + '../Animations/_TransitionAnimation', + '../BindingList', + '../ControlProcessor', + '../Promise', + '../_Signal', + '../Scheduler', + '../Utilities/_Control', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + '../Utilities/_UI', + './Hub/_Section', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' + ], function hubInit(_Global, _Base, _BaseUtils, _ErrorFromName, _Events, _Log, _Resources, _WriteProfilerMark, Animations, _TransitionAnimation, BindingList, ControlProcessor, Promise, _Signal, Scheduler, _Control, _ElementUtilities, _Hoverable, _UI, _Section) { + "use strict"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// + /// Displays sections of content. + /// + /// + /// + /// + /// + /// + ///
HubSection Content
+ /// ]]>
+ /// Raised when the Hub is about to play an entrance or a transition animation. + /// Raised when a header is invoked. + /// Raised when the loading state changes. + /// The entire Hub control. + /// The progress indicator for the Hub. + /// The viewport of the Hub. + /// The scrollable region of the Hub. + /// + /// + /// + Hub: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + function hubDefaultHeaderTemplate(section) { + var element = _Global.document.createTextNode(typeof section.header === "object" ? JSON.stringify(section.header) : ('' + section.header)); + return element; + } + + var createEvent = _Events._createEventProperty; + var eventNames = { + contentAnimating: "contentanimating", + headerInvoked: "headerinvoked", + loadingStateChanged: "loadingstatechanged" + }; + + // Delay time before progress dots are shown when loading hub section(s) on screen. + var progressDelay = 500; + + var verticalNames = { + scrollPos: "scrollTop", + scrollSize: "scrollHeight", + offsetPos: "offsetTop", + offsetSize: "offsetHeight", + oppositeOffsetSize: "offsetWidth", + marginStart: "marginTop", + marginEnd: "marginBottom", + borderStart: "borderTopWidth", + borderEnd: "borderBottomWidth", + paddingStart: "paddingTop", + paddingEnd: "paddingBottom" + }; + var rtlHorizontalNames = { + scrollPos: "scrollLeft", + scrollSize: "scrollWidth", + offsetPos: "offsetLeft", + offsetSize: "offsetWidth", + oppositeOffsetSize: "offsetHeight", + marginStart: "marginRight", + marginEnd: "marginLeft", + borderStart: "borderRightWidth", + borderEnd: "borderLeftWidth", + paddingStart: "paddingRight", + paddingEnd: "paddingLeft" + }; + var ltrHorizontalNames = { + scrollPos: "scrollLeft", + scrollSize: "scrollWidth", + offsetPos: "offsetLeft", + offsetSize: "offsetWidth", + oppositeOffsetSize: "offsetHeight", + marginStart: "marginLeft", + marginEnd: "marginRight", + borderStart: "borderLeftWidth", + borderEnd: "borderRightWidth", + paddingStart: "paddingLeft", + paddingEnd: "paddingRight" + }; + + var Hub = _Base.Class.define(function Hub_ctor(element, options) { + /// + /// + /// Creates a new Hub control. + /// + /// + /// The DOM element that hosts the Hub control. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. + /// Each property of the options object corresponds to one of the control's properties or events. + /// Event names must begin with "on". For example, to provide a handler for the contentanimating event, + /// add a property named "oncontentanimating" to the options object and set its value to the event handler. + /// + /// + /// The new Hub. + /// + /// + /// + element = element || _Global.document.createElement("DIV"); + options = options || {}; + + if (element.winControl) { + throw new _ErrorFromName("WinJS.UI.Hub.DuplicateConstruction", strings.duplicateConstruction); + } + + this._id = element.id || _ElementUtilities._uniqueID(element); + this._writeProfilerMark("constructor,StartTM"); + + this._windowKeyDownHandlerBound = this._windowKeyDownHandler.bind(this); + _Global.addEventListener('keydown', this._windowKeyDownHandlerBound); + + // Attaching JS control to DOM element + element.winControl = this; + this._element = element; + _ElementUtilities.addClass(this.element, Hub._ClassName.hub); + _ElementUtilities.addClass(this.element, "win-disposable"); + + this._viewportElement = _Global.document.createElement("DIV"); + this._viewportElement.className = Hub._ClassName.hubViewport; + this._element.appendChild(this._viewportElement); + this._viewportElement.setAttribute("role", "group"); + this._viewportElement.setAttribute("aria-label", strings.hubViewportAriaLabel); + + this._surfaceElement = _Global.document.createElement("DIV"); + this._surfaceElement.className = Hub._ClassName.hubSurface; + this._viewportElement.appendChild(this._surfaceElement); + + // Start invisible so that you do not see the content loading until the sections are ready. + this._visible = false; + this._viewportElement.style.opacity = 0; + + if (!options.orientation) { + this._orientation = _UI.Orientation.horizontal; + _ElementUtilities.addClass(this.element, Hub._ClassName.hubHorizontal); + } + + this._fireEntrance = true; + this._animateEntrance = true; + this._loadId = 0; + this.runningAnimations = new Promise.wrap(); + this._currentIndexForSezo = 0; + + // This internally assigns this.sections which causes section to be used (even from options) before + // scrollPosition or sectionOnScreen. + this._parse(); + + _Control.setOptions(this, options); + + _ElementUtilities._addEventListener(this.element, "focusin", this._focusin.bind(this), false); + this.element.addEventListener("keydown", this._keyDownHandler.bind(this)); + this.element.addEventListener("click", this._clickHandler.bind(this)); + this._resizeHandlerBound = this._resizeHandler.bind(this); + this.element.addEventListener("mselementresize", this._resizeHandlerBound); + _ElementUtilities._resizeNotifier.subscribe(this.element, this._resizeHandlerBound); + this._viewportElement.addEventListener("scroll", this._scrollHandler.bind(this)); + this._surfaceElement.addEventListener("mselementresize", this._contentResizeHandler.bind(this)); + + this._handleSectionChangedBind = this._handleSectionChanged.bind(this); + this._handleSectionInsertedBind = this._handleSectionInserted.bind(this); + this._handleSectionMovedBind = this._handleSectionMoved.bind(this); + this._handleSectionRemovedBind = this._handleSectionRemoved.bind(this); + this._handleSectionReloadBind = this._handleSectionReload.bind(this); + + this._refresh(); + + this._writeProfilerMark("constructor,StopTM"); + }, { + /// + element: { + get: function () { + return this._element; + } + }, + /// + /// Gets or sets the orientation of sections within the Hub. + /// + /// + orientation: { + get: function () { + return this._orientation; + }, + set: function (value) { + if (value === this._orientation) { + return; + } + this._measured = false; + // clear existing scroll before we switch orientation + if (this._names) { // handle setting orientation before we measure + var newScrollPos = {}; + newScrollPos[this._names.scrollPos] = 0; + _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); + } + if (value === _UI.Orientation.vertical) { + _ElementUtilities.removeClass(this.element, Hub._ClassName.hubHorizontal); + _ElementUtilities.addClass(this.element, Hub._ClassName.hubVertical); + } else { + value = _UI.Orientation.horizontal; + _ElementUtilities.removeClass(this.element, Hub._ClassName.hubVertical); + _ElementUtilities.addClass(this.element, Hub._ClassName.hubHorizontal); + } + this._orientation = value; + Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); + } + }, + /// + /// Gets or sets the WinJS.Binding.List of HubSection objects that belong to this Hub. + /// + /// + sections: { + get: function () { + if (this._pendingSections) { + return this._pendingSections; + } + return this._sections; + }, + set: function (value) { + var resetScrollPosition = !this._pendingSections; + this._pendingSections = value; + this._refresh(); + if (resetScrollPosition) { + this.scrollPosition = 0; + } + } + }, + /// + /// Gets or sets the WinJS.Binding.Template or template function that creates the DOM elements + /// which represent the header for each HubSection. Each header can + /// contain multiple DOM elements, but we recommend that it have a single + /// root element. + /// + /// + headerTemplate: { + get: function () { + if (this._pendingHeaderTemplate) { + return this._pendingHeaderTemplate; + } + + if (!this._headerTemplate) { + this._headerTemplate = hubDefaultHeaderTemplate; + } + + return this._headerTemplate; + }, + set: function (value) { + this._pendingHeaderTemplate = value || hubDefaultHeaderTemplate; + this._refresh(); + } + }, + /// + /// Gets or sets the position of the Hub's scrollbar. + /// + /// + scrollPosition: { + get: function () { + if (+this._pendingScrollLocation === this._pendingScrollLocation) { + return this._pendingScrollLocation; + } + + this._measure(); + return this._scrollPosition; + }, + set: function (value) { + value = Math.max(0, value); + if (this._pendingRefresh) { + // Unable to constrain length because sections may have changed. + this._pendingScrollLocation = value; + this._pendingSectionOnScreen = null; + } else { + this._measure(); + var targetScrollPos = Math.max(0, Math.min(this._scrollLength - this._viewportSize, value)); + this._scrollPosition = targetScrollPos; + var newScrollPos = {}; + newScrollPos[this._names.scrollPos] = targetScrollPos; + _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); + } + } + }, + + /// + /// Gets or sets the index of first section in view. This property is useful for restoring a previous view when your app launches or resumes. + /// + /// + sectionOnScreen: { + get: function () { + if (+this._pendingSectionOnScreen === this._pendingSectionOnScreen) { + return this._pendingSectionOnScreen; + } + + this._measure(); + for (var i = 0; i < this._sectionSizes.length; i++) { + var sectionSize = this._sectionSizes[i]; + if ((sectionSize.offset + sectionSize.size - sectionSize.borderEnd - sectionSize.paddingEnd) > (this._scrollPosition + this._startSpacer + sectionSize.borderStart + sectionSize.paddingStart)) { + return i; + } + } + return -1; + }, + set: function (value) { + value = Math.max(0, value); + if (this._pendingRefresh) { + this._pendingSectionOnScreen = value; + this._pendingScrollLocation = null; + } else { + this._measure(); + if (value >= 0 && value < this._sectionSizes.length) { + this._scrollToSection(value); + } + } + } + }, + /// + /// Gets or sets the index of first section at least partially in view. Use for animations. + /// + /// + indexOfFirstVisible: { + get: function () { + this._measure(); + for (var i = 0; i < this._sectionSizes.length; i++) { + var sectionSize = this._sectionSizes[i]; + if ((sectionSize.offset + sectionSize.size - sectionSize.borderEnd - sectionSize.paddingEnd) > this._scrollPosition) { + return i; + } + } + return -1; + } + }, + /// + /// Gets or sets the index of last section at least partially in view. Use for animations. + /// + /// + indexOfLastVisible: { + get: function () { + this._measure(); + for (var i = this._sectionSizes.length - 1; i >= 0; i--) { + var sectionSize = this._sectionSizes[i]; + if ((sectionSize.offset + sectionSize.paddingStart + sectionSize.borderStart) < (this._scrollPosition + this._viewportSize)) { + return i; + } + } + return -1; + } + }, + + /// + /// Raised when the user clicks on an interactive header. + /// + /// + onheaderinvoked: createEvent(eventNames.headerInvoked), + + /// + /// Raised when the loadingState of the Hub changes. + /// + /// + onloadingstatechanged: createEvent(eventNames.loadingStateChanged), + + /// + /// Raised when Hub is about to play entrance, contentTransition, insert, or remove animations. + /// + /// + oncontentanimating: createEvent(eventNames.contentAnimating), + + _refresh: function hub_refresh() { + if (this._pendingRefresh) { + return; + } + + this._loadId++; + this._setState(Hub.LoadingState.loading); + // This is to coalesce property setting operations such as sections and scrollPosition. + this._pendingRefresh = true; + + Scheduler.schedule(this._refreshImpl.bind(this), Scheduler.Priority.high); + }, + _refreshImpl: function hub_refreshImpl() { + if (this._disposed) { + return; + } + + var fadeOutAnimation = Promise.wrap(); + if (this._pendingSections) { + this._animateEntrance = true; + this._fireEntrance = !this._visible; + if (!this._fireEntrance) { + this._visible = false; + this._viewportElement.style.opacity = 0; + + if (_TransitionAnimation.isAnimationEnabled()) { + var animateTransition = this._fireEvent(Hub._EventName.contentAnimating, { + type: Hub.AnimationType.contentTransition + }); + + if (animateTransition) { + this._viewportElement.style["-ms-overflow-style"] = "none"; + fadeOutAnimation = Animations.fadeOut(this._viewportElement).then(function () { + this._viewportElement.style["-ms-overflow-style"] = ""; + }.bind(this)); + } + this._animateEntrance = animateTransition; + } + } + } + + fadeOutAnimation.done(this._applyProperties.bind(this)); + }, + _applyProperties: function hub_applyProperties() { + if (this._disposed) { + return; + } + + this._pendingRefresh = false; + + var needsToLoadSections = false; + if (this._pendingSections) { + needsToLoadSections = true; + this._updateEvents(this._sections, this._pendingSections); + this._sections = this._pendingSections; + this._pendingSections = null; + // Remove any declaratively specified hub sections before attachSections. + while (this.element.firstElementChild !== this._viewportElement) { + var toRemove = this.element.firstElementChild; + toRemove.parentNode.removeChild(toRemove); + } + _ElementUtilities.empty(this._surfaceElement); + } + + if (this._pendingHeaderTemplate) { + this._headerTemplate = this._pendingHeaderTemplate; + this._pendingHeaderTemplate = null; + } + + this._assignHeaderTemplate(); + + if (needsToLoadSections) { + this._attachSections(); + } + + // Scroll after headers are rendered and sections are attached so the scroll thumb is correct. + if (+this._pendingSectionOnScreen === this._pendingSectionOnScreen) { + // If there are both pending section on screen and scroll location use section on screen. + this.sectionOnScreen = this._pendingSectionOnScreen; + } else if (+this._pendingScrollLocation === this._pendingScrollLocation) { + this.scrollPosition = this._pendingScrollLocation; + } else { + // Sections reset without sectionOnScreen or scrollPosition APIs. + this.scrollPosition = 0; + } + + this._pendingSectionOnScreen = null; + this._pendingScrollLocation = null; + + // Using current (or new) scroll location load the sections + this._setState(Hub.LoadingState.loading); + this._loadSections(); + }, + _handleSectionChanged: function hub_handleSectionChanged(ev) { + // Change is triggered by binding list setAt() API. + if (this._pendingSections) { + return; + } + + var newSection = ev.detail.newValue; + var oldSection = ev.detail.oldValue; + newSection._setHeaderTemplate(this.headerTemplate); + if (newSection.element !== oldSection.element) { + if (newSection.element.parentNode === this._surfaceElement) { + throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); + } + + this._surfaceElement.insertBefore(newSection.element, oldSection.element); + this._surfaceElement.removeChild(oldSection.element); + this._measured = false; + + this._setState(Hub.LoadingState.loading); + this._loadSections(); + } + }, + _handleSectionInserted: function hub_handleSectionInserted(ev) { + // Insert is triggered by binding list insert APIs such as splice(), push(), and unshift(). + if (this._pendingSections) { + return; + } + + var index = ev.detail.index; + var section = ev.detail.value; + + if (section._animation) { + section._animation.cancel(); + } + + var animation; + var result = this._fireEvent(Hub._EventName.contentAnimating, { + type: Hub.AnimationType.insert, + index: index, + section: section + }); + + if (result) { + + var affectedElements = []; + + for (var i = index + 1; i < this.sections.length; i++) { + affectedElements.push(this.sections.getAt(i).element); + } + + animation = new Animations._createUpdateListAnimation([section.element], [], affectedElements); + } + + if (section.element.parentNode === this._surfaceElement) { + throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); + } + + section._setHeaderTemplate(this.headerTemplate); + if (index < this.sections.length - 1) { + this._surfaceElement.insertBefore(section.element, this.sections.getAt(index + 1).element); + } else { + this._surfaceElement.appendChild(section.element); + } + this._measured = false; + + if (animation) { + var insertAnimation = animation.execute(); + this.runningAnimations = Promise.join([this.runningAnimations, insertAnimation]); + } + + this._setState(Hub.LoadingState.loading); + this._loadSections(); + }, + _handleSectionMoved: function hub_handleSectionMoved(ev) { + // Move is triggered by binding list move() API. + if (this._pendingSections) { + return; + } + + var newIndex = ev.detail.newIndex; + var section = ev.detail.value; + + if (newIndex < this.sections.length - 1) { + this._surfaceElement.insertBefore(section.element, this.sections.getAt(newIndex + 1).element); + } else { + this._surfaceElement.appendChild(section.element); + } + this._measured = false; + + this._setState(Hub.LoadingState.loading); + this._loadSections(); + }, + _handleSectionRemoved: function hub_handleSectionRemoved(ev) { + // Removed is triggered by binding list removal APIs such as splice(), pop(), and shift(). + if (this._pendingSections) { + return; + } + + var section = ev.detail.value; + var index = ev.detail.index; + + var animationPromise = Promise.wrap(); + var result = this._fireEvent(Hub._EventName.contentAnimating, { + type: Hub.AnimationType.remove, + index: index, + section: section + }); + + if (result) { + var affectedElements = []; + + for (var i = index; i < this.sections.length; i++) { + affectedElements.push(this.sections.getAt(i).element); + } + + var animation = new Animations._createUpdateListAnimation([], [section.element], affectedElements); + + this._measure(); + var offsetTop = section.element.offsetTop; + var offsetLeft = section.element.offsetLeft; + section.element.style.position = "absolute"; + section.element.style.top = offsetTop; + section.element.style.left = offsetLeft; + section.element.style.opacity = 0; + this._measured = false; + + animationPromise = animation.execute().then(function () { + section.element.style.position = ""; + section.element.style.top = ""; + section.element.style.left = ""; + section.element.style.opacity = 1; + }.bind(this)); + } + + animationPromise.done(function () { + if (!this._disposed) { + this._surfaceElement.removeChild(section.element); + this._measured = false; + } + }.bind(this)); + + // Store animation promise in case it is inserted before remove animation finishes. + section._animation = animationPromise; + this.runningAnimations = Promise.join([this.runningAnimations, animationPromise]); + + this._setState(Hub.LoadingState.loading); + this._loadSections(); + }, + _handleSectionReload: function hub_handleSectionReload() { + // Reload is triggered by large operations on the binding list such as reverse(). This causes + // _pendingSections to be true which ignores future insert/remove/modified/moved events until the new + // sections list is applied. + this.sections = this.sections; + }, + _updateEvents: function hub_updateEvents(oldSections, newSections) { + if (oldSections) { + oldSections.removeEventListener("itemchanged", this._handleSectionChangedBind); + oldSections.removeEventListener("iteminserted", this._handleSectionInsertedBind); + oldSections.removeEventListener("itemmoved", this._handleSectionMovedBind); + oldSections.removeEventListener("itemremoved", this._handleSectionRemovedBind); + oldSections.removeEventListener("reload", this._handleSectionReloadBind); + } + + if (newSections) { + newSections.addEventListener("itemchanged", this._handleSectionChangedBind); + newSections.addEventListener("iteminserted", this._handleSectionInsertedBind); + newSections.addEventListener("itemmoved", this._handleSectionMovedBind); + newSections.addEventListener("itemremoved", this._handleSectionRemovedBind); + newSections.addEventListener("reload", this._handleSectionReloadBind); + } + }, + _attachSections: function hub_attachSections() { + this._measured = false; + for (var i = 0; i < this.sections.length; i++) { + var section = this._sections.getAt(i); + if (section._animation) { + section._animation.cancel(); + } + if (section.element.parentNode === this._surfaceElement) { + throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); + } + this._surfaceElement.appendChild(section.element); + } + }, + _assignHeaderTemplate: function hub_assignHeaderTemplate() { + this._measured = false; + for (var i = 0; i < this.sections.length; i++) { + var section = this._sections.getAt(i); + section._setHeaderTemplate(this.headerTemplate); + } + }, + _loadSection: function hub_loadSection(index) { + var section = this._sections.getAt(index); + return section._process().then(function resetVisibility() { + var style = section.contentElement.style; + if (style.visibility !== "") { + style.visibility = ""; + } + }); + }, + _loadSections: function hub_loadSections() { + // Used to know if another load has interrupted this one. + this._loadId++; + var loadId = this._loadId; + var that = this; + var onScreenItemsAnimatedPromise = Promise.wrap(); + var sectionIndicesToLoad = []; + var allSectionsLoadedPromise = Promise.wrap(); + + function loadNextSectionAfterPromise(promise) { + promise.then(function () { + Scheduler.schedule(loadNextSection, Scheduler.Priority.idle); + }); + } + + function loadNextSection() { + if (loadId === that._loadId && !that._disposed) { + if (sectionIndicesToLoad.length) { + var index = sectionIndicesToLoad.shift(); + var loadedPromise = that._loadSection(index); + loadNextSectionAfterPromise(loadedPromise); + } else { + allSectionsLoadedSignal.complete(); + } + } + } + + if (!this._showProgressPromise) { + this._showProgressPromise = Promise.timeout(progressDelay).then(function () { + if (this._disposed) { + return; + } + + if (!this._progressBar) { + this._progressBar = _Global.document.createElement("progress"); + _ElementUtilities.addClass(this._progressBar, Hub._ClassName.hubProgress); + this._progressBar.max = 100; + } + if (!this._progressBar.parentNode) { + this.element.insertBefore(this._progressBar, this._viewportElement); + } + this._showProgressPromise = null; + }.bind(this), function () { + this._showProgressPromise = null; + }.bind(this)); + } + + if (this.sections.length) { + var allSectionsLoadedSignal = new _Signal(); + allSectionsLoadedPromise = allSectionsLoadedSignal.promise; + // Synchronously load the sections on screen. + var synchronousProcessPromises = []; + var start = Math.max(0, this.indexOfFirstVisible); + var end = Math.max(0, this.indexOfLastVisible); + for (var i = start; i <= end; i++) { + synchronousProcessPromises.push(this._loadSection(i)); + } + + // Determine the order to load the rest of the sections. + start--; + end++; + while (start >= 0 || end < this.sections.length) { + if (end < this.sections.length) { + sectionIndicesToLoad.push(end); + end++; + } + if (start >= 0) { + sectionIndicesToLoad.push(start); + start--; + } + } + + var onScreenSectionsLoadedPromise = Promise.join(synchronousProcessPromises); + + // In case there are overlapping load calls + onScreenSectionsLoadedPromise.done(function () { + if (loadId === this._loadId && !that._disposed) { + if (this._showProgressPromise) { + this._showProgressPromise.cancel(); + } + + if (this._progressBar && this._progressBar.parentNode) { + this._progressBar.parentNode.removeChild(this._progressBar); + } + + Scheduler.schedule(function Hub_entranceAnimation() { + if (loadId === this._loadId && !that._disposed) { + if (!this._visible) { + this._visible = true; + this._viewportElement.style.opacity = 1; + + if (this._animateEntrance && _TransitionAnimation.isAnimationEnabled()) { + var eventDetail = { + type: Hub.AnimationType.entrance + }; + + if (!this._fireEntrance || this._fireEvent(Hub._EventName.contentAnimating, eventDetail)) { + this._viewportElement.style["-ms-overflow-style"] = "none"; + onScreenItemsAnimatedPromise = Animations.enterContent(this._viewportElement, [{ left: this._fireEntrance ? "100px" : "40px", top: "0px", rtlflip: true }], { mechanism: "transition" }).then(function () { + this._viewportElement.style["-ms-overflow-style"] = ""; + }.bind(this)); + } + } + if (this._element === _Global.document.activeElement) { + this._moveFocusIn(this.sectionOnScreen); + } + } + } + }, Scheduler.Priority.high, this, "WinJS.UI.Hub.entranceAnimation"); + } + }.bind(this)); + + loadNextSectionAfterPromise(onScreenSectionsLoadedPromise); + } else { + if (this._showProgressPromise) { + this._showProgressPromise.cancel(); + } + + if (this._progressBar && this._progressBar.parentNode) { + this._progressBar.parentNode.removeChild(this._progressBar); + } + } + + Promise.join([this.runningAnimations, onScreenItemsAnimatedPromise, allSectionsLoadedPromise]).done(function () { + if (loadId === this._loadId && !that._disposed) { + this.runningAnimations = Promise.wrap(); + this._setState(Hub.LoadingState.complete); + Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); + } + }.bind(this)); + }, + /// + loadingState: { + get: function () { + return this._loadingState; + } + }, + _setState: function Hub_setState(state) { + if (state !== this._loadingState) { + this._writeProfilerMark("loadingStateChanged:" + state + ",info"); + this._loadingState = state; + var eventObject = _Global.document.createEvent("CustomEvent"); + eventObject.initCustomEvent(Hub._EventName.loadingStateChanged, true, false, { loadingState: state }); + this._element.dispatchEvent(eventObject); + } + }, + _parse: function hub_parse() { + var hubSections = []; + var hubSectionEl = this.element.firstElementChild; + + while (hubSectionEl !== this._viewportElement) { + ControlProcessor.processAll(hubSectionEl); + + var hubSectionContent = hubSectionEl.winControl; + if (hubSectionContent) { + hubSections.push(hubSectionContent); + } else { + throw new _ErrorFromName("WinJS.UI.Hub.InvalidContent", strings.invalidContent); + } + + var nextSectionEl = hubSectionEl.nextElementSibling; + hubSectionEl = nextSectionEl; + } + + this.sections = new BindingList.List(hubSections); + }, + _fireEvent: function hub_fireEvent(type, detail) { + // Returns true if ev.preventDefault() was not called + var event = _Global.document.createEvent("CustomEvent"); + event.initCustomEvent(type, true, true, detail); + return this.element.dispatchEvent(event); + }, + + _findHeaderTabStop: function hub_findHeaderTabStop(element) { + if (element.parentNode) { + if (_ElementUtilities._matchesSelector(element, ".win-hub-section-header-tabstop, .win-hub-section-header-tabstop *")) { + while (!_ElementUtilities.hasClass(element, "win-hub-section-header-tabstop")) { + element = element.parentElement; + } + return element; + } + } + return null; + }, + _isHeaderInteractive: function hub_isHeaderInteractive(element) { + // Helper method to skip keyboarding and clicks with a header's sub interactive content + if (element.parentNode) { + return _ElementUtilities._matchesSelector(element, ".win-interactive, .win-interactive *"); + } + return false; + }, + _clickHandler: function hub_clickHandler(ev) { + var headerTabStopElement = this._findHeaderTabStop(ev.target); + if (headerTabStopElement && !this._isHeaderInteractive(ev.target)) { + var section = headerTabStopElement.parentElement.parentElement.winControl; + if (!section.isHeaderStatic) { + var sectionIndex = this.sections.indexOf(section); + this._fireEvent(Hub._EventName.headerInvoked, { + index: sectionIndex, + section: section + }); + } + } + }, + _resizeHandler: function hub_resizeHandler() { + // Viewport needs to be measured + this._measured = false; + Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); + }, + _contentResizeHandler: function hub_contentResizeHandler() { + // Sections and scroll length need to be measured + this._measured = false; + Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); + }, + _scrollHandler: function hub_scrollHandler() { + // Scroll location needs to be retrieved + this._measured = false; + + if (this._pendingSections) { + return; + } + + // Scroll events caused by users overwrite pending API modifications to scrollposition. + this._pendingScrollLocation = null; + this._pendingSectionOnScreen = null; + + if (!this._pendingScrollHandler) { + this._pendingScrollHandler = _BaseUtils._requestAnimationFrame(function () { + this._pendingScrollHandler = null; + + if (this._pendingSections) { + return; + } + + if (this.loadingState !== Hub.LoadingState.complete) { + this._loadSections(); + } + }.bind(this)); + } + }, + _measure: function hub_measure() { + // Any time a size changes (section growing, window resizing, etc) cachedSizes should be set to false + // and any time the variables need to be read again we should measure the variables. To avoid a lot of + // seperate layouts we measure the variables in a single batch. + if (!this._measured || this._scrollLength === 0) { + this._writeProfilerMark("measure,StartTM"); + this._measured = true; + + this._rtl = _Global.getComputedStyle(this._element, null).direction === "rtl"; + + if (this.orientation === _UI.Orientation.vertical) { + this._names = verticalNames; + } else { + if (this._rtl) { + this._names = rtlHorizontalNames; + } else { + this._names = ltrHorizontalNames; + } + } + + this._viewportSize = this._viewportElement[this._names.offsetSize]; + this._viewportOppositeSize = this._viewportElement[this._names.oppositeOffsetSize]; + this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportElement)[this._names.scrollPos]; + this._scrollLength = this._viewportElement[this._names.scrollSize]; + + var surfaceElementComputedStyle = _Global.getComputedStyle(this._surfaceElement); + this._startSpacer = parseFloat(surfaceElementComputedStyle[this._names.marginStart]) + parseFloat(surfaceElementComputedStyle[this._names.borderStart]) + parseFloat(surfaceElementComputedStyle[this._names.paddingStart]); + this._endSpacer = parseFloat(surfaceElementComputedStyle[this._names.marginEnd]) + parseFloat(surfaceElementComputedStyle[this._names.borderEnd]) + parseFloat(surfaceElementComputedStyle[this._names.paddingEnd]); + + this._sectionSizes = []; + for (var i = 0; i < this.sections.length; i++) { + var section = this.sections.getAt(i); + var computedSectionStyle = _Global.getComputedStyle(section.element); + this._sectionSizes[i] = { + offset: section.element[this._names.offsetPos], + // Reminder: offsetWidth doesn't include margins and also rounds. + size: section.element[this._names.offsetSize], + marginStart: parseFloat(computedSectionStyle[this._names.marginStart]), + marginEnd: parseFloat(computedSectionStyle[this._names.marginEnd]), + borderStart: parseFloat(computedSectionStyle[this._names.borderStart]), + borderEnd: parseFloat(computedSectionStyle[this._names.borderEnd]), + paddingStart: parseFloat(computedSectionStyle[this._names.paddingStart]), + paddingEnd: parseFloat(computedSectionStyle[this._names.paddingEnd]) + }; + + if (this._rtl && this.orientation === _UI.Orientation.horizontal) { + this._sectionSizes[i].offset = this._viewportSize - (this._sectionSizes[i].offset + this._sectionSizes[i].size); + } + } + + this._writeProfilerMark("measure,StopTM"); + } + }, + _updateSnapList: function hub_updateSnapList() { + this._writeProfilerMark("updateSnapList,StartTM"); + this._measure(); + + var snapList = "snapList("; + for (var i = 0; i < this._sectionSizes.length; i++) { + if (i > 0) { + snapList += ","; + } + var sectionSize = this._sectionSizes[i]; + snapList += (sectionSize.offset - sectionSize.marginStart - this._startSpacer) + "px"; + } + snapList += ")"; + + var snapListY = ""; + var snapListX = ""; + if (this.orientation === _UI.Orientation.vertical) { + snapListY = snapList; + } else { + snapListX = snapList; + } + + if (this._lastSnapPointY !== snapListY) { + this._lastSnapPointY = snapListY; + this._viewportElement.style['-ms-scroll-snap-points-y'] = snapListY; + } + + if (this._lastSnapPointX !== snapListX) { + this._lastSnapPointX = snapListX; + this._viewportElement.style['-ms-scroll-snap-points-x'] = snapListX; + } + + this._writeProfilerMark("updateSnapList,StopTM"); + }, + _scrollToSection: function Hub_scrollToSection(index, withAnimation) { + this._measure(); + var sectionSize = this._sectionSizes[index]; + var scrollPositionToShowStartMargin = Math.min(this._scrollLength - this._viewportSize, sectionSize.offset - sectionSize.marginStart - this._startSpacer); + + this._scrollTo(scrollPositionToShowStartMargin, withAnimation); + }, + _ensureVisible: function hub_ensureVisible(index, withAnimation) { + this._measure(); + var targetScrollPos = this._ensureVisibleMath(index, this._scrollPosition); + this._scrollTo(targetScrollPos, withAnimation); + }, + _ensureVisibleMath: function hub_ensureVisibleMath(index, targetScrollPos) { + this._measure(); + var sectionSize = this._sectionSizes[index]; + + var scrollPositionToShowStartMargin = Math.min(this._scrollLength - this._viewportSize, sectionSize.offset - sectionSize.marginStart - this._startSpacer); + var scrollPositionToShowEndMargin = Math.max(0, sectionSize.offset + sectionSize.size + sectionSize.marginEnd + this._endSpacer - this._viewportSize + 1); + if (targetScrollPos > scrollPositionToShowStartMargin) { + targetScrollPos = scrollPositionToShowStartMargin; + } else if (targetScrollPos < scrollPositionToShowEndMargin) { + targetScrollPos = Math.min(scrollPositionToShowStartMargin, scrollPositionToShowEndMargin); + } + + return targetScrollPos; + }, + _scrollTo: function hub_scrollTo(scrollPos, withAnimation) { + this._scrollPosition = scrollPos; + if (withAnimation) { + if (this.orientation === _UI.Orientation.vertical) { + _ElementUtilities._zoomTo(this._viewportElement, { contentX: 0, contentY: this._scrollPosition, viewportX: 0, viewportY: 0 }); + } else { + _ElementUtilities._zoomTo(this._viewportElement, { contentX: this._scrollPosition, contentY: 0, viewportX: 0, viewportY: 0 }); + } + } else { + var newScrollPos = {}; + newScrollPos[this._names.scrollPos] = this._scrollPosition; + _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); + } + }, + _windowKeyDownHandler: function hub_windowKeyDownHandler(ev) { + // Include tab and shift tab. Note: Alt Key + Tab and Windows Key + Tab do not fire keydown with ev.key === "Tab". + if (ev.keyCode === Key.tab) { + this._tabSeenLast = true; + + var that = this; + _BaseUtils._yieldForEvents(function () { + that._tabSeenLast = false; + }); + } + }, + _focusin: function hub_focusin(ev) { + // On focus we call ensureVisible to handle the tab or shift/tab to header. However if the + // focus was caused by a pointer down event we skip the focus. + if (this._tabSeenLast) { + var headerTabStopElement = this._findHeaderTabStop(ev.target); + if (headerTabStopElement && !this._isHeaderInteractive(ev.target)) { + var sectionIndex = this.sections.indexOf(headerTabStopElement.parentElement.parentElement.winControl); + if (sectionIndex > -1) { + this._ensureVisible(sectionIndex, true); + } + } + } + + // Always remember the focused section for SemanticZoom. + var sectionElement = ev.target; + while (sectionElement && !_ElementUtilities.hasClass(sectionElement, _Section.HubSection._ClassName.hubSection)) { + sectionElement = sectionElement.parentElement; + } + if (sectionElement) { + var sectionIndex = this.sections.indexOf(sectionElement.winControl); + if (sectionIndex > -1) { + this._currentIndexForSezo = sectionIndex; + } + } + + if (ev.target === this.element) { + var indexToFocus; + if (+this._sectionToFocus === this._sectionToFocus && this._sectionToFocus >= 0 && this._sectionToFocus < this.sections.length) { + indexToFocus = this._sectionToFocus; + this._sectionToFocus = null; + } else { + indexToFocus = this.sectionOnScreen; + } + + this._moveFocusIn(indexToFocus); + } + }, + _moveFocusIn: function hub_moveFocusIn(indexToFocus) { + if (indexToFocus >= 0) { + for (var i = indexToFocus; i < this.sections.length; i++) { + var section = this.sections.getAt(i); + + var focusAttempt = _ElementUtilities._trySetActive(section._headerTabStopElement, this._viewportElement); + + if (focusAttempt) { + return; + } + + if (_ElementUtilities._setActiveFirstFocusableElement(section.contentElement, this._viewportElement)) { + return; + } + } + + for (var i = indexToFocus - 1; i >= 0; i--) { + var section = this.sections.getAt(i); + + if (_ElementUtilities._setActiveFirstFocusableElement(section.contentElement, this._viewportElement)) { + return; + } + + var focusAttempt = _ElementUtilities._trySetActive(section._headerTabStopElement, this._viewportElement); + + if (focusAttempt) { + return; + } + } + } + }, + _keyDownHandler: function hub_keyDownHandler(ev) { + var leftKey = this._rtl ? Key.rightArrow : Key.leftArrow; + var rightKey = this._rtl ? Key.leftArrow : Key.rightArrow; + + if (ev.keyCode === Key.upArrow || ev.keyCode === Key.downArrow || ev.keyCode === Key.leftArrow || ev.keyCode === Key.rightArrow || ev.keyCode === Key.pageUp || ev.keyCode === Key.pageDown) { + var headerTabStopElement = this._findHeaderTabStop(ev.target); + if (headerTabStopElement && !this._isHeaderInteractive(ev.target)) { + var currentSection = this.sections.indexOf(headerTabStopElement.parentElement.parentElement.winControl); + var targetSectionIndex; + var useEnsureVisible = false; + // Page up/down go to the next/previous header and line it up with the app header. Up/Right/Down/Left + // move focus to the next/previous header and move it on screen (app header distance from either edge). + if (ev.keyCode === Key.pageDown || + (this.orientation === _UI.Orientation.horizontal && ev.keyCode === rightKey) || + (this.orientation === _UI.Orientation.vertical && ev.keyCode === Key.downArrow)) { + // Do not include hidden headers. + for (var i = currentSection + 1; i < this.sections.length; i++) { + if (this._tryFocus(i)) { + targetSectionIndex = i; + break; + } + } + } else if (ev.keyCode === Key.pageUp || + (this.orientation === _UI.Orientation.horizontal && ev.keyCode === leftKey) || + (this.orientation === _UI.Orientation.vertical && ev.keyCode === Key.upArrow)) { + // Do not include hidden headers. + for (var i = currentSection - 1; i >= 0; i--) { + if (this._tryFocus(i)) { + targetSectionIndex = i; + break; + } + } + } + if (ev.keyCode === Key.upArrow || ev.keyCode === Key.downArrow || ev.keyCode === Key.leftArrow || ev.keyCode === Key.rightArrow) { + useEnsureVisible = true; + } + + if (+targetSectionIndex === targetSectionIndex) { + if (useEnsureVisible) { + this._ensureVisible(targetSectionIndex, true); + } else { + this._scrollToSection(targetSectionIndex, true); + } + } + + ev.preventDefault(); + } + } else if (ev.keyCode === Key.home || ev.keyCode === Key.end) { + // Home/End scroll to start/end and leave focus where it is. + this._measure(); + var maxScrollPos = Math.max(0, this._scrollLength - this._viewportSize); + this._scrollTo(ev.keyCode === Key.home ? 0 : maxScrollPos, true); + ev.preventDefault(); + } + }, + _tryFocus: function hub_tryFocus(index) { + var targetSection = this.sections.getAt(index); + + _ElementUtilities._setActive(targetSection._headerTabStopElement, this._viewportElement); + + return _Global.document.activeElement === targetSection._headerTabStopElement; + }, + /// + /// Gets a ZoomableView. This API supports the SemanticZoom infrastructure + /// and is not intended to be used directly from your code. + /// + /// + zoomableView: { + get: function zoomableView_get() { + if (!this._zoomableView) { + this._zoomableView = new ZoomableView(this); + } + + return this._zoomableView; + } + }, + _getPanAxis: function hub_getPanAxis() { + return this.orientation === _UI.Orientation.horizontal ? "horizontal" : "vertical"; + }, + _configureForZoom: function hub_configureForZoom() { + // Nothing to configure. + }, + _setCurrentItem: function hub_setCurrentItem(x, y) { + var offset; + if (this.orientation === _UI.Orientation.horizontal) { + offset = x; + } else { + offset = y; + } + + this._measure(); + offset = offset + this._scrollPosition; + this._currentIndexForSezo = this._sectionSizes.length - 1; + for (var i = 1; i < this._sectionSizes.length; i++) { + var sectionSize = this._sectionSizes[i]; + if (sectionSize.offset - sectionSize.marginStart > offset) { + this._currentIndexForSezo = i - 1; + break; + } + } + }, + _getCurrentItem: function hub_getCurrentItem() { + var itemPosition; + if (this._sectionSizes.length > 0) { + this._measure(); + var index = Math.max(0, Math.min(this._currentIndexForSezo, this._sectionSizes.length)); + var sectionSize = this._sectionSizes[index]; + if (this.orientation === _UI.Orientation.horizontal) { + itemPosition = { + left: Math.max(0, sectionSize.offset - sectionSize.marginStart - this._scrollPosition), + top: 0, + width: sectionSize.size, + height: this._viewportOppositeSize + }; + } else { + itemPosition = { + left: 0, + top: Math.max(0, sectionSize.offset - sectionSize.marginStart - this._scrollPosition), + width: this._viewportOppositeSize, + height: sectionSize.size, + }; + } + + var section = this.sections.getAt(index); + // BUGBUG: 53301 ListView and Hub should document what they expect to be returned from the + // getCurrentItem so that positionItem apis line up. ListView zoomed out expects an object with + // groupIndexHint, groupKey, or groupDescription. Hub expects an object with index. + return Promise.wrap({ item: { data: section, index: index, groupIndexHint: index }, position: itemPosition }); + } + }, + _beginZoom: function hub_beginZoom() { + // Hide scroll thumb. + this._viewportElement.style["-ms-overflow-style"] = "none"; + }, + _positionItem: function hub_positionItem(item, position) { + if (item.index >= 0 && item.index < this._sectionSizes.length) { + this._measure(); + var sectionSize = this._sectionSizes[item.index]; + + var offsetFromViewport; + if (this.orientation === _UI.Orientation.horizontal) { + offsetFromViewport = position.left; + } else { + offsetFromViewport = position.top; + } + + this._sectionToFocus = item.index; + + var targetScrollPosition = sectionSize.offset - offsetFromViewport; + // clamp section: + var targetScrollPosition = this._ensureVisibleMath(item.index, targetScrollPosition); + + this._scrollPosition = targetScrollPosition; + var newScrollPos = {}; + newScrollPos[this._names.scrollPos] = this._scrollPosition; + _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); + } + }, + _endZoom: function hub_endZoom() { + // Show scroll thumb. + this._viewportElement.style["-ms-overflow-style"] = ""; + }, + _writeProfilerMark: function hub_writeProfilerMark(text) { + var message = "WinJS.UI.Hub:" + this._id + ":" + text; + _WriteProfilerMark(message); + _Log.log && _Log.log(message, null, "hubprofiler"); + }, + dispose: function hub_dispose() { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + + _Global.removeEventListener('keydown', this._windowKeyDownHandlerBound); + _ElementUtilities._resizeNotifier.unsubscribe(this.element, this._resizeHandlerBound); + + this._updateEvents(this._sections); + + for (var i = 0; i < this.sections.length; i++) { + this.sections.getAt(i).dispose(); + } + } + }, { + /// + /// Specifies whether the Hub animation is an entrance animation or a transition animation. + /// + /// + AnimationType: { + /// + /// The animation plays when the Hub is first displayed. + /// + /// + entrance: "entrance", + /// + /// The animation plays when the Hub is changing its content. + /// + /// + contentTransition: "contentTransition", + /// + /// The animation plays when a section is inserted into the Hub. + /// + /// + insert: "insert", + /// + /// The animation plays when a section is removed into the Hub. + /// + /// + remove: "remove", + }, + /// + /// Gets the current loading state of the Hub. + /// + /// + LoadingState: { + /// + /// The Hub is loading sections. + /// + /// + loading: "loading", + /// + /// All sections are loaded and animations are complete. + /// + /// + complete: "complete" + }, + // Names of classes used by the Hub. + _ClassName: { + hub: "win-hub", + hubSurface: "win-hub-surface", + hubProgress: "win-hub-progress", + hubViewport: "win-hub-viewport", + hubVertical: "win-hub-vertical", + hubHorizontal: "win-hub-horizontal", + }, + // Names of events fired by the Hub. + _EventName: { + contentAnimating: eventNames.contentAnimating, + headerInvoked: eventNames.headerInvoked, + loadingStateChanged: eventNames.loadingStateChanged + }, + }); + + _Base.Class.mix(Hub, _Control.DOMEventMixin); + + var ZoomableView = _Base.Class.define(function ZoomableView_ctor(hub) { + this._hub = hub; + }, { + getPanAxis: function () { + return this._hub._getPanAxis(); + }, + configureForZoom: function (isZoomedOut, isCurrentView, triggerZoom, prefetchedPages) { + this._hub._configureForZoom(isZoomedOut, isCurrentView, triggerZoom, prefetchedPages); + }, + setCurrentItem: function (x, y) { + this._hub._setCurrentItem(x, y); + }, + getCurrentItem: function () { + return this._hub._getCurrentItem(); + }, + beginZoom: function () { + this._hub._beginZoom(); + }, + positionItem: function (item, position) { + return this._hub._positionItem(item, position); + }, + endZoom: function (isCurrentView) { + this._hub._endZoom(isCurrentView); + } + }); + + var strings = { + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get duplicateSection() { return "Hub duplicate sections: Each HubSection must be unique"; }, + get invalidContent() { return "Invalid content: Hub content must be made up of HubSections."; }, + get hubViewportAriaLabel() { return _Resources._getWinJSString("ui/hubViewportAriaLabel").value; } + }; + + return Hub; + }) + }); + +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/AppBar/_Constants',[ + 'exports', + '../../Core/_Base', +], function appBarConstantsInit(exports, _Base) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, null, { + // AppBar class names. + appBarClass: "win-appbar", + firstDivClass: "win-firstdiv", + finalDivClass: "win-finaldiv", + invokeButtonClass: "win-appbar-invokebutton", + ellipsisClass: "win-appbar-ellipsis", + primaryCommandsClass: "win-primarygroup", + secondaryCommandsClass: "win-secondarygroup", + reducedClass: "win-reduced", + commandLayoutClass: "win-commandlayout", + topClass: "win-top", + bottomClass: "win-bottom", + showingClass : "win-appbar-showing", + shownClass : "win-appbar-shown", + hidingClass : "win-appbar-hiding", + hiddenClass: "win-appbar-hidden", + minimalClass: "win-appbar-minimal", + + // Constants for AppBar placement + appBarPlacementTop: "top", + appBarPlacementBottom: "bottom", + + // Constants for AppBar layouts + appBarLayoutCustom: "custom", + appBarLayoutCommands: "commands", + + // Constant for AppBar invokebutton width + appBarInvokeButtonWidth: 60, + + // Constants for Commands + typeSeparator: "separator", + typeContent: "content", + typeButton: "button", + typeToggle: "toggle", + typeFlyout: "flyout", + menuCommandClass: "win-command", + appBarCommandClass: "win-command", + appBarCommandGlobalClass: "win-global", + appBarCommandSelectionClass: "win-selection", + sectionSelection: "selection", + sectionGlobal: "global", + + // Prevents the element from showing a focus rect + hideFocusClass: "win-hidefocus", + + // Other class names + overlayClass: "win-overlay", + flyoutClass: "win-flyout", + flyoutLightClass: "win-ui-light", + menuClass: "win-menu", + menuToggleClass: "win-menu-toggle", + settingsFlyoutClass: "win-settingsflyout", + scrollsClass: "win-scrolls", + + // Constants for AppBarCommand full-size widths. + separatorWidth: 60, + buttonWidth: 100, + + narrowClass: "win-narrow", + wideClass: "win-wide", + _clickEatingAppBarClass: "win-appbarclickeater", + _clickEatingFlyoutClass: "win-flyoutmenuclickeater", + _visualViewportClass: "win-visualviewport-space", + }); +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +/// animatable,appbar,appbars,divs,Flyout,Flyouts,iframe,Statics,unfocus,unselectable +define('WinJS/Controls/Flyout/_Overlay',[ + 'exports', + '../../Core/_Global', + '../../Core/_WinRT', + '../../Core/_Base', + '../../Core/_BaseUtils', + '../../Core/_ErrorFromName', + '../../Core/_Events', + '../../Core/_Resources', + '../../Core/_WriteProfilerMark', + '../../Animations', + '../../ControlProcessor', + '../../Promise', + '../../Scheduler', + '../../Utilities/_Control', + '../../Utilities/_ElementUtilities', + '../AppBar/_Constants' +], function overlayInit(exports, _Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Events, _Resources, _WriteProfilerMark, Animations, ControlProcessor, Promise, Scheduler, _Control, _ElementUtilities, _Constants) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + _Overlay: _Base.Namespace._lazy(function () { + var createEvent = _Events._createEventProperty; + + // Event Names + var BEFORESHOW = "beforeshow"; + var AFTERSHOW = "aftershow"; + var BEFOREHIDE = "beforehide"; + var AFTERHIDE = "afterhide"; + + // Helper to get DOM elements from input single object or array or IDs/toolkit/dom elements + function _resolveElements(elements) { + // No input is just an empty array + if (!elements) { + return []; + } + + // Make sure it's in array form. + if (typeof elements === "string" || !elements || !elements.length) { + elements = [elements]; + } + + // Make sure we have a DOM element for each one, (could be string id name or toolkit object) + var i, + realElements = []; + for (i = 0; i < elements.length; i++) { + if (elements[i]) { + if (typeof elements[i] === "string") { + var element = _Global.document.getElementById(elements[i]); + if (element) { + realElements.push(element); + } + } else if (elements[i].element) { + realElements.push(elements[i].element); + } else { + realElements.push(elements[i]); + } + } + } + + return realElements; + } + + // Helpers for keyboard showing related events + function _allOverlaysCallback(event, command) { + var elements = _Global.document.querySelectorAll("." + _Constants.overlayClass); + if (elements) { + var len = elements.length; + for (var i = 0; i < len; i++) { + var element = elements[i]; + var control = element.winControl; + if (!control._disposed) { + if (control) { + control[command](event); + } + } + } + } + } + + function _edgyMayHideFlyouts() { + // Flyouts and SettingsFlyouts should not light dismiss when they are the target of a right click. + if (!_Overlay._rightMouseMightEdgy) { + _Overlay._hideAllFlyouts(); + } + } + + var strings = { + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get mustContainCommands() { return "Invalid HTML: AppBars/Menus must contain only AppBarCommands/MenuCommands"; }, + get closeOverlay() { return _Resources._getWinJSString("ui/closeOverlay").value; }, + }; + + var _Overlay = _Base.Class.define(function _Overlay_ctor(element, options) { + /// + /// + /// Constructs the Overlay control and associates it with the underlying DOM element. + /// + /// + /// The DOM element to be associated with the Overlay control. + /// + /// + /// The set of options to be applied initially to the Overlay control. + /// + /// A fully constructed Overlay control. + /// + this._baseOverlayConstructor(element, options); + }, { + // Functions/properties + _baseOverlayConstructor: function _Overlay_baseOverlayConstructor(element, options) { + this._disposed = false; + + // Make sure there's an input element + if (!element) { + element = _Global.document.createElement("div"); + } + + // Check to make sure we weren't duplicated + var overlay = element.winControl; + if (overlay) { + throw new _ErrorFromName("WinJS.UI._Overlay.DuplicateConstruction", strings.duplicateConstruction); + } + + if (!this._element) { + this._element = element; + } + this._sticky = false; + this._doNext = ""; + + this._element.style.visibility = "hidden"; + this._element.style.opacity = 0; + + // Remember ourselves + element.winControl = this; + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.overlayClass); + _ElementUtilities.addClass(this._element, "win-disposable"); + + // We don't want to be selectable, set UNSELECTABLE + var unselectable = this._element.getAttribute("unselectable"); + if (unselectable === null || unselectable === undefined) { + this._element.setAttribute("unselectable", "on"); + } + + // Base animation is popIn/popOut + this._currentAnimateIn = this._baseAnimateIn; + this._currentAnimateOut = this._baseAnimateOut; + this._animationPromise = Promise.as(); + + // Command Animations to Queue + this._queuedToShow = []; + this._queuedToHide = []; + this._queuedCommandAnimation = false; + + if (options) { + _Control.setOptions(this, options); + } + }, + + /// + element: { + get: function () { + return this._element; + } + }, + + /// Disable an Overlay, setting or getting the HTML disabled attribute. When disabled the Overlay will no longer display with show(), and will hide if currently visible. + disabled: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return !!this._element.disabled; + }, + set: function (value) { + // Force this check into a boolean because our current state could be a bit confused since we tie to the DOM element + value = !!value; + var oldValue = !!this._element.disabled; + if (oldValue !== value) { + this._element.disabled = value; + if (!this.hidden && this._element.disabled) { + this._hideOrDismiss(); + } + } + } + }, + + /// + /// Occurs immediately before the control is shown. + /// + onbeforeshow: createEvent(BEFORESHOW), + + /// + /// Occurs immediately after the control is shown. + /// + onaftershow: createEvent(AFTERSHOW), + + /// + /// Occurs immediately before the control is hidden. + /// + onbeforehide: createEvent(BEFOREHIDE), + + /// + /// Occurs immediately after the control is hidden. + /// + onafterhide: createEvent(AFTERHIDE), + + dispose: function () { + /// + /// + /// Disposes this Overlay. + /// + /// + if (this._disposed) { + return; + } + + this._disposed = true; + this._dispose(); + }, + + _dispose: function _Overlay_dispose() { + // To be overridden by subclasses + }, + + show: function () { + /// + /// + /// Shows the Overlay, if hidden, regardless of other state + /// + /// + // call private show to distinguish it from public version + this._show(); + }, + + _show: function _Overlay_show() { + // We call our base _baseShow because AppBar may need to override show + this._baseShow(); + }, + + hide: function () { + /// + /// + /// Hides the Overlay, if visible, regardless of other state + /// + /// + // call private hide to distinguish it from public version + this._hide(); + }, + + _hide: function _Overlay_hide() { + // We call our base _baseHide because AppBar may need to override hide + this._baseHide(); + }, + + // Is the overlay "hidden"? + /// + hidden: { + get: function () { + return (this._element.style.visibility === "hidden" || + this._element.winAnimating === "hiding" || + this._doNext === "hide"); + } + }, + + addEventListener: function (type, listener, useCapture) { + /// + /// + /// Add an event listener to the DOM element for this Overlay + /// + /// Required. Event type to add, "beforehide", "afterhide", "beforeshow", or "aftershow" + /// Required. The event handler function to associate with this event. + /// Optional. True, register for the event capturing phase. False for the event bubbling phase. + /// + return this._element.addEventListener(type, listener, useCapture); + }, + + removeEventListener: function (type, listener, useCapture) { + /// + /// + /// Remove an event listener to the DOM element for this Overlay + /// + /// Required. Event type to remove, "beforehide", "afterhide", "beforeshow", or "aftershow" + /// Required. The event handler function to associate with this event. + /// Optional. True, register for the event capturing phase. False for the event bubbling phase. + /// + return this._element.removeEventListener(type, listener, useCapture); + }, + + _baseShow: function _Overlay_baseShow() { + // If we are already animating, just remember this for later + if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard) { + this._doNext = "show"; + return false; + } + + // Each overlay tracks the size of the element for triggering light-dismiss in the window resize handler. + this._cachedDocumentSize = this._cachedDocumentSize || _Overlay._sizeOfDocument(); + + // "hiding" would need to cancel. + if (this._element.style.visibility !== "visible") { + // Let us know we're showing. + this._element.winAnimating = "showing"; + + // Hiding, but not none + this._element.style.display = ""; + this._element.style.visibility = "hidden"; + + // In case their event is going to manipulate commands, see if there are + // any queued command animations we can handle while we're still hidden. + if (this._queuedCommandAnimation) { + this._showAndHideFast(this._queuedToShow, this._queuedToHide); + this._queuedToShow = []; + this._queuedToHide = []; + } + + // Send our "beforeShow" event + this._sendEvent(_Overlay.beforeShow); + + // Need to measure + this._findPosition(); + + // Make sure it's visible, and fully opaque. + // Do the popup thing, sending event afterward. + var that = this; + this._animationPromise = this._currentAnimateIn(). + then(function () { + that._baseEndShow(); + }, function () { + that._baseEndShow(); + }); + return true; + } + return false; + }, + + // Flyout in particular will need to measure our positioning. + _findPosition: function _Overlay_findPosition() { + }, + + _baseEndShow: function _Overlay_baseEndShow() { + if (this._disposed) { + return; + } + + // Make sure it's visible after showing + this._element.setAttribute("aria-hidden", "false"); + + this._element.winAnimating = ""; + + // Do our derived classes show stuff + this._endShow(); + + // We're shown now + if (this._doNext === "show") { + this._doNext = ""; + } + + // After showing, send the after showing event + this._sendEvent(_Overlay.afterShow); + this._writeProfilerMark("show,StopTM"); // Overlay writes the stop profiler mark for all of its derived classes. + + // If we had something queued, do that + Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); + + }, + + _endShow: function _Overlay_endShow() { + // Nothing by default + }, + + _baseHide: function _Overlay_baseHide() { + // If we are already animating, just remember this for later + if (this._animating || this._needToHandleShowingKeyboard) { + this._doNext = "hide"; + return false; + } + + // In the unlikely event we're between the hiding keyboard and the resize events, just snap it away: + if (this._needToHandleHidingKeyboard) { + // use the "uninitialized" flag + this._element.style.visibility = ""; + } + + // "showing" would need to queue up. + if (this._element.style.visibility !== "hidden") { + // Let us know we're hiding, accessibility as well. + this._element.winAnimating = "hiding"; + this._element.setAttribute("aria-hidden", "true"); + + // Send our "beforeHide" event + this._sendEvent(_Overlay.beforeHide); + + // If our visibility is empty, then this is the first time, just hide it + if (this._element.style.visibility === "") { + // Initial hiding, just hide it + this._element.style.opacity = 0; + this._baseEndHide(); + } else { + // Make sure it's hidden, and fully transparent. + var that = this; + this._animationPromise = this._currentAnimateOut(). + then(function () { + that._baseEndHide(); + }, function () { + that._baseEndHide(); + }); + } + return true; + } + + return false; + }, + + _baseEndHide: function _Overlay_baseEndHide() { + if (this._disposed) { + return; + } + + // Make sure animation is finished. + this._element.style.visibility = "hidden"; + this._element.style.display = "none"; + this._element.winAnimating = ""; + + // In case their event is going to manipulate commands, see if there + // are any queued command animations we can handle now we're hidden. + if (this._queuedCommandAnimation) { + this._showAndHideFast(this._queuedToShow, this._queuedToHide); + this._queuedToShow = []; + this._queuedToHide = []; + } + + // We're hidden now + if (this._doNext === "hide") { + this._doNext = ""; + } + + // After hiding, send our "afterHide" event + this._sendEvent(_Overlay.afterHide); + this._writeProfilerMark("hide,StopTM"); // Overlay writes the stop profiler mark for all of its derived classes. + + + // If we had something queued, do that. This has to be after + // the afterHide event in case it triggers a show() and they + // have something to do in beforeShow that requires afterHide first. + Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); + }, + + _checkDoNext: function _Overlay_checkDoNext() { + // Do nothing if we're still animating + if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard || this._disposed) { + return; + } + + if (this._doNext === "hide") { + // Do hide first because animating commands would be easier + this._hide(); + this._doNext = ""; + } else if (this._queuedCommandAnimation) { + // Do queued commands before showing if possible + this._showAndHideQueue(); + } else if (this._doNext === "show") { + // Show last so that we don't unnecessarily animate commands + this._show(); + this._doNext = ""; + } + }, + + // Default animations + _baseAnimateIn: function _Overlay_baseAnimateIn() { + this._element.style.opacity = 0; + this._element.style.visibility = "visible"; + // touch opacity so that IE fades from the 0 we just set to 1 + _Global.getComputedStyle(this._element, null).opacity; + return Animations.fadeIn(this._element); + }, + + _baseAnimateOut: function _Overlay_baseAnimateOut() { + this._element.style.opacity = 1; + // touch opacity so that IE fades from the 1 we just set to 0 + _Global.getComputedStyle(this._element, null).opacity; + return Animations.fadeOut(this._element); + }, + + _animating: { + get: function _Overlay_animating_get() { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return !!this._element.winAnimating; + } + }, + + // Send one of our events + _sendEvent: function _Overlay_sendEvent(eventName, detail) { + if (this._disposed) { + return; + } + var event = _Global.document.createEvent("CustomEvent"); + event.initEvent(eventName, true, true, (detail || {})); + this._element.dispatchEvent(event); + }, + + // Show commands + _showCommands: function _Overlay_showCommands(commands, immediate) { + var showHide = this._resolveCommands(commands); + this._showAndHideCommands(showHide.commands, [], immediate); + }, + + // Hide commands + _hideCommands: function _Overlay_hideCommands(commands, immediate) { + var showHide = this._resolveCommands(commands); + this._showAndHideCommands([], showHide.commands, immediate); + }, + + // Hide commands + _showOnlyCommands: function _Overlay_showOnlyCommands(commands, immediate) { + var showHide = this._resolveCommands(commands); + this._showAndHideCommands(showHide.commands, showHide.others, immediate); + }, + + _showAndHideCommands: function _Overlay_showAndHideCommands(showCommands, hideCommands, immediate) { + // Immediate is "easy" + if (immediate || (this.hidden && !this._animating)) { + // Immediate mode (not animated) + this._showAndHideFast(showCommands, hideCommands); + // Need to remove them from queues, but others could be queued + this._removeFromQueue(showCommands, this._queuedToShow); + this._removeFromQueue(hideCommands, this._queuedToHide); + } else { + + // Queue Commands + this._updateAnimateQueue(showCommands, this._queuedToShow, this._queuedToHide); + this._updateAnimateQueue(hideCommands, this._queuedToHide, this._queuedToShow); + } + }, + + _removeFromQueue: function _Overlay_removeFromQueue(commands, queue) { + // remove commands from queue. + var count; + for (count = 0; count < commands.length; count++) { + // Remove if it was in queue + var countQ; + for (countQ = 0; countQ < queue.length; countQ++) { + if (queue[countQ] === commands[count]) { + queue.splice(countQ, 1); + break; + } + } + } + }, + + _updateAnimateQueue: function _Overlay_updateAnimateQueue(addCommands, toQueue, fromQueue) { + if (this._disposed) { + return; + } + + // Add addCommands to toQueue and remove addCommands from fromQueue. + var count; + for (count = 0; count < addCommands.length; count++) { + // See if it's already in toQueue + var countQ; + for (countQ = 0; countQ < toQueue.length; countQ++) { + if (toQueue[countQ] === addCommands[count]) { + break; + } + } + if (countQ === toQueue.length) { + // Not found, add it + toQueue[countQ] = addCommands[count]; + } + // Remove if it was in fromQueue + for (countQ = 0; countQ < fromQueue.length; countQ++) { + if (fromQueue[countQ] === addCommands[count]) { + fromQueue.splice(countQ, 1); + break; + } + } + } + // If we haven't queued the actual animation + if (!this._queuedCommandAnimation) { + // If not already animating, we'll need to call _checkDoNext + if (!this._animating) { + Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); + } + this._queuedCommandAnimation = true; + } + }, + + // show/hide commands without doing any animation. + _showAndHideFast: function _Overlay_showAndHideFast(showCommands, hideCommands) { + var count; + var command; + for (count = 0; count < showCommands.length; count++) { + command = showCommands[count]; + if (command && command.style) { + command.style.visibility = ""; + command.style.display = ""; + } + } + for (count = 0; count < hideCommands.length; count++) { + command = hideCommands[count]; + if (command && command.style) { + command.style.visibility = "hidden"; + command.style.display = "none"; + } + } + + this._commandsUpdated(); + + }, + + // show and hide the queued commands, perhaps animating if overlay isn't hidden. + _showAndHideQueue: function _Overlay_showAndHideQueue() { + // Only called if not currently animating. + // We'll be done with the queued stuff when we return. + this._queuedCommandAnimation = false; + + // Shortcut if hidden + if (this.hidden) { + this._showAndHideFast(this._queuedToShow, this._queuedToHide); + // Might be something else to do + Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); + } else { + // Animation has 3 parts: "hiding", "showing", and "moving" + // PVL has "addToList" and "deleteFromList", both of which allow moving parts. + // So we'll set up "add" for showing, and use "delete" for "hiding" + moving, + // then trigger both at the same time. + var showCommands = this._queuedToShow; + var hideCommands = this._queuedToHide; + var siblings = this._findSiblings(showCommands.concat(hideCommands)); + + // Filter out the commands queued for animation that don't need to be animated. + var count; + for (count = 0; count < showCommands.length; count++) { + // If this one's not real or not attached, skip it + if (!showCommands[count] || + !showCommands[count].style || + !_Global.document.body.contains(showCommands[count])) { + // Not real, skip it + showCommands.splice(count, 1); + count--; + } else if (showCommands[count].style.visibility !== "hidden" && showCommands[count].style.opacity !== "0") { + // Don't need to animate showing this one, already visible, so now it's a sibling + siblings.push(showCommands[count]); + showCommands.splice(count, 1); + count--; + } + } + for (count = 0; count < hideCommands.length; count++) { + // If this one's not real or not attached, skip it + if (!hideCommands[count] || + !hideCommands[count].style || + !_Global.document.body.contains(hideCommands[count]) || + hideCommands[count].style.visibility === "hidden" || + hideCommands[count].style.opacity === "0") { + // Don't need to animate hiding this one, not real, or it's hidden, + // so don't even need it as a sibling. + hideCommands.splice(count, 1); + count--; + } + } + + // Start command animations. + var commandsAnimationPromise = this._baseBeginAnimateCommands(showCommands, hideCommands, siblings); + + // Hook end animations + var that = this; + if (commandsAnimationPromise) { + // Needed to animate + commandsAnimationPromise.done( + function () { that._baseEndAnimateCommands(hideCommands); }, + function () { that._baseEndAnimateCommands(hideCommands); } + ); + } else { + // Already positioned correctly + Scheduler.schedule(function Overlay_async_baseEndAnimationCommands() { that._baseEndAnimateCommands([]); }, + Scheduler.Priority.normal, null, + "WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation"); + } + } + + // Done, clear queues + this._queuedToShow = []; + this._queuedToHide = []; + }, + + _baseBeginAnimateCommands: function _Overlay_baseBeginAnimateCommands(showCommands, hideCommands, siblings) { + // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. + // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. + // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE shceduled to hide. + // 3) siblings[]: i. All VISIBLE win-command elements that ARE NOT scheduled to hide. + // ii. All HIDDEN win-command elements that ARE NOT scheduled to hide OR show. + this._beginAnimateCommands(showCommands, hideCommands, this._getVisibleCommands(siblings)); + + var showAnimated = null, + hideAnimated = null; + + // Hide commands first, with siblings if necessary, + // so that the showing commands don't disrupt the hiding commands position. + if (hideCommands.length > 0) { + hideAnimated = Animations.createDeleteFromListAnimation(hideCommands, showCommands.length === 0 ? siblings : undefined); + } + if (showCommands.length > 0) { + showAnimated = Animations.createAddToListAnimation(showCommands, siblings); + } + + // Update hiding commands + for (var count = 0, len = hideCommands.length; count < len; count++) { + // Need to fix our position + var rectangle = hideCommands[count].getBoundingClientRect(), + style = _Global.getComputedStyle(hideCommands[count]); + + // Use the bounding box, adjusting for margins + hideCommands[count].style.top = (rectangle.top - parseFloat(style.marginTop)) + "px"; + hideCommands[count].style.left = (rectangle.left - parseFloat(style.marginLeft)) + "px"; + hideCommands[count].style.opacity = 0; + hideCommands[count].style.position = "fixed"; + } + + // Mark as animating + this._element.winAnimating = "rearranging"; + + // Start hiding animations + // Hide needs extra cleanup when done + var promise = null; + if (hideAnimated) { + promise = hideAnimated.execute(); + } + + // Update showing commands, + // After hiding commands so that the hiding ones fade in the right place. + for (count = 0; count < showCommands.length; count++) { + showCommands[count].style.visibility = ""; + showCommands[count].style.display = ""; + showCommands[count].style.opacity = 1; + } + + // Start showing animations + if (showAnimated) { + var newPromise = showAnimated.execute(); + if (promise) { + promise = Promise.join([promise, newPromise]); + } else { + promise = newPromise; + } + } + + return promise; + }, + + _beginAnimateCommands: function _Overlay_beginAnimateCommands() { + // Nothing by default + }, + + _getVisibleCommands: function _Overlay_getVisibleCommands(commandSubSet) { + var command, + commands = commandSubSet, + visibleCommands = []; + + if (!commands) { + // Crawl the inner HTML for the commands. + commands = this.element.querySelectorAll(".win-command"); + } + + for (var i = 0, len = commands.length; i < len; i++) { + command = commands[i].winControl || commands[i]; + if (!command.hidden) { + visibleCommands.push(command); + } + } + + return visibleCommands; + }, + + // Once animation is complete, ensure that the commands are display:none + // and check if there's another animation to start. + _baseEndAnimateCommands: function _Overlay_baseEndAnimateCommands(hideCommands) { + if (this._disposed) { + return; + } + + // Update us + var count; + for (count = 0; count < hideCommands.length; count++) { + // Force us back into our appbar so that we can show again correctly + hideCommands[count].style.position = ""; + hideCommands[count].getBoundingClientRect(); + // Now make us really hidden + hideCommands[count].style.visibility = "hidden"; + hideCommands[count].style.display = "none"; + hideCommands[count].style.opacity = 1; + } + // Done animating + this._element.winAnimating = ""; + + this._endAnimateCommands(); + + // Might be something else to do + this._checkDoNext(); + }, + + _endAnimateCommands: function _Overlay_endAnimateCommands() { + // Nothing by default + }, + + // Resolves our commands + _resolveCommands: function _Overlay_resolveCommands(commands) { + // First make sure they're all DOM elements. + commands = _resolveElements(commands); + + // Now make sure they're all in this container + var result = {}; + result.commands = []; + result.others = []; + var allCommands = this.element.querySelectorAll(".win-command"); + var countAll, countIn; + for (countAll = 0; countAll < allCommands.length; countAll++) { + var found = false; + for (countIn = 0; countIn < commands.length; countIn++) { + if (commands[countIn] === allCommands[countAll]) { + result.commands.push(allCommands[countAll]); + commands.splice(countIn, 1); + found = true; + break; + } + } + if (!found) { + result.others.push(allCommands[countAll]); + } + } + return result; + }, + + // Find siblings, all DOM elements now. + // Returns all .win-commands in this Overlay that are NOT in the passed in 'commands' array. + _findSiblings: function _Overlay_findSiblings(commands) { + // Now make sure they're all in this container + var siblings = []; + var allCommands = this.element.querySelectorAll(".win-command"); + var countAll, countIn; + for (countAll = 0; countAll < allCommands.length; countAll++) { + var found = false; + for (countIn = 0; countIn < commands.length; countIn++) { + if (commands[countIn] === allCommands[countAll]) { + commands.splice(countIn, 1); + found = true; + break; + } + } + if (!found) { + siblings.push(allCommands[countAll]); + } + } + return siblings; + }, + + _baseResize: function _Overlay_baseResize(event) { + // Avoid the cost of a resize if the Overlay is hidden. + if (this._cachedDocumentSize) { + if (this.hidden) { + this._cachedDocumentSize = null; + } else { + // Overlays will light dismiss on resize. + var newDocSize = _Overlay._sizeOfDocument(); + if (this._cachedDocumentSize.width !== newDocSize.width || this._cachedDocumentSize.height !== newDocSize.height) { + this._cachedDocumentSize = newDocSize; + if (!this._sticky) { + this._hideOrDismiss(); + } + } + } + } + + // Call specific resize + this._resize(event); + }, + + _hideOrDismiss: function _Overlay_hideOrDismiss() { + var element = this._element; + if (element && _ElementUtilities.hasClass(element, _Constants.settingsFlyoutClass)) { + this._dismiss(); + } else { + this.hide(); + } + }, + + _resize: function _Overlay_resize() { + // Nothing by default + }, + + _commandsUpdated: function _Overlay_commandsUpdated() { + // Nothing by default + }, + + _checkScrollPosition: function _Overlay_checkScrollPosition() { + // Nothing by default + }, + + _showingKeyboard: function _Overlay_showingKeyboard() { + // Nothing by default + }, + + _hidingKeyboard: function _Overlay_hidingKeyboard() { + // Nothing by default + }, + + // Verify that this HTML AppBar only has AppBar/MenuCommands. + _verifyCommandsOnly: function _Overlay_verifyCommandsOnly(element, type) { + var children = element.children; + var commands = new Array(children.length); + for (var i = 0; i < children.length; i++) { + // If constructed they have win-command class, otherwise they have data-win-control + if (!_ElementUtilities.hasClass(children[i], "win-command") && + children[i].getAttribute("data-win-control") !== type) { + // Wasn't tagged with class or AppBar/MenuCommand, not an AppBar/MenuCommand + throw new _ErrorFromName("WinJS.UI._Overlay.MustContainCommands", strings.mustContainCommands); + } else { + // Instantiate the commands. + ControlProcessor.processAll(children[i]); + commands[i] = children[i].winControl; + } + } + return commands; + }, + + // Sets focus on what we think is the last tab stop. If nothing is focusable will + // try to set focus on itself. + _focusOnLastFocusableElementOrThis: function _Overlay_focusOnLastFocusableElementOrThis() { + if (!this._focusOnLastFocusableElement()) { + // Nothing is focusable. Set focus to this. + _Overlay._trySetActive(this._element); + } + }, + + // Sets focus to what we think is the last tab stop. This element must have + // a firstDiv with tabIndex equal to the lowest tabIndex in the element + // and a finalDiv with tabIndex equal to the highest tabIndex in the element. + // Also the firstDiv must be its first child and finalDiv be its last child. + // Returns true if successful, false otherwise. + _focusOnLastFocusableElement: function _Overlay_focusOnLastFocusableElement() { + if (this._element.firstElementChild) { + var oldFirstTabIndex = this._element.firstElementChild.tabIndex; + var oldLastTabIndex = this._element.lastElementChild.tabIndex; + this._element.firstElementChild.tabIndex = -1; + this._element.lastElementChild.tabIndex = -1; + + var tabResult = _ElementUtilities._focusLastFocusableElement(this._element); + + if (tabResult) { + _Overlay._trySelect(_Global.document.activeElement); + } + + this._element.firstElementChild.tabIndex = oldFirstTabIndex; + this._element.lastElementChild.tabIndex = oldLastTabIndex; + + return tabResult; + } else { + return false; + } + }, + + + // Sets focus on what we think is the first tab stop. If nothing is focusable will + // try to set focus on itself. + _focusOnFirstFocusableElementOrThis: function _Overlay_focusOnFirstFocusableElementOrThis() { + if (!this._focusOnFirstFocusableElement()) { + // Nothing is focusable. Set focus to this. + _Overlay._trySetActive(this._element); + } + }, + + // Sets focus to what we think is the first tab stop. This element must have + // a firstDiv with tabIndex equal to the lowest tabIndex in the element + // and a finalDiv with tabIndex equal to the highest tabIndex in the element. + // Also the firstDiv must be its first child and finalDiv be its last child. + // Returns true if successful, false otherwise. + _focusOnFirstFocusableElement: function _Overlay__focusOnFirstFocusableElement() { + if (this._element.firstElementChild) { + var oldFirstTabIndex = this._element.firstElementChild.tabIndex; + var oldLastTabIndex = this._element.lastElementChild.tabIndex; + this._element.firstElementChild.tabIndex = -1; + this._element.lastElementChild.tabIndex = -1; + + var tabResult = _ElementUtilities._focusFirstFocusableElement(this._element); + + if (tabResult) { + _Overlay._trySelect(_Global.document.activeElement); + } + + this._element.firstElementChild.tabIndex = oldFirstTabIndex; + this._element.lastElementChild.tabIndex = oldLastTabIndex; + + return tabResult; + } else { + return false; + } + }, + + _addOverlayEventHandlers: function _Overlay_addOverlayEventHandlers(isFlyoutOrSettingsFlyout) { + // Set up global event handlers for all overlays + if (!_Overlay._flyoutEdgeLightDismissEvent) { + // Dismiss on blur & resize + // Focus handlers generally use WinJS.Utilities._addEventListener with focusout/focusin. This + // uses the browser's blur event directly beacuse _addEventListener doesn't support focusout/focusin + // on window. + _Global.addEventListener("blur", _Overlay._checkBlur, false); + + var that = this; + + // Be careful so it behaves in designer as well. + if (_WinRT.Windows.UI.Input.EdgeGesture) { + // Catch edgy events too + var commandUI = _WinRT.Windows.UI.Input.EdgeGesture.getForCurrentView(); + commandUI.addEventListener("starting", _Overlay._hideAllFlyouts); + commandUI.addEventListener("completed", _edgyMayHideFlyouts); + } + + if (_WinRT.Windows.UI.ViewManagement.InputPane) { + // React to Soft Keyboard events + var inputPane = _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView(); + inputPane.addEventListener("showing", function (event) { + that._writeProfilerMark("_showingKeyboard,StartTM"); + _allOverlaysCallback(event, "_showingKeyboard"); + that._writeProfilerMark("_showingKeyboard,StopTM"); + }); + inputPane.addEventListener("hiding", function (event) { + that._writeProfilerMark("_hidingKeyboard,StartTM"); + _allOverlaysCallback(event, "_hidingKeyboard"); + that._writeProfilerMark("_hidingKeyboard,StopTM"); + }); + // Document scroll event + _Global.document.addEventListener("scroll", function (event) { + that._writeProfilerMark("_checkScrollPosition,StartTM"); + _allOverlaysCallback(event, "_checkScrollPosition"); + that._writeProfilerMark("_checkScrollPosition,StopTM"); + }); + } + + // Window resize event + _Global.addEventListener("resize", function (event) { + that._writeProfilerMark("_baseResize,StartTM"); + _allOverlaysCallback(event, "_baseResize"); + that._writeProfilerMark("_baseResize,StopTM"); + }); + + _Overlay._flyoutEdgeLightDismissEvent = true; + } + + // Individual handlers for Flyouts only + if (isFlyoutOrSettingsFlyout) { + this._handleEventsForFlyoutOrSettingsFlyout(); + } + }, + + _handleEventsForFlyoutOrSettingsFlyout: function _Overlay_handleEventsForFlyoutOrSettingsFlyout() { + var that = this; + // Need to hide ourselves if we lose focus + _ElementUtilities._addEventListener(this._element, "focusout", function (e) { _Overlay._hideIfLostFocus(that, e); }, false); + + // Attempt to flag right clicks that may turn into edgy + _ElementUtilities._addEventListener(this._element, "pointerdown", _Overlay._checkRightClickDown, true); + _ElementUtilities._addEventListener(this._element, "pointerup", _Overlay._checkRightClickUp, true); + }, + + _writeProfilerMark: function _Overlay_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI._Overlay:" + this._id + ":" + text); + } + }, + { + // Statics + _clickEatingAppBarDiv: false, + _clickEatingFlyoutDiv: false, + _flyoutEdgeLightDismissEvent: false, + + _hideFlyouts: function (testElement, notSticky) { + var elements = testElement.querySelectorAll("." + _Constants.flyoutClass); + var len = elements.length; + for (var i = 0; i < len; i++) { + var element = elements[i]; + if (element.style.visibility !== "hidden") { + var flyout = element.winControl; + if (flyout && (!notSticky || !flyout._sticky)) { + flyout._hideOrDismiss(); + } + } + } + }, + + _hideSettingsFlyouts: function (testElement, notSticky) { + var elements = testElement.querySelectorAll("." + _Constants.settingsFlyoutClass); + var len = elements.length; + for (var i = 0; i < len; i++) { + var element = elements[i]; + if (element.style.visibility !== "hidden") { + var settingsFlyout = element.winControl; + if (settingsFlyout && (!notSticky || !settingsFlyout._sticky)) { + settingsFlyout._hideOrDismiss(); + } + } + } + }, + + _hideAllFlyouts: function () { + _Overlay._hideFlyouts(_Global.document, true); + _Overlay._hideSettingsFlyouts(_Global.document, true); + }, + + _createClickEatingDivTemplate: function (divClass, hideClickEatingDivFunction) { + var clickEatingDiv = _Global.document.createElement("section"); + clickEatingDiv._winHideClickEater = hideClickEatingDivFunction; + _ElementUtilities.addClass(clickEatingDiv, divClass); + _ElementUtilities._addEventListener(clickEatingDiv, "pointerup", function (event) { _Overlay._checkSameClickEatingPointerUp(event, true); }, true); + _ElementUtilities._addEventListener(clickEatingDiv, "pointerdown", function (event) { _Overlay._checkClickEatingPointerDown(event, true); }, true); + clickEatingDiv.addEventListener("click", function (event) { clickEatingDiv._winHideClickEater(event); }, true); + // Tell Aria that it's clickable + clickEatingDiv.setAttribute("role", "menuitem"); + clickEatingDiv.setAttribute("aria-label", strings.closeOverlay); + // Prevent CED from removing any current selection + clickEatingDiv.setAttribute("unselectable", "on"); + _Global.document.body.appendChild(clickEatingDiv); + return clickEatingDiv; + }, + + // Used by AppBar, and Settings Pane + _createClickEatingDivAppBar: function () { + if (!_Overlay._clickEatingAppBarDiv) { + _Overlay._clickEatingAppBarDiv = _Overlay._createClickEatingDivTemplate(_Constants._clickEatingAppBarClass, _Overlay._handleAppBarClickEatingClick); + } + }, + + // Used by Flyout and Menu + _createClickEatingDivFlyout: function () { + if (!_Overlay._clickEatingFlyoutDiv) { + _Overlay._clickEatingFlyoutDiv = _Overlay._createClickEatingDivTemplate(_Constants._clickEatingFlyoutClass, _Overlay._handleFlyoutClickEatingClick); + } + }, + + // All click-eaters eat "down" clicks so that we can still eat + // the "up" click that'll come later. + _checkClickEatingPointerDown: function (event, stopPropagation) { + var target = event.currentTarget; + if (target) { + try { + // Remember pointer id and remember right mouse + target._winPointerId = event.pointerId; + // Cache right mouse if that was what happened + target._winRightMouse = (event.button === 2); + } catch (e) { } + } + + if (stopPropagation && !target._winRightMouse) { + event.stopPropagation(); + event.preventDefault(); + } + }, + + // Make sure that if we have an up we had an earlier down of the same kind + _checkSameClickEatingPointerUp: function (event, stopPropagation) { + var result = false, + rightMouse = false, + target = event.currentTarget; + + // Same pointer we were watching? + try { + if (target && target._winPointerId === event.pointerId) { + // Same pointer + result = true; + rightMouse = target._winRightMouse; + // For click-eaters, don't count right click the same because edgy will dismiss + if (rightMouse && stopPropagation) { + result = false; + } + } + } catch (e) { } + + if (stopPropagation && !rightMouse) { + event.stopPropagation(); + event.preventDefault(); + target._winHideClickEater(event); + } + + return result; + }, + + // If they click on a click eating div, even with a right click, + // touch or anything, then we want to light dismiss that layer. + _handleAppBarClickEatingClick: function (event) { + event.stopPropagation(); + event.preventDefault(); + + _Overlay._hideLightDismissAppBars(null, false); + _Overlay._hideClickEatingDivAppBar(); + _Overlay._hideAllFlyouts(); + }, + + // If they click on a click eating div, even with a right click, + // touch or anything, then we want to light dismiss that layer. + _handleFlyoutClickEatingClick: function (event) { + event.stopPropagation(); + event.preventDefault(); + + // Don't light dismiss AppBars because edgy will do that as needed, + // so flyouts only. + _Overlay._hideClickEatingDivFlyout(); + _Overlay._hideFlyouts(_Global.document, true); + }, + + _checkRightClickDown: function (event) { + _Overlay._checkClickEatingPointerDown(event, false); + }, + + _checkRightClickUp: function (event) { + if (_Overlay._checkSameClickEatingPointerUp(event, false)) { + // It was a right click we may want to eat. + _Overlay._rightMouseMightEdgy = true; + _BaseUtils._yieldForEvents(function () { _Overlay._rightMouseMightEdgy = false; }); + } + }, + + _showClickEatingDivAppBar: function () { + Scheduler.schedule(function Overlay_async_showClickEatingDivAppBar() { + if (_Overlay._clickEatingAppBarDiv) { + _Overlay._clickEatingAppBarDiv.style.display = "block"; + } + }, Scheduler.Priority.high, null, "WinJS.UI._Overlay._showClickEatingDivAppBar"); + }, + + _hideClickEatingDivAppBar: function () { + Scheduler.schedule(function Overlay_async_hideClickEatingDivAppBar() { + if (_Overlay._clickEatingAppBarDiv) { + _Overlay._clickEatingAppBarDiv.style.display = "none"; + } + }, Scheduler.Priority.high, null, "WinJS.UI._Overlay._hideClickEatingDivAppBar"); + }, + + _showClickEatingDivFlyout: function () { + Scheduler.schedule(function Overlay_async_showClickEatingDivFlyout() { + if (_Overlay._clickEatingFlyoutDiv) { + _Overlay._clickEatingFlyoutDiv.style.display = "block"; + } + }, Scheduler.Priority.high, null, "WinJS.UI._Overlay._showClickEatingDivFlyout"); + }, + + _hideClickEatingDivFlyout: function () { + Scheduler.schedule(function Overlay_async_hideClickEatingDivFlyout() { + if (_Overlay._clickEatingFlyoutDiv) { + _Overlay._clickEatingFlyoutDiv.style.display = "none"; + } + }, Scheduler.Priority.high, null, "WinJS.UI._Overlay._hideClickEatingDivFlyout"); + }, + + _isFlyoutVisible: function () { + if (!_Overlay._clickEatingFlyoutDiv) { + return false; + } + return (_Overlay._clickEatingFlyoutDiv.style.display === "block"); + }, + + _hideIfLostFocus: function (overlay) { + // If we're still showing we haven't really lost focus + if (overlay.hidden || overlay.element.winAnimating === "showing" || overlay._sticky) { + return; + } + // If the active thing is within our element, we haven't lost focus + var active = _Global.document.activeElement; + if (overlay._element && overlay._element.contains(active)) { + return; + } + // SettingFlyouts don't dismiss if they spawned a flyout + if (_ElementUtilities.hasClass(overlay._element, _Constants.settingsFlyoutClass)) { + var settingsFlyout = overlay; + var flyoutControl = _Overlay._getParentControlUsingClassName(active, "win-flyout"); + if (flyoutControl && flyoutControl._previousFocus && settingsFlyout.element.contains(flyoutControl._previousFocus)) { + _ElementUtilities._addEventListener(flyoutControl.element, 'focusout', function focusOut(event) { + // When the Flyout closes, hide the SetingsFlyout if it didn't regain focus. + _Overlay._hideIfLostFocus(settingsFlyout, event); + _ElementUtilities._removeEventListener(flyoutControl.element, 'focusout', focusOut, false); + }, false); + return; + } + } + // Do not hide focus if focus moved to a CED. Let the click handler on the CED take care of hiding us. + if (active && + (_ElementUtilities.hasClass(active, _Constants._clickEatingFlyoutClass) || + _ElementUtilities.hasClass(active, _Constants._clickEatingAppBarClass))) { + return; + } + + overlay._hideOrDismiss(); + }, + + // Want to hide flyouts on blur. + // We get blur if we click off the window, including to an iframe within our window. + // Both blurs call this function, but fortunately document.hasFocus is true if either + // the document window or our iframe window has focus. + _checkBlur: function () { + if (!_Global.document.hasFocus()) { + // The document doesn't have focus, so they clicked off the app, so light dismiss. + _Overlay._hideAllFlyouts(); + _Overlay._hideLightDismissAppBars(null, false); + } else { + if ((_Overlay._clickEatingFlyoutDiv && + _Overlay._clickEatingFlyoutDiv.style.display === "block") || + (_Overlay._clickEatingAppBarDiv && + _Overlay._clickEatingAppBarDiv.style.display === "block")) { + // We were trying to unfocus the window, but document still has focus, + // so make sure the iframe that took the focus will check for blur next time. + // We don't have to do this if the click eating div is hidden because then + // there would be no flyout or appbar needing light dismiss. + var active = _Global.document.activeElement; + if (active && active.tagName === "IFRAME" && !active.msLightDismissBlur) { + // - This will go away when the IFRAME goes away, and we only create one. + // - This only works in IE because other browsers don't fire focus events on iframe elements. + // - Can't use WinJS.Utilities._addEventListener's focusout because it doesn't fire when an + // iframe loses focus due to changing windows. + active.addEventListener("blur", _Overlay._checkBlur, false); + active.msLightDismissBlur = true; + } + } + } + }, + + // Try to set us as active + _trySetActive: function (element) { + if (!element || !_Global.document.body || !_Global.document.body.contains(element)) { + return false; + } + if (!_ElementUtilities._setActive(element)) { + return false; + } + return (element === _Global.document.activeElement); + }, + + // Try to select the text so keyboard can be used. + _trySelect: function (element) { + try { + if (element && element.select) { + element.select(); + } + } catch (e) { } + }, + + // Prevent the document.activeElement from showing focus + _addHideFocusClass: function (element) { + if (element) { + _ElementUtilities.addClass(element, _Constants.hideFocusClass); + _ElementUtilities._addEventListener(element, "focusout", _Overlay._removeHideFocusClass, false); + } + }, + + // Allow the event.target (element that is losing focus) to show focus next time it gains focus + _removeHideFocusClass: function (event) { + // Make sure we really lost focus and was not just an App switch + var target = event.target; + if (target && target !== _Global.document.activeElement) { + _ElementUtilities.removeClass(target, _Constants.hideFocusClass); + _ElementUtilities._removeEventListener(event.target, "focusout", _Overlay._removeHideFocusClass, false); + } + }, + + _sizeOfDocument: function () { + return { + width: _Global.document.documentElement.offsetWidth, + height: _Global.document.documentElement.offsetHeight, + }; + }, + + _getParentControlUsingClassName: function (element, className) { + while (element && element !== _Global.document.body) { + if (_ElementUtilities.hasClass(element, className)) { + return element.winControl; + } + element = element.parentNode; + } + return null; + }, + + // Hide all light dismiss AppBars if what has focus is not part of a AppBar or flyout. + _hideIfAllAppBarsLostFocus: function _hideIfAllAppBarsLostFocus() { + if (!_Overlay._isAppBarOrChild(_Global.document.activeElement)) { + _Overlay._hideLightDismissAppBars(null, false); + // Ensure that sticky appbars clear cached focus after light dismiss are dismissed, which moved focus. + _Overlay._ElementWithFocusPreviousToAppBar = null; + } + }, + + _hideLightDismissAppBars: function (event, keyboardInvoked) { + var elements = _Global.document.querySelectorAll("." + _Constants.appBarClass); + var len = elements.length; + var AppBars = []; + for (var i = 0; i < len; i++) { + var AppBar = elements[i].winControl; + if (AppBar && !AppBar.sticky && !AppBar.hidden) { + AppBars.push(AppBar); + } + } + + _Overlay._hideAllBars(AppBars, keyboardInvoked); + }, + + // Show/Hide all bars + _hideAllBars: function _Overlay_hideAllBars(bars, keyboardInvoked) { + var allBarsAnimationPromises = bars.map(function (bar) { + bar._keyboardInvoked = keyboardInvoked; + bar.hide(); + return bar._animationPromise; + }); + return Promise.join(allBarsAnimationPromises); + }, + + _showAllBars: function _Overlay_showAllBars(bars, keyboardInvoked) { + var allBarsAnimationPromises = bars.map(function (bar) { + bar._keyboardInvoked = keyboardInvoked; + bar._doNotFocus = false; + bar._show(); + return bar._animationPromise; + }); + return Promise.join(allBarsAnimationPromises); + }, + + // Returns appbar element (or CED/sentinal) if the element or what had focus before the element (if a Flyout) is either: + // 1) an AppBar, + // 2) OR in the subtree of an AppBar, + // 3) OR an AppBar click eating div. + // Returns null otherwise. + _isAppBarOrChild: function (element) { + // If it's null, we can't do this + if (!element) { + return null; + } + + // Intrinsic components of the AppBar count as the AppBar + if (_ElementUtilities.hasClass(element, _Constants._clickEatingAppBarClass) || + _ElementUtilities.hasClass(element, _Constants._clickEatingFlyoutClass) || + _ElementUtilities.hasClass(element, _Constants.firstDivClass) || + _ElementUtilities.hasClass(element, _Constants.finalDivClass) || + _ElementUtilities.hasClass(element, _Constants.invokeButtonClass)) { + return element; + } + + while (element && element !== _Global.document) { + if (_ElementUtilities.hasClass(element, _Constants.appBarClass)) { + return element; + } + if (_ElementUtilities.hasClass(element, "win-flyout") + && element !== element.winControl._previousFocus) { + var flyoutControl = element.winControl; + // If _previousFocus was in a light dismissable AppBar, then this Flyout is considered of an extension of it and that AppBar should not hide. + // Hook up a 'focusout' listener to this Flyout element to make sure that light dismiss AppBars hide if focus moves anywhere other than back to an AppBar. + var appBarElement = _Overlay._isAppBarOrChild(flyoutControl._previousFocus); + if (appBarElement) { + _ElementUtilities._addEventListener(flyoutControl.element, 'focusout', function focusOut() { + // Hides any shown AppBars if the new activeElement is not in an AppBar. + _Overlay._hideIfAllAppBarsLostFocus(); + _ElementUtilities._removeEventListener(flyoutControl.element, 'focusout', focusOut, false); + }, false); + } + return appBarElement; + } + + element = element.parentNode; + } + + return null; + }, + + // WWA Soft Keyboard offsets + _keyboardInfo: { + // Determine if the keyboard is visible or not. + get _visible() { + + try { + return ( + _WinRT.Windows.UI.ViewManagement.InputPane && + _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height > 0 + ); + } catch (e) { + return false; + } + + }, + + // See if we have to reserve extra space for the IHM + get _extraOccluded() { + var occluded; + if (_WinRT.Windows.UI.ViewManagement.InputPane) { + try { + occluded = _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height; + } catch (e) { + } + } + + // Nothing occluded if not visible. + if (occluded && !_Overlay._keyboardInfo._isResized) { + // View hasn't been resized, need to return occluded height. + return occluded; + } + + // View already has space for keyboard or there's no keyboard + return 0; + + }, + + // See if the view has been resized to fit a keyboard + get _isResized() { + // Compare ratios. Very different includes IHM space. + var heightRatio = _Global.document.documentElement.clientHeight / _Global.innerHeight, + widthRatio = _Global.document.documentElement.clientWidth / _Global.innerWidth; + + // If they're nearly identical, then the view hasn't been resized for the IHM + // Only check one bound because we know the IHM will make it shorter, not skinnier. + return (widthRatio / heightRatio < 0.99); + + }, + + // Get the bottom of our visible area. + get _visibleDocBottom() { + return _Overlay._keyboardInfo._visibleDocTop + _Overlay._keyboardInfo._visibleDocHeight; + + }, + + // Get the height of the visible document, e.g. the height of the visual viewport minus any IHM occlusion. + get _visibleDocHeight() { + return _Overlay._keyboardInfo._visualViewportHeight - _Overlay._keyboardInfo._extraOccluded; + + }, + + // Get total length of the IHM showPanel animation + get _animationShowLength() { + if (_WinRT.Windows.UI.Core.AnimationMetrics) { + var a = _WinRT.Windows.UI.Core.AnimationMetrics, + animationDescription = new a.AnimationDescription(a.AnimationEffect.showPanel, a.AnimationEffectTarget.primary); + var animations = animationDescription.animations; + var max = 0; + for (var i = 0; i < animations.size; i++) { + var animation = animations[i]; + max = Math.max(max, animation.delay + animation.duration); + } + return max; + } else { + return 0; + } + }, + }, + + _ElementWithFocusPreviousToAppBar: null, + + // for tests + _clickEatingAppBarClass: _Constants._clickEatingAppBarClass, + _clickEatingFlyoutClass: _Constants._clickEatingFlyoutClass, + + // Padding for IHM timer to allow for first scroll event + _scrollTimeout: 150, + + // Events + beforeShow: BEFORESHOW, + beforeHide: BEFOREHIDE, + afterShow: AFTERSHOW, + afterHide: AFTERHIDE, + + commonstrings: { + get cannotChangeCommandsWhenVisible() { return "Invalid argument: You must call hide() before changing {0} commands"; }, + get cannotChangeHiddenProperty() { return "Unable to set hidden property while parent {0} is visible."; } + } + }); + + // Mixin for WWA's Soft Keyboard offsets when -ms-device-fixed CSS positioning is supported, or for general _Overlay positioning whenever we are in a web browser outside of WWA. + // If we are in an instance of WWA, all _Overlay elements will use -ms-device-fixed positioning which fixes them to the visual viewport directly. + var _keyboardInfo_Mixin = { + + // Get the top offset of our visible area, aka the top of the visual viewport. + // This is always 0 when _Overlay elements use -ms-device-fixed positioning. + _visibleDocTop: function _visibleDocTop() { + return 0; + }, + + // Get the bottom offset of the visual viewport, plus any IHM occlusion. + _visibleDocBottomOffset: function _visibleDocBottomOffset() { + // For -ms-device-fixed positioned elements, the bottom is just 0 when there's no IHM. + // When the IHM appears, the text input that invoked it may be in a position on the page that is occluded by the IHM. + // In that instance, the default browser behavior is to resize the visual viewport and scroll the input back into view. + // However, if the viewport resize is prevented by an IHM event listener, the keyboard will still occlude + // -ms-device-fixed elements, so we adjust the bottom offset of the appbar by the height of the occluded rect of the IHM. + return (_Overlay._keyboardInfo._isResized) ? 0 : _Overlay._keyboardInfo._extraOccluded; + }, + + // Get the visual viewport height. window.innerHeight doesn't return floating point values which are present with high DPI. + _visualViewportHeight: function _visualViewportHeight() { + var boundingRect = _Overlay._keyboardInfo._visualViewportSpace; + return boundingRect.bottom - boundingRect.top; + }, + + // Get the visual viewport width. window.innerWidth doesn't return floating point values which are present with high DPI. + _visualViewportWidth: function _visualViewportWidth() { + var boundingRect = _Overlay._keyboardInfo._visualViewportSpace; + return boundingRect.right - boundingRect.left; + }, + + _visualViewportSpace: function _visualViewportSpace() { + var visualViewportSpace = _Global.document.body.querySelector("." + _Constants._visualViewportClass); + if (!visualViewportSpace) { + visualViewportSpace = _Global.document.createElement("DIV"); + visualViewportSpace.className = _Constants._visualViewportClass; + _Global.document.body.appendChild(visualViewportSpace); + } + return visualViewportSpace.getBoundingClientRect(); + }, + }; + + // Mixin for WWA's Soft Keyboard offsets in IE10 mode, where -ms-device-fixed positioning is not available. + // In that instance, all _Overlay elements fall back to using CSS fixed positioning. + // This is for backwards compatibility with Apache Cordova Apps targeting WWA since they target IE10. + // This is essentially the original logic for WWA _Overlay / Soft Keyboard interactions we used when windows 8 first launched. + var _keyboardInfo_Windows8WWA_Mixin = { + // Get the top of our visible area in terms of its absolute distance from the top of document.documentElement. + // Normalizes any offsets which have have occured between the visual viewport and the layout viewport due to resizing the viewport to fit the IHM and/or optical zoom. + _visibleDocTop: function _visibleDocTop_Windows8WWA() { + return _Global.window.pageYOffset - _Global.document.documentElement.scrollTop; + }, + + // Get the bottom offset of the visual viewport from the bottom of the layout viewport, plus any IHM occlusion. + _visibleDocBottomOffset: function _visibleDocBottomOffset_Windows8WWA() { + return _Global.document.documentElement.clientHeight - _Overlay._keyboardInfo._visibleDocBottom; + }, + + _visualViewportHeight: function _visualViewportHeight_Windows8WWA() { + return _Global.window.innerHeight; + }, + + _visualViewportWidth: function _visualViewportWidth_Windows8WWA() { + return _Global.window.innerWidth; + }, + }; + + _Base.Class.mix(_Overlay, _Control.DOMEventMixin); + + // Feature detect for -ms-device-fixed positioning and fill out the + // remainder of our WWA Soft KeyBoard handling logic with mixins. + var visualViewportSpace = _Global.document.createElement("DIV"); + visualViewportSpace.className = _Constants._visualViewportClass; + _Global.document.body.appendChild(visualViewportSpace); + + var propertiesMixin, + hasDeviceFixed = _Global.getComputedStyle(visualViewportSpace).position === "-ms-device-fixed"; + if (!hasDeviceFixed && _WinRT.Windows.UI.ViewManagement.InputPane) { + // If we are in WWA with IE 10 mode, use special keyboard handling knowledge for IE10 IHM. + propertiesMixin = _keyboardInfo_Windows8WWA_Mixin; + _Global.document.body.removeChild(visualViewportSpace); + } else { + // If we are in WWA on IE 11 or outside of WWA on any web browser use general positioning logic. + propertiesMixin = _keyboardInfo_Mixin; + } + + for (var propertyName in propertiesMixin) { + Object.defineProperty(_Overlay._keyboardInfo, propertyName, { + get: propertiesMixin[propertyName], + }); + } + + return _Overlay; + }) + }); + +}); + + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +/// appbar,Flyout,Flyouts,Statics +define('WinJS/Controls/Flyout',[ + 'exports', + '../Core/_Global', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Resources', + '../Core/_WriteProfilerMark', + '../Animations', + '../Utilities/_Dispose', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + './AppBar/_Constants', + './Flyout/_Overlay', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' + ], function flyoutInit(exports, _Global, _Base, _BaseUtils, _ErrorFromName, _Resources, _WriteProfilerMark, Animations, _Dispose, _ElementUtilities, _Hoverable, _Constants, _Overlay) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + /// + /// + /// Displays lightweight UI that is either informational, or requires user interaction. + /// Unlike a dialog, a Flyout can be light dismissed by clicking or tapping off of it. + /// + /// + /// + /// Flyout + /// + /// + /// ]]> + /// Raised just before showing a flyout. + /// Raised immediately after a flyout is fully shown. + /// Raised just before hiding a flyout. + /// Raised immediately after a flyout is fully hidden. + /// The Flyout control itself. + /// + /// + /// + Flyout: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + function getDimension(element, property) { + return parseFloat(element, _Global.getComputedStyle(element, null)[property]); + } + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/flyoutAriaLabel").value; }, + get noAnchor() { return "Invalid argument: Showing flyout requires a DOM element as its parameter."; }, + get badPlacement() { return "Invalid argument: Flyout placement should be 'top' (default), 'bottom', 'left', 'right', or 'auto'."; }, + get badAlignment() { return "Invalid argument: Flyout alignment should be 'center' (default), 'left', or 'right'."; } + }; + + var Flyout = _Base.Class.derive(_Overlay._Overlay, function Flyout_ctor(element, options) { + /// + /// + /// Creates a new Flyout control. + /// + /// + /// The DOM element that hosts the control. + /// + /// + /// The set of properties and values to apply to the new Flyout. + /// + /// The new Flyout control. + /// + /// + + // Simplify checking later + options = options || {}; + + // Make sure there's an input element + this._element = element || _Global.document.createElement("div"); + this._id = this._element.id || _ElementUtilities._uniqueID(this._element); + this._writeProfilerMark("constructor,StartTM"); + + this._baseFlyoutConstructor(this._element, options); + + var _elms = this._element.getElementsByTagName("*"); + var firstDiv = this._addFirstDiv(); + firstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(_elms); + var finalDiv = this._addFinalDiv(); + finalDiv.tabIndex = _ElementUtilities._getHighestTabIndexInList(_elms); + + // Handle "esc" & "tab" key presses + this._element.addEventListener("keydown", this._handleKeyDown, true); + + this._writeProfilerMark("constructor,StopTM"); + return this; + }, { + _lastMaxHeight: null, + + _baseFlyoutConstructor: function Flyout_baseFlyoutContstructor(element, options) { + // Flyout constructor + + // We have some options with defaults + this._placement = "auto"; + this._alignment = "center"; + + // Call the base overlay constructor helper + this._baseOverlayConstructor(element, options); + + // Make a click eating div + _Overlay._Overlay._createClickEatingDivFlyout(); + + // Start flyouts hidden + this._element.style.visibilty = "hidden"; + this._element.style.display = "none"; + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.flyoutClass); + _ElementUtilities.addClass(this._element, _Constants.flyoutLightClass); + + // Make sure we have an ARIA role + var role = this._element.getAttribute("role"); + if (role === null || role === "" || role === undefined) { + if (_ElementUtilities.hasClass(this._element, _Constants.menuClass)) { + this._element.setAttribute("role", "menu"); + } else { + this._element.setAttribute("role", "dialog"); + } + } + var label = this._element.getAttribute("aria-label"); + if (label === null || label === "" || label === undefined) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + + // Base animation is popIn, but our flyout has different arguments + this._currentAnimateIn = this._flyoutAnimateIn; + this._currentAnimateOut = this._flyoutAnimateOut; + + // Make sure _Overlay event handlers are hooked up + this._addOverlayEventHandlers(true); + }, + + /// + /// Gets or sets the Flyout control's anchor. The anchor element is the HTML element which the Flyout originates from and is positioned relative to. + /// (This setting can be overridden when you call the show method.) + /// + /// + anchor: { + get: function () { + return this._anchor; + }, + set: function (value) { + this._anchor = value; + } + }, + + /// + /// Gets or sets the default placement of this Flyout. (This setting can be overridden when you call the show method.) + /// + /// + placement: { + get: function () { + return this._placement; + }, + set: function (value) { + if (value !== "top" && value !== "bottom" && value !== "left" && value !== "right" && value !== "auto") { + // Not a legal placement value + throw new _ErrorFromName("WinJS.UI.Flyout.BadPlacement", strings.badPlacement); + } + this._placement = value; + } + }, + + /// + /// Gets or sets the default alignment for this Flyout. (This setting can be overridden when you call the show method.) + /// + /// + alignment: { + get: function () { + return this._alignment; + }, + set: function (value) { + if (value !== "right" && value !== "left" && value !== "center") { + // Not a legal alignment value + throw new _ErrorFromName("WinJS.UI.Flyout.BadAlignment", strings.badAlignment); + } + this._alignment = value; + } + }, + + _dispose: function Flyout_dispose() { + _Dispose.disposeSubTree(this.element); + this._hide(); + this.anchor = null; + }, + + show: function (anchor, placement, alignment) { + /// + /// + /// Shows the Flyout, if hidden, regardless of other states. + /// + /// + /// The DOM element, or ID of a DOM element to anchor the Flyout, overriding the anchor property for this time only. + /// + /// + /// The placement of the Flyout to the anchor: 'auto' (default), 'top', 'bottom', 'left', or 'right'. This parameter overrides the placement property for this show only. + /// + /// + /// For 'top' or 'bottom' placement, the alignment of the Flyout to the anchor's edge: 'center' (default), 'left', or 'right'. + /// This parameter overrides the alignment property for this show only. + /// + /// + /// + this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). + // Just call private version to make appbar flags happy + this._show(anchor, placement, alignment); + }, + + _show: function Flyout_show(anchor, placement, alignment) { + this._baseFlyoutShow(anchor, placement, alignment); + }, + + hide: function () { + /// + /// + /// Hides the Flyout, if visible, regardless of other states. + /// + /// + /// + // Just wrap the private one, turning off keyboard invoked flag + this._writeProfilerMark("hide,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndHide(). + this._keyboardInvoked = false; + this._hide(); + }, + + _hide: function Flyout_hide() { + if (this._baseHide()) { + // Return focus if this or the flyout CED has focus + var active = _Global.document.activeElement; + if (this._previousFocus + && active + && (this._element.contains(active) + || _ElementUtilities.hasClass(active, _Overlay._Overlay._clickEatingFlyoutClass)) + && this._previousFocus.focus !== undefined) { + + // _isAppBarOrChild may return a CED or sentinal + var appBar = _Overlay._Overlay._isAppBarOrChild(this._previousFocus); + if (!appBar || (appBar.winControl && !appBar.winControl.hidden && !appBar.winAnimating)) { + // Don't move focus back to a appBar that is hidden + // We cannot rely on element.style.visibility because it will be visible while animating + var role = this._previousFocus.getAttribute("role"); + var fHideRole = _Overlay._Overlay._keyboardInfo._visible && !this._keyboardWasUp; + if (fHideRole) { + // Convince IHM to dismiss because it only came up after the flyout was up. + // Change aria role and back to get IHM to dismiss. + this._previousFocus.setAttribute("role", ""); + } + + if (this._keyboardInvoked) { + this._previousFocus.focus(); + } else { + _Overlay._Overlay._trySetActive(this._previousFocus); + } + active = _Global.document.activeElement; + + if (fHideRole) { + // Restore the role so that css is applied correctly + var previousFocus = this._previousFocus; + if (previousFocus) { + _BaseUtils._yieldForDomModification(function () { + previousFocus.setAttribute("role", role); + }); + } + } + } + + // If the anchor gained focus we want to hide the focus in the non-keyboarding scenario + if (!this._keyboardInvoked && (this._previousFocus === active) && appBar && active) { + _Overlay._Overlay._addHideFocusClass(active); + } + } + + this._previousFocus = null; + + // Need click-eating div to be hidden if there are no other visible flyouts + if (!this._isThereVisibleFlyout()) { + _Overlay._Overlay._hideClickEatingDivFlyout(); + } + } + }, + + _baseFlyoutShow: function Flyout_baseFlyoutShow(anchor, placement, alignment) { + // Don't do anything if disabled + if (this.disabled) { + return; + } + // Pick up defaults + if (!anchor) { + anchor = this._anchor; + } + if (!placement) { + placement = this._placement; + } + if (!alignment) { + alignment = this._alignment; + } + + // Dereference the anchor if necessary + if (typeof anchor === "string") { + anchor = _Global.document.getElementById(anchor); + } else if (anchor && anchor.element) { + anchor = anchor.element; + } + + // We expect an anchor + if (!anchor) { + // If we have _nextLeft, etc., then we were continuing an old animation, so that's OK + if (!this._retryLast) { + throw new _ErrorFromName("WinJS.UI.Flyout.NoAnchor", strings.noAnchor); + } + // Last call was incomplete, so use the previous _current values. + this._retryLast = null; + } else { + // Remember the anchor so that if we lose focus we can go back + this._currentAnchor = anchor; + // Remember current values + this._currentPlacement = placement; + this._currentAlignment = alignment; + } + + // Need click-eating div to be visible, no matter what + if (!this._sticky) { + _Overlay._Overlay._showClickEatingDivFlyout(); + } + + // If we're animating (eg baseShow is going to fail), then don't mess up our current state. + // Queue us up to wait for current animation to finish first. + if (this._element.winAnimating) { + this._doNext = "show"; + this._retryLast = true; + return; + } + + // We call our base _baseShow to handle the actual animation + if (this._baseShow()) { + // (_baseShow shouldn't ever fail because we tested winAnimating above). + if (!_ElementUtilities.hasClass(this.element, "win-menu")) { + // Verify that the firstDiv is in the correct location. + // Move it to the correct location or add it if not. + var _elms = this._element.getElementsByTagName("*"); + var firstDiv = this.element.querySelectorAll(".win-first"); + if (this.element.children.length && !_ElementUtilities.hasClass(this.element.children[0], _Constants.firstDivClass)) { + if (firstDiv && firstDiv.length > 0) { + firstDiv.item(0).parentNode.removeChild(firstDiv.item(0)); + } + + firstDiv = this._addFirstDiv(); + } + firstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(_elms); + + // Verify that the finalDiv is in the correct location. + // Move it to the correct location or add it if not. + var finalDiv = this.element.querySelectorAll(".win-final"); + if (!_ElementUtilities.hasClass(this.element.children[this.element.children.length - 1], _Constants.finalDivClass)) { + if (finalDiv && finalDiv.length > 0) { + finalDiv.item(0).parentNode.removeChild(finalDiv.item(0)); + } + + finalDiv = this._addFinalDiv(); + } + finalDiv.tabIndex = _ElementUtilities._getHighestTabIndexInList(_elms); + } + + // Hide all other flyouts + this._hideAllOtherFlyouts(this); + + // Store what had focus before showing the Flyout. + // This must happen after we hide all other flyouts so that we store the correct element. + this._previousFocus = _Global.document.activeElement; + } + }, + + _endShow: function Flyout_endShow() { + // Remember if the IHM was up since we may need to hide it when the flyout hides. + // This check needs to happen after the IHM has a chance to hide itself after we force hide + // all other visible Flyouts. + this._keyboardWasUp = _Overlay._Overlay._keyboardInfo._visible; + + if (!_ElementUtilities.hasClass(this.element, _Constants.menuClass)) { + // Put focus on the first child in the Flyout + this._focusOnFirstFocusableElementOrThis(); + + // Prevent what is gaining focus from showing that it has focus + _Overlay._Overlay._addHideFocusClass(_Global.document.activeElement); + } else { + // Make sure the menu has focus, but don't show a focus rect + _Overlay._Overlay._trySetActive(this._element); + } + }, + + // Find our new flyout position. + _findPosition: function Flyout_findPosition() { + this._nextHeight = null; + this._keyboardMovedUs = false; + this._hasScrolls = false; + this._keyboardSquishedUs = 0; + + // Make sure menu toggles behave + if (this._checkToggle) { + this._checkToggle(); + } + + // Update margins for this alignment and remove old scrolling + this._updateAdjustments(this._currentAlignment); + + // Set up the new position, and prep the offset for showPopup + this._getTopLeft(); + // Panning top offset is calculated top + this._scrollTop = this._nextTop - _Overlay._Overlay._keyboardInfo._visibleDocTop; + + // Adjust position + if (this._nextTop < 0) { + // Need to attach to bottom + this._element.style.bottom = "0px"; + this._element.style.top = "auto"; + } else { + // Normal, attach to top + this._element.style.top = this._nextTop + "px"; + this._element.style.bottom = "auto"; + } + if (this._nextLeft < 0) { + // Overran right, attach to right + this._element.style.right = "0px"; + this._element.style.left = "auto"; + } else { + // Normal, attach to left + this._element.style.left = this._nextLeft + "px"; + this._element.style.right = "auto"; + } + + // Adjust height/scrollbar + if (this._nextHeight !== null) { + _ElementUtilities.addClass(this._element, _Constants.scrollsClass); + this._lastMaxHeight = this._element.style.maxHeight; + this._element.style.maxHeight = this._nextHeight + "px"; + this._nextBottom = this._nextTop + this._nextHeight; + this._hasScrolls = true; + } + + // May need to adjust if the IHM is showing. + if (_Overlay._Overlay._keyboardInfo._visible) { + // Use keyboard logic + this._checkKeyboardFit(); + + if (this._keyboardMovedUs) { + this._adjustForKeyboard(); + } + } + }, + + // This determines our positioning. We have 5 modes, the 1st four are explicit, the last is automatic: + // * top - position explicitly on the top of the anchor, shrinking and adding scrollbar as needed. + // * bottom - position explicitly below the anchor, shrinking and adding scrollbar as needed. + // * left - position left of the anchor, shrinking and adding a vertical scrollbar as needed. + // * right - position right of the anchor, shrinking and adding a vertical scroolbar as needed. + // * auto - Automatic placement. + // Auto tests the height of the anchor and the flyout. For consistency in orientation, we imagine + // that the anchor is placed in the vertical center of the display. If the flyout would fit above + // that centered anchor, then we will place the flyout vertically in relation to the anchor, otherwise + // placement will be horizontal. + // Vertical auto placement will be positioned on top of the anchor if room, otherwise below the anchor. + // - this is because touch users would be more likely to obscure flyouts below the anchor. + // Horizontal auto placement will be positioned to the left of the anchor if room, otherwise to the right. + // - this is because right handed users would be more likely to obscure a flyout on the right of the anchor. + // Auto placement will add a vertical scrollbar if necessary. + _getTopLeft: function Flyout_getTopLeft() { + var anchorRawRectangle = this._currentAnchor.getBoundingClientRect(), + flyout = {}, + anchor = {}; + + // Adjust for the anchor's margins. + anchor.top = anchorRawRectangle.top; + anchor.bottom = anchorRawRectangle.bottom; + anchor.left = anchorRawRectangle.left; + anchor.right = anchorRawRectangle.right; + anchor.height = anchor.bottom - anchor.top; + anchor.width = anchor.right - anchor.left; + + // Get our flyout and margins, note that getDimension calls + // window.getComputedStyle, which ensures layout is updated. + flyout.marginTop = getDimension(this._element, "marginTop"); + flyout.marginBottom = getDimension(this._element, "marginBottom"); + flyout.marginLeft = getDimension(this._element, "marginLeft"); + flyout.marginRight = getDimension(this._element, "marginRight"); + flyout.width = _ElementUtilities.getTotalWidth(this._element); + flyout.height = _ElementUtilities.getTotalHeight(this._element); + flyout.innerWidth = _ElementUtilities.getContentWidth(this._element); + flyout.innerHeight = _ElementUtilities.getContentHeight(this._element); + this._nextMarginPadding = (flyout.height - flyout.innerHeight); + + // Check fit for requested this._currentPlacement, doing fallback if necessary + switch (this._currentPlacement) { + case "top": + if (!this._fitTop(anchor, flyout)) { + // Didn't fit, needs scrollbar + this._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; + this._nextHeight = anchor.top - _Overlay._Overlay._keyboardInfo._visibleDocTop - this._nextMarginPadding; + } + this._centerHorizontally(anchor, flyout, this._currentAlignment); + break; + case "bottom": + if (!this._fitBottom(anchor, flyout)) { + // Didn't fit, needs scrollbar + this._nextTop = -1; + this._nextHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight - (anchor.bottom - _Overlay._Overlay._keyboardInfo._visibleDocTop) - this._nextMarginPadding; + } + this._centerHorizontally(anchor, flyout, this._currentAlignment); + break; + case "left": + if (!this._fitLeft(anchor, flyout)) { + // Didn't fit, just shove it to edge + this._nextLeft = 0; + } + this._centerVertically(anchor, flyout); + break; + case "right": + if (!this._fitRight(anchor, flyout)) { + // Didn't fit,just shove it to edge + this._nextLeft = -1; + } + this._centerVertically(anchor, flyout); + break; + case "auto": + // Auto, if the anchor was in the vertical center of the display would we fit above it? + if (this._sometimesFitsAbove(anchor, flyout)) { + // It will fit above or below the anchor + if (!this._fitTop(anchor, flyout)) { + // Didn't fit above (preferred), so go below. + this._fitBottom(anchor, flyout); + } + this._centerHorizontally(anchor, flyout, this._currentAlignment); + } else { + // Won't fit above or below, try a side + if (!this._fitLeft(anchor, flyout) && + !this._fitRight(anchor, flyout)) { + // Didn't fit left or right either, is top or bottom bigger? + if (this._topHasMoreRoom(anchor)) { + // Top, won't fit, needs scrollbar + this._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; + this._nextHeight = anchor.top - _Overlay._Overlay._keyboardInfo._visibleDocTop - this._nextMarginPadding; + } else { + // Bottom, won't fit, needs scrollbar + this._nextTop = -1; + this._nextHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight - (anchor.bottom - _Overlay._Overlay._keyboardInfo._visibleDocTop) - this._nextMarginPadding; + } + this._centerHorizontally(anchor, flyout, this._currentAlignment); + } else { + this._centerVertically(anchor, flyout); + } + } + break; + default: + // Not a legal this._currentPlacement value + throw new _ErrorFromName("WinJS.UI.Flyout.BadPlacement", strings.badPlacement); + } + + // Remember "bottom" in case we need to consider keyboard later, only tested for top-pinned bars + this._nextBottom = this._nextTop + flyout.height; + }, + + // If the anchor is centered vertically, would the flyout fit above it? + _sometimesFitsAbove: function Flyout_sometimesFitsAbove(anchor, flyout) { + return ((_Overlay._Overlay._keyboardInfo._visibleDocHeight - anchor.height) / 2) >= flyout.height; + }, + + _topHasMoreRoom: function Flyout_topHasMoreRoom(anchor) { + return anchor.top > _Overlay._Overlay._keyboardInfo._visibleDocHeight - anchor.bottom; + }, + + // See if we can fit in various places, fitting in the main view, + // ignoring viewport changes, like for the IHM. + _fitTop: function Flyout_fitTop(anchor, flyout) { + this._nextTop = anchor.top - flyout.height; + this._nextAnimOffset = { top: "50px", left: "0px", keyframe: "WinJS-showFlyoutTop" }; + return (this._nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && + this._nextTop + flyout.height <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); + }, + + _fitBottom: function Flyout_fitBottom(anchor, flyout) { + this._nextTop = anchor.bottom; + this._nextAnimOffset = { top: "-50px", left: "0px", keyframe: "WinJS-showFlyoutBottom" }; + return (this._nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && + this._nextTop + flyout.height <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); + }, + + _fitLeft: function Flyout_fitLeft(anchor, flyout) { + this._nextLeft = anchor.left - flyout.width; + this._nextAnimOffset = { top: "0px", left: "50px", keyframe: "WinJS-showFlyoutLeft" }; + return (this._nextLeft >= 0 && this._nextLeft + flyout.width <= _Overlay._Overlay._keyboardInfo._visualViewportWidth); + }, + + _fitRight: function Flyout_fitRight(anchor, flyout) { + this._nextLeft = anchor.right; + this._nextAnimOffset = { top: "0px", left: "-50px", keyframe: "WinJS-showFlyoutRight" }; + return (this._nextLeft >= 0 && this._nextLeft + flyout.width <= _Overlay._Overlay._keyboardInfo._visualViewportWidth); + }, + + _centerVertically: function Flyout_centerVertically(anchor, flyout) { + this._nextTop = anchor.top + anchor.height / 2 - flyout.height / 2; + if (this._nextTop < _Overlay._Overlay._keyboardInfo._visibleDocTop) { + this._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; + } else if (this._nextTop + flyout.height >= _Overlay._Overlay._keyboardInfo._visibleDocBottom) { + // Flag to put on bottom + this._nextTop = -1; + } + }, + + _centerHorizontally: function Flyout_centerHorizontally(anchor, flyout, alignment) { + if (alignment === "center") { + this._nextLeft = anchor.left + anchor.width / 2 - flyout.width / 2; + } else if (alignment === "left") { + this._nextLeft = anchor.left; + } else if (alignment === "right") { + this._nextLeft = anchor.right - flyout.width; + } else { + throw new _ErrorFromName("WinJS.UI.Flyout.BadAlignment", strings.badAlignment); + } + if (this._nextLeft < 0) { + this._nextLeft = 0; + } else if (this._nextLeft + flyout.width >= _Global.document.documentElement.clientWidth) { + // flag to put on right + this._nextLeft = -1; + } + }, + + _updateAdjustments: function Flyout_updateAdjustments(alignment) { + // Move to 0,0 in case it is off screen, so that it lays out at a reasonable size + this._element.style.top = "0px"; + this._element.style.bottom = "auto"; + this._element.style.left = "0px"; + this._element.style.right = "auto"; + + // Scrolling may not be necessary + _ElementUtilities.removeClass(this._element, _Constants.scrollsClass); + if (this._lastMaxHeight !== null) { + this._element.style.maxHeight = this._lastMaxHeight; + this._lastMaxHeight = null; + } + // Alignment + if (alignment === "center") { + _ElementUtilities.removeClass(this._element, "win-leftalign"); + _ElementUtilities.removeClass(this._element, "win-rightalign"); + } else if (alignment === "left") { + _ElementUtilities.addClass(this._element, "win-leftalign"); + _ElementUtilities.removeClass(this._element, "win-rightalign"); + } else if (alignment === "right") { + _ElementUtilities.addClass(this._element, "win-rightalign"); + _ElementUtilities.removeClass(this._element, "win-leftalign"); + } + }, + + _showingKeyboard: function Flyout_showingKeyboard(event) { + if (this.hidden) { + return; + } + + // The only way that we can be showing a keyboard when a flyout is up is because the input was + // in the flyout itself, in which case we'll be moving ourselves. There is no practical way + // for the application to override this as the focused element is in our flyout. + event.ensuredFocusedElementInView = true; + + // See if the keyboard is going to force us to move + this._checkKeyboardFit(); + + if (this._keyboardMovedUs) { + // Pop out immediately, then move to new spot + this._element.style.opacity = 0; + var that = this; + _Global.setTimeout(function () { that._adjustForKeyboard(); that._baseAnimateIn(); }, _Overlay._Overlay._keyboardInfo._animationShowLength); + } + }, + + _resize: function Flyout_resize() { + // If hidden and not busy animating, then nothing to do + if (this.hidden && !this._animating) { + return; + } + + // This should only happen if the IHM is dismissing, + // the only other way is for viewstate changes, which + // would dismiss any flyout. + if (this._needToHandleHidingKeyboard) { + // Hiding keyboard, update our position, giving the anchor a chance to update first. + var that = this; + _BaseUtils._setImmediate(function () { that._findPosition(); }); + this._needToHandleHidingKeyboard = false; + } + }, + + _checkKeyboardFit: function Flyout_checkKeyboardFit() { + // Check for moving to fit keyboard: + // - Too Tall, above top, or below bottom. + var height = _ElementUtilities.getTotalHeight(this._element); + var viewportHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight - this._nextMarginPadding; + if (height > viewportHeight) { + // Too Tall, pin to top with max height + this._keyboardMovedUs = true; + this._scrollTop = 0; + this._keyboardSquishedUs = viewportHeight; + } else if (this._nextTop === -1) { + // Pinned to bottom counts as moved + this._keyboardMovedUs = true; + } else if (this._nextTop < _Overlay._Overlay._keyboardInfo._visibleDocTop) { + // Above the top of the viewport + this._scrollTop = 0; + this._keyboardMovedUs = true; + } else if (this._nextBottom > _Overlay._Overlay._keyboardInfo._visibleDocBottom) { + // Below the bottom of the viewport + this._scrollTop = -1; + this._keyboardMovedUs = true; + } + }, + + _adjustForKeyboard: function Flyout_adjustForKeyboard() { + // Keyboard moved us, update our metrics as needed + if (this._keyboardSquishedUs) { + // Add scrollbar if we didn't already have scrollsClass + if (!this._hasScrolls) { + _ElementUtilities.addClass(this._element, _Constants.scrollsClass); + this._lastMaxHeight = this._element.style.maxHeight; + } + // Adjust height + this._element.style.maxHeight = this._keyboardSquishedUs + "px"; + } + + // Update top/bottom + this._checkScrollPosition(true); + }, + + _hidingKeyboard: function Flyout_hidingKeyboard() { + // If we aren't visible and not animating, or haven't been repositioned, then nothing to do + // We don't know if the keyboard moved the anchor, so _keyboardMovedUs doesn't help here + if (this.hidden && !this._animating) { + return; + } + + // Snap to the final position + // We'll either just reveal the current space or resize the window + if (_Overlay._Overlay._keyboardInfo._isResized) { + // Flag resize that we'll need an updated position + this._needToHandleHidingKeyboard = true; + } else { + // Not resized, update our final position, giving the anchor a chance to update first. + var that = this; + _BaseUtils._setImmediate(function () { that._findPosition(); }); + } + }, + + _checkScrollPosition: function Flyout_checkScrollPosition(showing) { + if (this.hidden && !showing) { + return; + } + + // May need to adjust top by viewport offset + if (this._scrollTop < 0) { + // Need to attach to bottom + this._element.style.bottom = _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset + "px"; + this._element.style.top = "auto"; + } else { + // Normal, attach to top + this._element.style.top = _Overlay._Overlay._keyboardInfo._visibleDocTop + "px"; + this._element.style.bottom = "auto"; + } + }, + + // AppBar flyout animations + _flyoutAnimateIn: function Flyout_flyoutAnimateIn() { + if (this._keyboardMovedUs) { + return this._baseAnimateIn(); + } else { + this._element.style.opacity = 1; + this._element.style.visibility = "visible"; + return Animations.showPopup(this._element, this._nextAnimOffset); + } + }, + + _flyoutAnimateOut: function Flyout_flyoutAnimateOut() { + if (this._keyboardMovedUs) { + return this._baseAnimateOut(); + } else { + this._element.style.opacity = 0; + return Animations.hidePopup(this._element, this._nextAnimOffset); + } + }, + + // Hide all other flyouts besides this one + _hideAllOtherFlyouts: function Flyout_hideAllOtherFlyouts(thisFlyout) { + var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); + for (var i = 0; i < flyouts.length; i++) { + var flyoutControl = flyouts[i].winControl; + if (flyoutControl && !flyoutControl.hidden && (flyoutControl !== thisFlyout)) { + flyoutControl.hide(); + } + } + }, + + // Returns true if there is a flyout in the DOM that is not hidden + _isThereVisibleFlyout: function Flyout_isThereVisibleFlyout() { + var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); + for (var i = 0; i < flyouts.length; i++) { + var flyoutControl = flyouts[i].winControl; + if (flyoutControl && !flyoutControl.hidden) { + return true; + } + } + + return false; + }, + + _handleKeyDown: function Flyout_handleKeyDown(event) { + // Escape closes flyouts but if the user has a text box with an IME candidate + // window open, we want to skip the ESC key event since it is handled by the IME. + // When the IME handles a key it sets event.keyCode === Key.IME for an easy check. + if (event.keyCode === Key.escape && event.keyCode !== Key.IME) { + // Show a focus rect on what we move focus to + event.preventDefault(); + event.stopPropagation(); + this.winControl._keyboardInvoked = true; + this.winControl._hide(); + } else if ((event.keyCode === Key.space || event.keyCode === Key.enter) + && (this === _Global.document.activeElement)) { + event.preventDefault(); + event.stopPropagation(); + this.winControl.hide(); + } else if (event.shiftKey && event.keyCode === Key.tab + && this === _Global.document.activeElement + && !event.altKey && !event.ctrlKey && !event.metaKey) { + event.preventDefault(); + event.stopPropagation(); + this.winControl._focusOnLastFocusableElementOrThis(); + } + }, + + // Create and add a new first div as the first child + _addFirstDiv: function Flyout_addFirstDiv() { + var firstDiv = _Global.document.createElement("div"); + firstDiv.className = _Constants.firstDivClass; + firstDiv.style.display = "inline"; + firstDiv.setAttribute("role", "menuitem"); + firstDiv.setAttribute("aria-hidden", "true"); + + // add to beginning + if (this._element.children[0]) { + this._element.insertBefore(firstDiv, this._element.children[0]); + } else { + this._element.appendChild(firstDiv); + } + + var that = this; + _ElementUtilities._addEventListener(firstDiv, "focusin", function () { that._focusOnLastFocusableElementOrThis(); }, false); + + return firstDiv; + }, + + // Create and add a new final div as the last child + _addFinalDiv: function Flyout_addFinalDiv() { + var finalDiv = _Global.document.createElement("div"); + finalDiv.className = _Constants.finalDivClass; + finalDiv.style.display = "inline"; + finalDiv.setAttribute("role", "menuitem"); + finalDiv.setAttribute("aria-hidden", "true"); + + this._element.appendChild(finalDiv); + var that = this; + _ElementUtilities._addEventListener(finalDiv, "focusin", function () { that._focusOnFirstFocusableElementOrThis(); }, false); + + return finalDiv; + }, + + _writeProfilerMark: function Flyout_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI.Flyout:" + this._id + ":" + text); + } + }); + return Flyout; + }) + }); + +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Glyph Enumeration +/// Segoe +define('WinJS/Controls/AppBar/_Icon',[ + 'exports', + '../../Core/_Base', + '../../Core/_Resources' + ], function appBarIconInit(exports, _Base, _Resources) { + "use strict"; + + var glyphs = ["previous", + "next", + "play", + "pause", + "edit", + "save", + "clear", + "delete", + "remove", + "add", + "cancel", + "accept", + "more", + "redo", + "undo", + "home", + "up", + "forward", + "right", + "back", + "left", + "favorite", + "camera", + "settings", + "video", + "sync", + "download", + "mail", + "find", + "help", + "upload", + "emoji", + "twopage", + "leavechat", + "mailforward", + "clock", + "send", + "crop", + "rotatecamera", + "people", + "closepane", + "openpane", + "world", + "flag", + "previewlink", + "globe", + "trim", + "attachcamera", + "zoomin", + "bookmarks", + "document", + "protecteddocument", + "page", + "bullets", + "comment", + "mail2", + "contactinfo", + "hangup", + "viewall", + "mappin", + "phone", + "videochat", + "switch", + "contact", + "rename", + "pin", + "musicinfo", + "go", + "keyboard", + "dockleft", + "dockright", + "dockbottom", + "remote", + "refresh", + "rotate", + "shuffle", + "list", + "shop", + "selectall", + "orientation", + "import", + "importall", + "browsephotos", + "webcam", + "pictures", + "savelocal", + "caption", + "stop", + "showresults", + "volume", + "repair", + "message", + "page2", + "calendarday", + "calendarweek", + "calendar", + "characters", + "mailreplyall", + "read", + "link", + "accounts", + "showbcc", + "hidebcc", + "cut", + "attach", + "paste", + "filter", + "copy", + "emoji2", + "important", + "mailreply", + "slideshow", + "sort", + "manage", + "allapps", + "disconnectdrive", + "mapdrive", + "newwindow", + "openwith", + "contactpresence", + "priority", + "uploadskydrive", + "gototoday", + "font", + "fontcolor", + "contact2", + "folder", + "audio", + "placeholder", + "view", + "setlockscreen", + "settile", + "cc", + "stopslideshow", + "permissions", + "highlight", + "disableupdates", + "unfavorite", + "unpin", + "openlocal", + "mute", + "italic", + "underline", + "bold", + "movetofolder", + "likedislike", + "dislike", + "like", + "alignright", + "aligncenter", + "alignleft", + "zoom", + "zoomout", + "openfile", + "otheruser", + "admin", + "street", + "map", + "clearselection", + "fontdecrease", + "fontincrease", + "fontsize", + "cellphone", + "reshare", + "tag", + "repeatone", + "repeatall", + "outlinestar", + "solidstar", + "calculator", + "directions", + "target", + "library", + "phonebook", + "memo", + "microphone", + "postupdate", + "backtowindow", + "fullscreen", + "newfolder", + "calendarreply", + "unsyncfolder", + "reporthacked", + "syncfolder", + "blockcontact", + "switchapps", + "addfriend", + "touchpointer", + "gotostart", + "zerobars", + "onebar", + "twobars", + "threebars", + "fourbars", + "scan", + "preview"]; + + // Provide properties to grab resources for each of the icons + /// + /// The AppBarIcon enumeration provides a set of glyphs for use with the AppBarCommand icon property. + /// + var icons = glyphs.reduce(function (fixedIcons, item) { + fixedIcons[item] = { get: function () { return _Resources._getWinJSString("ui/appBarIcons/" + item).value; } }; + return fixedIcons; + }, {}); + + _Base.Namespace._moduleDefine(exports, "WinJS.UI.AppBarIcon", icons); +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// AppBarCommand +/// appbar,appbars,Flyout,Flyouts,onclick,Statics +define('WinJS/Controls/AppBar/_Command',[ + 'exports', + '../../Core/_Global', + '../../Core/_WinRT', + '../../Core/_Base', + '../../Core/_ErrorFromName', + '../../Core/_Resources', + '../../Utilities/_Control', + '../../Utilities/_Dispose', + '../../Utilities/_ElementUtilities', + '../Flyout/_Overlay', + '../Tooltip', + './_Constants', + './_Icon' + ], function appBarCommandInit(exports, _Global, _WinRT, _Base, _ErrorFromName, _Resources, _Control, _Dispose, _ElementUtilities, _Overlay, Tooltip, _Constants, _Icon) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + /// + /// + /// Represents a command to display in an AppBar. + /// + /// + /// + /// + /// ]]> + /// The AppBarCommand control itself. + /// The AppBarCommand's icon box. + /// The AppBarCommand's icon's image formatting. + /// The AppBarCommand's icon's ring. + /// The AppBarCommand's label + /// + /// + /// + AppBarCommand: _Base.Namespace._lazy(function () { + + + function _handleClick(event) { + /*jshint validthis: true */ + var command = this.winControl; + if (command) { + if (command._type === _Constants.typeToggle) { + command.selected = !command.selected; + } else if (command._type === _Constants.typeFlyout && command._flyout) { + var parentAppBar = _Overlay._Overlay._getParentControlUsingClassName(this, _Constants.appBarClass); + var placement = "top"; + if (parentAppBar && parentAppBar.placement === "top") { + placement = "bottom"; + } + var flyout = command._flyout; + // Flyout may not have processAll'd, so this may be a DOM object + if (typeof flyout === "string") { + flyout = _Global.document.getElementById(flyout); + } + if (!flyout.show) { + flyout = flyout.winControl; + } + if (flyout && flyout.show) { + flyout.show(this, placement); + } + } + if (command.onclick) { + command.onclick(event); + } + } + } + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/appBarCommandAriaLabel").value; }, + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get badClick() { return "Invalid argument: The onclick property for an {0} must be a function"; }, + get badDivElement() { return "Invalid argument: For a content command, the element must be null or a div element"; }, + get badHrElement() { return "Invalid argument: For a separator, the element must be null or an hr element"; }, + get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; } + }; + + return _Base.Class.define(function AppBarCommand_ctor(element, options) { + /// + /// + /// Creates a new AppBarCommand control. + /// + /// + /// The DOM element that will host the control. AppBarCommand will create one if null. + /// + /// + /// The set of properties and values to apply to the new AppBarCommand. + /// + /// + /// The new AppBarCommand control. + /// + /// + + // Check to make sure we weren't duplicated + if (element && element.winControl) { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.DuplicateConstruction", strings.duplicateConstruction); + } + + this._disposed = false; + + // Don't blow up if they didn't pass options + if (!options) { + options = {}; + } + + // Need a type before we can create our element + if (!options.type) { + this._type = _Constants.typeButton; + } + + options.section = options.section || _Constants.sectionGlobal; + + // Go ahead and create it, separator and content types look different than buttons + // Don't forget to use passed in element if one was provided. + this._element = element; + + if (options.type === _Constants.typeContent) { + this._createContent(); + } else if (options.type === _Constants.typeSeparator) { + this._createSeparator(); + } else { + // This will also set the icon & label + this._createButton(); + } + _ElementUtilities.addClass(this._element, "win-disposable"); + + // Remember ourselves + this._element.winControl = this; + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.appBarCommandClass); + + if (options.onclick) { + this.onclick = options.onclick; + } + // We want to handle some clicks + options.onclick = _handleClick; + + _Control.setOptions(this, options); + + if (this._type === _Constants.typeToggle && !options.selected) { + this.selected = false; + } + + // Set up pointerdown handler and clean up ARIA if needed + if (this._type !== _Constants.typeSeparator) { + + // Hide the modern focus rect on click or touch + var that = this; + _ElementUtilities._addEventListener(this._element, "pointerdown", function () { _Overlay._Overlay._addHideFocusClass(that._element); }, false); + + // Make sure we have an ARIA role + var role = this._element.getAttribute("role"); + if (role === null || role === "" || role === undefined) { + if (this._type === _Constants.typeToggle) { + role = "menuitemcheckbox"; + } else if (this._type === _Constants.typeContent) { + role = "group"; + } else { + role = "menuitem"; + } + this._element.setAttribute("role", role); + if (this._type === _Constants.typeFlyout) { + this._element.setAttribute("aria-haspopup", true); + } + } + // Label should've been set by label, but if it was missed for some reason: + var label = this._element.getAttribute("aria-label"); + if (label === null || label === "" || label === undefined) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + } + }, { + /// + /// Gets or sets the ID of the AppBarCommand. + /// + id: { + get: function () { + return this._element.id; + }, + + set: function (value) { + // we allow setting first time only. otherwise we ignore it. + if (value && !this._element.id) { + this._element.id = value; + } + } + }, + + /// + /// Gets or sets the type of the AppBarCommand. Possible values are "button", "toggle", "flyout", "content" or "separator". + /// + type: { + get: function () { + return this._type; + }, + set: function (value) { + // we allow setting first time only. otherwise we ignore it. + if (!this._type) { + if (value !== _Constants.typeContent && value !== _Constants.typeFlyout && value !== _Constants.typeToggle && value !== _Constants.typeSeparator) { + this._type = _Constants.typeButton; + } else { + this._type = value; + } + } + } + }, + + /// + /// Gets or sets the label of the AppBarCommand. + /// + label: { + get: function () { + return this._label; + }, + set: function (value) { + this._label = value; + if (this._labelSpan) { + this._labelSpan.textContent = this.label; + } + + // Ensure that we have a tooltip, by updating already-constructed tooltips. Separators won't have these: + if (!this.tooltip && this._tooltipControl) { + this._tooltip = this.label; + this._tooltipControl.innerHTML = this.label; + } + + // Update aria-label + this._element.setAttribute("aria-label", this.label); + + // Check if we need to suppress the tooltip + this._testIdenticalTooltip(); + } + }, + + /// + /// Gets or sets the icon of the AppBarCommand. + /// + icon: { + get: function () { + return this._icon; + }, + set: function (value) { + + this._icon = _Icon[value] || value; + + if (this._imageSpan) { + // If the icon's a single character, presume a glyph + if (this._icon && this._icon.length === 1) { + // Set the glyph + this._imageSpan.textContent = this._icon; + this._imageSpan.style.backgroundImage = ""; + this._imageSpan.style.msHighContrastAdjust = ""; + } else { + // Must be an image, set that + this._imageSpan.textContent = ""; + this._imageSpan.style.backgroundImage = this._icon; + this._imageSpan.style.msHighContrastAdjust = "none"; + } + } + } + }, + + /// + /// Gets or sets the function to invoke when the command is clicked. + /// + onclick: { + get: function () { + return this._onclick; + }, + set: function (value) { + if (value && typeof value !== "function") { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadClick", _Resources._formatString(strings.badClick, "AppBarCommand")); + } + this._onclick = value; + } + }, + + /// + /// For flyout-type AppBarCommands, this property returns the WinJS.UI.Flyout that this command invokes. + /// When setting this property, you may also use the String ID of the flyout to invoke, the DOM object + /// for the flyout, or the WinJS.UI.Flayout object itself. + /// + flyout: { + get: function () { + // Resolve it to the flyout + var flyout = this._flyout; + if (typeof flyout === "string") { + flyout = _Global.document.getElementById(flyout); + } + // If it doesn't have a .element, then we need to getControl on it + if (flyout && !flyout.element) { + flyout = flyout.winControl; + } + + return flyout; + }, + set: function (value) { + // Need to update aria-owns with the new ID. + var id = value; + if (id && typeof id !== "string") { + // Our controls have .element properties + if (id.element) { + id = id.element; + } + // Hope it's a DOM element, get ID from DOM element + if (id) { + if (id.id) { + id = id.id; + } else { + // No id, have to fake one + id.id = _ElementUtilities._uniqueID(id); + id = id.id; + } + } + } + if (typeof id === "string") { + this._element.setAttribute("aria-owns", id); + } + + // Remember it + this._flyout = value; + } + }, + + /// + /// Gets or sets the section that the AppBarCommand is in. Possible values are "selection" and "global". + /// + section: { + get: function () { + return this._section; + }, + set: function (value) { + // we allow settings section only one time + if (!this._section || _WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { + this._setSection(value); + } + } + }, + + /// Gets or sets the tooltip text of the AppBarCommand. + tooltip: { + get: function () { + return this._tooltip; + }, + set: function (value) { + this._tooltip = value; + + // Update already-constructed tooltips. Separators and content commands won't have these: + if (this._tooltipControl) { + this._tooltipControl.innerHTML = this._tooltip; + } + + // Check if we need to suppress the tooltip + this._testIdenticalTooltip(); + } + }, + + /// Set or get the selected state of a toggle button. + selected: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return this._element.getAttribute("aria-checked") === "true"; + }, + set: function (value) { + this._element.setAttribute("aria-checked", value); + } + }, + + /// + element: { + get: function () { + return this._element; + } + }, + + /// + /// Gets or sets a value that indicates whether the AppBarCommand is disabled. A value of true disables the AppBarCommand, and a value of false enables it. + /// + disabled: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return !!this._element.disabled; + }, + set: function (value) { + this._element.disabled = value; + } + }, + + /// + hidden: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return this._element.style.visibility === "hidden"; + }, + set: function (value) { + var appbarControl = _Overlay._Overlay._getParentControlUsingClassName(this._element, _Constants.appBarClass); + if (appbarControl && !appbarControl.hidden) { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.CannotChangeHiddenProperty", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeHiddenProperty, "AppBar")); + } + + if (value === this.hidden) { + // No changes to make. + return; + } + + var style = this._element.style; + + if (value) { + style.visibility = "hidden"; + style.display = "none"; + } else { + style.visibility = ""; + style.display = "inline-block"; + } + if (appbarControl) { + appbarControl._commandsUpdated(); + } + } + }, + + /// + /// Gets or sets the HTMLElement within a "content" type AppBarCommand that should receive focus whenever focus moves via Home or the arrow keys, + /// from the previous AppBarCommand to the this AppBarCommand. Returns the AppBarCommand object's host element by default. + /// + firstElementFocus: { + get: function () { + return this._firstElementFocus || this._lastElementFocus || this._element; + }, + set: function (element) { + // Arguments of null and this.element should treated the same to ensure that this.element is never a tabstop when either focus property has been set. + this._firstElementFocus = (element === this.element) ? null : element; + this._updateTabStop(); + } + }, + + /// + /// Gets or sets the HTMLElement within a "content" type AppBarCommand that should receive focus whenever focus would move, via End or arrow keys, + /// from the next AppBarCommand to this AppBarCommand. Returns this AppBarCommand object's host element by default. + /// + lastElementFocus: { + get: function () { + return this._lastElementFocus || this._firstElementFocus || this._element; + }, + set: function (element) { + // Arguments of null and this.element should treated the same to ensure that this.element is never a tabstop when either focus property has been set. + this._lastElementFocus = (element === this.element) ? null : element; + this._updateTabStop(); + } + }, + + dispose: function () { + /// + /// + /// Disposes this control. + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + + if (this._tooltipControl) { + this._tooltipControl.dispose(); + } + + if (this._type === _Constants.typeContent) { + _Dispose.disposeSubTree(this.element); + } + }, + + addEventListener: function (type, listener, useCapture) { + /// + /// + /// Registers an event handler for the specified event. + /// + /// + /// Required. The name of the event to register. It must be "beforeshow", "beforehide", "aftershow", or "afterhide". + /// + /// Required. The event handler function to associate with this event. + /// + /// Optional. Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + /// + /// + return this._element.addEventListener(type, listener, useCapture); + }, + + removeEventListener: function (type, listener, useCapture) { + /// + /// + /// Removes an event handler that the addEventListener method registered. + /// + /// Required. The name of the event to remove. + /// Required. The event handler function to remove. + /// + /// Optional. Set to true to remove the capturing phase event handler; otherwise, set to false to remove the bubbling phase event handler. + /// + /// + return this._element.removeEventListener(type, listener, useCapture); + }, + + /// Adds an extra CSS class during construction. + extraClass: { + get: function () { + return this._extraClass; + }, + set: function (value) { + if (this._extraClass) { + _ElementUtilities.removeClass(this._element, this._extraClass); + } + this._extraClass = value; + _ElementUtilities.addClass(this._element, this._extraClass); + } + }, + + // Private + _testIdenticalTooltip: function AppBarCommand_testIdenticalToolTip() { + this._hideIfFullSize = (this._label === this._tooltip); + }, + + _createContent: function AppBarCommand_createContent() { + // Make sure there's an element + if (!this._element) { + this._element = _Global.document.createElement("div"); + } else { + // Verify the element was a div + if (this._element.tagName !== "DIV") { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadDivElement", strings.badDivElement); + } + } + + // If a tabIndex isnt set, default to 0; + if (parseInt(this._element.getAttribute("tabIndex"), 10) !== this._element.tabIndex) { + this._element.tabIndex = 0; + } + }, + + _createSeparator: function AppBarCommand_createSeparator() { + // Make sure there's an element + if (!this._element) { + this._element = _Global.document.createElement("hr"); + } else { + // Verify the element was an hr + if (this._element.tagName !== "HR") { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadHrElement", strings.badHrElement); + } + } + }, + + _createButton: function AppBarCommand_createButton() { + // Make sure there's an element + if (!this._element) { + this._element = _Global.document.createElement("button"); + } else { + // Verify the element was a button + if (this._element.tagName !== "BUTTON") { + throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadButtonElement", strings.badButtonElement); + } + // Make sure it has a type="button" + var type = this._element.getAttribute("type"); + if (type === null || type === "" || type === undefined) { + this._element.setAttribute("type", "button"); + } + this._element.innerHTML = ""; + } + + // AppBarCommand buttons need to look like this: + //// + this._element.type = "button"; + this._iconSpan = _Global.document.createElement("span"); + this._iconSpan.setAttribute("aria-hidden", "true"); + this._iconSpan.className = "win-commandicon win-commandring"; + this._iconSpan.tabIndex = -1; + this._element.appendChild(this._iconSpan); + this._imageSpan = _Global.document.createElement("span"); + this._imageSpan.setAttribute("aria-hidden", "true"); + this._imageSpan.className = "win-commandimage"; + this._imageSpan.tabIndex = -1; + this._iconSpan.appendChild(this._imageSpan); + this._labelSpan = _Global.document.createElement("span"); + this._labelSpan.setAttribute("aria-hidden", "true"); + this._labelSpan.className = "win-label"; + this._labelSpan.tabIndex = -1; + this._element.appendChild(this._labelSpan); + // 'win-global' or 'win-selection' are added later by caller. + // Label and icon are added later by caller. + + // Attach a tooltip - Note: we're going to stomp on it's setControl so we don't have to make another DOM element to hang it off of. + // This private _tooltipControl attribute is used by other pieces, changing the name could break them. + this._tooltipControl = new Tooltip.Tooltip(this._element); + var that = this; + this._tooltipControl.addEventListener("beforeopen", function () { + if (that._hideIfFullSize && !_Overlay._Overlay._getParentControlUsingClassName(that._element.parentElement, _Constants.reducedClass)) { + that._tooltipControl.close(); + } + }, false); + }, + + _setSection: function AppBarCommand_setSection(section) { + if (!section) { + section = _Constants.sectionGlobal; + } + if (this._section) { + // Remove the old section class + if (this._section === _Constants.sectionGlobal) { + _ElementUtilities.removeClass(this._element, _Constants.appBarCommandGlobalClass); + } else if (this.section === _Constants.sectionSelection) { + _ElementUtilities.removeClass(this._element, _Constants.appBarCommandSelectionClass); + } + } + // Add the new section class + this._section = section; + if (section === _Constants.sectionGlobal) { + _ElementUtilities.addClass(this._element, _Constants.appBarCommandGlobalClass); + } else if (section === _Constants.sectionSelection) { + _ElementUtilities.addClass(this._element, _Constants.appBarCommandSelectionClass); + } + }, + + _updateTabStop: function AppBarCommand_updateTabStop() { + // Whenever the firstElementFocus or lastElementFocus properties are set for content type AppBarCommands, + // the containing command element is no longer a tabstop. + + if (this._firstElementFocus || this._lastElementFocus) { + this.element.tabIndex = -1; + } else { + this.element.tabIndex = 0; + } + }, + + _isFocusable: function AppBarCommand_isFocusable() { + return (!this.hidden && this._type !== _Constants.typeSeparator && !this.element.disabled && + (this.firstElementFocus.tabIndex >= 0 || this.lastElementFocus.tabIndex >= 0)); + }, + }); + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/AppBar/_Layouts',[ + 'exports', + '../../Core/_Global', + '../../Core/_Base', + '../../Core/_ErrorFromName', + '../../Core/_Resources', + '../../Scheduler', + '../../Utilities/_Control', + '../../Utilities/_Dispose', + '../../Utilities/_ElementUtilities', + './_Command', + './_Constants' +], function appBarLayoutsInit(exports, _Global, _Base, _ErrorFromName, _Resources, Scheduler, _Control, _Dispose, _ElementUtilities, _Command, _Constants) { + "use strict"; + + // AppBar will use this when AppBar.layout property is set to "custom" + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + _AppBarBaseLayout: _Base.Namespace._lazy(function () { + var baseType = _Constants.appBarLayoutCustom; + + var strings = { + get nullCommand() { return "Invalid argument: command must not be null"; } + }; + + var _AppBarBaseLayout = _Base.Class.define(function _AppBarBaseLayout_ctor(appBarEl, options) { + this._disposed = false; + + options = options || {}; + _Control.setOptions(this, options); + + if (appBarEl) { + this.connect(appBarEl); + } + }, { + // Members + className: { + get: function _AppBarBaseLayout_get_className() { + return this._className; + }, + }, + type: { + get: function _AppBarBaseLayout_get_className() { + return this._type || baseType; + }, + }, + commandsInOrder: { + get: function _AppBarBaseLayout_get_commandsInOrder() { + // Gets a DOM ordered Array of the AppBarCommand elements in the AppBar. + var commands = this.appBarEl.querySelectorAll("." + _Constants.appBarCommandClass); + + // Needs to be an array, in case these are getting passed to a new layout. + // The new layout will invoke the AppBar._layoutCommands, and it expects an + // Array. + return Array.prototype.slice.call(commands); + } + }, + connect: function _AppBarBaseLayout_connect(appBarEl) { + if (this.className) { + _ElementUtilities.addClass(appBarEl, this.className); + } + this.appBarEl = appBarEl; + }, + disconnect: function _AppBarBaseLayout_disconnect() { + if (this.className) { + _ElementUtilities.removeClass(this.appBarEl, this.className); + } + this.appBarEl = null; + this.dispose(); + }, + layout: function _AppBarBaseLayout_layout(commands) { + // Append commands to the DOM. + var len = commands.length; + for (var i = 0; i < len; i++) { + var command = this.sanitizeCommand(commands[i]); + this.appBarEl.appendChild(command._element); + } + }, + sanitizeCommand: function _AppBarBaseLayout_sanitizeCommand(command) { + if (!command) { + throw new _ErrorFromName("WinJS.UI.AppBar.NullCommand", strings.nullCommand); + } + // See if it's a command already + command = command.winControl || command; + if (!command._element) { + // Not a command, so assume it is options for the command's constructor. + command = new _Command.AppBarCommand(null, command); + } + // If we were attached somewhere else, detach us + if (command._element.parentElement) { + command._element.parentElement.removeChild(command._element); + } + + return command; + }, + dispose: function _AppBarBaseLayout_dispose() { + this._disposed = true; + }, + disposeChildren: function _AppBarBaseLayout_disposeChildren() { + var appBarFirstDiv = this.appBarEl.querySelectorAll("." + _Constants.firstDivClass); + appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; + var appBarFinalDiv = this.appBarEl.querySelectorAll("." + _Constants.finalDivClass); + appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; + + var children = this.appBarEl.children; + var length = children.length; + for (var i = 0; i < length; i++) { + var element = children[i]; + if (element === appBarFirstDiv || element === appBarFinalDiv) { + continue; + } else { + _Dispose.disposeSubTree(element); + } + } + }, + handleKeyDown: function _AppBarBaseLayout_handleKeyDown() { + // NOP + }, + commandsUpdated: function _AppBarBaseLayout_commandsUpdated() { + // NOP + }, + beginAnimateCommands: function _AppBarBaseLayout_beginAnimateCommands() { + // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. + // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. + // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. + // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. + + // NOP + }, + endAnimateCommands: function _AppBarBaseLayout_endAnimateCommands() { + // NOP + }, + scale: function _AppBarBaseLayout_scale() { + // NOP + }, + resize: function _AppBarBaseLayout_resize() { + // NOP + }, + }); + return _AppBarBaseLayout; + }), + }); + + // AppBar will use this when AppBar.layout property is set to "commands" + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + _AppBarCommandsLayout: _Base.Namespace._lazy(function () { + var layoutClassName = _Constants.commandLayoutClass; + var layoutType = _Constants.appBarLayoutCommands; + + var _AppBarCommandsLayout = _Base.Class.derive(exports._AppBarBaseLayout, function _AppBarCommandsLayout_ctor(appBarEl) { + exports._AppBarBaseLayout.call(this, appBarEl, { _className: layoutClassName, _type: layoutType }); + this._commandLayoutsInit(appBarEl); + }, { + _getWidthOfFullSizeCommands: function _AppBarCommandsLayout_getWidthOfFullSizeCommands(commands) { + // Commands layout puts primary commands and secondary commands into the primary row. + // Return the total width of all visible primary and secondary commands as if they were full-size. + + // Perform any pending measurements on "content" type AppBarCommands. + if (this._needToMeasureNewCommands) { + this._measureContentCommands(); + } + var accumulatedWidth = 0; + var separatorsCount = 0; + var buttonsCount = 0; + + if (!commands) { + // Return the cached full size width of the last known visible commands in the AppBar. + return this._fullSizeWidthOfLastKnownVisibleCommands; + } else { + // Return the width of the specified commands. + var command; + for (var i = 0, len = commands.length; i < len; i++) { + command = commands[i].winControl || commands[i]; + if (command._type === _Constants.typeSeparator) { + separatorsCount++; + } else if (command._type !== _Constants.typeContent) { + // button, toggle, and flyout types all have the same width. + buttonsCount++; + } else { + accumulatedWidth += command._fullSizeWidth; + } + } + } + return accumulatedWidth += (separatorsCount * _Constants.separatorWidth) + (buttonsCount * _Constants.buttonWidth); + }, + _getFocusableCommandsInLogicalOrder: function _AppBarCommandsLayout_getCommandsInLogicalOrder() { + // Function returns an array of all the contained AppBarCommands which are reachable by left/right arrows. + + var selectionCommands = this._secondaryCommands.children, + globalCommands = this._primaryCommands.children, + focusedIndex = -1; + + var getFocusableCommandsHelper = function (commandsInReach) { + var focusableCommands = []; + for (var i = 0, len = commandsInReach.length; i < len; i++) { + var element = commandsInReach[i]; + if (_ElementUtilities.hasClass(element, _Constants.appBarCommandClass) && element.winControl) { + var containsFocus = element.contains(_Global.document.activeElement); + // With the inclusion of content type commands, it may be possible to tab to elements in AppBarCommands that are not reachable by arrow keys. + // Regardless, when an AppBarCommand contains the element with focus, we just include the whole command so that we can determine which + // commands are adjacent to it when looking for the next focus destination. + if (element.winControl._isFocusable() || containsFocus) { + focusableCommands.push(element); + if (containsFocus) { + focusedIndex = focusableCommands.length - 1; + } + } + } + } + return focusableCommands; + }; + + // Determines which set of commands the user could potentially reach through Home, End, and arrow keys. + // All commands in the commands layout AppBar, from left to right are in reach. Selection then Global. + var commandsInReach = Array.prototype.slice.call(selectionCommands).concat(Array.prototype.slice.call(globalCommands)); + + var focusableCommands = getFocusableCommandsHelper(commandsInReach); + focusableCommands.focusedIndex = focusedIndex; + return focusableCommands; + }, + }); + + // Override some our base implementations and expand our API surface with the commandLayoutsMixin object. + _Base.Class.mix(_AppBarCommandsLayout, _commandLayoutsMixin); + return _AppBarCommandsLayout; + }), + }); + + // These are functions and properties that any new command layout would want to share with our existing "commands" layout. + var _commandLayoutsMixin = { + layout: function _commandLayoutsMixin_layout(commands) { + // Insert commands and other layout specific DOM into the AppBar element. + + // Empty our tree. + _ElementUtilities.empty(this._primaryCommands); + _ElementUtilities.empty(this._secondaryCommands); + + // Keep track of the order we receive the commands in. + this._commandsInOriginalOrder = []; + + // Layout commands + for (var i = 0, len = commands.length; i < len; i++) { + var command = this.sanitizeCommand(commands[i]); + + this._commandsInOriginalOrder.push(command.element); + + if ("global" === command.section) { + this._primaryCommands.appendChild(command._element); + } else { + this._secondaryCommands.appendChild(command._element); + } + } + + // Append layout containers to AppBar element. + // Secondary Commands should come first in Tab Order. + this.appBarEl.appendChild(this._secondaryCommands); + this.appBarEl.appendChild(this._primaryCommands); + + + // Need to measure all content commands after they have been added to the AppBar to make sure we allow + // user defined CSS rules based on the ancestor of the content command to take affect. + this._needToMeasureNewCommands = true; + + // In case this is called from the constructor before the AppBar element has been appended to the DOM, + // we schedule the initial scaling of commands, with the expectation that the element will be added + // synchronously, in the same block of code that called the constructor. + Scheduler.schedule(function () { + if (this._needToMeasureNewCommands && !this._disposed) { + this.scale(); + } + }.bind(this), Scheduler.Priority.idle, this, "WinJS._commandLayoutsMixin._scaleNewCommands"); + + }, + commandsInOrder: { + get: function () { + return this._commandsInOriginalOrder.filter(function (command) { + // Make sure the element is still in the AppBar. + return this.appBarEl.contains(command); + }, this); + } + }, + disposeChildren: function _commandLayoutsMixin_disposeChildren() { + _Dispose.disposeSubTree(this._primaryCommands); + _Dispose.disposeSubTree(this._secondaryCommands); + }, + handleKeyDown: function _commandLayoutsMixin_handleKeyDown(event) { + var Key = _ElementUtilities.Key; + + if (_ElementUtilities._matchesSelector(event.target, ".win-interactive, .win-interactive *")) { + return; // Ignore left, right, home & end keys if focused element has win-interactive class. + } + var rtl = _Global.getComputedStyle(this.appBarEl).direction === "rtl"; + var leftKey = rtl ? Key.rightArrow : Key.leftArrow; + var rightKey = rtl ? Key.leftArrow : Key.rightArrow; + + if (event.keyCode === leftKey || event.keyCode === rightKey || event.keyCode === Key.home || event.keyCode === Key.end) { + + var globalCommandHasFocus = this._primaryCommands.contains(_Global.document.activeElement); + var focusableCommands = this._getFocusableCommandsInLogicalOrder(globalCommandHasFocus); + var targetCommand; + + if (focusableCommands.length) { + switch (event.keyCode) { + case leftKey: + // Arrowing past the last command wraps back around to the first command. + var index = Math.max(-1, focusableCommands.focusedIndex - 1) + focusableCommands.length; + targetCommand = focusableCommands[index % focusableCommands.length].winControl.lastElementFocus; + break; + + case rightKey: + // Arrowing previous to the first command wraps back around to the last command. + var index = focusableCommands.focusedIndex + 1 + focusableCommands.length; + targetCommand = focusableCommands[index % focusableCommands.length].winControl.firstElementFocus; + break; + + case Key.home: + var index = 0; + targetCommand = focusableCommands[index].winControl.firstElementFocus; + break; + + case Key.end: + var index = focusableCommands.length - 1; + targetCommand = focusableCommands[index].winControl.lastElementFocus; + break; + } + } + + if (targetCommand) { + targetCommand.focus(); + // Prevent default so that the browser doesn't also evaluate the keydown event on the newly focused element. + event.preventDefault(); + } + } + }, + commandsUpdated: function _commandLayoutsMixin_commandsUpdated(newSetOfVisibleCommands) { + // Whenever new commands are set or existing commands are hiding/showing in the AppBar, this + // function is called to update the cached width measurement of all visible AppBarCommands. + + var visibleCommands = (newSetOfVisibleCommands) ? newSetOfVisibleCommands : this.commandsInOrder.filter(function (command) { + return !command.winControl.hidden; + }); + this._fullSizeWidthOfLastKnownVisibleCommands = this._getWidthOfFullSizeCommands(visibleCommands); + }, + beginAnimateCommands: function _commandLayoutsMixin_beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands) { + // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. + // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. + // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. + // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. + + this._scaleAfterAnimations = false; + + // Determine if the overall width of visible commands in the primary row will be increasing OR decreasing. + var changeInWidth = this._getWidthOfFullSizeCommands(showCommands) - this._getWidthOfFullSizeCommands(hideCommands); + if (changeInWidth > 0) { + // Width of contents is going to increase, update our command counts now, to what they will be after we complete the animations. + var visibleCommandsAfterAnimations = otherVisibleCommands.concat(showCommands); + this.commandsUpdated(visibleCommandsAfterAnimations); + // Make sure we will have enough room to fit everything on a single row. + this.scale(); + } else if (changeInWidth < 0) { + // Width of contents is going to decrease. Once animations are complete, check if + // there is enough available space to make the remaining commands full size. + this._scaleAfterAnimations = true; + } + }, + endAnimateCommands: function _commandLayoutsMixin_endAnimateCommands() { + if (this._scaleAfterAnimations) { + this.commandsUpdated(); + this.scale(); + } + }, + scale: function _commandLayoutsMixin_scale() { + // If the total width of all AppBarCommands in the primary row is greater than the + // width of the AppBar, add the win-reduced class to the AppBar element and all + // AppBarCommands will reduce in size. + + // Measure the width all visible commands in AppBar's primary row, the AppBar's offsetWidth and the AppBar horizontal padding: + var fullSizeWidthOfVisibleContent = this._getWidthOfFullSizeCommands(); + if (this._appBarTotalKnownWidth !== +this._appBarTotalKnownWidth) { + this._appBarTotalKnownWidth = this._scaleHelper(); + } + + if (fullSizeWidthOfVisibleContent <= this._appBarTotalKnownWidth) { + // Full size commands + _ElementUtilities.removeClass(this.appBarEl, _Constants.reducedClass); + } else { + // Reduced size commands + _ElementUtilities.addClass(this.appBarEl, _Constants.reducedClass); + } + }, + resize: function _commandLayoutsMixin_resize() { + if (!this._disposed) { + // Check for horizontal window resizes. + this._appBarTotalKnownWidth = null; + if (!this.appBarEl.winControl.hidden) { + this.scale(); + } + } + }, + disconnect: function _commandLayoutsMixin_disconnect() { + _ElementUtilities.removeClass(this.appBarEl, _Constants.reducedClass); + exports._AppBarBaseLayout.prototype.disconnect.call(this); + }, + _commandLayoutsInit: function _commandLayoutsMixin_commandLayoutsInit() { + // Create layout infrastructure + this._primaryCommands = _Global.document.createElement("DIV"); + this._secondaryCommands = _Global.document.createElement("DIV"); + _ElementUtilities.addClass(this._primaryCommands, _Constants.primaryCommandsClass); + _ElementUtilities.addClass(this._secondaryCommands, _Constants.secondaryCommandsClass); + }, + _scaleHelper: function _commandLayoutsMixin_scaleHelper() { + // This exists as a single line function so that unit tests can + // overwrite it since they can't resize the WWA window. + + // It is expected that AppBar is an immediate child of the and will have 100% width. + // We measure the clientWidth of the documentElement so that we can scale the AppBar lazily + // even while its element is display: 'none' + var extraPadding = this.appBarEl.winControl.closedDisplayMode === "minimal" ? _Constants.appBarInvokeButtonWidth : 0; + return _Global.document.documentElement.clientWidth - extraPadding; + }, + _measureContentCommands: function _commandLayoutsMixin_measureContentCommands() { + // AppBar measures the width of content commands when they are first added + // and then caches that value to avoid additional layouts in the future. + + // Can't measure unless We're in the document body + if (_Global.document.body.contains(this.appBarEl)) { + this._needToMeasureNewCommands = false; + + // Remove the reducedClass from AppBar to ensure fullsize measurements + var hadReducedClass = _ElementUtilities.hasClass(this.appBarEl, _Constants.reducedClass); + _ElementUtilities.removeClass(this.appBarEl, _Constants.reducedClass); + + var hadHiddenClass = _ElementUtilities.hasClass(this.appBarEl, _Constants.hiddenClass); + _ElementUtilities.removeClass(this.appBarEl, _Constants.hiddenClass); + + // Make sure AppBar and children have width dimensions. + var prevAppBarDisplay = this.appBarEl.style.display; + this.appBarEl.style.display = ""; + var prevCommandDisplay; + + var contentElements = this.appBarEl.querySelectorAll("div." + _Constants.appBarCommandClass); + var element; + for (var i = 0, len = contentElements.length; i < len; i++) { + element = contentElements[i]; + if (element.winControl && element.winControl._type === _Constants.typeContent) { + // Make sure command has width dimensions before we measure. + prevCommandDisplay = element.style.display; + element.style.display = ""; + element.winControl._fullSizeWidth = _ElementUtilities.getTotalWidth(element) || 0; + element.style.display = prevCommandDisplay; + } + } + + // Restore state to AppBar. + this.appBarEl.style.display = prevAppBarDisplay; + if (hadReducedClass) { + _ElementUtilities.addClass(this.appBarEl, _Constants.reducedClass); + } + if (hadHiddenClass) { + _ElementUtilities.addClass(this.appBarEl, _Constants.hiddenClass); + } + + this.commandsUpdated(); + } + }, + }; +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// AppBar +/// appbar,appBars,Flyout,Flyouts,iframe,Statics,unfocus,WinJS +define('WinJS/Controls/AppBar',[ + 'exports', + '../Core/_Global', + '../Core/_WinRT', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Resources', + '../Core/_WriteProfilerMark', + '../Animations', + '../Promise', + '../Scheduler', + '../Utilities/_Control', + '../Utilities/_Dispose', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + '../Utilities/_KeyboardBehavior', + './AppBar/_Constants', + './AppBar/_Layouts', + './AppBar/_Command', + './AppBar/_Icon', + './Flyout/_Overlay', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' +], function appBarInit(exports, _Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Resources, _WriteProfilerMark, Animations, Promise, Scheduler, _Control, _Dispose, _ElementUtilities, _Hoverable, _KeyboardBehavior, _Constants, _Layouts, _Command, _Icon, _Overlay) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + /// + /// + /// Represents an application toolbar for display commands. + /// + /// + /// + /// + /// + /// + /// ]]> + /// Raised just before showing the AppBar. + /// Raised immediately after the AppBar is fully shown. + /// Raised just before hiding the AppBar. + /// Raised immediately after the AppBar is fully hidden. + /// The AppBar control itself. + /// Style for a custom layout AppBar. + /// + /// + /// + AppBar: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + // Enum of known constant pixel values for display modes. + var knownVisibleHeights = { + disabled: 0, + none: 0, + hidden: 0, + minimal: 25, + }; + + // Maps each notion of a display modes to the corresponding visible position + var displayModeVisiblePositions = { + disabled: "hidden", + none: "hidden", + hidden: "hidden", + minimal: "minimal", + shown: "shown", + }; + + // Enum of closedDisplayMode constants + var closedDisplayModes = { + none: "none", + minimal: "minimal", + }; + + // Constants shown/hidden states + var appbarShownState = "shown", + appbarHiddenState = "hidden"; + + // Hook into event + var appBarCommandEvent = false; + var edgyHappening = null; + + // Handler for the edgy starting/completed/cancelled events + function _completedEdgy(e) { + // If we had a right click on a flyout, ignore it. + if (_Overlay._Overlay._rightMouseMightEdgy && + e.kind === _WinRT.Windows.UI.Input.EdgeGestureKind.mouse) { + return; + } + if (edgyHappening) { + // Edgy was happening, just skip it + edgyHappening = null; + } else { + // Edgy wasn't happening, so toggle + var keyboardInvoked = e.kind === _WinRT.Windows.UI.Input.EdgeGestureKind.keyboard; + AppBar._toggleAllAppBarsState(keyboardInvoked); + } + } + + function _startingEdgy() { + if (!edgyHappening) { + // Edgy wasn't happening, so toggle & start it + edgyHappening = AppBar._toggleAllAppBarsState(false); + } + } + + function _canceledEdgy() { + // Shouldn't get here unless edgy was happening. + // Undo whatever we were doing. + var bars = _getDynamicBarsForEdgy(); + if (edgyHappening === "showing") { + _Overlay._Overlay._hideAllBars(bars, false); + } else if (edgyHappening === "hiding") { + _Overlay._Overlay._showAllBars(bars, false); + } + edgyHappening = null; + } + + function _allManipulationChanged(event) { + var elements = _Global.document.querySelectorAll("." + _Constants.appBarClass); + if (elements) { + var len = elements.length; + for (var i = 0; i < len; i++) { + var element = elements[i]; + var appbar = element.winControl; + if (appbar && !element.disabled) { + appbar._manipulationChanged(event); + } + } + } + } + + // Get all the non-sticky bars and return them. + // Returns array of AppBar objects. + // The array also has _hidden and/or _shown set if ANY are hidden or shown. + function _getDynamicBarsForEdgy() { + var elements = _Global.document.querySelectorAll("." + _Constants.appBarClass); + var len = elements.length; + var AppBars = []; + AppBars._shown = false; + AppBars._hidden = false; + for (var i = 0; i < len; i++) { + var element = elements[i]; + if (element.disabled) { + // Skip disabled AppBars + continue; + } + var AppBar = element.winControl; + if (AppBar) { + AppBars.push(AppBar); + if (_ElementUtilities.hasClass(AppBar._element, _Constants.hiddenClass) || _ElementUtilities.hasClass(AppBar._element, _Constants.hidingClass)) { + AppBars._hidden = true; + } else { + AppBars._shown = true; + } + } + } + + return AppBars; + } + + // Sets focus to the last AppBar in the provided appBars array with given placement. + // Returns true if focus was set. False otherwise. + function _setFocusToPreviousAppBarHelper(startIndex, appBarPlacement, appBars) { + var appBar; + for (var i = startIndex; i >= 0; i--) { + appBar = appBars[i].winControl; + if (appBar + && appBar.placement === appBarPlacement + && !appBar.hidden + && appBar._focusOnLastFocusableElement + && appBar._focusOnLastFocusableElement()) { + return true; + } + } + return false; + } + + // Sets focus to the last tab stop of the previous AppBar + // AppBar tabbing order: + // 1) Bottom AppBars + // 2) Top AppBars + // DOM order is respected, because an AppBar should not have a defined tabIndex + function _setFocusToPreviousAppBar() { + /*jshint validthis: true */ + var appBars = _Global.document.querySelectorAll("." + _Constants.appBarClass); + if (!appBars.length) { + return; + } + + var thisAppBarIndex = 0; + for (var i = 0; i < appBars.length; i++) { + if (appBars[i] === this.parentElement) { + thisAppBarIndex = i; + break; + } + } + + var appBarControl = this.parentElement.winControl; + if (appBarControl.placement === _Constants.appBarPlacementBottom) { + // Bottom appBar: Focus order: (1)previous bottom appBars (2)top appBars (3)bottom appBars + if (thisAppBarIndex && _setFocusToPreviousAppBarHelper(thisAppBarIndex - 1, _Constants.appBarPlacementBottom, appBars)) { return; } + if (_setFocusToPreviousAppBarHelper(appBars.length - 1, _Constants.appBarPlacementTop, appBars)) { return; } + if (_setFocusToPreviousAppBarHelper(appBars.length - 1, _Constants.appBarPlacementBottom, appBars)) { return; } + } else if (appBarControl.placement === _Constants.appBarPlacementTop) { + // Top appBar: Focus order: (1)previous top appBars (2)bottom appBars (3)top appBars + if (thisAppBarIndex && _setFocusToPreviousAppBarHelper(thisAppBarIndex - 1, _Constants.appBarPlacementTop, appBars)) { return; } + if (_setFocusToPreviousAppBarHelper(appBars.length - 1, _Constants.appBarPlacementBottom, appBars)) { return; } + if (_setFocusToPreviousAppBarHelper(appBars.length - 1, _Constants.appBarPlacementTop, appBars)) { return; } + } + } + + // Sets focus to the first AppBar in the provided appBars array with given placement. + // Returns true if focus was set. False otherwise. + function _setFocusToNextAppBarHelper(startIndex, appBarPlacement, appBars) { + var appBar; + for (var i = startIndex; i < appBars.length; i++) { + appBar = appBars[i].winControl; + if (appBar + && appBar.placement === appBarPlacement + && !appBar.hidden + && appBar._focusOnFirstFocusableElement + && appBar._focusOnFirstFocusableElement()) { + return true; + } + } + return false; + } + + // Sets focus to the first tab stop of the next AppBar + // AppBar tabbing order: + // 1) Bottom AppBars + // 2) Top AppBars + // DOM order is respected, because an AppBar should not have a defined tabIndex + function _setFocusToNextAppBar() { + /*jshint validthis: true */ + var appBars = _Global.document.querySelectorAll("." + _Constants.appBarClass); + + var thisAppBarIndex = 0; + for (var i = 0; i < appBars.length; i++) { + if (appBars[i] === this.parentElement) { + thisAppBarIndex = i; + break; + } + } + + if (this.parentElement.winControl.placement === _Constants.appBarPlacementBottom) { + // Bottom appBar: Focus order: (1)next bottom appBars (2)top appBars (3)bottom appBars + if (_setFocusToNextAppBarHelper(thisAppBarIndex + 1, _Constants.appBarPlacementBottom, appBars)) { return; } + if (_setFocusToNextAppBarHelper(0, _Constants.appBarPlacementTop, appBars)) { return; } + if (_setFocusToNextAppBarHelper(0, _Constants.appBarPlacementBottom, appBars)) { return; } + } else if (this.parentElement.winControl.placement === _Constants.appBarPlacementTop) { + // Top appBar: Focus order: (1)next top appBars (2)bottom appBars (3)top appBars + if (_setFocusToNextAppBarHelper(thisAppBarIndex + 1, _Constants.appBarPlacementTop, appBars)) { return; } + if (_setFocusToNextAppBarHelper(0, _Constants.appBarPlacementBottom, appBars)) { return; } + if (_setFocusToNextAppBarHelper(0, _Constants.appBarPlacementTop, appBars)) { return; } + } + } + + // Updates the firstDiv & finalDiv of all shown AppBars + function _updateAllAppBarsFirstAndFinalDiv() { + var appBars = _Global.document.querySelectorAll("." + _Constants.appBarClass); + var appBar; + for (var i = 0; i < appBars.length; i++) { + appBar = appBars[i].winControl; + if (appBar + && !appBar.hidden + && appBar._updateFirstAndFinalDiv) { + appBar._updateFirstAndFinalDiv(); + } + } + } + + // Returns true if a visible non-sticky (light dismiss) AppBar is found in the document + function _isThereVisibleNonStickyBar() { + var appBars = _Global.document.querySelectorAll("." + _Constants.appBarClass); + for (var i = 0; i < appBars.length; i++) { + var appBarControl = appBars[i].winControl; + if (appBarControl && !appBarControl.sticky && + (!appBarControl.hidden || appBarControl._element.winAnimating === displayModeVisiblePositions.shown)) { + return true; + } + } + return false; + } + + // If the previous focus was not a AppBar or CED, store it in the cache + // (_isAppBarOrChild tests CED for us). + function _checkStorePreviousFocus(focusEvent) { + if (focusEvent.relatedTarget + && focusEvent.relatedTarget.focus + && !_Overlay._Overlay._isAppBarOrChild(focusEvent.relatedTarget)) { + _storePreviousFocus(focusEvent.relatedTarget); + } + } + + // Cache the previous focus information + function _storePreviousFocus(element) { + if (element) { + _Overlay._Overlay._ElementWithFocusPreviousToAppBar = element; + } + } + + // Try to return focus to what had focus before. + // If successfully return focus to a textbox, restore the selection too. + function _restorePreviousFocus() { + _Overlay._Overlay._trySetActive(_Overlay._Overlay._ElementWithFocusPreviousToAppBar); + } + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/appBarAriaLabel").value; }, + get requiresCommands() { return "Invalid argument: commands must not be empty"; }, + get cannotChangePlacementWhenVisible() { return "Invalid argument: The placement property cannot be set when the AppBar is visible, call hide() first"; }, + get badLayout() { return "Invalid argument: The layout property must be 'custom' or 'commands'"; }, + get cannotChangeLayoutWhenVisible() { return "Invalid argument: The layout property cannot be set when the AppBar is visible, call hide() first"; } + }; + + var AppBar = _Base.Class.derive(_Overlay._Overlay, function AppBar_ctor(element, options) { + /// + /// + /// Creates a new AppBar control. + /// + /// + /// The DOM element that will host the control. + /// + /// + /// The set of properties and values to apply to the new AppBar control. + /// + /// + /// The new AppBar control. + /// + /// + + this._initializing = true; + + // Simplify checking later + options = options || {}; + + // Make sure there's an element + this._element = element || _Global.document.createElement("div"); + this._id = this._element.id || _ElementUtilities._uniqueID(this._element); + this._writeProfilerMark("constructor,StartTM"); + + if (!this._element.hasAttribute("tabIndex")) { + this._element.tabIndex = -1; + } + + // Attach our css class. + _ElementUtilities.addClass(this._element, _Constants.appBarClass); + + // Make sure we have an ARIA role + var role = this._element.getAttribute("role"); + if (!role) { + this._element.setAttribute("role", "menubar"); + } + var label = this._element.getAttribute("aria-label"); + if (!label) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + + // Call the _Overlay constructor helper to finish setting up our element. + // Don't pass constructor options, AppBar needs to set those itself specific order. + this._baseOverlayConstructor(this._element); + + // Start off hidden + this._lastPositionVisited = displayModeVisiblePositions.none; + _ElementUtilities.addClass(this._element, _Constants.hiddenClass); + + // validate that if they didn't set commands, but want command + // layout that the HTML only contains commands. Do this first + // so that we don't leave partial AppBars in the DOM. + if (options.layout !== _Constants.appBarLayoutCustom && !options.commands && this._element) { + // Shallow copy object so we can modify it. + options = _BaseUtils._shallowCopy(options); + options.commands = this._verifyCommandsOnly(this._element, "WinJS.UI.AppBarCommand"); + } + + // Add Invoke button. + this._invokeButton = _Global.document.createElement("button"); + this._invokeButton.tabIndex = 0; + this._invokeButton.innerHTML = ""; + _ElementUtilities.addClass(this._invokeButton, _Constants.invokeButtonClass); + this._element.appendChild(this._invokeButton); + var that = this; + _ElementUtilities._addEventListener(this._invokeButton, "pointerdown", function () { _Overlay._Overlay._addHideFocusClass(that._invokeButton); }, false); + this._invokeButton.addEventListener("click", function () { AppBar._toggleAllAppBarsState(_KeyboardBehavior._keyboardSeenLast, that); }, false); + + // Run layout setter immediately. We need to know our layout in order to correctly + // position any commands that may be getting set through the constructor. + this.layout = options.layout || _Constants.appBarLayoutCommands; + delete options.layout; + + // Need to set placement before closedDisplayMode, closedDisplayMode sets our starting position, which is dependant on placement. + this.placement = options.placement || _Constants.appBarPlacementBottom; + this.closedDisplayMode = options.closedDisplayMode || closedDisplayModes.minimal; + + _Control.setOptions(this, options); + + this._initializing = false; + + // Make a click eating div + _Overlay._Overlay._createClickEatingDivAppBar(); + + // Handle key down (esc) and (left & right) + this._element.addEventListener("keydown", this._handleKeyDown.bind(this), false); + + // Attach event handler + if (!appBarCommandEvent) { + // We'll trigger on invoking. Could also have invoked or canceled + // Eventually we may want click up on invoking and drop back on invoked. + // Check for namespace so it'll behave in the designer. + if (_WinRT.Windows.UI.Input.EdgeGesture) { + var commandUI = _WinRT.Windows.UI.Input.EdgeGesture.getForCurrentView(); + commandUI.addEventListener("starting", _startingEdgy); + commandUI.addEventListener("completed", _completedEdgy); + commandUI.addEventListener("canceled", _canceledEdgy); + } + + // Need to know if the IHM is done scrolling + _Global.document.addEventListener("MSManipulationStateChanged", _allManipulationChanged, false); + + appBarCommandEvent = true; + } + + // Make sure _Overlay event handlers are hooked up (this aids light dismiss) + this._addOverlayEventHandlers(false); + + // Need to store what had focus before + _ElementUtilities._addEventListener(this._element, "focusin", function (event) { _checkStorePreviousFocus(event); }, false); + + // Need to hide ourselves if we lose focus + _ElementUtilities._addEventListener(this._element, "focusout", function () { _Overlay._Overlay._hideIfAllAppBarsLostFocus(); }, false); + + + if (this.closedDisplayMode === closedDisplayModes.none && this.layout === _Constants.appBarLayoutCommands) { + // Remove the commands layout AppBar from the layout tree at this point so we don't cause unnecessary layout costs whenever + // the window resizes or when CSS changes are applied to the commands layout AppBar's parent element. + this._element.style.display = "none"; + } + + this._writeProfilerMark("constructor,StopTM"); + + return this; + }, { + // Public Properties + + /// The placement of the AppBar on the display. Values are "top" or "bottom". + placement: { + get: function AppBar_get_placement() { + return this._placement; + }, + set: function AppBar_set_placement(value) { + // In designer we may have to move it + var wasShown = false; + if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { + this._hide(); + wasShown = true; + } + + if (!this.hidden) { + throw new _ErrorFromName("WinJS.UI.AppBar.CannotChangePlacementWhenVisible", strings.cannotChangePlacementWhenVisible); + } + + // Set placement, coerce invalid values to 'bottom' + this._placement = (value === _Constants.appBarPlacementTop) ? _Constants.appBarPlacementTop : _Constants.appBarPlacementBottom; + + // Clean up win-top, win-bottom styles + if (this._placement === _Constants.appBarPlacementTop) { + _ElementUtilities.addClass(this._element, _Constants.topClass); + _ElementUtilities.removeClass(this._element, _Constants.bottomClass); + } else if (this._placement === _Constants.appBarPlacementBottom) { + _ElementUtilities.removeClass(this._element, _Constants.topClass); + _ElementUtilities.addClass(this._element, _Constants.bottomClass); + } + + // Show again if we hid ourselves for the designer + if (wasShown) { + this._show(); + } + } + }, + + /// + /// Gets or sets the layout of the AppBar contents to either "commands" or "custom". + /// + layout: { + get: function AppBar_get_layout() { + return this._layout.type; + }, + set: function (layout) { + if (layout !== _Constants.appBarLayoutCommands && layout !== _Constants.appBarLayoutCustom) { + throw new _ErrorFromName("WinJS.UI.AppBar.BadLayout", strings.badLayout); + } + + // In designer we may have to redraw it + var wasShown = false; + if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { + this._hide(); + wasShown = true; + } + + if (!this.hidden) { + throw new _ErrorFromName("WinJS.UI.AppBar.CannotChangeLayoutWhenVisible", strings.cannotChangeLayoutWhenVisible); + } + + var commands; + if (!this._initializing) { + // Gather commands in preparation for hand off to new layout. + // We expect prev layout to return commands in the order they were set in, + // not necessarily the current DOM order the layout is using. + commands = this._layout.commandsInOrder; + this._layout.disconnect(); + } + + // Set layout + if (layout === _Constants.appBarLayoutCommands) { + this._layout = new _Layouts._AppBarCommandsLayout(); + } else { + // Custom layout uses Base AppBar Layout class. + this._layout = new _Layouts._AppBarBaseLayout(); + } + this._layout.connect(this._element); + + if (commands && commands.length) { + // Reset AppBar since layout changed. + this._layoutCommands(commands); + } + this._layout.connect(this._element); + + if (commands && commands.length) { + // Reset AppBar since layout changed. + this._layoutCommands(commands); + } + + // Show again if we hid ourselves for the designer + if (wasShown) { + this._show(); + } + }, + configurable: true + }, + + /// + /// Gets or sets value that indicates whether the AppBar is sticky. + /// This value is true if the AppBar is sticky; otherwise, it's false. + /// + sticky: { + get: function AppBar_get_sticky() { + return this._sticky; + }, + set: function AppBar_set_sticky(value) { + // If it doesn't change, do nothing + if (this._sticky === !!value) { + return; + } + + this._sticky = !!value; + + // Note: caller still has to call .show() if also want it shown. + + // Show or hide the click eating div based on sticky value + if (!this.hidden && this._element.style.visibility === "visible") { + // May have changed sticky state for keyboard navigation + _updateAllAppBarsFirstAndFinalDiv(); + + // Ensure that the click eating div is in the correct state + if (this._sticky) { + if (!_isThereVisibleNonStickyBar()) { + _Overlay._Overlay._hideClickEatingDivAppBar(); + } + } else { + _Overlay._Overlay._showClickEatingDivAppBar(); + + if (this._shouldStealFocus()) { + _storePreviousFocus(_Global.document.activeElement); + this._setFocusToAppBar(); + } + } + } + } + }, + + /// + /// Sets the AppBarCommands in the AppBar. This property accepts an array of AppBarCommand objects. + /// + commands: { + set: function AppBar_set_commands(commands) { + // Fail if trying to set when shown + if (!this.hidden) { + throw new _ErrorFromName("WinJS.UI.AppBar.CannotChangeCommandsWhenVisible", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeCommandsWhenVisible, "AppBar")); + } + + // Dispose old commands before tossing them out. + if (!this._initializing) { + // AppBarCommands defined in markup don't want to be disposed during initialization. + this._disposeChildren(); + } + this._layoutCommands(commands); + } + }, + + _layoutCommands: function AppBar_layoutCommands(commands) { + // Function precondition: AppBar must not be shown. + + // Empties AppBar HTML and repopulates with passed in commands. + _ElementUtilities.empty(this._element); + this._element.appendChild(this._invokeButton); // Keep our Show/Hide button. + + // In case they had only one command to set... + if (!Array.isArray(commands)) { + commands = [commands]; + } + + this._layout.layout(commands); + }, + + /// + /// Gets/Sets how AppBar will display itself while hidden. Values are "none" and "minimal". + /// + closedDisplayMode: { + get: function AppBar_get_closedDisplayMode() { + return this._closedDisplayMode; + }, + set: function AppBar_set_closedDisplayMode(value) { + var oldValue = this._closedDisplayMode; + + if (oldValue !== value) { + if (value === closedDisplayModes.none) { + this._closedDisplayMode = closedDisplayModes.none; + _ElementUtilities.removeClass(this._element, _Constants.minimalClass); + } else { + // Minimal is default fallback. + this._closedDisplayMode = closedDisplayModes.minimal; + _ElementUtilities.addClass(this._element, _Constants.minimalClass); + } + + // The invoke button has changed the amount of available space in the AppBar. Layout might need to scale. + this._layout.resize(); + + if (_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) || _ElementUtilities.hasClass(this._element, _Constants.hidingClass)) { + // If the value is being set while we are not showing, change to our new position. + this._changeVisiblePosition(displayModeVisiblePositions[this._closedDisplayMode]); + } + } + }, + }, + + /// + /// Disable an AppBar, setting or getting the HTML disabled attribute. While disabled, the AppBar is hidden completely, and will not respond to attempts to show it. + /// + disabled: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return !!this._element.disabled; + }, + set: function (disable) { + var disable = !!disable; + if (this.disabled !== disable) { + this._element.disabled = disable; + var toPosition; + if (disable) { + // Disabling. Move to the position mapped to the disabled state. + toPosition = displayModeVisiblePositions.disabled; + } else { + // Enabling. Move to the position mapped to our closedDisplayMode. + toPosition = displayModeVisiblePositions[this.closedDisplayMode]; + } + this._hide(toPosition); + } + }, + }, + + /// + hidden: { + get: function () { + // Returns true if AppBar is 'hidden'. + return _ElementUtilities.hasClass(this._element, _Constants.hiddenClass) || + _ElementUtilities.hasClass(this._element, _Constants.hidingClass) || + this._doNext === displayModeVisiblePositions.minimal || + this._doNext === displayModeVisiblePositions.none; + }, + }, + + getCommandById: function (id) { + /// + /// + /// Retrieves the command with the specified ID from this AppBar. + /// If more than one command is found, this method returns them all. + /// + /// Id of the command to return. + /// + /// The command found, an array of commands if more than one have the same ID, or null if no command is found. + /// + /// + var commands = this.element.querySelectorAll("#" + id); + var newCommands = []; + for (var count = 0, len = commands.length; count < len; count++) { + if (commands[count].winControl) { + newCommands.push(commands[count].winControl); + } + } + + if (newCommands.length === 1) { + return newCommands[0]; + } else if (newCommands.length === 0) { + return null; + } + + return newCommands; + }, + + showCommands: function (commands) { + /// + /// + /// Show the specified commands of the AppBar. + /// + /// + /// An array of the commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. + /// + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.AppBar.RequiresCommands", strings.requiresCommands); + } + + this._showCommands(commands); + }, + + hideCommands: function (commands) { + /// + /// + /// Hides the specified commands of the AppBar. + /// + /// Required. Command or Commands to hide, either String, DOM elements, or WinJS objects. + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.AppBar.RequiresCommands", strings.requiresCommands); + } + + this._hideCommands(commands); + }, + + showOnlyCommands: function (commands) { + /// + /// + /// Show the specified commands, hiding all of the others in the AppBar. + /// + /// + /// An array of the commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. + /// + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.AppBar.RequiresCommands", strings.requiresCommands); + } + + this._showOnlyCommands(commands); + }, + + show: function () { + /// + /// + /// Shows the AppBar, if hidden and not disabled, regardless of other state. + /// + /// + // Just wrap the private one, turning off keyboard invoked flag + this._writeProfilerMark("show,StartTM"); + this._keyboardInvoked = false; + this._doNotFocus = !!this.sticky; + this._show(); + }, + + _show: function AppBar_show() { + + var toPosition = displayModeVisiblePositions.shown; + var showing = null; + + // If we're already shown, we are just going to animate our position, not fire events or manage focus. + if (!this.disabled && (_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) || _ElementUtilities.hasClass(this._element, _Constants.hidingClass))) { + showing = appbarShownState; + } + + this._changeVisiblePosition(toPosition, showing); + + if (showing) { + // Configure shown state for lightdismiss & sticky appbars. + if (!this.sticky) { + // Need click-eating div to be visible ASAP. + _Overlay._Overlay._showClickEatingDivAppBar(); + } + + // Clean up tabbing behavior by making sure first and final divs are correct after showing. + if (!this.sticky && _isThereVisibleNonStickyBar()) { + _updateAllAppBarsFirstAndFinalDiv(); + } else { + this._updateFirstAndFinalDiv(); + } + + // Check if we should steal focus + if (!this._doNotFocus && this._shouldStealFocus()) { + // Store what had focus if nothing currently is stored + if (!_Overlay._Overlay._ElementWithFocusPreviousToAppBar) { + _storePreviousFocus(_Global.document.activeElement); + } + + this._setFocusToAppBar(); + } + } + }, + + hide: function () { + /// + /// + /// Hides the AppBar. + /// + /// + // Just wrap the private one + this._writeProfilerMark("hide,StartTM"); + this._hide(); + }, + + _hide: function AppBar_hide(toPosition) { + + var toPosition = toPosition || displayModeVisiblePositions[this.closedDisplayMode]; + var hiding = null; + + // If were already hidden, we are just going to animate our position, not fire events or manage focus again. + if (!_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) && !_ElementUtilities.hasClass(this._element, _Constants.hidingClass)) { + hiding = appbarHiddenState; + } + + this._changeVisiblePosition(toPosition, hiding); + if (hiding) { + // Determine if there are any AppBars that are shown. + // Set the focus to the next shown AppBar. + // If there are none, set the focus to the control stored in the cache, which + // is what had focus before the AppBars were given focus. + var appBars = _Global.document.querySelectorAll("." + _Constants.appBarClass); + var areOtherAppBars = false; + var areOtherNonStickyAppBars = false; + var i; + for (i = 0; i < appBars.length; i++) { + var appBarControl = appBars[i].winControl; + if (appBarControl && !appBarControl.hidden && (appBarControl !== this)) { + areOtherAppBars = true; + + if (!appBarControl.sticky) { + areOtherNonStickyAppBars = true; + break; + } + } + } + + var settingsFlyouts = _Global.document.querySelectorAll("." + _Constants.settingsFlyoutClass); + var areVisibleSettingsFlyouts = false; + for (i = 0; i < settingsFlyouts.length; i++) { + var settingsFlyoutControl = settingsFlyouts[i].winControl; + if (settingsFlyoutControl && !settingsFlyoutControl.hidden) { + areVisibleSettingsFlyouts = true; + break; + } + } + + if (!areOtherNonStickyAppBars && !areVisibleSettingsFlyouts) { + // Hide the click eating div because there are no other AppBars showing + _Overlay._Overlay._hideClickEatingDivAppBar(); + } + + var that = this; + if (!areOtherAppBars) { + // Set focus to what had focus before showing the AppBar + if (_Overlay._Overlay._ElementWithFocusPreviousToAppBar && + (!_Global.document.activeElement || _Overlay._Overlay._isAppBarOrChild(_Global.document.activeElement))) { + _restorePreviousFocus(); + } + // Always clear the previous focus (to prevent temporary leaking of element) + _Overlay._Overlay._ElementWithFocusPreviousToAppBar = null; + } else if (AppBar._isWithinAppBarOrChild(_Global.document.activeElement, that.element)) { + // Set focus to next visible AppBar in DOM + + var foundCurrentAppBar = false; + for (i = 0; i <= appBars.length; i++) { + if (i === appBars.length) { + i = 0; + } + + var appBar = appBars[i]; + if (appBar === this.element) { + foundCurrentAppBar = true; + } else if (foundCurrentAppBar && !appBar.winControl.hidden) { + appBar.winControl._keyboardInvoked = !!this._keyboardInvoked; + appBar.winControl._setFocusToAppBar(); + break; + } + } + } + + // If we are hiding the last lightDismiss AppBar, + // then we need to update the tabStops of the other AppBars + if (!this.sticky && !_isThereVisibleNonStickyBar()) { + _updateAllAppBarsFirstAndFinalDiv(); + } + + // Reset these values + this._keyboardInvoked = false; + this._doNotFocus = false; + } + }, + + _dispose: function AppBar_dispose() { + _Dispose.disposeSubTree(this.element); + this._layout.dispose(); + this.disabled = true; + + }, + + _disposeChildren: function AppBar_disposeChildren() { + // Be purposeful about what we dispose. + this._layout.disposeChildren(); + }, + + _handleKeyDown: function AppBar_handleKeyDown(event) { + // On Left/Right arrow keys, moves focus to previous/next AppbarCommand element. + // On "Esc" key press hide flyouts and hide light dismiss AppBars. + + // Esc hides light-dismiss AppBars in all layouts but if the user has a text box with an IME + // candidate window open, we want to skip the ESC key event since it is handled by the IME. + // When the IME handles a key it sets event.keyCode === Key.IME for an easy check. + if (event.keyCode === Key.escape && event.keyCode !== Key.IME) { + event.preventDefault(); + event.stopPropagation(); + _Overlay._Overlay._hideAllFlyouts(); + _Overlay._Overlay._hideLightDismissAppBars(null, true); + } + + // If the current active element isn't an intrinsic part of the AppBar, + // Layout might want to handle additional keys. + if (!this._invokeButton.contains(_Global.document.activeElement)) { + this._layout.handleKeyDown(event); + } + }, + + _visiblePixels: { + get: function () { + // Returns object containing pixel height of each visible position + return { + hidden: knownVisibleHeights.hidden, + minimal: knownVisibleHeights.minimal, + // Element can change size as content gets added or removed or if it + // experinces style changes. We have to look this up at run time. + shown: this._element.offsetHeight, + }; + } + }, + + _visiblePosition: { + // Returns string value of our nearest, stationary, visible position. + get: function () { + // If we're animating into a new posistion, return the position we're animating into. + if (this._animating && displayModeVisiblePositions[this._element.winAnimating]) { + return this._element.winAnimating; + } else { + return this._lastPositionVisited; + } + } + }, + + _visible: { + // Returns true if our visible position is not completely hidden, else false. + get: function () { + return (this._visiblePosition !== displayModeVisiblePositions.none); + } + }, + + _changeVisiblePosition: function (toPosition, newState) { + /// + /// + /// Changes the visible position of the AppBar. + /// + /// + /// Name of the visible position we want to move to. + /// + /// + /// Name of the state we are entering. Values can be "showing", "hiding" or null. + /// If the value is null, then we are not changing states, only changing visible position. + /// + /// + + if ((this._visiblePosition === toPosition && !this._keyboardObscured) || + (this.disabled && toPosition !== displayModeVisiblePositions.disabled)) { + // If we want to go where we already are, or we're disabled, return false. + this._afterPositionChange(null); + } else if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard) { + // Only do one thing at a time. If we are already animating, + // or the IHM is animating, schedule this for later. + this._doNext = toPosition; + this._afterPositionChange(null); + } else { + // Begin position changing sequence. + + // Set the animating flag to block any queued position changes until we're done. + this._element.winAnimating = toPosition; + var performAnimation = this._initializing ? false : true; + + // Assume we are animating from the last position visited. + var fromPosition = this._lastPositionVisited; + + // We'll need to measure our element to determine how far we need to animate. + // Make sure we have accurate dimensions. + this._element.style.display = ""; + + // Are we hiding completely, or about to become visible? + var hidingCompletely = (toPosition === displayModeVisiblePositions.hidden); + + if (this._keyboardObscured) { + // We're changing position while covered by the IHM. + if (hidingCompletely) { + // If we're covered by the IHM we already look hidden. + // We can skip our animation and just hide. + performAnimation = false; + } else { + // Some portion of the AppBar should be visible to users after its position changes. + + // Un-obscure ourselves and become visible to the user again. + // Need to animate to our desired position as if we were coming up from behind the keyboard. + fromPosition = displayModeVisiblePositions.hidden; + } + this._keyboardObscured = false; + } + + // Fire "before" event if we are changing state. + if (newState === appbarShownState) { + this._beforeShow(); + } else if (newState === appbarHiddenState) { + this._beforeHide(); + } + + // Position our element into the correct "end of animation" position, + // also accounting for any viewport scrolling or soft keyboard positioning. + this._ensurePosition(); + + this._element.style.opacity = 1; + this._element.style.visibility = "visible"; + + this._animationPromise = (performAnimation) ? this._animatePositionChange(fromPosition, toPosition) : Promise.wrap(); + this._animationPromise.then( + function () { this._afterPositionChange(toPosition, newState); }.bind(this), + function () { this._afterPositionChange(toPosition, newState); }.bind(this) + ); + } + }, + + _afterPositionChange: function AppBar_afterPosiitonChange(newPosition, newState) { + // Defines body of work to perform after changing positions. + if (this._disposed) { + return; + } + + if (newPosition) { + // Clear animation flag and record having visited this position. + this._element.winAnimating = ""; + this._lastPositionVisited = newPosition; + + if (this._doNext === this._lastPositionVisited) { + this._doNext = ""; + } + + if (newPosition === displayModeVisiblePositions.hidden) { + // Make sure animation is finished. + this._element.style.visibility = "hidden"; + this._element.style.display = "none"; + } + + // Clean up animation transforms. + var transformProperty = _BaseUtils._browserStyleEquivalents["transform"].scriptName; + this._element.style[transformProperty] = ""; + + // Fire "after" event if we changed state. + if (newState === appbarShownState) { + this._afterShow(); + } else if (newState === appbarHiddenState) { + this._afterHide(); + } + + // If we had something queued, do that + Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI.AppBar._checkDoNext"); + } + + this._afterPositionChangeCallBack(); + }, + + _afterPositionChangeCallBack: function () { + // Leave this blank for unit tests to overwrite. + }, + + _beforeShow: function AppBar_beforeShow() { + // Each overlay tracks the size of the element for triggering light-dismiss in the window resize handler. + this._cachedDocumentSize = this._cachedDocumentSize || _Overlay._Overlay._sizeOfDocument(); + + // In case their event 'beforeshow' event listener is going to manipulate commands, + // first see if there are any queued command animations we can handle while we're still hidden. + if (this._queuedCommandAnimation) { + this._showAndHideFast(this._queuedToShow, this._queuedToHide); + this._queuedToShow = []; + this._queuedToHide = []; + } + + // Make sure everything fits before showinging + this._layout.scale(); + + _ElementUtilities.removeClass(this._element, _Constants.hiddenClass); + _ElementUtilities.addClass(this._element, _Constants.showingClass); + + // Send our "beforeShow" event + this._sendEvent(_Overlay._Overlay.beforeShow); + }, + + _afterShow: function AppBar_afterShow() { + _ElementUtilities.removeClass(this._element, _Constants.showingClass); + _ElementUtilities.addClass(this._element, _Constants.shownClass); + + // Send our "afterShow" event + this._sendEvent(_Overlay._Overlay.afterShow); + this._writeProfilerMark("show,StopTM"); + }, + + _beforeHide: function AppBar_beforeHide() { + + _ElementUtilities.removeClass(this._element, _Constants.shownClass); + _ElementUtilities.addClass(this._element, _Constants.hidingClass); + + // Send our "beforeHide" event + this._sendEvent(_Overlay._Overlay.beforeHide); + }, + + _afterHide: function AppBar_afterHide() { + + // In case their 'afterhide' event handler is going to manipulate commands, + // first see if there are any queued command animations we can handle now we're hidden. + if (this._queuedCommandAnimation) { + this._showAndHideFast(this._queuedToShow, this._queuedToHide); + this._queuedToShow = []; + this._queuedToHide = []; + } + + _ElementUtilities.removeClass(this._element, _Constants.hidingClass); + _ElementUtilities.addClass(this._element, _Constants.hiddenClass); + + // Send our "afterHide" event + this._sendEvent(_Overlay._Overlay.afterHide); + this._writeProfilerMark("hide,StopTM"); + }, + + _animatePositionChange: function AppBar_animatePositionChange(fromPosition, toPosition) { + // Determines and executes the proper transition between visible positions + + // Get values in terms of pixels to perform animation. + var beginningVisiblePixelHeight = this._visiblePixels[fromPosition], + endingVisiblePixelHeight = this._visiblePixels[toPosition], + distance = Math.abs(endingVisiblePixelHeight - beginningVisiblePixelHeight), + offsetTop = (this._placement === _Constants.appBarPlacementTop) ? -distance : distance; + + // Animate + if (endingVisiblePixelHeight > beginningVisiblePixelHeight) { + var fromOffset = { top: offsetTop + "px", left: "0px" }; + return Animations.showEdgeUI(this._element, fromOffset, { mechanism: "transition" }); + } else { + var toOffset = { top: offsetTop + "px", left: "0px" }; + return Animations.hideEdgeUI(this._element, toOffset, { mechanism: "transition" }); + } + }, + + _checkDoNext: function AppBar_checkDoNext() { + // Do nothing if we're still animating + if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard || this._disposed) { + return; + } + + if (this._doNext === displayModeVisiblePositions.disabled || + this._doNext === displayModeVisiblePositions.hidden || + this._doNext === displayModeVisiblePositions.minimal) { + // Do hide first because animating commands would be easier + this._hide(this._doNext); + this._doNext = ""; + } else if (this._queuedCommandAnimation) { + // Do queued commands before showing if possible + this._showAndHideQueue(); + } else if (this._doNext === displayModeVisiblePositions.shown) { + // Show last so that we don't unnecessarily animate commands + this._show(); + this._doNext = ""; + } + }, + + _isABottomAppBarInTheProcessOfShowing: function AppBar_isABottomAppBarInTheProcessOfShowing() { + var appbars = _Global.document.querySelectorAll("." + _Constants.appBarClass + "." + _Constants.bottomClass); + for (var i = 0; i < appbars.length; i++) { + if (appbars[i].winAnimating === displayModeVisiblePositions.shown) { + return true; + } + } + + return false; + }, + + // Returns true if + // 1) This is a bottom appbar + // 2) No appbar has focus and a bottom appbar is not in the process of showing + // 3) What currently has focus is neither a bottom appbar nor a top appbar + // AND a bottom appbar is not in the process of showing. + // Otherwise Returns false + _shouldStealFocus: function AppBar_shouldStealFocus() { + var activeElementAppBar = _Overlay._Overlay._isAppBarOrChild(_Global.document.activeElement); + if (this._element === activeElementAppBar) { + // This appbar already has focus and we don't want to move focus + // from where it currently is in this appbar. + return false; + } + if (this._placement === _Constants.appBarPlacementBottom) { + // This is a bottom appbar + return true; + } + + var isBottomAppBarShowing = this._isABottomAppBarInTheProcessOfShowing(); + if (!activeElementAppBar) { + // Currently no appbar has focus. + // Return true if a bottom appbar is not in the process of showing. + return !isBottomAppBarShowing; + } + if (!activeElementAppBar.winControl) { + // This should not happen, but if it does we want to make sure + // that an AppBar ends up with focus. + return true; + } + if ((activeElementAppBar.winControl._placement !== _Constants.appBarPlacementBottom) + && (activeElementAppBar.winControl._placement !== _Constants.appBarPlacementTop) + && !isBottomAppBarShowing) { + // What currently has focus is neither a bottom appbar nor a top appbar + // -and- + // a bottom appbar is not in the process of showing. + return true; + } + return false; + }, + + // Set focus to the passed in AppBar + _setFocusToAppBar: function AppBar_setFocusToAppBar() { + if (this._focusOnFirstFocusableElement()) { + // Prevent what is gaining focus from showing that it has focus, + // but only in the non-keyboard scenario. + if (!this._keyboardInvoked) { + _Overlay._Overlay._addHideFocusClass(_Global.document.activeElement); + } + } else { + // No first element, set it to appbar itself + _Overlay._Overlay._trySetActive(this._element); + } + }, + + _commandsUpdated: function AppBar_commandsUpdated() { + // If we are still initializing then we don't have a layout yet so it doesn't need updating. + if (!this._initializing) { + this._layout.commandsUpdated(); + this._layout.scale(); + } + }, + + _beginAnimateCommands: function AppBar_beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands) { + // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. + // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. + // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. + // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. + this._layout.beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands); + }, + + _endAnimateCommands: function AppBar_endAnimateCommands() { + this._layout.endAnimateCommands(); + this._endAnimateCommandsCallBack(); + }, + + _endAnimateCommandsCallBack: function AppBar_endAnimateCommandsCallBack() { + // Leave this blank for unit tests to overwrite. + }, + + // Get the top offset for top appbars. + _getTopOfVisualViewport: function AppBar_getTopOfVisualViewPort() { + return _Overlay._Overlay._keyboardInfo._visibleDocTop; + }, + + // Get the bottom offset for bottom appbars. + _getAdjustedBottom: function AppBar_getAdjustedBottom() { + // Need the distance the IHM moved as well. + return _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset; + }, + + _showingKeyboard: function AppBar_showingKeyboard(event) { + // Remember keyboard showing state. + this._keyboardObscured = false; + this._needToHandleHidingKeyboard = false; + + // If we're already moved, then ignore the whole thing + if (_Overlay._Overlay._keyboardInfo._visible && this._alreadyInPlace()) { + return; + } + + this._needToHandleShowingKeyboard = true; + // If focus is in the appbar, don't cause scrolling. + if (!this.hidden && this._element.contains(_Global.document.activeElement)) { + event.ensuredFocusedElementInView = true; + } + + // Check if appbar moves or if we're ok leaving it obscured instead. + if (this._visible && this._placement !== _Constants.appBarPlacementTop && _Overlay._Overlay._isFlyoutVisible()) { + // Remember that we're obscured + this._keyboardObscured = true; + } else { + // Don't be obscured, clear _scrollHappened flag to give us inference later on when to re-show ourselves. + this._scrollHappened = false; + } + + // Also set timeout regardless, so we can clean up our _keyboardShowing flag. + var that = this; + _Global.setTimeout(function (e) { that._checkKeyboardTimer(e); }, _Overlay._Overlay._keyboardInfo._animationShowLength + _Overlay._Overlay._scrollTimeout); + }, + + _hidingKeyboard: function AppBar_hidingKeyboard() { + // We'll either just reveal the current space under the IHM or restore the window height. + + // We won't be obscured + this._keyboardObscured = false; + this._needToHandleShowingKeyboard = false; + this._needToHandleHidingKeyboard = true; + + // We'll either just reveal the current space or resize the window + if (!_Overlay._Overlay._keyboardInfo._isResized) { + // If we're not completely hidden, only fake hiding under keyboard, or already animating, + // then snap us to our final position. + if (this._visible || this._animating) { + // Not resized, update our final position immediately + this._checkScrollPosition(); + this._element.style.display = ""; + } + this._needToHandleHidingKeyboard = false; + } + // Else resize should clear keyboardHiding. + }, + + _resize: function AppBar_resize(event) { + // If we're hidden by the keyboard, then hide bottom appbar so it doesn't pop up twice when it scrolls + if (this._needToHandleShowingKeyboard) { + // Top is allowed to scroll off the top, but we don't want bottom to peek up when + // scrolled into view since we'll show it ourselves and don't want a stutter effect. + if (this._visible) { + if (this._placement !== _Constants.appBarPlacementTop && !this._keyboardObscured) { + // If viewport doesn't match window, need to vanish momentarily so it doesn't scroll into view, + // however we don't want to toggle the visibility="hidden" hidden flag. + this._element.style.display = "none"; + } + } + // else if we're top we stay, and if there's a flyout, stay obscured by the keyboard. + } else if (this._needToHandleHidingKeyboard) { + this._needToHandleHidingKeyboard = false; + if (this._visible || this._animating) { + // Snap to final position + this._checkScrollPosition(); + this._element.style.display = ""; + } + } + + // Make sure everything still fits. + if (!this._initializing) { + this._layout.resize(event); + } + }, + + _checkKeyboardTimer: function AppBar_checkKeyboardTimer() { + if (!this._scrollHappened) { + this._mayEdgeBackIn(); + } + }, + + _manipulationChanged: function AppBar_manipulationChanged(event) { + // See if we're at the not manipulating state, and we had a scroll happen, + // which is implicitly after the keyboard animated. + if (event.currentState === 0 && this._scrollHappened) { + this._mayEdgeBackIn(); + } + }, + + _mayEdgeBackIn: function AppBar_mayEdgeBackIn() { + // May need to react to IHM being resized event + if (this._needToHandleShowingKeyboard) { + // If not top appbar or viewport isn't still at top, then need to show again + this._needToHandleShowingKeyboard = false; + // If obscured (IHM + flyout showing), it's ok to stay obscured. + // If bottom we have to move, or if top scrolled off screen. + if (!this._keyboardObscured && + (this._placement !== _Constants.appBarPlacementTop || _Overlay._Overlay._keyboardInfo._visibleDocTop !== 0)) { + var toPosition = this._visiblePosition; + this._lastPositionVisited = displayModeVisiblePositions.hidden; + this._changeVisiblePosition(toPosition, false); + } else { + // Ensure any animations dropped during the showing keyboard are caught up. + this._checkDoNext(); + } + } + this._scrollHappened = false; + }, + + _ensurePosition: function AppBar_ensurePosition() { + // Position the AppBar element relative to the top or bottom edge of the visible + // document, based on the the visible position we think we need to be in. + var offSet = this._computePositionOffset(); + this._element.style.bottom = offSet.bottom; + this._element.style.top = offSet.top; + + }, + + _computePositionOffset: function AppBar_computePositionOffset() { + // Calculates and returns top and bottom offsets for the AppBar element, relative to the top or bottom edge of the visible + // document. + var positionOffSet = {}; + + if (this._placement === _Constants.appBarPlacementBottom) { + // If the IHM is open, the bottom of the visual viewport may or may not be obscured + // Use _getAdjustedBottom to account for the IHM if it is covering the bottom edge. + positionOffSet.bottom = this._getAdjustedBottom() + "px"; + positionOffSet.top = ""; + } else if (this._placement === _Constants.appBarPlacementTop) { + positionOffSet.bottom = ""; + positionOffSet.top = this._getTopOfVisualViewport() + "px"; + } + + return positionOffSet; + }, + + _checkScrollPosition: function AppBar_checkScrollPosition() { + // If IHM has appeared, then remember we may come in + if (this._needToHandleShowingKeyboard) { + // Tag that it's OK to edge back in. + this._scrollHappened = true; + return; + } + + // We only need to update if we're not completely hidden. + if (this._visible || this._animating) { + this._ensurePosition(); + // Ensure any animations dropped during the showing keyboard are caught up. + this._checkDoNext(); + } + }, + + _alreadyInPlace: function AppBar_alreadyInPlace() { + // See if we're already where we're supposed to be. + var offSet = this._computePositionOffset(); + return (offSet.top === this._element.style.top && offSet.bottom === this._element.style.bottom); + }, + + // If there is a shown non-sticky AppBar then it sets the firstDiv tabIndex to + // the minimum tabIndex found in the AppBars and finalDiv to the max found. + // Otherwise sets their tabIndex to -1 so they are not tab stops. + _updateFirstAndFinalDiv: function AppBar_updateFirstAndFinalDiv() { + var appBarFirstDiv = this._element.querySelectorAll("." + _Constants.firstDivClass); + appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; + + var appBarFinalDiv = this._element.querySelectorAll("." + _Constants.finalDivClass); + appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; + + // Remove the firstDiv & finalDiv if they are not at the appropriate locations + if (appBarFirstDiv && (this._element.children[0] !== appBarFirstDiv)) { + appBarFirstDiv.parentNode.removeChild(appBarFirstDiv); + appBarFirstDiv = null; + } + if (appBarFinalDiv && (this._element.children[this._element.children.length - 1] !== appBarFinalDiv)) { + appBarFinalDiv.parentNode.removeChild(appBarFinalDiv); + appBarFinalDiv = null; + } + + // Create and add the firstDiv & finalDiv if they don't already exist + if (!appBarFirstDiv) { + // Add a firstDiv that will be the first child of the appBar. + // On focus set focus to the previous appBar. + // The div should only be focusable if there are shown non-sticky AppBars. + appBarFirstDiv = _Global.document.createElement("div"); + // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus + appBarFirstDiv.style.display = "inline"; + appBarFirstDiv.className = _Constants.firstDivClass; + appBarFirstDiv.tabIndex = -1; + appBarFirstDiv.setAttribute("aria-hidden", "true"); + _ElementUtilities._addEventListener(appBarFirstDiv, "focusin", _setFocusToPreviousAppBar, false); + // add to beginning + if (this._element.children[0]) { + this._element.insertBefore(appBarFirstDiv, this._element.children[0]); + } else { + this._element.appendChild(appBarFirstDiv); + } + } + if (!appBarFinalDiv) { + // Add a finalDiv that will be the last child of the appBar. + // On focus set focus to the next appBar. + // The div should only be focusable if there are shown non-sticky AppBars. + appBarFinalDiv = _Global.document.createElement("div"); + // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus + appBarFinalDiv.style.display = "inline"; + appBarFinalDiv.className = _Constants.finalDivClass; + appBarFinalDiv.tabIndex = -1; + appBarFinalDiv.setAttribute("aria-hidden", "true"); + _ElementUtilities._addEventListener(appBarFinalDiv, "focusin", _setFocusToNextAppBar, false); + this._element.appendChild(appBarFinalDiv); + } + + + // invokeButton should be the second to last element in the AppBar's tab order. Second to the finalDiv. + if (this._element.children[this._element.children.length - 2] !== this._invokeButton) { + this._element.insertBefore(this._invokeButton, appBarFinalDiv); + } + var elms = this._element.getElementsByTagName("*"); + var highestTabIndex = _ElementUtilities._getHighestTabIndexInList(elms); + this._invokeButton.tabIndex = highestTabIndex; + + // Update the tabIndex of the firstDiv & finalDiv + if (_isThereVisibleNonStickyBar()) { + + if (appBarFirstDiv) { + appBarFirstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(elms); + } + if (appBarFinalDiv) { + appBarFinalDiv.tabIndex = highestTabIndex; + } + } else { + if (appBarFirstDiv) { + appBarFirstDiv.tabIndex = -1; + } + if (appBarFinalDiv) { + appBarFinalDiv.tabIndex = -1; + } + } + }, + + _writeProfilerMark: function AppBar_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI.AppBar:" + this._id + ":" + text); + } + }, { + // Statics + _appBarsSynchronizationPromise: Promise.as(), + + // Returns true if the element or what had focus before the element (if a Flyout) is either: + // 1) the appBar or subtree + // 2) OR in a flyout spawned by the appBar + // Returns false otherwise. + _isWithinAppBarOrChild: function (element, appBar) { + if (!element || !appBar) { + return false; + } + if (appBar.contains(element)) { + return true; + } + var flyout = _Overlay._Overlay._getParentControlUsingClassName(element, _Constants.flyoutClass); + return (flyout && appBar.contains(flyout._previousFocus)); + }, + + // Callback for AppBar invokeButton and Edgy Event Command + _toggleAllAppBarsState: function (keyboardInvoked, sourceAppBar) { + var bars = _getDynamicBarsForEdgy(); + + var hiding; + if (sourceAppBar) { + // If the sourceAppBar is shown, hide all AppBars, else show all AppBars. + hiding = _ElementUtilities.hasClass(sourceAppBar._element, _Constants.showingClass) || _ElementUtilities.hasClass(sourceAppBar._element, _Constants.shownClass); + } else { + // EDGY event behavior. No sourceAppBar specified. + // If every AppBar is shown, hide them. Otherwise show them all. + hiding = bars._shown && !bars._hidden; + } + + if (hiding) { + AppBar._appBarsSynchronizationPromise = AppBar._appBarsSynchronizationPromise.then(function () { + return _Overlay._Overlay._hideAllBars(bars, keyboardInvoked); + }); + return "hiding"; + } else { + AppBar._appBarsSynchronizationPromise = AppBar._appBarsSynchronizationPromise.then(function () { + return _Overlay._Overlay._showAllBars(bars, keyboardInvoked); + }); + return "showing"; + } + }, + }); + + return AppBar; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Menu Command +/// appbar,appbars,Flyout,Flyouts,onclick,Statics +define('WinJS/Controls/Menu/_Command',[ + 'exports', + '../../Core/_Global', + '../../Core/_Base', + '../../Core/_ErrorFromName', + '../../Core/_Resources', + '../../Utilities/_Control', + '../../Utilities/_ElementUtilities', + '../AppBar/_Constants', + '../Flyout/_Overlay' + ], function menuCommandInit(exports, _Global, _Base, _ErrorFromName, _Resources, _Control, _ElementUtilities, _Constants, _Overlay) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + /// + /// + /// Represents a command to be displayed in a Menu. MenuCommand objects provide button, toggle button, flyout button, + /// or separator functionality for Menu controls. + /// + /// + /// + /// + /// + /// ]]> + /// The MenuCommand control itself + /// + /// + /// + MenuCommand: _Base.Namespace._lazy(function () { + + function _handleMenuClick(event) { + /*jshint validthis: true */ + var command = this.winControl; + if (command) { + var hideParent = true; + if (command._type === _Constants.typeToggle) { + command.selected = !command.selected; + } else if (command._type === _Constants.typeFlyout && command._flyout) { + var flyout = command._flyout; + // Flyout may not have processAll'd, so this may be a DOM object + if (typeof flyout === "string") { + flyout = _Global.document.getElementById(flyout); + } + if (!flyout.show) { + flyout = flyout.winControl; + } + if (flyout && flyout.show) { + if (command._parentFlyout) { + hideParent = false; + flyout.show(command._parentFlyout._currentAnchor, command._parentFlyout._currentPlacement, command._parentFlyout._currentAlignment); + } else { + flyout.show(this); + } + } + } + if (command.onclick) { + command.onclick(event); + } + // Dismiss parent flyout + if (hideParent && command._parentFlyout) { + command._parentFlyout.hide(); + } + } + } + + function _handleMouseOver() { + /*jshint validthis: true */ + if (this && this.focus) { + this.focus(); + + this.addEventListener("mousemove", _handleMouseMove, false); + } + } + + function _handleMouseMove() { + /*jshint validthis: true */ + if (this && this.focus && this !== _Global.document.activeElement) { + this.focus(); + } + } + + function _handleMouseOut() { + /*jshint validthis: true */ + var that = this; + var parentFlyout = _getParentFlyout(that); + if (parentFlyout + && this === _Global.document.activeElement + && _ElementUtilities.hasClass(parentFlyout, _Constants.menuClass) + && parentFlyout.focus) { + // Menu gives focus to the menu itself + parentFlyout.focus(); + } else if (parentFlyout + && this === _Global.document.activeElement + && parentFlyout.children + && parentFlyout.children.length > 0 + && parentFlyout.children[0] + && _ElementUtilities.hasClass(parentFlyout.children[0], _Constants.firstDivClass) + && parentFlyout.children[0].focus) { + // Flyout gives focus to firstDiv + parentFlyout.children[0].focus(); + } + + this.removeEventListener("mousemove", _handleMouseMove, false); + } + + function _getParentFlyout(element) { + while (element && !_ElementUtilities.hasClass(element, _Constants.flyoutClass)) { + element = element.parentElement; + } + + return element; + } + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/menuCommandAriaLabel").value; }, + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get badClick() { return "Invalid argument: The onclick property for an {0} must be a function"; }, + get badHrElement() { return "Invalid argument: For a separator, the element must be null or an hr element"; }, + get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; } + }; + + return _Base.Class.define(function MenuCommand_ctor(element, options) { + /// + /// + /// Creates a new MenuCommand object. + /// + /// + /// The DOM element that will host the control. + /// + /// + /// The set of properties and values to apply to the new MenuCommand. + /// + /// + /// A MenuCommand control. + /// + /// + /// + + // Check to make sure we weren't duplicated + if (element && element.winControl) { + throw new _ErrorFromName("WinJS.UI.MenuCommand.DuplicateConstruction", strings.duplicateConstruction); + } + + this._disposed = false; + + // Don't blow up if they didn't pass options + if (!options) { + options = {}; + } + + // Need a type before we can create our element + if (!options.type) { + this._type = _Constants.typeButton; + } + + // Go ahead and create it, separator types look different than buttons + // Don't forget to use passed in element if one was provided. + this._element = element; + if (options.type === _Constants.typeSeparator) { + this._createSeparator(); + } else { + // This will also set the icon & label + this._createButton(); + } + _ElementUtilities.addClass(this._element, "win-disposable"); + + // Remember ourselves + this._element.winControl = this; + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.menuCommandClass); + + if (!options.selected && options.type === _Constants.typeToggle) { + // Make sure toggle's have selected false for CSS + this.selected = false; + } + if (options.onclick) { + this.onclick = options.onclick; + } + options.onclick = _handleMenuClick; + + _Control.setOptions(this, options); + + // Set our options + if (this._type !== _Constants.typeSeparator) { + // Make sure we have an ARIA role + var role = this._element.getAttribute("role"); + if (role === null || role === "" || role === undefined) { + role = "menuitem"; + if (this._type === _Constants.typeToggle) { + role = "menuitemcheckbox"; + } + this._element.setAttribute("role", role); + if (this._type === _Constants.typeFlyout) { + this._element.setAttribute("aria-haspopup", true); + } + } + var label = this._element.getAttribute("aria-label"); + if (label === null || label === "" || label === undefined) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + } + + this._element.addEventListener("mouseover", _handleMouseOver, false); + this._element.addEventListener("mouseout", _handleMouseOut, false); + }, { + /// + /// Gets the ID of the MenuCommand. + /// + /// + id: { + get: function () { + return this._element.id; + }, + set: function (value) { + // we allow setting first time only. otherwise we ignore it. + if (!this._element.id) { + this._element.id = value; + } + } + }, + + /// + /// Gets the type of the MenuCommand. Possible values are "button", "toggle", "flyout", or "separator". + /// + /// + type: { + get: function () { + return this._type; + }, + set: function (value) { + // we allow setting first time only. otherwise we ignore it. + if (!this._type) { + if (value !== _Constants.typeButton && value !== _Constants.typeFlyout && value !== _Constants.typeToggle && value !== _Constants.typeSeparator) { + this._type = _Constants.typeButton; + } else { + this._type = value; + } + } + } + }, + + /// + /// The label of the MenuCommand + /// + /// + label: { + get: function () { + return this._label; + }, + set: function (value) { + this._label = value; + this._element.textContent = this.label; + + // Update aria-label + this._element.setAttribute("aria-label", this.label); + } + }, + + /// + /// Gets or sets the function to invoke when the command is clicked. + /// + /// + onclick: { + get: function () { + return this._onclick; + }, + set: function (value) { + if (value && typeof value !== "function") { + throw new _ErrorFromName("WinJS.UI.MenuCommand.BadClick", _Resources._formatString(strings.badClick, "MenuCommand")); + } + this._onclick = value; + } + }, + + /// + /// For flyout type MenuCommands, this property returns the WinJS.UI.Flyout that this command invokes. When setting this property, you can set + /// it to the string ID of the Flyout, the DOM object that hosts the Flyout, or the Flyout object itself. + /// + /// + flyout: { + get: function () { + // Resolve it to the flyout + var flyout = this._flyout; + if (typeof flyout === "string") { + flyout = _Global.document.getElementById(flyout); + } + // If it doesn't have a .element, then we need to getControl on it + if (flyout && !flyout.element) { + flyout = flyout.winControl; + } + + return flyout; + }, + set: function (value) { + // Need to update aria-owns with the new ID. + var id = value; + if (id && typeof id !== "string") { + // Our controls have .element properties + if (id.element) { + id = id.element; + } + // Hope it's a DOM element, get ID from DOM element + if (id) { + if (id.id) { + id = id.id; + } else { + // No id, have to fake one + id.id = _ElementUtilities._uniqueID(id); + id = id.id; + } + } + } + if (typeof id === "string") { + this._element.setAttribute("aria-owns", id); + } + + // Remember it + this._flyout = value; + } + }, + + /// + /// Gets or sets the selected state of a toggle button. This property is true if the toggle button is selected; otherwise, it's false. + /// + /// + selected: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return this._element.getAttribute("aria-checked") === "true"; + }, + set: function (value) { + this._element.setAttribute("aria-checked", !!value); + } + }, + + /// + element: { + get: function () { + return this._element; + } + }, + + /// + /// Gets or sets a value that indicates whether the MenuCommand is disabled. This value is true if the MenuCommand is disabled; otherwise, false. + /// + /// + disabled: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return !!this._element.disabled; + }, + set: function (value) { + this._element.disabled = !!value; + } + }, + + /// + hidden: { + get: function () { + // Ensure it's a boolean because we're using the DOM element to keep in-sync + return this._element.style.visibility === "hidden"; + }, + set: function (value) { + var menuControl = _Overlay._Overlay._getParentControlUsingClassName(this._element, _Constants.menuClass); + if (menuControl && !menuControl.hidden) { + throw new _ErrorFromName("WinJS.UI.MenuCommand.CannotChangeHiddenProperty", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeHiddenProperty, "Menu")); + } + + var style = this._element.style; + if (value) { + style.visibility = "hidden"; + style.display = "none"; + } else { + style.visibility = ""; + style.display = "block"; + } + } + }, + + /// + /// Gets or sets the extra CSS class that is applied to the host DOM element. + /// + /// + extraClass: { + get: function () { + return this._extraClass; + }, + set: function (value) { + if (this._extraClass) { + _ElementUtilities.removeClass(this._element, this._extraClass); + } + this._extraClass = value; + _ElementUtilities.addClass(this._element, this._extraClass); + } + }, + + + dispose: function () { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + + if (this._flyout) { + this._flyout.dispose(); + } + }, + + addEventListener: function (type, listener, useCapture) { + /// + /// + /// Registers an event handler for the specified event. + /// + /// The name of the event to register. + /// The function that handles the event. + /// + /// Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + /// + /// + /// + return this._element.addEventListener(type, listener, useCapture); + }, + + removeEventListener: function (type, listener, useCapture) { + /// + /// + /// Removes the specified event handler that the addEventListener method registered. + /// + /// The name of the event to remove. + /// The event handler function to remove. + /// + /// Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + /// + /// + /// + return this._element.removeEventListener(type, listener, useCapture); + }, + + // Private properties + _createSeparator: function MenuCommand_createSeparator() { + // Make sure there's an input element + if (!this._element) { + this._element = _Global.document.createElement("hr"); + } else { + // Verify the input was an hr + if (this._element.tagName !== "HR") { + throw new _ErrorFromName("WinJS.UI.MenuCommand.BadHrElement", strings.badHrElement); + } + } + }, + + _createButton: function MenuCommand_createButton() { + // Make sure there's an input element + if (!this._element) { + this._element = _Global.document.createElement("button"); + } else { + // Verify the input was a button + if (this._element.tagName !== "BUTTON") { + throw new _ErrorFromName("WinJS.UI.MenuCommand.BadButtonElement", strings.badButtonElement); + } + this._element.innerHTML = ""; + } + + // MenuCommand buttons need to look like this: + //// + this._element.type = "button"; + + // 'textContent' label is added later by caller + } + }); + }) + }); + +}); + + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Menu +/// Menu,Menus,Flyout,Flyouts,Statics +define('WinJS/Controls/Menu',[ + '../Core/_Global', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Resources', + '../Core/_WriteProfilerMark', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + './AppBar/_Constants', + './Flyout', + './Flyout/_Overlay', + './Menu/_Command', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' + ], function menuInit(_Global,_Base, _BaseUtils, _ErrorFromName, _Resources, _WriteProfilerMark, _ElementUtilities, _Hoverable, _Constants, Flyout, _Overlay, _Command) { + "use strict"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// Represents a menu flyout for displaying commands. + /// + /// + /// Menu + /// + /// + /// + /// + /// ]]> + /// Raised just before showing a menu. + /// Raised immediately after a menu is fully shown. + /// Raised just before hiding a menu. + /// Raised immediately after a menu is fully hidden. + /// The Menu control itself + /// + /// + /// + Menu: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/menuAriaLabel").value; }, + get requiresCommands() { return "Invalid argument: commands must not be empty"; }, + get nullCommand() { return "Invalid argument: command must not be null"; }, + }; + + var Menu = _Base.Class.derive(Flyout.Flyout, function Menu_ctor(element, options) { + /// + /// + /// Creates a new Menu control. + /// + /// + /// The DOM element that will host the control. + /// + /// + /// The set of properties and values to apply to the control. + /// + /// The new Menu control. + /// + /// + + // We need to be built on top of a Flyout, so stomp on the user's input + options = options || {}; + + // Make sure there's an input element + this._element = element || _Global.document.createElement("div"); + this._id = this._element.id || _ElementUtilities._uniqueID(this._element); + this._writeProfilerMark("constructor,StartTM"); + + // validate that if they didn't set commands, in which + // case any HTML only contains commands. Do this first + // so that we don't leave partial Menus in the DOM. + if (!options.commands && this._element) { + // Shallow copy object so we can modify it. + options = _BaseUtils._shallowCopy(options); + options.commands = this._verifyCommandsOnly(this._element, "WinJS.UI.MenuCommand"); + } + + // Remember aria role in case base constructor changes it + var role = this._element ? this._element.getAttribute("role") : null; + var label = this._element ? this._element.getAttribute("aria-label") : null; + + // Call the base overlay constructor helper + this._baseFlyoutConstructor(this._element, options); + + // Make sure we have an ARIA role + if (role === null || role === "" || role === undefined) { + this._element.setAttribute("role", "menu"); + } + if (label === null || label === "" || label === undefined) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + + // Handle "esc" & "up/down" key presses + this._element.addEventListener("keydown", this._handleKeyDown, true); + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.menuClass); + + // Need to set our commands, making sure we're hidden first + this.hide(); + this._writeProfilerMark("constructor,StopTM"); + }, { + // Public Properties + + /// + /// Sets the MenuCommand objects that appear in the Menu. You can set this to a single MenuCommand or an array of MenuCommand objects. + /// + /// + commands: { + set: function (value) { + // Fail if trying to set when visible + if (!this.hidden) { + throw new _ErrorFromName("WinJS.UI.Menu.CannotChangeCommandsWhenVisible", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeCommandsWhenVisible, "Menu")); + } + + // Start from scratch + _ElementUtilities.empty(this._element); + + // In case they had only one... + if (!Array.isArray(value)) { + value = [value]; + } + + // Add commands + var len = value.length; + for (var i = 0; i < len; i++) { + this._addCommand(value[i]); + } + } + }, + + getCommandById: function (id) { + /// + /// + /// Retrieve the command with the specified ID from this Menu. If more than one command is found, all are returned. + /// + /// The ID of the command to find. + /// + /// The command found, an array of commands if more than one have the same ID, or null if no command is found. + /// + /// + /// + var commands = this.element.querySelectorAll("#" + id); + var newCommands = []; + for (var count = 0, len = commands.length; count < len; count++) { + if (commands[count].winControl) { + newCommands.push(commands[count].winControl); + } + } + + if (newCommands.length === 1) { + return newCommands[0]; + } else if (newCommands.length === 0) { + return null; + } + + return newCommands; + }, + + + showCommands: function (commands) { + /// + /// + /// Shows the specified commands of the Menu. + /// + /// + /// The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. + /// + /// + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); + } + + this._showCommands(commands, true); + }, + + hideCommands: function (commands) { + /// + /// + /// Hides the Menu. + /// + /// + /// Required. Command or Commands to hide, either String, DOM elements, or WinJS objects. + /// + /// + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); + } + + this._hideCommands(commands, true); + }, + + showOnlyCommands: function (commands) { + /// + /// + /// Shows the specified commands of the Menu while hiding all other commands. + /// + /// + /// The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. + /// + /// + /// + if (!commands) { + throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); + } + + this._showOnlyCommands(commands, true); + }, + + show: function (anchor, placement, alignment) { + /// + /// + /// Shows the Menu, if hidden, regardless of other states. + /// + /// + /// The DOM element, or ID of a DOM element, to anchor the Menu. This parameter overrides the anchor property for this method call only. + /// + /// + /// The placement of the Menu to the anchor: 'auto' (default), 'top', 'bottom', 'left', or 'right'. This parameter overrides the placement + /// property for this method call only. + /// + /// + /// For 'top' or 'bottom' placement, the alignment of the Menu to the anchor's edge: 'center' (default), 'left', or 'right'. This parameter + /// overrides the alignment property for this method call only. + /// + /// + /// + // Just call private version to make appbar flags happy + this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). + this._show(anchor, placement, alignment); + }, + + _show: function Menu_show(anchor, placement, alignment) { + // Before we show, we also need to check for children flyouts needing anchors + this._checkForFlyoutCommands(); + + // Call flyout show + this._baseFlyoutShow(anchor, placement, alignment); + + // We need to check for toggles after we send the beforeshow event, + // so the developer has a chance to show or hide more commands. + // Flyout's _findPosition will make that call. + }, + + _addCommand: function Menu_addCommand(command) { + if (!command) { + throw new _ErrorFromName("WinJS.UI.Menu.NullCommand", strings.nullCommand); + } + // See if it's a command already + if (!command._element) { + // Not a command, so assume it's options for a command + command = new _Command.MenuCommand(null, command); + } + // If we were attached somewhere else, detach us + if (command._element.parentElement) { + command._element.parentElement.removeChild(command._element); + } + + // Reattach us + this._element.appendChild(command._element); + }, + + // Called by flyout's _findPosition so that application can update it status + // we do the test and we can then fix this last-minute before showing. + _checkToggle: function Menu_checkToggle() { + var toggles = this._element.querySelectorAll(".win-command[aria-checked]"); + var hasToggle = false; + if (toggles) { + for (var i = 0; i < toggles.length; i++) { + if (toggles[i] && toggles[i].winControl && !toggles[i].winControl.hidden) { + // Found a visible toggle control + hasToggle = true; + break; + } + } + } + if (hasToggle) { + _ElementUtilities.addClass(this._element, _Constants.menuToggleClass); + } else { + _ElementUtilities.removeClass(this._element, _Constants.menuToggleClass); + } + }, + + _checkForFlyoutCommands: function Menu_checkForFlyoutCommands() { + var commands = this._element.querySelectorAll(".win-command"); + for (var count = 0; count < commands.length; count++) { + if (commands[count].winControl) { + // Remember our anchor in case it's a flyout + commands[count].winControl._parentFlyout = this; + } + } + }, + + _handleKeyDown: function Menu_handleKeyDown(event) { + var that = this; + if (event.keyCode === Key.escape) { + // Show a focus rect on what we move focus to + this.winControl._keyboardInvoked = true; + this.winControl._hide(); + } else if ((event.keyCode === Key.space || event.keyCode === Key.enter) + && (this === _Global.document.activeElement)) { + event.preventDefault(); + this.winControl.hide(); + } else if (event.keyCode === Key.upArrow) { + Menu._focusOnPreviousElement(that); + + // Prevent the page from scrolling + event.preventDefault(); + } else if (event.keyCode === Key.downArrow) { + Menu._focusOnNextElement(that); + + // Prevent the page from scrolling + event.preventDefault(); + } else if (event.keyCode === Key.tab) { + event.preventDefault(); + } + }, + + _writeProfilerMark: function Menu_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI.Menu:" + this._id + ":" + text); + } + }); + + // Statics + + // Set focus to next focusable element in the menu (loop if necessary). + // Note: The loop works by first setting focus to the menu itself. If the menu is + // what had focus before, then we break. Otherwise we try the first child next. + // Focus remains on the menu if nothing is focusable. + Menu._focusOnNextElement = function (menu) { + var _currentElement = _Global.document.activeElement; + + do { + if (_currentElement === menu) { + _currentElement = _currentElement.firstElementChild; + } else { + _currentElement = _currentElement.nextElementSibling; + } + + if (_currentElement) { + _currentElement.focus(); + } else { + _currentElement = menu; + } + + } while (_currentElement !== _Global.document.activeElement); + }; + + // Set focus to previous focusable element in the menu (loop if necessary). + // Note: The loop works by first setting focus to the menu itself. If the menu is + // what had focus before, then we break. Otherwise we try the last child next. + // Focus remains on the menu if nothing is focusable. + Menu._focusOnPreviousElement = function (menu) { + var _currentElement = _Global.document.activeElement; + + do { + if (_currentElement === menu) { + _currentElement = _currentElement.lastElementChild; + } else { + _currentElement = _currentElement.previousElementSibling; + } + + if (_currentElement) { + _currentElement.focus(); + } else { + _currentElement = menu; + } + + } while (_currentElement !== _Global.document.activeElement); + }; + + return Menu; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/SearchBox/_SearchSuggestionManagerShim',[ + 'exports', + '../../_Signal', + '../../Core/_Base', + '../../Core/_BaseUtils', + '../../Core/_Events', + '../../BindingList', +], function SearchSuggestionManagerShimInit(exports, _Signal, _Base, _BaseUtils, _Events, BindingList) { + "use strict"; + + var CollectionChange = { + reset: 0, + itemInserted: 1, + itemRemoved: 2, + itemChanged: 3 + }; + var SearchSuggestionKind = { + Query: 0, + Result: 1, + Separator: 2 + }; + + var SuggestionVectorShim = _Base.Class.derive(Array, function SuggestionVectorShim_ctor() { + }, { + reset: function () { + this.length = 0; + this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.reset, index: 0 }); + }, + + insert: function (index, data) { + this.splice(index, 0, data); + this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.itemInserted, index: index }); + }, + + remove: function (index) { + this.splice(index, 1); + this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.itemRemoved, index: index }); + }, + }); + _Base.Class.mix(SuggestionVectorShim, _Events.eventMixin); + + var SearchSuggestionCollectionShim = _Base.Class.define(function SearchSuggestionCollectionShim_ctor() { + this._data = []; + }, { + size: { + get: function () { + return this._data.length; + } + }, + + appendQuerySuggestion: function (text) { + this._data.push({ kind: SearchSuggestionKind.Query, text: text }); + }, + appendQuerySuggestions: function (suggestions) { + suggestions.forEach(this.appendQuerySuggestion.bind(this)); + }, + appendResultSuggestion: function (text, detailText, tag, imageUrl, imageAlternateText) { + // 'image' must be null (not undefined) for SearchBox to fallback to use imageUrl instead + this._data.push({ kind: SearchSuggestionKind.Result, text: text, detailText: detailText, tag: tag, imageUrl: imageUrl, imageAlternateText: imageAlternateText, image: null }); + }, + appendSearchSeparator: function (label) { + this._data.push({ kind: SearchSuggestionKind.Separator, text: label }); + } + }); + + var SuggestionsRequestedEventArgShim = _Base.Class.define(function SuggestionsRequestedEventArgShim_ctor(queryText, language, linguisticDetails) { + this._queryText = queryText; + this._language = language; + this._linguisticDetails = linguisticDetails; + this._searchSuggestionCollection = new SearchSuggestionCollectionShim(); + }, { + language: { + get: function () { + return this._language; + } + }, + linguisticDetails: { + get: function () { + return this._linguisticDetails; + } + }, + queryText: { + get: function () { + return this._queryText; + } + }, + searchSuggestionCollection: { + get: function () { + return this._searchSuggestionCollection; + } + }, + getDeferral: function () { + return this._deferralSignal || (this._deferralSignal = new _Signal()); + }, + + _deferralSignal: null, + }); + + var SearchSuggestionManagerShim = _Base.Class.define(function SearchSuggestionManagerShim_ctor() { + this._updateVector = this._updateVector.bind(this); + + this._suggestionVector = new SuggestionVectorShim(); + this._query = ""; + this._history = { "": [] }; + + this._dataSource = []; + + this.searchHistoryContext = ""; + this.searchHistoryEnabled = true; + }, { + addToHistory: function (queryText /*, language */) { + if (!queryText || !queryText.trim()) { + return; + } + + var history = this._history[this.searchHistoryContext]; + var dupeIndex = -1; + for (var i = 0, l = history.length; i < l; i++) { + var item = history[i]; + if (item.text.toLowerCase() === queryText.toLowerCase()) { + dupeIndex = i; + break; + } + } + if (dupeIndex >= 0) { + history.splice(dupeIndex, 1); + } + + history.splice(0, 0, { text: queryText, kind: SearchSuggestionKind.Query }); + this._updateVector(); + }, + + clearHistory: function () { + this._history[this.searchHistoryContext] = []; + this._updateVector(); + }, + + setLocalContentSuggestionSettings: function (settings) { + }, + + setQuery: function (queryText) { + var that = this; + function update(arr) { + that._dataSource = arr; + that._updateVector(); + } + + this._query = queryText; + var arg = new SuggestionsRequestedEventArgShim(queryText); + this.dispatchEvent("suggestionsrequested", { request: arg }); + if (arg._deferralSignal) { + arg._deferralSignal.promise.then(update.bind(this, arg.searchSuggestionCollection._data)); + } else { + update(arg.searchSuggestionCollection._data); + } + }, + + searchHistoryContext: { + get: function () { + return "" + this._searchHistoryContext; + }, + set: function (value) { + value = "" + value; + if (!this._history[value]) { + this._history[value] = []; + } + this._searchHistoryContext = value; + } + }, + + searchHistoryEnabled: { + get: function () { + return this._searchHistoryEnabled; + }, + set: function (value) { + this._searchHistoryEnabled = value; + } + }, + + suggestions: { + get: function () { + return this._suggestionVector; + } + }, + + _updateVector: function () { + // Can never clear the entire suggestions list or it will cause a visual flash because + // the SearchBox control removes the suggestions list UI when the SSM fires vectorChanged + // with size === 0, then re-renders it when the first suggestion is added. + // Workaround is to insert a dummy entry, remove all old entries, add the new set of + // eligible suggestions, then remove the dummy entry. + this.suggestions.insert(this.suggestions.length, { text: "", kind: SearchSuggestionKind.Query }); + + while (this.suggestions.length > 1) { + this.suggestions.remove(0); + } + + var index = 0; + var added = {}; + if (this.searchHistoryEnabled) { + var q = this._query.toLowerCase(); + this._history[this.searchHistoryContext].forEach(function (item) { + var text = item.text.toLowerCase(); + if (text.indexOf(q) === 0) { + this.suggestions.insert(index, item); + added[text] = true; + index++; + } + }, this); + } + this._dataSource.forEach(function (item) { + if (item.kind === SearchSuggestionKind.Query) { + if (!added[item.text.toLowerCase()]) { + this.suggestions.insert(index, item); + index++; + } + } else { + this.suggestions.insert(index, item); + index++; + } + }, this); + + this.suggestions.remove(this.suggestions.length - 1); + }, + }); + _Base.Class.mix(SearchSuggestionManagerShim, _Events.eventMixin); + + _Base.Namespace._moduleDefine(exports, null, { + _CollectionChange: CollectionChange, + _SearchSuggestionKind: SearchSuggestionKind, + _SearchSuggestionManagerShim: SearchSuggestionManagerShim, + }); +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/SearchBox',[ + '../Core/_Global', + '../Core/_WinRT', + '../Core/_Base', + '../Core/_ErrorFromName', + '../Core/_Events', + '../Core/_Resources', + '../Animations', + '../BindingList', + '../Controls/Repeater', + '../Utilities/_Control', + '../Utilities/_ElementListUtilities', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + './SearchBox/_SearchSuggestionManagerShim', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls', +], function searchboxInit(_Global, _WinRT, _Base, _ErrorFromName, _Events, _Resources, Animations, BindingList, Repeater, _Control, _ElementListUtilities, _ElementUtilities, _Hoverable, _SearchSuggestionManagerShim) { + "use strict"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// + /// Enables the user to perform search queries and select suggestions. + /// + /// + /// + /// + /// + /// ]]> + /// Raised when user or app changes the query text. + /// Raised when user clicks on search glyph or presses Enter. + /// Raised when user clicks one of the displayed suggestions. + /// Raised when the system requests search suggestions from this app. + /// + /// Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true. + /// + /// Styles the entire Search box control. + /// Styles the query input box. + /// Styles the search button. + /// Styles the result suggestions flyout. + /// Styles the result type suggestion. + /// Styles the query type suggestion. + /// + /// Styles the separator type suggestion. + /// + /// + /// Styles the currently selected suggestion. + /// + /// + /// + /// + SearchBox: _Base.Namespace._lazy(function () { + var createEvent = _Events._createEventProperty; + var Key = _ElementUtilities.Key; + + // Enums + var ClassName = { + searchBox: "win-searchbox", + searchBoxInput: "win-searchbox-input", + searchBoxButton: "win-searchbox-button", + searchBoxFlyout: "win-searchbox-flyout", + searchBoxSuggestionResult: "win-searchbox-suggestion-result", + searchBoxSuggestionQuery: "win-searchbox-suggestion-query", + searchBoxSuggestionSeparator: "win-searchbox-suggestion-separator", + searchBoxSuggestionSelected: "win-searchbox-suggestion-selected", + searchBoxFlyoutHighlightText: "win-searchbox-flyout-highlighttext", + searchBoxButtonInputFocus: "win-searchbox-button-input-focus", + searchBoxInputFocus: "win-searchbox-input-focus", + searchBoxSuggestionResultText: "win-searchbox-suggestion-result-text", + searchBoxSuggestionResultDetailedText: "win-searchbox-suggestion-result-detailed-text", + searchboxDisabled: "win-searchbox-disabled", + searchboxHitHighlightSpan: "win-searchbox-hithighlight-span", + }; + + var EventName = { + querychanged: "querychanged", + querysubmitted: "querysubmitted", + resultsuggestionchosen: "resultsuggestionchosen", + suggestionsrequested: "suggestionsrequested", + receivingfocusonkeyboardinput: "receivingfocusonkeyboardinput" + }; + + var strings = { + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get invalidSearchBoxSuggestionKind() { return "Error: Invalid search suggestion kind."; }, + get ariaLabel() { return _Resources._getWinJSString("ui/searchBoxAriaLabel").value; }, + get ariaLabelInputNoPlaceHolder() { return _Resources._getWinJSString("ui/searchBoxAriaLabelInputNoPlaceHolder").value; }, + get ariaLabelInputPlaceHolder() { return _Resources._getWinJSString("ui/searchBoxAriaLabelInputPlaceHolder").value; }, + get ariaLabelButton() { return _Resources._getWinJSString("ui/searchBoxAriaLabelButton").value; }, + get ariaLabelQuery() { return _Resources._getWinJSString("ui/searchBoxAriaLabelQuery").value; }, + get ariaLabelSeparator() { return _Resources._getWinJSString("ui/searchBoxAriaLabelSeparator").value; }, + get ariaLabelResult() { return _Resources._getWinJSString("ui/searchBoxAriaLabelResult").value; } + }; + + var SearchBox = _Base.Class.define(function SearchBox_ctor(element, options) { + /// + /// + /// Creates a new SearchBox. + /// + /// + /// The DOM element that hosts the SearchBox. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. + /// Each property of the options object corresponds to one of the control's properties or events. + /// Event names must begin with "on". For example, to provide a handler for the querychanged event, + /// add a property named "onquerychanged" to the options object and set its value to the event handler. + /// This parameter is optional. + /// + /// + /// The new SearchBox. + /// + /// + /// + + element = element || _Global.document.createElement("div"); + + if (element.winControl) { + throw new _ErrorFromName("WinJS.UI.SearchBox.DuplicateConstruction", strings.duplicateConstruction); + } + element.winControl = this; + + // Elements + this._domElement = null; + this._inputElement = null; + this._buttonElement = null; + this._flyout = null; + this._flyoutDivElement = null; + this._repeaterDivElement = null; + this._repeater = null; + + // Variables + this._disposed = false; + this._focusOnKeyboardInput = false; + this._chooseSuggestionOnEnter = false; + this._lastKeyPressLanguage = ""; + + // These are used to eliminate redundant query submitted events + this._prevQueryText = ""; + this._prevLinguisticDetails = this._createSearchQueryLinguisticDetails([], 0, 0, "", ""); + this._prevCompositionStart = 0; + this._prevCompositionLength = 0; + this._isProcessingDownKey = false; + this._isProcessingUpKey = false; + this._isProcessingTabKey = false; + this._isProcessingEnterKey = false; + this._isFlyoutPointerDown = false; + this._reflowImeOnPointerRelease = false; + + // Focus and selection related variables + this._currentFocusedIndex = -1; + this._currentSelectedIndex = -1; + + this._suggestionRendererBind = this._suggestionRenderer.bind(this); + this._requestingFocusOnKeyboardInputHandlerBind = this._requestingFocusOnKeyboardInputHandler.bind(this); + this._suggestionsRequestedHandlerBind = this._suggestionsRequestedHandler.bind(this); + this._suggestionsChangedHandlerBind = this._suggestionsChangedHandler.bind(this); + this._keydownCaptureHandlerBind = this._keydownCaptureHandler.bind(this); + this._frameLoadCaptureHandlerBind = this._frameLoadCaptureHandler.bind(this); + + // Find out if we are in local compartment and if search APIs are available. + this._searchSuggestionManager = null; + this._searchSuggestions = null; + + // Get the search suggestion provider if it is available + if (_WinRT.Windows.ApplicationModel.Search.Core.SearchSuggestionManager) { + this._searchSuggestionManager = new _WinRT.Windows.ApplicationModel.Search.Core.SearchSuggestionManager(); + } else { + this._searchSuggestionManager = new _SearchSuggestionManagerShim._SearchSuggestionManagerShim(); + } + this._searchSuggestions = this._searchSuggestionManager.suggestions; + + this._hitFinder = null; + this._setElement(element); + _Control.setOptions(this, options); + this._setAccessibilityProperties(); + _ElementUtilities.addClass(element, "win-disposable"); + }, { + + /// + element: { + get: function () { + return this._domElement; + } + }, + + /// + /// Gets or sets the placeholder text for the SearchBox. This text is displayed if there is no + /// other text in the input box. + /// + /// + placeholderText: { + get: function () { + return this._inputElement.placeholder; + }, + set: function (value) { + this._inputElement.placeholder = value; + this._updateInputElementAriaLabel(); + } + }, + + /// + /// Gets or sets the query text for the SearchBox. + /// + /// + queryText: { + get: function () { + return this._inputElement.value; + }, + set: function (value) { + this._inputElement.value = value; + } + }, + + /// + /// Gets or sets a value that specifies whether search history is disabled for the SearchBox. The default value is false. + /// + /// + searchHistoryDisabled: { + get: function () { + if (this._searchSuggestionManager) { + return !this._searchSuggestionManager.searchHistoryEnabled; + } else { + return true; + } + }, + set: function (value) { + if (this._searchSuggestionManager) { + this._searchSuggestionManager.searchHistoryEnabled = !value; + } + } + }, + + /// + /// Gets or sets the search history context for the SearchBox. The search history context string is used as a secondary key for storing search history. + /// (The primary key is the AppId.) An app can use the search history context string to store different search histories based on the context of the application. + /// If you don't set this property, the system assumes that all searches in your app occur in the same context. + /// If you update this property while the search pane is open with suggestions showing, the changes won't take effect until the user enters the next character. + /// + /// + searchHistoryContext: { + get: function () { + if (this._searchSuggestionManager) { + return this._searchSuggestionManager.searchHistoryContext; + } else { + return ""; + } + }, + set: function (value) { + if (this._searchSuggestionManager) { + this._searchSuggestionManager.searchHistoryContext = value; + } + } + }, + + /// + /// Enable automatically focusing the search box when the user types into the app window (off by default) While this is enabled, + /// input on the current thread will be intercepted and redirected to the search box. Only textual input will trigger the search box to focus. + /// The caller will continue to receive non-text keys (such as arrows, tab, etc + /// This will also not affect WIN/CTRL/ALT key combinations (except for Ctrl-V for paste). + /// If the client needs more to happen than just set focus in the box (make control visible, etc.), they will need to handle the event. + /// If enabled, the app must be sure to disable this if the user puts focus in some other edit field. + /// + /// + focusOnKeyboardInput: { + get: function () { + return this._focusOnKeyboardInput; + }, + set: function (value) { + if (this._focusOnKeyboardInput && !value) { + if (!(this._searchSuggestionManager instanceof _SearchSuggestionManagerShim._SearchSuggestionManagerShim)) { + this._searchSuggestionManager.removeEventListener("requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); + } else { + this._updateKeydownCaptureListeners(_Global.top, false /*add*/); + } + + } else if (!this._focusOnKeyboardInput && !!value) { + if (!(this._searchSuggestionManager instanceof _SearchSuggestionManagerShim._SearchSuggestionManagerShim)) { + this._searchSuggestionManager.addEventListener("requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); + } else { + this._updateKeydownCaptureListeners(_Global.top, true /*add*/); + } + + } + this._focusOnKeyboardInput = !!value; + } + }, + + /// + /// Gets or sets whether the first suggestion is chosen when the user presses Enter. + /// When set to true, as the user types in the search box, a focus rectangle is drawn on the first search suggestion + /// (if present and no IME composition in progress). Pressing enter will behave the same as if clicked on the focused suggestion, + /// and the down arrow key press will put real focus to the second suggestion and the up arrow key will remove focus. + /// + /// + chooseSuggestionOnEnter: { + get: function () { + return this._chooseSuggestionOnEnter; + }, + set: function (value) { + this._chooseSuggestionOnEnter = !!value; + this._updateSearchButtonClass(); + } + }, + + /// + /// Gets or sets a value that specifies whether the SearchBox is disabled. + /// + /// + disabled: { + get: function () { + return this._inputElement.disabled; + }, + set: function (value) { + if (this._inputElement.disabled === !!value) { + return; + } + + if (!value) { + // Enable control + this._inputElement.disabled = false; + this._buttonElement.disabled = false; + this._domElement.disabled = false; + _ElementUtilities.removeClass(this.element, ClassName.searchboxDisabled); + if (_Global.document.activeElement === this.element) { + _ElementUtilities._setActive(this._inputElement); + } + } else { + // Disable control + if (this._isFlyoutShown) { + this._hideFlyout(); + } + _ElementUtilities.addClass(this.element, ClassName.searchboxDisabled); + this._inputElement.disabled = true; + this._buttonElement.disabled = true; + this._domElement.disabled = true; + } + } + }, + + // Methods + setLocalContentSuggestionSettings: function SearchBox_setLocalContentSuggestionSettings(settings) { + /// + /// + /// Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that + /// the system uses to locate and filter these suggestions. + /// + /// + /// The new settings for local content suggestions. + /// + /// + /// + if (this._searchSuggestionManager) { + this._searchSuggestionManager.setLocalContentSuggestionSettings(settings); + } + }, + + dispose: function SearchBox() { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + + // Cancel pending promises. + if (this._flyoutOpenPromise) { + this._flyoutOpenPromise.cancel(); + } + + // Detach winrt events. + if (this._focusOnKeyboardInput) { + if (!(this._searchSuggestionManager instanceof _SearchSuggestionManagerShim._SearchSuggestionManagerShim)) { + this._searchSuggestionManager.removeEventListener("requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); + } else { + this._updateKeydownCaptureListeners(_Global.top, false /*add*/); + } + + } + this._searchSuggestions.removeEventListener("vectorchanged", this._suggestionsChangedHandlerBind); + this._searchSuggestionManager.removeEventListener("suggestionsrequested", this._suggestionsRequestedHandlerBind); + + this._searchSuggestionManager = null; + this._searchSuggestions = null; + this._hitFinder = null; + + this._disposed = true; + + }, + + /// + /// Raised when user or app changes the query text. + /// + /// + onquerychanged: createEvent(EventName.querychanged), + + /// + /// Raised when user clicks on search glyph or presses enter button. + /// + /// + onquerysubmitted: createEvent(EventName.querysubmitted), + + /// + /// Raised when user clicks on one of the suggestions displayed. + /// + /// + onresultsuggestionchosen: createEvent(EventName.resultsuggestionchosen), + + /// + /// Raised when Windows requests search suggestions from the app. + /// + /// + onsuggestionsrequested: createEvent(EventName.suggestionsrequested), + + // Private methods + _isFlyoutShown: function SearchBox_isFlyoutShown() { + return (this._flyoutDivElement.style.display !== "none"); + }, + + _isFlyoutBelow: function SearchBox_isFlyoutBelow() { + if (this._flyoutDivElement.getBoundingClientRect().top > this._inputElement.getBoundingClientRect().top) { + return true; + } + return false; + }, + + _getFlyoutTop: function SearchBox_getFlyoutTop() { + if (this._isFlyoutBelow()) { + return this._inputElement.getBoundingClientRect().bottom; + } + var popupHeight = this._flyoutDivElement.getBoundingClientRect().bottom - this._flyoutDivElement.getBoundingClientRect().top; + return this._inputElement.getBoundingClientRect().top - popupHeight; + }, + + _getFlyoutBottom: function SearchBox_getFlyoutBottom() { + if (this._isFlyoutBelow()) { + var popupHeight = this._flyoutDivElement.getBoundingClientRect().bottom - this._flyoutDivElement.getBoundingClientRect().top; + return this._inputElement.getBoundingClientRect().bottom + popupHeight; + } + return this._inputElement.getBoundingClientRect().top; + }, + + _updateFlyoutTopAndTouchAction: function SearchBox_updateFlyoutTopAndTouchAction() { + var popupHeight = this._flyoutDivElement.getBoundingClientRect().bottom - this._flyoutDivElement.getBoundingClientRect().top; + if (!this._isFlyoutBelow()) { + this._flyoutDivElement.style.top = "-" + popupHeight + "px"; + } + + // ms-scroll-chaining:none will still chain scroll parent element if child div does + // not have a scroll bar. Prevent this by setting and updating touch action + if (this._flyoutDivElement.scrollHeight > popupHeight) { + this._flyoutDivElement.style.touchAction = "pan-y"; + } else { + this._flyoutDivElement.style.touchAction = "none"; + } + }, + + _showFlyout: function SearchBox_showFlyout() { + + if (this._isFlyoutShown()) { + return; + } + + if (this._suggestionsData.length === 0) { + return; + } + + this._flyoutDivElement.style.display = "block"; + + // Display above vs below + var minPopupHeight = this._flyoutDivElement.clientHeight; + if (minPopupHeight < SearchBox._Constants.MIN_POPUP_HEIGHT) { + minPopupHeight = SearchBox._Constants.MIN_POPUP_HEIGHT; + } + var flyoutRect = this._flyoutDivElement.getBoundingClientRect(); + var searchBoxRect = this.element.getBoundingClientRect(); + var popupHeight = flyoutRect.bottom - flyoutRect.top; + var popupWidth = flyoutRect.right - flyoutRect.left; + var searchBoxWidth = searchBoxRect.right - searchBoxRect.left; + var documentClientHeight = _Global.document.documentElement.clientHeight; + var documentClientWidth = _Global.document.documentElement.clientWidth; + var searchBoxClientHeight = this.element.clientHeight; + var searchBoxClientLeft = this.element.clientLeft; + + var flyoutBelowSearchBox = true; + if ((searchBoxRect.bottom + minPopupHeight) <= documentClientHeight) { + // There is enough space below. Show below + this._flyoutDivElement.style.top = searchBoxClientHeight + "px"; + } else if ((searchBoxRect.top - minPopupHeight) >= 0) { + // There is enough space above. Show above + this._flyoutDivElement.style.top = "-" + popupHeight + "px"; + flyoutBelowSearchBox = false; + } else { + // Not enough space above or below. Show below. + this._flyoutDivElement.style.top = searchBoxClientHeight + "px"; + } + + // Align left vs right edge + var alignRight; + if (_Global.getComputedStyle(this._flyoutDivElement).direction === "rtl") { + // RTL: Align to the right edge if there is enough space to the left of the search box's + // right edge, or if there is not enough space to fit the flyout aligned to either edge. + alignRight = ((searchBoxRect.right - popupWidth) >= 0) || ((searchBoxRect.left + popupWidth) > documentClientWidth); + + } else { + // LTR: Align to the right edge if there isn't enough space to the right of the search box's + // left edge, but there is enough space to the left of the search box's right edge. + alignRight = ((searchBoxRect.left + popupWidth) > documentClientWidth) && ((searchBoxRect.right - popupWidth) >= 0); + } + + if (alignRight) { + this._flyoutDivElement.style.left = (searchBoxWidth - popupWidth - searchBoxClientLeft) + "px"; + } else { + this._flyoutDivElement.style.left = "-" + searchBoxClientLeft + "px"; + } + + // ms-scroll-chaining:none will still chain scroll parent element if child div does + // not have a scroll bar. Prevent this by setting and updating touch action + if (this._flyoutDivElement.scrollHeight > popupHeight) { + this._flyoutDivElement.style.touchAction = "pan-y"; + } else { + this._flyoutDivElement.style.touchAction = "none"; + } + + this._addFlyoutIMEPaddingIfRequired(); + + if (this._flyoutOpenPromise) { + this._flyoutOpenPromise.cancel(); + this._flyoutOpenPromise = null; + } + var animationKeyframe = flyoutBelowSearchBox ? "WinJS-flyoutBelowSearchBox-showPopup" : "WinJS-flyoutAboveSearchBox-showPopup"; + this._flyoutOpenPromise = Animations.showPopup(this._flyoutDivElement, { top: "0px", left: "0px", keyframe: animationKeyframe }); + }, + + _hideFlyout: function SearchBox_hideFlyout() { + if (this._isFlyoutShown()) { + this._flyoutDivElement.style.display = "none"; + this._updateSearchButtonClass(); + } + }, + + _addNewSpan: function SearchBox_addNewSpan(element, textContent, insertBefore) { + // Adds new span element with specified inner text as child to element, placed before insertBefore + var spanElement = _Global.document.createElement("span"); + spanElement.textContent = textContent; + spanElement.setAttribute("aria-hidden", "true"); + _ElementUtilities.addClass(spanElement, ClassName.searchboxHitHighlightSpan); + element.insertBefore(spanElement, insertBefore); + return spanElement; + }, + + _addHitHighlightedText: function SearchBox_addHitHighlightedText(element, item, text) { + if (text) { + // Remove any existing hit highlighted text spans + _ElementListUtilities.query("." + ClassName.searchboxHitHighlightSpan, element).forEach(function (childElement) { + childElement.parentNode.removeChild(childElement); + }); + + // Insert spans at the front of element + var firstChild = element.firstChild; + + var hitsProvided = item.hits; + if ((!hitsProvided) && (this._hitFinder !== null) && (item.kind !== _SearchSuggestionManagerShim._SearchSuggestionKind.Separator)) { + hitsProvided = this._hitFinder.find(text); + } + + var hits = SearchBox._sortAndMergeHits(hitsProvided); + + var lastPosition = 0; + for (var i = 0; i < hits.length; i++) { + var hit = hits[i]; + + // Add previous normal text + this._addNewSpan(element, text.substring(lastPosition, hit.startPosition), firstChild); + + lastPosition = hit.startPosition + hit.length; + + // Add hit highlighted text + var spanHitHighlightedText = this._addNewSpan(element, text.substring(hit.startPosition, lastPosition), firstChild); + _ElementUtilities.addClass(spanHitHighlightedText, ClassName.searchBoxFlyoutHighlightText); + } + + // Add final normal text + if (lastPosition < text.length) { + this._addNewSpan(element, text.substring(lastPosition), firstChild); + } + } + }, + + _findSuggestionElementIndex: function SearchBox_findSuggestionElementIndex(curElement) { + if (curElement) { + for (var i = 0; i < this._suggestionsData.length; i++) { + if (this._repeater.elementFromIndex(i) === curElement) { + return i; + } + } + } + return -1; + }, + + _isSuggestionSelectable: function SearchBox_isSuggestionSelectable(suggestion) { + return ((suggestion.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Query) || + (suggestion.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Result)); + }, + + _findNextSuggestionElementIndex: function SearchBox_findNextSuggestionElementIndex(curIndex) { + // Returns -1 if there are no focusable elements after curIndex + // Returns first element if curIndex < 0 + var startIndex = curIndex + 1; + if (startIndex < 0) { + startIndex = 0; + } + + for (var i = startIndex; i < this._suggestionsData.length; i++) { + if ((this._repeater.elementFromIndex(i)) && (this._isSuggestionSelectable(this._suggestionsData.getAt(i)))) { + return i; + } + } + return -1; + }, + + _findPreviousSuggestionElementIndex: function SearchBox_findPreviousSuggestionElementIndex(curIndex) { + // Returns -1 if there are no focusable elements before curIndex + // Returns last element if curIndex >= suggestionsdata.length + var startIndex = curIndex - 1; + if (startIndex >= this._suggestionsData.length) { + startIndex = this._suggestionsData.length - 1; + } + + for (var i = startIndex; i >= 0; i--) { + if ((this._repeater.elementFromIndex(i)) && (this._isSuggestionSelectable(this._suggestionsData.getAt(i)))) { + return i; + } + } + return -1; + }, + + _trySetFocusOnSuggestionIndex: function SearchBox_trySetFocusOnSuggestionIndex(index) { + try { + this._repeater.elementFromIndex(index).focus(); + } catch (e) { + } + }, + + _updateFakeFocus: function SearchBox_updateFakeFocus() { + var firstElementIndex; + if (this._isFlyoutShown() && (this._chooseSuggestionOnEnter)) { + firstElementIndex = this._findNextSuggestionElementIndex(-1); + } else { + // This will clear the fake focus. + firstElementIndex = -1; + } + + this._selectSuggestionAtIndex(firstElementIndex); + }, + + _updateSearchButtonClass: function SearchBox_updateSearchButtonClass() { + if ((this._currentSelectedIndex !== -1) || (_Global.document.activeElement !== this._inputElement)) { + // Focus is not in input. remove class + _ElementUtilities.removeClass(this._buttonElement, ClassName.searchBoxButtonInputFocus); + } else if (_Global.document.activeElement === this._inputElement) { + _ElementUtilities.addClass(this._buttonElement, ClassName.searchBoxButtonInputFocus); + } + }, + + _selectSuggestionAtIndex: function SearchBox_selectSuggestionAtIndex(indexToSelect) { + // Sets focus on the specified element and removes focus from others. + // Clears selection if index is outside of suggestiondata index range. + var curElement = null; + for (var i = 0; i < this._suggestionsData.length; i++) { + curElement = this._repeater.elementFromIndex(i); + if (i !== indexToSelect) { + _ElementUtilities.removeClass(curElement, ClassName.searchBoxSuggestionSelected); + curElement.setAttribute("aria-selected", "false"); + } else { + _ElementUtilities.addClass(curElement, ClassName.searchBoxSuggestionSelected); + this._scrollToView(curElement); + curElement.setAttribute("aria-selected", "true"); + } + } + this._updateSearchButtonClass(); + this._currentSelectedIndex = indexToSelect; + if (curElement) { + this._inputElement.setAttribute("aria-activedescendant", this._repeaterDivElement.id + indexToSelect); + } else if (this._inputElement.hasAttribute("aria-activedescendant")) { + this._inputElement.removeAttribute("aria-activedescendant"); + } + }, + + _scrollToView: function SearchBox_scrollToView(targetElement) { + var popupHeight = this._flyoutDivElement.getBoundingClientRect().bottom - this._flyoutDivElement.getBoundingClientRect().top; + if ((targetElement.offsetTop + targetElement.offsetHeight) > (this._flyoutDivElement.scrollTop + popupHeight)) { + // Element to scroll is below popup visible area + var scrollDifference = (targetElement.offsetTop + targetElement.offsetHeight) - (this._flyoutDivElement.scrollTop + popupHeight); + _ElementUtilities._zoomTo(this._flyoutDivElement, { contentX: 0, contentY: (this._flyoutDivElement.scrollTop + scrollDifference), viewportX: 0, viewportY: 0 }); + } else if (targetElement.offsetTop < this._flyoutDivElement.scrollTop) { + // Element to scroll is above popup visible area + _ElementUtilities._zoomTo(this._flyoutDivElement, { contentX: 0, contentY: targetElement.offsetTop, viewportX: 0, viewportY: 0 }); + } + }, + + _querySuggestionRenderer: function SearchBox_querySuggestionRenderer(item) { + var root = _Global.document.createElement("div"); + + this._addHitHighlightedText(root, item, item.text); + root.title = item.text; + + _ElementUtilities.addClass(root, ClassName.searchBoxSuggestionQuery); + + var that = this; + _ElementUtilities._addEventListener(root, "pointerup", function (ev) { + that._inputElement.focus(); + that._processSuggestionChosen(item, ev); + }); + + root.setAttribute("role", "option"); + var ariaLabel = _Resources._formatString(strings.ariaLabelQuery, item.text); + root.setAttribute("aria-label", ariaLabel); + return root; + }, + + _separatorSuggestionRenderer: function SearchBox_separatorSuggestionRenderer(item) { + var root = _Global.document.createElement("div"); + if (item.text.length > 0) { + var textElement = _Global.document.createElement("div"); + textElement.textContent = item.text; + textElement.title = item.text; + textElement.setAttribute("aria-hidden", "true"); + root.appendChild(textElement); + } + root.insertAdjacentHTML("beforeend", "
"); + _ElementUtilities.addClass(root, ClassName.searchBoxSuggestionSeparator); + root.setAttribute("role", "separator"); + var ariaLabel = _Resources._formatString(strings.ariaLabelSeparator, item.text); + root.setAttribute("aria-label", ariaLabel); + return root; + }, + + _resultSuggestionRenderer: function SearchBox_resultSuggestionRenderer(item) { + var root = _Global.document.createElement("div"); + var image = new _Global.Image(); + image.style.opacity = 0; + var loadImage = function (url) { + function onload() { + image.removeEventListener("load", onload, false); + Animations.fadeIn(image); + } + image.addEventListener("load", onload, false); + image.src = url; + }; + + if (item.image !== null) { + item.image.openReadAsync().then(function (streamWithContentType) { + if (streamWithContentType !== null) { + loadImage(_Global.URL.createObjectURL(streamWithContentType, { oneTimeOnly: true })); + } + }); + } else if (item.imageUrl !== null) { + loadImage(item.imageUrl); + } + image.setAttribute("aria-hidden", "true"); + root.appendChild(image); + + var divElement = _Global.document.createElement("div"); + _ElementUtilities.addClass(divElement, ClassName.searchBoxSuggestionResultText); + this._addHitHighlightedText(divElement, item, item.text); + divElement.title = item.text; + divElement.setAttribute("aria-hidden", "true"); + root.appendChild(divElement); + + var brElement = _Global.document.createElement("br"); + divElement.appendChild(brElement); + + var divDetailElement = _Global.document.createElement("span"); + _ElementUtilities.addClass(divDetailElement, ClassName.searchBoxSuggestionResultDetailedText); + this._addHitHighlightedText(divDetailElement, item, item.detailText); + divDetailElement.title = item.detailText; + divDetailElement.setAttribute("aria-hidden", "true"); + divElement.appendChild(divDetailElement); + + _ElementUtilities.addClass(root, ClassName.searchBoxSuggestionResult); + + var that = this; + _ElementUtilities._addEventListener(root, "pointerup", function (ev) { + that._inputElement.focus(); + that._processSuggestionChosen(item, ev); + }); + + root.setAttribute("role", "option"); + var ariaLabel = _Resources._formatString(strings.ariaLabelResult, item.text, item.detailText); + root.setAttribute("aria-label", ariaLabel); + return root; + }, + + _suggestionRenderer: function SearchBox_suggestionRenderer(item) { + var root = null; + if (!item) { + return root; + } + if (item.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Query) { + root = this._querySuggestionRenderer(item); + } else if (item.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Separator) { + root = this._separatorSuggestionRenderer(item); + } else if (item.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Result) { + root = this._resultSuggestionRenderer(item); + } else { + throw new _ErrorFromName("WinJS.UI.SearchBox.invalidSearchBoxSuggestionKind", strings.invalidSearchBoxSuggestionKind); + } + + return root; + }, + + _setElement: function SearchBox_setElement(element) { + this._domElement = element; + _ElementUtilities.addClass(this._domElement, ClassName.searchBox); + + this._inputElement = _Global.document.createElement("input"); + this._inputElement.type = "search"; + _ElementUtilities.addClass(this._inputElement, ClassName.searchBoxInput); + + this._buttonElement = _Global.document.createElement("div"); + this._buttonElement.tabIndex = -1; + _ElementUtilities.addClass(this._buttonElement, ClassName.searchBoxButton); + + this._flyoutDivElement = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._flyoutDivElement, ClassName.searchBoxFlyout); + + this._repeaterDivElement = _Global.document.createElement('div'); + this._suggestionsData = new BindingList.List(); + this._repeater = new Repeater.Repeater(this._repeaterDivElement, { data: this._suggestionsData, template: this._suggestionRendererBind }); + + this._domElement.appendChild(this._inputElement); + this._domElement.appendChild(this._buttonElement); + this._domElement.appendChild(this._flyoutDivElement); + this._flyoutDivElement.appendChild(this._repeaterDivElement); + this._hideFlyout(); + + this._wireupUserEvents(); + this._wireupWinRTEvents(); + this._wireupRepeaterEvents(); + }, + + _setAccessibilityProperties: function Searchbox_setAccessibilityProperties() { + // Set up accessibility properties + var label = this._domElement.getAttribute("aria-label"); + if (!label) { + this._domElement.setAttribute("aria-label", strings.ariaLabel); + } + this._domElement.setAttribute("role", "group"); + this._updateInputElementAriaLabel(); + this._inputElement.setAttribute("role", "textbox"); + this._buttonElement.setAttribute("role", "button"); + this._buttonElement.setAttribute("aria-label", strings.ariaLabelButton); + this._repeaterDivElement.setAttribute("role", "listbox"); + _ElementUtilities._ensureId(this._repeaterDivElement); + this._inputElement.setAttribute("aria-controls", this._repeaterDivElement.id); + this._repeaterDivElement.setAttribute("aria-live", "polite"); + }, + + _updateInputElementAriaLabel: function Searchbox_updateInputElementAriaLabel() { + var ariaLabel = strings.ariaLabelInputNoPlaceHolder; + if (this._inputElement.placeholder && this._inputElement.placeholder) { + ariaLabel = _Resources._formatString(strings.ariaLabelInputPlaceHolder, this._inputElement.placeholder); + } + this._inputElement.setAttribute("aria-label", ariaLabel); + }, + + _submitQuery: function Searchbox_submitQuery(queryText, fillLinguisticDetails, event) { + if (this._disposed) { + return; + } + + // get the most up to date value of the input langauge from WinRT if available + if (_WinRT.Windows.Globalization.Language) { + this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; + } + + this._fireEvent(SearchBox._EventName.querysubmitted, { + language: this._lastKeyPressLanguage, + linguisticDetails: this._getLinguisticDetails(true /*useCache*/, fillLinguisticDetails), // allow caching, but generate empty linguistic details if suggestion is used + queryText: queryText, + keyModifiers: SearchBox._getKeyModifiers(event) + }); + + if (this._searchSuggestionManager) { + this._searchSuggestionManager.addToHistory( + this._inputElement.value, + this._lastKeyPressLanguage + ); + } + }, + + _processSuggestionChosen: function Searchbox_processSuggestionChosen(item, event) { + this.queryText = item.text; + if (item.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Query) { + this._submitQuery(item.text, false /*fillLinguisticDetails*/, event); // force empty linguistic details since explicitly chosen suggestion from list + } else if (item.kind === _SearchSuggestionManagerShim._SearchSuggestionKind.Result) { + this._fireEvent(SearchBox._EventName.resultsuggestionchosen, { + tag: item.tag, + keyModifiers: SearchBox._getKeyModifiers(event), + storageFile: null + }); + } + this._hideFlyout(); + }, + + _buttonClickHandler: function SearchBox_buttonClickHandler(event) { + this._inputElement.focus(); + this._submitQuery(this._inputElement.value, true /*fillLinguisticDetails*/, event); + this._hideFlyout(); + }, + + _inputOrImeChangeHandler: function SearchBox_inputImeChangeHandler() { + var isButtonDown = _ElementUtilities._matchesSelector(this._buttonElement, ":active"); + // swallow the IME change event that gets fired when composition is ended due to keyboarding down to the suggestion list & mouse down on the button + if (!this._isProcessingImeFocusLossKey() && !isButtonDown && !this._isFlyoutPointerDown) { + var linguisticDetails = this._getLinguisticDetails(false /*useCache*/, true /*createFilled*/); // never cache on explicit user changes + var hasLinguisticDetailsChanged = this._hasLinguisticDetailsChanged(linguisticDetails); // updates this._prevLinguisticDetails + + // Keep the previous composition cache up to date, execpt when composition ended with no text change and alternatives are kept. + // In that case, we need to use the cached values to correctly generate the query prefix/suffix for substituting alternatives, but still report to the client that the composition has ended (via start & length of composition of 0) + if ((this._inputElement.value !== this._prevQueryText) || (this._prevCompositionLength === 0) || (linguisticDetails.queryTextCompositionLength > 0)) { + this._prevCompositionStart = linguisticDetails.queryTextCompositionStart; + this._prevCompositionLength = linguisticDetails.queryTextCompositionLength; + } + + if ((this._prevQueryText === this._inputElement.value) && !hasLinguisticDetailsChanged) { + // Sometimes the input change is fired even if there is no change in input. + // Swallow event in those cases. + return; + } + this._prevQueryText = this._inputElement.value; + + // get the most up to date value of the input langauge from WinRT if available + if (_WinRT.Windows.Globalization.Language) { + this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; + } + + if (_WinRT.Windows.Data.Text.SemanticTextQuery) { + if (this._inputElement.value !== "") { + this._hitFinder = new _WinRT.Windows.Data.Text.SemanticTextQuery(this._inputElement.value, this._lastKeyPressLanguage); + } else { + this._hitFinder = null; + } + } + + this._fireEvent(SearchBox._EventName.querychanged, { + language: this._lastKeyPressLanguage, + queryText: this._inputElement.value, + linguisticDetails: linguisticDetails + }); + if (this._searchSuggestionManager) { + this._searchSuggestionManager.setQuery( + this._inputElement.value, + this._lastKeyPressLanguage, + linguisticDetails + ); + } + } + }, + + _createSearchQueryLinguisticDetails: function SearchBox_createSearchQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix) { + var linguisticDetails = null; + + // The linguistic alternatives we receive are only for the composition string being composed. We need to provide the linguistic alternatives + // in the form of the full query text with alternatives embedded. + var fullCompositionAlternatives = []; + for (var i = 0; i < compositionAlternatives.length; i++) { + fullCompositionAlternatives[i] = queryTextPrefix + compositionAlternatives[i] + queryTextSuffix; + } + + if (_WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails) { + linguisticDetails = new _WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails(fullCompositionAlternatives, compositionStartOffset, compositionLength); + } else { + // If we're in web compartment, create a script version of the WinRT SearchQueryLinguisticDetails object + linguisticDetails = { + queryTextAlternatives: fullCompositionAlternatives, + queryTextCompositionStart: compositionStartOffset, + queryTextCompositionLength: compositionLength + }; + } + return linguisticDetails; + }, + + _getLinguisticDetails: function SearchBox_getLinguisticDetails(useCache, createFilled) { // createFilled=false always creates an empty linguistic details object, otherwise generate it or use the cache + var linguisticDetails = null; + if ((this._inputElement.value === this._prevQueryText) && useCache && this._prevLinguisticDetails && createFilled) { + linguisticDetails = this._prevLinguisticDetails; + } else { + var compositionAlternatives = []; + var compositionStartOffset = 0; + var compositionLength = 0; + var queryTextPrefix = ""; + var queryTextSuffix = ""; + if (createFilled && this._inputElement.msGetInputContext && this._inputElement.msGetInputContext().getCompositionAlternatives) { + var context = this._inputElement.msGetInputContext(); + compositionAlternatives = context.getCompositionAlternatives(); + compositionStartOffset = context.compositionStartOffset; + compositionLength = context.compositionEndOffset - context.compositionStartOffset; + + if ((this._inputElement.value !== this._prevQueryText) || (this._prevCompositionLength === 0) || (compositionLength > 0)) { + queryTextPrefix = this._inputElement.value.substring(0, compositionStartOffset); + queryTextSuffix = this._inputElement.value.substring(compositionStartOffset + compositionLength); + } else { + // composition ended, but alternatives have been kept, need to reuse the previous query prefix/suffix, but still report to the client that the composition has ended (start & length of composition of 0) + queryTextPrefix = this._inputElement.value.substring(0, this._prevCompositionStart); + queryTextSuffix = this._inputElement.value.substring(this._prevCompositionStart + this._prevCompositionLength); + } + } + linguisticDetails = this._createSearchQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix); + } + return linguisticDetails; + }, + + _handleTabKeyDown: function SearchBox_handleTabKeyDown(event) { + var closeFlyout = true; + if (event.shiftKey) { + // If focus is not in input + if (this._currentFocusedIndex !== -1) { + // Remove selection. + this._currentFocusedIndex = -1; + this._selectSuggestionAtIndex(this._currentFocusedIndex); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + closeFlyout = false; + } + } else if (this._currentFocusedIndex === -1) { + if (this._isFlyoutBelow()) { + // Move to first element + this._currentFocusedIndex = this._findNextSuggestionElementIndex(this._currentFocusedIndex); + } else { + // Move to last element + this._currentFocusedIndex = this._findPreviousSuggestionElementIndex(this._suggestionsData.length); + } + if (this._currentFocusedIndex !== -1) { + this._selectSuggestionAtIndex(this._currentFocusedIndex); + this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + closeFlyout = false; + } + } + + if (closeFlyout) { + this._hideFlyout(); + } + }, + + _keyDownHandler: function SearchBox_keyDownHandler(event) { + this._lastKeyPressLanguage = event.locale; + if (event.keyCode === Key.tab) { + this._isProcessingTabKey = true; + } else if (event.keyCode === Key.upArrow) { + this._isProcessingUpKey = true; + } else if (event.keyCode === Key.downArrow) { + this._isProcessingDownKey = true; + } else if ((event.keyCode === Key.enter) && (event.locale === "ko")) { + this._isProcessingEnterKey = true; + } + // Ignore keys handled by ime. + if (event.keyCode !== Key.IME) { + if (event.keyCode === Key.tab) { + this._handleTabKeyDown(event); + } else if (event.keyCode === Key.escape) { + // If focus is not in input + if (this._currentFocusedIndex !== -1) { + this.queryText = this._prevQueryText; + this._currentFocusedIndex = -1; + this._selectSuggestionAtIndex(this._currentFocusedIndex); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + } else if (this.queryText !== "") { + this.queryText = ""; + this._inputOrImeChangeHandler(null); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + } + } else if (event.keyCode === Key.upArrow) { + var prevIndex; + if (this._currentSelectedIndex !== -1) { + prevIndex = this._findPreviousSuggestionElementIndex(this._currentSelectedIndex); + // Restore user entered query when user navigates back to input. + if (prevIndex === -1) { + this.queryText = this._prevQueryText; + } + } else { + prevIndex = this._findPreviousSuggestionElementIndex(this._suggestionsData.length); + } + this._currentFocusedIndex = prevIndex; + this._selectSuggestionAtIndex(prevIndex); + this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + } else if (event.keyCode === Key.downArrow) { + var nextIndex = this._findNextSuggestionElementIndex(this._currentSelectedIndex); + // Restore user entered query when user navigates back to input. + if ((this._currentSelectedIndex !== -1) && (nextIndex === -1)) { + this.queryText = this._prevQueryText; + } + this._currentFocusedIndex = nextIndex; + this._selectSuggestionAtIndex(nextIndex); + this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); + this._updateSearchButtonClass(); + event.preventDefault(); + event.stopPropagation(); + } else if (event.keyCode === Key.enter) { + if (this._currentSelectedIndex === -1) { + this._submitQuery(this._inputElement.value, true /*fillLinguisticDetails*/, event); + } else { + this._processSuggestionChosen(this._suggestionsData.getAt(this._currentSelectedIndex), event); + } + this._hideFlyout(); + } else if (SearchBox._isTypeToSearchKey(event)) { + // Type to search on suggestions scenario. + if (this._currentFocusedIndex !== -1) { + this._currentFocusedIndex = -1; + this._selectSuggestionAtIndex(-1); + this._updateFakeFocus(); + } + } + } + }, + + _keyPressHandler: function SearchBox_keyPressHandler(event) { + this._lastKeyPressLanguage = event.locale; + }, + + _keyUpHandler: function SearchBox_keyUpHandler(event) { + if (event.keyCode === Key.tab) { + this._isProcessingTabKey = false; + } else if (event.keyCode === Key.upArrow) { + this._isProcessingUpKey = false; + } else if (event.keyCode === Key.downArrow) { + this._isProcessingDownKey = false; + } else if (event.keyCode === Key.enter) { + this._isProcessingEnterKey = false; + } + }, + + _inputFocusHandler: function SearchBox_inputFocusHandler(event) { + // Refresh hit highlighting if text has changed since focus was present + // This can happen if the user committed a suggestion previously. + if (this._inputElement.value !== this._prevQueryText) { + if (_WinRT.Windows.Data.Text.SemanticTextQuery) { + if (this._inputElement.value !== "") { + this._hitFinder = new _WinRT.Windows.Data.Text.SemanticTextQuery(this._inputElement.value, this._inputElement.lang); + } else { + this._hitFinder = null; + } + } + } + + // If focus is returning to the input box from outside the search control, show the flyout and refresh the suggestions + if ((event.target === this._inputElement) && !this._internalFocusMove) { + this._showFlyout(); + // If focus is not in input + if (this._currentFocusedIndex !== -1) { + this._selectSuggestionAtIndex(this._currentFocusedIndex); + } else { + this._updateFakeFocus(); + } + + if (this._searchSuggestionManager) { + this._searchSuggestionManager.setQuery( + this._inputElement.value, + this._lastKeyPressLanguage, + this._getLinguisticDetails(true /*useCache*/, true /*createFilled*/) + ); + } + } + + this._internalFocusMove = false; + _ElementUtilities.addClass(this.element, ClassName.searchBoxInputFocus); + this._updateSearchButtonClass(); + }, + + _flyoutBlurHandler: function SearchBox_flyoutBlurHandler() { + if (this._isElementInSearchControl(_Global.document.activeElement)) { + this._internalFocusMove = true; + } else { + this._hideFlyout(); + _ElementUtilities.removeClass(this.element, ClassName.searchBoxInputFocus); + } + }, + + _inputBlurHandler: function SearchBox_inputBlurHandler(event) { + if (!this._isElementInSearchControl(_Global.document.activeElement)) { + this._hideFlyout(); + _ElementUtilities.removeClass(this.element, ClassName.searchBoxInputFocus); + } + this._updateSearchButtonClass(); + this._isProcessingDownKey = false; + this._isProcessingUpKey = false; + this._isProcessingTabKey = false; + this._isProcessingEnterKey = false; + }, + + _isIMEOccludingFlyout: function SearchBox_isIMEOccludingFlyout(imeRect) { + var flyoutTop = this._getFlyoutTop(); + var flyoutBottom = this._getFlyoutBottom(); + if (((imeRect.top >= flyoutTop) && (imeRect.top <= flyoutBottom)) || + ((imeRect.bottom >= flyoutTop) && (imeRect.bottom <= flyoutBottom))) { + return true; + } + return false; + }, + + _addFlyoutIMEPaddingIfRequired: function SearchBox_addFlyoutIMEPaddingIfRequired() { + if (this._isFlyoutShown() && this._isFlyoutBelow() && this._inputElement.msGetInputContext && this._inputElement.msGetInputContext()) { + var context = this._inputElement.msGetInputContext(); + var rect = context.getCandidateWindowClientRect(); + if (this._isIMEOccludingFlyout(rect)) { + var animation = Animations.createRepositionAnimation(this._flyoutDivElement.children); + this._flyoutDivElement.style.paddingTop = (rect.bottom - rect.top) + "px"; + animation.execute(); + } + } + }, + + _msCandidateWindowShowHandler: function SearchBox_msCandidateWindowShowHandler() { + this._addFlyoutIMEPaddingIfRequired(); + this._reflowImeOnPointerRelease = false; + }, + + _msCandidateWindowHideHandler: function SearchBox_msCandidateWindowHideHandler() { + if (!this._isFlyoutPointerDown) { + var animation = Animations.createRepositionAnimation(this._flyoutDivElement.children); + this._flyoutDivElement.style.paddingTop = ""; + animation.execute(); + } else { + this._reflowImeOnPointerRelease = true; + } + }, + + _wireupUserEvents: function SearchBox_wireupUserEvents() { + var inputOrImeChangeHandler = this._inputOrImeChangeHandler.bind(this); + this._buttonElement.addEventListener("click", this._buttonClickHandler.bind(this)); + this._inputElement.addEventListener("input", inputOrImeChangeHandler); + this._inputElement.addEventListener("keydown", this._keyDownHandler.bind(this)); + this._inputElement.addEventListener("keypress", this._keyPressHandler.bind(this)); + this._inputElement.addEventListener("keyup", this._keyUpHandler.bind(this)); + this._inputElement.addEventListener("focus", this._inputFocusHandler.bind(this)); + this._inputElement.addEventListener("blur", this._inputBlurHandler.bind(this)); + _ElementUtilities._addEventListener(this._inputElement, "pointerdown", this._inputPointerDownHandler.bind(this)); + + this._flyoutDivElement.addEventListener("blur", this._flyoutBlurHandler.bind(this)); + _ElementUtilities._addEventListener(this._flyoutDivElement, "pointerdown", this._flyoutPointerDownHandler.bind(this)); + _ElementUtilities._addEventListener(this._flyoutDivElement, "pointerup", this._flyoutPointerReleasedHandler.bind(this)); + _ElementUtilities._addEventListener(this._flyoutDivElement, "pointercancel", this._flyoutPointerReleasedHandler.bind(this)); + _ElementUtilities._addEventListener(this._flyoutDivElement, "pointerout", this._flyoutPointerReleasedHandler.bind(this)); + + this._inputElement.addEventListener("compositionstart", inputOrImeChangeHandler); + this._inputElement.addEventListener("compositionupdate", inputOrImeChangeHandler); + this._inputElement.addEventListener("compositionend", inputOrImeChangeHandler); + + if (this._inputElement.msGetInputContext && this._inputElement.msGetInputContext()) { + var context = this._inputElement.msGetInputContext(); + context.addEventListener("MSCandidateWindowShow", this._msCandidateWindowShowHandler.bind(this)); + context.addEventListener("MSCandidateWindowHide", this._msCandidateWindowHideHandler.bind(this)); + } + }, + + _repeaterChangedHandler: function SearchBox_repeaterChangedHandler() { + this._updateFlyoutTopAndTouchAction(); + if (this._isFlyoutShown()) { + this._repeaterDivElement.style.display = "none"; + this._repeaterDivElement.style.display = "block"; + } + }, + + _wireupRepeaterEvents: function SearchBox_wireupRepeaterEvents() { + var repeaterChangeHandler = this._repeaterChangedHandler.bind(this); + this._repeater.addEventListener("itemchanged", repeaterChangeHandler); + this._repeater.addEventListener("iteminserted", repeaterChangeHandler); + this._repeater.addEventListener("itemremoved", repeaterChangeHandler); + this._repeater.addEventListener("itemsreloaded", repeaterChangeHandler); + }, + + _inputPointerDownHandler: function SearchBox_inputPointerDownHandler() { + if ((_Global.document.activeElement === this._inputElement) && (this._currentSelectedIndex !== -1)) { + this._currentFocusedIndex = -1; + this._selectSuggestionAtIndex(this._currentFocusedIndex); + } + }, + + _flyoutPointerDownHandler: function SearchBox_flyoutPointerDownHandler(ev) { + this._isFlyoutPointerDown = true; + var srcElement = ev.target; + while (srcElement && (srcElement.parentNode !== this._repeaterDivElement)) { + srcElement = srcElement.parentNode; + } + var index = this._findSuggestionElementIndex(srcElement); + if ((index >= 0) && (index < this._suggestionsData.length) && (this._currentFocusedIndex !== index)) { + if (this._isSuggestionSelectable(this._suggestionsData.getAt(index))) { + this._currentFocusedIndex = index; + this._selectSuggestionAtIndex(index); + this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); + } + } + // Prevent default so focus does not leave input element. + ev.preventDefault(); + }, + + _flyoutPointerReleasedHandler: function SearchBox_flyoutPointerReleasedHandler() { + this._isFlyoutPointerDown = false; + + if (this._reflowImeOnPointerRelease) { + this._reflowImeOnPointerRelease = false; + var animation = Animations.createRepositionAnimation(this._flyoutDivElement.children); + this._flyoutDivElement.style.paddingTop = ""; + animation.execute(); + } + }, + + _isElementInSearchControl: function SearchBox_isElementInSearchControl(targetElement) { + return this.element.contains(targetElement) || (this.element === targetElement); + }, + + _hideFlyoutIfLeavingSearchControl: function SearchBox_hideFlyoutIfLeavingSearchControl(targetElement) { + if (!this._isFlyoutShown()) { + return; + } + if (!this._isElementInSearchControl(targetElement)) { + this._hideFlyout(); + } + }, + + _wireupWinRTEvents: function SearchBox_wireupWinRTEvents() { + this._searchSuggestions.addEventListener("vectorchanged", this._suggestionsChangedHandlerBind); + this._searchSuggestionManager.addEventListener("suggestionsrequested", this._suggestionsRequestedHandlerBind); + }, + + _suggestionsChangedHandler: function SearchBox_suggestionsChangedHandler(event) { + var collectionChange = event.collectionChange || event.detail.collectionChange; + var changeIndex = (+event.index === event.index) ? event.index : event.detail.index; + var ChangeEnum = _SearchSuggestionManagerShim._CollectionChange; + if (collectionChange === ChangeEnum.reset) { + if (this._isFlyoutShown()) { + this._hideFlyout(); + } + this._suggestionsData.splice(0, this._suggestionsData.length); + } else if (collectionChange === ChangeEnum.itemInserted) { + var suggestion = this._searchSuggestions[changeIndex]; + this._suggestionsData.splice(changeIndex, 0, suggestion); + + this._showFlyout(); + + } else if (collectionChange === ChangeEnum.itemRemoved) { + if ((this._suggestionsData.length === 1)) { + _ElementUtilities._setActive(this._inputElement); + + this._hideFlyout(); + } + this._suggestionsData.splice(changeIndex, 1); + } else if (collectionChange === ChangeEnum.itemChanged) { + var suggestion = this._searchSuggestions[changeIndex]; + if (suggestion !== this._suggestionsData.getAt(changeIndex)) { + this._suggestionsData.setAt(changeIndex, suggestion); + } else { + // If the suggestions manager gives us an identical item, it means that only the hit highlighted text has changed. + var existingElement = this._repeater.elementFromIndex(changeIndex); + if (_ElementUtilities.hasClass(existingElement, ClassName.searchBoxSuggestionQuery)) { + this._addHitHighlightedText(existingElement, suggestion, suggestion.text); + } else { + var resultSuggestionDiv = existingElement.querySelector("." + ClassName.searchBoxSuggestionResultText); + if (resultSuggestionDiv) { + this._addHitHighlightedText(resultSuggestionDiv, suggestion, suggestion.text); + var resultSuggestionDetailDiv = existingElement.querySelector("." + ClassName.searchBoxSuggestionResultDetailedText); + if (resultSuggestionDetailDiv) { + this._addHitHighlightedText(resultSuggestionDetailDiv, suggestion, suggestion.detailText); + } + } + } + } + } + + if (_Global.document.activeElement === this._inputElement) { + this._updateFakeFocus(); + } + }, + + _suggestionsRequestedHandler: function SearchBox_suggestionsRequestedHandler(event) { + // get the most up to date value of the input langauge from WinRT if available + if (_WinRT.Windows.Globalization.Language) { + this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; + } + + var request = event.request || event.detail.request; + var deferral; + this._fireEvent(SearchBox._EventName.suggestionsrequested, { + setPromise: function (promise) { + deferral = request.getDeferral(); + promise.then(function () { + deferral.complete(); + }); + }, + searchSuggestionCollection: request.searchSuggestionCollection, + language: this._lastKeyPressLanguage, + linguisticDetails: this._getLinguisticDetails(true /*useCache*/, true /*createFilled*/), + queryText: this._inputElement.value + }); + }, + + _fireEvent: function SearchBox_fireEvent(type, detail) { + // Returns true if ev.preventDefault() was not called + var event = _Global.document.createEvent("CustomEvent"); + event.initCustomEvent(type, true, true, detail); + return this.element.dispatchEvent(event); + }, + + _requestingFocusOnKeyboardInputHandler: function SearchBox_requestingFocusOnKeyboardInputHandler() { + this._fireEvent(SearchBox._EventName.receivingfocusonkeyboardinput, null); + if (_Global.document.activeElement !== this._inputElement) { + try { + this._inputElement.focus(); + } catch (e) { + } + } + }, + + _keydownCaptureHandler: function SearchBox_keydownCaptureHandler(event) { + if (this._focusOnKeyboardInput && this._shouldKeyTriggerTypeToSearch(event)) { + this._requestingFocusOnKeyboardInputHandler(event); + } + }, + + _frameLoadCaptureHandler: function SearchBox_frameLoadCaptureHandler(event) { + if (this._focusOnKeyboardInput) { + this._updateKeydownCaptureListeners(event.target.contentWindow, true /*add*/); + } + }, + + _updateKeydownCaptureListeners: function SearchBox_updateTypeToSearchListeners(win, add) { + // Register for child frame keydown events in order to support FocusOnKeyboardInput + // when focus is in a child frame. Also register for child frame load events so + // it still works after frame navigations. + // Note: This won't catch iframes added programmatically later, but that can be worked + // around by toggling FocusOnKeyboardInput off/on after the new iframe is added. + try { + if (add) { + win.document.addEventListener('keydown', this._keydownCaptureHandlerBind, true); + } else { + win.document.removeEventListener('keydown', this._keydownCaptureHandlerBind, true); + } + } catch (e) { // if the IFrame crosses domains, we'll get a permission denied error + } + + if (win.frames) { + for (var i = 0, l = win.frames.length; i < l; i++) { + var childWin = win.frames[i]; + this._updateKeydownCaptureListeners(childWin, add); + + try { + if (add) { + if (childWin.frameElement) { + childWin.frameElement.addEventListener('load', this._frameLoadCaptureHandlerBind, true); + } + } else { + if (childWin.frameElement) { + childWin.frameElement.removeEventListener('load', this._frameLoadCaptureHandlerBind, true); + } + } + } catch (e) { // if the IFrame crosses domains, we'll get a permission denied error + } + } + } + }, + + _shouldKeyTriggerTypeToSearch: function SearchBox_shouldKeyTriggerTypeToSearch(event) { + var shouldTrigger = false; + // First, check if a metaKey is pressed (only applies to MacOS). If so, do nothing here. + if (!event.metaKey) { + // We also don't handle CTRL/ALT combinations, unless ALTGR is also set. Since there is no shortcut for checking AltGR, + // we need to use getModifierState, however, Safari currently doesn't support this. + if ((!event.ctrlKey && !event.altKey) || (event.getModifierState && event.getModifierState("AltGraph"))) { + // Show on most keys for visible characters like letters, numbers, etc. + switch (event.keyCode) { + case 0x30: //0x30 0 key + case 0x31: //0x31 1 key + case 0x32: //0x32 2 key + case 0x33: //0x33 3 key + case 0x34: //0x34 4 key + case 0x35: //0x35 5 key + case 0x36: //0x36 6 key + case 0x37: //0x37 7 key + case 0x38: //0x38 8 key + case 0x39: //0x39 9 key + + case 0x41: //0x41 A key + case 0x42: //0x42 B key + case 0x43: //0x43 C key + case 0x44: //0x44 D key + case 0x45: //0x45 E key + case 0x46: //0x46 F key + case 0x47: //0x47 G key + case 0x48: //0x48 H key + case 0x49: //0x49 I key + case 0x4A: //0x4A J key + case 0x4B: //0x4B K key + case 0x4C: //0x4C L key + case 0x4D: //0x4D M key + case 0x4E: //0x4E N key + case 0x4F: //0x4F O key + case 0x50: //0x50 P key + case 0x51: //0x51 Q key + case 0x52: //0x52 R key + case 0x53: //0x53 S key + case 0x54: //0x54 T key + case 0x55: //0x55 U key + case 0x56: //0x56 V key + case 0x57: //0x57 W key + case 0x58: //0x58 X key + case 0x59: //0x59 Y key + case 0x5A: //0x5A Z key + + case 0x60: // VK_NUMPAD0, //0x60 Numeric keypad 0 key + case 0x61: // VK_NUMPAD1, //0x61 Numeric keypad 1 key + case 0x62: // VK_NUMPAD2, //0x62 Numeric keypad 2 key + case 0x63: // VK_NUMPAD3, //0x63 Numeric keypad 3 key + case 0x64: // VK_NUMPAD4, //0x64 Numeric keypad 4 key + case 0x65: // VK_NUMPAD5, //0x65 Numeric keypad 5 key + case 0x66: // VK_NUMPAD6, //0x66 Numeric keypad 6 key + case 0x67: // VK_NUMPAD7, //0x67 Numeric keypad 7 key + case 0x68: // VK_NUMPAD8, //0x68 Numeric keypad 8 key + case 0x69: // VK_NUMPAD9, //0x69 Numeric keypad 9 key + case 0x6A: // VK_MULTIPLY, //0x6A Multiply key + case 0x6B: // VK_ADD, //0x6B Add key + case 0x6C: // VK_SEPARATOR, //0x6C Separator key + case 0x6D: // VK_SUBTRACT, //0x6D Subtract key + case 0x6E: // VK_DECIMAL, //0x6E Decimal key + case 0x6F: // VK_DIVIDE, //0x6F Divide key + + case 0xBA: // VK_OEM_1, //0xBA Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key + case 0xBB: // VK_OEM_PLUS, //0xBB For any country/region, the '+' key + case 0xBC: // VK_OEM_COMMA, //0xBC For any country/region, the ',' key + case 0xBD: // VK_OEM_MINUS, //0xBD For any country/region, the '-' key + case 0xBE: // VK_OEM_PERIOD, //0xBE For any country/region, the '.' key + case 0xBF: // VK_OEM_2, //0xBF Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key + case 0xC0: // VK_OEM_3, //0xC0 Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key + + case 0xDB: // VK_OEM_4, //0xDB Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key + case 0xDC: // VK_OEM_5, //0xDC Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key + case 0xDD: // VK_OEM_6, //0xDD Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key + case 0xDE: // VK_OEM_7, //0xDE Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key + case 0xDF: // VK_OEM_8, //0xDF Used for miscellaneous characters; it can vary by keyboard. + + case 0xE2: // VK_OEM_102, //0xE2 Either the angle bracket key or the backslash key on the RT 102-key keyboard + + case 0xE5: // VK_PROCESSKEY, //0xE5 IME PROCESS key + + case 0xE7: // VK_PACKET, //0xE7 Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP + shouldTrigger = true; + break; + } + } + } + return shouldTrigger; + }, + + _hasLinguisticDetailsChanged: function SearchBox_hasLinguisticDetailsChanged(newLinguisticDetails) { + var hasLinguisticDetailsChanged = false; + if ((this._prevLinguisticDetails.queryTextCompositionStart !== newLinguisticDetails.queryTextCompositionStart) || + (this._prevLinguisticDetails.queryTextCompositionLength !== newLinguisticDetails.queryTextCompositionLength) || + (this._prevLinguisticDetails.queryTextAlternatives.length !== newLinguisticDetails.queryTextAlternatives.length)) { + hasLinguisticDetailsChanged = true; + } + this._prevLinguisticDetails = newLinguisticDetails; + return hasLinguisticDetailsChanged; + }, + + _isProcessingImeFocusLossKey: function SearchBox_isProcessingImeFocusLossKey() { + return this._isProcessingDownKey || this._isProcessingUpKey || this._isProcessingTabKey || this._isProcessingEnterKey; + }, + + _updateQueryTextWithSuggestionText: function SearchBox_updateQueryTextWithSuggestionText(suggestionIndex) { + if ((suggestionIndex >= 0) && (suggestionIndex < this._suggestionsData.length)) { + this.queryText = this._suggestionsData.getAt(suggestionIndex).text; + } + } + + }, { + _EventName: { + querychanged: EventName.querychanged, + querysubmitted: EventName.querysubmitted, + resultsuggestionchosen: EventName.resultsuggestionchosen, + suggestionsrequested: EventName.suggestionsrequested, + receivingfocusonkeyboardinput: EventName.receivingfocusonkeyboardinput + }, + + _Constants: { + MIN_POPUP_HEIGHT: 152, + }, + + createResultSuggestionImage: function SearchBox_createResultSuggestionImage(url) { + /// + /// + /// Creates the image argument for SearchSuggestionCollection.appendResultSuggestion. + /// + /// + /// The url of the image. + /// + /// + /// + if (_WinRT.Windows.Foundation.Uri && _WinRT.Windows.Storage.Streams.RandomAccessStreamReference) { + return _WinRT.Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(new _WinRT.Windows.Foundation.Uri(url)); + } + return url; + }, + + _getKeyModifiers: function SearchBox_getKeyModifiers(ev) { + + // Returns the same value as http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.system.virtualkeymodifiers + var VirtualKeys = { + ctrlKey: 1, + altKey: 2, + shiftKey: 4 + }; + + var keyModifiers = 0; + if (ev.ctrlKey) { + keyModifiers |= VirtualKeys.ctrlKey; + } + if (ev.altKey) { + keyModifiers |= VirtualKeys.altKey; + } + if (ev.shiftKey) { + keyModifiers |= VirtualKeys.shiftKey; + } + return keyModifiers; + }, + + _sortAndMergeHits: function searchBox_sortAndMergeHits(hitsProvided) { + var reducedHits = []; + if (hitsProvided) { + // Copy hitsprovided array as winrt objects are immutable. + var hits = new Array(hitsProvided.length); + for (var i = 0; i < hitsProvided.length; i++) { + hits.push({ startPosition: hitsProvided[i].startPosition, length: hitsProvided[i].length }); + } + hits.sort(SearchBox._hitStartPositionAscendingSorter); + hits.reduce(SearchBox._hitIntersectionReducer, reducedHits); + } + return reducedHits; + }, + + _hitStartPositionAscendingSorter: function searchBox_hitStartPositionAscendingSorter(firstHit, secondHit) { + var returnValue = 0; + if (firstHit.startPosition < secondHit.startPosition) { + returnValue = -1; + } else if (firstHit.startPosition > secondHit.startPosition) { + returnValue = 1; + } + return returnValue; + }, + + _hitIntersectionReducer: function searchBox_hitIntersectionReducer(reducedHits, nextHit, currentIndex) { + if (currentIndex === 0) { + reducedHits.push(nextHit); + } else { + var curHit = reducedHits[reducedHits.length - 1]; + var curHitEndPosition = curHit.startPosition + curHit.length; + if (nextHit.startPosition <= curHitEndPosition) { + // The next hit intersects or is next to current hit. Merge it. + var nextHitEndPosition = nextHit.startPosition + nextHit.length; + if (nextHitEndPosition > curHitEndPosition) { + curHit.length = nextHitEndPosition - curHit.startPosition; + } + } else { + // No intersection, simply add to reduced list. + reducedHits.push(nextHit); + } + } + return reducedHits; + }, + + _isTypeToSearchKey: function searchBox_isTypeToSearchKey(event) { + if (event.shiftKey || event.ctrlKey || event.altKey) { + return false; + } + return true; + } + }); + _Base.Class.mix(SearchBox, _Control.DOMEventMixin); + return SearchBox; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +/// appbar,Flyout,Flyouts,registeredforsettings,SettingsFlyout,Statics,Syriac +define('WinJS/Controls/SettingsFlyout',[ + '../Core/_Global', + '../Core/_WinRT', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Resources', + '../Core/_WriteProfilerMark', + '../Animations', + '../Pages', + '../Promise', + '../Utilities/_Dispose', + '../Utilities/_ElementUtilities', + '../Utilities/_ElementListUtilities', + '../Utilities/_Hoverable', + './AppBar/_Constants', + './Flyout/_Overlay', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' + ], function settingsFlyoutInit(_Global,_WinRT, _Base, _BaseUtils, _ErrorFromName, _Resources, _WriteProfilerMark, Animations, Pages, Promise, _Dispose, _ElementUtilities, _ElementListUtilities, _Hoverable, _Constants, _Overlay) { + "use strict"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// Provides users with fast, in-context access to settings that affect the current app. + /// + /// + /// Settings Flyout + /// + /// + /// + ///
+ /// + ///
Custom Settings
+ ///
+ ///
+ /// {Your Content Here} + ///
+ /// ]]>
+ /// Raised just before showing a SettingsFlyout. + /// Raised immediately after a SettingsFlyout is fully shown. + /// Raised just before hiding a SettingsFlyout. + /// Raised immediately after a SettingsFlyout is fully hidden. + /// The SettingsFlyout control itself. + /// + /// + /// + SettingsFlyout: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + var settingsPageIsFocusedOnce; + + // Constants for width + var settingsNarrow = "narrow", + settingsWide = "wide"; + + // Determine if the settings pane (system language) is RTL or not. + function _shouldAnimateFromLeft() { + if (_WinRT.Windows.UI.ApplicationSettings.SettingsEdgeLocation) { + var appSettings = _WinRT.Windows.UI.ApplicationSettings; + return (appSettings.SettingsPane.edge === appSettings.SettingsEdgeLocation.left); + } else { + return false; + } + } + + // Get the settings control by matching the settingsCommandId + // if no match we'll try to match element id + function _getChildSettingsControl(parentElement, id) { + var settingElements = parentElement.querySelectorAll("." + _Constants.settingsFlyoutClass); + var retValue, + control; + for (var i = 0; i < settingElements.length; i++) { + control = settingElements[i].winControl; + if (control) { + if (control.settingsCommandId === id) { + retValue = control; + break; + } + if (settingElements[i].id === id) { + retValue = retValue || control; + } + } + } + + return retValue; + } + + var SettingsFlyout = _Base.Class.derive(_Overlay._Overlay, function SettingsFlyout_ctor(element, options) { + /// + /// Creates a new SettingsFlyout control. + /// + /// The DOM element that will host the control. + /// + /// + /// The set of properties and values to apply to the new SettingsFlyout. + /// + /// The new SettingsFlyout control. + /// + /// + + // Make sure there's an input element + this._element = element || _Global.document.createElement("div"); + this._id = this._element.id || _ElementUtilities._uniqueID(this._element); + this._writeProfilerMark("constructor,StartTM"); + + // Call the base overlay constructor helper + this._baseOverlayConstructor(this._element, options); + + this._addFirstDiv(); + this._addFinalDiv(); + + // Handle "esc" & "tab" key presses + this._element.addEventListener("keydown", this._handleKeyDown, true); + + // Make a click eating div + _Overlay._Overlay._createClickEatingDivAppBar(); + + // Start settings hidden + this._element.style.visibilty = "hidden"; + this._element.style.display = "none"; + + // Attach our css class + _ElementUtilities.addClass(this._element, _Constants.settingsFlyoutClass); + + // apply the light theme styling to the win-content elements inside the SettingsFlyout + _ElementListUtilities.query("div.win-content", this._element). + forEach(function (e) { + if (!_ElementUtilities._matchesSelector(e, '.win-ui-dark, .win-ui-dark *')){ + _ElementUtilities.addClass(e, _Constants.flyoutLightClass); + } + }); + + // Make sure we have an ARIA role + var role = this._element.getAttribute("role"); + if (role === null || role === "" || role === undefined) { + this._element.setAttribute("role", "dialog"); + } + var label = this._element.getAttribute("aria-label"); + if (label === null || label === "" || label === undefined) { + this._element.setAttribute("aria-label", strings.ariaLabel); + } + + // Make sure _Overlay event handlers are hooked up + this._addOverlayEventHandlers(true); + + // Make sure animations are hooked up + this._currentAnimateIn = this._animateSlideIn; + this._currentAnimateOut = this._animateSlideOut; + this._writeProfilerMark("constructor,StopTM"); + }, { + // Public Properties + + /// + /// Width of the SettingsFlyout, "narrow", or "wide". + /// + /// SettingsFlyout.width may be altered or unavailable in future versions. Instead, style the CSS width property on elements with the .win-settingsflyout class. + /// + /// + /// + width: { + get: function () { + return this._width; + }, + + set: function (value) { + _ElementUtilities._deprecated(strings.widthDeprecationMessage); + if (value === this._width) { + return; + } + // Get rid of old class + if (this._width === settingsNarrow) { + _ElementUtilities.removeClass(this._element, _Constants.narrowClass); + } else if (this._width === settingsWide) { + _ElementUtilities.removeClass(this._element, _Constants.wideClass); + } + this._width = value; + + // Attach our new css class + if (this._width === settingsNarrow) { + _ElementUtilities.addClass(this._element, _Constants.narrowClass); + } else if (this._width === settingsWide) { + _ElementUtilities.addClass(this._element, _Constants.wideClass); + } + } + }, + + /// + /// Define the settings command Id for the SettingsFlyout control. + /// + /// + settingsCommandId: { + get: function () { + return this._settingsCommandId; + }, + + set: function (value) { + this._settingsCommandId = value; + } + }, + + show: function () { + /// + /// + /// Shows the SettingsFlyout, if hidden. + /// + /// + /// + // Just call private version to make appbar flags happy + + // Don't do anything if disabled + if (this.disabled) { + return; + } + this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). + this._show(); + }, + + _dispose: function SettingsFlyout_dispose() { + _Dispose.disposeSubTree(this.element); + this._dismiss(); + }, + + _show: function SettingsFlyout_show() { + // We call our base "_baseShow" because SettingsFlyout overrides show + this._baseShow(); + // Need click-eating div to be visible, + // (even if now hiding, we'll show and need click eater) + _Overlay._Overlay._showClickEatingDivAppBar(); + }, + + _endShow: function SettingsFlyout_endShow() { + // Clean up after showing + this._initAfterAnimation(); + }, + + _initAfterAnimation: function SettingsFlyout_initAfterAnimation() { + settingsPageIsFocusedOnce = 0; + + // Verify that the firstDiv and finalDiv are in the correct location. + // Move them to the correct location or add them if they are not. + if (!_ElementUtilities.hasClass(this.element.children[0], _Constants.firstDivClass)) { + var firstDiv = this.element.querySelectorAll(".win-first"); + if (firstDiv && firstDiv.length > 0) { + firstDiv.item(0).parentNode.removeChild(firstDiv.item(0)); + } + + this._addFirstDiv(); + } + + // Set focus to the firstDiv + if (this.element.children[0]) { + _ElementUtilities._addEventListener(this.element.children[0], "focusout", function () { settingsPageIsFocusedOnce = 1; }, false); + this.element.children[0].focus(); + } + + if (!_ElementUtilities.hasClass(this.element.children[this.element.children.length - 1], _Constants.finalDivClass)) { + var finalDiv = this.element.querySelectorAll(".win-final"); + if (finalDiv && finalDiv.length > 0) { + finalDiv.item(0).parentNode.removeChild(finalDiv.item(0)); + } + + this._addFinalDiv(); + } + + this._setBackButtonsAriaLabel(); + }, + + _setBackButtonsAriaLabel: function SettingsFlyout_setBackButtonsAriaLabel() { + var backbuttons = this.element.querySelectorAll(".win-backbutton"); + var label; + for (var i = 0; i < backbuttons.length; i++) { + label = backbuttons[i].getAttribute("aria-label"); + if (label === null || label === "" || label === undefined) { + backbuttons[i].setAttribute("aria-label", strings.backbuttonAriaLabel); + } + } + }, + + hide: function () { + /// + /// + /// Hides the SettingsFlyout, if visible, regardless of other state. + /// + /// + /// + // Just call private version to make appbar flags happy + this._writeProfilerMark("hide,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndHide(). + this._hide(); + }, + + _hide: function SettingsFlyout_hide() { + if (this._baseHide()) { + // Need click-eating div to be hidden + _Overlay._Overlay._hideClickEatingDivAppBar(); + } + }, + + // SettingsFlyout animations + _animateSlideIn: function SettingsFlyout_animateSlideIn() { + var animateFromLeft = _shouldAnimateFromLeft(); + var offset = animateFromLeft ? "-100px" : "100px"; + _ElementListUtilities.query("div.win-content", this._element). + forEach(function (e) { Animations.enterPage(e, { left: offset }); }); + + var where, + width = this._element.offsetWidth; + // Slide in from right side or left side? + if (animateFromLeft) { + // RTL + where = { top: "0px", left: "-" + width + "px" }; + this._element.style.right = "auto"; + this._element.style.left = "0px"; + } else { + // From right side + where = { top: "0px", left: width + "px" }; + this._element.style.right = "0px"; + this._element.style.left = "auto"; + } + + this._element.style.opacity = 1; + this._element.style.visibility = "visible"; + + return Animations.showPanel(this._element, where); + }, + + _animateSlideOut: function SettingsFlyout_animateSlideOut() { + var where, + width = this._element.offsetWidth; + if (_shouldAnimateFromLeft()) { + // RTL + where = { top: "0px", left: width + "px" }; + this._element.style.right = "auto"; + this._element.style.left = "-" + width + "px"; + } else { + // From right side + where = { top: "0px", left: "-" + width + "px" }; + this._element.style.right = "-" + width + "px"; + this._element.style.left = "auto"; + } + + return Animations.showPanel(this._element, where); + }, + + _fragmentDiv: { + get: function SettingsFlyout_fragmentDiv_get() { + return this._fragDiv; + }, + + set: function SettingsFlyout_fragmentDiv_set(value) { + this._fragDiv = value; + } + }, + + _unloadPage: function SettingsFlyout_unloadPage(event) { + var settingsControl = event.currentTarget.winControl; + settingsControl.removeEventListener(_Overlay._Overlay.afterHide, this._unloadPage, false); + + Promise.as().then(function () { + if (settingsControl._fragmentDiv) { + _Global.document.body.removeChild(settingsControl._fragmentDiv); + settingsControl._fragmentDiv = null; + } + }); + }, + + _dismiss: function SettingsFlyout_dismiss() { + this.addEventListener(_Overlay._Overlay.afterHide, this._unloadPage, false); + this._hide(); + }, + + _handleKeyDown: function SettingsFlyout_handleKeyDown(event) { + if (event.keyCode === Key.escape) { + event.preventDefault(); + event.stopPropagation(); + this.winControl._dismiss(); + } else if ((event.keyCode === Key.space || event.keyCode === Key.enter) + && (this.children[0] === _Global.document.activeElement)) { + event.preventDefault(); + event.stopPropagation(); + this.winControl._dismiss(); + } else if (event.shiftKey && event.keyCode === Key.tab + && this.children[0] === _Global.document.activeElement) { + event.preventDefault(); + event.stopPropagation(); + var _elms = this.getElementsByTagName("*"); + + for (var i = _elms.length - 2; i >= 0; i--) { + _elms[i].focus(); + + if (_elms[i] === _Global.document.activeElement) { + break; + } + } + } + }, + + _focusOnLastFocusableElementFromParent: function SettingsFlyout_focusOnLastFocusableElementFromParent() { + var active = _Global.document.activeElement; + if (!settingsPageIsFocusedOnce || !active || !_ElementUtilities.hasClass(active, _Constants.firstDivClass)) { + return; + } + + var _elms = this.parentElement.getElementsByTagName("*"); + + // There should be at least 1 element in addition to the firstDiv & finalDiv + if (_elms.length <= 2) { + return; + } + + // Get the tabIndex set to the finalDiv (which is the highest) + var _highestTabIndex = _elms[_elms.length - 1].tabIndex; + + // If there are positive tabIndices, set focus to the element with the highest tabIndex. + // Otherwise set focus to the last focusable element in DOM order. + var i; + if (_highestTabIndex) { + for (i = _elms.length - 2; i > 0; i--) { + if (_elms[i].tabIndex === _highestTabIndex) { + _elms[i].focus(); + break; + } + } + } else { + for (i = _elms.length - 2; i > 0; i--) { + // Skip
with undefined tabIndex (To work around Win8 bug #622245) + if ((_elms[i].tagName !== "DIV") || (_elms[i].getAttribute("tabIndex") !== null)) { + _elms[i].focus(); + + if (_elms[i] === _Global.document.activeElement) { + break; + } + } + } + } + }, + + _focusOnFirstFocusableElementFromParent: function SettingsFlyout_focusOnFirstFocusableElementFromParent() { + var active = _Global.document.activeElement; + if (!active || !_ElementUtilities.hasClass(active, _Constants.finalDivClass)) { + return; + } + var _elms = this.parentElement.getElementsByTagName("*"); + + // There should be at least 1 element in addition to the firstDiv & finalDiv + if (_elms.length <= 2) { + return; + } + + // Get the tabIndex set to the firstDiv (which is the lowest) + var _lowestTabIndex = _elms[0].tabIndex; + + // If there are positive tabIndices, set focus to the element with the lowest tabIndex. + // Otherwise set focus to the first focusable element in DOM order. + var i; + if (_lowestTabIndex) { + for (i = 1; i < _elms.length - 1; i++) { + if (_elms[i].tabIndex === _lowestTabIndex) { + _elms[i].focus(); + break; + } + } + } else { + for (i = 1; i < _elms.length - 1; i++) { + // Skip
with undefined tabIndex (To work around Win8 bug #622245) + if ((_elms[i].tagName !== "DIV") || (_elms[i].getAttribute("tabIndex") !== null)) { + _elms[i].focus(); + + if (_elms[i] === _Global.document.activeElement) { + break; + } + } + } + } + }, + + // Create and add a new first div to the beginning of the list + _addFirstDiv: function SettingsFlyout_addFirstDiv() { + var _elms = this._element.getElementsByTagName("*"); + var _minTab = 0; + for (var i = 0; i < _elms.length; i++) { + if ((0 < _elms[i].tabIndex) && (_minTab === 0 || _elms[i].tabIndex < _minTab)) { + _minTab = _elms[i].tabIndex; + } + } + var firstDiv = _Global.document.createElement("div"); + firstDiv.className = _Constants.firstDivClass; + firstDiv.style.display = "inline"; + firstDiv.setAttribute("role", "menuitem"); + firstDiv.setAttribute("aria-hidden", "true"); + firstDiv.tabIndex = _minTab; + _ElementUtilities._addEventListener(firstDiv, "focusin", this._focusOnLastFocusableElementFromParent, false); + + // add to beginning + if (this._element.children[0]) { + this._element.insertBefore(firstDiv, this._element.children[0]); + } else { + this._element.appendChild(firstDiv); + } + }, + + // Create and add a new final div to the end of the list + _addFinalDiv: function SettingsFlyout_addFinalDiv() { + var _elms = this._element.getElementsByTagName("*"); + var _maxTab = 0; + for (var i = 0; i < _elms.length; i++) { + if (_elms[i].tabIndex > _maxTab) { + _maxTab = _elms[i].tabIndex; + } + } + var finalDiv = _Global.document.createElement("div"); + finalDiv.className = _Constants.finalDivClass; + finalDiv.style.display = "inline"; + finalDiv.setAttribute("role", "menuitem"); + finalDiv.setAttribute("aria-hidden", "true"); + finalDiv.tabIndex = _maxTab; + _ElementUtilities._addEventListener(finalDiv, "focusin", this._focusOnFirstFocusableElementFromParent, false); + + this._element.appendChild(finalDiv); + }, + + _writeProfilerMark: function SettingsFlyout_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI.SettingsFlyout:" + this._id + ":" + text); + } + }); + + // Statics + SettingsFlyout.show = function () { + /// + /// + /// Shows the SettingsPane UI, if hidden, regardless of other states. + /// + /// + /// + /// Show the main settings pane + if (_WinRT.Windows.UI.ApplicationSettings.SettingsPane) { + _WinRT.Windows.UI.ApplicationSettings.SettingsPane.show(); + } + // And hide the WWA one + var elements = _Global.document.querySelectorAll('div[data-win-control="WinJS.UI.SettingsFlyout"]'); + var len = elements.length; + for (var i = 0; i < len; i++) { + var settingsFlyout = elements[i].winControl; + if (settingsFlyout) { + settingsFlyout._dismiss(); + } + } + }; + + var _settingsEvent = { event: undefined }; + SettingsFlyout.populateSettings = function (e) { + /// + /// + /// Loads a portion of the SettingsFlyout. Your app calls this when the user invokes a settings command and the WinJS.Application.onsettings event occurs. + /// + /// + /// An object that contains information about the event, received from the WinJS.Application.onsettings event. The detail property of this object contains + /// the applicationcommands sub-property that you set to an array of settings commands. + /// + /// + /// + _settingsEvent.event = e.detail; + + if (_settingsEvent.event.applicationcommands) { + var n = _WinRT.Windows.UI.ApplicationSettings; + Object.keys(_settingsEvent.event.applicationcommands).forEach(function (name) { + var setting = _settingsEvent.event.applicationcommands[name]; + if (!setting.title) { setting.title = name; } + var command = new n.SettingsCommand(name, setting.title, SettingsFlyout._onSettingsCommand); + _settingsEvent.event.e.request.applicationCommands.append(command); + }); + } + }; + + SettingsFlyout._onSettingsCommand = function (command) { + var id = command.id; + if (_settingsEvent.event.applicationcommands && _settingsEvent.event.applicationcommands[id]) { + SettingsFlyout.showSettings(id, _settingsEvent.event.applicationcommands[id].href); + } + }; + + SettingsFlyout.showSettings = function (id, path) { + /// + /// + /// Show the SettingsFlyout using the settings element identifier (ID) and the path of the page that contains the settings element. + /// + /// + /// The ID of the settings element. + /// + /// + /// The path of the page that contains the settings element. + /// + /// + /// + var control = _getChildSettingsControl(_Global.document, id); + if (control) { + control.show(); + } else if (path) { + var divElement = _Global.document.createElement("div"); + divElement = _Global.document.body.appendChild(divElement); + Pages.render(path, divElement).then(function () { + control = _getChildSettingsControl(divElement, id); + if (control) { + control._fragmentDiv = divElement; + control.show(); + } else { + _Global.document.body.removeChild(divElement); + } + }); + } else { + throw new _ErrorFromName("WinJS.UI.SettingsFlyout.BadReference", strings.badReference); + } + }; + + var strings = { + get ariaLabel() { return _Resources._getWinJSString("ui/settingsFlyoutAriaLabel").value; }, + get badReference() { return "Invalid argument: Invalid href to settings flyout fragment"; }, + get backbuttonAriaLabel() { return _Resources._getWinJSString("ui/backbuttonarialabel").value; }, + get widthDeprecationMessage() { return "SettingsFlyout.width may be altered or unavailable in future versions. Instead, style the CSS width property on elements with the .win-settingsflyout class."; }, + }; + + return SettingsFlyout; + }) + }); + + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/NavBar/_Command',[ + 'exports', + '../../Core/_Global', + '../../Core/_Base', + '../../Core/_ErrorFromName', + '../../Core/_Resources', + '../../ControlProcessor', + '../../Navigation', + '../../Utilities/_Control', + '../../Utilities/_ElementUtilities', + '../AppBar/_Icon' + ], function NavBarCommandInit(exports, _Global, _Base, _ErrorFromName, _Resources, ControlProcessor, Navigation, _Control, _ElementUtilities, _Icon) { + "use strict"; + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + _WinPressed: _Base.Namespace._lazy(function () { + var WinPressed = _Base.Class.define(function _WinPressed_ctor(element) { + // WinPressed is the combination of :hover:active + // :hover is delayed by trident for touch by 300ms so if you want :hover:active to work quickly you need to + // use this behavior. + // :active does not bubble to its parent like :hover does so this is also useful for that scenario. + this._element = element; + _ElementUtilities._addEventListener(this._element, "pointerdown", this._MSPointerDownButtonHandler.bind(this)); + }, { + _MSPointerDownButtonHandler: function _WinPressed_MSPointerDownButtonHandler(ev) { + if (!this._pointerUpBound) { + this._pointerUpBound = this._MSPointerUpHandler.bind(this); + this._pointerCancelBound = this._MSPointerCancelHandler.bind(this); + this._pointerOverBound = this._MSPointerOverHandler.bind(this); + this._pointerOutBound = this._MSPointerOutHandler.bind(this); + } + + if (ev.isPrimary) { + if (this._pointerId) { + this._resetPointer(); + } + + if (!_ElementUtilities._matchesSelector(ev.target, ".win-interactive, .win-interactive *")) { + this._pointerId = ev.pointerId; + + _ElementUtilities._addEventListener(_Global, "pointerup", this._pointerUpBound, true); + _ElementUtilities._addEventListener(_Global, "pointercancel", this._pointerCancelBound), true; + _ElementUtilities._addEventListener(this._element, "pointerover", this._pointerOverBound, true); + _ElementUtilities._addEventListener(this._element, "pointerout", this._pointerOutBound, true); + + _ElementUtilities.addClass(this._element, WinPressed.winPressed); + } + } + }, + + _MSPointerOverHandler: function _WinPressed_MSPointerOverHandler(ev) { + if (this._pointerId === ev.pointerId) { + _ElementUtilities.addClass(this._element, WinPressed.winPressed); + } + }, + + _MSPointerOutHandler: function _WinPressed_MSPointerOutHandler(ev) { + if (this._pointerId === ev.pointerId) { + _ElementUtilities.removeClass(this._element, WinPressed.winPressed); + } + }, + + _MSPointerCancelHandler: function _WinPressed_MSPointerCancelHandler(ev) { + if (this._pointerId === ev.pointerId) { + this._resetPointer(); + } + }, + + _MSPointerUpHandler: function _WinPressed_MSPointerUpHandler(ev) { + if (this._pointerId === ev.pointerId) { + this._resetPointer(); + } + }, + + _resetPointer: function _WinPressed_resetPointer() { + this._pointerId = null; + + _ElementUtilities._removeEventListener(_Global, "pointerup", this._pointerUpBound, true); + _ElementUtilities._removeEventListener(_Global, "pointercancel", this._pointerCancelBound, true); + _ElementUtilities._removeEventListener(this._element, "pointerover", this._pointerOverBound, true); + _ElementUtilities._removeEventListener(this._element, "pointerout", this._pointerOutBound, true); + + _ElementUtilities.removeClass(this._element, WinPressed.winPressed); + }, + + dispose: function _WinPressed_dispose() { + if (this._disposed) { + return; + } + this._disposed = true; + + this._resetPointer(); + } + }, { + winPressed: "win-pressed" + }); + + return WinPressed; + }), + /// + /// + /// Represents a navigation command in an NavBarContainer. + /// + /// + /// + /// + /// + ///
]]> + /// Styles the entire NavBarCommand control. + /// Styles the main button in a NavBarCommand. + /// Styles the split button in a NavBarCommand + /// Styles the icon in the main button of a NavBarCommand. + /// Styles the label in the main button of a NavBarCommand. + /// + /// + /// + NavBarCommand: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + var strings = { + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; } + }; + + var NavBarCommand = _Base.Class.define(function NavBarCommand_ctor(element, options) { + /// + /// + /// Creates a new NavBarCommand. + /// + /// + /// The DOM element that will host the new NavBarCommand control. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. + /// Each property of the options object corresponds to one of the control's properties or events. + /// Event names must begin with "on". + /// + /// + /// The new NavBarCommand. + /// + /// + /// + element = element || _Global.document.createElement("DIV"); + options = options || {}; + + if (element.winControl) { + throw new _ErrorFromName("WinJS.UI.NavBarCommand.DuplicateConstruction", strings.duplicateConstruction); + } + + // Attaching JS control to DOM element + element.winControl = this; + this._element = element; + _ElementUtilities.addClass(this.element, NavBarCommand._ClassName.navbarcommand); + _ElementUtilities.addClass(this.element, "win-disposable"); + + this._tooltip = null; + this._splitOpened = false; + this._buildDom(); + element.addEventListener('keydown', this._keydownHandler.bind(this)); + + _Control.setOptions(this, options); + }, { + /// + element: { + get: function () { + return this._element; + } + }, + + /// + /// Gets or sets the label of the NavBarCommand. + /// + /// + label: { + get: function () { + return this._label; + }, + set: function (value) { + this._label = value; + this._labelEl.textContent = value; + } + }, + + /// + /// Gets or sets the tooltip of the NavBarCommand. + /// + /// + tooltip: { + get: function () { + return this._tooltip; + }, + set: function (value) { + this._tooltip = value; + if (this._tooltip || this._tooltip === "") { + this._element.setAttribute('title', this._tooltip); + } else { + this._element.removeAttribute('title'); + } + } + }, + + /// + /// Gets or sets the icon of the NavBarCommand. This value is either one of the values of the AppBarIcon enumeration or the path of a custom PNG file. + /// + /// + icon: { + get: function () { + return this._icon; + }, + set: function (value) { + this._icon = (_Icon[value] || value); + + // If the icon's a single character, presume a glyph + if (this._icon && this._icon.length === 1) { + // Set the glyph + this._imageSpan.textContent = this._icon; + this._imageSpan.style.backgroundImage = ""; + this._imageSpan.style.msHighContrastAdjust = ""; + this._imageSpan.style.display = ""; + } else if (this._icon && this._icon.length > 1) { + // Must be an image, set that + this._imageSpan.textContent = ""; + this._imageSpan.style.backgroundImage = this._icon; + this._imageSpan.style.msHighContrastAdjust = "none"; + this._imageSpan.style.display = ""; + } else { + this._imageSpan.textContent = ""; + this._imageSpan.style.backgroundImage = ""; + this._imageSpan.style.msHighContrastAdjust = ""; + this._imageSpan.style.display = "none"; + } + } + }, + + /// + /// Gets or sets the command's target location. + /// + /// + location: { + get: function () { + return this._location; + }, + set: function (value) { + this._location = value; + } + }, + + /// + /// Gets or sets the state value used for navigation. The command passes this object to the WinJS.Navigation.navigate function. + /// + /// + state: { + get: function () { + return this._state; + }, + set: function (value) { + this._state = value; + } + }, + + /// + /// Gets or sets a value that specifies whether the NavBarCommand has a split button. + /// + /// + splitButton: { + get: function () { + return this._split; + }, + set: function (value) { + this._split = value; + if (this._split) { + this._splitButtonEl.style.display = ""; + } else { + this._splitButtonEl.style.display = "none"; + } + } + }, + + /// + splitOpened: { + get: function () { + return this._splitOpened; + }, + set: function (value) { + if (this._splitOpened !== !!value) { + this._toggleSplit(); + } + } + }, + + _toggleSplit: function NavBarCommand_toggleSplit() { + this._splitOpened = !this._splitOpened; + if (this._splitOpened) { + _ElementUtilities.addClass(this._splitButtonEl, NavBarCommand._ClassName.navbarcommandsplitbuttonopened); + this._splitButtonEl.setAttribute("aria-expanded", "true"); + } else { + _ElementUtilities.removeClass(this._splitButtonEl, NavBarCommand._ClassName.navbarcommandsplitbuttonopened); + this._splitButtonEl.setAttribute("aria-expanded", "false"); + } + this._fireEvent(NavBarCommand._EventName._splitToggle); + }, + + _rtl: { + get: function () { + return _Global.getComputedStyle(this.element).direction === "rtl"; + } + }, + + _keydownHandler: function NavBarCommand_keydownHandler(ev) { + if (_ElementUtilities._matchesSelector(ev.target, ".win-interactive, .win-interactive *")) { + return; + } + + var leftStr = this._rtl ? Key.rightArrow : Key.leftArrow; + var rightStr = this._rtl ? Key.leftArrow : Key.rightArrow; + + if (!ev.altKey && (ev.keyCode === leftStr || ev.keyCode === Key.home || ev.keyCode === Key.end) && ev.target === this._splitButtonEl) { + _ElementUtilities._setActive(this._buttonEl); + if (ev.keyCode === leftStr) { + ev.stopPropagation(); + } + ev.preventDefault(); + } else if (!ev.altKey && ev.keyCode === rightStr && this.splitButton && (ev.target === this._buttonEl || this._buttonEl.contains(ev.target))) { + _ElementUtilities._setActive(this._splitButtonEl); + if (ev.keyCode === rightStr) { + ev.stopPropagation(); + } + ev.preventDefault(); + } else if ((ev.keyCode === Key.space || ev.keyCode === Key.enter) && (ev.target === this._buttonEl || this._buttonEl.contains(ev.target))) { + if (this.location) { + Navigation.navigate(this.location, this.state); + } + this._fireEvent(NavBarCommand._EventName._invoked); + } else if ((ev.keyCode === Key.space || ev.keyCode === Key.enter) && ev.target === this._splitButtonEl) { + this._toggleSplit(); + } + }, + + _getFocusInto: function NavBarCommand_getFocusInto(keyCode) { + var leftStr = this._rtl ? Key.rightArrow : Key.leftArrow; + if ((keyCode === leftStr) && this.splitButton) { + return this._splitButtonEl; + } else { + return this._buttonEl; + } + }, + + _buildDom: function NavBarCommand_buildDom() { + var markup = + '' + + ''; + this.element.insertAdjacentHTML("afterBegin", markup); + + this._buttonEl = this.element.firstElementChild; + this._buttonPressedBehavior = new exports._WinPressed(this._buttonEl); + this._contentEl = this._buttonEl.firstElementChild; + this._imageSpan = this._contentEl.firstElementChild; + this._imageSpan.style.display = "none"; + this._labelEl = this._imageSpan.nextElementSibling; + this._splitButtonEl = this._buttonEl.nextElementSibling; + this._splitButtonPressedBehavior = new exports._WinPressed(this._splitButtonEl); + this._splitButtonEl.style.display = "none"; + + _ElementUtilities._ensureId(this._buttonEl); + this._splitButtonEl.setAttribute("aria-labelledby", this._buttonEl.id); + + this._buttonEl.addEventListener("click", this._handleButtonClick.bind(this)); + + var mutationObserver = new _ElementUtilities._MutationObserver(this._splitButtonAriaExpandedPropertyChangeHandler.bind(this)); + mutationObserver.observe(this._splitButtonEl, { attributes: true, attributeFilter: ["aria-expanded"] }); + this._splitButtonEl.addEventListener("click", this._handleSplitButtonClick.bind(this)); + + // reparent any other elements. + var tempEl = this._splitButtonEl.nextSibling; + while (tempEl) { + this._buttonEl.insertBefore(tempEl, this._contentEl); + if (tempEl.nodeName !== "#text") { + ControlProcessor.processAll(tempEl); + } + tempEl = this._splitButtonEl.nextSibling; + } + }, + + _handleButtonClick: function NavBarCommand_handleButtonClick(ev) { + var srcElement = ev.target; + if (!_ElementUtilities._matchesSelector(srcElement, ".win-interactive, .win-interactive *")) { + if (this.location) { + Navigation.navigate(this.location, this.state); + } + this._fireEvent(NavBarCommand._EventName._invoked); + } + }, + + _splitButtonAriaExpandedPropertyChangeHandler: function NavBarCommand_splitButtonAriaExpandedPropertyChangeHandler() { + if ((this._splitButtonEl.getAttribute("aria-expanded") === "true") !== this._splitOpened) { + this._toggleSplit(); + } + }, + + _handleSplitButtonClick: function NavBarCommand_handleSplitButtonClick() { + this._toggleSplit(); + }, + + _fireEvent: function NavBarCommand_fireEvent(type, detail) { + var event = _Global.document.createEvent("CustomEvent"); + event.initCustomEvent(type, true, false, detail); + this.element.dispatchEvent(event); + }, + + dispose: function NavBarCommand_dispose() { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + + this._buttonPressedBehavior.dispose(); + this._splitButtonPressedBehavior.dispose(); + } + }, { + _ClassName: { + navbarcommand: "win-navbarcommand", + navbarcommandbutton: "win-navbarcommand-button", + navbarcommandbuttoncontent: "win-navbarcommand-button-content", + navbarcommandsplitbutton: "win-navbarcommand-splitbutton", + navbarcommandsplitbuttonopened: "win-navbarcommand-splitbutton-opened", + navbarcommandicon: "win-navbarcommand-icon", + navbarcommandlabel: "win-navbarcommand-label" + }, + _EventName: { + _invoked: "_invoked", + _splitToggle: "_splittoggle" + } + }); + _Base.Class.mix(NavBarCommand, _Control.DOMEventMixin); + return NavBarCommand; + }) + }); + +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/NavBar/_Container',[ + 'exports', + '../../Core/_Global', + '../../Core/_Base', + '../../Core/_BaseUtils', + '../../Core/_ErrorFromName', + '../../Core/_Events', + '../../Core/_Log', + '../../Core/_Resources', + '../../Core/_WriteProfilerMark', + '../../Animations', + '../../Animations/_TransitionAnimation', + '../../BindingList', + '../../ControlProcessor', + '../../Navigation', + '../../Promise', + '../../Scheduler', + '../../Utilities/_Control', + '../../Utilities/_ElementUtilities', + '../../Utilities/_KeyboardBehavior', + '../../Utilities/_UI', + '../AppBar/_Constants', + '../Repeater', + './_Command' + ], function NavBarContainerInit(exports, _Global, _Base, _BaseUtils, _ErrorFromName, _Events, _Log, _Resources, _WriteProfilerMark, Animations, _TransitionAnimation, BindingList, ControlProcessor, Navigation, Promise, Scheduler, _Control, _ElementUtilities, _KeyboardBehavior, _UI, _Constants, Repeater, _Command) { + "use strict"; + + function nobodyHasFocus() { + return _Global.document.activeElement === null || _Global.document.activeElement === _Global.document.body; + } + + _Base.Namespace._moduleDefine(exports, "WinJS.UI", { + /// + /// + /// Contains a group of NavBarCommand objects in a NavBar. + /// + /// + /// + /// + /// + /// + ///
+ ///
]]> + /// Raised when a NavBarCommand is invoked. + /// Raised when the split button on a NavBarCommand is toggled. + /// Styles the entire NavBarContainer control. + /// + /// Styles the page indication for the NavBarContainer. + /// + /// Styles the page indication for each page. + /// + /// Styles the indication of the current page. + /// + /// Styles the area that contains items for the NavBarContainer. + /// Styles left and right navigation arrows. + /// Styles the left navigation arrow. + /// Styles the right navigation arrow. + /// + /// + /// + NavBarContainer: _Base.Namespace._lazy(function () { + var Key = _ElementUtilities.Key; + + var buttonFadeDelay = 3000; + var PT_TOUCH = _ElementUtilities._MSPointerEvent.MSPOINTER_TYPE_TOUCH || "touch"; + var MS_MANIPULATION_STATE_STOPPED = 0; + + var createEvent = _Events._createEventProperty; + var eventNames = { + invoked: "invoked", + splittoggle: "splittoggle" + }; + + var strings = { + get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, + get navBarContainerViewportAriaLabel() { return _Resources._getWinJSString("ui/navBarContainerViewportAriaLabel").value; } + }; + + var NavBarContainer = _Base.Class.define(function NavBarContainer_ctor(element, options) { + /// + /// + /// Creates a new NavBarContainer. + /// + /// + /// The DOM element that will host the NavBarContainer control. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. + /// Each property of the options object corresponds to one of the control's properties or events. + /// Event names must begin with "on". + /// + /// + /// The new NavBarContainer. + /// + /// + /// + + element = element || _Global.document.createElement("DIV"); + this._id = element.id || _ElementUtilities._uniqueID(element); + this._writeProfilerMark("constructor,StartTM"); + + options = options || {}; + + if (element.winControl) { + throw new _ErrorFromName("WinJS.UI.NavBarContainer.DuplicateConstruction", strings.duplicateConstruction); + } + + // Attaching JS control to DOM element + element.winControl = this; + this._element = element; + _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.navbarcontainer); + _ElementUtilities.addClass(this.element, "win-disposable"); + if (!element.getAttribute("tabIndex")) { + element.tabIndex = -1; + } + + this._focusCurrentItemPassivelyBound = this._focusCurrentItemPassively.bind(this); + this._closeSplitAndResetBound = this._closeSplitAndReset.bind(this); + this._currentManipulationState = MS_MANIPULATION_STATE_STOPPED; + + this._panningDisabled = !_ElementUtilities._supportsSnapPoints; + this._fixedSize = false; + this._maxRows = 1; + this._sizes = {}; + + this._setupTree(); + + this._duringConstructor = true; + + this._dataChangingBound = this._dataChanging.bind(this); + this._dataChangedBound = this._dataChanged.bind(this); + + Navigation.addEventListener('navigated', this._closeSplitAndResetBound); + + // Don't use set options for the properties so we can control the ordering to avoid rendering multiple times. + this.layout = options.layout || _UI.Orientation.horizontal; + if (options.maxRows) { + this.maxRows = options.maxRows; + } + if (options.template) { + this.template = options.template; + } + if (options.data) { + this.data = options.data; + } + if (options.fixedSize) { + this.fixedSize = options.fixedSize; + } + + // Events only + _Control._setOptions(this, options, true); + + this._duringConstructor = false; + + if (options.currentIndex) { + this.currentIndex = options.currentIndex; + } + + this._updatePageUI(); + + Scheduler.schedule(function NavBarContainer_async_initialize() { + this._updateAppBarReference(); + }, Scheduler.Priority.normal, this, "WinJS.UI.NavBarContainer_async_initialize"); + + this._writeProfilerMark("constructor,StopTM"); + }, { + /// + element: { + get: function () { + return this._element; + } + }, + + /// + /// Gets or sets a Template or custom rendering function that defines the HTML of each item within the NavBarContainer. + /// + /// + template: { + get: function () { + return this._template; + }, + set: function (value) { + this._template = value; + if (this._repeater) { + var hadFocus = this.element.contains(_Global.document.activeElement); + + if (!this._duringConstructor) { + this._closeSplitIfOpen(); + } + + // the repeater's template is wired up to this._render() so just resetting it will rebuild the tree. + this._repeater.template = this._repeater.template; + + if (!this._duringConstructor) { + this._measured = false; + this._sizes.itemMeasured = false; + this._reset(); + if (hadFocus) { + this._keyboardBehavior._focus(0); + } + } + } + } + }, + + _render: function NavBarContainer_render(item) { + var navbarCommandEl = _Global.document.createElement('div'); + + var template = this._template; + if (template) { + if (template.render) { + template.render(item, navbarCommandEl); + } else if (template.winControl && template.winControl.render) { + template.winControl.render(item, navbarCommandEl); + } else { + navbarCommandEl.appendChild(template(item)); + } + } + + // Create the NavBarCommand after calling render so that the reparenting in navbarCommand works. + var navbarCommand = new _Command.NavBarCommand(navbarCommandEl, item); + return navbarCommand._element; + }, + + /// + /// Gets or sets the WinJS.Binding.List that provides the NavBarContainer with items to display. + /// + /// + data: { + get: function () { + return this._repeater && this._repeater.data; + }, + set: function (value) { + if (!value) { + value = new BindingList.List(); + } + + if (!this._duringConstructor) { + this._closeSplitIfOpen(); + } + + this._removeDataChangingEvents(); + this._removeDataChangedEvents(); + + var hadFocus = this.element.contains(_Global.document.activeElement); + + if (!this._repeater) { + this._surfaceEl.innerHTML = ""; + this._repeater = new Repeater.Repeater(this._surfaceEl, { + template: this._render.bind(this) + }); + } + + this._addDataChangingEvents(value); + this._repeater.data = value; + this._addDataChangedEvents(value); + + if (!this._duringConstructor) { + this._measured = false; + this._sizes.itemMeasured = false; + this._reset(); + if (hadFocus) { + this._keyboardBehavior._focus(0); + } + } + } + }, + + /// + /// Gets or sets the number of rows allowed to be used before items are placed on additional pages. + /// + /// + maxRows: { + get: function () { + return this._maxRows; + }, + set: function (value) { + value = (+value === value) ? value : 1; + this._maxRows = Math.max(1, value); + + if (!this._duringConstructor) { + this._closeSplitIfOpen(); + + this._measured = false; + this._reset(); + } + } + }, + + /// + /// Gets or sets a value that specifies whether the NavBarContainer has a horizontal or vertical layout. The default is "horizontal". + /// + /// + layout: { + get: function () { + return this._layout; + }, + set: function (value) { + if (value === _UI.Orientation.vertical) { + this._layout = _UI.Orientation.vertical; + _ElementUtilities.removeClass(this.element, NavBarContainer._ClassName.horizontal); + _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.vertical); + } else { + this._layout = _UI.Orientation.horizontal; + _ElementUtilities.removeClass(this.element, NavBarContainer._ClassName.vertical); + _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.horizontal); + } + + this._viewportEl.style.msScrollSnapType = ""; + this._zooming = false; + + if (!this._duringConstructor) { + this._measured = false; + this._sizes.itemMeasured = false; + this._ensureVisible(this._keyboardBehavior.currentIndex, true); + this._updatePageUI(); + this._closeSplitIfOpen(); + } + } + }, + + /// + currentIndex: { + get: function () { + return this._keyboardBehavior.currentIndex; + }, + set: function (value) { + if (value === +value) { + var hadFocus = this.element.contains(_Global.document.activeElement); + + this._keyboardBehavior.currentIndex = value; + + this._ensureVisible(this._keyboardBehavior.currentIndex, true); + + if (hadFocus) { + this._keyboardBehavior._focus(); + } + } + } + }, + + /// + /// Gets or sets a value that specifies whether child NavBarCommand objects should be a fixed width when there are multiple pages. A value of true indicates + /// that the NavBarCommand objects use a fixed width; a value of false indicates that they use a dynamic width. + /// + /// + fixedSize: { + get: function () { + return this._fixedSize; + }, + set: function (value) { + this._fixedSize = !!value; + + if (!this._duringConstructor) { + this._closeSplitIfOpen(); + + if (!this._measured) { + this._measure(); + } else if (this._surfaceEl.children.length > 0) { + this._updateGridStyles(); + } + } + } + }, + + /// + /// Raised when a NavBarCommand has been invoked. + /// + /// + oninvoked: createEvent(eventNames.invoked), + + /// + /// Raised when the split button on a NavBarCommand is toggled. + /// + /// + onsplittoggle: createEvent(eventNames.splittoggle), + + forceLayout: function NavBarContainer_forceLayout() { + /// + /// + /// Forces the NavBarContainer to update scroll positions and if the NavBar has changed size, it will also re-measure. + /// Use this function when making the NavBarContainer visible again after you set its style.display property to "none". + /// + /// + /// + this._resizeHandler(); + if (this._measured) { + this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportEl)[(this.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")]; + } + + this._duringForceLayout = true; + this._ensureVisible(this._keyboardBehavior.currentIndex, true); + this._updatePageUI(); + this._duringForceLayout = false; + }, + + _updateAppBarReference: function NavBarContainer_updateAppBarReference() { + if (!this._appBarEl || !this._appBarEl.contains(this.element)) { + if (this._appBarEl) { + this._appBarEl.removeEventListener('beforeshow', this._closeSplitAndResetBound); + this._appBarEl.removeEventListener('beforeshow', this._resizeImplBound); + this._appBarEl.removeEventListener('aftershow', this._focusCurrentItemPassivelyBound); + } + + var appBarEl = this.element.parentNode; + while (appBarEl && !_ElementUtilities.hasClass(appBarEl, _Constants.appBarClass)) { + appBarEl = appBarEl.parentNode; + } + this._appBarEl = appBarEl; + + if (this._appBarEl) { + this._appBarEl.addEventListener('beforeshow', this._closeSplitAndResetBound); + this._appBarEl.addEventListener('aftershow', this._focusCurrentItemPassivelyBound); + } + } + }, + + _closeSplitAndReset: function NavBarContainer_closeSplitAndReset() { + this._closeSplitIfOpen(); + this._reset(); + }, + + _dataChanging: function NavBarContainer_dataChanging(ev) { + // Store the element that was active so that we can detect + // if the focus went away because of the data change. + this._elementHadFocus = _Global.document.activeElement; + + if (this._currentSplitNavItem && this._currentSplitNavItem.splitOpened) { + if (ev.type === "itemremoved") { + if (this._surfaceEl.children[ev.detail.index].winControl === this._currentSplitNavItem) { + this._closeSplitIfOpen(); + } + } else if (ev.type === "itemchanged") { + if (this._surfaceEl.children[ev.detail.index].winControl === this._currentSplitNavItem) { + this._closeSplitIfOpen(); + } + } else if (ev.type === "itemmoved") { + if (this._surfaceEl.children[ev.detail.oldIndex].winControl === this._currentSplitNavItem) { + this._closeSplitIfOpen(); + } + } else if (ev.type === "reload") { + this._closeSplitIfOpen(); + } + } + }, + + _dataChanged: function NavBarContainer_dataChanged(ev) { + this._measured = false; + + if (ev.type === "itemremoved") { + if (ev.detail.index < this._keyboardBehavior.currentIndex) { + this._keyboardBehavior.currentIndex--; + } else if (ev.detail.index === this._keyboardBehavior.currentIndex) { + // This clamps if the item being removed was the last item in the list + this._keyboardBehavior.currentIndex = this._keyboardBehavior.currentIndex; + if (nobodyHasFocus() && this._elementHadFocus) { + this._keyboardBehavior._focus(); + } + } + } else if (ev.type === "itemchanged") { + if (ev.detail.index === this._keyboardBehavior.currentIndex) { + if (nobodyHasFocus() && this._elementHadFocus) { + this._keyboardBehavior._focus(); + } + } + } else if (ev.type === "iteminserted") { + if (ev.detail.index <= this._keyboardBehavior.currentIndex) { + this._keyboardBehavior.currentIndex++; + } + } else if (ev.type === "itemmoved") { + if (ev.detail.oldIndex === this._keyboardBehavior.currentIndex) { + this._keyboardBehavior.currentIndex = ev.detail.newIndex; + if (nobodyHasFocus() && this._elementHadFocus) { + this._keyboardBehavior._focus(); + } + } + } else if (ev.type === "reload") { + this._keyboardBehavior.currentIndex = 0; + if (nobodyHasFocus() && this._elementHadFocus) { + this._keyboardBehavior._focus(); + } + } + + this._ensureVisible(this._keyboardBehavior.currentIndex, true); + this._updatePageUI(); + }, + + _focusCurrentItemPassively: function NavBarContainer_focusCurrentItemPassively() { + if (this.element.contains(_Global.document.activeElement)) { + this._keyboardBehavior._focus(); + } + }, + + _reset: function NavBarContainer_reset() { + this._keyboardBehavior.currentIndex = 0; + + if (this.element.contains(_Global.document.activeElement)) { + this._keyboardBehavior._focus(0); + } + + this._viewportEl.style.msScrollSnapType = ""; + this._zooming = false; + + this._ensureVisible(0, true); + this._updatePageUI(); + }, + + _removeDataChangedEvents: function NavBarContainer_removeDataChangedEvents() { + if (this._repeater) { + this._repeater.data.removeEventListener("itemchanged", this._dataChangedBound); + this._repeater.data.removeEventListener("iteminserted", this._dataChangedBound); + this._repeater.data.removeEventListener("itemmoved", this._dataChangedBound); + this._repeater.data.removeEventListener("itemremoved", this._dataChangedBound); + this._repeater.data.removeEventListener("reload", this._dataChangedBound); + } + }, + + _addDataChangedEvents: function NavBarContainer_addDataChangedEvents() { + if (this._repeater) { + this._repeater.data.addEventListener("itemchanged", this._dataChangedBound); + this._repeater.data.addEventListener("iteminserted", this._dataChangedBound); + this._repeater.data.addEventListener("itemmoved", this._dataChangedBound); + this._repeater.data.addEventListener("itemremoved", this._dataChangedBound); + this._repeater.data.addEventListener("reload", this._dataChangedBound); + } + }, + + _removeDataChangingEvents: function NavBarContainer_removeDataChangingEvents() { + if (this._repeater) { + this._repeater.data.removeEventListener("itemchanged", this._dataChangingBound); + this._repeater.data.removeEventListener("iteminserted", this._dataChangingBound); + this._repeater.data.removeEventListener("itemmoved", this._dataChangingBound); + this._repeater.data.removeEventListener("itemremoved", this._dataChangingBound); + this._repeater.data.removeEventListener("reload", this._dataChangingBound); + } + }, + + _addDataChangingEvents: function NavBarContainer_addDataChangingEvents(bindingList) { + bindingList.addEventListener("itemchanged", this._dataChangingBound); + bindingList.addEventListener("iteminserted", this._dataChangingBound); + bindingList.addEventListener("itemmoved", this._dataChangingBound); + bindingList.addEventListener("itemremoved", this._dataChangingBound); + bindingList.addEventListener("reload", this._dataChangingBound); + }, + + _mouseleave: function NavBarContainer_mouseleave() { + if (this._mouseInViewport) { + this._mouseInViewport = false; + this._updateArrows(); + } + }, + + _MSPointerDown: function NavBarContainer_MSPointerDown(ev) { + if (ev.pointerType === PT_TOUCH) { + if (this._mouseInViewport) { + this._mouseInViewport = false; + this._updateArrows(); + } + } + }, + + _MSPointerMove: function NavBarContainer_MSPointerMove(ev) { + if (ev.pointerType !== PT_TOUCH) { + if (!this._mouseInViewport) { + this._mouseInViewport = true; + this._updateArrows(); + } + } + }, + + _setupTree: function NavBarContainer_setupTree() { + this._animateNextPreviousButtons = Promise.wrap(); + this._element.addEventListener('mouseleave', this._mouseleave.bind(this)); + _ElementUtilities._addEventListener(this._element, 'pointerdown', this._MSPointerDown.bind(this)); + _ElementUtilities._addEventListener(this._element, 'pointermove', this._MSPointerMove.bind(this)); + _ElementUtilities._addEventListener(this._element, "focusin", this._focusHandler.bind(this), false); + + this._pageindicatorsEl = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._pageindicatorsEl, NavBarContainer._ClassName.pageindicators); + this._element.appendChild(this._pageindicatorsEl); + + this._ariaStartMarker = _Global.document.createElement("div"); + this._element.appendChild(this._ariaStartMarker); + + this._viewportEl = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._viewportEl, NavBarContainer._ClassName.viewport); + this._element.appendChild(this._viewportEl); + this._viewportEl.setAttribute("role", "group"); + this._viewportEl.setAttribute("aria-label", strings.navBarContainerViewportAriaLabel); + + this._boundResizeHandler = this._resizeHandler.bind(this); + _ElementUtilities._resizeNotifier.subscribe(this._element, this._boundResizeHandler); + this._viewportEl.addEventListener("mselementresize", this._resizeHandler.bind(this)); + this._viewportEl.addEventListener("scroll", this._scrollHandler.bind(this)); + this._viewportEl.addEventListener("MSManipulationStateChanged", this._MSManipulationStateChangedHandler.bind(this)); + + this._ariaEndMarker = _Global.document.createElement("div"); + this._element.appendChild(this._ariaEndMarker); + + this._surfaceEl = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._surfaceEl, NavBarContainer._ClassName.surface); + this._viewportEl.appendChild(this._surfaceEl); + + this._surfaceEl.addEventListener("_invoked", this._navbarCommandInvokedHandler.bind(this)); + this._surfaceEl.addEventListener("_splittoggle", this._navbarCommandSplitToggleHandler.bind(this)); + _ElementUtilities._addEventListener(this._surfaceEl, "focusin", this._itemsFocusHandler.bind(this), false); + this._surfaceEl.addEventListener("keydown", this._keyDownHandler.bind(this)); + + // Reparent NavBarCommands which were in declarative markup + var tempEl = this.element.firstElementChild; + while (tempEl !== this._pageindicatorsEl) { + this._surfaceEl.appendChild(tempEl); + ControlProcessor.process(tempEl); + tempEl = this.element.firstElementChild; + } + + this._leftArrowEl = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._leftArrowEl, NavBarContainer._ClassName.navleftarrow); + _ElementUtilities.addClass(this._leftArrowEl, NavBarContainer._ClassName.navarrow); + this._element.appendChild(this._leftArrowEl); + this._leftArrowEl.addEventListener('click', this._goLeft.bind(this)); + this._leftArrowEl.style.opacity = 0; + this._leftArrowEl.style.visibility = 'hidden'; + this._leftArrowFadeOut = Promise.wrap(); + + this._rightArrowEl = _Global.document.createElement('div'); + _ElementUtilities.addClass(this._rightArrowEl, NavBarContainer._ClassName.navrightarrow); + _ElementUtilities.addClass(this._rightArrowEl, NavBarContainer._ClassName.navarrow); + this._element.appendChild(this._rightArrowEl); + this._rightArrowEl.addEventListener('click', this._goRight.bind(this)); + this._rightArrowEl.style.opacity = 0; + this._rightArrowEl.style.visibility = 'hidden'; + this._rightArrowFadeOut = Promise.wrap(); + + this._keyboardBehavior = new _KeyboardBehavior._KeyboardBehavior(this._surfaceEl, { + scroller: this._viewportEl + }); + this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._surfaceEl); + }, + + _goRight: function NavBarContainer_goRight() { + if (this._sizes.rtl) { + this._goPrev(); + } else { + this._goNext(); + } + }, + + _goLeft: function NavBarContainer_goLeft() { + if (this._sizes.rtl) { + this._goNext(); + } else { + this._goPrev(); + } + }, + + _goNext: function NavBarContainer_goNext() { + this._measure(); + var itemsPerPage = this._sizes.rowsPerPage * this._sizes.columnsPerPage; + var targetPage = Math.min(Math.floor(this._keyboardBehavior.currentIndex / itemsPerPage) + 1, this._sizes.pages - 1); + this._keyboardBehavior.currentIndex = Math.min(itemsPerPage * targetPage, this._surfaceEl.children.length); + this._keyboardBehavior._focus(); + }, + + _goPrev: function NavBarContainer_goPrev() { + this._measure(); + var itemsPerPage = this._sizes.rowsPerPage * this._sizes.columnsPerPage; + var targetPage = Math.max(0, Math.floor(this._keyboardBehavior.currentIndex / itemsPerPage) - 1); + this._keyboardBehavior.currentIndex = Math.max(itemsPerPage * targetPage, 0); + this._keyboardBehavior._focus(); + }, + + _currentPage: { + get: function () { + if (this.layout === _UI.Orientation.horizontal) { + this._measure(); + if (this._sizes.viewportOffsetWidth > 0) { + return Math.min(this._sizes.pages - 1, Math.round(this._scrollPosition / this._sizes.viewportOffsetWidth)); + } + } + return 0; + } + }, + + _resizeHandler: function NavBarContainer_resizeHandler() { + if (this._disposed) { return; } + if (!this._measured) { return; } + var viewportResized = this.layout === _UI.Orientation.horizontal + ? this._sizes.viewportOffsetWidth !== parseFloat(_Global.getComputedStyle(this._viewportEl).width) + : this._sizes.viewportOffsetHeight !== parseFloat(_Global.getComputedStyle(this._viewportEl).height); + if (!viewportResized) { return; } + + this._measured = false; + + if (!this._pendingResize) { + this._pendingResize = true; + + this._resizeImplBound = this._resizeImplBound || this._resizeImpl.bind(this); + + this._updateAppBarReference(); + + if (this._appBarEl && this._appBarEl.winControl && this._appBarEl.winControl.hidden) { + // Do resize lazily. + Scheduler.schedule(this._resizeImplBound, Scheduler.Priority.idle, null, "WinJS.UI.NavBarContainer._resizeImpl"); + this._appBarEl.addEventListener('beforeshow', this._resizeImplBound); + } else { + // Do resize now + this._resizeImpl(); + } + } + }, + + _resizeImpl: function NavBarContainer_resizeImpl() { + if (!this._disposed && this._pendingResize) { + this._pendingResize = false; + if (this._appBarEl) { + this._appBarEl.removeEventListener('beforeshow', this._resizeImplBound); + } + + this._keyboardBehavior.currentIndex = 0; + if (this.element.contains(_Global.document.activeElement)) { + this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); + } + this._closeSplitIfOpen(); + this._ensureVisible(this._keyboardBehavior.currentIndex, true); + this._updatePageUI(); + } + }, + + _keyDownHandler: function NavBarContainer_keyDownHandler(ev) { + var keyCode = ev.keyCode; + if (!ev.altKey && (keyCode === Key.pageUp || keyCode === Key.pageDown)) { + var srcElement = ev.target; + if (_ElementUtilities._matchesSelector(srcElement, ".win-interactive, .win-interactive *")) { + return; + } + + var index = this._keyboardBehavior.currentIndex; + this._measure(); + + var sizes = this._sizes; + var page = Math.floor(index / (sizes.columnsPerPage * sizes.rowsPerPage)); + + var scrollPositionTarget = null; + if (keyCode === Key.pageUp) { + if (this.layout === _UI.Orientation.horizontal) { + var indexOfFirstItemOnPage = page * sizes.columnsPerPage * sizes.rowsPerPage; + if (index === indexOfFirstItemOnPage && this._surfaceEl.children[index].winControl._buttonEl === _Global.document.activeElement) { + // First item on page so go back 1 page. + index = index - sizes.columnsPerPage * sizes.rowsPerPage; + } else { + // Not first item on page so go to the first item on page. + index = indexOfFirstItemOnPage; + } + } else { + var currentItem = this._surfaceEl.children[index]; + var top = currentItem.offsetTop; + var bottom = top + currentItem.offsetHeight; + var scrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; + + if (top >= scrollPosition && bottom < scrollPosition + sizes.viewportOffsetHeight) { + // current item is fully on screen. + while (index > 0 && + this._surfaceEl.children[index - 1].offsetTop > scrollPosition) { + index--; + } + } + + if (this._keyboardBehavior.currentIndex === index) { + var scrollPositionForOnePageAboveItem = bottom - sizes.viewportOffsetHeight; + index = Math.max(0, index - 1); + while (index > 0 && + this._surfaceEl.children[index - 1].offsetTop > scrollPositionForOnePageAboveItem) { + index--; + } + if (index > 0) { + scrollPositionTarget = this._surfaceEl.children[index].offsetTop - this._sizes.itemMarginTop; + } else { + scrollPositionTarget = 0; + } + } + } + + index = Math.max(index, 0); + this._keyboardBehavior.currentIndex = index; + + var element = this._surfaceEl.children[index].winControl._buttonEl; + + if (scrollPositionTarget !== null) { + this._scrollTo(scrollPositionTarget); + } + + _ElementUtilities._setActive(element, this._viewportEl); + } else { + if (this.layout === _UI.Orientation.horizontal) { + var indexOfLastItemOnPage = (page + 1) * sizes.columnsPerPage * sizes.rowsPerPage - 1; + + if (index === indexOfLastItemOnPage) { + // Last item on page so go forward 1 page. + index = index + sizes.columnsPerPage * sizes.rowsPerPage; + } else { + // Not Last item on page so go to last item on page. + index = indexOfLastItemOnPage; + } + } else { + var currentItem = this._surfaceEl.children[this._keyboardBehavior.currentIndex]; + var top = currentItem.offsetTop; + var bottom = top + currentItem.offsetHeight; + var scrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; + + if (top >= scrollPosition && bottom < scrollPosition + sizes.viewportOffsetHeight) { + // current item is fully on screen. + while (index < this._surfaceEl.children.length - 1 && + this._surfaceEl.children[index + 1].offsetTop + this._surfaceEl.children[index + 1].offsetHeight < scrollPosition + sizes.viewportOffsetHeight) { + index++; + } + } + + if (index === this._keyboardBehavior.currentIndex) { + var scrollPositionForOnePageBelowItem = top + sizes.viewportOffsetHeight; + index = Math.min(this._surfaceEl.children.length - 1, index + 1); + while (index < this._surfaceEl.children.length - 1 && + this._surfaceEl.children[index + 1].offsetTop + this._surfaceEl.children[index + 1].offsetHeight < scrollPositionForOnePageBelowItem) { + index++; + } + + if (index < this._surfaceEl.children.length - 1) { + scrollPositionTarget = this._surfaceEl.children[index + 1].offsetTop - this._sizes.viewportOffsetHeight; + } else { + scrollPositionTarget = this._scrollLength - this._sizes.viewportOffsetHeight; + } + } + } + + index = Math.min(index, this._surfaceEl.children.length - 1); + this._keyboardBehavior.currentIndex = index; + + var element = this._surfaceEl.children[index].winControl._buttonEl; + + if (scrollPositionTarget !== null) { + this._scrollTo(scrollPositionTarget); + } + + try { + _ElementUtilities._setActive(element, this._viewportEl); + } catch (e) { + } + } + } + }, + + _focusHandler: function NavBarContainer_focusHandler(ev) { + var srcElement = ev.target; + if (!this._surfaceEl.contains(srcElement)) { + // Forward focus from NavBarContainer, viewport or surface to the currentIndex. + this._skipEnsureVisible = true; + this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); + } + }, + + _itemsFocusHandler: function NavBarContainer_itemsFocusHandler(ev) { + // Find the item which is being focused and scroll it to view. + var srcElement = ev.target; + if (srcElement === this._surfaceEl) { + return; + } + + while (srcElement.parentNode !== this._surfaceEl) { + srcElement = srcElement.parentNode; + } + + var index = -1; + while (srcElement) { + index++; + srcElement = srcElement.previousSibling; + } + + if (this._skipEnsureVisible) { + this._skipEnsureVisible = false; + } else { + this._ensureVisible(index); + } + }, + + _ensureVisible: function NavBarContainer_ensureVisible(index, withoutAnimation) { + this._measure(); + + if (this.layout === _UI.Orientation.horizontal) { + var page = Math.floor(index / (this._sizes.rowsPerPage * this._sizes.columnsPerPage)); + this._scrollTo(page * this._sizes.viewportOffsetWidth, withoutAnimation); + } else { + var element = this._surfaceEl.children[index]; + var maxScrollPosition; + if (index > 0) { + maxScrollPosition = element.offsetTop - this._sizes.itemMarginTop; + } else { + maxScrollPosition = 0; + } + var minScrollPosition; + if (index < this._surfaceEl.children.length - 1) { + minScrollPosition = this._surfaceEl.children[index + 1].offsetTop - this._sizes.viewportOffsetHeight; + } else { + minScrollPosition = this._scrollLength - this._sizes.viewportOffsetHeight; + } + + var newScrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; + newScrollPosition = Math.max(newScrollPosition, minScrollPosition); + newScrollPosition = Math.min(newScrollPosition, maxScrollPosition); + this._scrollTo(newScrollPosition, withoutAnimation); + } + }, + + _scrollTo: function NavBarContainer_scrollTo(targetScrollPosition, withoutAnimation) { + this._measure(); + if (this.layout === _UI.Orientation.horizontal) { + targetScrollPosition = Math.max(0, Math.min(this._scrollLength - this._sizes.viewportOffsetWidth, targetScrollPosition)); + } else { + targetScrollPosition = Math.max(0, Math.min(this._scrollLength - this._sizes.viewportOffsetHeight, targetScrollPosition)); + } + + if (withoutAnimation) { + if (Math.abs(this._scrollPosition - targetScrollPosition) > 1) { + this._zooming = false; + + this._scrollPosition = targetScrollPosition; + this._updatePageUI(); + if (!this._duringForceLayout) { + this._closeSplitIfOpen(); + } + + var newScrollPos = {}; + newScrollPos[(this.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")] = targetScrollPosition; + _ElementUtilities.setScrollPosition(this._viewportEl, newScrollPos); + } + } else { + if ((!this._zooming && Math.abs(this._scrollPosition - targetScrollPosition) > 1) || (this._zooming && Math.abs(this._zoomPosition - targetScrollPosition) > 1)) { + this._zoomPosition = targetScrollPosition; + + this._zooming = true; + + if (this.layout === _UI.Orientation.horizontal) { + this._viewportEl.style.msScrollSnapType = "none"; + _ElementUtilities._zoomTo(this._viewportEl, { contentX: targetScrollPosition, contentY: 0, viewportX: 0, viewportY: 0 }); + } else { + _ElementUtilities._zoomTo(this._viewportEl, { contentX: 0, contentY: targetScrollPosition, viewportX: 0, viewportY: 0 }); + } + + this._closeSplitIfOpen(); + } + } + }, + + _MSManipulationStateChangedHandler: function NavBarContainer_MSManipulationStateChangedHandler(e) { + this._currentManipulationState = e.currentState; + + if (e.currentState === e.MS_MANIPULATION_STATE_ACTIVE) { + this._viewportEl.style.msScrollSnapType = ""; + this._zooming = false; + } + + _Global.clearTimeout(this._manipulationStateTimeoutId); + // The extra stop event is firing when an zoomTo is called during another zoomTo and + // also the first zoomTo after a resize. + if (e.currentState === e.MS_MANIPULATION_STATE_STOPPED) { + this._manipulationStateTimeoutId = _Global.setTimeout(function () { + this._viewportEl.style.msScrollSnapType = ""; + this._zooming = false; + this._updateCurrentIndexIfPageChanged(); + }.bind(this), 100); + } + }, + + _scrollHandler: function NavBarContainer_scrollHandler() { + if (this._disposed) { return; } + + this._measured = false; + if (!this._checkingScroll) { + var that = this; + this._checkingScroll = _BaseUtils._requestAnimationFrame(function () { + if (that._disposed) { return; } + that._checkingScroll = null; + + var newScrollPosition = _ElementUtilities.getScrollPosition(that._viewportEl)[(that.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")]; + if (newScrollPosition !== that._scrollPosition) { + that._scrollPosition = newScrollPosition; + that._closeSplitIfOpen(); + } + that._updatePageUI(); + + if (!that._zooming && that._currentManipulationState === MS_MANIPULATION_STATE_STOPPED) { + that._updateCurrentIndexIfPageChanged(); + } + }); + } + }, + + _updateCurrentIndexIfPageChanged: function NavBarContainer_updateCurrentIndexIfPageChanged() { + // If you change pages via pagination arrows, mouse wheel, or panning we need to update the current + // item to be the first item on the new page. + if (this.layout === _UI.Orientation.horizontal) { + this._measure(); + var currentPage = this._currentPage; + var firstIndexOnPage = currentPage * this._sizes.rowsPerPage * this._sizes.columnsPerPage; + var lastIndexOnPage = (currentPage + 1) * this._sizes.rowsPerPage * this._sizes.columnsPerPage - 1; + + if (this._keyboardBehavior.currentIndex < firstIndexOnPage || this._keyboardBehavior.currentIndex > lastIndexOnPage) { + // Page change occurred. + this._keyboardBehavior.currentIndex = firstIndexOnPage; + + if (this.element.contains(_Global.document.activeElement)) { + this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); + } + } + } + }, + + _measure: function NavBarContainer_measure() { + if (!this._measured) { + this._resizeImpl(); + this._writeProfilerMark("measure,StartTM"); + + var sizes = this._sizes; + + sizes.rtl = _Global.getComputedStyle(this._element).direction === "rtl"; + + var itemCount = this._surfaceEl.children.length; + if (itemCount > 0) { + if (!this._sizes.itemMeasured) { + this._writeProfilerMark("measureItem,StartTM"); + + var elementToMeasure = this._surfaceEl.firstElementChild; + // Clear inline margins set by NavBarContainer before measuring. + elementToMeasure.style.margin = ""; + elementToMeasure.style.width = ""; + var elementComputedStyle = _Global.getComputedStyle(elementToMeasure); + sizes.itemOffsetWidth = parseFloat(_Global.getComputedStyle(elementToMeasure).width); + if (elementToMeasure.offsetWidth === 0) { + sizes.itemOffsetWidth = 0; + } + sizes.itemMarginLeft = parseFloat(elementComputedStyle.marginLeft); + sizes.itemMarginRight = parseFloat(elementComputedStyle.marginRight); + sizes.itemWidth = sizes.itemOffsetWidth + sizes.itemMarginLeft + sizes.itemMarginRight; + sizes.itemOffsetHeight = parseFloat(_Global.getComputedStyle(elementToMeasure).height); + if (elementToMeasure.offsetHeight === 0) { + sizes.itemOffsetHeight = 0; + } + sizes.itemMarginTop = parseFloat(elementComputedStyle.marginTop); + sizes.itemMarginBottom = parseFloat(elementComputedStyle.marginBottom); + sizes.itemHeight = sizes.itemOffsetHeight + sizes.itemMarginTop + sizes.itemMarginBottom; + if (sizes.itemOffsetWidth > 0 && sizes.itemOffsetHeight > 0) { + sizes.itemMeasured = true; + } + this._writeProfilerMark("measureItem,StopTM"); + } + + sizes.viewportOffsetWidth = parseFloat(_Global.getComputedStyle(this._viewportEl).width); + if (this._viewportEl.offsetWidth === 0) { + sizes.viewportOffsetWidth = 0; + } + sizes.viewportOffsetHeight = parseFloat(_Global.getComputedStyle(this._viewportEl).height); + if (this._viewportEl.offsetHeight === 0) { + sizes.viewportOffsetHeight = 0; + } + + if (sizes.viewportOffsetWidth === 0 || sizes.itemOffsetHeight === 0) { + this._measured = false; + } else { + this._measured = true; + } + + if (this.layout === _UI.Orientation.horizontal) { + this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportEl).scrollLeft; + + sizes.leadingEdge = this._leftArrowEl.offsetWidth + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginLeft) + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginRight); + var usableSpace = sizes.viewportOffsetWidth - sizes.leadingEdge * 2; + sizes.maxColumns = sizes.itemWidth ? Math.max(1, Math.floor(usableSpace / sizes.itemWidth)) : 1; + sizes.rowsPerPage = Math.min(this.maxRows, Math.ceil(itemCount / sizes.maxColumns)); + sizes.columnsPerPage = Math.min(sizes.maxColumns, itemCount); + sizes.pages = Math.ceil(itemCount / (sizes.columnsPerPage * sizes.rowsPerPage)); + sizes.trailingEdge = sizes.leadingEdge; + sizes.extraSpace = usableSpace - (sizes.columnsPerPage * sizes.itemWidth); + + this._scrollLength = sizes.viewportOffsetWidth * sizes.pages; + + this._keyboardBehavior.fixedSize = sizes.rowsPerPage; + this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.height; + + this._surfaceEl.style.height = (sizes.itemHeight * sizes.rowsPerPage) + "px"; + this._surfaceEl.style.width = this._scrollLength + "px"; + } else { + this._scrollPosition = this._viewportEl.scrollTop; + + sizes.leadingEdge = 0; + sizes.rowsPerPage = itemCount; + sizes.columnsPerPage = 1; + sizes.pages = 1; + sizes.trailingEdge = 0; + + // Reminder there is margin collapsing so just use scrollHeight instead of itemHeight * itemCount + this._scrollLength = this._viewportEl.scrollHeight; + + this._keyboardBehavior.fixedSize = sizes.columnsPerPage; + this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.width; + + this._surfaceEl.style.height = ""; + this._surfaceEl.style.width = ""; + } + + this._updateGridStyles(); + } else { + sizes.pages = 1; + this._hasPreviousContent = false; + this._hasNextContent = false; + this._surfaceEl.style.height = ""; + this._surfaceEl.style.width = ""; + } + + this._writeProfilerMark("measure,StopTM"); + } + }, + + _updateGridStyles: function NavBarContainer_updateGridStyles() { + var sizes = this._sizes; + var itemCount = this._surfaceEl.children.length; + + for (var index = 0; index < itemCount; index++) { + var itemEl = this._surfaceEl.children[index]; + + var marginRight; + var marginLeft; + var width = ""; + + if (this.layout === _UI.Orientation.horizontal) { + var column = Math.floor(index / sizes.rowsPerPage); + var isFirstColumnOnPage = column % sizes.columnsPerPage === 0; + var isLastColumnOnPage = column % sizes.columnsPerPage === sizes.columnsPerPage - 1; + + var extraTrailingMargin = sizes.trailingEdge; + if (this.fixedSize) { + extraTrailingMargin += sizes.extraSpace; + } else { + var spaceToDistribute = sizes.extraSpace - (sizes.maxColumns - sizes.columnsPerPage) * sizes.itemWidth; + width = (sizes.itemOffsetWidth + (spaceToDistribute / sizes.maxColumns)) + "px"; + } + + var extraMarginRight; + var extraMarginLeft; + + if (sizes.rtl) { + extraMarginRight = (isFirstColumnOnPage ? sizes.leadingEdge : 0); + extraMarginLeft = (isLastColumnOnPage ? extraTrailingMargin : 0); + } else { + extraMarginRight = (isLastColumnOnPage ? extraTrailingMargin : 0); + extraMarginLeft = (isFirstColumnOnPage ? sizes.leadingEdge : 0); + } + + marginRight = extraMarginRight + sizes.itemMarginRight + "px"; + marginLeft = extraMarginLeft + sizes.itemMarginLeft + "px"; + } else { + marginRight = ""; + marginLeft = ""; + } + + if (itemEl.style.marginRight !== marginRight) { + itemEl.style.marginRight = marginRight; + } + if (itemEl.style.marginLeft !== marginLeft) { + itemEl.style.marginLeft = marginLeft; + } + if (itemEl.style.width !== width) { + itemEl.style.width = width; + } + } + }, + + _updatePageUI: function NavBarContainer_updatePageUI() { + this._measure(); + var currentPage = this._currentPage; + + this._hasPreviousContent = (currentPage !== 0); + this._hasNextContent = (currentPage < this._sizes.pages - 1); + this._updateArrows(); + + // Always output the pagination indicators so they reserves up space. + if (this._indicatorCount !== this._sizes.pages) { + this._indicatorCount = this._sizes.pages; + this._pageindicatorsEl.innerHTML = new Array(this._sizes.pages + 1).join(''); + } + + for (var i = 0; i < this._pageindicatorsEl.children.length; i++) { + if (i === currentPage) { + _ElementUtilities.addClass(this._pageindicatorsEl.children[i], NavBarContainer._ClassName.currentindicator); + } else { + _ElementUtilities.removeClass(this._pageindicatorsEl.children[i], NavBarContainer._ClassName.currentindicator); + } + } + + if (this._sizes.pages > 1) { + this._viewportEl.style.overflowX = this._panningDisabled ? "hidden" : ""; + this._pageindicatorsEl.style.visibility = ""; + } else { + this._viewportEl.style.overflowX = "hidden"; + this._pageindicatorsEl.style.visibility = "hidden"; + } + + if (this._sizes.pages <= 1 || this._layout !== _UI.Orientation.horizontal) { + this._ariaStartMarker.removeAttribute("aria-flowto"); + this._ariaEndMarker.removeAttribute("x-ms-aria-flowfrom"); + } else { + var firstIndexOnCurrentPage = currentPage * this._sizes.rowsPerPage * this._sizes.columnsPerPage; + var firstItem = this._surfaceEl.children[firstIndexOnCurrentPage].winControl._buttonEl; + _ElementUtilities._ensureId(firstItem); + this._ariaStartMarker.setAttribute("aria-flowto", firstItem.id); + + var lastIndexOnCurrentPage = Math.min(this._surfaceEl.children.length - 1, (currentPage + 1) * this._sizes.rowsPerPage * this._sizes.columnsPerPage - 1); + var lastItem = this._surfaceEl.children[lastIndexOnCurrentPage].winControl._buttonEl; + _ElementUtilities._ensureId(lastItem); + this._ariaEndMarker.setAttribute("x-ms-aria-flowfrom", lastItem.id); + } + }, + + _closeSplitIfOpen: function NavBarContainer_closeSplitIfOpen() { + if (this._currentSplitNavItem) { + if (this._currentSplitNavItem.splitOpened) { + this._currentSplitNavItem._toggleSplit(); + } + this._currentSplitNavItem = null; + } + }, + + _updateArrows: function NavBarContainer_updateArrows() { + var hasLeftContent = this._sizes.rtl ? this._hasNextContent : this._hasPreviousContent; + var hasRightContent = this._sizes.rtl ? this._hasPreviousContent : this._hasNextContent; + + var that = this; + // Previous and next are the arrows, not states. On mouse hover the arrows fade in immediately. If you + // mouse out the arrows fade out after a delay. When you reach the last/first page, the corresponding + // arrow fades out immediately as well. + if ((this._mouseInViewport || this._panningDisabled) && hasLeftContent) { + this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); + this._leftArrowWaitingToFadeOut = null; + this._leftArrowFadeOut && this._leftArrowFadeOut.cancel(); + this._leftArrowFadeOut = null; + this._leftArrowEl.style.visibility = ''; + this._leftArrowFadeIn = this._leftArrowFadeIn || Animations.fadeIn(this._leftArrowEl); + } else { + if (hasLeftContent) { + // If we need a delayed fade out and we are already running a delayed fade out just use that one, don't extend it. + // Otherwise create a delayed fade out. + this._leftArrowWaitingToFadeOut = this._leftArrowWaitingToFadeOut || Promise.timeout(_TransitionAnimation._animationTimeAdjustment(buttonFadeDelay)); + } else { + // If we need a immediate fade out and already have a delayed fade out cancel that one and create an immediate one. + this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); + this._leftArrowWaitingToFadeOut = Promise.wrap(); + } + this._leftArrowWaitingToFadeOut.then(function () { + // After the delay cancel any fade in if running. If we already were fading out continue it otherwise start the fade out. + this._leftArrowFadeIn && this._leftArrowFadeIn.cancel(); + this._leftArrowFadeIn = null; + this._leftArrowFadeOut = this._leftArrowFadeOut || Animations.fadeOut(this._leftArrowEl).then(function () { + that._leftArrowEl.style.visibility = 'hidden'; + }); + }.bind(this)); + } + + // Same pattern for Next arrow. + if ((this._mouseInViewport || this._panningDisabled) && hasRightContent) { + this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); + this._rightArrowWaitingToFadeOut = null; + this._rightArrowFadeOut && this._rightArrowFadeOut.cancel(); + this._rightArrowFadeOut = null; + this._rightArrowEl.style.visibility = ''; + this._rightArrowFadeIn = this._rightArrowFadeIn || Animations.fadeIn(this._rightArrowEl); + } else { + if (hasRightContent) { + this._rightArrowWaitingToFadeOut = this._rightArrowWaitingToFadeOut || Promise.timeout(_TransitionAnimation._animationTimeAdjustment(buttonFadeDelay)); + } else { + this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); + this._rightArrowWaitingToFadeOut = Promise.wrap(); + } + this._rightArrowWaitingToFadeOut.then(function () { + this._rightArrowFadeIn && this._rightArrowFadeIn.cancel(); + this._rightArrowFadeIn = null; + this._rightArrowFadeOut = this._rightArrowFadeOut || Animations.fadeOut(this._rightArrowEl).then(function () { + that._rightArrowEl.style.visibility = 'hidden'; + }); + }.bind(this)); + } + }, + + _navbarCommandInvokedHandler: function NavBarContainer_navbarCommandInvokedHandler(ev) { + var srcElement = ev.target; + var index = -1; + while (srcElement) { + index++; + srcElement = srcElement.previousSibling; + } + + this._fireEvent(NavBarContainer._EventName.invoked, { + index: index, + navbarCommand: ev.target.winControl, + data: this._repeater ? this._repeater.data.getAt(index) : null + }); + }, + + _navbarCommandSplitToggleHandler: function NavBarContainer_navbarCommandSplitToggleHandler(ev) { + var srcElement = ev.target; + var index = -1; + while (srcElement) { + index++; + srcElement = srcElement.previousSibling; + } + + var navbarCommand = ev.target.winControl; + + this._closeSplitIfOpen(); + + if (navbarCommand.splitOpened) { + this._currentSplitNavItem = navbarCommand; + } + + this._fireEvent(NavBarContainer._EventName.splitToggle, { + opened: navbarCommand.splitOpened, + index: index, + navbarCommand: navbarCommand, + data: this._repeater ? this._repeater.data.getAt(index) : null + }); + }, + + _fireEvent: function NavBarContainer_fireEvent(type, detail) { + var event = _Global.document.createEvent("CustomEvent"); + event.initCustomEvent(type, true, false, detail); + this.element.dispatchEvent(event); + }, + + _writeProfilerMark: function NavBarContainer_writeProfilerMark(text) { + var message = "WinJS.UI.NavBarContainer:" + this._id + ":" + text; + _WriteProfilerMark(message); + _Log.log && _Log.log(message, null, "navbarcontainerprofiler"); + }, + + dispose: function NavBarContainer_dispose() { + /// + /// + /// Disposes this control. + /// + /// + /// + if (this._disposed) { + return; + } + this._disposed = true; + + if (this._appBarEl) { + this._appBarEl.removeEventListener('beforeshow', this._closeSplitAndResetBound); + this._appBarEl.removeEventListener('beforeshow', this._resizeImplBound); + } + + Navigation.removeEventListener('navigated', this._closeSplitAndResetBound); + + this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); + this._leftArrowFadeOut && this._leftArrowFadeOut.cancel(); + this._leftArrowFadeIn && this._leftArrowFadeIn.cancel(); + this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); + this._rightArrowFadeOut && this._rightArrowFadeOut.cancel(); + this._rightArrowFadeIn && this._rightArrowFadeIn.cancel(); + + _ElementUtilities._resizeNotifier.unsubscribe(this._element, this._boundResizeHandler); + + this._removeDataChangingEvents(); + this._removeDataChangedEvents(); + } + }, { + // Names of classes used by the NavBarContainer. + _ClassName: { + navbarcontainer: "win-navbarcontainer", + pageindicators: "win-navbarcontainer-pageindicator-box", + indicator: "win-navbarcontainer-pageindicator", + currentindicator: "win-navbarcontainer-pageindicator-current", + vertical: "win-navbarcontainer-vertical", + horizontal: "win-navbarcontainer-horizontal", + viewport: "win-navbarcontainer-viewport", + surface: "win-navbarcontainer-surface", + navarrow: "win-navbarcontainer-navarrow", + navleftarrow: "win-navbarcontainer-navleft", + navrightarrow: "win-navbarcontainer-navright" + }, + _EventName: { + invoked: eventNames.invoked, + splitToggle: eventNames.splittoggle + } + }); + _Base.Class.mix(NavBarContainer, _Control.DOMEventMixin); + return NavBarContainer; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS/Controls/NavBar',[ + '../Core/_Global', + '../Core/_WinRT', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_Events', + '../Core/_WriteProfilerMark', + '../Promise', + '../Scheduler', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + './AppBar', + './NavBar/_Command', + './NavBar/_Container', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' +], function NavBarInit(_Global,_WinRT, _Base, _BaseUtils, _Events, _WriteProfilerMark, Promise, Scheduler, _ElementUtilities, _Hoverable, AppBar, _Command, _Container) { + "use strict"; + + var customLayout = "custom"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// + /// Displays navigation commands in a toolbar that the user can show or hide. + /// + /// + /// + /// + /// + /// + ///
+ ///
+ ///
+ /// ]]>
+ /// Raised just before showing the NavBar. + /// Raised immediately after an NavBar is fully shown. + /// Raised just before hiding the NavBar. + /// Raised immediately after the NavBar is fully hidden. + /// Fired when children of NavBar control have been processed from a WinJS.UI.processAll call. + /// Styles the entire NavBar. + /// + /// + /// + NavBar: _Base.Namespace._lazy(function () { + var childrenProcessedEventName = "childrenprocessed"; + var createEvent = _Events._createEventProperty; + + var NavBar = _Base.Class.derive(AppBar.AppBar, function NavBar_ctor(element, options) { + /// + /// + /// Creates a new NavBar. + /// + /// + /// The DOM element that will host the new NavBar control. + /// + /// + /// An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's + /// properties or events. + /// + /// + /// The new NavBar control. + /// + /// + /// + + options = options || {}; + + // Shallow copy object so we can modify it. + options = _BaseUtils._shallowCopy(options); + + // Default to Placement = Top and Layout = Custom + options.placement = options.placement || "top"; + options.layout = customLayout; + + AppBar.AppBar.call(this, element, options); + + this._element.addEventListener("beforeshow", this._handleBeforeShow.bind(this)); + + _ElementUtilities.addClass(this.element, NavBar._ClassName.navbar); + + if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { + this._processChildren(); + } else { + Scheduler.schedule(this._processChildren.bind(this), Scheduler.Priority.idle, null, "WinJS.UI.NavBar.processChildren"); + } + }, { + // Block others from setting the layout property. + + /// + /// The layout of the NavBar contents. + /// + /// + layout: { + get: function () { + return customLayout; + }, + set: function () { + Object.getOwnPropertyDescriptor(AppBar.AppBar.prototype, "layout").set.call(this, customLayout); + }, + }, + + /// + /// Raised when children of NavBar control have been processed by a WinJS.UI.processAll call. + /// + /// + onchildrenprocessed: createEvent(childrenProcessedEventName), + + _processChildren: function NavBar_processChildren() { + // The NavBar control schedules processAll on its children at idle priority to avoid hurting startup + // performance. If the NavBar is shown before the scheduler gets to the idle job, the NavBar will + // immediately call processAll on its children. If your app needs the children to be processed before + // the scheduled job executes, you may call processChildren to force the processAll call. + if (!this._processed) { + this._processed = true; + + this._writeProfilerMark("processChildren,StartTM"); + var that = this; + var processed = Promise.as(); + if (this._processors) { + this._processors.forEach(function (processAll) { + for (var i = 0, len = that.element.children.length; i < len; i++) { + (function (child) { + processed = processed.then(function () { + processAll(child); + }); + }(that.element.children[i])); + } + }); + } + return processed.then( + function () { + that._writeProfilerMark("processChildren,StopTM"); + that._fireEvent(NavBar._EventName.childrenProcessed); + }, + function () { + that._writeProfilerMark("processChildren,StopTM"); + that._fireEvent(NavBar._EventName.childrenProcessed); + } + ); + } + return Promise.wrap(); + }, + + _show: function NavBar_show() { + // Override _show to call processChildren first. + // + if (this.disabled) { + return; + } + var that = this; + this._processChildren().then(function () { + AppBar.AppBar.prototype._show.call(that); + }); + }, + + _handleBeforeShow: function NavBar_handleBeforeShow() { + // Navbar needs to ensure its elements to have their correct height and width after AppBar changes display="none" + // to display="" and AppBar needs the elements to have their final height before it measures its own element height + // to do the slide in animation over the correct amount of pixels. + if (this._disposed) { + return; + } + + var navbarcontainerEls = this.element.querySelectorAll('.win-navbarcontainer'); + for (var i = 0; i < navbarcontainerEls.length; i++) { + navbarcontainerEls[i].winControl.forceLayout(); + } + }, + + _fireEvent: function NavBar_fireEvent(type, detail) { + var event = _Global.document.createEvent("CustomEvent"); + event.initCustomEvent(type, true, false, detail || {}); + this.element.dispatchEvent(event); + }, + + _writeProfilerMark: function NavBar_writeProfilerMark(text) { + _WriteProfilerMark("WinJS.UI.NavBar:" + this._id + ":" + text); + } + }, { + _ClassName: { + navbar: "win-navbar" + }, + _EventName: { + childrenProcessed: childrenProcessedEventName + }, + isDeclarativeControlContainer: _BaseUtils.markSupportedForProcessing(function (navbar, callback) { + if (navbar._processed) { + for (var i = 0, len = navbar.element.children.length; i < len; i++) { + callback(navbar.element.children[i]); + } + } else { + navbar._processors = navbar._processors || []; + navbar._processors.push(callback); + } + }) + }); + + return NavBar; + }) + }); + +}); +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// ViewBox control +define('WinJS/Controls/ViewBox',[ + '../Core/_Global', + '../Core/_Base', + '../Core/_BaseUtils', + '../Core/_ErrorFromName', + '../Core/_Resources', + '../Scheduler', + '../Utilities/_Control', + '../Utilities/_Dispose', + '../Utilities/_ElementUtilities', + '../Utilities/_Hoverable', + 'require-style!less/desktop/controls', + 'require-style!less/phone/controls' + ], function viewboxInit(_Global, _Base, _BaseUtils, _ErrorFromName, _Resources, Scheduler, _Control, _Dispose, _ElementUtilities, _Hoverable) { + "use strict"; + + _Base.Namespace.define("WinJS.UI", { + /// + /// + /// Scales a single child element to fill the available space without + /// resizing it. This control reacts to changes in the size of the container as well as + /// changes in size of the child element. For example, a media query may result in + /// a change in aspect ratio. + /// + /// + /// View Box + /// + /// + ///
ViewBox
]]>
+ /// + /// + /// + ViewBox: _Base.Namespace._lazy(function () { + + var strings = { + get invalidViewBoxChildren() { return "ViewBox expects to only have one child element"; }, + }; + + function onresize(control) { + if (control && !control._resizing) { + control._resizing = control._resizing || 0; + control._resizing++; + try { + control._updateLayout(); + } finally { + control._resizing--; + } + } + } + + function onresizeBox(ev) { + if (ev.target) { + onresize(ev.target.winControl); + } + } + + function onresizeSizer(ev) { + if (ev.target) { + onresize(ev.target.parentElement.winControl); + } + } + + var ViewBox = _Base.Class.define(function ViewBox_ctor(element) { + /// + /// Initializes a new instance of the ViewBox control + /// + /// The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. + /// + /// + /// The set of options to be applied initially to the ViewBox control. + /// + /// A constructed ViewBox control. + /// + this._disposed = false; + + this._element = element || _Global.document.createElement("div"); + var box = this.element; + box.winControl = this; + _ElementUtilities.addClass(box, "win-disposable"); + _ElementUtilities.addClass(box, "win-viewbox"); + this.forceLayout(); + }, { + _sizer: null, + _element: null, + + /// + element: { + get: function () { return this._element; } + }, + + _rtl: { + get: function () { + return _Global.getComputedStyle(this.element).direction === "rtl"; + } + }, + + _initialize: function () { + var box = this.element; + if (box.firstElementChild !== this._sizer) { + if (_BaseUtils.validation) { + if (box.childElementCount !== 1) { + throw new _ErrorFromName("WinJS.UI.ViewBox.InvalidChildren", strings.invalidViewBoxChildren); + } + } + if (this._sizer) { + this._sizer.onresize = null; + } + var sizer = box.firstElementChild; + this._sizer = sizer; + if (sizer) { + _ElementUtilities._resizeNotifier.subscribe(box, onresizeBox); + box.addEventListener("mselementresize", onresizeBox); + _ElementUtilities._resizeNotifier.subscribe(sizer, onresizeSizer); + sizer.addEventListener("mselementresize", onresizeSizer); + } + if (box.clientWidth === 0 && box.clientHeight === 0) { + var that = this; + // Wait for the viewbox to get added to the DOM. It should be added + // in the synchronous block in which _initialize was called. + Scheduler.schedule(function ViewBox_async_initialize() { + that._updateLayout(); + }, Scheduler.Priority.normal, null, "WinJS.UI.ViewBox._updateLayout"); + } + } + }, + _updateLayout: function () { + var sizer = this._sizer; + if (sizer) { + var box = this.element; + var w = sizer.clientWidth; + var h = sizer.clientHeight; + var bw = box.clientWidth; + var bh = box.clientHeight; + var wRatio = bw / w; + var hRatio = bh / h; + var mRatio = Math.min(wRatio, hRatio); + var transX = Math.abs(bw - (w * mRatio)) / 2; + var transY = Math.abs(bh - (h * mRatio)) / 2; + var rtl = this._rtl; + this._sizer.style[_BaseUtils._browserStyleEquivalents["transform"].scriptName] = "translate(" + (rtl ? "-" : "") + transX + "px," + transY + "px) scale(" + mRatio + ")"; + this._sizer.style[_BaseUtils._browserStyleEquivalents["transform-origin"].scriptName] = rtl ? "top right" : "top left"; + } + }, + + dispose: function () { + /// + /// + /// Disposes this ViewBox. + /// + /// + if (this._disposed) { + return; + } + + if (this.element) { + _ElementUtilities._resizeNotifier.unsubscribe(this.element, onresizeBox); + } + if (this._sizer) { + _ElementUtilities._resizeNotifier.unsubscribe(this._sizer, onresizeSizer); + } + + this._disposed = true; + _Dispose.disposeSubTree(this._element); + }, + + forceLayout: function () { + this._initialize(); + this._updateLayout(); + } + }); + _Base.Class.mix(ViewBox, _Control.DOMEventMixin); + return ViewBox; + }) + }); + +}); + +// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +define('WinJS',[ + 'WinJS/Core/_WinJS', + 'WinJS/Core', + 'WinJS/Promise', + 'WinJS/_Signal', + 'WinJS/Scheduler', + 'WinJS/Utilities', + 'WinJS/Fragments', + 'WinJS/Application', + 'WinJS/Navigation', + 'WinJS/Animations', + 'WinJS/Binding', + 'WinJS/BindingTemplate', + 'WinJS/BindingList', + 'WinJS/Res', + 'WinJS/Pages', + 'WinJS/ControlProcessor', + 'WinJS/Controls/HtmlControl', + 'WinJS/VirtualizedDataSource', + 'WinJS/Controls/IntrinsicControls', + 'WinJS/Controls/ListView', + 'WinJS/Controls/FlipView', + 'WinJS/Controls/ItemContainer', + 'WinJS/Controls/Repeater', + 'WinJS/Controls/DatePicker', + 'WinJS/Controls/TimePicker', + 'WinJS/Controls/BackButton', + 'WinJS/Controls/Rating', + 'WinJS/Controls/ToggleSwitch', + 'WinJS/Controls/SemanticZoom', + 'WinJS/Controls/Pivot', + 'WinJS/Controls/Hub', + 'WinJS/Controls/Flyout', + 'WinJS/Controls/AppBar', + 'WinJS/Controls/Menu', + 'WinJS/Controls/SearchBox', + 'WinJS/Controls/SettingsFlyout', + 'WinJS/Controls/NavBar', + 'WinJS/Controls/Tooltip', + 'WinJS/Controls/ViewBox' + ], function (_WinJS) { + "use strict"; + + return _WinJS; +}); + + require(['WinJS/Core/_WinJS', 'WinJS'], function (_WinJS) { + global.WinJS = _WinJS; + return _WinJS; + }); + })); +}(this)); + diff --git a/ajax/libs/winjs/3.0.1/js/WinJS.min.js b/ajax/libs/winjs/3.0.1/js/WinJS.min.js new file mode 100644 index 000000000..d3dc84633 --- /dev/null +++ b/ajax/libs/winjs/3.0.1/js/WinJS.min.js @@ -0,0 +1,35 @@ +/*! Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See https://github.com/winjs/winjs/blob/master/License.txt for license information. */ +!function(global){!function(a){"function"==typeof define&&define.amd?define([],a):(global.msWriteProfilerMark&&msWriteProfilerMark("WinJS.3.0 3.0.0.winjs.2014.10.2 WinJS.js,StartTM"),a(global.WinJS),global.msWriteProfilerMark&&msWriteProfilerMark("WinJS.3.0 3.0.0.winjs.2014.10.2 WinJS.js,StopTM"))}(function(WinJS){var require,define;!function(){"use strict";function a(a,b){var c=a.split("/");return c.pop(),b.map(function(a){if("."===a[0]){var b=a.split("/"),d=c.slice(0);return b.forEach(function(a){".."===a?d.pop():"."!==a&&d.push(a)}),d.join("/")}return a})}function b(a,b){return a.map(function(a){if("exports"===a)return b;var e=d[a];if(!e)throw new Error("Undefined dependency: "+a);return e.resolved||(e.resolved=c(e.dependencies,e.factory,e.exports),e.exports&&(e.resolved=e.exports)),e.resolved})}function c(a,c,d){var e=b(a,d);return c&&c.apply?c.apply(null,e):c}var d={};define=function(b,c,e){Array.isArray(c)||(e=c,c=[]);var f={dependencies:a(b,c),factory:e};-1!==c.indexOf("exports")&&(f.exports={}),d[b]=f},require=function(a,b){Array.isArray(a)||(a=[a]),c(a,b)}}(),define("amd",function(){}),define("WinJS/Core/_WinJS",{}),function(a){"use strict";define("WinJS/Core/_Global",a)}(this),define("WinJS/Core/_BaseCoreUtils",["./_Global"],function(a){"use strict";function b(a){return a.supportedForProcessing=!0,a}var c=!!a.Windows;return{hasWinRT:c,markSupportedForProcessing:b,_setImmediate:a.setImmediate?a.setImmediate.bind(a):function(b){a.setTimeout(b,0)}}}),define("WinJS/Core/_WriteProfilerMark",["./_Global"],function(a){"use strict";return a.msWriteProfilerMark||function(){}}),define("WinJS/Core/_Base",["./_WinJS","./_Global","./_BaseCoreUtils","./_WriteProfilerMark"],function(a,b,c,d){"use strict";function e(a,b,c){var d,e,f,g=Object.keys(b),h=Array.isArray(a);for(e=0,f=g.length;f>e;e++){var i=g[e],j=95!==i.charCodeAt(0),k=b[i];!k||"object"!=typeof k||void 0===k.value&&"function"!=typeof k.get&&"function"!=typeof k.set?j?h?a.forEach(function(a){a[i]=k}):a[i]=k:(d=d||{},d[i]={value:k,enumerable:j,configurable:!0,writable:!0}):(void 0===k.enumerable&&(k.enumerable=j),c&&k.setName&&"function"==typeof k.setName&&k.setName(c+"."+i),d=d||{},d[i]=k)}d&&(h?a.forEach(function(a){Object.defineProperties(a,d)}):Object.defineProperties(a,d))}return function(){function c(c,d){var e=c||{};if(d){var f=d.split(".");e===b&&"WinJS"===f[0]&&(e=a,f.splice(0,1));for(var g=0,h=f.length;h>g;g++){var i=f[g];e[i]||Object.defineProperty(e,i,{value:{},writable:!1,enumerable:!0,configurable:!0}),e=e[i]}}return e}function f(a,b,d){var f=c(a,b);return d&&e(f,d,b||""),f}function g(a,c){return f(b,a,c)}function h(a){var b,c,e=k.uninitialized;return{setName:function(a){b=a},get:function(){switch(e){case k.initialized:return c;case k.uninitialized:e=k.working;try{d("WinJS.Namespace._lazy:"+b+",StartTM"),c=a()}finally{d("WinJS.Namespace._lazy:"+b+",StopTM"),e=k.uninitialized}return a=null,e=k.initialized,c;case k.working:throw"Illegal: reentrancy on initialization";default:throw"Illegal"}},set:function(a){switch(e){case k.working:throw"Illegal: reentrancy on initialization";default:e=k.initialized,c=a}},enumerable:!0,configurable:!0}}function i(a,d,f){var g=[a],h=null;return d&&(h=c(b,d),g.push(h)),e(g,f,d||""),h}var j=a;j.Namespace||(j.Namespace=Object.create(Object.prototype));var k={uninitialized:1,working:2,initialized:3};Object.defineProperties(j.Namespace,{defineWithParent:{value:f,writable:!0,enumerable:!0,configurable:!0},define:{value:g,writable:!0,enumerable:!0,configurable:!0},_lazy:{value:h,writable:!0,enumerable:!0,configurable:!0},_moduleDefine:{value:i,writable:!0,enumerable:!0,configurable:!0}})}(),function(){function b(a,b,d){return a=a||function(){},c.markSupportedForProcessing(a),b&&e(a.prototype,b),d&&e(a,d),a}function d(a,d,f,g){if(a){d=d||function(){};var h=a.prototype;return d.prototype=Object.create(h),c.markSupportedForProcessing(d),Object.defineProperty(d.prototype,"constructor",{value:d,writable:!0,configurable:!0,enumerable:!0}),f&&e(d.prototype,f),g&&e(d,g),d}return b(d,f,g)}function f(a){a=a||function(){};var b,c;for(b=1,c=arguments.length;c>b;b++)e(a.prototype,arguments[b]);return a}a.Namespace.define("WinJS.Class",{define:b,derive:d,mix:f})}(),{Namespace:a.Namespace,Class:a.Class}}),define("WinJS/Core/_ErrorFromName",["./_Base"],function(a){"use strict";var b=a.Class.derive(Error,function(a,b){this.name=a,this.message=b||a},{},{supportedForProcessing:!1});return a.Namespace.define("WinJS",{ErrorFromName:b}),b}),define("WinJS/Core/_WinRT",["exports","./_Global","./_Base"],function(a,b,c){"use strict";a.msGetWeakWinRTProperty=b.msGetWeakWinRTProperty,a.msSetWeakWinRTProperty=b.msSetWeakWinRTProperty;var d=["Windows.ApplicationModel.DesignMode.designModeEnabled","Windows.ApplicationModel.Resources.Core.ResourceContext","Windows.ApplicationModel.Resources.Core.ResourceManager","Windows.ApplicationModel.Search.Core.SearchSuggestionManager","Windows.ApplicationModel.Search.SearchQueryLinguisticDetails","Windows.Data.Text.SemanticTextQuery","Windows.Foundation.Collections.CollectionChange","Windows.Foundation.Uri","Windows.Globalization.ApplicationLanguages","Windows.Globalization.Calendar","Windows.Globalization.DateTimeFormatting","Windows.Globalization.Language","Windows.Phone.UI.Input.HardwareButtons","Windows.Storage.ApplicationData","Windows.Storage.CreationCollisionOption","Windows.Storage.BulkAccess.FileInformationFactory","Windows.Storage.FileIO","Windows.Storage.FileProperties.ThumbnailType","Windows.Storage.FileProperties.ThumbnailMode","Windows.Storage.FileProperties.ThumbnailOptions","Windows.Storage.KnownFolders","Windows.Storage.Search.FolderDepth","Windows.Storage.Search.IndexerOption","Windows.Storage.Streams.RandomAccessStreamReference","Windows.UI.ApplicationSettings.SettingsEdgeLocation","Windows.UI.ApplicationSettings.SettingsCommand","Windows.UI.ApplicationSettings.SettingsPane","Windows.UI.Core.AnimationMetrics","Windows.UI.Input.EdgeGesture","Windows.UI.Input.EdgeGestureKind","Windows.UI.Input.PointerPoint","Windows.UI.ViewManagement.HandPreference","Windows.UI.ViewManagement.InputPane","Windows.UI.ViewManagement.UISettings","Windows.UI.WebUI.Core.WebUICommandBar","Windows.UI.WebUI.Core.WebUICommandBarBitmapIcon","Windows.UI.WebUI.Core.WebUICommandBarClosedDisplayMode","Windows.UI.WebUI.Core.WebUICommandBarIconButton","Windows.UI.WebUI.Core.WebUICommandBarSymbolIcon","Windows.UI.WebUI.WebUIApplication"];d.forEach(function(d){var e=d.split("."),f={};f[e[e.length-1]]={get:function(){return e.reduce(function(a,b){return a?a[b]:null},b)}},c.Namespace.defineWithParent(a,e.slice(0,-1).join("."),f)})}),define("WinJS/Core/_Events",["exports","./_Base"],function(a,b){"use strict";function c(a){var b="_on"+a+"state";return{get:function(){var a=this[b];return a&&a.userHandler},set:function(c){var d=this[b];c?(d||(d={wrapper:function(a){return d.userHandler(a)},userHandler:c},Object.defineProperty(this,b,{value:d,enumerable:!1,writable:!0,configurable:!0}),this.addEventListener(a,d.wrapper,!1)),d.userHandler=c):d&&(this.removeEventListener(a,d.wrapper,!1),this[b]=null)},enumerable:!0}}function d(){for(var a={},b=0,d=arguments.length;d>b;b++){var e=arguments[b];a["on"+e]=c(e)}return a}var e=b.Class.define(function(a,b,c){this.detail=b,this.target=c,this.timeStamp=Date.now(),this.type=a},{bubbles:{value:!1,writable:!1},cancelable:{value:!1,writable:!1},currentTarget:{get:function(){return this.target}},defaultPrevented:{get:function(){return this._preventDefaultCalled}},trusted:{value:!1,writable:!1},eventPhase:{value:0,writable:!1},target:null,timeStamp:null,type:null,preventDefault:function(){this._preventDefaultCalled=!0},stopImmediatePropagation:function(){this._stopImmediatePropagationCalled=!0},stopPropagation:function(){}},{supportedForProcessing:!1}),f={_listeners:null,addEventListener:function(a,b,c){c=c||!1,this._listeners=this._listeners||{};for(var d=this._listeners[a]=this._listeners[a]||[],e=0,f=d.length;f>e;e++){var g=d[e];if(g.useCapture===c&&g.listener===b)return}d.push({listener:b,useCapture:c})},dispatchEvent:function(a,b){var c=this._listeners&&this._listeners[a];if(c){var d=new e(a,b,this);c=c.slice(0,c.length);for(var f=0,g=c.length;g>f&&!d._stopImmediatePropagationCalled;f++)c[f].listener(d);return d.defaultPrevented||!1}return!1},removeEventListener:function(a,b,c){c=c||!1;var d=this._listeners&&this._listeners[a];if(d)for(var e=0,f=d.length;f>e;e++){var g=d[e];if(g.listener===b&&g.useCapture===c){d.splice(e,1),0===d.length&&delete this._listeners[a];break}}}};b.Namespace._moduleDefine(a,"WinJS.Utilities",{_createEventProperty:c,createEventProperties:d,eventMixin:f})}),define("require-json",{load:function(a){throw new Error("Dynamic load not allowed: "+a)}}),define("require-json!en-US/ui.resjson",{appBarAriaLabel:"App Bar",appBarCommandAriaLabel:"App Bar Item",averageRating:"Average Rating",backbuttonarialabel:"Back",clearYourRating:"Clear your rating",closeOverlay:"Close",datePicker:"Date Picker",flipViewPanningContainerAriaLabel:"Scrolling Container",flyoutAriaLabel:"Flyout",hubViewportAriaLabel:"Scrolling Container",listViewViewportAriaLabel:"Scrolling Container",menuCommandAriaLabel:"Menu Item",menuAriaLabel:"Menu",navBarContainerViewportAriaLabel:"Scrolling Container",off:"Off",on:"On",pivotAriaLabel:"Pivot",pivotViewportAriaLabel:"Scrolling Container",searchBoxAriaLabel:"Searchbox",searchBoxAriaLabelInputNoPlaceHolder:"Searchbox, enter to submit query, esc to clear text",searchBoxAriaLabelInputPlaceHolder:"Searchbox, {0}, enter to submit query, esc to clear text",searchBoxAriaLabelButton:"Click to submit query",searchBoxAriaLabelQuery:"Suggestion: {0}","_searchBoxAriaLabelQuery.comment":"Suggestion: query text (example: Suggestion: contoso)",searchBoxAriaLabelSeparator:"Separator: {0}","_searchBoxAriaLabelSeparator.comment":"Separator: separator text (example: Separator: People or Separator: Apps)",searchBoxAriaLabelResult:"Result: {0}, {1}","_searchBoxAriaLabelResult.comment":"Result: text, detailed text (example: Result: contoso, www.contoso.com)",selectAMPM:"Select A.M P.M",selectDay:"Select Day",selectHour:"Select Hour",selectMinute:"Select Minute",selectMonth:"Select Month",selectYear:"Select Year",settingsFlyoutAriaLabel:"Settings Flyout",tentativeRating:"Tentative Rating",timePicker:"Time Picker",unrated:"Unrated",userRating:"User Rating","appBarIcons\\previous":"","_appBarIcons\\previous.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\next":"","_appBarIcons\\next.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\play":"","_appBarIcons\\play.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\pause":"","_appBarIcons\\pause.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\edit":"","_appBarIcons\\edit.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\save":"","_appBarIcons\\save.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\clear":"","_appBarIcons\\clear.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\delete":"","_appBarIcons\\delete.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\remove":"","_appBarIcons\\remove.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\add":"","_appBarIcons\\add.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\cancel":"","_appBarIcons\\cancel.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\accept":"","_appBarIcons\\accept.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\more":"","_appBarIcons\\more.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\redo":"","_appBarIcons\\redo.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\undo":"","_appBarIcons\\undo.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\home":"","_appBarIcons\\home.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\up":"","_appBarIcons\\up.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\forward":"","_appBarIcons\\forward.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\right":"","_appBarIcons\\right.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\back":"","_appBarIcons\\back.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\left":"","_appBarIcons\\left.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\favorite":"","_appBarIcons\\favorite.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\camera":"","_appBarIcons\\camera.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\settings":"","_appBarIcons\\settings.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\video":"","_appBarIcons\\video.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\sync":"","_appBarIcons\\sync.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\download":"","_appBarIcons\\download.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mail":"","_appBarIcons\\mail.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\find":"","_appBarIcons\\find.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\help":"","_appBarIcons\\help.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\upload":"","_appBarIcons\\upload.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\emoji":"","_appBarIcons\\emoji.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\twopage":"","_appBarIcons\\twopage.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\leavechat":"","_appBarIcons\\leavechat.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mailforward":"","_appBarIcons\\mailforward.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\clock":"","_appBarIcons\\clock.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\send":"","_appBarIcons\\send.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\crop":"","_appBarIcons\\crop.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\rotatecamera":"","_appBarIcons\\rotatecamera.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\people":"","_appBarIcons\\people.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\closepane":"","_appBarIcons\\closepane.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\openpane":"","_appBarIcons\\openpane.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\world":"","_appBarIcons\\world.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\flag":"","_appBarIcons\\flag.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\previewlink":"","_appBarIcons\\previewlink.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\globe":"","_appBarIcons\\globe.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\trim":"","_appBarIcons\\trim.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\attachcamera":"","_appBarIcons\\attachcamera.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\zoomin":"","_appBarIcons\\zoomin.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\bookmarks":"","_appBarIcons\\bookmarks.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\document":"","_appBarIcons\\document.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\protecteddocument":"","_appBarIcons\\protecteddocument.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\page":"","_appBarIcons\\page.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\bullets":"","_appBarIcons\\bullets.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\comment":"","_appBarIcons\\comment.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mail2":"","_appBarIcons\\mail2.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\contactinfo":"","_appBarIcons\\contactinfo.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\hangup":"","_appBarIcons\\hangup.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\viewall":"","_appBarIcons\\viewall.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mappin":"","_appBarIcons\\mappin.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\phone":"","_appBarIcons\\phone.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\videochat":"","_appBarIcons\\videochat.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\switch":"","_appBarIcons\\switch.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\contact":"","_appBarIcons\\contact.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\rename":"","_appBarIcons\\rename.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\pin":"","_appBarIcons\\pin.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\musicinfo":"","_appBarIcons\\musicinfo.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\go":"","_appBarIcons\\go.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\keyboard":"","_appBarIcons\\keyboard.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\dockleft":"","_appBarIcons\\dockleft.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\dockright":"","_appBarIcons\\dockright.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\dockbottom":"","_appBarIcons\\dockbottom.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\remote":"","_appBarIcons\\remote.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\refresh":"","_appBarIcons\\refresh.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\rotate":"","_appBarIcons\\rotate.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\shuffle":"","_appBarIcons\\shuffle.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\list":"","_appBarIcons\\list.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\shop":"","_appBarIcons\\shop.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\selectall":"","_appBarIcons\\selectall.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\orientation":"","_appBarIcons\\orientation.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\import":"","_appBarIcons\\import.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\importall":"","_appBarIcons\\importall.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\browsephotos":"","_appBarIcons\\browsephotos.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\webcam":"","_appBarIcons\\webcam.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\pictures":"","_appBarIcons\\pictures.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\savelocal":"","_appBarIcons\\savelocal.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\caption":"","_appBarIcons\\caption.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\stop":"","_appBarIcons\\stop.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\showresults":"","_appBarIcons\\showresults.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\volume":"","_appBarIcons\\volume.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\repair":"","_appBarIcons\\repair.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\message":"","_appBarIcons\\message.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\page2":"","_appBarIcons\\page2.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\calendarday":"","_appBarIcons\\calendarday.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\calendarweek":"","_appBarIcons\\calendarweek.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\calendar":"","_appBarIcons\\calendar.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\characters":"","_appBarIcons\\characters.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mailreplyall":"","_appBarIcons\\mailreplyall.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\read":"","_appBarIcons\\read.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\link":"","_appBarIcons\\link.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\accounts":"","_appBarIcons\\accounts.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\showbcc":"","_appBarIcons\\showbcc.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\hidebcc":"","_appBarIcons\\hidebcc.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\cut":"","_appBarIcons\\cut.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\attach":"","_appBarIcons\\attach.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\paste":"","_appBarIcons\\paste.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\filter":"","_appBarIcons\\filter.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\copy":"","_appBarIcons\\copy.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\emoji2":"","_appBarIcons\\emoji2.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\important":"","_appBarIcons\\important.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mailreply":"","_appBarIcons\\mailreply.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\slideshow":"","_appBarIcons\\slideshow.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\sort":"","_appBarIcons\\sort.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\manage":"","_appBarIcons\\manage.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\allapps":"","_appBarIcons\\allapps.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\disconnectdrive":"","_appBarIcons\\disconnectdrive.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mapdrive":"","_appBarIcons\\mapdrive.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\newwindow":"","_appBarIcons\\newwindow.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\openwith":"","_appBarIcons\\openwith.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\contactpresence":"","_appBarIcons\\contactpresence.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\priority":"","_appBarIcons\\priority.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\uploadskydrive":"","_appBarIcons\\uploadskydrive.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\gototoday":"","_appBarIcons\\gototoday.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\font":"","_appBarIcons\\font.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fontcolor":"","_appBarIcons\\fontcolor.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\contact2":"","_appBarIcons\\contact2.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\folder":"","_appBarIcons\\folder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\audio":"","_appBarIcons\\audio.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\placeholder":"","_appBarIcons\\placeholder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\view":"","_appBarIcons\\view.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\setlockscreen":"","_appBarIcons\\setlockscreen.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\settile":"","_appBarIcons\\settile.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\cc":"","_appBarIcons\\cc.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\stopslideshow":"","_appBarIcons\\stopslideshow.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\permissions":"","_appBarIcons\\permissions.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\highlight":"","_appBarIcons\\highlight.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\disableupdates":"","_appBarIcons\\disableupdates.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\unfavorite":"","_appBarIcons\\unfavorite.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\unpin":"","_appBarIcons\\unpin.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\openlocal":"","_appBarIcons\\openlocal.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\mute":"","_appBarIcons\\mute.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\italic":"","_appBarIcons\\italic.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\underline":"","_appBarIcons\\underline.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\bold":"","_appBarIcons\\bold.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\movetofolder":"","_appBarIcons\\movetofolder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\likedislike":"","_appBarIcons\\likedislike.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\dislike":"","_appBarIcons\\dislike.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\like":"","_appBarIcons\\like.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\alignright":"","_appBarIcons\\alignright.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\aligncenter":"","_appBarIcons\\aligncenter.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\alignleft":"","_appBarIcons\\alignleft.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\zoom":"","_appBarIcons\\zoom.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\zoomout":"","_appBarIcons\\zoomout.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\openfile":"","_appBarIcons\\openfile.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\otheruser":"","_appBarIcons\\otheruser.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\admin":"","_appBarIcons\\admin.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\street":"","_appBarIcons\\street.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\map":"","_appBarIcons\\map.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\clearselection":"","_appBarIcons\\clearselection.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fontdecrease":"","_appBarIcons\\fontdecrease.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fontincrease":"","_appBarIcons\\fontincrease.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fontsize":"","_appBarIcons\\fontsize.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\cellphone":"","_appBarIcons\\cellphone.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\reshare":"","_appBarIcons\\reshare.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\tag":"","_appBarIcons\\tag.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\repeatone":"","_appBarIcons\\repeatone.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\repeatall":"","_appBarIcons\\repeatall.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\outlinestar":"","_appBarIcons\\outlinestar.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\solidstar":"","_appBarIcons\\solidstar.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\calculator":"","_appBarIcons\\calculator.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\directions":"","_appBarIcons\\directions.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\target":"","_appBarIcons\\target.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\library":"","_appBarIcons\\library.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\phonebook":"","_appBarIcons\\phonebook.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\memo":"","_appBarIcons\\memo.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\microphone":"","_appBarIcons\\microphone.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\postupdate":"","_appBarIcons\\postupdate.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\backtowindow":"","_appBarIcons\\backtowindow.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fullscreen":"","_appBarIcons\\fullscreen.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\newfolder":"","_appBarIcons\\newfolder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\calendarreply":"","_appBarIcons\\calendarreply.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\unsyncfolder":"","_appBarIcons\\unsyncfolder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\reporthacked":"","_appBarIcons\\reporthacked.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\syncfolder":"","_appBarIcons\\syncfolder.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\blockcontact":"","_appBarIcons\\blockcontact.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\switchapps":"","_appBarIcons\\switchapps.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\addfriend":"","_appBarIcons\\addfriend.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\touchpointer":"","_appBarIcons\\touchpointer.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\gotostart":"","_appBarIcons\\gotostart.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\zerobars":"","_appBarIcons\\zerobars.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\onebar":"","_appBarIcons\\onebar.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\twobars":"","_appBarIcons\\twobars.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\threebars":"","_appBarIcons\\threebars.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\fourbars":"","_appBarIcons\\fourbars.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\scan":"","_appBarIcons\\scan.comment":"{Locked:qps-ploc,qps-plocm}","appBarIcons\\preview":"","_appBarIcons\\preview.comment":"{Locked:qps-ploc,qps-plocm}"}),define("WinJS/Core/_Resources",["exports","./_Global","./_WinRT","./_Base","./_Events","require-json!en-US/ui.resjson"],function(a,b,c,d,e,f){"use strict";function g(a){var b=u("ms-resource://"+j+"/"+a);return b.empty&&(b=h(a)),b}function h(a){var b=a.split("/");b.shift();var c=f[b.join("\\")];return"string"==typeof c&&(c={value:c}),c||{value:a,empty:!0}}function i(a){var b=arguments;return b.length>1&&(a=a.replace(/({{)|(}})|{(\d+)}|({)|(})/g,function(a,c,d,e,f,g){if(f||g)throw i(s.malformedFormatStringInput,f||g);return c&&"{"||d&&"}"||b[(0|e)+1]})),a}var j="WinJS.3.0",k="Developer.";0===j.indexOf(k)&&(j=j.substring(k.length));var l,m,n=!1,o="contextchanged",p=d.Class.mix(d.Class.define(null,{},{supportedForProcessing:!1}),e.eventMixin),q=new p,r=e._createEventProperty,s={get malformedFormatStringInput(){return"Malformed, did you mean to escape your '{0}'?"}};d.Namespace.define("WinJS.Resources",{_getWinJSString:g}),d.Namespace._moduleDefine(a,"WinJS.Resources",{addEventListener:function(b,d,e){if(c.Windows.ApplicationModel.Resources.Core.ResourceManager&&!n&&b===o)try{var f=a._getResourceContext();f?f.qualifierValues.addEventListener("mapchanged",function(b){a.dispatchEvent(o,{qualifier:b.key,changed:b.target[b.key]})},!1):c.Windows.ApplicationModel.Resources.Core.ResourceManager.current.defaultContext.qualifierValues.addEventListener("mapchanged",function(b){a.dispatchEvent(o,{qualifier:b.key,changed:b.target[b.key]})},!1),n=!0}catch(g){}q.addEventListener(b,d,e)},removeEventListener:q.removeEventListener.bind(q),dispatchEvent:q.dispatchEvent.bind(q),_formatString:i,_getStringWinRT:function(b){if(!l){var d=c.Windows.ApplicationModel.Resources.Core.ResourceManager.current.mainResourceMap;try{l=d.getSubtree("Resources")}catch(e){}l||(l=d)}var f,g,h;try{var i=a._getResourceContext();h=i?l.getValue(b,i):l.getValue(b),h&&(f=h.valueAsString,void 0===f&&(f=h.toString()))}catch(e){}if(!f)return a._getStringJS(b);try{g=h.getQualifierValue("Language")}catch(e){return{value:f}}return{value:f,lang:g}},_getStringJS:function(a){var c=b.strings&&b.strings[a];return"string"==typeof c&&(c={value:c}),c||{value:a,empty:!0}},_getResourceContext:function(){if(b.document&&"undefined"==typeof m){var a=c.Windows.ApplicationModel.Resources.Core.ResourceContext;m=a.getForCurrentView?a.getForCurrentView():null}return m},oncontextchanged:r(o)});var t=c.Windows.ApplicationModel.Resources.Core.ResourceManager?a._getStringWinRT:a._getStringJS,u=function(a){return t(a)};d.Namespace._moduleDefine(a,null,{_formatString:i,_getWinJSString:g}),d.Namespace._moduleDefine(a,"WinJS.Resources",{getString:{get:function(){return u},set:function(a){u=a}}})}),define("WinJS/Core/_Trace",["./_Global"],function(a){"use strict";function b(a){return a}return{_traceAsyncOperationStarting:a.Debug&&a.Debug.msTraceAsyncOperationStarting&&a.Debug.msTraceAsyncOperationStarting.bind(a.Debug)||b,_traceAsyncOperationCompleted:a.Debug&&a.Debug.msTraceAsyncOperationCompleted&&a.Debug.msTraceAsyncOperationCompleted.bind(a.Debug)||b,_traceAsyncCallbackStarting:a.Debug&&a.Debug.msTraceAsyncCallbackStarting&&a.Debug.msTraceAsyncCallbackStarting.bind(a.Debug)||b,_traceAsyncCallbackCompleted:a.Debug&&a.Debug.msTraceAsyncCallbackCompleted&&a.Debug.msTraceAsyncCallbackCompleted.bind(a.Debug)||b}}),define("WinJS/Promise/_StateMachine",["../Core/_Global","../Core/_BaseCoreUtils","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Trace"],function(a,b,c,d,e,f){"use strict";function g(){}function h(a,b){var c;c=b&&"object"==typeof b&&"function"==typeof b.then?I:M,a._value=b,a._setState(c)}function i(a,b,c,d,e,f){return{exception:a,error:b,promise:c,handler:f,id:d,parent:e}}function j(a,b,c,d){var e=c._isException,f=c._errorId;return i(e?b:null,e?null:b,a,f,c,d)}function k(a,b,c){var d=c._isException,e=c._errorId;return u(a,e,d),i(d?b:null,d?null:b,a,e,c)}function l(a,b){var c=++Q;return u(a,c),i(null,b,a,c)}function m(a,b){var c=++Q;return u(a,c,!0),i(b,null,a,c) +}function n(a,b,c,d){var e=f._traceAsyncOperationStarting("WinJS.Promise.done");t(a,{c:b,e:c,p:d,asyncOpID:e})}function o(a,b,c,d){a._value=b,r(a,b,c,d),a._setState(O)}function p(b,c){var d=b._value,e=b._listeners;if(e){b._listeners=null;var g,h;for(g=0,h=Array.isArray(e)?e.length:1;h>g;g++){var i=1===h?e:e[g],j=i.c,k=i.promise;if(f._traceAsyncOperationCompleted(i.asyncOpID,a.Debug&&a.Debug.MS_ASYNC_OP_STATUS_SUCCESS),k){f._traceAsyncCallbackStarting(i.asyncOpID);try{k._setCompleteValue(j?j(d):d)}catch(l){k._setExceptionValue(l)}finally{f._traceAsyncCallbackCompleted()}k._state!==I&&k._listeners&&c.push(k)}else W.prototype.done.call(b,j)}}}function q(b,c){var d=b._value,e=b._listeners;if(e){b._listeners=null;var g,h;for(g=0,h=Array.isArray(e)?e.length:1;h>g;g++){var i=1===h?e:e[g],k=i.e,l=i.promise,m=a.Debug&&(d&&d.name===D?a.Debug.MS_ASYNC_OP_STATUS_CANCELED:a.Debug.MS_ASYNC_OP_STATUS_ERROR);if(f._traceAsyncOperationCompleted(i.asyncOpID,m),l){var n=!1;try{k?(f._traceAsyncCallbackStarting(i.asyncOpID),n=!0,k.handlesOnError||r(l,d,j,b,k),l._setCompleteValue(k(d))):l._setChainedErrorValue(d,b)}catch(o){l._setExceptionValue(o)}finally{n&&f._traceAsyncCallbackCompleted()}l._state!==I&&l._listeners&&c.push(l)}else U.prototype.done.call(b,null,k)}}}function r(a,b,c,d,e){if(B._listeners[C]){if(b instanceof Error&&b.message===D)return;B.dispatchEvent(C,c(a,b,d,e))}}function s(a,b){var c=a._listeners;if(c){var d,e;for(d=0,e=Array.isArray(c)?c.length:1;e>d;d++){var f=1===e?c:c[d],g=f.p;if(g)try{g(b)}catch(h){}f.c||f.e||!f.promise||f.promise._progress(b)}}}function t(a,b){var c=a._listeners;c?(c=Array.isArray(c)?c:[c],c.push(b)):c=b,a._listeners=c}function u(a,b,c){a._isException=c||!1,a._errorId=b}function v(a,b,c,d){a._value=b,r(a,b,c,d),a._setState(P)}function w(a,b){var c;c=b&&"object"==typeof b&&"function"==typeof b.then?I:N,a._value=b,a._setState(c)}function x(a,b,c,d){var e=new T(a),g=f._traceAsyncOperationStarting("WinJS.Promise.then");return t(a,{promise:e,c:b,e:c,p:d,asyncOpID:g}),e}function y(c){var d;return new X(function(e){c?d=a.setTimeout(e,c):b._setImmediate(e)},function(){d&&a.clearTimeout(d)})}function z(a,b){var c=function(){b.cancel()},d=function(){a.cancel()};return a.then(c),b.then(d,d),b}a.Debug&&(a.Debug.setNonUserCodeExceptions=!0);var A=c.Class.mix(c.Class.define(null,{},{supportedForProcessing:!1}),e.eventMixin),B=new A;B._listeners={};var C="error",D="Canceled",E=!1,F={promise:1,thenPromise:2,errorPromise:4,exceptionPromise:8,completePromise:16};F.all=F.promise|F.thenPromise|F.errorPromise|F.exceptionPromise|F.completePromise;var G,H,I,J,K,L,M,N,O,P,Q=1;G={name:"created",enter:function(a){a._setState(H)},cancel:g,done:g,then:g,_completed:g,_error:g,_notify:g,_progress:g,_setCompleteValue:g,_setErrorValue:g},H={name:"working",enter:g,cancel:function(a){a._setState(K)},done:n,then:x,_completed:h,_error:o,_notify:g,_progress:s,_setCompleteValue:w,_setErrorValue:v},I={name:"waiting",enter:function(a){var b=a._value;if(b instanceof T&&b._state!==P&&b._state!==N)t(b,{promise:a});else{var c=function(d){b._errorId?a._chainedError(d,b):(r(a,d,j,b,c),a._error(d))};c.handlesOnError=!0,b.then(a._completed.bind(a),c,a._progress.bind(a))}},cancel:function(a){a._setState(J)},done:n,then:x,_completed:h,_error:o,_notify:g,_progress:s,_setCompleteValue:w,_setErrorValue:v},J={name:"waiting_canceled",enter:function(a){a._setState(L);var b=a._value;b.cancel&&b.cancel()},cancel:g,done:n,then:x,_completed:h,_error:o,_notify:g,_progress:s,_setCompleteValue:w,_setErrorValue:v},K={name:"canceled",enter:function(a){a._setState(L),a._cancelAction()},cancel:g,done:n,then:x,_completed:h,_error:o,_notify:g,_progress:s,_setCompleteValue:w,_setErrorValue:v},L={name:"canceling",enter:function(a){var b=new Error(D);b.name=b.message,a._value=b,a._setState(O)},cancel:g,done:g,then:g,_completed:g,_error:g,_notify:g,_progress:g,_setCompleteValue:g,_setErrorValue:g},M={name:"complete_notify",enter:function(a){if(a.done=W.prototype.done,a.then=W.prototype.then,a._listeners)for(var b,c=[a];c.length;)b=c.shift(),b._state._notify(b,c);a._setState(N)},cancel:g,done:null,then:null,_completed:g,_error:g,_notify:p,_progress:g,_setCompleteValue:g,_setErrorValue:g},N={name:"success",enter:function(a){a.done=W.prototype.done,a.then=W.prototype.then,a._cleanupAction()},cancel:g,done:null,then:null,_completed:g,_error:g,_notify:p,_progress:g,_setCompleteValue:g,_setErrorValue:g},O={name:"error_notify",enter:function(a){if(a.done=U.prototype.done,a.then=U.prototype.then,a._listeners)for(var b,c=[a];c.length;)b=c.shift(),b._state._notify(b,c);a._setState(P)},cancel:g,done:null,then:null,_completed:g,_error:g,_notify:q,_progress:g,_setCompleteValue:g,_setErrorValue:g},P={name:"error",enter:function(a){a.done=U.prototype.done,a.then=U.prototype.then,a._cleanupAction()},cancel:g,done:null,then:null,_completed:g,_error:g,_notify:q,_progress:g,_setCompleteValue:g,_setErrorValue:g};var R,S=c.Class.define(null,{_listeners:null,_nextState:null,_state:null,_value:null,cancel:function(){this._state.cancel(this),this._run()},done:function(a,b,c){this._state.done(this,a,b,c)},then:function(a,b,c){return this._state.then(this,a,b,c)},_chainedError:function(a,b){var c=this._state._error(this,a,k,b);return this._run(),c},_completed:function(a){var b=this._state._completed(this,a);return this._run(),b},_error:function(a){var b=this._state._error(this,a,l);return this._run(),b},_progress:function(a){this._state._progress(this,a)},_setState:function(a){this._nextState=a},_setCompleteValue:function(a){this._state._setCompleteValue(this,a),this._run()},_setChainedErrorValue:function(a,b){var c=this._state._setErrorValue(this,a,k,b);return this._run(),c},_setExceptionValue:function(a){var b=this._state._setErrorValue(this,a,m);return this._run(),b},_run:function(){for(;this._nextState;)this._state=this._nextState,this._nextState=null,this._state.enter(this)}},{supportedForProcessing:!1}),T=c.Class.derive(S,function(a){E&&(E===!0||E&F.thenPromise)&&(this._stack=X._getStack()),this._creator=a,this._setState(G),this._run()},{_creator:null,_cancelAction:function(){this._creator&&this._creator.cancel()},_cleanupAction:function(){this._creator=null}},{supportedForProcessing:!1}),U=c.Class.define(function(a){E&&(E===!0||E&F.errorPromise)&&(this._stack=X._getStack()),this._value=a,r(this,a,l)},{cancel:function(){},done:function(a,b){var c=this._value;if(b)try{b.handlesOnError||r(null,c,j,this,b);var d=b(c);return void(d&&"object"==typeof d&&"function"==typeof d.done&&d.done())}catch(e){c=e}c instanceof Error&&c.message===D||X._doneHandler(c)},then:function(a,b){if(!b)return this;var c,d=this._value;try{b.handlesOnError||r(null,d,j,this,b),c=new W(b(d))}catch(e){c=e===d?this:new V(e)}return c}},{supportedForProcessing:!1}),V=c.Class.derive(U,function(a){E&&(E===!0||E&F.exceptionPromise)&&(this._stack=X._getStack()),this._value=a,r(this,a,m)},{},{supportedForProcessing:!1}),W=c.Class.define(function(a){if(E&&(E===!0||E&F.completePromise)&&(this._stack=X._getStack()),a&&"object"==typeof a&&"function"==typeof a.then){var b=new T(null);return b._setCompleteValue(a),b}this._value=a},{cancel:function(){},done:function(a){if(a)try{var b=a(this._value);b&&"object"==typeof b&&"function"==typeof b.done&&b.done()}catch(c){X._doneHandler(c)}},then:function(a){try{var b=a?a(this._value):this._value;return b===this._value?this:new W(b)}catch(c){return new V(c)}}},{supportedForProcessing:!1}),X=c.Class.derive(S,function(a,b){E&&(E===!0||E&F.promise)&&(this._stack=X._getStack()),this._oncancel=b,this._setState(G),this._run();try{var c=this._completed.bind(this),d=this._error.bind(this),e=this._progress.bind(this);a(c,d,e)}catch(f){this._setExceptionValue(f)}},{_oncancel:null,_cancelAction:function(){if(this._oncancel)try{this._oncancel()}catch(a){}},_cleanupAction:function(){this._oncancel=null}},{addEventListener:function(a,b,c){B.addEventListener(a,b,c)},any:function(a){return new X(function(b,c){var d=Object.keys(a);0===d.length&&b();var e=0;d.forEach(function(f){X.as(a[f]).then(function(){b({key:f,value:a[f]})},function(g){return g instanceof Error&&g.name===D?void(++e===d.length&&b(X.cancel)):void c({key:f,value:a[f]})})})},function(){var b=Object.keys(a);b.forEach(function(b){var c=X.as(a[b]);"function"==typeof c.cancel&&c.cancel()})})},as:function(a){return a&&"object"==typeof a&&"function"==typeof a.then?a:new W(a)},cancel:{get:function(){return R=R||new U(new d(D))}},dispatchEvent:function(a,b){return B.dispatchEvent(a,b)},is:function(a){return a&&"object"==typeof a&&"function"==typeof a.then},join:function(a){return new X(function(b,c,d){var e=Object.keys(a),f=Array.isArray(a)?[]:{},g=Array.isArray(a)?[]:{},h=0,i=e.length,j=function(a){if(0===--i){var h=Object.keys(f).length;if(0===h)b(g);else{var j=0;e.forEach(function(a){var b=f[a];b instanceof Error&&b.name===D&&j++}),j===h?b(X.cancel):c(f)}}else d({Key:a,Done:!0})};return e.forEach(function(b){var c=a[b];void 0===c?h++:X.then(c,function(a){g[b]=a,j(b)},function(a){f[b]=a,j(b)})}),i-=h,0===i?void b(g):void 0},function(){Object.keys(a).forEach(function(b){var c=X.as(a[b]);"function"==typeof c.cancel&&c.cancel()})})},removeEventListener:function(a,b,c){B.removeEventListener(a,b,c)},supportedForProcessing:!1,then:function(a,b,c,d){return X.as(a).then(b,c,d)},thenEach:function(a,b,c,d){var e=Array.isArray(a)?[]:{};return Object.keys(a).forEach(function(f){e[f]=X.as(a[f]).then(b,c,d)}),X.join(e)},timeout:function(a,b){var c=y(a);return b?z(c,b):c},wrap:function(a){return new W(a)},wrapError:function(a){return new U(a)},_veryExpensiveTagWithStack:{get:function(){return E},set:function(a){E=a}},_veryExpensiveTagWithStack_tag:F,_getStack:function(){if(a.Debug&&a.Debug.debuggerEnabled)try{throw new Error}catch(b){return b.stack}},_cancelBlocker:function(a){if(!X.is(a))return X.wrap(a);var b,c,d=new X(function(a,d){b=a,c=d},function(){b=null,c=null});return a.then(function(a){b&&b(a)},function(a){c&&c(a)}),d}});return Object.defineProperties(X,e.createEventProperties(C)),X._doneHandler=function(a){b._setImmediate(function(){throw a})},{PromiseStateMachine:S,Promise:X,state_created:G}}),define("WinJS/Promise",["./Core/_Base","./Promise/_StateMachine"],function(a,b){"use strict";return a.Namespace.define("WinJS",{Promise:b.Promise}),b.Promise}),define("WinJS/Core/_Log",["exports","./_Global","./_Base"],function(a,b,c){"use strict";function d(a,b,c){var d=a;return"function"==typeof d&&(d=d()),(c&&h.test(c)?"":c?c+": ":"")+(b?b.replace(g,":")+": ":"")+d}function e(c,d,e){var f=a.formatLog(c,d,e);b.console&&b.console[e&&h.test(e)?e:"log"](f)}function f(a){return a.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&")}var g=/\s+/g,h=/^(error|warn|info|log)$/,i=null;c.Namespace._moduleDefine(a,"WinJS.Utilities",{startLog:function(b){b=b||{},"string"==typeof b&&(b={tags:b});var c=b.type&&new RegExp("^("+f(b.type).replace(g," ").split(" ").join("|")+")$"),d=b.excludeTags&&new RegExp("(^|\\s)("+f(b.excludeTags).replace(g," ").split(" ").join("|")+")(\\s|$)","i"),h=b.tags&&new RegExp("(^|\\s)("+f(b.tags).replace(g," ").split(" ").join("|")+")(\\s|$)","i"),i=b.action||e;if(!(c||d||h||a.log))return void(a.log=i);var j=function(a,b,e){c&&!c.test(e)||d&&d.test(b)||h&&!h.test(b)||i(a,b,e),j.next&&j.next(a,b,e)};j.next=a.log,a.log=j},stopLog:function(){a.log=null},formatLog:d}),c.Namespace._moduleDefine(a,"WinJS",{log:{get:function(){return i},set:function(a){i=a}}})}),define("WinJS/Scheduler",["exports","./Core/_Global","./Core/_Base","./Core/_ErrorFromName","./Core/_Log","./Core/_Resources","./Core/_Trace","./Core/_WriteProfilerMark","./Promise"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a){var b={},c="_prev"+a,d="_next"+a;return b["_remove"+a]=function(){var a=this[c],b=this[d];b&&(b[c]=a),a&&(a[d]=b),this[c]=null,this[d]=null},b["_insert"+a+"Before"]=function(a){var b=this[c];return b&&(b[d]=a),a[d]=this,a[c]=b,this[c]=a,a},b["_insert"+a+"After"]=function(a){var b=this[d];return this[d]=a,a[d]=b,a[c]=this,b&&(b[c]=a),a},b}function k(a,b,c){return void 0!==c?"("+a+";"+b+";"+c+")":void 0!==b?"("+a+";"+b+")":void 0!==a?"("+a+")":""}function l(a,b,c,d){h("WinJS.Scheduler:"+a+k(c,d)+","+b)}function m(a,b,c,d,e){var f=a.name||void 0!==d||void 0!==e;h("WinJS.Scheduler:"+b+":"+a.id+(f?k(a.name,d,e):"")+","+c)}function n(){return!1}function o(a){throw"Illegal call by job("+a.id+") in state: "+this.name}function p(a){return function(b,c,d){b._setState(a,c,d)}}function q(a,b){a._setPriority(b)}function r(a,b){function c(a,b){e.log&&e.log(b+": MARKER: "+a.name,"winjs scheduler","log")}function d(a,b){e.log&&e.log(b+": JOB("+a.id+"): state: "+(a._state?a._state.name:"")+(a.name?", name: "+a.name:""),"winjs scheduler","log")}e.log&&e.log("highWaterMark: "+Bb,"winjs scheduler","log");var f=0,g=b?vb[vb.length-1]:vb[0],h=g;do h instanceof mb&&c(h,f),h instanceof S&&d(h,f),f++,h=b?h["_prev"+a]:h["_next"+a];while(h)}function s(){function a(a,c){b+=" "+(c?"*":" ")+"id: "+a.id+", priority: "+I(a.priority).name+(a.name?", name: "+a.name:"")+"\n"}var b="";b+="Jobs:\n";var c=I(Bb),d=0;for(xb&&(a(xb,!0),d++);c.priority>=ub.min;)c instanceof S&&(a(c,!1),d++),c=c._nextJob;0===d&&(b+=" None\n"),b+="Drain requests:\n";for(var e=0,f=zb.length;f>e;e++)b+=" "+(0===e?"*":" ")+"priority: "+I(zb[e].priority).name+", name: "+zb[e].name+"\n";return 0===zb.length&&(b+=" None\n"),b}function t(){var a=vb[0];do{if(a instanceof S)return!1;a=a._nextJob}while(a);return!0}function u(){return 0===zb.length?null:zb[0].priority}function v(a){l("drain","StartTM",a.name,I(a.priority).name)}function w(a,b){b&&l("drain-canceled","info",a.name,I(a.priority).name),l("drain","StopTM",a.name,I(a.priority).name)}function x(a,b,c){zb.push({priority:a,complete:b,name:c}),1===zb.length&&(v(zb[0]),a>Bb&&(Bb=a,pb=!0))}function y(a,b){var c,d=zb.length;for(c=0;d>c;c++)if(zb[c].complete===a){0===c&&(w(zb[0],b),zb[1]&&v(zb[1])),zb.splice(c,1);break}}function z(){var a=zb.shift();a&&(w(a),zb[0]&&v(zb[0]),a.complete())}function A(){var a=!1;if(zb.length)for(var b=u();+b===b&&b>Bb;)ob=b,z(),a=!0,b=u();return a}function B(a){return a>=ub.aboveNormal+1?Eb.HIGH:a>=ub.belowNormal?Eb.NORMAL:Eb.IDLE}function C(a,b){return Fb[a]>=Fb[b]}function D(a,b){return Fb[a]>Fb[b]}function E(a){switch(a){case Eb.HIGH:return!1;case Eb.NORMAL:return Eb.isTaskScheduledAtPriorityOrHigher(Eb.HIGH);case Eb.IDLE:return Eb.isTaskScheduledAtPriorityOrHigher(Eb.NORMAL)}}function F(a,b){var c=I(b);c.priority>Bb&&(Bb=c.priority,pb=!0),c._insertJobAfter(a)}function G(a,b){var c=I(b);c.priority>Bb&&(Bb=c.priority,pb=!0),c._nextMarker._insertJobBefore(a)}function H(a){return a=0|a,a=Math.max(a,sb),a=Math.min(a,tb)}function I(a){return a=H(a),vb[-1*(a-tb)]}function J(a){nb=!0,l("timeslice","StartTM");var b,c,d,e=!0,f=!1,g=!1;pb=!1;try{for(var h=Gb(),i=h+Ab,j=function(){return f=!1,pb?!0:E(B(Bb))?!0:zb.length?!1:Gb()>i?(f=!0,!0):!1};Bb>=ub.min&&!j()&&!g;){b=!1,c=I(Bb)._nextJob;do{if(ob=c.priority,c instanceof S)d!==c.priority&&(+d===d&&l("priority","StopTM",I(d).name),l("priority","StartTM",I(c.priority).name),d=c.priority),b=!0,e=!1,xb=c,m(xb,"job-running","StartTM",I(ob).name),c._execute(j),m(xb,"job-running","StopTM",I(ob).name),xb=null,e=!0;else{var k=B(Bb);Bb=c.priority,b=A();var n=B(Bb);!D(k,n)||yb&&!Eb.isTaskScheduledAtPriorityOrHigher(n)||(g=!0)}c=c._nextJob}while(c&&!b&&!g&&!E(B(Bb)));pb=!1}}finally{xb=null,e||(m(c,"job-error","info"),m(c,"job-running","StopTM",I(ob).name),c.cancel()),+d===d&&l("priority","StopTM",I(d).name);for(var o=!1;Bb>=ub.min&&!o;){b=!1,c=I(Bb)._nextJob;do c instanceof S?o=!0:(Bb=c.priority,b=A()),c=c._nextJob;while(c&&!b&&!o)}var p;p=e?f?"timeslice exhausted":Bb=ub.min&&K(),l("yielding","info",p),l("timeslice","StopTM")}}function K(a){+a!==a&&(a=Bb);var b=B(a);if(!nb&&(!wb||yb&&!C(wb,b))){var c=++Hb,d=function(){c>Ib&&(Ib=Hb,J(!0))};Eb.execAsyncAtPriority(d,b),wb=b}}function L(a,b){var c=rb++;void 0===b&&(b="Drain Request "+c),a=+a===a?a:ub.min,a=H(a);var d,e=new i(function(c){d=c,x(a,d,b)},function(){y(d,!0)});return nb||K(),e}function M(a){return Eb.execAtPriority(a,Eb.HIGH)}function N(){return new V}function O(a,b,c,d){b=b||ub.normal,c=c||null;var e=++qb,f=g._traceAsyncOperationStarting("WinJS.Utilities.Scheduler.schedule: "+e+k(d));return d=d||"",new S(e,a,b,c,d,f)}function P(){if(nb)return ob;switch(Eb.getCurrentPriority()){case Eb.HIGH:return ub.high;case Eb.NORMAL:return ub.normal;case Eb.IDLE:return ub.idle}}function Q(a){return function(b,c){var d;return new i(function(e){d=O(function(){e(b)},a,null,c)},function(){d.cancel()})}}c.Namespace.define("WinJS.Utilities",{_linkedListMixin:j});var R={get jobInfoIsNoLongerValid(){return"The job info object can only be used while the job is running"}},S=c.Class.define(function(a,b,c,d,e,f){this._id=a,this._work=b,this._context=d,this._name=e,this._asyncOpID=f,this._setPriority(c),this._setState(X),m(this,"job-scheduled","info")},{completed:{get:function(){return!!this._state.completed}},id:{get:function(){return this._id}},name:{get:function(){return this._name},set:function(a){this._name=a}},owner:{get:function(){return this._owner},set:function(a){this._owner&&this._owner._remove(this),this._owner=a,this._owner&&this._owner._add(this)}},priority:{get:function(){return this._priority},set:function(a){a=H(a),this._state.setPriority(this,a)}},cancel:function(){this._state.cancel(this)},pause:function(){this._state.pause(this)},resume:function(){this._state.resume(this)},_execute:function(a){this._state.execute(this,a)},_executeDone:function(a){return this._state.executeDone(this,a)},_blockedDone:function(a){return this._state.blockedDone(this,a)},_setPriority:function(a){+this._priority===this._priority&&this._priority!==a&&m(this,"job-priority-changed","info",I(this._priority).name,I(a).name),this._priority=a},_setState:function(a,b,c){this._state&&e.log&&e.log("Transitioning job ("+this.id+") from: "+this._state.name+" to: "+a.name,"winjs scheduler","log"),this._state=a,this._state.enter(this,b,c)}});c.Class.mix(S,j("Job"));var T={complete:1,"continue":2,block:3},U=c.Class.define(function(a,b){this._job=b,this._result=null,this._yieldPolicy=T.complete,this._shouldYield=a},{job:{get:function(){return this._throwIfDisabled(),this._job}},shouldYield:{get:function(){return this._throwIfDisabled(),this._shouldYield()}},setPromise:function(a){this._throwIfDisabled(),this._result=a,this._yieldPolicy=T.block},setWork:function(a){this._throwIfDisabled(),this._result=a,this._yieldPolicy=T.continue},_disablePublicApi:function(){this._publicApiDisabled=!0},_throwIfDisabled:function(){if(this._publicApiDisabled)throw new d("WinJS.Utilities.Scheduler.JobInfoIsNoLongerValid",R.jobInfoIsNoLongerValid)}}),V=c.Class.define(function(){this._jobs={}},{cancelAll:function(){var a=this._jobs,b=Object.keys(a);this._jobs={};for(var c=0,d=b.length;d>c;c++)a[b[c]].cancel()},_add:function(a){this._jobs[a.id]=a},_remove:function(a){delete this._jobs[a.id]}}),W=c.Class.define(function(a){this.name=a,this.enter=o,this.execute=o,this.executeDone=o,this.blockedDone=o,this.cancel=o,this.pause=o,this.resume=o,this.setPriority=o}),X=new W("created"),Y=new W("scheduled"),Z=new W("paused"),$=new W("canceled"),_=new W("running"),ab=new W("running_paused"),bb=new W("running_resumed"),cb=new W("running_canceled"),db=new W("running_canceled_blocked"),eb=new W("cooperative_yield"),fb=new W("cooperative_yield_paused"),gb=new W("blocked"),hb=new W("blocked_waiting"),ib=new W("blocked_paused"),jb=new W("blocked_paused_waiting"),kb=new W("blocked_canceled"),lb=new W("complete");X.enter=function(a){G(a,a.priority),a._setState(Y)},Y.enter=function(){K()},Y.execute=p(_),Y.cancel=p($),Y.pause=p(Z),Y.resume=n,Y.setPriority=function(a,b){a.priority!==b&&(a._setPriority(b),a.pause(),a.resume())},Z.enter=function(a){m(a,"job-paused","info"),a._removeJob()},Z.cancel=p($),Z.pause=n,Z.resume=function(a){m(a,"job-resumed","info"),G(a,a.priority),a._setState(Y)},Z.setPriority=q,$.enter=function(a){m(a,"job-canceled","info"),g._traceAsyncOperationCompleted(a._asyncOpID,b.Debug&&b.Debug.MS_ASYNC_OP_STATUS_CANCELED),a._removeJob(),a._work=null,a._context=null,a.owner=null},$.cancel=n,$.pause=n,$.resume=n,$.setPriority=n,_.enter=function(a,b){a._removeJob();var c=a.priority,d=a._work,e=a._context;a._work=null,a._context=null;var f=new U(b,a);g._traceAsyncCallbackStarting(a._asyncOpID);try{Eb.execAtPriority(function(){d.call(e,f)},B(c))}finally{g._traceAsyncCallbackCompleted(),f._disablePublicApi()}a._context=e;var h=a._executeDone(f._yieldPolicy);a._setState(h,f._result,c)},_.executeDone=function(a,b){switch(b){case T.complete:return lb;case T.continue:return eb;case T.block:return gb}},_.cancel=function(a){pb=!0,a._setState(cb)},_.pause=function(a){pb=!0,a._setState(ab)},_.resume=n,_.setPriority=q,ab.enter=n,ab.executeDone=function(a,b){switch(b){case T.complete:return lb;case T.continue:return fb;case T.block:return ib}},ab.cancel=p(cb),ab.pause=n,ab.resume=p(bb),ab.setPriority=q,bb.enter=n,bb.executeDone=function(a,b){switch(b){case T.complete:return lb;case T.continue:return eb;case T.block:return gb}},bb.cancel=p(cb),bb.pause=p(ab),bb.resume=n,bb.setPriority=q,cb.enter=n,cb.executeDone=function(a,b){switch(b){case T.complete:case T.continue:return $;case T.block:return db}},cb.cancel=n,cb.pause=n,cb.resume=n,cb.setPriority=n,db.enter=function(a,b){b.cancel(),a._setState($)},eb.enter=function(a,b,c){m(a,"job-yielded","info"),c===a.priority?F(a,a.priority):G(a,a.priority),a._work=b,a._setState(Y)},fb.enter=function(a,b){m(a,"job-yielded","info"),a._work=b,a._setState(Z)},gb.enter=function(a,b,c){m(a,"job-blocked","StartTM"),a._work=b,a._setState(hb),b.done(function(b){m(a,"job-blocked","StopTM");var d=a._blockedDone(b);a._setState(d,b,c)},function(b){return b&&"Canceled"===b.name||m(a,"job-error","info"),m(a,"job-blocked","StopTM"),a._setState($),i.wrapError(b)})},hb.enter=n,hb.blockedDone=function(a,b){return"function"==typeof b?eb:lb},hb.cancel=p(kb),hb.pause=p(jb),hb.resume=n,hb.setPriority=q,ib.enter=function(a,b,c){m(a,"job-blocked","StartTM"),a._work=b,a._setState(jb),b.done(function(b){m(a,"job-blocked","StopTM");var d=a._blockedDone(b);a._setState(d,b,c)},function(b){return b&&"Canceled"===b.name||m(a,"job-error","info"),m(a,"job-blocked","StopTM"),a._setState($),i.wrapError(b)})},jb.enter=n,jb.blockedDone=function(a,b){return"function"==typeof b?fb:lb},jb.cancel=p(kb),jb.pause=n,jb.resume=p(hb),jb.setPriority=q,kb.enter=function(a){a._work.cancel(),a._work=null},kb.blockedDone=function(){return $},kb.cancel=n,kb.pause=n,kb.resume=n,kb.setPriority=n,lb.completed=!0,lb.enter=function(a){g._traceAsyncOperationCompleted(a._asyncOpID,b.Debug&&b.Debug.MS_ASYNC_OP_STATUS_SUCCESS),a._work=null,a._context=null,a.owner=null,m(a,"job-completed","info")},lb.cancel=n,lb.pause=n,lb.resume=n,lb.setPriority=n;var mb=c.Class.define(function(a,b){this.priority=a,this.name=b},{});c.Class.mix(mb,j("Job"),j("Marker"));var nb,ob,pb,qb=0,rb=0,sb=-15,tb=15,ub={max:15,high:13,aboveNormal:9,normal:0,belowNormal:-9,idle:-13,min:-15},vb=[new mb(15,"max"),new mb(14,"14"),new mb(13,"high"),new mb(12,"12"),new mb(11,"11"),new mb(10,"10"),new mb(9,"aboveNormal"),new mb(8,"8"),new mb(7,"7"),new mb(6,"6"),new mb(5,"5"),new mb(4,"4"),new mb(3,"3"),new mb(2,"2"),new mb(1,"1"),new mb(0,"normal"),new mb(-1,"-1"),new mb(-2,"-2"),new mb(-3,"-3"),new mb(-4,"-4"),new mb(-5,"-5"),new mb(-6,"-6"),new mb(-7,"-7"),new mb(-8,"-8"),new mb(-9,"belowNormal"),new mb(-10,"-10"),new mb(-11,"-11"),new mb(-12,"-12"),new mb(-13,"idle"),new mb(-14,"-14"),new mb(-15,"min"),new mb(-16,"")],wb=null,xb=null,yb=!(!b.MSApp||!b.MSApp.execAtPriority),zb=[],Ab=30,Bb=ub.min;vb.reduce(function(a,b){return a&&(a._insertJobAfter(b),a._insertMarkerAfter(b)),b});var Cb=b.setImmediate?b.setImmediate.bind(b):function(a){b.setTimeout(a,16)},Db={execAsyncAtPriority:function(a,c){c===Eb.HIGH&&b.setTimeout(a,0),Cb(a)},execAtPriority:function(a){return a()},getCurrentPriority:function(){return Db.NORMAL},isTaskScheduledAtPriorityOrHigher:function(){return!1},HIGH:"high",NORMAL:"normal",IDLE:"idle"},Eb=yb?b.MSApp:Db,Fb={};Fb[Eb.IDLE]=1,Fb[Eb.NORMAL]=2,Fb[Eb.HIGH]=3;var Gb=b.performance&&b.performance.now&&b.performance.now.bind(b.performance)||Date.now.bind(Date),Hb=0,Ib=0;c.Namespace._moduleDefine(a,"WinJS.Utilities.Scheduler",{Priority:ub,schedule:O,createOwnerToken:N,execHigh:M,requestDrain:L,currentPriority:{get:P},schedulePromiseHigh:Q(ub.high),schedulePromiseAboveNormal:Q(ub.aboveNormal),schedulePromiseNormal:Q(ub.normal),schedulePromiseBelowNormal:Q(ub.belowNormal),schedulePromiseIdle:Q(ub.idle),retrieveState:s,_JobNode:S,_JobInfo:U,_OwnerToken:V,_dumpList:r,_isEmpty:{get:t},_usingWwaScheduler:{get:function(){return yb},set:function(a){yb=a,Eb=yb?b.MSApp:Db}},_MSApp:{get:function(){return Eb},set:function(a){Eb=a}},_TIME_SLICE:Ab})}),define("WinJS/Core/_BaseUtils",["exports","./_Global","./_Base","./_BaseCoreUtils","./_ErrorFromName","./_Resources","./_Trace","../Promise","../Scheduler"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a){return a}function k(a,b,c){return a.split(".").reduce(function(a,b){return a?c(a[b]):null},b)}function l(a,c){return a?k(a,c||b,j):null}function m(a){return a.length>0&&0!==a.indexOf("-moz")&&"-"===a.charAt(0)&&(a=a.slice(1)),a.replace(/\-[a-z]/g,function(a){return a[1].toUpperCase()})}function n(a,b){return""===a?b:a+b.charAt(0).toUpperCase()+b.slice(1)}function o(a,b){return(""!==a?"-"+a.toLowerCase()+"-":"")+b}function p(){if(!b.document)return{};for(var a={},c=b.document.documentElement.style,d=["","webkit","ms","Moz"],e=["animation","transition","transform","animation-name","animation-duration","animation-delay","animation-timing-function","animation-iteration-count","animation-direction","animation-fill-mode","grid-column","grid-columns","grid-column-span","grid-row","grid-rows","grid-row-span","transform-origin","transition-property","transition-duration","transition-delay","transition-timing-function","scroll-snap-points-x","scroll-snap-points-y","scroll-chaining","scroll-limit","scroll-limit-x-max","scroll-limit-x-min","scroll-limit-y-max","scroll-limit-y-min","scroll-snap-type","scroll-snap-x","scroll-snap-y","touch-action","overflow-style","user-select"],f={},g=0,h=e.length;h>g;g++)for(var i=e[g],j=m(i),k=0,l=d.length;l>k;k++){var p=d[k],q=n(p,j);if(q in c){var r=o(p,i);a[i]={cssName:r,scriptName:q},f[i]=p;break}}return a.animationPrefix=o(f.animation,""),a.keyframes=o(f.animation,"keyframes"),a}function q(){for(var a={},c=["","WebKit"],d=[{eventObject:"TransitionEvent",events:["transitionStart","transitionEnd"]},{eventObject:"AnimationEvent",events:["animationStart","animationEnd"]}],e=0,f=d.length;f>e;e++){for(var g=d[e],h="",i=0,j=c.length;j>i;i++){var k=c[i];if(k+g.eventObject in b){h=k.toLowerCase();break}}for(var i=0,l=g.events.length;l>i;i++){var m=g.events[i];a[m]=n(h,m),""===h&&(a[m]=a[m].toLowerCase())}}return a.manipulationStateChanged="MSManipulationEvent"in b?"ManipulationEvent":null,a}var r,s={get notSupportedForProcessing(){return"Value is not supported within a declarative processing context, if you want it to be supported mark it using WinJS.Utilities.markSupportedForProcessing. The value was: '{0}'"}},t=0,u={},v=!1,w=!1,x=b.navigator.platform,y="iPhone"===x||"iPad"===x||"iPod"===x;c.Namespace._moduleDefine(a,"WinJS.Utilities",{_setHasWinRT:{value:function(a){d.hasWinRT=a},configurable:!1,writable:!1,enumerable:!1},hasWinRT:{get:function(){return d.hasWinRT},configurable:!1,enumerable:!0},_setIsiOS:{value:function(a){y=a},configurable:!1,writable:!1,enumerable:!1},_isiOS:{get:function(){return y},configurable:!1,enumerable:!0},_getMemberFiltered:k,getMember:l,_browserStyleEquivalents:p(),_browserEventEquivalents:q(),_getCamelCasedName:m,ready:function z(a,c){return new h(function(d,e){function f(){if(a)try{a(),d()}catch(b){e(b)}else d()}var g=z._testReadyState;g||(g=b.document?b.document.readyState:"complete"),"complete"===g||b.document&&null!==b.document.body?c?i.schedule(function(){f()},i.Priority.normal,null,"WinJS.Utilities.ready"):f():b.addEventListener("DOMContentLoaded",f,!1)})},strictProcessing:{get:function(){return!0},configurable:!1,enumerable:!0},markSupportedForProcessing:{value:d.markSupportedForProcessing,configurable:!1,writable:!1,enumerable:!0},requireSupportedForProcessing:{value:function(a){var c=!0;switch(c=c&&a!==b,c=c&&a!==b.location,c=c&&!(a instanceof b.HTMLIFrameElement),c=c&&!("function"==typeof a&&!a.supportedForProcessing),b.frames.length){case 0:break;case 1:c=c&&a!==b.frames[0];break;default:for(var d=0,g=b.frames.length;c&&g>d;d++)c=c&&a!==b.frames[d]}if(c)return a;throw new e("WinJS.Utilities.requireSupportedForProcessing",f._formatString(s.notSupportedForProcessing,a))},configurable:!1,writable:!1,enumerable:!0},_setImmediate:d._setImmediate,_requestAnimationFrame:b.requestAnimationFrame?b.requestAnimationFrame.bind(b):function(a){var c=++t;return u[c]=a,r=r||b.setTimeout(function(){var a=u,b=Date.now();u={},r=null,Object.keys(a).forEach(function(c){a[c](b)})},16),c},_cancelAnimationFrame:b.cancelAnimationFrame?b.cancelAnimationFrame.bind(b):function(a){delete u[a]},_yieldForEvents:b.setImmediate?b.setImmediate.bind(b):function(a){b.setTimeout(a,0)},_yieldForDomModification:b.setImmediate?b.setImmediate.bind(b):function(a){b.setTimeout(a,0)},_shallowCopy:function(a){return this._mergeAll([a])},_merge:function(a,b){return this._mergeAll([a,b])},_mergeAll:function(a){var b={};return a.forEach(function(a){Object.keys(a).forEach(function(c){b[c]=a[c]})}),b},_getProfilerMarkIdentifier:function(a){var b="";return a.id&&(b+=" id='"+a.id+"'"),a.className&&(b+=" class='"+a.className+"'"),b},_now:function(){return b.performance&&b.performance.now&&b.performance.now()||Date.now()},_traceAsyncOperationStarting:g._traceAsyncOperationStarting,_traceAsyncOperationCompleted:g._traceAsyncOperationCompleted,_traceAsyncCallbackStarting:g._traceAsyncCallbackStarting,_traceAsyncCallbackCompleted:g._traceAsyncCallbackCompleted,isPhone:{get:function(){return v},configurable:!1,enumerable:!0},_setIsPhone:{set:function(a){v=a}}}),c.Namespace._moduleDefine(a,"WinJS",{validation:{get:function(){return w},set:function(a){w=a}}}),c.Namespace.define("WinJS",{strictProcessing:{value:function(){},configurable:!1,writable:!1,enumerable:!1}})}),define("WinJS/Core",["./Core/_Base","./Core/_BaseCoreUtils","./Core/_BaseUtils","./Core/_ErrorFromName","./Core/_Events","./Core/_Global","./Core/_Log","./Core/_Resources","./Core/_Trace","./Core/_WinRT","./Core/_WriteProfilerMark"],function(){}),define("WinJS/_Signal",["./Core/_Base","./Promise/_StateMachine"],function(a,b){"use strict";var c=a.Class.derive(b.PromiseStateMachine,function(a){this._oncancel=a,this._setState(b.state_created),this._run()},{_cancelAction:function(){this._oncancel&&this._oncancel()},_cleanupAction:function(){this._oncancel=null}},{supportedForProcessing:!1}),d=a.Class.define(function(a){this._promise=new c(a)},{promise:{get:function(){return this._promise}},cancel:function(){this._promise.cancel()},complete:function(a){this._promise._completed(a)},error:function(a){this._promise._error(a)},progress:function(a){this._promise._progress(a)}},{supportedForProcessing:!1});return a.Namespace.define("WinJS",{_Signal:d}),d}),define("WinJS/Utilities/_Control",["exports","../Core/_Global","../Core/_Base"],function(a,b,c){"use strict";function d(a,b){e(a,b)}function e(a,b,c){if("object"==typeof b)for(var d=Object.keys(b),e=0,f=d.length;f>e;e++){var g=d[e],h=b[g];if(g.length>2){var i=g[0],j=g[1];if(!("o"!==i&&"O"!==i||"n"!==j&&"N"!==j)&&"function"==typeof h&&a.addEventListener){a.addEventListener(g.substr(2),h);continue}}c||(a[g]=h)}}b.document&&c.Namespace._moduleDefine(a,"WinJS.UI",{DOMEventMixin:c.Namespace._lazy(function(){return{_domElement:null,addEventListener:function(a,b,c){(this.element||this._domElement).addEventListener(a,b,c||!1) +},dispatchEvent:function(a,c){var d=b.document.createEvent("Event");return d.initEvent(a,!1,!1),d.detail=c,"object"==typeof c&&Object.keys(c).forEach(function(a){d[a]=c[a]}),(this.element||this._domElement).dispatchEvent(d)},removeEventListener:function(a,b,c){(this.element||this._domElement).removeEventListener(a,b,c||!1)}}}),setOptions:d,_setOptions:e})}),define("WinJS/Utilities/_ElementUtilities",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Promise","../Scheduler"],function(a,b,c,d,e,f){"use strict";function g(a){for(var b=a.length,c=b-1;c>=0;c--)a[c]||(a.splice(c,1),b--);return b}function h(a){var b=a.className||"";return"string"==typeof b?b:b.baseVal||""}function i(a,b){var c=a.className||"";return"string"==typeof c?a.className=b:a.className.baseVal=b,a}function j(a,b){if(a.classList){if(b.indexOf(" ")<0)a.classList.add(b);else{var c=b.split(" ");g(c);for(var d=0,e=c.length;e>d;d++)a.classList.add(c[d])}return a}var f,j=h(a),k=j.split(" "),l=g(k);if(b.indexOf(" ")>=0){var c=b.split(" ");g(c);for(var d=0;l>d;d++){var m=c.indexOf(k[d]);m>=0&&c.splice(m,1)}c.length>0&&(f=c.join(" "))}else{for(var n=!1,d=0;l>d;d++)if(k[d]===b){n=!0;break}n||(f=b)}return f&&(l>0&&k[0].length>0?i(a,j+" "+f):i(a,f)),a}function k(a,b){if(a.classList){if(0===a.classList.length)return a;var c=b.split(" ");g(c);for(var d=0,e=c.length;e>d;d++)a.classList.remove(c[d]);return a}var c,f,j=h(a);if(b.indexOf(" ")>=0)c=b.split(" "),f=g(c);else{if(j.indexOf(b)<0)return a;c=[b],f=1}for(var k,l=j.split(" "),m=g(l),d=m-1;d>=0;d--)c.indexOf(l[d])>=0&&(l.splice(d,1),k=!0);return k&&i(a,l.join(" ")),a}function l(a,b){if(a.classList)return a.classList.toggle(b),a;for(var c=h(a),d=c.trim().split(" "),e=d.length,f=!1,g=0;e>g;g++)d[g]===b&&(f=!0);return f?i(a,d.reduce(function(a,c){return c===b?a:a&&a.length>0?a+" "+c:c},"")):e>0&&d[0].length>0?i(a,c+" "+b):i(a,c+b),a}function m(a,b,c){a.getAttribute(b)!==""+c&&a.setAttribute(b,c)}function n(a,b,c,d){var e=Math.max(b,Math.min(c,+a));return 0===e?0:e||Math.max(b,Math.min(c,d))}function o(a,b){if(!L.test(b)&&M.test(b)){var c=a.style.left;return a.style.left=b,b=a.style.pixelLeft,a.style.left=c,b}return Math.round(parseFloat(b))||0}function p(a,c){return o(a,b.getComputedStyle(a,null)[c])}function q(a,b,c,d,e){var f=b.toLowerCase();a._eventsMap||(a._eventsMap={}),a._eventsMap[f]||(a._eventsMap[f]=[]),a._eventsMap[f].push({listener:c,useCapture:d,data:e})}function r(a,b,c,d){var e=b.toLowerCase(),f=a._eventsMap&&a._eventsMap[e];if(f)for(var g=f.length-1;g>=0;g--){var h=f[g];if(h.listener===c&&!!d==!!h.useCapture)return f.splice(g,1),h}return null}function s(a,b){var c=b.toLowerCase();return a._eventsMap&&a._eventsMap[c]&&a._eventsMap[c].slice(0)||[]}function t(a,b,c){for(;a;){for(var d=s(a,b),e=0,f=d.length;f>e;e++)d[e].listener.call(a,c);a=a.parentNode}}function u(a){return(a.relatedTarget&&"IFRAME"===a.relatedTarget.tagName||a.target&&"IFRAME"===a.target.tagName)&&(a.relatedTarget=null),a}function v(a,b,c,d){if(d)throw"This custom WinJS event only supports bubbling";q(a,b,c,d)}function w(a,b){var c=b.changedTouches,d=null;if(!c)return d;for(var e=0,f=c.length;f>e;e++){var g=c[e],h=new R(b,{pointerType:P.MSPOINTER_TYPE_TOUCH,pointerId:g.identifier,screenX:g.screenX,screenY:g.screenY,clientX:g.clientX,clientY:g.clientY,radiusX:g.radiusX,radiusY:g.radiusY,rotationAngle:g.rotationAngle,force:g.force,_currentTouch:g}),i=a(h);d=d||i}return d}function x(a,b){return b.pointerType=P.MSPOINTER_TYPE_MOUSE,b.pointerId=-1,a(b)}function y(a,b){return a(b)}function z(a,c,d,e){var f,g,h,i,j=c.toLowerCase(),k=S[j];b.MSPointerEvent?(h=function(a){return a._normalizedType=j,i=!0,y(d,a)},a.addEventListener(k.mspointer,h,e)):(k.mouse&&(f=function(a){return a._normalizedType=j,i?void(i=!1):x(d,a)},a.addEventListener(k.mouse,f,e)),k.touch&&(g=function(a){return a._normalizedType=j,i=!0,w(d,a)},a.addEventListener(k.touch,g,e))),q(a,c,d,e,{mouseWrapper:f,touchWrapper:g,mspointerWrapper:h})}function A(a,b,c,d){var e=b.toLowerCase(),f=r(a,b,c,d);if(f){var g=S[e];f.data.mouseWrapper&&a.removeEventListener(g.mouse,f.data.mouseWrapper,d),f.data.touchWrapper&&a.removeEventListener(g.touch,f.data.touchWrapper,d),f.data.mspointerWrapper&&a.removeEventListener(g.mspointer,f.data.mspointerWrapper,d)}}function B(){var a=b.document.createElement("div");a.style.direction="rtl",a.innerHTML="
",b.document.body.appendChild(a);var c=a.firstChild;c.scrollLeft>0&&(_=!0),c.scrollLeft+=100,0===c.scrollLeft&&(ab=!0),b.document.body.removeChild(a),$=!0}function C(a){var c=b.getComputedStyle(a),d=a.scrollLeft;return"rtl"===c.direction&&($||B(),_&&(d=a.scrollWidth-a.clientWidth-d),d=Math.abs(d)),{scrollLeft:d,scrollTop:a.scrollTop}}function D(a,c,d){if(void 0!==c){var e=b.getComputedStyle(a);"rtl"===e.direction&&($||B(),ab?c=-c:_&&(c=a.scrollWidth-a.clientWidth-c)),a.scrollLeft=c}void 0!==d&&(a.scrollTop=d)}function E(a){return C(a)}function F(a,b){b=b||{},D(a,b.scrollLeft,b.scrollTop)}function G(a){return a.uniqueID||a._uniqueID||(a._uniqueID="element__"+ ++db),a.uniqueID||a._uniqueID}function H(a){a.id||(a.id=G(a))}function I(a){var c=b.document.documentElement,d=E(c);return{left:a.clientX+("rtl"===b.document.body.dir?-d.scrollLeft:d.scrollLeft),top:a.clientY+c.scrollTop}}function J(a,b){for(var c=[],d=0,e=b.length;e>d;d++){var f=a.querySelector("."+b[d]);f&&c.push(f)}return c}if(b.document){var K=167,L=/^-?\d+\.?\d*(px)?$/i,M=/^-?\d+/i,N=b.MSGestureEvent||{MSGESTURE_FLAG_BEGIN:1,MSGESTURE_FLAG_CANCEL:4,MSGESTURE_FLAG_END:2,MSGESTURE_FLAG_INERTIA:8,MSGESTURE_FLAG_NONE:0},O=b.MSManipulationEvent||{MS_MANIPULATION_STATE_ACTIVE:1,MS_MANIPULATION_STATE_CANCELLED:6,MS_MANIPULATION_STATE_COMMITTED:7,MS_MANIPULATION_STATE_DRAGGING:5,MS_MANIPULATION_STATE_INERTIA:2,MS_MANIPULATION_STATE_PRESELECT:3,MS_MANIPULATION_STATE_SELECTING:4,MS_MANIPULATION_STATE_STOPPED:0},P=b.MSPointerEvent||{MSPOINTER_TYPE_TOUCH:"touch",MSPOINTER_TYPE_PEN:"pen",MSPOINTER_TYPE_MOUSE:"mouse"},Q=null;b.addEventListener("blur",function(){var a=Q;a&&t(a,"focusout",u({type:"focusout",target:a,relatedTarget:null})),Q=null}),b.document.documentElement.addEventListener("focus",function(a){var b=Q;Q=a.target,b&&t(b,"focusout",u({type:"focusout",target:b,relatedTarget:Q})),Q&&t(Q,"focusin",u({type:"focusin",target:Q,relatedTarget:b}))},!0);var R=function(a,b){b=b||{},this.__eventObject=a;var c=this;Object.keys(b).forEach(function(a){Object.defineProperty(c,a,{value:b[a]})})};["altKey","AT_TARGET","bubbles","BUBBLING_PHASE","button","buttons","cancelable","cancelBubble","CAPTURING_PHASE","clientX","clientY","ctrlKey","currentTarget","defaultPrevented","detail","eventPhase","fromElement","getModifierState","height","hwTimestamp","initEvent","initMouseEvent","initPointerEvent","initUIEvent","isPrimary","isTrusted","layerX","layerY","metaKey","offsetX","offsetY","pageX","pageY","pointerId","pointerType","pressure","preventDefault","relatedTarget","rotation","screenX","screenY","shiftKey","srcElement","stopImmediatePropagation","stopPropagation","target","tiltX","tiltY","timeStamp","toElement","type","view","which","width","x","y","_normalizedType","_fakedBySemanticZoom"].forEach(function(a){Object.defineProperty(R.prototype,a,{get:function(){var b=this.__eventObject[a];return"function"==typeof b?b.bind(this.__eventObject):b},configurable:!0})});var S={pointerdown:{touch:"touchstart",mspointer:"MSPointerDown",mouse:"mousedown"},pointerup:{touch:"touchend",mspointer:"MSPointerUp",mouse:"mouseup"},pointermove:{touch:"touchmove",mspointer:"MSPointerMove",mouse:"mousemove"},pointerenter:{touch:"touchenter",mspointer:"MSPointerEnter",mouse:"mouseenter"},pointerover:{touch:null,mspointer:"MSPointerOver",mouse:"mouseover"},pointerout:{touch:"touchleave",mspointer:"MSPointerOut",mouse:"mouseout"},pointercancel:{touch:"touchcancel",mspointer:"MSPointerCancel",mouse:null}},T={focusout:{register:v,unregister:r},focusin:{register:v,unregister:r}};if(!b.PointerEvent){var U={register:z,unregister:A};T.pointerdown=U,T.pointerup=U,T.pointermove=U,T.pointerenter=U,T.pointerover=U,T.pointerout=U,T.pointercancel=U}var V=c.Class.define(function(a){this._callback=a,this._toDispose=[],this._attributeFilter=[],this._scheduled=!1,this._pendingChanges=[],this._observerCount=0,this._handleCallback=this._handleCallback.bind(this),this._targetElements=[]},{observe:function(a,b){-1===this._targetElements.indexOf(a)&&this._targetElements.push(a),this._observerCount++,b.attributes&&this._addRemovableListener(a,"DOMAttrModified",this._handleCallback),b.attributeFilter&&(this._attributeFilter=b.attributeFilter)},disconnect:function(){this._observerCount=0,this._targetElements=[],this._toDispose.forEach(function(a){a()})},_addRemovableListener:function(a,b,c){a.addEventListener(b,c),this._toDispose.push(function(){a.removeEventListener(b,c)})},_handleCallback:function(a){if(a.stopPropagation(),(!this._attributeFilter.length||-1!==this._attributeFilter.indexOf(a.attrName))&&-1!==this._targetElements.indexOf(a.target)){var b=a.attrName;"tabindex"===b&&(b="tabIndex"),this._pendingChanges.push({type:"attributes",target:a.target,attributeName:b}),1===this._observerCount?this._dispatchEvent():this._scheduled===!1&&(this._scheduled=!0,d._setImmediate(this._dispatchEvent.bind(this)))}},_dispatchEvent:function(){try{this._callback(this._pendingChanges)}finally{this._pendingChanges=[],this._scheduled=!1}}},{_isShim:!0}),W=b.MutationObserver||V,X=null,Y=c.Class.define(function(){b.addEventListener("resize",this._handleResize.bind(this))},{subscribe:function(a,b){a.addEventListener(this._resizeEvent,b),j(a,this._resizeClass)},unsubscribe:function(a,b){k(a,this._resizeClass),a.removeEventListener(this._resizeEvent,b)},_handleResize:function(){for(var a=b.document.querySelectorAll("."+this._resizeClass),c=a.length,d=0;c>d;d++){var e=b.document.createEvent("Event");e.initEvent(this._resizeEvent,!1,!0),a[d].dispatchEvent(e)}},_resizeClass:{get:function(){return"win-element-resize"}},_resizeEvent:{get:function(){return"WinJSElementResize"}}}),Z=new(c.Class.define(function(){this.capture={},this.bubble={}},{addEventListener:function(c,d,e,f){d=d.toLowerCase();var g=this._getHandlers(f),h=g[d];h||(h=this._getListener(d,f),h.refCount=0,g[d]=h,a._addEventListener(b,d,h,f)),h.refCount++,c.addEventListener(this._getEventName(d,f),e),j(c,this._getClassName(d,f))},removeEventListener:function(c,d,e,f){d=d.toLowerCase();var g=this._getHandlers(f),h=g[d];h&&(h.refCount--,0===h.refCount&&(a._removeEventListener(b,d,h,f),delete g[d])),k(c,this._getClassName(d,f)),c.removeEventListener(this._getEventName(d,f),e)},_getHandlers:function(a){return a?this.capture:this.bubble},_getClassName:function(a,b){var c=b?"capture":"bubble";return"win-global-event-"+a+c},_getEventName:function(a,b){var c=b?"capture":"bubble";return"WinJSGlobalEvent-"+a+c},_getListener:function(a,c){var d=function(d){for(var e=b.document.querySelectorAll("."+this._getClassName(a,c)),f=e.length,g=0;f>g;g++){var h=b.document.createEvent("Event");h.initEvent(this._getEventName(a,c),!1,!0),h.detail={originalEvent:d},e[g].dispatchEvent(h)}};return d.bind(this)}})),$=!1,_=!1,ab=!1,bb=b.navigator.msManipulationViewsEnabled||b.navigator.userAgent.indexOf("MSAppHost")>=0,cb=!(!b.MSPointerEvent&&!b.TouchEvent),db=0,eb=".win-selectionborder, .win-selectionbackground, .win-selectioncheckmark, .win-selectioncheckmarkbackground",fb="_msDataKey";c.Namespace._moduleDefine(a,"WinJS.Utilities",{_dataKey:fb,_supportsSnapPoints:{get:function(){return bb}},_supportsTouchDetection:{get:function(){return cb}},_uniqueID:G,_ensureId:H,_clamp:n,_getCursorPos:I,_getElementsByClasses:J,_createGestureRecognizer:function(){if(b.MSGesture)return new b.MSGesture;var a=function(){};return{addEventListener:a,removeEventListener:a,addPointer:a,stop:a}},_supportsTouchActionCrossSlide:{get:function(){if(void 0===this._supportsTouchActionCrossSlideValue){this._supportsTouchActionCrossSlideValue=!1;var a=d._browserStyleEquivalents["touch-action"];if(a){var c=b.document.createElement("div");c.style.touchAction="cross-slide-x",b.document.body.appendChild(c),this._supportsTouchActionCrossSlideValue="cross-slide-x"===b.getComputedStyle(c).touchAction,b.document.body.removeChild(c)}}return this._supportsTouchActionCrossSlideValue}},_MSGestureEvent:N,_MSManipulationEvent:O,_elementsFromPoint:function(a,c){if(b.document.msElementsFromPoint)return b.document.msElementsFromPoint(a,c);var d=b.document.elementFromPoint(a,c);return d?[d]:null},_matchesSelector:function(a,b){var c=a.matches||a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector;return c.call(a,b)},_selectionPartsSelector:eb,_isSelectionRendered:function(a){return a.querySelectorAll(eb).length>0},_addEventListener:function(a,b,c,e){var f=b&&b.toLowerCase(),g=T[f],h=d._browserEventEquivalents[b];g?g.register(a,b,c,e):h?a.addEventListener(h,c,e):a.addEventListener(b,c,e)},_removeEventListener:function(a,b,c,e){var f=b&&b.toLowerCase(),g=T[f],h=d._browserEventEquivalents[b];g?g.unregister(a,b,c,e):h?a.removeEventListener(h,c,e):a.removeEventListener(b,c,e)},_initEventImpl:function(a,b,c){c=c.toLowerCase();var d=S[c];if(d)switch(a.toLowerCase()){case"pointer":arguments[2]=d.mspointer;break;default:arguments[2]=d[a.toLowerCase()]}b["init"+a+"Event"].apply(b,Array.prototype.slice.call(arguments,2))},_initMouseEvent:function(a){this._initEventImpl.apply(this,["Mouse",a].concat(Array.prototype.slice.call(arguments,1)))},_initPointerEvent:function(a){this._initEventImpl.apply(this,["Pointer",a].concat(Array.prototype.slice.call(arguments,1)))},_PointerEventProxy:R,_bubbleEvent:t,_setPointerCapture:function(a,b){a.setPointerCapture&&a.setPointerCapture(b)},_releasePointerCapture:function(a,b){a.releasePointerCapture&&a.releasePointerCapture(b)},_MSPointerEvent:P,_zoomToDuration:K,_zoomTo:function(a,c){a.msZoomTo?a.msZoomTo(c):f.schedule(function(){var e=C(a),f="number"==typeof a._zoomToDestX?a._zoomToDestX:e.scrollLeft,g="number"==typeof a._zoomToDestY?a._zoomToDestY:e.scrollTop,h=b.getComputedStyle(a),i=a.scrollWidth-parseInt(h.width,10)-parseInt(h.paddingLeft,10)-parseInt(h.paddingRight,10),j=a.scrollHeight-parseInt(h.height,10)-parseInt(h.paddingTop,10)-parseInt(h.paddingBottom,10);"number"!=typeof c.contentX&&(c.contentX=f),"number"!=typeof c.contentY&&(c.contentY=g);var k=n(c.contentX,0,i),l=n(c.contentY,0,j);if(k!==f||l!==g){a._zoomToId=a._zoomToId||0,a._zoomToId++,a._zoomToDestX=k,a._zoomToDestY=l;var m=a._zoomToId,o=d._now(),p=(a._zoomToDestX-e.scrollLeft)/K,q=(a._zoomToDestY-e.scrollTop)/K,r=function(){var b=d._now()-o;a._zoomToId===m&&(b>K?(D(a,a._zoomToDestX,a._zoomToDestY),a._zoomToDestX=null,a._zoomToDestY=null):(D(a,e.scrollLeft+b*p,e.scrollTop+b*q),d._requestAnimationFrame(r)))};d._requestAnimationFrame(r)}},f.Priority.high,null,"WinJS.Utilities._zoomTo")},_setActive:function(a,c){var d=!0;try{if(b.HTMLElement&&b.HTMLElement.prototype.setActive)a.setActive();else{var e,f;c&&(e=c.scrollLeft,f=c.scrollTop),a.focus(),c&&(c.scrollLeft=e,c.scrollTop=f)}}catch(g){d=!1}return d},_MutationObserver:W,_resizeNotifier:{get:function(){return X||(X=new Y),X}},_globalListener:Z,_addInsertedNotifier:function(c){var e=b.document.createElement("div");return e.style[d._browserStyleEquivalents["animation-name"].scriptName]="WinJS-node-inserted",e.style[d._browserStyleEquivalents["animation-duration"].scriptName]="0.01s",e.style.position="absolute",c.appendChild(e),a._addEventListener(e,"animationStart",function(a){if("WinJS-node-inserted"===a.animationName){var a=b.document.createEvent("Event");a.initEvent("WinJSNodeInserted",!1,!0),c.dispatchEvent(a)}},!1),e},_setFlexStyle:function(a,b){var c=a.style;"undefined"!=typeof b.grow&&(c.msFlexPositive=b.grow,c.webkitFlexGrow=b.grow,c.flexGrow=b.grow),"undefined"!=typeof b.shrink&&(c.msFlexNegative=b.shrink,c.webkitFlexShrink=b.shrink,c.flexShrink=b.shrink),"undefined"!=typeof b.basis&&(c.msFlexPreferredSize=b.basis,c.webkitFlexBasis=b.basis,c.flexBasis=b.basis)},Key:{backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capsLock:20,escape:27,space:32,pageUp:33,pageDown:34,end:35,home:36,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40,insert:45,deleteKey:46,num0:48,num1:49,num2:50,num3:51,num4:52,num5:53,num6:54,num7:55,num8:56,num9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,leftWindows:91,rightWindows:92,menu:93,numPad0:96,numPad1:97,numPad2:98,numPad3:99,numPad4:100,numPad5:101,numPad6:102,numPad7:103,numPad8:104,numPad9:105,multiply:106,add:107,subtract:109,decimalPoint:110,divide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,numLock:144,scrollLock:145,browserBack:166,browserForward:167,semicolon:186,equal:187,comma:188,dash:189,period:190,forwardSlash:191,graveAccent:192,openBracket:219,backSlash:220,closeBracket:221,singleQuote:222,IME:229},data:function(a){return a[fb]||(a[fb]={}),a[fb]},hasClass:function(a,b){if(a.classList)return a.classList.contains(b);for(var c=h(a),d=c.trim().split(" "),e=d.length,f=0;e>f;f++)if(d[f]===b)return!0;return!1},addClass:j,removeClass:k,toggleClass:l,_setAttribute:m,getRelativeLeft:function(a,b){if(!a)return 0;for(var c=a.offsetLeft,d=a.parentNode;d&&(c-=d.offsetLeft,d!==b);)d=d.parentNode;return c},getRelativeTop:function(a,b){if(!a)return 0;for(var c=a.offsetTop,d=a.parentNode;d&&(c-=d.offsetTop,d!==b);)d=d.parentNode;return c},getScrollPosition:E,setScrollPosition:F,empty:function(a){if(a.childNodes&&a.childNodes.length>0)for(var b=a.childNodes.length-1;b>=0;b--)a.removeChild(a.childNodes.item(b));return a},_isDOMElement:function(a){return a&&"object"==typeof a&&"string"==typeof a.tagName},getContentWidth:function(a){var b=p(a,"borderLeftWidth")+p(a,"borderRightWidth"),c=p(a,"paddingLeft")+p(a,"paddingRight");return a.offsetWidth-b-c},getTotalWidth:function(a){var b=p(a,"marginLeft")+p(a,"marginRight");return a.offsetWidth+b},getContentHeight:function(a){var b=p(a,"borderTopWidth")+p(a,"borderBottomWidth"),c=p(a,"paddingTop")+p(a,"paddingBottom");return a.offsetHeight-b-c},getTotalHeight:function(a){var b=p(a,"marginTop")+p(a,"marginBottom");return a.offsetHeight+b},getPosition:function(a){for(var c=a,d=a.offsetParent,e=a.offsetTop,f=a.offsetLeft;(a=a.parentNode)&&a!==b.document.body&&a!==b.document.documentElement;){e-=a.scrollTop;var g=b.document.defaultView.getComputedStyle(a,null).direction;f-="rtl"!==g?a.scrollLeft:-C(a).scrollLeft,a===d&&(e+=a.offsetTop,f+=a.offsetLeft,d=a.offsetParent)}return{left:f,top:e,width:c.offsetWidth,height:c.offsetHeight}},getTabIndex:function(a){var b=/BUTTON|COMMAND|MENUITEM|OBJECT|SELECT|TEXTAREA/;if(a.disabled)return-1;var c=a.getAttribute("tabindex");if(null===c||void 0===c){var d=a.tagName;return b.test(d)||a.href&&("A"===d||"AREA"===d||"LINK"===d)||"INPUT"===d&&"hidden"!==a.type||"TH"===d&&a.sorted?0:-1}return parseInt(c,10)},convertToPixels:o,eventWithinElement:function(a,b){var c=b.relatedTarget;return c&&c!==a?a.contains(c):!1},_deprecated:function(a){b.console&&b.console.warn(a)},_syncRenderer:function(a,c){if(c=c||"div","function"==typeof a)return function(b,c){return c?(c.appendChild(a(b)),c):a(b)};var d;return"function"==typeof a.render?d=a:a.winControl&&"function"==typeof a.winControl.render&&(d=a.winControl),function(a,e){var f=e||b.document.createElement(c);if(d.render(a,f),e)return e;var g=f.firstElementChild;if(g&&f.dispose){var h=g.dispose;g.dispose=function(){g.dispose=h,f.appendChild(g),f.dispose()}}return g}},_getLowestTabIndexInList:function(a){for(var b,c=0,d=0;d0&&(c>b||!c)&&(c=b);return c},_getHighestTabIndexInList:function(a){for(var b,c=0,d=0;dc&&(c=b)}return c},_trySetActive:function(a,b){return this._tryFocus(a,!0,b)},_tryFocus:function(c,d,e){var f=b.document.activeElement;if(c===f)return!0;var g=a.getTabIndex(c)>=0;return g?(d?a._setActive(c,e):c.focus(),f!==b.document.activeElement?!0:!1):!1},_setActiveFirstFocusableElement:function(a,b){return this._focusFirstFocusableElement(a,!0,b)},_focusFirstFocusableElement:function(a,b,c){for(var d,e=a.getElementsByTagName("*"),f=this._getLowestTabIndexInList(e),g=0;f;){for(d=0;d=0;d--)if(e[d].tabIndex===f){if(this._tryFocus(e[d],b,c))return!0}else g=0;d--)if(e[d].tabIndex===f){if(this._tryFocus(e[d],b,c))return!0}else g0;d--)if(this._tryFocus(e[d],b,c))return!0;return!1}})}}),define("WinJS/Utilities/_Dispose",["exports","../Core/_Base","../Core/_WriteProfilerMark","./_ElementUtilities"],function(a,b,c,d){"use strict";function e(a,b){var c=!1;d.addClass(a,"win-disposable");var e=a.winControl||a;e.dispose=function(){c||(c=!0,f(a),b&&b())}}function f(a){if(a){c("WinJS.Utilities.disposeSubTree,StartTM");for(var b=a.querySelectorAll(".win-disposable"),d=0,e=b.length;e>d;){var f=b[d];f.winControl&&f.winControl.dispose&&f.winControl.dispose(),f.dispose&&f.dispose(),d+=f.querySelectorAll(".win-disposable").length+1}c("WinJS.Utilities.disposeSubTree,StopTM")}}function g(a){if(a){var b=!1;a.winControl&&a.winControl.dispose&&(a.winControl.dispose(),b=!0),a.dispose&&(a.dispose(),b=!0),b||f(a)}}b.Namespace._moduleDefine(a,"WinJS.Utilities",{markDisposable:e,disposeSubTree:f,_disposeElement:g})}),define("WinJS/ControlProcessor/_OptionsLexer",["exports","../Core/_Base"],function optionsLexerInit(exports,_Base){"use strict";_Base.Namespace._moduleDefine(exports,"WinJS.UI",{_optionsLexer:_Base.Namespace._lazy(function(){function reservedWord(a){return{type:tokenType.reservedWord,value:a,length:a.length,keyword:!0}}function reservedWordLookup(a){switch(a.charCodeAt(0)){case 98:switch(a){case"break":return reservedWord(a)}break;case 99:switch(a){case"case":case"catch":case"class":case"const":case"continue":return reservedWord(a)}break;case 100:switch(a){case"debugger":case"default":case"delete":case"do":return reservedWord(a)}break;case 101:switch(a){case"else":case"enum":case"export":case"extends":return reservedWord(a)}break;case 102:switch(a){case"false":return tokens.falseLiteral;case"finally":case"for":case"function":return reservedWord(a)}break;case 105:switch(a){case"if":case"import":case"in":case"instanceof":return reservedWord(a)}break;case 110:switch(a){case"null":return tokens.nullLiteral;case"new":return reservedWord(a)}break;case 114:switch(a){case"return":return reservedWord(a)}break;case 115:switch(a){case"super":case"switch":return reservedWord(a)}break;case 116:switch(a){case"true":return tokens.trueLiteral;case"this":return tokens.thisKeyword;case"throw":case"try":case"typeof":return reservedWord(a)}break;case 118:switch(a){case"var":case"void":return reservedWord(a)}break;case 119:switch(a){case"while":case"with":return reservedWord(a)}}}var tokenType={leftBrace:1,rightBrace:2,leftBracket:3,rightBracket:4,separator:5,colon:6,semicolon:7,comma:8,dot:9,nullLiteral:10,trueLiteral:11,falseLiteral:12,numberLiteral:13,stringLiteral:14,identifier:15,reservedWord:16,thisKeyword:17,leftParentheses:18,rightParentheses:19,eof:20,error:21},tokens={leftBrace:{type:tokenType.leftBrace,length:1},rightBrace:{type:tokenType.rightBrace,length:1},leftBracket:{type:tokenType.leftBracket,length:1},rightBracket:{type:tokenType.rightBracket,length:1},colon:{type:tokenType.colon,length:1},semicolon:{type:tokenType.semicolon,length:1},comma:{type:tokenType.comma,length:1},dot:{type:tokenType.dot,length:1},nullLiteral:{type:tokenType.nullLiteral,length:4,value:null,keyword:!0},trueLiteral:{type:tokenType.trueLiteral,length:4,value:!0,keyword:!0},falseLiteral:{type:tokenType.falseLiteral,length:5,value:!1,keyword:!0},thisKeyword:{type:tokenType.thisKeyword,length:4,value:"this",keyword:!0},leftParentheses:{type:tokenType.leftParentheses,length:1},rightParentheses:{type:tokenType.rightParentheses,length:1},eof:{type:tokenType.eof,length:0}},lexer=function(){function isIdentifierStartCharacter(a,b,c,d){switch(a){case a>=97&&122>=a&&a:case a>=65&&90>=a&&a:case 36:case 95:return!0;case isWhitespace(a)&&a:case isLineTerminator(a)&&a:return!1;case a>127&&a:return!0;case 92:return d>c+4&&117===b.charCodeAt(c)&&isHexDigit(b.charCodeAt(c+1))&&isHexDigit(b.charCodeAt(c+2))&&isHexDigit(b.charCodeAt(c+3))&&isHexDigit(b.charCodeAt(c+4))?!0:!1;default:return!1}}function readIdentifierPart(a,b,c){for(var d=!1;c>b;){var e=a.charCodeAt(b);switch(e){case e>=97&&122>=e&&e:case e>=65&&90>=e&&e:case 36:case 95:break;case isWhitespace(e)&&e:case isLineTerminator(e)&&e:return d?-b:b;case e>127&&e:break;case e>=48&&57>=e&&e:break;case 92:if(c>b+5&&117===a.charCodeAt(b+1)&&isHexDigit(a.charCodeAt(b+2))&&isHexDigit(a.charCodeAt(b+3))&&isHexDigit(a.charCodeAt(b+4))&&isHexDigit(a.charCodeAt(b+5))){b+=5,d=!0;break}return d?-b:b;default:return d?-b:b}b++}return d?-b:b}function readIdentifierToken(a,b,c){var d=b;b=readIdentifierPart(a,b,c);var e=!1;0>b&&(b=-b,e=!0);var f=a.substr(d,b-d);e&&(f=""+JSON.parse('"'+f+'"'));var g=reservedWordLookup(f);return g?g:{type:tokenType.identifier,length:b-d,value:f}}function isHexDigit(a){switch(a){case a>=48&&57>=a&&a:case a>=97&&102>=a&&a:case a>=65&&70>=a&&a:return!0;default:return!1}}function readHexIntegerLiteral(a,b,c){for(;c>b&&isHexDigit(a.charCodeAt(b));)b++;return b}function isDecimalDigit(a){switch(a){case a>=48&&57>=a&&a:return!0;default:return!1}}function readDecimalDigits(a,b,c){for(;c>b&&isDecimalDigit(a.charCodeAt(b));)b++;return b}function readDecimalLiteral(a,b,c){if(b=readDecimalDigits(a,b,c),c>b&&46===a.charCodeAt(b)&&c>b+1&&isDecimalDigit(a.charCodeAt(b+1))&&(b=readDecimalDigits(a,b+2,c)),c>b){var d=a.charCodeAt(b);if(101===d||69===d){var e=b+1;c>e&&(d=a.charCodeAt(e),(43===d||45===d)&&e++,b=readDecimalDigits(a,e,c))}}return b}function readDecimalLiteralToken(a,b,c,d){var c=readDecimalLiteral(a,c,d),e=c-b;return{type:tokenType.numberLiteral,length:e,value:+a.substr(b,e)}}function isLineTerminator(a){switch(a){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function readStringLiteralToken(text,offset,limit){var startOffset=offset,quoteCharCode=text.charCodeAt(offset),hasEscape=!1;for(offset++;limit>offset&&!isLineTerminator(text.charCodeAt(offset));){if(limit>offset+1&&92===text.charCodeAt(offset))switch(hasEscape=!0,text.charCodeAt(offset+1)){case quoteCharCode:case 92:case 10:case 8232:case 8233:offset+=2;continue;case 13:offset+=limit>offset+2&&10===text.charCodeAt(offset+2)?3:2;continue}if(offset++,text.charCodeAt(offset-1)===quoteCharCode)break}var length=offset-startOffset;hasEscape=hasEscape||1===length||text.charCodeAt(offset-1)!==quoteCharCode;var stringValue;return stringValue=hasEscape?eval(text.substr(startOffset,length)):text.substr(startOffset+1,length-2),{type:tokenType.stringLiteral,length:length,value:stringValue}}function isWhitespace(a){switch(a){case 9:case 11:case 12:case 32:case 160:case 65279:return!0;case 5760>a&&a:return!1;case 5760:case 6158:case a>=8192&&8202>=a&&a:case 8239:case 8287:case 12288:return!0;default:return!1}}function readWhitespace(a,b,c){for(;c>b;){var d=a.charCodeAt(b);switch(d){case 9:case 11:case 12:case 32:case 160:case 65279:break;case 5760>d&&d:return b;case 5760:case 6158:case d>=8192&&8202>=d&&d:case 8239:case 8287:case 12288:break;default:return b}b++}return b}function lex(a,b,c,d){for(;d>c;){var e,f=c,g=b.charCodeAt(c++);switch(g){case isWhitespace(g)&&g:case isLineTerminator(g)&&g:c=readWhitespace(b,c,d),e={type:tokenType.separator,length:c-f};continue;case 34:case 39:e=readStringLiteralToken(b,c-1,d);break;case 40:e=tokens.leftParentheses;break;case 41:e=tokens.rightParentheses;break;case 43:case 45:if(d>c){var h=b.charCodeAt(c);if(46===h){var i=c+1;if(d>i&&isDecimalDigit(b.charCodeAt(i))){e=readDecimalLiteralToken(b,f,i,d);break}}else if(isDecimalDigit(h)){e=readDecimalLiteralToken(b,f,c,d);break}}e={type:tokenType.error,length:c-f,value:b.substring(f,c)};break;case 44:e=tokens.comma;break;case 46:e=tokens.dot,d>c&&isDecimalDigit(b.charCodeAt(c))&&(e=readDecimalLiteralToken(b,f,c,d));break;case 48:var j=d>c?b.charCodeAt(c):0;if(120===j||88===j){var k=readHexIntegerLiteral(b,c+1,d);e={type:tokenType.numberLiteral,length:k-f,value:+b.substr(f,k-f)}}else e=readDecimalLiteralToken(b,f,c,d);break;case g>=49&&57>=g&&g:e=readDecimalLiteralToken(b,f,c,d);break;case 58:e=tokens.colon;break;case 59:e=tokens.semicolon;break;case 91:e=tokens.leftBracket;break;case 93:e=tokens.rightBracket;break;case 123:e=tokens.leftBrace;break;case 125:e=tokens.rightBrace;break;default:if(isIdentifierStartCharacter(g,b,c,d)){e=readIdentifierToken(b,c-1,d);break}e={type:tokenType.error,length:c-f,value:b.substring(f,c)}}c+=e.length-1,a.push(e)}}return function(a){var b=[];return lex(b,a,0,a.length),b.push(tokens.eof),b}}();return lexer.tokenType=tokenType,lexer})})}),define("WinJS/ControlProcessor/_OptionsParser",["exports","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","./_OptionsLexer"],function(a,b,c,d,e,f){"use strict";function g(){throw"Illegal"}function h(a){for(var b=Object.keys(j.tokenType),c=0,d=b.length;d>c;c++)if(a===j.tokenType[b[c]])return b[c];return""}var i={get invalidOptionsRecord(){return"Invalid options record: '{0}', expected to be in the format of an object literal. {1}"},get unexpectedTokenExpectedToken(){return"Unexpected token: {0}, expected token: {1}, at offset {2}"},get unexpectedTokenExpectedTokens(){return"Unexpected token: {0}, expected one of: {1}, at offset {2}"},get unexpectedTokenGeneric(){return"Unexpected token: {0}, at offset {1}"}},j=b.Namespace.defineWithParent(null,null,{lexer:b.Namespace._lazy(function(){return f._optionsLexer}),tokenType:b.Namespace._lazy(function(){return f._optionsLexer.tokenType})}),k=c.requireSupportedForProcessing,l=b.Namespace.defineWithParent(null,null,{BaseInterpreter:b.Namespace._lazy(function(){return b.Class.define(null,{_error:function(a){throw new d("WinJS.UI.ParseError",a)},_currentOffset:function(){for(var a=this._pos,b=0,c=0;a>c;c++)b+=this._tokens[c].length;return b},_evaluateAccessExpression:function(a){switch(this._current.type){case j.tokenType.dot:switch(this._read(),this._current.type){case j.tokenType.identifier:case this._current.keyword&&this._current.type:var b=this._current.value;return this._read(),a[b];default:this._unexpectedToken(j.tokenType.identifier,j.tokenType.reservedWord)}return;case j.tokenType.leftBracket:this._read();var c=this._evaluateValue();return this._read(j.tokenType.rightBracket),a[c]}},_evaluateAccessExpressions:function(a){for(;;)switch(this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:a=this._evaluateAccessExpression(a);break;default:return a}},_evaluateIdentifier:function(a,b){var c=this._readIdentifier();return b=a?b[c]:this._context[c]},_evaluateIdentifierExpression:function(){var a=this._evaluateIdentifier(!1);switch(this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:return this._evaluateAccessExpressions(a);default:return a}},_initialize:function(a,b,c,d){this._originalSource=b,this._tokens=a,this._context=c,this._functionContext=d,this._pos=0,this._current=this._tokens[0]},_read:function(a){a&&this._current.type!==a&&this._unexpectedToken(a),this._current!==j.tokenType.eof&&(this._current=this._tokens[++this._pos]) +},_peek:function(a){return a&&this._current.type!==a?void 0:this._current!==j.tokenType.eof?this._tokens[this._pos+1]:void 0},_readAccessExpression:function(a){switch(this._current.type){case j.tokenType.dot:switch(this._read(),this._current.type){case j.tokenType.identifier:case this._current.keyword&&this._current.type:a.push(this._current.value),this._read();break;default:this._unexpectedToken(j.tokenType.identifier,j.tokenType.reservedWord)}return;case j.tokenType.leftBracket:return this._read(),a.push(this._evaluateValue()),void this._read(j.tokenType.rightBracket)}},_readAccessExpressions:function(a){for(;;)switch(this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:this._readAccessExpression(a);break;default:return}},_readIdentifier:function(){var a=this._current.value;return this._read(j.tokenType.identifier),a},_readIdentifierExpression:function(){var a=[];switch(this._peek(j.tokenType.thisKeyword)&&0===a.length?this._read():a.push(this._readIdentifier()),this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:this._readAccessExpressions(a)}return a},_unexpectedToken:function(a){var b=this._current.type===j.tokenType.error?"'"+this._current.value+"'":h(this._current.type);if(a)if(1===arguments.length)a=h(a),this._error(e._formatString(i.unexpectedTokenExpectedToken,b,a,this._currentOffset()));else{for(var c=[],d=0,f=arguments.length;f>d;d++)c.push(h(arguments[d]));a=c.join(", "),this._error(e._formatString(i.unexpectedTokenExpectedTokens,b,a,this._currentOffset()))}else this._error(e._formatString(i.unexpectedTokenGeneric,b,this._currentOffset()))}},{supportedForProcessing:!1})}),OptionsInterpreter:b.Namespace._lazy(function(){return b.Class.derive(l.BaseInterpreter,function(a,b,c,d){this._initialize(a,b,c,d)},{_error:function(a){throw new d("WinJS.UI.ParseError",e._formatString(i.invalidOptionsRecord,this._originalSource,a))},_evaluateArrayLiteral:function(){var a=[];return this._read(j.tokenType.leftBracket),this._readArrayElements(a),this._read(j.tokenType.rightBracket),a},_evaluateObjectLiteral:function(){var a={};return this._read(j.tokenType.leftBrace),this._readObjectProperties(a),this._tryReadComma(),this._read(j.tokenType.rightBrace),a},_evaluateOptionsLiteral:function(){var a=this._evaluateValue();return this._current.type!==j.tokenType.eof&&this._unexpectedToken(j.tokenType.eof),a},_peekValue:function(){switch(this._current.type){case j.tokenType.falseLiteral:case j.tokenType.nullLiteral:case j.tokenType.stringLiteral:case j.tokenType.trueLiteral:case j.tokenType.numberLiteral:case j.tokenType.leftBrace:case j.tokenType.leftBracket:case j.tokenType.identifier:return!0;default:return!1}},_evaluateValue:function(){switch(this._current.type){case j.tokenType.falseLiteral:case j.tokenType.nullLiteral:case j.tokenType.stringLiteral:case j.tokenType.trueLiteral:case j.tokenType.numberLiteral:var a=this._current.value;return this._read(),a;case j.tokenType.leftBrace:return this._evaluateObjectLiteral();case j.tokenType.leftBracket:return this._evaluateArrayLiteral();case j.tokenType.identifier:return k(this._peek(j.tokenType.identifier).type===j.tokenType.leftParentheses?this._evaluateObjectQueryExpression():this._evaluateIdentifierExpression());default:this._unexpectedToken(j.tokenType.falseLiteral,j.tokenType.nullLiteral,j.tokenType.stringLiteral,j.tokenType.trueLiteral,j.tokenType.numberLiteral,j.tokenType.leftBrace,j.tokenType.leftBracket,j.tokenType.identifier)}},_tryReadElement:function(a){return this._peekValue()?(a.push(this._evaluateValue()),!0):!1},_tryReadComma:function(){return this._peek(j.tokenType.comma)?(this._read(),!0):!1},_tryReadElision:function(a){for(var b=!1;this._tryReadComma();)a.push(void 0),b=!0;return b},_readArrayElements:function(a){for(;!this._peek(j.tokenType.rightBracket);){var b=this._tryReadElision(a),c=this._tryReadElement(a),d=this._peek(j.tokenType.comma);if(!c||!d){if(c||b)break;this._unexpectedToken(j.tokenType.falseLiteral,j.tokenType.nullLiteral,j.tokenType.stringLiteral,j.tokenType.trueLiteral,j.tokenType.numberLiteral,j.tokenType.leftBrace,j.tokenType.leftBracket,j.tokenType.identifier);break}this._read()}},_readObjectProperties:function(a){for(;!this._peek(j.tokenType.rightBrace);){var b=this._tryReadObjectProperty(a),c=this._peek(j.tokenType.comma);if(!b||!c){if(b)break;this._unexpectedToken(j.tokenType.numberLiteral,j.tokenType.stringLiteral,j.tokenType.identifier);break}this._read()}},_tryReadObjectProperty:function(a){switch(this._current.type){case j.tokenType.numberLiteral:case j.tokenType.stringLiteral:case j.tokenType.identifier:case this._current.keyword&&this._current.type:var b=this._current.value;return this._read(),this._read(j.tokenType.colon),a[b]=this._evaluateValue(),!0;default:return!1}},_failReadObjectProperty:function(){this._unexpectedToken(j.tokenType.numberLiteral,j.tokenType.stringLiteral,j.tokenType.identifier,j.tokenType.reservedWord)},_evaluateObjectQueryExpression:function(){var a=this._current.value;this._read(j.tokenType.identifier),this._read(j.tokenType.leftParentheses);var b=this._current.value;this._read(j.tokenType.stringLiteral),this._read(j.tokenType.rightParentheses);var c=k(this._functionContext[a])(b);switch(this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:return this._evaluateAccessExpressions(c);default:return c}},run:function(){return this._evaluateOptionsLiteral()}},{supportedForProcessing:!1})}),OptionsParser:b.Namespace._lazy(function(){return b.Class.derive(l.OptionsInterpreter,function(a,b){this._initialize(a,b)},{_evaluateAccessExpression:g,_evaluateAccessExpressions:g,_evaluateIdentifier:g,_evaluateIdentifierExpression:g,_evaluateObjectQueryExpression:g,_evaluateValue:function(){switch(this._current.type){case j.tokenType.falseLiteral:case j.tokenType.nullLiteral:case j.tokenType.stringLiteral:case j.tokenType.trueLiteral:case j.tokenType.numberLiteral:var a=this._current.value;return this._read(),a;case j.tokenType.leftBrace:return this._evaluateObjectLiteral();case j.tokenType.leftBracket:return this._evaluateArrayLiteral();case j.tokenType.identifier:return this._peek(j.tokenType.identifier).type===j.tokenType.leftParentheses?this._readObjectQueryExpression():this._readIdentifierExpression();default:this._unexpectedToken(j.tokenType.falseLiteral,j.tokenType.nullLiteral,j.tokenType.stringLiteral,j.tokenType.trueLiteral,j.tokenType.numberLiteral,j.tokenType.leftBrace,j.tokenType.leftBracket,j.tokenType.identifier)}},_readIdentifierExpression:function(){var a=l.BaseInterpreter.prototype._readIdentifierExpression.call(this);return new p(a)},_readObjectQueryExpression:function(){var a=this._current.value;this._read(j.tokenType.identifier),this._read(j.tokenType.leftParentheses);var b=this._current.value;this._read(j.tokenType.stringLiteral),this._read(j.tokenType.rightParentheses);var c=new o(a,b);switch(this._current.type){case j.tokenType.dot:case j.tokenType.leftBracket:var d=[c];return this._readAccessExpressions(d),new p(d);default:return c}}},{supportedForProcessing:!1})})}),m=function(a,b,c){var d=j.lexer(a),e=new l.OptionsInterpreter(d,a,b||{},c||{});return e.run()};Object.defineProperty(m,"_BaseInterpreter",{get:function(){return l.BaseInterpreter}});var n=function(a){var b=j.lexer(a),c=new l.OptionsParser(b,a);return c.run()},o=b.Class.define(function(a,b){this.target=a,this.arg0Value=b});o.supportedForProcessing=!1;var p=b.Class.define(function(a){this.parts=a});p.supportedForProcessing=!1,b.Namespace._moduleDefine(a,"WinJS.UI",{optionsParser:m,_optionsParser:n,_CallExpression:o,_IdentifierExpression:p})}),define("WinJS/ControlProcessor",["exports","./Core/_Global","./Core/_Base","./Core/_BaseUtils","./Core/_Log","./Core/_Resources","./Core/_WriteProfilerMark","./ControlProcessor/_OptionsParser","./Promise","./Utilities/_ElementUtilities"],function(a,b,c,d,e,f,g,h,i,j){"use strict";function k(a){var c=function(c){for(var d,e=a;e;){if(e.msParentSelectorScope){var f=e.parentNode;if(f&&(d=j._matchesSelector(f,c)?f:f.querySelector(c)))break}e=e.parentNode}return d||b.document.querySelector(c)};return s(c)}function l(a,c){return new i(function(d,g){try{var i,j=a.getAttribute("data-win-options");j&&(i=h.optionsParser(j,b,{select:k(a)}));var l,m=1;c.length>2&&m++;var n=function(){m--,0===m&&(a.winControl=a.winControl||l,d(l))};l=new c(a,i,n),n()}catch(o){e.log&&e.log(f._formatString(r.errorActivatingControl,o&&o.message),"winjs controls","error"),g(o)}})}function m(a,c){return new i(function(d,e){g("WinJS.UI:processAll,StartTM"),a=a||b.document.body;var f=0,h="[data-win-control]",i=a.querySelectorAll(h),j=[];!c&&n(a)&&j.push(a);for(var k=0,m=i.length;m>k;k++)j.push(i[k]);if(0===j.length)return g("WinJS.UI:processAll,StopTM"),void d(a);for(var o=function(){f-=1,0>f&&(g("WinJS.UI:processAll,StopTM"),d(a))},q=new Array(j.length),k=0,m=j.length;m>k;k++){var r,s=j[k],u=s.winControl;u?r=u.constructor:q[k]=r=n(s),r&&r.isDeclarativeControlContainer&&(k+=s.querySelectorAll(h).length)}g("WinJS.UI:processAllActivateControls,StartTM");for(var k=0,m=j.length;m>k;k++){var v=q[k],s=j[k];if(v&&!s.winControl&&(f++,l(s,v).then(o,function(a){g("WinJS.UI:processAll,StopTM"),e(a)}),v.isDeclarativeControlContainer&&"function"==typeof v.isDeclarativeControlContainer)){var w=t(v.isDeclarativeControlContainer);w(s.winControl,p)}}g("WinJS.UI:processAllActivateControls,StopTM"),o()})}function n(a){if(a.getAttribute){var c=a.getAttribute("data-win-control");if(c)return d._getMemberFiltered(c.trim(),b,t)}}function o(a,b){return k(b)(a)}function p(a,b){return u?m(a,b):d.ready().then(function(){return u=!0,m(a,b)})}function q(a){if(a&&a.winControl)return i.as(a.winControl);var b=n(a);return b?l(a,b):i.as()}if(b.document){var r={get errorActivatingControl(){return"Error activating control: {0}"}},s=d.markSupportedForProcessing,t=d.requireSupportedForProcessing,u=!1;c.Namespace._moduleDefine(a,"WinJS.UI",{scopedSelect:o,processAll:p,process:q})}}),define("WinJS/Utilities/_ElementListUtilities",["exports","../Core/_Global","../Core/_Base","../ControlProcessor","../Promise","../Utilities/_Control","../Utilities/_ElementUtilities"],function(a,b,c,d,e,f,g){"use strict";b.document&&c.Namespace._moduleDefine(a,"WinJS.Utilities",{QueryCollection:c.Class.derive(Array,function(a){a&&this.include(a)},{forEach:function(a,b){return Array.prototype.forEach.apply(this,[a,b]),this},get:function(a){return this[a]},setAttribute:function(a,b){return this.forEach(function(c){c.setAttribute(a,b)}),this},getAttribute:function(a){return this.length>0?this[0].getAttribute(a):void 0},addClass:function(a){return this.forEach(function(b){g.addClass(b,a)}),this},hasClass:function(a){return this.length>0?g.hasClass(this[0],a):!1},removeClass:function(a){return this.forEach(function(b){g.removeClass(b,a)}),this},toggleClass:function(a){return this.forEach(function(b){g.toggleClass(b,a)}),this},listen:function(a,b,c){return this.forEach(function(d){d.addEventListener(a,b,c)}),this},removeEventListener:function(a,b,c){return this.forEach(function(d){d.removeEventListener(a,b,c)}),this},setStyle:function(a,b){return this.forEach(function(c){c.style[a]=b}),this},clearStyle:function(a){return this.forEach(function(b){b.style[a]=""}),this},query:function(b){var c=new a.QueryCollection;return this.forEach(function(a){c.include(a.querySelectorAll(b))}),c},include:function(a){if("number"==typeof a.length)for(var b=0;bj;j++){var c,d;do c=i.shift(),d=c&&h[c];while(c&&!d);if(!d)break;delete h[c];try{d().then(b,b)}catch(e){b()}}k--}function f(a,b,d){var f,j="w"+g++;return new c(function(c,g,k){var l=function(){return f=a().then(c,g,k)};l.data=b,h[j]=l,d?i.unshift(j):i.push(j),e()},function(){delete h[j],f&&f.cancel()})}var g=0,h={},i=[];a=a||3;var j=0,k=0;this.sort=function(a){i.sort(function(b,c){return b=h[b],c=h[c],void 0===b&&void 0===c?0:void 0===b?1:void 0===c?-1:a(b.data,c.data)})},this.queue=f},{},{supportedForProcessing:!1})})})}),define("WinJS/Utilities/_VersionManager",["exports","../Core/_Base","../_Signal"],function(a,b,c){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_VersionManager:b.Namespace._lazy(function(){return b.Class.define(function(){this._unlocked=new c,this._unlocked.complete()},{_cancelCount:0,_notificationCount:0,_updateCount:0,_version:0,locked:{get:function(){return 0!==this._notificationCount||0!==this._updateCount}},noOutstandingNotifications:{get:function(){return 0===this._notificationCount}},version:{get:function(){return this._version}},unlocked:{get:function(){return this._unlocked.promise}},_dispose:function(){this._unlocked&&(this._unlocked.cancel(),this._unlocked=null)},beginUpdating:function(){this._checkLocked(),this._updateCount++},endUpdating:function(){this._updateCount--,this._checkUnlocked()},beginNotifications:function(){this._checkLocked(),this._notificationCount++},endNotifications:function(){this._notificationCount--,this._checkUnlocked()},_checkLocked:function(){this.locked||(this._dispose(),this._unlocked=new c)},_checkUnlocked:function(){this.locked||this._unlocked.complete()},receivedNotification:function(){if(this._version++,this._cancel){var a=this._cancel;this._cancel=null,a.forEach(function(a){a&&a.cancel()})}},cancelOnNotification:function(a){return this._cancel||(this._cancel=[],this._cancelCount=0),this._cancel[this._cancelCount++]=a,this._cancelCount-1},clearCancelOnNotification:function(a){this._cancel&&delete this._cancel[a]}},{supportedForProcessing:!1})})})}),define("WinJS/Utilities/_ItemsManager",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../_Signal","../Scheduler","../Utilities/_ElementUtilities","./_ParallelWorkQueue","./_VersionManager"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";function n(a){return t(function(b,c){return b.then(function(b){return b?a(b,c):null})})}function o(a,b){var c=!1,d=!1;return a.isOnScreen().then(function(a){c=a}),b.isOnScreen().then(function(a){d=a}),(c?0:1)-(d?0:1)}function p(a){if(!/^blob:/i.test(a)&&(B[a]=!0,C.push(a),C.length>E)){var b=C;B={},C=[];for(var c=0,d=b.length-1;d>=0&&D>c;d--){var e=b[d];B[e]||(B[e]=!0,c++)}}}function q(a,c,d){var e=A++;return w=w||new l._ParallelWorkQueue(6),w.queue(function(){return new h(function(d,f){j.schedule(function(e){c||(c=b.document.createElement("img"));var g=B[a];g?(p(a),c.src=a,d(c)):e.setPromise(new h(function(e){var g=b.document.createElement("img"),h=function(){g.removeEventListener("load",i,!1),g.removeEventListener("error",j,!1),c.src=a;var b=new Date;b-y>z&&(y=b,w.sort(o))},i=function(){e(k)},j=function(){e(l)},k=function(){p(a),h(),d(c)},l=function(){h(),f(c)};g.addEventListener("load",i,!1),g.addEventListener("error",j,!1),g.src=a}))},j.Priority.normal,null,"WinJS.UI._ImageLoader._image"+e)})},d)}function r(a){return B[a]}function s(){return b.document.createElement("div")}var t=d.markSupportedForProcessing,u=k._uniqueID,v=n(function(a){if(k._isDOMElement(a.data))return a.data;var c=a.data;void 0===c?c="undefined":null===c?c="null":"object"==typeof c&&(c=JSON.stringify(c));var d=b.document.createElement("span");return d.textContent=c.toString(),d});c.Namespace._moduleDefine(a,"WinJS.UI",{_normalizeRendererReturn:function(a){if(a){if("object"==typeof a&&a.element){var b=h.as(a.element);return b.then(function(b){return{element:b,renderComplete:h.as(a.renderComplete)}})}var b=h.as(a);return b.then(function(a){return{element:a,renderComplete:h.as()}})}return{element:null,renderComplete:h.as()}},simpleItemRenderer:n,_trivialHtmlRenderer:v});var w,x={get listDataSourceIsInvalid(){return"Invalid argument: dataSource must be an object."},get itemRendererIsInvalid(){return"Invalid argument: itemRenderer must be a function."},get itemIsInvalid(){return"Invalid argument: item must be a DOM element that was returned by the Items Manager, and has not been replaced or released."}},y=new Date,z=64,A=0,B={},C=[],D=250,E=1e3;c.Namespace._moduleDefine(a,"WinJS.UI",{_seenUrl:p,_getSeenUrls:function(){return B},_getSeenUrlsMRU:function(){return C},_seenUrlsMaxSize:D,_seenUrlsMRUMaxSize:E}),c.Namespace._moduleDefine(a,"WinJS.UI",{_createItemsManager:c.Namespace._lazy(function(){var b=c.Class.define(function(a){this._itemsManager=a},{beginNotifications:function(){this._itemsManager._versionManager.beginNotifications(),this._itemsManager._beginNotifications()},inserted:function(a,b,c){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._inserted(a,b,c)},changed:function(a,b){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._changed(a,b)},moved:function(a,b,c){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._moved(a,b,c)},removed:function(a,b){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._removed(a,b)},countChanged:function(a,b){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._countChanged(a,b)},indexChanged:function(a,b,c){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._indexChanged(a,b,c)},affectedRange:function(a){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._affectedRange(a)},endNotifications:function(){this._itemsManager._versionManager.endNotifications(),this._itemsManager._endNotifications()},reload:function(){this._itemsManager._versionManager.receivedNotification(),this._itemsManager._reload()}},{supportedForProcessing:!1}),d=c.Class.define(function(a,c,d,f){if(!a)throw new e("WinJS.UI.ItemsManager.ListDataSourceIsInvalid",x.listDataSourceIsInvalid);if(!c)throw new e("WinJS.UI.ItemsManager.ItemRendererIsInvalid",x.itemRendererIsInvalid);this.$pipeline_callbacksMap={},this._listDataSource=a,this.dataSource=this._listDataSource,this._elementNotificationHandler=d,this._listBinding=this._listDataSource.createListBinding(new b(this)),f&&(f.ownerElement&&(this._ownerElement=f.ownerElement),this._profilerId=f.profilerId,this._versionManager=f.versionManager||new m._VersionManager),this._indexInView=f&&f.indexInView,this._itemRenderer=c,this._viewCallsReady=f&&f.viewCallsReady,this._elementMap={},this._handleMap={},this._jobOwner=j.createOwnerToken(),this._notificationsSent=!1,this._listBinding.last&&(this.lastItem=function(){return this._elementForItem(this._listBinding.last())})},{_itemFromItemPromise:function(a){return this._waitForElement(this._elementForItem(a))},_itemFromItemPromiseThrottled:function(a){return this._waitForElement(this._elementForItem(a,!0))},_itemAtIndex:function(a){var b=this._itemPromiseAtIndex(a);this._itemFromItemPromise(b).then(null,function(a){return b.cancel(),h.wrapError(a)})},_itemPromiseAtIndex:function(a){return this._listBinding.fromIndex(a)},_waitForElement:function(a){var b=this;return new h(function(c){if(a)if(b.isPlaceholder(a)){var d=u(a),e=b.$pipeline_callbacksMap[d];e?e.push(c):b.$pipeline_callbacksMap[d]=[c]}else c(a);else c(a)})},_updateElement:function(a,b){var c=u(b),d=this.$pipeline_callbacksMap[c];d&&(delete this.$pipeline_callbacksMap[c],d.forEach(function(b){b(a)}))},_firstItem:function(){return this._waitForElement(this._elementForItem(this._listBinding.first()))},_lastItem:function(){return this._waitForElement(this._elementForItem(this._listBinding.last()))},_previousItem:function(a){return this._listBinding.jumpToItem(this._itemFromElement(a)),this._waitForElement(this._elementForItem(this._listBinding.previous()))},_nextItem:function(a){return this._listBinding.jumpToItem(this._itemFromElement(a)),this._waitForElement(this._elementForItem(this._listBinding.next()))},_itemFromPromise:function(a){return this._waitForElement(this._elementForItem(a))},isPlaceholder:function(a){return!!this._recordFromElement(a).elementIsPlaceholder},itemObject:function(a){return this._itemFromElement(a)},release:function(){this._listBinding.release(),this._elementNotificationHandler=null,this._listBinding=null,this._jobOwner.cancelAll(),this._released=!0},releaseItemPromise:function(a){var b=a.handle,c=this._handleMap[b];c?this._releaseRecord(c):a.cancel()},releaseItem:function(a){var b=this._elementMap[u(a)];this._releaseRecord(b)},_releaseRecord:function(a){a&&(a.renderPromise&&a.renderPromise.cancel(),a.itemPromise&&a.itemPromise.cancel(),a.imagePromises&&a.imagePromises.forEach(function(a){a.cancel()}),a.itemReadyPromise&&a.itemReadyPromise.cancel(),a.renderComplete&&a.renderComplete.cancel(),this._removeEntryFromElementMap(a.element),this._removeEntryFromHandleMap(a.itemPromise.handle,a),a.item&&this._listBinding.releaseItem(a.item))},refresh:function(){return this._listDataSource.invalidateAll()},_handlerToNotifyCaresAboutItemAvailable:function(){return!(!this._elementNotificationHandler||!this._elementNotificationHandler.itemAvailable)},_handlerToNotify:function(){return this._notificationsSent||(this._notificationsSent=!0,this._elementNotificationHandler&&this._elementNotificationHandler.beginNotifications&&this._elementNotificationHandler.beginNotifications()),this._elementNotificationHandler},_defineIndexProperty:function(a,b,c){c.indexObserved=!1,Object.defineProperty(a,"index",{get:function(){return c.indexObserved=!0,b.index}})},_renderPlaceholder:function(a){var b={},c=s(b);return a.elementIsPlaceholder=!0,c},_renderItem:function(b,c,d){function e(){b.then(function(a){f._writeProfilerMark(m+",StartTM"),k.complete(a),f._writeProfilerMark(m+",StopTM")})}var f=this,g=f._indexInView||function(){return!0},k=new i,l=new i,m="_renderItem("+c.item.index+"):itemPromise",n=!0,o=!1;b.then(function(a){o=!0,n&&k.complete(a)}),n=!1;var p=k.promise.then(function(a){if(a){var b=Object.create(a);return f._defineIndexProperty(b,a,c),b.ready=l.promise,b.isOnScreen=function(){return h.wrap(g(a.index))},b.loadImage=function(a,d){var e=q(a,d,b);return c.imagePromises?c.imagePromises.push(e):c.imagePromises=[e],e},b.isImageCached=r,b}return h.cancel});o||(d?(c.stage0=b,c.startStage1=function(){c.startStage1=null,e()}):e()),p.handle=b.handle,c.itemPromise=p,c.itemReadyPromise=l.promise,c.readyComplete=!1;var s="_renderItem("+c.item.index+(o?"):syncItemPromise":"):placeholder"),t="_renderItem("+c.item.index+"):itemReady";this._writeProfilerMark(s+",StartTM");var u=h.as(f._itemRenderer(p,c.element)).then(a._normalizeRendererReturn).then(function(a){return f._released?h.cancel:(p.then(function(a){if(c.pendingReady=function(){c.pendingReady&&(c.pendingReady=null,c.readyComplete=!0,f._writeProfilerMark(t+",StartTM"),l.complete(a),f._writeProfilerMark(t+",StopTM"))},!f._viewCallsReady){var b=j.schedule(c.pendingReady,j.Priority.normal,c,"WinJS.UI._ItemsManager._pendingReady");b.owner=f._jobOwner}}),a)});return this._writeProfilerMark(s+",StopTM"),u},_replaceElement:function(a,b){this._removeEntryFromElementMap(a.element),a.element=b,this._addEntryToElementMap(b,a)},_changeElement:function(a,b,c){a.renderPromise=null;var d=a.element,e=a.item;a.newItem&&(a.item=a.newItem,a.newItem=null),this._replaceElement(a,b),a.item&&a.elementIsPlaceholder&&!c?(a.elementDelayed=null,a.elementIsPlaceholder=!1,this._updateElement(a.element,d),this._handlerToNotifyCaresAboutItemAvailable()&&this._handlerToNotify().itemAvailable(a.element,d)):this._handlerToNotify().changed(b,d,e)},_elementForItem:function(a,b){var c,d=a.handle,e=this._recordFromHandle(d,!0);if(!d)return null;if(e)c=e.element;else{e={item:a,itemPromise:a},this._addEntryToHandleMap(d,e);var f=this,g=!1,h=!1,i=f._renderItem(a,e,b).then(function(b){var d=b.element;e.renderComplete=b.renderComplete,a.then(function(a){e.item=a,a||(g=!0,c=null)}),h=!0,e.renderPromise=null,d&&(c?f._presentElements(e,d):c=d)});g||(h||(e.renderPromise=i),c||(c=this._renderPlaceholder(e)),e.element=c,this._addEntryToElementMap(c,e),a.retain())}return c},_addEntryToElementMap:function(a,b){this._elementMap[u(a)]=b},_removeEntryFromElementMap:function(a){delete this._elementMap[u(a)]},_recordFromElement:function(a){var b=this._elementMap[u(a)];if(!b)throw this._writeProfilerMark("_recordFromElement:ItemIsInvalidError,info"),new e("WinJS.UI.ItemsManager.ItemIsInvalid",x.itemIsInvalid);return b},_addEntryToHandleMap:function(a,b){this._handleMap[a]=b},_removeEntryFromHandleMap:function(a){delete this._handleMap[a]},_handleInHandleMap:function(a){return!!this._handleMap[a]},_recordFromHandle:function(a,b){var c=this._handleMap[a];if(!c&&!b)throw new e("WinJS.UI.ItemsManager.ItemIsInvalid",x.itemIsInvalid);return c},_foreachRecord:function(a){var b=this._handleMap;for(var c in b){var d=b[c];a(d)}},_itemFromElement:function(a){return this._recordFromElement(a).item},_elementFromHandle:function(a){if(a){var b=this._recordFromHandle(a,!0);if(b&&b.element)return b.element}return null},_inserted:function(a,b,c){this._handlerToNotify().inserted(a,b,c)},_changed:function(a,b){if(this._handleInHandleMap(b.handle)){var c=this._recordFromHandle(b.handle);c.renderPromise&&c.renderPromise.cancel(),c.itemPromise&&c.itemPromise.cancel(),c.imagePromises&&c.imagePromises.forEach(function(a){a.cancel()}),c.itemReadyPromise&&c.itemReadyPromise.cancel(),c.renderComplete&&c.renderComplete.cancel(),c.newItem=a;var d=this,e=h.as(a);e.handle=c.itemPromise.handle,c.renderPromise=this._renderItem(e,c).then(function(a){c.renderComplete=a.renderComplete,d._changeElement(c,a.element,!1),d._presentElements(c)})}},_moved:function(a,b,c){var d=this._elementFromHandle(a.handle),e=this._elementFromHandle(b),f=this._elementFromHandle(c);this._handlerToNotify().moved(d,e,f,a),this._presentAllElements()},_removed:function(a,b){if(this._handleInHandleMap(a)){var c=this._elementFromHandle(a);this._handlerToNotify().removed(c,b,a),this.releaseItem(c),this._presentAllElements()}else this._handlerToNotify().removed(null,b,a)},_countChanged:function(a,b){this._elementNotificationHandler&&this._elementNotificationHandler.countChanged&&this._handlerToNotify().countChanged(a,b)},_indexChanged:function(a,b,c){var d;if(this._handleInHandleMap(a)){var e=this._recordFromHandle(a);if(e.indexObserved)if(e.elementIsPlaceholder)this._changeElement(e,this._renderPlaceholder(e),!0);else if(e.item.index!==b){e.renderPromise&&e.renderPromise.cancel(),e.renderComplete&&e.renderComplete.cancel();var f=e.newItem||e.item;f.index=b;var g=h.as(f);g.handle=e.itemPromise.handle;var i=this;e.renderPromise=this._renderItem(g,e).then(function(a){e.renderComplete=a.renderComplete,i._changeElement(e,a.element,!1),i._presentElements(e)})}d=e.element}this._elementNotificationHandler&&this._elementNotificationHandler.indexChanged&&this._handlerToNotify().indexChanged(d,b,c)},_affectedRange:function(a){this._elementNotificationHandler&&this._elementNotificationHandler.updateAffectedRange&&this._handlerToNotify().updateAffectedRange(a)},_beginNotifications:function(){this._externalBegin=!0,this._handlerToNotify()},_endNotifications:function(){this._notificationsSent&&(this._notificationsSent=!1,this._externalBegin=!1,this._elementNotificationHandler&&this._elementNotificationHandler.endNotifications&&this._elementNotificationHandler.endNotifications())},_reload:function(){this._elementNotificationHandler&&this._elementNotificationHandler.reload&&this._elementNotificationHandler.reload()},_postEndNotifications:function(){if(this._notificationsSent&&!this._externalBegin&&!this._endNotificationsPosted){this._endNotificationsPosted=!0;var a=this;j.schedule(function(){a._endNotificationsPosted=!1,a._endNotifications()},j.Priority.high,null,"WinJS.UI._ItemsManager._postEndNotifications")}},_presentElement:function(a){var b=a.element;this._replaceElement(a,a.elementDelayed),a.elementDelayed=null,a.elementIsPlaceholder=!1,this._updateElement(a.element,b),this._handlerToNotifyCaresAboutItemAvailable()&&this._handlerToNotify().itemAvailable(a.element,b)},_presentElements:function(a,b){b&&(a.elementDelayed=b),this._listBinding.jumpToItem(a.item),a.elementDelayed&&this._presentElement(a),this._postEndNotifications()},_presentAllElements:function(){var a=this;this._foreachRecord(function(b){b.elementDelayed&&a._presentElement(b)})},_writeProfilerMark:function(a){var b="WinJS.UI._ItemsManager:"+(this._profilerId?this._profilerId+":":":")+a;g(b)}},{supportedForProcessing:!1});return function(a,b,c,e){return new d(a,b,c,e)}})})}),define("WinJS/Utilities/_TabContainer",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","./_ElementUtilities"],function(a,b,c,d,e){"use strict";function f(a,c,d,e){var f=b.document.createEvent("UIEvent");return f.initUIEvent(c,!1,!!e,b,d?1:0),!a.dispatchEvent(f)}function g(a){var c=b.getComputedStyle(a);if("none"===c.display||"hidden"===c.visibility)return b.NodeFilter.FILTER_REJECT;if(a._tabContainer)return b.NodeFilter.FILTER_ACCEPT;if(a.parentNode&&a.parentNode._tabContainer){var d=a.parentNode._tabContainer.childFocus;return d&&a.contains(d)?j(a)>=0?b.NodeFilter.FILTER_ACCEPT:b.NodeFilter.FILTER_SKIP:b.NodeFilter.FILTER_REJECT}var e=j(a);return e>=0?b.NodeFilter.FILTER_ACCEPT:b.NodeFilter.FILTER_SKIP}function h(a){function b(){if(a.currentNode._tabContainer)e=e.concat(h(a));else if(j(a.currentNode)>=0&&e.push(a.currentNode),a.firstChild()){do b();while(a.nextSibling());a.parentNode()}}var c=a.currentNode,d=c._tabContainer.childFocus,e=[];return d?(a.currentNode=d,b(),a.currentNode=c,e):[]}function i(a,c){function d(){var a=b.document.createElement("DIV");return a.tabIndex=c?c:0,a.setAttribute("aria-hidden",!0),a}var e=a.parentNode,g=d();e.insertBefore(g,a);var h=d();e.insertBefore(h,a.nextSibling),g.addEventListener("focus",function(){f(a,"onTabEnter",!0)},!0),h.addEventListener("focus",function(){f(a,"onTabEnter",!1)},!0),this._catcherBegin=g,this._catcherEnd=h;var i=1;this.addRef=function(){i++},this.release=function(){return 0===--i&&(g.parentElement&&e.removeChild(g),h.parentElement&&e.removeChild(h)),i},this.updateTabIndex=function(a){g.tabIndex=a,h.tabIndex=a}}if(b.document){var j=e.getTabIndex,k={attach:function(a,b){return a["win-trackTabHelperObject"]?a["win-trackTabHelperObject"].addRef():a["win-trackTabHelperObject"]=new i(a,b),a["win-trackTabHelperObject"]},detach:function(a){a["win-trackTabHelperObject"].release()||delete a["win-trackTabHelperObject"]}};c.Namespace._moduleDefine(a,"WinJS.UI",{TrackTabBehavior:k,TabContainer:c.Class.define(function(a){this._element=a,this._tabIndex=0,a._tabContainer=this,null===a.getAttribute("tabindex")&&(a.tabIndex=-1); +var b=this;a.addEventListener("onTabEnter",function(c){var d=f(b._element,"onTabEntered",c.detail,!0);d||(b.childFocus?b.childFocus.focus():a.focus())}),a.addEventListener("keydown",function(a){var c=a.target;if(a.keyCode===e.Key.tab){var g=!a.shiftKey,h=b._hasMoreElementsInTabOrder(c,g);if(!h){var i=f(b._element,"onTabExiting",g,!0);if(i)return a.stopPropagation(),void a.preventDefault();for(var j=b._element.querySelectorAll("a[href],area[href],button,command,input,link,menuitem,object,select,textarea,th[sorted],[tabindex]"),k=j.length,l=[],m=0;k>m;m++){var n=j[m];l.push(n.tabIndex),n.tabIndex=-1}b._elementTabHelper[g?"_catcherEnd":"_catcherBegin"].tabIndex=-1;var o=function(){c.removeEventListener("blur",o,!1);for(var a=0;k>a;a++)-1!==l[a]&&(j[a].tabIndex=l[a]);b._elementTabHelper._catcherBegin.tabIndex=b._tabIndex,b._elementTabHelper._catcherEnd.tabIndex=b._tabIndex};c.addEventListener("blur",o,!1),d._yieldForEvents(function(){f(b._element,"onTabExit",g)})}}}),this._elementTabHelper=k.attach(a,this._tabIndex),this._elementTabHelper._catcherBegin.tabIndex=0,this._elementTabHelper._catcherEnd.tabIndex=0},{dispose:function(){k.detach(this._element,this._tabIndex)},childFocus:{set:function(a){a!==this._focusElement&&(this._focusElement=a&&a.parentNode?a:null)},get:function(){return this._focusElement}},tabIndex:{set:function(a){this._tabIndex=a,this._elementTabHelper.updateTabIndex(a)},get:function(){return this._tabIndex}},_element:null,_skipper:function(a){a.stopPropagation(),a.preventDefault()},_hasMoreElementsInTabOrder:function(a,c){if(!this.childFocus)return!1;for(var d=b.document.createTreeWalker(this._element,b.NodeFilter.SHOW_ELEMENT,g,!1),e=h(d),f=0;f0;return!1},_focusElement:null},{supportedForProcessing:!1})})}}),define("WinJS/Utilities/_KeyboardBehavior",["exports","../Core/_Global","../Core/_Base","./_Control","./_ElementUtilities","./_TabContainer"],function(a,b,c,d,e,f){"use strict";if(b.document){var g=!1;e._addEventListener(b,"pointerdown",function(){g&&(g=!1)},!0),b.addEventListener("keydown",function(){g||(g=!0)},!0),c.Namespace._moduleDefine(a,"WinJS.UI",{_keyboardSeenLast:{get:function(){return g},set:function(a){g=a}},_WinKeyboard:function(b){e._addEventListener(b,"pointerdown",function(a){e.removeClass(a.target,"win-keyboard")},!0),b.addEventListener("keydown",function(a){e.addClass(a.target,"win-keyboard")},!0),e._addEventListener(b,"focusin",function(b){a._keyboardSeenLast&&e.addClass(b.target,"win-keyboard")},!1),e._addEventListener(b,"focusout",function(a){e.removeClass(a.target,"win-keyboard")},!1)},_KeyboardBehavior:c.Namespace._lazy(function(){var a=e.Key,g=c.Class.define(function(a,c){a=a||b.document.createElement("DIV"),c=c||{},a._keyboardBehavior=this,this._element=a,this._fixedDirection=g.FixedDirection.width,this._fixedSize=1,this._currentIndex=0,d.setOptions(this,c),this._tabContainer=new f.TabContainer(this.scroller||this._element),this._tabContainer.tabIndex=0,this._element.children.length>0&&(this._tabContainer.childFocus=this._getFocusInto(this._element.children[0])),this._element.addEventListener("keydown",this._keyDownHandler.bind(this)),e._addEventListener(this._element,"pointerdown",this._MSPointerDownHandler.bind(this))},{element:{get:function(){return this._element}},fixedDirection:{get:function(){return this._fixedDirection},set:function(a){this._fixedDirection=a}},fixedSize:{get:function(){return this._fixedSize},set:function(a){+a===a&&(a=Math.max(1,a),this._fixedSize=a)}},currentIndex:{get:function(){return this._element.children.length>0?this._currentIndex:-1},set:function(a){if(+a===a){var b=this._element.children.length;a=Math.max(0,Math.min(b-1,a)),this._currentIndex=a,this._tabContainer.childFocus=this._getFocusInto(this._element.children[a])}}},getAdjacent:{get:function(){return this._getAdjacent},set:function(a){this._getAdjacent=a}},scroller:{get:function(){return this._scroller},set:function(a){this._scroller=a}},_keyDownHandler:function(c){if(!c.altKey){if(e._matchesSelector(c.target,".win-interactive, .win-interactive *"))return;var d=!1,f=this.currentIndex,h=this._element.children.length-1,i="rtl"===b.getComputedStyle(this._element).direction,j=i?a.rightArrow:a.leftArrow,k=i?a.leftArrow:a.rightArrow,l=this.getAdjacent&&this.getAdjacent(f,c.keyCode);if(+l===l)d=!0,f=l;else{var m=f%this.fixedSize;c.keyCode===j?(d=!0,this.fixedDirection===g.FixedDirection.width?0!==m&&f--:f>=this.fixedSize&&(f-=this.fixedSize)):c.keyCode===k?(d=!0,this.fixedDirection===g.FixedDirection.width?m!==this.fixedSize-1&&f++:f+this.fixedSize-m<=h&&(f+=this.fixedSize)):c.keyCode===a.upArrow?(d=!0,this.fixedDirection===g.FixedDirection.height?0!==m&&f--:f>=this.fixedSize&&(f-=this.fixedSize)):c.keyCode===a.downArrow?(d=!0,this.fixedDirection===g.FixedDirection.height?m!==this.fixedSize-1&&f++:f+this.fixedSize-m<=h&&(f+=this.fixedSize)):c.keyCode===a.home?(d=!0,f=0):c.keyCode===a.end?(d=!0,f=this._element.children.length-1):c.keyCode===a.pageUp?d=!0:c.keyCode===a.pageDown&&(d=!0)}f=Math.max(0,Math.min(this._element.children.length-1,f)),f!==this.currentIndex&&(this._focus(f,c.keyCode),(c.keyCode===j||c.keyCode===k||c.keyCode===a.upArrow||c.keyCode===a.downArrow)&&c.stopPropagation()),d&&c.preventDefault()}},_getFocusInto:function(a,b){return a&&a.winControl&&a.winControl._getFocusInto?a.winControl._getFocusInto(b):a},_focus:function(a,b){a=+a===a?a:this.currentIndex;var c=this._element.children[a];c&&(c=this._getFocusInto(c,b),this.currentIndex=a,e._setActive(c,this.scroller))},_MSPointerDownHandler:function(a){var b=a.target;if(b!==this.element){for(;b.parentNode!==this.element;)b=b.parentNode;for(var c=-1;b;)c++,b=b.previousElementSibling;this.currentIndex=c}}},{FixedDirection:{height:"height",width:"width"}});return g})})}}),define("WinJS/Utilities/_SafeHtml",["exports","../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Resources"],function(a,b,c,d){"use strict";var e,f,g,h,i,j,k={get nonStaticHTML(){return"Unable to add dynamic content. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property or the document.write method to add a script element will generate this exception. If the content is safe and from a trusted source, use a method to explicitly manipulate elements and attributes, such as createElement, or use setInnerHTMLUnsafe (or other unsafe method)."}};e=f=function(a,b){a.innerHTML=b},g=h=function(a,b){a.outerHTML=b},i=j=function(a,b,c){a.insertAdjacentHTML(b,c)};var l=b.MSApp;if(l)f=function(a,b){l.execUnsafeLocalFunction(function(){a.innerHTML=b})},h=function(a,b){l.execUnsafeLocalFunction(function(){a.outerHTML=b})},j=function(a,b,c){l.execUnsafeLocalFunction(function(){a.insertAdjacentHTML(b,c)})};else if(b.msIsStaticHTML){var m=function(a){if(!b.msIsStaticHTML(a))throw new d("WinJS.Utitilies.NonStaticHTML",k.nonStaticHTML)};e=function(a,b){m(b),a.innerHTML=b},g=function(a,b){m(b),a.outerHTML=b},i=function(a,b,c){m(c),a.insertAdjacentHTML(b,c)}}c.Namespace._moduleDefine(a,"WinJS.Utilities",{setInnerHTML:e,setInnerHTMLUnsafe:f,setOuterHTML:g,setOuterHTMLUnsafe:h,insertAdjacentHTML:i,insertAdjacentHTMLUnsafe:j})}),define("WinJS/Utilities/_Select",["exports","../Core/_Base","./_SafeHtml"],function(a,b,c){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_Select:b.Namespace._lazy(function(){function a(a){return a.replace(h,function(a){return i[a]||""})}function d(a){return a.replace(j,"")}function e(a){return this[a]}function f(){return this.length}function g(a){return a.getValue||(a.getValue=e),a.getLength||(a.getLength=f),a}var h=/[&<>'"]/g,i={"&":"&","<":"<",">":">","'":"'",'"':"""},j=/[\u200e\u200f]/g;return b.Class.define(function(a,b){this._dataSource=g(b.dataSource),this._index=b.index||0,this._domElement=a,this._domElement.tabIndex=0,b.disabled&&this.setDisabled(b.disabled);var c=this;this._domElement.addEventListener("change",function(){c._index=c._domElement.selectedIndex},!1),this._createSelectElement()},{_index:0,_dataSource:null,dataSource:{get:function(){return this._dataSource},set:function(a){this._dataSource=g(a),this._domElement&&this._createSelectElement()}},setDisabled:function(a){a?this._domElement.setAttribute("disabled","disabled"):this._domElement.removeAttribute("disabled")},_createSelectElement:function(){for(var b=this._dataSource.getLength(),e="",f=0;b>f;f++){var g=""+this._dataSource.getValue(f),h=a(g),i=d(h);e+=""}c.setInnerHTMLUnsafe(this._domElement,e),this._domElement.selectedIndex=this._index},index:{get:function(){return Math.max(0,Math.min(this._index,this._dataSource.getLength()-1))},set:function(a){if(this._index!==a){this._index=a;var b=this._domElement;b&&b.selectedIndex!==a&&(b.selectedIndex=a)}}},value:{get:function(){return this._dataSource.getValue(this.index)}}})})})}),define("WinJS/Utilities/_UI",["exports","../Core/_BaseCoreUtils","../Core/_Base"],function(a,b,c){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{eventHandler:function(a){return b.markSupportedForProcessing(a)},Orientation:{horizontal:"horizontal",vertical:"vertical"},CountResult:{unknown:"unknown"},CountError:{noResponse:"noResponse"},DataSourceStatus:{ready:"ready",waiting:"waiting",failure:"failure"},FetchError:{noResponse:"noResponse",doesNotExist:"doesNotExist"},EditError:{noResponse:"noResponse",canceled:"canceled",notPermitted:"notPermitted",noLongerMeaningful:"noLongerMeaningful"},ObjectType:{item:"item",groupHeader:"groupHeader"},SelectionMode:{none:"none",single:"single",multi:"multi"},TapBehavior:{directSelect:"directSelect",toggleSelect:"toggleSelect",invokeOnly:"invokeOnly",none:"none"},SwipeBehavior:{select:"select",none:"none"},GroupHeaderTapBehavior:{invoke:"invoke",none:"none"}})}),define("WinJS/Utilities/_Xhr",["../Core/_Global","../Core/_Base","../Promise","../Scheduler"],function(a,b,c,d){"use strict";function e(a,b,c){d.schedule(function(){a(b)},c,null,"WinJS.xhr")}function f(){}function g(b){var g;return new c(function(c,h,i){var j=d.currentPriority;g=new a.XMLHttpRequest,g.onreadystatechange=function(){return g._canceled?void(g.onreadystatechange=f):void(4===g.readyState?(g.status>=200&&g.status<300||0===g.status?e(c,g,j):e(h,g,j),g.onreadystatechange=f):e(i,g,j))},g.open(b.type||"GET",b.url,!0,b.user,b.password),g.responseType=b.responseType||"",Object.keys(b.headers||{}).forEach(function(a){g.setRequestHeader(a,b.headers[a])}),b.customRequestInitializer&&b.customRequestInitializer(g),void 0===b.data?g.send():g.send(b.data)},function(){g.onreadystatechange=f,g._canceled=!0,g.abort()})}return b.Namespace.define("WinJS",{xhr:g}),g}),define("WinJS/Utilities",["./Utilities/_Control","./Utilities/_Dispose","./Utilities/_ElementListUtilities","./Utilities/_ElementUtilities","./Utilities/_Hoverable","./Utilities/_ItemsManager","./Utilities/_KeyboardBehavior","./Utilities/_ParallelWorkQueue","./Utilities/_SafeHtml","./Utilities/_Select","./Utilities/_TabContainer","./Utilities/_UI","./Utilities/_VersionManager","./Utilities/_Xhr"],function(){}),define("WinJS/Fragments",["exports","./Core/_Global","./Core/_WinRT","./Core/_Base","./Core/_BaseUtils","./Core/_ErrorFromName","./Core/_Resources","./Core/_WriteProfilerMark","./Promise","./Utilities/_ElementUtilities","./Utilities/_SafeHtml","./Utilities/_Xhr"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";function m(a,c,d,e){var f=a.src,g=!f;if(g&&(f=c+"script["+d+"]"),f=f.toLowerCase(),!(f in F)){var h=null;F[f]=!0;var j=b.document.createElement("script");if(a.language&&j.setAttribute("language","javascript"),j.setAttribute("type",a.type),j.setAttribute("async","false"),a.id&&j.setAttribute("id",a.id),g){var k=a.text;h=e.then(function(){j.text=k}).then(null,function(){})}else h=new i(function(b){j.onload=j.onerror=function(){b()},j.setAttribute("src",a.src)});return E.appendChild(j),{promise:h,inline:g}}}function n(a,b,c){var d=(b+"script["+c+"]").toLowerCase();d in G||(G[d]=!0,E.appendChild(a.cloneNode(!0)))}function o(a){var b=a.href.toLowerCase();if(!(b in H)){H[b]=!0;var c=a.cloneNode(!1);c.href=a.href,E.appendChild(c)}}function p(a,c){if("string"==typeof a)return r(a,c);var d={docfrag:j.data(a).docFragment};if(!d.docfrag){for(var e=b.document.createDocumentFragment();a.childNodes.length>0;)e.appendChild(a.childNodes[0]);d.docfrag=j.data(a).docFragment=e,a.setAttribute("data-win-hasfragment","")}return c&&y(a),i.as(d)}function q(a,b){return A(a,b).then(function(){return a.document?s(b,a):a}).then(function(){return a.document&&delete a.document,a})}function r(a,b){var c=a.toLowerCase(),d=J[c];if(d)return b&&delete J[c],d.promise?d.promise:i.as(d);d={},b||(J[c]=d);var e=d.promise=q(d,a);return d.promise.then(function(){delete d.promise}),e}function s(a,c){var d=c.document,e=d.body,f=[];D(d.querySelectorAll('link[rel="stylesheet"], link[type="text/css"]'),o),D(d.getElementsByTagName("style"),function(b,c){n(b,a,c)});var g=i.as();D(d.getElementsByTagName("script"),function(b,c){var d=m(b,a,c,g);d&&(d.inline||(g=d.promise),f.push(d.promise))}),D(e.getElementsByTagName("img"),function(a){a.src=a.src}),D(e.getElementsByTagName("a"),function(a){if(""!==a.href){var b=a.getAttribute("href");b&&"#"!==b[0]&&(a.href=a.href)}});for(var h=e.getElementsByTagName("script");h.length>0;){var j=h[0];j.parentNode.removeChild(j)}return i.join(f).then(function(){for(var a=b.document.createDocumentFragment(),e=b.document.importNode(d.body,!0);e.childNodes.length>0;)a.appendChild(e.childNodes[0]);return c.docfrag=a,c})}function t(){I||(I=!0,D(E.querySelectorAll("script"),function(a){F[a.src.toLowerCase()]=!0}),D(E.querySelectorAll('link[rel="stylesheet"], link[type="text/css"]'),function(a){H[a.href.toLowerCase()]=!0}))}function u(a,b){return v(a,b,!0)}function v(a,c,d){var f=(a instanceof b.HTMLElement?e._getProfilerMarkIdentifier(a):" href='"+a+"'")+"["+ ++K+"]";return L("WinJS.UI.Fragments:render"+f+",StartTM"),t(),p(a,!d).then(function(a){var b=a.docfrag;d&&(b=b.cloneNode(!0));for(var e=b.firstChild;e;)1===e.nodeType&&(e.msParentSelectorScope=!0),e=e.nextSibling;var g;return c?(c.appendChild(b),g=c):g=b,L("WinJS.UI.Fragments:render"+f+",StopTM"),g})}function w(a,b){return v(a,b,!1)}function x(a){return t(),p(a).then(function(a){return a.docfrag})}function y(a){a?"string"==typeof a?delete J[a.toLowerCase()]:(delete j.data(a).docFragment,a.removeAttribute("data-win-hasfragment")):J={}}function z(a){if(e.hasWinRT){var d=b.document.createElement("a");d.href=a;var g=d.href,h=new c.Windows.Foundation.Uri(g),i=h.schemeName;if("ms-appx"!==i)throw new f("WinJS.UI.Fragments.InvalidUri",C.invalidFragmentUri);return g}return a}function A(a,c){c=z(c);var d=b.document.implementation.createHTMLDocument("frag"),e=d.createElement("base");d.head.appendChild(e);var f=d.createElement("a");return d.body.appendChild(f),e.href=b.document.location.href,f.setAttribute("href",c),e.href=f.href,a.document=d,M(c).then(function(a){k.setInnerHTMLUnsafe(d.documentElement,a),d.head.appendChild(e)})}function B(a){return l({url:a}).then(function(a){return a.responseText})}var C={get invalidFragmentUri(){return"Unsupported uri for fragment loading. Fragments in the local context can only load from package content or local sources. To load fragments from other sources, use a web context."}};if(b.document){var D=function(a,b){for(var c=0,d=a.length;d>c;c++)b(a[c],c)},E=b.document.head||b.document.getElementsByTagName("head")[0],F={},G={},H={},I=!1,J={},K=1,L=h,M=B;d.Namespace._moduleDefine(a,"WinJS.UI.Fragments",{renderCopy:u,render:w,cache:x,clearCache:y,_cacheStore:{get:function(){return J}},_forceLocal:z,_getFragmentContents:{get:function(){return M},set:function(a){M=a}},_writeProfilerMark:{get:function(){return L},set:function(a){L=a}}})}}),define("WinJS/Application/_State",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Promise"],function(a,b,c,d,e,f){"use strict";function g(){var b,e,f,g=d.Class.define(function(a){this.folder=a,this._path=a.path,a.tryGetItemAsync&&(this._tryGetItemAsync=a.tryGetItemAsync.bind(a))},{_tryGetItemAsync:function(a){return this.folder.getFileAsync(a).then(null,function(){return!1})},exists:function(a){return this._tryGetItemAsync(a).then(function(a){return a?!0:!1})},remove:function(a){return this._tryGetItemAsync(a).then(function(a){return a?a.deleteAsync():!1}).then(null,function(){return!1})},writeText:function(a,b){var d=c.Windows.Storage,e=this;return e.folder.createFileAsync(a,d.CreationCollisionOption.openIfExists).then(function(a){return d.FileIO.writeTextAsync(a,b)})},readText:function(a,b){var d=c.Windows.Storage;return this._tryGetItemAsync(a).then(function(a){return a?d.FileIO.readTextAsync(a):b}).then(null,function(){return b})}},{supportedForProcessing:!1});d.Namespace._moduleDefine(a,"WinJS.Application",{local:{get:function(){return b||(b=new g(c.Windows.Storage.ApplicationData.current.localFolder)),b}},temp:{get:function(){return e||(e=new g(c.Windows.Storage.ApplicationData.current.temporaryFolder)),e}},roaming:{get:function(){return f||(f=new g(c.Windows.Storage.ApplicationData.current.roamingFolder)),f}}})}function h(){var b=d.Class.define(function(){this.storage={}},{exists:function(a){return f.as(void 0!==this.storage[a])},remove:function(a){return delete this.storage[a],f.as()},writeText:function(a,b){return this.storage[a]=b,f.as(b.length)},readText:function(a,b){var c=this.storage[a];return f.as("string"==typeof c?c:b)}},{supportedForProcessing:!1});d.Namespace._moduleDefine(a,"WinJS.Application",{local:new b,temp:new b,roaming:new b})}c.Windows.Storage.FileIO&&c.Windows.Storage.ApplicationData&&c.Windows.Storage.CreationCollisionOption?g():h();var i={};d.Namespace._moduleDefine(a,"WinJS.Application",{sessionState:{get:function(){return i},set:function(a){i=a}},_loadState:function(b){return 3===b.previousExecutionState?a.local.readText("_sessionState.json","{}").then(function(b){var c=JSON.parse(b);c&&Object.keys(c).length>0&&(a._sessionStateLoaded=!0),a.sessionState=c}).then(null,function(){a.sessionState={}}):f.as()},_oncheckpoint:function(c,d){if(!(b.MSApp&&b.MSApp.getViewOpener&&b.MSApp.getViewOpener())){var e=a.sessionState;if(e&&Object.keys(e).length>0||a._sessionStateLoaded){var f;try{f=JSON.stringify(e)}catch(g){f="",d.queueEvent({type:"error",detail:g})}c.setPromise(a.local.writeText("_sessionState.json",f).then(null,function(a){d.queueEvent({type:"error",detail:a})}))}}}})}),define("WinJS/Navigation",["exports","./Core/_Base","./Core/_Events","./Core/_WriteProfilerMark","./Promise"],function(a,b,c,d,e){"use strict";var f="navigated",g="navigating",h="beforenavigate",i=b.Class.mix(b.Class.define(null,{},{supportedForProcessing:!1}),c.eventMixin),j=new i,k={backStack:[],current:{location:"",initialPlaceholder:!0},forwardStack:[]},l=c._createEventProperty,m=function(a){return d("WinJS.Navigation:navigation,StartTM"),e.as().then(function(){var b=e.as(),c=j.dispatchEvent(h,{setPromise:function(a){b=b.then(function(){return a})},location:a.location,state:a.state});return b.then(function(a){return c||a})})},n=function(a){return e.as().then(function(){var b=e.as();return j.dispatchEvent(g,{setPromise:function(a){b=b.then(function(){return a})},location:k.current.location,state:k.current.state,delta:a}),b})},o=function(a,b){d("WinJS.Navigation:navigation,StopTM");var c=e.as(),g={value:a,location:k.current.location,state:k.current.state,setPromise:function(a){c=c.then(function(){return a})}};return!a&&b&&(g.error=b),j.dispatchEvent(f,g),c},p=function(a,b,c,d){return a=Math.min(a,b.length),a>0?m(b[b.length-a]).then(function(e){if(e)return!1;for(c.push(k.current);a-1>0;)a--,c.push(b.pop());return k.current=b.pop(),n(d).then(o,function(a){throw o(void 0,a||!0),a}).then(function(){return!0})}):e.wrap(!1)};b.Namespace._moduleDefine(a,"WinJS.Navigation",{canGoForward:{get:function(){return k.forwardStack.length>0}},canGoBack:{get:function(){return k.backStack.length>0}},location:{get:function(){return k.current.location}},state:{get:function(){return k.current.state},set:function(a){k.current.state=a}},history:{get:function(){return k},set:function(a){k=a,k.backStack=k.backStack||[],k.forwardStack=k.forwardStack||[],k.current=k.current||{location:"",initialPlaceholder:!0},k.current.location=k.current.location||""}},forward:function(a){return a=a||1,p(a,k.forwardStack,k.backStack,a)},back:function(a){return a=a||1,p(a,k.backStack,k.forwardStack,-a)},navigate:function(a,b){var c={location:a,state:b};return m(c).then(function(a){return a?!1:(k.current.initialPlaceholder||k.backStack.push(k.current),k.forwardStack=[],k.current=c,n().then(o,function(a){throw o(void 0,a||!0),a}).then(function(){return!0}))})},addEventListener:function(a,b,c){j.addEventListener(a,b,c)},removeEventListener:function(a,b,c){j.removeEventListener(a,b,c)},onnavigated:l(f),onnavigating:l(g),onbeforenavigate:l(h)})}),define("WinJS/Application",["exports","./Core/_Global","./Core/_WinRT","./Core/_Base","./Core/_Events","./Core/_Log","./Core/_WriteProfilerMark","./Application/_State","./Navigation","./Promise","./_Signal","./Scheduler"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";function m(a){var c;try{var d=[];c=JSON.stringify(a,function(a,c){return c===b?"[window]":c instanceof b.HTMLElement?"[HTMLElement]":"function"==typeof c?"[function]":"object"==typeof c?null===c?c:-1===d.indexOf(c)?(d.push(c),c):"[circular]":c})}catch(e){c=JSON.stringify("[object]")}return c}function n(a){b.MSApp&&b.MSApp.terminateApp(a)}function o(a){var b="def"+$++;return{deferral:Z[b]=a.getDeferral(),id:b}}function p(a,b){b&&(a=Z[b],delete Z[b]),a&&a.complete()}function q(){Z&&(Object.keys(Z).forEach(function(a){Z[a].complete()}),Z={})}function r(a){function b(b){return g("WinJS.Application:Event_"+a.type+",StopTM"),a._deferral&&p(a._deferral,a._deferralID),b}g("WinJS.Application:Event_"+a.type+",StartTM");var c=j.as();a.setPromise=function(a){c=c.then(function(){return a})},a.detail=a.detail||{},"object"==typeof a.detail&&(a.detail.setPromise=a.setPromise);try{if(X._listeners){var d=!1;e=X._listeners[a.type],e&&e.forEach(function(b){d=b.listener(a)||d})}var e=ab[a.type];e&&e.forEach(function(b){b(a,d)})}catch(f){w({type:O,detail:f})}return c.then(b,function(a){return a=b(a),a&&"Canceled"===a.name?void 0:j.wrapError(a)})}function s(){return T||(T=new k,T.promise.done(function(){T=null},function(){T=null})),T}function t(a){function b(a){w({type:O,detail:a})}return 0===a.length?s().promise:r(a.shift()).then(null,b)}function u(a){function b(){return u}var c=a.job._queue;0===c.length&&R.length>0&&(c=a.job._queue=x()),a.setPromise(t(c).then(b,b))}function v(){function a(){d=!0}for(var b,c=[],d=!0;d;)0===c.length&&R.length>0&&(c=x()),d=!1,b=t(c),b.done(a,a);S=l.schedule(function(a){function c(){return u}a.setPromise(b.then(c,c))},l.Priority.high,null,"WinJS.Application._pumpEventQueue"),S._queue=c}function w(a){g("WinJS.Application:Event_"+a.type+" queued,Info"),R.push(a),U&&T&&T.complete(u)}function x(){var a=R;return R=[],a}function y(a){var b=o(a.activatedOperation);h._loadState(a).then(function(){w({type:L,detail:a,_deferral:b.deferral,_deferralID:b.id})})}function z(a){var b=o(a.suspendingOperation);w({type:J,_deferral:b.deferral,_deferralID:b.id})}function A(){if(w({type:M}),!b.document||!c.Windows.UI.WebUI.WebUIApplication){var a={arguments:"",kind:"Windows.Launch",previousExecutionState:0};h._loadState(a).then(function(){w({type:L,detail:a})})}}function B(){q(),w({type:K})}function C(b){var c={};for(var d in b)c[d]=b[d];var e,f=!0,g=a._terminateApp;try{a._terminateApp=function(a,b){f=!1,e=a,g!==n&&g(a,b)},r({type:O,detail:{error:c,errorLine:b.lineno,errorCharacter:b.colno,errorUrl:b.filename,errorMessage:b.message}})}finally{a._terminateApp=g}return f}function D(a){var b=a.detail,c=b.id;if(b.parent)return void(b.handler&&I&&delete I[c]);if(b.exception instanceof Error){var d={stack:b.exception.stack,message:b.exception.message};b.exception=d}var e=!I;I=I||[],I[c]=b,e&&l.schedule(function(){var a=I;I=null,a.forEach(function(a){w({type:O,detail:a})})},l.Priority.high,null,"WinJS.Application._queuePromiseErrors")}function E(a){var b={e:a,applicationcommands:void 0};X.dispatchEvent(P,b)}function F(a){var b={type:Q};Object.defineProperty(b,"_winRTBackPressedEvent",{value:a,enumerable:!1}),r(b)}function G(){if(!V){if(V=!0,b.addEventListener("beforeunload",B,!1),b.document){if(b.addEventListener("error",C,!1),c.Windows.UI.WebUI.WebUIApplication){var a=c.Windows.UI.WebUI.WebUIApplication;a.addEventListener("activated",y,!1),a.addEventListener("suspending",z,!1)}if(c.Windows.UI.ApplicationSettings.SettingsPane){var d=c.Windows.UI.ApplicationSettings.SettingsPane.getForCurrentView();d.addEventListener("commandsrequested",E)}c.Windows.Phone.UI.Input.HardwareButtons&&c.Windows.Phone.UI.Input.HardwareButtons.addEventListener("backpressed",F)}j.addEventListener("error",D)}}function H(){if(V){if(V=!1,b.removeEventListener("beforeunload",B,!1),b.document){if(c.Windows.UI.WebUI.WebUIApplication){b.removeEventListener("error",C,!1);var a=c.Windows.UI.WebUI.WebUIApplication;a.removeEventListener("activated",y,!1),a.removeEventListener("suspending",z,!1)}if(c.Windows.UI.ApplicationSettings.SettingsPane){var d=c.Windows.UI.ApplicationSettings.SettingsPane.getForCurrentView();d.removeEventListener("commandsrequested",E)}c.Windows.Phone.UI.Input.HardwareButtons&&c.Windows.Phone.UI.Input.HardwareButtons.removeEventListener("backpressed",F)}j.removeEventListener("error",D)}}b.Debug&&(b.Debug.setNonUserCodeExceptions=!0);var I,J="checkpoint",K="unload",L="activated",M="loaded",N="ready",O="error",P="settings",Q="backclick",R=[],S=null,T=null,U=!1,V=!1,W=d.Class.mix(d.Class.define(null,{},{supportedForProcessing:!1}),e.eventMixin),X=new W,Y=e._createEventProperty,Z={},$=0,_=n,ab={activated:[function(){w({type:N})}],checkpoint:[function(b){h._oncheckpoint(b,a)}],error:[function(c,d){if(!d&&(f.log&&f.log(m(c),"winjs","error"),b.document&&a._terminateApp)){var e=c.detail,g=e&&(e.number||e.exception&&(e.exception.number||e.exception.code)||e.error&&e.error.number||e.errorCode||0),h={description:m(e),stack:e&&(e.stack||e.exception&&(e.exception.stack||e.exception.message)||e.error&&e.error.stack||null),errorNumber:g,number:g};a._terminateApp(h,c)}}],backclick:[function(a,b){b?a._winRTBackPressedEvent.handled=!0:i.canGoBack&&(i.back(),a._winRTBackPressedEvent.handled=!0)}]};b.document&&b.document.addEventListener("DOMContentLoaded",A,!1);var bb=d.Namespace._moduleDefine(a,"WinJS.Application",{stop:function(){bb.onactivated=null,bb.oncheckpoint=null,bb.onerror=null,bb.onloaded=null,bb.onready=null,bb.onsettings=null,bb.onunload=null,bb.onbackclick=null,X=new W,h.sessionState={},U=!1,x(),S&&S.cancel(),S=null,T=null,H(),q()},addEventListener:function(a,b,c){X.addEventListener(a,b,c)},removeEventListener:function(a,b,c){X.removeEventListener(a,b,c)},checkpoint:function(){w({type:J})},start:function(){G(),U=!0,v()},queueEvent:w,_terminateApp:{get:function(){return _},set:function(a){_=a}},oncheckpoint:Y(J),onunload:Y(K),onactivated:Y(L),onloaded:Y(M),onready:Y(N),onsettings:Y(P),onerror:Y(O),onbackclick:Y(Q)})}),define("WinJS/Animations/_Constants",["exports","../Core/_Base"],function(a,b){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{PageNavigationAnimation:{turnstile:"turnstile",slide:"slide",enterPage:"enterPage",continuum:"continuum"}})}),define("WinJS/Animations/_TransitionAnimation",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Promise","../Scheduler","../Utilities/_ElementUtilities"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){return Array.isArray(a)||a instanceof b.NodeList||a instanceof b.HTMLCollection?a:a?[a]:[]}function j(){return++B,"WinJSUIAnimation"+B}function k(a){return"WinJSUIAnimation"===a.substring(0,16)}function l(a){b.getComputedStyle(a,null).opacity}function m(b,c){return function(d){var e={};for(var f in d){var g=d[f];"function"==typeof g&&(g=g(b,c)),e[f]=g}return e.exactTiming||(e.delay+=a._libraryDelay),e}}function n(a,b){var c=a+"|"+b,d=C[c];d&&d(D)}function o(a,b,c){C[a+"|"+b]=c}function p(a,b){delete C[a+"|"+b]}function q(a,b,c,d,e){var f=e.styleCaches[b]||new F(b,e,c);f.cref+=d.length,d.forEach(function(a){n(b,a.property)}),(e.isTransition||d.some(function(a){return f.removed[a[e.nameField]]}))&&(l(a),f.removed={});var g=d.map(function(a){return a[e.nameField]+" "+e.props.map(function(b){return(b[1]?a[b[1]]:"")+b[2]}).join(" ")}).join(", "),h=d.map(function(a){return a[e.nameField]}).join(", ");return""!==f.names&&(g=f.names+", "+g,h=f.names+", "+h),c[e.shorthandProp]=g,f.names=h,f}function r(a,b){b?a():g.schedule(function(){a()},g.Priority.normal,null,"WinJS.UI._Animation._completeAnimationPromise")}function s(a,c,d,g,i){if(d.length>0){var j=a.style,k=h._uniqueID(a);if(y||(y=b.document.createElement("DIV").style),d=d.map(m(c,a)),d.forEach(function(a){var b=e._getCamelCasedName(a.property);a.hasOwnProperty("from")&&(j[b]=a.from),y[b]=a.to,a.to=y[b],a.propertyScriptName=b}),i){var l=q(a,k,j,d,G),n=a.disabled?b.document:a;d.forEach(function(c){var d;g.push(new f(function(f){d=function(d){g&&(n.removeEventListener(e._browserEventEquivalents.transitionEnd,g,!1),p(k,c.property),l.removeName(j,c.propertyScriptName,d?a:null,c.skipStylesReset),b.clearTimeout(i),g=null),r(f,d===E)};var g=function(b){b.target===a&&b.propertyName===c.property&&d()};o(k,c.property,d),n.addEventListener(e._browserEventEquivalents.transitionEnd,g,!1);var h=0;j[c.propertyScriptName]!==c.to&&(j[c.propertyScriptName]=c.to,h=50);var i=b.setTimeout(function(){i=b.setTimeout(d,c.delay+c.duration)},h)},function(){d(E)}))})}else d.forEach(function(a){j[a.propertyScriptName]=a.to})}}function t(a,c,d,g,i){if(i&&d.length>0){var k=a.style,l=h._uniqueID(a);d=d.map(m(c,a));var n,s=a.disabled?b.document:a;d.forEach(function(a){if(a.keyframe)a.keyframe=A.animationPrefix+a.keyframe;else{n||(n=b.document.createElement("STYLE"),b.document.documentElement.appendChild(n)),a.keyframe=j();var c="@"+A.keyframes+" "+a.keyframe+" { from {"+a.property+":"+a.from+";} to {"+a.property+":"+a.to+";}}";n.sheet.insertRule(c,0)}});var t=q(a,l,k,d,H),u=[],v=[];d.forEach(function(c){var d;v.push(new f(function(f){d=function(a){g&&(s.removeEventListener(e._browserEventEquivalents.animationEnd,g,!1),b.clearTimeout(h),g=null),r(f,a===E)};var g=function(b){b.target===a&&b.animationName===c.keyframe&&d()};o(l,c.property,d),u.push({id:l,property:c.property,style:k,keyframe:c.keyframe});var h=b.setTimeout(function(){h=b.setTimeout(d,c.delay+c.duration)},50);s.addEventListener(e._browserEventEquivalents.animationEnd,g,!1)},function(){d(E)}))}),n&&b.setTimeout(function(){var a=n.parentElement;a&&a.removeChild(n)},50);var w=function(){for(var a=0;a=0&&(f.splice(g,1),this.names=e=f.join(", "),""===e&&this.desc.isTransition&&(e="none")),--this.cref?(a[this.desc.nameProp]=e,k(b)||(this.removed[b]=!0)):(c&&"none"===e&&(a[this.desc.nameProp]=e,l(c)),this.destroy(a,d))}}),G={shorthandProp:A.transition.scriptName,nameProp:A["transition-property"].scriptName,nameField:"property",props:[[A["transition-duration"].scriptName,"duration","ms"],[A["transition-timing-function"].scriptName,"timing",""],[A["transition-delay"].scriptName,"delay","ms"]],isTransition:!0,styleCaches:[]},H={shorthandProp:A.animation.scriptName,nameProp:A["animation-name"].scriptName,nameField:"keyframe",props:[[A["animation-duration"].scriptName,"duration","ms"],[A["animation-timing-function"].scriptName,"timing",""],[A["animation-delay"].scriptName,"delay","ms"],[A["animation-iteration-count"].scriptName,"","1"],[A["animation-direction"].scriptName,"","normal"],[A["animation-fill-mode"].scriptName,"","both"]],isTransition:!1,styleCaches:[]},I=0,J=function(){return u(),I+z.animationsEnabled>0},K=function(a){return L?a/20:a},L=!1,M=0;d.Namespace._moduleDefine(a,"WinJS.UI",{disableAnimations:function(){I--},enableAnimations:function(){I++},isAnimationEnabled:{get:function(){return J},set:function(a){J=a}},_libraryDelay:{get:function(){return M},set:function(a){M=a}},executeAnimation:function(a,b){return v(a,x(b),t)},executeTransition:function(a,b){return v(a,x(b),s)},_animationTimeAdjustment:{get:function(){return K},set:function(a){K=a}}}),d.Namespace._moduleDefine(a,"WinJS.Utilities",{_fastAnimations:{get:function(){return L},set:function(a){L=a}}})}}),define("WinJS/Animations",["exports","./Core/_Global","./Core/_Base","./Core/_BaseUtils","./Core/_WriteProfilerMark","./Animations/_Constants","./Animations/_TransitionAnimation","./Promise"],function(a,b,c,d,e,f,g,h){"use strict";function i(a,b,c){return a.keyframe?a.keyframe:!c||a.left!==b.left||a.top!==b.top||a.rtlflip&&!b.rtlflip?null:a.rtlflip?k(c):c}function j(a,b){return b&&a.rtlflip?k(b):b}function k(a){var c=a+"-rtl";return function(d,e){return"ltr"===b.getComputedStyle(e).direction?a:c}}function l(a){return Array.isArray(a)||a instanceof b.NodeList||a instanceof b.HTMLCollection?a:a?[a]:[]}function m(a){for(var c=[],d=0;dg;g++)b*=c,f+=b;return d&&(f=Math.min(f,d)),f}}function o(a,b){for(var c=0;cf;f++)k.push(a[f]),l.push(d),m.push(e);else k.push(a),l.push(d),m.push(e)}}var k=[],l=[],m=[],n=200,o=0!==b?0>b?-n:n:0,p=0!==c?0>c?-n:n:0;return j(e,b,c),j(f,o,p),j(h,2*o,2*p),j(i,3*o,3*p),l=new B(l),m=new B(m),g.executeTransition(k,[{property:z.cssName,delay:0,duration:350,timing:a,from:t(l),to:t(m)},{property:"opacity",delay:0,duration:350,timing:d?"steps(1, start)":"steps(1, end)",from:d?0:1,to:d?1:0}])}function r(a,c,e){function f(){s(a)}a=l(a),c=l(c);for(var h=0,i=a.length;i>h;h++){var j="rtl"===b.getComputedStyle(a[h]).direction;a[h].style[d._browserStyleEquivalents["transform-origin"].scriptName]=c[Math.min(c.length-1,h)][j?"rtl":"ltr"]}return g.executeTransition(a,e).then(f,f)}function s(a){for(var b=0,c=a.length;c>b;b++)a[b].style[d._browserStyleEquivalents["transform-origin"].scriptName]="",a[b].style[z.scriptName]="",a[b].style.opacity=""}function t(a,c){return c=c||"",function(d,e){var f=a.getOffset(d),g=f.left;return f.rtlflip&&"rtl"===b.getComputedStyle(e).direction&&(g=g.toString(),g="-"===g.charAt(0)?g.substring(1):"-"+g),c+"translate("+g+", "+f.top+")"}}function u(a,b){return b=b||"",function(c){var d=a[c];return"translate("+d.left+"px, "+d.top+"px) "+b}}function v(a,b){return function(c){var d=a[c];return 0===d.left&&0===d.top?b:null}}function w(a,b,c,d){var e=l(b),f=l(c),g=m(f);return new a(e,f,g,d)}function x(a){for(var c=[],d=0,e=a.length;e>d;d++){var f=a[d].getBoundingClientRect(),g=-(40+f.left),h=40+(b.innerWidth-f.right),i=b.innerHeight/2-f.top;c.push({ltr:g+"px "+i+"px",rtl:h+"px "+i+"px"})}return c}function y(a){e("WinJS.UI.Animation:"+a)}var z=d._browserStyleEquivalents.transform,A=[{top:"0px",left:"11px",rtlflip:!0}],B=c.Class.define(function(a,b,c){c=c||A,Array.isArray(a)&&a.length>0?(this.offsetArray=a,1===a.length&&(this.keyframe=i(a[0],c[0],b))):a&&a.hasOwnProperty("top")&&a.hasOwnProperty("left")?(this.offsetArray=[a],this.keyframe=i(a,c[0],b)):(this.offsetArray=c,this.keyframe=j(c[0],b))},{getOffset:function(a){return a>=this.offsetArray.length&&(a=this.offsetArray.length-1),this.offsetArray[a]}},{supportedForProcessing:!1}),C=c.Class.define(function(a,b,c){this.revealedArray=a,this.affectedArray=b,this.offsetArray=c},{execute:function(){y("expandAnimation,StartTM");var a=g.executeAnimation(this.revealedArray,{keyframe:"WinJS-opacity-in",property:"opacity",delay:this.affectedArray.length>0?200:0,duration:167,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1}),b=p(this.affectedArray,this.offsetArray,{property:z.cssName,delay:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([a,b]).then(function(){y("expandAnimation,StopTM")})}},{supportedForProcessing:!1}),D=c.Class.define(function(a,b,c){this.hiddenArray=a,this.affectedArray=b,this.offsetArray=c},{execute:function(){y("collapseAnimation,StartTM");var a=g.executeAnimation(this.hiddenArray,{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:167,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:1,to:0}),b=p(this.affectedArray,this.offsetArray,{property:z.cssName,delay:this.hiddenArray.length>0?167:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([a,b]).then(function(){y("collapseAnimation,StopTM")})}},{supportedForProcessing:!1}),E=c.Class.define(function(a,b,c){this.elementArray=b,this.offsetArray=c},{execute:function(){return y("repositionAnimation,StartTM"),p(this.elementArray,this.offsetArray,{property:z.cssName,delay:n(0,33,1,250),duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""}).then(function(){y("repositionAnimation,StopTM")})}},{supportedForProcessing:!1}),F=c.Class.define(function(a,b,c){this.addedArray=a,this.affectedArray=b,this.offsetArray=c},{execute:function(){y("addToListAnimation,StartTM");var a=this.affectedArray.length>0?240:0,b=g.executeAnimation(this.addedArray,[{keyframe:"WinJS-scale-up",property:z.cssName,delay:a,duration:120,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:"scale(0.85)",to:"none"},{keyframe:"WinJS-opacity-in",property:"opacity",delay:a,duration:120,timing:"linear",from:0,to:1}]),c=p(this.affectedArray,this.offsetArray,{property:z.cssName,delay:0,duration:400,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([b,c]).then(function(){y("addToListAnimation,StopTM")})}},{supportedForProcessing:!1}),G=c.Class.define(function(a,b,c){this.deletedArray=a,this.remainingArray=b,this.offsetArray=c},{execute:function(){y("deleteFromListAnimation,StartTM");var a=g.executeAnimation(this.deletedArray,[{keyframe:"WinJS-scale-down",property:z.cssName,delay:0,duration:120,timing:"cubic-bezier(0.11, 0.5, 0.24, .96)",from:"none",to:"scale(0.85)"},{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:120,timing:"linear",from:1,to:0}]),b=p(this.remainingArray,this.offsetArray,{property:z.cssName,delay:this.deletedArray.length>0?60:0,duration:400,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([a,b]).then(function(){y("deleteFromListAnimation,StopTM")})}},{supportedForProcessing:!1}),H=c.Class.define(function(a,b,c,d){this.addedArray=a,this.affectedArray=b,this.offsetArray=c;var e=l(d);this.deletedArray=e,this.deletedOffsetArray=m(e)},{execute:function(){y("_updateListAnimation,StartTM"),o(this.deletedArray,this.deletedOffsetArray);var a=0,b=g.executeAnimation(this.deletedArray,[{keyframe:v(this.deletedOffsetArray,"WinJS-scale-down"),property:z.cssName,delay:0,duration:120,timing:"cubic-bezier(0.11, 0.5, 0.24, .96)",from:u(this.deletedOffsetArray),to:u(this.deletedOffsetArray,"scale(0.85)")},{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:120,timing:"linear",from:1,to:0}]);this.deletedArray.length>0&&(a+=60);var c=p(this.affectedArray,this.offsetArray,{property:z.cssName,delay:a,duration:400,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});this.affectedArray.length>0?a+=240:a&&(a+=60);var d=g.executeAnimation(this.addedArray,[{keyframe:"WinJS-scale-up",property:z.cssName,delay:a,duration:120,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:"scale(0.85)",to:"none"},{keyframe:"WinJS-opacity-in",property:"opacity",delay:a,duration:120,timing:"linear",from:0,to:1}]);return h.join([b,c,d]).then(function(){y("_updateListAnimation,StopTM")})}},{supportedForProcessing:!1}),I=c.Class.define(function(a,b,c){this.addedArray=a,this.affectedArray=b,this.offsetArray=c},{execute:function(){y("addToSearchListAnimation,StartTM");var a=g.executeAnimation(this.addedArray,{keyframe:"WinJS-opacity-in",property:"opacity",delay:this.affectedArray.length>0?240:0,duration:117,timing:"linear",from:0,to:1}),b=p(this.affectedArray,this.offsetArray,{property:z.cssName,delay:0,duration:400,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([a,b]).then(function(){y("addToSearchListAnimation,StopTM")})}},{supportedForProcessing:!1}),J=c.Class.define(function(a,b,c){this.deletedArray=a,this.remainingArray=b,this.offsetArray=c},{execute:function(){y("deleteFromSearchListAnimation,StartTM");var a=g.executeAnimation(this.deletedArray,{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:93,timing:"linear",from:1,to:0}),b=p(this.remainingArray,this.offsetArray,{property:z.cssName,delay:this.deletedArray.length>0?60:0,duration:400,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([a,b]).then(function(){y("deleteFromSearchListAnimation,StopTM")})}},{supportedForProcessing:!1}),K=c.Class.define(function(a,b,c){this.elementArray=b,this.offsetArray=c},{execute:function(){return y("peekAnimation,StartTM"),p(this.elementArray,this.offsetArray,{property:z.cssName,delay:0,duration:2e3,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""}).then(function(){y("peekAnimation,StopTM")})}},{supportedForProcessing:!1});c.Namespace._moduleDefine(a,"WinJS.UI.Animation",{createExpandAnimation:function(a,b){return w(C,a,b)},createCollapseAnimation:function(a,b){return w(D,a,b)},createRepositionAnimation:function(a){return w(E,null,a)},fadeIn:function(a){return y("fadeIn,StartTM"),g.executeTransition(a,{property:"opacity",delay:0,duration:250,timing:"linear",from:0,to:1}).then(function(){y("fadeIn,StopTM")})},fadeOut:function(a){return y("fadeOut,StartTM"),g.executeTransition(a,{property:"opacity",delay:0,duration:167,timing:"linear",to:0}).then(function(){y("fadeOut,StopTM")})},createAddToListAnimation:function(a,b){return w(F,a,b)},createDeleteFromListAnimation:function(a,b){return w(G,a,b)},_createUpdateListAnimation:function(a,b,c){return w(H,a,c,b)},createAddToSearchListAnimation:function(a,b){return w(I,a,b)},createDeleteFromSearchListAnimation:function(a,b){return w(J,a,b)},showEdgeUI:function(a,b,c){y("showEdgeUI,StartTM");var d=new B(b,"WinJS-showEdgeUI",[{top:"-70px",left:"0px"}]);return g[c&&"transition"===c.mechanism?"executeTransition":"executeAnimation"](a,{keyframe:d.keyframe,property:z.cssName,delay:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:d.keyframe||t(d),to:"none"}).then(function(){y("showEdgeUI,StopTM")})},showPanel:function(a,b){y("showPanel,StartTM");var c=new B(b,"WinJS-showPanel",[{top:"0px",left:"364px",rtlflip:!0}]);return g.executeAnimation(a,{keyframe:c.keyframe,property:z.cssName,delay:0,duration:550,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:c.keyframe||t(c),to:"none"}).then(function(){y("showPanel,StopTM")})},hideEdgeUI:function(a,b,c){y("hideEdgeUI,StartTM");var d=new B(b,"WinJS-hideEdgeUI",[{top:"-70px",left:"0px"}]);return g[c&&"transition"===c.mechanism?"executeTransition":"executeAnimation"](a,{keyframe:d.keyframe,property:z.cssName,delay:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:"none",to:d.keyframe||t(d)}).then(function(){y("hideEdgeUI,StopTM")})},hidePanel:function(a,b){y("hidePanel,StartTM");var c=new B(b,"WinJS-hidePanel",[{top:"0px",left:"364px",rtlflip:!0}]);return g.executeAnimation(a,{keyframe:c.keyframe,property:z.cssName,delay:0,duration:550,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:"none",to:c.keyframe||t(c)}).then(function(){y("hidePanel,StopTM")})},showPopup:function(a,b){y("showPopup,StartTM");var c=new B(b,"WinJS-showPopup",[{top:"50px",left:"0px"}]);return g.executeAnimation(a,[{keyframe:"WinJS-opacity-in",property:"opacity",delay:83,duration:83,timing:"linear",from:0,to:1},{keyframe:c.keyframe,property:z.cssName,delay:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:c.keyframe||t(c),to:"none"}]).then(function(){y("showPopup,StopTM")})},hidePopup:function(a){return y("hidePopup,StartTM"),g.executeAnimation(a,{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:83,timing:"linear",from:1,to:0}).then(function(){y("hidePopup,StopTM")})},pointerDown:function(a){return y("pointerDown,StartTM"),g.executeTransition(a,{property:z.cssName,delay:0,duration:167,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:"scale(0.975, 0.975)"}).then(function(){y("pointerDown,StopTM")})},pointerUp:function(a){return y("pointerUp,StartTM"),g.executeTransition(a,{property:z.cssName,delay:0,duration:167,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""}).then(function(){y("pointerUp,StopTM")})},dragSourceStart:function(a,b){y("dragSourceStart,StartTM");var c=g.executeTransition(a,[{property:z.cssName,delay:0,duration:240,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:"scale(1.05)"},{property:"opacity",delay:0,duration:240,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:.65}]),d=g.executeTransition(b,{property:z.cssName,delay:0,duration:240,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:"scale(0.95)"});return h.join([c,d]).then(function(){y("dragSourceStart,StopTM")})},dragSourceEnd:function(a,b,c){y("dragSourceEnd,StartTM");var d=new B(b,"WinJS-dragSourceEnd"),e=g.executeTransition(a,[{property:z.cssName,delay:0,duration:500,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""},{property:"opacity",delay:0,duration:500,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:1}]),f=g.executeAnimation(a,{keyframe:d.keyframe,property:z.cssName,delay:0,duration:500,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:d.keyframe||t(d,"scale(1.05) "),to:"none"}),i=g.executeTransition(c,{property:z.cssName,delay:0,duration:500,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""});return h.join([e,f,i]).then(function(){y("dragSourceEnd,StopTM")})},enterContent:function(a,b,c){y("enterContent,StartTM");var d,e=new B(b,"WinJS-enterContent",[{top:"0px",left:"40px",rtlflip:!0}]);if(c&&"transition"===c.mechanism)d=g.executeTransition(a,[{property:z.cssName,delay:0,duration:550,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:t(e),to:"none"},{property:"opacity",delay:0,duration:170,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1}]);else{var f=g.executeAnimation(a,{keyframe:e.keyframe,property:z.cssName,delay:0,duration:550,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:e.keyframe||t(e),to:"none"}),i=g.executeTransition(a,{property:"opacity",delay:0,duration:170,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1});d=h.join([f,i])}return d.then(function(){y("enterContent,StopTM")})},exitContent:function(a,b){y("exitContent,StartTM");var c=new B(b,"WinJS-exit",[{top:"0px",left:"0px"}]),d=g.executeAnimation(a,b&&{keyframe:c.keyframe,property:z.cssName,delay:0,duration:117,timing:"linear",from:"none",to:c.keyframe||t(c)}),e=g.executeTransition(a,{property:"opacity",delay:0,duration:117,timing:"linear",to:0});return h.join([d,e]).then(function(){y("exitContent,StopTM")})},dragBetweenEnter:function(a,b){y("dragBetweenEnter,StartTM");var c=new B(b,null,[{top:"-40px",left:"0px"},{top:"40px",left:"0px"}]);return g.executeTransition(a,{property:z.cssName,delay:0,duration:200,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:t(c,"scale(0.95) ")}).then(function(){y("dragBetweenEnter,StopTM")})},dragBetweenLeave:function(a){return y("dragBetweenLeave,StartTM"),g.executeTransition(a,{property:z.cssName,delay:0,duration:200,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:"scale(0.95)"}).then(function(){y("dragBetweenLeave,StopTM")})},swipeSelect:function(a,b){y("swipeSelect,StartTM");var c=g.executeTransition(a,{property:z.cssName,delay:0,duration:300,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""}),d=g.executeAnimation(b,{keyframe:"WinJS-opacity-in",property:"opacity",delay:0,duration:300,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1});return h.join([c,d]).then(function(){y("swipeSelect,StopTM")})},swipeDeselect:function(a,b){y("swipeDeselect,StartTM");var c=g.executeTransition(a,{property:z.cssName,delay:0,duration:300,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""}),d=g.executeAnimation(b,{keyframe:"WinJS-opacity-out",property:"opacity",delay:0,duration:300,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:1,to:0});return h.join([c,d]).then(function(){y("swipeDeselect,StopTM")})},swipeReveal:function(a,b){y("swipeReveal,StartTM");var c=new B(b,null,[{top:"25px",left:"0px"}]);return g.executeTransition(a,{property:z.cssName,delay:0,duration:300,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:t(c)}).then(function(){y("swipeReveal,StopTM")})},enterPage:function(a,b){y("enterPage,StartTM");var c=new B(b,"WinJS-enterPage",[{top:"0px",left:"100px",rtlflip:!0}]),d=g.executeAnimation(a,{keyframe:c.keyframe,property:z.cssName,delay:n(0,83,1,333),duration:1e3,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:c.keyframe||t(c),to:"none"}),e=g.executeTransition(a,{property:"opacity",delay:n(0,83,1,333),duration:170,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1});return h.join([d,e]).then(function(){y("enterPage,StopTM")})},exitPage:function(a,b){y("exitPage,StartTM");var c=new B(b,"WinJS-exit",[{top:"0px",left:"0px"}]),d=g.executeAnimation(a,b&&{keyframe:c.keyframe,property:z.cssName,delay:0,duration:117,timing:"linear",from:"none",to:c.keyframe||t(c)}),e=g.executeTransition(a,{property:"opacity",delay:0,duration:117,timing:"linear",to:0});return h.join([d,e]).then(function(){y("exitPage,StopTM")})},crossFade:function(a,b){y("crossFade,StartTM");var c=g.executeTransition(a,{property:"opacity",delay:0,duration:167,timing:"linear",to:1}),d=g.executeTransition(b,{property:"opacity",delay:0,duration:167,timing:"linear",to:0});return h.join([c,d]).then(function(){y("crossFade,StopTM")})},createPeekAnimation:function(a){return w(K,null,a)},updateBadge:function(a,b){y("updateBadge,StartTM");var c=new B(b,"WinJS-updateBadge",[{top:"24px",left:"0px"}]);return g.executeAnimation(a,[{keyframe:"WinJS-opacity-in",property:"opacity",delay:0,duration:367,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:0,to:1},{keyframe:c.keyframe,property:z.cssName,delay:0,duration:1333,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",from:c.keyframe||t(c),to:"none"}]).then(function(){y("updateBadge,StopTM")})},turnstileForwardIn:function(a){y("turnstileForwardIn,StartTM"),a=l(a);var b=x(a);return r(a,b,[{property:z.cssName,delay:n(0,50,1,1e3),duration:300,timing:"cubic-bezier(0.01,0.975,0.4775,0.9775)",from:"perspective(600px) rotateY(80deg)",to:"perspective(600px) rotateY(0deg)"},{property:"opacity",delay:n(0,50,1,1e3),duration:300,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]).then(function(){y("turnstileForwardIn,StopTM")})},turnstileForwardOut:function(a){y("turnstileForwardOut,StartTM"),a=l(a);var b=x(a);return r(a,b,[{property:z.cssName,delay:n(0,50,1,1e3),duration:128,timing:"cubic-bezier(0.4925,0.01,0.7675,-0.01)",from:"perspective(600px) rotateY(0deg)",to:"perspective(600px) rotateY(-50deg)"},{property:"opacity",delay:n(0,50,1,1e3),duration:128,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}]).then(function(){y("turnstileForwardOut,StopTM")})},turnstileBackwardIn:function(a){y("turnstileBackwardIn,StartTM"),a=l(a);var b=x(a);return r(a,b,[{property:z.cssName,delay:n(0,50,1,1e3),duration:300,timing:"cubic-bezier(0.01,0.975,0.4775,0.9775)",from:"perspective(600px) rotateY(-50deg)",to:"perspective(600px) rotateY(0deg)"},{property:"opacity",delay:n(0,50,1,1e3),duration:300,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]).then(function(){y("turnstileBackwardIn,StopTM")})},turnstileBackwardOut:function(a){y("turnstileBackwardOut,StartTM"),a=l(a);var b=x(a);return r(a,b,[{property:z.cssName,delay:n(0,50,1,1e3),duration:128,timing:"cubic-bezier(0.4925,0.01,0.7675,-0.01)",from:"perspective(800px) rotateY(0deg)",to:"perspective(800px) rotateY(80deg)"},{property:"opacity",delay:n(0,50,1,1e3),duration:128,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}]).then(function(){y("turnstileBackwardOut,StopTM")})},slideDown:function(a){return y("slideDown,StartTM"),r(a,{ltr:"",rtl:""},[{property:z.cssName,delay:0,duration:250,timing:"cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",from:"translate(0px, 0px)",to:"translate(0px, 200px)"},{property:"opacity",delay:0,duration:250,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}]).then(function(){y("slideDown,StopTM")})},slideUp:function(a){return y("slideUp,StartTM"),r(a,{ltr:"",rtl:""},[{property:z.cssName,delay:0,duration:350,timing:"cubic-bezier(0.17,0.79,0.215,1.0025)",from:"translate(0px, 200px)",to:"translate(0px, 0px)"},{property:"opacity",delay:n(0,34,1,1e3),duration:350,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]).then(function(){y("slideUp,StopTM")})},slideRightIn:function(a,c,d,e){return y("slideRightIn,StartTM"),q("cubic-bezier(0.17,0.79,0.215,1.0025)",-b.innerWidth,0,!0,a,c,d,e).then(function(){y("slideRightIn,StopTM")})},slideRightOut:function(a,c,d,e){return y("slideRightOut,StartTM"),q("cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",0,b.innerWidth,!1,a,c,d,e).then(function(){y("slideRightOut,StopTM")})},slideLeftIn:function(a,c,d,e){return y("slideLeftIn,StartTM"),q("cubic-bezier(0.17,0.79,0.215,1.0025)",b.innerWidth,0,!0,a,c,d,e).then(function(){y("slideLeftIn,StopTM")})},slideLeftOut:function(a,c,d,e){return y("slideLeftOut,StartTM"),q("cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",0,-b.innerWidth,!1,a,c,d,e).then(function(){y("slideLeftOut,StopTM")})},continuumForwardIn:function(a,b,c){return y("continuumForwardIn,StartTM"),h.join([g.executeTransition(a,[{property:z.cssName,delay:0,duration:350,timing:"cubic-bezier(0.33, 0.18, 0.11, 1)",from:"scale(0.5, 0.5)",to:"scale(1.0, 1.0)"},{property:"opacity",delay:0,duration:350,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]),g.executeTransition(b,[{property:z.cssName,delay:0,duration:350,timing:"cubic-bezier(0.24,1.15,0.11,1.1575)",from:"translate(0px, 225px)",to:"translate(0px, 0px)"},{property:"opacity",delay:0,duration:350,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]),r(c,{ltr:"0px 50%",rtl:"100% 50%"},[{property:z.cssName,delay:0,duration:350,timing:"cubic-bezier(0,0.62,0.8225,0.9625)",from:"rotateX(80deg) scale(1.5, 1.5)",to:"rotateX(0deg) scale(1.0, 1.0)"},{property:"opacity",delay:0,duration:350,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}])]).then(function(){y("continuumForwardIn,StopTM")})},continuumForwardOut:function(a,b){return y("continuumForwardOut,StartTM"),h.join([g.executeTransition(a,[{property:z.cssName,delay:0,duration:120,timing:"cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",from:"scale(1.0, 1.0)",to:"scale(1.1, 1.1)"},{property:"opacity",delay:0,duration:120,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}]),r(b,{ltr:"0px 100%",rtl:"100% 100%"},[{property:z.cssName,delay:0,duration:152,timing:"cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",from:"rotateX(0deg) scale(1.0, 1.0) translate(0px, 0px)",to:"rotateX(80deg) scale(1.5, 1.5) translate(0px, 150px)"},{property:"opacity",delay:0,duration:152,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}])]).then(function(){y("continuumForwardOut,StopTM")})},continuumBackwardIn:function(a,b){return y("continuumBackwardIn,StartTM"),h.join([g.executeTransition(a,[{property:z.cssName,delay:0,duration:200,timing:"cubic-bezier(0.33, 0.18, 0.11, 1)",from:"scale(1.25, 1.25)",to:"scale(1.0, 1.0)"},{property:"opacity",delay:0,duration:200,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}]),r(b,{ltr:"0px 50%",rtl:"100% 50%"},[{property:z.cssName,delay:0,duration:250,timing:"cubic-bezier(0.2975, 0.7325, 0.4725, 0.99)",from:"rotateX(80deg) translate(0px, -100px)",to:"rotateX(0deg) translate(0px, 0px)"},{property:"opacity",delay:0,duration:250,timing:"cubic-bezier(0, 2, 0, 2)",from:0,to:1}])]).then(function(){y("continuumBackwardIn,StopTM")})},continuumBackwardOut:function(a){return y("continuumBackwardOut,StartTM"),g.executeTransition(a,[{property:z.cssName,delay:0,duration:167,timing:"cubic-bezier(0.3825,0.0025,0.8775,-0.1075)",from:"scale(1.0, 1.0)",to:"scale(0.5, 0.5)"},{property:"opacity",delay:0,duration:167,timing:"cubic-bezier(1,-0.42,0.995,-0.425)",from:1,to:0}]).then(function(){y("continuumBackwardOut,StopTM")})},createPageNavigationAnimations:function(b,c,e){function g(){return h.wrap()}var i=f.PageNavigationAnimation;return d.isPhone&&b!==i.enterPage&&c!==i.enterPage?(c||(c=i.turnstile),b===i.slide&&e||c===i.slide&&!e?{exit:e?a.slideDown:g,entrance:e?g:a.slideUp}:{exit:a[c+(e?"Backward":"Forward")+"Out"],entrance:a[c+(e?"Backward":"Forward")+"In"]}):{exit:g,entrance:a.enterPage}}})}),define("WinJS/Binding/_BindingParser",["exports","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../ControlProcessor/_OptionsLexer","../ControlProcessor/_OptionsParser"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a,b){g("WinJS.Binding:bindingParser,StartTM");var c=m.lexer(a),d=new o.BindingInterpreter(c,a,b||{}),e=d.run();return g("WinJS.Binding:bindingParser,StopTM"),e}function k(a){g("WinJS.Binding:bindingParser,StartTM");var b=m.lexer(a),c=new o.BindingParser(b,a),d=c.run();return g("WinJS.Binding:bindingParser,StopTM"),d}var l={get invalidBinding(){return"Invalid binding:'{0}'. Expected to be ':;'. {1}"},get bindingInitializerNotFound(){return"Initializer not found:'{0}'"}},m=b.Namespace.defineWithParent(null,null,{lexer:b.Namespace._lazy(function(){return h._optionsLexer}),tokenType:b.Namespace._lazy(function(){return h._optionsLexer.tokenType})}),n=c.requireSupportedForProcessing,o=b.Namespace.defineWithParent(null,null,{BindingInterpreter:b.Namespace._lazy(function(){return b.Class.derive(i.optionsParser._BaseInterpreter,function(a,b,c){this._initialize(a,b,c)},{_error:function(a){throw new d("WinJS.Binding.ParseError",f._formatString(l.invalidBinding,this._originalSource,a))},_evaluateInitializerName:function(){if(this._current.type===m.tokenType.identifier){var a=this._evaluateIdentifierExpression();return e.log&&!a&&e.log(f._formatString(l.bindingInitializerNotFound,this._originalSource),"winjs binding","error"),n(a)}},_evaluateValue:function(){switch(this._current.type){case m.tokenType.stringLiteral:case m.tokenType.numberLiteral:var a=this._current.value;return this._read(),a;default:return void this._unexpectedToken(m.tokenType.stringLiteral,m.tokenType.numberLiteral)}},_readBindDeclarations:function(){for(var a=[];;)switch(this._current.type){case m.tokenType.identifier:case m.tokenType.thisKeyword:a.push(this._readBindDeclaration());break;case m.tokenType.semicolon:this._read();break;case m.tokenType.eof:return a;default:return void this._unexpectedToken(m.tokenType.identifier,m.tokenType.semicolon,m.tokenType.eof)}},_readBindDeclaration:function(){var a=this._readDestinationPropertyName();this._read(m.tokenType.colon);var b=this._readSourcePropertyName(),c=this._evaluateInitializerName();return{destination:a,source:b,initializer:c}},_readDestinationPropertyName:function(){return this._readIdentifierExpression()},_readSourcePropertyName:function(){return this._readIdentifierExpression()},run:function(){return this._readBindDeclarations()}},{supportedForProcessing:!1})}),BindingParser:b.Namespace._lazy(function(){return b.Class.derive(o.BindingInterpreter,function(a,b){this._initialize(a,b,{})},{_readInitializerName:function(){return this._current.type===m.tokenType.identifier?this._readIdentifierExpression():void 0},_readBindDeclaration:function(){var a=this._readDestinationPropertyName();this._read(m.tokenType.colon);var b=this._readSourcePropertyName(),c=this._readInitializerName();return{destination:a,source:b,initializer:c}}},{supportedForProcessing:!1})})});b.Namespace._moduleDefine(a,"WinJS.Binding",{_bindingParser:j,_bindingParser2:k})}),define("WinJS/Binding/_DomWeakRefTable",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Scheduler"],function(a,b,c,d,e,f){"use strict";function g(){0===n&&(m=0);var a,b,c=Object.keys(p),d=Date.now()-o;for(a=0,b=c.length;b>a;a++){var e=c[a];p[e].time=0;e--){var f=b[d[e]];f.target===a&&(f.promise&&(f.promise.cancel(),f.promise=null),delete b[d[e]],c=!0)}return c},notify:function(a,b,c){var d=this._listeners&&this._listeners[a];if(d){var e=this;e._cancel(a),e._pendingNotifications=e._pendingNotifications||{};var j=e._notifyId++,l=e._pendingNotifications[j]={target:a},m=function(){delete e._pendingNotifications[j]};return l.promise=i.schedulePromiseNormal(null,"WinJS.Binding.observableMixin.notify").then(function(){for(var a=0,e=d.length;e>a&&l.promise;a++)try{d[a](b,c) +}catch(h){f.log&&f.log(g._formatString(k.exceptionFromBindingInitializer,h.toString()),"winjs binding","error")}return m(),b}),l.promise}return h.as()},bind:function(a,b){this._listeners=this._listeners||{};for(var c=this._listeners[a]=this._listeners[a]||[],d=!1,e=0,f=c.length;f>e;e++)if(c[e]===b){d=!0;break}return d||(c.push(b),b(w(this[a]))),this},unbind:function(a,b){if(this._listeners=this._listeners||{},a&&b){var c=this._listeners[a];if(c){for(var d,e=0,f=c.length;f>e;e++)c[e]!==b&&(d=d||[]).push(c[e]);this._listeners[a]=d}}else if(a)this._cancel(a),delete this._listeners[a];else{var g=this;if(g._pendingNotifications){var h=g._pendingNotifications;g._pendingNotifications={},Object.keys(h).forEach(function(a){var b=h[a];b.promise&&b.promise.cancel()})}this._listeners={}}return this}},m={_backingData:null,_initObservable:function(a){this._backingData=a||{}},getProperty:function(a){var b=this._backingData[a];return f.log&&void 0===b&&f.log(g._formatString(k.propertyIsUndefined,a),"winjs binding","warn"),v(b)},setProperty:function(a,b){return this.updateProperty(a,b),this},addProperty:function(a,b){return this[a]||Object.defineProperty(this,a,{get:function(){return this.getProperty(a)},set:function(b){this.setProperty(a,b)},enumerable:!0,configurable:!0}),this.setProperty(a,b)},updateProperty:function(a,b){var c=this._backingData[a],d=w(b);return c!==d&&(this._backingData[a]=d,this._backingData[a]===d)?this.notify(a,d,c):h.as()},removeProperty:function(a){var b,c=this._backingData[a];try{delete this._backingData[a]}catch(d){}try{delete this[a]}catch(d){}return this.notify(a,b,c),this}};Object.keys(l).forEach(function(a){m[a]=l[a]});var n=function(a,b){return r(a,b)},o=0,p=function(){return"bindHandler"+o++},q=function(a,c){if(!b.msGetWeakWinRTProperty)return a;var d=p();return j._getWeakRefElement(c)[d]=a,function(a,b){var e=j._getWeakRefElement(c);e&&e[d](a,b)}},r=function(a,b,c){function d(){h&&h.forEach(function(a){a.source.unbind(a.prop,a.listener)}),h=null}function e(a){g[a]&&(g[a].complexBind.cancel(),delete g[a])}if(a=v(a),!a)return{cancel:function(){},empty:!0};var f;c||(c=p(),f={},j._createWeakRef(f,c));var g={},h=null;return Object.keys(b).forEach(function(d){var i=b[d];if(i instanceof Function)i=q(i,c),i.bindState=f,h=h||[],h.push({source:a,prop:d,listener:i}),a.bind(d,i);else{var j=function(a){e(d);var b=r(v(a),i,c);if(b.empty){var f=function(a){Object.keys(a).forEach(function(b){var c=a[b];c instanceof Function?c(void 0,void 0):f(c)})};f(i)}g[d]={source:a,complexBind:b}};j=q(j,c),j.bindState=f,h=h||[],h.push({source:a,prop:d,listener:j}),a.bind(d,j)}}),{cancel:function(){d(),Object.keys(g).forEach(function(a){e(a)})}}},s=c.Class.mix(function(a){this._initObservable(a),Object.defineProperties(this,t(a))},m),t=function(a){function b(a){c[a]={get:function(){return this.getProperty(a)},set:function(b){this.setProperty(a,b)},enumerable:!0,configurable:!0}}for(var c={};a&&a!==Object.prototype;)Object.keys(a).forEach(b),a=Object.getPrototypeOf(a);return c},u=function(a){if(!(!a||"object"!=typeof a||a instanceof Date||Array.isArray(a)))return c.Class.mix(function(b){this._initObservable(b||Object.create(a))},m,t(a));if(d.validation)throw new e("WinJS.Binding.UnsupportedDataType",g._formatString(k.unsupportedDataTypeForBinding))},v=function(a){if(!a)return a;var b=typeof a;if("object"!==b||a instanceof Date||Array.isArray(a))return a;if(a._getObservable)return a._getObservable();var c=new s(a);return c.backingData=a,Object.defineProperty(a,"_getObservable",{value:function(){return c},enumerable:!1,writable:!1}),c},w=function(a){return a&&a.backingData?a.backingData:a};c.Namespace._moduleDefine(a,"WinJS.Binding",{mixin:{value:m,enumerable:!1,writable:!0,configurable:!0},dynamicObservableMixin:{value:m,enumerable:!0,writable:!0,configurable:!0},observableMixin:{value:l,enumerable:!0,writable:!0,configurable:!0},expandProperties:t,define:u,as:v,unwrap:w,bind:n})}),define("WinJS/Binding/_Declarative",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../Utilities/_ElementUtilities","./_BindingParser","./_Data","./_DomWeakRefTable"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";function o(a,b){var c=a._autoDispose;c&&c.push(b)}function p(a){a._autoDispose=(a._autoDispose||[]).filter(function(a){return a()})}function q(a,b){return a?a.winBindingToken===b?a:void(g.log&&g.log(h._formatString(N.duplicateBindingDetected,a.id),"winjs binding","error")):a}function r(a){if(a.winBindingToken)return a.winBindingToken;var b="_win_bind"+L++;return Object.defineProperty(a,"winBindingToken",{configurable:!1,writable:!1,enumerable:!1,value:b}),b}function s(a,b,c,d,e,f,g){var h=a.initializer;if(h&&(h=h.winControl||h["data-win-control"]||h),h instanceof Function){var i=h(d,a.source,e,a.destination);return g&&(i&&i.cancel?g.bindings.push(function(){i.cancel()}):g.nocache=!0),i}h&&h.render&&(f.count++,g&&(g.nocache=!0),P(h.render).call(h,A(d,a.source),e).then(function(){f.checkComplete()}))}function t(a,b,c,d,e,f){var i,j=!0,k=!1;p(d);var l=function(){if(!k){var c=q(n._getWeakRefElement(a),b);return c||(g.log&&g.log(h._formatString(N.elementNotFound,a),"winjs binding","info"),i&&i.cancel()),c}},m=function(a){var b=l();b&&B(b,e.destination,a),j&&(c.checkComplete(),j=!1)};if(o(d,l),i=H(d,e.source,m)){var r=i.cancel;i.cancel=function(){return k=!0,r.call(i)},f&&f.bindings.push(function(){i.cancel()})}return i}function u(a,c,d,e,f,g,h){var i;return e!==b&&(e=m.as(e)),e._getObservable&&(i=e._getObservable()),i?(g.count++,t(c,d,g,i,a,h)):void B(f,a.destination,A(e,a.source))}function v(a,b){for(var c=a.length-1;c>=0;c--){var d=a[c],i=d.destination;if(1===i.length&&"id"===i[0]){if(e.validation)throw new f("WinJS.Binding.IdBindingNotSupported",h._formatString(N.idBindingNotSupported,b));g.log&&g.log(h._formatString(N.idBindingNotSupported,b),"winjs binding","error"),a.splice(c,1)}}return a}function w(a,c){if(c){var d,e=c.expressions[a];return e||(d=v(l._bindingParser(a,b),a),c.expressions[a]=d),d||(d=e),d}return v(l._bindingParser(a,b),a)}function x(a,c,d,e,f,g){i("WinJS.Binding:processAll,StartTM");var h,j={count:0,checkComplete:function(){this.count--,0===this.count&&(i("WinJS.Binding:processAll,StopTM"),g())}},l=a||b.document.body,m="[data-win-bind],[data-win-control]",o=l.querySelectorAll(m);!d&&l.getAttribute("data-win-bind")&&(h=l),j.count++;var p=c||b;n._DOMWeakRefTable_fastLoadPath=!0;try{var q=k.data(l);q.winBindings=q.winBindings||[];for(var t=h?-1:0,v=o.length;v>t;t++){var x=0>t?h:o[t];if(x.winControl&&x.winControl.constructor&&x.winControl.constructor.isDeclarativeControlContainer){t+=x.querySelectorAll(m).length;var z=x.winControl.constructor.isDeclarativeControlContainer;"function"==typeof z&&(z=P(z))(x.winControl,function(a){return y(a,c,!1,e,f)})}if(x.hasAttribute("data-win-bind")){var A=x.getAttribute("data-win-bind"),B=w(A,e);if(!B.implemented){for(var C=0,D=B.length;D>C;C++){var E=B[C];E.initializer=E.initializer||f,E.implementation=E.initializer?s:u}B.implemented=!0}j.count++;var F=r(x),G=M?F:x.id;G||(x.id=G=F),n._createWeakRef(x,G);var H=k.data(x);H.winBindings=null;var I;e&&e.elements&&(I=e.elements[G],I||(e.elements[G]=I={bindings:[]}));for(var J=0,K=B.length;K>J;J++){var L=B[J],N=L.implementation(L,G,F,p,x,j,I);N&&(H.winBindings=H.winBindings||[],H.winBindings.push(N),q.winBindings.push(N))}j.count--}}}finally{n._DOMWeakRefTable_fastLoadPath=!1}j.checkComplete()}function y(a,b,c,d,e){return new j(function(f,g,h){x(a,b,c,d,e,f,g,h)}).then(null,function(a){return g.log&&g.log(h._formatString(N.errorInitializingBindings,a&&a.message),"winjs binding","error"),j.wrapError(a)})}function z(a){var c=function(c,d,e,f,i){var j=r(e),k=M?j:e.id;k||(e.id=k=j),n._createWeakRef(e,k);var l;if(c!==b&&(c=m.as(c)),c._getObservable&&(l=c._getObservable()),l){var o=0,p=H(m.as(c),d,function(b){if(1!==++o||b!==i){var c=q(n._getWeakRefElement(k),j);c?B(c,f,a(P(b))):p&&(g.log&&g.log(h._formatString(N.elementNotFound,k),"winjs binding","info"),p.cancel())}});return p}var s=A(c,d);s!==i&&B(e,f,a(s))};return O(c)}function A(a,c){if(a!==b&&(a=P(a)),c)for(var d=0,e=c.length;e>d&&null!==a&&void 0!==a;d++)a=P(a[c[d]]);return a}function B(a,c,d){P(d),a=P(a);for(var e=0,f=c.length-1;f>e;e++){if(a=P(a[c[e]]),!a)return void(g.log&&g.log(h._formatString(N.propertyDoesNotExist,c[e],c.join(".")),"winjs binding","error"));if(a instanceof b.Node)return void(g.log&&g.log(h._formatString(N.nestedDOMElementBindingNotSupported,c[e],c.join(".")),"winjs binding","error"))}if(0===c.length)return void(g.log&&g.log(N.cannotBindToThis,"winjs binding","error"));var i=c[c.length-1];g.log&&void 0===a[i]&&g.log(h._formatString(N.creatingNewProperty,i,c.join(".")),"winjs binding","warn"),a[i]=d}function C(a,b,c){return a=P(a),b&&1===b.length&&b[0]?void a.setAttribute(b[0],c):void(g.log&&g.log(N.attributeBindingSingleProperty,"winjs binding","error"))}function D(a,c,d,e,f){var i=r(d),j=M?i:d.id;j||(d.id=j=i),n._createWeakRef(d,j);var k;if(a!==b&&(a=m.as(a)),a._getObservable&&(k=a._getObservable()),k){var l=0,o=H(k,c,function(a){if(1!==++l||a!==f){var b=q(n._getWeakRefElement(j),i);b?C(b,e,P(a)):o&&(g.log&&g.log(h._formatString(N.elementNotFound,j),"winjs binding","info"),o.cancel())}});return o}var p=A(a,c);p!==f&&C(d,e,p)}function E(a,b,c,d){return C(c,d,A(a,b))}function F(a,b,c){c=P(c);var d=A(a,b);Array.isArray(d)?d.forEach(function(a){k.addClass(c,a)}):d&&k.addClass(c,d)}function G(a,b,c,d,e){return Q(a,b,c,d,e)}function H(a,b,c){if(b.length>1){for(var d={},e=d,f=0,g=b.length-1;g>f;f++)e=e[b[f]]={};return e[b[b.length-1]]=c,m.bind(a,d,!0)}return 1===b.length?(a.bind(b[0],c,!0),{cancel:function(){a.unbind(b[0],c),this.cancel=I}}):void c(a)}function I(){}function J(a,b,c,d){return B(c,d,A(a,b)),{cancel:I}}function K(a){return O(a)}var L=1e3*Math.random()>>0,M=c.msSetWeakWinRTProperty&&c.msGetWeakWinRTProperty,N={get attributeBindingSingleProperty(){return'Attribute binding requires a single destination attribute name, often in the form "this[\'aria-label\']" or "width".'},get cannotBindToThis(){return"Can't bind to 'this'."},get creatingNewProperty(){return"Creating new property {0}. Full path:{1}"},get duplicateBindingDetected(){return"Binding against element with id {0} failed because a duplicate id was detected."},get elementNotFound(){return"Element not found:{0}"},get errorInitializingBindings(){return"Error initializing bindings: {0}"},get propertyDoesNotExist(){return"{0} doesn't exist. Full path:{1}"},get idBindingNotSupported(){return"Declarative binding to ID field is not supported. Initializer: {0}"},get nestedDOMElementBindingNotSupported(){return"Binding through a property {0} of type HTMLElement is not supported, Full path:{1}."}},O=e.markSupportedForProcessing,P=e.requireSupportedForProcessing,Q=z(function(a){return a});d.Namespace._moduleDefine(a,"WinJS.Binding",{processAll:y,oneTime:K(J),defaultBind:K(G),converter:z,initializer:K,getValue:A,setAttribute:K(D),setAttributeOneTime:K(E),addClassOneTime:K(F)})}),define("WinJS/Binding",["./Binding/_BindingParser","./Binding/_Data","./Binding/_Declarative","./Binding/_DomWeakRefTable"],function(){}),define("WinJS/BindingTemplate/_DataTemplateCompiler",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Binding/_BindingParser","../Binding/_Declarative","../ControlProcessor","../ControlProcessor/_OptionsParser","../Fragments","../Promise","../_Signal","../Utilities/_Dispose","../Utilities/_SafeHtml","../Utilities/_ElementUtilities"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){"use strict";if(b.document){var s={get attributeBindingSingleProperty(){return'Attribute binding requires a single destination attribute name, often in the form "this[\'aria-label\']" or "width".'},get cannotBindToThis(){return"Can't bind to 'this'."},get idBindingNotSupported(){return"Declarative binding to ID field is not supported. Initializer: {0}"}};c.Namespace._moduleDefine(a,"WinJS.Binding",{_TemplateCompiler:c.Namespace._lazy(function(){function a(a,b,c){var d=r.data(a).bindTokens;d&&d.forEach(function(a){a&&a.cancel&&a.cancel()}),b&&b.cancel(),c&&c.cancel()}function t(a,b){return function(c){return j.processAll(c,a,!1,null,b)}}function u(a){return a=Z(a),a instanceof b.Node?null:a}function v(a,b){var c=-1!==a.indexOf("\n"),d=arguments,f=a.replace(nb,function(f,g,h,i,j,k,l){if(j||k)throw new e("Format:MalformedInputString","Did you forget to escape a: "+(j||k)+" at: "+l);if(g)return"{";if(h)return"}";var m,n=+i;if(m=n===+n?d[n+1]:b[i],void 0===m)throw new e("Format:MissingPart","Missing part '"+i+"'");if(c){for(var o=l;o>0&&" "===a[--o];);o>=0&&"\n"===a[o]&&(m=w(l-o-1,m))}return m});return f}function w(a,b){for(var c="",d=0;a>d;d++)c+=" ";return b.split("\n").map(function(a,b){return b?c+a:a}).join("\n")}function x(a){return a.trim()}function y(a){return a.join(";\n")}function z(a){return a.join(", ")||"empty"}function A(a){return a.map(function(a){return a.match(jb)?"."+a:+a===a?v("[{0}]",a):v("[{0}]",C(a))}).join("")}function B(a,b,c,d){var b=b.map(function(a){return a.match(jb)?"."+a:(+a===a&&(a=+a),G(C(a)))}).map(function(a){return v("{filter}({temp} = {temp}{part})",{filter:d,temp:c,part:a})});return b.unshift(F(E(c,a))),b.push(c),F(b.join(" && "))}function C(a){return JSON.stringify(a)}function D(a){return a?"new Array("+ +a+")":"[]"}function E(a,b){return""+a+" = "+b}function F(a){return"("+a+")"}function G(a){return"["+a+"]"}function H(a){return a.match(jb)?a:+a===a?+a:C(a)}function I(a){return a=""+a,a.replace(lb,function(a){return mb[a]||" "})}function J(a,b,c){return new String(c?""+a+b+"_"+c:""+a+b)}function K(a){return a.replace(/\\n/g,"\\n\\\n")}function L(a){return Object.keys(a)}function M(a){return Object.keys(a).map(function(b){return a[b]})}function N(a,b){return O([a,b])}function O(a){for(var b={},c=0,d=a.length;d>c;c++)for(var e=a[c],f=Object.keys(e),g=0,h=f.length;h>g;g++){var i=f[g];b[i]=e[i]}return b}function P(a){return a.reduce(function(a,b){return a?Z(a[b]):null},b)}function Q(a,b,c,d){var e=a.children;if(e){var f=Object.keys(e);b&&c&&c(a,b,f.length);for(var g=0,h=f.length;h>g;g++){var i=f[g],j=e[i];Q(j,i,c,d)}b&&d&&d(a,b,Object.keys(e).length)}else b&&c&&c(a,b,0),b&&d&&d(a,b,0)}function R(a){return a.replace(/^\s*$/gm,"").replace(/^(.*[^\s])( *)$/gm,function(a,b){return b})}var S=n._cancelBlocker,T=j.defaultBind,U=j.oneTime,V=j.setAttribute,W=j.setAttributeOneTime,X=j.addClassOneTime,Y=n.as,Z=d.requireSupportedForProcessing,$=q.insertAdjacentHTMLUnsafe,_=r.data,ab=p.markDisposable,bb=k.processAll,cb=j.processAll,db=l._optionsParser,eb=l._CallExpression,fb=l._IdentifierExpression,gb=i._bindingParser2,hb=k.scopedSelect,ib=h,jb=/^[A-Za-z]\w*$/,kb=/[^A-Za-z\w$]/g,lb=/[&<>'"]/g,mb={"&":"&","<":"<",">":">","'":"'",'"':"""},nb=/({{)|(}})|{(\w+)}|({)|(})/g,ob=/^\s*;\s*$/,pb=/[A-Z]/g,qb=c.Class.define(function(a,b,c,d,e){var f=this;this.compiler=a,this.kind=c,this.base=new String(b),this.tree={children:{},parent:this.base,reference:function(){return f.base}},this.accessExpression=d,this.filter=e||""},{createPathExpression:function(a,b){if(a.length){var c=this,d=a.reduce(function(a,b){return a.children=a.children||{},a.children[b]=a.children[b]||{parent:a},a.children[b]},this.tree);return d.name=d.name||c.compiler.defineInstance(c.kind,b||"",function(){return c.accessExpression(d.parent.name?d.parent.name:d.parent.reference(),a.slice(-1)[0],d.parent.parent===c.base,c.filter,!0)}),d.name}return this.base},lower:function(){var a=this,b=[],c=function(b,c,d){return a.accessExpression(b.parent.name?b.parent.name:b.parent.reference(),c,b.parent.parent===a.base,a.filter,d)};Q(this.tree,"",function(d,e,f){b.push(e),f>1?(d.name=d.name||a.compiler.defineInstance(a.kind,b.join("_"),c.bind(null,d,e,!0)),d.reference=function(){return d.name}):1===f&&(d.reference=c.bind(null,d,e))},function(){b.pop()})},deadNodeElimination:function(){Q(this.tree,"",null,function(a,b,c){(!a.name||a.name.dead)&&0===c&&a.parent&&a.parent.children&&delete a.parent.children[b]})},definitions:function(){var a=[];return Q(this.tree,"",function(b){b.name&&a.push(b)}),a.map(function(a){return a.name.definition()})}}),rb={capture:"capture",temporary:"temporary",variable:"variable",data:"data",global:"global"},sb={capture:"c",temporary:"t",variable:"iv",data:"d",global:"g"},tb={"import":"import",variable:"variable"},ub={"import":"i",variable:"sv"},vb={tree:"tree",text:"text",initializer:"initializer",template:"template",error:"error"},wb={attribute:"attribute",booleanAttribute:"booleanAttribute",inlineStyle:"inlineStyle",textContent:"textContent"},xb="imports",yb={initial:0,analyze:1,optimze:2,lower:3,compile:4,link:5,done:6},zb=c.Class.define(function(a,c){if(this._stage=yb.initial,this._staticVariables={},this._staticVariablesCount=0,this._instanceVariables={},this._instanceVariablesCount={},this._debugBreak=c.debugBreakOnRender,this._defaultInitializer=Z(c.defaultInitializer||T),this._optimizeTextBindings=!c.disableTextBindingOptimization,this._templateElement=a,this._templateContent=b.document.createElement(a.tagName),this._extractChild=c.extractChild||!1,this._controls=null,this._bindings=null,this._bindTokens=null,this._textBindingPrefix=null,this._textBindingId=0,this._suffix=[],this._htmlProcessors=[],this._profilerMarkIdentifier=c.profilerMarkIdentifier,this._captureCSE=new qb(this,"container",rb.capture,this.generateElementCaptureAccess.bind(this)),this._dataCSE=new qb(this,"data",rb.data,this.generateNormalAccess.bind(this),this.importSafe("dataSecurityCheck",Z)),this._globalCSE=new qb(this,this.importSafe("global",b),rb.global,this.generateNormalAccess.bind(this),this.importSafe("globalSecurityCheck",Z)),m.renderCopy(this._templateElement,this._templateContent),this._extractChild)for(;this._templateContent.childElementCount>1;)this._templateContent.removeChild(this._templateContent.lastElementChild)},{addClassOneTimeTextBinding:function(a){var b=this,c=this.createTextBindingHole(a.elementCapture.element.tagName,"class",++this._textBindingId);a.textBindingId=c,a.kind=vb.text,a.elementCapture.element.classList.add(c),a.elementCapture.refCount--,a.definition=function(){return b.formatCode("{htmlEscape}({value})",{htmlEscape:b._staticVariables.htmlEscape,value:a.value()})}},addClassOneTimeTreeBinding:function(a){var b=this;a.pathExpression=this.bindingExpression(a),a.value=function(){return a.pathExpression},a.kind=vb.tree,a.definition=function(){return b.formatCode("{element}.classList.add({value})",{element:a.elementCapture,value:a.value()})}},analyze:function(){if(this._stage>yb.analyze)throw"Illegal: once we have moved past analyze we cannot revist it";this._stage=yb.analyze,this._controls=this.gatherControls(),this._bindings=this.gatherBindings(),this._children=this.gatherChildren(),this.cleanControlAndBindingAttributes(),this.async&&this.createAsyncParts(),this.nullableIdentifierAccessTemporary=this.defineInstance(rb.temporary);var a=this._templateContent.innerHTML;this._html=function(){return K(C(a))},this._html.text=a},bindingExpression:function(a){return this._dataCSE.createPathExpression(a.source,a.source.join("_"))},capture:function(a){var b=a._capture;if(b)return b.refCount++,b;for(var c=[a],d=a.parentNode,e=a.tagName;d!==this._templateContent;)e=d.tagName+"_"+e,c.unshift(d),d=d.parentNode;for(var f=0,g=c.length;g>f;f++){var h=c[f];c[f]=Array.prototype.indexOf.call(d.children,h),d=h}return b=this._captureCSE.createPathExpression(c,e.toLowerCase()),b.element=a,b.element._capture=b,b.refCount=1,b},cleanControlAndBindingAttributes:function(){for(var a="[data-win-bind],[data-win-control]",b=this._templateContent.querySelectorAll(a),c=0,d=b.length;d>c;c++){var e=b[c];e.isDeclarativeControlContainer&&(c+=e.querySelectorAll("[data-win-bind],[data-win-control]").length),e.removeAttribute("data-win-bind"),e.removeAttribute("data-win-control"),e.removeAttribute("data-win-options")}},compile:function(a,b,c){if(this._stage>yb.compile)throw"Illegal: once we have moved past compile we cannot revist it";this._stage=yb.compile;var d=this;this._returnedElement=this._extractChild?"container.firstElementChild":"container";var e,f,g=this._controls.map(function(a){var b;b=a.async?"{target}.winControl = {target}.winControl || new {SafeConstructor}({target}, {options}, controlDone)":"{target}.winControl = {target}.winControl || new {SafeConstructor}({target}, {options})";var c=d.formatCode(b,{target:a.elementCapture,SafeConstructor:a.SafeConstructor,options:d.generateOptionsLiteral(a.optionsParsed,a.elementCapture)});if(a.isDeclarativeControlContainer&&"function"==typeof a.isDeclarativeControlContainer.import){var e=[c];return e.push(d.formatCode("{isDeclarativeControlContainer}({target}.winControl, {delayedControlProcessing})",{target:a.elementCapture,isDeclarativeControlContainer:a.isDeclarativeControlContainer,delayedControlProcessing:d._staticVariables.ui_processAll})),e.push(d.formatCode("{isDeclarativeControlContainer}({target}.winControl, {delayedBindingProcessing}(data, {templateDefaultInitializer}))",{target:a.elementCapture,isDeclarativeControlContainer:a.isDeclarativeControlContainer,delayedBindingProcessing:d._staticVariables.delayedBindingProcessing,templateDefaultInitializer:d._staticVariables.templateDefaultInitializer||C(null)})),e.join(";\n")}return c}),h=this._bindings.map(function(a){switch(a.kind){case vb.template:return d.formatCode("({nestedTemplates}[{nestedTemplate}] = {template}.render({path}, {dest}))",{nestedTemplates:d._nestedTemplates,nestedTemplate:C(a.nestedTemplate),template:a.template,path:a.pathExpression,dest:a.elementCapture});case vb.initializer:var b;return b=a.initialValue?"({bindTokens}[{bindToken}] = {initializer}(data, {sourceProperties}, {dest}, {destProperties}, {initialValue}))":"({bindTokens}[{bindToken}] = {initializer}(data, {sourceProperties}, {dest}, {destProperties}))",d.formatCode(b,{bindTokens:d._bindTokens,bindToken:C(a.bindToken),initializer:a.initializer,sourceProperties:C(a.source),destProperties:C(a.destination),dest:a.elementCapture,initialValue:a.initialValue});case vb.tree:return a.definition();case vb.text:break;case vb.error:break;default:throw"NYI"}});c?(e=h.filter(function(a,b){return!d._bindings[b].delayable}),f=h.filter(function(a,b){return d._bindings[b].delayable})):(e=h,f=[]);var i=M(this._instanceVariables),j=i.filter(function(a){return a.kind===rb.variable}).map(function(a){return a.definition()}),k=this._captureCSE.definitions(),l=this._globalCSE.definitions(),m=this._dataCSE.definitions(),n=this._children.map(function(a){return d.formatCodeN("{0}.msParentSelectorScope = true",a)}),o=this._suffix.map(function(a){return a()}),p="";c&&f.length&&(p=d.formatCode(Ib,{delayed_binding_processing:y(f)}));var q=d.formatCode(a,O([this._staticVariables,b||{},{profilerMarkIdentifierStart:C("WinJS.Binding.Template:render"+this._profilerMarkIdentifier+",StartTM"),profilerMarkIdentifierStop:C("WinJS.Binding.Template:render"+this._profilerMarkIdentifier+",StopTM"),html:this._html(),tagName:C(this._templateElement.tagName),instance_variable_declarations:z(i),global_definitions:y(l),data_definitions:y(m),instance_variable_definitions:y(j),capture_definitions:y(k),set_msParentSelectorScope:y(n),debug_break:this.generateDebugBreak(),control_processing:y(g),control_counter:this._controlCounter,binding_processing:y(e),renderComplete:p,suffix_statements:y(o),nestedTemplates:this._nestedTemplates,returnedElement:this._returnedElement}]));return this.prettify(q)},createAsyncParts:function(){this._nestedTemplates=this._nestedTemplates||this.defineInstance(rb.variable,"nestedTemplates",function(){return D(0)}),this._controlCounter=this._controlCounter||this.defineInstance(rb.variable,"controlCounter",function(){return C(1)})},createTextBindingHole:function(a,b,c){if(!this._textBindingPrefix){for(var d="";-1!==this._html.text.indexOf("textbinding"+d);)d=d||0,d++;this._textBindingPrefix="textbinding"+d,this._textBindingRegex=new RegExp("(#?"+this._textBindingPrefix+"_\\d+)")}var e=this._textBindingPrefix+"_"+c;return"IMG"===a&&"src"===b&&(e="#"+e),e},deadCodeElimination:function(){var a=this;Object.keys(this._instanceVariables).forEach(function(b){var c=a._instanceVariables[b];c.kind===rb.capture&&(a._templateContent.contains(c.element)||(c.dead=!0),0===c.refCount&&(c.dead=!0),c.dead&&(c.definition=function(){},c.name=null,delete a._instanceVariables[b]))}),this._controls=this._controls.filter(function(a){return!a.elementCapture.dead}),this._bindings=this._bindings.filter(function(a){return!a.elementCapture.dead}),this._captureCSE.deadNodeElimination()},defineInstance:function(a,b,c){if(this._stage>=yb.compile)throw"Illegal: define instance variable after compilation stage has started";var d=this._instanceVariablesCount[a]||0,e=b?b.replace(kb,"_"):"",f=J(sb[a],d,e);return f.definition=function(){return E(f,c())},f.kind=a,this._instanceVariables[f]=f,this._instanceVariablesCount[a]=d+1,f},defineStatic:function(a,b,c){if(this._stage>=yb.link)throw"Illegal: define static variable after link stage has started";if(b){var d=this._staticVariables[b];if(d)return d}var e=b?b.replace(kb,"_"):"",f=J(ub[a],this._staticVariablesCount,e);return f.definition=function(){return E(f,c())},f.kind=a,this._staticVariables[b||f]=f,this._staticVariablesCount++,f},done:function(){if(this._stage>yb.done)throw"Illegal: once we have moved past done we cannot revist it";this._stage=yb.done},emitScopedSelect:function(a,b){return this.formatCode("{scopedSelect}({selector}, {element})",{scopedSelect:this._staticVariables.scopedSelect,selector:C(a),element:b})},emitOptionsNode:function(a,b,c){var d=this;if(a)switch(typeof a){case"object":if(Array.isArray(a)){b.push("[");for(var e=0,f=a.length;f>e;e++)this.emitOptionsNode(a[e],b,c),b.push(",");b.push("]")}else if(a instanceof eb)b.push("select"===a.target?this.emitScopedSelect(a.arg0Value,c):C(null));else if(a instanceof fb&&a.parts[0]instanceof eb){var g=a.parts[0];b.push(B("select"===g.target?this.emitScopedSelect(g.arg0Value,c):C(null),a.parts.slice(1),this.nullableIdentifierAccessTemporary,this.importSafe("requireSupportedForProcessing",Z)))}else a instanceof fb?b.push(a.pathExpression):(b.push("{"),Object.keys(a).forEach(function(e){b.push(H(e)),b.push(":"),d.emitOptionsNode(a[e],b,c),b.push(",")}),b.push("}"));break;default:b.push(C(a))}else b.push(C(null))},findGlobalIdentifierExpressions:function(a,b){b=b||[];var c=this;return Object.keys(a).forEach(function(d){var e=a[d];"object"==typeof e&&(e instanceof fb?e.parts[0]instanceof eb||b.push(e):c.findGlobalIdentifierExpressions(e,b))}),b},formatCodeN:function(){if(this._stageh;h++){var j=g[h];if(j.isDeclarativeControlContainer&&(h+=j.querySelectorAll(f).length),j.hasAttribute("data-win-bind")){var k=j.getAttribute("data-win-bind"),l=gb(k,b);l.forEach(function(b){if(b.initializer){var e=b.initializer.join("."),f=P(b.initializer);f.render?(Z(f.render),b.template=c.importSafe(e,f),b.pathExpression=c.bindingExpression(b),b.nestedTemplate=++d,b.kind=vb.template):f.winControl&&f.winControl.render?(Z(f.winControl.render),b.template=c.importSafe(e,f.winControl),b.pathExpression=c.bindingExpression(b),b.nestedTemplate=++d,b.kind=vb.template):(b.initializer=c.import(e,f),b.bindToken=++a,b.kind=vb.initializer)}else b.initializer=c.importSafe("templateDefaultInitializer",c._defaultInitializer),b.bindToken=++a,b.kind=vb.initializer;b.elementCapture=c.capture(j),b.bindingText=k}),e.push.apply(e,l)}}var m=d+1;m>0&&(this.async=!0,this._nestedTemplates=this.defineInstance(rb.variable,"nestedTemplates",function(){return D(m)}));var n=a+1;return n>0&&(this._bindTokens=this.defineInstance(rb.variable,"bindTokens",function(){return D(n)}),this._suffix.push(function(){return c.formatCode("{utilities_data}(returnedElement).bindTokens = {bindTokens}",{utilities_data:c._staticVariables.utilities_data,bindTokens:c._bindTokens})})),e},gatherChildren:function(){var a=this;return Array.prototype.map.call(this._templateContent.children,function(b){return a.capture(b)})},gatherControls:function(){for(var a=this,c=0,e=[],f="[data-win-control]",g=this._templateContent.querySelectorAll(f),h=0,i=g.length;i>h;h++){var j=g[h],k=j.getAttribute("data-win-control"),l=d._getMemberFiltered(k.trim(),b,Z);if(l){var m=j.getAttribute("data-win-options")||C({}),n=l.length>2;n&&(c++,this.async=!0);var o=l.isDeclarativeControlContainer;o&&("function"==typeof o&&(o=this.import(k+"_isDeclarativeControlContainer",o)),j.isDeclarativeControlContainer=o,h+=j.querySelectorAll(f).length);var p={elementCapture:this.capture(j),name:k,SafeConstructor:this.importSafe(k,l),async:n,optionsText:C(m),optionsParsed:db(m),isDeclarativeControlContainer:o};e.push(p);var q=this.findGlobalIdentifierExpressions(p.optionsParsed);q.forEach(function(b){b.pathExpression=a.globalExpression(b.parts)})}}return c>0&&(this._controlCounter=this.defineInstance(rb.variable,"controlCounter",function(){return C(c+1)})),e},generateElementCaptureAccess:function(a,b,c){if(c){var d=""+b=="0"?"":" + "+b;return this.formatCodeN("{0}.children[startIndex{1}]",a,d)}return this.formatCodeN("{0}.children[{1}]",a,b)},generateNormalAccess:function(a,b,c,d,e){if(a.indexOf(this.nullableIdentifierAccessTemporary)>=0){var f;return f=e?"{left} && {filter}({temp}{right})":"{left} && ({temp} = {filter}({temp}{right}))",this.formatCode(f,{temp:this.nullableIdentifierAccessTemporary,left:a,right:A([b]),filter:d})}var f;return f=e?"({temp} = {left}) && {filter}({temp}{right})":"({temp} = {left}) && ({temp} = {filter}({temp}{right}))",this.formatCode(f,{temp:this.nullableIdentifierAccessTemporary,left:a,right:A([b]),filter:d})},generateOptionsLiteral:function(a,b){var c=[];return this.emitOptionsNode(a,c,b),c.join(" ")},generateDebugBreak:function(){if(this._debugBreak){var a=this.defineStatic(tb.variable,"debugCounter",function(){return C(0)});return this.formatCodeN("if (++{0} === 1) {{ debugger; }}",a)}return""},globalExpression:function(a){return this._globalCSE.createPathExpression(a,a.join("_"))},"import":function(a,b){return this.importSafe(a,Z(b))},importSafe:function(a,b){var c=this,d=this.defineStatic(tb.import,a,function(){return c.formatCodeN("({0}{1})",xb,A([a]))});if(d.import&&d.import!==b)throw"Duplicate import: '"+a+"'";return d.import=b,d},importAll:function(a){return Object.keys(a).forEach(function(b){Z(a[b])}),this.importAllSafe(a)},importAllSafe:function(a){var b=this,c=Object.keys(a).reduce(function(c,d){return c[d]=b.importSafe(d,a[d]),c},{});return c},link:function(a){if(this._stage>yb.link)throw"Illegal: once we have moved past link we cannot revist it";this._stage=yb.link;var b=this,c=L(this._staticVariables).filter(function(a){return b._staticVariables[a].kind===tb.import}).reduce(function(a,c){return a[c]=b._staticVariables[c].import,a},{}),d=M(this._staticVariables);return new Function(xb,this.formatCode(Kb,{static_variable_declarations:z(d),static_variable_definitions:y(d.map(function(a){return a.definition()})),body:a.trim()}))(c)},lower:function(){if(this._stage>yb.lower)throw"Illegal: once we have moved past lower we cannot revist it";this._stage=yb.lower,this._captureCSE.lower(),this._dataCSE.lower(),this._globalCSE.lower()},markBindingAsError:function(a){a&&(a.kind=vb.error,this.markBindingAsError(a.original))},oneTimeTextBinding:function(a){var b=this,c=this.oneTimeTextBindingAnalyze(a);if(c){var d;a.original&&(d=a.original.initialValue); +var e=this.createTextBindingHole(a.elementCapture.element.tagName,c.attribute,++this._textBindingId);switch(a.textBindingId=e,a.kind=vb.text,a.elementCapture.refCount--,a.definition=function(){var c;return c=d?"{htmlEscape}({initialValue})":"{htmlEscape}({getter})",b.formatCode(c,{htmlEscape:b._staticVariables.htmlEscape,getter:a.value(),initialValue:d})},c.kind){case wb.attribute:a.elementCapture.element.setAttribute(c.attribute,e);break;case wb.booleanAttribute:a.elementCapture.element.setAttribute(c.attribute,e),a.definition=function(){var e;return e=d?'({initialValue} ? {attribute} : "")':'({value} ? {attribute} : "")',b.formatCode(e,{value:a.value(),attribute:C(c.attribute),initialValue:d})},this._htmlProcessors.push(function(a){return a.replace(new RegExp(c.attribute+'="'+e+'"',"i"),e)});break;case wb.textContent:a.elementCapture.element.textContent=e;break;case wb.inlineStyle:var f=a.elementCapture.element;if(!f.msReplaceStyle){f.msReplaceStyle=f.getAttribute("style")||"",""!==f.msReplaceStyle&&";"!==f.msReplaceStyle[f.msReplaceStyle.length-1]&&(f.msReplaceStyle=f.msReplaceStyle+";"),f.setAttribute("style","msReplaceStyle:'"+e+"'");var g=f.getAttribute("style");this._htmlProcessors.push(function(a){return a.replace(g,f.msReplaceStyle)})}f.msReplaceStyle=f.msReplaceStyle+c.property+":"+e+";";break;default:throw"NYI"}}},oneTimeTextBindingAnalyze:function(a){var b=a.elementCapture.element,c=b.tagName,d=a.destination[0];switch(c){case"A":switch(d){case"href":return{kind:wb.attribute,attribute:d}}break;case"IMG":switch(d){case"alt":case"src":case"width":case"height":return{kind:wb.attribute,attribute:d}}break;case"SELECT":switch(d){case"disabled":case"multiple":case"required":return{kind:wb.booleanAttribute,attribute:d};case"size":return{kind:wb.attribute,attribute:d}}break;case"OPTION":switch(d){case"label":case"value":return{kind:wb.attribute,attribute:d};case"disabled":case"selected":return{kind:wb.booleanAttribute,attribute:d}}break;case"INPUT":switch(d){case"checked":switch(b.type){case"checkbox":case"radio":return{kind:wb.booleanAttribute,attribute:d}}break;case"disabled":return{kind:wb.booleanAttribute,attribute:d};case"max":case"maxLength":case"min":case"step":case"value":return{kind:wb.attribute,attribute:d};case"size":switch(b.type){case"text":case"search":case"tel":case"url":case"email":case"password":return{kind:wb.attribute,attribute:d}}break;case"readOnly":switch(b.type){case"hidden":case"range":case"color":case"checkbox":case"radio":case"file":case"button":break;default:return{kind:wb.booleanAttribute,attribute:d}}}break;case"BUTTON":switch(d){case"disabled":return{kind:wb.booleanAttribute,attribute:d};case"value":return{kind:wb.attribute,attribute:d}}break;case"TEXTAREA":switch(d){case"disabled":case"readOnly":case"required":return{kind:wb.booleanAttribute,attribute:d};case"cols":case"maxLength":case"placeholder":case"rows":case"wrap":return{kind:wb.attribute,attribute:d}}}switch(d){case"className":return{kind:wb.attribute,attribute:"class"};case"dir":case"lang":case"name":case"title":case"tabIndex":return{kind:wb.attribute,attribute:d};case"style":if(a.destination.length>1){var e=a.destination[1];if("cssText"===e)return;var f="string"==typeof b.style[e];if(f)return("m"===e[0]&&"s"===e[1]||"webkit"===e.substring(0,6))&&(e="-"+e),e=e.replace(pb,function(a){return"-"+a.toLowerCase()}),{kind:wb.inlineStyle,property:e,attribute:"style"}}break;case"innerText":case"textContent":return{kind:wb.textContent,attribute:"textContent"}}},oneTimeTreeBinding:function(a){if(1===a.destination.length&&"id"===a.destination[0]){if(d.validation)throw new e("WinJS.Binding.IdBindingNotSupported",g._formatString(s.idBindingNotSupported,a.bindingText));return f.log&&f.log(g._formatString(s.idBindingNotSupported,a.bindingText),"winjs binding","error"),void this.markBindingAsError(a)}if(0===a.destination.length)return f.log&&f.log(s.cannotBindToThis,"winjs binding","error"),void this.markBindingAsError(a);var b,c=this;a.pathExpression=this.bindingExpression(a),a.value=function(){return a.pathExpression},a.original&&(b=a.pathExpression,a.original.initialValue=b),a.kind=vb.tree,a.definition=function(){var d;return d=b?"({targetPath} || {{}}){prop} = {initialValue}":"({targetPath} || {{}}){prop} = {sourcePath}",c.formatCode(d,{targetPath:B(a.elementCapture,a.destination.slice(0,-1),c.nullableIdentifierAccessTemporary,c.importSafe("targetSecurityCheck",u)),prop:A(a.destination.slice(-1)),sourcePath:a.value(),initialValue:b})}},optimize:function(){if(this._stage>yb.optimze)throw"Illegal: once we have moved past link we cannot revist it";this._stage=yb.optimze;for(var a=0;ag;g++)e.push(d[g]);b=function(a,b,c,d){var f=[];return e.forEach(function(e){f.push(a(e,b,c,d))}),l.join(f)}}}for(var m=i.firstElementChild;m;)m.msParentSelectorScope=!0,m=m.nextElementSibling;var n=s.processTimeout;return n?(0>n&&(n=0),l.timeout(n).then(function(){return f=a()})):f=a()}).then(e,function(a){return e(),l.wrapError(a)});return{element:q,renderComplete:v}}var p=d.Class.define(function(a,c){this._element=a||b.document.createElement("div"),this._element.winControl=this,this._profilerMarkIdentifier=e._getProfilerMarkIdentifier(this._element),g("WinJS.Binding:newTemplate"+this._profilerMarkIdentifier+",StartTM");var d=this;this._element.renderItem=function(a,b){return d._renderItemImpl(a,b)},c=c||{},this.href=c.href,this.enableRecycling=!!c.enableRecycling,this.processTimeout=c.processTimeout||0,this.bindingInitializer=c.bindingInitializer,this.debugBreakOnRender=c.debugBreakOnRender,this.disableOptimizedProcessing=c.disableOptimizedProcessing,this.extractChild=c.extractChild,this._counter=0,this._compile=!!c._compile,this.href||(this.element.style.display="none"),this.bindingCache={expressions:{}},g("WinJS.Binding:newTemplate"+this._profilerMarkIdentifier+",StopTM")},{_shouldCompile:{get:function(){var a=!0;return a=a&&!p._interpretAll,a=a&&!this.disableOptimizedProcessing,a&&(a=a&&0===this.processTimeout,a=a&&(!this.href||this.href instanceof b.HTMLElement),a||f.log&&f.log("Cannot compile templates which use processTimeout or href properties","winjs binding","warn")),a}},bindingInitializer:{get:function(){return this._bindingInitializer},set:function(a){this._bindingInitializer=a,this._reset()}},debugBreakOnRender:{get:function(){return this._debugBreakOnRender},set:function(a){this._debugBreakOnRender=!!a,this._reset()}},disableOptimizedProcessing:{get:function(){return this._disableOptimizedProcessing},set:function(a){this._disableOptimizedProcessing=!!a,this._reset()}},element:{get:function(){return this._element}},extractChild:{get:function(){return this._extractChild},set:function(a){this._extractChild=!!a,this._reset()}},processTimeout:{get:function(){return this._processTimeout||0},set:function(a){this._processTimeout=a,this._reset()}},render:e.markSupportedForProcessing(function(a,b){return this._renderImpl(a,b)}),_renderImpl:function(b,c){if(this._shouldCompile)try{return this._renderImpl=this._compileTemplate({target:"render"}),this._renderImpl(b,c)}catch(d){return l.wrapError(d)}var e=a(this,b,c);return e.element.then(function(){return e.renderComplete})},_renderInterpreted:function(b,c){return a(this,b,c)},renderItem:function(a,b){return this._renderItemImpl(a,b)},_renderItemImpl:function(b,c){if(this._shouldCompile)try{return this._renderItemImpl=this._compileTemplate({target:"renderItem"}),this._renderItemImpl(b)}catch(d){return{element:l.wrapError(d),renderComplete:l.wrapError(d)}}var e=this;if(this.enableRecycling&&!this.bindingCache.elements&&(this.bindingCache.elements={}),this.enableRecycling&&c&&c.msOriginalTemplate===this){var f=this.bindingCache.elements[c.id],g=!0;if(f&&(f.bindings.forEach(function(a){a()}),f.bindings=[],g=!f.nocache),g)return{element:c,renderComplete:b.then(function(a){return h.processAll(c,a.data,!0,e.bindingCache)})}}var i=a(this,b.then(function(a){return a.data}));return i.element=i.element.then(function(a){return a.msOriginalTemplate=e,a}),i},_compileTemplate:function(a){var b=this,d=i._TemplateCompiler.compile(this,this.href||this.element,{debugBreakOnRender:this.debugBreakOnRender||p._debugBreakOnRender,defaultInitializer:this.bindingInitializer||a.defaultInitializer,disableTextBindingOptimization:a.disableTextBindingOptimization||!1,target:a.target,extractChild:this.extractChild,profilerMarkIdentifier:this._profilerMarkIdentifier}),e=a.resetOnFragmentChange||c.Windows.ApplicationModel.DesignMode.designModeEnabled;if(e){var f=new n._MutationObserver(function(){b._reset(),f.disconnect()});f.observe(n.data(this.element).docFragment,{childList:!0,attributes:!0,characterData:!0,subtree:!0})}return d},_reset:function(){delete this._renderImpl,delete this._renderItemImpl}},{isDeclarativeControlContainer:{value:!0,writable:!1,configurable:!1},render:{value:function(a,b,c){return new p(null,{href:a}).render(b,c)}}});return p})})}}),define("WinJS/BindingList/_BindingListDataSource",["exports","../Core/_WinRT","../Core/_Base","../Core/_ErrorFromName","../Binding/_DomWeakRefTable","../Promise","../Scheduler","../Utilities/_UI"],function(a,b,c,d,e,f,g,h){"use strict";c.Namespace._moduleDefine(a,"WinJS.Binding",{_BindingListDataSource:c.Namespace._lazy(function(){function a(a,b){for(var c=a.length;c-1>b;){var d=a.getItem(++b);if(d)return d.key}return null}function i(a,b){for(;b>0;){var c=a.getItem(--b);if(c)return c.key}return null}function j(a,b){Object.keys(b).forEach(function(c){a.addEventListener(c,b[c])})}function k(a,b){Object.keys(b).forEach(function(c){a.removeEventListener(c,b[c])})}function l(a,b){return b?new B(a,b):new A}function m(a,b,c){return b?new C(a,b,c):new A}function n(a,b,c){return b&&a._annotateWithIndex(b,c)}function o(a,b){return this._list.unshift(b),this.itemFromIndex(0)}function p(a,b,c){var d=this._list.indexOfKey(c);return-1===d?y.noLongerMeaningful:(this._list.splice(d,0,b),this.itemFromIndex(d))}function q(a,b,c){var d=this._list.indexOfKey(c);return-1===d?y.noLongerMeaningful:(d+=1,this._list.splice(d,0,b),this.itemFromIndex(d))}function r(a,b){return this._list.push(b),this.itemFromIndex(this._list.length-1)}function s(a,b){var c=this._list.indexOfKey(a);return-1===c?y.noLongerMeaningful:(this._list.setAt(c,b),this.itemFromIndex(c))}function t(a){var b=this._list.indexOfKey(a);if(-1===b)return y.noLongerMeaningful;var c=0;return this._list.move(b,c),this.itemFromIndex(c)}function u(a,b){var c=this._list.indexOfKey(a),d=this._list.indexOfKey(b);return-1===c||-1===d?y.noLongerMeaningful:(d=d>c?d-1:d,this._list.move(c,d),this.itemFromIndex(d))}function v(a,b){var c=this._list.indexOfKey(a),d=this._list.indexOfKey(b);return-1===c||-1===d?y.noLongerMeaningful:(d=d>=c?d:d+1,this._list.move(c,d),this.itemFromIndex(d))}function w(a){var b=this._list.indexOfKey(a);if(-1===b)return y.noLongerMeaningful;var c=this._list.length-1;return this._list.move(b,c),this.itemFromIndex(c)}function x(a){var b=this._list.indexOfKey(a);return-1===b?y.noLongerMeaningful:(this._list.splice(b,1),f.wrap())}var y={get noLongerMeaningful(){return f.wrapError(new d(h.EditError.noLongerMeaningful))}},z=f.wrap().constructor,A=c.Class.derive(z,function(){this._value=null},{release:function(){},retain:function(){return this}},{supportedForProcessing:!1}),B=c.Class.derive(z,function(a,b){this._value=b,this._listBinding=a},{handle:{get:function(){return this._value.key}},index:{get:function(){return this._value.index}},release:function(){this._listBinding._release(this._value,this._listBinding._list.indexOfKey(this._value.key))},retain:function(){return this._listBinding._addRef(this._value,this._listBinding._list.indexOfKey(this._value.key)),this}},{supportedForProcessing:!1}),C=c.Class.derive(f,function(a,b,c){var d=this;this._item=b,this._listBinding=a,f.call(this,function(e){g.schedule(function(){return a._released?void d.cancel():void e(b)},g.Priority.normal,null,"WinJS.Binding.List."+c)})},{handle:{get:function(){return this._item.key}},index:{get:function(){return this._item.index}},release:function(){this._listBinding._release(this._item,this._listBinding._list.indexOfKey(this._item.key))},retain:function(){return this._listBinding._addRef(this._item,this._listBinding._list.indexOfKey(this._item.key)),this}},{supportedForProcessing:!1}),D=c.Class.define(function(a,c,d,f){this._dataSource=a,this._list=c,this._editsCount=0,this._notificationHandler=d,this._pos=-1,this._retained=[],this._retained.length=c.length,this._retainedKeys={},this._affectedRange=null;var g=null;if(b.msSetWeakWinRTProperty&&b.msGetWeakWinRTProperty||(g=this),d){var h=function(a,b){var c=e._getWeakRefElement(f)||g;return c?(c["_"+a](b),!0):!1};this._handlers={itemchanged:function i(a){h("itemchanged",a)||c.removeEventListener("itemchanged",i)},iteminserted:function k(a){h("iteminserted",a)||c.removeEventListener("iteminserted",k)},itemmoved:function l(a){h("itemmoved",a)||c.removeEventListener("itemmoved",l)},itemremoved:function m(a){h("itemremoved",a)||c.removeEventListener("itemremoved",m)},reload:function n(){h("reload")||c.removeEventListener("reload",n)}},j(this._list,this._handlers)}},{_itemchanged:function(a){var b=a.detail.key,c=a.detail.index;this._updateAffectedRange(c,"changed");var d=a.detail.newItem,e=this._retained[c];if(e){var f=this._notificationHandler;if(e.index!==c){var g=e.index;e.index=c,f&&f.indexChanged&&f.indexChanged(d.key,c,g)}d=n(this._list,d,c),d._retainedCount=e._retainedCount,this._retained[c]=d,this._retainedKeys[b]=d,this._beginEdits(this._list.length),f&&f.changed&&f.changed(d,e),this._endEdits()}else this._beginEdits(this._list.length),this._endEdits()},_iteminserted:function(b){var c=b.detail.index;this._updateAffectedRange(c,"inserted"),this._beginEdits(this._list.length-1),c<=this._pos&&(this._pos=Math.min(this._pos+1,this._list.length));var d=this._retained;if(d.splice(c,0,0),delete d[c],this._shouldNotify(c)||1===this._list.length){var e=this._notificationHandler;e&&e.inserted&&e.inserted(l(this,n(this._list,this._list.getItem(c),c)),i(this._list,c),a(this._list,c))}this._endEdits()},_itemmoved:function(a){var b=a.detail.oldIndex,c=a.detail.newIndex;this._updateAffectedRange(b,"moved"),this._updateAffectedRange(c,"moved"),this._beginEdits(this._list.length),(bthis._pos?this._pos=Math.max(-1,this._pos-1):b>this._pos&&(this._pos=Math.min(this._pos+1,this._list.length)));var d=this._retained,e=d.splice(b,1)[0];d.splice(c,0,e),e||(delete d[c],e=n(this._list,this._list.getItem(c),c)),e._moved=!0,this._addRef(e,c),this._endEdits()},_itemremoved:function(a){var b=a.detail.key,c=a.detail.index;this._updateAffectedRange(c,"removed"),this._beginEdits(this._list.length+1),cb;b++){var d=a[b];if(d&&d.index!==b){var e=b,f=d.index;d.index=e;var g=this._notificationHandler;g&&g.indexChanged&&g.indexChanged(d.key,e,f)}}},_notifyMoved:function(){for(var b=this._retained,c=0,d=b.length;d>c;c++){var e=b[c];if(e&&e._moved&&(e._moved=!1,this._release(e,c),this._shouldNotify(c))){var f=this._notificationHandler;f&&f.moved&&f.moved(l(this,e),i(this._list,c),a(this._list,c))}}},_beginEdits:function(a,b){this._editsCount++;var c=this._notificationHandler;if(1===this._editsCount&&c){if(!b){this._editsCount++;var d=this;g.schedule(function(){d._endEdits()},g.Priority.high,null,"WinJS.Binding.List._endEdits")}c.beginNotifications&&c.beginNotifications(),this._countAtBeginEdits=a}},_endEdits:function(){this._editsCount--;var a=this._notificationHandler;0===this._editsCount&&a&&(this._notifyIndicesChanged(),this._notifyMoved(),this._notifyCountChanged(),this._notifyAffectedRange(),a.endNotifications&&a.endNotifications())},jumpToItem:function(a){var b=this._list.indexOfKey(a.handle);return-1===b?f.wrap(null):(this._pos=b,this.current())},current:function(){return this.fromIndex(this._pos)},previous:function(){return this._pos=Math.max(-1,this._pos-1),this._fromIndex(this._pos,!0,"previous")},next:function(){return this._pos=Math.min(this._pos+1,this._list.length),this._fromIndex(this._pos,!0,"next")},releaseItem:function(a){a.release?a.release():this._release(a,this._list.indexOfKey(a.key))},release:function(){this._notificationHandler&&k(this._list,this._handlers),this._notificationHandler=null,this._dataSource._releaseBinding(this),this._released=!0},first:function(){return this.fromIndex(0)},last:function(){return this.fromIndex(this._list.length-1)},fromKey:function(a){var b,c=this._retainedKeys;return b=a in c?c[a]:n(this._list,this._list.getItemFromKey(a),this._list.indexOfKey(a)),l(this,b)},fromIndex:function(a){return this._fromIndex(a,!1,"fromIndex")},_fromIndex:function(a,b,c){var d,e=this._retained;return d=a in e?e[a]:n(this._list,this._list.getItem(a),a),b?m(this,d,c):l(this,d)}},{supportedForProcessing:!1}),E=0,F=c.Class.define(function(a){this._usingWeakRef=b.msSetWeakWinRTProperty&&b.msGetWeakWinRTProperty,this._bindings={},this._list=a,a.unshift&&(this.insertAtStart=o),a.push&&(this.insertAtEnd=r),a.setAt&&(this.change=s),a.splice&&(this.insertAfter=q,this.insertBefore=p,this.remove=x),a.move&&(this.moveAfter=v,this.moveBefore=u,this.moveToEnd=w,this.moveToStart=t)},{_releaseBinding:function(a){delete this._bindings[a._id]},addEventListener:function(){},removeEventListener:function(){},createListBinding:function(a){var b="ds_"+ ++E,c=new D(this,this._list,a,b);return c._id=b,this._usingWeakRef?(e._createWeakRef(c,b),this._bindings[b]=b):this._bindings[b]=c,c},getCount:function(){return f.wrap(this._list.length)},itemFromKey:function(a){var b=this._list,c=n(b,b.getItemFromKey(a),-1);return Object.defineProperty(c,"index",{get:function(){return b.indexOfKey(a)},enumerable:!1,configurable:!0}),f.wrap(c)},itemFromIndex:function(a){return f.wrap(n(this._list,this._list.getItem(a),a))},list:{get:function(){return this._list}},beginEdits:function(){var a=this._list.length;this._forEachBinding(function(b){b._beginEdits(a,!0)})},endEdits:function(){this._forEachBinding(function(a){a._endEdits()})},_forEachBinding:function(a){if(this._usingWeakRef){var b=[];Object.keys(this._bindings).forEach(function(c){var d=e._getWeakRefElement(c);d?a(d):b.push(c)});for(var c=0,d=b.length;d>c;c++)delete this._bindings[b[c]]}else{var f=this;Object.keys(this._bindings).forEach(function(b){a(f._bindings[b])})}},invalidateAll:function(){return f.wrap()},moveAfter:void 0,moveBefore:void 0,moveToEnd:void 0,moveToStart:void 0},{supportedForProcessing:!1});return F})})}),define("WinJS/BindingList",["exports","./Core/_Base","./Core/_BaseUtils","./Core/_ErrorFromName","./Core/_Events","./Core/_Resources","./Binding/_Data","./BindingList/_BindingListDataSource"],function(a,b,c,d,e,f,g,h){"use strict";function i(a){return Array.prototype.slice.call(a,0)}function j(a){return{handle:a.handle,key:a.key,data:a.data,groupKey:a.groupKey,groupSize:a.groupSize,firstItemKey:a.firstItemKey,firstItemIndexHint:a.firstItemIndexHint}}function k(a){return void 0===a?void 0:+a}function l(a,b){var c=a.length;if(1>=c)return a;var d=c/2>>>0,e=l(a.slice(0,d),b),f=l(a.slice(d),b);return m(e,f,b)}function m(a,b,c){for(var d=[];a.length&&b.length;){var e=c(a[0],b[0]);d.push(0>=e?a.shift():b.shift())}return a.length&&d.push.apply(d,a),b.length&&d.push.apply(d,b),d}var n={get sparseArrayNotSupported(){return"Sparse arrays are not supported with proxy: true"},get illegalListLength(){return"List length must be assigned a finite positive number"}},o=e._createEventProperty,p={},q=b.Namespace.defineWithParent(null,null,{ListBase:b.Namespace._lazy(function(){var a=b.Class.define(null,{_annotateWithIndex:function(a,b){var c=j(a);return c.index=b,c},onitemchanged:o("itemchanged"),oniteminserted:o("iteminserted"),onitemmoved:o("itemmoved"),onitemmutated:o("itemmutated"),onitemremoved:o("itemremoved"),onreload:o("reload"),_notifyItemChanged:function(a,b,c,d,e,f){this._listeners&&this._listeners.itemchanged&&this.dispatchEvent("itemchanged",{key:a,index:b,oldValue:c,newValue:d,oldItem:e,newItem:f})},_notifyItemInserted:function(a,b,c){this._listeners&&this._listeners.iteminserted&&this.dispatchEvent("iteminserted",{key:a,index:b,value:c});var d=this.length;d!==this._lastNotifyLength&&(this.notify("length",d,this._lastNotifyLength),this._lastNotifyLength=d)},_notifyItemMoved:function(a,b,c,d){this._listeners&&this._listeners.itemmoved&&this.dispatchEvent("itemmoved",{key:a,oldIndex:b,newIndex:c,value:d})},_notifyItemMutated:function(a,b,c){this._listeners&&this._listeners.itemmutated&&this.dispatchEvent("itemmutated",{key:a,value:b,item:c})},_notifyItemRemoved:function(a,b,c,d){this._listeners&&this._listeners.itemremoved&&this.dispatchEvent("itemremoved",{key:a,index:b,value:c,item:d});var e=this.length;e!==this._lastNotifyLength&&(this.notify("length",e,this._lastNotifyLength),this._lastNotifyLength=e)},_notifyReload:function(){if(this._listeners&&this._listeners.reload&&this.dispatchEvent("reload"),a!==this._lastNotifyLength){var a=this.length;this.notify("length",a,this._lastNotifyLength),this._lastNotifyLength=a}},_normalizeIndex:function(a){return a=k(a),0>a?this.length+a:a},_notifyMutatedFromKey:function(a){var b=this.getItemFromKey(a);this._notifyItemMutated(a,b.data,b)},notifyReload:function(){this._notifyReload()},getAt:function(a){a=k(a);var b=this.getItem(a);return b&&b.data},_getArray:function(){for(var a=new Array(this.length),b=0,c=this.length;c>b;b++){var d=this.getItem(b);d&&(a[b]=d.data)}return a},_getFromKey:function(a){var b=this.getItemFromKey(a);return b&&b.data},_getKey:function(a){a=k(a);var b=this.getItem(a);return b&&b.key},concat:function(){var a=this._getArray();return a.concat.apply(a,arguments)},join:function(a){return this._getArray().join(a||",")},slice:function(a,b){return this._getArray().slice(a,b)},indexOf:function(a,b){b=k(b),b=Math.max(0,this._normalizeIndex(b)||0);for(var c=b,d=this.length;d>c;c++){var e=this.getItem(c);if(e&&e.data===a)return c}return-1},lastIndexOf:function(a,b){b=k(b);var c=this.length;b=Math.min(this._normalizeIndex(void 0!==b?b:c),c-1);var d;for(d=b;d>=0;d--){var e=this.getItem(d);if(e&&e.data===a)return d}return-1},every:function(a,b){return this._getArray().every(a,b)},filter:function(a,b){return this._getArray().filter(a,b)},forEach:function(a,b){this._getArray().forEach(a,b)},map:function(a,b){return this._getArray().map(a,b)},some:function(a,b){return this._getArray().some(a,b)},reduce:function(a,b){return arguments.length>1?this._getArray().reduce(a,b):this._getArray().reduce(a)},reduceRight:function(a,b){return arguments.length>1?this._getArray().reduceRight(a,b):this._getArray().reduceRight(a)},createFiltered:function(a){return new q.FilteredListProjection(this,a)},createGrouped:function(a,b,c){return new q.GroupedSortedListProjection(this,a,b,c)},createSorted:function(a){return new q.SortedListProjection(this,a)},dataSource:{get:function(){return this._dataSource=this._dataSource||new h._BindingListDataSource(this)}}},{supportedForProcessing:!1});return b.Class.mix(a,g.observableMixin),b.Class.mix(a,e.eventMixin),a}),ListBaseWithMutators:b.Namespace._lazy(function(){return b.Class.derive(q.ListBase,null,{pop:function(){return this.splice(-1,1)[0]},push:function(a){if(1===arguments.length)return this.splice(this.length,0,a),this.length;var b=i(arguments);return b.splice(0,0,this.length,0),this.splice.apply(this,b),this.length},shift:function(){return this.splice(0,1)[0]},unshift:function(a){if(1===arguments.length)this.splice(0,0,a);else{var b=i(arguments);b.splice(0,0,0,0),this.splice.apply(this,b)}return this.length}},{supportedForProcessing:!1})}),ListProjection:b.Namespace._lazy(function(){return b.Class.derive(q.ListBaseWithMutators,null,{_list:null,_myListeners:null,_addListListener:function(a,b){var c={name:a,handler:b.bind(this)};this._myListeners=this._myListeners||[],this._myListeners.push(c),this._list.addEventListener(a,c.handler)},dispose:function(){var b=this._list,c=this._myListeners;this._myListeners=[];for(var d=0,e=c.length;e>d;d++){var f=c[d];b.removeEventListener(f.name,f.handler)}this._list=new a.List,this._listReload()},getItemFromKey:function(a){return this._list.getItemFromKey(a)},move:function(a,b){a=k(a),b=k(b),a===b||0>a||0>b||a>=this.length||b>=this.length||(a=this._list.indexOfKey(this._getKey(a)),b=this._list.indexOfKey(this._getKey(b)),this._list.move(a,b))},_notifyMutatedFromKey:function(a){this._list._notifyMutatedFromKey(a)},splice:function(a){a=k(a),a=Math.max(0,this._normalizeIndex(a));var b=i(arguments);return a===this.length?(b[0]=this._list.length,this._list.splice.apply(this._list,b)):(b[0]=this._getKey(a),this._spliceFromKey.apply(this,b))},_setAtKey:function(a,b){this._list._setAtKey(a,b)}},{supportedForProcessing:!1})}),FilteredListProjection:b.Namespace._lazy(function(){return b.Class.derive(q.ListProjection,function(a,b){this._list=a,this._addListListener("itemchanged",this._listItemChanged),this._addListListener("iteminserted",this._listItemInserted),this._addListListener("itemmutated",this._listItemMutated),this._addListListener("itemmoved",this._listItemMoved),this._addListListener("itemremoved",this._listItemRemoved),this._addListListener("reload",this._listReload),this._filter=b,this._initFilteredKeys()},{_filter:null,_filteredKeys:null,_initFilteredKeys:function(){for(var a=this._filter,b=this._list,c=[],d=0,e=b.length;e>d;d++){var f=b.getItem(d);f&&a(f.data)&&c.push(f.key)}this._filteredKeys=c},_findInsertionPosition:function(a,b){for(var c,d=this._filter;--b>=0;){var e=this._list.getItem(b);if(e&&d(e.data)){c=e.key;break}}var f=this._filteredKeys,g=c?f.indexOf(c)+1:0;return g},_listItemChanged:function(a){var b=a.detail.key,c=a.detail.index,d=a.detail.oldValue,e=a.detail.newValue,f=a.detail.oldItem,g=a.detail.newItem,h=this._filter,i=h(d),j=h(e);if(i&&j){var k=this._filteredKeys,l=k.indexOf(b);this._notifyItemChanged(b,l,d,e,f,g)}else i&&!j?this._listItemRemoved({detail:{key:b,index:c,value:d,item:f}}):!i&&j&&this._listItemInserted({detail:{key:b,index:c,value:e}})},_listItemInserted:function(a){var b=a.detail.key,c=a.detail.index,d=a.detail.value,e=this._filter;if(e(d)){var f=this._findInsertionPosition(b,c),g=this._filteredKeys;g.splice(f,0,b),this._notifyItemInserted(b,f,d)}},_listItemMoved:function(a){var b=a.detail.key,c=a.detail.newIndex,d=a.detail.value,e=this._filteredKeys,f=e.indexOf(b);if(-1!==f){e.splice(f,1);var g=this._findInsertionPosition(b,c);e.splice(g,0,b),this._notifyItemMoved(b,f,g,d)}},_listItemMutated:function(a){var b=a.detail.key,c=a.detail.value,d=a.detail.item,e=this._filter,f=this._filteredKeys,g=f.indexOf(b),h=-1!==g,i=e(c);h&&i?this._notifyItemMutated(b,c,d):h&&!i?(f.splice(g,1),this._notifyItemRemoved(b,g,c,d)):!h&&i&&this._listItemInserted({detail:{key:b,index:this._list.indexOfKey(b),value:c}})},_listItemRemoved:function(a){var b=a.detail.key,c=a.detail.value,d=a.detail.item,e=this._filteredKeys,f=e.indexOf(b);-1!==f&&(e.splice(f,1),this._notifyItemRemoved(b,f,c,d))},_listReload:function(){this._initFilteredKeys(),this._notifyReload()},length:{get:function(){return this._filteredKeys.length},set:function(a){if(!("number"==typeof a&&a>=0))throw new d("WinJS.Binding.List.IllegalLength",n.illegalListLength);var b=this.length;b>a&&this.splice(a,b-a)}},getItem:function(a){return a=k(a),this.getItemFromKey(this._filteredKeys[a])},indexOfKey:function(a){return this._filteredKeys.indexOf(a)},notifyMutated:function(a){return a=k(a),this._notifyMutatedFromKey(this._filteredKeys[a])},setAt:function(a,b){a=k(a),this._setAtKey(this._filteredKeys[a],b)},_spliceFromKey:function(a,b){if(arguments.length>2){var c=i(arguments);c[1]=0,this._list._spliceFromKey.apply(this._list,c)}var d=[];if(b){for(var e=[],f=this._filteredKeys,g=f.indexOf(a),h=g,j=f.length;j>h&&b>h-g;h++){var a=f[h];e.push(a)}var k=this;e.forEach(function(a){d.push(k._list._spliceFromKey(a,1)[0])})}return d}},{supportedForProcessing:!1})}),SortedListProjection:b.Namespace._lazy(function(){return b.Class.derive(q.ListProjection,function(a,b){this._list=a,this._addListListener("itemchanged",this._listItemChanged),this._addListListener("iteminserted",this._listItemInserted),this._addListListener("itemmoved",this._listItemMoved),this._addListListener("itemmutated",this._listItemMutated),this._addListListener("itemremoved",this._listItemRemoved),this._addListListener("reload",this._listReload),this._sortFunction=b,this._initSortedKeys()},{_sortFunction:null,_sortedKeys:null,_initSortedKeys:function(){for(var a=this._list,b=[],c=0,d=a.length;d>c;c++){var e=a.getItem(c);e&&(b[c]=e.key)}var f=this._sortFunction,g=l(b,function(b,c){return b=a.getItemFromKey(b).data,c=a.getItemFromKey(c).data,f(b,c)});this._sortedKeys=g},_findInsertionPos:function(a,b,c,d,e){for(var f=this._sortFunction,g=this._sortedKeys,h=Math.max(0,d||-1),i=Math.min(g.length,e||Number.MAX_VALUE),j=h;i>=h;){j=(h+i)/2>>>0;var k=g[j];if(!k)break;var l=this.getItemFromKey(k),m=f(l.data,c);if(0>m)h=j+1;else{if(0===m)return this._findStableInsertionPos(a,b,h,i,j,c);i=j-1}}return h},_findBeginningOfGroup:function(a,b,c,d,e){for(var f=0,g=a;g>=f;){a=(f+g)/2>>>0;var h=d[a],i=c.getItemFromKey(h),j=b(i.data,e);0>j?f=a+1:g=a-1}return f},_findEndOfGroup:function(a,b,c,d,e){for(var f=a,g=d.length;g>=f;){a=(f+g)/2>>>0;var h=d[a];if(!h)return d.length;var i=c.getItemFromKey(h),j=b(i.data,e);0>=j?f=a+1:g=a-1}return f},_findStableInsertionPos:function(a,b,c,d,e,f){var g=this._list,h=g.length,i=this._sortFunction,j=this._sortedKeys;if(h/2>b){for(var k=b-1;k>=0;k--){var l=g.getItem(k);if(0===i(l.data,f))return h-c>d?j.indexOf(l.key,c)+1:j.lastIndexOf(l.key,d)+1}return this._findBeginningOfGroup(e,i,g,j,f)}for(var k=b+1;h>k;k++){var l=g.getItem(k);if(0===i(l.data,f))return h-c>d?j.indexOf(l.key,c):j.lastIndexOf(l.key,d)}return this._findEndOfGroup(e,i,g,j,f)},_listItemChanged:function(a){var b=a.detail.key,c=a.detail.newValue,d=a.detail.oldValue,e=this._sortFunction;if(0===e(d,c)){var f=this.indexOfKey(b);this._notifyItemChanged(b,f,d,c,a.detail.oldItem,a.detail.newItem)}else this._listItemRemoved({detail:{key:b,index:a.detail.index,value:a.detail.oldValue,item:a.detail.oldItem}}),this._listItemInserted({detail:{key:b,index:a.detail.index,value:a.detail.newValue}})},_listItemInserted:function(a,b,c){var d=a.detail.key,e=a.detail.index,f=a.detail.value,g=this._findInsertionPos(d,e,f,b,c);this._sortedKeys.splice(g,0,d),this._notifyItemInserted(d,g,f)},_listItemMoved:function(a,b,c){var d=a.detail.key,e=a.detail.newIndex,f=a.detail.value,g=this._sortedKeys,h=g.indexOf(d,b);g.splice(h,1);var i=this._findInsertionPos(d,e,f,b,c);g.splice(i,0,d),i!==h&&this._notifyItemMoved(d,h,i,f)},_listItemMutated:function(a){var b=a.detail.key,c=a.detail.value,d=a.detail.item,e=this._list.indexOfKey(b),f=this._sortedKeys.indexOf(b);this._sortedKeys.splice(f,1);var g=this._findInsertionPos(b,e,c);return this._sortedKeys.splice(f,0,b),f===g?void this._notifyItemMutated(b,c,d):(this._listItemRemoved({detail:{key:b,index:e,value:c,item:d}}),void this._listItemInserted({detail:{key:b,index:e,value:c}}))},_listItemRemoved:function(a,b){var c=a.detail.key,d=a.detail.value,e=a.detail.item,f=this._sortedKeys,g=f.indexOf(c,b);f.splice(g,1),this._notifyItemRemoved(c,g,d,e)},_listReload:function(){this._initSortedKeys(),this._notifyReload()},length:{get:function(){return this._sortedKeys.length},set:function(a){if(!("number"==typeof a&&a>=0))throw new d("WinJS.Binding.List.IllegalLength",n.illegalListLength);var b=this.length;b>a&&this.splice(a,b-a)}},getItem:function(a){return a=k(a),this.getItemFromKey(this._sortedKeys[a])},indexOfKey:function(a){return this._sortedKeys.indexOf(a)},notifyMutated:function(a){a=k(a),this._notifyMutatedFromKey(this._sortedKeys[a])},setAt:function(a,b){a=k(a),this._setAtKey(this._sortedKeys[a],b)},_spliceFromKey:function(a,b){if(arguments.length>2){var c=i(arguments);c[1]=0,this._list._spliceFromKey.apply(this._list,c)}var d=[];if(b){for(var e=[],f=this._sortedKeys,g=f.indexOf(a),h=g,j=f.length;j>h&&b>h-g;h++)e.push(f[h]);var k=this;e.forEach(function(a){d.push(k._list._spliceFromKey(a,1)[0])})}return d}},{supportedForProcessing:!1})}),GroupedSortedListProjection:b.Namespace._lazy(function(){return b.Class.derive(q.SortedListProjection,function(a,b,c,d){this._list=a,this._addListListener("itemchanged",this._listGroupedItemChanged),this._addListListener("iteminserted",this._listGroupedItemInserted),this._addListListener("itemmoved",this._listGroupedItemMoved),this._addListListener("itemmutated",this._listGroupedItemMutated),this._addListListener("itemremoved",this._listGroupedItemRemoved),this._addListListener("reload",this._listReload),this._sortFunction=function(a,c){return a=b(a),c=b(c),d?d(a,c):c>a?-1:a===c?0:1},this._groupKeyOf=b,this._groupDataOf=c,this._initSortedKeys(),this._initGroupedItems()},{_groupKeyOf:null,_groupDataOf:null,_groupedItems:null,_initGroupedItems:function(){for(var a={},b=this._list,c=this._groupKeyOf,d=0,e=b.length;e>d;d++){var f=j(b.getItem(d));f.groupKey=c(f.data),a[f.key]=f}this._groupedItems=a},_groupsProjection:null,_listGroupedItemChanged:function(a){var b=a.detail.key,c=a.detail.oldValue,d=a.detail.newValue,e=this._groupedItems,f=e[b],g=j(f);g.data=d,g.groupKey=this._groupKeyOf(d),e[b]=g;var h;f.groupKey===g.groupKey?(h=this.indexOfKey(b),this._notifyItemChanged(b,h,c,d,f,g)):(h=a.detail.index,this._listItemChanged({detail:{key:b,index:h,oldValue:c,newValue:d,oldItem:f,newItem:g}}))},_listGroupedItemInserted:function(a){var b=a.detail.key,c=a.detail.value,d=this._groupKeyOf(c);this._groupedItems[b]={handle:b,key:b,data:c,groupKey:d};var e,f;if(this._groupsProjection){var g=this._groupsProjection._groupItems[d];g&&(e=g.firstItemIndexHint,f=e+g.groupSize)}this._listItemInserted(a,e,f)},_listGroupedItemMoved:function(a){var b,c,d=this._groupedItems[a.detail.key].groupKey;if(this._groupsProjection){var e=this._groupsProjection._groupItems[d];b=e.firstItemIndexHint,c=b+e.groupSize}this._listItemMoved(a,b,c)},_listGroupedItemMutated:function(a){var b=a.detail.key,c=a.detail.value,d=this._groupedItems,e=d[b],f=this._groupKeyOf(c);if(e.groupKey===f)this._notifyItemMutated(b,c,e);else{var g=j(e);g.groupKey=f,d[b]=g;var h=this._list.indexOfKey(b);this._listItemRemoved({detail:{key:b,index:h,value:c,item:e}}),this._listItemInserted({detail:{key:b,index:h,value:c}})}},_listGroupedItemRemoved:function(a){var b=a.detail.key,c=a.detail.index,d=a.detail.value,e=this._groupedItems,f=e[b];delete e[b];var g,h;if(this._groupsProjection){var i=this._groupsProjection._groupItems[f.groupKey];g=i.firstItemIndexHint,h=g+i.groupSize}this._listItemRemoved({detail:{key:b,index:c,value:d,item:f}},g,h) +},_listReload:function(){this._initGroupedItems(),q.SortedListProjection.prototype._listReload.call(this)},groups:{get:function(){return null===this._groupsProjection&&(this._groupsProjection=new q.GroupsListProjection(this,this._groupKeyOf,this._groupDataOf)),this._groupsProjection}},getItemFromKey:function(a){return this._groupedItems[a]}},{supportedForProcessing:!1})}),GroupsListProjection:b.Namespace._lazy(function(){return b.Class.derive(q.ListBase,function(a,b,c){this._list=a,this._addListListener("itemchanged",this._listItemChanged),this._addListListener("iteminserted",this._listItemInserted),this._addListListener("itemmoved",this._listItemMoved),this._addListListener("itemremoved",this._listItemRemoved),this._addListListener("reload",this._listReload),this._groupKeyOf=b,this._groupDataOf=c,this._initGroupKeysAndItems()},{_list:null,_addListListener:function(a,b){this._list.addEventListener(a,b.bind(this))},_groupDataOf:null,_groupKeyOf:null,_groupOf:function(a){return this.getItemFromKey(this._groupKeyOf(a.data))},_groupKeys:null,_groupItems:null,_initGroupKeysAndItems:function(){for(var a,b=this._groupDataOf,c=this._list,d={},e=[],f=null,g=null,h=0,i=c.length;i>h;h++){var j=c.getItem(h),k=j.groupKey;k!==f?(g&&(g.groupSize=a),a=1,f=k,g={handle:k,key:k,data:b(j.data),firstItemKey:j.key,firstItemIndexHint:h},d[k]=g,e.push(k)):a++}g&&(g.groupSize=a),this._groupKeys=e,this._groupItems=d},_listItemChanged:function(a){var b=a.detail.key,c=a.detail.index,d=a.detail.newValue,e=this._list,f=e.getItemFromKey(b).groupKey,g=this._groupItems,h=g[f];if(h.firstItemIndexHint===c){var i=j(h);i.data=this._groupDataOf(d),i.firstItemKey=b,g[f]=i,this._notifyItemChanged(f,this._groupKeys.indexOf(f),h.data,i.data,h,i)}},_listItemInserted:function(a){var b,c,d,e,f,g=a.detail.key,h=a.detail.index,i=a.detail.value,k=this._list,l=k.getItemFromKey(g).groupKey,m=this._groupItems,n=this._groupKeys,o=m[l];if(o)c=o,d=j(c),d.groupSize++,c.firstItemIndexHint===h&&(d.groupData=this._groupDataOf(i),d.firstItemKey=g,d.firstItemIndexHint=h),m[l]=d,b=n.indexOf(l),this._notifyItemChanged(l,b,c.data,d.data,c,d);else{for(e=0,f=n.length;f>e&&(o=m[n[e]],!(o.firstItemIndexHint>=h));e++);b=e,o={handle:l,key:l,data:this._groupDataOf(i),groupSize:1,firstItemKey:g,firstItemIndexHint:h},n.splice(b,0,l),m[l]=o,this._notifyItemInserted(l,b,o.data)}for(e=b+1,f=n.length;f>e;e++)c=m[n[e]],d=j(c),d.firstItemIndexHint++,m[d.key]=d,this._notifyItemChanged(d.key,e,c.data,d.data,c,d)},_listItemMoved:function(a){var b=a.detail.key,c=a.detail.oldIndex,d=a.detail.newIndex,e=this._list,f=e.getItemFromKey(b).groupKey,g=this._groupItems,h=g[f];if(h.firstItemIndexHint===d||h.firstItemIndexHint===c){var i=e.getItem(h.firstItemIndexHint),k=j(h);k.data=this._groupDataOf(i.data),k.firstItemKey=i.key,g[f]=k,this._notifyItemChanged(f,this._groupKeys.indexOf(f),h.data,k.data,h,k)}},_listItemRemoved:function(a){var b,c,d=a.detail.index,e=a.detail.item,f=this._groupItems,g=this._groupKeys,h=e.groupKey,i=f[h],k=g.indexOf(h);if(1===i.groupSize)g.splice(k,1),delete f[h],this._notifyItemRemoved(h,k,i.data,i),k--;else{if(b=i,c=j(b),c.groupSize--,b.firstItemIndexHint===d){var l=this._list.getItem(d);c.data=this._groupDataOf(l.data),c.firstItemKey=l.key}f[h]=c,this._notifyItemChanged(h,k,b.data,c.data,b,c)}for(var m=k+1,n=g.length;n>m;m++)b=f[g[m]],c=j(b),c.firstItemIndexHint--,f[c.key]=c,this._notifyItemChanged(c.key,m,b.data,c.data,b,c)},_listReload:function(){this._initGroupKeysAndItems(),this._notifyReload()},length:{get:function(){return this._groupKeys.length}},getItem:function(a){return a=k(a),this._groupItems[this._groupKeys[a]]},getItemFromKey:function(a){return this._groupItems[a]},indexOfKey:function(a){return this._groupKeys.indexOf(a)}},{supportedForProcessing:!1})})});b.Namespace._moduleDefine(a,"WinJS.Binding",{List:b.Namespace._lazy(function(){return b.Class.derive(q.ListBaseWithMutators,function(a,b){if(this._currentKey=0,this._keys=null,this._keyMap={},b=b||p,this._proxy=b.proxy,this._binding=b.binding,this._proxy){if(Object.keys(a).length!==a.length)throw new d("WinJS.Binding.List.NotSupported",n.sparseArrayNotSupported);this._data=a,this._currentKey=a.length}else if(a){for(var c=this._keyMap,e=0,f=0,h=a.length;h>f;f++)if(f in a){var i=a[f];this._binding&&(i=g.as(i));var j=e.toString();e++,c[j]={handle:j,key:j,data:i}}e!==f&&this._initializeKeys(),this._currentKey=e}},{_currentKey:0,_keys:null,_keyMap:null,_modifyingData:0,_initializeKeys:function(){if(!this._keys){var a=[];if(this._data){for(var b=this._keyMap,c=this._data,d=0,e=c.length;e>d;d++)if(d in c){var f=d.toString();if(a[d]=f,!(f in b)){var h=c[d];this._binding&&(h=g.as(h)),b[f]={handle:f,key:f,data:h}}}}else Object.keys(this._keyMap).forEach(function(b){a[b>>>0]=b});this._keys=a}},_lazyPopulateEntry:function(a){if(this._data&&a in this._data){var b=this._data[a];this._binding&&(b=g.as(b));var c=a.toString(),d={handle:c,key:c,data:b};return this._keyMap[d.key]=d,d}},_assignKey:function(){return(++this._currentKey).toString()},length:{get:function(){return this._data?this._data.length:this._keys?this._keys.length:this._currentKey},set:function(a){if(!("number"==typeof a&&a>=0))throw new d("WinJS.Binding.List.IllegalLength",n.illegalListLength);this._initializeKeys();var b=this.length;if(b>a?this.splice(a,b-a):a=b,this._data){this._modifyingData++;try{this._data.length=a}finally{this._modifyingData--}}this._keys&&(this._keys.length=a)}},getItem:function(a){var b,c;return a=k(a),this._keys?(c=this._keys[a],b=c&&this._keyMap[c]):(c=a.toString(),b=this._keyMap[c]||this._lazyPopulateEntry(a)),b},getItemFromKey:function(a){var b;return b=this._keys||!this._data?this._keyMap[a]:this.getItem(a>>>0)},indexOfKey:function(a){var b=-1;if(this._keys)b=this._keys.indexOf(a);else{var c=a>>>0;ca||0>b||a>=this.length||b>=this.length)){if(this._data){this._modifyingData++;try{var c=this._data.splice(a,1)[0];this._data.splice(b,0,c)}finally{this._modifyingData--}}var d=this._keys.splice(a,1)[0];this._keys.splice(b,0,d),this._notifyItemMoved(d,a,b,this.getItemFromKey(d).data)}},notifyMutated:function(a){a=k(a);var b=this._keys?this._keys[a]:a.toString();this._notifyMutatedFromKey(b)},setAt:function(a,b){a=k(a),this._initializeKeys();var c=this.length;if(a===c)this.push(b);else if(c>a){if(this._data){this._modifyingData++;try{this._data[a]=b}finally{this._modifyingData--}}if(this._binding&&(b=g.as(b)),a in this._keys){var d=this._keys[a],e=this._keyMap[d],f=j(e);f.data=b,this._keyMap[d]=f,this._notifyItemChanged(d,a,e.data,b,e,f)}}},_setAtKey:function(a,b){this.setAt(this.indexOfKey(a),b)},reverse:function(){if(this._initializeKeys(),this._data){this._modifyingData++;try{this._data.reverse()}finally{this._modifyingData--}}return this._keys.reverse(),this._notifyReload(),this},sort:function(a){if(this._initializeKeys(),this._data){this._modifyingData++;try{this._data.sort(a)}finally{this._modifyingData--}}var b=this;return this._keys.sort(function(c,d){return c=b._keyMap[c],d=b._keyMap[d],a?a(c.data,d.data):(c=(c&&c.data||"").toString(),d=(c&&d.data||"").toString(),d>c?-1:c===d?0:1)}),this._notifyReload(),this},pop:function(){if(0!==this.length){this._initializeKeys();var a=this._keys.pop(),b=this._keyMap[a],c=b&&b.data;if(this._data){this._modifyingData++;try{this._data.pop()}finally{this._modifyingData--}}return delete this._keyMap[a],this._notifyItemRemoved(a,this._keys.length,c,b),c}},push:function(){this._initializeKeys();for(var a=arguments.length,b=0;a>b;b++){var c=arguments[b];this._binding&&(c=g.as(c));var d=this._assignKey();if(this._keys.push(d),this._data){this._modifyingData++;try{this._data.push(arguments[b])}finally{this._modifyingData--}}this._keyMap[d]={handle:d,key:d,data:c},this._notifyItemInserted(d,this._keys.length-1,c)}return this.length},shift:function(){if(0!==this.length){this._initializeKeys();var a=this._keys.shift(),b=this._keyMap[a],c=b&&b.data;if(this._data){this._modifyingData++;try{this._data.shift()}finally{this._modifyingData--}}return delete this._keyMap[a],this._notifyItemRemoved(a,0,c,b),c}},unshift:function(){this._initializeKeys();for(var a=arguments.length,b=a-1;b>=0;b--){var c=arguments[b];this._binding&&(c=g.as(c));var d=this._assignKey();if(this._keys.unshift(d),this._data){this._modifyingData++;try{this._data.unshift(arguments[b])}finally{this._modifyingData--}}this._keyMap[d]={handle:d,key:d,data:c},this._notifyItemInserted(d,0,c)}return this.length},splice:function(a,b){a=k(a),this._initializeKeys(),a=Math.max(0,this._normalizeIndex(a)),b=Math.max(0,Math.min(b||0,this.length-a));for(var c=[];b;){var d=this._keys[a],e=this._keyMap[d],f=e&&e.data;if(c.push(f),this._keys.splice(a,1),this._data){this._modifyingData++;try{this._data.splice(a,1)}finally{this._modifyingData--}}delete this._keyMap[d],this._notifyItemRemoved(d,a,f,e),--b}if(arguments.length>2)for(var h=2,i=arguments.length;i>h;h++){var j=arguments[h];this._binding&&(j=g.as(j));var l=Math.min(a+h-2,this.length),m=this._assignKey();if(this._keys.splice(l,0,m),this._data){this._modifyingData++;try{this._data.splice(l,0,arguments[h])}finally{this._modifyingData--}}this._keyMap[m]={handle:m,key:m,data:j},this._notifyItemInserted(m,l,j)}return c},_spliceFromKey:function(a){this._initializeKeys();var b=i(arguments);return b[0]=this._keys.indexOf(a),this.splice.apply(this,b)}},{supportedForProcessing:!1})})})}),define("WinJS/Res",["exports","./Core/_Global","./Core/_Base","./Core/_BaseUtils","./Core/_ErrorFromName","./Core/_Resources","./ControlProcessor/_OptionsParser","./Promise"],function(a,b,c,d,e,f,g,h){"use strict";function i(a,c){a=a||b.document.body;var c=c||0;if(4>c){if(0===c&&a.getAttribute){var f=a.getAttribute("data-win-res");if(f){var i=g.optionsParser(f);l(a,a,i,c)}}var j="[data-win-res],[data-win-control]",k=a.querySelectorAll(j);if(0===k.length)return h.as(a);for(var n=0,p=k.length;p>n;n++){var q=k[n];if(q.winControl&&q.winControl.constructor&&q.winControl.constructor.isDeclarativeControlContainer){var r=q.winControl.constructor.isDeclarativeControlContainer;"function"==typeof r&&(r=o(r),r(q.winControl,m),n+=q.querySelectorAll(j).length)}if(q.hasAttribute("data-win-res")){var i=g.optionsParser(q.getAttribute("data-win-res"));l(q,q,i,c)}}}else if(d.validation)throw new e("WinJS.Res.NestingExceeded","NestingExceeded");return h.as(a)}function j(a,b){for(var c=Object.keys(b),e=0,g=c.length;g>e;e++){var h=c[e],i=b[h],j=f.getString(i);j&&j.empty?d.validation&&k(i):(a.setAttribute(h,j.value),void 0!==j.lang&&void 0!==a.lang&&a.lang!==j.lang&&(a.lang=j.lang))}}function k(a){throw new e("WinJS.Res.NotFound",f._formatString("NotFound: {0}",a))}function l(a,b,c,e){var g=Object.keys(c);b=o(b);for(var h=0,m=g.length;m>h;h++){var n=g[h],p=c[n];if("string"==typeof p){var q=f.getString(p);q&&q.empty?d.validation&&k(p):(b[n]=q.value,void 0!==q.lang&&void 0!==a.lang&&a.lang!==q.lang&&(a.lang=q.lang),"innerHTML"===n&&i(b,e+1))}else a===b&&"attributes"===n?j(a,p):l(a,b[n],p,e)}}function m(a){if(!n)return d.ready().then(function(){return n=!0,i(a)});try{return i(a)}catch(b){return h.wrapError(b)}}var n=!1,o=d.requireSupportedForProcessing;c.Namespace._moduleDefine(a,"WinJS.Resources",{processAll:m})}),define("WinJS/Pages/_BasePage",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_WriteProfilerMark","../Promise","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a){var c=b.document.createElement("a");return c.href=a,c.href}function k(a){return b.document.location.href.toLowerCase()===a.toLowerCase()}function l(a,h){var l=m(a);return a=j(a),l||(l=c.Class.define(function(c,g,h,j){var l=this;this._disposed=!1,this.element=c=c||b.document.createElement("div"),i.addClass(c,"win-disposable"),c.msSourceLocation=a,this.uri=a,this.selfhost=k(a),c.winControl=this,i.addClass(c,"pagecontrol");var m=" uri='"+a+"'"+d._getProfilerMarkIdentifier(this.element);e("WinJS.UI.Pages:createPage"+m+",StartTM");var n=f.wrap().then(function(){return l.load(a)}),o=n.then(function(a){return f.join({loadResult:a,initResult:l.init(c,g)})}).then(function(a){return l.render(c,g,a.loadResult)});this.elementReady=o.then(function(){return c}),this.renderComplete=o.then(function(){return l.process(c,g)}).then(function(){return l.processed(c,g)}).then(function(){return l});var p=function(){h&&h(l),e("WinJS.UI.Pages:createPage"+m+",StopTM")};this.renderComplete.then(p,p),this.renderComplete.then(function(){return j}).then(function(){l.ready(c,g)}).then(null,function(a){return l.error(a)})},p),l=c.Class.mix(l,g.DOMEventMixin),o[a.toLowerCase()]=l),h&&(l=c.Class.mix(l,h)),l.selfhost=k(a),l}function m(a){return a=j(a),o[a.toLowerCase()]}function n(a){a=j(a),delete o[a.toLowerCase()]}if(b.document){var o={},p={dispose:function(){this._disposed||(this._disposed=!0,h.disposeSubTree(this.element),this.element=null)},load:function(){},init:function(){},process:function(){},processed:function(){},render:function(){},ready:function(){},error:function(a){return f.wrapError(a)}};c.Namespace._moduleDefine(a,null,{abs:j,define:l,get:m,remove:n})}}),define("WinJS/Pages",["exports","./Core/_Global","./Core/_Base","./Core/_BaseUtils","./ControlProcessor","./Fragments","./Pages/_BasePage","./Promise"],function(a,b,c,d,e,f,g){"use strict";function h(a,e){var f=g.get(a);return f||(f=g.define(a,l)),e&&(f=c.Class.mix(f,e)),f.selfhost&&d.ready(function(){k(g.abs(a),b.document.body)},!0),f}function i(a){var b=g.get(a);return b||(b=h(a)),b}function j(a){f.clearCache(g.abs(a)),g.remove(a)}function k(a,b,c,d){var e=i(a),f=new e(b,c,null,d);return f.renderComplete}if(b.document){var l={load:function(a){return this.selfhost?void 0:f.renderCopy(g.abs(a))},process:function(a){return e.processAll(a)},render:function(a,b,c){return this.selfhost||a.appendChild(c),a}};c.Namespace._moduleDefine(a,"WinJS.UI.Pages",{define:h,get:i,_remove:j,render:k})}}),define("WinJS/Controls/HtmlControl",["exports","../Core/_Global","../Core/_Base","../Pages"],function(a,b,c,d){"use strict";b.document&&c.Namespace._moduleDefine(a,"WinJS.UI",{HtmlControl:c.Class.define(function(a,b,c){d.render(b.uri,a,b).then(c,function(){c()})})})}),define("WinJS/VirtualizedDataSource/_VirtualizedDataSourceImpl",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../Scheduler","../_Signal","../Utilities/_UI"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{VirtualizedDataSource:c.Namespace._lazy(function(){function a(a,c){function f(a){var b="WinJS.UI.VirtualizedDataSource:"+pe+":"+a+",StartTM";i(b),g.log&&g.log(b,"winjs vds","perf")}function u(a){var b="WinJS.UI.VirtualizedDataSource:"+pe+":"+a+",StopTM";i(b),g.log&&g.log(b,"winjs vds","perf")}function v(a){return"number"==typeof a&&a>=0}function w(a){return v(a)&&a===Math.floor(a)}function x(a){if(null===a)a=void 0;else if(void 0!==a&&!w(a))throw new e("WinJS.UI.ListDataSource.InvalidIndexReturned",s.invalidIndexReturned);return a}function y(a){if(null===a)a=void 0;else if(void 0!==a&&!w(a)&&a!==p.unknown)throw new e("WinJS.UI.ListDataSource.InvalidCountReturned",s.invalidCountReturned);return a}function z(){var a=(nd++).toString(),b={handle:a,item:null,itemNew:null,fetchListeners:null,cursorCount:0,bindingMap:null};return Nd[a]=b,b}function A(){return z()}function B(a,b){a.prev=b.prev,a.next=b,a.prev.next=a,b.prev=a}function C(a){a.lastInSequence&&(delete a.lastInSequence,a.prev.lastInSequence=!0),a.firstInSequence&&(delete a.firstInSequence,a.next.firstInSequence=!0),a.prev.next=a.next,a.next.prev=a.prev}function D(a){for(;!a.firstInSequence;)a=a.prev;return a}function E(a){for(;!a.lastInSequence;)a=a.next;return a}function F(a,b,c){return b.prev.next=c.next,c.next.prev=b.prev,b.prev=a.prev,c.next=a,b.prev.next=b,a.prev=c,!0}function G(a,b,c){return b.prev.next=c.next,c.next.prev=b.prev,b.prev=a,c.next=a.next,a.next=b,c.next.prev=c,!0}function H(a){delete a.lastInSequence,delete a.next.firstInSequence}function I(a){var b=a.next;a.lastInSequence=!0,b.firstInSequence=!0,b===Ld&&nb(Ld,void 0)}function J(a,b,c,d){B(a,b);var e=a.prev;e.lastInSequence&&(c?delete e.lastInSequence:a.firstInSequence=!0,d?delete b.firstInSequence:a.lastInSequence=!0)}function K(a,b){a.key=b,Od[a.key]=a}function L(a,b,c){+b===b&&(a.index=b,c[b]=a,Ad||(a.firstInSequence&&a.prev&&a.prev.index===b-1&&H(a.prev),a.lastInSequence&&a.next&&a.next.index===b+1&&H(a)))}function M(a,b){var c=b===Pd?A():z();return B(c,a),c}function N(a,b,c){var d=M(a,c);return d.firstInSequence=!0,d.lastInSequence=!0,L(d,b,c),d}function O(a,b){return N(a,b,Pd)}function P(a,b){var c=M(a,b);return delete a.firstInSequence,c.prev.index===c.index-1?delete c.prev.lastInSequence:c.firstInSequence=!0,L(c,a.index-1,b),c}function Q(a,b){var c=M(a.next,b);return delete a.lastInSequence,c.next.index===c.index+1?delete c.next.firstInSequence:c.lastInSequence=!0,L(c,a.index+1,b),c}function R(a,b,c,d){J(a,b,c,d),Od[a.key]=a,void 0!==a.index&&(Pd[a.index]=a)}function S(a){C(a),a.key&&delete Od[a.key],void 0!==a.index&&Pd[a.index]===a&&delete Pd[a.index];var b=a.bindingMap;for(var c in b){var d=b[c].handle;d&&Nd[d]===a&&delete Nd[d]}Nd[a.handle]===a&&delete Nd[a.handle]}function T(a){return!Nd[a.handle]}function U(a,b,c,d,e){var f=e?null:b[a-1];if(f&&(f.next!==d||d.firstInSequence))f=f.next;else if(f=b[a+1],!f){f=c.next;for(var g;;){if(f.firstInSequence&&(g=f),!(a>=f.index)||f===d)break;f=f.next}f!==d||d.firstInSequence||(f=g&&void 0===g.index?g:void 0)}return f}function V(a){return!a.item&&!a.itemNew&&a!==Ld}function W(a,b){Object.defineProperty(a,"handle",{value:b,writable:!1,enumerable:!1,configurable:!0})}function X(a,b,c){W(a,c),Object.defineProperty(a,"index",{get:function(){for(;b.slotMergedWith;)b=b.slotMergedWith;return b.index},enumerable:!1,configurable:!0})}function Y(a){if(void 0===a)return a;var b=JSON.stringify(a);if(void 0===b)throw new e("WinJS.UI.ListDataSource.ObjectIsNotValidJson",s.objectIsNotValidJson);return b}function Z(b){return a.itemSignature?a.itemSignature(b.data):Y(b.data)}function $(b){var c=b.itemNew;b.itemNew=null,c&&(c=Object.create(c),X(c,b,b.handle),a.compareByIdentity||(b.signature=Z(c))),b.item=c,delete b.indexRequested,delete b.keyRequested}function _(a){return a.bindingMap||a.cursorCount>0}function ab(a){return _(a)||a.fetchListeners||a.directFetchListeners}function bb(a){return ab(a)||!a.firstInSequence&&_(a.prev)||!a.lastInSequence&&_(a.next)||!ie&&(!a.firstInSequence&&a.prev!==Kd&&!(a.prev.item||a.prev.itemNew))|(!a.lastInSequence&&a.next!==Ld&&!(a.next.item||a.next.itemNew))}function cb(a){I(a),S(a)}function db(){if(!vd){(!Rd||T(Rd))&&(Rd=Ld.prev);for(var a=Rd.prev,b=Rd.next,c=0,d=function(a){a===Ld||bb(a)||(hd>=c?c++:cb(a))};a||b;){if(a){var e=a;a=e.prev,e!==Kd&&d(e)}if(b){var f=b;b=f.next,f!==Md&&d(f)}}Qd=0}}function eb(a){ab(a)||(Qd++,vd||Ud||(Rd=a,Qd>hd&&!Sd&&(Sd=!0,k.schedule(function(){Sd=!1,db()},k.Priority.idle,null,"WinJS.UI.VirtualizedDataSource.releaseSlotIfUnrequested"))))}function fb(a){for(var b in ld)a(ld[b])}function gb(a,b){for(var c in a.bindingMap)b(a.bindingMap[c].bindingRecord,c)}function hb(a){return a.notificationsSent||(a.notificationsSent=!0,a.notificationHandler.beginNotifications&&a.notificationHandler.beginNotifications()),a.notificationHandler}function ib(){sd||yd||fb(function(a){a.notificationsSent&&(a.notificationsSent=!1,a.notificationHandler.endNotifications&&a.notificationHandler.endNotifications())})}function jb(a,b){var c=a.bindingMap;if(c){var d=c[b];if(d){var e=d.handle;if(e)return e}}return a.handle}function kb(a,b){return a&&a.handle!==b&&(a=Object.create(a),W(a,b)),a}function lb(a){var b=Jd;Jd=a,fb(function(a){a.notificationHandler&&a.notificationHandler.countChanged&&hb(a).countChanged(Jd,b)})}function mb(a,b){gb(a,function(c,d){c.notificationHandler.indexChanged&&hb(c).indexChanged(jb(a,d),a.index,b)})}function nb(a,b){var c=a.index;if(void 0!==c&&Pd[c]===a&&delete Pd[c],+b===b)L(a,b,Pd);else{if(+c!==c)return;delete a.index}mb(a,c)}function ob(a,b,c,d,e){var f={};if(!(!d&&b.lastInSequence||!e&&c.firstInSequence))if(b===Kd)if(c===Ld)for(var g in ld)f[g]=ld[g];else for(var g in c.bindingMap)f[g]=ld[g];else if(c===Ld||c.bindingMap)for(var g in b.bindingMap)(c===Ld||c.bindingMap[g])&&(f[g]=ld[g]);for(var g in a.bindingMap)f[g]=ld[g];return f}function pb(a){var b,c=a.prev,d=a.next,e=ob(a,c,d);for(b in e){var f=e[b];f.notificationHandler&&hb(f).inserted(f.itemPromiseFromKnownSlot(a),c.lastInSequence||c===Kd?null:jb(c,b),d.firstInSequence||d===Ld?null:jb(d,b))}}function qb(a){var b=a.item;$(a),gb(a,function(c,d){var e=jb(a,d);hb(c).changed(kb(a.item,e),kb(b,e))})}function rb(a,b,c,d,e){var f,g=b.prev;if(b===a){if(!a.firstInSequence||!c)return;b=a.next}else if(g===a){if(!a.lastInSequence||!d)return;g=a.prev}if(!e){var h=ob(a,g,b,c,d);for(f in h){var i=h[f];hb(i).moved(i.itemPromiseFromKnownSlot(a),(g.lastInSequence||g===a.prev)&&!c||g===Kd?null:jb(g,f),(b.firstInSequence||b===a.next)&&!d||b===Ld?null:jb(b,f))}fb(function(b){b.adjustCurrentSlot(a)})}C(a),J(a,b,c,d)}function sb(a,b){Bb(a,!0),gb(a,function(c,d){hb(c).removed(jb(a,d),b)}),fb(function(b){b.adjustCurrentSlot(a)}),S(a)}function tb(a){for(;!a.firstInSequence;)a=a.prev;var b;do{b=a.lastInSequence;var c=a.next;sb(a,!0),a=c}while(!b)}function ub(a){var b;if(!a)return b;for(var c=0;!a.firstInSequence;)c++,a=a.prev;return"number"==typeof a.indexNew?a.indexNew+c:"number"==typeof a.index?a.index+c:b}function vb(a,b){for(a=a.next;a;a=a.next)if(a.firstInSequence){var c=void 0!==a.indexNew?a.indexNew:a.index;void 0!==c&&(a.indexNew=c+b)}zd+=b,Ad=!0,Ud?wc():Cd++}function wb(a,b){if(a.firstInSequence){var c;if(0>b)c=a.indexNew,void 0!==c?delete a.indexNew:c=a.index,a.lastInSequence||(a=a.next,void 0!==c&&(a.indexNew=c));else if(!a.lastInSequence){var d=a.next;c=d.indexNew,void 0!==c?delete d.indexNew:c=d.index,void 0!==c&&(a.indexNew=c)}}vb(a,b)}function xb(a,b){for(var c=Kd;c!==Ld;c=c.next){var d=c.indexNew;if(void 0!==d&&d>=a){vb(c,b);break}}}function yb(){var a,b,c;for(a=Kd;;a=a.next){if(a.firstInSequence){if(b=a,void 0!==a.indexNew){if(c=a.indexNew,delete a.indexNew,isNaN(c))break}else c=a.index;a!==Kd&&a.prev.index===c-1&&H(a.prev)}if(a.lastInSequence)for(var d=c,e=b;e!==a.next;e=e.next)d!==e.index&&nb(e,d),+d===d&&d++;if(a===Ld)break}for(;a!==Md;a=a.next)void 0!==a.index&&a!==Ld&&nb(a,void 0);Ad=!1,zd&&+Jd===Jd&&(pd?pd.reset():lb(Jd+zd),zd=0)}function zb(a,b,c,d,e){if(a.item)return new j(function(b){e?e(b,a.item):b(a.item)});var f={listBindingID:d,retained:!1};return a[b]||(a[b]={}),a[b][c]=f,f.promise=new j(function(a,b){f.complete=e?function(b){e(a,b)}:a,f.error=b},function(){for(;a.slotMergedWith;)a=a.slotMergedWith;var d=a[b];if(d){if(delete d[c],Object.keys(d).length>0)return;delete a[b]}eb(a)}),f.promise}function Ab(a,b){for(var c in b)b[c].complete(a)}function Bb(a,b){var c=a.fetchListeners,d=a.directFetchListeners;if(c||d){$(a);var e=a.item,f=function(a){b?Ab(e,a):Gd.push(function(){Ab(e,a)})};d&&(a.directFetchListeners=null,f(d)),c&&(a.fetchListeners=null,f(c)),eb(a)}}function Cb(){var a=Gd;Gd=[];for(var b=0,c=a.length;c>b;b++)a[b]()}function Db(a,b){var c=a.directFetchListeners;if(c){a.directFetchListeners=null;for(var d in c)c[d].error(b);eb(a)}}function Eb(a){return a.firstInSequence&&P(a,Pd),a.lastInSequence&&Q(a,Pd),a.itemNew&&$(a),ac(),a}function Fb(a){if(!a.firstInSequence){var b=a.prev;return b===Kd?null:Eb(b)}return Eb(P(a,Pd))}function Gb(a){if(!a.lastInSequence){var b=a.next;return b===Ld?null:Eb(b)}return Eb(Q(a,Pd))}function Hb(a){return a?zb(a,"directFetchListeners",(od++).toString()):j.wrap(null)}function Ib(a){if("string"!=typeof a||!a)throw new e("WinJS.UI.ListDataSource.KeyIsInvalid",s.keyIsInvalid)}function Jb(a){var b=O(Md);return K(b,a),b.keyRequested=!0,b}function Kb(a,b){Ib(a);var c=Od[a];return c||(c=Jb(a),c.hints=b),Eb(c)}function Lb(a){if("number"!=typeof a||0>a)throw new e("WinJS.UI.ListDataSource.IndexIsInvalid",s.indexIsInvalid);if(Ld.index<=a)return null;var b=Pd[a];if(!b){var c=U(a,Pd,Kd,Ld);if(!c)return null;c===Ld&&a>=Ld&&nb(Ld,void 0),b=c.prev.index===a-1?Q(c.prev,Pd):c.index===a+1?P(c,Pd):O(c,a)}return b.item||(b.indexRequested=!0),Eb(b)}function Mb(a){var b=O(Md);return b.description=a,Eb(b)}function Nb(a){if(jd=a,id!==jd){var c=function(){kd=!1,id!==jd&&(id=jd,qe.dispatchEvent(t,id))};jd===o.failure?c():kd||(kd=!0,b.setTimeout(c,40))}}function Ob(a){var b=a.fetchID;return b&&Fd[b]}function Pb(a,b){a.fetchID=b}function Qb(){var a=Ed;return Ed++,Fd[a]=!0,a}function Rb(a,b,c){var d=Qb();Pb(a,d);for(var e=a;!e.firstInSequence&&b>0;)e=e.prev,b--,Pb(e,d);for(var f=a;!f.lastInSequence&&c>0;)f=f.next,c--,Pb(f,d);return d}function Sb(a){var b=a.items,c=a.offset,d=a.totalCount,e=a.absoluteIndex,f=a.atStart,g=a.atEnd;if(v(e)){if(v(d)){var h=b.length;e-c+h===d&&(g=!0)}c===e&&(f=!0)}f&&(b.unshift(Hd),a.offset++),g&&b.push(Id)}function Tb(a,b,c){return delete Fd[c],b!==Cd||T(a)?(ac(),!1):!0}function Ub(a,b,c,d){var g=Cd;c.then(function(c){if(!c.items||!c.items.length)return j.wrapError(new e(q.doesNotExist));var h="itemsFetched id="+b+" count="+c.items.length;f(h),Tb(a,g,b)&&(+d===d&&(c.absoluteIndex=d),Sb(c),qc(a,c.items,c.offset,c.totalCount,c.absoluteIndex)),u(h)}).then(null,function(c){Tb(a,g,b)&&rc(a,c)})}function Vb(a,b,c,d){var g=Cd;d.then(function(d){if(!d.items||!d.items.length)return j.wrapError(new e(q.doesNotExist));var h="itemsFetched id="+c+" count="+d.items.length;f(h),Tb(b,g,c)&&(d.absoluteIndex=a,Sb(d),sc(a,b,d.items,d.offset,d.totalCount,d.absoluteIndex)),u(h)}).then(null,function(){Tb(b,g,c)&&tc(a,b,g)})}function Wb(a,b){var c=Rb(a,0,b-1);je?Ub(a,c,je(c,b),0):Ub(a,c,ie(c,0,0,b-1),0)}function Xb(a,b){var c=Rb(a,b-1,0);Ub(a,c,ke(c,b))}function Yb(a,b,c){var d=Rb(a,b,c);Ub(a,d,he(d,a.key,b,c,a.hints))}function Zb(a,b,c){var d=a.index;if(b>d&&(b=d),ie){var e=Rb(a,b,c);Ub(a,e,ie(e,d,b,c),d)}else if(a.key)Yb(a,b,c);else{var f,g,h=Kd,i=d+1;for(f=a.prev;f!==Kd;f=f.prev)if(void 0!==f.index&&f.key){g=d-f.index,i>g&&(i=g,h=f);break}for(f=a.next;f!==Ld;f=f.next)if(void 0!==f.index&&f.key){g=f.index-d,i>g&&(i=g,h=f);break}if(h===Kd){var e=Rb(a,0,d+1);Vb(0,a,e,je(e,d+1))}else{var j=Math.max(h.index-d,0),k=Math.max(d-h.index,0),e=Rb(h,j,k);Vb(h.index,a,e,he(e,h.key,j,k,a.hints))}}}function $b(a,b,c){var d=Rb(a,b,c);Ub(a,d,le(d,a.description,b,c))}function _b(){if(!Ud){for(var a,b,c,d,e,f,g,h,i=!1,j=!1,k=Kd.next;k!==Md;){var l=k.next;if(k!==Ld&&V(k)&&(j=!0,a?b++:(a=k,b=1),Ob(k)&&(i=!0),k.keyRequested&&!c&&(c=k,d=b-1),void 0===k.description||e||(e=k,f=b-1),k.indexRequested&&!g&&(g=k,h=b-1),k.lastInSequence||l===Md||!V(l))){if(i)i=!1;else{if(qd=!1,!a.firstInSequence&&a.prev.key&&he?Yb(a.prev,0,b):!k.lastInSequence&&l.key&&he?Yb(l,b,0):a.prev!==Kd||a.firstInSequence||!je&&!ie?l===Ld&&!k.lastInSequence&&ke?Xb(k,b):c?Yb(c,d,b-1-d):e?$b(e,f,b-1-f):g?Zb(g,h,b-1-h):"number"==typeof a.index?Zb(a,b-1,0):tb(a):Wb(a,b),qd)return void ac();if(Ud)return}a=g=c=null}k=l}Nb(j?o.waiting:o.ready)}}function ac(){Dd||(Dd=!0,k.schedule(function(){Dd=!1,_b(),ib()},k.Priority.max,null,"WinJS.UI.ListDataSource._fetch"))}function bc(b){var c=b.itemNew;if(!c)return!1;var d=b.item;for(var e in d)switch(e){case"data":break;default:if(d[e]!==c[e])return!0}return a.compareByIdentity?d.data!==c.data:b.signature!==Z(c)}function cc(a){ab(a)?bc(a)?qb(a):a.itemNew=null:a.item=null}function dc(a){a.item?cc(a):Bb(a)}function ec(a,b){a.key||K(a,b.key),a.itemNew=b,dc(a)}function fc(a,b,c){var d=b.bindingMap;if(d)for(var e in c)if(d[e]){var f=b.fetchListeners;for(var g in f){var h=f[g];h.listBindingID===e&&h.retained&&(delete f[g],h.complete(null))}var i=d[e].bindingRecord;hb(i).removed(jb(b,e),!0,jb(a,e)),b.bindingMap&&delete b.bindingMap[e]}}function gc(a,b){if(a.index!==b.index){var c=b.index;b.index=a.index,mb(b,c)}b.slotMergedWith=a;var d=b.bindingMap;for(var e in d){a.bindingMap||(a.bindingMap={});var f=d[e];f.handle||(f.handle=b.handle),Nd[f.handle]=a,a.bindingMap[e]=f}fb(function(c){c.adjustCurrentSlot(b,a)});var g=b.itemNew||b.item;if(g&&(g=Object.create(g),X(g,a,a.handle),ec(a,g)),a.item)b.directFetchListeners&&Gd.push(function(){Ab(a.item,b.directFetchListeners)}),b.fetchListeners&&Gd.push(function(){Ab(a.item,b.fetchListeners)});else{var h;for(h in b.directFetchListeners)a.directFetchListeners||(a.directFetchListeners={}),a.directFetchListeners[h]=b.directFetchListeners[h];for(h in b.fetchListeners)a.fetchListeners||(a.fetchListeners={}),a.fetchListeners[h]=b.fetchListeners[h]}a.itemNew&&Bb(a),b.handle=(nd++).toString(),I(b),S(b)}function hc(a,b,c){b&&b.key&&(c||(c=b.itemNew||b.item),delete b.key,delete Od[c.key],b.itemNew=null,b.item=null),c&&ec(a,c),b&&gc(a,b)}function ic(a){if("object"!=typeof a)throw new e("WinJS.UI.ListDataSource.InvalidItemReturned",s.invalidItemReturned);if(a===Hd)return Kd;if(a===Id)return Ld;if(a.key)return d.validation&&Ib(a.key),Od[a.key];throw new e("WinJS.UI.ListDataSource.InvalidKeyReturned",s.invalidKeyReturned)}function jc(a,b){var c=ic(b);c===a&&(c=null),c&&fc(a,c,a.bindingMap),hc(a,c,b)}function kc(a,b,c,d){if(b&&a.key&&a.key!==b.key)return wc(),!1;var e=Pd[c];if(e)if(e===a)e=null;else{if(e.key&&(a.key||b&&e.key!==b.key))return wc(),!1;if(!a.key&&e.bindingMap)return!1}var f;if(b)if(f=Od[b.key],f===a)f=null;else if(f&&f.bindingMap)return!1;return e?(fc(a,e,a.bindingMap),delete Pd[c],nb(a,c),a.prev.index===c-1&&H(a.prev),a.next.index===c+1&&H(a),d.slotNext=e.slotNext,b||(b=e.itemNew||e.item,b&&(f=Od[b.key]))):nb(a,c),f&&e!==f&&fc(a,f,a.bindingMap),hc(a,f,b),e&&e!==f&&gc(a,e),!0}function lc(a,b,c){if(b.key&&a.key&&b.key!==a.key)return wc(),!1;for(var d in a.bindingMap)c[d]=!0;return fc(a,b,c),hc(a,b),!0}function mc(a,b){for(var c={};a;){var d=a.firstInSequence?null:a.prev;if(b.firstInSequence||b.prev!==Kd){if(b=b.firstInSequence?P(b,Pd):b.prev,!lc(b,a,c))return}else sb(a,!0);a=d}}function nc(a,b){for(var c={};a;){var d=a.lastInSequence?null:a.next;if(b.lastInSequence||b.next!==Ld){if(b=b.lastInSequence?Q(b,Pd):b.next,!lc(b,a,c))return}else sb(a,!0);a=d}}function oc(a){for(var b=0;b0;){var f=e.prev;if(e===Kd){c(Kd);break}if(e.key){if(e.index>=a)return wc(),!1;if(!(e.index>=b))return he?Yb(e,0,d):Zb(e,0,d),!1;c(e)}else e.indexRequested||e.firstInSequence?c(f):d++;e=f}return!0}function qc(a,b,c,d,e){var g="WinJS.UI.ListDataSource.processResults";return f(g),e=x(e),d=y(d),vd?void u(g):(Ad&&yb(),!v(d)&&d!==p.unknown||d===Jd||Ld.firstInSequence?(qd=!0,function(){var f,g,h,i,j=b.length;if("number"!=typeof e)for(f=0;j>f;f++)if(h=ic(b[f]),h&&void 0!==h.index){e=h.index+c-f;break}"number"==typeof e&&b[j-1]===Id?d=e-c+j-1:!v(d)||void 0!==e&&null!==e||(e=d-(j-1)+c),v(d)&&!pc(d,e-c)&&(d=void 0);var k=new Array(j);for(f=0;j>f;f++){var l=null;if(h=ic(b[f])){if(f>0&&!h.firstInSequence&&h.prev.key&&h.prev.key!==b[f-1].key||"number"==typeof e&&void 0!==h.index&&h.index!==e-c+f)return void wc();(h===Kd||h===Ld||h.bindingMap)&&(l=h)}if("number"==typeof e&&(h=Pd[e-c+f])){if(h.key&&h.key!==b[f].key)return void wc();!l&&h.bindingMap&&(l=h)}if(f===c){if(a.key&&a.key!==b[f].key||"number"==typeof a.index&&"number"==typeof e&&a.index!==e)return void wc();l||(l=a)}k[f]=l}for(f=0;j>f;f++)h=k[f],h&&void 0!==h.index&&h!==Kd&&h!==Ld&&jc(h,b[f]);var m,n,o=[],p=!0;for(f=0;j>f;f++)if(h=k[f],h&&h!==Ld){var q=f;if(void 0===h.index){var r={};kc(h,b[f],e-c+f,r);var s,t=h,u=h;for(g=f-1;!t.firstInSequence&&(s=b[g],s!==Hd);g--){var w=e-c+g;if(0>w)break;if(!kc(t.prev,s,w,r))break;t=t.prev,g>=0&&(k[g]=t)}for(g=f+1;!u.lastInSequence&&(s=b[g],s!==Id&&g!==d||u.next===Ld)&&(u.next===Ld||kc(u.next,s,e-c+g,r))&&(u=u.next,j>g&&(k[g]=u),q=g,u!==Ld);g++);if(m=t.firstInSequence?null:t.prev,n=u.lastInSequence?null:u.next,m&&I(m),n&&I(u),"number"==typeof e){if(u===Ld)m&&G(Ld,D(m),m); +else{var x=r.slotNext;x||(x=U(u.index,Pd,Kd,Ld,!0)),F(x,t,u)}t.prev.index===t.index-1&&H(t.prev),u.next.index===u.index+1&&H(u)}else p||(i=k[f-1],i&&(t.prev!==i&&(u===Ld?(m&&G(Ld,D(m),m),F(t,D(i),i)):G(i,t,u)),H(i)));if(p=!1,Td)return;o.push({slotBeforeSequence:m,slotFirstInSequence:t,slotLastInSequence:u,slotAfterSequence:n})}f!==c||h===a||T(a)||(m=a.firstInSequence?null:a.prev,n=a.lastInSequence?null:a.next,fc(h,a,h.bindingMap),gc(h,a),o.push({slotBeforeSequence:m,slotFirstInSequence:h,slotLastInSequence:h,slotAfterSequence:n})),f=q}for(v(d)&&Ld.index!==d&&nb(Ld,d),oc(o),f=0;j>f;f++)if(h=k[f]){for(g=f-1;g>=0;g--){var y=k[g+1];jc(k[g]=y.firstInSequence?P(k[g+1],Pd):y.prev,b[g])}for(g=f+1;j>g;g++)i=k[g-1],h=k[g],h?h.firstInSequence&&(h.prev!==i&&G(i,h,E(h)),H(i)):jc(k[g]=i.lastInSequence?Q(i,Pd):i.next,b[g]);break}delete a.description}(),Td||(void 0!==d&&d!==Jd&&lb(d),ac()),ib(),Cb(),void u(g)):(wc(),void u(g)))}function rc(a,b){switch(b.name){case q.noResponse:Nb(o.failure),Db(a,b);break;case q.doesNotExist:a.indexRequested?pc(a.index):(a.keyRequested||a.description)&&tb(a),ib(),wc()}}function sc(a,b,c,d,f,g){g=x(g),f=y(f);var h=a-d,i=c.length;if(b.index>=h&&b.indexa&&b+(b-a)e;e++)if(ne[a+e].kind!==ne[b+e].kind){c=!1;break}if(c&&g.log){g.log(s.refreshCycleIdentified,"winjs vds","error");for(var e=a;b>e;e++)g.log(""+(e-a)+": "+JSON.stringify(ne[e]),"winjs vds","error")}return c}}function vc(){return++me>h&&uc()?void Nb(o.failure):(ne[++oe%ne.length]={kind:"beginRefresh"},Zd={firstInSequence:!0,lastInSequence:!0,index:-1},$d={firstInSequence:!0,lastInSequence:!0},Zd.next=$d,$d.prev=Zd,Xd=!1,Yd=void 0,_d={},ae={},be={},be[-1]=Zd,void(ce={}))}function wc(){if(!Td){if(Td=!0,Nb(o.waiting),xd)return xd=!1,void Zc();if(!vd){var a=++Cd;Ud=!0,Wd=0,k.schedule(function(){if(Cd===a){Td=!1,vc();for(var b=Kd.next;b!==Md;){var c=b.next;bb(b)||b===Ld||cb(b),b=c}Ec()}},k.Priority.high,null,"WinJS.VirtualizedDataSource.beginRefresh")}}}function xc(){return Vd=Vd||new l,wc(),Vd.promise}function yc(a,b){return delete Fd[b],a!==Cd?!1:(Wd--,!0)}function zc(a,b,c,d,g){var h=Cd;Wd++,d.then(function(b){if(!b.items||!b.items.length)return j.wrapError(new e(q.doesNotExist));var d="itemsFetched id="+c+" count="+b.items.length;f(d),yc(h,c)&&(Sb(b),Kc(a,b.items,b.offset,b.totalCount,"number"==typeof g?g:b.absoluteIndex)),u(d)}).then(null,function(d){yc(h,c)&&Lc(a,b,d)})}function Ac(a,b,c,d){if(he)zc(a.key,!1,b,he(b,a.key,c,d,a.hints));else{var e=10,f=a.index;be[f]&&be[f].firstInSequence?zc(a.key,!1,b,ie(b,f-1,Math.min(c+e,f)-1,d+1+e),f-1):be[f]&&be[f].lastInSequence?zc(a.key,!1,b,ie(b,f+1,Math.min(c+e,f)+1,d-1+e),f+1):zc(a.key,!1,b,ie(b,f,Math.min(c+e,f),d+e),f)}}function Bc(a){je?zc(null,!0,a,je(a,1),0):ie&&zc(null,!0,a,ie(a,0,0,0),0)}function Cc(a){return Fd[_d[a]]}function Dc(a,b){for(var c,d,e,f=3,g=Cd,h=0,i=a;i!==Md;i=i.next){if(!c&&i.key&&!ce[i.key]&&!Cc(i.key)){var j=ae[i.key];(!j||j.firstInSequence||j.lastInSequence)&&(c=i,d=j,e=Qb())}if(c){var k=Cc(i.key);if(ce[i.key]||ae[i.key]||k||(i.key&&(_d[i.key]=e),h++),i.lastInSequence||i.next===Ld||k){if(Ac(c,e,!d||d.firstInSequence?f:0,h-1+f),!b)break;c=null,h=0}}else i.key&&V(i)&&!ce[i.key]&&(ae[i.key]||(e=Qb(),zc(i.key,!1,e,he(e,i.key,1,1,i.hints))))}0!==Wd||Xd||Cd!==g||Bc(Qb())}function Ec(){var a=Cd;do de=!1,ee=!0,Dc(Kd.next,!0),ee=!1;while(0===Wd&&de&&Cd===a&&Ud);0===Wd&&Cd===a&&Uc()}function Fc(a){var b=Cd;if(a){var c=Od[a];c||(c=Kd.next);do fe=!1,ge=!0,Dc(c,!1),ge=!1;while(fe&&Cd===b&&Ud)}ee?de=!0:0===Wd&&Cd===b&&Ec()}function Gc(a){if("object"==typeof a&&a){if(a===Hd)return Zd;if(a===Id)return $d;if(a.key)return ae[a.key];throw new e("WinJS.UI.ListDataSource.InvalidKeyReturned",s.invalidKeyReturned)}throw new e("WinJS.UI.ListDataSource.InvalidItemReturned",s.invalidItemReturned)}function Hc(a,b){for(;void 0===a.index;){if(L(a,b,be),a.firstInSequence)return!0;a=a.prev,b--}return a.index!==b?(wc(),!1):!0}function Ic(a,b){a.key=b.key,ae[a.key]=a,a.item=b}function Jc(){for(var a=$d;!a.firstInSequence;)if(a=a.prev,a===Zd)return null;return a}function Kc(a,b,c,d,e){e=x(e),d=y(d);var f=!1;Xd=!0;var g=e-c,h=b[0];h.key===a&&(f=!0);var i=Gc(h);if(i){if(+g===g&&!Hc(i,g))return}else{if(be[g])return void wc();var j;if(void 0!==e&&(j=be[g-1])){if(!j.lastInSequence)return void wc();i=Q(j,be)}else{var k=+g===g?U(g,be,Zd,$d):Jc(Zd,$d);if(!k)return void wc();i=N(k,g,be)}Ic(i,b[0])}for(var l=b.length,m=1;l>m;m++){h=b[m],h.key===a&&(f=!0);var n=Gc(h);if(n){if(void 0!==i.index&&!Hc(n,i.index+1))return;if(n!==i.next){if(!i.lastInSequence||!n.firstInSequence)return void wc();var o=E(n);if(o!==$d)G(i,n,o);else{var q=D(i);if(q===Zd)return void wc();F(n,q,i)}H(i)}else i.lastInSequence&&H(i)}else{if(!i.lastInSequence)return void wc();n=Q(i,be),Ic(n,h)}i=n}if(f||(ce[a]=!0),!v(d)&&!$d.firstInSequence){var r=$d.prev.index;void 0!==r&&(d=r+1)}if(v(d)||d===p.unknown){if(v(Yd)){if(d!==Yd)return void wc()}else Yd=d;v(Yd)&&!be[Yd]&&L($d,Yd,be)}ge?fe=!0:Fc(a)}function Lc(a,b,c){switch(c.name){case q.noResponse:Nb(o.failure);break;case q.doesNotExist:b?(L($d,0,be),Yd=0,Uc()):(ce[a]=!0,ge?fe=!0:Fc(a))}}function Mc(a){return a===Zd?Kd:a===$d?Ld:Od[a.key]}function Nc(a){return a===Kd?Zd:a===Ld?$d:ae[a.key]}function Oc(a){H(a),a.next.mergedForRefresh=!0}function Pc(a,b){K(b,a.key),b.itemNew=a.item}function Qc(a,b,c){var d=A();Pc(a,d),J(d,b,c,!c);var e=a.index;return+e!==e&&(e=c?d.prev.index+1:b.next.index-1),L(d,e,Pd),d}function Rc(a,b,c){a?(fc(a,b,a.bindingMap),hc(a,b,c.item)):(Pc(c,b),b.indexRequested&&dc(b))}function Sc(a,b,c){return b.key?!1:(a?(c.mergeWithPrev=!b.firstInSequence,c.mergeWithNext=!b.lastInSequence):c.stationary=!0,Rc(a,b,c),!0)}function Tc(a){var b;if(a.indexRequested)b=a.index;else{var c=Nc(a);c&&(b=c.index)}return b}function Uc(){me=0,ne=new Array(100),oe=-1,Ad=!0,_d={};var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=[],t=[];for(o=0,h=Zd;h;h=h.next)h.sequenceNumber=o,h.firstInSequence&&(j=h),h.lastInSequence&&(t[o]={first:j,last:h,matchingItems:0},o++);for(Rd=null,Qd=0,c=Kd.next;c!==Md;)h=ae[c.key],e=c.next,c!==Ld&&(bb(c)?c.key&&!h?sb(c,!1):0===Yd||c.indexRequested&&c.index>=Yd?sb(c,!0):c.item||c.keyRequested?c.itemNew=h.item:c.key&&(c.keyRequested||(delete Od[c.key],delete c.key),c.itemNew=null):cb(c)),c=e;for(c=Kd.next;c!==Ld;)e=c.next,c.indexRequested&&(h=be[c.index],h&&Rc(Mc(h),c,h)),c=e;var u,v,w,x,y,z=0,A=[];for(k=0,c=Kd;c!==Md;c=c.next){if(c.firstInSequence)for(j=c,w=null,a=0;o>a;a++)A[a]=0;if(c.indexRequested&&(w=c),h=Nc(c),h&&A[h.sequenceNumber]++,c.lastInSequence){for(v=0,a=z;o>a;a++)v0?t[u]:void 0,matchingItems:v},w&&(l.indexRequested=!0,l.stationarySlot=w),s[k]=l,c===Ld&&(x=k,y=l),k++,void 0!==t[u].first.index&&(z=u)}}s[0].sequenceNew!==t[0]&&(I(Kd),s[0].first=Kd.next,s.unshift({first:Kd,last:Kd,sequenceNew:t[0],matchingItems:1}),x++,k++);var B=!Ld.firstInSequence;for(y.sequenceNew!==t[o-1]&&(I(Ld.prev),y.last=Ld.prev,x++,s.splice(x,0,{first:Ld,last:Ld,sequenceNew:t[o-1],matchingItems:1}),k++,y=s[x]),a=0;k>a;a++)p=s[a].sequenceNew,p&&p.matchingItems=a;a++)l=s[a],l.sequenceNew&&(n=l.sequenceNew.sequenceOld)===m&&m.last!==Ld?(Oc(n.last),n.last=l.last,delete s[a]):m=l;for(m=null,a=x;a>=0;a--)l=s[a],l&&(l.sequenceNew&&(n=l.sequenceNew.sequenceOld)===m&&l.last!==Ld?(Oc(l.last),n.first=l.first,delete s[a]):m=l);B&&delete Ld.mergedForRefresh;var C=[];for(a=x+1;k>a;a++)if(l=s[a],l&&(!l.sequenceNew||l.sequenceNew.sequenceOld!==l)){var D=!0,E=null,J=null,K=0;for(h=Nc(l.first),h&&(E=J=h,K=1),c=l.first;c!==l.last;c=c.next){var L=Nc(c.next);if(h&&L&&(h.lastInSequence||h.next!==L)){D=!1;break}h&&!E&&(E=J=h),L&&E&&(J=L,K++),h=L}if(D&&E&&void 0!==E.index){var M;E.firstInSequence||(f=Mc(E.prev),f&&(M=f.index));var N;if(J.lastInSequence||(g=Mc(J.next),g&&(N=g.index)),(!g||g.lastInSequence||g.mergedForRefresh)&&(void 0===M||void 0===N||N-M-1>=K)){for(l.locationJustDetermined=!0,h=E;h.locationJustDetermined=!0,h!==J;h=h.next);var j=Mc(E),O=Mc(J);C.push({slotBeforeSequence:j.firstInSequence?null:j.prev,slotFirstInSequence:j,slotLastInSequence:O,slotAfterSequence:O.lastInSequence?null:O.next})}}}for(a=0;k>a;a++)if(l=s[a],!(!l||l.indexRequested||l.locationJustDetermined||l.sequenceNew&&l.sequenceNew.sequenceOld===l)){l.sequenceNew=null,c=l.first;var P;do{if(P=c===l.last,e=c.next,c!==Kd&&c!==Ld&&c!==Md&&!c.item&&!c.keyRequested)if(sb(c,!0),l.first===c){if(l.last===c){delete s[a];break}l.first=c.next}else l.last===c&&(l.last=c.prev);c=e}while(!P)}for(a=0;o>a;a++){for(p=t[a],h=p.first;!Mc(h)&&!h.lastInSequence;h=h.next);if(h.lastInSequence&&!Mc(h))p.firstInner=p.lastInner=null;else{for(p.firstInner=h,h=p.last;!Mc(h);h=h.prev);p.lastInner=h}}for(a=0;o>a;a++)if(p=t[a],p&&p.firstInner&&(l=p.sequenceOld)){var Q=0;for(c=l.first;!0&&(h=Nc(c),h&&h.sequenceNumber===p.firstInner.sequenceNumber&&(h.ordinal=Q),!c.lastInSequence);c=c.next,Q++);var R=[];for(h=p.firstInner;!0;h=h.next){if(Q=h.ordinal,void 0!==Q){for(var S=0,T=R.length-1;T>=S;){var U=Math.floor(.5*(S+T));R[U].ordinal0&&(h.predecessor=R[S-1])}if(h===p.lastInner)break}var W=[],X=R.length;for(h=R[X-1],b=X;b--;)h.stationary=!0,W[b]=h,h=h.predecessor;l.stationarySlot=Mc(W[0]),h=W[0],c=Mc(h),d=c.prev;for(var Y=c.firstInSequence;!h.firstInSequence;)if(h=h.prev,i=Mc(h),!i||h.locationJustDetermined)for(;!Y&&d!==Kd&&(c=d,d=c.prev,Y=c.firstInSequence,!Sc(i,c,h)););for(b=0;X-1>b;b++){h=W[b],c=Mc(h);var i,Z=W[b+1],_=null,ab=Mc(Z);for(e=c.next,h=h.next;h!==Z&&!_&&c!==ab;h=h.next)if(i=Mc(h),!i||h.locationJustDetermined)for(;e!==ab;){if(e.mergedForRefresh){_=h.prev;break}if(c=e,e=c.next,Sc(i,c,h))break}if(_)for(d=ab.prev,h=Z.prev;h!==_&&ab!==c;h=h.prev)if(i=Mc(h),!i||h.locationJustDetermined)for(;d!==c&&(ab=d,d=ab.prev,!Sc(i,ab,h)););for(;e!==ab;)c=e,e=c.next,c!==Kd&&V(c)&&!c.keyRequested&&sb(c)}for(h=W[X-1],c=Mc(h),e=c.next,Y=c.lastInSequence;!h.lastInSequence;)if(h=h.next,i=Mc(h),!i||h.locationJustDetermined)for(;!Y&&e!==Ld&&(c=e,e=c.next,Y=c.lastInSequence,!Sc(i,c,h)););}for(a=0;o>a;a++)if(p=t[a],p.firstInner)for(d=null,h=p.firstInner;!0;h=h.next){if(c=Mc(h)){if(!h.stationary){var db,eb=!1,fb=!1;if(d)db=d.next,eb=!0;else{var gb;for(gb=p.firstInner;!gb.stationary&&gb!==p.lastInner;gb=gb.next);if(gb.stationary)db=Mc(gb),fb=!0;else if(q=h.index,0===q)db=Kd.next,eb=!0;else if(void 0===q)db=Md;else{db=Kd.next;for(var hb=null;;){if(db.firstInSequence&&(hb=db),qa;a++)if(p=t[a],p.firstInner)for(d=null,h=p.firstInner;!0;h=h.next){if(c=Mc(h),!c){var kb;if(d)kb=d.next;else{var mb;for(mb=p.firstInner;!Mc(mb);mb=mb.next);kb=Mc(mb)}c=Qc(h,kb,!!d);var L=Nc(kb);kb.mergedForRefresh||L&&L.locationJustDetermined||($(c),pb(c))}if(d=c,h===p.lastInner)break}Pd=[];var ob=-1;for(c=Kd,r=0;c!==Md;r++){var e=c.next;if(c.firstInSequence&&(j=c,r=0),void 0===ob){var qb=Tc(c);void 0!==qb&&(ob=qb-r)}if(void 0!==ob&&!c.lastInSequence){var tb=Tc(c.next);if(void 0!==tb&&tb!==ob+r+1){I(c);for(var ub=!0,vb=c.next,wb=!1;!wb&&vb!==Ld;){var xb=vb.next;wb=vb.lastInSequence,rb(vb,xb,!ub,!1),ub=!1,vb=xb}}}if(c.lastInSequence){q=ob;for(var yb=j;yb!==e;){var zb=yb.next;if(q>=Yd&&yb!==Ld)sb(yb,!0);else{var Ab=Pd[q];q!==yb.index?(delete Pd[q],nb(yb,q)):+q===q&&Pd[q]!==yb&&(Pd[q]=yb),yb.itemNew&&dc(yb),Ab&&(yb.key?(fc(yb,Ab,yb.bindingMap),gc(yb,Ab),+q===q&&(Pd[q]=yb)):(fc(Ab,yb,Ab.bindingMap),gc(Ab,yb),+q===q&&(Pd[q]=Ab))),+q===q&&q++}yb=zb}ob=void 0}c=e}var Bb,Db=-2;for(c=Kd,r=0;c!==Md;r++){var e=c.next;if(c.firstInSequence&&(j=c,r=0),delete c.mergedForRefresh,c.lastInSequence)if(void 0===j.index){f=j.prev;var Eb;f&&(Eb=Nc(f))&&!Eb.lastInSequence&&(h=Nc(c))&&h.prev===Eb?(G(f,j,c),H(f)):c===Ld||Bb||F(Md,j,c)}else{if(Dba;a++){p=t[a];var Gb=[];c=null,r=0;var Hb;for(h=p.first;!0&&(h===Zd?Gb.push(Hd):h===$d?Gb.push(Id):(Gb.push(h.item),c||(c=Mc(h),Hb=r)),!h.lastInSequence);h=h.next,r++);c&&Fb.push({slot:c,results:Gb,offset:Hb})}for(vc(),Ud=!1,Cb(),a=0;ae&&f--,xb(f,1)),a()):i||j?(void 0!==e&&(xb(e,-1),f>e&&f--),this.inserted(b,c,d,f)):void 0!==e&&(xb(e,-1),f>e&&f--,xb(f,1),a())}},this.removed=function(b,c){if(vd)wc();else{var d;d="string"==typeof b?Od[b]:Pd[c],d?d.keyRequested?wc():(wb(d,-1),sb(d,!1),a()):void 0!==c&&(xb(c,-1),a())}},this.endNotifications=function(){yd=!1,a()}}function fd(){Nb(o.ready),pd=null,rd=!1,sd=!1,td=!1,ud={},ud.next=ud,ud.prev=ud,vd=!1,xd=!1,zd=0,Ad=!1,Bd=0,Fd={},Gd=[],Jd=p.unknown,Kd={firstInSequence:!0,lastInSequence:!0,index:-1},Ld={firstInSequence:!0,lastInSequence:!0},Md={firstInSequence:!0,lastInSequence:!0},Kd.next=Ld,Ld.prev=Kd,Ld.next=Md,Md.prev=Ld,Nd={},Od={},Pd={},Pd[-1]=Kd,Qd=0,Rd=null,Sd=!1,Td=!1,Ud=!1,Vd=null}var gd,hd,id,jd,kd,ld,md,nd,od,pd,qd,rd,sd,td,ud,vd,wd,xd,yd,zd,Ad,Bd,Cd,Dd,Ed,Fd,Gd,Hd,Id,Jd,Kd,Ld,Md,Nd,Od,Pd,Qd,Rd,Sd,Td,Ud,Vd,Wd,Xd,Yd,Zd,$d,_d,ae,be,ce,de,ee,fe,ge,he,ie,je,ke,le,me=0,ne=new Array(100),oe=-1;a.itemsFromKey&&(he=function(b,c,d,e,g){var h="fetchItemsFromKey id="+b+" key="+c+" countBefore="+d+" countAfter="+e;f(h),ne[++oe%ne.length]={kind:"itemsFromKey",key:c,countBefore:d,countAfter:e};var i=a.itemsFromKey(c,d,e,g);return u(h),i}),a.itemsFromIndex&&(ie=function(b,c,d,e){var g="fetchItemsFromIndex id="+b+" index="+c+" countBefore="+d+" countAfter="+e;f(g),ne[++oe%ne.length]={kind:"itemsFromIndex",index:c,countBefore:d,countAfter:e};var h=a.itemsFromIndex(c,d,e);return u(g),h}),a.itemsFromStart&&(je=function(b,c){var d="fetchItemsFromStart id="+b+" count="+c;f(d),ne[++oe%ne.length]={kind:"itemsFromStart",count:c};var e=a.itemsFromStart(c);return u(d),e}),a.itemsFromEnd&&(ke=function(b,c){var d="fetchItemsFromEnd id="+b+" count="+c;f(d),ne[++oe%ne.length]={kind:"itemsFromEnd",count:c};var e=a.itemsFromEnd(c);return u(d),e}),a.itemsFromDescription&&(le=function(b,c,d,e){var g="fetchItemsFromDescription id="+b+" desc="+c+" countBefore="+d+" countAfter="+e;f(g),ne[++oe%ne.length]={kind:"itemsFromDescription",description:c,countBefore:d,countAfter:e};var h=a.itemsFromDescription(c,d,e);return u(g),h});var pe=++n,qe=this,re={insert:"insert",change:"change",move:"move",remove:"remove"};if(!a)throw new e("WinJS.UI.ListDataSource.ListDataAdapterIsInvalid",s.listDataAdapterIsInvalid);hd=a.compareByIdentity?0:200,c&&"number"==typeof c.cacheSize&&(hd=c.cacheSize),a.setNotificationHandler&&(gd=new ed,a.setNotificationHandler(gd)),id=o.ready,kd=!1,ld={},md=0,nd=1,od=0,Cd=0,Dd=!1,Ed=1,Hd={},Id={},fd(),this.createListBinding=function(a){function b(a){a&&a.cursorCount++}function c(a){a&&0===--a.cursorCount&&eb(a)}function d(a){b(a),c(m),m=a}function e(a,b){a===m&&(b||(b=!m||m.lastInSequence||m.next===Ld?null:m.next),d(b))}function f(a){var b=a.bindingMap,c=b[l].handle;delete a.bindingMap[l];var d=!0,e=!0;for(var f in b)if(d=!1,c&&b[f].handle===c){e=!1;break}c&&e&&delete Nd[c],d&&(a.bindingMap=null,eb(a))}function g(a,b){a.bindingMap||(a.bindingMap={});var c=a.bindingMap[l];if(c?c.count++:a.bindingMap[l]={bindingRecord:ld[l],count:1},a.fetchListeners){var d=a.fetchListeners[b];d&&(d.retained=!0)}}function h(a){var b=Nd[a];if(b){var c=b.bindingMap[l];if(0===--c.count){var d=b.fetchListeners;for(var e in d){var g=d[e];g.listBindingID===l&&(g.retained=!1)}f(b)}}}function i(b){var c=jb(b,l),d=(od++).toString(),e=zb(b,"fetchListeners",d,l,function(a,b){a(kb(b,c))});return X(e,b,c),a&&(e.retain=function(){return o._retainItem(b,d),e},e.release=function(){o._releaseItem(c)}),e}function k(b){var c;return!n&&b?c=i(b):(n?(c=new j(function(){}),c.cancel()):c=j.wrap(null),W(c,null),a&&(c.retain=function(){return c},c.release=function(){})),d(b),c}var l=(md++).toString(),m=null,n=!1;ld[l]={notificationHandler:a,notificationsSent:!1,adjustCurrentSlot:e,itemPromiseFromKnownSlot:i};var o={_retainItem:function(a,b){g(a,b)},_releaseItem:function(a){h(a)},jumpToItem:function(a){return k(a?Nd[a.handle]:null)},current:function(){return k(m)},previous:function(){return k(m?Fb(m):null)},next:function(){return k(m?Gb(m):null)},releaseItem:function(a){this._releaseItem(a.handle)},release:function(){n=!0,c(m),m=null;for(var a=Kd.next;a!==Md;){var b=a.next,d=a.fetchListeners;for(var e in d){var g=d[e];g.listBindingID===l&&(g.promise.cancel(),delete d[e])}a.bindingMap&&a.bindingMap[l]&&f(a),a=b}delete ld[l]}};return(je||ie)&&(o.first=function(){return k(Gb(Kd))}),ke&&(o.last=function(){return k(Fb(Ld))}),he&&(o.fromKey=function(a,b){return k(Kb(a,b))}),(ie||je&&he)&&(o.fromIndex=function(a){return k(Lb(a))}),le&&(o.fromDescription=function(a){return k(Mb(a))}),o},this.invalidateAll=function(){return xc()};var se=function(a,b){var c=new l;a.then(function(a){c.complete(a)},function(a){c.error(a)});var d=c.promise.then(null,function(c){return"WinJS.UI.VirtualizedDataSource.resetCount"===c.name?(pd=null,a=b.getCount()):j.wrapError(c)}),f=0,g={get:function(){return f++,new j(function(a,b){d.then(a,b)},function(){0===--f&&(c.promise.cancel(),a.cancel(),g===pd&&(pd=null))})},reset:function(){c.error(new e("WinJS.UI.VirtualizedDataSource.resetCount"))},cancel:function(){c.promise.cancel(),a.cancel(),g===pd&&(pd=null)}};return g};this.getCount=function(){if(a.getCount){var b=this;return j.wrap().then(function(){if(sd||vd)return Jd;var c;if(!pd){var d;c=a.getCount();var e;c.then(function(){pd===d&&(pd=null),e=!0},function(){pd===d&&(pd=null),e=!0}),zd=0,e||(d=pd=se(c,b))}return pd?pd.get():c}).then(function(a){if(!w(a)&&void 0!==a)throw new e("WinJS.UI.ListDataSource.InvalidRequestedCountReturned",s.invalidRequestedCountReturned);return a!==Jd&&(Jd===p.unknown?Jd=a:(lb(a),ib())),0===a&&(Kd.next!==Ld||Ld.next!==Md?wc():Kd.lastInSequence&&(H(Kd),Ld.index=0)),a}).then(null,function(a){return a.name===m.CountError.noResponse?(Nb(o.failure),Jd):j.wrapError(a)})}return j.wrap(Jd)},he&&(this.itemFromKey=function(a,b){return Hb(Kb(a,b))}),(ie||je&&he)&&(this.itemFromIndex=function(a){return Hb(Lb(a))}),le&&(this.itemFromDescription=function(a){return Hb(Mb(a))}),this.beginEdits=function(){sd=!0},a.insertAtStart&&(this.insertAtStart=function(b,c){return cd(b,c,Kd.lastInSequence?null:Kd.next,!0,function(){return a.insertAtStart(b,c)})}),a.insertBefore&&(this.insertBefore=function(b,c,d){var e=ad(d);return cd(b,c,e,!1,function(){return a.insertBefore(b,c,d,ub(e))})}),a.insertAfter&&(this.insertAfter=function(b,c,d){var e=ad(d);return cd(b,c,e?e.next:null,!0,function(){return a.insertAfter(b,c,d,ub(e))})}),a.insertAtEnd&&(this.insertAtEnd=function(b,c){return cd(b,c,Ld.firstInSequence?null:Ld,!1,function(){return a.insertAtEnd(b,c)})}),a.change&&(this.change=function(b,c){var d=ad(b);return new j(function(e,f){var g;Vc(function(){return a.change(b,c,ub(d))},re.change,e,f,null,function(){g=d.item,d.itemNew={key:b,data:c},g?qb(d):Bb(d)},function(){g?(d.itemNew=g,qb(d)):wc()})})}),a.moveToStart&&(this.moveToStart=function(b){var c=ad(b);return dd(c,Kd.next,!0,function(){return a.moveToStart(b,ub(c))})}),a.moveBefore&&(this.moveBefore=function(b,c){var d=ad(b),e=ad(c);return dd(d,e,!1,function(){return a.moveBefore(b,c,ub(d),ub(e))})}),a.moveAfter&&(this.moveAfter=function(b,c){var d=ad(b),e=ad(c);return dd(d,e.next,!0,function(){return a.moveAfter(b,c,ub(d),ub(e))})}),a.moveToEnd&&(this.moveToEnd=function(b){var c=ad(b);return dd(c,Ld,!1,function(){return a.moveToEnd(b,ub(c))})}),a.remove&&(this.remove=function(b){Ib(b);var c=Od[b];return new j(function(d,e){var f,g,h;Vc(function(){return a.remove(b,ub(c))},re.remove,d,e,null,function(){c&&(f=c.next,g=c.firstInSequence,h=c.lastInSequence,wb(c,-1),sb(c,!1))},function(){c&&(R(c,f,!g,!h),wb(c,1),pb(c))})})}),this.endEdits=function(){sd=!1,$c()}}var h=100,n=1,o=m.DataSourceStatus,p=m.CountResult,q=m.FetchError,r=m.EditError,s={get listDataAdapterIsInvalid(){return"Invalid argument: listDataAdapter must be an object or an array."},get indexIsInvalid(){return"Invalid argument: index must be a non-negative integer."},get keyIsInvalid(){return"Invalid argument: key must be a string."},get invalidItemReturned(){return"Error: data adapter returned item that is not an object."},get invalidKeyReturned(){return"Error: data adapter returned item with undefined or null key."},get invalidIndexReturned(){return"Error: data adapter should return undefined, null or a non-negative integer for the index."},get invalidCountReturned(){return"Error: data adapter should return undefined, null, CountResult.unknown, or a non-negative integer for the count."},get invalidRequestedCountReturned(){return"Error: data adapter should return CountResult.unknown, CountResult.failure, or a non-negative integer for the count."},get refreshCycleIdentified(){return"refresh cycle found, likely data inconsistency"}},t="statuschanged",u=c.Class.define(function(){},{_baseDataSourceConstructor:a,_isVirtualizedDataSource:!0},{supportedForProcessing:!1});return c.Class.mix(u,f.eventMixin),u})})}),define("WinJS/VirtualizedDataSource/_GroupDataSource",["exports","../Core/_Base","../Core/_ErrorFromName","../Promise","../Scheduler","../Utilities/_UI","./_VirtualizedDataSourceImpl"],function(a,b,c,d,e,f,g){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupDataSource:b.Namespace._lazy(function(){function a(){return new c(f.FetchError.doesNotExist)}function h(a){return a&&a.firstReached&&a.lastReached}var i=101,j=b.Class.define(function(a){this._groupDataAdapter=a},{beginNotifications:function(){},inserted:function(a,b,c){this._groupDataAdapter._inserted(a,b,c)},changed:function(a,b){this._groupDataAdapter._changed(a,b)},moved:function(a,b,c){this._groupDataAdapter._moved(a,b,c)},removed:function(a,b){this._groupDataAdapter._removed(a,b)},countChanged:function(a,b){0===a&&0!==b&&this._groupDataAdapter.invalidateGroups()},indexChanged:function(a,b,c){this._groupDataAdapter._indexChanged(a,b,c)},endNotifications:function(){this._groupDataAdapter._endNotifications()},reload:function(){this._groupDataAdapter._reload()}},{supportedForProcessing:!1}),k=b.Class.define(function(a,b,c,d){this._listBinding=a.createListBinding(new j(this)),this._groupKey=b,this._groupData=c,this._initializeState(),this._batchSize=i,this._count=null,d&&("number"==typeof d.groupCountEstimate&&(this._count=d.groupCountEstimate<0?null:Math.max(d.groupCountEstimate,1)),"number"==typeof d.batchSize&&(this._batchSize=d.batchSize+1)),this._listBinding.last&&(this.itemsFromEnd=function(a){var b=this;return this._fetchItems(function(){return b._lastGroup},function(a){if(a)return!1;var c=b._count;return+c!==c?!0:c>0?!0:void 0},function(){b._fetchBatch(b._listBinding.last(),b._batchSize-1,0)},a-1,0)})},{setNotificationHandler:function(a){this._listDataNotificationHandler=a},compareByIdentity:!0,itemsFromKey:function(a,b,c,d){var e=this;return this._fetchItems(function(){return e._keyMap[a]},function(){var a=e._lastGroup;return a?+a.index!==a.index?!0:void 0:!0},function(){d=d||{};var a="string"==typeof d.groupMemberKey&&e._listBinding.fromKey?e._listBinding.fromKey(d.groupMemberKey):"number"==typeof d.groupMemberIndex&&e._listBinding.fromIndex?e._listBinding.fromIndex(d.groupMemberIndex):void 0!==d.groupMemberDescription&&e._listBinding.fromDescription?e._listBinding.fromDescription(d.groupMemberDescription):e._listBinding.first(),b=Math.floor(.5*(e._batchSize-1));e._fetchBatch(a,b,e._batchSize-1-b)},b,c)},itemsFromIndex:function(a,b,c){var d=this;return this._fetchItems(function(){return d._indexMap[a]},function(){var b=d._lastGroup;return b?+b.index!==b.index?!0:a<=b.index?!0:void 0:!0},function(){d._fetchNextIndex()},b,c)},getCount:function(){if(this._lastGroup&&"number"==typeof this._lastGroup.index)return d.wrap(this._count);var a=this,b=new d(function(b){var c={initialBatch:function(){a._fetchNextIndex()},getGroup:function(){return null},countBefore:0,countAfter:0,complete:function(c){c&&(a._count=0);var d=a._count;return"number"==typeof d?(b(d),!0):!1}};a._fetchQueue.push(c),a._itemBatch||a._continueFetch(c)});return"number"==typeof this._count?d.wrap(this._count):b},invalidateGroups:function(){this._beginRefresh(),this._initializeState()},_initializeState:function(){this._count=null,this._indexMax=null,this._keyMap={},this._indexMap={},this._lastGroup=null,this._handleMap={},this._fetchQueue=[],this._itemBatch=null,this._itemsToFetch=0,this._indicesChanged=!1},_releaseItem:function(a){delete this._handleMap[a.handle],this._listBinding.releaseItem(a)},_processBatch:function(){for(var a=null,b=null,c=null,d=0,f=!0,g=0;g0&&(k.firstReached=!0,b||(j=0)),"number"!=typeof k.index&&"number"==typeof j){for(var l=k;l;l=this._nextGroup(l))l.index=j,this._indexMap[j]=l,j++;this._indexMax=j,"number"==typeof this._count&&!this._lastGroup&&this._count<=this._indexMax&&(this._count=this._indexMax+1)}c=h,d=0,b=k}else b&&(this._lastGroup=b,"number"==typeof b.index&&(this._count=b.index+1),this._listDataNotificationHandler.invalidateAll(),b=null)}a=h}var m;for(m=this._fetchQueue[0];m&&m.complete(f);m=this._fetchQueue[0])this._fetchQueue.splice(0,1);if(m){var n=this;e.schedule(function(){n._continueFetch(m)},e.Priority.normal,null,"WinJS.UI._GroupDataSource._continueFetch")}else this._itemBatch=null},_processPromise:function(a,b){a.retain(),this._itemBatch[b]=a;var c=this;a.then(function(a){c._itemBatch[b]=a,0===--c._itemsToFetch&&c._processBatch()})},_fetchBatch:function(a,b){this._itemBatch=new Array(this._batchSize),this._itemsToFetch=this._batchSize,this._processPromise(a,b);var c;for(this._listBinding.jumpToItem(a),c=b-1;c>=0;c--)this._processPromise(this._listBinding.previous(),c);for(this._listBinding.jumpToItem(a),c=b+1;c0&&0!==b.index&&!h(c=this._previousGroup(b))?this._fetchAdjacent(c&&c.lastReached?c.firstItem:b.firstItem,!1):(d=this._nextGroup(b),this._fetchAdjacent(d&&d.firstReached?d.lastItem:b.lastItem,!0)):this._fetchAdjacent(b.lastItem,!0):this._fetchAdjacent(b.firstItem,!1)}else this._fetchNextIndex()}},_fetchComplete:function(a,b,c,d,e){if(h(a)){var g=this._previousGroup(a);if(d||h(g)||0===a.index||0===b){var i=this._nextGroup(a);if(d||h(i)||this._lastGroup===a||0===c){for(var j=0,k=a;b>j&&(g=this._previousGroup(k),h(g));)k=g,j++; +for(var l=0,m=a;c>l&&(i=this._nextGroup(m),h(i));)m=i,l++;for(var n=j+1+l,o=new Array(n),p=0;n>p;p++){var q={key:k.key,data:k.data,firstItemKey:k.firstItem.key,groupSize:k.size},r=k.firstItem.index;"number"==typeof r&&(q.firstItemIndexHint=r),o[p]=q,k=this._nextGroup(k)}var s={items:o,offset:j};return s.totalCount="number"==typeof this._count?this._count:f.CountResult.unknown,"number"==typeof a.index&&(s.absoluteIndex=a.index),m===this._lastGroup&&(s.atEnd=!0),e(s),!0}}}return!1},_fetchItems:function(b,c,e,f,g){var h=this;return new d(function(d,i){function j(e){var j=b();return j?h._fetchComplete(j,f,g,l,d,i):l&&!c(e)?(i(a()),!0):m>2?(i(a()),!0):(e?m++:m=0,!1)}var k=b(),l=!k,m=0;if(!j()){var n={initialBatch:l?e:null,getGroup:b,countBefore:f,countAfter:g,complete:j};h._fetchQueue.push(n),h._itemBatch||h._continueFetch(n)}})},_previousGroup:function(a){return a&&a.firstReached?(this._listBinding.jumpToItem(a.firstItem),this._handleMap[this._listBinding.previous().handle]):null},_nextGroup:function(a){return a&&a.lastReached?(this._listBinding.jumpToItem(a.lastItem),this._handleMap[this._listBinding.next().handle]):null},_invalidateIndices:function(a){this._count=null,this._lastGroup=null,"number"==typeof a.index&&(this._indexMax=a.index>0?a.index:null);for(var b=a;b&&"number"==typeof b.index;b=this._nextGroup(b))delete this._indexMap[b.index],b.index=null},_releaseGroup:function(a){this._invalidateIndices(a),delete this._keyMap[a.key],this._lastGroup===a&&(this._lastGroup=null),a.firstItem!==a.lastItem&&this._releaseItem(a.firstItem),this._releaseItem(a.lastItem)},_beginRefresh:function(){if(this._fetchQueue=[],this._itemBatch){for(var a=0;ai;i++)!function(a){d[a]&&(e[a]=function(){return g(d[a].apply(d,arguments))})}(h[i]);return d.fromKey&&(e.fromKey=function(a){return g(d.fromKey(a))}),d.fromIndex&&(e.fromIndex=function(a){return g(d.fromIndex(a))}),e.prev=function(){return g(d.prev())},e.next=function(){return g(d.next())},e};for(var i=["itemFromKey","itemFromIndex","itemFromDescription","insertAtStart","insertBefore","insertAfter","insertAtEnd","change","moveToStart","moveBefore","moveAfter","moveToEnd"],j=0,k=i.length;k>j;j++)!function(b){a[b]&&(h[b]=function(){return g(a[b].apply(a,arguments))})}(i[j]);["addEventListener","removeEventListener","dispatchEvent"].forEach(function(b){a[b]&&(h[b]=function(){return a[b].apply(a,arguments)})});var l=null;return Object.defineProperty(h,"groups",{get:function(){return l||(l=new b._GroupDataSource(a,c,d,e)),l},enumerable:!0,configurable:!0}),h}})}),define("WinJS/VirtualizedDataSource/_StorageDataSource",["exports","../Core/_WinRT","../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_WriteProfilerMark","../Animations","../Promise","../Utilities/_UI","./_VirtualizedDataSourceImpl"],function(a,b,c,d,e,f,g,h,i,j){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{StorageDataSource:d.Namespace._lazy(function(){var a=d.Class.define(function(a,c){f("WinJS.UI.StorageDataSource:constructor,StartTM");var d,e=b.Windows.Storage.FileProperties.ThumbnailMode.singleItem,g=256,h=b.Windows.Storage.FileProperties.ThumbnailOptions.useCurrentScale,i=!0;if("Pictures"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.picturesView,d=b.Windows.Storage.KnownFolders.picturesLibrary,g=190):"Music"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.musicView,d=b.Windows.Storage.KnownFolders.musicLibrary,g=256):"Documents"===a?(e=b.Windows.Storage.FileProperties.ThumbnailMode.documentsView,d=b.Windows.Storage.KnownFolders.documentsLibrary,g=40):"Videos"===a&&(e=b.Windows.Storage.FileProperties.ThumbnailMode.videosView,d=b.Windows.Storage.KnownFolders.videosLibrary,g=190),d){var j=new b.Windows.Storage.Search.QueryOptions;j.folderDepth=b.Windows.Storage.Search.FolderDepth.deep,j.indexerOption=b.Windows.Storage.Search.IndexerOption.useIndexerWhenAvailable,this._query=d.createFileQueryWithOptions(j)}else this._query=a;if(c){if("number"==typeof c.mode&&(e=c.mode),"number"==typeof c.requestedThumbnailSize)g=Math.max(1,Math.min(c.requestedThumbnailSize,1024));else switch(e){case b.Windows.Storage.FileProperties.ThumbnailMode.picturesView:case b.Windows.Storage.FileProperties.ThumbnailMode.videosView:g=190;break;case b.Windows.Storage.FileProperties.ThumbnailMode.documentsView:case b.Windows.Storage.FileProperties.ThumbnailMode.listView:g=40;break;case b.Windows.Storage.FileProperties.ThumbnailMode.musicView:case b.Windows.Storage.FileProperties.ThumbnailMode.singleItem:g=256}"number"==typeof c.thumbnailOptions&&(h=c.thumbnailOptions),"boolean"==typeof c.waitForFileLoad&&(i=!c.waitForFileLoad)}this._loader=new b.Windows.Storage.BulkAccess.FileInformationFactory(this._query,e,g,h,i),this.compareByIdentity=!1,this.firstDataRequest=!0,f("WinJS.UI.StorageDataSource:constructor,StopTM")},{setNotificationHandler:function(a){this._notificationHandler=a,this._query.addEventListener("contentschanged",function(){a.invalidateAll()}),this._query.addEventListener("optionschanged",function(){a.invalidateAll()})},itemsFromEnd:function(a){var b=this;return f("WinJS.UI.StorageDataSource:itemsFromEnd,info"),this.getCount().then(function(c){return 0===c?h.wrapError(new e(i.FetchError.doesNotExist)):b.itemsFromIndex(c-1,Math.min(c-1,a-1),1)})},itemsFromIndex:function(a,b,c){function d(a){k._notificationHandler.changed(k._item(a.target))}b+c>64&&(b=Math.min(b,32),c=64-(b+1));var g=a-b,j=b+1+c,k=this;k.firstDataRequest&&(k.firstDataRequest=!1,j=Math.max(j,32));var l="WinJS.UI.StorageDataSource:itemsFromIndex("+g+"-"+(g+j-1)+")";return f(l+",StartTM"),this._loader.getItemsAsync(g,j).then(function(c){var m=c.size;if(b>=m)return h.wrapError(new e(i.FetchError.doesNotExist));var n=new Array(m),o=new Array(m);c.getMany(0,o);for(var p=0;m>p;p++)n[p]=k._item(o[p]),o[p].addEventListener("propertiesupdated",d);var q={items:n,offset:b,absoluteIndex:a};return j>m&&(q.totalCount=g+m),f(l+",StopTM"),q})},itemsFromDescription:function(a,b,c){var d=this;return f("WinJS.UI.StorageDataSource:itemsFromDescription,info"),this._query.findStartIndexAsync(a).then(function(a){return d.itemsFromIndex(a,b,c)})},getCount:function(){return f("WinJS.UI.StorageDataSource:getCount,info"),this._query.getItemCountAsync()},itemSignature:function(a){return a.folderRelativeId},_item:function(a){return{key:a.path||a.folderRelativeId,data:a}}},{supportedForProcessing:!1});return d.Class.derive(j.VirtualizedDataSource,function(b,c){this._baseDataSourceConstructor(new a(b,c))},{},{loadThumbnail:function(a,d){var e,i,j=!1;return new h(function(k){var l=d?!0:!1,m=function(m){if(m){var n=c.URL.createObjectURL(m,{oneTimeOnly:!0});i=i?i.then(function(b){return a.loadImage(n,b)}):a.loadImage(n,d).then(function(b){return a.isOnScreen().then(function(a){var c;return a&&l?c=g.fadeIn(b).then(function(){return b}):(b.style.opacity=1,c=h.wrap(b)),c})}),m.type===b.Windows.Storage.FileProperties.ThumbnailType.icon||m.returnedSmallerCachedSize||(f("WinJS.UI.StorageDataSource:loadThumbnail complete,info"),a.data.removeEventListener("thumbnailupdated",e),j=!1,i=i.then(function(a){e=null,i=null,k(a)}))}};e=function(a){j&&m(a.target.thumbnail)},a.data.addEventListener("thumbnailupdated",e),j=!0,m(a.data.thumbnail)},function(){a.data.removeEventListener("thumbnailupdated",e),j=!1,e=null,i&&(i.cancel(),i=null)})},supportedForProcessing:!1})})})}),define("WinJS/VirtualizedDataSource",["./VirtualizedDataSource/_VirtualizedDataSourceImpl","./VirtualizedDataSource/_GroupDataSource","./VirtualizedDataSource/_GroupedItemDataSource","./VirtualizedDataSource/_StorageDataSource"],function(){}),define("require-style",{load:function(a){throw new Error("Dynamic load not allowed: "+a)}}),define("require-style!less/desktop/styles-intrinsic",[],function(){}),define("require-style!less/desktop/colors-intrinsic",[],function(){}),define("require-style!less/phone/styles-intrinsic",[],function(){}),define("require-style!less/phone/colors-intrinsic",[],function(){}),define("WinJS/Controls/IntrinsicControls",["../Utilities/_Hoverable","require-style!less/desktop/styles-intrinsic","require-style!less/desktop/colors-intrinsic","require-style!less/phone/styles-intrinsic","require-style!less/phone/colors-intrinsic"],function(){}),define("WinJS/Controls/ItemContainer/_Constants",["exports","../../Core/_Base"],function(a,b){"use strict";var c={};c._listViewClass="win-listview",c._listViewSupportsCrossSlideClass="win-listview-supports-cross-slide",c._viewportClass="win-viewport",c._rtlListViewClass="win-rtl",c._horizontalClass="win-horizontal",c._verticalClass="win-vertical",c._scrollableClass="win-surface",c._itemsContainerClass="win-itemscontainer",c._padderClass="win-itemscontainer-padder",c._proxyClass="_win-proxy",c._itemClass="win-item",c._itemBoxClass="win-itembox",c._itemsBlockClass="win-itemsblock",c._containerClass="win-container",c._backdropClass="win-backdrop",c._footprintClass="win-footprint",c._groupsClass="win-groups",c._selectedClass="win-selected",c._swipeableClass="win-swipeable",c._swipeClass="win-swipe",c._selectionBorderClass="win-selectionborder",c._selectionBackgroundClass="win-selectionbackground",c._selectionCheckmarkClass="win-selectioncheckmark",c._selectionCheckmarkBackgroundClass="win-selectioncheckmarkbackground",c._pressedClass="win-pressed",c._headerClass="win-groupheader",c._headerContainerClass="win-groupheadercontainer",c._groupLeaderClass="win-groupleader",c._progressClass="win-progress",c._selectionHintClass="win-selectionhint",c._revealedClass="win-revealed",c._itemFocusClass="win-focused",c._itemFocusOutlineClass="win-focusedoutline",c._zoomingXClass="win-zooming-x",c._zoomingYClass="win-zooming-y",c._listLayoutClass="win-listlayout",c._gridLayoutClass="win-gridlayout",c._headerPositionTopClass="win-headerpositiontop",c._headerPositionLeftClass="win-headerpositionleft",c._structuralNodesClass="win-structuralnodes",c._uniformGridLayoutClass="win-uniformgridlayout",c._uniformListLayoutClass="win-uniformlistlayout",c._cellSpanningGridLayoutClass="win-cellspanninggridlayout",c._laidOutClass="win-laidout",c._nonDraggableClass="win-nondraggable",c._nonSelectableClass="win-nonselectable",c._nonSwipeableClass="win-nonswipeable",c._dragOverClass="win-dragover",c._dragSourceClass="win-dragsource",c._clipClass="win-clip",c._selectionModeClass="win-selectionmode",c._noCSSGrid="win-nocssgrid",c._INVALID_INDEX=-1,c._UNINITIALIZED=-1,c._LEFT_MSPOINTER_BUTTON=0,c._RIGHT_MSPOINTER_BUTTON=2,c._TAP_END_THRESHOLD=10,c._DEFAULT_PAGES_TO_LOAD=5,c._DEFAULT_PAGE_LOAD_THRESHOLD=2,c._MIN_AUTOSCROLL_RATE=150,c._MAX_AUTOSCROLL_RATE=1500,c._AUTOSCROLL_THRESHOLD=100,c._AUTOSCROLL_DELAY=50,c._DEFERRED_ACTION=250,c._DEFERRED_SCROLL_END=250,c._VERTICAL_SWIPE_SELECTION_THRESHOLD=39,c._VERTICAL_SWIPE_SPEED_BUMP_START=0,c._VERTICAL_SWIPE_SPEED_BUMP_END=127,c._VERTICAL_SWIPE_SELF_REVEAL_GESTURE=15,c._HORIZONTAL_SWIPE_SELECTION_THRESHOLD=27,c._HORIZONTAL_SWIPE_SPEED_BUMP_START=0,c._HORIZONTAL_SWIPE_SPEED_BUMP_END=150,c._HORIZONTAL_SWIPE_SELF_REVEAL_GESTURE=23,c._SELECTION_CHECKMARK="",c._LISTVIEW_PROGRESS_DELAY=2e3;var d={uninitialized:0,low:1,medium:2,high:3},e={rebuild:0,remeasure:1,relayout:2,realize:3};c._ScrollToPriority=d,c._ViewChange=e,b.Namespace._moduleDefine(a,"WinJS.UI",c)}),define("WinJS/Controls/ItemContainer/_ItemEventsHandler",["exports","../../Core/_Global","../../Core/_WinRT","../../Core/_Base","../../Core/_BaseUtils","../../Core/_WriteProfilerMark","../../Animations","../../Animations/_TransitionAnimation","../../Promise","../../Utilities/_ElementUtilities","../../Utilities/_UI","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l){"use strict";function m(a){var b=Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z);return{x:a.x/b,y:a.y/b,z:a.z/b}}function n(a,b){var c=m(b),d=Math.cos(a),e=Math.sin(a),f=[d+c.x*c.x*(1-d),c.x*c.y*(1-d)-c.z*e,c.x*c.z*(1-d)+c.y*e,0,c.y*c.x*(1-d)+c.z*e,d+c.y*c.y*(1-d),c.y*c.z*(1-d)-c.x*e,0,c.z*c.x*(1-d)-c.y*e,c.z*c.y*(1-d)+c.x*e,d+c.z*c.z*(1-d),0,0,0,0,1];return f=f.map(function(a){return a.toFixed(8)}),"matrix3d("+f.join(",")+")"}function o(a,b,c){var d=j._clamp((a-c.left)/c.width,0,1),e=j._clamp((b-c.top)/c.height,0,1),f={x:e-.5,y:-(d-.5),z:1e-4},g=Math.abs(d-.5)+Math.abs(e-.5),h=g*q,i=1-(1-g)*r,k="perspective(800px) scale("+i+", "+i+") "+n(h,f);return k}var p=e._browserStyleEquivalents.transform,q=.15,r=.025,s=j._uniqueID,t=j._MSManipulationEvent;d.Namespace._moduleDefine(a,"WinJS.UI",{_rotationTransform3d:n,_tiltTransform:o,_ItemEventsHandler:d.Namespace._lazy(function(){function a(a,b){return a.querySelector("."+b)}function m(a,c){var d=b.document.createElement("div");return d.className=a,c||d.setAttribute("aria-hidden",!0),d}var n=j._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",q=d.Class.define(function(a){if(this._site=a,this._work=[],this._animations={},this._selectionHintTracker={},this._swipeClassTracker={},!e.isPhone&&this._selectionAllowed()){var c=this;b.setTimeout(function(){c._gestureRecognizer||a.isZombie()||(c._gestureRecognizer=c._createGestureRecognizer())},500)}},{dispose:function(){this._disposed||(this._disposed=!0,this._gestureRecognizer=null,j._removeEventListener(b,"pointerup",this._resetPointerDownStateBound),j._removeEventListener(b,"pointercancel",this._resetPointerDownStateBound))},onMSManipulationStateChanged:function(a){var b=a.currentState;if(b===t.MS_MANIPULATION_STATE_PRESELECT&&!this._site.pressedItemBox){var c=this._site.indexForItemElement(a.target);if(this._site.pressedEntity={type:k.ObjectType.item,index:c},this._site.pressedEntity.index!==l._INVALID_INDEX){this._site.pressedItemBox=this._site.itemBoxAtIndex(this._site.pressedEntity.index),this._site.pressedContainer=this._site.containerAtIndex(this._site.pressedEntity.index),this._site.animatedElement=e.isPhone?this._site.pressedItemBox:this._site.pressedContainer,this._site.pressedHeader=null;var d=this._site.verifySelectionAllowed(this._site.pressedEntity);this._canSelect=d.canSelect,this._canTapSelect=d.canTapSelect,this._swipeBehaviorSelectionChanged=!1,this._selectionHint=null,this._canSelect&&this._addSelectionHint()}}!this._canSelect||b!==t.MS_MANIPULATION_STATE_PRESELECT&&b!==t.MS_MANIPULATION_STATE_COMMITTED&&b!==t.MS_MANIPULATION_STATE_CANCELLED&&b!==t.MS_MANIPULATION_STATE_SELECTING&&b!==t.MS_MANIPULATION_STATE_DRAGGING||this._dispatchSwipeBehavior(b),(b===t.MS_MANIPULATION_STATE_COMMITTED||b===t.MS_MANIPULATION_STATE_CANCELLED||b===t.MS_MANIPULATION_STATE_STOPPED)&&this.resetPointerDownState()},onPointerDown:function(a){f("WinJS.UI._ItemEventsHandler:MSPointerDown,StartTM");var d,g,h=this._site,i=a.pointerType===n;if(h.pressedElement=a.target,c.Windows.UI.Input.PointerPoint){var m=this._getCurrentPoint(a),o=m.properties;i||o.isInverted||o.isEraser||o.isMiddleButtonPressed?d=g=!1:(g=o.isRightButtonPressed,d=!g&&o.isLeftButtonPressed)}else d=a.button===l._LEFT_MSPOINTER_BUTTON,g=a.button===l._RIGHT_MSPOINTER_BUTTON;this._DragStartBound=this._DragStartBound||this.onDragStart.bind(this),this._PointerEnterBound=this._PointerEnterBound||this.onPointerEnter.bind(this),this._PointerLeaveBound=this._PointerLeaveBound||this.onPointerLeave.bind(this),this._swipeBehaviorState=t.MS_MANIPULATION_STATE_STOPPED;var p=h.swipeBehavior===k.SwipeBehavior.select,q=this._isInteractive(a.target),r=h.indexForItemElement(a.target),s=h.indexForHeaderElement(a.target),u=!q&&r!==l._INVALID_INDEX;if((i||d||this._selectionAllowed()&&p&&g)&&this._site.pressedEntity.index===l._INVALID_INDEX&&!q&&(this._site.pressedEntity=s===l._INVALID_INDEX?{type:k.ObjectType.item,index:r}:{type:k.ObjectType.groupHeader,index:s},this._site.pressedEntity.index!==l._INVALID_INDEX)){this._site.pressedPosition=j._getCursorPos(a);var v=h.verifySelectionAllowed(this._site.pressedEntity);if(this._canSelect=v.canSelect,this._canTapSelect=v.canTapSelect,this._swipeBehaviorSelectionChanged=!1,this._selectionHint=null,this._site.pressedEntity.type!==k.ObjectType.groupHeader?(this._site.pressedItemBox=h.itemBoxAtIndex(this._site.pressedEntity.index),this._site.pressedContainer=h.containerAtIndex(this._site.pressedEntity.index),this._site.animatedElement=e.isPhone?this._site.pressedItemBox:this._site.pressedContainer,this._site.pressedHeader=null,this._togglePressed(!0,!1,a),this._site.pressedContainer.addEventListener("dragstart",this._DragStartBound),i||(j._addEventListener(this._site.pressedContainer,"pointerenter",this._PointerEnterBound,!1),j._addEventListener(this._site.pressedContainer,"pointerleave",this._PointerLeaveBound,!1))):(this._site.pressedHeader=this._site.headerFromElement(a.target),e.isPhone?(this._site.animatedElement=this._site.pressedHeader,this._togglePressed(!0,!1,a)):(this._site.pressedItemBox=null,this._site.pressedContainer=null,this._site.animatedElement=null)),this._resetPointerDownStateBound||(this._resetPointerDownStateBound=this._resetPointerDownStateForPointerId.bind(this)),i||(j._addEventListener(b,"pointerup",this._resetPointerDownStateBound,!1),j._addEventListener(b,"pointercancel",this._resetPointerDownStateBound,!1)),this._canSelect&&!e.isPhone&&(this._gestureRecognizer||(this._gestureRecognizer=this._createGestureRecognizer()),this._addSelectionHint()),this._pointerId=a.pointerId,this._pointerRightButton=g,this._pointerTriggeredSRG=!1,this._gestureRecognizer&&i)try{this._gestureRecognizer.addPointer(this._pointerId)}catch(w){this._gestureRecognizer.stop()}}if(u&&i)try{j._setPointerCapture(h.canvasProxy,a.pointerId)}catch(w){return void f("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM")}this._site.pressedEntity.type!==k.ObjectType.groupHeader&&this._selectionAllowed()&&this._multiSelection()&&this._site.pressedEntity.index!==l._INVALID_INDEX&&h.selection._getFocused().index!==l._INVALID_INDEX&&h.selection._pivot===l._INVALID_INDEX&&(h.selection._pivot=h.selection._getFocused().index),f("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM")},onPointerEnter:function(a){this._site.pressedContainer&&this._pointerId===a.pointerId&&this._togglePressed(!0,!1,a)},onPointerLeave:function(a){this._site.pressedContainer&&this._pointerId===a.pointerId&&this._togglePressed(!1,!0,a)},onDragStart:function(){this._resetPressedContainer()},_resetPressedContainer:function(){(this._site.pressedContainer||this._site.pressedHeader)&&this._site.animatedElement&&(this._togglePressed(!1),this._site.pressedContainer&&(this._site.pressedContainer.removeEventListener("dragstart",this._DragStartBound),j._removeEventListener(this._site.pressedContainer,"pointerenter",this._PointerEnterBound,!1),j._removeEventListener(this._site.pressedContainer,"pointerleave",this._PointerLeaveBound,!1)))},onClick:function(a){if(!this._skipClick){var b={type:k.ObjectType.item,index:this._site.indexForItemElement(a.target)};if(b.index===l._INVALID_INDEX&&(b.index=this._site.indexForHeaderElement(a.target),b.index!==l._INVALID_INDEX&&(b.type=k.ObjectType.groupHeader)),b.index!==l._INVALID_INDEX&&(j.hasClass(a.target,this._site.accessibleItemClass)||j.hasClass(a.target,l._headerClass))){var c=this._site.verifySelectionAllowed(b);c.canTapSelect&&this.handleTap(b),this._site.fireInvokeEvent(b,a.target)}}},onPointerUp:function(a){f("WinJS.UI._ItemEventsHandler:MSPointerUp,StartTM");var b=this._site;this._skipClick=!0;var c=this,d=this._site.swipeBehavior===k.SwipeBehavior.select;e._yieldForEvents(function(){c._skipClick=!1});try{j._releasePointerCapture(b.canvasProxy,a.pointerId)}catch(g){}var h=a.pointerType===n,i=this._releasedElement(a),m=b.indexForItemElement(i),o=b.indexForHeaderElement(i&&j.hasClass(i,l._headerContainerClass)?b.pressedHeader:i);if(this._pointerId===a.pointerId){var p;if(p=o===l._INVALID_INDEX?{type:k.ObjectType.item,index:m}:{type:k.ObjectType.groupHeader,index:o},this._resetPressedContainer(),this._site.pressedEntity.type!==k.ObjectType.groupHeader&&p.type!==k.ObjectType.groupHeader&&this._site.pressedContainer&&this._site.pressedEntity.index===p.index)if(a.shiftKey||(b.selection._pivot=l._INVALID_INDEX),a.shiftKey){if(this._selectionAllowed()&&this._multiSelection()&&b.selection._pivot!==l._INVALID_INDEX){var q=Math.min(this._site.pressedEntity.index,b.selection._pivot),r=Math.max(this._site.pressedEntity.index,b.selection._pivot),s=this._pointerRightButton||a.ctrlKey||b.tapBehavior===k.TapBehavior.toggleSelect;b.selectRange(q,r,s)}}else(a.ctrlKey||this._selectionAllowed()&&d&&this._pointerRightButton)&&this.handleSwipeBehavior(this._site.pressedEntity.index);if((this._site.pressedHeader||this._site.pressedContainer)&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_COMMITTED){var u=j._getCursorPos(a),v=Math.abs(u.left-this._site.pressedPosition.left)<=l._TAP_END_THRESHOLD&&Math.abs(u.top-this._site.pressedPosition.top)<=l._TAP_END_THRESHOLD;this._endSelfRevealGesture(),this._clearItem(this._site.pressedEntity,this._isSelected(this._site.pressedEntity.index)),this._pointerRightButton||this._pointerTriggeredSRG||a.ctrlKey||a.shiftKey||!(h&&v||!h&&this._site.pressedEntity.index===p.index&&this._site.pressedEntity.type===p.type)||(p.type===k.ObjectType.groupHeader?(this._site.pressedHeader=b.headerAtIndex(p.index),this._site.pressedItemBox=null,this._site.pressedContainer=null):(this._site.pressedItemBox=b.itemBoxAtIndex(p.index),this._site.pressedContainer=b.containerAtIndex(p.index),this._site.pressedHeader=null),this._canTapSelect&&this.handleTap(this._site.pressedEntity),this._site.fireInvokeEvent(this._site.pressedEntity,this._site.pressedItemBox||this._site.pressedHeader))}this._site.pressedEntity.index!==l._INVALID_INDEX&&b.changeFocus(this._site.pressedEntity,!0,!1,!0),this.resetPointerDownState()}f("WinJS.UI._ItemEventsHandler:MSPointerUp,StopTM")},onPointerCancel:function(a){this._pointerId===a.pointerId&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_PRESELECT&&(f("WinJS.UI._ItemEventsHandler:MSPointerCancel,info"),this.resetPointerDownState())},onLostPointerCapture:function(a){this._pointerId===a.pointerId&&this._swipeBehaviorState!==t.MS_MANIPULATION_STATE_PRESELECT&&(f("WinJS.UI._ItemEventsHandler:MSLostPointerCapture,info"),this.resetPointerDownState())},onContextMenu:function(a){var b=this._site.containerFromElement(a.target);this._selectionAllowed()&&b&&!this._isInteractive(a.target)&&a.preventDefault()},onMSHoldVisual:function(a){this._isInteractive(a.target)||a.preventDefault()},onDataChanged:function(){this.resetPointerDownState()},handleSwipeBehavior:function(a){this._selectionAllowed(a)&&this._toggleItemSelection(a)},handleTap:function(a){if(a.type!==k.ObjectType.groupHeader){var b=this._site,c=b.selection;this._selectionAllowed(a.index)&&this._selectOnTap()&&(b.tapBehavior===k.TapBehavior.toggleSelect?this._toggleItemSelection(a.index):b.selectionMode!==k.SelectionMode.multi&&c._isIncluded(a.index)||c.set(a.index))}},_toggleItemSelection:function(a){var b=this._site,c=b.selection,d=c._isIncluded(a);b.selectionMode===k.SelectionMode.single?d?c.clear():c.set(a):d?c.remove(a):c.add(a)},_getCurrentPoint:function(a){return c.Windows.UI.Input.PointerPoint.getCurrentPoint(a.pointerId)},_containedInElementWithClass:function(a,b){if(a.parentNode)for(var c=a.parentNode.querySelectorAll("."+b+", ."+b+" *"),d=0,e=c.length;e>d;d++)if(c[d]===a)return!0;return!1},_isSelected:function(a){return!this._swipeBehaviorSelectionChanged&&this._site.selection._isIncluded(a)||this._swipeBehaviorSelectionChanged&&this.swipeBehaviorSelected},_isInteractive:function(a){return this._containedInElementWithClass(a,"win-interactive")},_togglePressed:function(a,b,c){function d(a){""===m._site.animatedElement.style[p.scriptName]?(m._site.animatedElement.style[p.scriptName]=a,m._site.animatedElementScaleTransform=m._site.animatedElement.style[p.scriptName]):m._site.animatedElementScaleTransform=""}function g(a,b){f("WinJS.UI._ItemEventsHandler:removePressedUI,info"),j.removeClass(a,l._pressedClass),e.isPhone?m._containsTransform(a,b)&&h.executeTransition(a,{property:p.cssName,delay:0,duration:500,timing:"cubic-bezier(0.7025,0,0.9225,-0.115)",to:a.style[p.scriptName].replace(b,"")}):m._removeTransform(a,b)}var m=this,n=this._site.pressedEntity.type===k.ObjectType.groupHeader;if(this._site.animatedDownPromise&&this._site.animatedDownPromise.cancel(),!(e.isPhone&&!n&&j.hasClass(this._site.pressedItemBox,l._nonSelectableClass)||this._staticMode(n)))if(a){if(!j.hasClass(this._site.animatedElement,l._pressedClass))if(f("WinJS.UI._ItemEventsHandler:applyPressedUI,info"),j.addClass(this._site.animatedElement,l._pressedClass),c&&e.isPhone){var q=n?m._site.pressedHeader:m._site.pressedContainer,r=o(c.clientX,c.clientY,q.getBoundingClientRect());this._site.animatedDownPromise=i.timeout(50).then(function(){d(r)})}else{var s=.975,t=7;this._site.getItemPosition(this._site.pressedEntity).then(function(a){a.contentWidth>0&&(s=Math.max(s,1-t/a.contentWidth)),a.contentHeight>0&&(s=Math.max(s,1-t/a.contentHeight))},function(){}),d("scale("+s+","+s+")")}}else if(j.hasClass(this._site.animatedElement,l._pressedClass)){var u=this._site.animatedElement,v=this._site.animatedElementScaleTransform;b?g(u,v):e._setImmediate(function(){j.hasClass(u,l._pressedClass)&&g(u,v)})}},_containsTransform:function(a,b){return b&&-1!==a.style[p.scriptName].indexOf(b)},_removeTransform:function(a,b){this._containsTransform(a,b)&&(a.style[p.scriptName]=a.style[p.scriptName].replace(b,""))},_endSwipeBehavior:function(){if((this._swipeBehaviorState===t.MS_MANIPULATION_STATE_PRESELECT||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_SELECTING||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_DRAGGING||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_COMMITTED||this._swipeBehaviorState===t.MS_MANIPULATION_STATE_CANCELLED)&&this._site.pressedEntity.type!==k.ObjectType.groupHeader){this._flushUIBatches();var a=this._selectionHint;if(this._selectionHint=null,this._site.pressedItemBox){var b=this._site.pressedEntity.index,c=this._site.selection._isIncluded(b);if(c)for(var d=j._getElementsByClasses(this._site.pressedItemBox,[l._selectionCheckmarkClass,l._selectionCheckmarkBackgroundClass]),e=0;ei;i++)h[i].style.opacity=0}}})}},_clearItem:function(a,b){function c(a){var b=--e._swipeClassTracker[s(a)];return b?!1:(delete e._swipeClassTracker[s(a)],j.removeClass(a,l._swipeClass),!0)}function d(a){var b=a.parentNode;b&&j.hasClass(b,l._itemsBlockClass)&&c(b)}if(a.type===k.ObjectType.item){var e=this,f=this._site,g=f.containerAtIndex(a.index),h=f.itemBoxAtIndex(a.index),i=f.itemAtIndex(a.index);if(g&&h&&i){var m=c(g);d(g),m&&q.renderSelection(h,i,b,!0,g)}}},_animateSelectionChange:function(b,c){function d(){var c=b?"addClass":"removeClass";if(j[c](h,l._selectedClass),j[c](g,l._selectedClass),e._selectionHint){var d=a(e._selectionHint,l._selectionHintClass);d&&j[c](d,l._revealedClass)}}var e=this,g=this._site.pressedContainer,h=this._site.pressedItemBox;this._swipeBehaviorSelectionChanged=!0,this.swipeBehaviorSelected=b;var i=j._getElementsByClasses(this._site.pressedItemBox,[l._selectionBorderClass,l._selectionBackgroundClass]);(!b||c)&&(i=i.concat(j._getElementsByClasses(this._site.pressedItemBox,[l._selectionCheckmarkBackgroundClass,l._selectionCheckmarkClass]))),f("WinJS.UI._ItemEventsHandler:"+(b?"hitSelectThreshold":"hitUnselectThreshold")+",info"),this._applyUIInBatches(function(){f("WinJS.UI._ItemEventsHandler:"+(b?"apply":"remove")+"SelectionVisual,info");for(var a=b?1:0,c=0;c0?(c._flushUIBatches(),c._paintedThisFrame=e._requestAnimationFrame(b.bind(c))):c._paintedThisFrame=null}var c=this;this._work.push(a),this._paintedThisFrame||b()},_flushUIBatches:function(){if(this._work.length>0){var a=this._work;this._work=[];for(var b=0;bg;g++)a.appendChild(q._selectionTemplate[g].cloneNode(!0))}else for(var i=a.querySelectorAll(j._selectionPartsSelector),g=0,h=i.length;h>g;g++)a.removeChild(i[g]);j[c?"addClass":"removeClass"](a,l._selectedClass),e&&j[c?"addClass":"removeClass"](e,l._selectedClass)}d&&q.setAriaSelected(b,c)}});return q})})}),define("WinJS/Controls/ListView/_SelectionManager",["exports","../../Core/_Global","../../Core/_Base","../../Promise","../../_Signal","../../Utilities/_UI","../ItemContainer/_Constants"],function(a,b,c,d,e,f,g){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_ItemSet:c.Namespace._lazy(function(){var b=c.Class.define(function(a,b,c){this._listView=a,this._ranges=b,this._itemsCount=c});return b.prototype={getRanges:function(){for(var a=[],b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];a.push({firstIndex:d.firstIndex,lastIndex:d.lastIndex,firstKey:d.firstKey,lastKey:d.lastKey})}return a},getItems:function(){return a.getItemsFromRanges(this._listView._itemsManager.dataSource,this._ranges)},isEverything:function(){return this.count()===this._itemsCount},count:function(){for(var a=0,b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];a+=d.lastIndex-d.firstIndex+1}return a},getIndices:function(){for(var a=[],b=0,c=this._ranges.length;c>b;b++)for(var d=this._ranges[b],e=d.firstIndex;e<=d.lastIndex;e++)a.push(e);return a}},b}),getItemsFromRanges:function(a,b){function c(){for(var a=[],c=0,e=b.length;e>c;c++)for(var f=b[c],g=f.firstIndex;g<=f.lastIndex;g++)a.push(g);return d.wrap(a)}var e=a.createListBinding(),f=[];return c().then(function(a){for(var b=0;bj;j++){var l=h[j];"number"==typeof l?this[a](c("Index",l,l)):l&&(g&&void 0!==l.key?e(c("Key",l.key,l.key)):g&&void 0!==l.firstKey&&void 0!==l.lastKey?e(c("Key",l.firstKey,l.lastKey)):void 0!==l.index&&"number"==typeof l.index?this[a](c("Index",l.index,l.index)):void 0!==l.firstIndex&&void 0!==l.lastIndex&&"number"==typeof l.firstIndex&&"number"==typeof l.lastIndex&&this[a](c("Index",l.firstIndex,l.lastIndex)))}return d.join(i)},_set:function(a){this._retainRange(a),this._ranges.push(a)},_add:function(a){for(var b,c,d,e=this,f=null,g=function(a,b){b.lastIndex>a.lastIndex&&(a.lastIndex=b.lastIndex,a.lastKey=b.lastKey,a.lastPromise&&a.lastPromise.release(),a.lastPromise=e._getListBinding().fromIndex(a.lastIndex).retain())},h=0,i=this._ranges.length;i>h;h++){if(b=this._ranges[h],a.firstIndexh;h++){if(b=this._ranges[h],a.lastIndexa.lastIndex,d&&g(this._ranges[c],f),this._removeRanges(c+1,h-c-1);break}if(a.lastIndex===b.firstIndex){g(this._ranges[c],b),this._removeRanges(c+1,h-c);break}f=b}h>=i&&(g(this._ranges[c],this._ranges[i-1]),this._removeRanges(c+1,i-c-1))}},_remove:function(a){function b(a){return c._getListBinding().fromIndex(a).retain()}for(var c=this,d=[],e=0,f=this._ranges.length;f>e;e++){var g=this._ranges[e];g.lastIndexa.lastIndex?d.push(g):g.firstIndex=a.firstIndex&&g.lastIndex<=a.lastIndex?(d.push({firstIndex:g.firstIndex,firstKey:g.firstKey,firstPromise:g.firstPromise,lastIndex:a.firstIndex-1,lastPromise:b(a.firstIndex-1)}),g.lastPromise.release()):g.lastIndex>a.lastIndex&&g.firstIndex>=a.firstIndex&&g.firstIndex<=a.lastIndex?(d.push({firstIndex:a.lastIndex+1,firstPromise:b(a.lastIndex+1),lastIndex:g.lastIndex,lastKey:g.lastKey,lastPromise:g.lastPromise}),g.firstPromise.release()):g.firstIndexa.lastIndex?(d.push({firstIndex:g.firstIndex,firstKey:g.firstKey,firstPromise:g.firstPromise,lastIndex:a.firstIndex-1,lastPromise:b(a.firstIndex-1)}),d.push({firstIndex:a.lastIndex+1,firstPromise:b(a.lastIndex+1),lastIndex:g.lastIndex,lastKey:g.lastKey,lastPromise:g.lastPromise})):(g.firstPromise.release(),g.lastPromise.release())}this._ranges=d},_ensureKeys:function(){for(var a=[d.wrap()],b=this,c=function(a,b){var c=a+"Key";if(b[c])return d.wrap();var e=b[a+"Promise"];return e.then(function(a){a&&(b[c]=a.key)}),e},e=0,f=this._ranges.length;f>e;e++){var g=this._ranges[e];a.push(c("first",g)),a.push(c("last",g))}return d.join(a).then(function(){b._ranges=b._ranges.filter(function(a){return a.firstKey&&a.lastKey})}),d.join(a)},_mergeRanges:function(a,b){a.lastIndex=b.lastIndex,a.lastKey=b.lastKey},_isIncluded:function(a){if(this.isEverything())return!0;for(var b=0,c=this._ranges.length;c>b;b++){var d=this._ranges[b];if(d.firstIndex<=a&&a<=d.lastIndex)return!0}return!1},_ensureCount:function(){var a=this;return this._listView._itemsCount().then(function(b){a._itemsCount=b})},_insertRange:function(a,b){this._retainRange(b),this._ranges.splice(a,0,b)},_removeRanges:function(a,b){for(var c=0;b>c;c++)this._releaseRange(this._ranges[a+c]);this._ranges.splice(a,b)},_retainRange:function(a){a.firstPromise||(a.firstPromise=this._getListBinding().fromIndex(a.firstIndex).retain()),a.lastPromise||(a.lastPromise=this._getListBinding().fromIndex(a.lastIndex).retain())},_retainRanges:function(){for(var a=0,b=this._ranges.length;b>a;a++)this._retainRange(this._ranges[a])},_releaseRange:function(a){a.firstPromise.release(),a.lastPromise.release()},_releaseRanges:function(a){for(var b=0,c=a.length;c>b;++b)this._releaseRange(a[b])},_getListBinding:function(){return this._listView._itemsManager._listBinding}},{supportedForProcessing:!1})}),_SelectionManager:c.Namespace._lazy(function(){var c=function(b){this._listView=b,this._selected=new a._Selection(this._listView),this._pivot=g._INVALID_INDEX,this._focused={type:f.ObjectType.item,index:0},this._pendingChange=d.wrap()};return c.prototype={count:function(){return this._selected.count()},getIndices:function(){return this._selected.getIndices()},getItems:function(){return this._selected.getItems()},getRanges:function(){return this._selected.getRanges()},isEverything:function(){return this._selected.isEverything()},set:function(b){var c=this,f=new e;return this._synchronize(f).then(function(){var e=new a._Selection(c._listView);return e.set(b).then(function(){c._set(e),f.complete()},function(a){return e.clear(),f.complete(),d.wrapError(a)})})},clear:function(){var b=this,c=new e;return this._synchronize(c).then(function(){var e=new a._Selection(b._listView);return e.clear().then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},add:function(a){var b=this,c=new e;return this._synchronize(c).then(function(){var e=b._cloneSelection();return e.add(a).then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},remove:function(a){var b=this,c=new e;return this._synchronize(c).then(function(){var e=b._cloneSelection();return e.remove(a).then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},selectAll:function(){var b=this,c=new e;return this._synchronize(c).then(function(){var e=new a._Selection(b._listView);return e.selectAll().then(function(){b._set(e),c.complete()},function(a){return e.clear(),c.complete(),d.wrapError(a)})})},_synchronize:function(a){var b=this;return this._listView._versionManager.unlocked.then(function(){var c=b._pendingChange;return b._pendingChange=d.join([c,a.promise]).then(function(){}),c})},_reset:function(){this._pivot=g._INVALID_INDEX,this._setFocused({type:f.ObjectType.item,index:0},this._keyboardFocused()),this._pendingChange.cancel(),this._pendingChange=d.wrap(),this._selected.clear(),this._selected=new a._Selection(this._listView)},_dispose:function(){this._selected.clear(),this._selected=null,this._listView=null},_set:function(a){var b=this;return this._fireSelectionChanging(a).then(function(c){return c?(b._selected.clear(),b._selected=a,b._listView._updateSelection(),b._fireSelectionChanged()):a.clear(),c})},_fireSelectionChanging:function(a){var c=b.document.createEvent("CustomEvent"),e=d.wrap();c.initCustomEvent("selectionchanging",!0,!0,{newSelection:a,preventTapBehavior:function(){},setPromise:function(a){e=a}});var f=this._listView._element.dispatchEvent(c);return e.then(function(){return f})},_fireSelectionChanged:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("selectionchanged",!0,!1,null),this._listView._element.dispatchEvent(a)},_getFocused:function(){return{type:this._focused.type,index:this._focused.index}},_setFocused:function(a,b){this._focused={type:a.type,index:a.index},this._focusedByKeyboard=b},_keyboardFocused:function(){return this._focusedByKeyboard},_updateCount:function(a){this._selected._itemsCount=a},_isIncluded:function(a){return this._selected._isIncluded(a)},_cloneSelection:function(){var b=new a._Selection(this._listView);return b._ranges=this._selected.getRanges(),b._itemsCount=this._selected._itemsCount,b._retainRanges(),b}},c.supportedForProcessing=!1,c})})}),define("WinJS/Controls/ListView/_BrowseMode",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Animations","../../Promise","../../Utilities/_ElementUtilities","../../Utilities/_UI","../ItemContainer/_Constants","../ItemContainer/_ItemEventsHandler","./_SelectionManager"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";var l=d._browserStyleEquivalents.transform.scriptName;c.Namespace._moduleDefine(a,"WinJS.UI",{_SelectionMode:c.Namespace._lazy(function(){function a(a,b,c){return Math.max(a,Math.min(b,c))}function e(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("keyboardnavigating",!0,!0,{oldFocus:c.index,oldFocusType:c.type,newFocus:d.index,newFocusType:d.type}),a.dispatchEvent(e)}var m=c.Class.define(function(a){this.inboundFocusHandled=!1,this._pressedContainer=null,this._pressedItemBox=null,this._pressedHeader=null,this._pressedEntity={type:h.ObjectType.item,index:i._INVALID_INDEX},this._pressedPosition=null,this.initialize(a)},{_dispose:function(){this._itemEventsHandler&&this._itemEventsHandler.dispose(),this._setNewFocusItemOffsetPromise&&this._setNewFocusItemOffsetPromise.cancel()},initialize:function(a){function b(b,c){var d=function(c){return a._view.getAdjacent(c,b)};return d.clampToBounds=c,d}this.site=a,this._keyboardNavigationHandlers={},this._keyboardAcceleratorHandlers={};var c=this.site,d=this;this._itemEventsHandler=new j._ItemEventsHandler(Object.create({containerFromElement:function(a){return c._view.items.containerFrom(a)},indexForItemElement:function(a){return c._view.items.index(a)},indexForHeaderElement:function(a){return c._groups.index(a)},itemBoxAtIndex:function(a){return c._view.items.itemBoxAt(a)},itemAtIndex:function(a){return c._view.items.itemAt(a)},headerAtIndex:function(a){return c._groups.group(a).header},headerFromElement:function(a){return c._groups.headerFrom(a)},containerAtIndex:function(a){return c._view.items.containerAt(a)},isZombie:function(){return c._isZombie()},getItemPosition:function(a){return c._getItemPosition(a)},rtl:function(){return c._rtl()},fireInvokeEvent:function(a,b){return d._fireInvokeEvent(a,b)},verifySelectionAllowed:function(a){return d._verifySelectionAllowed(a)},changeFocus:function(a,b,d,e,f){return c._changeFocus(a,b,d,e,f)},selectRange:function(a,b,c){return d._selectRange(a,b,c)}},{pressedEntity:{enumerable:!0,get:function(){return d._pressedEntity},set:function(a){d._pressedEntity=a}},pressedContainerScaleTransform:{enumerable:!0,get:function(){return d._pressedContainerScaleTransform},set:function(a){d._pressedContainerScaleTransform=a}},pressedContainer:{enumerable:!0,get:function(){return d._pressedContainer},set:function(a){d._pressedContainer=a}},pressedItemBox:{enumerable:!0,get:function(){return d._pressedItemBox},set:function(a){d._pressedItemBox=a}},pressedHeader:{enumerable:!0,get:function(){return d._pressedHeader},set:function(a){return d._pressedHeader=a}},pressedPosition:{enumerable:!0,get:function(){return d._pressedPosition},set:function(a){d._pressedPosition=a}},pressedElement:{enumerable:!0,set:function(a){d._pressedElement=a}},swipeBehavior:{enumerable:!0,get:function(){return c._swipeBehavior}},eventHandlerRoot:{enumerable:!0,get:function(){return c._viewport}},selectionMode:{enumerable:!0,get:function(){return c._selectionMode}},accessibleItemClass:{enumerable:!0,get:function(){return i._itemClass}},canvasProxy:{enumerable:!0,get:function(){return c._canvasProxy}},tapBehavior:{enumerable:!0,get:function(){return c._tap}},headerTapBehavior:{enumerable:!0,get:function(){return c._groupHeaderTap}},draggable:{enumerable:!0,get:function(){return c.itemsDraggable||c.itemsReorderable}},selection:{enumerable:!0,get:function(){return c._selection}},horizontal:{enumerable:!0,get:function(){return c._horizontal()}},customFootprintParent:{enumerable:!0,get:function(){return null}}}));var e=g.Key;this._keyboardNavigationHandlers[e.upArrow]=b(e.upArrow),this._keyboardNavigationHandlers[e.downArrow]=b(e.downArrow),this._keyboardNavigationHandlers[e.leftArrow]=b(e.leftArrow),this._keyboardNavigationHandlers[e.rightArrow]=b(e.rightArrow),this._keyboardNavigationHandlers[e.pageUp]=b(e.pageUp,!0),this._keyboardNavigationHandlers[e.pageDown]=b(e.pageDown,!0),this._keyboardNavigationHandlers[e.home]=function(a){return f.wrap({type:a.type,index:0})},this._keyboardNavigationHandlers[e.end]=function(a){return a.type===h.ObjectType.groupHeader?f.wrap({type:a.type,index:c._groups.length()-1}):d.site._view.finalItem().then(function(b){return{type:a.type,index:b}},function(a){return f.wrapError(a)})},this._keyboardAcceleratorHandlers[e.a]=function(){d.site._multiSelection()&&d._selectAll()}},staticMode:function(){return this.site._tap===h.TapBehavior.none&&this.site._selectionMode===h.SelectionMode.none},itemUnrealized:function(a,b){if(this._pressedEntity.type!==h.ObjectType.groupHeader&&(this._pressedEntity.index===a&&this._resetPointerDownState(),this._itemBeingDragged(a)))for(var c=this._draggedItemBoxes.length-1;c>=0;c--)this._draggedItemBoxes[c]===b&&(g.removeClass(b,i._dragSourceClass),this._draggedItemBoxes.splice(c,1))},_fireInvokeEvent:function(a,c){function d(d,f){var g=d.createListBinding(),h=g.fromIndex(a.index),i=f?"groupheaderinvoked":"iteminvoked";h.done(function(){g.release()});var j=b.document.createEvent("CustomEvent");j.initCustomEvent(i,!0,!0,f?{groupHeaderPromise:h,groupHeaderIndex:a.index}:{itemPromise:h,itemIndex:a.index}),c.dispatchEvent(j)&&e.site._defaultInvoke(a)}if(c){var e=this;a.type===h.ObjectType.groupHeader?this.site._groupHeaderTap===h.GroupHeaderTapBehavior.invoke&&a.index!==i._INVALID_INDEX&&d(this.site.groupDataSource,!0):this.site._tap!==h.TapBehavior.none&&a.index!==i._INVALID_INDEX&&d(this.site.itemDataSource,!1)}},_verifySelectionAllowed:function(a){if(a.type===h.ObjectType.groupHeader)return{canSelect:!1,canTapSelect:!1};var c=a.index,d=this.site,e=this.site._view.items.itemAt(c);if(!d._selectionAllowed()||!d._selectOnTap()&&d._swipeBehavior!==h.SwipeBehavior.select||e&&g.hasClass(e,i._nonSelectableClass))return{canSelect:!1,canTapSelect:!1};var j=d._selection._isIncluded(c),k=!d._multiSelection(),l=d._selection._cloneSelection();j?k?l.clear():l.remove(c):k?l.set(c):l.add(c);var m,n=b.document.createEvent("CustomEvent"),o=f.wrap(),p=!1,q=!1;n.initCustomEvent("selectionchanging",!0,!0,{newSelection:l,preventTapBehavior:function(){q=!0},setPromise:function(a){o=a}});var r=d._element.dispatchEvent(n);o.then(function(){p=!0,m=l._isIncluded(c),l.clear()});var s=r&&p&&(j||m);return{canSelect:s,canTapSelect:s&&!q}},_containedInElementWithClass:function(a,b){if(a.parentNode)for(var c=a.parentNode.querySelectorAll("."+b+", ."+b+" *"),d=0,e=c.length;e>d;d++)if(c[d]===a)return!0;return!1},_isDraggable:function(a){return!this._containedInElementWithClass(a,i._nonDraggableClass)},_isInteractive:function(a){return this._containedInElementWithClass(a,"win-interactive")},_resetPointerDownState:function(){this._itemEventsHandler.resetPointerDownState()},onMSManipulationStateChanged:function(a){this._itemEventsHandler.onMSManipulationStateChanged(a)},onPointerDown:function(a){this._itemEventsHandler.onPointerDown(a)},onclick:function(a){this._itemEventsHandler.onClick(a)},onPointerUp:function(a){this._itemEventsHandler.onPointerUp(a)},onPointerCancel:function(a){this._itemEventsHandler.onPointerCancel(a)},onLostPointerCapture:function(a){this._itemEventsHandler.onLostPointerCapture(a)},onContextMenu:function(a){this._itemEventsHandler.onContextMenu(a)},onMSHoldVisual:function(a){this._itemEventsHandler.onMSHoldVisual(a)},onDataChanged:function(a){this._itemEventsHandler.onDataChanged(a)},_removeTransform:function(a,b){b&&-1!==a.style[l].indexOf(b)&&(a.style[l]=a.style[l].replace(b,""))},_selectAll:function(){var a=[];this.site._view.items.each(function(b,c){c&&g.hasClass(c,i._nonSelectableClass)&&a.push(b)}),this.site._selection.selectAll(),a.length>0&&this.site._selection.remove(a)},_selectRange:function(a,b,c){for(var d=[],e=-1,f=a;b>=f;f++){var h=this.site._view.items.itemAt(f);h&&g.hasClass(h,i._nonSelectableClass)?-1!==e&&(d.push({firstIndex:e,lastIndex:f-1}),e=-1):-1===e&&(e=f)}-1!==e&&d.push({firstIndex:e,lastIndex:b}),d.length>0&&this.site._selection[c?"add":"set"](d)},onDragStart:function(a){if(this._pressedEntity={type:h.ObjectType.item,index:this.site._view.items.index(a.target)},this.site._selection._pivot=i._INVALID_INDEX,this._pressedEntity.index===i._INVALID_INDEX||!this.site.itemsDraggable&&!this.site.itemsReorderable||this.site._view.animating||!this._isDraggable(a.target)||this._pressedElement&&this._isInteractive(this._pressedElement))a.preventDefault();else{this._dragging=!0,this._dragDataTransfer=a.dataTransfer,this._pressedPosition=g._getCursorPos(a),this._dragInfo=null,this._lastEnteredElement=a.target,this.site._selection._isIncluded(this._pressedEntity.index)?this._dragInfo=this.site.selection:(this._draggingUnselectedItem=!0,this._dragInfo=new k._Selection(this.site,[{firstIndex:this._pressedEntity.index,lastIndex:this._pressedEntity.index}]));var c=this.site.itemsReorderable,e=b.document.createEvent("CustomEvent");if(e.initCustomEvent("itemdragstart",!0,!1,{dataTransfer:a.dataTransfer,dragInfo:this._dragInfo}),a.dataTransfer.setData("text",""),a.dataTransfer.setDragImage){var f=this.site._view.items.itemDataAt(this._pressedEntity.index);if(f&&f.container){var j=f.container.getBoundingClientRect();a.dataTransfer.setDragImage(f.container,a.clientX-j.left,a.clientY-j.top)}}this.site.element.dispatchEvent(e),this.site.itemsDraggable&&!this.site.itemsReorderable&&(this._firedDragEnter||this._fireDragEnterEvent(a.dataTransfer)&&(c=!0,this._dragUnderstood=!0)),c&&(this._addedDragOverClass=!0,g.addClass(this.site._element,i._dragOverClass)),this._draggedItemBoxes=[];var l=this,m=a.target;m.addEventListener("dragend",function n(a){m.removeEventListener("dragend",n),l.onDragEnd(a)}),d._yieldForDomModification(function(){if(l._dragging)for(var a=l._dragInfo.getIndices(),b=0,c=a.length;c>b;b++){var d=l.site._view.items.itemDataAt(a[b]);d&&d.itemBox&&l._addDragSourceClass(d.itemBox)}})}},onDragEnter:function(a){var c=this._dragUnderstood;this._lastEnteredElement=a.target,this._exitEventTimer&&(b.clearTimeout(this._exitEventTimer),this._exitEventTimer=0),this._firedDragEnter||this._fireDragEnterEvent(a.dataTransfer)&&(c=!0),(c||this._dragging&&this.site.itemsReorderable)&&(a.preventDefault(),this._dragUnderstood=!0,this._addedDragOverClass||(this._addedDragOverClass=!0,g.addClass(this.site._element,i._dragOverClass))),this._pointerLeftRegion=!1},onDragLeave:function(a){a.target===this._lastEnteredElement&&(this._pointerLeftRegion=!0,this._handleExitEvent())},fireDragUpdateEvent:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("itemdragchanged",!0,!1,{dataTransfer:this._dragDataTransfer,dragInfo:this._dragInfo}),this.site.element.dispatchEvent(a)},_fireDragEnterEvent:function(a){var c=b.document.createEvent("CustomEvent");c.initCustomEvent("itemdragenter",!0,!0,{dataTransfer:a});var d=!this.site.element.dispatchEvent(c);return this._firedDragEnter=!0,d},_fireDragBetweenEvent:function(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("itemdragbetween",!0,!0,{index:a,insertAfterIndex:c,dataTransfer:d}),this.site.element.dispatchEvent(e)},_fireDropEvent:function(a,c,d){var e=b.document.createEvent("CustomEvent");return e.initCustomEvent("itemdragdrop",!0,!0,{index:a,insertAfterIndex:c,dataTransfer:d}),this.site.element.dispatchEvent(e)},_handleExitEvent:function(){this._exitEventTimer&&(b.clearTimeout(this._exitEventTimer),this._exitEventTimer=0);var a=this;this._exitEventTimer=b.setTimeout(function(){if(!a.site._disposed&&a._pointerLeftRegion){if(a.site._layout.dragLeave&&a.site._layout.dragLeave(),a._pointerLeftRegion=!1,a._dragUnderstood=!1,a._lastEnteredElement=null,a._lastInsertPoint=null,a._dragBetweenDisabled=!1,a._firedDragEnter){var c=b.document.createEvent("CustomEvent");c.initCustomEvent("itemdragleave",!0,!1,{}),a.site.element.dispatchEvent(c),a._firedDragEnter=!1}a._addedDragOverClass&&(a._addedDragOverClass=!1,g.removeClass(a.site._element,i._dragOverClass)),a._exitEventTimer=0,a._stopAutoScroll()}},40)},_getEventPositionInElementSpace:function(a,c){var d={left:0,top:0};try{d=a.getBoundingClientRect()}catch(e){}var f=b.getComputedStyle(a,null),g=parseInt(f.paddingLeft),h=parseInt(f.paddingTop),i=parseInt(f.borderLeftWidth),j=parseInt(f.borderTopWidth),k=c.clientX,l=c.clientY,m={x:+k===k?k-d.left-g-i:0,y:+l===l?l-d.top-h-j:0};return this.site._rtl()&&(m.x=d.right-d.left-m.x),m},_getPositionInCanvasSpace:function(a){var b=this.site._horizontal()?this.site.scrollPosition:0,c=this.site._horizontal()?0:this.site.scrollPosition,d=this._getEventPositionInElementSpace(this.site.element,a);return{x:d.x+b,y:d.y+c}},_itemBeingDragged:function(a){return this._dragging?this._draggingUnselectedItem&&this._dragInfo._isIncluded(a)||!this._draggingUnselectedItem&&this.site._isSelected(a):!1},_addDragSourceClass:function(a){this._draggedItemBoxes.push(a),g.addClass(a,i._dragSourceClass),a.parentNode&&g.addClass(a.parentNode,i._footprintClass)},renderDragSourceOnRealizedItem:function(a,b){this._itemBeingDragged(a)&&this._addDragSourceClass(b)},onDragOver:function(b){if(this._dragUnderstood){this._pointerLeftRegion=!1,b.preventDefault();var c=this._getPositionInCanvasSpace(b),d=this._getEventPositionInElementSpace(this.site.element,b);if(this._checkAutoScroll(d.x,d.y),this.site._layout.hitTest)if(this._autoScrollFrame)this._lastInsertPoint&&(this.site._layout.dragLeave(),this._lastInsertPoint=null);else{var e=this.site._view.hitTest(c.x,c.y);e.insertAfterIndex=a(-1,this.site._cachedCount-1,e.insertAfterIndex),this._lastInsertPoint&&this._lastInsertPoint.insertAfterIndex===e.insertAfterIndex&&this._lastInsertPoint.index===e.index||(this._dragBetweenDisabled=!this._fireDragBetweenEvent(e.index,e.insertAfterIndex,b.dataTransfer),this._dragBetweenDisabled?this.site._layout.dragLeave():this.site._layout.dragOver(c.x,c.y,this._dragInfo)),this._lastInsertPoint=e}}},_clearDragProperties:function(){if(this._addedDragOverClass&&(this._addedDragOverClass=!1,g.removeClass(this.site._element,i._dragOverClass)),this._draggedItemBoxes){for(var a=0,b=this._draggedItemBoxes.length;b>a;a++)g.removeClass(this._draggedItemBoxes[a],i._dragSourceClass),this._draggedItemBoxes[a].parentNode&&g.removeClass(this._draggedItemBoxes[a].parentNode,i._footprintClass);this._draggedItemBoxes=[]}this.site._layout.dragLeave(),this._dragging=!1,this._dragInfo=null,this._draggingUnselectedItem=!1,this._dragDataTransfer=null,this._lastInsertPoint=null,this._resetPointerDownState(),this._lastEnteredElement=null,this._dragBetweenDisabled=!1,this._firedDragEnter=!1,this._dragUnderstood=!1,this._stopAutoScroll() +},onDragEnd:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent("itemdragend",!0,!1,{}),this.site.element.dispatchEvent(a),this._clearDragProperties()},_findFirstAvailableInsertPoint:function(a,b,c){for(var d=a.getIndices(),e=-1,f=this.site._cachedCount,g=d.length,h=-1,i=b,j=0;g>j;j++)if(d[j]===i){e=j,h=j;break}for(;e>=0&&i>=0;)c?(i++,g>e&&d[e+1]===i&&f>i?e++:i>=f?(c=!1,i=b,e=h):e=-1):(i--,e>0&&d[e-1]===i?e--:e=-1);return i},_reorderItems:function(a,b,c,d,e){var f=this.site,g=function(a){c?f._selection.remove({key:a[0].key}):f._selection.set({firstKey:a[0].key,lastKey:a[a.length-1].key}),e&&f.ensureVisible(f._selection._getFocused())};b.getItems().then(function(b){var c=f.itemDataSource;if(-1===a){c.beginEdits();for(var e=b.length-1;e>=0;e--)c.moveToStart(b[e].key);c.endEdits(),g(b)}else{var h=c.createListBinding();h.fromIndex(a).then(function(a){if(h.release(),c.beginEdits(),d)for(var e=0,f=b.length;f>e;e++)c.moveBefore(b[e].key,a.key);else for(var e=b.length-1;e>=0;e--)c.moveAfter(b[e].key,a.key);c.endEdits(),g(b)})}})},onDrop:function(b){if(this._draggedItemBoxes)for(var c=0,d=this._draggedItemBoxes.length;d>c;c++)this._draggedItemBoxes[c].parentNode&&g.removeClass(this._draggedItemBoxes[c].parentNode,i._footprintClass);if(!this._dragBetweenDisabled){var e=this._getPositionInCanvasSpace(b),f=this.site._view.hitTest(e.x,e.y),h=a(-1,this.site._cachedCount-1,f.insertAfterIndex),j=!0;if(this._lastInsertPoint&&this._lastInsertPoint.insertAfterIndex===h&&this._lastInsertPoint.index===f.index||(j=this._fireDragBetweenEvent(f.index,h,b.dataTransfer)),j&&(this._lastInsertPoint=null,this.site._layout.dragLeave(),this._fireDropEvent(f.index,h,b.dataTransfer)&&this._dragging&&this.site.itemsReorderable)){if(this._dragInfo.isEverything()||this.site._groupsEnabled())return;h=this._findFirstAvailableInsertPoint(this._dragInfo,h,!1),this._reorderItems(h,this._dragInfo,this._draggingUnselectedItem)}}this._clearDragProperties(),b.preventDefault()},_checkAutoScroll:function(a,c){var e=this.site._getViewportLength(),f=this.site._horizontal(),h=f?a:c,j=this.site._viewport[f?"scrollWidth":"scrollHeight"],k=Math.floor(this.site.scrollPosition),l=0;if(he-i._AUTOSCROLL_THRESHOLD&&(l=h-(e-i._AUTOSCROLL_THRESHOLD)),l=Math.round(l/i._AUTOSCROLL_THRESHOLD*(i._MAX_AUTOSCROLL_RATE-i._MIN_AUTOSCROLL_RATE)),(0===k&&0>l||k>=j-e&&l>0)&&(l=0),0===l)this._autoScrollDelay&&(b.clearTimeout(this._autoScrollDelay),this._autoScrollDelay=0);else if(!this._autoScrollDelay&&!this._autoScrollFrame){var m=this;this._autoScrollDelay=b.setTimeout(function(){if(m._autoScrollRate){m._lastDragTimeout=d._now();var a=function(){if(!m._autoScrollRate&&m._autoScrollFrame||m.site._disposed)m._stopAutoScroll();else{var b=d._now(),c=m._autoScrollRate*((b-m._lastDragTimeout)/1e3);c=0>c?Math.min(-1,c):Math.max(1,c);var e={};e[m.site._scrollProperty]=m.site._viewportScrollPosition+c,g.setScrollPosition(m.site._viewport,e),m._lastDragTimeout=b,m._autoScrollFrame=d._requestAnimationFrame(a)}};m._autoScrollFrame=d._requestAnimationFrame(a)}},i._AUTOSCROLL_DELAY)}this._autoScrollRate=l},_stopAutoScroll:function(){this._autoScrollDelay&&(b.clearTimeout(this._autoScrollDelay),this._autoScrollDelay=0),this._autoScrollRate=0,this._autoScrollFrame=0},onKeyDown:function(a){function b(a,b,g){function j(j){var k=!0,l=!1;if(g?a.index=Math.max(0,Math.min(j,a.index)):(a.index<0||a.index>j)&&(l=!0),!l&&(m.index!==a.index||m.type!==a.type)){var n=e(d._element,m,a);n&&(k=!1,c._setNewFocusItemOffsetPromise&&c._setNewFocusItemOffsetPromise.cancel(),d._batchViewUpdates(i._ViewChange.realize,i._ScrollToPriority.high,function(){return c._setNewFocusItemOffsetPromise=d._getItemOffset(m,!0).then(function(e){e=d._convertFromCanvasCoordinates(e);var g=e.end<=d.scrollPosition||e.begin>=d.scrollPosition+d._getViewportLength()-1;return c._setNewFocusItemOffsetPromise=d._getItemOffset(a).then(function(e){c._setNewFocusItemOffsetPromise=null;var h={position:d.scrollPosition,direction:"right"};return g&&(d._selection._setFocused(a,!0),e=d._convertFromCanvasCoordinates(e),a.index>m.index?(h.direction="right",h.position=e.end-d._getViewportLength()):(h.direction="left",h.position=e.begin)),d._changeFocus(a,b,o,g,!0),g?h:f.cancel},function(c){return d._changeFocus(a,b,o,!0,!0),f.wrapError(c)}),c._setNewFocusItemOffsetPromise},function(c){return d._changeFocus(a,b,o,!0,!0),f.wrapError(c)}),c._setNewFocusItemOffsetPromise},!0))}return k&&(d._selection._setFocused(m,!0),d.ensureVisible(m)),l?{type:h.ObjectType.item,index:i._INVALID_INDEX}:a}return a.type!==h.ObjectType.groupHeader?l.finalItem().then(j):f.wrap(d._groups.length()-1).then(j)}var c=this,d=this.site,j=d._swipeBehavior===h.SwipeBehavior.select,l=d._view,m=d._selection._getFocused(),n=!0,o=a.ctrlKey,p=g.Key,q=a.keyCode,r=d._rtl();if(!this._isInteractive(a.target)){if(a.ctrlKey&&!a.altKey&&!a.shiftKey&&this._keyboardAcceleratorHandlers[q]&&this._keyboardAcceleratorHandlers[q](),d.itemsReorderable&&!a.ctrlKey&&a.altKey&&a.shiftKey&&m.type===h.ObjectType.item&&(q===p.leftArrow||q===p.rightArrow||q===p.upArrow||q===p.downArrow)){var s=d._selection,t=m.index,u=!1,v=!0;if(!s.isEverything()){if(!s._isIncluded(t)){var w=d._view.items.itemAt(t);w&&g.hasClass(w,i._nonDraggableClass)?v=!1:(u=!0,s=new k._Selection(this.site,[{firstIndex:t,lastIndex:t}]))}if(v){var x=t;q===p.rightArrow?x+=r?-1:1:q===p.leftArrow?x+=r?1:-1:q===p.upArrow?x--:x++;var y=x>t,z=y;y&&x>=this.site._cachedCount&&(z=!1,x=this.site._cachedCount-1),x=this._findFirstAvailableInsertPoint(s,x,z),x=Math.min(Math.max(-1,x),this.site._cachedCount-1);var A=x-(y||-1===x?0:1),B=x,C=this.site._groupsEnabled();if(C){var D=this.site._groups,E=x>-1?D.groupFromItem(x):0;y?D.group(E).startIndex===x&&A--:E0?(d._selection._pivot=i._INVALID_INDEX,d._selection.clear()):n=!1;else{var F=m.type===h.ObjectType.groupHeader?d._groups.group(m.index).header:d._view.items.itemBoxAt(m.index);if(F){m.type===h.ObjectType.groupHeader?(this._pressedHeader=F,this._pressedItemBox=null,this._pressedContainer=null):(this._pressedItemBox=F,this._pressedContainer=d._view.items.containerAt(m.index),this._pressedHeader=null);var G=this._verifySelectionAllowed(m);G.canTapSelect&&this._itemEventsHandler.handleTap(m),this._fireInvokeEvent(m,F)}}this._keyDownHandled=n,n&&(a.stopPropagation(),a.preventDefault())}q===p.tab&&(this.site._keyboardFocusInbound=!0)},onKeyUp:function(a){this._keyDownHandled&&(a.stopPropagation(),a.preventDefault())},onTabEntered:function(a){if(0!==this.site._groups.length()){var b=this.site,c=b._selection._getFocused(),d=a.detail,f=!b._hasKeyboardFocus||a.target===b._viewport;if(f)if(this.inboundFocusHandled=!0,c.index=c.index===i._INVALID_INDEX?0:c.index,d||!this.site._supportsGroupHeaderKeyboarding){var g={type:h.ObjectType.item};c.type===h.ObjectType.groupHeader?(g.index=b._groupFocusCache.getIndexForGroup(c.index),e(b._element,c,g)?b._changeFocus(g,!0,!1,!1,!0):b._changeFocus(c,!0,!1,!1,!0)):(g.index=c.index,b._changeFocus(g,!0,!1,!1,!0)),a.preventDefault()}else{var g={type:h.ObjectType.groupHeader};c.type!==h.ObjectType.groupHeader?(g.index=b._groups.groupFromItem(c.index),e(b._element,c,g)?b._changeFocus(g,!0,!1,!1,!0):b._changeFocus(c,!0,!1,!1,!0)):(g.index=c.index,b._changeFocus(g,!0,!1,!1,!0)),a.preventDefault()}}},onTabExiting:function(a){if(this.site._supportsGroupHeaderKeyboarding&&0!==this.site._groups.length()){var b=this.site,c=b._selection._getFocused(),d=a.detail;if(d&&c.type!==h.ObjectType.groupHeader){var f={type:h.ObjectType.groupHeader,index:b._groups.groupFromItem(c.index)};e(b._element,c,f)&&(b._changeFocus(f,!0,!1,!1,!0),a.preventDefault())}else if(!d&&c.type===h.ObjectType.groupHeader){var f={type:h.ObjectType.item,index:b._groupFocusCache.getIndexForGroup(c.index)};e(b._element,c,f)&&(b._changeFocus(f,!0,!1,!1,!0),a.preventDefault())}}}});return m})})}),define("WinJS/Controls/ListView/_ErrorMessages",["exports","../../Core/_Base","../../Core/_Resources"],function(a,b){"use strict";b.Namespace._moduleDefine(a,null,{modeIsInvalid:{get:function(){return"Invalid argument: mode must be one of following values: 'none', 'single' or 'multi'."}},loadingBehaviorIsDeprecated:{get:function(){return"Invalid configuration: loadingBehavior is deprecated. The control will default this property to 'randomAccess'. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},pagesToLoadIsDeprecated:{get:function(){return"Invalid configuration: pagesToLoad is deprecated. The control will not use this property. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},pagesToLoadThresholdIsDeprecated:{get:function(){return"Invalid configuration: pagesToLoadThreshold is deprecated. The control will not use this property. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},automaticallyLoadPagesIsDeprecated:{get:function(){return"Invalid configuration: automaticallyLoadPages is deprecated. The control will default this property to false. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},invalidTemplate:{get:function(){return"Invalid template: Templates must be created before being passed to the ListView, and must contain a valid tree of elements."}},loadMorePagesIsDeprecated:{get:function(){return"loadMorePages is deprecated. Invoking this function will not have any effect. Please refer to the 'ListView loading behaviors' SDK Sample for guidance on how to implement incremental load behavior."}},disableBackdropIsDeprecated:{get:function(){return"Invalid configuration: disableBackdrop is deprecated. Style: .win-listview .win-container.win-backdrop { background-color:transparent; } instead."}},backdropColorIsDeprecated:{get:function(){return"Invalid configuration: backdropColor is deprecated. Style: .win-listview .win-container.win-backdrop { rgba(155,155,155,0.23); } instead."}},itemInfoIsDeprecated:{get:function(){return"GridLayout.itemInfo may be altered or unavailable in future versions. Instead, use CellSpanningLayout."}},groupInfoIsDeprecated:{get:function(){return"GridLayout.groupInfo may be altered or unavailable in future versions. Instead, use CellSpanningLayout."}},resetItemIsDeprecated:{get:function(){return"resetItem may be altered or unavailable in future versions. Instead, mark the element as disposable using WinJS.Utilities.markDisposable."}},resetGroupHeaderIsDeprecated:{get:function(){return"resetGroupHeader may be altered or unavailable in future versions. Instead, mark the header element as disposable using WinJS.Utilities.markDisposable."}},maxRowsIsDeprecated:{get:function(){return"GridLayout.maxRows may be altered or unavailable in future versions. Instead, use the maximumRowsOrColumns property."}}})}),define("WinJS/Controls/ListView/_GroupFocusCache",["exports","../../Core/_Base"],function(a,b){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupFocusCache:b.Namespace._lazy(function(){return b.Class.define(function(a){this._listView=a,this.clear()},{updateCache:function(a,b,c){c=""+c,this._itemToIndex[b]=c,this._groupToItem[a]=b},deleteItem:function(a){if(this._itemToIndex[a])for(var b=this,c=Object.keys(this._groupToItem),d=0,e=c.length;e>d;d++){var f=c[d];if(b._groupToItem[f]===a){b.deleteGroup(f);break}}},deleteGroup:function(a){var b=this._groupToItem[a];b&&delete this._itemToIndex[b],delete this._groupToItem[a]},updateItemIndex:function(a,b){this._itemToIndex[a]&&(this._itemToIndex[a]=""+b)},getIndexForGroup:function(a){var b=this._listView._groups.group(a).key,c=this._groupToItem[b];return c&&this._itemToIndex[c]?+this._itemToIndex[c]:this._listView._groups.fromKey(b).group.startIndex},clear:function(){this._groupToItem={},this._itemToIndex={}}})}),_UnsupportedGroupFocusCache:b.Namespace._lazy(function(){return b.Class.define(null,{updateCache:function(){},deleteItem:function(){},deleteGroup:function(){},updateItemIndex:function(){},getIndexForGroup:function(){return 0},clear:function(){}})})})}),define("WinJS/Controls/ListView/_GroupsContainer",["exports","../../Core/_Base","../../Promise","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_ItemsManager","../../Utilities/_UI","../ItemContainer/_Constants"],function(a,b,c,d,e,f,g,h){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_GroupsContainerBase:b.Namespace._lazy(function(){return b.Class.define(function(){},{index:function(a){var b=this.headerFrom(a);if(b)for(var c=0,d=this.groups.length;d>c;c++)if(b===this.groups[c].header)return c;return h._INVALID_INDEX},headerFrom:function(a){for(;a&&!e.hasClass(a,h._headerClass);)a=a.parentNode;return a},requestHeader:function(a){this._waitingHeaderRequests=this._waitingHeaderRequests||{},this._waitingHeaderRequests[a]||(this._waitingHeaderRequests[a]=[]);var b=this;return new c(function(c){var d=b.groups[a];d&&d.header?c(d.header):b._waitingHeaderRequests[a].push(c)})},notify:function(a,b){if(this._waitingHeaderRequests&&this._waitingHeaderRequests[a]){for(var c=this._waitingHeaderRequests[a],d=0,e=c.length;e>d;d++)c[d](b);this._waitingHeaderRequests[a]=[]}},groupFromImpl:function(a,b,c){if(a>b)return null;var d=a+Math.floor((b-a)/2),e=this.groups[d];return c(e,d)?this.groupFromImpl(a,d-1,c):b>d&&!c(this.groups[d+1],d+1)?this.groupFromImpl(d+1,b,c):d},groupFrom:function(a){if(this.groups.length>0){var b=this.groups.length-1,c=this.groups[b];return a(c,b)?this.groupFromImpl(0,this.groups.length-1,a):b}return null},groupFromItem:function(a){return this.groupFrom(function(b){return aa;a++){var c=this.groups[a];c.userData&&this.listBinding.releaseItem(c.userData)}this.listBinding.release()}},_dispose:function(){this.cleanUp()},synchronizeGroups:function(){var a=this;return this.pendingChanges=[],this.ignoreChanges=!0,this.groupDataSource.invalidateAll().then(function(){return c.join(a.pendingChanges)}).then(function(){return a._listView._ifZombieDispose()?c.cancel:void 0}).then(function(){a.ignoreChanges=!1},function(b){return a.ignoreChanges=!1,c.wrapError(b)})},fromKey:function(a){for(var b=0,c=this.groups.length;c>b;b++){var d=this.groups[b];if(d.key===a)return{group:d,index:b}}return null},fromHandle:function(a){for(var b=0,c=this.groups.length;c>b;b++){var d=this.groups[b];if(d.handle===a)return{group:d,index:b}}return null}})}),_UnvirtualizedGroupsContainer:b.Namespace._lazy(function(){return b.Class.derive(a._GroupsContainerBase,function(a,b){this._listView=a,this.groupDataSource=b,this.groups=[],this.pendingChanges=[],this.dirty=!0;var c=this,f={beginNotifications:function(){c._listView._versionManager.beginNotifications()},endNotifications:function(){c._listView._versionManager.endNotifications(),c._listView._ifZombieDispose()||!c.ignoreChanges&&c._listView._groupsChanged&&c._listView._scheduleUpdate()},indexChanged:function(){c._listView._versionManager.receivedNotification(),c._listView._ifZombieDispose()||this.scheduleUpdate()},itemAvailable:function(){},countChanged:function(a){c._listView._versionManager.receivedNotification(),c._listView._writeProfilerMark("groupCountChanged("+a+"),info"),c._listView._ifZombieDispose()||this.scheduleUpdate()},changed:function(a){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){var b=c.fromKey(a.key);b&&(c._listView._writeProfilerMark("groupChanged("+b.index+"),info"),b.group.userData=a,b.group.startIndex=a.firstItemIndexHint,this.markToRemove(b.group)),this.scheduleUpdate()}},removed:function(a){if(c._listView._versionManager.receivedNotification(),c._listView._groupRemoved(a),!c._listView._ifZombieDispose()){var b=c.fromHandle(a);if(b){c._listView._writeProfilerMark("groupRemoved("+b.index+"),info"),c.groups.splice(b.index,1);var d=c.groups.indexOf(b.group,b.index);d>-1&&c.groups.splice(d,1),this.markToRemove(b.group)}this.scheduleUpdate()}},inserted:function(a,b,d){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){c._listView._writeProfilerMark("groupInserted,info");var e=this;a.retain().then(function(f){var g;if(g=b||d||c.groups.length?e.findIndex(b,d):0,-1!==g){var h={key:f.key,startIndex:f.firstItemIndexHint,userData:f,handle:a.handle};c.groups.splice(g,0,h)}e.scheduleUpdate()}),c.pendingChanges.push(a)}},moved:function(a,b,d){if(c._listView._versionManager.receivedNotification(),!c._listView._ifZombieDispose()){c._listView._writeProfilerMark("groupMoved,info");var e=this;a.then(function(f){var g=e.findIndex(b,d),h=c.fromKey(f.key);if(h)c.groups.splice(h.index,1),-1!==g&&(h.indexe;e++)d.push(a.listBinding.fromIndex(e).retain());return c.join(d)}).then(function(b){a.groups=[];for(var c=0,d=b.length;d>c;c++){var e=b[c];a.groups.push({key:e.key,startIndex:e.firstItemIndexHint,handle:e.handle,userData:e})}a._listView._writeProfilerMark("GroupsContainer_initialize groups("+b.length+"),info"),a._listView._writeProfilerMark("GroupsContainer_initialize,StopTM")},function(b){return a._listView._writeProfilerMark("GroupsContainer_initialize,StopTM"),c.wrapError(b)}),this.initializePromise},renderGroup:function(a){if(this._listView.groupHeaderTemplate){var b=this.groups[a];return c.wrap(this._listView._groupHeaderRenderer(c.wrap(b.userData))).then(f._normalizeRendererReturn)}return c.wrap(null)},setDomElement:function(a,b){this.groups[a].header=b,this.notify(a,b)},removeElements:function(){for(var a=this._listView._groupsToRemove||{},b=Object.keys(a),c=!1,e=this._listView._selection._getFocused(),f=0,h=b.length;h>f;f++){var i=a[b[f]],j=i.header,k=i.group;if(c||e.type!==g.ObjectType.groupHeader||k.userData.index!==e.index||(this._listView._unsetFocusOnItem(),c=!0),j){var l=j.parentNode;l&&(d._disposeElement(j),l.removeChild(j))}}c&&this._listView._setFocusOnItem(e),this._listView._groupsToRemove={}},resetGroups:function(){for(var a=this.groups.slice(0),b=0,c=a.length;c>b;b++){var d=a[b];this.listBinding&&d.userData&&this.listBinding.releaseItem(d.userData)}this.groups.length=0,this.dirty=!0}})}),_NoGroups:b.Namespace._lazy(function(){return b.Class.derive(a._GroupsContainerBase,function(a){this._listView=a,this.groups=[{startIndex:0}],this.dirty=!0},{synchronizeGroups:function(){return c.wrap()},addItem:function(){return c.wrap(this.groups[0])},resetGroups:function(){this.groups=[{startIndex:0}],delete this.pinnedItem,delete this.pinnedOffset,this.dirty=!0},renderGroup:function(){return c.wrap(null)},ensureFirstGroup:function(){return c.wrap(this.groups[0])},groupOf:function(){return c.wrap(this.groups[0])},removeElements:function(){}})})})}),define("WinJS/Controls/ListView/_Helpers",["exports","../../Core/_Base","../../Animations"],function(a,b,c){"use strict";function d(a){return Array.prototype.slice.call(a)}function e(a,b){return new Array(b+1).join(a)}b.Namespace._moduleDefine(a,"WinJS.UI",{_nodeListToArray:d,_repeat:e,_ListViewAnimationHelper:{fadeInElement:function(a){return c.fadeIn(a)},fadeOutElement:function(a){return c.fadeOut(a)},animateEntrance:function(a,b){return c.enterContent(a,[{left:b?"100px":"40px",top:"0px",rtlflip:!0}],{mechanism:"transition"})}}})}),define("WinJS/Controls/ListView/_ItemsContainer",["exports","../../Core/_Base","../../Promise","../../Utilities/_ElementUtilities","../ItemContainer/_Constants"],function(a,b,c,d,e){"use strict";b.Namespace._moduleDefine(a,"WinJS.UI",{_ItemsContainer:b.Namespace._lazy(function(){var a=function(a){this.site=a,this._itemData={},this.waitingItemRequests={}};return a.prototype={requestItem:function(a){this.waitingItemRequests[a]||(this.waitingItemRequests[a]=[]);var b=this,d=new c(function(c){var d=b._itemData[a];d&&!d.detached&&d.element?c(d.element):b.waitingItemRequests[a].push(c)});return d},removeItem:function(a){delete this._itemData[a]},removeItems:function(){this._itemData={},this.waitingItemRequests={}},setItemAt:function(a,b){this._itemData[a]=b,b.detached||this.notify(a,b)},notify:function(a,b){if(this.waitingItemRequests[a]){for(var c=this.waitingItemRequests[a],d=0;da;a++)for(c="."+M[a]+" ",b=d.length-1;b>=0;b--)-1!==d[b].selectorText.indexOf(c)&&K.sheet.deleteRule(b);M=[]}function t(a,b,c,d){s();var e="."+p._listViewClass+" ."+a+" "+c+" { "+d+"}",f="_addDynamicCssRule:"+a+",info";b?b._writeProfilerMark(f):g("WinJS.UI.ListView:Layout"+f),K.sheet.insertRule(e,0)}function u(a){M.push(a)}function v(a,b,c){return Math.max(a,Math.min(b,c))}function w(a,c){return m.convertToPixels(a,b.getComputedStyle(a,null)[c])}function x(a,b){return w(b,"margin"+a)+w(b,"border"+a+"Width")+w(b,"padding"+a)}function y(a){return x("Top",a)+x("Bottom",a)}function z(a){return x("Left",a)+x("Right",a)}function A(a,b){if(a.items)for(var c=0,d=a.items.length;d>c;c++)b(a.items[c],c);else for(var e=0,f=0;ec;c++)b(g.items[c],f++)}function B(a,b){if(0>b)return null;if(a.items)return bd;d++)if(b[d].itemsContainer.element===a){c=b[d].itemsContainer;break}return c}function D(a){var b,c;return a.itemsBlocks?(b=a.itemsBlocks.length,c=b>0?a.itemsBlocks[0].items.length*(b-1)+a.itemsBlocks[b-1].items.length:0):c=a.items.length,c}function E(a){if(!S){var c=b.document.createElement("div");c.style.width="500px",c.style.visibility="hidden";var d=b.document.createElement("div");d.style.cssText+="width: 500px; height: 200px; display: -webkit-flex; display: flex",n.setInnerHTMLUnsafe(d,"
"),c.appendChild(d),a.viewport.insertBefore(c,a.viewport.firstChild);var e=c.offsetWidth>0,f=200;e&&(S={supportsCSSGrid:!!("-ms-grid-row"in b.document.documentElement.style),nestedFlexTooLarge:d.firstElementChild.offsetWidth>f,nestedFlexTooSmall:d.firstElementChild.offsetWidthb;b++)a[b].cleanUp(!0)}var b="Layout:uninitialize,info";this._elementsToMeasure={},this._site?(this._site._writeProfilerMark(b),m.removeClass(this._site.surface,p._gridLayoutClass),m.removeClass(this._site.surface,p._headerPositionTopClass),m.removeClass(this._site.surface,p._headerPositionLeftClass),m.removeClass(this._site.surface,p._structuralNodesClass),this._site.surface.style.cssText="",this._groups&&(a(this._groups),this._groups=null,this._groupMap=null),this._layoutPromise&&(this._layoutPromise.cancel(),this._layoutPromise=null),this._resetMeasurements(),this._oldGroupHeaderPosition=null,this._usingStructuralNodes=null,this._backdropColorClassName&&(m.removeClass(this._site.surface,this._backdropColorClassName),u(this._backdropColorClassName),this._backdropColorClassName=null),this._disableBackdropClassName&&(m.removeClass(this._site.surface,this._disableBackdropClassName),u(this._disableBackdropClassName),this._disableBackdropClassName=null),this._site=null,this._groupsEnabled=null,this._animationsRunning&&this._animationsRunning.cancel(),this._animatingItemsBlocks={}):g("WinJS.UI.ListView:"+b)},numberOfItemsPerItemsBlock:{get:function(){function b(){var a,b=c._site.groupCount;for(a=0;b>a;a++)if(c._isCellSpanning(a))return!1;return!0}var c=this;return c._measureItem(0).then(function(){return c._sizes.viewportContentSize!==c._getViewportCrossSize()&&c._viewportSizeChanged(c._getViewportCrossSize()),c._envInfo.nestedFlexTooLarge||c._envInfo.nestedFlexTooSmall||!b()?(c._usingStructuralNodes=!1,null):(c._usingStructuralNodes=a._LayoutCommon._barsPerItemsBlock>0,a._LayoutCommon._barsPerItemsBlock*c._itemsPerBar)})}},layout:function(a,b,c,d){function e(a){function b(a){if(l._usingStructuralNodes){var b=[];return a.itemsBlocks.forEach(function(a){b=b.concat(a.items.slice(0))}),b}return a.items.slice(0)}return{element:a.element,items:b(a)}}function f(){function c(a,b){var c=a.enableCellSpanning?T.CellSpanningGroup:T.UniformGroup;return new c(l,b)}var d,f=l._groups.length>0?l._getRealizationRange():null,g=[],h=[],j={},k={},m=0,n=a.length;for(d=0;n>d;d++){var o=null,p=l._getGroupInfo(d),q=l._site.groupFromIndex(d).key,r=l._groupMap[q],s=r instanceof T.CellSpanningGroup,t=p.enableCellSpanning;if(r)if(s!==t)j[q]=!0;else{var u=Math.max(0,b.firstIndex-r.startIndex),v=l._rangeForGroup(r,f);v&&u<=v.lastIndex&&(o={firstIndex:Math.max(u,v.firstIndex),lastIndex:v.lastIndex})}var w,x=c(p,a[d].itemsContainer.element);w=x.prepareLayoutWithCopyOfTree?x.prepareLayoutWithCopyOfTree(e(a[d].itemsContainer),o,r,{groupInfo:p,startIndex:m}):x.prepareLayout(D(a[d].itemsContainer),o,r,{groupInfo:p,startIndex:m}),h.push(w),m+=x.count,g.push(x),k[q]=x}return i.join(h).then(function(){for(var a=0,b=0,c=g.length;c>b;b++){var d=g[b];d.offset=a,a+=l._getGroupSize(d)}Object.keys(l._groupMap).forEach(function(a){var b=!j[a];l._groupMap[a].cleanUp(b)}),l._groups=g,l._groupMap=k})}function g(a,c,d){var e,f=l._groups[a],g=Math.max(0,b.firstIndex-f.startIndex),h=l._rangeForGroup(f,c);return d?void f.layoutRealizedRange(g,h):(h||(e=f.startIndex+f.count-1c;c++)g(c,d,!0),l._layoutGroup(c)}}function j(){if(0===l._groups.length)return i.wrap();var a=l._getRealizationRange(),c=n.groupIndexFromItemIndex(a.firstIndex-1),d=n.groupIndexFromItemIndex(a.lastIndex+1),e=n.groupIndexFromItemIndex(b.firstIndex),f=[],h=l._groups.length,j=!1,k=c,m=Math.max(e,d); +for(m=Math.max(k+1,m);!j;)j=!0,k>=e&&(f.push(g(k,a,!1)),j=!1,k--),h>m&&(f.push(g(m,a,!1)),j=!1,m++);return i.join(f)}var k,l=this,n=l._site,o="Layout.layout",q=o+":realizedRange";return l._site._writeProfilerMark(o+",StartTM"),l._site._writeProfilerMark(q+",StartTM"),k=l._measureItem(0).then(function(){return m[l._usingStructuralNodes?"addClass":"removeClass"](l._site.surface,p._structuralNodesClass),l._sizes.viewportContentSize!==l._getViewportCrossSize()&&l._viewportSizeChanged(l._getViewportCrossSize()),l._cacheRemovedElements(c,l._cachedItemRecords,l._cachedInsertedItemRecords,l._cachedRemovedItems,!1),l._cacheRemovedElements(d,l._cachedHeaderRecords,l._cachedInsertedHeaderRecords,l._cachedRemovedHeaders,!0),f()}).then(function(){l._syncDomWithGroupHeaderPosition(a);var b=0;if(l._groups.length>0){var e=l._groups[l._groups.length-1];b=e.offset+l._getGroupSize(e)}l._horizontal?(l._groupsEnabled&&l._groupHeaderPosition===U.left?n.surface.style.cssText+=";height:"+l._sizes.surfaceContentSize+"px;-ms-grid-columns: ("+l._sizes.headerContainerWidth+"px auto)["+a.length+"]":n.surface.style.height=l._sizes.surfaceContentSize+"px",(l._envInfo.nestedFlexTooLarge||l._envInfo.nestedFlexTooSmall)&&(n.surface.style.width=b+"px")):(l._groupsEnabled&&l._groupHeaderPosition===U.top?n.surface.style.cssText+=";width:"+l._sizes.surfaceContentSize+"px;-ms-grid-rows: ("+l._sizes.headerContainerHeight+"px auto)["+a.length+"]":n.surface.style.width=l._sizes.surfaceContentSize+"px",(l._envInfo.nestedFlexTooLarge||l._envInfo.nestedFlexTooSmall)&&(n.surface.style.height=b+"px")),h(),l._layoutAnimations(c,d),l._site._writeProfilerMark(q+":complete,info"),l._site._writeProfilerMark(q+",StopTM")},function(a){return l._site._writeProfilerMark(q+":canceled,info"),l._site._writeProfilerMark(q+",StopTM"),i.wrapError(a)}),l._layoutPromise=k.then(function(){return j().then(function(){l._site._writeProfilerMark(o+":complete,info"),l._site._writeProfilerMark(o+",StopTM")},function(a){return l._site._writeProfilerMark(o+":canceled,info"),l._site._writeProfilerMark(o+",StopTM"),i.wrapError(a)})}),{realizedRangeComplete:k,layoutComplete:l._layoutPromise}},itemsFromRange:function(a,b){return this._rangeContainsItems(a,b)?{firstIndex:this._firstItemFromRange(a),lastIndex:this._lastItemFromRange(b)}:{firstIndex:0,lastIndex:-1}},getAdjacent:function(b,c){function d(){var a={type:b.type,index:b.index-g.startIndex},c=g.getAdjacent(a,h);if("boundary"===c){var d=e._groups[f-1],i=e._groups[f+1],j=e._groups.length-1;if(h===H.leftArrow){if(0===f)return b;if(d instanceof T.UniformGroup&&g instanceof T.UniformGroup){var k=e._indexToCoordinate(a.index),l=e._horizontal?k.row:k.column,m=Math.floor((d.count-1)/e._itemsPerBar),n=m*e._itemsPerBar;return{type:o.ObjectType.item,index:d.startIndex+Math.min(d.count-1,n+l)}}return{type:o.ObjectType.item,index:g.startIndex-1}}if(h===H.rightArrow){if(f===j)return b;if(g instanceof T.UniformGroup&&i instanceof T.UniformGroup){var k=e._indexToCoordinate(a.index),l=e._horizontal?k.row:k.column;return{type:o.ObjectType.item,index:i.startIndex+Math.min(i.count-1,l)}}return{type:o.ObjectType.item,index:i.startIndex}}return b}return c.index+=g.startIndex,c}var e=this,f=e._site.groupIndexFromItemIndex(b.index),g=e._groups[f],h=e._adjustedKeyForOrientationAndBars(e._adjustedKeyForRTL(c),g instanceof T.CellSpanningGroup);if(b.type===o.ObjectType.groupHeader){if(c!==H.pageUp&&c!==H.pageDown){switch(h){case H.leftArrow:return{type:o.ObjectType.groupHeader,index:Math.max(0,b.index-1)};case H.rightArrow:return{type:o.ObjectType.groupHeader,index:Math.min(e._groups.length-1,b.index+1)}}return b}b={type:o.ObjectType.item,index:this._groups[b.index].startIndex}}switch(e._adjustedKeyForRTL(c)){case H.upArrow:case H.leftArrow:case H.downArrow:case H.rightArrow:return d();default:return a._LayoutCommon.prototype._getAdjacentForPageKeys.call(e,b,c)}},hitTest:function(a,b){var c,d=this._sizes;a-=d.layoutOriginX,b-=d.layoutOriginY;var e=this._groupFromOffset(this._horizontal?a:b),f=this._groups[e];return this._horizontal?a-=f.offset:b-=f.offset,this._groupsEnabled&&(this._groupHeaderPosition===U.left?a-=d.headerContainerWidth:b-=d.headerContainerHeight),c=f.hitTest(a,b),c.index+=f.startIndex,c.insertAfterIndex+=f.startIndex,c},setupAnimations:function(){if(0===this._groups.length)return void this._resetAnimationCaches();if(!Object.keys(this._cachedItemRecords).length){this._site._writeProfilerMark("Animation:setupAnimations,StartTM");for(var a=this._getRealizationRange(),b=this._site.tree,c=0,d="horizontal"===this.orientation,e=0,f=b.length;f>e;e++){var g=b[e],h=!1,i=this._groups[e],j=i instanceof T.CellSpanningGroup,k=i?i.offset:0;if(A(g.itemsContainer,function(b,d){if(a.firstIndex<=c&&a.lastIndex>=c&&(h=!0,!this._cachedItemRecords[c])){var f=this._getItemPositionForAnimations(c,e,d),g=f.row,i=f.column,k=f.left,l=f.top;this._cachedItemRecords[c]={oldRow:g,oldColumn:i,oldLeft:k,oldTop:l,width:f.width,height:f.height,element:b,inCellSpanningGroup:j}}c++}.bind(this)),h){var l=e;if(!this._cachedHeaderRecords[l]){var m=this._getHeaderPositionForAnimations(l);this._cachedHeaderRecords[l]={oldLeft:m.left,oldTop:m.top,width:m.width,height:m.height,element:g.header}}this._cachedGroupRecords[I(g.itemsContainer.element)]||(this._cachedGroupRecords[I(g.itemsContainer.element)]={oldLeft:d?k:0,left:d?k:0,oldTop:d?0:k,top:d?0:k,element:g.itemsContainer.element})}}this._site._writeProfilerMark("Animation:setupAnimations,StopTM")}},_layoutAnimations:function(a,b){if(Object.keys(this._cachedItemRecords).length||Object.keys(this._cachedGroupRecords).length||Object.keys(this._cachedHeaderRecords).length){this._site._writeProfilerMark("Animation:layoutAnimation,StartTM"),this._updateAnimationCache(a,b);for(var c=this._getRealizationRange(),d=this._site.tree,e=0,f="horizontal"===this.orientation,g=0,h=d.length;h>g;g++){var i=d[g],j=this._groups[g],k=j instanceof T.CellSpanningGroup,l=j?j.offset:0,n=0,o=0,q=this._cachedGroupRecords[I(i.itemsContainer.element)];q&&(f?n=q.oldLeft-l:o=q.oldTop-l),A(i.itemsContainer,function(a,b){if(c.firstIndex<=e&&c.lastIndex>=e){var d=this._cachedItemRecords[e];if(d){var f=this._getItemPositionForAnimations(e,g,b),h=f.row,i=f.column,j=f.left,l=f.top;if(d.inCellSpanningGroup=d.inCellSpanningGroup||k,d.oldRow!==h||d.oldColumn!==i||d.oldTop!==l||d.oldLeft!==j){d.row=h,d.column=i,d.left=j,d.top=l;var q=d.oldLeft-d.left-n,r=d.oldTop-d.top-o;if(q=(this._site.rtl?-1:1)*q,d.xOffset=q,d.yOffset=r,0!==q||0!==r){var s=d.element;d.needsToResetTransform=!0,s.style[P]="",s.style[O.scriptName]="translate("+q+"px,"+r+"px)"}var t=a.parentNode;m.hasClass(t,p._itemsBlockClass)&&(this._animatingItemsBlocks[I(t)]=t)}}else this._cachedInsertedItemRecords[e]=a,a.style[P]="",a.style.opacity=0}e++}.bind(this));var r=g,s=this._cachedHeaderRecords[r];if(s){var t=this._getHeaderPositionForAnimations(r);if(s.height=t.height,s.width=t.width,s.oldLeft!==t.left||s.oldTop!==t.top){s.left=t.left,s.top=t.top;var u=s.oldLeft-s.left,v=s.oldTop-s.top;if(u=(this._site.rtl?-1:1)*u,0!==u||0!==v){s.needsToResetTransform=!0;var w=s.element;w.style[P]="",w.style[O.scriptName]="translate("+u+"px,"+v+"px)"}}}if(q&&(f&&q.left!==l||!f&&q.top!==l)){var x=q.element;if(0===n&&0===o)q.needsToResetTransform&&(q.needsToResetTransform=!1,x.style[O.scriptName]="");else{var y=(this._site.rtl?-1:1)*n,z=o;q.needsToResetTransform=!0,x.style[P]="",x.style[O.scriptName]="translate("+y+"px, "+z+"px)"}}}if(this._inListMode||1===this._itemsPerBar)for(var B=Object.keys(this._animatingItemsBlocks),C=0,D=B.length;D>C;C++)this._animatingItemsBlocks[B[C]].style.overflow="visible";this._site._writeProfilerMark("Animation:layoutAnimation,StopTM")}},executeAnimations:function(){function b(){if(e(),H)f();else{if(bb._itemsPerBar>1)for(var a=bb._itemsPerBar*bb._sizes.containerCrossSize+bb._getHeaderSizeContentAdjustment()+bb._sizes.containerMargins[U?"top":v.rtl?"right":"left"]+(U?bb._sizes.layoutOriginY:bb._sizes.layoutOriginX),b=0,c=y.length;c>b;b++){var d=y[b];d[V]>d[W]?(N=Math.max(N,d[X]+d[U?"height":"width"]),R=Math.max(R,a-d[Y]),J=!0,T.push(d)):d[V]b;b++){var e=y[b],f=e.element;a.push(f)}for(var b=0,d=z.length;d>b;b++){var e=z[b],f=e.element;a.push(f)}var i=120;u&&(i*=10),G.push(h.executeTransition(a,{property:"opacity",delay:A,duration:i,timing:"linear",to:0})),c(g),v._writeProfilerMark("Animation:cellSpanningFadeOutMove,StopTM")}function g(){v._writeProfilerMark("Animation:cellSpanningFadeInMove,StartTM"),E=0;for(var a=[],b=0,c=y.length;c>b;b++){var d=y[b],e=d.element;e.style[O.scriptName]="",a.push(e)}for(var b=0,c=z.length;c>b;b++){var d=z[b],e=d.element;e.style[O.scriptName]="",a.push(e)}var f=120;u&&(f*=10),G.push(h.executeTransition(a,{property:"opacity",delay:E,duration:f,timing:"linear",to:1})),v._writeProfilerMark("Animation:cellSpanningFadeInMove,StopTM"),r()}function j(a){v._writeProfilerMark("Animation:setupReflowAnimation,StartTM");for(var b={},d=0,e=T.length;e>d;d++){var f=T[d],g=f.xOffset,i=f.yOffset;f[V]>f[W]?U?i-=N:g-=N:f[V]d;d++){var s=M[r[d]];v.rtl&&U?(s.style.paddingLeft=-1*K+"px",s.style.marginLeft=K+"px"):(s.style[U?"paddingRight":"paddingBottom"]=L+"px",s.style[U?"marginRight":"marginBottom"]="-"+L+"px")}for(var t=Object.keys(Z),d=0,e=t.length;e>d;d++)Z[t[d]].classList.add(p._clipClass);c(o),v._writeProfilerMark("Animation:setupReflowAnimation,StopTM")}function n(){for(var a=Object.keys(M),b=0,c=a.length;c>b;b++){var d=M[a[b]];v.rtl&&U?(d.style.paddingLeft="",d.style.marginLeft=""):(d.style[U?"paddingRight":"paddingBottom"]="",d.style[U?"marginRight":"marginBottom"]="")}M={};for(var e=Object.keys(Z),b=0,c=e.length;c>b;b++){var f=Z[e[b]];f.style.overflow="",f.classList.remove(p._clipClass)}}function o(){v._writeProfilerMark("Animation:prepareReflowedItems,StartTM");for(var b=0,c=T.length;c>b;b++){var e=T[b],f=0,g=0;e[V]>e[W]?U?g=R:f=R:e[V]0||z.length>0){v._writeProfilerMark("Animation:setupMoveAnimation,StartTM");for(var c=[],d=0,e=z.length;e>d;d++){var f=z[d].element;c.push(f)}for(var d=0,e=y.length;e>d;d++){var f=y[d].element;c.push(f)}G.push(h.executeTransition(c,{property:O.cssName,delay:B,duration:b,timing:"cubic-bezier(0.1, 0.9, 0.2, 1)",to:""})),E+=80,v._writeProfilerMark("Animation:setupMoveAnimation,StopTM")}r()}function r(){if(w.length>0){v._writeProfilerMark("Animation:setupInsertAnimation,StartTM");var a=120;u&&(a*=10),G.push(h.executeTransition(w,[{property:"opacity",delay:E,duration:a,timing:"linear",to:1}])),v._writeProfilerMark("Animation:setupInsertAnimation,StopTM")}c(s)}function s(){v._writeProfilerMark("Animation:cleanupAnimations,StartTM"),n();for(var a=0,b=x.length;b>a;a++){var c=x[a];c.parentNode&&(l._disposeElement(c),c.parentNode.removeChild(c))}v._writeProfilerMark("Animation:cleanupAnimations,StopTM"),bb._animationsRunning=null,t.complete()}var t=new k;if(this._filterInsertedElements(),this._filterMovedElements(),this._filterRemovedElements(),0===this._insertedElements.length&&0===this._removedElements.length&&0===this._itemMoveRecords.length&&0===this._moveRecords.length)return this._resetAnimationCaches(!0),t.complete(),t.promise;this._animationsRunning=t.promise;for(var u=a.Layout._debugAnimations||a.Layout._slowAnimations,v=this._site,w=this._insertedElements,x=this._removedElements,y=this._itemMoveRecords,z=this._moveRecords,A=0,B=0,E=0,F=null,G=[],H=!1,J=!1,K=0,L=0,M={},N=0,Q=0,R=0,S=0,T=[],U="horizontal"===this.orientation,V=U?"oldColumn":"oldRow",W=U?"column":"row",X=U?"oldTop":"oldLeft",Y=U?"top":"left",Z=this._animatingItemsBlocks,$=0,_=y.length;_>$;$++){var ab=y[$];if(ab.inCellSpanningGroup){H=!0;break}}var bb=this;return a.Layout._debugAnimations?d._requestAnimationFrame(function(){b()}):b(),this._resetAnimationCaches(!0),t.promise.then(null,function(){n();for(var a=0,b=z.length;b>a;a++){var c=z[a].element;c.style[O.scriptName]="",c.style.opacity=1}for(var a=0,b=y.length;b>a;a++){var c=y[a].element;c.style[O.scriptName]="",c.style.opacity=1}for(var a=0,b=w.length;b>a;a++)w[a].style.opacity=1;for(var a=0,b=x.length;b>a;a++){var c=x[a];c.parentNode&&(l._disposeElement(c),c.parentNode.removeChild(c))}this._animationsRunning=null,t=null,F&&F.cancel()}.bind(this)),t.promise},dragOver:function(a,b,c){var d=this.hitTest(a,b),e=this._groups?this._site.groupIndexFromItemIndex(d.index):0,f=this._site.tree[e].itemsContainer,g=D(f),h=this._groups?this._groups[e].startIndex:0,i=this._getVisibleRange();d.index-=h,d.insertAfterIndex-=h,i.firstIndex=Math.max(i.firstIndex-h-1,0),i.lastIndex=Math.min(i.lastIndex-h+1,g);var j=Math.max(Math.min(g-1,d.insertAfterIndex),-1),k=Math.min(j+1,g);if(c){for(var l=j;l>=i.firstIndex;l--){if(!c._isIncluded(l+h)){j=l;break}l===i.firstIndex&&(j=-1)}for(var l=k;ll;l++){var p=this._animatedDragItems[l];p&&(p.style[P]=this._site.animationsDisabled?"":Q,p.style[O.scriptName]="")}this._animatedDragItems=[];var q="horizontal"===this.orientation,r=this._inListMode||1===this._itemsPerBar;this._groups&&this._groups[e]instanceof T.CellSpanningGroup&&(r=1===this._groups[e]._slotsPerColumn);var s=0,t=0;!q&&!r||q&&r?s=this._site.rtl?-R:R:t=R,m&&(m.style[P]=this._site.animationsDisabled?"":Q,m.style[O.scriptName]="translate("+s+"px, "+t+"px)",this._animatedDragItems.push(m)),n&&(n.style[P]=this._site.animationsDisabled?"":Q,n.style[O.scriptName]="translate("+-s+"px, -"+t+"px)",this._animatedDragItems.push(n))},dragLeave:function(){if(this._animatedDragItems)for(var a=0,b=this._animatedDragItems.length;b>a;a++)this._animatedDragItems[a].style[P]=this._site.animationsDisabled?"":Q,this._animatedDragItems[a].style[O.scriptName]="";this._animatedDragItems=[]},_setMaxRowsOrColumns:function(a){a===this._maxRowsOrColumns||this._inListMode||(this._sizes&&this._sizes.containerSizeLoaded&&(this._itemsPerBar=Math.floor(this._sizes.maxItemsContainerContentSize/this._sizes.containerCrossSize),a&&(this._itemsPerBar=Math.min(this._itemsPerBar,a)),this._itemsPerBar=Math.max(1,this._itemsPerBar)),this._maxRowsOrColumns=a,this._invalidateLayout())},_getItemPosition:function(a){if(this._groupsEnabled){var b=Math.min(this._groups.length-1,this._site.groupIndexFromItemIndex(a)),c=this._groups[b],d=a-c.startIndex;return this._getItemPositionForAnimations(a,b,d)}return this._getItemPositionForAnimations(a,0,a)},_getRealizationRange:function(){var a=this._site.realizedRange;return{firstIndex:this._firstItemFromRange(a.firstPixel),lastIndex:this._lastItemFromRange(a.lastPixel)}},_getVisibleRange:function(){var a=this._site.visibleRange;return{firstIndex:this._firstItemFromRange(a.firstPixel),lastIndex:this._lastItemFromRange(a.lastPixel)}},_resetAnimationCaches:function(a){if(!a){this._resetStylesForRecords(this._cachedGroupRecords),this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords),this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords),this._resetStylesForRemovedRecords(this._cachedRemovedItems),this._resetStylesForRemovedRecords(this._cachedRemovedHeaders);for(var b=Object.keys(this._animatingItemsBlocks),c=0,d=b.length;d>c;c++){var e=this._animatingItemsBlocks[b[c]];e.style.overflow="",e.classList.remove(p._clipClass)}}this._cachedGroupRecords={},this._cachedItemRecords={},this._cachedHeaderRecords={},this._cachedInsertedItemRecords={},this._cachedInsertedHeaderRecords={},this._cachedRemovedItems=[],this._cachedRemovedHeaders=[],this._animatingItemsBlocks={}},_cacheRemovedElements:function(a,b,c,d,e){var f="left";this._site.rtl&&(f="right");var g,h;e?(g=this._sizes.headerContainerOuterX,h=this._sizes.headerContainerOuterY):(g=this._sizes.containerMargins[f],h=this._sizes.containerMargins.top);for(var i=0,j=a.length;j>i;i++){var k=a[i];if(-1===k.newIndex){var l=k.element,m=b[k.oldIndex];m&&(m.element=l,delete b[k.oldIndex],l.style.position="absolute",l.style[P]="",l.style.top=m.oldTop-h+"px",l.style[f]=m.oldLeft-g+"px",l.style.width=m.width+"px",l.style.height=m.height+"px",l.style[O.scriptName]="",this._site.surface.appendChild(l),d.push(m)),c[k.oldIndex]&&delete c[k.oldIndex]}}},_cacheInsertedElements:function(a,b,c){for(var d={},e=0,f=a.length;f>e;e++){var g=a[e],h=b[g.oldIndex];if(h&&delete b[g.oldIndex],h||-1===g.oldIndex||g.moved){var i=c[g.newIndex];i&&delete c[g.newIndex];var j=g.element;d[g.newIndex]=j,j.style[P]="",j.style[O.scriptName]="",j.style.opacity=0}}for(var k=Object.keys(b),e=0,f=k.length;f>e;e++)d[k[e]]=b[k[e]];return d},_resetStylesForRecords:function(a){for(var b=Object.keys(a),c=0,d=b.length;d>c;c++){var e=a[b[c]];e.needsToResetTransform&&(e.element.style[O.scriptName]="",e.needsToResetTransform=!1)}},_resetStylesForInsertedRecords:function(a){for(var b=Object.keys(a),c=0,d=b.length;d>c;c++){var e=a[b[c]];e.style.opacity=1}},_resetStylesForRemovedRecords:function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b].element;d.parentNode&&(l._disposeElement(d),d.parentNode.removeChild(d))}},_updateAnimationCache:function(a,b){function c(a,b){for(var c={},e=0,f=a.length;f>e;e++){var g=a[e],h=b[g.oldIndex];h&&(c[g.newIndex]=h,h.element=g.element,delete b[g.oldIndex])}for(var i=Object.keys(b),e=0,f=i.length;f>e;e++){var j=i[e],k=b[j];(!k.element||d[I(k.element)])&&(c[j]=k)}return c}this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords),this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords);for(var d={},e=this._getRealizationRange(),f=this._site.tree,g=0,h=0,i=f.length;i>g;g++)A(f[g].itemsContainer,function(a){e.firstIndex<=h&&e.lastIndex>=h&&(d[I(a)]=!0),h++});this._cachedItemRecords=c(a,this._cachedItemRecords),this._cachedHeaderRecords=c(b,this._cachedHeaderRecords),this._cachedInsertedItemRecords=this._cacheInsertedElements(a,this._cachedInsertedItemRecords,this._cachedItemRecords),this._cachedInsertedHeaderRecords=this._cacheInsertedElements(b,this._cachedInsertedHeaderRecords,this._cachedHeaderRecords)},_filterRemovedElements:function(){function a(a,g){for(var h=0,i=a.length;i>h;h++){var j=a[h],k=j.element;j[c]+j[d]-1f||!b._site.viewport.contains(k)?k.parentNode&&(l._disposeElement(k),k.parentNode.removeChild(k)):g.push(k)}}if(this._removedElements=[],this._site.animationsDisabled)return this._resetStylesForRemovedRecords(this._cachedRemovedItems),void this._resetStylesForRemovedRecords(this._cachedRemovedHeaders);var b=this,c="horizontal"===this.orientation?"oldLeft":"oldTop",d="horizontal"===this.orientation?"width":"height",e=this._site.scrollbarPos,f=e+this._site.viewportSize[d]-1;a(this._cachedRemovedItems,this._removedElements),a(this._cachedRemovedHeaders,this._removedElements)},_filterInsertedElements:function(){function a(a,d){for(var e=Object.keys(a),f=0,g=e.length;g>f;f++){var h=e[f],i=a[h];hc.lastIndex||b._site.viewport.contains(i.element)?i.style.opacity=1:d.push(i)}}if(this._insertedElements=[],this._site.animationsDisabled)return this._resetStylesForInsertedRecords(this._cachedInsertedItemRecords),void this._resetStylesForInsertedRecords(this._cachedInsertedHeaderRecords);var b=this,c=this._getVisibleRange();a(this._cachedInsertedItemRecords,this._insertedElements),a(this._cachedInsertedHeaderRecords,this._insertedElements)},_filterMovedElements:function(){var a=this,b="horizontal"===this.orientation?"oldLeft":"oldTop",c="horizontal"===this.orientation?"left":"top",d="horizontal"===this.orientation?"width":"height",e=this._getRealizationRange(),f=this._site.scrollbarPos,g=f+this._site.viewportSize[d]-1;if(this._itemMoveRecords=[],this._moveRecords=[],!this._site.animationsDisabled)for(var h=this._site.tree,i=0,j=0,k=h.length;k>j;j++){var l=h[j],m=!1;A(l.itemsContainer,function(){if(e.firstIndex<=i&&e.lastIndex>=i){var h=this._cachedItemRecords[i];if(h){var j=(h[b]+h[d]-1>=f&&h[b]<=g||h[c]+h[d]-1>=f&&h[c]<=g)&&a._site.viewport.contains(h.element);j&&(m=!0,h.needsToResetTransform&&(this._itemMoveRecords.push(h),delete this._cachedItemRecords[i]))}}i++}.bind(this));var n=j,o=this._cachedHeaderRecords[n];o&&m&&o.needsToResetTransform&&(this._moveRecords.push(o),delete this._cachedHeaderRecords[n]);var p=this._cachedGroupRecords[I(l.itemsContainer.element)];p&&m&&p.needsToResetTransform&&(this._moveRecords.push(p),delete this._cachedGroupRecords[I(l.itemsContainer.element)])}this._resetStylesForRecords(this._cachedGroupRecords),this._resetStylesForRecords(this._cachedItemRecords),this._resetStylesForRecords(this._cachedHeaderRecords)},_getItemPositionForAnimations:function(a,b,c){var d=this._groups[b],e=d.getItemPositionForAnimations(c),f=this._groups[b]?this._groups[b].offset:0,g=this._groupsEnabled&&this._groupHeaderPosition===U.left?this._sizes.headerContainerWidth:0,h=this._groupsEnabled&&this._groupHeaderPosition===U.top?this._sizes.headerContainerHeight:0;return e.left+=this._sizes.layoutOriginX+g+this._sizes.itemsContainerOuterX,e.top+=this._sizes.layoutOriginY+h+this._sizes.itemsContainerOuterY,e[this._horizontal?"left":"top"]+=f,e},_getHeaderPositionForAnimations:function(a){var b;if(this._groupsEnabled){var c=this._sizes.headerContainerWidth-this._sizes.headerContainerOuterWidth,d=this._sizes.headerContainerHeight-this._sizes.headerContainerOuterHeight;this._groupHeaderPosition!==U.left||this._horizontal?this._groupHeaderPosition===U.top&&this._horizontal&&(c=this._groups[a].getItemsContainerSize()-this._sizes.headerContainerOuterWidth):d=this._groups[a].getItemsContainerSize()-this._sizes.headerContainerOuterHeight;var e=this._horizontal?this._groups[a].offset:0,f=this._horizontal?0:this._groups[a].offset;b={top:this._sizes.layoutOriginY+f+this._sizes.headerContainerOuterY,left:this._sizes.layoutOriginX+e+this._sizes.headerContainerOuterX,height:d,width:c}}else b={top:0,left:0,height:0,width:0};return b},_rangeContainsItems:function(a,b){if(0===this._groups.length)return!1;var c=this._groups[this._groups.length-1],d=this._sizes.layoutOrigin+c.offset+this._getGroupSize(c)-1;return b>=0&&d>=a},_itemFromOffset:function(a,b){function c(a){if(!b.wholeItem){var c=e._horizontal?e._site.rtl?"right":"left":"top",d=e._horizontal?e._site.rtl?"left":"right":"bottom";return b.last?a-e._sizes.containerMargins[c]:a+e._sizes.containerMargins[d]}return a}function d(a){return b.last?a-e._getHeaderSizeGroupAdjustment()-e._sizes.itemsContainerOuterStart:a}var e=this;if(0===this._groups.length)return 0;b=b||{},a-=this._sizes.layoutOrigin,a=c(a);var f=this._groupFromOffset(d(a)),g=this._groups[f];return a-=g.offset,a-=this._getHeaderSizeGroupAdjustment(),g.startIndex+g.itemFromOffset(a,b)},_firstItemFromRange:function(a,b){return b=b||{},b.last=0,this._itemFromOffset(a,b)},_lastItemFromRange:function(a,b){return b=b||{},b.last=1,this._itemFromOffset(a,b)},_adjustedKeyForRTL:function(a){return this._site.rtl&&(a===H.leftArrow?a=H.rightArrow:a===H.rightArrow&&(a=H.leftArrow)),a},_adjustedKeyForOrientationAndBars:function(a,b){var c=a;if(b)return a;if(!this._horizontal)switch(c){case H.leftArrow:c=H.upArrow;break;case H.rightArrow:c=H.downArrow;break;case H.upArrow:c=H.leftArrow;break;case H.downArrow:c=H.rightArrow}return 1===this._itemsPerBar&&(c===H.upArrow?c=H.leftArrow:c===H.downArrow&&(c=H.rightArrow)),c},_getAdjacentForPageKeys:function(a,b){var c,d=this._sizes.containerMargins,e="horizontal"===this.orientation?d.left+d.right:d.top+d.bottom,f=this._site.viewportSize["horizontal"===this.orientation?"width":"height"],g=this._site.scrollbarPos,h=g+f-1-d["horizontal"===this.orientation?"right":"bottom"],i=this._firstItemFromRange(g,{wholeItem:!0}),j=this._lastItemFromRange(h,{wholeItem:!1}),k=this._getItemPosition(a.index),l=!1;if((a.indexj)&&(l=!0,g="horizontal"===this.orientation?k.left-e:k.top-e,h=g+f-1,i=this._firstItemFromRange(g,{wholeItem:!0}),j=this._lastItemFromRange(h,{wholeItem:!1})),b===H.pageUp){if(!l&&i!==a.index)return{type:o.ObjectType.item,index:i};var m;m="horizontal"===this.orientation?k.left+k.width+e+d.left:k.top+k.height+e+d.bottom;var n=this._firstItemFromRange(m-f,{wholeItem:!0});c=a.index===n?Math.max(0,a.index-this._itemsPerBar):n}else{if(!l&&j!==a.index)return{type:o.ObjectType.item,index:j};var p;p="horizontal"===this.orientation?k.left-e-d.right:k.top-e-d.bottom;var q=Math.max(0,this._lastItemFromRange(p+f-1,{wholeItem:!0}));c=a.index===q?a.index+this._itemsPerBar:q}return{type:o.ObjectType.item,index:c}},_isCellSpanning:function(a){var b=this._site.groupFromIndex(a),c=this._groupInfo;return c?!!("function"==typeof c?c(b):c).enableCellSpanning:!1},_getGroupInfo:function(a){var b=this._site.groupFromIndex(a),c=this._groupInfo,d=this._sizes.containerMargins,f={enableCellSpanning:!1};if(c="function"==typeof c?c(b):c){if(c.enableCellSpanning&&(+c.cellWidth!==c.cellWidth||+c.cellHeight!==c.cellHeight))throw new e("WinJS.UI.GridLayout.GroupInfoResultIsInvalid",J.groupInfoResultIsInvalid);f={enableCellSpanning:!!c.enableCellSpanning,cellWidth:c.cellWidth+d.left+d.right,cellHeight:c.cellHeight+d.top+d.bottom}}return f},_getItemInfo:function(a){var b;if(this._itemInfo&&"function"==typeof this._itemInfo)b=this._itemInfo(a);else{if(!this._useDefaultItemInfo)throw new e("WinJS.UI.GridLayout.ItemInfoIsInvalid",J.itemInfoIsInvalid);b=this._defaultItemInfo(a)}return i.as(b).then(function(a){if(!a||+a.width!==a.width||+a.height!==a.height)throw new e("WinJS.UI.GridLayout.ItemInfoIsInvalid",J.itemInfoIsInvalid);return a})},_defaultItemInfo:function(a){var b=this;return this._site.renderItem(this._site.itemFromIndex(a)).then(function(c){return b._elementsToMeasure[a]={element:c},b._measureElements()}).then(function(){var c=b._elementsToMeasure[a],d={width:c.width,height:c.height};return delete b._elementsToMeasure[a],d},function(c){return delete b._elementsToMeasure[a],i.wrapError(c)})},_getGroupSize:function(a){var b=0;return this._groupsEnabled&&(this._horizontal&&this._groupHeaderPosition===U.top?b=this._sizes.headerContainerMinWidth:this._horizontal||this._groupHeaderPosition!==U.left||(b=this._sizes.headerContainerMinHeight)),Math.max(b,a.getItemsContainerSize()+this._getHeaderSizeGroupAdjustment())},_groupFromOffset:function(a){return ab)return null;var d=a+Math.floor((b-a)/2),e=this._groups[d];return c(e,d)?this._groupFromImpl(a,d-1,c):b>d&&!c(this._groups[d+1],d+1)?this._groupFromImpl(d+1,b,c):d},_groupFrom:function(a){if(this._groups.length>0){var b=this._groups.length-1,c=this._groups[b];return a(c,b)?this._groupFromImpl(0,this._groups.length-1,a):b}return null},_invalidateLayout:function(){this._site&&this._site.invalidateLayout()},_resetMeasurements:function(){this._measuringPromise&&(this._measuringPromise.cancel(),this._measuringPromise=null),this._containerSizeClassName&&(m.removeClass(this._site.surface,this._containerSizeClassName),u(this._containerSizeClassName),this._containerSizeClassName=null),this._sizes=null,this._resetAnimationCaches()},_measureElements:function(){if(!this._measuringElements){var a=this;a._measuringElements=j.schedulePromiseHigh(null,"WinJS.UI.GridLayout._measuringElements").then(function(){a._site._writeProfilerMark("_measureElements,StartTM");var c=a._createMeasuringSurface(),d=b.document.createElement("div"),e=a._site,f=a._measuringElements,g=a._elementsToMeasure,h=!1;d.className=p._itemsContainerClass+" "+p._laidOutClass,d.style.cssText+=";display: -ms-grid;-ms-grid-column: 1;-ms-grid-row: 1";var i,j,k=Object.keys(g);for(j=0,i=k.length;i>j;j++){var l=g[k[j]].element;l.style["-ms-grid-column"]=j+1,l.style["-ms-grid-row"]=j+1,d.appendChild(l)}for(c.appendChild(d),e.viewport.insertBefore(c,e.viewport.firstChild),f.then(null,function(){h=!0}),j=0,i=k.length;i>j&&!h;j++){var n=g[k[j]],o=n.element.querySelector("."+p._itemClass);n.width=m.getTotalWidth(o),n.height=m.getTotalHeight(o)}c.parentNode&&c.parentNode.removeChild(c),f===a._measuringElements&&(a._measuringElements=null),e._writeProfilerMark("_measureElements,StopTM")},function(b){return a._measuringElements=null,i.wrapError(b)})}return this._measuringElements},_ensureEnvInfo:function(){return this._envInfo||(this._envInfo=E(this._site),this._envInfo&&!this._envInfo.supportsCSSGrid&&m.addClass(this._site.surface,p._noCSSGrid)),!!this._envInfo},_createMeasuringSurface:function(){var a=b.document.createElement("div");return a.style.cssText="visibility: hidden;-ms-grid-columns: auto;-ms-grid-rows: auto;-ms-flex-align: start;-webkit-align-items: flex-start;align-items: flex-start",a.className=p._scrollableClass+" "+(this._inListMode?p._listLayoutClass:p._gridLayoutClass),this._envInfo.supportsCSSGrid||m.addClass(a,p._noCSSGrid),this._groupsEnabled&&(this._groupHeaderPosition===U.top?m.addClass(a,p._headerPositionTopClass):m.addClass(a,p._headerPositionLeftClass)),a},_measureItem:function(a){function c(a,e){var e,h=!!e,j={},k=f.rtl?"right":"left";return f.itemCount.then(function(b){return!b||d._groupsEnabled&&!f.groupCount?i.cancel:(e=e||f.itemFromIndex(a),j.container=f.renderItem(e),d._groupsEnabled&&(j.headerContainer=f.renderHeader(d._site.groupFromIndex(f.groupIndexFromItemIndex(a)))),i.join(j))}).then(function(j){function l(){var a=d._horizontal,b=d._groupsEnabled,c=!1;g.then(null,function(){c=!0});var e=G(C),h=f.rtl?f.viewport.offsetWidth-(C.offsetLeft+C.offsetWidth):C.offsetLeft,i=C.offsetTop,l={viewportContentSize:0,surfaceContentSize:0,maxItemsContainerContentSize:0,surfaceOuterHeight:y(o),surfaceOuterWidth:z(o),layoutOriginX:h-e[k],layoutOriginY:i-e.top,itemsContainerOuterHeight:y(q),itemsContainerOuterWidth:z(q),itemsContainerOuterX:x(f.rtl?"Right":"Left",q),itemsContainerOuterY:x("Top",q),itemsContainerMargins:G(q),itemBoxOuterHeight:y(s),itemBoxOuterWidth:z(s),containerOuterHeight:y(j.container),containerOuterWidth:z(j.container),emptyContainerContentHeight:m.getContentHeight(r),emptyContainerContentWidth:m.getContentWidth(r),containerMargins:G(j.container),containerWidth:0,containerHeight:0,containerSizeLoaded:!1};b&&(l.headerContainerOuterX=x(f.rtl?"Right":"Left",j.headerContainer),l.headerContainerOuterY=x("Top",j.headerContainer),l.headerContainerOuterWidth=z(j.headerContainer),l.headerContainerOuterHeight=y(j.headerContainer),l.headerContainerWidth=m.getTotalWidth(j.headerContainer),l.headerContainerHeight=m.getTotalHeight(j.headerContainer),l.headerContainerMinWidth=w(j.headerContainer,"minWidth")+l.headerContainerOuterWidth,l.headerContainerMinHeight=w(j.headerContainer,"minHeight")+l.headerContainerOuterHeight); +var n={sizes:l,viewportContentWidth:m.getContentWidth(f.viewport),viewportContentHeight:m.getContentHeight(f.viewport),containerContentWidth:m.getContentWidth(j.container),containerContentHeight:m.getContentHeight(j.container),containerWidth:m.getTotalWidth(j.container),containerHeight:m.getTotalHeight(j.container)};return n.viewportCrossSize=n[a?"viewportContentHeight":"viewportContentWidth"],f.readyToMeasure(),c?null:n}function n(){o.parentNode&&o.parentNode.removeChild(o)}var o=d._createMeasuringSurface(),q=b.document.createElement("div"),r=b.document.createElement("div"),s=j.container.querySelector("."+p._itemBoxClass),t=f.groupIndexFromItemIndex(a);r.className=p._containerClass,q.className=p._itemsContainerClass+" "+p._laidOutClass;var u=1,v=1,A=2,B=2,C=q,D=!1;d._inListMode&&d._groupsEnabled&&(d._horizontal&&d._groupHeaderPosition===U.top?(u=2,B=1,A=1,C=j.headerContainer,D=!0):d._horizontal||d._groupHeaderPosition!==U.left||(v=2,B=1,A=1,C=j.headerContainer,D=!0)),q.style.cssText+=";display: "+(d._inListMode?(d._horizontal?"flex":"block")+"; overflow: hidden":"inline-block")+";vertical-align:top;-ms-grid-column: "+v+";-ms-grid-row: "+u,d._inListMode||(j.container.style.display="inline-block"),d._groupsEnabled&&(j.headerContainer.style.cssText+=";display: inline-block;-ms-grid-column: "+B+";-ms-grid-row: "+A,m.addClass(j.headerContainer,p._laidOutClass+" "+p._groupLeaderClass),(d._groupHeaderPosition===U.top&&d._horizontal||d._groupHeaderPosition===U.left&&!d._horizontal)&&m.addClass(q,p._groupLeaderClass)),D&&o.appendChild(j.headerContainer),q.appendChild(j.container),q.appendChild(r),o.appendChild(q),!D&&d._groupsEnabled&&o.appendChild(j.headerContainer),f.viewport.insertBefore(o,f.viewport.firstChild);var E=l();if(!E)return n(),i.cancel;if(d._horizontal&&0===E.viewportContentHeight||!d._horizontal&&0===E.viewportContentWidth)return n(),i.cancel;if(!(h||d._isCellSpanning(t)||0!==E.containerContentWidth&&0!==E.containerContentHeight))return n(),e.then(function(){return c(a,e)});var F=d._sizes=E.sizes;if(Object.defineProperties(F,{surfaceOuterCrossSize:{get:function(){return d._horizontal?F.surfaceOuterHeight:F.surfaceOuterWidth},enumerable:!0},layoutOrigin:{get:function(){return d._horizontal?F.layoutOriginX:F.layoutOriginY},enumerable:!0},itemsContainerOuterSize:{get:function(){return d._horizontal?F.itemsContainerOuterWidth:F.itemsContainerOuterHeight},enumerable:!0},itemsContainerOuterCrossSize:{get:function(){return d._horizontal?F.itemsContainerOuterHeight:F.itemsContainerOuterWidth},enumerable:!0},itemsContainerOuterStart:{get:function(){return d._horizontal?F.itemsContainerOuterX:F.itemsContainerOuterY},enumerable:!0},itemsContainerOuterCrossStart:{get:function(){return d._horizontal?F.itemsContainerOuterY:F.itemsContainerOuterX},enumerable:!0},containerCrossSize:{get:function(){return d._horizontal?F.containerHeight:F.containerWidth},enumerable:!0},containerSize:{get:function(){return d._horizontal?F.containerWidth:F.containerHeight},enumerable:!0}}),!d._isCellSpanning(t)){if(d._inListMode){var H=E.viewportCrossSize-F.surfaceOuterCrossSize-d._getHeaderSizeContentAdjustment()-F.itemsContainerOuterCrossSize;d._horizontal?(F.containerHeight=H,F.containerWidth=E.containerWidth):(F.containerHeight=E.containerHeight,F.containerWidth=H)}else F.containerWidth=E.containerWidth,F.containerHeight=E.containerHeight;F.containerSizeLoaded=!0}d._createContainerStyleRule(),d._viewportSizeChanged(E.viewportCrossSize),n()})}var d=this,e="Layout:measureItem",f=d._site,g=d._measuringPromise;if(!g){f._writeProfilerMark(e+",StartTM");var h=new k;d._measuringPromise=g=h.promise.then(function(){return d._ensureEnvInfo()?c(a):i.cancel}).then(function(){f._writeProfilerMark(e+":complete,info"),f._writeProfilerMark(e+",StopTM")},function(a){return d._measuringPromise=null,f._writeProfilerMark(e+":canceled,info"),f._writeProfilerMark(e+",StopTM"),i.wrapError(a)}),h.complete()}return g},_getHeaderSizeGroupAdjustment:function(){if(this._groupsEnabled){if(this._horizontal&&this._groupHeaderPosition===U.left)return this._sizes.headerContainerWidth;if(!this._horizontal&&this._groupHeaderPosition===U.top)return this._sizes.headerContainerHeight}return 0},_getHeaderSizeContentAdjustment:function(){if(this._groupsEnabled){if(this._horizontal&&this._groupHeaderPosition===U.top)return this._sizes.headerContainerHeight;if(!this._horizontal&&this._groupHeaderPosition===U.left)return this._sizes.headerContainerWidth}return 0},_getViewportCrossSize:function(){return this._site.viewportSize[this._horizontal?"height":"width"]},_viewportSizeChanged:function(a){var b=this._sizes;b.viewportContentSize=a,b.surfaceContentSize=a-b.surfaceOuterCrossSize,b.maxItemsContainerContentSize=b.surfaceContentSize-b.itemsContainerOuterCrossSize-this._getHeaderSizeContentAdjustment(),b.containerSizeLoaded&&!this._inListMode?(this._itemsPerBar=Math.floor(b.maxItemsContainerContentSize/b.containerCrossSize),this.maximumRowsOrColumns&&(this._itemsPerBar=Math.min(this._itemsPerBar,this.maximumRowsOrColumns)),this._itemsPerBar=Math.max(1,this._itemsPerBar)):(this._inListMode&&(b[this._horizontal?"containerHeight":"containerWidth"]=b.maxItemsContainerContentSize),this._itemsPerBar=1),this._resetAnimationCaches()},_createContainerStyleRule:function(){var a=this._sizes;if(!this._containerSizeClassName&&a.containerSizeLoaded&&(0===a.emptyContainerContentHeight||0===a.emptyContainerContentWidth)){var b=a.containerWidth-a.containerOuterWidth+"px",c=a.containerHeight-a.containerOuterHeight+"px";this._inListMode&&(this._horizontal?c="calc(100% - "+(a.containerMargins.top+a.containerMargins.bottom)+"px)":b="auto"),this._containerSizeClassName||(this._containerSizeClassName=r("containersize"),m.addClass(this._site.surface,this._containerSizeClassName));var d="."+p._containerClass,e="width:"+b+";height:"+c+";";t(this._containerSizeClassName,this._site,d,e)}},_ensureContainerSize:function(a){var b=this._sizes;if(b.containerSizeLoaded||this._ensuringContainerSize)return this._ensuringContainerSize?this._ensuringContainerSize:i.wrap();var c;if(this._itemInfo&&"function"==typeof this._itemInfo||!this._useDefaultItemInfo)c=this._getItemInfo();else{var d=b.containerMargins;c=i.wrap({width:a.groupInfo.cellWidth-d.left-d.right,height:a.groupInfo.cellHeight-d.top-d.bottom})}var e=this;return this._ensuringContainerSize=c.then(function(a){b.containerSizeLoaded=!0,b.containerWidth=a.width+b.itemBoxOuterWidth+b.containerOuterWidth,b.containerHeight=a.height+b.itemBoxOuterHeight+b.containerOuterHeight,e._inListMode?e._itemsPerBar=1:(e._itemsPerBar=Math.floor(b.maxItemsContainerContentSize/b.containerCrossSize),e.maximumRowsOrColumns&&(e._itemsPerBar=Math.min(e._itemsPerBar,e.maximumRowsOrColumns)),e._itemsPerBar=Math.max(1,e._itemsPerBar)),e._createContainerStyleRule()}),c.done(function(){e._ensuringContainerSize=null},function(){e._ensuringContainerSize=null}),c},_indexToCoordinate:function(a,b){b=b||this._itemsPerBar;var c=Math.floor(a/b);return this._horizontal?{column:c,row:a-c*b}:{row:c,column:a-c*b}},_rangeForGroup:function(a,b){var c=a.startIndex,d=c+a.count-1;return!b||b.firstIndex>d||b.lastIndexb;b++)a[b].header.style.maxWidth="",m.removeClass(a[b].itemsContainer.element,p._groupLeaderClass);else this._site.surface.style.msGridRows="";else if(this._oldGroupHeaderPosition===U.left){if(m.removeClass(this._site.surface,p._headerPositionLeftClass),!this._horizontal)for(b=0;c>b;b++)a[b].header.style.maxHeight="",m.removeClass(a[b].itemsContainer.element,p._groupLeaderClass);this._site.surface.style.msGridColumns=""}if(this._groupHeaderPosition===U.top){if(m.addClass(this._site.surface,p._headerPositionTopClass),this._horizontal)for(b=0;c>b;b++)m.addClass(a[b].itemsContainer.element,p._groupLeaderClass)}else if(m.addClass(this._site.surface,p._headerPositionLeftClass),!this._horizontal)for(b=0;c>b;b++)m.addClass(a[b].itemsContainer.element,p._groupLeaderClass);this._oldGroupHeaderPosition=this._groupHeaderPosition}},_layoutGroup:function(a){var b=this._groups[a],c=this._site.tree[a],d=c.header,e=c.itemsContainer.element,f=this._sizes,g=b.getItemsContainerCrossSize();if(this._groupsEnabled){if(this._horizontal)if(this._groupHeaderPosition===U.top){var h=f.headerContainerMinWidth-f.headerContainerOuterWidth,i=b.getItemsContainerSize()-f.headerContainerOuterWidth;d.style.maxWidth=Math.max(h,i)+"px",this._envInfo.supportsCSSGrid?(d.style.msGridColumn=a+1,e.style.msGridColumn=a+1):(d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px",e.style.height=g-f.itemsContainerOuterHeight+"px",e.style.marginBottom=f.itemsContainerMargins.bottom+(f.maxItemsContainerContentSize-g+f.itemsContainerOuterHeight)+"px"),m.addClass(e,p._groupLeaderClass)}else this._envInfo.supportsCSSGrid?(d.style.msGridColumn=2*a+1,e.style.msGridColumn=2*a+2):(d.style.width=f.headerContainerWidth-f.headerContainerOuterWidth+"px",d.style.height=g-f.headerContainerOuterHeight+"px",e.style.height=g-f.itemsContainerOuterHeight+"px");else if(this._groupHeaderPosition===U.left){var j=f.headerContainerMinHeight-f.headerContainerOuterHeight,k=b.getItemsContainerSize()-f.headerContainerOuterHeight;d.style.maxHeight=Math.max(j,k)+"px",this._envInfo.supportsCSSGrid?(d.style.msGridRow=a+1,e.style.msGridRow=a+1):(d.style.width=f.headerContainerWidth-f.headerContainerOuterWidth+"px",e.style.width=g-f.itemsContainerOuterWidth+"px",e.style["margin"+(this._site.rtl?"Left":"Right")]=f.itemsContainerMargins[this._site.rtl?"left":"right"]+(f.maxItemsContainerContentSize-g+f.itemsContainerOuterWidth)+"px"),m.addClass(e,p._groupLeaderClass)}else d.style.msGridRow=2*a+1,this._inListMode?d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px":this._envInfo.supportsCSSGrid?e.style.msGridRow=2*a+2:(d.style.height=f.headerContainerHeight-f.headerContainerOuterHeight+"px",d.style.width=g-f.headerContainerOuterWidth+"px",e.style.width=g-f.itemsContainerOuterWidth+"px");m.addClass(d,p._laidOutClass+" "+p._groupLeaderClass)}m.addClass(e,p._laidOutClass)}},{_barsPerItemsBlock:4})}),_LegacyLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LayoutCommon,null,{disableBackdrop:{get:function(){return this._backdropDisabled||!1},set:function(a){if(m._deprecated(q.disableBackdropIsDeprecated),a=!!a,this._backdropDisabled!==a&&(this._backdropDisabled=a,this._disableBackdropClassName&&(u(this._disableBackdropClassName),this._site&&m.removeClass(this._site.surface,this._disableBackdropClassName),this._disableBackdropClassName=null),this._disableBackdropClassName=r("disablebackdrop"),this._site&&m.addClass(this._site.surface,this._disableBackdropClassName),a)){var b=".win-container.win-backdrop",c="background-color:transparent;";t(this._disableBackdropClassName,this._site,b,c)}}},backdropColor:{get:function(){return this._backdropColor||"rgba(155,155,155,0.23)"},set:function(a){if(m._deprecated(q.backdropColorIsDeprecated),a&&this._backdropColor!==a){this._backdropColor=a,this._backdropColorClassName&&(u(this._backdropColorClassName),this._site&&m.removeClass(this._site.surface,this._backdropColorClassName),this._backdropColorClassName=null),this._backdropColorClassName=r("backdropcolor"),this._site&&m.addClass(this._site.surface,this._backdropColorClassName);var b=".win-container.win-backdrop",c="background-color:"+a+";";t(this._backdropColorClassName,this._site,b,c)}}}})}),GridLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LegacyLayout,function(a){a=a||{},this.itemInfo=a.itemInfo,this.groupInfo=a.groupInfo,this._maxRowsOrColumns=0,this._useDefaultItemInfo=!0,this._elementsToMeasure={},this._groupHeaderPosition=a.groupHeaderPosition||U.top,this.orientation=a.orientation||"horizontal",a.maxRows&&(this.maxRows=+a.maxRows),a.maximumRowsOrColumns&&(this.maximumRowsOrColumns=+a.maximumRowsOrColumns)},{maximumRowsOrColumns:{get:function(){return this._maxRowsOrColumns},set:function(a){this._setMaxRowsOrColumns(a)}},maxRows:{get:function(){return this.maximumRowsOrColumns},set:function(a){m._deprecated(q.maxRowsIsDeprecated),this.maximumRowsOrColumns=a}},itemInfo:{enumerable:!0,get:function(){return this._itemInfo},set:function(a){a&&m._deprecated(q.itemInfoIsDeprecated),this._itemInfo=a,this._invalidateLayout()}},groupInfo:{enumerable:!0,get:function(){return this._groupInfo},set:function(a){a&&m._deprecated(q.groupInfoIsDeprecated),this._groupInfo=a,this._invalidateLayout()}}})})});var T=c.Namespace.defineWithParent(null,null,{UniformGroupBase:c.Namespace._lazy(function(){return c.Class.define(null,{cleanUp:function(){},itemFromOffset:function(a,b){b=b||{};var c=this._layout._sizes;a-=c.itemsContainerOuterStart,b.wholeItem&&(a+=(b.last?-1:1)*(c.containerSize-1));var d=this.count-1,e=Math.floor(d/this._layout._itemsPerBar),f=v(0,e,Math.floor(a/c.containerSize)),g=(f+b.last)*this._layout._itemsPerBar-b.last;return v(0,this.count-1,g)},hitTest:function(a,b){var c=this._layout._horizontal,d=this._layout._itemsPerBar,e=this._layout._inListMode||1===d,f=c?a:b,g=c?b:a,h=this._layout._sizes;f-=h.itemsContainerOuterStart,g-=h.itemsContainerOuterCrossStart;var i,j=Math.floor(f/h.containerSize),k=v(0,d-1,Math.floor(g/h.containerCrossSize)),l=Math.max(-1,j*d+k);if(i=!c&&e||c&&!e?(b-h.containerHeight/2)/h.containerHeight:(a-h.containerWidth/2)/h.containerWidth,e)return i=Math.floor(i),{index:l,insertAfterIndex:i>=0&&l>=0?i:-1};i=v(-1,d-1,i);var m;return m=0>i?j*d-1:j*d+Math.floor(i),{index:v(-1,this.count-1,l),insertAfterIndex:v(-1,this.count-1,m)}},getAdjacent:function(a,b){var c,d=a.index,e=Math.floor(d/this._layout._itemsPerBar),f=d%this._layout._itemsPerBar;switch(b){case H.upArrow:c=0===f?"boundary":d-1;break;case H.downArrow:var g=d===this.count-1,h=this._layout._itemsPerBar>1&&f===this._layout._itemsPerBar-1;c=g||h?"boundary":d+1;break;case H.leftArrow:c=0===e&&this._layout._itemsPerBar>1?"boundary":d-this._layout._itemsPerBar;break;case H.rightArrow:var i=this.count-1,j=Math.floor(i/this._layout._itemsPerBar);c=e===j?"boundary":Math.min(d+this._layout._itemsPerBar,this.count-1)}return"boundary"===c?c:{type:o.ObjectType.item,index:c}},getItemsContainerSize:function(){var a=this._layout._sizes,b=Math.ceil(this.count/this._layout._itemsPerBar);return b*a.containerSize+a.itemsContainerOuterSize},getItemsContainerCrossSize:function(){var a=this._layout._sizes;return this._layout._itemsPerBar*a.containerCrossSize+a.itemsContainerOuterCrossSize},getItemPositionForAnimations:function(a){var b=this._layout._sizes,c=this._layout._site.rtl?"right":"left",d=this._layout._sizes.containerMargins,e=this._layout._indexToCoordinate(a),f={row:e.row,column:e.column,top:d.top+e.row*b.containerHeight,left:d[c]+e.column*b.containerWidth,height:b.containerHeight-b.containerMargins.top-b.containerMargins.bottom,width:b.containerWidth-b.containerMargins.left-b.containerMargins.right};return f}})}),UniformGroup:c.Namespace._lazy(function(){return c.Class.derive(T.UniformGroupBase,function(a,b){this._layout=a,this._itemsContainer=b,m.addClass(this._itemsContainer,a._inListMode?p._uniformListLayoutClass:p._uniformGridLayoutClass)},{cleanUp:function(a){a||(m.removeClass(this._itemsContainer,p._uniformGridLayoutClass),m.removeClass(this._itemsContainer,p._uniformListLayoutClass),this._itemsContainer.style.height=this._itemsContainer.style.width=""),this._itemsContainer=null,this._layout=null,this.groupInfo=null,this.startIndex=null,this.offset=null,this.count=null},prepareLayout:function(a,b,c,d){return this.groupInfo=d.groupInfo,this.startIndex=d.startIndex,this.count=a,this._layout._ensureContainerSize(this)},layoutRealizedRange:function(){var a=this._layout._sizes;this._itemsContainer.style[this._layout._horizontal?"width":"height"]=this.getItemsContainerSize()-a.itemsContainerOuterSize+"px",this._itemsContainer.style[this._layout._horizontal?"height":"width"]=this._layout._inListMode?a.maxItemsContainerContentSize+"px":this._layout._itemsPerBar*a.containerCrossSize+"px"},layoutUnrealizedRange:function(){return i.wrap()}})}),UniformFlowGroup:c.Namespace._lazy(function(){return c.Class.derive(T.UniformGroupBase,function(a,b){this._layout=a,this._itemsContainer=b.element,m.addClass(this._itemsContainer,a._inListMode?p._uniformListLayoutClass:p._uniformGridLayoutClass)},{cleanUp:function(a){a||(m.removeClass(this._itemsContainer,p._uniformListLayoutClass),m.removeClass(this._itemsContainer,p._uniformGridLayoutClass),this._itemsContainer.style.height="")},layout:function(){this._layout._site._writeProfilerMark("Layout:_UniformFlowGroup:setItemsContainerHeight,info"),this._itemsContainer.style.height=this.count*this._layout._sizes.containerHeight+"px"}})}),CellSpanningGroup:c.Namespace._lazy(function(){return c.Class.define(function(a,b){this._layout=a,this._itemsContainer=b,m.addClass(this._itemsContainer,p._cellSpanningGridLayoutClass),this.resetMap()},{cleanUp:function(a){a||(this._cleanContainers(),m.removeClass(this._itemsContainer,p._cellSpanningGridLayoutClass),this._itemsContainer.style.cssText=""),this._itemsContainer=null,this._layoutPromise&&(this._layoutPromise.cancel(),this._layoutPromise=null),this.resetMap(),this._slotsPerColumn=null,this._offScreenSlotsPerColumn=null,this._items=null,this._layout=null,this._containersToHide=null,this.groupInfo=null,this.startIndex=null,this.offset=null,this.count=null},prepareLayoutWithCopyOfTree:function(a,b,c,d){var e,f=this;if(this._containersToHide={},b)for(e=b.firstIndex;e<=b.lastIndex;e++)this._containersToHide[I(c._items[e])]=c._items[e];this.groupInfo=d.groupInfo,this.startIndex=d.startIndex,this.count=a.items.length,this._items=a.items,this._slotsPerColumn=Math.floor(this._layout._sizes.maxItemsContainerContentSize/this.groupInfo.cellHeight),this._layout.maximumRowsOrColumns&&(this._slotsPerColumn=Math.min(this._slotsPerColumn,this._layout.maximumRowsOrColumns)),this._slotsPerColumn=Math.max(this._slotsPerColumn,1),this.resetMap();var g=new Array(this.count);for(e=0;e=a&&(e._layoutItem(k),k--,i=!1),l=a;m--){if(b.shouldYield)return void b.setWork(o);e._layoutItem(m)}g()})}else{var m=a;d=h(function p(a){for(;m0))return{type:o.ObjectType.item,index:d};g--;break;case H.downArrow:if(!(i+10?g-this._slotsPerColumn:-1;break;case H.rightArrow:g=j>h?g+this._slotsPerColumn:this.occupancyMap.length}f=g>=0&&g0){for(var e=this.indexFromOffset(a,!1,0),f=Math.min(this._slotsPerColumn-1,Math.floor(b/this.groupInfo.cellHeight)),g=e.index,h=g;f-->0;)g++,this.occupancyMap[g]&&(h=g);this.occupancyMap[h]||h--,d=this.occupancyMap[h].index}var i=this.getItemSize(d),j=i.column*this.groupInfo.cellWidth,k=i.row*this.groupInfo.cellHeight,l=1===this._slotsPerColumn,m=d;return(l&&aa;a++)b[a].style.cssText="",m.removeClass(b[a],p._laidOutClass)},getColumnCount:function(){return Math.ceil(this.occupancyMap.length/this._slotsPerColumn)},getOccupancyMapItemCount:function(){var a=-1;return this.occupancyMap.forEach(function(b){b.index>a&&(a=b.index)}),a+1},coordinateToIndex:function(a,b){return a*this._slotsPerColumn+b},markSlotAsFull:function(a,b){for(var c=this._layout._indexToCoordinate(a,this._slotsPerColumn),d=c.row+b.rows,e=c.row;d>e&&ef;f++)this.occupancyMap[this.coordinateToIndex(f,e)]=b;this._offScreenSlotsPerColumn=Math.max(this._offScreenSlotsPerColumn,d-this._slotsPerColumn)},isSlotEmpty:function(a,b,c){for(var d=b,e=b+a.rows;e>d;d++)for(var f=c,g=c+a.columns;g>f;f++)if(d>=this._slotsPerColumn||void 0!==this.occupancyMap[this.coordinateToIndex(f,d)])return!1;return!0},findEmptySlot:function(a,b,c){var d=this._layout._indexToCoordinate(a,this._slotsPerColumn),e=d.row,f=Math.floor((this.occupancyMap.length-1)/this._slotsPerColumn);if(c){for(var g=d.column+1;f>=g;g++)if(this.isSlotEmpty(b,0,g))return this.coordinateToIndex(g,0)}else for(var g=d.column;f>=g;g++){for(var h=e;hb;b++){var d=this.occupancyMap[b];if(d&&d.index===a)return b}return b},getItemSize:function(a){var b=this.findItem(a),c=this.occupancyMap[b],d=this._layout._indexToCoordinate(b,this._slotsPerColumn);return a===c.index?{row:d.row,column:d.column,contentWidth:c.contentWidth,contentHeight:c.contentHeight,columns:c.columns,rows:c.rows}:null},resetMap:function(){this.occupancyMap=[],this.lastAdded=0,this._offScreenSlotsPerColumn=0},addItemToMap:function(a,b){function c(a,b){var c=d.findEmptySlot(d.lastAdded,a,b);d.lastAdded=c,d.markSlotAsFull(c,a)}var d=this,e=d.groupInfo,f=d._layout._sizes.containerMargins,g={index:a,contentWidth:b.width,contentHeight:b.height,columns:Math.max(1,Math.ceil((b.width+f.left+f.right)/e.cellWidth)),rows:Math.max(1,Math.ceil((b.height+f.top+f.bottom)/e.cellHeight))};c(g,b.newColumn)},indexFromOffset:function(a,b,c){var d=0,e=0,f=this.groupInfo,g=0;if(this.occupancyMap.length>0){if(e=this.getOccupancyMapItemCount()-1,d=Math.ceil((this.occupancyMap.length-1)/this._slotsPerColumn)*f.cellWidth,d>a){for(var h=this._slotsPerColumn,g=(Math.max(0,Math.floor(a/f.cellWidth))+c)*this._slotsPerColumn-c;!this.occupancyMap[g]&&h-->0;)g+=c>0?-1:1;return{index:g,item:this.occupancyMap[g].index}}g=this.occupancyMap.length-1}return{index:g,item:e+(Math.max(0,Math.floor((a-d)/f.cellWidth))+c)*this._slotsPerColumn-c}}})})});c.Namespace._moduleDefine(a,"WinJS.UI",{ListLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LegacyLayout,function(a){a=a||{},this._itemInfo={},this._groupInfo={},this._groupHeaderPosition=a.groupHeaderPosition||U.top,this._inListMode=!0,this.orientation=a.orientation||"vertical"},{initialize:function(b,c){m.addClass(b.surface,p._listLayoutClass),a._LegacyLayout.prototype.initialize.call(this,b,c)},uninitialize:function(){this._site&&m.removeClass(this._site.surface,p._listLayoutClass),a._LegacyLayout.prototype.uninitialize.call(this)},layout:function(b,c,d,e){return this._groupsEnabled||this._horizontal?a._LegacyLayout.prototype.layout.call(this,b,c,d,e):this._layoutNonGroupedVerticalList(b,c,d,e)},_layoutNonGroupedVerticalList:function(a,b,c,d){var e=this,f="Layout:_layoutNonGroupedVerticalList";return e._site._writeProfilerMark(f+",StartTM"),this._layoutPromise=e._measureItem(0).then(function(){m[e._usingStructuralNodes?"addClass":"removeClass"](e._site.surface,p._structuralNodesClass),e._sizes.viewportContentSize!==e._getViewportCrossSize()&&e._viewportSizeChanged(e._getViewportCrossSize()),e._cacheRemovedElements(c,e._cachedItemRecords,e._cachedInsertedItemRecords,e._cachedRemovedItems,!1),e._cacheRemovedElements(d,e._cachedHeaderRecords,e._cachedInsertedHeaderRecords,e._cachedRemovedHeaders,!0);var b=a[0].itemsContainer,g=new T.UniformFlowGroup(e,b);e._groups=[g],g.groupInfo={enableCellSpanning:!1},g.startIndex=0,g.count=D(b),g.offset=0,g.layout(),e._site._writeProfilerMark(f+":setSurfaceWidth,info"),e._site.surface.style.width=e._sizes.surfaceContentSize+"px",e._layoutAnimations(c,d),e._site._writeProfilerMark(f+":complete,info"),e._site._writeProfilerMark(f+",StopTM")},function(a){return e._site._writeProfilerMark(f+":canceled,info"),e._site._writeProfilerMark(f+",StopTM"),i.wrapError(a)}),{realizedRangeComplete:this._layoutPromise,layoutComplete:this._layoutPromise}},numberOfItemsPerItemsBlock:{get:function(){var b=this;return this._measureItem(0).then(function(){return b._usingStructuralNodes=b._envInfo.nestedFlexTooLarge||b._envInfo.nestedFlexTooSmall?!1:a.ListLayout._numberOfItemsPerItemsBlock>0,b._usingStructuralNodes?a.ListLayout._numberOfItemsPerItemsBlock:null})}}},{_numberOfItemsPerItemsBlock:10})}),CellSpanningLayout:c.Namespace._lazy(function(){return c.Class.derive(a._LayoutCommon,function(a){a=a||{},this._itemInfo=a.itemInfo,this._groupInfo=a.groupInfo,this._groupHeaderPosition=a.groupHeaderPosition||U.top,this._horizontal=!0,this._cellSpanning=!0},{maximumRowsOrColumns:{get:function(){return this._maxRowsOrColumns},set:function(a){this._setMaxRowsOrColumns(a)}},itemInfo:{enumerable:!0,get:function(){return this._itemInfo},set:function(a){this._itemInfo=a,this._invalidateLayout()}},groupInfo:{enumerable:!0,get:function(){return this._groupInfo},set:function(a){this._groupInfo=a,this._invalidateLayout()}},orientation:{enumerable:!0,get:function(){return"horizontal"}}})}),_LayoutWrapper:c.Namespace._lazy(function(){return c.Class.define(function(a){this.defaultAnimations=!0,this.initialize=function(b,c){a.initialize(b,c)},this.hitTest=function(b,c){return a.hitTest(b,c)},a.uninitialize&&(this.uninitialize=function(){a.uninitialize()}),"numberOfItemsPerItemsBlock"in a&&Object.defineProperty(this,"numberOfItemsPerItemsBlock",{get:function(){return a.numberOfItemsPerItemsBlock}}),a._getItemPosition&&(this._getItemPosition=function(b){return a._getItemPosition(b)}),a.itemsFromRange&&(this.itemsFromRange=function(b,c){return a.itemsFromRange(b,c)}),a.getAdjacent&&(this.getAdjacent=function(b,c){return a.getAdjacent(b,c)}),a.dragOver&&(this.dragOver=function(b,c,d){return a.dragOver(b,c,d)}),a.dragLeave&&(this.dragLeave=function(){return a.dragLeave()});var b={enumerable:!0,get:function(){return"vertical"}};if(void 0!==a.orientation&&(b.get=function(){return a.orientation},b.set=function(b){a.orientation=b}),Object.defineProperty(this,"orientation",b),(a.setupAnimations||a.executeAnimations)&&(this.defaultAnimations=!1,this.setupAnimations=function(){return a.setupAnimations()},this.executeAnimations=function(){return a.executeAnimations()}),a.layout)if(this.defaultAnimations){var c=this;this.layout=function(b,d,e,f){var g,h=F(a.layout(b,d,[],[]));return h.realizedRangeComplete.then(function(){g=!0}),g&&c._layoutAnimations(e,f),h}}else this.layout=function(b,c,d,e){return F(a.layout(b,c,d,e))}},{uninitialize:function(){},numberOfItemsPerItemsBlock:{get:function(){}},layout:function(a,b,c,d){return this.defaultAnimations&&this._layoutAnimations(c,d),F()},itemsFromRange:function(){return{firstIndex:0,lastIndex:Number.MAX_VALUE}},getAdjacent:function(a,b){switch(b){case H.pageUp:case H.upArrow:case H.leftArrow:return{type:a.type,index:a.index-1};case H.downArrow:case H.rightArrow:case H.pageDown:return{type:a.type,index:a.index+1}}},dragOver:function(){},dragLeave:function(){},setupAnimations:function(){},executeAnimations:function(){},_getItemPosition:function(){},_layoutAnimations:function(){}})})});var U={left:"left",top:"top"};c.Namespace._moduleDefine(a,"WinJS.UI",{HeaderPosition:U,_getMargins:G})}),define("WinJS/Controls/ListView/_VirtualizeContentsView",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Promise","../../_Signal","../../Scheduler","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_SafeHtml","../../Utilities/_UI","../ItemContainer/_Constants","../ItemContainer/_ItemEventsHandler","./_Helpers","./_ItemsContainer"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";function p(a,b){i._setAttribute(a,"aria-flowto",b.id),i._setAttribute(b,"x-ms-aria-flowfrom",a.id)}c.Namespace._moduleDefine(a,"WinJS.UI",{_VirtualizeContentsView:c.Namespace._lazy(function(){function a(b){for(var c,d=b.job._workItems;d.length&&!b.shouldYield;)(c=d.shift())();b.setWork(a),d.length||b.job.pause()}function q(b,c){var d=g.schedule(a,b,null,c);return d._workItems=[],d.addWork=function(a,b){b?this._workItems.unshift(a):this._workItems.push(a),this.resume()},d.clearWork=function(){this._workItems.length=0},d.dispose=function(){this.cancel(),this._workItems.length=0},d}function r(a){return a._zooming||a._pinching}function s(a,b){return a._isZombie()?e.wrap():r(a)?(+b!==b&&(b=v._waitForSeZoTimeoutDuration),e.timeout(v._waitForSeZoIntervalDuration).then(function(){return b-=v._waitForSeZoIntervalDuration,0>=b?!0:s(a,b)})):e.wrap()}function t(a){if("number"==typeof a){var b=a;a=function(){return{position:b,direction:"right"}}}return a}function u(){}var v=c.Class.define(function(a){this._listView=a,this._forceRelayout=!1,this.items=new o._ItemsContainer(a),this.firstIndexDisplayed=-1,this.lastIndexDisplayed=-1,this.begin=0,this.end=0,this._realizePass=1,this._firstLayoutPass=!0,this._runningAnimations=null,this._renderCompletePromise=e.wrap(),this._state=new w(this),this._createLayoutSignal(),this._createTreeBuildingSignal(),this._layoutWork=null,this._onscreenJob=q(g.Priority.aboveNormal,"on-screen items"),this._frontOffscreenJob=q(g.Priority.normal,"front off-screen items"),this._backOffscreenJob=q(g.Priority.belowNormal,"back off-screen items"),this._scrollbarPos=0,this._direction="right",this._scrollToFunctor=t(0) +},{_dispose:function(){this.cleanUp(),this.items=null,this._renderCompletePromise&&this._renderCompletePromise.cancel(),this._renderCompletePromise=null,this._onscreenJob.dispose(),this._frontOffscreenJob.dispose(),this._backOffscreenJob.dispose()},_createItem:function(a,b,c,d){this._listView._writeProfilerMark("createItem("+a+") "+this._getBoundingRectString(a)+",info");var f=this;f._listView._itemsManager._itemFromItemPromiseThrottled(b).done(function(b){b?c(a,b,f._listView._itemsManager._recordFromElement(b)):d(a)},function(b){return d(a),e.wrapError(b)})},_addItem:function(a,b,c,d){if(this._realizePass===d){var e=this._listView._itemsManager._recordFromElement(c);delete this._pendingItemPromises[e.itemPromise.handle],this.items.setItemAt(b,{itemBox:null,container:null,element:c,detached:!0,itemsManagerRecord:e})}},finalItem:function(){return this.containers?e.wrap(this.containers.length-1):e.cancel},_setSkipRealizationForChange:function(a){a?this._realizationLevel!==v._realizationLevel.realize&&(this._realizationLevel=v._realizationLevel.skip):this._realizationLevel=v._realizationLevel.realize},_realizeItems:function(a,b,c,d,h,j,n,o,p,q){function r(a,b){D.push(e._cancelBlocker(b.renderComplete)),v(a)}function s(a,b){function c(a,b){!a.updatedSwipeableAttribute&&(H._listView.itemsDraggable||H._listView.itemsReorderable||H._listView._swipeable)&&a.itemsManagerRecord.renderComplete.done(function(){if(H._realizePass===h){var c=i.hasClass(b,l._nonDraggableClass),d=i.hasClass(b,l._nonSelectableClass),e=H._listView.itemsDraggable||H._listView.itemsReorderable,f=H._listView._selectionAllowed()&&H._listView._swipeBehavior===k.SwipeBehavior.select;e&&!c&&(a.itemBox.draggable=!0),H._listView._swipeable&&(e&&!f&&c||f&&!e&&d||c&&d)&&i.addClass(a.itemBox,l._nonSwipeableClass),a.updatedSwipeableAttribute=!0}})}if(H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom,StartTM"),!H._listView._isZombie()){var d,e=0,f=-1,g=-1;for(d=a;b>=d;d++){var j=H.items.itemDataAt(d);if(j){var o=j.element,p=j.itemBox;p||(p=H._listView._itemBoxTemplate.cloneNode(!0),j.itemBox=p,p.appendChild(o),i.addClass(o,l._itemClass),H._listView._setupAriaSelectionObserver(o),H._listView._isSelected(d)&&m._ItemEventsHandler.renderSelection(p,o,!0,!0),H._listView._currentMode().renderDragSourceOnRealizedItem(d,p)),c(j,o,p);var q=H.getContainer(d);p.parentNode!==q&&(H._appendAndRestoreFocus(q,p),e++,0>f&&(f=d),g=d,j.container=q,H._listView._isSelected(d)&&i.addClass(q,l._selectedClass),i.removeClass(q,l._backdropClass),H.items.elementAvailable(d))}}H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom,StopTM"),e>0&&(H._listView._writeProfilerMark("_realizeItems_appendedItemsToDom:"+e+" ("+f+"-"+g+"),info"),H._reportElementsLevel(n))}}function t(a,b,c,d){function e(a,b){var c=H.items.itemDataAt(a);if(c){var d=c.itemBox;return d&&d.parentNode?b?(i.addClass(d.parentNode,l._backdropClass),d.parentNode.removeChild(d),!0):!1:!0}return!0}if(!q){for(var f=!1;a>=c;)f=e(a,f),a--;for(f=!1;d>=b;)f=e(b,f),b++}}function u(a,b,c,d,f){function g(a){var b=H.items.itemDataAt(a);if(b){var d=b.itemsManagerRecord;d.readyComplete||H._realizePass!==h||c.addWork(function(){H._listView._isZombie()||d.pendingReady&&H._realizePass===h&&(H._listView._writeProfilerMark("pendingReady("+a+"),info"),d.pendingReady())},f)}}for(var i=[],j=a;b>=j;j++){var k=H.items.itemDataAt(j);k&&i.push(k.itemsManagerRecord.itemPromise)}e.join(i).then(function(){if("right"===d)for(var c=a;b>=c;c++)g(c);else for(var c=b;c>=a;c--)g(c)})}function v(a){if(H._realizePass===h){if(a>=o&&p>=a){if(0===--A){if(s(o,p),t(o,p,b,c),H._firstLayoutPass){u(o,p,H._frontOffscreenJob,"right"===n?"left":"right",!0);var d=g.schedulePromiseHigh(null,"WinJS.UI.ListView.entranceAnimation").then(function(){if(!H._listView._isZombie()){H._listView._writeProfilerMark("entranceAnimation,StartTM");var a=H._listView._animateListEntrance(!H._firstEntranceAnimated);return H._firstEntranceAnimated=!0,a}});H._runningAnimations=e.join([H._runningAnimations,d]),H._runningAnimations.done(function(){H._listView._writeProfilerMark("entranceAnimation,StopTM"),H._realizePass===h&&(H._runningAnimations=null,E.complete())}),H._firstLayoutPass=!1,H._listView._isCurrentZoomView&&g.requestDrain(H._onscreenJob.priority)}else u(o,p,H._frontOffscreenJob,n),E.complete();H._updateHeaders(H._listView._canvas,o,p+1).done(function(){F.complete()})}}else o>a?(--C,C%z===0&&s(b,o-1),C||(H._updateHeaders(H._listView._canvas,b,o).done(function(){"right"!==n&&G.complete()}),u(b,o-1,"right"!==n?H._frontOffscreenJob:H._backOffscreenJob,"left"))):a>p&&(--B,B%z===0&&s(p+1,c-1),B||(H._updateHeaders(H._listView._canvas,p+1,c).then(function(){"right"===n&&G.complete()}),u(p+1,c-1,"right"===n?H._frontOffscreenJob:H._backOffscreenJob,"right")));y--,0===y&&(H._renderCompletePromise=e.join(D).then(null,function(a){var b=Array.isArray(a)&&a.some(function(a){return a&&!(a instanceof Error&&"Canceled"===a.name)});return b?e.wrapError(a):void 0}),(H._headerRenderPromises||e.wrap()).done(function(){g.schedule(function(){H._listView._isZombie()?M.cancel():M.complete()},Math.min(H._onscreenJob.priority,H._backOffscreenJob.priority),null,"WinJS.UI.ListView._allItemsRealized")}))}}function w(b,c,d){if(H._realizePass===h){var c=d.element;H._addItem(a,b,c,h),r(b,d)}}var x="_realizeItems("+b+"-"+(c-1)+") visible("+o+"-"+p+")";this._listView._writeProfilerMark(x+",StartTM"),n=n||"right";var y=c-b,z=p-o+1,A=z,B=c-p-1,C=o-b,D=[],E=new f,F=new f,G=new f,H=this;if(y>0){var I=0,J=0,K=0;H.firstIndexDisplayed=o,H.lastIndexDisplayed=p;var L=H._listView._isCurrentZoomView;H._highPriorityRealize&&(H._firstLayoutPass||H._hasAnimationInViewportPending)?(H._highPriorityRealize=!1,H._onscreenJob.priority=g.Priority.high,H._frontOffscreenJob.priority=g.Priority.normal,H._backOffscreenJob.priority=g.Priority.belowNormal):H._highPriorityRealize?(H._highPriorityRealize=!1,H._onscreenJob.priority=g.Priority.high,H._frontOffscreenJob.priority=g.Priority.high-1,H._backOffscreenJob.priority=g.Priority.high-1):L?(H._onscreenJob.priority=g.Priority.aboveNormal,H._frontOffscreenJob.priority=g.Priority.normal,H._backOffscreenJob.priority=g.Priority.belowNormal):(H._onscreenJob.priority=g.Priority.belowNormal,H._frontOffscreenJob.priority=g.Priority.idle,H._backOffscreenJob.priority=g.Priority.idle);var M=new f,N=H._listView._versionManager.cancelOnNotification(M.promise),O=function(a,b){b.startStage1&&b.stage0.then(function(){H._realizePass===h&&b.startStage1&&a.addWork(b.startStage1)})},P=function(a,b){var c=H.items.itemDataAt(b);if(!c){var d=H._listView._itemsManager._itemPromiseAtIndex(b);H._pendingItemPromises[d.handle]=d,delete H._previousRealizationPendingItemPromises[d.handle],a.addWork(function(){if(!H._listView._isZombie()&&(I++,H._createItem(b,d,w,v),!H._listView._isZombie()&&H._realizePass===h&&d.handle)){var c=H._listView._itemsManager._recordFromHandle(d.handle);O(a,c)}})}},Q=function(a,b,c){for(var d=b;c>=d;d++)P(a,d)},R=function(a,b,c){for(var d=c;d>=b;d--)P(a,d)},S=function(a,b,c){for(var d=b;c>=d;d++){var e=H.items.itemDataAt(d);if(e){var f=e.itemsManagerRecord;r(d,f),J++,O(a,f)}}};this._previousRealizationPendingItemPromises=this._pendingItemPromises||{},this._pendingItemPromises={};var T;"left"===n?(R(H._onscreenJob,o,p),R(H._frontOffscreenJob,b,o-1),T=b>o-1):(Q(H._onscreenJob,o,p),Q(H._frontOffscreenJob,p+1,c-1),T=p+1>c-1);for(var U=0,V=Object.keys(this._previousRealizationPendingItemPromises),W=V.length;W>U;U++){var X=V[U];H._listView._itemsManager.releaseItemPromise(this._previousRealizationPendingItemPromises[X])}this._previousRealizationPendingItemPromises={},S(H._onscreenJob,o,p),"left"===n?S(H._frontOffscreenJob,b,o-1):S(H._frontOffscreenJob,p+1,c-1);var Y=A===p-o+1;return H._firstLayoutPass?H._listView._canvas.style.opacity=0:Y?H._listView._showProgressBar(H._listView._element,"50%","50%"):H._listView._hideProgressBar(),H._frontOffscreenJob.pause(),H._backOffscreenJob.pause(),F.promise.done(function(){H._frontOffscreenJob.resume(),T&&G.complete()},function(){M.cancel()}),G.promise.done(function(){H._listView._writeProfilerMark("frontItemsRealized,info"),"left"===n?(Q(H._backOffscreenJob,p+1,c-1),S(H._backOffscreenJob,p+1,c-1)):(R(H._backOffscreenJob,b,o-1),S(H._backOffscreenJob,b,o-1)),H._backOffscreenJob.resume()}),M.promise.done(function(){H._listView._versionManager.clearCancelOnNotification(N),H._listView._writeProfilerMark(x+" complete(created:"+I+" updated:"+J+"),info")},function(a){return H._listView._versionManager.clearCancelOnNotification(N),H._onscreenJob.clearWork(),H._frontOffscreenJob.clearWork(),H._backOffscreenJob.clearWork(),E.cancel(),F.cancel(),H._listView._writeProfilerMark(x+" canceled(created:"+I+" updated:"+J+" clean:"+K+"),info"),e.wrapError(a)}),H._listView._writeProfilerMark(x+",StopTM"),{viewportItemsRealized:F.promise,allItemsRealized:M.promise,loadingCompleted:e.join([M.promise,E.promise]).then(function(){for(var a=[],d=b;c>d;d++){var f=H.items.itemDataAt(d);f&&a.push(f.itemsManagerRecord.itemReadyPromise)}return e._cancelBlocker(e.join(a))})}}return H._listView._writeProfilerMark(x+",StopTM"),{viewportItemsRealized:e.wrap(),allItemsRealized:e.wrap(),loadingCompleted:e.wrap()}},_setAnimationInViewportState:function(a){if(this._hasAnimationInViewportPending=!1,a&&a.length>0)for(var b=this._listView._getViewportLength(),c=this._listView._layout.itemsFromRange(this._scrollbarPos,this._scrollbarPos+b-1),d=0,e=a.length;e>d;d++){var f=a[d];if(f.newIndex>=c.firstIndex&&f.newIndex<=c.lastIndex&&f.newIndex!==f.oldIndex){this._hasAnimationInViewportPending=!0;break}}},_addHeader:function(a,b){var c=this;return this._listView._groups.renderGroup(b).then(function(a){if(a){a.element.tabIndex=0;var d=c._getHeaderContainer(b);a.element.parentNode!==d&&(d.appendChild(a.element),i.addClass(a.element,l._headerClass)),c._listView._groups.setDomElement(b,a.element)}})},_updateHeaders:function(a,b,c){function d(b){var c=g._listView._groups.group(b);if(c&&!c.header){var d=c.headerPromise;return d||(d=c.headerPromise=g._addHeader(a,b),d.done(function(){c.headerPromise=null},function(){c.headerPromise=null})),d}return e.wrap()}function f(){g._headerRenderPromises=null}var g=this;this._listView._groups.removeElements();var h=this._listView._groups.groupFromItem(b),i=h,j=this._listView._groups.groupFromItem(c-1),k=[];if(null!==i)for(;j>=i;i++)k.push(d(i));return this._headerRenderPromises=e.join(k,this._headerRenderPromises).then(f,f),this._headerRenderPromises||e.wrap()},_unrealizeItem:function(a){var b,c=this._listView;this._listView._writeProfilerMark("_unrealizeItem("+a+"),info");var d=c._selection._getFocused();d.type!==k.ObjectType.groupHeader&&d.index===a&&(c._unsetFocusOnItem(),b=!0);var e=this.items.itemDataAt(a),f=e.element,g=e.itemBox;g&&g.parentNode&&(i.removeClass(g.parentNode,l._selectedClass),i.removeClass(g.parentNode,l._footprintClass),i.addClass(g.parentNode,l._backdropClass),g.parentNode.removeChild(g)),e.container=null,c._currentMode().itemUnrealized&&c._currentMode().itemUnrealized(a,g),this.items.removeItem(a),e.removed||c._itemsManager.releaseItem(f),h._disposeElement(f),b&&c._setFocusOnItem(c._selection._getFocused())},_unrealizeGroup:function(a){var b,c=a.header,d=this._listView._selection._getFocused();d.type===k.ObjectType.groupHeader&&this._listView._groups.group(d.index)===a&&(this._listView._unsetFocusOnItem(),b=!0),c.parentNode&&c.parentNode.removeChild(c),h._disposeElement(c),a.header=null,a.left=-1,a.top=-1,b&&this._listView._setFocusOnItem(this._listView._selection._getFocused())},_unrealizeItems:function(a){var b=this,c=0;this.items.eachIndex(function(d){return d=b.end?(b._unrealizeItem(d),a&&++c>=a):void 0});var d=this._listView._groups,e=d.groupFromItem(this.begin);if(null!==e)for(var f=d.groupFromItem(this.end-1),g=0,h=d.length();h>g;g++){var i=d.group(g);(e>g||g>f)&&i.header&&this._unrealizeGroup(i)}},_unrealizeExcessiveItems:function(){var a=this.items.count(),b=this.end-this.begin,c=b+this._listView._maxDeferredItemCleanup;this._listView._writeProfilerMark("_unrealizeExcessiveItems realized("+a+") approved("+c+"),info"),a>c&&this._unrealizeItems(a-c)},_lazilyUnrealizeItems:function(){this._listView._writeProfilerMark("_lazilyUnrealizeItems,StartTM");var a=this;return s(this._listView).then(function(){function b(){a._listView._writeProfilerMark("_lazilyUnrealizeItems,StopTM")}if(a._listView._isZombie())return void b();var c=[];a.items.eachIndex(function(b){(b=a.end)&&c.push(b)}),a._listView._writeProfilerMark("_lazilyUnrealizeItems itemsToUnrealize("+c.length+"),info");var d=[],f=a._listView._groups,h=f.groupFromItem(a.begin);if(null!==h)for(var i=f.groupFromItem(a.end-1),j=0,k=f.length();k>j;j++){var l=f.group(j);(h>j||j>i)&&l.header&&d.push(l)}if(c.length||d.length){var m,n=new e(function(b){function e(f){if(!a._listView._isZombie()){for(var g=-1,h=-1,i=0,j=r(a._listView);c.length&&!j&&!f.shouldYield;){var k=c.shift();a._unrealizeItem(k),i++,0>g&&(g=k),h=k}for(a._listView._writeProfilerMark("unrealizeWorker removeItems:"+i+" ("+g+"-"+h+"),info");d.length&&!j&&!f.shouldYield;)a._unrealizeGroup(d.shift());c.length||d.length?j?f.setPromise(s(a._listView).then(function(){return e})):f.setWork(e):b()}}m=g.schedule(e,g.Priority.belowNormal,null,"WinJS.UI.ListView._lazilyUnrealizeItems")});return n.then(b,function(b){return m.cancel(),a._listView._writeProfilerMark("_lazilyUnrealizeItems canceled,info"),a._listView._writeProfilerMark("_lazilyUnrealizeItems,StopTM"),e.wrapError(b)})}return b(),e.wrap()})},_getBoundingRectString:function(a){var b;if(a>=0&&a0&&-1!==d.firstIndexDisplayed&&-1!==d.lastIndexDisplayed))return e.wrap();d._listView._writeProfilerMark("aria work,StartTM");var h,j,k,l,m,n,o=d._listView._ariaStartMarker,q=d._listView._ariaEndMarker,t=d.begin,u=d.items.itemAt(d.begin);return u?(i._ensureId(u),d._listView._groupsEnabled()?(j=d._listView._groups,k=l=j.groupFromItem(d.begin),m=j.group(l),n=c(l),i._ensureId(m.header),i._setAttribute(m.header,"role",d._listView._headerRole),i._setAttribute(m.header,"x-ms-aria-flowfrom",o.id),p(m.header,u),i._setAttribute(m.header,"tabindex",d._listView._tabIndex)):i._setAttribute(u,"x-ms-aria-flowfrom",o.id),new e(function(e){var o=a;h=g.schedule(function v(a){if(d._listView._isZombie())return void b();for(;t=b;a--)if(f.items.itemAt(a))return f.items.itemAt(a);return null}var f=this;if(!this._listView._isZombie()){this._listView._createAriaMarkers();var g,h,j=this._listView._ariaStartMarker,k=this._listView._ariaEndMarker;if(-1!==b&&-1!==c&&c>=b&&(g=d(),h=e()),!a&&g&&h){if(i._ensureId(g),i._ensureId(h),this._listView._groupsEnabled()){var l=this._listView._groups,m=l.group(l.groupFromItem(b));m.header&&(i._ensureId(m.header),b===m.startIndex?i._setAttribute(j,"aria-flowto",m.header.id):i._setAttribute(j,"aria-flowto",g.id))}else i._setAttribute(j,"aria-flowto",g.id);i._setAttribute(k,"x-ms-aria-flowfrom",h.id)}else p(j,k),this._listView._fireAccessibilityAnnotationCompleteEvent(-1,-1)}},updateAriaForAnnouncement:function(a,b){var c=-1,d=k.ObjectType.item;i.hasClass(a,l._headerClass)?(c=this._listView._groups.index(a),d=k.ObjectType.groupHeader,i._setAttribute(a,"role",this._listView._headerRole),i._setAttribute(a,"tabindex",this._listView._tabIndex)):(c=this.items.index(a),i._setAttribute(a,"aria-setsize",b),i._setAttribute(a,"aria-posinset",c+1),i._setAttribute(a,"role",this._listView._itemRole),i._setAttribute(a,"tabindex",this._listView._tabIndex)),d===k.ObjectType.groupHeader?this._listView._fireAccessibilityAnnotationCompleteEvent(-1,-1,c,c):this._listView._fireAccessibilityAnnotationCompleteEvent(c,c,-1,-1)},_reportElementsLevel:function(a){function b(a,b){for(var c=0,e=a;b>=e;e++){var f=d.itemDataAt(e);f&&f.container&&c++}return c}var c,d=this.items;c=Math.floor("right"===a?100*b(this.firstIndexDisplayed,this.end-1)/(this.end-this.firstIndexDisplayed):100*b(this.begin,this.lastIndexDisplayed)/(this.lastIndexDisplayed-this.begin+1)),this._listView._writeProfilerMark("elementsLevel level("+c+"),info")},_createHeaderContainer:function(a){return this._createSurfaceChild(l._headerContainerClass,a)},_createItemsContainer:function(a){var c=this._createSurfaceChild(l._itemsContainerClass,a),d=b.document.createElement("div");return d.className=l._padderClass,c.appendChild(d),c},_ensureContainerInDOM:function(a){var b=this.containers[a];return b&&!this._listView._canvas.contains(b)?(this._forceItemsBlocksInDOM(a,a+1),!0):!1},_ensureItemsBlocksInDOM:function(a,b){if(this._expandedRange){var c=this._expandedRange.first.index,d=this._expandedRange.last.index+1;c>=a&&b>c?b=Math.max(b,d):d>a&&b>=d&&(a=Math.min(a,c))}this._forceItemsBlocksInDOM(a,b)},_removeRedundantItemsBlocks:function(){-1!==this.begin&&-1!==this.end&&this._forceItemsBlocksInDOM(this.begin,this.end)},_lazilyRemoveRedundantItemsBlocks:function(){this._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StartTM");var a=this;return s(this._listView).then(function(){function b(){a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StopTM")}if(a._listView._isZombie())return void b();if(a._expandedRange&&-1!==a.begin&&-1!==a.end&&(a._expandedRange.first.indexa.end)){var c,d=new e(function(b){function d(c){if(!a._listView._isZombie()){for(var e=r(a._listView);a._expandedRange.first.indexa.end&&!e&&!c.shouldYield;){var g=Math.max(a.end,a._expandedRange.last.index-a._blockSize*v._blocksToRelease);a._forceItemsBlocksInDOM(a.begin,g)}a._expandedRange.first.indexa.end?e?c.setPromise(s(a._listView).then(function(){return d})):c.setWork(d):b()}}c=g.schedule(d,g.Priority.belowNormal,null,"WinJS.UI.ListView._lazilyRemoveRedundantItemsBlocks")});return d.then(b,function(b){return c.cancel(),a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks canceled,info"),a._listView._writeProfilerMark("_lazilyRemoveRedundantItemsBlocks,StopTM"),e.wrapError(b)})}return b(),e.wrap()})},_forceItemsBlocksInDOM:function(a,b){function c(a,b){var c=a.element.firstElementChild;c.style[q]=b}function d(a){for(var b=0;bd;d++)if(a(c,c.itemsBlocks[d]))return}function e(a){n._listView._writeProfilerMark("_itemsBlockExtent,StartTM"),n._listView._itemsBlockExtent=i[n._listView._horizontal()?"getTotalWidth":"getTotalHeight"](a.element),n._listView._writeProfilerMark("_itemsBlockExtent("+n._listView._itemsBlockExtent+"),info"),n._listView._writeProfilerMark("_itemsBlockExtent,StopTM")}function f(){return-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize&&b.element.parentNode===a.element?(e(b),!0):!1}),-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize?(a.element.appendChild(b.element),e(b),a.element.removeChild(b.element),!0):!1}),n._listView._itemsBlockExtent}function g(a,b,c){function d(b){var c=a.itemsBlocks[b];c&&c.element.parentNode===a.element&&(a.element.removeChild(c.element),p++)}if(Array.isArray(b))b.forEach(d);else for(var e=b;c>e;e++)d(e)}function h(a,b,c){for(var d=a.element.firstElementChild,e=d,f=b;c>f;f++){var g=a.itemsBlocks[f];g&&(g.element.parentNode!==a.element&&(a.element.insertBefore(g.element,e.nextElementSibling),o++),e=g.element)}}function j(a){if(a=d;d++)c.push(d);return c}var d=b[0],e=b[1],f=a[0],g=a[1];return f>e||d>g?c(f,g):d>f&&g>e?c(f,d-1).concat(c(e+1,g)):d>f?c(f,d-1):g>e?c(e+1,g):null}if(this._blockSize){var m="_forceItemsBlocksInDOM begin("+a+") end("+b+"),";this._listView._writeProfilerMark(m+"StartTM");var n=this,o=0,p=0,q="padding"+(this._listView._horizontal()?"Left":"Top"),r=this._listView._groups.groupFromItem(a),s=this._listView._groups.groupFromItem(b-1),t=this._listView._groups.group(r),u=n.tree[r].itemsContainer,v=Math.floor((a-t.startIndex)/this._blockSize),w=this._listView._groups.group(s),x=n.tree[s].itemsContainer,y=Math.floor((b-1-w.startIndex)/this._blockSize);v&&-1===n._listView._itemsBlockExtent&&d(function(a,b){return b.items.length===n._blockSize&&b.element.parentNode===a.element?(e(b),!0):!1});var z=this._expandedRange?l([this._expandedRange.first.groupIndex,this._expandedRange.last.groupIndex],[r,s]):null;if(z&&z.forEach(j),this._expandedRange&&this._expandedRange.first.groupKey===t.key){var A=l([this._expandedRange.first.block,Number.MAX_VALUE],[v,Number.MAX_VALUE]);A&&g(u,A)}else this._expandedRange&&r>=this._expandedRange.first.groupIndex&&r<=this._expandedRange.last.groupIndex&&g(u,0,v);if(r!==s?(h(u,v,u.itemsBlocks.length),h(x,0,y+1)):h(u,v,y+1),this._expandedRange&&this._expandedRange.last.groupKey===w.key){var A=l([0,this._expandedRange.last.block],[0,y]);A&&g(x,A)}else this._expandedRange&&s>=this._expandedRange.first.groupIndex&&s<=this._expandedRange.last.groupIndex&&g(x,y+1,x.itemsBlocks.length);c(u,v?v*f()+"px":""),r!==s&&c(x,"");for(var B=r+1;s>B;B++)k(B);this._expandedRange={first:{index:a,groupIndex:r,groupKey:t.key,block:v},last:{index:b-1,groupIndex:s,groupKey:w.key,block:y}},this._listView._writeProfilerMark("_forceItemsBlocksInDOM groups("+r+"-"+s+") blocks("+v+"-"+y+") added("+o+") removed("+p+"),info"),this._listView._writeProfilerMark(m+"StopTM")}},_realizePageImpl:function(){var a=this,b="realizePage(scrollPosition:"+this._scrollbarPos+" forceLayout:"+this._forceRelayout+")";return this._listView._writeProfilerMark(b+",StartTM"),this._listView._versionManager.locked?(this._listView._versionManager.unlocked.done(function(){a._listView._isZombie()||a._listView._batchViewUpdates(l._ViewChange.realize,l._ScrollToPriority.low,a._listView.scrollPosition)}),this._listView._writeProfilerMark(b+",StopTM"),e.cancel):new e(function(c){function g(){c(),l.complete()}function h(){a._listView._hideProgressBar(),a._state.setLoadingState(a._listView._LoadingState.viewPortLoaded),a._executeAnimations&&a._setState(F,l.promise)}function j(b){a._updateAriaMarkers(0===b,a.firstIndexDisplayed,a.lastIndexDisplayed),a._state.setLoadingState&&a._state.setLoadingState(a._listView._LoadingState.itemsLoaded)}function k(b){a._listView._clearInsertedItems(),a._listView._groups.removeElements(),h(),j(b),g()}var l=new f;a._state.setLoadingState(a._listView._LoadingState.itemsLoading),a._firstLayoutPass&&a._listView._showProgressBar(a._listView._element,"50%","50%");var m=a.containers.length;if(m){var n=v._pagesToPrefetch,o=v._customPagesToPrefetchMax,p=v._customPagesToPrefetchMin;a._listView._zooming&&(n=0,o=0,p=0);var q,r,s=a._listView._getViewportLength();if(d._isiOS&&!v._disableCustomPagesPrefetch){q="left"===a._direction?o:p;var t=Math.max(0,q-a._scrollbarPos/s);r=Math.min(o,t+("right"===a._direction?o:p))}else q=n,r=n;var u=Math.max(0,a._scrollbarPos-q*s),w=a._scrollbarPos+(1+r)*s,x=a._listView._layout.itemsFromRange(u,w-1);if((x.firstIndex<0||x.firstIndex>=m)&&(x.lastIndex<0||x.lastIndex>=m))a.begin=-1,a.end=-1,a.firstIndexDisplayed=-1,a.lastIndexDisplayed=-1,k(m);else{var y=i._clamp(x.firstIndex,0,m-1),z=i._clamp(x.lastIndex+1,0,m),A=a._listView._layout.itemsFromRange(a._scrollbarPos,a._scrollbarPos+s-1),B=i._clamp(A.firstIndex,0,m-1),C=i._clamp(A.lastIndex,0,m-1);if(a._realizationLevel!==v._realizationLevel.skip||a.lastRealizePass||B!==a.firstIndexDisplayed||C!==a.lastIndexDisplayed)if((a._forceRelayout||y!==a.begin||z!==a.end||B!==a.firstIndexDisplayed||C!==a.lastIndexDisplayed)&&z>y&&w>u){a._listView._writeProfilerMark("realizePage currentInView("+B+"-"+C+") previousInView("+a.firstIndexDisplayed+"-"+a.lastIndexDisplayed+") change("+(B-a.firstIndexDisplayed)+"),info"),a._cancelRealize();var D=a._realizePass;a.begin=y,a.end=z,a.firstIndexDisplayed=B,a.lastIndexDisplayed=C,a.deletesWithoutRealize=0,a._ensureItemsBlocksInDOM(a.begin,a.end);var E=a._realizeItems(a._listView._itemCanvas,a.begin,a.end,m,D,a._scrollbarPos,a._direction,B,C,a._forceRelayout);a._forceRelayout=!1;var G=E.viewportItemsRealized.then(function(){return h(),E.allItemsRealized}).then(function(){return a._realizePass===D?a._updateHeaders(a._listView._canvas,a.begin,a.end).then(function(){j(m)}):void 0}).then(function(){return E.loadingCompleted}).then(function(){a._unrealizeExcessiveItems(),a.lastRealizePass=null,g()},function(b){return a._realizePass===D&&(a.lastRealizePass=null,a.begin=-1,a.end=-1),e.wrapError(b)});a.lastRealizePass=e.join([E.viewportItemsRealized,E.allItemsRealized,E.loadingCompleted,G]),a._unrealizeExcessiveItems()}else a.lastRealizePass?a.lastRealizePass.then(g):k(m);else a.begin=y,a.end=y+Object.keys(a.items._itemData).length,a._updateHeaders(a._listView._canvas,a.begin,a.end).done(function(){a.lastRealizePass=null,k(m)})}}else a.begin=-1,a.end=-1,a.firstIndexDisplayed=-1,a.lastIndexDisplayed=-1,k(m);a._reportElementsLevel(a._direction),a._listView._writeProfilerMark(b+",StopTM")})},realizePage:function(a,b,c,d){this._scrollToFunctor=t(a),this._forceRelayout=this._forceRelayout||b,this._scrollEndPromise=c,this._listView._writeProfilerMark(this._state.name+"_realizePage,info"),this._state.realizePage(d||A)},onScroll:function(a,b){this.realizePage(a,!1,b,C)},reload:function(a,b){this._listView._isZombie()||(this._scrollToFunctor=t(a),this._forceRelayout=!0,this._highPriorityRealize=!!b,this.stopWork(!0),this._listView._writeProfilerMark(this._state.name+"_rebuildTree,info"),this._state.rebuildTree())},refresh:function(a){this._listView._isZombie()||(this._scrollToFunctor=t(a),this._forceRelayout=!0,this._highPriorityRealize=!0,this.stopWork(),this._listView._writeProfilerMark(this._state.name+"_relayout,info"),this._state.relayout())},waitForValidScrollPosition:function(a){var b=this,c=this._listView._viewport[this._listView._scrollLength]-this._listView._getViewportLength();return a>c?b._listView._itemsCount().then(function(c){return b.containers.length=b.containers.length||a.type===k.ObjectType.groupHeader&&b._listView._groups.group(a.index).startIndex>=b.containers.length?b._creatingContainersWork&&b._creatingContainersWork.promise:void 0}).then(function(){return b._getLayoutCompleted()}))},stopWork:function(a){this._listView._writeProfilerMark(this._state.name+"_stop,info"),this._state.stop(a),this._layoutWork&&this._layoutWork.cancel(),a&&this._creatingContainersWork&&this._creatingContainersWork.cancel(),a&&(this._state=new w(this))},_cancelRealize:function(){this._listView._writeProfilerMark("_cancelRealize,StartTM"),(this.lastRealizePass||this.deferTimeout)&&(this._forceRelayout=!0),this._clearDeferTimeout(),this._realizePass++,this._headerRenderPromises&&(this._headerRenderPromises.cancel(),this._headerRenderPromises=null);var a=this.lastRealizePass;a&&(this.lastRealizePass=null,this.begin=-1,this.end=-1,a.cancel()),this._listView._writeProfilerMark("_cancelRealize,StopTM")},resetItems:function(a){if(!this._listView._isZombie()){this.firstIndexDisplayed=-1,this.lastIndexDisplayed=-1,this._runningAnimations=null,this._executeAnimations=!1;var b=this._listView;this._firstLayoutPass=!0,b._unsetFocusOnItem(),b._currentMode().onDataChanged&&b._currentMode().onDataChanged(),this.items.each(function(c,d){a&&d.parentNode&&d.parentNode.parentNode&&d.parentNode.parentNode.removeChild(d.parentNode),b._itemsManager.releaseItem(d),h._disposeElement(d)}),this.items.removeItems(),this._deferredReparenting=[],a&&b._groups.removeElements(),b._clearInsertedItems()}},reset:function(){if(this.stopWork(!0),this._state=new w(this),this.resetItems(),!this._listView._isZombie()){var a=this._listView;a._groups.resetGroups(),a._resetCanvas(),this.tree=null,this.keyToGroupIndex=null,this.containers=null,this._expandedRange=null}},cleanUp:function(){this.stopWork(!0),this._runningAnimations&&this._runningAnimations.cancel();var a=this._listView._itemsManager;this.items.each(function(b,c){a.releaseItem(c),h._disposeElement(c)}),this._listView._unsetFocusOnItem(),this.items.removeItems(),this._deferredReparenting=[],this._listView._groups.resetGroups(),this._listView._resetCanvas(),this.tree=null,this.keyToGroupIndex=null,this.containers=null,this._expandedRange=null,this.destroyed=!0},getContainer:function(a){return this.containers[a]},_getHeaderContainer:function(a){return this.tree[a].header},_getGroups:function(a){if(this._listView._groupDataSource){var b=this._listView._groups.groups,c=[];if(a)for(var d=0,e=b.length;e>d;d++){var f=b[d],g=e>d+1?b[d+1].startIndex:a;c.push({key:f.key,size:g-f.startIndex})}return c}return[{key:"-1",size:a}]},_createChunk:function(a,b,c){function d(a,b){var d=a.element.children,e=d.length,g=Math.min(b-a.items.length,c); +j.insertAdjacentHTMLUnsafe(a.element,"beforeend",n._repeat("
",g));for(var h=0;g>h;h++){var i=d[e+h];a.items.push(i),f.containers.push(i)}}function e(a){var b={header:f._listView._groupDataSource?f._createHeaderContainer():null,itemsContainer:{element:f._createItemsContainer(),items:[]}};f.tree.push(b),f.keyToGroupIndex[a.key]=f.tree.length-1,d(b.itemsContainer,a.size)}var f=this;if(this._listView._writeProfilerMark("createChunk,StartTM"),this.tree.length&&this.tree.length<=a.length){var g=this.tree[this.tree.length-1],h=a[this.tree.length-1].size;if(g.itemsContainer.items.length",g));var i=f.items.length;s=f.element.children;for(var k=0;g>k;k++){var l=s[i+k];f.items.push(l),h.containers.push(l)}c-=g}c>e&&(c=Math.min(c,Math.max(1,Math.floor(e/d))*d));var m=Math.floor(c/d),o=c%d,p="
"+n._repeat("
",d)+"
",q=n._repeat(p,m);o&&(q+="
"+n._repeat("
",o)+"
",m++);var r=b.document.createElement("div");j.setInnerHTMLUnsafe(r,q);for(var s=r.children,t=0;m>t;t++){var u=s[t],v={element:u,items:n._nodeListToArray(u.children)};a.itemsBlocks.push(v);for(var w=0;wl)return f(i,k-l),void this._listView._writeProfilerMark("createChunk,StopTM")}this.tree.lengtha;a++){var c=e.containers[d+a];b.element.appendChild(c),b.items.push(c)}}function h(){b.itemsBlocks=[{element:j.length?j.shift():c(),items:[]}];for(var f=b.itemsBlocks[0],g=0;k>g;g++){if(f.items.length===a){var h=j.length?j.shift():c();b.itemsBlocks.push({element:h,items:[]}),f=b.itemsBlocks[b.itemsBlocks.length-1]}var i=e.containers[d+g];f.element.appendChild(i),f.items.push(i)}b.items=null}var i,j=[],k=0,l=b.itemsBlocks;if(l)for(i=0;ib;b++){var d=a[b];d.parentNode.removeChild(d)}}if(this._executeAnimations=!0,this._modifiedElements=d,!d.handled){d.handled=!0,this._listView._writeProfilerMark("_updateTreeImpl,StartTM");var g,h=this;e||this._unrealizeItems();for(var g=0,j=d.length;j>g;g++)d[g]._itemBox&&d[g]._itemBox.parentNode&&i.removeClass(d[g]._itemBox.parentNode,l._selectedClass);this.items.each(function(a,b,c){c.container&&i.removeClass(c.container,l._selectedClass),c.container&&i.addClass(c.container,l._backdropClass)});var k=this._listView._updateContainers(this._getGroups(a),a,c,d);f(k.removedHeaders),f(k.removedItemsContainers);for(var g=0,j=d.length;j>g;g++){var n=d[g];if(-1!==n.newIndex){if(n.element=this.getContainer(n.newIndex),!n.element)throw"Container missing after updateContainers."}else i.removeClass(n.element,l._backdropClass)}var o=b.document.activeElement;this._listView._canvas.contains(o)&&(this._requireFocusRestore=o),this._deferredReparenting=[],this.items.each(function(a,b,c){var d=h.getContainer(a),e=c.itemBox;e&&d&&(e.parentNode!==d&&(a>=h.firstIndexDisplayed&&a<=h.lastIndexDisplayed?h._appendAndRestoreFocus(d,e):h._deferredReparenting.push({itemBox:e,container:d})),i.removeClass(d,l._backdropClass),c.container=d,i[h._listView.selection._isIncluded(a)?"addClass":"removeClass"](d,l._selectedClass),!h._listView.selection._isIncluded(a)&&i.hasClass(e,l._selectedClass)&&m._ItemEventsHandler.renderSelection(e,c.element,!1,!0))}),this._listView._writeProfilerMark("_updateTreeImpl,StopTM")}},_completeUpdateTree:function(){if(this._deferredReparenting){var a=this._deferredReparenting.length;if(a>0){var b="_completeReparenting("+a+")";this._listView._writeProfilerMark(b+",StartTM");for(var c,d=0;a>d;d++)c=this._deferredReparenting[d],this._appendAndRestoreFocus(c.container,c.itemBox);this._deferredReparenting=[],this._listView._writeProfilerMark(b+",StopTM")}}this._requireFocusRestore=null},_appendAndRestoreFocus:function(a,c){if(c.parentNode!==a){var d;if(this._requireFocusRestore&&(d=b.document.activeElement),this._requireFocusRestore&&this._requireFocusRestore===d&&(a.contains(d)||c.contains(d))&&(this._listView._unsetFocusOnItem(),d=b.document.activeElement),i.empty(a),a.appendChild(c),this._requireFocusRestore&&d===this._listView._keyboardEventsHelper){var e=this._listView._selection._getFocused();e.type===k.ObjectType.item&&this.items.itemBoxAt(e.index)===c&&(i._setActive(this._requireFocusRestore),this._requireFocusRestore=null)}}},_startAnimations:function(){this._listView._writeProfilerMark("startAnimations,StartTM");var a=this;this._hasAnimationInViewportPending=!1;var b=e.as(this._listView._layout.executeAnimations()).then(function(){a._listView._writeProfilerMark("startAnimations,StopTM")});return b},_setState:function(a,b){if(!this._listView._isZombie()){var c=this._state.name;this._state=new a(this,b),this._listView._writeProfilerMark(this._state.name+"_enter from("+c+"),info"),this._state.enter()}},getAdjacent:function(a,b){var c=this;return this.waitForEntityPosition(a).then(function(){return c._listView._layout.getAdjacent(a,b)})},hitTest:function(a,b){if(this._realizedRangeLaidOut)return{index:-1,insertAfterIndex:-1};var c=this._listView._layout.hitTest(a,b);return c.index=i._clamp(c.index,-1,this._listView._cachedCount-1,0),c.insertAfterIndex=i._clamp(c.insertAfterIndex,-1,this._listView._cachedCount-1,0),c},_createTreeBuildingSignal:function(){if(!this._creatingContainersWork){this._creatingContainersWork=new f;var a=this;this._creatingContainersWork.promise.done(function(){a._creatingContainersWork=null},function(){a._creatingContainersWork=null})}},_createLayoutSignal:function(){var a=this;this._layoutCompleted||(this._layoutCompleted=new f,this._layoutCompleted.promise.done(function(){a._layoutCompleted=null},function(){a._layoutCompleted=null})),this._realizedRangeLaidOut||(this._realizedRangeLaidOut=new f,this._realizedRangeLaidOut.promise.done(function(){a._realizedRangeLaidOut=null},function(){a._realizedRangeLaidOut=null}))},_getLayoutCompleted:function(){return this._layoutCompleted?e._cancelBlocker(this._layoutCompleted.promise):e.wrap()},_createSurfaceChild:function(a,c){var d=b.document.createElement("div");return d.className=a,this._listView._canvas.insertBefore(d,c?c.nextElementSibling:null),d},_executeScrollToFunctor:function(){var a=this;return e.as(this._scrollToFunctor?this._scrollToFunctor():null).then(function(b){a._scrollToFunctor=null,b=b||{},+b.position===b.position&&(a._scrollbarPos=b.position),a._direction=b.direction||"right"})}},{_pagesToPrefetch:2,_customPagesToPrefetchMax:6,_customPagesToPrefetchMin:2,_disableCustomPagesPrefetch:!1,_waitForSeZoIntervalDuration:100,_waitForSeZoTimeoutDuration:500,_chunkSize:500,_startupChunkSize:100,_maxTimePerCreateContainers:5,_createContainersJobTimeslice:15,_blocksToRelease:10,_realizationLevel:{skip:"skip",realize:"realize",normal:"normal"}}),w=c.Class.define(function(a){this.view=a,this.view._createTreeBuildingSignal(),this.view._createLayoutSignal()},{name:"CreatedState",enter:function(){this.view._createTreeBuildingSignal(),this.view._createLayoutSignal()},stop:u,realizePage:u,rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(x)},layoutNewContainers:u,waitForEntityPosition:function(){return this.view._setState(x),this.view._getLayoutCompleted()},updateTree:u}),x=c.Class.define(function(a){this.view=a},{name:"BuildingState",enter:function(){this.canceling=!1,this.view._createTreeBuildingSignal(),this.view._createLayoutSignal();var a=this,b=new f;this.promise=b.promise.then(function(){return a.view._createContainers()}).then(function(){a.view._setState(y)},function(b){return a.canceling||(a.view._setState(w),a.view._listView._raiseViewComplete()),e.wrapError(b)}),b.complete()},stop:function(){this.canceling=!0,this.promise.cancel(),this.view._setState(w)},realizePage:u,rebuildTree:function(){this.canceling=!0,this.promise.cancel(),this.enter()},relayout:u,layoutNewContainers:u,waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:u}),y=c.Class.define(function(a,b){this.view=a,this.nextStateType=b||A},{name:"LayingoutState",enter:function(){var a=this;this.canceling=!1,this.view._createLayoutSignal(),this.view._listView._writeProfilerMark(this.name+"_enter_layoutItems,StartTM");var b=new f;this.promise=b.promise.then(function(){return a.view._layoutItems()}).then(function(b){return a.view._layoutWork=b.layoutComplete,b.realizedRangeComplete}).then(function(){a.view._listView._writeProfilerMark(a.name+"_enter_layoutItems,StopTM"),a.view._listView._clearInsertedItems(),a.view._setAnimationInViewportState(a.view._modifiedElements),a.view._modifiedElements=[],a.view._modifiedGroups=[],a.view._realizedRangeLaidOut.complete(),a.view._layoutWork.then(function(){a.view._listView._writeProfilerMark(a.name+"_enter_layoutCompleted,info"),a.view._listView._affectedRange.clear(),a.view._layoutCompleted.complete()}),a.canceling||a.view._setState(a.nextStateType)},function(b){return a.view._listView._writeProfilerMark(a.name+"_enter_layoutCanceled,info"),a.canceling||(a.view.firstIndexDisplayed=a.view.lastIndexDisplayed=-1,a.view._updateAriaMarkers(!0,a.view.firstIndexDisplayed,a.view.lastIndexDisplayed),a.view._setState(G)),e.wrapError(b)}),b.complete(),this.canceling&&this.promise.cancel()},cancelLayout:function(a){this.view._listView._writeProfilerMark(this.name+"_cancelLayout,info"),this.canceling=!0,this.promise&&this.promise.cancel(),a&&this.view._setState(z)},stop:function(){this.cancelLayout(!0)},realizePage:u,rebuildTree:function(){this.cancelLayout(!1),this.view._setState(x)},relayout:function(){this.cancelLayout(!1),this.enter()},layoutNewContainers:function(){this.relayout()},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),z=c.Class.define(function(a){this.view=a},{name:"LayoutCanceledState",enter:u,stop:u,realizePage:function(){this.relayout()},rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(y)},layoutNewContainers:function(){this.relayout()},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),A=c.Class.define(function(a){this.view=a,this.nextState=E,this.relayoutNewContainers=!0},{name:"RealizingState",enter:function(){var a=this,b=new f;this.promise=b.promise.then(function(){return a.view._executeScrollToFunctor()}).then(function(){return a.relayoutNewContainers=!1,e._cancelBlocker(a.view._realizePageImpl())}).then(function(){a.view._state===a&&(a.view._completeUpdateTree(),a.view._listView._writeProfilerMark("RealizingState_to_UnrealizingState"),a.view._setState(a.nextState))},function(b){return a.view._state!==a||a.canceling||(a.view._listView._writeProfilerMark("RealizingState_to_CanceledState"),a.view._setState(B)),e.wrapError(b)}),b.complete()},stop:function(){this.canceling=!0,this.promise.cancel(),this.view._cancelRealize(),this.view._setState(B)},realizePage:function(){this.canceling=!0,this.promise.cancel(),this.enter()},rebuildTree:function(){this.stop(),this.view._setState(x)},relayout:function(){this.stop(),this.view._setState(y)},layoutNewContainers:function(){this.relayoutNewContainers?this.relayout():(this.view._createLayoutSignal(),this.view._relayoutInComplete=!0)},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)},setLoadingState:function(a){this.view._listView._setViewState(a)}}),B=c.Class.define(function(a){this.view=a},{name:"CanceledState",enter:u,stop:function(){this.view._cancelRealize()},realizePage:function(a){this.stop(),this.view._setState(a)},rebuildTree:function(){this.stop(),this.view._setState(x)},relayout:function(a){this.stop(),this.view._setState(y,a)},layoutNewContainers:function(){this.relayout(B)},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),C=c.Class.derive(A,function(a){this.view=a,this.nextState=D,this.relayoutNewContainers=!0},{name:"ScrollingState",setLoadingState:function(){}}),D=c.Class.derive(B,function(a){this.view=a},{name:"ScrollingPausedState",enter:function(){var a=this;this.promise=e._cancelBlocker(this.view._scrollEndPromise).then(function(){a.view._setState(E)})},stop:function(){this.promise.cancel(),this.view._cancelRealize()}}),E=c.Class.define(function(a){this.view=a},{name:"UnrealizingState",enter:function(){var a=this;this.promise=this.view._lazilyUnrealizeItems().then(function(){return a.view._listView._writeProfilerMark("_renderCompletePromise wait starts,info"),a.view._renderCompletePromise}).then(function(){a.view._setState(G)})},stop:function(){this.view._cancelRealize(),this.promise.cancel(),this.view._setState(B)},realizePage:function(a){this.promise.cancel(),this.view._setState(a)},rebuildTree:function(){this.view._setState(x)},relayout:function(){this.view._setState(y)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._relayoutInComplete=!0},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c)}}),F=c.Class.define(function(a,b){this.view=a,this.realizePromise=b,this.realizeId=1},{name:"RealizingAnimatingState",enter:function(){var a=this;this.animating=!0,this.animatePromise=this.view._startAnimations(),this.animateSignal=new f,this.view._executeAnimations=!1,this.animatePromise.done(function(){a.animating=!1,a.modifiedElements?(a.view._updateTreeImpl(a.count,a.delta,a.modifiedElements),a.modifiedElements=null,a.view._setState(B)):a.animateSignal.complete()},function(b){return a.animating=!1,e.wrapError(b)}),this._waitForRealize()},_waitForRealize:function(){var a=this;this.realizing=!0,this.realizePromise.done(function(){a.realizing=!1});var b=++this.realizeId;e.join([this.realizePromise,this.animateSignal.promise]).done(function(){b===a.realizeId&&(a.view._completeUpdateTree(),a.view._listView._writeProfilerMark("RealizingAnimatingState_to_UnrealizingState"),a.view._setState(E))})},stop:function(a){this.realizePromise.cancel(),this.view._cancelRealize(),a&&(this.animatePromise.cancel(),this.view._setState(B))},realizePage:function(){if(!this.modifiedElements){var a=this;this.realizePromise=this.view._executeScrollToFunctor().then(function(){return e._cancelBlocker(a.view._realizePageImpl())}),this._waitForRealize()}},rebuildTree:function(){this.stop(!0),this.view._setState(x)},relayout:function(){this.stop(!0),this.modifiedElements&&(this.view._updateTreeImpl(this.count,this.delta,this.modifiedElements),this.modifiedElements=null),this.view._setState(y)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._relayoutInComplete=!0},waitForEntityPosition:function(){return this.view._getLayoutCompleted()},updateTree:function(a,b,c){if(this.animating){var d=this.modifiedElements;return this.count=a,this.delta=b,this.modifiedElements=c,d?e.cancel:this.animatePromise}return this.view._updateTreeImpl(a,b,c)},setLoadingState:function(a){this.view._listView._setViewState(a)}}),G=c.Class.derive(B,function(a){this.view=a},{name:"CompletedState",enter:function(){this._stopped=!1,this.view._setupDeferredActions(),this.view._realizationLevel=v._realizationLevel.normal,this.view._listView._raiseViewComplete(),this.view._state===this&&this.view._relayoutInComplete&&!this._stopped&&this.view._setState(H)},stop:function(){this._stopped=!0,B.prototype.stop.call(this)},layoutNewContainers:function(){this.view._createLayoutSignal(),this.view._setState(H)},updateTree:function(a,b,c){return this.view._updateTreeImpl(a,b,c,!0)}}),H=c.Class.derive(B,function(a){this.view=a},{name:"LayingoutNewContainersState",enter:function(){var a=this;this.promise=e.join([this.view.deferTimeout,this.view._layoutWork]),this.promise.then(function(){a.view._relayoutInComplete=!1,a.relayout(B)})},stop:function(){this.promise.cancel(),this.view._cancelRealize()},realizePage:function(a){this.stop(),this.view._setState(y,a)},layoutNewContainers:function(){this.view._createLayoutSignal()}});return v})})}),define("require-style!less/desktop/controls",[],function(){}),define("require-style!less/phone/controls",[],function(){}),define("WinJS/Controls/ListView",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Animations/_TransitionAnimation","../BindingList","../Promise","../Scheduler","../_Signal","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_ItemsManager","../Utilities/_SafeHtml","../Utilities/_TabContainer","../Utilities/_UI","../Utilities/_VersionManager","./ItemContainer/_Constants","./ItemContainer/_ItemEventsHandler","./ListView/_BrowseMode","./ListView/_ErrorMessages","./ListView/_GroupFocusCache","./ListView/_GroupsContainer","./ListView/_Helpers","./ListView/_ItemsContainer","./ListView/_Layouts","./ListView/_SelectionManager","./ListView/_VirtualizeContentsView","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){"use strict";function H(){var a=N;N=[],a=a.filter(function(a){return a._isZombie()?(a._dispose(),!1):!0}),N=N.concat(a)}function I(a){N.push(a),K&&K.cancel(),K=k.timeout(M).then(H)}function J(a){return a.offsetParent?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:0}var K,L=c._browserStyleEquivalents.transform,M=1e3,N=[],O=p._uniqueID,P=C._ListViewAnimationHelper,Q={get notCompatibleWithSemanticZoom(){return"ListView can only be used with SemanticZoom if randomAccess loading behavior is specified."},get listViewInvalidItem(){return"Item must provide index, key or description of corresponding item."},get listViewViewportAriaLabel(){return g._getWinJSString("ui/listViewViewportAriaLabel").value}},R=c.requireSupportedForProcessing,S={entrance:"entrance",contentTransition:"contentTransition"};b.Namespace.define("WinJS.UI",{ListViewAnimationType:S,ListView:b.Namespace._lazy(function(){var g=b.Class.define(function(){this.clear()},{add:function(a,b){if(a._lastKnownSizeOfData=b,this._range){this._range.start=Math.min(this._range.start,a.start);var c=this._range._lastKnownSizeOfData-this._range.end,d=a._lastKnownSizeOfData-a.end,e=Math.min(c,d);this._range._lastKnownSizeOfData=a._lastKnownSizeOfData,this._range.end=this._range._lastKnownSizeOfData-e}else this._range=a},addAll:function(){this.add({start:0,end:Number.MAX_VALUE},Number.MAX_VALUE)},clear:function(){this._range=null},get:function(){return this._range}}),q=b.Class.define(function(a){this._listView=a},{getPanAxis:function(){return this._listView._getPanAxis()},configureForZoom:function(a,b,c,d){this._listView._configureForZoom(a,b,c,d)},setCurrentItem:function(a,b){this._listView._setCurrentItem(a,b)},getCurrentItem:function(){return this._listView._getCurrentItem()},beginZoom:function(){return this._listView._beginZoom()},positionItem:function(a,b){return this._listView._positionItem(a,b)},endZoom:function(a){this._listView._endZoom(a)},pinching:{get:function(){return this._listView._pinching},set:function(a){this._listView._pinching=a}}}),D=b.Class.define(function(b,c){if(b=b||a.document.createElement("div"),p._supportsTouchActionCrossSlide&&b.classList.add(w._listViewSupportsCrossSlideClass),this._id=b.id||"",this._writeProfilerMark("constructor,StartTM"),c=c||{},b.winControl=this,p.addClass(b,"win-disposable"),this._affectedRange=new g,this._mutationObserver=new p._MutationObserver(this._itemPropertyChange.bind(this)),this._versionManager=null,this._insertedItems={},this._element=b,this._startProperty=null,this._scrollProperty=null,this._scrollLength=null,this._scrolling=!1,this._zooming=!1,this._pinching=!1,this._itemsManager=null,this._canvas=null,this._cachedCount=w._UNINITIALIZED,this._loadingState=this._LoadingState.complete,this._firstTimeDisplayed=!0,this._currentScrollPosition=0,this._lastScrollPosition=0,this._notificationHandlers=[],this._itemsBlockExtent=-1,this._viewportWidth=w._UNINITIALIZED,this._viewportHeight=w._UNINITIALIZED,this._manipulationState=p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED,this._maxDeferredItemCleanup=Number.MAX_VALUE,this._groupsToRemove={},this._setupInternalTree(),this._isCurrentZoomView=!0,this._dragSource=!1,this._reorderable=!1,this._groupFocusCache=new A._UnsupportedGroupFocusCache,this._viewChange=w._ViewChange.rebuild,this._scrollToFunctor=null,this._setScrollbarPosition=!1,this._view=new G._VirtualizeContentsView(this),this._selection=new F._SelectionManager(this),this._createTemplates(),this._groupHeaderRenderer=r._trivialHtmlRenderer,this._itemRenderer=r._trivialHtmlRenderer,this._groupHeaderRelease=null,this._itemRelease=null,c.itemDataSource)this._dataSource=c.itemDataSource;else{var d=new j.List;this._dataSource=d.dataSource}this._selectionMode=u.SelectionMode.multi,this._tap=u.TapBehavior.invokeOnly,this._groupHeaderTap=u.GroupHeaderTapBehavior.invoke,this._swipeBehavior=u.SwipeBehavior.select,this._mode=new y._SelectionMode(this),this._setSwipeClass(),this._groups=new B._NoGroups(this),this._updateItemsAriaRoles(),this._updateGroupHeadersAriaRoles(),this._element.setAttribute("aria-multiselectable",this._multiSelection()),this._element.tabIndex=-1,this._tabManager.tabIndex=this._tabIndex,"absolute"!==this._element.style.position&&"relative"!==this._element.style.position&&(this._element.style.position="relative"),this._updateItemsManager(),c.layout||this._updateLayout(new E.GridLayout),this._attachEvents(),this._runningInit=!0,n.setOptions(this,c),this._runningInit=!1,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},layout:{get:function(){return this._layoutImpl},set:function(a){this._updateLayout(a),this._runningInit||(this._view.reset(),this._updateItemsManager(),this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},pagesToLoad:{get:function(){return 2*G._VirtualizeContentsView._pagesToPrefetch+1},set:function(){p._deprecated(z.pagesToLoadIsDeprecated)}},pagesToLoadThreshold:{get:function(){return 0},set:function(){p._deprecated(z.pagesToLoadThresholdIsDeprecated)}},groupDataSource:{get:function(){return this._groupDataSource},set:function(a){function b(a){a.detail===u.DataSourceStatus.failure&&(c.itemDataSource=null,c.groupDataSource=null)}this._writeProfilerMark("set_groupDataSource,info");var c=this;this._groupDataSource&&this._groupDataSource.removeEventListener&&this._groupDataSource.removeEventListener("statuschanged",b,!1),this._groupDataSource=a,this._groupFocusCache=a&&this._supportsGroupHeaderKeyboarding?new A._GroupFocusCache(this):new A._UnsupportedGroupFocusCache,this._groupDataSource&&this._groupDataSource.addEventListener&&this._groupDataSource.addEventListener("statuschanged",b,!1),this._createGroupsContainer(),this._runningInit?(this._updateGroupWork(),this._resetLayout()):(this._view.reset(),this._pendingLayoutReset=!0,this._pendingGroupWork=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},_updateGroupWork:function(){this._pendingGroupWork=!1,this._groupDataSource?p.addClass(this._element,w._groupsClass):p.removeClass(this._element,w._groupsClass),this._resetLayout()},automaticallyLoadPages:{get:function(){return!1},set:function(){p._deprecated(z.automaticallyLoadPagesIsDeprecated)}},loadingBehavior:{get:function(){return"randomAccess"},set:function(){p._deprecated(z.loadingBehaviorIsDeprecated)}},selectionMode:{get:function(){return this._selectionMode},set:function(a){if("string"==typeof a&&a.match(/^(none|single|multi)$/)){if(c.isPhone&&a===u.SelectionMode.single)return;return this._selectionMode=a,this._element.setAttribute("aria-multiselectable",this._multiSelection()),this._updateItemsAriaRoles(),this._setSwipeClass(),void this._configureSelectionMode()}throw new d("WinJS.UI.ListView.ModeIsInvalid",z.modeIsInvalid)}},tapBehavior:{get:function(){return this._tap},set:function(a){c.isPhone&&a===u.TapBehavior.directSelect||(this._tap=a,this._updateItemsAriaRoles(),this._configureSelectionMode())}},groupHeaderTapBehavior:{get:function(){return this._groupHeaderTap},set:function(a){this._groupHeaderTap=a,this._updateGroupHeadersAriaRoles()}},swipeBehavior:{get:function(){return this._swipeBehavior},set:function(a){this._swipeBehavior=a,this._setSwipeClass()}},itemDataSource:{get:function(){return this._itemsManager.dataSource},set:function(a){this._writeProfilerMark("set_itemDataSource,info"),this._dataSource=a||(new j.List).dataSource,this._groupFocusCache.clear(),this._runningInit||(this._selection._reset(),this._cancelAsyncViewWork(!0),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},itemTemplate:{get:function(){return this._itemRenderer},set:function(a){this._setRenderer(a,!1),this._runningInit||(this._cancelAsyncViewWork(!0),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},resetItem:{get:function(){return this._itemRelease},set:function(a){p._deprecated(z.resetItemIsDeprecated),this._itemRelease=a}},groupHeaderTemplate:{get:function(){return this._groupHeaderRenderer},set:function(a){this._setRenderer(a,!0),this._runningInit||(this._cancelAsyncViewWork(!0),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.medium,0,!0))}},resetGroupHeader:{get:function(){return this._groupHeaderRelease},set:function(a){p._deprecated(z.resetGroupHeaderIsDeprecated),this._groupHeaderRelease=a}},loadingState:{get:function(){return this._loadingState}},selection:{get:function(){return this._selection}},indexOfFirstVisible:{get:function(){return this._view.firstIndexDisplayed},set:function(a){if(!(0>a)){this._writeProfilerMark("set_indexOfFirstVisible("+a+"),info"),this._raiseViewLoading(!0);var b=this;this._batchViewUpdates(w._ViewChange.realize,w._ScrollToPriority.high,function(){var c;return b._entityInRange({type:u.ObjectType.item,index:a}).then(function(a){return a.inRange?b._getItemOffset({type:u.ObjectType.item,index:a.index}).then(function(a){return c=a,b._ensureFirstColumnRange(u.ObjectType.item)}).then(function(){return c=b._correctRangeInFirstColumn(c,u.ObjectType.item),c=b._convertFromCanvasCoordinates(c),b._view.waitForValidScrollPosition(c.begin)}).then(function(a){var c=ac)){this._raiseViewLoading(!0);var d=this;this._batchViewUpdates(w._ViewChange.realize,w._ScrollToPriority.high,function(){var a;return d._entityInRange({type:b,index:c}).then(function(c){return c.inRange?d._getItemOffset({type:b,index:c.index}).then(function(c){return a=c,d._ensureFirstColumnRange(b)}).then(function(){a=d._correctRangeInFirstColumn(a,b);var e=d._getViewportLength(),f=d._viewportScrollPosition,g=f+e,h=d._viewportScrollPosition,i=a.end-a.begin;a=d._convertFromCanvasCoordinates(a);var j=!1;if(b===u.ObjectType.groupHeader&&f<=a.begin){var k=d._groups.group(c.index).header;if(k){var l,m=E._getMargins(k);if(d._horizontalLayout){var n=d._rtl(),o=n?J(k)-m.right:k.offsetLeft-m.left;l=o+k.offsetWidth+(n?m.left:m.right)}else l=k.offsetTop+k.offsetHeight+m.top;j=g>=l}}j||(i>=g-f?h=a.begin:a.beging&&(h=a.end-e));var q=h=0&&b>c,index:c}});var b=p._clamp(a.index,0,this._groups.length()-1);return k.wrap({inRange:b>=0&&bb;b++)this._insertedItems[a[b]].release();this._insertedItems={},this._modifiedElements=[],this._countDifference=0},_cancelAsyncViewWork:function(a){this._view.stopWork(a)},_updateView:function(){function a(){c._itemsBlockExtent=-1,c._firstItemRange=null,c._firstHeaderRange=null,c._itemMargins=null,c._headerMargins=null,c._canvasMargins=null,c._cachedRTL=null,c._rtl()}function b(){c._scrollToPriority=w._ScrollToPriority.uninitialized;var a=c._setScrollbarPosition;c._setScrollbarPosition=!1;var b="number"==typeof c._scrollToFunctor?{position:c._scrollToFunctor}:c._scrollToFunctor();return k.as(b).then(function(b){return b=b||{},a&&+b.position===b.position&&(c._lastScrollPosition=b.position,c._viewportScrollPosition=b.position),b},function(b){return c._setScrollbarPosition|=a,k.wrapError(b)})}if(!this._isZombie()){var c=this,d=this._viewChange;this._viewChange=w._ViewChange.realize,d===w._ViewChange.rebuild?(this._pendingGroupWork&&this._updateGroupWork(),this._pendingLayoutReset&&this._resetLayout(),a(),this._firstTimeDisplayed||this._view.reset(),this._view.reload(b,!0),this._setFocusOnItem(this._selection._getFocused())):d===w._ViewChange.remeasure?(this._view.resetItems(!0),this._resetLayout(),a(),this._view.refresh(b),this._setFocusOnItem(this._selection._getFocused())):d===w._ViewChange.relayout?(this._pendingLayoutReset&&(this._resetLayout(),a()),this._view.refresh(b)):this._view.onScroll(b)}},_batchViewUpdates:function(a,b,c,d,e){if(this._viewChange=Math.min(this._viewChange,a),(null===this._scrollToFunctor||b>=this._scrollToPriority)&&(this._scrollToPriority=b,this._scrollToFunctor=c),this._setScrollbarPosition|=!!d,!this._batchingViewUpdates){this._raiseViewLoading();var f=this;this._batchingViewUpdatesSignal=new m,this._batchingViewUpdates=k.any([this._batchingViewUpdatesSignal.promise,l.schedulePromiseHigh(null,"WinJS.UI.ListView._updateView")]).then(function(){return f._isZombie()?void 0:f._viewChange!==w._ViewChange.rebuild||f._firstTimeDisplayed||0===Object.keys(f._view.items._itemData).length||e?void 0:f._fadeOutViewport()}).then(function(){f._batchingViewUpdates=null,f._batchingViewUpdatesSignal=null,f._updateView(),f._firstTimeDisplayed=!1},function(){f._batchingViewUpdates=null,f._batchingViewUpdatesSignal=null})}return this._batchingViewUpdatesSignal},_resetCanvas:function(){if(!this._disposed){var b=a.document.createElement("div");b.className=this._canvas.className,this._viewport.replaceChild(b,this._canvas),this._canvas=b,this._groupsToRemove={},this._canvas.appendChild(this._canvasProxy)}},_setupInternalTree:function(){p.addClass(this._element,w._listViewClass),p[this._rtl()?"addClass":"removeClass"](this._element,w._rtlListViewClass),this._element.innerHTML='
',this._viewport=this._element.firstElementChild,this._canvas=this._viewport.firstElementChild,this._canvasProxy=this._canvas.firstElementChild,this._deleteWrapper=this._canvas.nextElementSibling,this._keyboardEventsHelper=this._viewport.nextElementSibling,this._tabIndex=p.getTabIndex(this._element),this._tabIndex<0&&(this._tabIndex=0),this._tabManager=new t.TabContainer(this._viewport),this._tabManager.tabIndex=this._tabIndex,this._progressBar=a.document.createElement("progress"),p.addClass(this._progressBar,w._progressClass),this._progressBar.style.position="absolute",this._progressBar.max=100},_unsetFocusOnItem:function(b){this._tabManager.childFocus&&this._clearFocusRectangle(this._tabManager.childFocus),this._isZombie()||(b||(this._tabManager.childFocus&&(this._tabManager.childFocus=null),this._keyboardEventsHelper._shouldHaveFocus=!1,a.document.activeElement!==this._viewport&&this._hasKeyboardFocus&&(this._keyboardEventsHelper._shouldHaveFocus=!0,p._setActive(this._keyboardEventsHelper))),this._itemFocused=!1)},_setFocusOnItem:function(a){if(this._writeProfilerMark("_setFocusOnItem,info"),this._focusRequest&&this._focusRequest.cancel(),!this._isZombie()){var b=this,c=function(c){b._isZombie()||(b._tabManager.childFocus!==c&&(b._tabManager.childFocus=c),b._focusRequest=null,b._hasKeyboardFocus&&!b._itemFocused&&(b._selection._keyboardFocused()&&b._drawFocusRectangle(c),b._view.updateAriaForAnnouncement(c,a.type===u.ObjectType.groupHeader?b._groups.length():b._cachedCount),b._itemFocused=!0,p._setActive(c)))};this._focusRequest=a.type!==u.ObjectType.groupHeader?this._view.items.requestItem(a.index):this._groups.requestHeader(a.index),this._focusRequest.then(c)}},_attachEvents:function(){function a(a,b,c){return{name:b?a:a.toLowerCase(),handler:function(b){d["_on"+a](b)},capture:c}}function b(a,b,c){return{capture:c,name:b?a:a.toLowerCase(),handler:function(b){var c=d._mode,e="on"+a;!d._disposed&&c[e]&&c[e](b)}}}function c(a,b){return{handler:function(b){d["_on"+a](b)},filter:b}}var d=this,e=[c("PropertyChange",["dir","style","tabindex"])];this._cachedStyleDir=this._element.style.direction,e.forEach(function(a){new p._MutationObserver(a.handler).observe(d._element,{attributes:!0,attributeFilter:a.filter})});var f=[b("PointerDown"),b("click",!1),b("PointerUp"),b("LostPointerCapture"),b("MSHoldVisual",!0),b("PointerCancel",!0),b("DragStart"),b("DragOver"),b("DragEnter"),b("DragLeave"),b("Drop"),b("ContextMenu"),b("MSManipulationStateChanged",!0,!0)];f.forEach(function(a){p._addEventListener(d._viewport,a.name,a.handler,!!a.capture)});var g=[a("FocusIn",!1,!1),a("FocusOut",!1,!1),b("KeyDown"),b("KeyUp"),a("MSElementResize",!1,!1)];g.forEach(function(a){p._addEventListener(d._element,a.name,a.handler,!!a.capture)}),this._onMSElementResizeBound=this._onMSElementResize.bind(this),p._resizeNotifier.subscribe(this._element,this._onMSElementResizeBound);var h=[a("MSManipulationStateChanged",!0),a("Scroll")];h.forEach(function(a){d._viewport.addEventListener(a.name,a.handler,!1)}),this._viewport.addEventListener("onTabEnter",this._onTabEnter.bind(this)),this._viewport.addEventListener("onTabExit",this._onTabExit.bind(this)),this._viewport.addEventListener("onTabEntered",function(a){d._mode.onTabEntered(a)}),this._viewport.addEventListener("onTabExiting",function(a){d._mode.onTabExiting(a)})},_updateItemsManager:function(){function a(a){a.detail===u.DataSourceStatus.failure&&(b.itemDataSource=null,b.groupDataSource=null)}var b=this,c={beginNotifications:function(){},changed:function(a,c){if(!b._ifZombieDispose()){b._createUpdater();var d=b._updater.elements[O(c)];if(d){var e=b.selection._isIncluded(d.index);if(e&&(b._updater.updateDrag=!0),c!==a){if((b._tabManager.childFocus===c||b._updater.newFocusedItem===c)&&(b._updater.newFocusedItem=a,b._tabManager.childFocus=null),d.itemBox){p.addClass(a,w._itemClass),b._setupAriaSelectionObserver(a);var f=c.nextElementSibling;d.itemBox.removeChild(c),d.itemBox.insertBefore(a,f)}b._setAriaSelected(a,e),b._view.items.setItemAt(d.newIndex,{element:a,itemBox:d.itemBox,container:d.container,itemsManagerRecord:d.itemsManagerRecord}),delete b._updater.elements[O(c)],o._disposeElement(c),b._updater.elements[O(a)]={item:a,container:d.container,itemBox:d.itemBox,index:d.index,newIndex:d.newIndex,itemsManagerRecord:d.itemsManagerRecord}}else d.itemBox&&d.container&&(x._ItemEventsHandler.renderSelection(d.itemBox,a,e,!0),p[e?"addClass":"removeClass"](d.container,w._selectedClass));b._updater.changed=!0}for(var g=0,h=b._notificationHandlers.length;h>g;g++)b._notificationHandlers[g].changed(a,c);b._writeProfilerMark("changed,info")}},removed:function(a,c,d){function e(a){b._updater.updateDrag=!0,b._currentMode()._dragging&&b._currentMode()._draggingUnselectedItem&&b._currentMode()._dragInfo._isIncluded(a)&&(b._updater.newDragInfo=new F._Selection(b,[]));var c=b._updater.selectionFirst[a],d=b._updater.selectionLast[a],e=c||d;e&&(delete b._updater.selectionFirst[e.oldFirstIndex],delete b._updater.selectionLast[e.oldLastIndex],b._updater.selectionChanged=!0)}if(!b._ifZombieDispose()){b._createUpdater();var f=b._insertedItems[d];f&&delete b._insertedItems[d];var g;if(a){var h=b._updater.elements[O(a)],i=b._itemsManager.itemObject(a);if(i&&b._groupFocusCache.deleteItem(i.key),h){g=h.index,h.itemBox&&b._updater.removed.push({index:g,itemBox:h.itemBox}),b._updater.deletesCount++;var j=b._view.items.itemDataAt(g);j.removed=!0,delete b._updater.elements[O(a)]}else g=i&&i.index;b._updater.oldFocus.type!==u.ObjectType.groupHeader&&b._updater.oldFocus.index===g&&(b._updater.newFocus.index=g,b._updater.focusedItemRemoved=!0),e(g)}else g=b._updater.selectionHandles[d],g===+g&&e(g);b._writeProfilerMark("removed("+g+"),info"),b._updater.changed=!0}},updateAffectedRange:function(a){b._itemsCount().then(function(c){var d=b._view.containers?b._view.containers.length:0;a.start=Math.min(a.start,d),b._affectedRange.add(a,c)}),b._createUpdater(),b._updater.changed=!0},indexChanged:function(a,c,d){if(!b._ifZombieDispose()){if(b._createUpdater(),a){var e=b._itemsManager.itemObject(a);e&&b._groupFocusCache.updateItemIndex(e.key,c);var f=b._updater.elements[O(a)];f&&(f.newIndex=c,b._updater.changed=!0),b._updater.itemsMoved=!0}b._currentMode()._dragging&&b._currentMode()._draggingUnselectedItem&&b._currentMode()._dragInfo._isIncluded(d)&&(b._updater.newDragInfo=new F._Selection(b,[{firstIndex:c,lastIndex:c}]),b._updater.updateDrag=!0),b._updater.oldFocus.type!==u.ObjectType.groupHeader&&b._updater.oldFocus.index===d&&(b._updater.newFocus.index=c,b._updater.changed=!0),b._updater.oldSelectionPivot===d&&(b._updater.newSelectionPivot=c,b._updater.changed=!0);var g=b._updater.selectionFirst[d];g&&(g.newFirstIndex=c,b._updater.changed=!0,b._updater.updateDrag=!0),g=b._updater.selectionLast[d],g&&(g.newLastIndex=c,b._updater.changed=!0,b._updater.updateDrag=!0)}},endNotifications:function(){b._update()},inserted:function(a){b._ifZombieDispose()||(b._writeProfilerMark("inserted,info"),b._createUpdater(),b._updater.changed=!0,a.retain(),b._updater.insertsCount++,b._insertedItems[a.handle]=a)},moved:function(a,c,d,e){if(!b._ifZombieDispose()){if(b._createUpdater(),b._updater.movesCount++,a){b._updater.itemsMoved=!0;var f=b._updater.elements[O(a)];f&&(f.moved=!0)}var g=b._updater.selectionHandles[e.handle];if(g===+g){b._updater.updateDrag=!0;var h=b._updater.selectionFirst[g],i=b._updater.selectionLast[g],j=h||i;j&&j.oldFirstIndex!==j.oldLastIndex&&(delete b._updater.selectionFirst[j.oldFirstIndex],delete b._updater.selectionLast[j.oldLastIndex],b._updater.selectionChanged=!0,b._updater.changed=!0)}b._writeProfilerMark("moved("+g+"),info")}},countChanged:function(a,c){b._ifZombieDispose()||(b._writeProfilerMark("countChanged("+a+"),info"),b._cachedCount=a,b._createUpdater(),b._view.lastIndexDisplayed+1===c&&(b._updater.changed=!0),b._updater.countDifference+=a-c)},reload:function(){b._ifZombieDispose()||(b._writeProfilerMark("reload,info"),b._processReload())}};this._versionManager&&this._versionManager._dispose(),this._versionManager=new v._VersionManager,this._updater=null;var d=this._selection.getRanges();this._selection._selected.clear(),this._itemsManager&&(this._itemsManager.dataSource&&this._itemsManager.dataSource.removeEventListener&&this._itemsManager.dataSource.removeEventListener("statuschanged",a,!1),this._clearInsertedItems(),this._itemsManager.release()),this._itemsCountPromise&&(this._itemsCountPromise.cancel(),this._itemsCountPromise=null),this._cachedCount=w._UNINITIALIZED,this._itemsManager=r._createItemsManager(this._dataSource,this._renderWithoutReuse.bind(this),c,{ownerElement:this._element,versionManager:this._versionManager,indexInView:function(a){return a>=b.indexOfFirstVisible&&a<=b.indexOfLastVisible},viewCallsReady:!0,profilerId:this._id}),this._dataSource.addEventListener&&this._dataSource.addEventListener("statuschanged",a,!1),this._selection._selected.set(d)},_processReload:function(){this._affectedRange.addAll(),this._cancelAsyncViewWork(!0),this._currentMode()._dragging&&this._currentMode()._clearDragProperties(),this._groupFocusCache.clear(),this._selection._reset(),this._updateItemsManager(),this._pendingLayoutReset=!0,this._batchViewUpdates(w._ViewChange.rebuild,w._ScrollToPriority.low,this.scrollPosition)},_createUpdater:function(){if(!this._updater){this.itemDataSource._isVirtualizedDataSource&&this._affectedRange.addAll(),this._versionManager.beginUpdating(),this._cancelAsyncViewWork();var a={changed:!1,elements:{},selectionFirst:{},selectionLast:{},selectionHandles:{},oldSelectionPivot:{type:u.ObjectType.item,index:w._INVALID_INDEX},newSelectionPivot:{type:u.ObjectType.item,index:w._INVALID_INDEX},removed:[],selectionChanged:!1,oldFocus:{type:u.ObjectType.item,index:w._INVALID_INDEX},newFocus:{type:u.ObjectType.item,index:w._INVALID_INDEX},hadKeyboardFocus:this._hasKeyboardFocus,itemsMoved:!1,lastVisible:this.indexOfLastVisible,updateDrag:!1,movesCount:0,insertsCount:0,deletesCount:0,countDifference:0};this._view.items.each(function(b,c,d){a.elements[O(c)]={item:c,container:d.container,itemBox:d.itemBox,index:b,newIndex:b,itemsManagerRecord:d.itemsManagerRecord,detached:d.detached}});for(var b=this._selection._selected._ranges,c=0,d=b.length;d>c;c++){var e=b[c],f={newFirstIndex:b[c].firstIndex,oldFirstIndex:b[c].firstIndex,newLastIndex:b[c].lastIndex,oldLastIndex:b[c].lastIndex};a.selectionFirst[f.oldFirstIndex]=f,a.selectionLast[f.oldLastIndex]=f,a.selectionHandles[e.firstPromise.handle]=f.oldFirstIndex,a.selectionHandles[e.lastPromise.handle]=f.oldLastIndex}a.oldSelectionPivot=this._selection._pivot,a.newSelectionPivot=a.oldSelectionPivot,a.oldFocus=this._selection._getFocused(),a.newFocus=this._selection._getFocused(),this._updater=a}},_synchronize:function(){var a=this._updater;if(this._updater=null,this._groupsChanged=!1,this._countDifference=this._countDifference||0,a&&a.changed){a.itemsMoved&&this._layout.itemsMoved&&this._layout.itemsMoved(),a.removed.length&&this._layout.itemsRemoved&&this._layout.itemsRemoved(a.removed.map(function(a){return a.itemBox})),(a.itemsMoved||a.removed.length||Object.keys(this._insertedItems).length)&&this._layout.setupAnimations&&this._layout.setupAnimations(),this._currentMode().onDataChanged&&this._currentMode().onDataChanged();var b=[];for(var c in a.selectionFirst)if(a.selectionFirst.hasOwnProperty(c)){var d=a.selectionFirst[c];a.selectionChanged=a.selectionChanged||d.newLastIndex-d.newFirstIndex!==d.oldLastIndex-d.oldFirstIndex,d.newFirstIndex<=d.newLastIndex&&b.push({firstIndex:d.newFirstIndex,lastIndex:d.newLastIndex})}if(a.selectionChanged){var e=new F._Selection(this,b);this._selection._fireSelectionChanging(e),this._selection._selected.set(b),this._selection._fireSelectionChanged(),e.clear()}else this._selection._selected.set(b);this._selection._updateCount(this._cachedCount),a.newSelectionPivot=Math.min(this._cachedCount-1,a.newSelectionPivot),this._selection._pivot=a.newSelectionPivot>=0?a.newSelectionPivot:w._INVALID_INDEX,a.newFocus.type!==u.ObjectType.groupHeader&&(a.newFocus.index=Math.max(0,Math.min(this._cachedCount-1,a.newFocus.index))),this._selection._setFocused(a.newFocus,this._selection._keyboardFocused());var f=this._modifiedElements||[],g={};for(this._modifiedElements=[],this._countDifference+=a.countDifference,c=0;c0&&o._updateDeleteWrapperSize(),o._view.updateTree(o._cachedCount,o._countDifference,o._modifiedElements)}).then(function(){return o._lastScrollPosition})}this._countDifference+=a?a.countDifference:0;var o=this;return this._groups.synchronizeGroups().then(function(){return a&&o._versionManager.endUpdating(),o._view.updateTree(o._cachedCount,o._countDifference,o._modifiedElements)}).then(function(){return o.scrollPosition})},_updateDeleteWrapperSize:function(a){var b=this._horizontal()?"width":"height";this._deleteWrapper.style["min-"+b]=(a?0:this.scrollPosition+this._getViewportSize()[b])+"px"},_verifyRealizationNeededForChange:function(){var a=!1,b=(this._view.lastIndexDisplayed||0)-(this._view.firstIndexDisplayed||0),c=this._updater&&0===this._updater.movesCount&&0===this._updater.insertsCount&&this._updater.deletesCount>0&&this._updater.deletesCount===Math.abs(this._updater.countDifference);if(c&&this._updater.elements)for(var d=Object.keys(this._updater.elements),e=0,f=d.length;f>e;e++){var g=this._updater.elements[d[e]],h=g.index-g.newIndex;if(0>h||h>this._updater.deletesCount){c=!1;break}}this._view.deletesWithoutRealize=this._view.deletesWithoutRealize||0,c&&this._view.lastIndexDisplayed ("+a+"x"+b+"),info"),this._previousWidth=a,this._previousHeight=b,this._resizeViewport();var c=this;this._affectedRange.addAll(),this._batchViewUpdates(w._ViewChange.relayout,w._ScrollToPriority.low,function(){return{position:c.scrollPosition,direction:"right"}})}}},l.Priority.max,this,"WinJS.UI.ListView._onMSElementResize")},_onFocusIn:function(a){function b(a){c._changeFocus(c._selection._getFocused(),!0,!1,!1,a)}this._hasKeyboardFocus=!0;var c=this;if(a.target===this._keyboardEventsHelper)!this._keyboardEventsHelper._shouldHaveFocus&&this._keyboardFocusInbound?b(!0):this._keyboardEventsHelper._shouldHaveFocus=!1;else if(a.target===this._element)b();else{if(this._mode.inboundFocusHandled)return void(this._mode.inboundFocusHandled=!1);var d=this._view.items,e={},f=this._groups.headerFrom(a.target),g=null;if(f?(e.type=u.ObjectType.groupHeader,e.index=this._groups.index(f)):(e.index=d.index(a.target),e.type=u.ObjectType.item,f=d.itemBoxAt(e.index),g=d.itemAt(e.index)),e.index!==w._INVALID_INDEX&&((this._keyboardFocusInbound||this._selection._keyboardFocused())&&(e.type===u.ObjectType.groupHeader&&a.target===f||e.type===u.ObjectType.item&&a.target.parentNode===f)&&this._drawFocusRectangle(f),this._tabManager.childFocus!==f&&this._tabManager.childFocus!==g&&(this._selection._setFocused(e,this._keyboardFocusInbound||this._selection._keyboardFocused()),this._keyboardFocusInbound=!1,f=e.type===u.ObjectType.groupHeader?f:d.itemAt(e.index),this._tabManager.childFocus=f,c._updater))){var h=c._updater.elements[O(f)],i=e.index;h&&h.newIndex&&(i=h.newIndex),c._updater.oldFocus={type:e.type,index:i},c._updater.newFocus={type:e.type,index:i}}}},_onFocusOut:function(a){if(!this._disposed){this._hasKeyboardFocus=!1,this._itemFocused=!1;var b=this._view.items.itemBoxFrom(a.target)||this._groups.headerFrom(a.target);b&&this._clearFocusRectangle(b)}},_onMSManipulationStateChanged:function(a){function b(){c._manipulationEndSignal=null}var c=this;this._manipulationState=a.currentState,c._writeProfilerMark("_onMSManipulationStateChanged state("+a.currentState+"),info"),this._manipulationState===p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED||this._manipulationEndSignal||(this._manipulationEndSignal=new m,this._manipulationEndSignal.promise.done(b,b)),this._manipulationState===p._MSManipulationEvent.MS_MANIPULATION_STATE_STOPPED&&this._manipulationEndSignal.complete()},_pendingScroll:!1,_onScroll:function(){this._zooming||this._pendingScroll||this._checkScroller()},_checkScroller:function(){if(!this._isZombie()){var a=this._viewportScrollPosition;if(a!==this._lastScrollPosition){this._pendingScroll=c._requestAnimationFrame(this._checkScroller.bind(this)),a=Math.max(0,a);var b=this._scrollDirection(a);this._lastScrollPosition=a,this._raiseViewLoading(!0);var d=this;this._view.onScroll(function(){return{position:d._lastScrollPosition,direction:b}},this._manipulationEndSignal?this._manipulationEndSignal.promise:k.timeout(w._DEFERRED_SCROLL_END))}else this._pendingScroll=null}},_scrollDirection:function(a){var b=a=0&&(b._view.items.each(function(a,b){b.tabIndex=d}),b._tabIndex=d,b._tabManager.tabIndex=d,b._element.tabIndex=-1)}})},_getCanvasMargins:function(){return this._canvasMargins||(this._canvasMargins=E._getMargins(this._canvas)),this._canvasMargins},_convertCoordinatesByCanvasMargins:function(a,b){function c(c,d){void 0!==a[c]&&(a[c]=b(a[c],d))}var d;return this._horizontal()?(d=this._getCanvasMargins()[this._rtl()?"right":"left"],c("left",d)):(d=this._getCanvasMargins().top,c("top",d)),c("begin",d),c("end",d),a},_convertFromCanvasCoordinates:function(a){return this._convertCoordinatesByCanvasMargins(a,function(a,b){return a+b})},_convertToCanvasCoordinates:function(a){return this._convertCoordinatesByCanvasMargins(a,function(a,b){return a-b})},_getViewportSize:function(){return(this._viewportWidth===w._UNINITIALIZED||this._viewportHeight===w._UNINITIALIZED)&&(this._viewportWidth=Math.max(0,p.getContentWidth(this._element)),this._viewportHeight=Math.max(0,p.getContentHeight(this._element)),this._writeProfilerMark("viewportSizeDetected width:"+this._viewportWidth+" height:"+this._viewportHeight),this._previousWidth=this._element.offsetWidth,this._previousHeight=this._element.offsetHeight),{width:this._viewportWidth,height:this._viewportHeight}},_itemsCount:function(){function a(){b._itemsCountPromise=null}var b=this;if(this._cachedCount!==w._UNINITIALIZED)return k.wrap(this._cachedCount);var c;return this._itemsCountPromise?c=this._itemsCountPromise:(c=this._itemsCountPromise=this._itemsManager.dataSource.getCount().then(function(a){return a===u.CountResult.unknown&&(a=0),b._cachedCount=a,b._selection._updateCount(b._cachedCount),a},function(){return k.cancel}),this._itemsCountPromise.then(a,a)),c},_isSelected:function(a){return this._selection._isIncluded(a)},_LoadingState:{itemsLoading:"itemsLoading",viewPortLoaded:"viewPortLoaded",itemsLoaded:"itemsLoaded",complete:"complete"},_raiseViewLoading:function(a){this._loadingState!==this._LoadingState.itemsLoading&&(this._scrolling=!!a),this._setViewState(this._LoadingState.itemsLoading)},_raiseViewComplete:function(){this._disposed||this._view.animating||this._setViewState(this._LoadingState.complete)},_setViewState:function(b){if(b!==this._loadingState){var c=null;switch(b){case this._LoadingState.viewPortLoaded:this._scheduledForDispose||(I(this),this._scheduledForDispose=!0),this._setViewState(this._LoadingState.itemsLoading);break;case this._LoadingState.itemsLoaded:c={scrolling:this._scrolling},this._setViewState(this._LoadingState.viewPortLoaded);break;case this._LoadingState.complete:this._setViewState(this._LoadingState.itemsLoaded),this._updateDeleteWrapperSize(!0)}this._writeProfilerMark("loadingStateChanged:"+b+",info"),this._loadingState=b;var d=a.document.createEvent("CustomEvent");d.initCustomEvent("loadingstatechanged",!0,!1,c),this._element.dispatchEvent(d)}},_createTemplates:function(){function b(b,c){var d=a.document.createElement("div");return d.className=b,c||d.setAttribute("aria-hidden",!0),d}this._itemBoxTemplate=b(w._itemBoxClass,!0)},_updateSelection:function(){var a=this._selection.getIndices(),b=this._selection.isEverything(),c={};if(!b)for(var d=0,e=a.length;e>d;d++){var f=a[d];c[f]=!0}this._view.items.each(function(a,d,e){if(e.itemBox&&!p.hasClass(e.itemBox,w._swipeClass)){var f=b||!!c[a];x._ItemEventsHandler.renderSelection(e.itemBox,d,f,!0),e.container&&p[f?"addClass":"removeClass"](e.container,w._selectedClass)}})},_getViewportLength:function(){return this._getViewportSize()[this._horizontal()?"width":"height"]},_horizontal:function(){return this._horizontalLayout},_rtl:function(){return"boolean"!=typeof this._cachedRTL&&(this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction),this._cachedRTL},_showProgressBar:function(a,b,c){var d=this._progressBar,e=d.style;if(!d.parentNode){this._fadingProgressBar=!1,this._progressIndicatorDelayTimer&&this._progressIndicatorDelayTimer.cancel();var f=this;this._progressIndicatorDelayTimer=k.timeout(w._LISTVIEW_PROGRESS_DELAY).then(function(){f._isZombie()||(a.appendChild(d),P.fadeInElement(d),f._progressIndicatorDelayTimer=null)})}e[this._rtl()?"right":"left"]=b,e.top=c},_hideProgressBar:function(){this._progressIndicatorDelayTimer&&(this._progressIndicatorDelayTimer.cancel(),this._progressIndicatorDelayTimer=null);var a=this._progressBar;if(a.parentNode&&!this._fadingProgressBar){this._fadingProgressBar=!0;var b=this;P.fadeOutElement(a).then(function(){a.parentNode&&a.parentNode.removeChild(a),b._fadingProgressBar=!1})}},_getPanAxis:function(){return this._horizontal()?"horizontal":"vertical"},_configureForZoom:function(a,b,e){if(c.validation&&(!this._view.realizePage||"number"!=typeof this._view.begin))throw new d("WinJS.UI.ListView.NotCompatibleWithSemanticZoom",Q.notCompatibleWithSemanticZoom);this._isZoomedOut=a,this._disableEntranceAnimation=!b,this._isCurrentZoomView=b,this._triggerZoom=e},_setCurrentItem:function(a,b){this._rtl()&&(a=this._viewportWidth-a),this._horizontal()?a+=this.scrollPosition:b+=this.scrollPosition;var c=this._view.hitTest(a,b),d={type:c.type?c.type:u.ObjectType.item,index:c.index};d.index>=0&&(this._hasKeyboardFocus?this._changeFocus(d,!0,!1,!0):this._changeFocusPassively(d))},_getCurrentItem:function(){var a=this._selection._getFocused();a.type===u.ObjectType.groupHeader&&(a={type:u.ObjectType.item,index:this._groups.group(a.index).startIndex}),"number"!=typeof a.index&&(this._setCurrentItem(.5*this._viewportWidth,.5*this._viewportHeight),a=this._selection._getFocused());var b=this,c=this._getItemOffsetPosition(a.index).then(function(a){var c=b._canvasStart;return a[b._startProperty]+=c,a});return k.join({item:this._dataSource.itemFromIndex(a.index),position:c})},_animateItemsForPhoneZoom:function(){function a(a,b,c){return function(d){return(b[d]-a)*c}}function b(){for(var a=0,b=c.length;b>a;a++)c[a].style[L.scriptName]=""}for(var c=[],d=[],e=[],f=Number.MAX_VALUE,g=this,h=this._view.firstIndexDisplayed,j=Math.min(this._cachedCount,this._view.lastIndexDisplayed+1);j>h;h++)e.push(this._view.waitForEntityPosition({type:u.ObjectType.item,index:h}).then(function(){c.push(g._view.items.containerAt(h));var a=0;if(g.layout._getItemPosition){var b=g.layout._getItemPosition(h);b.row&&(a=b.row)}d.push(a),f=Math.min(a,f)}));return k.join(e).then(function(){return(0===c.length?k.wrap():i.executeTransition(c,{property:L.cssName,delay:a(f,d,30),duration:100,timing:"ease-in-out",from:g._isCurrentZoomView?"rotateX(0deg)":"rotateX(-90deg)",to:g._isCurrentZoomView?"rotateX(90deg)":"rotateX(0deg)"})).then(b,b)}).then(b,b)},_beginZoom:function(){this._zooming=!0;var a=null;if(c.isPhone){if(this._isZoomedOut)if(this._zoomAnimationPromise&&this._zoomAnimationPromise.cancel(),this._isCurrentZoomView){var b=this,d=function(){b._zoomAnimationPromise=null};this._zoomAnimationPromise=a=this._animateItemsForPhoneZoom().then(d,d)}else this._zoomAnimationPromise=new m,a=this._zoomAnimationPromise.promise}else{var e=this._horizontal(),f=-this.scrollPosition;p.addClass(this._viewport,e?w._zoomingXClass:w._zoomingYClass),this._canvasStart=f,p.addClass(this._viewport,e?w._zoomingYClass:w._zoomingXClass)}return a},_positionItem:function(a,b){function e(a){return f._getItemOffsetPosition(a).then(function(d){var e,g=f._horizontal(),h=f._viewport[g?"scrollWidth":"scrollHeight"],i=g?f._viewportWidth:f._viewportHeight,j=g?"headerContainerWidth":"headerContainerHeight",k=f.layout._sizes,l=0;k&&k[j]&&(l=k[j]);var m=c.isPhone?l:b[f._startProperty],n=i-(g?d.width:d.height);m=Math.max(0,Math.min(n,m)),e=d[f._startProperty]-m;var o=Math.max(0,Math.min(h-i,e)),p=o-e;e=o;var q={type:u.ObjectType.item,index:a};if(f._hasKeyboardFocus?f._changeFocus(q,!0):f._changeFocusPassively(q),f._raiseViewLoading(!0),c.isPhone)f._viewportScrollPosition=e;else{var r=-e;f._canvasStart=r}if(f._view.realizePage(e,!0),c.isPhone&&f._isZoomedOut){var s=function(){f._zoomAnimationPromise&&f._zoomAnimationPromise.complete&&f._zoomAnimationPromise.complete(),f._zoomAnimationPromise=null};f._animateItemsForPhoneZoom().then(s,s)}return g?{x:p,y:0}:{x:0,y:p}})}var f=this,g=0;if(a&&(g=this._isZoomedOut?a.groupIndexHint:a.firstItemIndexHint),"number"==typeof g)return e(g);var h,i=this._isZoomedOut?a.groupKey:a.firstItemKey;if("string"==typeof i&&this._dataSource.itemFromKey)h=this._dataSource.itemFromKey(i,this._isZoomedOut?{groupMemberKey:a.key,groupMemberIndex:a.index}:null);else{var j=this._isZoomedOut?a.groupDescription:a.firstItemDescription;if(c.validation&&void 0===j)throw new d("WinJS.UI.ListView.InvalidItem",Q.listViewInvalidItem);h=this._dataSource.itemFromDescription(j)}return h.then(function(a){return e(a.index)})},_endZoom:function(a){if(!this._isZombie()){if(!c.isPhone){var b=this._canvasStart;p.removeClass(this._viewport,w._zoomingYClass),p.removeClass(this._viewport,w._zoomingXClass),this._canvasStart=0,this._viewportScrollPosition=-b}this._disableEntranceAnimation=!a,this._isCurrentZoomView=a,this._zooming=!1,this._view.realizePage(this.scrollPosition,!1)}},_getItemOffsetPosition:function(a){var b=this;return this._getItemOffset({type:u.ObjectType.item,index:a}).then(function(a){return b._ensureFirstColumnRange(u.ObjectType.item).then(function(){return a=b._correctRangeInFirstColumn(a,u.ObjectType.item),a=b._convertFromCanvasCoordinates(a),b._horizontal()?(a.left=a.begin,a.width=a.end-a.begin,a.height=a.totalHeight):(a.top=a.begin,a.height=a.end-a.begin,a.width=a.totalWidth),a})})},_groupRemoved:function(a){this._groupFocusCache.deleteGroup(a)},_updateFocusCache:function(a){this._updateFocusCacheItemRequest&&this._updateFocusCacheItemRequest.cancel();var b=this;this._updateFocusCacheItemRequest=this._view.items.requestItem(a).then(function(){b._updateFocusCacheItemRequest=null;var c=b._view.items.itemDataAt(a),d=b._groups.groupFromItem(a),e=b._groups.group(d).key;c.itemsManagerRecord.item&&b._groupFocusCache.updateCache(e,c.itemsManagerRecord.item.key,a)})},_changeFocus:function(a,b,c,d,e){if(!this._isZombie()){var f;if(a.type!==u.ObjectType.groupHeader)f=this._view.items.itemAt(a.index),!b&&f&&p.hasClass(f,w._nonSelectableClass)&&(b=!0),this._updateFocusCache(a.index);else{var g=this._groups.group(a.index);f=g&&g.header}this._unsetFocusOnItem(!!f),this._hasKeyboardFocus=!0,this._selection._setFocused(a,e),d||this.ensureVisible(a),!b&&this._selectFocused(c)&&this._selection.set(a.index),this._setFocusOnItem(a)}},_changeFocusPassively:function(a){var b;if(a.type!==u.ObjectType.groupHeader)b=this._view.items.itemAt(a.index),this._updateFocusCache(a.index);else{var c=this._groups.group(a.index);b=c&&c.header}this._unsetFocusOnItem(!!b),this._selection._setFocused(a),this._setFocusOnItem(a)},_drawFocusRectangle:function(b){if(p.hasClass(b,w._headerClass))p.addClass(b,w._itemFocusClass);else{var c=this._view.items.itemBoxFrom(b);if(c.querySelector("."+w._itemFocusOutlineClass))return;p.addClass(c,w._itemFocusClass);var d=a.document.createElement("div");d.className=w._itemFocusOutlineClass,c.appendChild(d)}},_clearFocusRectangle:function(a){if(a&&!this._isZombie()){var b=this._view.items.itemBoxFrom(a);if(b){p.removeClass(b,w._itemFocusClass);var c=b.querySelector("."+w._itemFocusOutlineClass);c&&c.parentNode.removeChild(c)}else{var d=this._groups.headerFrom(a);d&&p.removeClass(d,w._itemFocusClass)}}},_defaultInvoke:function(a){(this._isZoomedOut||c.isPhone&&this._triggerZoom&&a.type===u.ObjectType.groupHeader)&&(this._changeFocusPassively(a),this._triggerZoom())},_selectionAllowed:function(a){var b=void 0!==a?this.elementFromIndex(a):null,c=!(b&&p.hasClass(b,w._nonSelectableClass));return c&&this._selectionMode!==u.SelectionMode.none},_multiSelection:function(){return this._selectionMode===u.SelectionMode.multi},_selectOnTap:function(){return this._tap===u.TapBehavior.toggleSelect||this._tap===u.TapBehavior.directSelect},_selectFocused:function(a){return this._tap===u.TapBehavior.directSelect&&this._selectionMode===u.SelectionMode.multi&&!a},_dispose:function(){if(!this._disposed){this._disposed=!0;var a=function(a){a&&(a.textContent="")};p._resizeNotifier.unsubscribe(this._element,this._onMSElementResizeBound),this._batchingViewUpdates&&this._batchingViewUpdates.cancel(),this._view&&this._view._dispose&&this._view._dispose(),this._mode&&this._mode._dispose&&this._mode._dispose(),this._groups&&this._groups._dispose&&this._groups._dispose(),this._selection&&this._selection._dispose&&this._selection._dispose(),this._layout&&this._layout.uninitialize&&this._layout.uninitialize(),this._itemsCountPromise&&this._itemsCountPromise.cancel(),this._versionManager&&this._versionManager._dispose(),this._clearInsertedItems(),this._itemsManager&&this._itemsManager.release(),this._zoomAnimationPromise&&this._zoomAnimationPromise.cancel(),a(this._viewport),a(this._canvas),a(this._canvasProxy),this._versionManager=null,this._view=null,this._mode=null,this._element=null,this._viewport=null,this._itemsManager=null,this._canvas=null,this._canvasProxy=null,this._itemsCountPromise=null,this._scrollToFunctor=null;var b=N.indexOf(this);b>=0&&N.splice(b,1)}},_isZombie:function(){return this._disposed||!(this.element.firstElementChild&&a.document.body.contains(this.element))},_ifZombieDispose:function(){var a=this._isZombie();return a&&!this._disposed&&I(this),a},_animationsDisabled:function(){return 0===this._viewportWidth||0===this._viewportHeight?!0:!i.isAnimationEnabled()},_fadeOutViewport:function(){var a=this;return new k(function(b){if(a._animationsDisabled())return void b();if(!a._fadingViewportOut){a._waitingEntranceAnimationPromise&&(a._waitingEntranceAnimationPromise.cancel(),a._waitingEntranceAnimationPromise=null);var d=a._fireAnimationEvent(S.contentTransition);a._firedAnimationEvent=!0;var e=c._browserStyleEquivalents["overflow-style"],f=e?a._viewport:a._canvas;d.prevented?(a._disableEntranceAnimation=!0,f.style.opacity=1,b()):(a._fadingViewportOut=!0,e&&(f.style[e.scriptName]="none"),P.fadeOutElement(f).then(function(){a._isZombie()||(a._fadingViewportOut=!1,f.style.opacity=1,b())}))}})},_animateListEntrance:function(a){function b(){e._canvas.style.opacity=1,f&&(g.style[f.scriptName]="")}var d={prevented:!1,animationPromise:k.wrap()},e=this,f=c._browserStyleEquivalents["overflow-style"],g=f?this._viewport:this._canvas;return this._disableEntranceAnimation||this._animationsDisabled()?(b(),this._waitingEntranceAnimationPromise&&(this._waitingEntranceAnimationPromise.cancel(),this._waitingEntranceAnimationPromise=null),k.wrap()):(this._firedAnimationEvent?this._firedAnimationEvent=!1:d=this._fireAnimationEvent(S.entrance),d.prevented||c.isPhone?(b(),k.wrap()):(this._waitingEntranceAnimationPromise&&this._waitingEntranceAnimationPromise.cancel(),this._canvas.style.opacity=0,f&&(g.style[f.scriptName]="none"),this._waitingEntranceAnimationPromise=d.animationPromise.then(function(){return e._isZombie()?void 0:(e._canvas.style.opacity=1,P.animateEntrance(g,a).then(function(){e._isZombie()||(f&&(g.style[f.scriptName]=""),e._waitingEntranceAnimationPromise=null)}))}),this._waitingEntranceAnimationPromise))},_fireAnimationEvent:function(b){var c=a.document.createEvent("CustomEvent"),d=k.wrap();c.initCustomEvent("contentanimating",!0,!0,{type:b}),b===S.entrance&&(c.detail.setPromise=function(a){d=a});var e=!this._element.dispatchEvent(c);return{prevented:e,animationPromise:d}},_createAriaMarkers:function(){this._viewport.getAttribute("aria-label")||this._viewport.setAttribute("aria-label",Q.listViewViewportAriaLabel),this._ariaStartMarker||(this._ariaStartMarker=a.document.createElement("div"),this._ariaStartMarker.id=O(this._ariaStartMarker),this._viewport.insertBefore(this._ariaStartMarker,this._viewport.firstElementChild)),this._ariaEndMarker||(this._ariaEndMarker=a.document.createElement("div"),this._ariaEndMarker.id=O(this._ariaEndMarker),this._viewport.appendChild(this._ariaEndMarker))},_updateItemsAriaRoles:function(){var a,b,c=this,d=this._element.getAttribute("role");this._currentMode().staticMode()?(a="list",b="listitem"):(a="listbox",b="option"),(d!==a||this._itemRole!==b)&&(this._element.setAttribute("role",a),this._itemRole=b,this._view.items.each(function(a,b){b.setAttribute("role",c._itemRole)}))},_updateGroupHeadersAriaRoles:function(){var a=this.groupHeaderTapBehavior===u.GroupHeaderTapBehavior.none?"separator":"link";if(this._headerRole!==a){this._headerRole=a;for(var b=0,c=this._groups.length();c>b;b++){var d=this._groups.group(b).header;d&&d.setAttribute("role",this._headerRole)}}},_setAriaSelected:function(a,b){var c="true"===a.getAttribute("aria-selected");b!==c&&a.setAttribute("aria-selected",b)},_setupAriaSelectionObserver:function(a){a._mutationObserver||(this._mutationObserver.observe(a,{attributes:!0,attributeFilter:["aria-selected"]}),a._mutationObserver=!0)},_itemPropertyChange:function(a){function b(a){a.forEach(function(a){a.item.setAttribute("aria-selected",!a.selected)})}if(!this._isZombie()){for(var c=this,d=c._selectionMode===u.SelectionMode.single,e=[],f=[],g=0,h=a.length;h>g;g++){var i=a[g].target,j=c._view.items.itemBoxFrom(i),k="true"===i.getAttribute("aria-selected");if(j&&k!==p._isSelectionRendered(j)){var l=c._view.items.index(j),n={index:l,item:i,selected:k};(c._selectionAllowed(l)?e:f).push(n)}}if(e.length>0){var o=new m;c.selection._synchronize(o).then(function(){var a=c.selection._cloneSelection();return e.forEach(function(b){b.selected?a[d?"set":"add"](b.index):a.remove(b.index)}),c.selection._set(a)}).then(function(a){c._isZombie()||a||b(e),o.complete()})}b(f)}},_groupsEnabled:function(){return!!this._groups.groupDataSource},_getItemPosition:function(a,b){var c=this;return this._view.waitForEntityPosition(a).then(function(){var d=a.type===u.ObjectType.groupHeader?c._view._getHeaderContainer(a.index):c._view.getContainer(a.index);if(d){c._writeProfilerMark("WinJS.UI.ListView:getItemPosition,info");var e,f;c._view._expandedRange?(e=c._view._expandedRange.first.index,f=c._view._expandedRange.last.index):b=!1,a.type===u.ObjectType.item?(b=!!b,b&=c._view._ensureContainerInDOM(a.index)):b=!1;var g=c._getItemMargins(a.type),h={left:c._rtl()?J(d)-g.right:d.offsetLeft-g.left,top:d.offsetTop-g.top,totalWidth:p.getTotalWidth(d),totalHeight:p.getTotalHeight(d),contentWidth:p.getContentWidth(d),contentHeight:p.getContentHeight(d)};return b&&c._view._forceItemsBlocksInDOM(e,f+1),c._zooming&&0!==c._canvasStart?h:c._convertToCanvasCoordinates(h)}return k.cancel})},_getItemOffset:function(a,b){var c=this;return this._getItemPosition(a,b).then(function(b){var d=c._getItemMargins(a.type);if(c._horizontal()){var e=c._rtl();b.begin=b.left-d[e?"left":"right"],b.end=b.left+b.totalWidth+d[e?"right":"left"]}else b.begin=b.top-d.bottom,b.end=b.top+b.totalHeight+d.top;return b})},_getItemMargins:function(b){b=b||u.ObjectType.item;var c=this,d=function(b){var d,e=c._canvas.querySelector("."+b);e||(e=a.document.createElement("div"),p.addClass(e,b),c._viewport.appendChild(e),d=!0);var f=E._getMargins(e);return d&&c._viewport.removeChild(e),f};return b!==u.ObjectType.groupHeader?this._itemMargins?this._itemMargins:this._itemMargins=d(w._containerClass):this._headerMargins?this._headerMargins:this._headerMargins=d(w._headerContainerClass)},_fireAccessibilityAnnotationCompleteEvent:function(b,c,d,e){var f={firstIndex:b,lastIndex:c,firstHeaderIndex:+d||-1,lastHeaderIndex:+e||-1},g=a.document.createEvent("CustomEvent");g.initCustomEvent("accessibilityannotationcomplete",!0,!1,f),this._element.dispatchEvent(g)},_ensureFirstColumnRange:function(a){var b=a===u.ObjectType.item?"_firstItemRange":"_firstHeaderRange";if(this[b])return k.wrap();var c=this;return this._getItemOffset({type:a,index:0},!0).then(function(a){c[b]=a})},_correctRangeInFirstColumn:function(a,b){var c=b===u.ObjectType.groupHeader?this._firstHeaderRange:this._firstItemRange;return c.begin===a.begin&&(a.begin=this._horizontal()?-this._getCanvasMargins()[this._rtl()?"right":"left"]:-this._getCanvasMargins().top),a},_updateContainers:function(b,c,d,e){function f(){var b=a.document.createElement("div");return b.className=w._containerClass,b}function g(b,c,d){c+d>n&&(d=n-c);var e,f,g=b.itemsContainer,h=g.itemsBlocks,i=h.length?h[h.length-1]:null,j=h.length?(h.length-1)*m._view._blockSize+i.items.length:0,k=d-j;if(k>0){if(i&&i.items.length",l)),e=i.items.length,f=i.element.children;for(var o=0;l>o;o++)i.items.push(f[e+o]);k-=l}var p=Math.floor(k/m._view._blockSize),q=k%m._view._blockSize,u="
"+C._repeat("
",m._view._blockSize)+"
",v=C._repeat(u,p);q&&(v+="
"+C._repeat("
",q)+"
",p++);var w=a.document.createElement("div");s.setInnerHTMLUnsafe(w,v);for(var f=w.children,o=0;p>o;o++){var x=f[o],y={element:x,items:C._nodeListToArray(x.children)};g.itemsBlocks.push(y)}}else if(0>k)for(var z=k;0>z;z++){var A=i.items.pop();!m._view._requireFocusRestore&&A.contains(a.document.activeElement)&&(m._view._requireFocusRestore=a.document.activeElement,m._unsetFocusOnItem()),i.element.removeChild(A),t.push(A),i.items.length||(g.element===i.element.parentNode&&g.element.removeChild(i.element),h.pop(),i=h[h.length-1])}for(var o=0,B=h.length;B>o;o++)for(var x=h[o],z=0;z=b&&a.newIndexh;h++){var j=d[h],k=j.newIndex-b,l=f(),m=kn&&(c=n-b);var d=a.itemsContainer,e=c-d.items.length;if(e>0){var f=d.element.children,g=f.length;s.insertAdjacentHTMLUnsafe(d.element,"beforeend",C._repeat("
",e));for(var h=0;e>h;h++){var i=f[g+h];d.items.push(i)}}for(var h=e;0>h;h++){var i=d.items.pop();d.element.removeChild(i),t.push(i)}for(var h=0,j=d.items.length;j>h;h++)r.push(d.items[h])}function j(a,b){var c=m._view._createHeaderContainer(G),d={header:c,itemsContainer:{element:m._view._createItemsContainer(c)}};return d.itemsContainer[m._view._blockSize?"itemsBlocks":"items"]=[],m._view._blockSize?g(d,b,a.size):i(d,b,a.size),d}function k(a,b,d,f){for(var g,h,i=d+f-1,j=0,k=e.length;k>j;j++){var l=e[j];l.newIndex>=d&&l.newIndex<=i&&-1!==l.oldIndex&&(g!==+g||l.newIndexj;j++){var l=e[j];l.newIndex>=d&&l.newIndexj;j++){var l=e[j];l.oldIndex>=b&&l.oldIndex0){var r=q.element.children;s.insertAdjacentHTMLUnsafe(q.element,"afterBegin",C._repeat("
",h));for(var t=0;h>t;t++){var u=r[t];q.items.splice(t,0,u)}}for(var t=h;0>t;t++){var u=q.items.shift();q.element.removeChild(u)}h&&m._affectedRange.add({start:d,end:d+f},c)}}function l(a){for(var b=0,c=0,d=m._view.tree.length;d>c;c++){var e=m._view.tree[c],f=e.itemsContainer.items.length,g=b+f-1;if(a>=b&&g>=a)return{group:c,item:a-b};b+=f}}var m=this,n=this._view.containers.length+(d>0?d:0),o=[],q={},r=[],t=[],u=[],v=0;if(!m._view._blockSize)for(var x=0,y=this._view.tree.length;y>x;x++)u.push(v),v+=this._view.tree[x].itemsContainer.items.length;if(!m._view._blockSize)for(var z=e.filter(function(a){return-1===a.newIndex&&!a._removalHandled}).sort(function(a,b){return b.oldIndex-a.oldIndex}),x=0,y=z.length;y>x;x++){var A=z[x];A._removalHandled=!0;var B=A._itemBox;A._itemBox=null;var D=l(A.oldIndex),E=this._view.tree[D.group],F=E.itemsContainer.items[D.item];F.parentNode.removeChild(F),p.hasClass(B,w._selectedClass)&&p.addClass(F,w._selectedClass),E.itemsContainer.items.splice(D.item,1),A.element=F}this._view._modifiedGroups=[];var G=this._canvasProxy;v=0;for(var x=0,y=b.length;y>x&&(!this._groupsEnabled()||n>v);x++){var H=b[x],I=this._view.keyToGroupIndex[H.key],J=this._view.tree[I];if(J)m._view._blockSize?g(J,v,H.size):(k(J,u[I],v,H.size),h(J,v,H.size),i(J,v,H.size)),o.push(J),q[H.key]=o.length-1,delete this._view.keyToGroupIndex[H.key],G=J.itemsContainer.element,this._view._modifiedGroups.push({oldIndex:I,newIndex:o.length-1,element:J.header});else{var K=j(H,v);o.push(K),q[H.key]=o.length-1,this._view._modifiedGroups.push({oldIndex:-1,newIndex:o.length-1,element:K.header}),G=K.itemsContainer.element}v+=H.size}for(var L=[],M=[],N=this._view.keyToGroupIndex?Object.keys(this._view.keyToGroupIndex):[],x=0,y=N.length;y>x;x++){var D=this._view.keyToGroupIndex[N[x]],O=this._view.tree[D];if(M.push(O.header),L.push(O.itemsContainer.element),this._view._blockSize)for(var P=0;Px;x++)if(-1===e[x].newIndex&&!e[x]._removalHandled){e[x]._removalHandled=!0;var B=e[x]._itemBox;e[x]._itemBox=null;var F;t.length?(F=t.pop(),p.empty(F)):F=f(),p.hasClass(B,w._selectedClass)&&p.addClass(F,w._selectedClass),F.appendChild(B),e[x].element=F}return this._view.tree=o,this._view.keyToGroupIndex=q,this._view.containers=r,{removedHeaders:M,removedItemsContainers:L}},_writeProfilerMark:function(a){var b="WinJS.UI.ListView:"+this._id+":"+a;h(b),f.log&&f.log(b,null,"listviewprofiler")}},{triggerDispose:function(){H()}});return b.Class.mix(D,e.createEventProperties("iteminvoked","groupheaderinvoked","selectionchanging","selectionchanged","loadingstatechanged","keyboardnavigating","contentanimating","itemdragstart","itemdragenter","itemdragend","itemdragbetween","itemdragleave","itemdragchanged","itemdragdrop","accessibilityannotationcomplete")),b.Class.mix(D,n.DOMEventMixin),D})})}),define("WinJS/Controls/FlipView/_Constants",[],function(){"use strict";var a={};return a.datasourceCountChangedEvent="datasourcecountchanged",a.pageVisibilityChangedEvent="pagevisibilitychanged",a.pageSelectedEvent="pageselected",a.pageCompletedEvent="pagecompleted",a}),define("WinJS/Controls/FlipView/_PageManager",["exports","../../Core/_Global","../../Core/_Base","../../Core/_BaseUtils","../../Core/_ErrorFromName","../../Core/_Log","../../Core/_Resources","../../Core/_WriteProfilerMark","../../Animations","../../Promise","../../_Signal","../../Scheduler","../../Utilities/_Dispose","../../Utilities/_ElementUtilities","../../Utilities/_TabContainer","./_Constants"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{_FlipPageManager:c.Namespace._lazy(function(){function a(a){var b=a.winControl;return b&&b._isFlipView?!0:!1}function g(a){a.forEach(function(a){var c=a.target;c.winControl&&c.tabIndex>=0&&(c.winControl._pageManager._updateTabIndex(c.tabIndex),c.tabIndex=-1);var d=c.winControl;if(d&&d._isFlipView){var e=!1;"dir"===a.attributeName?e=!0:"style"===a.attributeName&&(e=d._cachedStyleDir!==c.style.direction),e&&(d._cachedStyleDir=c.style.direction,d._pageManager._rtl="rtl"===b.getComputedStyle(d._pageManager._flipperDiv,null).direction,d._pageManager.resized())}})}var q=n._uniqueID,r=d._browserStyleEquivalents,s=50,t=250,u={get badCurrentPage(){return"Invalid argument: currentPage must be a number greater than or equal to zero and be within the bounds of the datasource"}},v=c.Class.define(function(a,c,e,f,h,i,j){this._visibleElements=[],this._flipperDiv=a,this._panningDiv=c,this._panningDivContainer=e,this._buttonVisibilityHandler=j,this._currentPage=null,this._rtl="rtl"===b.getComputedStyle(this._flipperDiv,null).direction,this._itemsManager=f,this._itemSpacing=h,this._tabIndex=n.getTabIndex(a),this._tabIndex<0&&(this._tabIndex=0),c.tabIndex=-1,a.tabIndex=-1,this._tabManager=new o.TabContainer(this._panningDivContainer),this._tabManager.tabIndex=this._tabIndex,this._lastSelectedPage=null,this._lastSelectedElement=null,this._bufferSize=v.flipPageBufferCount,this._cachedSize=-1,this._environmentSupportsTouch=i; +var k=this;this._panningDiv.addEventListener("keydown",function(a){k._blockTabs&&a.keyCode===n.Key.tab&&(a.stopImmediatePropagation(),a.preventDefault())},!0),n._addEventListener(this._flipperDiv,"focusin",function(a){a.target===k._flipperDiv&&k._currentPage.element&&n._setActive(k._currentPage.element)},!1),new n._MutationObserver(g).observe(this._flipperDiv,{attributes:!0,attributeFilter:["dir","style","tabindex"]}),this._cachedStyleDir=this._flipperDiv.style.direction,this._handleManipulationStateChangedBound=this._handleManipulationStateChanged.bind(this),this._environmentSupportsTouch&&this._panningDivContainer.addEventListener(d._browserEventEquivalents.manipulationStateChanged,this._handleManipulationStateChangedBound,!0)},{initialize:function(a,c){var d=null;if(this._panningDivContainerOffsetWidth=this._panningDivContainer.offsetWidth,this._panningDivContainerOffsetHeight=this._panningDivContainer.offsetHeight,this._isHorizontal=c,!this._currentPage){this._bufferAriaStartMarker=b.document.createElement("div"),this._bufferAriaStartMarker.id=q(this._bufferAriaStartMarker),this._panningDiv.appendChild(this._bufferAriaStartMarker),this._currentPage=this._createFlipPage(null,this),d=this._currentPage,this._panningDiv.appendChild(d.pageRoot);for(var e=2*this._bufferSize,f=0;e>f;f++)d=this._createFlipPage(d,this),this._panningDiv.appendChild(d.pageRoot);this._bufferAriaEndMarker=b.document.createElement("div"),this._bufferAriaEndMarker.id=q(this._bufferAriaEndMarker),this._panningDiv.appendChild(this._bufferAriaEndMarker)}this._prevMarker=this._currentPage.prev.prev,this._itemsManager&&this.setNewItemsManager(this._itemsManager,a)},dispose:function(){var a=this._currentPage,b=a;do m._disposeElement(b.element),b=b.next;while(b!==a)},setOrientation:function(a){if(this._notificationsEndedSignal){var b=this;return void this._notificationsEndedSignal.promise.done(function(){b._notificationsEndedSignal=null,b.setOrientation(a)})}if(a!==this._isHorizontal){this._isOrientationChanging=!0,this._isHorizontal?n.setScrollPosition(this._panningDivContainer,{scrollLeft:this._getItemStart(this._currentPage),scrollTop:0}):n.setScrollPosition(this._panningDivContainer,{scrollLeft:0,scrollTop:this._getItemStart(this._currentPage)}),this._isHorizontal=a;var c=this._panningDivContainer.style;c.overflowX="hidden",c.overflowY="hidden";var b=this;d._requestAnimationFrame(function(){b._isOrientationChanging=!1,b._forEachPage(function(a){var b=a.pageRoot.style;b.left="0px",b.top="0px"}),c.overflowX=b._isHorizontal&&b._environmentSupportsTouch?"scroll":"hidden",c.overflowY=b._isHorizontal||!b._environmentSupportsTouch?"hidden":"scroll",b._ensureCentered()})}},resetState:function(a){if(this._writeProfilerMark("WinJS.UI.FlipView:resetState,info"),0!==a){var b=this.jumpToIndex(a,!0);if(!b&&d.validation)throw new e("WinJS.UI.FlipView.BadCurrentPage",u.badCurrentPage);return b}m.disposeSubTree(this._flipperDiv),this._resetBuffer(null,!0);var c=this,f=j.wrap(!0);return this._itemsManager&&(f=c._itemsManager._firstItem().then(function(a){return c._currentPage.setElement(a),c._fetchPreviousItems(!0).then(function(){return c._fetchNextItems()}).then(function(){c._setButtonStates()})})),f.then(function(){c._tabManager.childFocus=c._currentPage.element,c._ensureCentered(),c._itemSettledOn()})},setNewItemsManager:function(a,b){this._itemsManager=a;var c=this;return this.resetState(b).then(function(){0!==b&&(c._tabManager.childFocus=c._currentPage.element,c._ensureCentered(),c._itemSettledOn())})},currentIndex:function(){if(!this._itemsManager)return 0;var a=0,b=this._navigationAnimationRecord?this._navigationAnimationRecord.newCurrentElement:this._currentPage.element;return b&&(a=this._getElementIndex(b)),a},resetScrollPos:function(){this._ensureCentered()},scrollPosChanged:function(){if(this._hasFocus&&(this._hadFocus=!0),this._itemsManager&&this._currentPage.element&&!this._isOrientationChanging){var a=this._getViewportStart(),b=this._lastScrollPos>a?this._getTailOfBuffer():this._getHeadOfBuffer();if(a!==this._lastScrollPos){for(;this._currentPage.element&&this._getItemStart(this._currentPage)>a&&this._currentPage.prev.element;)this._currentPage=this._currentPage.prev,this._fetchOnePrevious(b.prev),b=b.prev;for(;this._currentPage.element&&this._itemEnd(this._currentPage)<=a&&this._currentPage.next.element;)this._currentPage=this._currentPage.next,this._fetchOneNext(b.next),b=b.next;this._setButtonStates(),this._checkElementVisibility(!1),this._blockTabs=!0,this._lastScrollPos=a,this._currentPage.element&&(this._tabManager.childFocus=this._currentPage.element),this._setListEnds(),!this._manipulationState&&this._viewportOnItemStart()&&(this._currentPage.element.setAttribute("aria-setsize",this._cachedSize),this._currentPage.element.setAttribute("aria-posinset",this.currentIndex()+1),this._timeoutPageSelection())}}},itemRetrieved:function(a,b){var c=this;if(this._forEachPage(function(d){return d.element===b?(d===c._currentPage||d===c._currentPage.next?c._changeFlipPage(d,b,a):d.setElement(a,!0),!0):void 0}),this._navigationAnimationRecord&&this._navigationAnimationRecord.elementContainers)for(var d=this._navigationAnimationRecord.elementContainers,e=0,f=d.length;f>e;e++)d[e].element===b&&(c._changeFlipPage(d[e],b,a),d[e].element=a);this._checkElementVisibility(!1)},resized:function(){this._panningDivContainerOffsetWidth=this._panningDivContainer.offsetWidth,this._panningDivContainerOffsetHeight=this._panningDivContainer.offsetHeight;var a=this;this._forEachPage(function(b){b.pageRoot.style.width=a._panningDivContainerOffsetWidth+"px",b.pageRoot.style.height=a._panningDivContainerOffsetHeight+"px"}),this._ensureCentered(),this._writeProfilerMark("WinJS.UI.FlipView:resize,StopTM")},jumpToIndex:function(a,b){if(!b){if(!this._itemsManager||!this._currentPage.element||0>a)return j.wrap(!1);var c=this._getElementIndex(this._currentPage.element),d=Math.abs(a-c);if(0===d)return j.wrap(!1)}var e=j.wrap(!0),f=this;return e=e.then(function(){var c=f._itemsManager._itemPromiseAtIndex(a);return j.join({element:f._itemsManager._itemFromItemPromise(c),item:c}).then(function(a){var c=a.element;return f._resetBuffer(c,b),c?(f._currentPage.setElement(c),f._fetchNextItems().then(function(){return f._fetchPreviousItems(!0)}).then(function(){return!0})):!1})}),e=e.then(function(a){return f._setButtonStates(),a})},startAnimatedNavigation:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:startAnimatedNavigation,info"),this._currentPage.element){var d=this._currentPage,e=a?this._currentPage.next:this._currentPage.prev;if(e.element){this._hasFocus&&n._setActive(this._panningDiv),this._navigationAnimationRecord={},this._navigationAnimationRecord.goForward=a,this._navigationAnimationRecord.cancelAnimationCallback=b,this._navigationAnimationRecord.completionCallback=c,this._navigationAnimationRecord.oldCurrentPage=d,this._navigationAnimationRecord.newCurrentPage=e;var f=d.element,g=e.element;this._navigationAnimationRecord.newCurrentElement=g,d.setElement(null,!0),d.elementUniqueID=q(f),e.setElement(null,!0),e.elementUniqueID=q(g);var h=this._createDiscardablePage(f),i=this._createDiscardablePage(g);return h.pageRoot.itemIndex=this._getElementIndex(f),i.pageRoot.itemIndex=h.pageRoot.itemIndex+(a?1:-1),h.pageRoot.style.position="absolute",i.pageRoot.style.position="absolute",h.pageRoot.style.zIndex=1,i.pageRoot.style.zIndex=2,this._setItemStart(h,0),this._setItemStart(i,0),this._blockTabs=!0,this._visibleElements.push(g),this._announceElementVisible(g),this._navigationAnimationRecord.elementContainers=[h,i],{outgoing:h,incoming:i}}}return null},endAnimatedNavigation:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:endAnimatedNavigation,info"),this._navigationAnimationRecord&&this._navigationAnimationRecord.oldCurrentPage&&this._navigationAnimationRecord.newCurrentPage){var d=this._restoreAnimatedElement(this._navigationAnimationRecord.oldCurrentPage,b);this._restoreAnimatedElement(this._navigationAnimationRecord.newCurrentPage,c),d||this._setViewportStart(this._getItemStart(a?this._currentPage.next:this._currentPage.prev)),this._navigationAnimationRecord=null,this._itemSettledOn()}},startAnimatedJump:function(a,b,c){if(this._writeProfilerMark("WinJS.UI.FlipView:startAnimatedJump,info"),this._hasFocus&&(this._hadFocus=!0),this._currentPage.element){var d=this._currentPage.element,e=this._getElementIndex(d),f=this;return f.jumpToIndex(a).then(function(g){if(!g)return null;if(f._navigationAnimationRecord={},f._navigationAnimationRecord.cancelAnimationCallback=b,f._navigationAnimationRecord.completionCallback=c,f._navigationAnimationRecord.oldCurrentPage=null,f._forEachPage(function(a){return a.element===d?(f._navigationAnimationRecord.oldCurrentPage=a,!0):void 0}),f._navigationAnimationRecord.newCurrentPage=f._currentPage,f._navigationAnimationRecord.newCurrentPage===f._navigationAnimationRecord.oldCurrentPage)return null;var h=f._currentPage.element;f._navigationAnimationRecord.newCurrentElement=h,f._currentPage.setElement(null,!0),f._currentPage.elementUniqueID=q(h),f._navigationAnimationRecord.oldCurrentPage&&f._navigationAnimationRecord.oldCurrentPage.setElement(null,!0);var i=f._createDiscardablePage(d),j=f._createDiscardablePage(h);return i.pageRoot.itemIndex=e,j.pageRoot.itemIndex=a,i.pageRoot.style.position="absolute",j.pageRoot.style.position="absolute",i.pageRoot.style.zIndex=1,j.pageRoot.style.zIndex=2,f._setItemStart(i,0),f._setItemStart(j,f._itemSize(f._currentPage)),f._visibleElements.push(h),f._announceElementVisible(h),f._navigationAnimationRecord.elementContainers=[i,j],f._blockTabs=!0,{oldPage:i,newPage:j}})}return j.wrap(null)},simulateMouseWheelScroll:function(a){if(!this._environmentSupportsTouch&&!this._waitingForMouseScroll){var c;c="number"==typeof a.deltaY?(a.deltaX||a.deltaY)>0:a.wheelDelta<0;var d=c?this._currentPage.next:this._currentPage.prev;if(d.element){var e={contentX:0,contentY:0,viewportX:0,viewportY:0};e[this._isHorizontal?"contentX":"contentY"]=this._getItemStart(d),n._zoomTo(this._panningDivContainer,e),this._waitingForMouseScroll=!0,b.setTimeout(function(){this._waitingForMouseScroll=!1}.bind(this),n._zoomToDuration+100)}}},endAnimatedJump:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:endAnimatedJump,info"),this._navigationAnimationRecord.oldCurrentPage?this._navigationAnimationRecord.oldCurrentPage.setElement(a.element,!0):a.element.parentNode&&a.element.parentNode.removeChild(a.element),this._navigationAnimationRecord.newCurrentPage.setElement(b.element,!0),this._navigationAnimationRecord=null,this._ensureCentered(),this._itemSettledOn()},inserted:function(a,b,c,d){this._writeProfilerMark("WinJS.UI.FlipView:inserted,info");var e=this._prevMarker,f=!1,g=!1;if(d&&(this._createAnimationRecord(q(a),null),this._getAnimationRecord(a).inserted=!0),b){do{if(e===this._currentPage&&(f=!0),e.elementUniqueID===q(b)){g=!0;var h,i=e,j=a,k=q(a);if(f)for(;i.next!==this._prevMarker;)h=i.next.element,k=i.next.elementUniqueID,i.next.setElement(j,!0),!j&&k&&(i.next.elementUniqueID=k),j=h,i=i.next;else for(e.elementUniqueID===e.next.elementUniqueID&&e.elementUniqueID&&(i=e.next);i.next!==this._prevMarker;)h=i.element,k=i.elementUniqueID,i.setElement(j,!0),!j&&k&&(i.elementUniqueID=k),j=h,i=i.prev;if(j){var l=!1;this._forEachPage(function(a){return q(j)===a.elementUniqueID?(l=!0,!0):void 0}),l||this._releaseElementIfNotAnimated(j)}break}e=e.next}while(e!==this._prevMarker)}else if(c){for(;e.next!==this._prevMarker&&e.elementUniqueID!==q(c);)e===this._currentPage&&(f=!0),e=e.next;e.elementUniqueID===q(c)&&e!==this._prevMarker?(e.prev.setElement(a),g=!0):this._releaseElementIfNotAnimated(a)}else this._currentPage.setElement(a);this._getAnimationRecord(a).successfullyMoved=g,this._setButtonStates()},changed:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:changed,info");var c=this;if(this._forEachPage(function(d){if(d.elementUniqueID===q(b)){var e=c._animationRecords[d.elementUniqueID];return e.changed=!0,e.oldElement=b,e.newElement=a,d.element=a,d.elementUniqueID=q(a),c._animationRecords[q(a)]=e,!0}}),this._navigationAnimationRecord&&this._navigationAnimationRecord.elementContainers){for(var d=0,e=this._navigationAnimationRecord.elementContainers.length;e>d;d++){var f=this._navigationAnimationRecord.elementContainers[d];f&&f.elementUniqueID===q(b)&&(f.element=a,f.elementUniqueID=q(a))}var g=this._navigationAnimationRecord.newCurrentElement;g&&q(g)===q(b)&&(this._navigationAnimationRecord.newCurrentElement=a)}},moved:function(a,b,c){this._writeProfilerMark("WinJS.UI.FlipView:moved,info");var d=this._getAnimationRecord(a);d||(d=this._createAnimationRecord(q(a))),d.moved=!0,this.removed(a,!1,!1),b||c?this.inserted(a,b,c,!1):d.successfullyMoved=!1},removed:function(a,b,c){this._writeProfilerMark("WinJS.UI.FlipView:removed,info");var d=this,e=this._prevMarker,f=j.wrap();if(b){var g=!1;return this._forEachPage(function(b){(b.elementUniqueID===q(a)||g)&&(b.setElement(null,!0),g=!0)}),void this._setButtonStates()}if(c){var h=this._getAnimationRecord(a);h&&(h.removed=!0)}if(this._currentPage.elementUniqueID===q(a))this._currentPage.next.elementUniqueID?(this._shiftLeft(this._currentPage),this._ensureCentered()):this._currentPage.prev.elementUniqueID?this._shiftRight(this._currentPage):this._currentPage.setElement(null,!0);else if(e.elementUniqueID===q(a))e.next.element?f=this._itemsManager._previousItem(e.next.element).then(function(b){return b===a&&(b=d._itemsManager._previousItem(b)),b}).then(function(a){e.setElement(a,!0)}):e.setElement(null,!0);else if(e.prev.elementUniqueID===q(a))e.prev.prev&&e.prev.prev.element?f=this._itemsManager._nextItem(e.prev.prev.element).then(function(b){return b===a&&(b=d._itemsManager._nextItem(b)),b}).then(function(a){e.prev.setElement(a,!0)}):e.prev.setElement(null,!0);else{for(var i=this._currentPage.prev,k=!1;i!==e&&!k;)i.elementUniqueID===q(a)&&(this._shiftRight(i),k=!0),i=i.prev;for(i=this._currentPage.next;i!==e&&!k;)i.elementUniqueID===q(a)&&(this._shiftLeft(i),k=!0),i=i.next}return f.then(function(){d._setButtonStates()})},reload:function(){this._writeProfilerMark("WinJS.UI.FlipView:reload,info"),this.resetState(0)},getItemSpacing:function(){return this._itemSpacing},setItemSpacing:function(a){this._itemSpacing=a,this._ensureCentered()},notificationsStarted:function(){this._writeProfilerMark("WinJS.UI.FlipView:changeNotifications,StartTM"),this._logBuffer(),this._notificationsStarted=this._notificationsStarted||0,this._notificationsStarted++,this._notificationsEndedSignal=new k,this._temporaryKeys=[],this._animationRecords={};var a=this;this._forEachPage(function(b){a._createAnimationRecord(b.elementUniqueID,b)}),this._animationRecords.currentPage=this._currentPage.element,this._animationRecords.nextPage=this._currentPage.next.element},notificationsEnded:function(){var a=this;this._endNotificationsWork&&this._endNotificationsWork.cancel(),this._endNotificationsWork=this._ensureBufferConsistency().then(function(){function b(b){var c=null;return a._forEachPage(function(a){return a.element===b?(c=a,!0):void 0}),c}function c(b,c){a._writeProfilerMark("WinJS.UI.FlipView:_animateOldViewportItemRemoved,info");var d=a._createDiscardablePage(c);a._setItemStart(d,b.originalLocation),f.push(a._deleteFlipPage(d))}function d(c,d){a._writeProfilerMark("WinJS.UI.FlipView:_animateOldViewportItemMoved,info");var e,g=c.originalLocation;if(c.successfullyMoved)e=b(d),g=c.newLocation;else{e=a._createDiscardablePage(d);var h=a._getElementIndex(d),i=a._currentPage.element?a._getElementIndex(a._currentPage.element):0;g+=i>h?-100*a._bufferSize:100*a._bufferSize}e&&(a._setItemStart(e,c.originalLocation),f.push(a._moveFlipPage(e,function(){a._setItemStart(e,g)})))}function e(){return 0===f.length&&f.push(j.wrap()),j.join(f)}var f=[];a._forEachPage(function(b){var c=a._getAnimationRecord(b.element);c&&(c.changed&&(c.oldElement.removedFromChange=!0,f.push(a._changeFlipPage(b,c.oldElement,c.newElement))),c.newLocation=b.location,a._setItemStart(b,c.originalLocation),c.inserted&&(b.elementRoot.style.opacity=0))});var g=a._animationRecords.currentPage,h=a._getAnimationRecord(g),i=a._animationRecords.nextPage,k=a._getAnimationRecord(i);h&&h.changed&&(g=h.newElement),k&&k.changed&&(i=k.newElement),(g!==a._currentPage.element||i!==a._currentPage.next.element)&&(h&&h.removed&&c(h,g),k&&k.removed&&c(k,i)),a._blockTabs=!0,e().then(function(){f=[],h&&h.moved&&d(h,g),k&&k.moved&&d(k,i);var b=a._getAnimationRecord(a._currentPage.element),c=a._getAnimationRecord(a._currentPage.next.element);a._forEachPage(function(d){var e=a._getAnimationRecord(d.element);e&&(e.inserted?e!==b&&e!==c&&(d.elementRoot.style.opacity=1):e.originalLocation!==e.newLocation&&(e!==h&&e!==k||e===h&&!h.moved||e===k&&!k.moved)&&f.push(a._moveFlipPage(d,function(){a._setItemStart(d,e.newLocation)})))}),e().then(function(){f=[],b&&b.inserted&&f.push(a._insertFlipPage(a._currentPage)),c&&c.inserted&&f.push(a._insertFlipPage(a._currentPage.next)),e().then(function(){a._checkElementVisibility(!1),a._itemSettledOn(),a._setListEnds(),a._notificationsStarted--,0===a._notificationsStarted&&a._notificationsEndedSignal.complete(),a._writeProfilerMark("WinJS.UI.FlipView:changeNotifications,StopTM"),a._logBuffer(),a._endNotificationsWork=null})})})})},disableTouchFeatures:function(){this._environmentSupportsTouch=!1;var a=this._panningDivContainer.style;this._panningDivContainer.removeEventListener(d._browserEventEquivalents.manipulationStateChanged,this._handleManipulationStateChangedBound,!0),a.overflowX="hidden",a.overflowY="hidden";var b=["scroll-snap-type","scroll-snap-points-x","scroll-snap-points-y","scroll-limit-x-min","scroll-limit-x-max","scroll-limit-y-min","scroll-limit-y-max"];b.forEach(function(b){var c=r[b];c&&(a[c.scriptName]="")})},_hasFocus:{get:function(){return this._flipperDiv.contains(b.document.activeElement)}},_timeoutPageSelection:function(){var a=this;this._lastTimeoutRequest&&this._lastTimeoutRequest.cancel(),this._lastTimeoutRequest=j.timeout(t).then(function(){a._itemSettledOn()})},_updateTabIndex:function(a){this._forEachPage(function(b){b.element&&(b.element.tabIndex=a)}),this._tabIndex=a,this._tabManager.tabIndex=a},_releaseElementIfNotAnimated:function(a){var b=this._getAnimationRecord(a);b&&(b.changed||b.inserted||b.moved||b.removed)||this._itemsManager.releaseItem(a)},_getAnimationRecord:function(a){return a?this._animationRecords[q(a)]:null},_createAnimationRecord:function(a,b){if(a){var c=this._animationRecords[a]={removed:!1,changed:!1,inserted:!1};return b&&(c.originalLocation=b.location),c}},_writeProfilerMark:function(a){h(a),this._flipperDiv.winControl.constructor._enabledDebug&&f.log&&f.log(a,null,"flipviewdebug")},_getElementIndex:function(a){var b=0;try{b=this._itemsManager.itemObject(a).index}catch(c){}return b},_resetBuffer:function(a,b){this._writeProfilerMark("WinJS.UI.FlipView:_resetBuffer,info");var c=this._currentPage,d=c;do d.element&&d.element===a||b?d.setElement(null,!0):d.setElement(null),d=d.next;while(d!==c)},_getHeadOfBuffer:function(){return this._prevMarker.prev},_getTailOfBuffer:function(){return this._prevMarker},_insertNewFlipPage:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_insertNewFlipPage,info");var b=this._createFlipPage(a,this);return this._panningDiv.appendChild(b.pageRoot),b},_fetchNextItems:function(){this._writeProfilerMark("WinJS.UI.FlipView:_fetchNextItems,info");for(var a=j.wrap(this._currentPage),b=this,c=0;c0){if(e[a.location])return c=!0,!0;e[a.location]=!0}}});var f=Object.keys(this._animationRecords);return f.forEach(function(b){var d=a._animationRecords[b];d&&(d.changed||d.inserted||d.moved||d.removed)&&(c=!0)}),c?(this._resetBuffer(null,!0),this._currentPage.setElement(b),this._fetchNextItems().then(function(){return a._fetchPreviousItems(!0)}).then(function(){a._ensureCentered()})):j.wrap()},_shiftLeft:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_shiftLeft,info");for(var b=a,c=null;b!==this._prevMarker&&b.next!==this._prevMarker;)c=b.next.element,!c&&b.next.elementUniqueID&&(b.elementUniqueID=b.next.elementUniqueID),b.next.setElement(null,!0),b.setElement(c,!0),b=b.next;if(b!==this._prevMarker&&b.prev.element){var d=this;return this._itemsManager._nextItem(b.prev.element).then(function(a){b.setElement(a),d._createAnimationRecord(b.elementUniqueID,b)})}},_logBuffer:function(){if(this._flipperDiv.winControl.constructor._enabledDebug){f.log&&f.log(this._currentPage.next.next.next.elementUniqueID+" @:"+this._currentPage.next.next.next.location+(this._currentPage.next.next.next.element?" "+this._currentPage.next.next.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.next.next.next.elementUniqueID+" @:"+this._currentPage.next.next.next.next.location+(this._currentPage.next.next.next.next.element?" "+this._currentPage.next.next.next.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log("> "+this._currentPage.elementUniqueID+" @:"+this._currentPage.location+(this._currentPage.element?" "+this._currentPage.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.elementUniqueID+" @:"+this._currentPage.next.location+(this._currentPage.next.element?" "+this._currentPage.next.element.textContent:""),null,"flipviewdebug"),f.log&&f.log(this._currentPage.next.next.elementUniqueID+" @:"+this._currentPage.next.next.location+(this._currentPage.next.next.element?" "+this._currentPage.next.next.element.textContent:""),null,"flipviewdebug");var a=Object.keys(this._itemsManager._elementMap),b=[];this._forEachPage(function(a){a&&a.elementUniqueID&&b.push(a.elementUniqueID)}),f.log&&f.log("itemsmanager = ["+a.join(" ")+"] flipview ["+b.join(" ")+"]",null,"flipviewdebug")}},_shiftRight:function(a){this._writeProfilerMark("WinJS.UI.FlipView:_shiftRight,info");for(var b=a,c=null;b!==this._prevMarker;)c=b.prev.element,!c&&b.prev.elementUniqueID&&(b.elementUniqueID=b.prev.elementUniqueID),b.prev.setElement(null,!0),b.setElement(c,!0),b=b.prev;if(b.next.element){var d=this;return this._itemsManager._previousItem(b.next.element).then(function(a){b.setElement(a),d._createAnimationRecord(b.elementUniqueID,b)})}},_checkElementVisibility:function(a){var b,c;if(a){var d=this._currentPage.element;for(b=0,c=this._visibleElements.length;c>b;b++)this._visibleElements[b]!==d&&this._announceElementInvisible(this._visibleElements[b]);this._visibleElements=[],d&&(this._visibleElements.push(d),this._announceElementVisible(d))}else{for(b=0,c=this._visibleElements.length;c>b;b++)(!this._visibleElements[b].parentNode||this._visibleElements[b].removedFromChange)&&this._announceElementInvisible(this._visibleElements[b]);this._visibleElements=[];var e=this;this._forEachPage(function(a){var b=a.element;b&&(e._itemInView(a)?(e._visibleElements.push(b),e._announceElementVisible(b)):e._announceElementInvisible(b))})}},_announceElementVisible:function(a){if(a&&!a.visible){a.visible=!0;var c=b.document.createEvent("CustomEvent");this._writeProfilerMark("WinJS.UI.FlipView:pageVisibilityChangedEvent(visible:true),info"),c.initCustomEvent(p.pageVisibilityChangedEvent,!0,!1,{source:this._flipperDiv,visible:!0}),a.dispatchEvent(c)}},_announceElementInvisible:function(a){if(a&&a.visible){a.visible=!1;var c=!1;a.parentNode||(c=!0,this._panningDivContainer.appendChild(a));var d=b.document.createEvent("CustomEvent");this._writeProfilerMark("WinJS.UI.FlipView:pageVisibilityChangedEvent(visible:false),info"),d.initCustomEvent(p.pageVisibilityChangedEvent,!0,!1,{source:this._flipperDiv,visible:!1}),a.dispatchEvent(d),c&&this._panningDivContainer.removeChild(a)}},_createDiscardablePage:function(a){var b=this._createPageContainer(),c={pageRoot:b.root,elementRoot:b.elementContainer,discardable:!0,element:a,elementUniqueID:q(a),discard:function(){c.pageRoot.parentNode&&c.pageRoot.parentNode.removeChild(c.pageRoot),c.element.parentNode&&c.element.parentNode.removeChild(c.element)}};return c.pageRoot.style.top="0px",c.elementRoot.appendChild(a),this._panningDiv.appendChild(c.pageRoot),c},_createPageContainer:function(){var a=this._panningDivContainerOffsetWidth,c=this._panningDivContainerOffsetHeight,d=b.document.createElement("div"),e=d.style,f=b.document.createElement("div");return f.className="win-item",e.position="absolute",e.overflow="hidden",e.width=a+"px",e.height=c+"px",d.appendChild(f),{root:d,elementContainer:f}},_createFlipPage:function(b,c){var d={};d.element=null,d.elementUniqueID=null,b?(d.prev=b,d.next=b.next,d.next.prev=d,b.next=d):(d.next=d,d.prev=d);var e=this._createPageContainer();return d.elementRoot=e.elementContainer,d.elementRoot.style.msOverflowStyle="auto",d.pageRoot=e.root,d.setElement=function(b,e){if(void 0===b&&(b=null),b===d.element)return void(b||(d.elementUniqueID=null));if(d.element&&(e||(c._itemsManager.releaseItem(d.element),m._disposeElement(d.element))),d.element=b,d.elementUniqueID=b?q(b):null,n.empty(d.elementRoot),d.element){if(d===c._currentPage&&(c._tabManager.childFocus=b),!a(d.element)){d.element.tabIndex=c._tabIndex,d.element.setAttribute("role","option"),d.element.setAttribute("aria-selected",!1),d.element.id||(d.element.id=q(d.element));var f=function(a,b,c){a.setAttribute(c,b.id)},g=!d.next.element||d===c._prevMarker.prev;g&&(f(d.element,c._bufferAriaEndMarker,"aria-flowto"),f(c._bufferAriaEndMarker,d.element,"x-ms-aria-flowfrom")),d!==c._prevMarker&&d.prev.element&&(f(d.prev.element,d.element,"aria-flowto"),f(d.element,d.prev.element,"x-ms-aria-flowfrom")),d.next!==c._prevMarker&&d.next.element&&(f(d.element,d.next.element,"aria-flowto"),f(d.next.element,d.element,"x-ms-aria-flowfrom")),d.prev.element||f(d.element,c._bufferAriaStartMarker,"x-ms-aria-flowfrom")}d.elementRoot.appendChild(d.element)}},d},_itemInView:function(a){return this._itemEnd(a)>this._getViewportStart()&&this._getItemStart(a)>0,h=0>h?0:h),c.itemDataSource&&(e=c.itemDataSource),c.itemTemplate&&(f=this._getItemRenderer(c.itemTemplate)),c.itemSpacing&&(i=c.itemSpacing>>0,i=0>i?0:i)}if(!e){var k=new j.List;e=k.dataSource}o.empty(b),this._flipviewDiv=b,b.winControl=this,m._setOptions(this,c,!0),this._initializeFlipView(b,d,e,f,h,i),o.addClass(b,"win-disposable"),this._avoidTrappingTime=0,this._windowWheelHandlerBound=this._windowWheelHandler.bind(this),o._globalListener.addEventListener(b,"wheel",this._windowWheelHandlerBound),o._globalListener.addEventListener(b,"mousewheel",this._windowWheelHandlerBound),g("WinJS.UI.FlipView:constructor,StopTM")},{dispose:function(){g("WinJS.UI.FlipView:dispose,StopTM"),this._disposed||(o._globalListener.removeEventListener(this._flipviewDiv,"wheel",this._windowWheelHandlerBound),o._globalListener.removeEventListener(this._flipviewDiv,"mousewheel",this._windowWheelHandlerBound),o._resizeNotifier.unsubscribe(this._flipviewDiv,u),this._disposed=!0,this._pageManager.dispose(),this._itemsManager.release(),this.itemDataSource=null)},next:function(){g("WinJS.UI.FlipView:next,info");var a=this._nextAnimation?null:this._cancelDefaultAnimation;return this._navigate(!0,a)},previous:function(){g("WinJS.UI.FlipView:prev,info");var a=this._prevAnimation?null:this._cancelDefaultAnimation;return this._navigate(!1,a)},element:{get:function(){return this._flipviewDiv}},currentPage:{get:function(){return this._getCurrentIndex()},set:function(a){if(g("WinJS.UI.FlipView:set_currentPage,info"),this._pageManager._notificationsEndedSignal){var b=this;return void this._pageManager._notificationsEndedSignal.promise.done(function(){b._pageManager._notificationsEndedSignal=null,b.currentPage=a})}if(!this._animating||this._cancelAnimation())if(a>>=0,a=0>a?0:a,this._refreshTimer)this._indexAfterRefresh=a;else{this._pageManager._cachedSize>0?a=Math.min(this._pageManager._cachedSize-1,a):0===this._pageManager._cachedSize&&(a=0);var b=this;if(this._jumpingToIndex===a)return;var c=function(){b._jumpingToIndex=null};this._jumpingToIndex=a;var d=this._jumpAnimation?this._jumpAnimation:this._defaultAnimation.bind(this),e=this._jumpAnimation?null:this._cancelDefaultAnimation,f=function(){b._completeJump()};this._pageManager.startAnimatedJump(a,e,f).then(function(a){if(a){b._animationsStarted();var e=a.oldPage.pageRoot,h=a.newPage.pageRoot;b._contentDiv.appendChild(e),b._contentDiv.appendChild(h),b._completeJumpPending=!0,d(e,h).then(function(){b._completeJumpPending&&(f(),g("WinJS.UI.FlipView:set_currentPage.animationComplete,info"))}).done(c,c)}else c()},c)}}},orientation:{get:function(){return this._axisAsString()},set:function(a){g("WinJS.UI.FlipView:set_orientation,info");var b="horizontal"===a;b!==this._isHorizontal&&(this._isHorizontal=b,this._setupOrientation(),this._pageManager.setOrientation(this._isHorizontal))}},itemDataSource:{get:function(){return this._dataSource},set:function(a){g("WinJS.UI.FlipView:set_itemDataSource,info"),this._dataSourceAfterRefresh=a||(new j.List).dataSource,this._refresh()}},itemTemplate:{get:function(){return this._itemRenderer},set:function(a){g("WinJS.UI.FlipView:set_itemTemplate,info"),this._itemRendererAfterRefresh=this._getItemRenderer(a),this._refresh()}},itemSpacing:{get:function(){return this._pageManager.getItemSpacing()},set:function(a){g("WinJS.UI.FlipView:set_itemSpacing,info"),a>>=0,a=0>a?0:a,this._pageManager.setItemSpacing(a)}},count:function(){g("WinJS.UI.FlipView:count,info");var a=this;return new k(function(b,c){a._itemsManager?a._pageManager._cachedSize===r.CountResult.unknown||a._pageManager._cachedSize>=0?b(a._pageManager._cachedSize):a._dataSource.getCount().then(function(c){a._pageManager._cachedSize=c,b(c)}):c(L.noitemsManagerForCount)})},setCustomAnimations:function(a){g("WinJS.UI.FlipView:setCustomAnimations,info"),void 0!==a.next&&(this._nextAnimation=a.next),void 0!==a.previous&&(this._prevAnimation=a.previous),void 0!==a.jump&&(this._jumpAnimation=a.jump)},forceLayout:function(){g("WinJS.UI.FlipView:forceLayout,info"),this._pageManager.resized()},_initializeFlipView:function(b,d,e,f,g,h){function i(a){a.setAttribute("aria-hidden",!0),a.style.visibility="hidden",a.style.opacity=0,a.tabIndex=-1,a.style.zIndex=1e3}function j(a){if(a.pointerType!==D){if(m._touchInteraction=!1,a.screenX===m._lastMouseX&&a.screenY===m._lastMouseY)return;m._lastMouseX=a.screenX,m._lastMouseY=a.screenY,m._mouseInViewport=!0,m._fadeInButton("prev"),m._fadeInButton("next"),m._fadeOutButtons()}}function k(a){a.pointerType===D?(m._mouseInViewport=!1,m._touchInteraction=!0,m._fadeOutButtons(!0)):(m._touchInteraction=!1,m._isInteractive(a.target)||0!==(4&a.buttons)&&(a.stopPropagation(),a.preventDefault()))}function l(a){a.pointerType!==D&&(m._touchInteraction=!1)}var m=this,n=!1;this._flipviewDiv=b,o.addClass(this._flipviewDiv,w),this._contentDiv=a.document.createElement("div"),this._panningDivContainer=a.document.createElement("div"),this._panningDivContainer.className="win-surface",this._panningDiv=a.document.createElement("div"),this._prevButton=a.document.createElement("button"),this._nextButton=a.document.createElement("button"),this._isHorizontal=d,this._dataSource=e,this._itemRenderer=f,this._itemsManager=null,this._pageManager=null;for(var s=["scroll-limit-x-max","scroll-limit-x-min","scroll-limit-y-max","scroll-limit-y-min","scroll-snap-type","scroll-snap-x","scroll-snap-y","overflow-style"],v=!0,x=c._browserStyleEquivalents,y=0,z=s.length;z>y;y++)v=v&&!!x[s[y]];v=v&&!!c._browserEventEquivalents.manipulationStateChanged,v=v&&o._supportsSnapPoints,this._environmentSupportsTouch=v;var A=this._flipviewDiv.getAttribute("aria-label");A||this._flipviewDiv.setAttribute("aria-label",""),this._flipviewDiv.setAttribute("role","listbox"),this._flipviewDiv.style.overflow||(this._flipviewDiv.style.overflow="hidden"),this._contentDiv.style.position="relative",this._contentDiv.style.zIndex=0,this._contentDiv.style.width="100%",this._contentDiv.style.height="100%",this._panningDiv.style.position="relative",this._panningDivContainer.style.position="relative",this._panningDivContainer.style.width="100%",this._panningDivContainer.style.height="100%",this._panningDivContainer.setAttribute("role","group"),this._panningDivContainer.setAttribute("aria-label",K.panningContainerAriaLabel),this._contentDiv.appendChild(this._panningDivContainer),this._flipviewDiv.appendChild(this._contentDiv),this._panningDiv.style.width="100%",this._panningDiv.style.height="100%",this._setupOrientation(),i(this._prevButton),i(this._nextButton),this._prevButton.setAttribute("aria-label",B),this._nextButton.setAttribute("aria-label",C),this._prevButton.setAttribute("type","button"),this._nextButton.setAttribute("type","button"),this._panningDivContainer.appendChild(this._panningDiv),this._contentDiv.appendChild(this._prevButton),this._contentDiv.appendChild(this._nextButton),this._itemsManagerCallback={inserted:function(a,b,c){m._itemsManager._itemFromPromise(a).then(function(a){var d=m._itemsManager._elementFromHandle(b),e=m._itemsManager._elementFromHandle(c);m._pageManager.inserted(a,d,e,!0)})},countChanged:function(a,b){m._pageManager._cachedSize=a,b!==r.CountResult.unknown&&m._fireDatasourceCountChangedEvent()},changed:function(a,b){m._pageManager.changed(a,b)},moved:function(a,b,c,d){var e=function(a){m._pageManager.moved(a,b,c)};a?e(a):m._itemsManager._itemFromPromise(d).then(e)},removed:function(a,b){a&&m._pageManager.removed(a,b,!0)},knownUpdatesComplete:function(){},beginNotifications:function(){m._cancelAnimation(),m._pageManager.notificationsStarted()},endNotifications:function(){m._pageManager.notificationsEnded()},itemAvailable:function(a,b){m._pageManager.itemRetrieved(a,b)},reload:function(){m._pageManager.reload()}},this._dataSource&&(this._itemsManager=q._createItemsManager(this._dataSource,this._itemRenderer,this._itemsManagerCallback,{ownerElement:this._flipviewDiv})),this._pageManager=new t._FlipPageManager(this._flipviewDiv,this._panningDiv,this._panningDivContainer,this._itemsManager,h,this._environmentSupportsTouch,{hidePreviousButton:function(){m._hasPrevContent=!1,m._fadeOutButton("prev"),m._prevButton.setAttribute("aria-hidden",!0)},showPreviousButton:function(){m._hasPrevContent=!0,m._fadeInButton("prev"),m._prevButton.setAttribute("aria-hidden",!1)},hideNextButton:function(){m._hasNextContent=!1,m._fadeOutButton("next"),m._nextButton.setAttribute("aria-hidden",!0)},showNextButton:function(){m._hasNextContent=!0,m._fadeInButton("next"),m._nextButton.setAttribute("aria-hidden",!1)}}),this._pageManager.initialize(g,this._isHorizontal),this._dataSource.getCount().then(function(a){m._pageManager._cachedSize=a}),this._prevButton.addEventListener("click",function(){m.previous()},!1),this._nextButton.addEventListener("click",function(){m.next()},!1),new o._MutationObserver(p).observe(this._flipviewDiv,{attributes:!0,attributeFilter:["dir","style"]}),this._cachedStyleDir=this._flipviewDiv.style.direction,this._flipviewDiv.addEventListener("mselementresize",u),o._resizeNotifier.subscribe(this._flipviewDiv,u),this._contentDiv.addEventListener("mouseleave",function(){m._mouseInViewport=!1},!1);var D=o._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch";this._environmentSupportsTouch&&(o._addEventListener(this._contentDiv,"pointerdown",k,!1),o._addEventListener(this._contentDiv,"pointermove",j,!1),o._addEventListener(this._contentDiv,"pointerup",l,!1)),this._panningDivContainer.addEventListener("scroll",function(){m._scrollPosChanged()},!1),this._panningDiv.addEventListener("blur",function(){m._touchInteraction||m._fadeOutButtons()},!0);var E=a.document.body.contains(this._flipviewDiv);o._addInsertedNotifier(this._flipviewDiv),this._flipviewDiv.addEventListener("WinJSNodeInserted",function(){return E?void(E=!1):void m._pageManager.resized()},!1),this._flipviewDiv.addEventListener("keydown",function(a){var b=!0;if(!m._isInteractive(a.target)){var c=o.Key,d=!1;if(m._isHorizontal)switch(a.keyCode){case c.leftArrow:m._rtl?m.next():m.previous(),d=!0;break;case c.pageUp:m.previous(),d=!0;break;case c.rightArrow:m._rtl?m.previous():m.next(),d=!0;break;case c.pageDown:m.next(),d=!0;break;case c.upArrow:case c.downArrow:d=!0,b=!1}else switch(a.keyCode){case c.upArrow:case c.pageUp:m.previous(),d=!0;break;case c.downArrow:case c.pageDown:m.next(),d=!0;break;case c.space:d=!0}switch(a.keyCode){case c.home:m.currentPage=0,d=!0;break;case c.end:m._pageManager._cachedSize>0&&(m.currentPage=m._pageManager._cachedSize-1),d=!0}if(d)return a.preventDefault(),b&&a.stopPropagation(),!0}},!1),n=!0},_windowWheelHandler:function(a){a=a.detail.originalEvent;var b=a.target&&(this._flipviewDiv.contains(a.target)||this._flipviewDiv===a.target),d=this,e=c._now(),f=this._avoidTrappingTime>e;(!b||f)&&(this._avoidTrappingTime=e+E),b&&f?(this._panningDivContainer.style.overflowX="hidden",this._panningDivContainer.style.overflowY="hidden",c._yieldForDomModification(function(){d._pageManager._ensureCentered(),d._isHorizontal?(d._panningDivContainer.style.overflowX=d._environmentSupportsTouch?"scroll":"hidden",d._panningDivContainer.style.overflowY="hidden"):(d._panningDivContainer.style.overflowY=d._environmentSupportsTouch?"scroll":"hidden",d._panningDivContainer.style.overflowX="hidden")})):b&&this._pageManager.simulateMouseWheelScroll(a)},_isInteractive:function(a){if(a.parentNode)for(var b=a.parentNode.querySelectorAll(".win-interactive, .win-interactive *"),c=0,d=b.length;d>c;c++)if(b[c]===a)return!0;return!1},_refreshHandler:function(){var a=this._dataSourceAfterRefresh||this._dataSource,b=this._itemRendererAfterRefresh||this._itemRenderer,c=this._indexAfterRefresh||0;this._setDatasource(a,b,c),this._dataSourceAfterRefresh=null,this._itemRendererAfterRefresh=null,this._indexAfterRefresh=0,this._refreshTimer=!1},_refresh:function(){if(!this._refreshTimer){var a=this;this._refreshTimer=!0,l.schedule(function(){a._refreshTimer&&!a._disposed&&a._refreshHandler()},l.Priority.high,null,"WinJS.UI.FlipView._refreshHandler")}},_getItemRenderer:function(b){var c=null;if("function"==typeof b){var d=new k(function(){}),e=b(d);c=e.element?"object"==typeof e.element&&"function"==typeof e.element.then?function(c){var d=a.document.createElement("div");return d.className="win-template",n.markDisposable(d),{element:d,renderComplete:b(c).element.then(function(a){d.appendChild(a)})}}:b:function(c){var d=a.document.createElement("div");return d.className="win-template",n.markDisposable(d),{element:d,renderComplete:c.then(function(){return k.as(b(c)).then(function(a){d.appendChild(a)})})}}}else"object"==typeof b&&(c=b.renderItem);return c},_navigate:function(a,b){if(c.validation&&this._refreshTimer)throw new d("WinJS.UI.FlipView.NavigationDuringStateChange",K.navigationDuringStateChange);if(this._animating||(this._animatingForward=a),this._goForward=a,this._animating&&!this._cancelAnimation())return!1;var e=this,f=a?this._nextAnimation:this._prevAnimation,g=f?f:this._defaultAnimation.bind(this),h=function(a){e._completeNavigation(a)},i=this._pageManager.startAnimatedNavigation(a,b,h);if(i){this._animationsStarted();var j=i.outgoing.pageRoot,k=i.incoming.pageRoot;return this._contentDiv.appendChild(j),this._contentDiv.appendChild(k),this._completeNavigationPending=!0,g(j,k).then(function(){e._completeNavigationPending&&h(e._goForward)}).done(),!0}return!1},_cancelDefaultAnimation:function(a,b){a.style.opacity=0,b.style.animationName="",b.style.opacity=1},_cancelAnimation:function(){if(this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.completionCallback){var a=this._pageManager._navigationAnimationRecord.cancelAnimationCallback;if(a&&(a=a.bind(this)),this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var b=this._pageManager._navigationAnimationRecord.elementContainers[0],c=this._pageManager._navigationAnimationRecord.elementContainers[1],d=b.pageRoot,e=c.pageRoot;return a&&a(d,e),this._pageManager._navigationAnimationRecord.completionCallback(this._animatingForward),!0}}return!1},_completeNavigation:function(a){if(!this._disposed){if(this._pageManager._resizing=!1,this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var b=this._pageManager._navigationAnimationRecord.elementContainers[0],c=this._pageManager._navigationAnimationRecord.elementContainers[1],d=b.pageRoot,e=c.pageRoot;d.parentNode&&d.parentNode.removeChild(d),e.parentNode&&e.parentNode.removeChild(e),this._pageManager.endAnimatedNavigation(a,b,c),this._fadeOutButtons(),this._scrollPosChanged(),this._pageManager._ensureCentered(!0),this._animationsFinished()}this._completeNavigationPending=!1}},_completeJump:function(){if(!this._disposed){if(this._pageManager._resizing=!1,this._pageManager._navigationAnimationRecord&&this._pageManager._navigationAnimationRecord.elementContainers){var a=this._pageManager._navigationAnimationRecord.elementContainers[0],b=this._pageManager._navigationAnimationRecord.elementContainers[1],c=a.pageRoot,d=b.pageRoot;c.parentNode&&c.parentNode.removeChild(c),d.parentNode&&d.parentNode.removeChild(d),this._pageManager.endAnimatedJump(a,b),this._animationsFinished()}this._completeJumpPending=!1}},_resize:function(){this._pageManager.resized()},_setCurrentIndex:function(a){return this._pageManager.jumpToIndex(a)},_getCurrentIndex:function(){return this._pageManager.currentIndex()},_setDatasource:function(a,b,c){this._animating&&this._cancelAnimation();var d=0;void 0!==c&&(d=c),this._dataSource=a,this._itemRenderer=b;var e=this._itemsManager;this._itemsManager=q._createItemsManager(this._dataSource,this._itemRenderer,this._itemsManagerCallback,{ownerElement:this._flipviewDiv}),this._dataSource=this._itemsManager.dataSource;var f=this;this._dataSource.getCount().then(function(a){f._pageManager._cachedSize=a}),this._pageManager.setNewItemsManager(this._itemsManager,d),e&&e.release()},_fireDatasourceCountChangedEvent:function(){var b=this;l.schedule(function(){var c=a.document.createEvent("Event");c.initEvent(L.datasourceCountChangedEvent,!0,!0),g("WinJS.UI.FlipView:dataSourceCountChangedEvent,info"),b._flipviewDiv.dispatchEvent(c)},l.Priority.normal,null,"WinJS.UI.FlipView._dispatchDataSourceCountChangedEvent")},_scrollPosChanged:function(){this._pageManager.scrollPosChanged()},_axisAsString:function(){return this._isHorizontal?"horizontal":"vertical"},_setupOrientation:function(){if(this._isHorizontal){this._panningDivContainer.style.overflowX=this._environmentSupportsTouch?"scroll":"hidden",this._panningDivContainer.style.overflowY="hidden";var b="rtl"===a.getComputedStyle(this._flipviewDiv,null).direction;this._rtl=b,b?(this._prevButton.className=v+" "+y,this._nextButton.className=v+" "+x):(this._prevButton.className=v+" "+x,this._nextButton.className=v+" "+y),this._prevButton.innerHTML=b?G:F,this._nextButton.innerHTML=b?F:G}else this._panningDivContainer.style.overflowY=this._environmentSupportsTouch?"scroll":"hidden",this._panningDivContainer.style.overflowX="hidden",this._prevButton.className=v+" "+z,this._nextButton.className=v+" "+A,this._prevButton.innerHTML=H,this._nextButton.innerHTML=I;this._panningDivContainer.style.msOverflowStyle="none"},_fadeInButton:function(a,b){(this._mouseInViewport||b||!this._environmentSupportsTouch)&&("next"===a&&this._hasNextContent?(this._nextButtonAnimation&&(this._nextButtonAnimation.cancel(),this._nextButtonAnimation=null),this._nextButton.style.visibility="visible",this._nextButtonAnimation=this._fadeInFromCurrentValue(this._nextButton)):"prev"===a&&this._hasPrevContent&&(this._prevButtonAnimation&&(this._prevButtonAnimation.cancel(),this._prevButtonAnimation=null),this._prevButton.style.visibility="visible",this._prevButtonAnimation=this._fadeInFromCurrentValue(this._prevButton)))},_fadeOutButton:function(a){var b=this;return"next"===a?(this._nextButtonAnimation&&(this._nextButtonAnimation.cancel(),this._nextButtonAnimation=null),this._nextButtonAnimation=h.fadeOut(this._nextButton).then(function(){b._nextButton.style.visibility="hidden"}),this._nextButtonAnimation):(this._prevButtonAnimation&&(this._prevButtonAnimation.cancel(),this._prevButtonAnimation=null),this._prevButtonAnimation=h.fadeOut(this._prevButton).then(function(){b._prevButton.style.visibility="hidden"}),this._prevButtonAnimation)},_fadeOutButtons:function(a){if(this._environmentSupportsTouch){this._buttonFadePromise&&(this._buttonFadePromise.cancel(),this._buttonFadePromise=null);var b=this;this._buttonFadePromise=(a?k.wrap():k.timeout(i._animationTimeAdjustment(D))).then(function(){b._fadeOutButton("prev"),b._fadeOutButton("next"),b._buttonFadePromise=null})}},_animationsStarted:function(){this._animating=!0},_animationsFinished:function(){this._animating=!1},_defaultAnimation:function(a,b){var c={};b.style.left="0px",b.style.top="0px",b.style.opacity=0;var d=a.itemIndex>b.itemIndex?-J:J;c.left=(this._isHorizontal?this._rtl?-d:d:0)+"px",c.top=(this._isHorizontal?0:d)+"px";var e=h.fadeOut(a),f=h.enterContent(b,[c],{mechanism:"transition"});return k.join([e,f])},_fadeInFromCurrentValue:function(a){return i.executeTransition(a,{property:"opacity",delay:0,duration:167,timing:"linear",to:1})}},s);return b.Class.mix(L,e.createEventProperties(L.datasourceCountChangedEvent,L.pageVisibilityChangedEvent,L.pageSelectedEvent,L.pageCompletedEvent)),b.Class.mix(L,m.DOMEventMixin),L})})}),define("WinJS/Controls/ItemContainer",["exports","../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Promise","../Scheduler","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_KeyboardBehavior","../Utilities/_UI","./ItemContainer/_Constants","./ItemContainer/_ItemEventsHandler"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){"use strict";var t=f._createEventProperty,u={invoked:"invoked",selectionchanging:"selectionchanging",selectionchanged:"selectionchanged"};c.Namespace._moduleDefine(a,"WinJS.UI",{ItemContainer:c.Namespace._lazy(function(){var f={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"}},h=c.Class.define(function(c,d){function g(a,b,c){return{name:b?a:a.toLowerCase(),handler:function(b){i["_on"+a](b)},capture:c}}if(c=c||b.document.createElement("DIV"),this._id=c.id||n._uniqueID(c),this._writeProfilerMark("constructor,StartTM"),d=d||{},c.winControl)throw new e("WinJS.UI.ItemContainer.DuplicateConstruction",f.duplicateConstruction);c.winControl=this,this._element=c,n.addClass(c,"win-disposable"),this._selectionMode=q.SelectionMode.single,this._draggable=!1,this._pressedEntity={type:q.ObjectType.item,index:r._INVALID_INDEX},this.tapBehavior=q.TapBehavior.invokeOnly,this.swipeOrientation=q.Orientation.vertical,this.swipeBehavior=q.SwipeBehavior.select,n.addClass(this.element,h._ClassName.itemContainer+" "+r._containerClass),this._setupInternalTree(),this._selection=new a._SingleItemSelectionManager(c,this._itemBox),this._setTabIndex(),l.setOptions(this,d),this._mutationObserver=new n._MutationObserver(this._itemPropertyChange.bind(this)),this._mutationObserver.observe(c,{attributes:!0,attributeFilter:["aria-selected"]}),this._setAriaRole();var i=this;this.selectionDisabled||k.schedule(function(){i._setDirectionClass()},k.Priority.normal,null,"WinJS.UI.ItemContainer_async_initialize"),this._itemEventsHandler=new s._ItemEventsHandler(Object.create({containerFromElement:function(){return i.element},indexForItemElement:function(){return 1},indexForHeaderElement:function(){return r._INVALID_INDEX},itemBoxAtIndex:function(){return i._itemBox},itemAtIndex:function(){return i.element},headerAtIndex:function(){return null},containerAtIndex:function(){return i.element},isZombie:function(){return this._disposed},getItemPosition:function(){return i._getItemPosition()},rtl:function(){return i._rtl()},fireInvokeEvent:function(){i._fireInvokeEvent()},verifySelectionAllowed:function(){return i._verifySelectionAllowed()},changeFocus:function(){},selectRange:function(a,b){return i._selection.set({firstIndex:a,lastIndex:b})}},{pressedEntity:{get:function(){return i._pressedEntity},set:function(a){i._pressedEntity=a}},pressedElement:{enumerable:!0,set:function(a){i._pressedElement=a}},eventHandlerRoot:{enumerable:!0,get:function(){return i.element}},swipeBehavior:{enumerable:!0,get:function(){return i._swipeBehavior}},selectionMode:{enumerable:!0,get:function(){return i._selectionMode}},accessibleItemClass:{enumerable:!0,get:function(){return r._containerClass}},canvasProxy:{enumerable:!0,get:function(){return i._captureProxy}},tapBehavior:{enumerable:!0,get:function(){return i._tapBehavior}},draggable:{enumerable:!0,get:function(){return i._draggable}},selection:{enumerable:!0,get:function(){return i._selection}},horizontal:{enumerable:!0,get:function(){return i._swipeOrientation===q.Orientation.vertical}},customFootprintParent:{enumerable:!0,get:function(){return null}},skipPreventDefaultOnPointerDown:{enumerable:!0,get:function(){return!0}}}));var j=[g("MSManipulationStateChanged",!0,!0),g("PointerDown"),g("Click"),g("PointerUp"),g("PointerCancel"),g("LostPointerCapture"),g("ContextMenu"),g("MSHoldVisual",!0),g("FocusIn"),g("FocusOut"),g("DragStart"),g("DragEnd"),g("KeyDown")];j.forEach(function(a){n._addEventListener(i.element,a.name,a.handler,!!a.capture)}),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},draggable:{get:function(){return this._draggable},set:function(a){d.isPhone||this._draggable!==a&&(this._draggable=a,this._updateDraggableAttribute())}},selected:{get:function(){return this._selection.selected},set:function(a){this._selection.selected!==a&&(this._selection.selected=a)}},swipeOrientation:{get:function(){return this._swipeOrientation},set:function(a){a===q.Orientation.vertical?(n.removeClass(this.element,h._ClassName.horizontal),n.addClass(this.element,h._ClassName.vertical)):(a=q.Orientation.horizontal,n.removeClass(this.element,h._ClassName.vertical),n.addClass(this.element,h._ClassName.horizontal)),this._swipeOrientation=a}},tapBehavior:{get:function(){return this._tapBehavior},set:function(a){d.isPhone&&a===q.TapBehavior.directSelect||(this._tapBehavior=a,this._setAriaRole())}},swipeBehavior:{get:function(){return this._swipeBehavior},set:function(a){this._swipeBehavior=a,this._setSwipeClass()}},selectionDisabled:{get:function(){return this._selectionMode===q.SelectionMode.none},set:function(a){a?this._selectionMode=q.SelectionMode.none:(this._setDirectionClass(),this._selectionMode=q.SelectionMode.single),this._setSwipeClass(),this._setAriaRole()}},oninvoked:t(u.invoked),onselectionchanging:t(u.selectionchanging),onselectionchanged:t(u.selectionchanged),forceLayout:function(){this._forceLayout()},dispose:function(){this._disposed||(this._disposed=!0,this._itemEventsHandler.dispose(),m.disposeSubTree(this.element))},_onMSManipulationStateChanged:function(a){this._itemEventsHandler.onMSManipulationStateChanged(a)},_onPointerDown:function(a){this._itemEventsHandler.onPointerDown(a)},_onClick:function(a){this._itemEventsHandler.onClick(a)},_onPointerUp:function(a){n.hasClass(this._itemBox,r._itemFocusClass)&&this._onFocusOut(a),this._itemEventsHandler.onPointerUp(a)},_onPointerCancel:function(a){this._itemEventsHandler.onPointerCancel(a)},_onLostPointerCapture:function(a){this._itemEventsHandler.onLostPointerCapture(a)},_onContextMenu:function(a){this._itemEventsHandler.onContextMenu(a)},_onMSHoldVisual:function(a){this._itemEventsHandler.onMSHoldVisual(a)},_onFocusIn:function(){if(!this._itemBox.querySelector("."+r._itemFocusOutlineClass)&&p._keyboardSeenLast){n.addClass(this._itemBox,r._itemFocusClass);var a=b.document.createElement("div");a.className=r._itemFocusOutlineClass,this._itemBox.appendChild(a)}},_onFocusOut:function(){n.removeClass(this._itemBox,r._itemFocusClass);var a=this._itemBox.querySelector("."+r._itemFocusOutlineClass);a&&a.parentNode.removeChild(a)},_onDragStart:function(a){if(this._pressedElement&&this._itemEventsHandler._isInteractive(this._pressedElement))a.preventDefault();else{this._dragging=!0;var b=this;if(a.dataTransfer.setData("text",""),a.dataTransfer.setDragImage){var c=this.element.getBoundingClientRect();a.dataTransfer.setDragImage(this.element,a.clientX-c.left,a.clientY-c.top)}d._yieldForDomModification(function(){b._dragging&&n.addClass(b._itemBox,r._dragSourceClass)})}},_onDragEnd:function(){this._dragging=!1,n.removeClass(this._itemBox,r._dragSourceClass),this._itemEventsHandler.resetPointerDownState()},_onKeyDown:function(a){if(!this._itemEventsHandler._isInteractive(a.target)){var b=n.Key,c=a.keyCode,d=this._swipeBehavior===q.SwipeBehavior.select,e=!1;if(a.ctrlKey||c!==b.enter)a.ctrlKey&&c===b.enter||d&&a.shiftKey&&c===b.F10||d&&c===b.menu||c===b.space?this.selectionDisabled||(this.selected=!this.selected,e=n._setActive(this.element)):c===b.escape&&this.selected&&(this.selected=!1,e=!0);else{var f=this._verifySelectionAllowed();f.canTapSelect&&(this.selected=!this.selected),this._fireInvokeEvent(),e=!0 +}e&&(a.stopPropagation(),a.preventDefault())}},_setTabIndex:function(){var a=this.element.getAttribute("tabindex");a||this.element.setAttribute("tabindex","0")},_rtl:function(){return"boolean"!=typeof this._cachedRTL&&(this._cachedRTL="rtl"===b.getComputedStyle(this.element,null).direction),this._cachedRTL},_setDirectionClass:function(){n[this._rtl()?"addClass":"removeClass"](this.element,r._rtlListViewClass)},_forceLayout:function(){this._cachedRTL="rtl"===b.getComputedStyle(this.element,null).direction,this._setDirectionClass()},_getItemPosition:function(){var a=this.element;return a?j.wrap({left:this._rtl()?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft,top:a.offsetTop,totalWidth:n.getTotalWidth(a),totalHeight:n.getTotalHeight(a),contentWidth:n.getContentWidth(a),contentHeight:n.getContentHeight(a)}):j.cancel},_itemPropertyChange:function(a){if(!this._disposed){var b=a[0].target,c="true"===b.getAttribute("aria-selected");c!==n._isSelectionRendered(this._itemBox)&&(this.selectionDisabled?n._setAttribute(b,"aria-selected",!c):(this.selected=c,c!==this.selected&&n._setAttribute(b,"aria-selected",!c)))}},_setSwipeClass:function(){d.isPhone||(this._swipeBehavior===q.SwipeBehavior.select&&this._selectionMode!==q.SelectionMode.none||this._draggable?n.addClass(this._element,r._swipeableClass):n.removeClass(this._element,r._swipeableClass))},_updateDraggableAttribute:function(){this._setSwipeClass(),this._itemBox.setAttribute("draggable",this._draggable)},_verifySelectionAllowed:function(){if(this._selectionMode===q.SelectionMode.none||this._tapBehavior!==q.TapBehavior.toggleSelect&&this._swipeBehavior!==q.SwipeBehavior.select)return{canSelect:!1,canTapSelect:!1};var a=this._selection.fireSelectionChanging();return{canSelect:a,canTapSelect:a&&this._tapBehavior===q.TapBehavior.toggleSelect}},_setupInternalTree:function(){var a=b.document.createElement("div");a.className=r._itemClass,this._captureProxy=b.document.createElement("div"),this._itemBox=b.document.createElement("div"),this._itemBox.className=r._itemBoxClass;for(var c=this.element.firstChild;c;){var d=c.nextSibling;a.appendChild(c),c=d}this.element.appendChild(this._itemBox),this._itemBox.appendChild(a),this.element.appendChild(this._captureProxy)},_fireInvokeEvent:function(){if(this.tapBehavior!==q.TapBehavior.none){var a=b.document.createEvent("CustomEvent");a.initCustomEvent(u.invoked,!0,!1,{}),this.element.dispatchEvent(a)}},_setAriaRole:function(){if(!this.element.getAttribute("role")||this._usingDefaultItemRole){this._usingDefaultItemRole=!0;var a;a=this.tapBehavior===q.TapBehavior.none&&this.selectionDisabled?"listitem":"option",n._setAttribute(this.element,"role",a)}},_writeProfilerMark:function(a){var b="WinJS.UI.ItemContainer:"+this._id+":"+a;i(b),g.log&&g.log(b,null,"itemcontainerprofiler")}},{_ClassName:{itemContainer:"win-itemcontainer",vertical:"win-vertical",horizontal:"win-horizontal"}});return c.Class.mix(h,l.DOMEventMixin),h}),_SingleItemSelectionManager:c.Namespace._lazy(function(){return c.Class.define(function(a,b){this._selected=!1,this._element=a,this._itemBox=b},{selected:{get:function(){return this._selected},set:function(a){a=!!a,this._selected!==a&&this.fireSelectionChanging()&&(this._selected=a,s._ItemEventsHandler.renderSelection(this._itemBox,this._element,a,!0,this._element),this.fireSelectionChanged())}},count:function(){return this._selected?1:0},getIndices:function(){},getItems:function(){},getRanges:function(){},isEverything:function(){return!1},set:function(){this.selected=!0},clear:function(){this.selected=!1},add:function(){this.selected=!0},remove:function(){this.selected=!1},selectAll:function(){},fireSelectionChanging:function(){var a=b.document.createEvent("CustomEvent");return a.initCustomEvent(u.selectionchanging,!0,!0,{}),this._element.dispatchEvent(a)},fireSelectionChanged:function(){var a=b.document.createEvent("CustomEvent");a.initCustomEvent(u.selectionchanged,!0,!1,{}),this._element.dispatchEvent(a)},_isIncluded:function(){return this._selected},_getFocused:function(){return{type:q.ObjectType.item,index:r._INVALID_INDEX}}})})})}),define("WinJS/Controls/Repeater",["exports","../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Core/_WriteProfilerMark","../BindingList","../BindingTemplate","../Promise","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){"use strict";c.Namespace._moduleDefine(a,"WinJS.UI",{Repeater:c.Namespace._lazy(function(){function a(a){var c=b.document.createElement("div");return c.textContent=JSON.stringify(a),c}var f="itemsloaded",n="itemchanging",o="itemchanged",p="iteminserting",q="iteminserted",r="itemmoving",s="itemmoved",t="itemremoving",u="itemremoved",v="itemsreloading",w="itemsreloaded",x=e._createEventProperty,y={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get asynchronousRender(){return"Top level items must render synchronously"},get repeaterReentrancy(){return"Cannot modify Repeater data until Repeater has commited previous modification."}},z=c.Class.define(function(a,c){if(a&&a.winControl)throw new d("WinJS.UI.Repeater.DuplicateConstruction",y.duplicateConstruction);this._element=a||b.document.createElement("div"),this._id=this._element.id||m._uniqueID(this._element),this._writeProfilerMark("constructor,StartTM"),c=c||{},m.addClass(this._element,"win-repeater win-disposable"),this._render=null,this._modifying=!1,this._disposed=!1,this._element.winControl=this,this._dataListeners={itemchanged:this._dataItemChangedHandler.bind(this),iteminserted:this._dataItemInsertedHandler.bind(this),itemmoved:this._dataItemMovedHandler.bind(this),itemremoved:this._dataItemRemovedHandler.bind(this),reload:this._dataReloadHandler.bind(this)};var e=this._extractInlineTemplate();this._initializing=!0,this.template=c.template||e,this.data=c.data,this._initializing=!1,k._setOptions(this,c,!0),this._repeatedDOM=[],this._renderAllItems(),this.dispatchEvent(f,{}),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},data:{get:function(){return this._data},set:function(a){this._writeProfilerMark("data.set,StartTM"),this._data&&this._removeDataListeners(),this._data=a||new h.List,this._addDataListeners(),this._initializing||(this._reloadRepeater(!0),this.dispatchEvent(f,{})),this._writeProfilerMark("data.set,StopTM")}},template:{get:function(){return this._template},set:function(b){this._writeProfilerMark("template.set,StartTM"),this._template=b||a,this._render=m._syncRenderer(this._template,this.element.tagName),this._initializing||(this._reloadRepeater(!0),this.dispatchEvent(f,{})),this._writeProfilerMark("template.set,StopTM")}},length:{get:function(){return this._repeatedDOM.length}},elementFromIndex:function(a){return this._repeatedDOM[a]},dispose:function(){if(!this._disposed){this._disposed=!0,this._removeDataListeners(),this._data=null,this._template=null;for(var a=0,b=this._repeatedDOM.length;b>a;a++)l._disposeElement(this._repeatedDOM[a])}},onitemsloaded:x(f),onitemchanging:x(n),onitemchanged:x(o),oniteminserting:x(p),oniteminserted:x(q),onitemmoving:x(r),onitemmoved:x(s),onitemremoving:x(t),onitemremoved:x(u),onitemsreloading:x(v),onitemsreloaded:x(w),_extractInlineTemplate:function(){if(this._element.firstElementChild){for(var a=b.document.createElement(this._element.tagName);this._element.firstElementChild;)a.appendChild(this._element.firstElementChild);return new i.Template(a,{extractChild:!0})}},_renderAllItems:function(){for(var a=b.document.createDocumentFragment(),c=0,e=this._data.length;e>c;c++){var f=this._render(this._data.getAt(c));if(!f)throw new d("WinJS.UI.Repeater.AsynchronousRender",y.asynchronousRender);a.appendChild(f),this._repeatedDOM.push(f)}this._element.appendChild(a)},_reloadRepeater:function(a){this._unloadRepeatedDOM(a),this._repeatedDOM=[],this._renderAllItems()},_unloadRepeatedDOM:function(a){for(var b=0,c=this._repeatedDOM.length;c>b;b++){var d=this._repeatedDOM[b];a&&l._disposeElement(d),d.parentElement===this._element&&this._element.removeChild(d)}},_addDataListeners:function(){Object.keys(this._dataListeners).forEach(function(a){this._data.addEventListener(a,this._dataListeners[a],!1)}.bind(this))},_beginModification:function(){if(this._modifying)throw new d("WinJS.UI.Repeater.RepeaterModificationReentrancy",y.repeaterReentrancy);this._modifying=!0},_endModification:function(){this._modifying=!1},_removeDataListeners:function(){Object.keys(this._dataListeners).forEach(function(a){this._data.removeEventListener(a,this._dataListeners[a],!1)}.bind(this))},_dataItemChangedHandler:function(a){this._beginModification();var b,c=this._element,e=a.detail.index,f=this._render(a.detail.newValue);if(!f)throw new d("WinJS.UI.Repeater.AsynchronousRender",y.asynchronousRender);this._repeatedDOM[e]&&(a.detail.oldElement=this._repeatedDOM[e]),a.detail.newElement=f,a.detail.setPromise=function(a){b=a},this._writeProfilerMark(n+",info"),this.dispatchEvent(n,a.detail);var g=null;ea;a++)l._disposeElement(b[a])}.bind(this))},_writeProfilerMark:function(a){g("WinJS.UI.Repeater:"+this._id+":"+a)}},{isDeclarativeControlContainer:!0});return c.Class.mix(z,k.DOMEventMixin),z})})}),define("WinJS/Controls/DatePicker",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_Select","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";c.Namespace.define("WinJS.UI",{DatePicker:c.Namespace._lazy(function(){function d(a,c,d){var e=b.Windows.Globalization.DateTimeFormatting;a=a?a:d;var f=new e.DateTimeFormatter(a);return c?new e.DateTimeFormatter(a,f.languages,f.geographicRegion,c,f.clock):f}function i(a,b,c){var e=t[a];e||(e=t[a]={});var f=e[b];f||(f=e[b]={});var g=f[c];return g||(g=f[c]={},g.formatter=d(a,b,c),g.years={}),g}function k(a,b,c,d,e,f){var g=i(a,b,c),h=g.years[f.year+"-"+f.era];return h||(h=g.formatter.format(f.getDateTime()),g.years[f.year+"-"+f.era]=h),h}function l(a,b,c,d){var e=i(a,b,c);return e.formatter.format(d.getDateTime())}function m(a,b,c,d){var e=i(a,b,c);return e.formatter.format(d.getDateTime())}function n(a){var c=b.Windows.Globalization,d=new c.Calendar;return a?new c.Calendar(d.languages,a,d.getClock()):d}function o(a,b){var c=0;if(a.era===b.era)c=b.year-a.year;else for(;a.era!==b.era||a.year!==b.year;)c++,a.addYears(1);return c}var p="day",q="{month.full}",r="year.full",s={get ariaLabel(){return f._getWinJSString("ui/datePicker").value},get selectDay(){return f._getWinJSString("ui/selectDay").value},get selectMonth(){return f._getWinJSString("ui/selectMonth").value},get selectYear(){return f._getWinJSString("ui/selectYear").value}},t={},u=c.Class.define(function(b,c){this._currentDate=new Date,this._minYear=this._currentDate.getFullYear()-100,this._maxYear=this._currentDate.getFullYear()+100,this._datePatterns={date:null,month:null,year:null},b=b||a.document.createElement("div"),h.addClass(b,"win-disposable"),b.winControl=this;var d=b.getAttribute("aria-label");d||b.setAttribute("aria-label",s.ariaLabel),this._init(b),g.setOptions(this,c)},{_information:null,_currentDate:null,_calendar:null,_disabled:!1,_dateElement:null,_dateControl:null,_monthElement:null,_monthControl:null,_minYear:null,_maxYear:null,_yearElement:null,_yearControl:null,_datePatterns:{date:null,month:null,year:null},_addAccessibilityAttributes:function(){this._domElement.setAttribute("role","group"),this._dateElement.setAttribute("aria-label",s.selectDay),this._monthElement.setAttribute("aria-label",s.selectMonth),this._yearElement.setAttribute("aria-label",s.selectYear)},_addControlsInOrder:function(){var a=this._domElement,b=this,c=0;b._information.order.forEach(function(d){switch(d){case"month":a.appendChild(b._monthElement),h.addClass(b._monthElement,"win-order"+c++);break;case"date":a.appendChild(b._dateElement),h.addClass(b._dateElement,"win-order"+c++);break;case"year":a.appendChild(b._yearElement),h.addClass(b._yearElement,"win-order"+c++)}})},_createControlElements:function(){this._monthElement=a.document.createElement("select"),this._monthElement.className="win-datepicker-month",this._dateElement=a.document.createElement("select"),this._dateElement.className="win-datepicker-date",this._yearElement=a.document.createElement("select"),this._yearElement.className="win-datepicker-year"},_createControls:function(){var a=this._information,b=a.getIndex(this.current);a.forceLanguage&&(this._domElement.setAttribute("lang",a.forceLanguage),this._domElement.setAttribute("dir",a.isRTL?"rtl":"ltr")),this._yearControl=new j._Select(this._yearElement,{dataSource:this._information.years,disabled:this.disabled,index:b.year}),this._monthControl=new j._Select(this._monthElement,{dataSource:this._information.months(b.year),disabled:this.disabled,index:b.month}),this._dateControl=new j._Select(this._dateElement,{dataSource:this._information.dates(b.year,b.month),disabled:this.disabled,index:b.date}),this._wireupEvents()},dispose:function(){},calendar:{get:function(){return this._calendar},set:function(a){this._calendar=a,this._setElement(this._domElement)}},current:{get:function(){var a=this._currentDate,b=a.getFullYear();return new Date(Math.max(Math.min(this.maxYear,b),this.minYear),a.getMonth(),a.getDate(),12,0,0,0)},set:function(a){var b;"string"==typeof a?(b=new Date(Date.parse(a)),b.setHours(12,0,0,0)):b=a;var c=this._currentDate;c!==b&&(this._currentDate=b,this._updateDisplay())}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled!==a&&(this._disabled=a,this._yearControl&&(this._monthControl.setDisabled(a),this._dateControl.setDisabled(a),this._yearControl.setDisabled(a)))}},datePattern:{get:function(){return this._datePatterns.date},set:function(a){this._datePatterns.date!==a&&(this._datePatterns.date=a,this._init())}},element:{get:function(){return this._domElement}},_setElement:function(a){this._domElement=this._domElement||a,this._domElement&&(h.empty(this._domElement),h.addClass(this._domElement,"win-datepicker"),this._updateInformation(),this._createControlElements(),this._addControlsInOrder(),this._createControls(),this._addAccessibilityAttributes())},minYear:{get:function(){return this._information.getDate({year:0,month:0,date:0}).getFullYear()},set:function(a){this._minYear!==a&&(this._minYear=a,a>this._maxYear&&(this._maxYear=a),this._updateInformation(),this._yearControl&&(this._yearControl.dataSource=this._information.years),this._updateDisplay())}},maxYear:{get:function(){var a={year:this._information.years.getLength()-1};return a.month=this._information.months(a.year).getLength()-1,a.date=this._information.dates(a.year,a.month).getLength()-1,this._information.getDate(a).getFullYear()},set:function(a){this._maxYear!==a&&(this._maxYear=a,az[b]?1:0});var A=function(){return{getLength:function(){return u},getValue:function(b){return f.setDateTime(a),f.addYears(b),k(d.year,c,r,d,y,f)}}}(),B=function(b){return g.setDateTime(a),g.addYears(b),{getLength:function(){return g.numberOfMonthsInThisYear},getValue:function(a){return g.month=g.firstMonthInThisYear,g.addMonths(a),l(d.month,c,q,g)}}},C=function(b,e){return h.setDateTime(a),h.addYears(b),h.month=h.firstMonthInThisYear,h.addMonths(e),h.day=h.firstDayInThisMonth,{getLength:function(){return h.numberOfDaysInThisMonth},getValue:function(a){return h.day=h.firstDayInThisMonth,h.addDays(a),m(d.date,c,p,h)}}};return{isRTL:x,forceLanguage:v.resolvedLanguage,order:y,getDate:function(b,c){var d;c&&(f.setDateTime(c),d={year:f.year,month:f.month,day:f.day});var e=f;e.setDateTime(a),e.addYears(b.year);var g;e.firstMonthInThisYear>e.lastMonthInThisYear?(g=b.month+e.firstMonthInThisYear>e.numberOfMonthsInThisYear?b.month+e.firstMonthInThisYear-e.numberOfMonthsInThisYear:b.month+e.firstMonthInThisYear,d&&d.year!==e.year&&(g=Math.max(Math.min(d.month,e.numberOfMonthsInThisYear),1))):g=d&&d.year!==e.year?Math.max(Math.min(d.month,e.firstMonthInThisYear+e.numberOfMonthsInThisYear-1),e.firstMonthInThisYear):Math.max(Math.min(b.month+e.firstMonthInThisYear,e.firstMonthInThisYear+e.numberOfMonthsInThisYear-1),e.firstMonthInThisYear),e.month=g;var h=Math.max(Math.min(b.date+e.firstDayInThisMonth,e.firstDayInThisMonth+e.numberOfDaysInThisMonth-1),e.firstDayInThisMonth);return!d||d.year===e.year&&d.month===e.month||(h=Math.max(Math.min(d.day,e.firstDayInThisMonth+e.numberOfDaysInThisMonth-1),e.firstDayInThisMonth)),e.day=e.firstDayInThisMonth,e.addDays(h-e.firstDayInThisMonth),e.getDateTime()},getIndex:function(b){var c=e(b);f.setDateTime(c);var d={year:f.year,era:f.era},g=0;f.setDateTime(a),f.month=1,g=o(f,d),f.setDateTime(c);var h=f.month-f.firstMonthInThisYear;0>h&&(h=f.month-f.firstMonthInThisYear+f.numberOfMonthsInThisYear);var i=f.day-f.firstDayInThisMonth,j={year:g,month:h,date:i};return j},years:A,months:B,dates:C}},_getInformationJS:function(a,b){var c=a.getFullYear(),d=b.getFullYear(),e={getLength:function(){return Math.max(0,d-c+1)},getValue:function(a){return c+a}},f=["January","February","March","April","May","June","July","August","September","October","November","December"],g=function(){return{getLength:function(){return f.length},getValue:function(a){return f[a]},getMonthNumber:function(a){return Math.min(a,f.length-1)}}},h=function(a,b){var c=new Date,d=e.getValue(a),f=b+1;c.setFullYear(d,f,0);var g=c.getDate();return{getLength:function(){return g},getValue:function(a){return""+(a+1)},getDateNumber:function(a){return Math.min(a+1,g)}}};return{order:["month","date","year"],getDate:function(a){return new Date(e.getValue(a.year),g(a.year).getMonthNumber(a.month),h(a.year,a.month).getDateNumber(a.date),12,0)},getIndex:function(a){var b=0,d=a.getFullYear();b=c>d?0:d>this.maxYear?e.getLength()-1:a.getFullYear()-c;var f=Math.min(a.getMonth(),g(b).getLength()),i=Math.min(a.getDate()-1,h(b,f).getLength());return{year:b,month:f,date:i}},years:e,months:g,dates:h}}});return u.getInformation=b.Windows.Globalization.Calendar&&b.Windows.Globalization.DateTimeFormatting?u._getInformationWinRT:u._getInformationJS,c.Class.mix(u,e.createEventProperties("change")),c.Class.mix(u,g.DOMEventMixin),u})})}),define("WinJS/Controls/TimePicker",["../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_Select","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";c.Namespace.define("WinJS.UI",{TimePicker:c.Namespace._lazy(function(){var d="{minute.integer(2)}",i="{hour.integer(1)}",k="{period.abbreviated(2)}",l={get ariaLabel(){return f._getWinJSString("ui/timePicker").value},get selectHour(){return f._getWinJSString("ui/selectHour").value},get selectMinute(){return f._getWinJSString("ui/selectMinute").value},get selectAMPM(){return f._getWinJSString("ui/selectAMPM").value}},m=function(a,b){return a.getHours()===b.getHours()&&a.getMinutes()===b.getMinutes()},n=c.Class.define(function(b,c){this._currentTime=n._sentinelDate(),b=b||a.document.createElement("div"),h.addClass(b,"win-disposable"),b.winControl=this;var d=b.getAttribute("aria-label");d||b.setAttribute("aria-label",l.ariaLabel),this._timePatterns={minute:null,hour:null,period:null},this._init(b),g.setOptions(this,c)},{_currentTime:null,_clock:null,_disabled:!1,_hourElement:null,_hourControl:null,_minuteElement:null,_minuteControl:null,_ampmElement:null,_ampmControl:null,_minuteIncrement:1,_timePatterns:{minute:null,hour:null,period:null},_information:null,_addAccessibilityAttributes:function(){this._domElement.setAttribute("role","group"),this._hourElement.setAttribute("aria-label",l.selectHour),this._minuteElement.setAttribute("aria-label",l.selectMinute),this._ampmElement&&this._ampmElement.setAttribute("aria-label",l.selectAMPM)},_addControlsInOrder:function(a){var b=this;a.order.forEach(function(a,c){switch(a){case"hour":b._domElement.appendChild(b._hourElement),h.addClass(b._hourElement,"win-order"+c);break;case"minute":b._domElement.appendChild(b._minuteElement),h.addClass(b._minuteElement,"win-order"+c);break;case"period":b._ampmElement&&(b._domElement.appendChild(b._ampmElement),h.addClass(b._ampmElement,"win-order"+c))}})},dispose:function(){},clock:{get:function(){return this._clock},set:function(a){this._clock!==a&&(this._clock=a,this._init())}},current:{get:function(){var a=this._currentTime;if(a){var b=n._sentinelDate();return b.setHours(a.getHours()),b.setMinutes(this._getMinutesIndex(a)*this.minuteIncrement),b.setSeconds(0),b.setMilliseconds(0),b}return a},set:function(a){var b;"string"==typeof a?(b=n._sentinelDate(),b.setTime(Date.parse(b.toDateString()+" "+a))):(b=n._sentinelDate(),b.setHours(a.getHours()),b.setMinutes(a.getMinutes()));var c=this._currentTime;m(c,b)||(this._currentTime=b,this._updateDisplay())}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled!==a&&(this._disabled=a,this._hourControl&&(this._hourControl.setDisabled(a),this._minuteControl.setDisabled(a)),this._ampmControl&&this._ampmControl.setDisabled(a))}},element:{get:function(){return this._domElement}},_init:function(a){this._setElement(a),this._updateDisplay()},hourPattern:{get:function(){return this._timePatterns.hour.pattern},set:function(a){this._timePatterns.hour!==a&&(this._timePatterns.hour=a,this._init())}},_getHoursAmpm:function(a){var b=a.getHours();return this._ampmElement?0===b?{hours:12,ampm:0}:12>b?{hours:b,ampm:0}:{hours:b-12,ampm:1}:{hours:b}},_getHoursIndex:function(a){return this._ampmElement&&12===a?0:a},_getMinutesIndex:function(a){return parseInt(a.getMinutes()/this.minuteIncrement)},minuteIncrement:{get:function(){return Math.max(1,Math.abs(0|this._minuteIncrement)%60)},set:function(a){this._minuteIncrement!==a&&(this._minuteIncrement=a,this._init())}},minutePattern:{get:function(){return this._timePatterns.minute.pattern},set:function(a){this._timePatterns.minute!==a&&(this._timePatterns.minute=a,this._init())}},periodPattern:{get:function(){return this._timePatterns.period.pattern},set:function(a){this._timePatterns.period!==a&&(this._timePatterns.period=a,this._init())}},_setElement:function(b){if(this._domElement=this._domElement||b,this._domElement){var c=n.getInformation(this.clock,this.minuteIncrement,this._timePatterns);this._information=c,c.forceLanguage&&(this._domElement.setAttribute("lang",c.forceLanguage),this._domElement.setAttribute("dir",c.isRTL?"rtl":"ltr")),h.empty(this._domElement),h.addClass(this._domElement,"win-timepicker"),this._hourElement=a.document.createElement("select"),h.addClass(this._hourElement,"win-timepicker-hour"),this._minuteElement=a.document.createElement("select"),h.addClass(this._minuteElement,"win-timepicker-minute"),this._ampmElement=null,"12HourClock"===c.clock&&(this._ampmElement=a.document.createElement("select"),h.addClass(this._ampmElement,"win-timepicker-period")),this._addControlsInOrder(c);var d=this._getHoursAmpm(this.current);this._hourControl=new j._Select(this._hourElement,{dataSource:this._getInfoHours(),disabled:this.disabled,index:this._getHoursIndex(d.hours)}),this._minuteControl=new j._Select(this._minuteElement,{dataSource:c.minutes,disabled:this.disabled,index:this._getMinutesIndex(this.current)}),this._ampmControl=null,this._ampmElement&&(this._ampmControl=new j._Select(this._ampmElement,{dataSource:c.periods,disabled:this.disabled,index:d.ampm})),this._wireupEvents(),this._updateValues(),this._addAccessibilityAttributes()}},_getInfoHours:function(){return this._information.hours},_updateLayout:function(){this._domElement&&this._updateValues()},_updateValues:function(){if(this._hourControl){var a=this._getHoursAmpm(this.current);this._ampmControl&&(this._ampmControl.index=a.ampm),this._hourControl.index=this._getHoursIndex(a.hours),this._minuteControl.index=this._getMinutesIndex(this.current)}},_updateDisplay:function(){var a=this._getHoursAmpm(this.current);this._ampmControl&&(this._ampmControl.index=a.ampm),this._hourControl&&(this._hourControl.index=this._getHoursIndex(a.hours),this._minuteControl.index=this._getMinutesIndex(this.current))},_wireupEvents:function(){var a=this,b=function(){var b=a._hourControl.index;return a._ampmElement&&1===a._ampmControl.index&&12!==b&&(b+=12),b},c=function(){var c=b();a._currentTime.setHours(c),a._currentTime.setMinutes(a._minuteControl.index*a.minuteIncrement)};this._hourElement.addEventListener("change",c,!1),this._minuteElement.addEventListener("change",c,!1),this._ampmElement&&this._ampmElement.addEventListener("change",c,!1)}},{_sentinelDate:function(){var a=new Date;return new Date(2011,6,15,a.getHours(),a.getMinutes())},_getInformationWinRT:function(a,c,e){var f=function(c,d){var e=b.Windows.Globalization.DateTimeFormatting;c=c?c:d;var f=new e.DateTimeFormatter(c);return a&&(f=e.DateTimeFormatter(c,f.languages,f.geographicRegion,f.calendar,a)),f},g=b.Windows.Globalization,h=new g.Calendar;a&&(h=new g.Calendar(h.languages,h.getCalendarSystem(),a)),h.setDateTime(n._sentinelDate());var j=h.getClock(),l=24;l=h.numberOfHoursInThisPeriod;var m=function(){var a=f(e.period,k);return{getLength:function(){return 2},getValue:function(b){var c=n._sentinelDate();if(0===b){c.setHours(1);var d=a.format(c);return d}if(1===b){c.setHours(13);var e=a.format(c);return e}return null}}}(),o=function(){var a=f(e.minute,d),b=n._sentinelDate();return{getLength:function(){return 60/c},getValue:function(d){var e=d*c;return b.setMinutes(e),a.format(b)}}}(),p=function(){var a=f(e.hour,i),b=n._sentinelDate();return{getLength:function(){return l},getValue:function(c){return b.setHours(c),a.format(b)}}}(),q=f("hour minute"),r=q.patterns[0],s=["hour","minute"],t={period:r.indexOf("{period"),hour:r.indexOf("{hour"),minute:r.indexOf("{minute")};t.period>-1&&s.push("period");var u=b.Windows.Globalization.DateTimeFormatting.DateTimeFormatter,v=new u("month.full",b.Windows.Globalization.ApplicationLanguages.languages,"ZZ","GregorianCalendar","24HourClock"),w=v.patterns[0],x=8207===w.charCodeAt(0);if(x){var y=t.hour;t.hour=t.minute,t.minute=y}return s.sort(function(a,b){return t[a]t[b]?1:0}),{minutes:o,hours:p,clock:j,periods:m,order:s,forceLanguage:q.resolvedLanguage,isRTL:x}},_getInformationJS:function(a,b){var c=[12,1,2,3,4,5,6,7,8,9,10,11],d={};d.getLength=function(){return 60/b},d.getValue=function(a){var c=a*b;return 10>c?"0"+c.toString():c.toString()};var e=["hour","minute","period"];return"24HourClock"===a&&(c=["00","01","02","03","04","05","06","07","08","09",10,11,12,13,14,15,16,17,18,19,20,21,22,23],e=["hour","minute"]),{minutes:d,hours:c,clock:a||"12HourClock",periods:["AM","PM"],order:e}}});return n.getInformation=b.Windows.Globalization.DateTimeFormatting&&b.Windows.Globalization.Calendar&&b.Windows.Globalization.ApplicationLanguages?n._getInformationWinRT:n._getInformationJS,c.Class.mix(n,e.createEventProperties("change")),c.Class.mix(n,g.DOMEventMixin),n})})}),define("WinJS/Controls/BackButton",["../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Resources","../Navigation","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g){"use strict"; +var h=g.Key,i="win-navigation-backbutton",j="win-back",k=3,l=function(){function b(){a.addEventListener("keyup",d,!1),g._addEventListener(a,"pointerup",f,!1)}function c(){a.removeEventListener("keyup",d,!1),g._removeEventListener(a,"pointerup",f,!1)}function d(a){(a.keyCode===h.leftArrow&&a.altKey&&!a.shiftKey&&!a.ctrlKey||a.keyCode===h.browserBack)&&e.back()}function f(a){a.button===k&&e.back()}var i=0;return{addRef:function(){0===i&&b(),i++},release:function(){i>0&&(i--,0===i&&c())},getCount:function(){return i}}}();b.Namespace.define("WinJS.UI",{BackButton:b.Namespace._lazy(function(){var h={get ariaLabel(){return d._getWinJSString("ui/backbuttonarialabel").value},get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get badButtonElement(){return"Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"}},k=b.Class.define(function(b,d){if(b&&b.winControl)throw new c("WinJS.UI.BackButton.DuplicateConstruction",h.duplicateConstruction);this._element=b||a.document.createElement("button"),d=d||{},this._initializeButton(),this._disposed=!1,this._element.winControl=this,f.setOptions(this,d),this._buttonClickHandler=this._handleBackButtonClick.bind(this),this._element.addEventListener("click",this._buttonClickHandler,!1),this._navigatedHandler=this._handleNavigatedEvent.bind(this),e.addEventListener("navigated",this._navigatedHandler,!1),l.addRef()},{element:{get:function(){return this._element}},dispose:function(){this._disposed||(this._disposed=!0,e.removeEventListener("navigated",this._navigatedHandler,!1),l.release())},refresh:function(){this._element.disabled=e.canGoBack?!1:!0},_initializeButton:function(){if("BUTTON"!==this._element.tagName)throw new c("WinJS.UI.BackButton.BadButtonElement",h.badButtonElement);g.addClass(this._element,i),g.addClass(this._element,"win-disposable"),this._element.innerHTML='',this.refresh(),this._element.setAttribute("aria-label",h.ariaLabel),this._element.setAttribute("title",h.ariaLabel),this._element.setAttribute("type","button")},_handleNavigatedEvent:function(){this.refresh()},_handleBackButtonClick:function(){e.back()}});return k._getReferenceCount=function(){return l.getCount()},b.Class.mix(k,f.DOMEventMixin),k})})}),define("WinJS/Controls/Tooltip",["exports","../Core/_Global","../Core/_WinRT","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Animations","../Animations/_TransitionAnimation","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";d.Namespace._moduleDefine(a,"WinJS.UI",{Tooltip:d.Namespace._lazy(function(){function a(a,b){return"pointerdown"===a?b===G:a in H}function l(a,b){return"pointerdown"===a?b!==G:a in J}var m=0,n=k.Key,o="top",p=h._animationTimeAdjustment(400),q=h._animationTimeAdjustment(1200),r=h._animationTimeAdjustment(400),s=h._animationTimeAdjustment(5e3),t=h._animationTimeAdjustment(0),u=h._animationTimeAdjustment(600),v=h._animationTimeAdjustment(400),w=h._animationTimeAdjustment(600),x=h._animationTimeAdjustment(200),y=h._animationTimeAdjustment(3e5),z=12,A=20,B=45,C=20,D=12,E=1,F=k._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",G=k._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",H={keyup:"",pointerover:"",pointerdown:""},I={pointermove:""},J={pointerdown:"",keydown:"",focusout:"",pointerout:"",pointercancel:"",pointerup:""},K={pointerover:"",pointerout:""},L="win-tooltip",M="win-tooltip-phantom",N=r,O=2*N,P=2.5*N,Q=s,R=!1,S=!1,T=f._createEventProperty;return d.Class.define(function(a,d){a=a||b.document.createElement("div");var e=k.data(a).tooltip;if(e)return e;if(!S&&c.Windows.UI.ViewManagement.UISettings){var f=new c.Windows.UI.ViewManagement.UISettings;N=h._animationTimeAdjustment(f.mouseHoverTime),O=2*N,P=2.5*N,Q=h._animationTimeAdjustment(1e3*f.messageDuration);var g=f.handPreference;R=g===c.Windows.UI.ViewManagement.HandPreference.leftHanded}S=!0,this._disposed=!1,this._placement=o,this._infotip=!1,this._innerHTML=null,this._contentElement=null,this._extraClass=null,this._lastContentType="html",this._anchorElement=a,this._domElement=null,this._phantomDiv=null,this._triggerByOpen=!1,this._eventListenerRemoveStack=[],this._lastKeyOrBlurEvent=null,this._currentKeyOrBlurEvent=null,a.winControl=this,k.addClass(a,"win-disposable"),a.title&&(this._innerHTML=this._anchorElement.title,this._anchorElement.removeAttribute("title")),i.setOptions(this,d),this._events(),k.data(a).tooltip=this},{innerHTML:{get:function(){return this._innerHTML},set:function(a){if(this._innerHTML=a,this._domElement){if(!this._innerHTML||""===this._innerHTML)return void this._onDismiss();this._domElement.innerHTML=a,this._position()}this._lastContentType="html"}},element:{get:function(){return this._anchorElement}},contentElement:{get:function(){return this._contentElement},set:function(a){if(this._contentElement=a,this._domElement){if(!this._contentElement)return void this._onDismiss();this._domElement.innerHTML="",this._domElement.appendChild(this._contentElement),this._position()}this._lastContentType="element"}},placement:{get:function(){return this._placement},set:function(a){"top"!==a&&"bottom"!==a&&"left"!==a&&"right"!==a&&(a=o),this._placement=a,this._domElement&&this._position()}},infotip:{get:function(){return this._infotip},set:function(a){this._infotip=!!a}},extraClass:{get:function(){return this._extraClass},set:function(a){this._extraClass=a}},onbeforeopen:T("beforeopen"),onopened:T("opened"),onbeforeclose:T("beforeclose"),onclosed:T("closed"),dispose:function(){if(!this._disposed){this._disposed=!0,j.disposeSubTree(this.element);for(var a=0,b=this._eventListenerRemoveStack.length;b>a;a++)this._eventListenerRemoveStack[a]();this._onDismiss();var c=k.data(this._anchorElement);c&&delete c.tooltip}},addEventListener:function(a,b,c){if(this._anchorElement){this._anchorElement.addEventListener(a,b,c);var d=this;this._eventListenerRemoveStack.push(function(){d._anchorElement.removeEventListener(a,b,c)})}},removeEventListener:function(a,b,c){this._anchorElement&&this._anchorElement.removeEventListener(a,b,c)},open:function(a){switch(this._triggerByOpen=!0,"touch"!==a&&"mouseover"!==a&&"mousedown"!==a&&"keyboard"!==a&&(a="default"),a){case"touch":this._onInvoke("touch","never");break;case"mouseover":this._onInvoke("mouse","auto");break;case"keyboard":this._onInvoke("keyboard","auto");break;case"mousedown":case"default":this._onInvoke("nodelay","never")}},close:function(){this._onDismiss()},_cleanUpDOM:function(){this._domElement&&(j.disposeSubTree(this._domElement),b.document.body.removeChild(this._domElement),this._domElement=null,b.document.body.removeChild(this._phantomDiv),this._phantomDiv=null)},_createTooltipDOM:function(){this._cleanUpDOM(),this._domElement=b.document.createElement("div");var a=k._uniqueID(this._domElement);this._domElement.setAttribute("id",a);var c=b.document.defaultView.getComputedStyle(this._anchorElement,null),d=this._domElement.style;d.direction=c.direction,d.writingMode=c["writing-mode"],this._domElement.setAttribute("tabindex",-1),this._domElement.setAttribute("role","tooltip"),this._anchorElement.setAttribute("aria-describedby",a),"element"===this._lastContentType?this._domElement.appendChild(this._contentElement):this._domElement.innerHTML=this._innerHTML,b.document.body.appendChild(this._domElement),k.addClass(this._domElement,L),this._extraClass&&k.addClass(this._domElement,this._extraClass),this._phantomDiv=b.document.createElement("div"),this._phantomDiv.setAttribute("tabindex",-1),b.document.body.appendChild(this._phantomDiv),k.addClass(this._phantomDiv,M);var e=b.document.defaultView.getComputedStyle(this._domElement,null).zIndex+1;this._phantomDiv.style.zIndex=e},_raiseEvent:function(a,c){if(this._anchorElement){var d=b.document.createEvent("CustomEvent");d.initCustomEvent(a,!1,!1,c),this._anchorElement.dispatchEvent(d)}},_captureLastKeyBlurOrPointerOverEvent:function(a){switch(this._lastKeyOrBlurEvent=this._currentKeyOrBlurEvent,a.type){case"keyup":this._currentKeyOrBlurEvent=a.keyCode===n.shift?null:"keyboard";break;case"focusout":this._currentKeyOrBlurEvent=null}},_registerEventToListener:function(a,b){var c=this,d=function(a){c._captureLastKeyBlurOrPointerOverEvent(a),c._handleEvent(a)};k._addEventListener(a,b,d,!1),this._eventListenerRemoveStack.push(function(){k._removeEventListener(a,b,d,!1)})},_events:function(){for(var a in H)this._registerEventToListener(this._anchorElement,a);for(var a in I)this._registerEventToListener(this._anchorElement,a);for(a in J)this._registerEventToListener(this._anchorElement,a);this._registerEventToListener(this._anchorElement,"contextmenu"),this._registerEventToListener(this._anchorElement,"MSHoldVisual")},_handleEvent:function(b){var c=b._normalizedType||b.type;if(!this._triggerByOpen){if(c in K&&k.eventWithinElement(this._anchorElement,b))return;if(a(c,b.pointerType))if(b.pointerType===G)this._isShown||(this._showTrigger="touch"),this._onInvoke("touch","never",b);else{if(this._skipMouseOver&&b.pointerType===F&&"pointerover"===c)return void(this._skipMouseOver=!1);var d="key"===c.substring(0,3)?"keyboard":"mouse";this._isShown||(this._showTrigger=d),this._onInvoke(d,"auto",b)}else if(c in I)this._contactPoint={x:b.clientX,y:b.clientY};else if(l(c,b.pointerType)){var f;if(b.pointerType===G){if("pointerup"===c){this._skipMouseOver=!0;var g=this;e._yieldForEvents(function(){g._skipMouseOver=!1})}f="touch"}else f="key"===c.substring(0,3)?"keyboard":"mouse";if("focusout"!==c&&f!==this._showTrigger)return;this._onDismiss()}else("contextmenu"===c||"MSHoldVisual"===c)&&b.preventDefault()}},_onShowAnimationEnd:function(){if(!this._shouldDismiss&&!this._disposed&&(this._raiseEvent("opened"),this._domElement&&"never"!==this._hideDelay)){var a=this,b=this._infotip?Math.min(3*Q,y):Q;this._hideDelayTimer=this._setTimeout(function(){a._onDismiss()},b)}},_onHideAnimationEnd:function(){b.document.body.removeEventListener("DOMNodeRemoved",this._removeTooltip,!1),this._cleanUpDOM(),this._anchorElement&&this._anchorElement.removeAttribute("aria-describedby"),m=(new Date).getTime(),this._triggerByOpen=!1,this._disposed||this._raiseEvent("closed")},_decideOnDelay:function(a){var b;if(this._useAnimation=!0,"nodelay"===a)b=0,this._useAnimation=!1;else{var c=(new Date).getTime();x>=c-m?(b="touch"===a?this._infotip?v:t:this._infotip?w:u,this._useAnimation=!1):b="touch"===a?this._infotip?q:p:this._infotip?P:O}return b},_getAnchorPositionFromElementWindowCoord:function(){var a=this._anchorElement.getBoundingClientRect();return{x:a.left,y:a.top,width:a.width,height:a.height}},_getAnchorPositionFromPointerWindowCoord:function(a){return{x:a.x,y:a.y,width:1,height:1}},_canPositionOnSide:function(a,b,c,d){var e=0,f=0;switch(a){case"top":e=d.width+this._offset,f=c.y;break;case"bottom":e=d.width+this._offset,f=b.height-c.y-c.height;break;case"left":e=c.x,f=d.height+this._offset;break;case"right":e=b.width-c.x-c.width,f=d.height+this._offset}return e>=d.width+this._offset&&f>=d.height+this._offset},_positionOnSide:function(a,b,c,d){var e=0,f=0;switch(a){case"top":case"bottom":e=c.x+c.width/2-d.width/2,e=Math.min(Math.max(e,0),b.width-d.width-E),f="top"===a?c.y-d.height-this._offset:c.y+c.height+this._offset;break;case"left":case"right":f=c.y+c.height/2-d.height/2,f=Math.min(Math.max(f,0),b.height-d.height-E),e="left"===a?c.x-d.width-this._offset:c.x+c.width+this._offset}this._domElement.style.left=e+"px",this._domElement.style.top=f+"px",this._phantomDiv.style.left=e+"px",this._phantomDiv.style.top=f+"px",this._phantomDiv.style.width=d.width+"px",this._phantomDiv.style.height=d.height+"px"},_position:function(a){var c={width:0,height:0},d={x:0,y:0,width:0,height:0},e={width:0,height:0};c.width=b.document.documentElement.clientWidth,c.height=b.document.documentElement.clientHeight,"tb-rl"===b.document.defaultView.getComputedStyle(b.document.body,null)["writing-mode"]&&(c.width=b.document.documentElement.clientHeight,c.height=b.document.documentElement.clientWidth),d=!this._contactPoint||"touch"!==a&&"mouse"!==a?this._getAnchorPositionFromElementWindowCoord():this._getAnchorPositionFromPointerWindowCoord(this._contactPoint),e.width=this._domElement.offsetWidth,e.height=this._domElement.offsetHeight;var f={top:["top","bottom","left","right"],bottom:["bottom","top","left","right"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]};R&&(f.top[2]="right",f.top[3]="left",f.bottom[2]="right",f.bottom[3]="left");for(var g=f[this._placement],h=g.length,i=0;h>i;i++)if(i===h-1||this._canPositionOnSide(g[i],c,d,e)){this._positionOnSide(g[i],c,d,e);break}return g[i]},_showTooltip:function(a){if(!this._shouldDismiss&&(this._isShown=!0,this._raiseEvent("beforeopen"),b.document.body.contains(this._anchorElement)&&!this._shouldDismiss)){if("element"===this._lastContentType){if(!this._contentElement)return void(this._isShown=!1)}else if(!this._innerHTML||""===this._innerHTML)return void(this._isShown=!1);var c=this;this._removeTooltip=function(a){for(var d=c._anchorElement;d;){if(a.target===d){b.document.body.removeEventListener("DOMNodeRemoved",c._removeTooltip,!1),c._cleanUpDOM();break}d=d.parentNode}},b.document.body.addEventListener("DOMNodeRemoved",this._removeTooltip,!1),this._createTooltipDOM(),this._position(a),this._useAnimation?g.fadeIn(this._domElement).then(this._onShowAnimationEnd.bind(this)):this._onShowAnimationEnd()}},_onInvoke:function(a,b,c){if(this._shouldDismiss=!1,!this._isShown&&(!c||"keyup"!==c.type||"keyboard"!==this._lastKeyOrBlurEvent&&(this._lastKeyOrBlurEvent||c.keyCode===n.tab))){this._hideDelay=b,this._contactPoint=null,c?(this._contactPoint={x:c.clientX,y:c.clientY},this._offset="touch"===a?B:"keyboard"===a?z:A):this._offset="touch"===a?C:D,this._clearTimeout(this._delayTimer),this._clearTimeout(this._hideDelayTimer);var d=this._decideOnDelay(a);if(d>0){var e=this;this._delayTimer=this._setTimeout(function(){e._showTooltip(a)},d)}else this._showTooltip(a)}},_onDismiss:function(){this._shouldDismiss=!0,this._isShown&&(this._isShown=!1,this._showTrigger="mouse",this._domElement?(this._raiseEvent("beforeclose"),this._useAnimation?g.fadeOut(this._domElement).then(this._onHideAnimationEnd.bind(this)):this._onHideAnimationEnd()):(this._raiseEvent("beforeclose"),this._raiseEvent("closed")))},_setTimeout:function(a,c){return b.setTimeout(a,c)},_clearTimeout:function(a){b.clearTimeout(a)}},{_DELAY_INITIAL_TOUCH_SHORT:{get:function(){return p}},_DELAY_INITIAL_TOUCH_LONG:{get:function(){return q}},_DEFAULT_MOUSE_HOVER_TIME:{get:function(){return r}},_DEFAULT_MESSAGE_DURATION:{get:function(){return s}},_DELAY_RESHOW_NONINFOTIP_TOUCH:{get:function(){return t}},_DELAY_RESHOW_NONINFOTIP_NONTOUCH:{get:function(){return u}},_DELAY_RESHOW_INFOTIP_TOUCH:{get:function(){return v}},_DELAY_RESHOW_INFOTIP_NONTOUCH:{get:function(){return w}},_RESHOW_THRESHOLD:{get:function(){return x}},_HIDE_DELAY_MAX:{get:function(){return y}}})})})}),define("WinJS/Controls/Rating",["../Core/_Global","../Core/_Base","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_SafeHtml","./Tooltip","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j){"use strict";b.Namespace.define("WinJS.UI",{Rating:b.Namespace._lazy(function(){var h=d._createEventProperty,k={get averageRating(){return e._getWinJSString("ui/averageRating").value},get clearYourRating(){return e._getWinJSString("ui/clearYourRating").value},get tentativeRating(){return e._getWinJSString("ui/tentativeRating").value},get tooltipStringsIsInvalid(){return"Invalid argument: tooltipStrings must be null or an array of strings."},get unrated(){return e._getWinJSString("ui/unrated").value},get userRating(){return e._getWinJSString("ui/userRating").value}},l=5,m=!1,n="cancel",o="change",p="previewchange",q=0,r=g._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",s=g._MSPointerEvent.MSPOINTER_TYPE_PEN||"pen",t=g._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",u="padding-left: 0px; padding-right: 0px; border-left: 0px; border-right: 0px; -ms-flex: none; -webkit-flex: none; flex: none; display: none",v="win-rating",w="win-star win-empty",x="win-star win-average win-empty",y="win-star win-average win-full",z="win-star win-user win-empty",A="win-star win-user win-full",B="win-star win-tentative win-empty",C="win-star win-tentative win-full",D="win-disabled",E="win-average",F="win-user";return b.Class.define(function(b,c){this._disposed=!1,b=b||a.document.createElement("div"),c=c||{},this._element=b,g.addClass(this._element,"win-disposable"),this._userRating=0,this._averageRating=0,this._disabled=m,this._enableClear=!0,this._tooltipStrings=[],this._controlUpdateNeeded=!1,this._setControlSize(c.maxRating),c.tooltipStrings||this._updateTooltips(null),f.setOptions(this,c),this._controlUpdateNeeded=!0,this._forceLayout(),g._addInsertedNotifier(this._element),b.winControl=this,this._events()},{maxRating:{get:function(){return this._maxRating},set:function(a){this._setControlSize(a),this._forceLayout()}},userRating:{get:function(){return this._userRating},set:function(a){this._userRating=Math.max(0,Math.min(Number(a)>>0,this._maxRating)),this._updateControl()}},averageRating:{get:function(){return this._averageRating},set:function(a){this._averageRating=Number(a)<1?0:Math.min(Number(a)||0,this._maxRating),this._averageRatingElement&&this._ensureAverageMSStarRating(),this._updateControl()}},disabled:{get:function(){return this._disabled},set:function(a){this._disabled=!!a,this._disabled&&this._clearTooltips(),this._updateTabIndex(),this._updateControl()}},enableClear:{get:function(){return this._enableClear},set:function(a){this._enableClear=!!a,this._setAriaValueMin(),this._updateControl()}},tooltipStrings:{get:function(){return this._tooltipStrings},set:function(a){if("object"!=typeof a)throw new c("WinJS.UI.Rating.TooltipStringsIsInvalid",k.tooltipStringsIsInvalid);this._updateTooltips(a),this._updateAccessibilityRestState()}},element:{get:function(){return this._element}},oncancel:h(n),onchange:h(o),onpreviewchange:h(p),dispose:function(){if(!this._disposed){this._disposed=!0;for(var a=0;a":a+"
";i.setInnerHTMLUnsafe(this._element,a);for(var c=this._element.firstElementChild,b=0;c;)this._elements[b]=c,b0?(a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuenow",this._tentativeRating),a.setAttribute("aria-valuetext",this._getText(this._tentativeRating-1))):0===this._tentativeRating?(a.setAttribute("aria-valuenow",k.unrated),a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuetext",this._getText(this._maxRating))):(a.setAttribute("aria-valuenow",k.unrated),a.setAttribute("aria-label",k.tentativeRating),a.setAttribute("aria-valuetext",k.unrated)),this._ariaValueNowMutationObserver&&this._ariaValueNowMutationObserver.observe(this._element,{attributes:!0,attributeFilter:["aria-valuenow"]})},_ensureTooltips:function(){if(!this.disabled&&0===this._toolTips.length)for(var a=0;a0?this._tentativeRating--:-1===this._tentativeRating&&(this._tentativeRating=0!==this._userRating&&this._userRating>0?this._userRating-1:0),0!==this._tentativeRating||this._enableClear||(this._tentativeRating=1,a=!1)),this._showTentativeRating(a,"keyboard")},_events:function(){function a(a){return{name:a,lowerCaseName:a.toLowerCase(),handler:function(b){var d=c["_on"+a];d&&d.apply(c,[b])}}}var b,c=this,d=[a("KeyDown"),a("FocusOut"),a("FocusIn"),a("PointerCancel"),a("PointerDown"),a("PointerMove"),a("PointerOver"),a("PointerUp"),a("PointerOut")],e=[a("WinJSNodeInserted")];for(b=0;bh;h++){var j=f[h];if("tooltip"===j.getAttribute("role"))return;if(g.hasClass(j,"win-star")){d=j;break}}var k;if(d&&d.parentElement===this._element)k=g.data(d).msStarRating||0;else{var l=0,m=this.maxRating;"rtl"===a.getComputedStyle(this._element).direction&&(l=m,m=0),k=b.clientX=c.num0&&d<=c.num9?h=c.num0:d>=c.numPad0&&d<=c.numPad9&&(h=c.numPad0),h>0){var i=!1,j=Math.min(d-h,this._maxRating);0!==j||this._enableClear||(j=1),j!==this._tentativeRating&&(this._closeTooltip(),i=!0),this._tentativeRating=j,this._showTentativeRating(i,"keyboard")}else f=!1}f&&(b.stopPropagation(),b.preventDefault())},_onPointerOut:function(a){this._captured||g.eventWithinElement(this._element,a)||(this._showCurrentRating(),this._lastEventWasChange||this._raiseEvent(n,null))},_onUserRatingChanged:function(){this._disabled||(this._closeTooltip(),this._userRating===this._tentativeRating||this._lastEventWasCancel||this._lastEventWasChange?this._updateControl():(this.userRating=this._tentativeRating,this._raiseEvent(o,this._userRating)))},_raiseEvent:function(b,c){if(!this._disabled&&(this._lastEventWasChange=b===o,this._lastEventWasCancel=b===n,a.document.createEvent)){var d=a.document.createEvent("CustomEvent");d.initCustomEvent(b,!1,!1,{tentativeRating:c}),this._element.dispatchEvent(d)}},_resetNextElement:function(b){if(null!==this._averageRatingElement.nextSibling){g._setFlexStyle(this._averageRatingElement.nextSibling,{grow:1,shrink:1});var c=this._averageRatingElement.nextSibling.style,d=a.getComputedStyle(this._element).direction;b&&(d="rtl"===d?"ltr":"rtl"),"rtl"===d?(c.paddingRight=this._elementPadding,c.borderRight=this._elementBorder,c.direction="rtl"):(c.paddingLeft=this._elementPadding,c.borderLeft=this._elementBorder,c.direction="ltr"),c.backgroundPosition="left",c.backgroundSize="100% 100%",c.width=this._resizeStringValue(this._elementWidth,1,c.width)}},_resetAverageStar:function(a){this._resetNextElement(a),this._hideAverageRating()},_resizeStringValue:function(a,b,c){var d=parseFloat(a);if(isNaN(d))return null!==c?c:a;var e=a.substring(d.toString(10).length);return d*=b,d+e},_setControlSize:function(a){var b=(Number(a)||l)>>0;this._maxRating=b>0?b:l},_updateTooltips:function(a){var b,c=0;if(null!==a)for(c=a.length<=this._maxRating+1?a.length:this._maxRating+1,b=0;c>b;b++)this._tooltipStrings[b]=a[b];else{for(b=0;bd?a:c},_updateAverageStar:function(){var b=this._averageRatingElement.style,c=this._averageRatingElement.nextSibling.style;"rtl"===a.getComputedStyle(this._element).direction?(b.backgroundPosition="right",b.paddingRight=this._elementPadding,b.borderRight=this._elementBorder,c.paddingRight="0px",c.borderRight="0px",c.direction="ltr"):(b.backgroundPosition="left",c.backgroundPosition="right",b.paddingLeft=this._elementPadding,b.borderLeft=this._elementBorder,c.paddingLeft="0px",c.borderLeft="0px",c.direction="rtl"),g._setFlexStyle(this._averageRatingElement,{grow:this._floatingValue,shrink:this._floatingValue}),b.width=this._resizeStringValue(this._elementWidth,this._floatingValue,b.width),b.backgroundSize=100/this._floatingValue+"% 100%",b.display=a.getComputedStyle(this._averageRatingElement.nextSibling).display,this._averageRatingHidden=!1,g._setFlexStyle(this._averageRatingElement.nextSibling,{grow:1-this._floatingValue,shrink:1-this._floatingValue}),c.width=this._resizeStringValue(this._elementWidth,1-this._floatingValue,c.width),c.backgroundSize=100/(1-this._floatingValue)+"% 100%"},_showCurrentRating:function(){this._closeTooltip(),this._tentativeRating=-1,this._disabled||this._updateControl(),this._updateAccessibilityRestState()},_showTentativeRating:function(a,b){!this._disabled&&this._tentativeRating>=0&&(this._setStarClasses(C,this._tentativeRating,B),this._hideAverageStar()),this._updateAccessibilityHoverState(),a&&(this._openTooltip(b),this._raiseEvent(p,this._tentativeRating))},_openTooltip:function(b){if(!this.disabled)if(this._ensureTooltips(),this._tentativeRating>0)this._toolTips[this._tentativeRating-1].innerHTML=this._tooltipStrings[this._tentativeRating-1],this._toolTips[this._tentativeRating-1].open(b);else if(0===this._tentativeRating){this._clearElement=a.document.createElement("div");var c=this._elements[0].offsetWidth+parseInt(this._elementPadding,10);"ltr"===a.getComputedStyle(this._element).direction&&(c*=-1),this._clearElement.style.cssText="visiblity:hidden; position:absolute; width:0px; height:100%; left:"+c+"px; top:0px;",this._elements[0].appendChild(this._clearElement),this._toolTips[this._maxRating]=new j.Tooltip(this._clearElement),this._toolTips[this._maxRating].innerHTML=this._tooltipStrings[this._maxRating],this._toolTips[this._maxRating].open(b) +}},_closeTooltip:function(){0!==this._toolTips.length&&(this._tentativeRating>0?this._toolTips[this._tentativeRating-1].close():0===this._tentativeRating&&null!==this._clearElement&&(this._toolTips[this._maxRating].close(),this._elements[0].removeChild(this._clearElement),this._clearElement=null))},_clearTooltips:function(){if(this._toolTips&&0!==this._toolTips.length)for(var a=0;ad?a:c},_ensureAverageMSStarRating:function(){g.data(this._averageRatingElement).msStarRating=Math.ceil(this._averageRating)},_updateControl:function(){if(this._controlUpdateNeeded){if(0!==this._averageRating&&0===this._userRating&&this._averageRating>=1&&this._averageRating<=this._maxRating){this._setClasses(y,this._averageRating-1,x),this._averageRatingElement.className=y;for(var b=0;b=this._averageRating){this._resetNextElement(!1),this._element.insertBefore(this._averageRatingElement,this._elements[b]),this._floatingValue=this._averageRating-b;var c=a.getComputedStyle(this._elements[b]);this._elementWidth=c.width,"rtl"===a.getComputedStyle(this._element).direction?(this._elementPadding=c.paddingRight,this._elementBorder=c.borderRight):(this._elementPadding=c.paddingLeft,this._elementBorder=c.borderLeft),this._updateAverageStar()}}0!==this._userRating&&this._userRating>=1&&this._userRating<=this._maxRating&&(this._setClasses(A,this._userRating,z),this._resetAverageStar(!1)),0===this._userRating&&0===this._averageRating&&(this._setClasses(w,this._maxRating),this._resetAverageStar(!1)),this.disabled&&this._appendClass(D),this._appendClass(0!==this._averageRating&&0===this._userRating?E:F),this._updateAccessibilityRestState()}}})})})}),define("WinJS/Controls/ToggleSwitch",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_Events","../Core/_Resources","../Utilities/_Control","../Utilities/_ElementUtilities","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g){"use strict";b.Namespace.define("WinJS.UI",{ToggleSwitch:b.Namespace._lazy(function(){var c="win-toggleswitch",h="win-toggleswitch-header",i="win-toggleswitch-clickregion",j="win-toggleswitch-track",k="win-toggleswitch-fill",l="win-toggleswitch-fill-lower",m="win-toggleswitch-fill-upper",n="win-toggleswitch-thumb",o="win-toggleswitch-values",p="win-toggleswitch-value",q="win-toggleswitch-value-on",r="win-toggleswitch-value-off",s="win-toggleswitch-description",t="win-toggleswitch-on",u="win-toggleswitch-off",v="win-toggleswitch-disabled",w="win-toggleswitch-enabled",x="win-toggleswitch-dragging",y="win-toggleswitch-pressed",z={get on(){return e._getWinJSString("ui/on").value},get off(){return e._getWinJSString("ui/off").value}},A=b.Class.define(function(b,d){b=b||a.document.createElement("div"),this._domElement=b,g.addClass(this._domElement,c),this._domElement.innerHTML=['
','
','
','
',"
",'
','
','
','
','
',"
","
",'
'].join("\n"),this._headerElement=this._domElement.firstElementChild,this._labelsElement=this._headerElement.nextElementSibling,this._labelOnElement=this._labelsElement.firstElementChild,this._labelOffElement=this._labelOnElement.nextElementSibling,this._clickElement=this._labelsElement.nextElementSibling,this._trackElement=this._clickElement.firstElementChild,this._fillLowerElement=this._trackElement.firstElementChild,this._thumbElement=this._fillLowerElement.nextElementSibling,this._fillUpperElement=this._thumbElement.nextElementSibling,this._descriptionElement=this._clickElement.nextElementSibling,this._headerElement.setAttribute("aria-hidden",!0),this._labelsElement.setAttribute("aria-hidden",!0),this._headerElement.setAttribute("id",g._uniqueID(this._headerElement)),this._domElement.setAttribute("aria-labelledby",this._headerElement.id),this._domElement.setAttribute("role","checkbox"),this._domElement.winControl=this,g.addClass(this._domElement,"win-disposable"),this._domElement.addEventListener("keydown",this._keyDownHandler.bind(this)),g._addEventListener(this._clickElement,"pointerdown",this._pointerDownHandler.bind(this)),g._globalListener.addEventListener(this._domElement,"pointermove",this._pointerMoveHandler.bind(this)),g._globalListener.addEventListener(this._domElement,"pointerup",this._pointerUpHandler.bind(this)),this._mutationObserver=new g._MutationObserver(this._ariaChangedHandler.bind(this)),this._mutationObserver.observe(this._domElement,{attributes:!0,attributeFilter:["aria-checked"]}),this._dragX=0,this._dragging=!1,this.checked=!1,this.disabled=!1,this.labelOn=z.on,this.labelOff=z.off,f.setOptions(this,d)},{element:{get:function(){return this._domElement}},checked:{get:function(){return this._checked},set:function(a){a=!!a,a!==this.checked&&(this._checked=a,this._domElement.setAttribute("aria-checked",a),a?(g.addClass(this._domElement,t),g.removeClass(this._domElement,u)):(g.addClass(this._domElement,u),g.removeClass(this._domElement,t)),this.dispatchEvent("change"))}},disabled:{get:function(){return this._disabled},set:function(a){a=!!a,a!==this._disabled&&(a?(g.addClass(this._domElement,v),g.removeClass(this._domElement,w)):(g.removeClass(this._domElement,v),g.addClass(this._domElement,w)),this._disabled=a,this._domElement.setAttribute("aria-disabled",a),this._domElement.setAttribute("tabIndex",a?-1:0))}},labelOn:{get:function(){return this._labelOnElement.innerHTML},set:function(a){this._labelOnElement.innerHTML=a}},labelOff:{get:function(){return this._labelOffElement.innerHTML},set:function(a){this._labelOffElement.innerHTML=a}},title:{get:function(){return this._headerElement.innerHTML},set:function(a){this._headerElement.innerHTML=a}},onchange:d._createEventProperty("change"),dispose:function(){this._disposed||(this._disposed=!0)},_ariaChangedHandler:function(){var a=this._domElement.getAttribute("aria-checked");a="true"===a?!0:!1,this.checked=a},_keyDownHandler:function(a){this.disabled||(a.keyCode===g.Key.space&&(this.checked=!this.checked),(a.keyCode===g.Key.rightArrow||a.keyCode===g.Key.upArrow)&&(this.checked=!0),(a.keyCode===g.Key.leftArrow||a.keyCode===g.Key.downArrow)&&(this.checked=!1))},_pointerDownHandler:function(a){this.disabled||(a.preventDefault(),this._mousedown=!0,this._dragXStart=a.pageX-this._trackElement.offsetLeft-this._thumbElement.offsetWidth/2,this._dragX=this._dragXStart,this._dragging=!1,g.addClass(this._domElement,y))},_pointerUpHandler:function(b){if(!this.disabled&&this._mousedown){b=b.detail.originalEvent,b.preventDefault();var c="rtl"===a.getComputedStyle(this._domElement).direction;if(this._dragging){var d=this._trackElement.offsetWidth-this._thumbElement.offsetWidth;this.checked=c?this._dragX=d/2,this._dragging=!1,g.removeClass(this._domElement,x)}else this.checked=!this.checked;this._mousedown=!1,this._thumbElement.style.left="",this._fillLowerElement.style.width="",this._fillUpperElement.style.width="",g.removeClass(this._domElement,y)}},_pointerMoveHandler:function(a){if(!this.disabled&&this._mousedown){a=a.detail.originalEvent,a.preventDefault();var b=a.pageX-this._trackElement.offsetLeft-this._thumbElement.offsetWidth/2,c=this._trackElement.offsetWidth-this._thumbElement.offsetWidth,d=this._fillLowerElement.offsetLeft+this._trackElement.clientLeft;this._dragX=Math.min(c,b),this._dragX=Math.max(0,this._dragX),!this._dragging&&Math.abs(this._dragX-this._dragXStart)>3&&(this._dragging=!0,g.addClass(this._domElement,x)),this._thumbElement.style.left=this._dragX+"px",this._fillLowerElement.style.width=this._dragX-d+"px",this._fillUpperElement.style.width=c-this._dragX-d+"px"}}});return b.Class.mix(A,f.DOMEventMixin),A})})}),define("WinJS/Controls/SemanticZoom",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../ControlProcessor","../Promise","../Utilities/_Control","../Utilities/_Dispose","../Utilities/_ElementUtilities","../Utilities/_ElementListUtilities","../Utilities/_Hoverable","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";b.Namespace.define("WinJS.UI",{SemanticZoom:b.Namespace._lazy(function(){function f(a){return a}function q(a,b,c){return a+" "+i._animationTimeAdjustment(b)+"s "+c+" "+i._libraryDelay+"ms"}function r(){return q(X.cssName,Q,"ease-in-out")+", "+q("opacity",O,"ease-in-out")}function s(){return q(X.cssName,R,"ease-in-out")+", "+q("opacity",P,"ease-in-out")}function t(){return q(X.cssName,U,W)}function u(){return q(X.cssName,V,W)}function v(a,b){return n.convertToPixels(a,b)}function w(a,b){i.isAnimationEnabled()&&(a.style[X.scriptName]="scale("+b+")")}function x(a){var b=a.target&&a.target.winControl;b&&!b._resizing&&b._onResize()}function y(a){var b=a[0].target&&a[0].target.winControl;b&&b instanceof hb&&b._onPropertyChanged()}var z=c._browserStyleEquivalents,A={get invalidZoomFactor(){return"Invalid zoomFactor"}},B="win-semanticzoom-button",C="win-semanticzoom-button-location",D=3e3,E=8,F="win-semanticzoom",G="win-semanticzoom-zoomedinview",H="win-semanticzoom-zoomedoutview",I="zoomchanged",J=1.05,K=.65,L=.8,M=.2,N=4096,O=.333,P=.333,Q=.333,R=.333,S=1e3*O,T=50,U=.333,V=.333,W="cubic-bezier(0.1,0.9,0.2,1)",X=z.transform,Y=z.transition.scriptName,Z=2,$=.2,_=.45,ab=1e3,bb=50,cb={none:0,zoomedIn:1,zoomedOut:2},db=n._MSPointerEvent.MSPOINTER_TYPE_TOUCH||"touch",eb=n._MSPointerEvent.MSPOINTER_TYPE_PEN||"pen",fb=n._MSPointerEvent.MSPOINTER_TYPE_MOUSE||"mouse",gb={x:0,y:0},hb=b.Class.define(function(b,e){this._disposed=!1;var f=this,g=c.isPhone;this._element=b,this._element.winControl=this,n.addClass(this._element,"win-disposable"),n.addClass(this._element,F),this._element.setAttribute("role","ms-semanticzoomcontainer");var h=this._element.getAttribute("aria-label");if(h||this._element.setAttribute("aria-label",""),e=e||{},this._zoomedOut=!!e.zoomedOut||!!e.initiallyZoomedOut||!1,this._enableButton=!g,g||void 0===e.enableButton||(this._enableButton=!!e.enableButton),this._element.setAttribute("aria-checked",this._zoomedOut.toString()),this._zoomFactor=n._clamp(e.zoomFactor,M,L,K),this.zoomedInItem=e.zoomedInItem,this.zoomedOutItem=e.zoomedOutItem,c.validation&&e._zoomFactor&&e._zoomFactor!==this._zoomFactor)throw new d("WinJS.UI.SemanticZoom.InvalidZoomFactor",A.invalidZoomFactor);this._locked=!!e.locked,this._zoomInProgress=!1,this._isBouncingIn=!1,this._isBouncing=!1,this._zooming=!1,this._aligning=!1,this._gesturing=!1,this._gestureEnding=!1,this._buttonShown=!1,this._shouldFakeTouchCancel="TouchEvent"in a,this._initialize(),this._configure(),this._element.addEventListener("mselementresize",x),n._resizeNotifier.subscribe(this._element,x),new n._MutationObserver(y).observe(this._element,{attributes:!0,attributeFilter:["aria-checked"]}),g||(this._element.addEventListener("wheel",this._onWheel.bind(this),!0),this._element.addEventListener("mousewheel",this._onMouseWheel.bind(this),!0),this._element.addEventListener("keydown",this._onKeyDown.bind(this),!0),n._addEventListener(this._element,"pointerdown",this._onPointerDown.bind(this),!0),n._addEventListener(this._element,"pointermove",this._onPointerMove.bind(this),!0),n._addEventListener(this._element,"pointerout",this._onPointerOut.bind(this),!0),n._addEventListener(this._element,"pointercancel",this._onPointerCancel.bind(this),!0),n._addEventListener(this._element,"pointerup",this._onPointerUp.bind(this),!1),this._hiddenElement.addEventListener("gotpointercapture",this._onGotPointerCapture.bind(this),!1),this._hiddenElement.addEventListener("lostpointercapture",this._onLostPointerCapture.bind(this),!1),this._element.addEventListener("click",this._onClick.bind(this),!0),this._canvasIn.addEventListener(c._browserEventEquivalents.transitionEnd,this._onCanvasTransitionEnd.bind(this),!1),this._canvasOut.addEventListener(c._browserEventEquivalents.transitionEnd,this._onCanvasTransitionEnd.bind(this),!1),this._element.addEventListener("MSContentZoom",this._onMSContentZoom.bind(this),!0),this._resetPointerRecords()),this._onResizeImpl(),l._setOptions(this,e,!0),f._setVisibility()},{element:{get:function(){return this._element}},enableButton:{get:function(){return this._enableButton},set:function(a){var b=!!a;this._enableButton===b||c.isPhone||(this._enableButton=b,b?this._createSemanticZoomButton():this._removeSemanticZoomButton())}},zoomedOut:{get:function(){return this._zoomedOut},set:function(a){this._zoom(!!a,{x:.5*this._sezoClientWidth,y:.5*this._sezoClientHeight},!1,!1,this._zoomedOut&&c.isPhone)}},zoomFactor:{get:function(){return this._zoomFactor},set:function(a){var b=this._zoomFactor,c=n._clamp(a,M,L,K);b!==c&&(this._zoomFactor=c,this._onResize())}},locked:{get:function(){return this._locked},set:function(a){this._locked=!!a,a?this._hideSemanticZoomButton():this._displayButton()}},zoomedInItem:{get:function(){return this._zoomedInItem},set:function(a){this._zoomedInItem=a||f}},zoomedOutItem:{get:function(){return this._zoomedOutItem},set:function(a){this._zoomedOutItem=a||f}},dispose:function(){this._disposed||(this._disposed=!0,n._resizeNotifier.unsubscribe(this._element,x),m._disposeElement(this._elementIn),m._disposeElement(this._elementOut),this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer))},forceLayout:function(){this._onResizeImpl()},_initialize:function(){var b=o.children(this._element);this._elementIn=b[0],this._elementOut=b[1],this._elementIn.style.height=this._elementOut.style.height=this._element.offsetHeight+"px",j.processAll(this._elementIn),j.processAll(this._elementOut),this._viewIn=this._elementIn.winControl.zoomableView,this._viewOut=this._elementOut.winControl.zoomableView,this._element.removeChild(this._elementOut),this._element.removeChild(this._elementIn),this._element.innerHTML="",this._cropViewport=a.document.createElement("div"),this._element.appendChild(this._cropViewport),this._viewportIn=a.document.createElement("div"),this._opticalViewportIn=a.document.createElement("div"),this._viewportOut=a.document.createElement("div"),this._opticalViewportOut=a.document.createElement("div"),this._opticalViewportIn.appendChild(this._viewportIn),this._opticalViewportOut.appendChild(this._viewportOut),this._cropViewport.appendChild(this._opticalViewportIn),this._cropViewport.appendChild(this._opticalViewportOut),this._canvasIn=a.document.createElement("div"),this._canvasOut=a.document.createElement("div"),this._viewportIn.appendChild(this._canvasIn),this._viewportOut.appendChild(this._canvasOut),this._canvasIn.appendChild(this._elementIn),this._canvasOut.appendChild(this._elementOut),this._enableButton&&this._createSemanticZoomButton(),this._hiddenElement=a.document.createElement("div"),this._hiddenElement.tabIndex=-1,this._hiddenElement.visibility="hidden",this._hiddenElement.setAttribute("aria-hidden","true"),this._element.appendChild(this._hiddenElement),n.addClass(this._elementIn,G),n.addClass(this._elementOut,H),this._setLayout(this._element,"relative","hidden"),this._setLayout(this._cropViewport,"absolute","hidden"),this._setLayout(this._opticalViewportIn,"absolute","auto"),this._setLayout(this._opticalViewportOut,"absolute","auto"),this._setLayout(this._viewportIn,"absolute","hidden"),this._setLayout(this._viewportOut,"absolute","hidden"),this._setLayout(this._canvasIn,"absolute","hidden"),this._setLayout(this._canvasOut,"absolute","hidden"),this._setupOpticalViewport(this._opticalViewportIn),this._setupOpticalViewport(this._opticalViewportOut),this._viewportIn.style["-ms-overflow-style"]="-ms-autohiding-scrollbar",this._viewportOut.style["-ms-overflow-style"]="-ms-autohiding-scrollbar",this._elementIn.style.position="absolute",this._elementOut.style.position="absolute"},_createSemanticZoomButton:function(){this._sezoButton=a.document.createElement("button"),this._sezoButton.className=B+" "+C,this._sezoButton.tabIndex=-1,this._sezoButton.style.visibility="hidden",this._sezoButton.setAttribute("aria-hidden",!0),this._element.appendChild(this._sezoButton),this._sezoButton.addEventListener("click",this._onSeZoButtonZoomOutClick.bind(this),!1),this._element.addEventListener("scroll",this._onSeZoChildrenScroll.bind(this),!0),n._addEventListener(this._element,"pointermove",this._onPenHover.bind(this),!1)},_removeSemanticZoomButton:function(){this._sezoButton&&(this._element.removeChild(this._sezoButton),this._sezoButton=null)},_configure:function(){var a=this._viewIn.getPanAxis(),b=this._viewOut.getPanAxis(),d=c.isPhone;if(this._pansHorizontallyIn="horizontal"===a||"both"===a,this._pansVerticallyIn="vertical"===a||"both"===a,this._pansHorizontallyOut="horizontal"===b||"both"===b,this._pansVerticallyOut="vertical"===b||"both"===b,!this._zoomInProgress){var e=1/this._zoomFactor-1,f=J-1;this._setLayout(this._elementIn,"absolute","visible"),this._setLayout(this._elementOut,"absolute","visible"),this._viewIn.configureForZoom(!1,!this._zoomedOut,this._zoomFromCurrent.bind(this,!0),e),this._viewOut.configureForZoom(!0,this._zoomedOut,this._zoomFromCurrent.bind(this,!1),f),this._pinching=!1,this._pinchGesture=0,this._canvasLeftIn=0,this._canvasTopIn=0,this._canvasLeftOut=0,this._canvasTopOut=0,d||(this._zoomedOut?w(this._canvasIn,this._zoomFactor):w(this._canvasOut,1/this._zoomFactor));var g=this._opticalViewportIn.style,h=this._opticalViewportOut.style,j=this._canvasIn.style,k=this._canvasOut.style;j.opacity=this._zoomedOut&&!d?0:1,k.opacity=this._zoomedOut?1:0,d&&(j.zIndex=1,k.zIndex=2),i.isAnimationEnabled()&&!d&&(g[z["transition-property"].scriptName]=X.cssName,g[z["transition-duration"].scriptName]="0s",g[z["transition-timing-function"].scriptName]="linear",h[z["transition-property"].scriptName]=X.cssName,h[z["transition-duration"].scriptName]="0s",h[z["transition-timing-function"].scriptName]="linear")}},_onPropertyChanged:function(){var a=this._element.getAttribute("aria-checked"),b="true"===a;this._zoomedOut!==b&&(this.zoomedOut=b)},_onResizeImpl:function(){this._resizing=this._resizing||0,this._resizing++;try{var b=function(a,b,c,d,e){var f=a.style;f.left=b+"px",f.top=c+"px",f.width=d+"px",f.height=e+"px"},c=a.getComputedStyle(this._element,null),d=parseFloat(c.width),e=parseFloat(c.height),f=v(this._element,c.paddingLeft),g=v(this._element,c.paddingRight),h=v(this._element,c.paddingTop),i=v(this._element,c.paddingBottom),j=d-f-g,k=e-h-i,l=1/this._zoomFactor;if(this._viewportWidth===j&&this._viewportHeight===k)return;this._sezoClientHeight=e,this._sezoClientWidth=d,this._viewportWidth=j,this._viewportHeight=k,this._configure();var m=2*l-1,n=Math.min(N,(this._pansHorizontallyIn?m:1)*j),o=Math.min(N,(this._pansVerticallyIn?m:1)*k);this._canvasLeftIn=.5*(n-j),this._canvasTopIn=.5*(o-k),b(this._cropViewport,f,h,j,k),b(this._viewportIn,0,0,j,k),b(this._opticalViewportIn,0,0,j,k),b(this._canvasIn,-this._canvasLeftIn,-this._canvasTopIn,n,o),b(this._elementIn,this._canvasLeftIn,this._canvasTopIn,j,k);var p=2*J-1,q=(this._pansHorizontallyOut?p:1)*j,r=(this._pansVerticallyOut?p:1)*k;this._canvasLeftOut=.5*(q-j),this._canvasTopOut=.5*(r-k),b(this._viewportOut,0,0,j,k),b(this._opticalViewportOut,0,0,j,k),b(this._canvasOut,-this._canvasLeftOut,-this._canvasTopOut,q,r),b(this._elementOut,this._canvasLeftOut,this._canvasTopOut,j,k)}finally{this._resizing--}},_onResize:function(){this._onResizeImpl()},_onMouseMove:function(a){return this._zooming||!this._lastMouseX&&!this._lastMouseY||a.screenX===this._lastMouseX&&a.screenY===this._lastMouseY?(this._lastMouseX=a.screenX,void(this._lastMouseY=a.screenY)):void(Math.abs(a.screenX-this._lastMouseX)<=E&&Math.abs(a.screenY-this._lastMouseY)<=E||(this._lastMouseX=a.screenX,this._lastMouseY=a.screenY,this._displayButton()))},_displayButton:function(){if(p.isHoverable){a.clearTimeout(this._dismissButtonTimer),this._showSemanticZoomButton();var b=this;this._dismissButtonTimer=a.setTimeout(function(){b._hideSemanticZoomButton()},i._animationTimeAdjustment(D))}},_showSemanticZoomButton:function(){this._disposed||this._buttonShown||!this._sezoButton||this._zoomedOut||this._locked||(h.fadeIn(this._sezoButton),this._sezoButton.style.visibility="visible",this._buttonShown=!0)},_hideSemanticZoomButton:function(a){if(!this._disposed&&this._buttonShown&&this._sezoButton){if(a)this._sezoButton.style.visibility="hidden";else{var b=this;h.fadeOut(this._sezoButton).then(function(){b._sezoButton.style.visibility="hidden"})}this._buttonShown=!1}},_onSeZoChildrenScroll:function(a){a.target!==this.element&&this._hideSemanticZoomButton(!0)},_onWheel:function(a){a.ctrlKey&&(this._zoom(a.deltaY>0,this._getPointerLocation(a)),a.stopPropagation(),a.preventDefault())},_onMouseWheel:function(a){a.ctrlKey&&(this._zoom(a.wheelDelta<0,this._getPointerLocation(a)),a.stopPropagation(),a.preventDefault())},_onPenHover:function(a){a.pointerType===eb&&0===a.buttons&&this._displayButton()},_onSeZoButtonZoomOutClick:function(){this._hideSemanticZoomButton(),this._zoom(!0,{x:.5*this._sezoClientWidth,y:.5*this._sezoClientHeight},!1)},_onKeyDown:function(a){var b=!1;if(a.ctrlKey){var c=n.Key;switch(a.keyCode){case c.add:case c.equal:case 61:this._zoom(!1),b=!0;break;case c.subtract:case c.dash:case 173:this._zoom(!0),b=!0}}b&&(a.stopPropagation(),a.preventDefault())},_createPointerRecord:function(a,b){var c=this._getPointerLocation(a),d={};return d.startX=d.currentX=c.x,d.startY=d.currentY=c.y,d.fireCancelOnPinch=b,this._pointerRecords[a.pointerId]=d,this._pointerCount=Object.keys(this._pointerRecords).length,d},_deletePointerRecord:function(a){var b=this._pointerRecords[a];return delete this._pointerRecords[a],this._pointerCount=Object.keys(this._pointerRecords).length,2!==this._pointerCount&&(this._pinching=!1),b},_fakeCancelOnPointer:function(b){var c=a.document.createEvent("UIEvent");c.initUIEvent("touchcancel",!0,!0,a,0),c.touches=b.touches,c.targetTouches=b.targetTouches,c.changedTouches=[b._currentTouch],c._fakedBySemanticZoom=!0,b.target.dispatchEvent(c)},_handlePointerDown:function(a){this._createPointerRecord(a,!1);for(var b=Object.keys(this._pointerRecords),c=0,d=b.length;d>c;c++)try{n._setPointerCapture(this._hiddenElement,b[c]||0)}catch(e){return void this._resetPointerRecords()}a.stopImmediatePropagation(),a.preventDefault()},_handleFirstPointerDown:function(a){this._resetPointerRecords(),this._createPointerRecord(a,this._shouldFakeTouchCancel),this._startedZoomedOut=this._zoomedOut},_onClick:function(a){a.target!==this._element&&this._isBouncing&&a.stopImmediatePropagation()},_onPointerDown:function(a){a.pointerType===db&&(0===this._pointerCount?this._handleFirstPointerDown(a):this._handlePointerDown(a))},_onPointerMove:function(a){function b(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function c(a,b){return{x:.5*(a.currentX+b.currentX)|0,y:.5*(a.currentY+b.currentY)|0}}if(a.pointerType===fb||a.pointerType===eb)return void this._onMouseMove(a);if(a.pointerType===db){var d=this._pointerRecords[a.pointerId],e=this._getPointerLocation(a);if(d){if(d.currentX=e.x,d.currentY=e.y,2===this._pointerCount){this._pinching=!0;var f=Object.keys(this._pointerRecords),h=this._pointerRecords[f[0]],i=this._pointerRecords[f[1]];this._currentMidPoint=c(h,i);var j=b(h.currentX,h.currentY,i.currentX,i.currentY),k=this,l=function(a){var b=a?cb.zoomedOut:cb.zoomedIn,d=a?k._pinchedDirection===cb.zoomedIn&&!k._zoomingOut:k._pinchedDirection===cb.zoomedOut&&k._zoomingOut,e=a?!k._zoomedOut:k._zoomedOut;if(k._pinchedDirection===cb.none)e?(k._isBouncingIn=!1,k._zoom(a,c(h,i),!0),k._pinchedDirection=b):k._isBouncingIn||k._playBounce(!0,c(h,i));else if(d){var f=k._lastPinchDistance/k._lastPinchStartDistance,g=k._lastLastPinchDistance/k._lastPinchDistance;(a&&f>$||!a&&g>_)&&(k._zoom(a,c(h,i),!0),k._pinchedDirection=b)}};this._updatePinchDistanceRecords(j),this._pinchDistanceCount>=Z&&(this._zooming||this._isBouncing||(g("WinJS.UI.SemanticZoom:EndPinchDetection,info"),l(this._lastPinchDirection===cb.zoomedOut)))}else this._pointerCount>2&&this._resetPinchDistanceRecords();this._pointerCount>=2&&(d.fireCancelOnPinch&&(this._fakeCancelOnPointer(a,d),d.fireCancelOnPinch=!1),a.stopImmediatePropagation(),a.preventDefault()),2!==this._pointerCount&&this._isBouncingIn&&this._playBounce(!1)}}},_onPointerOut:function(a){a.pointerType===db&&a.target===this._element&&this._completePointerUp(a,!1)},_onPointerUp:function(a){this._releasePointerCapture(a),this._completePointerUp(a,!0),this._completeZoomingIfTimeout()},_onPointerCancel:function(a){a._fakedBySemanticZoom||(this._releasePointerCapture(a),this._completePointerUp(a,!1),this._completeZoomingIfTimeout())},_onGotPointerCapture:function(a){var b=this._pointerRecords[a.pointerId];b&&(b.dirty=!1)},_onLostPointerCapture:function(a){var b=this._pointerRecords[a.pointerId];if(b){b.dirty=!0;var c=this;k.timeout(bb).then(function(){b.dirty&&c._completePointerUp(a,!1)})}},_onMSContentZoom:function(a){var b=a.target;if(b===this._opticalViewportIn||b===this._opticalViewportOut){var c=b.msContentZoomFactor<.995,d=b.msContentZoomFactor>1.005;!c||this._zoomedOut||this._zoomingOut?d&&(this._zoomedOut||this._zoomingOut)&&(this.zoomedOut=!1):this.zoomedOut=!0}},_updatePinchDistanceRecords:function(a){function b(b){c._lastPinchDirection===b?c._pinchDistanceCount++:(c._pinchGesture++,c._pinchDistanceCount=0,c._lastPinchStartDistance=a),c._lastPinchDirection=b,c._lastPinchDistance=a,c._lastLastPinchDistance=c._lastPinchDistance}var c=this;-1===this._lastPinchDistance?(g("WinJS.UI.SemanticZoom:StartPinchDetection,info"),this._lastPinchDistance=a):this._lastPinchDistance!==a&&b(this._lastPinchDistance>a?cb.zoomedOut:cb.zoomedIn)},_zoomFromCurrent:function(a){this._zoom(a,null,!1,!0)},_zoom:function(a,b,d,e,f){if(g("WinJS.UI.SemanticZoom:StartZoom(zoomOut="+a+"),info"),this._clearTimeout(this._completeZoomTimer),this._clearTimeout(this._TTFFTimer),this._hideSemanticZoomButton(),this._resetPinchDistanceRecords(),!this._locked&&!this._gestureEnding)if(this._zoomInProgress){if(this._gesturing===!d)return;a!==this._zoomingOut&&this._startAnimations(a)}else if(a!==this._zoomedOut){this._zooming=!0,this._aligning=!0,this._gesturing=!!d,b&&(a?this._viewIn:this._viewOut).setCurrentItem(b.x,b.y),this._zoomInProgress=!0,(a?this._opticalViewportOut:this._opticalViewportIn).style.visibility="visible",a&&c.isPhone&&(this._canvasOut.style.opacity=1);var h=this._viewIn.beginZoom(),i=this._viewOut.beginZoom(),j=null;if((h||i)&&c.isPhone&&(j=k.join([h,i])),e&&!f){var l=this;(a?this._viewIn:this._viewOut).getCurrentItem().then(function(b){var c=b.position;l._prepareForZoom(a,{x:l._rtl()?l._sezoClientWidth-c.left-.5*c.width:c.left+.5*c.width,y:c.top+.5*c.height},k.wrap(b),j)})}else this._prepareForZoom(a,b||{},null,j,f)}},_prepareForZoom:function(b,c,d,e,f){function h(a,b){i._canvasIn.style[z["transform-origin"].scriptName]=i._canvasLeftIn+j-a.x+"px "+(i._canvasTopIn+k-a.y)+"px",i._canvasOut.style[z["transform-origin"].scriptName]=i._canvasLeftOut+j-b.x+"px "+(i._canvasTopOut+k-b.y)+"px"}g("WinJS.UI.SemanticZoom:prepareForZoom,StartTM");var i=this,j=c.x,k=c.y;"number"==typeof j&&this._pansHorizontallyIn&&this._pansHorizontallyOut||(j=.5*this._sezoClientWidth),"number"==typeof k&&this._pansVerticallyIn&&this._pansVerticallyOut||(k=.5*this._sezoClientHeight),h(gb,gb),f?this._aligning=!1:this._alignViewsPromise=this._alignViews(b,j,k,d).then(function(){i._aligning=!1,i._gestureEnding=!1,i._alignViewsPromise=null,i._zooming||i._gesturing||i._completeZoom()}),this._zoomingOut=b,a.getComputedStyle(this._canvasIn).opacity,a.getComputedStyle(this._canvasOut).opacity,g("WinJS.UI.SemanticZoom:prepareForZoom,StopTM"),this._startAnimations(b,e)},_alignViews:function(a,b,c,d){var e=1-this._zoomFactor,f=this._rtl(),g=e*(f?this._viewportWidth-b:b),h=e*c,i=this;if(a){var j=d||this._viewIn.getCurrentItem();if(j)return j.then(function(a){var b=a.position,c={left:b.left*i._zoomFactor+g,top:b.top*i._zoomFactor+h,width:b.width*i._zoomFactor,height:b.height*i._zoomFactor};return i._viewOut.positionItem(i._zoomedOutItem(a.item),c)})}else{var l=d||this._viewOut.getCurrentItem();if(l)return l.then(function(a){var b=a.position,c={left:(b.left-g)/i._zoomFactor,top:(b.top-h)/i._zoomFactor,width:b.width/i._zoomFactor,height:b.height/i._zoomFactor};return i._viewIn.positionItem(i._zoomedInItem(a.item),c)})}return new k(function(a){a({x:0,y:0})})},_startAnimations:function(a,b){this._zoomingOut=a;var d=c.isPhone;if(i.isAnimationEnabled()&&!d&&(g("WinJS.UI.SemanticZoom:ZoomAnimation,StartTM"),this._canvasIn.style[Y]=a?r():s(),this._canvasOut.style[Y]=a?s():r()),d||(w(this._canvasIn,a?this._zoomFactor:1),w(this._canvasOut,a?1:1/this._zoomFactor)),this._canvasIn.style.opacity=a&&!d?0:1,(!d||a)&&(this._canvasOut.style.opacity=a?1:0),i.isAnimationEnabled())if(b){var e=this,f=function(){e._canvasIn.style[X.scriptName]="",e._canvasOut.style[X.scriptName]="",e._onZoomAnimationComplete()};b.then(f,f)}else this.setTimeoutAfterTTFF(this._onZoomAnimationComplete.bind(this),i._animationTimeAdjustment(S));else this._zooming=!1,this._canvasIn.style[X.scriptName]="",this._canvasOut.style[X.scriptName]="",this._completeZoom()},_onBounceAnimationComplete:function(){this._isBouncingIn||this._disposed||this._completeZoom()},_onZoomAnimationComplete:function(){g("WinJS.UI.SemanticZoom:ZoomAnimation,StopTM"),this._disposed||(this._zooming=!1,this._aligning||this._gesturing||this._gestureEnding||this._completeZoom())},_onCanvasTransitionEnd:function(a){return this._disposed?void 0:a.target!==this._canvasOut&&a.target!==this._canvasIn||!this._isBouncing?void(a.target===this._canvasIn&&a.propertyName===X.cssName&&this._onZoomAnimationComplete()):void this._onBounceAnimationComplete()},_clearTimeout:function(b){b&&a.clearTimeout(b)},_completePointerUp:function(a,b){if(!this._disposed){var c=a.pointerId,d=this._pointerRecords[c];if(d&&(this._deletePointerRecord(c),this._isBouncingIn&&this._playBounce(!1),b&&this._pinchedDirection!==cb.none&&a.stopImmediatePropagation(),0===this._pointerCount)){if(1===this._pinchGesture&&!this._zooming&&this._lastPinchDirection!==cb.none&&this._pinchDistanceCount=0&&aa;a++)this.items.getAt(a).dispose()}},onselectionchanged:z(A.selectionChanged),onitemanimationstart:z(A.itemAnimationStart),onitemanimationend:z(A.itemAnimationEnd),_currentScrollTargetLocation:{get:function(){return this._viewportWidth===D._invalidViewportWidth?0:(50+this._offsetFromCenter)*Math.ceil(this._viewportWidth)}},_pointerType:{get:function(){return this._pointerTypeValue},set:function(a){this._pointerTypeValue!==a&&(this._pointerTypeValue=a,a===x?(r.removeClass(this.element,D._ClassName.pivotInputTypeMouse),r.addClass(this.element,D._ClassName.pivotInputTypeTouch),this._hideNavButtons()):(r.removeClass(this.element,D._ClassName.pivotInputTypeTouch),r.addClass(this.element,D._ClassName.pivotInputTypeMouse)))}},_rtl:{get:function(){return this._cachedRTL}},_viewportWidth:{get:function(){return this._viewportElWidth||(this._viewportElWidth=parseFloat(a.getComputedStyle(this._viewportElement).width),C&&(this._viewportElement.style[c._browserStyleEquivalents["scroll-snap-points-x"].scriptName]="snapInterval(0%, "+Math.ceil(this._viewportElWidth)+"px)")),this._viewportElWidth||D._invalidViewportWidth},set:function(a){this._viewportElWidth=a}},_applyProperties:function(){if(!this._disposed){if(this._pendingItems){for(this._updateEvents(this._items,this._pendingItems),this._items=this._pendingItems,this._pendingItems=null;this.element.firstElementChild!==this._titleElement;){var a=this.element.firstElementChild;a.parentNode.removeChild(a)}r.empty(this._surfaceElement)}this._attachItems();var b=this._pendingIndexOnScreen;this._pendingIndexOnScreen=null,this._currentIndexOnScreen=0,this._skipHeaderSlide=!0,this._pendingRefresh=!1,this.selectedIndex=Math.min(b,this.items.length-1),this._skipHeaderSlide=!1,this._recenterUI()}},_attachItems:function(){this._measured=!1;for(var a=0,b=this.items.length;b>a;a++){var c=this._items.getAt(a);if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,this._surfaceElement.appendChild(c.element)}},_parse:function(){for(var a=[],b=this.element.firstElementChild;b!==this._titleElement;){l.processAll(b);var c=b.winControl;if(!c)throw new d("WinJS.UI.Pivot.InvalidContent",E.invalidContent);a.push(c);var e=b.nextElementSibling;b=e}this.items=new k.List(a)},_refresh:function(){this._pendingRefresh||(this._pendingRefresh=!0,n.schedule(this._applyProperties.bind(this),n.Priority.high))},_renderHeaders:function(b){function d(b){function c(){l._disposed||l._headersContainerElement.contains(e)&&b!==l.selectedIndex&&"true"===e.getAttribute("aria-selected")&&(l.selectedIndex=b)}var d=l._items.getAt(b),e=a.document.createElement("BUTTON");e.style.maxWidth=.8*k+"px",b===l.selectedIndex?(r.addClass(e,D._ClassName.pivotHeaderSelected),e.setAttribute("aria-selected",!0)):e.setAttribute("aria-selected",!1),r.addClass(e,D._ClassName.pivotHeader),e._item=d,f(d,e),e.setAttribute("role","tab"),l._headersContainerElement.appendChild(e),new r._MutationObserver(c).observe(e,{attributes:!0,attributeFilter:["aria-selected"]})}if(!this._pendingRefresh&&this._items){var e=this._headersContainerElement.contains(a.document.activeElement),f=r._syncRenderer(s);q._disposeElement(this._headersContainerElement),r.empty(this._headersContainerElement);var g=a.getComputedStyle(this._headersContainerElement),h=parseFloat(g.marginLeft);h=h>0?0:h;var i=parseFloat(g.marginRight);i=i>0?0:i;var k=parseFloat(g.width)+h+i,l=this;if(1===this._items.length)d(0),this._viewportElement.style.overflow="hidden",this._headersContainerElement.style.marginLeft="0px",this._headersContainerElement.style.marginRight="0px";else if(this._items.length>1){var m=this._items.length+(b?2:1),n=this.selectedIndex-1;this._viewportElement.style.overflow&&(this._viewportElement.style.overflow="");for(var o=0;m>o;o++)-1===n?n=this._items.length-1:n===this._items.length&&(n=0),d(n),n++;if(!this._skipHeaderSlide){var p,t;b?(p="",t="0"):(p="0",t="");var u=this._headersContainerElement.children[m-1];u.style.opacity=p;var v=.167;u.style[c._browserStyleEquivalents.transition.scriptName]="opacity "+j._animationTimeAdjustment(v)+"s",a.getComputedStyle(u).opacity,u.style.opacity=t}this._headersContainerElement.children[0].setAttribute("aria-hidden","true"),this._headersContainerElement.style.marginLeft="0px",this._headersContainerElement.style.marginRight="0px";var w=this._rtl?"marginRight":"marginLeft",x=this._rtl?"paddingLeft":"paddingRight",y=this._headersContainerElement.children[0],z=y.offsetWidth+parseFloat(a.getComputedStyle(y)[w])-parseFloat(a.getComputedStyle(y)[x]);if(y!==this._headersContainerElement.children[0])return;this._headersContainerElement.style[w]=-1*z+"px",this._prevButton=a.document.createElement("button"),r.addClass(this._prevButton,D._ClassName.pivotNavButton),r.addClass(this._prevButton,D._ClassName.pivotNavButtonPrev),this._prevButton.addEventListener("click",function(){l.locked||(l._rtl?l._goNext():l._goPrevious())}),this._headersContainerElement.appendChild(this._prevButton),this._prevButton.style.left=this._rtl?"0px":z+"px",this._nextButton=a.document.createElement("button"),r.addClass(this._nextButton,D._ClassName.pivotNavButton),r.addClass(this._nextButton,D._ClassName.pivotNavButtonNext),this._nextButton.addEventListener("click",function(){l.locked||(l._rtl?l._goPrevious():l._goNext())}),this._headersContainerElement.appendChild(this._nextButton),this._nextButton.style.right=this._rtl?z+"px":"0px"}var A=this._headersContainerElement.children.length>1?1:0;this._tabContainer.childFocus=this._headersContainerElement.children[A],e&&this._headersContainerElement.children[A].focus()}},_resizeHandler:function(){if(!this._disposed){var a=this._viewportWidth;this._viewportWidth=null,a!==this._viewportWidth?(f.log&&f.log("_resizeHandler from:"+a+" to: "+this._viewportWidth),this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel(),this._showPivotItemAnimation&&this._showPivotItemAnimation.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._recenterUI(),this._renderHeaders()):f.log&&f.log("_resizeHandler worthless resize")}},_activateHeader:function(a){if(!this.locked){var b=this._items.indexOf(a._item);if(b!==this.selectedIndex){if(!a.previousSibling)return;this.selectedIndex=b}else r._setActiveFirstFocusableElement(this.selectedItem.element)}},_goNext:function(){this.selectedIndex0?this.selectedIndex--:this.selectedIndex=this._items.length-1,this._animateToPrevious=!1},_loadItem:function(b){var c=this._animateToPrevious;this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction,this._loadId++;var d=this._loadId;this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel(),this._showPivotItemAnimation&&this._showPivotItemAnimation.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._currentItem&&this._hidePivotItem(this._currentItem.element,c);var e=this._currentIndexOnScreen;if(this._currentIndexOnScreen=b,this._slideHeaders(c,b,e),!(0>b)){var g=this._items.getAt(b);this._currentItem=g,c?this._offsetFromCenter--:b!==e&&this._offsetFromCenter++;var h=!1;C&&this._currentManipulationState!==B.MS_MANIPULATION_STATE_INERTIA&&(this._skipHeaderSlide?(f.log&&f.log("_skipHeaderSlide index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation,"winjs pivot","log"),r.setScrollPosition(this._viewportElement,{scrollLeft:this._currentScrollTargetLocation})):(f.log&&f.log("zoomTo index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation,"winjs pivot","log"),this._viewportElement.msZoomTo({contentX:this._currentScrollTargetLocation,contentY:0,viewportX:0,viewportY:0}),h=0!==this._offsetFromCenter&&this.items.length>1));var i=this,j={index:b,direction:c?"backwards":"forward",item:g};this._writeProfilerMark("selectionChanged,info"),this._fireEvent(D._EventName.selectionChanged,!0,!1,j),g._process().then(function(){if(!i._disposed&&d===i._loadId){C?(g.element.style[i._getDirectionAccessor()]=i._currentScrollTargetLocation+"px",i._showPivotItem(g.element,c)):i._hidePivotItemAnimation?i._showPivotItemAnimation=i._hidePivotItemAnimation.then(function(){return i._disposed||d!==i._loadId?void 0:i._showPivotItem(g.element,c)}):i._showPivotItem(g.element,c);var a;h?(i._stoppedAndRecenteredSignal||(i._stoppedAndRecenteredSignal=new o),a=i._stoppedAndRecenteredSignal.promise):a=m.wrap(),m.join([i._slideHeadersAnimation,i._showPivotItemAnimation,i._hidePivotItemAnimation]).then(function(){a.then(function(){m.timeout(50).then(function(){i._disposed||d!==i._loadId||(i._navMode=D._NavigationModes.none,i._writeProfilerMark("itemAnimationStop,info"),i._fireEvent(D._EventName.itemAnimationEnd,!0))})})})}})}},_MSManipulationStateChangedHandler:function(a){if(this._currentManipulationState=a.currentState,C&&a.target===this._viewportElement)if(this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED?f.log&&f.log("MSManipulation: Stopped","winjs pivot","log"):this._currentManipulationState===B.MS_MANIPULATION_STATE_INERTIA?f.log&&f.log("MSManipulation: Inertia","winjs pivot","log"):f.log&&f.log("MSManipulation: Active","winjs pivot","log"),this._stoppedAndRecenteredSignal||(this._stoppedAndRecenteredSignal=new o),this._manipulationRecenterPromise&&this._manipulationRecenterPromise.cancel(),this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED){this._navMode===D._NavigationModes.scroll&&this._scrollHandler(),this._navMode=D._NavigationModes.none;var b=this;this._manipulationRecenterPromise=m._cancelBlocker(m.join([n.schedulePromiseNormal(null,"WinJS.UI.Pivot._MSManipulationStateChangedHandler_animationPlaceholder"),this._hidePivotItemAnimation,this._showPivotItemAnimation,this._slideHeadersAnimation])).then(function(){b._disposed||(b._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED?(f.log&&f.log("Still in Stopped state: calling _recenterUI","winjs pivot","log"),b._recenterUI()):(this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null))})}else if(this._currentManipulationState===B.MS_MANIPULATION_STATE_INERTIA){var c=a.inertiaDestinationX;if(+c===c){f.log&&f.log("MSManipulation: inertiaDestinationX: "+c);var d=c-this._currentScrollTargetLocation;d>0?(f.log&&f.log("MSManipulation: Inertia diff > 1","winjs pivot","log"),this._navMode=D._NavigationModes.inertia,this._goNext()):0>d&&(f.log&&f.log("MSManipulation: Stopped diff < -1","winjs pivot","log"),this._navMode=D._NavigationModes.inertia,this._goPrevious())}}},_scrollHandler:function(){if(C&&!this._disposed){if(this._recentering&&this._stoppedAndRecenteredSignal)return this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null,void(this._recentering=!1);if((this._navMode===D._NavigationModes.none||this._navMode===D._NavigationModes.scroll)&&(this._navMode=D._NavigationModes.scroll,this._currentManipulationState===B.MS_MANIPULATION_STATE_STOPPED)){f.log&&f.log("_scrollHandler ScrollPosition: "+r.getScrollPosition(this._viewportElement).scrollLeft,"winjs pivot","log");var b=r.getScrollPosition(this._viewportElement).scrollLeft-this._currentScrollTargetLocation;this._cachedRTL="rtl"===a.getComputedStyle(this._element,null).direction,b>0?(f.log&&f.log("_scrollHandler diff > 1: "+b,"winjs pivot","log"),this._goNext()):0>b&&(f.log&&f.log("_scrollHandler diff < -1: "+b,"winjs pivot","log"),this._goPrevious())}}},_recenterUI:function(){C&&(this._offsetFromCenter=0,r.getScrollPosition(this._viewportElement).scrollLeft!==this._currentScrollTargetLocation?(this._recentering=!0,this._stoppedAndRecenteredSignal=this._stoppedAndRecenteredSignal||new o):this._stoppedAndRecenteredSignal&&(this._stoppedAndRecenteredSignal.complete(),this._stoppedAndRecenteredSignal=null),this.selectedItem&&(this.selectedItem.element.style[this._getDirectionAccessor()]=this._currentScrollTargetLocation+"px"),f.log&&f.log("_recenterUI index:"+this.selectedIndex+" offset: "+this._offsetFromCenter+" scrollLeft: "+this._currentScrollTargetLocation),r.setScrollPosition(this._viewportElement,{scrollLeft:this._currentScrollTargetLocation}))},_hidePivotItem:function(a,b){function c(){d._disposed||(d._hidePivotItemAnimation=null,a.style.visibility="hidden",a.style.opacity=0)}var d=this,e=this._rtl&&!b||b&&!this._rtl;this._hidePivotItemAnimation=j.isAnimationEnabled()?i[e?"slideRightOut":"slideLeftOut"](a):n.schedulePromiseNormal(null,"WinJS.UI.Pivot._hidePivotItem_animationPlaceholder"),this._hidePivotItemAnimation.then(c,c)},_showPivotItem:function(a,b){function c(a){var b=a.getBoundingClientRect();return b.toph.top}function d(){l._disposed||(l._showPivotItemAnimation=null)}if(this._writeProfilerMark("itemAnimationStart,info"),this._fireEvent(D._EventName.itemAnimationStart,!0),!j.isAnimationEnabled())return a.style.visibility="",a.style.opacity="",void(this._showPivotItemAnimation=null);var e=a.querySelectorAll(".win-pivot-slide1"),f=a.querySelectorAll(".win-pivot-slide2"),g=a.querySelectorAll(".win-pivot-slide3"),h=this._viewportElement.getBoundingClientRect();e=Array.prototype.filter.call(e,c),f=Array.prototype.filter.call(f,c),g=Array.prototype.filter.call(g,c);var k=this._rtl&&!b||b&&!this._rtl;a.style.visibility="",this._showPivotItemAnimation=i[k?"slideRightIn":"slideLeftIn"](a,e,f,g);var l=this;return this._showPivotItemAnimation.then(d,d),this._showPivotItemAnimation},_slideHeaders:function(a,b,d){function e(a){return h?a.offsetParent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft}function f(){l._disposed||(l._renderHeaders(a),l._slideHeadersAnimation=null)}if(0>b||this._skipHeaderSlide)return void this._renderHeaders(a);var g;if(a?g=this._headersContainerElement.children[0]:(d>b&&(b+=this._items.length),g=this._headersContainerElement.children[1+b-d]),!g)return void this._renderHeaders(a);r.removeClass(this._headersContainerElement.children[1],D._ClassName.pivotHeaderSelected),r.addClass(g,D._ClassName.pivotHeaderSelected);var h=this._rtl,i=e(this._headersContainerElement.children[1])-e(g);h&&(i*=-1);var k,l=this;k=j.isAnimationEnabled()?j.executeTransition(this._headersContainerElement.querySelectorAll("."+D._ClassName.pivotHeader),{property:c._browserStyleEquivalents.transform.cssName,delay:0,duration:D._headerSlideAnimationDuration,timing:"ease-out",to:"translateX("+i+"px)"}):m.wrap(),this._slideHeadersAnimation=k.then(f,f)},_elementClickedHandler:function(a){if(this.locked||this._navigationHandled)return void(this._navigationHandled=!1);var b,c=a.target;if(r.hasClass(c,D._ClassName.pivotHeader))b=c;else{var d=!1,e=r._elementsFromPoint(a.clientX,a.clientY);if(e&&e[0]===this._viewportElement)for(var f=0,g=e.length;g>f;f++)e[f]===c&&(d=!0),r.hasClass(e[f],D._ClassName.pivotHeader)&&(b=e[f]);d||(b=null)}b&&this._activateHeader(b)},_headersKeyDown:function(a){this.locked||(a.keyCode===y.leftArrow||a.keyCode===y.pageUp?this._rtl?this._goNext():this._goPrevious():(a.keyCode===y.rightArrow||a.keyCode===y.pageDown)&&(this._rtl?this._goPrevious():this._goNext()))},_headersPointerDownHandler:function(a){a.preventDefault(),this._headersPointerDownPoint={x:a.clientX,y:a.clientY,type:a.pointerType||"mouse"}},_headersPointerUpHandler:function(a){if(!this._headersPointerDownPoint||this.locked)return void(this._headersPointerDownPoint=null);var b=a.clientX-this._headersPointerDownPoint.x;if(b=this._rtl?-b:b,this._navigationHandled=!1,(!r._supportsTouchDetection||this._headersPointerDownPoint.type===a.pointerType&&a.pointerType===x)&&(b<-D._headerSwipeTriggerDistance?(this._goNext(),this._navigationHandled=!0):b>D._headerSwipeTriggerDistance&&(this._goPrevious(),this._navigationHandled=!0)),!this._navigationHandled){for(var c=a.target;null!==c&&!r.hasClass(c,D._ClassName.pivotHeader);)c=c.parentElement;null!==c&&(this._activateHeader(c),this._navigationHandled=!0)}this._headersPointerDownPoint=null},_hideNavButtons:function(a){a&&this._headersContainerElement.contains(a.relatedTarget)||r.removeClass(this._headersContainerElement,D._ClassName.pivotShowNavButtons)},_pointerDownHandler:function(){f.log&&f.log("_pointerDown","winjs pivot","log"),this._manipulationRecenterPromise&&this._manipulationRecenterPromise.cancel(),this._slideHeadersAnimation&&this._slideHeadersAnimation.cancel(),this._hidePivotItemAnimation&&this._hidePivotItemAnimation.cancel()},_showNavButtons:function(a){this.locked||a&&a.pointerType===x||r.addClass(this._headersContainerElement,D._ClassName.pivotShowNavButtons)},_handleItemChanged:function(a){if(!this._pendingItems){var b=a.detail.index,c=a.detail.newValue,e=a.detail.oldValue;if(c.element!==e.element){if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,this._surfaceElement.insertBefore(c.element,e.element),this._surfaceElement.removeChild(e.element),b===this._currentIndexOnScreen&&(this.selectedIndex=this._currentIndexOnScreen)}this._renderHeaders()}},_handleItemInserted:function(a){if(!this._pendingItems){var b=a.detail.index,c=a.detail.value;if(c.element.parentNode===this._surfaceElement)throw new d("WinJS.UI.Pivot.DuplicateItem",E.duplicateItem);c.element.style.visibility="hidden",c.element.style.opacity=0,b=this._currentIndexOnScreen?this._currentIndexOnScreen--:c>this._currentIndexOnScreen&&b<=this._currentIndexOnScreen?this._currentIndexOnScreen++:b===this._currentIndexOnScreen&&(this.selectedIndex=c),this._renderHeaders()}},_handleItemReload:function(){this.items=this.items},_handleItemRemoved:function(a){if(!this._pendingItems){var b=a.detail.value,c=a.detail.index;this._surfaceElement.removeChild(b.element),c

',this._headerTabStopElement=this._headerElement.firstElementChild,this._headerWrapperElement=this._headerTabStopElement.firstElementChild,this._headerContentElement=this._headerWrapperElement.firstElementChild,this._headerChevronElement=this._headerWrapperElement.lastElementChild,c.appendChild(this._headerElement),this._winKeyboard=new l._WinKeyboard(this._headerElement),this._contentElement=b.document.createElement("DIV"),this._contentElement.className=f._ClassName.hubSectionContent,this._contentElement.style.visibility="hidden",c.appendChild(this._contentElement);for(var h=this.element.firstChild;h!==this._headerElement;){var j=h.nextSibling;this._contentElement.appendChild(h),h=j}this._processors=[g.processAll],i.setOptions(this,d)},{element:{get:function(){return this._element}},isHeaderStatic:{get:function(){return this._isHeaderStatic},set:function(a){this._isHeaderStatic=a,this._isHeaderStatic?(this._headerTabStopElement.setAttribute("role","heading"),k.removeClass(this._headerTabStopElement,f._ClassName.hubSectionInteractive)):(this._headerTabStopElement.setAttribute("role","link"),k.addClass(this._headerTabStopElement,f._ClassName.hubSectionInteractive))}},contentElement:{get:function(){return this._contentElement}},header:{get:function(){return this._header},set:function(a){this._header=a,this._renderHeader()}},_setHeaderTemplate:function(a){this._template=k._syncRenderer(a),this._renderHeader()},_renderHeader:function(){this._template&&(j._disposeElement(this._headerContentElement),k.empty(this._headerContentElement),this._template(this,this._headerContentElement))},_process:function(){var a=this;return this._processed=(this._processors||[]).reduce(function(b,c){return b.then(function(){return c(a.contentElement)})},this._processed||h.as()),this._processors=null,this._processed},dispose:function(){this._disposed||(this._disposed=!0,this._processors=null,j._disposeElement(this._headerContentElement),j.disposeSubTree(this.contentElement))}},{_ClassName:{hubSection:"win-hub-section",hubSectionHeader:"win-hub-section-header",hubSectionHeaderTabStop:"win-hub-section-header-tabstop",hubSectionHeaderWrapper:"win-hub-section-header-wrapper",hubSectionInteractive:"win-hub-section-header-interactive",hubSectionHeaderContent:"win-hub-section-header-content",hubSectionHeaderChevron:"win-hub-section-header-chevron",hubSectionContent:"win-hub-section-content"},_Constants:{ellipsisTypeClassName:"win-type-ellipsis",xLargeTypeClassName:"win-type-x-large"},isDeclarativeControlContainer:d.markSupportedForProcessing(function(a,b){b!==g.processAll&&(a._processors=a._processors||[],a._processors.push(b),a._processed&&a._process())})});return f})})}),define("WinJS/Controls/Hub",["../Core/_Global","../Core/_Base","../Core/_BaseUtils","../Core/_ErrorFromName","../Core/_Events","../Core/_Log","../Core/_Resources","../Core/_WriteProfilerMark","../Animations","../Animations/_TransitionAnimation","../BindingList","../ControlProcessor","../Promise","../_Signal","../Scheduler","../Utilities/_Control","../Utilities/_ElementUtilities","../Utilities/_Hoverable","../Utilities/_UI","./Hub/_Section","require-style!less/desktop/controls","require-style!less/phone/controls"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){"use strict";b.Namespace.define("WinJS.UI",{Hub:b.Namespace._lazy(function(){function r(b){var c=a.document.createTextNode("object"==typeof b.header?JSON.stringify(b.header):""+b.header);return c}var u=q.Key,v=e._createEventProperty,w={contentAnimating:"contentanimating",headerInvoked:"headerinvoked",loadingStateChanged:"loadingstatechanged"},x=500,y={scrollPos:"scrollTop",scrollSize:"scrollHeight",offsetPos:"offsetTop",offsetSize:"offsetHeight",oppositeOffsetSize:"offsetWidth",marginStart:"marginTop",marginEnd:"marginBottom",borderStart:"borderTopWidth",borderEnd:"borderBottomWidth",paddingStart:"paddingTop",paddingEnd:"paddingBottom"},z={scrollPos:"scrollLeft",scrollSize:"scrollWidth",offsetPos:"offsetLeft",offsetSize:"offsetWidth",oppositeOffsetSize:"offsetHeight",marginStart:"marginRight",marginEnd:"marginLeft",borderStart:"borderRightWidth",borderEnd:"borderLeftWidth",paddingStart:"paddingRight",paddingEnd:"paddingLeft"},A={scrollPos:"scrollLeft",scrollSize:"scrollWidth",offsetPos:"offsetLeft",offsetSize:"offsetWidth",oppositeOffsetSize:"offsetHeight",marginStart:"marginLeft",marginEnd:"marginRight",borderStart:"borderLeftWidth",borderEnd:"borderRightWidth",paddingStart:"paddingLeft",paddingEnd:"paddingRight"},B=b.Class.define(function(b,c){if(b=b||a.document.createElement("DIV"),c=c||{},b.winControl)throw new d("WinJS.UI.Hub.DuplicateConstruction",D.duplicateConstruction);this._id=b.id||q._uniqueID(b),this._writeProfilerMark("constructor,StartTM"),this._windowKeyDownHandlerBound=this._windowKeyDownHandler.bind(this),a.addEventListener("keydown",this._windowKeyDownHandlerBound),b.winControl=this,this._element=b,q.addClass(this.element,B._ClassName.hub),q.addClass(this.element,"win-disposable"),this._viewportElement=a.document.createElement("DIV"),this._viewportElement.className=B._ClassName.hubViewport,this._element.appendChild(this._viewportElement),this._viewportElement.setAttribute("role","group"),this._viewportElement.setAttribute("aria-label",D.hubViewportAriaLabel),this._surfaceElement=a.document.createElement("DIV"),this._surfaceElement.className=B._ClassName.hubSurface,this._viewportElement.appendChild(this._surfaceElement),this._visible=!1,this._viewportElement.style.opacity=0,c.orientation||(this._orientation=s.Orientation.horizontal,q.addClass(this.element,B._ClassName.hubHorizontal)),this._fireEntrance=!0,this._animateEntrance=!0,this._loadId=0,this.runningAnimations=new m.wrap,this._currentIndexForSezo=0,this._parse(),p.setOptions(this,c),q._addEventListener(this.element,"focusin",this._focusin.bind(this),!1),this.element.addEventListener("keydown",this._keyDownHandler.bind(this)),this.element.addEventListener("click",this._clickHandler.bind(this)),this._resizeHandlerBound=this._resizeHandler.bind(this),this.element.addEventListener("mselementresize",this._resizeHandlerBound),q._resizeNotifier.subscribe(this.element,this._resizeHandlerBound),this._viewportElement.addEventListener("scroll",this._scrollHandler.bind(this)),this._surfaceElement.addEventListener("mselementresize",this._contentResizeHandler.bind(this)),this._handleSectionChangedBind=this._handleSectionChanged.bind(this),this._handleSectionInsertedBind=this._handleSectionInserted.bind(this),this._handleSectionMovedBind=this._handleSectionMoved.bind(this),this._handleSectionRemovedBind=this._handleSectionRemoved.bind(this),this._handleSectionReloadBind=this._handleSectionReload.bind(this),this._refresh(),this._writeProfilerMark("constructor,StopTM")},{element:{get:function(){return this._element}},orientation:{get:function(){return this._orientation},set:function(a){if(a!==this._orientation){if(this._measured=!1,this._names){var b={};b[this._names.scrollPos]=0,q.setScrollPosition(this._viewportElement,b)}a===s.Orientation.vertical?(q.removeClass(this.element,B._ClassName.hubHorizontal),q.addClass(this.element,B._ClassName.hubVertical)):(a=s.Orientation.horizontal,q.removeClass(this.element,B._ClassName.hubVertical),q.addClass(this.element,B._ClassName.hubHorizontal)),this._orientation=a,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)}}},sections:{get:function(){return this._pendingSections?this._pendingSections:this._sections},set:function(a){var b=!this._pendingSections;this._pendingSections=a,this._refresh(),b&&(this.scrollPosition=0)}},headerTemplate:{get:function(){return this._pendingHeaderTemplate?this._pendingHeaderTemplate:(this._headerTemplate||(this._headerTemplate=r),this._headerTemplate)},set:function(a){this._pendingHeaderTemplate=a||r,this._refresh()}},scrollPosition:{get:function(){return+this._pendingScrollLocation===this._pendingScrollLocation?this._pendingScrollLocation:(this._measure(),this._scrollPosition)},set:function(a){if(a=Math.max(0,a),this._pendingRefresh)this._pendingScrollLocation=a,this._pendingSectionOnScreen=null;else{this._measure();var b=Math.max(0,Math.min(this._scrollLength-this._viewportSize,a));this._scrollPosition=b;var c={};c[this._names.scrollPos]=b,q.setScrollPosition(this._viewportElement,c)}}},sectionOnScreen:{get:function(){if(+this._pendingSectionOnScreen===this._pendingSectionOnScreen)return this._pendingSectionOnScreen;this._measure();for(var a=0;athis._scrollPosition+this._startSpacer+b.borderStart+b.paddingStart)return a}return-1},set:function(a){a=Math.max(0,a),this._pendingRefresh?(this._pendingSectionOnScreen=a,this._pendingScrollLocation=null):(this._measure(),a>=0&&athis._scrollPosition)return a}return-1}},indexOfLastVisible:{get:function(){this._measure();for(var a=this._sectionSizes.length-1;a>=0;a--){var b=this._sectionSizes[a];if(b.offset+b.paddingStart+b.borderStart=s;s++)l.push(this._loadSection(s));for(p--,r++;p>=0||r=0&&(g.push(p),p--);var t=m.join(l);t.done(function(){d!==this._loadId||e._disposed||(this._showProgressPromise&&this._showProgressPromise.cancel(),this._progressBar&&this._progressBar.parentNode&&this._progressBar.parentNode.removeChild(this._progressBar),o.schedule(function(){if(d===this._loadId&&!e._disposed&&!this._visible){if(this._visible=!0,this._viewportElement.style.opacity=1,this._animateEntrance&&j.isAnimationEnabled()){var b={type:B.AnimationType.entrance};(!this._fireEntrance||this._fireEvent(B._EventName.contentAnimating,b))&&(this._viewportElement.style["-ms-overflow-style"]="none",f=i.enterContent(this._viewportElement,[{left:this._fireEntrance?"100px":"40px",top:"0px",rtlflip:!0}],{mechanism:"transition"}).then(function(){this._viewportElement.style["-ms-overflow-style"]=""}.bind(this)))}this._element===a.document.activeElement&&this._moveFocusIn(this.sectionOnScreen)}},o.Priority.high,this,"WinJS.UI.Hub.entranceAnimation"))}.bind(this)),b(t)}else this._showProgressPromise&&this._showProgressPromise.cancel(),this._progressBar&&this._progressBar.parentNode&&this._progressBar.parentNode.removeChild(this._progressBar);m.join([this.runningAnimations,f,h]).done(function(){d!==this._loadId||e._disposed||(this.runningAnimations=m.wrap(),this._setState(B.LoadingState.complete),o.schedule(this._updateSnapList.bind(this),o.Priority.idle))}.bind(this))},loadingState:{get:function(){return this._loadingState}},_setState:function(b){if(b!==this._loadingState){this._writeProfilerMark("loadingStateChanged:"+b+",info"),this._loadingState=b;var c=a.document.createEvent("CustomEvent");c.initCustomEvent(B._EventName.loadingStateChanged,!0,!1,{loadingState:b}),this._element.dispatchEvent(c)}},_parse:function(){for(var a=[],b=this.element.firstElementChild;b!==this._viewportElement;){l.processAll(b);var c=b.winControl;if(!c)throw new d("WinJS.UI.Hub.InvalidContent",D.invalidContent);a.push(c);var e=b.nextElementSibling;b=e}this.sections=new k.List(a)},_fireEvent:function(b,c){var d=a.document.createEvent("CustomEvent");return d.initCustomEvent(b,!0,!0,c),this.element.dispatchEvent(d)},_findHeaderTabStop:function(a){if(a.parentNode&&q._matchesSelector(a,".win-hub-section-header-tabstop, .win-hub-section-header-tabstop *")){for(;!q.hasClass(a,"win-hub-section-header-tabstop");)a=a.parentElement;return a}return null},_isHeaderInteractive:function(a){return a.parentNode?q._matchesSelector(a,".win-interactive, .win-interactive *"):!1},_clickHandler:function(a){var b=this._findHeaderTabStop(a.target);if(b&&!this._isHeaderInteractive(a.target)){var c=b.parentElement.parentElement.winControl;if(!c.isHeaderStatic){var d=this.sections.indexOf(c);this._fireEvent(B._EventName.headerInvoked,{index:d,section:c})}}},_resizeHandler:function(){this._measured=!1,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)},_contentResizeHandler:function(){this._measured=!1,o.schedule(this._updateSnapList.bind(this),o.Priority.idle)},_scrollHandler:function(){this._measured=!1,this._pendingSections||(this._pendingScrollLocation=null,this._pendingSectionOnScreen=null,this._pendingScrollHandler||(this._pendingScrollHandler=c._requestAnimationFrame(function(){this._pendingScrollHandler=null,this._pendingSections||this.loadingState!==B.LoadingState.complete&&this._loadSections()}.bind(this))))},_measure:function(){if(!this._measured||0===this._scrollLength){this._writeProfilerMark("measure,StartTM"),this._measured=!0,this._rtl="rtl"===a.getComputedStyle(this._element,null).direction,this._names=this.orientation===s.Orientation.vertical?y:this._rtl?z:A,this._viewportSize=this._viewportElement[this._names.offsetSize],this._viewportOppositeSize=this._viewportElement[this._names.oppositeOffsetSize],this._scrollPosition=q.getScrollPosition(this._viewportElement)[this._names.scrollPos],this._scrollLength=this._viewportElement[this._names.scrollSize];var b=a.getComputedStyle(this._surfaceElement);this._startSpacer=parseFloat(b[this._names.marginStart])+parseFloat(b[this._names.borderStart])+parseFloat(b[this._names.paddingStart]),this._endSpacer=parseFloat(b[this._names.marginEnd])+parseFloat(b[this._names.borderEnd])+parseFloat(b[this._names.paddingEnd]),this._sectionSizes=[];for(var c=0;c0&&(a+=",");var c=this._sectionSizes[b];a+=c.offset-c.marginStart-this._startSpacer+"px"}a+=")";var d="",e="";this.orientation===s.Orientation.vertical?d=a:e=a,this._lastSnapPointY!==d&&(this._lastSnapPointY=d,this._viewportElement.style["-ms-scroll-snap-points-y"]=d),this._lastSnapPointX!==e&&(this._lastSnapPointX=e,this._viewportElement.style["-ms-scroll-snap-points-x"]=e),this._writeProfilerMark("updateSnapList,StopTM")},_scrollToSection:function(a,b){this._measure();var c=this._sectionSizes[a],d=Math.min(this._scrollLength-this._viewportSize,c.offset-c.marginStart-this._startSpacer);this._scrollTo(d,b)},_ensureVisible:function(a,b){this._measure();var c=this._ensureVisibleMath(a,this._scrollPosition);this._scrollTo(c,b)},_ensureVisibleMath:function(a,b){this._measure();var c=this._sectionSizes[a],d=Math.min(this._scrollLength-this._viewportSize,c.offset-c.marginStart-this._startSpacer),e=Math.max(0,c.offset+c.size+c.marginEnd+this._endSpacer-this._viewportSize+1);return b>d?b=d:e>b&&(b=Math.min(d,e)),b},_scrollTo:function(a,b){if(this._scrollPosition=a,b)this.orientation===s.Orientation.vertical?q._zoomTo(this._viewportElement,{contentX:0,contentY:this._scrollPosition,viewportX:0,viewportY:0}):q._zoomTo(this._viewportElement,{contentX:this._scrollPosition,contentY:0,viewportX:0,viewportY:0});else{var c={};c[this._names.scrollPos]=this._scrollPosition,q.setScrollPosition(this._viewportElement,c)}},_windowKeyDownHandler:function(a){if(a.keyCode===u.tab){this._tabSeenLast=!0;var b=this;c._yieldForEvents(function(){b._tabSeenLast=!1})}},_focusin:function(a){if(this._tabSeenLast){var b=this._findHeaderTabStop(a.target);if(b&&!this._isHeaderInteractive(a.target)){var c=this.sections.indexOf(b.parentElement.parentElement.winControl);c>-1&&this._ensureVisible(c,!0)}}for(var d=a.target;d&&!q.hasClass(d,t.HubSection._ClassName.hubSection);)d=d.parentElement;if(d){var c=this.sections.indexOf(d.winControl);c>-1&&(this._currentIndexForSezo=c)}if(a.target===this.element){var e;+this._sectionToFocus===this._sectionToFocus&&this._sectionToFocus>=0&&this._sectionToFocus=0){for(var b=a;b=0;b--){var c=this.sections.getAt(b);if(q._setActiveFirstFocusableElement(c.contentElement,this._viewportElement))return;var d=q._trySetActive(c._headerTabStopElement,this._viewportElement);if(d)return}}},_keyDownHandler:function(a){var b=this._rtl?u.rightArrow:u.leftArrow,c=this._rtl?u.leftArrow:u.rightArrow;if(a.keyCode===u.upArrow||a.keyCode===u.downArrow||a.keyCode===u.leftArrow||a.keyCode===u.rightArrow||a.keyCode===u.pageUp||a.keyCode===u.pageDown){var d=this._findHeaderTabStop(a.target);if(d&&!this._isHeaderInteractive(a.target)){var e,f=this.sections.indexOf(d.parentElement.parentElement.winControl),g=!1;if(a.keyCode===u.pageDown||this.orientation===s.Orientation.horizontal&&a.keyCode===c||this.orientation===s.Orientation.vertical&&a.keyCode===u.downArrow){for(var h=f+1;h=0;h--)if(this._tryFocus(h)){e=h;break}(a.keyCode===u.upArrow||a.keyCode===u.downArrow||a.keyCode===u.leftArrow||a.keyCode===u.rightArrow)&&(g=!0),+e===e&&(g?this._ensureVisible(e,!0):this._scrollToSection(e,!0)),a.preventDefault()}}else if(a.keyCode===u.home||a.keyCode===u.end){this._measure();var i=Math.max(0,this._scrollLength-this._viewportSize);this._scrollTo(a.keyCode===u.home?0:i,!0),a.preventDefault()}},_tryFocus:function(b){var c=this.sections.getAt(b);return q._setActive(c._headerTabStopElement,this._viewportElement),a.document.activeElement===c._headerTabStopElement},zoomableView:{get:function(){return this._zoomableView||(this._zoomableView=new C(this)),this._zoomableView}},_getPanAxis:function(){return this.orientation===s.Orientation.horizontal?"horizontal":"vertical"},_configureForZoom:function(){},_setCurrentItem:function(a,b){var c;c=this.orientation===s.Orientation.horizontal?a:b,this._measure(),c+=this._scrollPosition,this._currentIndexForSezo=this._sectionSizes.length-1;for(var d=1;dc){this._currentIndexForSezo=d-1;break}}},_getCurrentItem:function(){var a;if(this._sectionSizes.length>0){this._measure();var b=Math.max(0,Math.min(this._currentIndexForSezo,this._sectionSizes.length)),c=this._sectionSizes[b];a=this.orientation===s.Orientation.horizontal?{left:Math.max(0,c.offset-c.marginStart-this._scrollPosition),top:0,width:c.size,height:this._viewportOppositeSize}:{left:0,top:Math.max(0,c.offset-c.marginStart-this._scrollPosition),width:this._viewportOppositeSize,height:c.size};var d=this.sections.getAt(b);return m.wrap({item:{data:d,index:b,groupIndexHint:b},position:a})}},_beginZoom:function(){this._viewportElement.style["-ms-overflow-style"]="none"},_positionItem:function(a,b){if(a.index>=0&&a.indexf;f++){var g=d[f],h=g.winControl;h._disposed||h&&h[c](a)}}function r(){y._rightMouseMightEdgy||y._hideAllFlyouts()}var s=g._createEventProperty,t="beforeshow",u="aftershow",v="beforehide",w="afterhide",x={get duplicateConstruction(){return"Invalid argument: Controls may only be instantiated one time for each DOM element"},get mustContainCommands(){return"Invalid HTML: AppBars/Menus must contain only AppBarCommands/MenuCommands"},get closeOverlay(){return h._getWinJSString("ui/closeOverlay").value}},y=d.Class.define(function(a,b){this._baseOverlayConstructor(a,b)},{_baseOverlayConstructor:function(a,c){this._disposed=!1,a||(a=b.document.createElement("div"));var d=a.winControl;if(d)throw new f("WinJS.UI._Overlay.DuplicateConstruction",x.duplicateConstruction);this._element||(this._element=a),this._sticky=!1,this._doNext="",this._element.style.visibility="hidden",this._element.style.opacity=0,a.winControl=this,o.addClass(this._element,p.overlayClass),o.addClass(this._element,"win-disposable");var e=this._element.getAttribute("unselectable");(null===e||void 0===e)&&this._element.setAttribute("unselectable","on"),this._currentAnimateIn=this._baseAnimateIn,this._currentAnimateOut=this._baseAnimateOut,this._animationPromise=l.as(),this._queuedToShow=[],this._queuedToHide=[],this._queuedCommandAnimation=!1,c&&n.setOptions(this,c)},element:{get:function(){return this._element}},disabled:{get:function(){return!!this._element.disabled},set:function(a){a=!!a;var b=!!this._element.disabled;b!==a&&(this._element.disabled=a,!this.hidden&&this._element.disabled&&this._hideOrDismiss())}},onbeforeshow:s(t),onaftershow:s(u),onbeforehide:s(v),onafterhide:s(w),dispose:function(){this._disposed||(this._disposed=!0,this._dispose())},_dispose:function(){},show:function(){this._show()},_show:function(){this._baseShow()},hide:function(){this._hide()},_hide:function(){this._baseHide()},hidden:{get:function(){return"hidden"===this._element.style.visibility||"hiding"===this._element.winAnimating||"hide"===this._doNext}},addEventListener:function(a,b,c){return this._element.addEventListener(a,b,c)},removeEventListener:function(a,b,c){return this._element.removeEventListener(a,b,c)},_baseShow:function(){if(this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard)return this._doNext="show",!1;if(this._cachedDocumentSize=this._cachedDocumentSize||y._sizeOfDocument(),"visible"!==this._element.style.visibility){this._element.winAnimating="showing",this._element.style.display="",this._element.style.visibility="hidden",this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),this._sendEvent(y.beforeShow),this._findPosition();var a=this;return this._animationPromise=this._currentAnimateIn().then(function(){a._baseEndShow()},function(){a._baseEndShow()}),!0}return!1},_findPosition:function(){},_baseEndShow:function(){this._disposed||(this._element.setAttribute("aria-hidden","false"),this._element.winAnimating="",this._endShow(),"show"===this._doNext&&(this._doNext=""),this._sendEvent(y.afterShow),this._writeProfilerMark("show,StopTM"),m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext"))},_endShow:function(){},_baseHide:function(){if(this._animating||this._needToHandleShowingKeyboard)return this._doNext="hide",!1;if(this._needToHandleHidingKeyboard&&(this._element.style.visibility=""),"hidden"!==this._element.style.visibility){if(this._element.winAnimating="hiding",this._element.setAttribute("aria-hidden","true"),this._sendEvent(y.beforeHide),""===this._element.style.visibility)this._element.style.opacity=0,this._baseEndHide();else{var a=this;this._animationPromise=this._currentAnimateOut().then(function(){a._baseEndHide()},function(){a._baseEndHide()})}return!0}return!1},_baseEndHide:function(){this._disposed||(this._element.style.visibility="hidden",this._element.style.display="none",this._element.winAnimating="",this._queuedCommandAnimation&&(this._showAndHideFast(this._queuedToShow,this._queuedToHide),this._queuedToShow=[],this._queuedToHide=[]),"hide"===this._doNext&&(this._doNext=""),this._sendEvent(y.afterHide),this._writeProfilerMark("hide,StopTM"),m.schedule(this._checkDoNext,m.Priority.normal,this,"WinJS.UI._Overlay._checkDoNext"))},_checkDoNext:function(){this._animating||this._needToHandleShowingKeyboard||this._needToHandleHidingKeyboard||this._disposed||("hide"===this._doNext?(this._hide(),this._doNext=""):this._queuedCommandAnimation?this._showAndHideQueue():"show"===this._doNext&&(this._show(),this._doNext=""))},_baseAnimateIn:function(){return this._element.style.opacity=0,this._element.style.visibility="visible",b.getComputedStyle(this._element,null).opacity,j.fadeIn(this._element)},_baseAnimateOut:function(){return this._element.style.opacity=1,b.getComputedStyle(this._element,null).opacity,j.fadeOut(this._element)},_animating:{get:function(){return!!this._element.winAnimating}},_sendEvent:function(a,c){if(!this._disposed){var d=b.document.createEvent("CustomEvent");d.initEvent(a,!0,!0,c||{}),this._element.dispatchEvent(d)}},_showCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands(c.commands,[],b)},_hideCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands([],c.commands,b)},_showOnlyCommands:function(a,b){var c=this._resolveCommands(a);this._showAndHideCommands(c.commands,c.others,b)},_showAndHideCommands:function(a,b,c){c||this.hidden&&!this._animating?(this._showAndHideFast(a,b),this._removeFromQueue(a,this._queuedToShow),this._removeFromQueue(b,this._queuedToHide)):(this._updateAnimateQueue(a,this._queuedToShow,this._queuedToHide),this._updateAnimateQueue(b,this._queuedToHide,this._queuedToShow))},_removeFromQueue:function(a,b){var c;for(c=0;c0&&(f=j.createDeleteFromListAnimation(c,0===a.length?d:void 0)),a.length>0&&(e=j.createAddToListAnimation(a,d));for(var g=0,h=c.length;h>g;g++){var i=c[g].getBoundingClientRect(),k=b.getComputedStyle(c[g]);c[g].style.top=i.top-parseFloat(k.marginTop)+"px",c[g].style.left=i.left-parseFloat(k.marginLeft)+"px",c[g].style.opacity=0,c[g].style.position="fixed"}this._element.winAnimating="rearranging";var m=null;for(f&&(m=f.execute()),g=0;ge;e++)b=c[e].winControl||c[e],b.hidden||d.push(b);return d},_baseEndAnimateCommands:function(a){if(!this._disposed){var b;for(b=0;be;e++){var f=c[e];if("hidden"!==f.style.visibility){var g=f.winControl;!g||b&&g._sticky||g._hideOrDismiss()}}},_hideSettingsFlyouts:function(a,b){for(var c=a.querySelectorAll("."+p.settingsFlyoutClass),d=c.length,e=0;d>e;e++){var f=c[e];if("hidden"!==f.style.visibility){var g=f.winControl;!g||b&&g._sticky||g._hideOrDismiss()}}},_hideAllFlyouts:function(){y._hideFlyouts(b.document,!0),y._hideSettingsFlyouts(b.document,!0)},_createClickEatingDivTemplate:function(a,c){var d=b.document.createElement("section");return d._winHideClickEater=c,o.addClass(d,a),o._addEventListener(d,"pointerup",function(a){y._checkSameClickEatingPointerUp(a,!0)},!0),o._addEventListener(d,"pointerdown",function(a){y._checkClickEatingPointerDown(a,!0)},!0),d.addEventListener("click",function(a){d._winHideClickEater(a)},!0),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",x.closeOverlay),d.setAttribute("unselectable","on"),b.document.body.appendChild(d),d},_createClickEatingDivAppBar:function(){y._clickEatingAppBarDiv||(y._clickEatingAppBarDiv=y._createClickEatingDivTemplate(p._clickEatingAppBarClass,y._handleAppBarClickEatingClick))},_createClickEatingDivFlyout:function(){y._clickEatingFlyoutDiv||(y._clickEatingFlyoutDiv=y._createClickEatingDivTemplate(p._clickEatingFlyoutClass,y._handleFlyoutClickEatingClick))},_checkClickEatingPointerDown:function(a,b){var c=a.currentTarget;if(c)try{c._winPointerId=a.pointerId,c._winRightMouse=2===a.button}catch(d){}b&&!c._winRightMouse&&(a.stopPropagation(),a.preventDefault())},_checkSameClickEatingPointerUp:function(a,b){var c=!1,d=!1,e=a.currentTarget;try{e&&e._winPointerId===a.pointerId&&(c=!0,d=e._winRightMouse,d&&b&&(c=!1))}catch(f){}return b&&!d&&(a.stopPropagation(),a.preventDefault(),e._winHideClickEater(a)),c},_handleAppBarClickEatingClick:function(a){a.stopPropagation(),a.preventDefault(),y._hideLightDismissAppBars(null,!1),y._hideClickEatingDivAppBar(),y._hideAllFlyouts()},_handleFlyoutClickEatingClick:function(a){a.stopPropagation(),a.preventDefault(),y._hideClickEatingDivFlyout(),y._hideFlyouts(b.document,!0)},_checkRightClickDown:function(a){y._checkClickEatingPointerDown(a,!1)},_checkRightClickUp:function(a){y._checkSameClickEatingPointerUp(a,!1)&&(y._rightMouseMightEdgy=!0,e._yieldForEvents(function(){y._rightMouseMightEdgy=!1}))},_showClickEatingDivAppBar:function(){m.schedule(function(){y._clickEatingAppBarDiv&&(y._clickEatingAppBarDiv.style.display="block")},m.Priority.high,null,"WinJS.UI._Overlay._showClickEatingDivAppBar")},_hideClickEatingDivAppBar:function(){m.schedule(function(){y._clickEatingAppBarDiv&&(y._clickEatingAppBarDiv.style.display="none")},m.Priority.high,null,"WinJS.UI._Overlay._hideClickEatingDivAppBar")},_showClickEatingDivFlyout:function(){m.schedule(function(){y._clickEatingFlyoutDiv&&(y._clickEatingFlyoutDiv.style.display="block")},m.Priority.high,null,"WinJS.UI._Overlay._showClickEatingDivFlyout")},_hideClickEatingDivFlyout:function(){m.schedule(function(){y._clickEatingFlyoutDiv&&(y._clickEatingFlyoutDiv.style.display="none")},m.Priority.high,null,"WinJS.UI._Overlay._hideClickEatingDivFlyout")},_isFlyoutVisible:function(){return y._clickEatingFlyoutDiv?"block"===y._clickEatingFlyoutDiv.style.display:!1},_hideIfLostFocus:function(a){if(!a.hidden&&"showing"!==a.element.winAnimating&&!a._sticky){var c=b.document.activeElement;if(!a._element||!a._element.contains(c)){if(o.hasClass(a._element,p.settingsFlyoutClass)){var d=a,e=y._getParentControlUsingClassName(c,"win-flyout");if(e&&e._previousFocus&&d.element.contains(e._previousFocus))return void o._addEventListener(e.element,"focusout",function f(a){y._hideIfLostFocus(d,a),o._removeEventListener(e.element,"focusout",f,!1)},!1)}c&&(o.hasClass(c,p._clickEatingFlyoutClass)||o.hasClass(c,p._clickEatingAppBarClass))||a._hideOrDismiss()}}},_checkBlur:function(){if(b.document.hasFocus()){if(y._clickEatingFlyoutDiv&&"block"===y._clickEatingFlyoutDiv.style.display||y._clickEatingAppBarDiv&&"block"===y._clickEatingAppBarDiv.style.display){var a=b.document.activeElement;a&&"IFRAME"===a.tagName&&!a.msLightDismissBlur&&(a.addEventListener("blur",y._checkBlur,!1),a.msLightDismissBlur=!0)}}else y._hideAllFlyouts(),y._hideLightDismissAppBars(null,!1)},_trySetActive:function(a){return a&&b.document.body&&b.document.body.contains(a)&&o._setActive(a)?a===b.document.activeElement:!1},_trySelect:function(a){try{a&&a.select&&a.select()}catch(b){}},_addHideFocusClass:function(a){a&&(o.addClass(a,p.hideFocusClass),o._addEventListener(a,"focusout",y._removeHideFocusClass,!1))},_removeHideFocusClass:function(a){var c=a.target;c&&c!==b.document.activeElement&&(o.removeClass(c,p.hideFocusClass),o._removeEventListener(a.target,"focusout",y._removeHideFocusClass,!1))},_sizeOfDocument:function(){return{width:b.document.documentElement.offsetWidth,height:b.document.documentElement.offsetHeight}},_getParentControlUsingClassName:function(a,c){for(;a&&a!==b.document.body;){if(o.hasClass(a,c))return a.winControl;a=a.parentNode}return null},_hideIfAllAppBarsLostFocus:function(){y._isAppBarOrChild(b.document.activeElement)||(y._hideLightDismissAppBars(null,!1),y._ElementWithFocusPreviousToAppBar=null)},_hideLightDismissAppBars:function(a,c){for(var d=b.document.querySelectorAll("."+p.appBarClass),e=d.length,f=[],g=0;e>g;g++){var h=d[g].winControl;!h||h.sticky||h.hidden||f.push(h)}y._hideAllBars(f,c)},_hideAllBars:function(a,b){var c=a.map(function(a){return a._keyboardInvoked=b,a.hide(),a._animationPromise});return l.join(c)},_showAllBars:function(a,b){var c=a.map(function(a){return a._keyboardInvoked=b,a._doNotFocus=!1,a._show(),a._animationPromise});return l.join(c)},_isAppBarOrChild:function(a){if(!a)return null;if(o.hasClass(a,p._clickEatingAppBarClass)||o.hasClass(a,p._clickEatingFlyoutClass)||o.hasClass(a,p.firstDivClass)||o.hasClass(a,p.finalDivClass)||o.hasClass(a,p.invokeButtonClass))return a;for(;a&&a!==b.document;){if(o.hasClass(a,p.appBarClass))return a;if(o.hasClass(a,"win-flyout")&&a!==a.winControl._previousFocus){var c=a.winControl,d=y._isAppBarOrChild(c._previousFocus);return d&&o._addEventListener(c.element,"focusout",function e(){y._hideIfAllAppBarsLostFocus(),o._removeEventListener(c.element,"focusout",e,!1)},!1),d}a=a.parentNode}return null},_keyboardInfo:{get _visible(){try{return c.Windows.UI.ViewManagement.InputPane&&c.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height>0}catch(a){return!1}},get _extraOccluded(){var a;if(c.Windows.UI.ViewManagement.InputPane)try{a=c.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height}catch(b){}return a&&!y._keyboardInfo._isResized?a:0},get _isResized(){var a=b.document.documentElement.clientHeight/b.innerHeight,c=b.document.documentElement.clientWidth/b.innerWidth;return.99>c/a},get _visibleDocBottom(){return y._keyboardInfo._visibleDocTop+y._keyboardInfo._visibleDocHeight},get _visibleDocHeight(){return y._keyboardInfo._visualViewportHeight-y._keyboardInfo._extraOccluded},get _animationShowLength(){if(c.Windows.UI.Core.AnimationMetrics){for(var a=c.Windows.UI.Core.AnimationMetrics,b=new a.AnimationDescription(a.AnimationEffect.showPanel,a.AnimationEffectTarget.primary),d=b.animations,e=0,f=0;f