From 17712de385f3307bda328849c0ae0b7de33b5182 Mon Sep 17 00:00:00 2001 From: Vitali Malinouski Date: Wed, 26 Apr 2023 10:46:32 -0700 Subject: [PATCH] Release v2.0.0 --- dist/w2ui-1.5.css | 3720 --- dist/w2ui-1.5.js | 21491 ---------------- dist/w2ui-1.5.js.map | 1 - dist/w2ui-1.5.min.css | 2 - dist/w2ui-1.5.min.js | 2 - dist/{w2ui.css => w2ui-2.0.css} | 2 +- dist/{w2ui.es6.js => w2ui-2.0.es6.js} | 184 +- dist/{w2ui.es6.min.js => w2ui-2.0.es6.min.js} | 10 +- dist/{w2ui.js => w2ui-2.0.js} | 184 +- dist/{w2ui.min.css => w2ui-2.0.min.css} | 2 +- dist/{w2ui.min.js => w2ui-2.0.min.js} | 136 +- dist/w2ui-dark-1.5.css | 3734 --- dist/w2ui-dark-1.5.min.css | 3734 --- 13 files changed, 267 insertions(+), 32935 deletions(-) delete mode 100644 dist/w2ui-1.5.css delete mode 100644 dist/w2ui-1.5.js delete mode 100644 dist/w2ui-1.5.js.map delete mode 100644 dist/w2ui-1.5.min.css delete mode 100644 dist/w2ui-1.5.min.js rename dist/{w2ui.css => w2ui-2.0.css} (99%) rename dist/{w2ui.es6.js => w2ui-2.0.es6.js} (99%) rename dist/{w2ui.es6.min.js => w2ui-2.0.es6.min.js} (80%) rename dist/{w2ui.js => w2ui-2.0.js} (99%) rename dist/{w2ui.min.css => w2ui-2.0.min.css} (99%) rename dist/{w2ui.min.js => w2ui-2.0.min.js} (70%) delete mode 100644 dist/w2ui-dark-1.5.css delete mode 100644 dist/w2ui-dark-1.5.min.css diff --git a/dist/w2ui-1.5.css b/dist/w2ui-1.5.css deleted file mode 100644 index 57b9f6a72..000000000 --- a/dist/w2ui-1.5.css +++ /dev/null @@ -1,3720 +0,0 @@ -/* w2ui 1.5 (c) http://w2ui.com, vitmalina@gmail.com */ -@font-face { - font-family: "w2ui-font"; - src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAgYAAsAAAAADCgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAAQwAAAFZAvUydY21hcAAAAYAAAAB/AAACCorO9ixnbHlmAAACAAAAA9YAAAVEmVxhomhlYWQAAAXYAAAALgAAADYV9d2naGhlYQAABggAAAAgAAAAJAPzAcxobXR4AAAGKAAAABgAAAA0Ft0AAGxvY2EAAAZAAAAAHAAAABwGqghkbWF4cAAABlwAAAAfAAAAIAEdAGBuYW1lAAAGfAAAAS0AAAIixND/MnBvc3QAAAesAAAAawAAAI73f09seJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkPMQ4gYGVgYPRhTGNgYHBHUp/ZZBkaGFgYGJgZWbACgLSXFMYHD4yfuRhPPD/AIMe4wEGJ6AwI0gOAMnTC94AeJztkcsRwzAIRJ8sLP9USgpIQTmlqrRIBQ4LhzQRzbzdYYV0AGAFevAIDNqbhs4r0pZ558zceGaPKfd536FNGrWlLtFr8eNgY+eIdxczLgb/M1M/v8pbkdNcCuS90FbcCs3X10Ib81Eg3wrke4H8KJCfhTbpV4F8FswvHRkgdQB4nIVUXWgjVRS+Z6aZO3fSnSQ7f+2U/M2QGUtsWpL52bRuGmhVfJCNCLWSpBRf6oOyQtcuqyxUWGR9EJb1VZaKgoItCvusdl92obigIIr4Ep98ULQvPigy9dwmoSKCgXvOzfnOmTk/3xkChJwcCwR2SYoQoD61AD49fqVzCG3YHWqOnPwCf8FtwohG8mSORIRonpQBySyCH1MVihD7NbACz/U9iYrLcKo4bEaxFnmiCjVoQQGekQ1aooJ89MJj8wqdeFkyJ/RPMkojjQ97aXdO0VPvpyRlpA9SukYVXZPAwxBfNqWPvn3VmNCV336eZ7KCMZBJJ39+PWOlKEvuMWNiCi+wrOjJfUXigcwghIiY/x/wA9zBGyVpzL2Rc8dnttv9uNvd73bhTtKDD4YHW4FxBG7A28RFbZl6ZigkZx4oF17Ai0QR1bH4qA6dKmP9PmNVNi33e2yanf1nvb48DTeq8jQbIrLc78vyEEF39Oz1GJnAPB9gnz8jGTJNPNLATINoCepmHnSpCo4XWm7YCPEYDVEV9ALUWxDUQHRqELSgXgBdhR9VJctUlWUVdeN6sbhRbK1eWVm5cnN7dXV79UI/jvuXN6JoAx4ZOanKN6WN4nV4Hla2b448k+bI63I/Jqd5HcIADolBCuRRUseOuIHnSIaLJ6ebjXI9CnOB59dNXXK8INLKuYahm5h6dBEaoh9bsQVf3apElVuUMQp7KL87p2m2pj1MdtuMDihrD7YKT71VgN2ZSmWG0WRz7FnibraWICEXuG0hubtTWHytQATM63v4CT7EDDVClgU/gyzzlwWXipU4zMD9xaP80ZNp25prHqwdrEFpf999M4+2PctOv+7u7ycDNB80yXje78C7fN4Vg7fbGPb8Irhc8EGE42k06ibczqavZtPxZPZqOsuvk3GaX39Fy85kNju5M7ZwkD//5He4C1+QWXyP5zp8fEKjHsUtXB5Txx1ynZoQtNBmWnFEDQrx7IV86FmWF+bLS4Ygi54oFNcWqp2m4zQ71dmn84+n4CFunuWHS6FvFWwRRF/A4mfdxc5znUW3mL+U+jI1haXxXn0uCDhDm/hYoe/RFtZTA0cF5BFPRCrifkZe5Z9kguNr2nlzKlh/cT0I1gO3bUNu65xnC8k9d8lxlp7gYnIrB3bbDbgL+k2Z57VrGcH23hjhKIiE7x/gd+Y9YpEZZHZMLpFnkd9h4GGTpTy4xhljymEKKW6NobJRPiNT6FLE6H+HlTk2UJWOom5uniooIb+GlmQApRG02d77l9NgE+kl822Q2yOFv/X/NWBr/waLePNCAAB4nGNgZGBgAGKPXU+b4/ltvjJwMzGAwK0sv2kI+v8+JibGA0AuBwNYGgA8nwr1AAB4nGNgZGBgPPD/AIMeEwMDw/9/TEwMQBEUwAsAe4MEwXicY2BgYGBCwoyTUfkwMcbtCD4AJvcB8wAAAAAAEgByAIwAxgDGARIBXgGEAbQB9AI0AqJ4nGNgZGBg4GUIYWBjAAEmIOYCQgaG/2A+AwASZwF+AHicbY9NbsIwEIVfIFAVpAq1UqXurC66qQg/CxYcAPYs2IfgBFASR45B4gI9Qc/QM/QEXfYMPUpfwiiLFlsef/PmjX8ADPAFD9XwcFvHarRww+zCbdJA2Cc/CXfQx7Nwl/pQuIdXzIT7eEDIEzy/Ou0eTriFO7wJt6m/C/vkD+EOHvEp3KX+LdzDGj/Cfbx4s31k8mFscrfSyTENbZM3sNa23JtcTYJxoy11rm3o9FZtzqo8JVPnYhVbk6kFqzpNjSqsOejIBTvnivloFIseRCbDHhEMcv46rneHFTQSHJHyx/ZK/b+yZodFyUqVK0wQYHzFt6Qvr70hM40tvRucGUuceOeUqqNbcVn2ZKSF9Gq+JyUrFHXtQCWiHmBXdxWYY8QZ//EH9SuyX24OYHIAAAB4nG3FyxKDIAwF0FwlaB/2H5k0rUwRGIIL/76d6dazOTTQH9O5BQNGODA8Jsy44Iob7ljwIJZV5eOlpNJs+rVv2VhaMWPdaj9czK/CNVhXXzVLTK6m3XzTVMLTm4Ym62zae8xvI/oC0MIdHQA=") format("woff"); - font-weight: normal; - font-style: normal; -} -[class^="w2ui-icon-"]:before, -[class*=" w2ui-icon-"]:before { - font-family: "w2ui-font"; - display: inline-block; - vertical-align: middle; - line-height: 1; - font-weight: normal; - font-style: normal; - speak: none; - text-decoration: inherit; - text-transform: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} -/* Icons */ -.w2ui-icon-check:before { - content: "\f101"; -} -.w2ui-icon-colors:before { - content: "\f102"; -} -.w2ui-icon-columns:before { - content: "\f103"; -} -.w2ui-icon-cross:before { - content: "\f104"; -} -.w2ui-icon-empty:before { - content: "\f105"; -} -.w2ui-icon-info:before { - content: "\f106"; -} -.w2ui-icon-paste:before { - content: "\f107"; -} -.w2ui-icon-pencil:before { - content: "\f108"; -} -.w2ui-icon-plus:before { - content: "\f109"; -} -.w2ui-icon-reload:before { - content: "\f10a"; -} -.w2ui-icon-search:before { - content: "\f10b"; -} -.w2ui-icon-settings:before { - content: "\f10c"; -} -/************************************************* -* --- Reset (used for all w2ui widgets) -* --- The reset is needed to coexist with other CSS -* --- on the same page (for example bootstrap) -*/ -.w2ui-reset { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; - font-family: Verdana, Arial, sans-serif; - font-size: 11px; -} -.w2ui-reset * { - color: default; - line-height: 100%; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; - margin: 0px; - padding: 0px; -} -.w2ui-reset table { - max-width: none; - background-color: transparent; - border-collapse: separate; - border-spacing: 0; - border: none; -} -.w2ui-reset table tr th, -.w2ui-reset table tr td { - font-family: Verdana, Arial, sans-serif; - font-size: 11px; -} -.w2ui-reset input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]), -.w2ui-reset select, -.w2ui-reset textarea { - display: inline-block; - width: auto; - height: auto; - vertical-align: baseline; - padding: 4px; - margin: 0; - font-size: 11px; -} -.w2ui-reset select { - padding: 1px; - height: 23px; - font-size: 11px; -} -.w2ui-centered { - position: absolute; - left: 0px; - right: 0px; - top: 50%; - -webkit-transform: translateY(-50%); - -moz-transform: translateY(-50%); - -ms-transform: translateY(-50%); - -o-transform: translateY(-50%); - transform: translateY(-50%); - max-height: 100%; - margin: 0px; - padding: 0px 10px; - text-align: center; -} -.w2ui-disabled, -.w2ui-readonly { - background-color: #f1f1f1 !important; - color: #777 !important; - outline: none!important; -} -.w2ui-message { - font-size: 12px; - position: absolute; - z-index: 250; - background-color: #F9F9F9; - border: 1px solid #999; - box-shadow: 0px 0px 15px #aaa; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; - border-top: 0px; - border-radius: 0px 0px 6px 6px; - overflow: auto; -} -.w2ui-message .w2ui-message-body { - position: absolute; - top: 0px; - bottom: 45px; - left: 0px; - right: 0px; - overflow: auto; - line-height: 1.5; - font-size: 14px; -} -.w2ui-message .w2ui-message-body .w2ui-centered { - line-height: 1.5; -} -.w2ui-message .w2ui-message-buttons { - position: absolute; - height: 45px; - bottom: 0px; - left: 0px; - right: 0px; - border-top: 1px solid #e5e5e5; - text-align: center; - padding: 8px; -} -/************************************************* -* ---- Input Controls ---- -*/ -div.w2ui-input:focus { - outline-color: #72B2FF; -} -input:not([type=button]):not([type=submit]).w2ui-input, -textarea.w2ui-input { - padding: 4px; - border: 1px solid #cacaca; - border-radius: 3px; - color: black; - background-color: white; - line-height: normal; -} -input:not([type=button]):not([type=submit]).w2ui-input:focus, -textarea.w2ui-input:focus { - outline-color: #72B2FF; -} -input:not([type=button]):not([type=submit]).w2ui-input:disabled, -textarea.w2ui-input:disabled, -input:not([type=button]):not([type=submit]).w2ui-input[readonly], -textarea.w2ui-input[readonly] { - background-color: #f1f1f1; - color: #777; - outline: none!important; -} -/* IE9-11 specific classes */ -/* needs doblue :: */ -input.w2ui-input::-ms-clear { - display: none; -} -input.w2ui-input:-ms-input-placeholder { - color: #aaa !important; -} -select.w2ui-input { - color: black; - padding: 0px 15px 0px 7px; - line-height: 1.8; - border-radius: 3px; - border: 1px solid #cacaca; - -webkit-appearance: none; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), linear-gradient(to bottom, #FFF 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-size: 17px 6px, 100% 100%; - background-position: right center, left top; - background-repeat: no-repeat, no-repeat; -} -.w2ui-icon-expand:before { - position: relative; - top: 1px; - left: 1px; - content: ' '; - width: 5px; - height: 5px; - border: 2px solid rgba(150, 150, 150, 0.8); - border-bottom: 0; - border-left: 0; - transform: rotateZ(45deg); -} -.w2ui-icon-collapse:before { - position: relative; - top: -1px; - left: 3px; - content: ' '; - width: 5px; - height: 5px; - border: 2px solid rgba(150, 150, 150, 0.8); - border-bottom: 0; - border-left: 0; - transform: rotateZ(135deg); -} -/* On/Off switch */ -input[type="checkbox"].w2ui-toggle { - position: absolute; - opacity: 0; - width: 46px; - height: 22px; - padding: 0px; - margin: 0px; - margin-left: 2px; - /* Knob */ - /* Green */ - /* Default Blue */ -} -input[type="checkbox"].w2ui-toggle:focus { - box-shadow: 0px 0px 1px 2px #a8cfff; -} -input[type="checkbox"].w2ui-toggle + div { - display: inline-block; - width: 46px; - height: 22px; - border: 1px solid #bbb; - border-radius: 30px; - background-color: #eee; - transition-duration: 0.3s; - transition-property: background-color, box-shadow; - box-shadow: inset 0 0 0 0px rgba(0, 0, 0, 0.4); - margin-left: 2px; -} -input[type="checkbox"].w2ui-toggle.w2ui-small + div { - width: 30px; - height: 16px; -} -input[type="checkbox"].w2ui-toggle:focus + div { - box-shadow: 0px 0px 3px 2px #91baed; -} -input[type="checkbox"].w2ui-toggle:disabled + div { - opacity: 0.3; -} -input[type="checkbox"].w2ui-toggle + div > div { - float: left; - width: 22px; - height: 22px; - border-radius: inherit; - background: #f5f5f5; - transition-duration: 0.3s; - transition-property: transform, background-color, box-shadow; - box-shadow: 0px 0px 1px #323232, 0 0 0 1px rgba(200, 200, 200, 0.6); - pointer-events: none; - margin-top: -1px; - margin-left: -1px; -} -input[type="checkbox"].w2ui-toggle.w2ui-small + div > div { - width: 16px; - height: 16px; -} -input[type="checkbox"].w2ui-toggle:checked + div > div { - transform: translate3d(24px, 0, 0); - background-color: #ffffff; -} -input[type="checkbox"].w2ui-toggle.w2ui-small:checked + div > div { - transform: translate3d(14px, 0, 0); -} -input[type="checkbox"].w2ui-toggle:focus { - outline: none; -} -input[type="checkbox"].w2ui-toggle:checked + div { - border: 1px solid #00a23f; - box-shadow: inset 0 0 0 12px #54B350; -} -input[type="checkbox"].w2ui-toggle:checked:focus + div { - box-shadow: 0px 0px 3px 2px #91baed, inset 0 0 0 12px #54B350; -} -input[type="checkbox"].w2ui-toggle:checked + div > div { - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 1px #00a23f; -} -input[type="checkbox"].w2ui-toggle.blue:checked + div { - border: 1px solid #206FAD; - box-shadow: inset 0 0 0 12px #35A6EB; -} -input[type="checkbox"].w2ui-toggle.blue:checked:focus + div { - box-shadow: 0px 0px 3px 2px #91baed, inset 0 0 0 12px #35A6EB; -} -input[type="checkbox"].w2ui-toggle.blue:checked + div > div { - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px #206FAD; -} -/************************************************* -* ---- Overlay and Bubble ---- -*/ -.w2ui-overlay { - position: absolute; - margin-top: 4px; - margin-left: -17px; - display: none; - z-index: 1300; - color: inherit; - background-color: #FbFbFb; - border-color: #FbFbFb; - box-shadow: 0px 2px 10px #999; - border-radius: 4px; - text-align: left; -} -.w2ui-overlay > div { - border-radius: 4px; - position: relative; - border: 3px solid #777; -} -.w2ui-overlay table td { - color: inherit; -} -.w2ui-overlay:before { - content: ""; - position: absolute; - border-color: inherit; -} -.w2ui-overlay:after { - content: ""; - position: absolute; - border-color: inherit; - bottom: 100%; - left: 4px; -} -.w2ui-overlay.top-arrow:before { - border-bottom: 12px solid #6f6f6f; - border-right: 12px solid transparent; - border-left: 12px solid transparent; - bottom: 100%; - margin-bottom: -3px; -} -.w2ui-overlay.top-arrow:after { - border-bottom: 8px solid black; - border-bottom-color: inherit; - border-right: 8px solid transparent; - border-left: 8px solid transparent; - bottom: 100%; - margin-bottom: -3px; -} -.w2ui-overlay.bottom-arrow:before { - border-top: 12px solid #6f6f6f; - border-right: 12px solid transparent; - border-left: 12px solid transparent; - top: 100%; - margin-top: -3px; -} -.w2ui-overlay.bottom-arrow:after { - border-top: 8px solid black; - border-top-color: inherit; - border-right: 8px solid transparent; - border-left: 8px solid transparent; - top: 100%; - margin-top: -3px; -} -.w2ui-overlay.w2ui-overlay-popup { - z-index: 1700; -} -.w2ui-overlay .w2ui-grid-searches { - border-top: 3px solid #777 !important; -} -.w2ui-overlay .w2ui-no-color { - border: 1px solid #eee; - background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABlBMVEX/////TgCFoIUYAAAAGUlEQVR42uXHIQEAAACDsNO/NJ4Kn9uC8wsJkAARUrXAjwAAAABJRU5ErkJggg=='); - background-size: 15px 15px; -} -.w2ui-tag { - position: absolute; - z-index: 1300; - opacity: 0; - -webkit-transition: opacity 0.3s; - -moz-transition: opacity 0.3s; - -ms-transition: opacity 0.3s; - -o-transition: opacity 0.3s; - transition: opacity 0.3s; -} -.w2ui-tag .w2ui-tag-body { - box-sizing: border-box; - display: inline-block; - position: absolute; - border-radius: 3px; - padding: 6px 10px; - margin-left: 10px; - margin-top: 0px; - background-color: rgba(60, 60, 60, 0.9); - color: white !important; - font-size: 11px; - font-family: verdana; - text-shadow: 1px 1px 3px #000; - line-height: 1.4; - letter-spacing: 0.1px; -} -.w2ui-tag .w2ui-tag-body.w2ui-light { - color: #3c3c3c !important; - background-color: #fffde9; - border: 1px solid #9c9c9c; - box-shadow: 1px 1px 4px #bfbfbf; - text-shadow: none; -} -.w2ui-tag .w2ui-tag-body.w2ui-tag-right:before { - content: ""; - position: absolute; - margin: 2px 0 0 -15px; - border: 1px solid; - border-color: inherit; - background-color: inherit; - width: 7px; - height: 7px; - transform: rotate(135deg); - border-top-left-radius: 20px; - border-top-width: 0; - border-left-width: 0; -} -.w2ui-tag .w2ui-tag-body.w2ui-tag-left:after { - content: ""; - position: absolute; - top: 8px; - margin: 0px 0 0 7px; - border: 1px solid; - border-color: inherit; - background-color: inherit; - width: 7px; - height: 7px; - transform: rotate(-45deg); - border-top-left-radius: 20px; - border-top-width: 0; - border-left-width: 0; -} -.w2ui-tag .w2ui-tag-body.w2ui-tag-bottom:before { - content: ""; - position: absolute; - margin: -12px 0 0 2px; - border: 1px solid; - border-color: inherit; - background-color: inherit; - width: 8px; - height: 9px; - transform: rotate(-135deg); - border-top-left-radius: 20px; - border-top-width: 0; - border-left-width: 0; -} -.w2ui-tag .w2ui-tag-body.w2ui-tag-top:after { - content: ""; - position: absolute; - left: 12px; - bottom: -6px; - border: 1px solid; - border-color: inherit; - background-color: inherit; - width: 8px; - height: 9px; - transform: rotate(45deg); - border-top-left-radius: 20px; - border-top-width: 0; - border-left-width: 0; -} -.w2ui-tag.w2ui-tag-popup { - z-index: 1700; -} -/* -* Drop down menu -*/ -.w2ui-menu { - position: absolute; - top: 0px; - bottom: 0px; -} -.w2ui-menu table { - font-family: verdana; - font-size: 11px; - width: 100%; - color: black; - background-color: white; - padding: 5px 0px; - cursor: default; -} -.w2ui-menu table td { - white-space: nowrap; -} -.w2ui-menu table.sub-menu { - top: 0; - background-color: #fafdff; - border-top: 1px dotted #cccccc; - border-bottom: 1px dotted #cccccc; -} -.w2ui-menu table.sub-menu td:first-child { - padding-left: 10px; -} -.w2ui-menu table.sub-menu td.menu-divider { - padding-left: 16px; -} -.w2ui-menu table .w2ui-item-even { - color: inherit; - background-color: #FFF; -} -.w2ui-menu table .w2ui-item-odd { - color: inherit; - background-color: #F3F6FA; -} -.w2ui-menu table .w2ui-item-group { - color: #444; - font-weight: bold; - background-color: #ECEDF0; - border-bottom: 1px solid #D3D2D4; -} -.w2ui-menu table td.menu-icon { - padding: 3px 0px 4px 6px; - width: 20px; -} -.w2ui-menu table td.menu-icon > span { - height: 20px; - width: 18px; -} -.w2ui-menu table td.menu-divider { - padding: 6px; - pointer-events: none; -} -.w2ui-menu table td.menu-divider div.line { - border-top: 1px solid silver; - color: transparent; - height: 0px; - padding: 0px 25px 0 0px; -} -.w2ui-menu table td.menu-divider.divider-text { - padding: 12px 6px; -} -.w2ui-menu table td.menu-divider.divider-text div.text { - display: block; - position: absolute; - margin-top: -6px; - margin-left: 46%; - background-color: white; - padding: 0px 3px; - color: darkgrey; - transform: translateX(-50%); -} -.w2ui-menu table td.menu-text { - padding: 8px 10px 8px 5px; - width: auto; -} -.w2ui-menu table td.menu-count { - text-align: right; - padding-right: 1px; -} -.w2ui-menu table td.menu-count > span { - border: 1px solid #F6FCF4; - border-radius: 20px; - width: auto; - height: 18px; - padding: 2px 7px; - margin: 3px 5px 0px 5px; - background-color: #F2F8F0; - color: #666; - box-shadow: 0px 0px 2px #474545; - text-shadow: 1px 1px 0px #FFF; -} -.w2ui-menu table td.menu-count > span.hotkey { - border: none; - border-radius: 0px; - background-color: transparent !important; - color: #888; - box-shadow: none; - text-shadow: none; -} -.w2ui-menu table td.menu-count > span.remove { - border-color: transparent; - background-color: transparent; - box-shadow: none; - padding: 2px 5px; -} -.w2ui-menu table td.menu-count > span.remove:hover { - color: #982525; - border-color: #d28d5b; - background-color: #f9e7e7; -} -.w2ui-menu table tr.expanded td.menu-count > span, -.w2ui-menu table tr.collapsed td.menu-count > span { - border-color: transparent; - background-color: transparent; - box-shadow: none; - padding: 2px 5px; - border-radius: 0px; -} -.w2ui-menu table tr.expanded td.menu-count > span:after, -.w2ui-menu table tr.collapsed td.menu-count > span:after { - content: ""; - position: absolute; - border-left: 5px solid #808080; - border-top: 5px solid transparent; - border-bottom: 5px solid transparent; - transform: rotateZ(-90deg); - pointer-events: none; - margin-left: -2px; -} -.w2ui-menu table tr.expanded td.menu-count > span:hover, -.w2ui-menu table tr.collapsed td.menu-count > span:hover { - border-color: transparent; - background-color: transparent; -} -.w2ui-menu table tr.collapsed td.menu-count span:after { - transform: rotateZ(90deg); -} -.w2ui-menu table tr:hover { - color: inherit; - background-color: #E6F0FF; -} -.w2ui-menu table tr.w2ui-selected { - background-color: #B6D5FB; -} -.w2ui-menu table tr.w2ui-selected td { - color: inherit; -} -.w2ui-menu table tr.w2ui-disabled { - opacity: 0.4; - background-color: white !important; -} -.w2ui-menu table .w2ui-icon { - font-size: 14px; - color: #8D99A7; - display: inline-block; - padding-top: 4px; -} -.w2ui-menu-inline { - padding: 0; - margin: 0; -} -.w2ui-menu-inline .w2ui-menu { - position: static; -} -.w2ui-menu-inline .w2ui-menu > table { - padding: 0px; -} -.w2ui-menu-inline .w2ui-menu table td.menu-icon, -.w2ui-menu-inline .w2ui-menu table td.menu-text { - padding: 1px 1px 1px 5px; -} -/************************************************* -* ---- Common Classes ---- -*/ -.w2ui-marker { - color: #444; - background-color: rgba(252, 244, 161, 0.48); -} -.w2ui-spinner { - display: inline-block; - background-size: 100%; - background-repeat: no-repeat; - background-image: url(data:image/gif;base64,R0lGODlhgACAAKIAAP///93d3bu7u5mZmQAA/wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAEACwCAAIAfAB8AAAD/0i63P4wygYqmDjrzbtflvWNZGliYXiubKuloivPLlzReD7al+7/Eh5wSFQIi8hHYBkwHUmD6CD5YTJLz49USuVYraRsZ7vtar7XnQ1Kjpoz6LRHvGlz35O4nEPP2O94EnpNc2sef1OBGIOFMId/inB6jSmPdpGScR19EoiYmZobnBCIiZ95k6KGGp6ni4wvqxilrqBfqo6skLW2YBmjDa28r6Eosp27w8Rov8ekycqoqUHODrTRvXsQwArC2NLF29UM19/LtxO5yJd4Au4CK7DUNxPebG4e7+8n8iv2WmQ66BtoYpo/dvfacBjIkITBE9DGlMvAsOIIZjIUAixliv9ixYZVtLUos5GjwI8gzc3iCGghypQqrbFsme8lwZgLZtIcYfNmTJ34WPTUZw5oRxdD9w0z6iOpO15MgTh1BTTJUKos39jE+o/KS64IFVmsFfYT0aU7capdy7at27dw48qdS7eu3bt480I02vUbX2F/JxYNDImw4GiGE/P9qbhxVpWOI/eFKtlNZbWXuzlmG1mv58+gQ4seTbq06dOoU6vGQZJy0FNlMcV+czhQ7SQmYd8eMhPs5BxVdfcGEtV3buDBXQ+fURxx8oM6MT9P+Fh6dOrH2zavc13u9JXVJb520Vp8dvC76wXMuN5Sepm/1WtkEZHDefnzR9Qvsd9+/wi8+en3X0ntYVcSdAE+UN4zs7ln24CaLagghIxBaGF8kFGoIYV+Ybghh841GIyI5ICIFoklJsigihmimJOLEbLYIYwxSgigiZ+8l2KB+Ml4oo/w8dijjcrouCORKwIpnJIjMnkkksalNeR4fuBIm5UEYImhIlsGCeWNNJphpJdSTlkml1jWeOY6TnaRpppUctcmFW9mGSaZceYopH9zkjnjUe59iR5pdapWaGqHopboaYua1qije67GJ6CuJAAAIfkEBQUABAAsCgACAFcAMAAAA/9Iutz+ML5Ag7w46z0r5WAoSp43nihXVmnrdusrv+s332dt4Tyo9yOBUJD6oQBIQGs4RBlHySSKyczVTtHoidocPUNZaZAr9F5FYbGI3PWdQWn1mi36buLKFJvojsHjLnshdhl4L4IqbxqGh4gahBJ4eY1kiX6LgDN7fBmQEJI4jhieD4yhdJ2KkZk8oiSqEaatqBekDLKztBG2CqBACq4wJRi4PZu1sA2+v8C6EJexrBAD1AOBzsLE0g/V1UvYR9sN3eR6lTLi4+TlY1wz6Qzr8u1t6FkY8vNzZTxaGfn6mAkEGFDgL4LrDDJDyE4hEIbdHB6ESE1iD4oVLfLAqPETIsOODwmCDJlv5MSGJklaS6khAQAh+QQFBQAEACwfAAIAVwAwAAAD/0i63P5LSAGrvTjrNuf+YKh1nWieIumhbFupkivPBEzR+GnnfLj3ooFwwPqdAshAazhEGUXJJIrJ1MGOUamJ2jQ9QVltkCv0XqFh5IncBX01afGYnDqD40u2z76JK/N0bnxweC5sRB9vF34zh4gjg4uMjXobihWTlJUZlw9+fzSHlpGYhTminKSepqebF50NmTyor6qxrLO0L7YLn0ALuhCwCrJAjrUqkrjGrsIkGMW/BMEPJcphLgDaABjUKNEh29vdgTLLIOLpF80s5xrp8ORVONgi8PcZ8zlRJvf40tL8/QPYQ+BAgjgMxkPIQ6E6hgkdjoNIQ+JEijMsasNY0RQix4gKP+YIKXKkwJIFF6JMudFEAgAh+QQFBQAEACw8AAIAQgBCAAAD/kg0PPowykmrna3dzXvNmSeOFqiRaGoyaTuujitv8Gx/661HtSv8gt2jlwIChYtc0XjcEUnMpu4pikpv1I71astytkGh9wJGJk3QrXlcKa+VWjeSPZHP4Rtw+I2OW81DeBZ2fCB+UYCBfWRqiQp0CnqOj4J1jZOQkpOUIYx/m4oxg5cuAaYBO4Qop6c6pKusrDevIrG2rkwptrupXB67vKAbwMHCFcTFxhLIt8oUzLHOE9Cy0hHUrdbX2KjaENzey9Dh08jkz8Tnx83q66bt8PHy8/T19vf4+fr6AP3+/wADAjQmsKDBf6AOKjS4aaHDgZMeSgTQcKLDhBYPEswoA1BBAgAh+QQFBQAEACxOAAoAMABXAAAD7Ei6vPOjyUkrhdDqfXHm4OZ9YSmNpKmiqVqykbuysgvX5o2HcLxzup8oKLQQix0UcqhcVo5ORi+aHFEn02sDeuWqBGCBkbYLh5/NmnldxajX7LbPBK+PH7K6narfO/t+SIBwfINmUYaHf4lghYyOhlqJWgqDlAuAlwyBmpVnnaChoqOkpaanqKmqKgGtrq+wsbA1srW2ry63urasu764Jr/CAb3Du7nGt7TJsqvOz9DR0tPU1TIA2ACl2dyi3N/aneDf4uPklObj6OngWuzt7u/d8fLY9PXr9eFX+vv8+PnYlUsXiqC3c6PmUUgAACH5BAUFAAQALE4AHwAwAFcAAAPpSLrc/m7IAau9bU7MO9GgJ0ZgOI5leoqpumKt+1axPJO1dtO5vuM9yi8TlAyBvSMxqES2mo8cFFKb8kzWqzDL7Xq/4LB4TC6bz1yBes1uu9uzt3zOXtHv8xN+Dx/x/wJ6gHt2g3Rxhm9oi4yNjo+QkZKTCgGWAWaXmmOanZhgnp2goaJdpKGmp55cqqusrZuvsJays6mzn1m4uRAAvgAvuBW/v8GwvcTFxqfIycA3zA/OytCl0tPPO7HD2GLYvt7dYd/ZX99j5+Pi6tPh6+bvXuTuzujxXens9fr7YPn+7egRI9PPHrgpCQAAIfkEBQUABAAsPAA8AEIAQgAAA/lIutz+UI1Jq7026h2x/xUncmD5jehjrlnqSmz8vrE8u7V5z/m5/8CgcEgsGo/IpHLJbDqf0Kh0ShBYBdTXdZsdbb/Yrgb8FUfIYLMDTVYz2G13FV6Wz+lX+x0fdvPzdn9WeoJGAYcBN39EiIiKeEONjTt0kZKHQGyWl4mZdREAoQAcnJhBXBqioqSlT6qqG6WmTK+rsa1NtaGsuEu6o7yXubojsrTEIsa+yMm9SL8osp3PzM2cStDRykfZ2tfUtS/bRd3ewtzV5pLo4eLjQuUp70Hx8t9E9eqO5Oku5/ztdkxi90qPg3x2EMpR6IahGocPCxp8AGtigwQAIfkEBQUABAAsHwBOAFcAMAAAA/9Iutz+MMo36pg4682J/V0ojs1nXmSqSqe5vrDXunEdzq2ta3i+/5DeCUh0CGnF5BGULC4tTeUTFQVONYAs4CfoCkZPjFar83rBx8l4XDObSUL1Ott2d1U4yZwcs5/xSBB7dBMBhgEYfncrTBGDW4WHhomKUY+QEZKSE4qLRY8YmoeUfkmXoaKInJ2fgxmpqqulQKCvqRqsP7WooriVO7u8mhu5NacasMTFMMHCm8qzzM2RvdDRK9PUwxzLKdnaz9y/Kt8SyR3dIuXmtyHpHMcd5+jvWK4i8/TXHff47SLjQvQLkU+fG29rUhQ06IkEG4X/Rryp4mwUxSgLL/7IqFETB8eONT6ChCFy5ItqJomES6kgAQAh+QQFBQAEACwKAE4AVwAwAAAD/0i63A4QuEmrvTi3yLX/4MeNUmieITmibEuppCu3sDrfYG3jPKbHveDktxIaF8TOcZmMLI9NyBPanFKJp4A2IBx4B5lkdqvtfb8+HYpMxp3Pl1qLvXW/vWkli16/3dFxTi58ZRcChwIYf3hWBIRchoiHiotWj5AVkpIXi4xLjxiaiJR/T5ehoomcnZ+EGamqq6VGoK+pGqxCtaiiuJVBu7yaHrk4pxqwxMUzwcKbyrPMzZG90NGDrh/JH8t72dq3IN1jfCHb3L/e5ebh4ukmxyDn6O8g08jt7tf26ybz+m/W9GNXzUQ9fm1Q/APoSWAhhfkMAmpEbRhFKwsvCsmosRIHx444PoKcIXKkjIImjTzjkQAAIfkEBQUABAAsAgA8AEIAQgAAA/VIBNz+8KlJq72Yxs1d/uDVjVxogmQqnaylvkArT7A63/V47/m2/8CgcEgsGo/IpHLJbDqf0Kh0Sj0FroGqDMvVmrjgrDcTBo8v5fCZki6vCW33Oq4+0832O/at3+f7fICBdzsChgJGeoWHhkV0P4yMRG1BkYeOeECWl5hXQ5uNIAOjA1KgiKKko1CnqBmqqk+nIbCkTq20taVNs7m1vKAnurtLvb6wTMbHsUq4wrrFwSzDzcrLtknW16tI2tvERt6pv0fi48jh5h/U6Zs77EXSN/BE8jP09ZFA+PmhP/xvJgAMSGBgQINvEK5ReIZhQ3QEMTBLAAAh+QQFBQAEACwCAB8AMABXAAAD50i6DA4syklre87qTbHn4OaNYSmNqKmiqVqyrcvBsazRpH3jmC7yD98OCBF2iEXjBKmsAJsWHDQKmw571l8my+16v+CweEwum8+hgHrNbrvbtrd8znbR73MVfg838f8BeoB7doN0cYZvaIuMjY6PkJGSk2gClgJml5pjmp2YYJ6dX6GeXaShWaeoVqqlU62ir7CXqbOWrLafsrNctjIDwAMWvC7BwRWtNsbGFKc+y8fNsTrQ0dK3QtXAYtrCYd3eYN3c49/a5NVj5eLn5u3s6e7x8NDo9fbL+Mzy9/T5+tvUzdN3Zp+GBAAh+QQJBQAEACwCAAIAfAB8AAAD/0i63P4wykmrvTjrzbv/YCiOZGmeaKqubOu+cCzPdArcQK2TOL7/nl4PSMwIfcUk5YhUOh3M5nNKiOaoWCuWqt1Ou16l9RpOgsvEMdocXbOZ7nQ7DjzTaeq7zq6P5fszfIASAYUBIYKDDoaGIImKC4ySH3OQEJKYHZWWi5iZG0ecEZ6eHEOio6SfqCaqpaytrpOwJLKztCO2jLi1uoW8Ir6/wCHCxMG2x7muysukzb230M6H09bX2Nna29zd3t/g4cAC5OXm5+jn3Ons7eba7vHt2fL16tj2+QL0+vXw/e7WAUwnrqDBgwgTKlzIsKHDh2gGSBwAccHEixAvaqTYcFCjRoYeNyoM6REhyZIHT4o0qPIjy5YTTcKUmHImx5cwE85cmJPnSYckK66sSAAj0aNIkypdyrSp06dQo0qdSrWq1atYs2rdyrWr169gwxZJAAA7); -} -/* common icons */ -.w2ui-icon { - background-repeat: no-repeat; - height: 16px; - width: 16px; - overflow: hidden; - margin: 2px 2px; - display: inline-block; -} -.w2ui-icon.icon-search, -.w2ui-icon.icon-search-down { - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAgCAYAAAB+ZAqzAAACuElEQVRYw9WXSWhTQRjHR0UKLqhFaV0OUih68GAOWjyJKypCpAoV8aIiioIICiKiB1GMtE3MYmry2moXDz1UDx7sUXHBhQpSaRVxrYpWcMO9avx/8AJh/CbznHkxdeB3Cd/8589kvuUJkWcdjCTHghUgAi6DJ+AVeAqugSQIggniXywcNBJsB70g44EHYBcYXUhTM8EFj4ZkboKqQpiqAv2GprK8o7/f75t6pjn0M3gNPmri3vtycxAZA64qDvkJ2kENqAQTQQWoBg74qth3B4y3NbZDIX4fzNfsnQtuK/YfsjFVCh4pMq3Co0Y5uMVoUGkpy8aFT5xaeSzVEo45bXdBt4LeaLq1k0RXMYJfdDfFmAuAD4zWlty4UNyZEkm19MUb2zMw8Sfp1u+IWSrcIimLnTG8/SijdU6OO5poDESdtgHZVBzUHm/amhW7zoitMTS2mNHqASPk2FDCCcLMYK6p+obmulyxfiYLA4bGKFvfSnrUvkq5+Lpk8z4yRH8r3l/X4WiqJFfspSQ0CGYZGpsMnkt6L+h31Z76hpMdeOwPQ7H0NFnssST0C8wxNDaDKb6kP06150gsHahNNlVzYheZd7HJ0BiX4VRGhpmIhRixKyZilM2M1mnTArtIUbU3/qVO0H0GvmQ4CY4C3YopYYlHjXlggNG4R33Ypi2tVtwaPeTdNMkq9pVQZQdvFPs32zbx4aAjzxhDRfIAWAeWg7VgrzsY5ht/zoNJtubKwA3LITGjSKRyW3NTwaUCmKOSMd3WHH0ZJRQZZkOP1zFKZ3CB++4+aQ6kEeksWAb2a2L7qDv49S1Q6T72MOgEXa6RGFhP3wpS/B6NOWpRs0UxFg7eqTFHjX1hscxtAz/ymEuIYi0cvgF8Y0w5Ro3dZ3M1boJkTaXEUFlug6fsdsRQWzTj0cey+N/Xb2sj5lTh2M6OAAAAAElFTkSuQmCC) no-repeat center !important; - background-size: 14px 12px !important; - opacity: 0.9; -} -.w2ui-icon.icon-folder { - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGrSURBVDjLxZO7ihRBFIa/6u0ZW7GHBUV0UQQTZzd3QdhMQxOfwMRXEANBMNQX0MzAzFAwEzHwARbNFDdwEd31Mj3X7a6uOr9BtzNjYjKBJ6nicP7v3KqcJFaxhBVtZUAK8OHlld2st7Xl3DJPVONP+zEUV4HqL5UDYHr5xvuQAjgl/Qs7TzvOOVAjxjlC+ePSwe6DfbVegLVuT4r14eTr6zvA8xSAoBLzx6pvj4l+DZIezuVkG9fY2H7YRQIMZIBwycmzH1/s3F8AapfIPNF3kQk7+kw9PWBy+IZOdg5Ug3mkAATy/t0usovzGeCUWTjCz0B+Sj0ekfdvkZ3abBv+U4GaCtJ1iEm6ANQJ6fEzrG/engcKw/wXQvEKxSEKQxRGKE7Izt+DSiwBJMUSm71rguMYhQKrBygOIRStf4TiFFRBvbRGKiQLWP29yRSHKBTtfdBmHs0BUpgvtgF4yRFR+NUKi0XZcYjCeCG2smkzLAHkbRBmP0/Uk26O5YnUActBp1GsAI+S5nRJJJal5K1aAMrq0d6Tm9uI6zjyf75dAe6tx/SsWeD//o2/Ab6IH3/h25pOAAAAAElFTkSuQmCC) no-repeat center !important; -} -.w2ui-icon.icon-page { - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAINSURBVBgZBcG/r55zGAfg6/4+z3va01NHlYgzEfE7MdCIGISFgS4Gk8ViYyM2Mdlsko4GSf8Do0FLRCIkghhYJA3aVBtEz3nP89wf11VJvPDepdd390+8Nso5nESBQoq0pfvXm9fzWf19453LF85vASqJlz748vInb517dIw6EyYBIIG49u+xi9/c9MdvR//99MPPZ7+4cP4IZhhTPbwzT2d+vGoaVRRp1rRliVvHq+cfvM3TD82+7mun0o/ceO7NT+/4/KOXjwZU1ekk0840bAZzMQ2mooqh0A72d5x/6sB9D5zYnff3PoYBoWBgFKPKqDKqjCpjKr//dcu9p489dra88cydps30KswACfNEKanSaxhlntjJ8Mv12Paie+vZ+0+oeSwwQ0Iw1xAR1CiFNJkGO4wu3ZMY1AAzBI0qSgmCNJsJUEOtJSMaCTBDLyQ0CknAGOgyTyFFiLI2awMzdEcSQgSAAKVUmAeNkxvWJWCGtVlDmgYQ0GFtgg4pNtOwbBcwQy/Rife/2yrRRVI0qYCEBly8Z+P4qMEMy7JaVw72N568e+iwhrXoECQkfH91kY7jwwXMsBx1L93ZruqrK6uuiAIdSnTIKKPLPFcvay8ww/Hh+ufeznTXu49v95IMoQG3784gYXdTqvRmqn/Wpa/ADFX58MW3L71SVU9ETgEIQQQIOOzub+fhIvwPRDgeVjWDahIAAAAASUVORK5CYII=) no-repeat center !important; -} -/************************************************* -* ---- Locking portion of the screen (in grid, form, layout) -*/ -.w2ui-lock { - display: none; - position: absolute; - z-index: 1400; - top: 0px; - left: 0px; - width: 100%; - height: 100%; - opacity: 0.15; - filter: alpha(opacity=15); - background-color: #333; -} -.w2ui-lock-msg { - display: none; - position: absolute; - z-index: 1400; - top: 45%; - left: 50%; - -webkit-transform: translateX(-50%) translateY(-50%); - -moz-transform: translateX(-50%) translateY(-50%); - -ms-transform: translateX(-50%) translateY(-50%); - -o-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); - width: 200px; - height: 80px; - padding: 30px 8px; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - font-size: 13px; - font-family: Verdana, Arial, sans-serif; - opacity: 0.8; - filter: alpha(opacity=80); - background-color: #555; - color: white; - text-align: center; - border-radius: 5px; - border: 2px solid #444; -} -.w2ui-lock-msg .w2ui-spinner { - display: inline-block; - width: 24px; - height: 24px; - margin: -3px 8px -7px -10px; -} -/************************************************* -* ---- Scroll contet, used in toolbar and tabs ---- -*/ -.w2ui-scroll-wrapper { - overflow: hidden; -} -.w2ui-scroll-left, -.w2ui-scroll-right { - top: 0; - width: 18px; - height: 100%; - cursor: default !important; - z-index: 10; - display: none; - position: absolute; -} -.w2ui-scroll-left:hover, -.w2ui-scroll-right:hover { - background-color: #ddd; -} -.w2ui-scroll-left { - left: 0; - box-shadow: 0px 0px 7px #5F5F5F; - background: #F7F7F7 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAzklEQVR4Ae2THRDEMBCFzy1ucatb3eJ2uhi3uNUtbnGrW9zi1rOdNzdvdl7nDpvYt/9/r7+/51myZZf/zXkD2iMHHRSb0x3oskwMieK05PwEXqP4ExSL0wp0ROao2OOuMPOMdUL6XU1/oGLcFWb+NqyTd2W/P/2qTr9h+nFXhOkHXRHiNyjrgp/U/V+WaQcaNY13zZI0A1JvcVqAnrGDTdtDtZUHjHIJhxxVLN0iqXgCP1l/7h8U9kc6abyJ4/eNWPpGdBv+XdUK0K8cnvcBly2rDr7C1HQAAAAASUVORK5CYII=') center center no-repeat; - background-size: 15px 12px; -} -.w2ui-scroll-right { - right: 0; - box-shadow: 0px 0px 7px #5F5F5F; - background: #F7F7F7 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVR4Ae2UG7TGMBCEr1vd4la3uMUtuli3utWtbnGLW9zi9l/bDMzJG7u12cfJfLunf1+UEC9Bv0vVQwJ8hjRCaZafflb1C9RQf4OD0gSDE+i+PiJAabFhQc1y1AYYsJGLY3lgxM17uWPO56yPiFDqVPWgRtpIHSd1zPnwkBsdI58OlNwx4fP2X0TgfMTOoHSdKOXkpyNvEyQh7ul+4swxJSTQuwNDxz68l/ukVNbu0Neen5Z+KvzWxBAqHds349uPFJ/jVOrPjxUq++OLf+20q5+noXo0AAAAAElFTkSuQmCC') center center no-repeat; - background-size: 15px 13px; -} -button.w2ui-btn { - position: relative; - display: inline-block; - border-radius: 4px; - margin: 0px 5px; - padding: 6px 12px; - color: #666; - font-size: 12px; - border: 1px solid #B6B6B6; - background-image: -webkit-linear-gradient(#FFF 0%, #E7E7E7 100%); - background-image: -moz-linear-gradient(#FFF 0%, #E7E7E7 100%); - background-image: -ms-linear-gradient(#FFF 0%, #E7E7E7 100%); - background-image: -o-linear-gradient(#FFF 0%, #E7E7E7 100%); - background-image: linear-gradient(#FFF 0%, #E7E7E7 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffe7e7e7', endColorstr='#ffffffff', GradientType=0); - outline: none; - box-shadow: 0px 1px 0px white; - cursor: default; - min-width: 75px; - line-height: 110%; - user-select: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} -button.w2ui-btn:hover { - text-decoration: none; - border: 1px solid #bbb; - background-image: -webkit-linear-gradient(#F7F7F7 0%, #DDDDDD 100%); - background-image: -moz-linear-gradient(#F7F7F7 0%, #DDDDDD 100%); - background-image: -ms-linear-gradient(#F7F7F7 0%, #DDDDDD 100%); - background-image: -o-linear-gradient(#F7F7F7 0%, #DDDDDD 100%); - background-image: linear-gradient(#F7F7F7 0%, #DDDDDD 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffdddddd', endColorstr='#fff7f7f7', GradientType=0); - color: #333; -} -button.w2ui-btn:active, -button.w2ui-btn.clicked { - border: 1px solid #999; - background-image: -webkit-linear-gradient(#ccc 0%, #ccc 100%); - background-image: -moz-linear-gradient(#ccc 0%, #ccc 100%); - background-image: -ms-linear-gradient(#ccc 0%, #ccc 100%); - background-image: -o-linear-gradient(#ccc 0%, #ccc 100%); - background-image: linear-gradient(#ccc 0%, #ccc 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffcccccc', endColorstr='#ffcccccc', GradientType=0); - text-shadow: 1px 1px 1px #eee; -} -button.w2ui-btn:disabled { - border: 1px solid #bbb !important; - background: #f7f7f7 !important; - color: #bdbcbc !important; - text-shadow: none !important; -} -button.w2ui-btn:focus:before { - content: ""; - border: 1px dashed #aaa; - border-radius: 3px; - position: absolute; - top: 2px; - bottom: 2px; - left: 2px; - right: 2px; - pointer-events: none; -} -button.w2ui-btn::-moz-focus-inner { - border: 0; -} -button.w2ui-btn-blue { - color: white; - background-image: -webkit-linear-gradient(#80C0F7 0%, #269DF0 100%); - background-image: -moz-linear-gradient(#80C0F7 0%, #269DF0 100%); - background-image: -ms-linear-gradient(#80C0F7 0%, #269DF0 100%); - background-image: -o-linear-gradient(#80C0F7 0%, #269DF0 100%); - background-image: linear-gradient(#80C0F7 0%, #269DF0 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff269df0', endColorstr='#ff80c0f7', GradientType=0); - border: 1px solid #538AB7; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-blue:hover { - color: white; - background-image: -webkit-linear-gradient(#73B6F0 0%, #2391DD 100%); - background-image: -moz-linear-gradient(#73B6F0 0%, #2391DD 100%); - background-image: -ms-linear-gradient(#73B6F0 0%, #2391DD 100%); - background-image: -o-linear-gradient(#73B6F0 0%, #2391DD 100%); - background-image: linear-gradient(#73B6F0 0%, #2391DD 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff2391dd', endColorstr='#ff73b6f0', GradientType=0); - border: 1px solid #497BA3; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-blue:active, -button.w2ui-btn-blue.clicked { - color: white; - background-image: -webkit-linear-gradient(#1E83C9 0%, #1E83C9 100%); - background-image: -moz-linear-gradient(#1E83C9 0%, #1E83C9 100%); - background-image: -ms-linear-gradient(#1E83C9 0%, #1E83C9 100%); - background-image: -o-linear-gradient(#1E83C9 0%, #1E83C9 100%); - background-image: linear-gradient(#1E83C9 0%, #1E83C9 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff1e83c9', endColorstr='#ff1e83c9', GradientType=0); - border: 1px solid #1268A6; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-blue:focus:before { - border: 1px dashed #e8e8e8; -} -button.w2ui-btn-green { - color: white; - background-image: -webkit-linear-gradient(#81CF81 0%, #52A452 100%); - background-image: -moz-linear-gradient(#81CF81 0%, #52A452 100%); - background-image: -ms-linear-gradient(#81CF81 0%, #52A452 100%); - background-image: -o-linear-gradient(#81CF81 0%, #52A452 100%); - background-image: linear-gradient(#81CF81 0%, #52A452 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff52a452', endColorstr='#ff81cf81', GradientType=0); - border: 1px solid #479247; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-green:hover { - color: white; - background-image: -webkit-linear-gradient(#6ABE68 0%, #3F8F3D 100%); - background-image: -moz-linear-gradient(#6ABE68 0%, #3F8F3D 100%); - background-image: -ms-linear-gradient(#6ABE68 0%, #3F8F3D 100%); - background-image: -o-linear-gradient(#6ABE68 0%, #3F8F3D 100%); - background-image: linear-gradient(#6ABE68 0%, #3F8F3D 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff3f8f3d', endColorstr='#ff6abe68', GradientType=0); - border: 1px solid #479247; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-green:active, -button.w2ui-btn-green.clicked { - color: white; - background-image: -webkit-linear-gradient(#377D36 0%, #377D36 100%); - background-image: -moz-linear-gradient(#377D36 0%, #377D36 100%); - background-image: -ms-linear-gradient(#377D36 0%, #377D36 100%); - background-image: -o-linear-gradient(#377D36 0%, #377D36 100%); - background-image: linear-gradient(#377D36 0%, #377D36 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff377d36', endColorstr='#ff377d36', GradientType=0); - border: 1px solid #555 !important; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-green:focus:before { - border: 1px dashed #e8e8e8; -} -button.w2ui-btn-orange { - color: white; - background-image: -webkit-linear-gradient(#FCC272 0%, #FB8822 100%); - background-image: -moz-linear-gradient(#FCC272 0%, #FB8822 100%); - background-image: -ms-linear-gradient(#FCC272 0%, #FB8822 100%); - background-image: -o-linear-gradient(#FCC272 0%, #FB8822 100%); - background-image: linear-gradient(#FCC272 0%, #FB8822 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffb8822', endColorstr='#fffcc272', GradientType=0); - border: 1px solid #B68B4C; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-orange:hover { - color: white; - background-image: -webkit-linear-gradient(#F4AD59 0%, #F1731F 100%); - background-image: -moz-linear-gradient(#F4AD59 0%, #F1731F 100%); - background-image: -ms-linear-gradient(#F4AD59 0%, #F1731F 100%); - background-image: -o-linear-gradient(#F4AD59 0%, #F1731F 100%); - background-image: linear-gradient(#F4AD59 0%, #F1731F 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff1731f', endColorstr='#fff4ad59', GradientType=0); - border: 1px solid #B68B4C; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-orange:active, -button.w2ui-btn-orange.clicked { - color: white; - border: 1px solid #666; - background-image: -webkit-linear-gradient(#B98747 0%, #B98747 100%); - background-image: -moz-linear-gradient(#B98747 0%, #B98747 100%); - background-image: -ms-linear-gradient(#B98747 0%, #B98747 100%); - background-image: -o-linear-gradient(#B98747 0%, #B98747 100%); - background-image: linear-gradient(#B98747 0%, #B98747 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffb98747', endColorstr='#ffb98747', GradientType=0); - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-orange:focus:before { - border: 1px dashed #f9f9f9; -} -button.w2ui-btn-red { - color: white; - background-image: -webkit-linear-gradient(#FF6E70 0%, #C72D2D 100%); - background-image: -moz-linear-gradient(#FF6E70 0%, #C72D2D 100%); - background-image: -ms-linear-gradient(#FF6E70 0%, #C72D2D 100%); - background-image: -o-linear-gradient(#FF6E70 0%, #C72D2D 100%); - background-image: linear-gradient(#FF6E70 0%, #C72D2D 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffc72d2d', endColorstr='#ffff6e70', GradientType=0); - border: 1px solid #BB3C3E; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-red:hover { - color: white; - background-image: -webkit-linear-gradient(#EE696C 0%, #AE2527 100%); - background-image: -moz-linear-gradient(#EE696C 0%, #AE2527 100%); - background-image: -ms-linear-gradient(#EE696C 0%, #AE2527 100%); - background-image: -o-linear-gradient(#EE696C 0%, #AE2527 100%); - background-image: linear-gradient(#EE696C 0%, #AE2527 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffae2527', endColorstr='#ffee696c', GradientType=0); - border: 1px solid #BB3C3E; - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-red:active, -button.w2ui-btn-red.clicked { - color: white; - border: 1px solid #861C1E; - background-image: -webkit-linear-gradient(#9C2123 0%, #9C2123 100%); - background-image: -moz-linear-gradient(#9C2123 0%, #9C2123 100%); - background-image: -ms-linear-gradient(#9C2123 0%, #9C2123 100%); - background-image: -o-linear-gradient(#9C2123 0%, #9C2123 100%); - background-image: linear-gradient(#9C2123 0%, #9C2123 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff9c2123', endColorstr='#ff9c2123', GradientType=0); - text-shadow: 0px 0px 1px #111; -} -button.w2ui-btn-red:focus:before { - border: 1px dashed #ddd; -} -button.w2ui-btn-small { - padding: 5px !important; - margin: 0px; - min-width: 0px; -} -button.w2ui-btn-small:focus:before { - border-radius: 2px; - top: 2px; - bottom: 2px; - left: 2px; - right: 2px; -} -/************************************************* -* ---- Forms ---- -*/ -.w2ui-form { - position: relative; - color: black; - background-color: #F2F2F2; - border: 1px solid #c0c0c0; - border-radius: 3px; - padding: 0px; - overflow: hidden !important; -} -.w2ui-form > div { - position: absolute; - overflow: hidden; -} -.w2ui-form .w2ui-form-header { - position: absolute; - left: 0; - right: 0; - border-bottom: 1px solid #99bbe8 !important; - overflow: hidden; - color: #444; - font-size: 13px; - text-align: center; - padding: 8px; - background-image: -webkit-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -moz-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -ms-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -o-linear-gradient(#DAE6F3, #C2D5ED); - background-image: linear-gradient(#DAE6F3, #C2D5ED); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffdae6f3', endColorstr='#ffc2d5ed', GradientType=0); - border-top-left-radius: 3px; - border-top-right-radius: 3px; -} -.w2ui-form .w2ui-form-toolbar { - position: absolute; - left: 0px; - right: 0px; - margin: 0px; - padding: 5px 3px; - border-bottom: 1px solid #d5d8d8; -} -.w2ui-form .w2ui-form-tabs { - margin: 0px; - padding: 0px; -} -.w2ui-form .w2ui-tabs { - position: absolute; - left: 0; - right: 0; - height: 33px; - border-top-left-radius: 3px; - border-top-right-radius: 3px; - padding-top: 5px !important; - background-color: #fafafa; -} -.w2ui-form .w2ui-tabs .w2ui-tab.active { - background-color: #F2F2F2; -} -.w2ui-form .w2ui-page { - position: absolute; - left: 0; - right: 0; - overflow: auto; - padding: 10px 5px 0 5px; - border-left: 1px solid inherit; - border-right: 1px solid inherit; - background-color: inherit; - border-radius: 3px; -} -.w2ui-form .w2ui-column-container { - display: flex; - padding: 0; -} -.w2ui-form .w2ui-column-container .w2ui-column { - width: 100%; -} -.w2ui-form .w2ui-column-container .w2ui-column.col-0, -.w2ui-form .w2ui-column-container .w2ui-column.col-1, -.w2ui-form .w2ui-column-container .w2ui-column.col-2, -.w2ui-form .w2ui-column-container .w2ui-column.col-3, -.w2ui-form .w2ui-column-container .w2ui-column.col-4, -.w2ui-form .w2ui-column-container .w2ui-column.col-5, -.w2ui-form .w2ui-column-container .w2ui-column.col-6, -.w2ui-form .w2ui-column-container .w2ui-column.col-7, -.w2ui-form .w2ui-column-container .w2ui-column.col-8, -.w2ui-form .w2ui-column-container .w2ui-column.col-9, -.w2ui-form .w2ui-column-container .w2ui-column.col-10 { - padding: 0 5px; -} -.w2ui-form .w2ui-buttons { - position: absolute; - left: 0; - right: 0; - bottom: 0; - text-align: center; - border-top: 1px solid #d5d8d8; - border-bottom: 0px solid #d5d8d8; - background-color: #fafafa; - padding: 15px 0px !important; - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; -} -.w2ui-form .w2ui-buttons input[type="button"], -.w2ui-form .w2ui-buttons button { - min-width: 80px; - margin-right: 5px; -} -.w2ui-form input[type=checkbox], -.w2ui-form input[type=radio] { - margin-top: 4px; - margin-bottom: 4px; - width: 14px; - height: 14px; -} -.w2ui-form input[type=checkbox].w2ui-toggle { - margin: 0px; - width: 50px; -} -.w2ui-group-title { - padding: 5px 2px; - color: #8D96A2; - text-shadow: 1px 1px 2px #fdfdfd; - font-size: 120%; -} -.w2ui-group-fields { - background-color: #F9F9F9; - margin: 5px 0px 10px 0px; - padding: 10px 5px; - border-top: 1px solid #DCDCDC; - border-bottom: 1px solid #DCDCDC; -} -.w2ui-field > label { - display: block; - float: left; - margin-top: 7px; - margin-bottom: 3px; - width: 120px; - padding: 0px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - text-align: right; - min-height: 20px; - color: #666; -} -.w2ui-field > div { - /* do not include width */ - margin-bottom: 3px; - margin-left: 128px; - padding: 3px; - min-height: 28px; - float: none; -} -.w2ui-field.w2ui-required > div { - position: relative; -} -.w2ui-field.w2ui-required:not(.w2ui-field-inline) > div::before { - content: '*'; - position: absolute; - margin-top: 5px; - margin-left: -9px; - color: red; -} -.w2ui-field.w2ui-required.w2ui-field-inline > div::before { - content: '' !important; -} -.w2ui-field.w2ui-disabled { - opacity: 0.3; - background-color: transparent !important; -} -.w2ui-field.w2ui-span-none > label { - margin: 0; - padding: 5px 12px 0 4px; - display: block; - width: 98%; - text-align: left; -} -.w2ui-field.w2ui-span-none > div { - margin-left: 0; -} -.w2ui-field.w2ui-span0 > label { - display: none; -} -.w2ui-field.w2ui-span0 > div { - margin-left: 0; -} -.w2ui-field.w2ui-span1 > label { - width: 20px; -} -.w2ui-field.w2ui-span1 > div { - margin-left: 28px; -} -.w2ui-field.w2ui-span2 > label { - width: 40px; -} -.w2ui-field.w2ui-span2 > div { - margin-left: 48px; -} -.w2ui-field.w2ui-span3 > label { - width: 60px; -} -.w2ui-field.w2ui-span3 > div { - margin-left: 68px; -} -.w2ui-field.w2ui-span4 > label { - width: 80px; -} -.w2ui-field.w2ui-span4 > div { - margin-left: 88px; -} -.w2ui-field.w2ui-span5 > label { - width: 100px; -} -.w2ui-field.w2ui-span5 > div { - margin-left: 108px; -} -.w2ui-field.w2ui-span6 > label { - width: 120px; -} -.w2ui-field.w2ui-span6 > div { - margin-left: 128px; -} -.w2ui-field.w2ui-span7 > label { - width: 140px; -} -.w2ui-field.w2ui-span7 > div { - margin-left: 148px; -} -.w2ui-field.w2ui-span8 > label { - width: 160px; -} -.w2ui-field.w2ui-span8 > div { - margin-left: 168px; -} -.w2ui-field.w2ui-span9 > label { - width: 180px; -} -.w2ui-field.w2ui-span9 > div { - margin-left: 188px; -} -.w2ui-field.w2ui-span10 > label { - width: 200px; -} -.w2ui-field.w2ui-span10 > div { - margin-left: 208px; -} -.w2ui-field.w2ui-field-inline { - display: inline; -} -.w2ui-field.w2ui-field-inline > div { - display: inline; - margin: 0; - padding: 0; -} -.w2ui-field .w2ui-box-label { - user-select: none; - vertical-align: middle; -} -.w2ui-field .w2ui-box-label span, -.w2ui-field .w2ui-box-label input { - display: inline-block; - vertical-align: middle; -} -.w2ui-field .w2ui-box-label span { - padding-left: 3px; -} -.w2ui-field .w2ui-box-label input { - margin: 4px 0px 3px 0; -} -.w2ui-error { - border: 1px solid #FFA8A8 !important; - background-color: #FFF4EB !important; -} -.w2field { - padding: 3px; - border-radius: 3px; - border: 1px solid silver; -} -.w2ui-field-helper { - position: absolute; - display: inline-block; - line-height: 100%; - /* pointer-events: none; - do not use as IE does not support it */ - user-select: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; -} -.w2ui-field-helper .w2ui-field-up { - position: absolute; - top: 0px; - padding: 2px 3px; -} -.w2ui-field-helper .w2ui-field-down { - position: absolute; - bottom: 0px; - padding: 2px 3px; -} -.w2ui-field-helper .arrow-up:hover { - border-bottom-color: #81C6FF; -} -.w2ui-field-helper .arrow-down:hover { - border-top-color: #81C6FF; -} -/* -* ARROWS -*/ -.arrow-up { - background: none; - width: 0; - height: 0; - border-left: 4px solid transparent; - /* left arrow slant */ - border-right: 4px solid transparent; - /* right arrow slant */ - border-bottom: 5px solid #777; - /* bottom, add background color here */ - font-size: 0; - line-height: 0; -} -.arrow-down { - background: none; - width: 0; - height: 0; - border-left: 4px solid transparent; - border-right: 4px solid transparent; - border-top: 5px solid #777; - font-size: 0; - line-height: 0; -} -.arrow-left { - background: none; - width: 0; - height: 0; - border-bottom: 4px solid transparent; - /* left arrow slant */ - border-top: 4px solid transparent; - /* right arrow slant */ - border-right: 5px solid #777; - /* bottom, add background color here */ - font-size: 0; - line-height: 0; -} -.arrow-right { - background: none; - width: 0; - height: 0; - border-bottom: 4px solid transparent; - /* left arrow slant */ - border-top: 4px solid transparent; - /* right arrow slant */ - border-left: 5px solid #777; - /* bottom, add background color here */ - font-size: 0; - line-height: 0; -} -/* -* COLOR overlay -*/ -.w2ui-colors { - padding: 8px 5px 0px 5px; - background-color: white; - border-radius: 3px; -} -.w2ui-colors input:focus { - outline: none; - border: 1px solid #999 !important; -} -.w2ui-colors .w2ui-color-palette { - width: 242px; -} -.w2ui-colors .w2ui-color-palette table { - table-layout: fixed; - width: 160px; -} -.w2ui-colors .w2ui-color-palette table td { - width: 20px; - height: 20px; - text-align: center; -} -.w2ui-colors .w2ui-color-palette table td div { - cursor: pointer; - display: inline-block; - width: 16px; - height: 17px; - padding: 1px 4px; - border: 1px solid transparent; - color: white; - text-shadow: 0px 0px 2px #000; -} -.w2ui-colors .w2ui-color-palette table td div:hover { - outline: 1px solid #666; - border: 1px solid #fff; -} -.w2ui-colors .w2ui-color-palette table td div.w2ui-no-color { - border: 1px solid #efefef; -} -.w2ui-colors .w2ui-color-advanced { - height: 176px; - padding: 1px 2px; -} -.w2ui-colors .w2ui-color-advanced .palette { - position: relative; - width: 150px; - height: 125px; - outline: 1px solid #d2d2d2; - box-sizing: content-box; -} -.w2ui-colors .w2ui-color-advanced .palette .palette-bg { - height: 100%; - background-image: linear-gradient(0deg, #000000, rgba(204, 154, 129, 0)); - pointer-events: none; -} -.w2ui-colors .w2ui-color-advanced .rainbow { - position: relative; - width: 150px; - height: 12px; - margin: 10px 0px 0px 0px; - background: linear-gradient(90deg, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%); -} -.w2ui-colors .w2ui-color-advanced .alpha { - position: relative; - width: 150px; - height: 12px; - margin: 10px 0px 0px 0px; - background-color: #fff; - background-image: linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb), linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb); - background-size: 12px 12px; - background-position: 0 0, 6px 6px; -} -.w2ui-colors .w2ui-color-advanced .alpha .alpha-bg { - height: 100%; - background-image: linear-gradient(90deg, rgba(80, 80, 80, 0) 0%, #505050 100%); - pointer-events: none; -} -.w2ui-colors .w2ui-color-advanced .value1 { - pointer-events: none; - position: absolute; - top: 0px; - display: inline-block; - width: 8px; - height: 8px; - border-radius: 10px; - border: 1px solid #999; - background-color: transparent; - box-shadow: 0px 0px 1px white; - transform: translateX(-1px) translateY(-1px); -} -.w2ui-colors .w2ui-color-advanced .value2 { - pointer-events: none; - position: absolute; - top: -2px; - display: inline-block; - width: 8px; - height: 16px; - border-radius: 2px; - border: 1px solid #696969; - background-color: #ffffff; - box-shadow: 0px 0px 1px white; - transform: translateX(-1px); -} -.w2ui-colors .w2ui-color-advanced .color-info { - float: right; - width: 80px; - margin-left: 158px; - margin-top: 0px; -} -.w2ui-colors .w2ui-color-advanced .color-info .color-preview-bg { - box-shadow: 0 0 1px #c3c3c3; - height: 40px; - background-color: #fff; - background-image: linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb), linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb); - background-size: 16px 16px; - background-position: 0 0, 8px 8px; - margin-bottom: 10px; -} -.w2ui-colors .w2ui-color-advanced .color-info .color-preview, -.w2ui-colors .w2ui-color-advanced .color-info .color-original { - height: 40px; - width: 40px; - float: left; -} -.w2ui-colors .w2ui-color-advanced .color-info .color-part { - padding-top: 5px; -} -.w2ui-colors .w2ui-color-advanced .color-info .color-part span { - display: inline-block; - width: 7px; - margin-left: 1px; - color: #666; -} -.w2ui-colors .w2ui-color-advanced .color-info .color-part input { - font-size: 10px!important; - border-radius: 2px; - border: 1px solid #ccc; - width: 26px !important; - padding: 2px !important; - color: #333; -} -.w2ui-colors .w2ui-color-tabs { - background-color: #f7f7f7; - height: 30px; - margin: 10px -5px 0px -5px; - border-top: 1px solid #d6d6d6; -} -.w2ui-colors .w2ui-color-tabs .w2ui-color-tab { - float: left; - display: inline-block; - width: 34px; - height: 25px; - border: 1px solid transparent; - border-radius: 1px; - margin: -1px -3px 0px 8px; - text-align: center; - font-size: 15px; - padding-top: 1px; - color: #7b7b7b; -} -.w2ui-colors .w2ui-color-tabs .w2ui-color-tab.selected { - color: #555; - background-color: white; - border: 1px solid #e0e0e0; - border-top: 1px solid transparent; - border-bottom-left-radius: 5px; - border-bottom-right-radius: 5px; -} -/* -* DATE overlay -*/ -.w2ui-calendar { - margin: 0px; - padding: 1px; - line-height: 108%; -} -.w2ui-calendar .w2ui-calendar-title { - margin: 0px -1px; - padding: 7px 2px; - background-image: -webkit-linear-gradient(#f6f6f6, #d9d9d9); - background-image: -moz-linear-gradient(#f6f6f6, #d9d9d9); - background-image: -ms-linear-gradient(#f6f6f6, #d9d9d9); - background-image: -o-linear-gradient(#f6f6f6, #d9d9d9); - background-image: linear-gradient(#f6f6f6, #d9d9d9); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff6f6f6', endColorstr='#ffd9d9d9', GradientType=0); - border-bottom: 1px solid #bbb; - color: #555; - text-align: center; - text-shadow: 1px 1px 1px #eee; - cursor: pointer; -} -.w2ui-calendar .w2ui-calendar-jump { - position: absolute; - top: 27px; - left: 0px; - right: 0px; - bottom: 0px; - background-color: #FaFaFa; -} -.w2ui-calendar .w2ui-calendar-jump > :first-child { - position: absolute; - top: 0px; - left: 0px; - bottom: 0px; - width: 110px; - overflow: hidden; - padding-top: 5px; - border-right: 1px solid silver; -} -.w2ui-calendar .w2ui-calendar-jump > :last-child { - position: absolute; - top: 0px; - right: 0px; - bottom: 0px; - width: 88px; - overflow-x: hidden; - overflow-y: auto; - padding-top: 5px; - text-align: center; -} -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-month, -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-year { - display: inline-block; - padding: 5px 0px; - text-align: center; - float: left; - margin: 2px; - width: 50px; - cursor: default; - border: 1px solid transparent; - border-radius: 2px; -} -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-year { - float: none; - width: 95%; -} -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-month:hover, -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-year:hover { - border: 1px solid #ccc; - color: black; - background-color: #efefef; -} -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-month.selected, -.w2ui-calendar .w2ui-calendar-jump .w2ui-jump-year.selected { - border: 1px solid #ccc; - color: black; - background-color: #dadada; -} -.w2ui-calendar .w2ui-calendar-previous, -.w2ui-calendar .w2ui-calendar-next { - width: 24px; - height: 20px; - color: #666; - border: 1px solid transparent; - border-radius: 3px; - padding: 2px 3px 1px 2px; - margin: -4px 0px 0px 0px; - cursor: default; -} -.w2ui-calendar .w2ui-calendar-previous:hover, -.w2ui-calendar .w2ui-calendar-next:hover { - border: 1px solid silver; - background-color: #efefef; -} -.w2ui-calendar .w2ui-calendar-previous > div, -.w2ui-calendar .w2ui-calendar-next > div { - position: absolute; - border-left: 4px solid #888; - border-top: 4px solid #888; - border-right: 4px solid transparent; - border-bottom: 4px solid transparent; - width: 0px; - height: 0px; - padding: 0px; - margin: 3px 0px 0px 0px; -} -.w2ui-calendar .w2ui-calendar-previous { - float: left; -} -.w2ui-calendar .w2ui-calendar-previous > div { - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); - margin-left: 6px; -} -.w2ui-calendar .w2ui-calendar-next { - float: right; -} -.w2ui-calendar .w2ui-calendar-next > div { - -webkit-transform: rotate(135deg); - -moz-transform: rotate(135deg); - -ms-transform: rotate(135deg); - -o-transform: rotate(135deg); - transform: rotate(135deg); - margin-left: 2px; - margin-right: 2px; -} -.w2ui-calendar .w2ui-calendar-now { - cursor: pointer; - margin-bottom: 10px; - text-align: center; -} -.w2ui-calendar .w2ui-calendar-now:hover { - color: #0A96DE; -} -.w2ui-calendar table.w2ui-calendar-days { - padding: 0px; -} -.w2ui-calendar table.w2ui-calendar-days td { - border: 1px solid #fff; - color: black; - background-color: #f9f9f9; - padding: 6px; - cursor: default; - text-align: right; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-saturday, -.w2ui-calendar table.w2ui-calendar-days td.w2ui-sunday { - border: 1px solid #fff; - color: #c8493b; - background-color: #f9f9f9; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-saturday:hover, -.w2ui-calendar table.w2ui-calendar-days td.w2ui-sunday:hover { - border: 1px solid #ccc; - color: black; - background-color: #e9e9e9; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-saturday.w2ui-blocked, -.w2ui-calendar table.w2ui-calendar-days td.w2ui-sunday.w2ui-blocked { - text-decoration: line-through; - border: 1px solid #fff; - color: #ccc; - background-color: #fff; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-today { - color: black; - background-color: #e2f7cd; -} -.w2ui-calendar table.w2ui-calendar-days td:hover { - border: 1px solid #ccc; - color: black; - background-color: #e9e9e9; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-date-selected { - border: 1px solid #8cb067; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-blocked { - text-decoration: line-through; - border: 1px solid #fff; - color: #ccc; - background-color: #fff; -} -.w2ui-calendar table.w2ui-calendar-days td.w2ui-day-empty { - border: 1px solid #fff; - background-color: #fdfdfd; -} -.w2ui-calendar table.w2ui-calendar-days tr.w2ui-day-title td { - border: 1px solid #fff; - color: gray; - background-color: #fff; - text-align: center; - padding: 6px; -} -/* -* Time -*/ -.w2ui-calendar-time { - padding: 5px; - cursor: default; -} -.w2ui-calendar-time td div { - padding: 7px 10px; - text-align: center; - border: 1px solid transparent; - white-space: nowrap; -} -.w2ui-calendar-time td:nth-child(even) { - background-color: #f6f6f6; -} -.w2ui-calendar-time td div:hover { - border: 1px solid #ccc; - color: black; - background-color: #e9e9e9; -} -.w2ui-calendar-time td div.w2ui-blocked { - text-decoration: line-through; - border: 1px solid #fff; - color: #ccc; - background-color: #fff; -} -.w2ui-select { - cursor: default; - color: black !important; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), -webkit-linear-gradient(top, #fff 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), -moz-linear-gradient(top, #fff 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), -ms-linear-gradient(top, #fff 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), -o-linear-gradient(top, #fff 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAALCAQAAACnzwd+AAAAcklEQVR4AcXMsQFBQQDG4P9tAgC0gJYRQJZgKQMwCqCku6vVAAAA+NJHP4KHOk0aV2pRw61n4BBmyOxKQ8I4ehZeuhd3HTx6DQEGZ7sBfr2OOOOj3Yi43kMKs9sZknofOexqZ8npMygwWZTX51CipP+YA1OiZJbYYg9lAAAAAElFTkSuQmCC'), linear-gradient(to bottom, #fff 20%, #f6f6f6 50%, #EEE 52%, #f4f4f4 100%); - background-size: 17px 6px, 100% 100%; - background-position: right center, left top; - background-repeat: no-repeat, no-repeat; -} -.w2ui-select[readonly], -.w2ui-select[disabled] { - background-image: none; - background-color: #f1f1f1 !important; - color: #777 !important; - outline: none!important; -} -/* -* ENUM items -*/ -.w2ui-list { - color: inherit; - position: absolute; - padding: 0px; - margin: 0px; - min-height: 25px; - overflow: auto; - border: 1px solid silver; - border-radius: 3px; - font-size: 6px; - line-height: 100%; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; - background-color: white; -} -.w2ui-list input[type=text] { - -webkit-box-shadow: none; - -moz-box-shadow: none; - -ms-box-shadow: none; - -o-box-shadow: none; - box-shadow: none; -} -.w2ui-list ul { - list-style-type: none; - background-color: black; - margin: 0px; - padding: 0px; -} -.w2ui-list ul li { - float: left; - margin: 2px 1px 0px 2px; - border-radius: 3px; - width: auto; - padding: 3px 10px 1px 7px; - border: 1px solid #88B0D6; - background-color: #EFF3F5; - white-space: nowrap; - cursor: default; - font-family: verdana; - font-size: 11px; - line-height: 100%; - height: 20px; - overflow: hidden; - text-overflow: ellipsis; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-list ul li:hover { - background-color: #d0dbe1; -} -.w2ui-list ul li:last-child { - border-radius: 0px; - border: 1px solid transparent; - background-color: transparent; -} -.w2ui-list ul li:last-child input { - padding: 1px; - padding-top: 0px; - margin: 0px; - border: 0px; - outline: none; - height: auto; - line-height: 100%; - font-size: inherit; - font-family: inherit; - background-color: transparent; -} -.w2ui-list ul li .w2ui-list-remove { - float: right; - width: 15px; - height: 14px; - margin: -1px -9px 0px 3px; - border-radius: 15px; -} -.w2ui-list ul li .w2ui-list-remove:hover { - background-color: #D77F7F; - color: white; -} -.w2ui-list ul li .w2ui-list-remove:before { - position: relative; - top: 0px; - padding: 0px; - margin: 0px; - left: 5px; - color: inherit; - opacity: 0.7; - text-shadow: inherit; - font-size: inherit; - font-variant: small-caps; - content: 'x'; - line-height: 100%; -} -.w2ui-list ul li > span.file-size { - pointer-events: none; - color: #777; -} -.w2ui-list.w2ui-readonly ul > li:hover { - background-color: #EFF3F5; -} -.w2ui-list .w2ui-enum-placeholder { - display: inline; - position: absolute; - pointer-events: none; - color: #999; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-list.w2ui-file-dragover { - background-color: #E4FFDA; - border: 1px solid #93E07D; -} -/************************************************* -* ---- Layout ---- -*/ -.w2ui-layout { - overflow: hidden !important; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-layout * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-layout > div { - position: absolute; - overflow: hidden; - border: 0px; - margin: 0px; - padding: 0px; - outline: 0px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-layout > div .w2ui-panel { - display: none; - position: absolute; - z-index: 120; -} -.w2ui-layout > div .w2ui-panel .w2ui-panel-title { - position: absolute; - left: 0px; - top: 0px; - right: 0px; - padding: 5px; - background-image: -webkit-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -moz-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -ms-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -o-linear-gradient(#DAE6F3, #C2D5ED); - background-image: linear-gradient(#DAE6F3, #C2D5ED); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffdae6f3', endColorstr='#ffc2d5ed', GradientType=0); - border: 1px solid #B9CEE9; - border-bottom: 1px solid #99bbe8; -} -.w2ui-layout > div .w2ui-panel .w2ui-panel-tabs { - position: absolute; - left: 0px; - top: 0px; - right: 0px; - z-index: 2; - display: none; - overflow: hidden; - background-color: #FAFAFA; - padding: 4px 0px; -} -.w2ui-layout > div .w2ui-panel .w2ui-panel-tabs > .w2ui-tab.active { - background-color: #F2F2F2; -} -.w2ui-layout > div .w2ui-panel .w2ui-panel-toolbar { - position: absolute; - left: 0px; - top: 0px; - right: 0px; - z-index: 2; - display: none; - overflow: hidden; - background-color: #FAFAFA; - border-bottom: 1px solid silver; - padding: 4px; -} -.w2ui-layout > div .w2ui-panel .w2ui-panel-content { - position: absolute; - left: 0px; - top: 0px; - right: 0px; - bottom: 0px; - z-index: 1; - color: inherit; - background-color: #F2F2F2; -} -.w2ui-layout > div .w2ui-resizer { - display: none; - position: absolute; - z-index: 121; - background-color: transparent; -} -.w2ui-layout > div .w2ui-resizer:hover, -.w2ui-layout > div .w2ui-resizer.active { - background-color: #C8CAD1; -} -/************************************************* -* ---- Grid ---- -*/ -.w2ui-grid { - position: relative; - border: 1px solid silver; - border-radius: 2px; - overflow: hidden !important; -} -.w2ui-grid > div { - position: absolute; - overflow: hidden; -} -.w2ui-grid .w2ui-grid-header { - position: absolute; - top: 0; - left: 0; - right: 0; - border-bottom: 1px solid #99bbe8 !important; - height: 28px; - overflow: hidden; - color: #444; - font-size: 13px; - text-align: center; - padding: 7px; - background-image: -webkit-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -moz-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -ms-linear-gradient(#DAE6F3, #C2D5ED); - background-image: -o-linear-gradient(#DAE6F3, #C2D5ED); - background-image: linear-gradient(#DAE6F3, #C2D5ED); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffdae6f3', endColorstr='#ffc2d5ed', GradientType=0); - border-top-left-radius: 2px; - border-top-right-radius: 2px; -} -.w2ui-grid .w2ui-grid-toolbar { - position: absolute; - border-bottom: 1px solid silver; - background-color: #EAEAEA; - height: 38px; - padding: 6px 1px 4px 1px; - margin: 0px; - box-shadow: 0px 1px 2px #ddd; -} -.w2ui-grid .w2ui-toolbar-search { - position: relative; - width: 160px; - margin-right: 3px; -} -.w2ui-grid .w2ui-toolbar-search .w2ui-search-all { - outline: none !important; - width: 160px !important; - border-radius: 3px !important; - line-height: normal !important; - height: 23px !important; - border: 1px solid #B9B9B9 !important; - color: #000 !important; - background-color: white !important; - padding: 3px 18px 3px 21px !important; - margin: 0px !important; - margin-top: 1px !important; -} -.w2ui-grid .w2ui-toolbar-search .w2ui-search-down { - position: absolute; - margin-top: -7px; - margin-left: 4px; -} -.w2ui-grid .w2ui-toolbar-search .w2ui-search-clear { - position: absolute; - width: 16px; - height: 16px; - margin-top: -8px; - margin-left: -20px; - border-radius: 15px; - cursor: default; -} -.w2ui-grid .w2ui-toolbar-search .w2ui-search-clear:hover { - background-color: #D77F7F; - color: white; -} -.w2ui-grid .w2ui-toolbar-search .w2ui-search-clear:before { - position: relative; - top: 2px; - left: 5px; - opacity: 0.6; - color: inherit; - text-shadow: inherit; - content: 'x'; - cursor: default; -} -.w2ui-grid .w2ui-grid-body { - position: absolute; - overflow: hidden; - padding: 0px; - background-color: white; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} -.w2ui-grid .w2ui-grid-body input, -.w2ui-grid .w2ui-grid-body select, -.w2ui-grid .w2ui-grid-body textarea { - user-select: text; - -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - -o-user-select: text; -} -.w2ui-grid .w2ui-grid-body div.w2ui-input { - user-select: text; - -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - -o-user-select: text; - background-color: white; - padding: 4px 2px; - border: 1px solid transparent; - width: 100%; - height: 100%; - pointer-events: auto; - outline: none; - white-space: pre; - overflow: hidden; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-columns, -.w2ui-grid .w2ui-grid-body .w2ui-grid-fcolumns { - overflow: hidden; - position: absolute; - left: 0px; - top: 0px; - right: 0px; - box-shadow: 0px 1px 4px #ddd; - height: auto; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-columns table, -.w2ui-grid .w2ui-grid-body .w2ui-grid-fcolumns table { - height: auto; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-columns .w2ui-resizer, -.w2ui-grid .w2ui-grid-body .w2ui-grid-fcolumns .w2ui-resizer { - position: absolute; - z-index: 1000; - display: block; - background-image: none; - background-color: rgba(0, 0, 0, 0); - /* needed for IE */ - padding: 0px; - margin: 0px; - width: 6px; - height: 12px; - cursor: col-resize; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords { - position: absolute; - left: 0px; - right: 0px; - top: 0px; - bottom: 0px; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd { - color: inherit; - background-color: white; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd.w2ui-record-hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd.w2ui-record-hover { - color: inherit; - background-color: #E6F0FF; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd.w2ui-empty-record:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd.w2ui-empty-record:hover { - background-color: white; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even { - color: inherit; - background-color: #F3F6FA; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even.w2ui-record-hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even.w2ui-record-hover { - color: inherit; - background-color: #E6F0FF; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even.w2ui-empty-record:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even.w2ui-empty-record:hover { - background-color: #F3F6FA; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-selected, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-selected, -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr td.w2ui-selected, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr td.w2ui-selected { - color: black !important; - background-color: #B6D5FF !important; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr.w2ui-inactive, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-inactive, -.w2ui-grid .w2ui-grid-body .w2ui-grid-records table tr td.w2ui-inactive, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords table tr td.w2ui-inactive { - background-color: #D8DEE7 !important; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-expanded1, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-expanded1 { - height: 0px; - border-bottom: 1px solid #b2bac0; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-expanded1 > div, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-expanded1 > div { - height: 0px; - border: 0px; - transition: height 0.3s, opacity 0.3s; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-expanded2, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-expanded2 { - height: 0px; - border-radius: 0px; - border-bottom: 1px solid #b2bac0; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-expanded2 > div, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-expanded2 > div { - height: 0px; - border: 0px; - transition: height 0.3s, opacity 0.3s; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-load-more, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-load-more { - cursor: pointer; - background-color: rgba(233, 237, 243, 0.5); - border-right: 1px solid #D6D5D7; - height: 43px; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-load-more > div, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-load-more > div { - text-align: center; - color: #777; - background-color: rgba(233, 237, 243, 0.5); - padding: 10px 0px 15px 0px; - height: 43px; - border-top: 1px dashed #D6D5D7; - border-bottom: 1px dashed #D6D5D7; - font-size: 12px; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-records .w2ui-load-more > div:hover, -.w2ui-grid .w2ui-grid-body .w2ui-grid-frecords .w2ui-load-more > div:hover { - color: #438ba2; - background-color: #E6F0FF; -} -.w2ui-grid .w2ui-grid-body table { - border-spacing: 0px; - border-collapse: collapse; - table-layout: fixed; - width: 1px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head { - margin: 0px; - padding: 0px; - border-right: 1px solid #c5c5c5; - border-bottom: 1px solid #c5c5c5; - color: black; - background-image: -webkit-linear-gradient(#F9F9F9, #E4E4E4); - background-image: -moz-linear-gradient(#F9F9F9, #E4E4E4); - background-image: -ms-linear-gradient(#F9F9F9, #E4E4E4); - background-image: -o-linear-gradient(#F9F9F9, #E4E4E4); - background-image: linear-gradient(#F9F9F9, #E4E4E4); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff9f9f9', endColorstr='#ffe4e4e4', GradientType=0); -} -.w2ui-grid .w2ui-grid-body table .w2ui-head > div { - padding: 7px 3px; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - position: relative; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head.w2ui-col-intersection { - border-right-color: #72B2FF; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head.w2ui-reorder-cols-head:hover { - cursor: move; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head .col-intersection-marker { - padding: 0; - position: absolute; - height: 100%; - top: 0; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head .col-intersection-marker.left { - left: 0; - margin-left: -5px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head .col-intersection-marker.right { - right: 0; - margin-right: -5px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head .col-intersection-marker .top-marker { - position: absolute; - top: 0; - height: 0; - width: 0; - border-top: 5px solid #72B2FF; - border-left: 5px solid transparent; - border-right: 5px solid transparent; -} -.w2ui-grid .w2ui-grid-body table .w2ui-head .col-intersection-marker .bottom-marker { - position: absolute; - bottom: 0; - height: 0; - width: 0; - border-bottom: 5px solid #72B2FF; - border-left: 5px solid transparent; - border-right: 5px solid transparent; -} -.w2ui-grid .w2ui-grid-body table td { - border-right: 1px solid #D6D5D7; - border-bottom: 0px solid #D6D5D7; - cursor: default; - overflow: hidden; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-soft-span, -.w2ui-grid .w2ui-grid-body table td.w2ui-soft-hidden { - border-right-color: transparent; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data { - margin: 0px; - padding: 0px; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data .w2ui-info { - position: relative; - top: 1px; - font-size: 14px; - color: #8D99A7; - cursor: pointer; - width: 16px; - display: inline-block; - margin-right: 2px; - text-align: center; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data .w2ui-clipboard-copy { - float: right; - margin-top: -15px; - width: 20px; - height: 16px; - padding: 0px; - text-align: center; - cursor: pointer; - font-size: 13px; - color: #8d98a7; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data .w2ui-clipboard-copy:hover { - color: #545961; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data > div { - padding: 3px 3px 3px 3px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data > div.flexible-record { - height: auto; - overflow: visible; - white-space: normal; -} -.w2ui-grid .w2ui-grid-body table td.w2ui-grid-data .w2ui-show-children { - width: 16px; - height: 10px; - display: inline-block; - position: relative; - top: -1px; - cursor: pointer; -} -.w2ui-grid .w2ui-grid-body table td:last-child { - border-right: 0px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-number { - width: 34px; - color: #777; - background-color: rgba(233, 237, 243, 0.5); -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-number div { - padding: 0px 7px 0px 3px; - text-align: right; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-number.w2ui-head { - cursor: pointer; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-select { - width: 26px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-select div { - padding: 0px 0px; - text-align: center; - overflow: hidden; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-select div input[type=checkbox] { - margin-top: 0px; - margin-bottom: 0px; - position: relative; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-expand { - width: 26px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-expand div { - padding: 0px 0px; - text-align: center; - font-weight: bold; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-order { - width: 26px; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-order.w2ui-grid-data div { - cursor: move; - height: 18px; - background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxyZWN0IHN0eWxlPSJmaWxsOiAjYWFhOyIgeD0iMCIgeT0iNCIgaGVpZ2h0PSIzIiB3aWR0aD0iMTYiPjwvcmVjdD4KICA8cmVjdCBzdHlsZT0iZmlsbDogI2FhYTsiIHg9IjAiIHk9IjkiIGhlaWdodD0iMyIgd2lkdGg9IjE2Ij48L3JlY3Q+Cjwvc3ZnPg=="); - background-position: 5px 2px; - background-size: 14px 12px; - background-repeat: no-repeat; -} -.w2ui-grid .w2ui-grid-body table .w2ui-col-selected { - background-color: #d1d1d1 !important; -} -.w2ui-grid .w2ui-grid-body table .w2ui-row-selected { - background-color: #d1d1d1 !important; -} -.w2ui-grid .w2ui-grid-body div.w2ui-col-header { - height: auto !important; - width: 100%; - overflow: hidden; - padding-right: 10px !important; -} -.w2ui-grid .w2ui-grid-body div.w2ui-col-header > div.w2ui-sort-up { - border: 4px solid transparent; - border-bottom: 5px solid #8D99A7; - margin-top: -2px; - margin-right: -7px; - float: right; -} -.w2ui-grid .w2ui-grid-body div.w2ui-col-header > div.w2ui-sort-down { - border: 4px solid transparent; - border-top: 5px solid #8D99A7; - margin-top: 2px; - margin-right: -7px; - float: right; -} -.w2ui-grid .w2ui-grid-body .w2ui-col-group { - text-align: center; -} -.w2ui-grid .w2ui-grid-body .w2ui-grid-scroll1 { - position: absolute; - left: 0px; - bottom: 0px; - border-top: 1px solid #ddd; - border-right: 1px solid #ddd; - background-color: #FAFAFA; -} -.w2ui-grid .w2ui-grid-empty-msg { - position: absolute; - top: 27px; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(255, 255, 255, 0.65); -} -.w2ui-grid .w2ui-grid-empty-msg > div { - position: absolute; - left: 0; - right: 0; - top: 45%; - transform: translateY(-45%); - text-align: center; - font-size: 13px; - color: #666; -} -.w2ui-grid .w2ui-changed { - background: url(data:image/gif;base64,R0lGODlhCgAKAJEAALAABf///wAAAAAAACH5BAEAAAIALAAAAAAKAAoAAAIPlI8Hy8mbxIsSUnup3rQAADs=) no-repeat top right; -} -.w2ui-grid .w2ui-edit-box { - position: absolute; - z-index: 1001; - border: 2px solid #6299DA; - pointer-events: auto; -} -.w2ui-grid .w2ui-editable { - overflow: hidden; - height: 100% !important; - margin: 0px !important; - padding: 0px !important; -} -.w2ui-grid .w2ui-editable input { - border: 0px; - border-radius: 0px; - margin: 0px; - padding: 4px 3px; - width: 100%; - height: 100%; -} -.w2ui-grid .w2ui-editable input.w2ui-select { - outline: none !important; - background: #fff; -} -.w2ui-grid .w2ui-grid-summary { - position: absolute; - box-shadow: 0px -1px 4px #aaa; -} -.w2ui-grid .w2ui-grid-summary table { - color: inherit; -} -.w2ui-grid .w2ui-grid-summary table .w2ui-odd { - background-color: #EEF5EB; -} -.w2ui-grid .w2ui-grid-summary table .w2ui-even { - background-color: #F8FFF5; -} -.w2ui-grid .w2ui-grid-footer { - position: absolute; - bottom: 0; - left: 0; - right: 0; - margin: 0px; - padding: 0px; - text-align: center; - height: 24px; - overflow: hidden; - user-select: text; - -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - -o-user-select: text; - box-shadow: 0px -1px 4px #eee; - color: #444; - background-color: #F8F8F8; - border-top: 1px solid #ddd; - border-bottom-left-radius: 2px; - border-bottom-right-radius: 2px; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-left { - float: left; - padding-top: 5px; - padding-left: 5px; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-right { - float: right; - padding-top: 5px; - padding-right: 5px; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-center { - padding: 2px; - text-align: center; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-center .w2ui-footer-nav { - width: 110px; - margin: 0 auto; - padding: 0px; - text-align: center; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-center .w2ui-footer-nav input[type=text] { - padding: 1px 2px 2px 2px; - border-radius: 3px; - width: 40px; - text-align: center; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-center .w2ui-footer-nav a.w2ui-footer-btn { - display: inline-block; - border-radius: 3px; - cursor: pointer; - font-size: 11px; - line-height: 16px; - padding: 1px 5px; - width: 30px; - height: 18px; - margin-top: -1px; - color: black; - background-color: transparent; -} -.w2ui-grid .w2ui-grid-footer .w2ui-footer-center .w2ui-footer-nav a.w2ui-footer-btn:hover { - color: #000; - background-color: #AEC8FF; -} -.w2ui-grid .w2ui-grid-focus-input { - position: absolute; - top: 0; - right: 0; - z-index: -1; - opacity: 0; - overflow: hidden; - padding: 0px; - margin: 0px; - width: 1px; - height: 1px; - resize: none; - border: 0px; -} -/* SpeadSheet */ -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr td.w2ui-selected { - background-color: #EEF4FE !important; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr td.w2ui-inactive { - background-color: #F4F6F9 !important; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table td { - border-right-width: 1px; - border-bottom: 1px solid #efefef; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd, -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even, -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr.w2ui-odd:hover, -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr.w2ui-even:hover { - background-color: inherit; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-records table tr:first-child td { - border-top: 0px; - border-bottom: 0px; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr td.w2ui-selected { - background-color: #EEF4FE !important; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr td.w2ui-inactive { - background-color: #F4F6F9 !important; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table td { - border-right-width: 1px; - border-bottom: 1px solid #efefef; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd, -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even, -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-odd:hover, -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr.w2ui-even:hover { - background-color: inherit; -} -.w2ui-ss .w2ui-grid-body .w2ui-grid-frecords table tr:first-child td { - border-bottom: 0px; -} -.w2ui-ss .w2ui-grid-body .w2ui-selection { - position: absolute; - z-index: 1000; - border: 2px solid #6299DA; - /* #457FC2; */ - pointer-events: none; -} -.w2ui-ss .w2ui-grid-body .w2ui-selection .w2ui-selection-resizer { - cursor: crosshair; - position: absolute; - bottom: 0px; - right: 0px; - width: 6px; - height: 6px; - margin-right: -3px; - margin-bottom: -3px; - background-color: #457FC2; - border: 0.5px solid #fff; - outline: 1px solid white; - pointer-events: auto; -} -.w2ui-ss .w2ui-grid-body .w2ui-selection.w2ui-inactive { - border: 2px solid #C0C2C5; -} -.w2ui-ss .w2ui-grid-body .w2ui-selection.w2ui-inactive .w2ui-selection-resizer { - background-color: #B0B0B0; -} -.w2ui-ss .w2ui-grid-body .w2ui-soft-range { - position: absolute; - pointer-events: none; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} -.w2ui-ss .w2ui-grid-body .w2ui-changed { - background: inherit; - /* do not show changed for spreadsheet */ -} -.w2ui-info-bubble table { - font-size: 11px; - font-family: Verdana, Arial, sans-serif; - color: white; - text-shadow: 1px 1px solid #999; -} -.w2ui-info-bubble table tr td:first-child { - white-space: nowrap; - padding: 2px; - padding-right: 10px; - color: #ddd; - vertical-align: top; -} -.w2ui-info-bubble table tr td:last-child { - white-space: pre; - padding: 2px; -} -.w2ui-overlay .w2ui-select-field { - padding: 4px 0px; - cursor: default; -} -.w2ui-overlay .w2ui-select-field table { - font-size: 11px; - font-family: Verdana, Arial, sans-serif; - border-spacing: 0px; - border-collapse: border-collapse; -} -.w2ui-overlay .w2ui-select-field table tr { - height: 27px; -} -.w2ui-overlay .w2ui-select-field table tr:hover, -.w2ui-overlay .w2ui-select-field table tr.w2ui-selected { - background-color: #B6D5FF; -} -.w2ui-overlay .w2ui-select-field table tr td:nth-child(1) { - width: 26px; - padding-right: 6px; - text-align: right; - color: #888; -} -.w2ui-overlay .w2ui-select-field table tr td:nth-child(2) { - padding: 3px 20px 3px 0px; -} -.w2ui-overlay .w2ui-col-on-off { - padding: 4px 0px; -} -.w2ui-overlay .w2ui-col-on-off table { - border-spacing: 0px; - border-collapse: border-collapse; -} -.w2ui-overlay .w2ui-col-on-off table tr:hover, -.w2ui-overlay .w2ui-col-on-off table tr.w2ui-selected { - background-color: #B6D5FF; -} -.w2ui-overlay .w2ui-col-on-off table td input[type=checkbox] { - margin: 3px 2px 2px 2px; -} -.w2ui-overlay .w2ui-col-on-off table td label { - display: block; - padding: 3px 0px; - padding-right: 10px; -} -.w2ui-overlay .w2ui-col-on-off table td:first-child { - padding: 4px 0px 4px 6px; -} -.w2ui-overlay .w2ui-col-on-off table td:last-child { - padding: 4px 6px 4px 0px; -} -.w2ui-overlay .w2ui-grid-searches { - text-align: left; - padding: 0px; - border-top: 0px; - background-color: #f7f6f0; -} -.w2ui-overlay .w2ui-grid-searches table { - padding: 4px; - padding-top: 12px; - border-collapse: border-collapse; -} -.w2ui-overlay .w2ui-grid-searches table td { - padding: 4px; - /* for IE */ -} -.w2ui-overlay .w2ui-grid-searches table td.close-btn { - width: 20px; - padding-right: 20px; -} -.w2ui-overlay .w2ui-grid-searches table td.close-btn button { - min-width: 24px; - height: 24px; - padding-top: 5px !important; -} -.w2ui-overlay .w2ui-grid-searches table td.caption { - text-align: right; - padding-right: 5px; - border-right: 1px solid #E8E8E3; -} -.w2ui-overlay .w2ui-grid-searches table td.operator { - text-align: left; - padding: 0px 10px; - padding-right: 5px; - border-right: 1px solid #E8E8E3; - height: 31px; -} -.w2ui-overlay .w2ui-grid-searches table td.operator select { - width: 100%; - color: black; -} -.w2ui-overlay .w2ui-grid-searches table td.operator select::-ms-expand { - display: none; -} -.w2ui-overlay .w2ui-grid-searches table td.value { - padding-right: 5px; - padding-left: 5px; -} -.w2ui-overlay .w2ui-grid-searches table td.value input[type=text] { - border-radius: 3px; - padding: 3px; - margin-right: 3px; - height: 23px; -} -.w2ui-overlay .w2ui-grid-searches table td.value select { - padding: 3px; - margin-right: 3px; - height: 23px; -} -.w2ui-overlay .w2ui-grid-searches table td.actions { - border-right: 0px; -} -.w2ui-overlay .w2ui-grid-searches table td.actions > div { - margin: -7px; - margin-top: 15px; - padding: 13px 0px; - text-align: center; - background-color: #EFEFE9; - border-top: 1px solid #E8E8E3; -} -/************************************************* -* ---- Popup ---- -*/ -.w2ui-popup { - position: fixed; - z-index: 1600; - overflow: hidden; - font-family: Verdana, Arial, sans-serif; - border-radius: 6px; - padding: 0px; - margin: 0px; - border: 1px solid #777; - background-color: #eee; - box-shadow: 0px 0px 25px #555; -} -.w2ui-popup, -.w2ui-popup * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-popup.w2ui-popup-opening { - opacity: 0; - -webkit-transform: scale(0.8); - -moz-transform: scale(0.8); - -ms-transform: scale(0.8); - -o-transform: scale(0.8); - transform: scale(0.8); -} -.w2ui-popup.w2ui-popup-closing { - opacity: 0; - -webkit-transform: scale(0.9); - -moz-transform: scale(0.9); - -ms-transform: scale(0.9); - -o-transform: scale(0.9); - transform: scale(0.9); -} -.w2ui-popup .w2ui-popup-title { - padding: 6px; - border-radius: 6px 6px 0px 0px; - background-image: -webkit-linear-gradient(#ECECEC, #DFDFDF); - background-image: -moz-linear-gradient(#ECECEC, #DFDFDF); - background-image: -ms-linear-gradient(#ECECEC, #DFDFDF); - background-image: -o-linear-gradient(#ECECEC, #DFDFDF); - background-image: linear-gradient(#ECECEC, #DFDFDF); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffececec', endColorstr='#ffdfdfdf', GradientType=0); - border-bottom: 2px solid #BFBFBF; - position: absolute; - overflow: hidden; - height: 32px; - left: 0px; - right: 0px; - top: 0px; - text-overflow: ellipsis; - text-align: center; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; - cursor: move; - font-size: 15px; - color: #555; - z-index: 300; -} -.w2ui-popup .w2ui-popup-button { - float: right; - width: 18px; - height: 18px; - cursor: pointer; - overflow: hidden; - padding: 0px; - margin: 0px 3px 0px 0px; - background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAQCAYAAABQrvyxAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAj1JREFUeNrslr9rFFEQxz/zZi/qxSgW2lsqkiYoBku5Ro1o4UFKEYkgSaxSCLYqdv5IEVPYCMJJwERWrK0CKhoQ8hdobQTjXW7njcXlYnLunQQu0YDTLOy+Nzvfme98Z8Td2ckW2OGWdMvRvYfT/RGfBPoBBVpLK0AEPgVkdGL06vt/CoB5nBaRE8AXYKXNsQIwaB4fAwOtH+88mn4m7ifN4vUYebWBKkFKqjIV3N9NjI2Uuw5ARI45fBanH+F77iFnN8JHETmS68P9NHBQNTwHL8foaSN4SqoyA/SZyL4tqQAQBVYCLOFYlNxmq0WorVLpN9Oe5LKt1CsgRVWpAOfB66phBuhTkepSdfnKVjaxNJMSWn/iawmTtpeDp6pWBpaBoqrMqoYU6AOqIbFhxGa3R4V8nfNNKLUESzXJhoCvQC+wF/gW1C5IiC+2XUbD5jA3rd4C26NR3945IA2iRzqRJgdElJJlSQocAKrAD2A/6Ev3cLajjN59MDWHyKl2voOI1zKbv3Xj2lCHJFoz+LXuBoIAjnUklEvJrDDT5LwmdhG8blkyBxRjXSu4loE0X4VEznXKV3SnoOFMB7YUolBcbcKNdxuPXUBPu8pbLXsK0ghebVjEXgNoYmXLtGLuxd6ePU+AQ20AaIrb4DpFycmSv81/7YsiMgAstB1kQgE47O4LuQmCNwGOB7VxCb/URsRSTbhkmU4ifGiZHd1Z5m7fnxoIQSaBo39YJRZj9LGb4yPzXWm1/9voX7afAwAC5tacDTA2XgAAAABJRU5ErkJggg==) no-repeat center left; - background-position: 0px 0px; - color: transparent !important; - border-radius: 3px; - border: 1px solid transparent; -} -.w2ui-popup .w2ui-popup-close { - margin-top: 0px; - background-position: -32px 0px; -} -.w2ui-popup .w2ui-popup-close:hover { - background-color: #ccc; - border: 1px solid #aaa; -} -.w2ui-popup .w2ui-popup-max { - background-position: -16px 0px; -} -.w2ui-popup .w2ui-popup-max:hover { - background-color: #ccc; - border: 1px solid #aaa; -} -.w2ui-popup .w2ui-box, -.w2ui-popup .w2ui-box-temp { - position: absolute; - left: 0px; - right: 0px; - top: 32px; - bottom: 52px; - z-index: 100; -} -.w2ui-popup .w2ui-popup-body { - font-size: 12px; - line-height: 130%; - padding: 0px 7px 7px 7px; - color: #000; - background-color: #eee; - position: absolute; - overflow: auto; - width: 100%; - height: 100%; -} -.w2ui-popup .w2ui-popup-buttons { - font-size: 11px; - padding: 12px; - border-radius: 0px 0px 6px 6px; - border-top: 1px solid #d5d8d8; - background-color: #F1F1F1; - text-align: center; - position: absolute; - overflow: hidden; - height: 52px; - left: 0px; - right: 0px; - bottom: 0px; - z-index: 200; -} -.w2ui-popup .w2ui-popup-no-title { - border-top-left-radius: 6px; - border-top-right-radius: 6px; - top: 0px !important; -} -.w2ui-popup .w2ui-popup-no-buttons { - border-bottom-left-radius: 6px; - border-bottom-right-radius: 6px; - bottom: 0px !important; -} -.w2ui-popup .w2ui-alert-msg, -.w2ui-popup .w2ui-confirm-msg { - font-size: 12px; - line-height: 1.5; -} -.w2ui-popup .w2ui-prompt { - font-size: 12px; - padding: 15px 10px 0 10px; -} -.w2ui-popup .w2ui-prompt > div { - margin-bottom: 5px; -} -.w2ui-popup .w2ui-prompt > label { - margin-right: 5px; -} -.w2ui-popup .w2ui-prompt input { - width: 230px; -} -.w2ui-popup .w2ui-prompt textarea { - width: 100%; - height: 50px; - resize: none; -} -/************************************************* -* ---- Sidebar ---- -*/ -.w2ui-sidebar { - position: relative; - cursor: default; - overflow: hidden !important; - background-color: #fafafa !important; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-sidebar * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-sidebar > div { - position: absolute; - overflow: hidden; -} -.w2ui-sidebar .w2ui-sidebar-top { - position: absolute; - z-index: 2; - top: 0px; - left: 0px; - right: 0px; -} -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-left, -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-right { - position: absolute; - right: 2px; - top: 2px; - height: 24px; - padding: 5px; - border-radius: 2px; - background-size: 16px 12px; - background-position: center center; - background-repeat: no-repeat; - background-color: #fafafa; -} -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-left:hover, -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-right:hover { - background-color: #f1f1f1; -} -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-left { - left: auto; - width: 25px; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAzklEQVR4Ae2THRDEMBCFzy1ucatb3eJ2uhi3uNUtbnGrW9zi1rOdNzdvdl7nDpvYt/9/r7+/51myZZf/zXkD2iMHHRSb0x3oskwMieK05PwEXqP4ExSL0wp0ROao2OOuMPOMdUL6XU1/oGLcFWb+NqyTd2W/P/2qTr9h+nFXhOkHXRHiNyjrgp/U/V+WaQcaNY13zZI0A1JvcVqAnrGDTdtDtZUHjHIJhxxVLN0iqXgCP1l/7h8U9kc6abyJ4/eNWPpGdBv+XdUK0K8cnvcBly2rDr7C1HQAAAAASUVORK5CYII='); -} -.w2ui-sidebar .w2ui-sidebar-top .w2ui-flat-right { - left: 2px; - width: auto; - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVR4Ae2UG7TGMBCEr1vd4la3uMUtuli3utWtbnGLW9zi9l/bDMzJG7u12cfJfLunf1+UEC9Bv0vVQwJ8hjRCaZafflb1C9RQf4OD0gSDE+i+PiJAabFhQc1y1AYYsJGLY3lgxM17uWPO56yPiFDqVPWgRtpIHSd1zPnwkBsdI58OlNwx4fP2X0TgfMTOoHSdKOXkpyNvEyQh7ul+4swxJSTQuwNDxz68l/ukVNbu0Neen5Z+KvzWxBAqHds349uPFJ/jVOrPjxUq++OLf+20q5+noXo0AAAAAElFTkSuQmCC'); -} -.w2ui-sidebar .w2ui-sidebar-bottom { - position: absolute; - z-index: 2; - bottom: 0px; - left: 0px; - right: 0px; -} -.w2ui-sidebar .w2ui-sidebar-body { - position: absolute; - z-index: 1; - overflow: auto; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; - padding: 2px 0px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node { - position: relative; - background-color: transparent; - border: 1px solid transparent; - border-radius: 4px; - margin: 0px 3px; - padding: 1px 0px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-text, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image > span { - color: black; - text-shadow: 0px 0px 0px #fff; - pointer-events: none; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-text:hover, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image:hover, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image > span:hover { - color: inherit; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-handle { - display: inline-block; - padding: 0px; - margin: 0px; - height: 100%; - position: absolute; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node:hover { - border-top: 1px solid #f9f9f9; - border-bottom: 1px solid #f9f9f9; - background-color: #f1f1f1; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image { - width: 22px; - text-align: center; - pointer-events: none; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node .w2ui-node-image > span { - color: #888 !important; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node input, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node button { - pointer-events: auto; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected:hover { - position: relative; - background-color: #E9E9E9; - border: 1px solid #dfdfdf; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected .w2ui-node-text, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected:hover .w2ui-node-text, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected .w2ui-node-image, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected:hover .w2ui-node-image, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected .w2ui-node-image > span, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected:hover .w2ui-node-image > span { - color: inherit !important; - text-shadow: 0px 0px 0px #fff !important; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-selected:before { - content: ""; - border: 1px dashed transparent; - border-radius: 4px; - position: absolute; - top: -1px; - bottom: -1px; - left: -1px; - right: -1px; - pointer-events: none; -} -.w2ui-sidebar .w2ui-sidebar-body.w2ui-focus .w2ui-selected:before { - border: 1px solid #cccccc; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled:hover { - background: transparent !important; - border: 1px solid transparent; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled .w2ui-node-text, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled:hover .w2ui-node-text, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled .w2ui-node-image, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled:hover .w2ui-node-image, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled .w2ui-node-image > span, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-disabled:hover .w2ui-node-image > span { - opacity: 0.4; - filter: alpha(opacity=40); - color: black !important; - text-shadow: 0px 0px 0px #fff !important; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-text { - white-space: nowrap; - padding: 5px 0px 5px 3px; - margin: 1px 0px 1px 22px; - position: relative; - z-index: 1; - font-size: 12px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-group { - white-space: nowrap; - overflow: hidden; - padding: 10px 0px 10px 10px; - margin: 0px; - cursor: default; - color: #8fabca; - background-color: transparent; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-group :nth-child(1) { - /* show / hide link */ - margin-right: 10px; - float: right; - color: transparent; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-group :nth-child(2) { - /* title text */ - font-weight: normal; - text-transform: uppercase; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-sub { - overflow: hidden; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data { - padding: 2px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-node-image { - padding: 3px 0px 0px 0px; - float: left; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-node-image > span { - font-size: 16px; - color: black; - text-shadow: 0px 0px 0px #fff; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-node-image.w2ui-icon { - margin-top: 3px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-node-count { - float: right; - border: 1px solid #F6FCF4; - border-radius: 20px; - width: auto; - height: 18px; - padding: 2px 7px; - margin: 3px 4px -2px 0; - background-color: #F2F8F0; - color: #666; - box-shadow: 0px 0px 2px #474545; - text-shadow: 1px 1px 0px #FFF; - position: relative; - z-index: 2; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-collapsed, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-expanded { - float: right; - width: auto; - height: 18px; - position: relative; - z-index: 2; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-collapsed span, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-expanded span { - border-color: transparent; - background-color: transparent; - box-shadow: none; - padding: 2px 5px; - border-radius: 0px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-collapsed span:after, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-expanded span:after { - content: ""; - position: absolute; - border-left: 5px solid #808080; - border-top: 5px solid transparent; - border-bottom: 5px solid transparent; - transform: rotateZ(-90deg); - pointer-events: none; - margin-left: -4px; - margin-top: 7px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-collapsed span:hover, -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-expanded span:hover { - border-color: transparent; - background-color: transparent; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-data .w2ui-collapsed span:after { - transform: rotateZ(90deg); -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-flat { - display: block; - padding: 2px 0px; - text-align: center; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-flat .w2ui-node-image { - float: none; - text-align: center; - width: auto; - padding: 1px 0px; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-flat .w2ui-node-image > span { - font-size: 16px; - color: black; - text-shadow: 0px 0px 0px #fff; -} -.w2ui-sidebar .w2ui-sidebar-body .w2ui-node-flat .w2ui-node-image.w2ui-icon { - width: 21px; -} -/************************************************* -* ---- Tabs ---- -*/ -.w2ui-tabs { - cursor: default; - overflow: hidden !important; - position: relative; - background-color: #fafafa; - padding: 3px 0px; -} -.w2ui-tabs .w2ui-scroll-wrapper { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - justify-content: flex-start; - align-content: flex-start; - padding: 0 7px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tabs-line { - border-bottom: 1px solid silver; - position: absolute; - left: 0px; - right: 0px; - top: 3px; - bottom: 3px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab { - position: relative; - padding: 6px 20px; - text-align: center; - color: black; - background-color: transparent; - border: 1px solid silver; - border-bottom: 1px solid transparent; - white-space: nowrap; - margin: 1px 1px -1px 0px; - border-radius: 4px 4px 0 0; - cursor: default; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab.active { - color: black; - background-color: white; - border: 1px solid silver; - border-bottom: 3px solid 1px solid silver; - margin-bottom: -3px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab.moving { - color: black; - background-color: #ddd; - border: 1px solid silver; - border-bottom: 3px solid 1px solid silver; - margin-bottom: -3px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab.closable { - padding: 6px 28px 6px 20px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab .w2ui-tab-close { - position: absolute; - right: 3px; - top: 3px; - color: #555; - text-shadow: 1px 1px 1px #bbb; - float: right; - padding: 0px 4px; - width: 16px; - height: 16px; - opacity: 0.6; - border: 0px; - border-top: 3px solid transparent; - border-radius: 9px; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab .w2ui-tab-close:hover { - background-color: #D77F7F; - color: white; - opacity: 1; - text-shadow: 0px 0px 1px #777; - font-weight: bold; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tab .w2ui-tab-close:before { - position: relative; - top: -2px; - left: 0px; - color: inherit; - text-shadow: inherit; - content: 'x'; -} -.w2ui-tabs .w2ui-scroll-wrapper .w2ui-tabs-right { - padding: 5px; - width: 100%; - text-align: right; -} -.w2ui-tabs.w2ui-tabs-up .w2ui-scroll-wrapper .w2ui-tabs-line { - border-bottom: 1px solid transparent; - border-top: 1px solid silver; -} -.w2ui-tabs.w2ui-tabs-up .w2ui-scroll-wrapper .w2ui-tab { - border: 1px solid silver; - border-top: 1px solid white; - margin: -1px 1px 1px 0px; - border-radius: 0 0 4px 4px; -} -.w2ui-tabs.w2ui-tabs-up .w2ui-scroll-wrapper .w2ui-tab.active { - color: black; - background-color: white; - border: 1px solid silver; - margin: 1px 1px 1px 0px; - border-top: 2px solid white; - margin-top: -2px; -} -/************************************************* -* ---- Toolbar ---- -*/ -.w2ui-toolbar { - margin: 0px; - padding: 2px; - outline: 0px; - position: relative; - background-color: #efefef; - overflow: hidden !important; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} -.w2ui-toolbar .disabled { - opacity: 0.3; - filter: alpha(opacity=30); -} -.w2ui-toolbar table { - table-layout: auto !important; -} -.w2ui-toolbar table td { - border: 0px !important; -} -.w2ui-toolbar table.w2ui-button { - margin: 0 1px 0 0; - border-radius: 4px; - height: 24px; - min-width: 24px; - border: 1px solid transparent; - background-color: transparent; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-image { - width: 22px; - height: 16px; - padding: 0; - margin: 5px 1px 3px 1px!important; - border: 0!important; - text-align: center; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-image > span { - font-size: 15px; - display: block; - color: #8D99A7; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-image > span:before { - vertical-align: top !important; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-text { - color: black; - padding: 0px 4px 0px 2px; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-count { - padding: 0px 3px 0px 1px; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-count > span { - border: 1px solid #F6FCF4; - border-radius: 11px; - width: auto; - height: 18px; - padding: 0px 6px 1px 6px; - background-color: #F2F8F0; - color: #666; - box-shadow: 0px 0px 2px #474545; - text-shadow: 1px 1px 0px #FFF; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-down { - padding: 1px 3px 1px 1px; -} -.w2ui-toolbar table.w2ui-button .w2ui-tb-down > div { - border: 4px solid transparent; - border-top: 5px solid #8D99A7; - margin-top: 5px; -} -.w2ui-toolbar table.w2ui-button.over { - border: 1px solid #ccc; - background-color: #eee; -} -.w2ui-toolbar table.w2ui-button.over .w2ui-tb-text { - color: black; -} -.w2ui-toolbar table.w2ui-button.down { - border: 1px solid #aaa; - background-color: #ddd; -} -.w2ui-toolbar table.w2ui-button.down .w2ui-tb-text { - color: #666; -} -.w2ui-toolbar table.w2ui-button.checked { - border: 1px solid #aaa; - background-color: white; -} -.w2ui-toolbar table.w2ui-button.checked .w2ui-tb-text { - color: black; -} -.w2ui-toolbar table.w2ui-button table { - height: 17px; - border-radius: 4px; - cursor: default; -} -.w2ui-toolbar .w2ui-toolbar-new-line { - border-top: 1px solid #dedede; - border-bottom: 1px solid white; - margin: 5px 0 5px 0; -} -.w2ui-toolbar .w2ui-break { - background-image: -webkit-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, #999 40%, #999 60%, rgba(153, 153, 153, 0.1) 100%); - background-image: -moz-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, #999 40%, #999 60%, rgba(153, 153, 153, 0.1) 100%); - background-image: -ms-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, #999 40%, #999 60%, rgba(153, 153, 153, 0.1) 100%); - background-image: -o-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, #999 40%, #999 60%, rgba(153, 153, 153, 0.1) 100%); - background-image: linear-gradient(to bottom, rgba(153, 153, 153, 0.1) 0%, #999 40%, #999 60%, rgba(153, 153, 153, 0.1) 100%); - filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff999999', endColorstr='#ff999999', GradientType=0); - width: 1px !important; - height: 22px; - padding: 0px; - margin: 0px 6px; -} -.w2ui-listview { - overflow: auto !important; - background-color: white !important; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-listview * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -ms-box-sizing: border-box; - -o-box-sizing: border-box; - box-sizing: border-box; -} -.w2ui-listview > ul { - list-style-type: none; - margin: 0; - cursor: default; -} -.w2ui-listview > ul > li { - display: inline-block; - vertical-align: top; - overflow: hidden; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; - border: 1px solid transparent; - border-radius: 4px; -} -.w2ui-listview > ul > li.w2ui-focused { - border: 1px solid #2661A6; -} -.w2ui-listview > ul > li.w2ui-selected { - border: 1px solid #2661A6; -} -.w2ui-listview > ul > li.w2ui-selected, -.w2ui-listview > ul > li.w2ui-selected.hover { - background-color: #E9E9E9; -} -.w2ui-listview > ul > li.w2ui-selected > div > div.caption, -.w2ui-listview > ul > li.w2ui-selected.hover > div > div.caption { - color: inherit; -} -.w2ui-listview > ul > li.w2ui-selected > div > div.description, -.w2ui-listview > ul > li.w2ui-selected.hover > div > div.description { - color: #DDDDDD; -} -.w2ui-listview > ul > li.w2ui-selected > div > div.extra > div > div, -.w2ui-listview > ul > li.w2ui-selected.hover > div > div.extra > div > div { - color: #DDDDDD; -} -.w2ui-listview > ul > li.hover { - background-color: #f1f1f1; - border: 1px solid #2661A6; -} -.w2ui-listview > ul > li div { - vertical-align: middle; -} -.w2ui-listview > ul > li > div > div.caption { - display: block; - text-align: center; - word-wrap: break-word; - max-height: 50px; - color: black; - font-size: 12px; -} -.w2ui-listview > ul > li > div > div.description { - display: none; - text-align: left; - color: #777777; - font-size: 12px; -} -.w2ui-listview > ul > li > div > div.extra { - display: none; -} -.w2ui-listview > ul > li > div > div.extra > div > div { - color: #777777; -} -.w2ui-icon-small > ul { - padding: 1px 0px 0px 1px; -} -.w2ui-icon-small > ul > li { - margin: 0px 1px 1px 0px; - padding: 2px; - width: 250px; - white-space: nowrap; -} -.w2ui-icon-small > ul > li > div > div.w2ui-listview-img { - display: inline-block; - width: 26px; - height: 22px; - font-size: 21px; - margin-right: 2px; -} -.w2ui-icon-small > ul > li > div > div.caption { - display: inline-block; -} -.w2ui-icon-medium > ul { - padding: 4px 0px 0px 4px; -} -.w2ui-icon-medium > ul > li { - margin: 0px 4px 4px 0px; - padding: 4px; - width: 100px; -} -.w2ui-icon-medium > ul > li > div > div.w2ui-listview-img { - display: block; - width: 92px; - height: 60px; - font-size: 57px; - margin-left: auto; - margin-right: auto; - background-position: center; -} -.w2ui-icon-large > ul { - padding: 4px 0px 0px 4px; -} -.w2ui-icon-large > ul > li { - margin: 0px 4px 4px 0px; - padding: 4px; - width: 160px; -} -.w2ui-icon-large > ul > li > div > div.w2ui-listview-img { - display: block; - width: 152px; - height: 120px; - font-size: 114px; - margin-left: auto; - margin-right: auto; - background-position: center; -} -.w2ui-icon-tile > ul { - padding: 1px 0px 0px 1px; -} -.w2ui-icon-tile > ul > li { - margin: 0px 1px 1px 0px; - padding: 4px; - width: 250px; - white-space: nowrap; -} -.w2ui-icon-tile > ul > li > div > div.w2ui-listview-img { - display: inline-block; - width: 72px; - height: 60px; - font-size: 57px; - float: left; - margin-right: 4px; -} -.w2ui-icon-tile > ul > li > div > div.caption { - text-align: left; -} -.w2ui-icon-tile > ul > li > div > div.description { - display: block; -} -.w2ui-table > ul { - padding: 0; -} -.w2ui-table > ul > li { - width: 100%; - padding: 2px; - border-radius: 0px; - border-bottom: 1px dotted lightgray; -} -.w2ui-table > ul > li > div { - display: inline-block; - position: relative; - width: 100%; - white-space: nowrap; - overflow: hidden; -} -.w2ui-table > ul > li > div > div.w2ui-listview-img { - display: inline-block; - width: 38px; - height: 32px; - font-size: 31px; - margin-right: 2px; -} -.w2ui-table > ul > li > div > div.caption { - display: inline-block; -} -.w2ui-table > ul > li > div > div.extra { - display: inline-block; - position: absolute; - right: 0; - height: 100%; - background-color: white; -} -.w2ui-table > ul > li > div > div.extra > div:before { - display: inline-block; - height: 100%; - width: 0; - content: ''; - vertical-align: middle; -} -.w2ui-table > ul > li > div > div.extra > div { - display: inline; -} -.w2ui-table > ul > li > div > div.extra > div > div { - display: inline-block; - font-size: 12px; -} -.w2ui-table > ul > li.w2ui-selected div.extra, -.w2ui-table > ul > li.w2ui-selected.hover div.extra { - background-color: #E9E9E9; -} -.w2ui-table > ul > li.hover div.extra { - background-color: #f1f1f1; -} -.w2ui-listview > ul > li div.icon-none { - border: 1px solid rgba(102, 102, 102, 0.35); -} diff --git a/dist/w2ui-1.5.js b/dist/w2ui-1.5.js deleted file mode 100644 index 1226c2a5e..000000000 --- a/dist/w2ui-1.5.js +++ /dev/null @@ -1,21491 +0,0 @@ -/* w2ui 1.5 (c) http://w2ui.com, vitmalina@gmail.com */ -var w2ui = w2ui || {}; -var w2obj = w2obj || {}; // expose object to be able to overwrite default functions - -/************************************************ -* Library: Web 2.0 UI for jQuery -* - Following objects are defines -* - w2ui - object that will contain all widgets -* - w2obj - object with widget prototypes -* - w2utils - basic utilities -* - $().w2render - common render -* - $().w2destroy - common destroy -* - $().w2marker - marker plugin -* - $().w2tag - tag plugin -* - $().w2overlay - overlay plugin -* - $().w2menu - menu plugin -* - w2utils.event - generic event object -* - Dependencies: jQuery -* -* == NICE TO HAVE == -* - overlay should be displayed where more space (on top or on bottom) -* - write and article how to replace certain framework functions -* - add maxHeight for the w2menu -* - add time zone -* - TEST On IOS -* - $().w2marker() -- only unmarks first instance -* - subitems for w2menus() -* - add w2utils.lang wrap for all captions in all buttons. -* - $().w2date(), $().w2dateTime() -* -* == 1.5 change -* - parseColor(str) returns rgb -* - rgb2hsv, hsv2rgb -* - color.onSelect -* - color.html -* - refactored w2tag object, it has more potential with $().data('w2tag') -* - added w2utils.tooltip -* - w2tag options.hideOnFocus -* - w2tag options.maxWidth -* - w2tag options.auto - if set to true, then tag will show on mouseover -* - w2tag options.showOn, hideOn - if set to true, then tag will show on mouseover -* - w2tag options.className: 'w2ui-light' - for light color tag -* - w2menu options.items... remove t/f -* - w2menu options.items... keepOpen t/f -* - w2menu options.onRemove -* - w2menu options.hideOnRemove -* - w2menu - can not nest items, item.items and item.expanded -* - w2menu.options.topHTML -* - w2menu.options.menuStyle -* - naturalCompare -* -************************************************/ - -var w2utils = (function ($) { - var tmp = {}; // for some temp variables - var obj = { - version : '1.5.x', - settings : { - "locale" : "en-us", - "dateFormat" : "m/d/yyyy", - "timeFormat" : "hh:mi pm", - "datetimeFormat" : "m/d/yyyy|hh:mi pm", - "currencyPrefix" : "$", - "currencySuffix" : "", - "currencyPrecision" : 2, - "groupSymbol" : ",", - "decimalSymbol" : ".", - "shortmonths" : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - "fullmonths" : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - "shortdays" : ["M", "T", "W", "T", "F", "S", "S"], - "fulldays" : ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], - "weekStarts" : "M", // can be "M" for Monday or "S" for Sunday - "dataType" : 'HTTPJSON', // can be HTTP, HTTPJSON, RESTFULL, RESTFULLJSON, JSON (case sensitive) - "phrases" : {}, // empty object for english phrases - "dateStartYear" : 1950, // start year for date-picker - "dateEndYear" : 2030, // end year for date picker - "macButtonOrder" : false // if true, Yes on the right side - }, - isBin : isBin, - isInt : isInt, - isFloat : isFloat, - isMoney : isMoney, - isHex : isHex, - isAlphaNumeric : isAlphaNumeric, - isEmail : isEmail, - isIpAddress : isIpAddress, - isDate : isDate, - isTime : isTime, - isDateTime : isDateTime, - age : age, - interval : interval, - date : date, - formatSize : formatSize, - formatNumber : formatNumber, - formatDate : formatDate, - formatTime : formatTime, - formatDateTime : formatDateTime, - stripTags : stripTags, - encodeTags : encodeTags, - decodeTags : decodeTags, - escapeId : escapeId, - base64encode : base64encode, - base64decode : base64decode, - md5 : md5, - transition : transition, - lock : lock, - unlock : unlock, - message : message, - naturalCompare : naturalCompare, - lang : lang, - locale : locale, - getSize : getSize, - getStrWidth : getStrWidth, - scrollBarSize : scrollBarSize, - checkName : checkName, - checkUniqueId : checkUniqueId, - parseRoute : parseRoute, - cssPrefix : cssPrefix, - parseColor : parseColor, - hsv2rgb : hsv2rgb, - rgb2hsv : rgb2hsv, - tooltip : tooltip, - getCursorPosition : getCursorPosition, - setCursorPosition : setCursorPosition, - testLocalStorage : testLocalStorage, - hasLocalStorage : testLocalStorage(), - // some internal variables - isIOS : ((navigator.userAgent.toLowerCase().indexOf('iphone') !== -1 || - navigator.userAgent.toLowerCase().indexOf('ipod') !== -1 || - navigator.userAgent.toLowerCase().indexOf('ipad') !== -1 || - navigator.userAgent.toLowerCase().indexOf('mobile') !== -1 || - navigator.userAgent.toLowerCase().indexOf('android') !== -1) - ? true : false), - isIE : ((navigator.userAgent.toLowerCase().indexOf('msie') !== -1 || - navigator.userAgent.toLowerCase().indexOf('trident') !== -1 ) - ? true : false) - }; - return obj; - - function isBin (val) { - var re = /^[0-1]+$/; - return re.test(val); - } - - function isInt (val) { - var re = /^[-+]?[0-9]+$/; - return re.test(val); - } - - function isFloat (val) { - if (typeof val === 'string') val = val.replace(/\s+/g, '').replace(w2utils.settings.groupSymbol, '').replace(w2utils.settings.decimalSymbol, '.'); - return (typeof val === 'number' || (typeof val === 'string' && val !== '')) && !isNaN(Number(val)); - } - - function isMoney (val) { - var se = w2utils.settings; - var re = new RegExp('^'+ (se.currencyPrefix ? '\\' + se.currencyPrefix + '?' : '') + - '[-+]?'+ (se.currencyPrefix ? '\\' + se.currencyPrefix + '?' : '') + - '[0-9]*[\\'+ se.decimalSymbol +']?[0-9]+'+ (se.currencySuffix ? '\\' + se.currencySuffix + '?' : '') +'$', 'i'); - if (typeof val === 'string') { - val = val.replace(new RegExp(se.groupSymbol, 'g'), ''); - } - if (typeof val === 'object' || val === '') return false; - return re.test(val); - } - - function isHex (val) { - var re = /^(0x)?[0-9a-fA-F]+$/; - return re.test(val); - } - - function isAlphaNumeric (val) { - var re = /^[a-zA-Z0-9_-]+$/; - return re.test(val); - } - - function isEmail (val) { - var email = /^[a-zA-Z0-9._%\-+]+@[а-яА-Яa-zA-Z0-9.-]+\.[а-яА-Яa-zA-Z]+$/; - return email.test(val); - } - - function isIpAddress (val) { - var re = new RegExp('^' + - '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}' + - '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + - '$'); - return re.test(val); - } - - function isDate (val, format, retDate) { - if (!val) return false; - - var dt = 'Invalid Date'; - var month, day, year; - - if (format == null) format = w2utils.settings.dateFormat; - - if (typeof val.getFullYear === 'function') { // date object - year = val.getFullYear(); - month = val.getMonth() + 1; - day = val.getDate(); - } else if (parseInt(val) == val && parseInt(val) > 0) { - val = new Date(parseInt(val)); - year = val.getFullYear(); - month = val.getMonth() + 1; - day = val.getDate(); - } else { - val = String(val); - // convert month formats - if (new RegExp('mon', 'ig').test(format)) { - format = format.replace(/month/ig, 'm').replace(/mon/ig, 'm').replace(/dd/ig, 'd').replace(/[, ]/ig, '/').replace(/\/\//g, '/').toLowerCase(); - val = val.replace(/[, ]/ig, '/').replace(/\/\//g, '/').toLowerCase(); - for (var m = 0, len = w2utils.settings.fullmonths.length; m < len; m++) { - var t = w2utils.settings.fullmonths[m]; - val = val.replace(new RegExp(t, 'ig'), (parseInt(m) + 1)).replace(new RegExp(t.substr(0, 3), 'ig'), (parseInt(m) + 1)); - } - } - // format date - var tmp = val.replace(/-/g, '/').replace(/\./g, '/').toLowerCase().split('/'); - var tmp2 = format.replace(/-/g, '/').replace(/\./g, '/').toLowerCase(); - if (tmp2 === 'mm/dd/yyyy') { month = tmp[0]; day = tmp[1]; year = tmp[2]; } - if (tmp2 === 'm/d/yyyy') { month = tmp[0]; day = tmp[1]; year = tmp[2]; } - if (tmp2 === 'dd/mm/yyyy') { month = tmp[1]; day = tmp[0]; year = tmp[2]; } - if (tmp2 === 'd/m/yyyy') { month = tmp[1]; day = tmp[0]; year = tmp[2]; } - if (tmp2 === 'yyyy/dd/mm') { month = tmp[2]; day = tmp[1]; year = tmp[0]; } - if (tmp2 === 'yyyy/d/m') { month = tmp[2]; day = tmp[1]; year = tmp[0]; } - if (tmp2 === 'yyyy/mm/dd') { month = tmp[1]; day = tmp[2]; year = tmp[0]; } - if (tmp2 === 'yyyy/m/d') { month = tmp[1]; day = tmp[2]; year = tmp[0]; } - if (tmp2 === 'mm/dd/yy') { month = tmp[0]; day = tmp[1]; year = tmp[2]; } - if (tmp2 === 'm/d/yy') { month = tmp[0]; day = tmp[1]; year = parseInt(tmp[2]) + 1900; } - if (tmp2 === 'dd/mm/yy') { month = tmp[1]; day = tmp[0]; year = parseInt(tmp[2]) + 1900; } - if (tmp2 === 'd/m/yy') { month = tmp[1]; day = tmp[0]; year = parseInt(tmp[2]) + 1900; } - if (tmp2 === 'yy/dd/mm') { month = tmp[2]; day = tmp[1]; year = parseInt(tmp[0]) + 1900; } - if (tmp2 === 'yy/d/m') { month = tmp[2]; day = tmp[1]; year = parseInt(tmp[0]) + 1900; } - if (tmp2 === 'yy/mm/dd') { month = tmp[1]; day = tmp[2]; year = parseInt(tmp[0]) + 1900; } - if (tmp2 === 'yy/m/d') { month = tmp[1]; day = tmp[2]; year = parseInt(tmp[0]) + 1900; } - } - if (!isInt(year)) return false; - if (!isInt(month)) return false; - if (!isInt(day)) return false; - year = +year; - month = +month; - day = +day; - dt = new Date(year, month - 1, day); - dt.setFullYear(year); - // do checks - if (month == null) return false; - if (String(dt) === 'Invalid Date') return false; - if ((dt.getMonth() + 1 !== month) || (dt.getDate() !== day) || (dt.getFullYear() !== year)) return false; - if (retDate === true) return dt; else return true; - } - - function isTime (val, retTime) { - // Both formats 10:20pm and 22:20 - if (val == null) return false; - var max, am, pm; - // -- process american format - val = String(val); - val = val.toUpperCase(); - am = val.indexOf('AM') >= 0; - pm = val.indexOf('PM') >= 0; - var ampm = (pm || am); - if (ampm) max = 12; else max = 24; - val = val.replace('AM', '').replace('PM', ''); - val = $.trim(val); - // --- - var tmp = val.split(':'); - var h = parseInt(tmp[0] || 0), m = parseInt(tmp[1] || 0), s = parseInt(tmp[2] || 0); - // accept edge case: 3PM is a good timestamp, but 3 (without AM or PM) is NOT: - if ((!ampm || tmp.length !== 1) && tmp.length !== 2 && tmp.length !== 3) { return false; } - if (tmp[0] === '' || h < 0 || h > max || !this.isInt(tmp[0]) || tmp[0].length > 2) { return false; } - if (tmp.length > 1 && (tmp[1] === '' || m < 0 || m > 59 || !this.isInt(tmp[1]) || tmp[1].length !== 2)) { return false; } - if (tmp.length > 2 && (tmp[2] === '' || s < 0 || s > 59 || !this.isInt(tmp[2]) || tmp[2].length !== 2)) { return false; } - // check the edge cases: 12:01AM is ok, as is 12:01PM, but 24:01 is NOT ok while 24:00 is (midnight; equivalent to 00:00). - // meanwhile, there is 00:00 which is ok, but 0AM nor 0PM are okay, while 0:01AM and 0:00AM are. - if (!ampm && max === h && (m !== 0 || s !== 0)) { return false; } - if (ampm && tmp.length === 1 && h === 0) { return false; } - - if (retTime === true) { - if (pm && h !== 12) h += 12; // 12:00pm - is noon - if (am && h === 12) h += 12; // 12:00am - is midnight - return { - hours: h, - minutes: m, - seconds: s - }; - } - return true; - } - - function isDateTime (val, format, retDate) { - if (typeof val.getFullYear === 'function') { // date object - if (retDate !== true) return true; - return val; - } - var intVal = parseInt(val); - if (intVal === val) { - if (intVal < 0) return false; - else if (retDate !== true) return true; - else return new Date(intVal); - } - var tmp = String(val).indexOf(' '); - if (tmp < 0) { - if (String(val).indexOf('T') < 0 || String(new Date(val)) == 'Invalid Date') return false; - else if (retDate !== true) return true; - else return new Date(val); - } else { - if (format == null) format = w2utils.settings.datetimeFormat; - var formats = format.split('|'); - var values = [val.substr(0, tmp), val.substr(tmp).trim()]; - formats[0] = formats[0].trim(); - if (formats[1]) formats[1] = formats[1].trim(); - // check - var tmp1 = w2utils.isDate(values[0], formats[0], true); - var tmp2 = w2utils.isTime(values[1], true); - if (tmp1 !== false && tmp2 !== false) { - if (retDate !== true) return true; - tmp1.setHours(tmp2.hours); - tmp1.setMinutes(tmp2.minutes); - tmp1.setSeconds(tmp2.seconds); - return tmp1; - } else { - return false; - } - } - } - - function age(dateStr) { - var d1; - if (dateStr === '' || dateStr == null) return ''; - if (typeof dateStr.getFullYear === 'function') { // date object - d1 = dateStr; - } else if (parseInt(dateStr) == dateStr && parseInt(dateStr) > 0) { - d1 = new Date(parseInt(dateStr)); - } else { - d1 = new Date(dateStr); - } - if (String(d1) === 'Invalid Date') return ''; - - var d2 = new Date(); - var sec = (d2.getTime() - d1.getTime()) / 1000; - var amount = ''; - var type = ''; - if (sec < 0) { - amount = 0; - type = 'sec'; - } else if (sec < 60) { - amount = Math.floor(sec); - type = 'sec'; - if (sec < 0) { amount = 0; type = 'sec'; } - } else if (sec < 60*60) { - amount = Math.floor(sec/60); - type = 'min'; - } else if (sec < 24*60*60) { - amount = Math.floor(sec/60/60); - type = 'hour'; - } else if (sec < 30*24*60*60) { - amount = Math.floor(sec/24/60/60); - type = 'day'; - } else if (sec < 365*24*60*60) { - amount = Math.floor(sec/30/24/60/60*10)/10; - type = 'month'; - } else if (sec < 365*4*24*60*60) { - amount = Math.floor(sec/365/24/60/60*10)/10; - type = 'year'; - } else if (sec >= 365*4*24*60*60) { - // factor in leap year shift (only older then 4 years) - amount = Math.floor(sec/365.25/24/60/60*10)/10; - type = 'year'; - } - return amount + ' ' + type + (amount > 1 ? 's' : ''); - } - - function interval (value) { - var ret = ''; - if (value < 1000) { - ret = "< 1 sec"; - } else if (value < 60000) { - ret = Math.floor(value / 1000) + " secs"; - } else if (value < 3600000) { - ret = Math.floor(value / 60000) + " mins"; - } else if (value < 86400000) { - ret = Math.floor(value / 3600000 * 10) / 10 + " hours"; - } else if (value < 2628000000) { - ret = Math.floor(value / 86400000 * 10) / 10 + " days"; - } else if (value < 3.1536e+10) { - ret = Math.floor(value / 2628000000 * 10) / 10 + " months"; - } else { - ret = Math.floor(value / 3.1536e+9) / 10 + " years"; - } - return ret; - } - - function date (dateStr) { - if (dateStr === '' || dateStr == null || (typeof dateStr === 'object' && !dateStr.getMonth)) return ''; - var d1 = new Date(dateStr); - if (w2utils.isInt(dateStr)) d1 = new Date(Number(dateStr)); // for unix timestamps - if (String(d1) === 'Invalid Date') return ''; - - var months = w2utils.settings.shortmonths; - var d2 = new Date(); // today - var d3 = new Date(); - d3.setTime(d3.getTime() - 86400000); // yesterday - - var dd1 = months[d1.getMonth()] + ' ' + d1.getDate() + ', ' + d1.getFullYear(); - var dd2 = months[d2.getMonth()] + ' ' + d2.getDate() + ', ' + d2.getFullYear(); - var dd3 = months[d3.getMonth()] + ' ' + d3.getDate() + ', ' + d3.getFullYear(); - - var time = (d1.getHours() - (d1.getHours() > 12 ? 12 :0)) + ':' + (d1.getMinutes() < 10 ? '0' : '') + d1.getMinutes() + ' ' + (d1.getHours() >= 12 ? 'pm' : 'am'); - var time2= (d1.getHours() - (d1.getHours() > 12 ? 12 :0)) + ':' + (d1.getMinutes() < 10 ? '0' : '') + d1.getMinutes() + ':' + (d1.getSeconds() < 10 ? '0' : '') + d1.getSeconds() + ' ' + (d1.getHours() >= 12 ? 'pm' : 'am'); - var dsp = dd1; - if (dd1 === dd2) dsp = time; - if (dd1 === dd3) dsp = w2utils.lang('Yesterday'); - - return ''+ dsp +''; - } - - function formatSize (sizeStr) { - if (!w2utils.isFloat(sizeStr) || sizeStr === '') return ''; - sizeStr = parseFloat(sizeStr); - if (sizeStr === 0) return 0; - var sizes = ['Bt', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB']; - var i = parseInt( Math.floor( Math.log(sizeStr) / Math.log(1024) ) ); - return (Math.floor(sizeStr / Math.pow(1024, i) * 10) / 10).toFixed(i === 0 ? 0 : 1) + ' ' + (sizes[i] || '??'); - } - - function formatNumber (val, fraction, useGrouping) { - if (val == null || val === '' || typeof val === 'object') return ''; - var options = { - minimumFractionDigits : fraction, - maximumFractionDigits : fraction, - useGrouping : useGrouping - }; - if (fraction == null || fraction < 0) { - options.minimumFractionDigits = 0; - options.maximumFractionDigits = 20; - } - return parseFloat(val).toLocaleString(w2utils.settings.locale, options); - } - - function formatDate (dateStr, format) { // IMPORTANT dateStr HAS TO BE valid JavaScript Date String - if (!format) format = this.settings.dateFormat; - if (dateStr === '' || dateStr == null || (typeof dateStr === 'object' && !dateStr.getMonth)) return ''; - - var dt = new Date(dateStr); - if (w2utils.isInt(dateStr)) dt = new Date(Number(dateStr)); // for unix timestamps - if (String(dt) === 'Invalid Date') return ''; - - var year = dt.getFullYear(); - var month = dt.getMonth(); - var date = dt.getDate(); - return format.toLowerCase() - .replace('month', w2utils.settings.fullmonths[month]) - .replace('mon', w2utils.settings.shortmonths[month]) - .replace(/yyyy/g, ('000' + year).slice(-4)) - .replace(/yyy/g, ('000' + year).slice(-4)) - .replace(/yy/g, ('0' + year).slice(-2)) - .replace(/(^|[^a-z$])y/g, '$1' + year) // only y's that are not preceded by a letter - .replace(/mm/g, ('0' + (month + 1)).slice(-2)) - .replace(/dd/g, ('0' + date).slice(-2)) - .replace(/th/g, (date == 1 ? 'st' : 'th')) - .replace(/th/g, (date == 2 ? 'nd' : 'th')) - .replace(/th/g, (date == 3 ? 'rd' : 'th')) - .replace(/(^|[^a-z$])m/g, '$1' + (month + 1)) // only y's that are not preceded by a letter - .replace(/(^|[^a-z$])d/g, '$1' + date); // only y's that are not preceded by a letter - } - - function formatTime (dateStr, format) { // IMPORTANT dateStr HAS TO BE valid JavaScript Date String - var months = w2utils.settings.shortmonths; - var fullMonths = w2utils.settings.fullmonths; - if (!format) format = this.settings.timeFormat; - if (dateStr === '' || dateStr == null || (typeof dateStr === 'object' && !dateStr.getMonth)) return ''; - - var dt = new Date(dateStr); - if (w2utils.isInt(dateStr)) dt = new Date(Number(dateStr)); // for unix timestamps - if (w2utils.isTime(dateStr)) { - var tmp = w2utils.isTime(dateStr, true); - dt = new Date(); - dt.setHours(tmp.hours); - dt.setMinutes(tmp.minutes); - } - if (String(dt) === 'Invalid Date') return ''; - - var type = 'am'; - var hour = dt.getHours(); - var h24 = dt.getHours(); - var min = dt.getMinutes(); - var sec = dt.getSeconds(); - if (min < 10) min = '0' + min; - if (sec < 10) sec = '0' + sec; - if (format.indexOf('am') !== -1 || format.indexOf('pm') !== -1) { - if (hour >= 12) type = 'pm'; - if (hour > 12) hour = hour - 12; - if (hour === 0) hour = 12; - } - return format.toLowerCase() - .replace('am', type) - .replace('pm', type) - .replace('hhh', (hour < 10 ? '0' + hour : hour)) - .replace('hh24', (h24 < 10 ? '0' + h24 : h24)) - .replace('h24', h24) - .replace('hh', hour) - .replace('mm', min) - .replace('mi', min) - .replace('ss', sec) - .replace(/(^|[^a-z$])h/g, '$1' + hour) // only y's that are not preceded by a letter - .replace(/(^|[^a-z$])m/g, '$1' + min) // only y's that are not preceded by a letter - .replace(/(^|[^a-z$])s/g, '$1' + sec); // only y's that are not preceded by a letter - } - - function formatDateTime(dateStr, format) { - var fmt; - if (dateStr === '' || dateStr == null || (typeof dateStr === 'object' && !dateStr.getMonth)) return ''; - if (typeof format !== 'string') { - fmt = [this.settings.dateFormat, this.settings.timeFormat]; - } else { - fmt = format.split('|'); - fmt[0] = fmt[0].trim(); - fmt[1] = (fmt.length > 1 ? fmt[1].trim() : this.settings.timeFormat); - } - // older formats support - if (fmt[1] === 'h12') fmt[1] = 'h:m pm'; - if (fmt[1] === 'h24') fmt[1] = 'h24:m'; - return this.formatDate(dateStr, fmt[0]) + ' ' + this.formatTime(dateStr, fmt[1]); - } - - function stripTags (html) { - if (html == null) return html; - switch (typeof html) { - case 'number': - break; - case 'string': - html = String(html).replace(/<(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*>/ig, ""); - break; - case 'object': - // does not modify original object, but creates a copy - if (Array.isArray(html)) { - html = $.extend(true, [], html); - for (var i = 0; i < html.length; i++) html[i] = this.stripTags(html[i]); - } else { - html = $.extend(true, {}, html); - for (var i in html) html[i] = this.stripTags(html[i]); - } - break; - } - return html; - } - - function encodeTags (html) { - if (html == null) return html; - switch (typeof html) { - case 'number': - break; - case 'string': - html = String(html).replace(/&/g, "&").replace(/>/g, ">").replace(/").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&"); - break; - case 'object': - // does not modify original object, but creates a copy - if (Array.isArray(html)) { - html = $.extend(true, [], html); - for (var i = 0; i < html.length; i++) html[i] = this.decodeTags(html[i]); - } else { - html = $.extend(true, {}, html); - for (var i in html) html[i] = this.decodeTags(html[i]); - } - break; - } - return html; - } - - function escapeId (id) { - if (id === '' || id == null) return ''; - return String(id).replace(/([;&,\.\+\*\~'`:"\!\^#$%@\[\]\(\)=<>\|\/? {}\\])/g, '\\$1'); - } - - function base64encode (input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - input = utf8_encode(input); - - while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); - } - - function utf8_encode (string) { - string = String(string).replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - var c = string.charCodeAt(n); - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - return utftext; - } - - return output; - } - - function base64decode (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - enc1 = keyStr.indexOf(input.charAt(i++)); - enc2 = keyStr.indexOf(input.charAt(i++)); - enc3 = keyStr.indexOf(input.charAt(i++)); - enc4 = keyStr.indexOf(input.charAt(i++)); - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - output = output + String.fromCharCode(chr1); - if (enc3 !== 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 !== 64) { - output = output + String.fromCharCode(chr3); - } - } - output = utf8_decode(output); - - function utf8_decode (utftext) { - var string = ""; - var i = 0; - var c = 0, c2, c3; - - while ( i < utftext.length ) { - c = utftext.charCodeAt(i); - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - } - - return string; - } - - return output; - } - - function md5(input) { - /* - * Based on http://pajhome.org.uk/crypt/md5 - */ - - var hexcase = 0; - var b64pad = ""; - - function __pj_crypt_hex_md5(s) { - return __pj_crypt_rstr2hex(__pj_crypt_rstr_md5(__pj_crypt_str2rstr_utf8(s))); - } - function __pj_crypt_b64_md5(s) { - return __pj_crypt_rstr2b64(__pj_crypt_rstr_md5(__pj_crypt_str2rstr_utf8(s))); - } - function __pj_crypt_any_md5(s, e) { - return __pj_crypt_rstr2any(__pj_crypt_rstr_md5(__pj_crypt_str2rstr_utf8(s)), e); - } - function __pj_crypt_hex_hmac_md5(k, d) - { - return __pj_crypt_rstr2hex(__pj_crypt_rstr_hmac_md5(__pj_crypt_str2rstr_utf8(k), __pj_crypt_str2rstr_utf8(d))); - } - function __pj_crypt_b64_hmac_md5(k, d) - { - return __pj_crypt_rstr2b64(__pj_crypt_rstr_hmac_md5(__pj_crypt_str2rstr_utf8(k), __pj_crypt_str2rstr_utf8(d))); - } - function __pj_crypt_any_hmac_md5(k, d, e) - { - return __pj_crypt_rstr2any(__pj_crypt_rstr_hmac_md5(__pj_crypt_str2rstr_utf8(k), __pj_crypt_str2rstr_utf8(d)), e); - } - - /* - * Calculate the MD5 of a raw string - */ - function __pj_crypt_rstr_md5(s) - { - return __pj_crypt_binl2rstr(__pj_crypt_binl_md5(__pj_crypt_rstr2binl(s), s.length * 8)); - } - - /* - * Calculate the HMAC-MD5, of a key and some data (raw strings) - */ - function __pj_crypt_rstr_hmac_md5(key, data) - { - var bkey = __pj_crypt_rstr2binl(key); - if (bkey.length > 16) - bkey = __pj_crypt_binl_md5(bkey, key.length * 8); - - var ipad = Array(16), opad = Array(16); - for (var i = 0; i < 16; i++) - { - ipad[i] = bkey[i] ^ 0x36363636; - opad[i] = bkey[i] ^ 0x5C5C5C5C; - } - - var hash = __pj_crypt_binl_md5(ipad.concat(__pj_crypt_rstr2binl(data)), 512 + data.length * 8); - return __pj_crypt_binl2rstr(__pj_crypt_binl_md5(opad.concat(hash), 512 + 128)); - } - - /* - * Convert a raw string to a hex string - */ - function __pj_crypt_rstr2hex(input) - { - try { - hexcase - } catch (e) { - hexcase = 0; - } - var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; - var output = ""; - var x; - for (var i = 0; i < input.length; i++) - { - x = input.charCodeAt(i); - output += hex_tab.charAt((x >>> 4) & 0x0F) - + hex_tab.charAt(x & 0x0F); - } - return output; - } - - /* - * Convert a raw string to a base-64 string - */ - function __pj_crypt_rstr2b64(input) - { - try { - b64pad - } catch (e) { - b64pad = ''; - } - var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - var output = ""; - var len = input.length; - for (var i = 0; i < len; i += 3) - { - var triplet = (input.charCodeAt(i) << 16) - | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) - | (i + 2 < len ? input.charCodeAt(i + 2) : 0); - for (var j = 0; j < 4; j++) - { - if (i * 8 + j * 6 > input.length * 8) - output += b64pad; - else - output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F); - } - } - return output; - } - - /* - * Convert a raw string to an arbitrary string encoding - */ - function __pj_crypt_rstr2any(input, encoding) - { - var divisor = encoding.length; - var i, j, q, x, quotient; - - /* Convert to an array of 16-bit big-endian values, forming the dividend */ - var dividend = Array(Math.ceil(input.length / 2)); - for (i = 0; i < dividend.length; i++) - { - dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); - } - - /* - * Repeatedly perform a long division. The binary array forms the dividend, - * the length of the encoding is the divisor. Once computed, the quotient - * forms the dividend for the next step. All remainders are stored for later - * use. - */ - var full_length = Math.ceil(input.length * 8 / - (Math.log(encoding.length) / Math.log(2))); - var remainders = Array(full_length); - for (j = 0; j < full_length; j++) - { - quotient = Array(); - x = 0; - for (i = 0; i < dividend.length; i++) - { - x = (x << 16) + dividend[i]; - q = Math.floor(x / divisor); - x -= q * divisor; - if (quotient.length > 0 || q > 0) - quotient[quotient.length] = q; - } - remainders[j] = x; - dividend = quotient; - } - - /* Convert the remainders to the output string */ - var output = ""; - for (i = remainders.length - 1; i >= 0; i--) - output += encoding.charAt(remainders[i]); - - return output; - } - - /* - * Encode a string as utf-8. - * For efficiency, this assumes the input is valid utf-16. - */ - function __pj_crypt_str2rstr_utf8(input) - { - var output = ""; - var i = -1; - var x, y; - - while (++i < input.length) - { - /* Decode utf-16 surrogate pairs */ - x = input.charCodeAt(i); - y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; - if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) - { - x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); - i++; - } - - /* Encode output as utf-8 */ - if (x <= 0x7F) - output += String.fromCharCode(x); - else if (x <= 0x7FF) - output += String.fromCharCode(0xC0 | ((x >>> 6) & 0x1F), - 0x80 | (x & 0x3F)); - else if (x <= 0xFFFF) - output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), - 0x80 | ((x >>> 6) & 0x3F), - 0x80 | (x & 0x3F)); - else if (x <= 0x1FFFFF) - output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), - 0x80 | ((x >>> 12) & 0x3F), - 0x80 | ((x >>> 6) & 0x3F), - 0x80 | (x & 0x3F)); - } - return output; - } - - /* - * Encode a string as utf-16 - */ - function __pj_crypt_str2rstr_utf16le(input) - { - var output = ""; - for (var i = 0; i < input.length; i++) - output += String.fromCharCode(input.charCodeAt(i) & 0xFF, - (input.charCodeAt(i) >>> 8) & 0xFF); - return output; - } - - function __pj_crypt_str2rstr_utf16be(input) - { - var output = ""; - for (var i = 0; i < input.length; i++) - output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, - input.charCodeAt(i) & 0xFF); - return output; - } - - /* - * Convert a raw string to an array of little-endian words - * Characters >255 have their high-byte silently ignored. - */ - function __pj_crypt_rstr2binl(input) - { - var output = Array(input.length >> 2); - for (var i = 0; i < output.length; i++) - output[i] = 0; - for (var i = 0; i < input.length * 8; i += 8) - output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32); - return output; - } - - /* - * Convert an array of little-endian words to a string - */ - function __pj_crypt_binl2rstr(input) - { - var output = ""; - for (var i = 0; i < input.length * 32; i += 8) - output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF); - return output; - } - - /* - * Calculate the MD5 of an array of little-endian words, and a bit length. - */ - function __pj_crypt_binl_md5(x, len) - { - /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); - x[(((len + 64) >>> 9) << 4) + 14] = len; - - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - - for (var i = 0; i < x.length; i += 16) - { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - - a = __pj_crypt_md5_ff(a, b, c, d, x[i + 0], 7, -680876936); - d = __pj_crypt_md5_ff(d, a, b, c, x[i + 1], 12, -389564586); - c = __pj_crypt_md5_ff(c, d, a, b, x[i + 2], 17, 606105819); - b = __pj_crypt_md5_ff(b, c, d, a, x[i + 3], 22, -1044525330); - a = __pj_crypt_md5_ff(a, b, c, d, x[i + 4], 7, -176418897); - d = __pj_crypt_md5_ff(d, a, b, c, x[i + 5], 12, 1200080426); - c = __pj_crypt_md5_ff(c, d, a, b, x[i + 6], 17, -1473231341); - b = __pj_crypt_md5_ff(b, c, d, a, x[i + 7], 22, -45705983); - a = __pj_crypt_md5_ff(a, b, c, d, x[i + 8], 7, 1770035416); - d = __pj_crypt_md5_ff(d, a, b, c, x[i + 9], 12, -1958414417); - c = __pj_crypt_md5_ff(c, d, a, b, x[i + 10], 17, -42063); - b = __pj_crypt_md5_ff(b, c, d, a, x[i + 11], 22, -1990404162); - a = __pj_crypt_md5_ff(a, b, c, d, x[i + 12], 7, 1804603682); - d = __pj_crypt_md5_ff(d, a, b, c, x[i + 13], 12, -40341101); - c = __pj_crypt_md5_ff(c, d, a, b, x[i + 14], 17, -1502002290); - b = __pj_crypt_md5_ff(b, c, d, a, x[i + 15], 22, 1236535329); - - a = __pj_crypt_md5_gg(a, b, c, d, x[i + 1], 5, -165796510); - d = __pj_crypt_md5_gg(d, a, b, c, x[i + 6], 9, -1069501632); - c = __pj_crypt_md5_gg(c, d, a, b, x[i + 11], 14, 643717713); - b = __pj_crypt_md5_gg(b, c, d, a, x[i + 0], 20, -373897302); - a = __pj_crypt_md5_gg(a, b, c, d, x[i + 5], 5, -701558691); - d = __pj_crypt_md5_gg(d, a, b, c, x[i + 10], 9, 38016083); - c = __pj_crypt_md5_gg(c, d, a, b, x[i + 15], 14, -660478335); - b = __pj_crypt_md5_gg(b, c, d, a, x[i + 4], 20, -405537848); - a = __pj_crypt_md5_gg(a, b, c, d, x[i + 9], 5, 568446438); - d = __pj_crypt_md5_gg(d, a, b, c, x[i + 14], 9, -1019803690); - c = __pj_crypt_md5_gg(c, d, a, b, x[i + 3], 14, -187363961); - b = __pj_crypt_md5_gg(b, c, d, a, x[i + 8], 20, 1163531501); - a = __pj_crypt_md5_gg(a, b, c, d, x[i + 13], 5, -1444681467); - d = __pj_crypt_md5_gg(d, a, b, c, x[i + 2], 9, -51403784); - c = __pj_crypt_md5_gg(c, d, a, b, x[i + 7], 14, 1735328473); - b = __pj_crypt_md5_gg(b, c, d, a, x[i + 12], 20, -1926607734); - - a = __pj_crypt_md5_hh(a, b, c, d, x[i + 5], 4, -378558); - d = __pj_crypt_md5_hh(d, a, b, c, x[i + 8], 11, -2022574463); - c = __pj_crypt_md5_hh(c, d, a, b, x[i + 11], 16, 1839030562); - b = __pj_crypt_md5_hh(b, c, d, a, x[i + 14], 23, -35309556); - a = __pj_crypt_md5_hh(a, b, c, d, x[i + 1], 4, -1530992060); - d = __pj_crypt_md5_hh(d, a, b, c, x[i + 4], 11, 1272893353); - c = __pj_crypt_md5_hh(c, d, a, b, x[i + 7], 16, -155497632); - b = __pj_crypt_md5_hh(b, c, d, a, x[i + 10], 23, -1094730640); - a = __pj_crypt_md5_hh(a, b, c, d, x[i + 13], 4, 681279174); - d = __pj_crypt_md5_hh(d, a, b, c, x[i + 0], 11, -358537222); - c = __pj_crypt_md5_hh(c, d, a, b, x[i + 3], 16, -722521979); - b = __pj_crypt_md5_hh(b, c, d, a, x[i + 6], 23, 76029189); - a = __pj_crypt_md5_hh(a, b, c, d, x[i + 9], 4, -640364487); - d = __pj_crypt_md5_hh(d, a, b, c, x[i + 12], 11, -421815835); - c = __pj_crypt_md5_hh(c, d, a, b, x[i + 15], 16, 530742520); - b = __pj_crypt_md5_hh(b, c, d, a, x[i + 2], 23, -995338651); - - a = __pj_crypt_md5_ii(a, b, c, d, x[i + 0], 6, -198630844); - d = __pj_crypt_md5_ii(d, a, b, c, x[i + 7], 10, 1126891415); - c = __pj_crypt_md5_ii(c, d, a, b, x[i + 14], 15, -1416354905); - b = __pj_crypt_md5_ii(b, c, d, a, x[i + 5], 21, -57434055); - a = __pj_crypt_md5_ii(a, b, c, d, x[i + 12], 6, 1700485571); - d = __pj_crypt_md5_ii(d, a, b, c, x[i + 3], 10, -1894986606); - c = __pj_crypt_md5_ii(c, d, a, b, x[i + 10], 15, -1051523); - b = __pj_crypt_md5_ii(b, c, d, a, x[i + 1], 21, -2054922799); - a = __pj_crypt_md5_ii(a, b, c, d, x[i + 8], 6, 1873313359); - d = __pj_crypt_md5_ii(d, a, b, c, x[i + 15], 10, -30611744); - c = __pj_crypt_md5_ii(c, d, a, b, x[i + 6], 15, -1560198380); - b = __pj_crypt_md5_ii(b, c, d, a, x[i + 13], 21, 1309151649); - a = __pj_crypt_md5_ii(a, b, c, d, x[i + 4], 6, -145523070); - d = __pj_crypt_md5_ii(d, a, b, c, x[i + 11], 10, -1120210379); - c = __pj_crypt_md5_ii(c, d, a, b, x[i + 2], 15, 718787259); - b = __pj_crypt_md5_ii(b, c, d, a, x[i + 9], 21, -343485551); - - a = __pj_crypt_safe_add(a, olda); - b = __pj_crypt_safe_add(b, oldb); - c = __pj_crypt_safe_add(c, oldc); - d = __pj_crypt_safe_add(d, oldd); - } - return Array(a, b, c, d); - } - - /* - * These functions implement the four basic operations the algorithm uses. - */ - function __pj_crypt_md5_cmn(q, a, b, x, s, t) - { - return __pj_crypt_safe_add(__pj_crypt_bit_rol(__pj_crypt_safe_add(__pj_crypt_safe_add(a, q), __pj_crypt_safe_add(x, t)), s), b); - } - function __pj_crypt_md5_ff(a, b, c, d, x, s, t) - { - return __pj_crypt_md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); - } - function __pj_crypt_md5_gg(a, b, c, d, x, s, t) - { - return __pj_crypt_md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); - } - function __pj_crypt_md5_hh(a, b, c, d, x, s, t) - { - return __pj_crypt_md5_cmn(b ^ c ^ d, a, b, x, s, t); - } - function __pj_crypt_md5_ii(a, b, c, d, x, s, t) - { - return __pj_crypt_md5_cmn(c ^ (b | (~d)), a, b, x, s, t); - } - - /* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ - function __pj_crypt_safe_add(x, y) - { - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); - } - - /* - * Bitwise rotate a 32-bit number to the left. - */ - function __pj_crypt_bit_rol(num, cnt) - { - return (num << cnt) | (num >>> (32 - cnt)); - } - - return __pj_crypt_hex_md5(input); - - } - - function transition (div_old, div_new, type, callBack) { - var width = $(div_old).width(); - var height = $(div_old).height(); - var time = 0.5; - - if (!div_old || !div_new) { - console.log('ERROR: Cannot do transition when one of the divs is null'); - return; - } - - div_old.parentNode.style.cssText += 'perspective: 900px; overflow: hidden;'; - div_old.style.cssText += '; position: absolute; z-index: 1019; backface-visibility: hidden'; - div_new.style.cssText += '; position: absolute; z-index: 1020; backface-visibility: hidden'; - - switch (type) { - case 'slide-left': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; transform: translate3d('+ width + 'px, 0, 0)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: translate3d(0, 0, 0)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: translate3d(-'+ width +'px, 0, 0)'; - }, 1); - break; - - case 'slide-right': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; transform: translate3d(-'+ width +'px, 0, 0)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: translate3d(0px, 0, 0)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: translate3d('+ width +'px, 0, 0)'; - }, 1); - break; - - case 'slide-down': - // init divs - div_old.style.cssText += 'overflow: hidden; z-index: 1; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; z-index: 0; transform: translate3d(0, 0, 0)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: translate3d(0, 0, 0)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: translate3d(0, '+ height +'px, 0)'; - }, 1); - break; - - case 'slide-up': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; transform: translate3d(0, '+ height +'px, 0)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: translate3d(0, 0, 0)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: translate3d(0, 0, 0)'; - }, 1); - break; - - case 'flip-left': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: rotateY(0deg)'; - div_new.style.cssText += 'overflow: hidden; transform: rotateY(-180deg)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: rotateY(0deg)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: rotateY(180deg)'; - }, 1); - break; - - case 'flip-right': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: rotateY(0deg)'; - div_new.style.cssText += 'overflow: hidden; transform: rotateY(180deg)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: rotateY(0deg)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: rotateY(-180deg)'; - }, 1); - break; - - case 'flip-down': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: rotateX(0deg)'; - div_new.style.cssText += 'overflow: hidden; transform: rotateX(180deg)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: rotateX(0deg)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: rotateX(-180deg)'; - }, 1); - break; - - case 'flip-up': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: rotateX(0deg)'; - div_new.style.cssText += 'overflow: hidden; transform: rotateX(-180deg)'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: rotateX(0deg)'; - div_old.style.cssText += 'transition: '+ time +'s; transform: rotateX(180deg)'; - }, 1); - break; - - case 'pop-in': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(.8); opacity: 0;'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; transform: scale(1); opacity: 1;'; - div_old.style.cssText += 'transition: '+ time +'s;'; - }, 1); - break; - - case 'pop-out': - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(1); opacity: 1;'; - div_new.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0); opacity: 0;'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; opacity: 1;'; - div_old.style.cssText += 'transition: '+ time +'s; transform: scale(1.7); opacity: 0;'; - }, 1); - break; - - default: - // init divs - div_old.style.cssText += 'overflow: hidden; transform: translate3d(0, 0, 0)'; - div_new.style.cssText += 'overflow: hidden; translate3d(0, 0, 0); opacity: 0;'; - $(div_new).show(); - // -- need a timing function because otherwise not working - window.setTimeout(function() { - div_new.style.cssText += 'transition: '+ time +'s; opacity: 1;'; - div_old.style.cssText += 'transition: '+ time +'s'; - }, 1); - break; - } - - setTimeout(function () { - if (type === 'slide-down') { - $(div_old).css('z-index', '1019'); - $(div_new).css('z-index', '1020'); - } - if (div_new) { - $(div_new).css({ 'opacity': '1' }).css(w2utils.cssPrefix({ - 'transition': '', - 'transform' : '' - })); - } - if (div_old) { - $(div_old).css({ 'opacity': '1' }).css(w2utils.cssPrefix({ - 'transition': '', - 'transform' : '' - })); - } - if (typeof callBack === 'function') callBack(); - }, time * 1000); - } - - function lock (box, msg, spinner) { - var options = {}; - if (typeof msg === 'object') { - options = msg; - } else { - options.msg = msg; - options.spinner = spinner; - } - if (!options.msg && options.msg !== 0) options.msg = ''; - w2utils.unlock(box); - $(box).prepend( - '
'+ - '
' - ); - var $lock = $(box).find('.w2ui-lock'); - var mess = $(box).find('.w2ui-lock-msg'); - if (!options.msg) mess.css({ 'background-color': 'transparent', 'border': '0px' }); - if (options.spinner === true) options.msg = '
' + options.msg; - if (options.opacity != null) $lock.css('opacity', options.opacity); - if (typeof $lock.fadeIn === 'function') { - $lock.fadeIn(200); - mess.html(options.msg).fadeIn(200); - } else { - $lock.show(); - mess.html(options.msg).show(0); - } - } - - function unlock (box, speed) { - if (isInt(speed)) { - $(box).find('.w2ui-lock').fadeOut(speed); - setTimeout(function () { - $(box).find('.w2ui-lock').remove(); - $(box).find('.w2ui-lock-msg').remove(); - }, speed); - } else { - $(box).find('.w2ui-lock').remove(); - $(box).find('.w2ui-lock-msg').remove(); - } - } - - /** - * Used in w2popup, w2grid, w2form, w2layout - * should be called with .call(...) method - */ - - function message(where, options) { - var obj = this, closeTimer, edata; - // var where.path = 'w2popup'; - // var where.title = '.w2ui-popup-title'; - // var where.body = '.w2ui-box'; - $().w2tag(); // hide all tags - if (!options) options = { width: 200, height: 100 }; - if (options.on == null) $.extend(options, w2utils.event); - if (options.width == null) options.width = 200; - if (options.height == null) options.height = 100; - var pWidth = parseInt($(where.box).width()); - var pHeight = parseInt($(where.box).height()); - var titleHeight = parseInt($(where.box).find(where.title).css('height') || 0); - if (options.width > pWidth) options.width = pWidth - 10; - if (options.height > pHeight - titleHeight) options.height = pHeight - 10 - titleHeight; - options.originalWidth = options.width; - options.originalHeight = options.height; - if (parseInt(options.width) < 0) options.width = pWidth + options.width; - if (parseInt(options.width) < 10) options.width = 10; - if (parseInt(options.height) < 0) options.height = pHeight + options.height - titleHeight; - if (parseInt(options.height) < 10) options.height = 10; - if (options.hideOnClick == null) options.hideOnClick = false; - var poptions = $(where.box).data('options') || {}; - if (options.width == null || options.width > poptions.width - 10) { - options.width = poptions.width - 10; - } - if (options.height == null || options.height > poptions.height - titleHeight - 5) { - options.height = poptions.height - titleHeight - 5; // need margin from bottom only - } - // negative value means margin - if (options.originalHeight < 0) options.height = pHeight + options.originalHeight - titleHeight; - if (options.originalWidth < 0) options.width = pWidth + options.originalWidth * 2; // x 2 because there is left and right margin - var head = $(where.box).find(where.title); - - // if some messages are closing, insta close them - var $tmp = $(where.box).find('.w2ui-message.w2ui-closing'); - if ($(where.box).find('.w2ui-message.w2ui-closing').length > 0) { - clearTimeout(closeTimer); - closeCB($tmp, $tmp.data('options') || {}); - } - var msgCount = $(where.box).find('.w2ui-message').length; - // remove message - if ($.trim(options.html) === '' && $.trim(options.body) === '' && $.trim(options.buttons) === '') { - if (msgCount === 0) return; // no messages at all - var $msg = $(where.box).find('#w2ui-message'+ (msgCount-1)); - var options = $msg.data('options') || {}; - // before event - edata = options.trigger({ phase: 'before', type: 'close', target: 'self' }); - if (edata.isCancelled === true) return; - // default behavior - $msg.css(w2utils.cssPrefix({ - 'transition': '0.15s', - 'transform': 'translateY(-' + options.height + 'px)' - })).addClass('w2ui-closing'); - if (msgCount === 1) { - if (this.unlock) { - if (where.param) this.unlock(where.param, 150); else this.unlock(150); - } - } else { - $(where.box).find('#w2ui-message'+ (msgCount-2)).css('z-index', 1500); - } - closeTimer = setTimeout(function () { closeCB($msg, options); }, 150); - - } else { - - if ($.trim(options.body) !== '' || $.trim(options.buttons) !== '') { - options.html = '
'+ (options.body || '') +'
'+ - '
'+ (options.buttons || '') +'
'; - } - // hide previous messages - $(where.box).find('.w2ui-message').css('z-index', 1390); - head.data('old-z-index', head.css('z-index')); - head.css('z-index', 1501); - // add message - $(where.box).find(where.body) - .before(''); - $(where.box).find('#w2ui-message'+ msgCount) - .data('options', options) - .data('prev_focus', $(':focus')); - var display = $(where.box).find('#w2ui-message'+ msgCount).css('display'); - $(where.box).find('#w2ui-message'+ msgCount).css(w2utils.cssPrefix({ - 'transform': (display === 'none' ? 'translateY(-' + options.height + 'px)' : 'translateY(0px)') - })); - if (display === 'none') { - $(where.box).find('#w2ui-message'+ msgCount).show().html(options.html); - options.box = $(where.box).find('#w2ui-message'+ msgCount); - // before event - edata = options.trigger({ phase: 'before', type: 'open', target: 'self' }); - if (edata.isCancelled === true) { - head.css('z-index', head.data('old-z-index')); - $(where.box).find('#w2ui-message'+ msgCount).remove(); - return; - } - // timer needs to animation - setTimeout(function () { - $(where.box).find('#w2ui-message'+ msgCount).css(w2utils.cssPrefix({ - 'transform': (display === 'none' ? 'translateY(0px)' : 'translateY(-' + options.height + 'px)') - })); - }, 1); - // timer for lock - if (msgCount === 0 && this.lock) { - if (where.param) this.lock(where.param); else this.lock(); - } - setTimeout(function() { - // has to be on top of lock - $(where.box).find('#w2ui-message'+ msgCount).css(w2utils.cssPrefix({ 'transition': '0s' })); - // event after - options.trigger($.extend(edata, { phase: 'after' })); - }, 350); - } - } - - function closeCB($msg, options) { - if (edata == null) { - // before event - edata = options.trigger({ phase: 'before', type: 'open', target: 'self' }); - if (edata.isCancelled === true) { - head.css('z-index', head.data('old-z-index')); - $(where.box).find('#w2ui-message'+ msgCount).remove(); - return; - } - } - var $focus = $msg.data('prev_focus'); - $msg.remove(); - if ($focus && $focus.length > 0) { - $focus.focus(); - } else { - if (obj && obj.focus) obj.focus(); - } - head.css('z-index', head.data('old-z-index')); - // event after - options.trigger($.extend(edata, { phase: 'after' })); - } - } - - function getSize (el, type) { - var $el = $(el); - var bwidth = { - left : parseInt($el.css('border-left-width')) || 0, - right : parseInt($el.css('border-right-width')) || 0, - top : parseInt($el.css('border-top-width')) || 0, - bottom : parseInt($el.css('border-bottom-width')) || 0 - }; - var mwidth = { - left : parseInt($el.css('margin-left')) || 0, - right : parseInt($el.css('margin-right')) || 0, - top : parseInt($el.css('margin-top')) || 0, - bottom : parseInt($el.css('margin-bottom')) || 0 - }; - var pwidth = { - left : parseInt($el.css('padding-left')) || 0, - right : parseInt($el.css('padding-right')) || 0, - top : parseInt($el.css('padding-top')) || 0, - bottom : parseInt($el.css('padding-bottom')) || 0 - }; - switch (type) { - case 'top' : return bwidth.top + mwidth.top + pwidth.top; - case 'bottom' : return bwidth.bottom + mwidth.bottom + pwidth.bottom; - case 'left' : return bwidth.left + mwidth.left + pwidth.left; - case 'right' : return bwidth.right + mwidth.right + pwidth.right; - case 'width' : return bwidth.left + bwidth.right + mwidth.left + mwidth.right + pwidth.left + pwidth.right + parseInt($el.width()); - case 'height' : return bwidth.top + bwidth.bottom + mwidth.top + mwidth.bottom + pwidth.top + pwidth.bottom + parseInt($el.height()); - case '+width' : return bwidth.left + bwidth.right + mwidth.left + mwidth.right + pwidth.left + pwidth.right; - case '+height' : return bwidth.top + bwidth.bottom + mwidth.top + mwidth.bottom + pwidth.top + pwidth.bottom; - } - return 0; - } - - function getStrWidth (str, styles) { - var w, html = '
'+ - encodeTags(str) + - '
'; - $('body').append(html); - w = $('#_tmp_width').width(); - $('#_tmp_width').remove(); - return w; - } - - function lang (phrase) { - var translation = this.settings.phrases[phrase]; - if (translation == null) return phrase; else return translation; - } - - function locale (locale, callBack) { - if (!locale) locale = 'en-us'; - - // if the locale is an object, not a string, than we assume it's a - if (typeof locale !== "string" ) { - w2utils.settings = $.extend(true, w2utils.settings, locale); - return; - } - - if (locale.length === 5) locale = 'locale/'+ locale +'.json'; - - // clear phrases from language before - w2utils.settings.phrases = {}; - - // load from the file - $.ajax({ - url : locale, - type : "GET", - dataType : "JSON", - success : function (data, status, xhr) { - w2utils.settings = $.extend(true, w2utils.settings, data); - if (typeof callBack === 'function') callBack(); - }, - error : function (xhr, status, msg) { - console.log('ERROR: Cannot load locale '+ locale); - } - }); - } - - function scrollBarSize () { - if (tmp.scrollBarSize) return tmp.scrollBarSize; - var html = - '
'+ - '
1
'+ - '
'; - $('body').append(html); - tmp.scrollBarSize = 100 - $('#_scrollbar_width > div').width(); - $('#_scrollbar_width').remove(); - if (String(navigator.userAgent).indexOf('MSIE') >= 0) tmp.scrollBarSize = tmp.scrollBarSize / 2; // need this for IE9+ - return tmp.scrollBarSize; - } - - function checkName (params, component) { // was w2checkNameParam - if (!params || params.name == null) { - console.log('ERROR: The parameter "name" is required but not supplied in $().'+ component +'().'); - return false; - } - if (w2ui[params.name] != null) { - console.log('ERROR: The parameter "name" is not unique. There are other objects already created with the same name (obj: '+ params.name +').'); - return false; - } - if (!w2utils.isAlphaNumeric(params.name)) { - console.log('ERROR: The parameter "name" has to be alpha-numeric (a-z, 0-9, dash and underscore). '); - return false; - } - return true; - } - - function checkUniqueId (id, items, itemsDecription, objName) { // was w2checkUniqueId - if (!$.isArray(items)) items = [items]; - for (var i = 0; i < items.length; i++) { - if (items[i].id === id) { - console.log('ERROR: The parameter "id='+ id +'" is not unique within the current '+ itemsDecription +'. (obj: '+ objName +')'); - return false; - } - } - return true; - } - - function parseRoute(route) { - var keys = []; - var path = route - .replace(/\/\(/g, '(?:/') - .replace(/\+/g, '__plus__') - .replace(/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g, function(_, slash, format, key, capture, optional) { - keys.push({ name: key, optional: !! optional }); - slash = slash || ''; - return '' + (optional ? '' : slash) + '(?:' + (optional ? slash : '') + (format || '') + (capture || (format && '([^/.]+?)' || '([^/]+?)')) + ')' + (optional || ''); - }) - .replace(/([\/.])/g, '\\$1') - .replace(/__plus__/g, '(.+)') - .replace(/\*/g, '(.*)'); - return { - path : new RegExp('^' + path + '$', 'i'), - keys : keys - }; - } - - function cssPrefix(field, value, returnString) { - var css = {}; - var newCSS = {}; - var ret = ''; - if (!$.isPlainObject(field)) { - css[field] = value; - } else { - css = field; - if (value === true) returnString = true; - } - for (var c in css) { - newCSS[c] = css[c]; - newCSS['-webkit-'+c] = css[c]; - newCSS['-moz-'+c] = css[c].replace('-webkit-', '-moz-'); - newCSS['-ms-'+c] = css[c].replace('-webkit-', '-ms-'); - newCSS['-o-'+c] = css[c].replace('-webkit-', '-o-'); - } - if (returnString === true) { - for (var c in newCSS) { - ret += c + ': ' + newCSS[c] + '; '; - } - } else { - ret = newCSS; - } - return ret; - } - - function getCursorPosition(input) { - if (input == null) return null; - var caretOffset = 0; - var doc = input.ownerDocument || input.document; - var win = doc.defaultView || doc.parentWindow; - var sel; - if (input.tagName && input.tagName.toUpperCase() === 'INPUT' && input.selectionStart) { - // standards browser - caretOffset = input.selectionStart; - } else { - if (win.getSelection) { - sel = win.getSelection(); - if (sel.rangeCount > 0) { - var range = sel.getRangeAt(0); - var preCaretRange = range.cloneRange(); - preCaretRange.selectNodeContents(input); - preCaretRange.setEnd(range.endContainer, range.endOffset); - caretOffset = preCaretRange.toString().length; - } - } else if ( (sel = doc.selection) && sel.type !== "Control") { - var textRange = sel.createRange(); - var preCaretTextRange = doc.body.createTextRange(); - preCaretTextRange.moveToElementText(input); - preCaretTextRange.setEndPoint("EndToEnd", textRange); - caretOffset = preCaretTextRange.text.length; - } - } - return caretOffset; - } - - function setCursorPosition(input, pos, posEnd) { - var range = document.createRange(); - var el, sel = window.getSelection(); - if (input == null) return; - for (var i = 0; i < input.childNodes.length; i++) { - var tmp = $(input.childNodes[i]).text(); - if (input.childNodes[i].tagName) { - tmp = $(input.childNodes[i]).html(); - tmp = tmp.replace(/</g, '<') - .replace(/>/g, '>') - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(/ /g, ' '); - } - if (pos <= tmp.length) { - el = input.childNodes[i]; - if (el.childNodes && el.childNodes.length > 0) el = el.childNodes[0]; - if (el.childNodes && el.childNodes.length > 0) el = el.childNodes[0]; - break; - } else { - pos -= tmp.length; - } - } - if (el == null) return; - if (pos > el.length) pos = el.length; - range.setStart(el, pos); - if (posEnd) { - range.setEnd(el, posEnd); - } else { - range.collapse(true); - } - sel.removeAllRanges(); - sel.addRange(range); - } - - function testLocalStorage() { - // test if localStorage is available, see issue #1282 - // original code: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js - var str = 'w2ui_test'; - try { - localStorage.setItem(str, str); - localStorage.removeItem(str); - return true; - } catch (e) { - return false; - } - } - - function parseColor(str) { - if (typeof str !== 'string') return null; else str = str.trim().toUpperCase(); - if (str[0] === '#') str = str.substr(1); - var color = {}; - if (str.length === 3) { - color = { - r: parseInt(str[0] + str[0], 16), - g: parseInt(str[1] + str[1], 16), - b: parseInt(str[2] + str[2], 16), - a: 1 - } - } else if (str.length === 6) { - color = { - r: parseInt(str.substr(0, 2), 16), - g: parseInt(str.substr(2, 2), 16), - b: parseInt(str.substr(4, 2), 16), - a: 1 - } - } else if (str.length === 8) { - color = { - r: parseInt(str.substr(0, 2), 16), - g: parseInt(str.substr(2, 2), 16), - b: parseInt(str.substr(4, 2), 16), - a: Math.round(parseInt(str.substr(6, 2), 16) / 255 * 100) / 100 // alpha channel 0-1 - } - } else if (str.length > 4 && str.substr(0, 4) === 'RGB(') { - var tmp = str.replace('RGB', '').replace(/\(/g, '').replace(/\)/g, '').split(','); - color = { - r: parseInt(tmp[0], 10), - g: parseInt(tmp[1], 10), - b: parseInt(tmp[2], 10), - a: 1 - } - } else if (str.length > 5 && str.substr(0, 5) === 'RGBA(') { - var tmp = str.replace('RGBA', '').replace(/\(/g, '').replace(/\)/g, '').split(','); - color = { - r: parseInt(tmp[0], 10), - g: parseInt(tmp[1], 10), - b: parseInt(tmp[2], 10), - a: parseFloat(tmp[3]) - } - } else { - // word color - return null; - } - return color; - } - - // h=0..360, s=0..100, v=0..100 - function hsv2rgb(h, s, v, a) { - var r, g, b, i, f, p, q, t; - if (arguments.length === 1) { - s = h.s; v = h.v; a = h.a; h = h.h; - } - h = h / 360; - s = s / 100; - v = v / 100; - i = Math.floor(h * 6); - f = h * 6 - i; - p = v * (1 - s); - q = v * (1 - f * s); - t = v * (1 - (1 - f) * s); - switch (i % 6) { - case 0: r = v, g = t, b = p; break; - case 1: r = q, g = v, b = p; break; - case 2: r = p, g = v, b = t; break; - case 3: r = p, g = q, b = v; break; - case 4: r = t, g = p, b = v; break; - case 5: r = v, g = p, b = q; break; - } - return { - r: Math.round(r * 255), - g: Math.round(g * 255), - b: Math.round(b * 255), - a: (a != null ? a : 1) - }; - } - - // r=0..255, g=0..255, b=0..255 - function rgb2hsv(r, g, b, a) { - if (arguments.length === 1) { - g = r.g; b = r.b; a = r.a; r = r.r; - } - var max = Math.max(r, g, b), min = Math.min(r, g, b), - d = max - min, - h, - s = (max === 0 ? 0 : d / max), - v = max / 255; - switch (max) { - case min: h = 0; break; - case r: h = (g - b) + d * (g < b ? 6: 0); h /= 6 * d; break; - case g: h = (b - r) + d * 2; h /= 6 * d; break; - case b: h = (r - g) + d * 4; h /= 6 * d; break; - } - return { - h: Math.round(h * 360), - s: Math.round(s * 100), - v: Math.round(v * 100), - a: (a != null ? a : 1) - } - } - - function tooltip(msg, options) { - var actions, showOn = 'mouseenter', hideOn = 'mouseleave' - options = options || {} - if (options.showOn) { - showOn = options.showOn - delete options.showOn - } - if (options.hideOn) { - hideOn = options.hideOn - delete options.hideOn - } - // base64 is needed to avoid '"<> and other special chars conflicts - actions = 'on'+ showOn +'="$(this).w2tag(w2utils.base64decode(\'' + w2utils.base64encode(msg) + '\'),' - + 'JSON.parse(w2utils.base64decode(\'' + w2utils.base64encode(JSON.stringify(options)) + '\')))"' - + 'on'+ hideOn +'="$(this).w2tag()"' - - return actions - } - - /*! from litejs.com / MIT Licence - https://github.com/litejs/natural-compare-lite/blob/master/index.js */ - /* - * @version 1.4.0 - * @date 2015-10-26 - * @stability 3 - Stable - * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite) - * @license MIT License - */ - function naturalCompare(a, b) { - var i, codeA - , codeB = 1 - , posA = 0 - , posB = 0 - , alphabet = String.alphabet; - - function getCode(str, pos, code) { - if (code) { - for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i; - return +str.slice(pos - 1, i); - } - code = alphabet && alphabet.indexOf(str.charAt(pos)); - return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code - : code < 46 ? 65 // - - : code < 48 ? code - 1 - : code < 58 ? code + 18 // 0-9 - : code < 65 ? code - 11 - : code < 91 ? code + 11 // A-Z - : code < 97 ? code - 37 - : code < 123 ? code + 5 // a-z - : code - 63; - } - - - if ((a+="") != (b+="")) for (;codeB;) { - codeA = getCode(a, posA++); - codeB = getCode(b, posB++); - - if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) { - codeA = getCode(a, posA, posA); - codeB = getCode(b, posB, posA = i); - posB = i; - } - - if (codeA != codeB) return (codeA < codeB) ? -1 : 1; - } - return 0; - } -})(jQuery); - -/*********************************************************** -* Formatters object -* --- Primariy used in grid -* -*********************************************************/ - -w2utils.formatters = { - - 'number': function (value, params) { - if (parseInt(params) > 20) params = 20; - if (parseInt(params) < 0) params = 0; - if (value == null || value === '') return ''; - return w2utils.formatNumber(parseFloat(value), params, true); - }, - - 'float': function (value, params) { - return w2utils.formatters['number'](value, params); - }, - - 'int': function (value, params) { - return w2utils.formatters['number'](value, 0); - }, - - 'money': function (value, params) { - if (value == null || value === '') return ''; - var data = w2utils.formatNumber(Number(value), w2utils.settings.currencyPrecision || 2); - return (w2utils.settings.currencyPrefix || '') + data + (w2utils.settings.currencySuffix || ''); - }, - - 'currency': function (value, params) { - return w2utils.formatters['money'](value, params); - }, - - 'percent': function (value, params) { - if (value == null || value === '') return ''; - return w2utils.formatNumber(value, params || 1) + '%'; - }, - - 'size': function (value, params) { - if (value == null || value === '') return ''; - return w2utils.formatSize(parseInt(value)); - }, - - 'date': function (value, params) { - if (params === '') params = w2utils.settings.dateFormat; - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, params, true); - if (dt === false) dt = w2utils.isDate(value, params, true); - return '' + w2utils.formatDate(dt, params) + ''; - }, - - 'datetime': function (value, params) { - if (params === '') params = w2utils.settings.datetimeFormat; - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, params, true); - if (dt === false) dt = w2utils.isDate(value, params, true); - return '' + w2utils.formatDateTime(dt, params) + ''; - }, - - 'time': function (value, params) { - if (params === '') params = w2utils.settings.timeFormat; - if (params === 'h12') params = 'hh:mi pm'; - if (params === 'h24') params = 'h24:mi'; - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, params, true); - if (dt === false) dt = w2utils.isDate(value, params, true); - return '' + w2utils.formatTime(value, params) + ''; - }, - - 'timestamp': function (value, params) { - if (params === '') params = w2utils.settings.datetimeFormat; - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, params, true); - if (dt === false) dt = w2utils.isDate(value, params, true); - return dt.toString ? dt.toString() : ''; - }, - - 'gmt': function (value, params) { - if (params === '') params = w2utils.settings.datetimeFormat; - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, params, true); - if (dt === false) dt = w2utils.isDate(value, params, true); - return dt.toUTCString ? dt.toUTCString() : ''; - }, - - 'age': function (value, params) { - if (value == null || value === 0 || value === '') return ''; - var dt = w2utils.isDateTime(value, null, true); - if (dt === false) dt = w2utils.isDate(value, null, true); - return '' + w2utils.age(value) + (params ? (' ' + params) : '') + ''; - }, - - 'interval': function (value, params) { - if (value == null || value === 0 || value === '') return ''; - return w2utils.interval(value) + (params ? (' ' + params) : ''); - }, - - 'toggle': function (value, params) { - return (value ? 'Yes' : ''); - }, - - 'password': function (value, params) { - var ret = ""; - for (var i=0; i < value.length; i++) { - ret += "*"; - } - return ret; - } -}; - -/*********************************************************** -* Generic Event Object -* --- This object is reused across all other -* --- widgets in w2ui. -* -*********************************************************/ - -w2utils.event = { - - on: function (edata, handler) { - var $ = jQuery; - var scope; - // allow 'eventName.scope' syntax - if (typeof edata === 'string' && edata.indexOf('.') !== -1) { - var tmp = edata.split('.'); - edata = tmp[0]; - scope = tmp[1]; - } - // allow 'eventName:after' syntax - if (typeof edata === 'string' && edata.indexOf(':') !== -1) { - var tmp = edata.split(':'); - if (['complete', 'done'].indexOf(edata[1]) !== -1) edata[1] = 'after'; - edata = { - type : tmp[0], - execute : tmp[1] - }; - } - if (!$.isPlainObject(edata)) edata = { type: edata, scope: scope }; - edata = $.extend({ type: null, execute: 'before', target: null, onComplete: null }, edata); - // errors - if (!edata.type) { console.log('ERROR: You must specify event type when calling .on() method of '+ this.name); return; } - if (!handler) { console.log('ERROR: You must specify event handler function when calling .on() method of '+ this.name); return; } - if (!$.isArray(this.handlers)) this.handlers = []; - this.handlers.push({ edata: edata, handler: handler }); - }, - - off: function (edata, handler) { - var $ = jQuery; - var scope; - // allow 'eventName.scope' syntax - if (typeof edata === 'string' && edata.indexOf('.') !== -1) { - var tmp = edata.split('.'); - edata = tmp[0]; - scope = tmp[1]; - if (edata === '') edata = '*' - } - // allow 'eventName:after' syntax - if (typeof edata === 'string' && edata.indexOf(':') !== -1) { - var tmp = edata.split(':'); - if (['complete', 'done'].indexOf(edata[1]) !== -1) edata[1] = 'after'; - edata = { - type : tmp[0], - execute : tmp[1] - }; - } - if (!$.isPlainObject(edata)) edata = { type: edata }; - edata = $.extend({}, { type: null, execute: null, target: null, onComplete: null }, edata); - // errors - if (!edata.type && !scope) { console.log('ERROR: You must specify event type when calling .off() method of '+ this.name); return; } - if (!handler) { handler = null; } - // remove handlers - var newHandlers = []; - for (var h = 0, len = this.handlers.length; h < len; h++) { - var t = this.handlers[h]; - if ((t.edata.type === edata.type || edata.type === '*' || (t.edata.scope != null && edata.type == '')) && - (t.edata.target === edata.target || edata.target == null) && - (t.edata.execute === edata.execute || edata.execute == null) && - ((t.handler === handler && handler != null) || (scope != null && t.edata.scope == scope))) - { - // match - } else { - newHandlers.push(t); - } - } - this.handlers = newHandlers; - }, - - trigger: function (edata) { - var $ = jQuery; - var edata = $.extend({ type: null, phase: 'before', target: null, doneHandlers: [] }, edata, { - isStopped : false, - isCancelled : false, - done : function (handler) { this.doneHandlers.push(handler); }, - preventDefault : function () { this.isCancelled = true; }, - stopPropagation : function () { this.isStopped = true; } - }); - if (edata.phase === 'before') edata.onComplete = null; - var args, fun, tmp; - if (edata.target == null) edata.target = null; - if (!$.isArray(this.handlers)) this.handlers = []; - // process events in REVERSE order - for (var h = this.handlers.length-1; h >= 0; h--) { - var item = this.handlers[h]; - if (item != null && (item.edata.type === edata.type || item.edata.type === '*') && - (item.edata.target === edata.target || item.edata.target == null) && - (item.edata.execute === edata.phase || item.edata.execute === '*' || item.edata.phase === '*')) - { - edata = $.extend({}, item.edata, edata); - // check handler arguments - args = []; - tmp = new RegExp(/\((.*?)\)/).exec(item.handler); - if (tmp) args = tmp[1].split(/\s*,\s*/); - if (args.length === 2) { - item.handler.call(this, edata.target, edata); // old way for back compatibility - } else { - item.handler.call(this, edata); // new way - } - if (edata.isStopped === true || edata.stop === true) return edata; // back compatibility edata.stop === true - } - } - // main object events - var funName = 'on' + edata.type.substr(0,1).toUpperCase() + edata.type.substr(1); - if (edata.phase === 'before' && typeof this[funName] === 'function') { - fun = this[funName]; - // check handler arguments - args = []; - tmp = new RegExp(/\((.*?)\)/).exec(fun); - if (tmp) args = tmp[1].split(/\s*,\s*/); - if (args.length === 2) { - fun.call(this, edata.target, edata); // old way for back compatibility - } else { - fun.call(this, edata); // new way - } - if (edata.isStopped === true || edata.stop === true) return edata; // back compatibility edata.stop === true - } - // item object events - if (edata.object != null && edata.phase === 'before' && - typeof edata.object[funName] === 'function') - { - fun = edata.object[funName]; - // check handler arguments - args = []; - tmp = new RegExp(/\((.*?)\)/).exec(fun); - if (tmp) args = tmp[1].split(/\s*,\s*/); - if (args.length === 2) { - fun.call(this, edata.target, edata); // old way for back compatibility - } else { - fun.call(this, edata); // new way - } - if (edata.isStopped === true || edata.stop === true) return edata; - } - // execute onComplete - if (edata.phase === 'after') { - if (typeof edata.onComplete === 'function') edata.onComplete.call(this, edata); - for (var i = 0; i < edata.doneHandlers.length; i++) { - if (typeof edata.doneHandlers[i] === 'function') { - edata.doneHandlers[i].call(this, edata); - } - } - } - return edata; - } -}; - -/*********************************************************** -* Commonly used plugins -* --- used primarily in grid and form -* -*********************************************************/ - -(function ($) { - - $.fn.w2render = function (name) { - if ($(this).length > 0) { - if (typeof name === 'string' && w2ui[name]) w2ui[name].render($(this)[0]); - if (typeof name === 'object') name.render($(this)[0]); - } - }; - - $.fn.w2destroy = function (name) { - if (!name && this.length > 0) name = this.attr('name'); - if (typeof name === 'string' && w2ui[name]) w2ui[name].destroy(); - if (typeof name === 'object') name.destroy(); - }; - - $.fn.w2marker = function () { - var str = Array.prototype.slice.call(arguments, 0); - if (Array.isArray(str[0])) str = str[0]; - if (str.length === 0 || !str[0]) { // remove marker - return $(this).each(clearMarkedText); - } else { // add marker - return $(this).each(function (index, el) { - clearMarkedText(index, el); - for (var s = 0; s < str.length; s++) { - var tmp = str[s]; - if (typeof tmp !== 'string') tmp = String(tmp); - // escape regex special chars - tmp = tmp.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&").replace(/&/g, '&').replace(//g, '<'); - var regex = new RegExp(tmp + '(?!([^<]+)?>)', "gi"); // only outside tags - el.innerHTML = el.innerHTML.replace(regex, replaceValue); - } - function replaceValue(matched) { // mark new - return '' + matched + ''; - } - }); - } - - function clearMarkedText(index, el) { - while (el.innerHTML.indexOf('') !== -1) { - el.innerHTML = el.innerHTML.replace(/\((.|\n|\r)*)\<\/span\>/ig, '$1'); // unmark - } - } - }; - - // -- w2tag - there can be multiple on screen at a time - - $.fn.w2tag = function (text, options) { - // only one argument - if (arguments.length === 1 && typeof text === 'object') { - options = text; - if (options.html != null) text = options.html; - } - // default options - options = $.extend({ - id : null, // id for the tag, otherwise input id is used - auto : null, // if auto true, then tag will show on mouseEnter and hide on mouseLeave - html : text, // or html - position : 'right|top', // can be left, right, top, bottom - align : 'none', // can be none, left, right (only works for potision: top | bottom) - left : 0, // delta for left coordinate - top : 0, // delta for top coordinate - maxWidth : null, // max width - style : '', // adition style for the tag - css : {}, // add css for input when tag is shown - className : '', // add class bubble - inputClass : '', // add class for input when tag is shown - onShow : null, // callBack when shown - onHide : null, // callBack when hidden - hideOnKeyPress : true, // hide tag if key pressed - hideOnFocus : false, // hide tag on focus - hideOnBlur : false, // hide tag on blur - hideOnClick : false, // hide tag on document click - hideOnChange : true - }, options); - if (options.name != null && options.id == null) options.id = options.name; - - // for backward compatibility - if (options['class'] !== '' && options.inputClass === '') options.inputClass = options['class']; - - // remove all tags - if ($(this).length === 0) { - $('.w2ui-tag').each(function (index, el) { - var tag = $(el).data('w2tag'); - if (tag) tag.hide(); - }); - return; - } - if (options.auto === true || options.showOn != null || options.hideOn != null) { - if (arguments.length == 0 || !text) { - return $(this).each(function (index, el) { - $(el).off('.w2tooltip') - }) - } else { - return $(this).each(function (index, el) { - var showOn = 'mouseenter', hideOn = 'mouseleave' - if (options.showOn) { - showOn = String(options.showOn).toLowerCase() - delete options.showOn - } - if (options.hideOn) { - hideOn = String(options.hideOn).toLowerCase() - delete options.hideOn - } - if (!options.potision) { options.position = 'top|bottom' } - $(el) - .off('.w2tooltip') - .on(showOn + '.w2tooltip', function () { - options.auto = false; - $(this).w2tag(text, options) - }) - .on(hideOn + '.w2tooltip', function () { - $(this).w2tag() - }) - }) - } - } else { - return $(this).each(function (index, el) { - // main object - var tag; - var origID = (options.id ? options.id : el.id); - if (origID == '') { // search for an id - origID = $(el).find('input').attr('id'); - } - if (!origID) { - origID = 'noid'; - } - var tmpID = w2utils.escapeId(origID); - if ($(this).data('w2tag') != null) { - tag = $(this).data('w2tag'); - $.extend(tag.options, options); - } else { - tag = { - id : origID, - attachedTo: el, // element attached to - box : $('#w2ui-tag-' + tmpID), // tag itself - options : $.extend({}, options), - // methods - init : init, // attach events - hide : hide, // hide tag - getPos : getPos, // gets position of tag - isMoved : isMoved, // if called, will adjust position - // internal - tmp : {} // for temp variables - }; - } - // show or hide tag - if (text === '' || text == null) { - tag.hide(); - } else if (tag.box.length !== 0) { - // if already present - tag.box.find('.w2ui-tag-body') - .css(tag.options.css) - .attr('style', tag.options.style) - .addClass(tag.options.className) - .html(tag.options.html); - } else { - tag.tmp.originalCSS = ''; - if ($(tag.attachedTo).length > 0) tag.tmp.originalCSS = $(tag.attachedTo)[0].style.cssText; - var tagStyles = 'white-space: nowrap;' - if (tag.options.maxWidth && w2utils.getStrWidth(text) > tag.options.maxWidth) { - tagStyles = 'width: '+ tag.options.maxWidth + 'px' - } - // insert - $('body').append( - ''); - tag.box = $('#w2ui-tag-' + tmpID); - $(tag.attachedTo).data('w2tag', tag); // make available to element tag attached to - setTimeout(init, 1); - } - return; - - function init() { - tag.box.css('display', 'block'); - if (!tag || !tag.box || !$(tag.attachedTo).offset()) return; - var pos = tag.getPos(); - tag.box.css({ - opacity : '1', - left : pos.left + 'px', - top : pos.top + 'px' - }) - .data('w2tag', tag) - .find('.w2ui-tag-body').addClass(pos['posClass']); - tag.tmp.pos = pos.left + 'x' + pos.top; - - $(tag.attachedTo) - .off('.w2tag') - .css(tag.options.css) - .addClass(tag.options.inputClass); - - - if (tag.options.hideOnKeyPress) { - $(tag.attachedTo).on('keypress.w2tag', tag.hide); - } - if (tag.options.hideOnFocus) { - $(tag.attachedTo).on('focus.w2tag', tag.hide); - } - if (options.hideOnChange) { - if (el.nodeName === 'INPUT') { - $(el).on('change.w2tag', tag.hide); - } else { - $(el).find('input').on('change.w2tag', tag.hide); - } - } - if (tag.options.hideOnBlur) { - $(tag.attachedTo).on('blur.w2tag', tag.hide); - } - if (tag.options.hideOnClick) { - $('body').on('click.w2tag' + (tag.id || ''), tag.hide); - } - if (typeof tag.options.onShow === 'function') { - tag.options.onShow(); - } - isMoved(); - } - - // bind event to hide it - function hide() { - if (tag.box.length <= 0) return; - if (tag.tmp.timer) clearTimeout(tag.tmp.timer); - tag.box.remove(); - if (tag.options.hideOnClick) { - $('body').off('.w2tag' + (tag.id || '')); - } - $(tag.attachedTo).off('.w2tag') - .removeClass(tag.options.inputClass) - .removeData('w2tag'); - // restore original CSS - if ($(tag.attachedTo).length > 0) { - $(tag.attachedTo)[0].style.cssText = tag.tmp.originalCSS; - } - if (typeof tag.options.onHide === 'function') { - tag.options.onHide(); - } - } - - function isMoved(instant) { - // monitor if destroyed - var offset = $(tag.attachedTo).offset(); - if ($(tag.attachedTo).length === 0 || (offset.left === 0 && offset.top === 0) || tag.box.find('.w2ui-tag-body').length === 0) { - tag.hide(); - return; - } - var pos = getPos(); - if (tag.tmp.pos !== pos.left + 'x' + pos.top) { - tag.box - .css(w2utils.cssPrefix({ 'transition': (instant ? '0s' : '.2s') })) - .css({ - left: pos.left + 'px', - top : pos.top + 'px' - }); - tag.tmp.pos = pos.left + 'x' + pos.top; - } - if (tag.tmp.timer) clearTimeout(tag.tmp.timer); - tag.tmp.timer = setTimeout(isMoved, 100); - } - - function getPos() { - var offset = $(tag.attachedTo).offset(); - var posClass = 'w2ui-tag-right'; - var posLeft = parseInt(offset.left + tag.attachedTo.offsetWidth + (tag.options.left ? tag.options.left : 0)); - var posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)); - var tagBody = tag.box.find('.w2ui-tag-body'); - var width = tagBody[0].offsetWidth; - var height = tagBody[0].offsetHeight; - if (typeof tag.options.position === 'string' && tag.options.position.indexOf('|') !== -1) { - tag.options.position = tag.options.position.split('|'); - } - if (tag.options.position === 'top') { - posClass = 'w2ui-tag-top'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - 14; - posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)) - height - 10; - } else if (tag.options.position === 'bottom') { - posClass = 'w2ui-tag-bottom'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - 14; - posTop = parseInt(offset.top + tag.attachedTo.offsetHeight + (tag.options.top ? tag.options.top : 0)) + 10; - } else if (tag.options.position === 'left') { - posClass = 'w2ui-tag-left'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - width - 20; - posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)); - } else if (Array.isArray(tag.options.position)) { - // try to fit the tag on screen in the order defined in the array - var maxWidth = window.innerWidth; - var maxHeight = window.innerHeight; - for (var i = 0; i < tag.options.position.length; i++) { - var pos = tag.options.position[i]; - if (pos === 'right') { - posClass = 'w2ui-tag-right'; - posLeft = parseInt(offset.left + tag.attachedTo.offsetWidth + (tag.options.left ? tag.options.left : 0)); - posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)); - if (posLeft+width <= maxWidth) break; - } else if (pos === 'left') { - posClass = 'w2ui-tag-left'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - width - 20; - posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)); - if (posLeft >= 0) break; - } else if (pos === 'top') { - posClass = 'w2ui-tag-top'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - 14; - posTop = parseInt(offset.top + (tag.options.top ? tag.options.top : 0)) - height - 10; - if(posLeft+width <= maxWidth && posTop >= 0) break; - } else if (pos === 'bottom') { - posClass = 'w2ui-tag-bottom'; - posLeft = parseInt(offset.left + (tag.options.left ? tag.options.left : 0)) - 14; - posTop = parseInt(offset.top + tag.attachedTo.offsetHeight + (tag.options.top ? tag.options.top : 0)) + 10; - if (posLeft+width <= maxWidth && posTop+height <= maxHeight) break; - } - } - if (tagBody.data('posClass') !== posClass) { - tagBody.removeClass('w2ui-tag-right w2ui-tag-left w2ui-tag-top w2ui-tag-bottom') - .addClass(posClass) - .data('posClass', posClass); - } - } - return { left: posLeft, top: posTop, posClass: posClass }; - } - }) - } - } - - // w2overlay - appears under the element, there can be only one at a time - - $.fn.w2overlay = function (html, options) { - var obj = this; - var name = ''; - var defaults = { - name : null, // it not null, then allows multiple concurrent overlays - html : '', // html text to display - align : 'none', // can be none, left, right, both - left : 0, // offset left - top : 0, // offset top - tipLeft : 30, // tip offset left - noTip : false, // if true - no tip will be displayed - selectable : false, - width : 0, // fixed width - height : 0, // fixed height - maxWidth : null, // max width if any - maxHeight : null, // max height if any - contextMenu : false, // if true, it will be opened at mouse position - pageX : null, - pageY : null, - originalEvent : null, - style : '', // additional style for main div - 'class' : '', // additional class name for main div - overlayStyle: '', - onShow : null, // event on show - onHide : null, // event on hide - openAbove : false, // show above control - tmp : {} - }; - if (arguments.length === 1) { - if (typeof html === 'object') { - options = html; - } else { - options = { html: html }; - } - } - if (arguments.length === 2) options.html = html; - if (!$.isPlainObject(options)) options = {}; - options = $.extend({}, defaults, options); - if (options.name) name = '-' + options.name; - // hide - var tmp_hide; - if (this.length === 0 || options.html === '' || options.html == null) { - if ($('#w2ui-overlay'+ name).length > 0) { - tmp_hide = $('#w2ui-overlay'+ name)[0].hide; - if (typeof tmp_hide === 'function') tmp_hide(); - } else { - $('#w2ui-overlay'+ name).remove(); - } - return $(this); - } - // hide previous if any - if ($('#w2ui-overlay'+ name).length > 0) { - tmp_hide = $('#w2ui-overlay'+ name)[0].hide; - $(document).off('.w2overlay'+ name); - if (typeof tmp_hide === 'function') tmp_hide(); - } - if (obj.length > 0 && (obj[0].tagName == null || obj[0].tagName.toUpperCase() === 'BODY')) options.contextMenu = true; - if (options.contextMenu && options.originalEvent) { - options.pageX = options.originalEvent.pageX; - options.pageY = options.originalEvent.pageY; - } - if (options.contextMenu && (options.pageX == null || options.pageY == null)) { - console.log('ERROR: to display menu at mouse location, pass options.pageX and options.pageY.'); - } - var data_str = '' - if (options.data) { - Object.keys(options.data).forEach(function (item) { - data_str += 'data-'+ item + '="' + options.data[item] +'"' - }) - } - // append - $('body').append( - '' - ); - // init - var div1 = $('#w2ui-overlay'+ name); - var div2 = div1.find(' > div'); - div2.html(options.html); - // pick bg color of first div - var bc = div2.css('background-color'); - if (bc != null && bc !== 'rgba(0, 0, 0, 0)' && bc !== 'transparent') div1.css({ 'background-color': bc, 'border-color': bc }); - - var offset = $(obj).offset() || {}; - div1.data('element', obj.length > 0 ? obj[0] : null) - .data('options', options) - .data('position', offset.left + 'x' + offset.top) - .fadeIn('fast') - .on('click', function (event) { - $('#w2ui-overlay'+ name).data('keepOpen', true); - // if there is label for input, it will produce 2 click events - if (event.target.tagName.toUpperCase() === 'LABEL') event.stopPropagation(); - }) - .on('mousedown', function (event) { - var tmp = event.target.tagName.toUpperCase(); - if (['INPUT', 'TEXTAREA', 'SELECT'].indexOf(tmp) === -1 && !options.selectable) { - event.preventDefault(); - } - }); - div1[0].hide = hide; - div1[0].resize = resize; - - // need time to display - setTimeout(function () { - $(document).off('.w2overlay'+ name).on('click.w2overlay'+ name, hide); - if (typeof options.onShow === 'function') options.onShow(); - resize(); - }, 10); - - monitor(); - return $(this); - - // monitor position - function monitor() { - var tmp = $('#w2ui-overlay'+ name); - if (tmp.data('element') !== obj[0]) return; // it if it different overlay - if (tmp.length === 0) return; - var offset = $(obj).offset() || {}; - var pos = offset.left + 'x' + offset.top; - if (tmp.data('position') !== pos) { - hide(); - } else { - setTimeout(monitor, 250); - } - } - - // click anywhere else hides the drop down - function hide(event) { - if (event && event.button !== 0) return; // only for left click button - var div1 = $('#w2ui-overlay'+ name); - // Allow clicking inside other overlays which belong to the elements inside this overlay - if (event && $($(event.target).closest('.w2ui-overlay').data('element')).closest('.w2ui-overlay')[0] === div1[0]) return; - if (div1.data('keepOpen') === true) { - div1.removeData('keepOpen'); - return; - } - var result; - if (typeof options.onHide === 'function') result = options.onHide(); - if (result === false) return; - div1.remove(); - $(document).off('.w2overlay'+ name); - clearInterval(div1.data('timer')); - } - - function resize() { - var div1 = $('#w2ui-overlay'+ name); - var div2 = div1.find(' > div'); - var menu = $('#w2ui-overlay'+ name +' div.w2ui-menu'); - var pos = {}; - if (menu.length > 0) { - menu.css('overflow-y', 'hidden'); - pos.scrollTop = menu.scrollTop(); - pos.scrollLeft = menu.scrollLeft(); - } - // if goes over the screen, limit height and width - if (div1.length > 0) { - div2.height('auto').width('auto'); - // width/height - var overflowX = false; - var overflowY = false; - var h = div2.height(); - var w = div2.width(); - if (options.width && options.width < w) w = options.width; - if (w < 30) w = 30; - // if content of specific height - if (options.tmp.contentHeight) { - h = parseInt(options.tmp.contentHeight); - div2.height(h); - setTimeout(function () { - var $div = div2.find('div.w2ui-menu'); - if (h > $div.height()) { - div2.find('div.w2ui-menu').css('overflow-y', 'hidden'); - } - }, 1); - setTimeout(function () { - var $div = div2.find('div.w2ui-menu'); - if ($div.css('overflow-y') !== 'auto') $div.css('overflow-y', 'auto'); - }, 10); - } - if (options.tmp.contentWidth && options.align !== 'both') { - w = parseInt(options.tmp.contentWidth); - div2.width(w); - setTimeout(function () { - if (w > div2.find('div.w2ui-menu > table').width()) { - div2.find('div.w2ui-menu > table').css('overflow-x', 'hidden'); - } - }, 1); - setTimeout(function () { - div2.find('div.w2ui-menu > table').css('overflow-x', 'auto'); - }, 10); - } else { - div2.find('div.w2ui-menu').css('width', '100%'); - } - // adjust position - var boxLeft = options.left; - var boxWidth = options.width; - var tipLeft = options.tipLeft; - // alignment - switch (options.align) { - case 'both': - boxLeft = 17; - if (options.width === 0) options.width = w2utils.getSize($(obj), 'width'); - if (options.maxWidth && options.width > options.maxWidth) options.width = options.maxWidth; - break; - case 'left': - boxLeft = 17; - break; - case 'right': - boxLeft = w2utils.getSize($(obj), 'width') - w + 10; - tipLeft = w - 40; - break; - } - if (w === 30 && !boxWidth) boxWidth = 30; else boxWidth = (options.width ? options.width : 'auto'); - var tmp = (w - 17) / 2; - if (boxWidth !== 'auto') tmp = (boxWidth - 17) / 2; - if (tmp < 25) { - boxLeft = 25 - tmp; - tipLeft = Math.floor(tmp); - } - // Y coord - var X, Y, offsetTop; - if (options.contextMenu) { // context menu - X = options.pageX + 8; - Y = options.pageY - 0; - offsetTop = options.pageY; - } else { - var offset = obj.offset() || {}; - X = ((offset.left > 25 ? offset.left : 25) + boxLeft); - Y = (offset.top + w2utils.getSize(obj, 'height') + options.top + 7); - offsetTop = offset.top; - } - div1.css({ - left : X + 'px', - top : Y + 'px', - 'min-width' : boxWidth, - 'min-height': (options.height ? options.height : 'auto') - }); - // $(window).height() - has a problem in FF20 - var offset = div2.offset() || {}; - var maxHeight = window.innerHeight + $(document).scrollTop() - offset.top - 7; - var maxWidth = window.innerWidth + $(document).scrollLeft() - offset.left - 7; - if (options.contextMenu) { // context menu - maxHeight = window.innerHeight + $(document).scrollTop() - options.pageY - 15; - maxWidth = window.innerWidth + $(document).scrollLeft() - options.pageX; - } - - if (((maxHeight > -50 && maxHeight < 210) || options.openAbove === true) && options.openAbove !== false) { - var tipOffset; - // show on top - if (options.contextMenu) { // context menu - maxHeight = options.pageY - 7; - tipOffset = 5; - } else { - maxHeight = offset.top - $(document).scrollTop() - 7; - tipOffset = 24; - } - if (options.maxHeight && maxHeight > options.maxHeight) maxHeight = options.maxHeight; - if (h > maxHeight) { - overflowY = true; - div2.height(maxHeight).width(w).css({ 'overflow-y': 'auto' }); - h = maxHeight; - } - div1.addClass('bottom-arrow'); - div1.css('top', (offsetTop - h - tipOffset + options.top) + 'px'); - div1.find('>style').html( - '#w2ui-overlay'+ name +':before { margin-left: '+ parseInt(tipLeft) +'px; }'+ - '#w2ui-overlay'+ name +':after { margin-left: '+ parseInt(tipLeft) +'px; }' - ); - } else { - // show under - if (options.maxHeight && maxHeight > options.maxHeight) maxHeight = options.maxHeight; - if (h > maxHeight) { - overflowY = true; - div2.height(maxHeight).width(w).css({ 'overflow-y': 'auto' }); - } - div1.addClass('top-arrow'); - div1.find('>style').html( - '#w2ui-overlay'+ name +':before { margin-left: '+ parseInt(tipLeft) +'px; }'+ - '#w2ui-overlay'+ name +':after { margin-left: '+ parseInt(tipLeft) +'px; }' - ); - } - // check width - w = div2.width(); - maxWidth = window.innerWidth + $(document).scrollLeft() - offset.left - 7; - if (options.maxWidth && maxWidth > options.maxWidth) maxWidth = options.maxWidth; - if (w > maxWidth && options.align !== 'both') { - options.align = 'right'; - setTimeout(function () { resize(); }, 1); - } - // don't show tip - if (options.contextMenu || options.noTip) { // context menu - div1.find('>style').html( - '#w2ui-overlay'+ name +':before { display: none; }'+ - '#w2ui-overlay'+ name +':after { display: none; }' - ); - } - // check scroll bar (needed to avoid horizontal scrollbar) - if (overflowY && options.align !== 'both') div2.width(w + w2utils.scrollBarSize() + 2); - } - if (menu.length > 0) { - menu.css('overflow-y', 'auto'); - menu.scrollTop(pos.scrollTop); - menu.scrollLeft(pos.scrollLeft); - } - } - }; - - $.fn.w2menu = function (menu, options) { - /* - ITEM STRUCTURE - item : { - id : null, - text : '', - style : '', - img : '', - icon : '', - count : '', - tooltip : '', - hidden : false, - checked : null, - disabled : false - ... - } - */ - // if items is a function - if (options && typeof options.items === 'function') { - options.items = options.items(); - } - var defaults = { - type : 'normal', // can be normal, radio, check - index : null, // current selected - items : [], - render : null, - msgNoItems : 'No items', - onSelect : null, - hideOnRemove : false, - tmp : {} - }; - var ret; - var obj = this; - var name = ''; - if (menu === 'refresh') { - // if not show - call blur - if ($.fn.w2menuOptions && $.fn.w2menuOptions.name) name = '-' + $.fn.w2menuOptions.name; - if (options.name) name = '-' + options.name; - if ($('#w2ui-overlay'+ name).length > 0) { - options = $.extend($.fn.w2menuOptions, options); - var scrTop = $('#w2ui-overlay'+ name +' div.w2ui-menu').scrollTop(); - $('#w2ui-overlay'+ name +' div.w2ui-menu').html(getMenuHTML()); - $('#w2ui-overlay'+ name +' div.w2ui-menu').scrollTop(scrTop); - mresize(); - } else { - $(this).w2menu(options); - } - } else if (menu === 'refresh-index') { - var $menu = $('#w2ui-overlay'+ name +' div.w2ui-menu'); - var cur = $menu.find('tr[index='+ options.index +']'); - var scrTop = $menu.scrollTop(); - $menu.find('tr.w2ui-selected').removeClass('w2ui-selected'); // clear all - cur.addClass('w2ui-selected'); // select current - // scroll into view - if (cur.length > 0) { - var top = cur[0].offsetTop - 5; // 5 is margin top - var height = $menu.height(); - $menu.scrollTop(scrTop); - if (top < scrTop || top + cur.height() > scrTop + height) { - $menu.animate({ 'scrollTop': top - (height - cur.height() * 2) / 2 }, 200, 'linear'); - } - } - mresize(); - } else { - if (arguments.length === 1) options = menu; else options.items = menu; - if (typeof options !== 'object') options = {}; - options = $.extend({}, defaults, options); - $.fn.w2menuOptions = options; - if (options.name) name = '-' + options.name; - if (typeof options.select === 'function' && typeof options.onSelect !== 'function') options.onSelect = options.select; - if (typeof options.remove === 'function' && typeof options.onRemove !== 'function') options.onRemove = options.remove; - if (typeof options.onRender === 'function' && typeof options.render !== 'function') options.render = options.onRender; - // since only one overlay can exist at a time - $.fn.w2menuClick = function (event, index, parentIndex) { - var keepOpen = false; - var $tr = $(event.target).closest('tr'); - if (event.shiftKey || event.metaKey || event.ctrlKey) { - keepOpen = true; - } - if (parentIndex == null) { - items = options.items - } else { - items = options.items[parentIndex].items - } - if ($(event.target).hasClass('remove')) { - if (typeof options.onRemove === 'function') { - options.onRemove({ - index: index, - parentIndex: parentIndex, - item: items[index], - keepOpen: keepOpen, - originalEvent: event - }); - } - keepOpen = !options.hideOnRemove; - $(event.target).closest('tr').remove(); - mresize(); - } else if ($tr.hasClass('has-sub-menu')) { - keepOpen = true; - if ($tr.hasClass('expanded')) { - items[index].expanded = false; - $tr.removeClass('expanded').addClass('collapsed').next().hide(); - } else { - items[index].expanded = true; - $tr.addClass('expanded').removeClass('collapsed').next().show(); - } - mresize(); - } else if (typeof options.onSelect === 'function') { - var tmp = items; - if (typeof items == 'function') { - tmp = items(options.items[parentIndex]) - } - if (tmp[index].keepOpen != null) { - keepOpen = tmp[index].keepOpen - } - options.onSelect({ - index: index, - parentIndex: parentIndex, - item: tmp[index], - keepOpen: keepOpen, - originalEvent: event - }); - } - // -- hide - if (items[index] == null || items[index].keepOpen !== true) { - var div = $('#w2ui-overlay'+ name); - div.removeData('keepOpen'); - if (div.length > 0 && typeof div[0].hide === 'function' && !keepOpen) { - div[0].hide(); - } - } - }; - $.fn.w2menuDown = function (event, index, parentIndex) { - var items; - var $el = $(event.target).closest('tr'); - var tmp = $($el.get(0)).find('.w2ui-icon'); - if (parentIndex == null) { - items = options.items - } else { - items = options.items[parentIndex].items - } - var item = items[index]; - if ((options.type === 'check' || options.type === 'radio') && item.group !== false - && !$(event.target).hasClass('remove') - && !$(event.target).closest('tr').hasClass('has-sub-menu')) { - item.checked = !item.checked; - if (item.checked) { - if (options.type === 'radio') { - tmp.parents('table').find('.w2ui-icon') // should not be closest, but parents - .removeClass('w2ui-icon-check') - .addClass('w2ui-icon-empty'); - } - if (options.type === 'check' && item.group != null) { - items.forEach(function (sub, ind) { - if (sub.id == item.id) return; - if (sub.group === item.group && sub.checked) { - tmp.closest('table').find('tr[index='+ ind +'] .w2ui-icon') - .removeClass('w2ui-icon-check') - .addClass('w2ui-icon-empty'); - items[ind].checked = false; - } - }); - } - tmp.removeClass('w2ui-icon-empty').addClass('w2ui-icon-check'); - } else if (options.type === 'check' && item.group == null && item.group !== false) { - tmp.removeClass('w2ui-icon-check').addClass('w2ui-icon-empty'); - } - } - // highlight record - $el.parent().find('tr').removeClass('w2ui-selected'); - $el.addClass('w2ui-selected'); - }; - var html = ''; - if (options.search) { - html += - '
'+ - ' '+ - ' '+ - '
'; - options.style += ';background-color: #ECECEC'; - options.index = 0; - for (var i = 0; i < options.items.length; i++) options.items[i].hidden = false; - } - html += (options.topHTML || '') + - '
' + - getMenuHTML() + - '
'; - ret = $(this).w2overlay(html, options); - setTimeout(function () { - $('#w2ui-overlay'+ name +' #menu-search') - .on('keyup', change) - .on('keydown', function (event) { - // cancel tab key - if (event.keyCode === 9) { event.stopPropagation(); event.preventDefault(); } - }); - if (options.search) { - if (['text', 'password'].indexOf($(obj)[0].type) !== -1 || $(obj)[0].tagName.toUpperCase() === 'TEXTAREA') return; - $('#w2ui-overlay'+ name +' #menu-search').focus(); - } - mresize(); - }, 250); - mresize(); - // map functions - var div = $('#w2ui-overlay'+ name); - if (div.length > 0) { - div[0].mresize = mresize; - div[0].change = change; - } - } - return ret; - - function mresize() { - setTimeout(function () { - // show selected - $('#w2ui-overlay'+ name +' tr.w2ui-selected').removeClass('w2ui-selected'); - var cur = $('#w2ui-overlay'+ name +' tr[index='+ options.index +']'); - var scrTop = $('#w2ui-overlay'+ name +' div.w2ui-menu').scrollTop(); - cur.addClass('w2ui-selected'); - if (options.tmp) { - options.tmp.contentHeight = $('#w2ui-overlay'+ name +' table').height() + (options.search ? 50 : 10) - + (parseInt($('#w2ui-overlay'+ name +' .w2ui-menu').css('top')) || 0) // it menu is moved with menuStyle - + (parseInt($('#w2ui-overlay'+ name +' .w2ui-menu').css('bottom')) || 0); // it menu is moved with menuStyle - options.tmp.contentWidth = $('#w2ui-overlay'+ name +' table').width(); - } - if ($('#w2ui-overlay'+ name).length > 0) $('#w2ui-overlay'+ name)[0].resize(); - // scroll into view - if (cur.length > 0) { - var top = cur[0].offsetTop - 5; // 5 is margin top - var el = $('#w2ui-overlay'+ name +' div.w2ui-menu'); - var height = el.height(); - $('#w2ui-overlay'+ name +' div.w2ui-menu').scrollTop(scrTop); - if (top < scrTop || top + cur.height() > scrTop + height) { - $('#w2ui-overlay'+ name +' div.w2ui-menu').animate({ 'scrollTop': top - (height - cur.height() * 2) / 2 }, 200, 'linear'); - } - } - }, 1); - } - - function change(event) { - var search = this.value; - var key = event.keyCode; - var cancel = false; - switch (key) { - case 13: // enter - $('#w2ui-overlay'+ name).remove(); - $.fn.w2menuClick(event, options.index); - break; - case 9: // tab - case 27: // escape - $('#w2ui-overlay'+ name).remove(); - $.fn.w2menuClick(event, -1); - break; - case 38: // up - options.index = w2utils.isInt(options.index) ? parseInt(options.index) : 0; - options.index--; - while (options.index > 0 && options.items[options.index].hidden) options.index--; - if (options.index === 0 && options.items[options.index].hidden) { - while (options.items[options.index] && options.items[options.index].hidden) options.index++; - } - if (options.index < 0) options.index = 0; - cancel = true; - break; - case 40: // down - options.index = w2utils.isInt(options.index) ? parseInt(options.index) : 0; - options.index++; - while (options.index < options.items.length-1 && options.items[options.index].hidden) options.index++; - if (options.index === options.items.length-1 && options.items[options.index].hidden) { - while (options.items[options.index] && options.items[options.index].hidden) options.index--; - } - if (options.index >= options.items.length) options.index = options.items.length - 1; - cancel = true; - break; - } - // filter - if (!cancel) { - var shown = 0; - for (var i = 0; i < options.items.length; i++) { - var item = options.items[i]; - var prefix = ''; - var suffix = ''; - if (['is', 'begins with'].indexOf(options.match) !== -1) prefix = '^'; - if (['is', 'ends with'].indexOf(options.match) !== -1) suffix = '$'; - try { - var re = new RegExp(prefix + search + suffix, 'i'); - if (re.test(item.text) || item.text === '...') item.hidden = false; else item.hidden = true; - } catch (e) {} - // do not show selected items - if (obj.type === 'enum' && $.inArray(item.id, ids) !== -1) item.hidden = true; - if (item.hidden !== true) shown++; - } - options.index = 0; - while (options.index < options.items.length-1 && options.items[options.index].hidden) options.index++; - if (shown <= 0) options.index = -1; - } - $(obj).w2menu('refresh', options); - mresize(); - } - - function getMenuHTML(items, subMenu, expanded, parentIndex) { - if (options.spinner) { - return '
'+ - '
'+ - '
'+ w2utils.lang('Loading...') +'
'+ - '
'; - } - var count = 0; - var menu_html = ''; - var img = null, icon = null; - if (items == null) items = options.items; - if (!Array.isArray(items)) items = [] - for (var f = 0; f < items.length; f++) { - var mitem = items[f]; - if (typeof mitem === 'string') { - mitem = { id: mitem, text: mitem }; - } else { - if (mitem.text != null && mitem.id == null) mitem.id = mitem.text; - if (mitem.text == null && mitem.id != null) mitem.text = mitem.id; - if (mitem.caption != null) mitem.text = mitem.caption; - img = mitem.img; - icon = mitem.icon; - if (img == null) img = null; // img might be undefined - if (icon == null) icon = null; // icon might be undefined - } - if (['radio', 'check'].indexOf(options.type) != -1 && !Array.isArray(mitem.items) && mitem.group !== false) { - if (mitem.checked === true) icon = 'w2ui-icon-check'; else icon = 'w2ui-icon-empty'; - } - if (mitem.hidden !== true) { - var imgd = ''; - var txt = mitem.text; - var subMenu_dsp = ''; - if (typeof options.render === 'function') txt = options.render(mitem, options); - if (typeof txt == 'function') txt = txt(mitem, options) - if (img) imgd = ''; - if (icon) imgd = ''; - // render only if non-empty - if (mitem.type !== 'break' && txt != null && txt !== '' && String(txt).substr(0, 2) != '--') { - var bg = (count % 2 === 0 ? 'w2ui-item-even' : 'w2ui-item-odd'); - if (options.altRows !== true) bg = ''; - var colspan = 1; - if (imgd === '') colspan++; - if (mitem.count == null && mitem.hotkey == null && mitem.remove !== true && mitem.items == null) colspan++; - if (mitem.tooltip == null && mitem.hint != null) mitem.tooltip = mitem.hint; // for backward compatibility - var count_dsp = ''; - if (mitem.remove === true) { - count_dsp = 'X' - } else if (mitem.items != null) { - var _items = [] - if (typeof mitem.items == 'function') { - _items = mitem.items(mitem) - } else if (Array.isArray(mitem.items)) { - _items = mitem.items - } - count_dsp = '' - subMenu_dsp = ''+ - ' '+ - ''; - } else { - if (mitem.count != null) count_dsp += '' + mitem.count + '' - if (mitem.hotkey != null) count_dsp += '' + mitem.hotkey + '' - } - menu_html += - ''+ - (subMenu ? '' : '') + imgd + - ' '+ - ' '+ - ''+ subMenu_dsp; - count++; - } else { - // horizontal line - var divText = txt.replace(/^-+/g, '') - menu_html += ''; - } - } - items[f] = mitem; - } - if (count === 0 && options.msgNoItems) { - menu_html += ''; - } - menu_html += ""; - return menu_html; - } - }; - - $.fn.w2color = function (options, callBack) { - var obj = this; - var $el = $(this); - var el = $el[0]; - // no need to init - if ($el.data('skipInit')) { - $el.removeData('skipInit'); - return; - } - // needed for keyboard navigation - var index = [-1, -1]; - if ($.fn.w2colorPalette == null) { - $.fn.w2colorPalette = [ - ['000000', '333333', '555555', '777777', '888888', '999999', 'AAAAAA', 'CCCCCC', 'DDDDDD', 'EEEEEE', 'F7F7F7', 'FFFFFF'], - ['FF011B', 'FF9838', 'FFC300', 'FFFD59', '86FF14', '14FF7A', '2EFFFC', '2693FF', '006CE7', '9B24F4', 'FF21F5', 'FF0099'], - ['FFEAEA', 'FCEFE1', 'FCF4DC', 'FFFECF', 'EBFFD9', 'D9FFE9', 'E0FFFF', 'E8F4FF', 'ECF4FC', 'EAE6F4', 'FFF5FE', 'FCF0F7'], - ['F4CCCC', 'FCE5CD', 'FFF1C2', 'FFFDA1', 'D5FCB1', 'B5F7D0', 'BFFFFF', 'D6ECFF', 'CFE2F3', 'D9D1E9', 'FFE3FD', 'FFD9F0'], - ['EA9899', 'F9CB9C', 'FFE48C', 'F7F56F', 'B9F77E', '84F0B1', '83F7F7', 'B5DAFF', '9FC5E8', 'B4A7D6', 'FAB9F6', 'FFADDE'], - ['E06666', 'F6B26B', 'DEB737', 'E0DE51', '8FDB48', '52D189', '4EDEDB', '76ACE3', '6FA8DC', '8E7CC3', 'E07EDA', 'F26DBD'], - ['CC0814', 'E69138', 'AB8816', 'B5B20E', '6BAB30', '27A85F', '1BA8A6', '3C81C7', '3D85C6', '674EA7', 'A14F9D', 'BF4990'], - ['99050C', 'B45F17', '80650E', '737103', '395E14', '10783D', '13615E', '094785', '0A5394', '351C75', '780172', '782C5A'] - ]; - } - var pal = $.fn.w2colorPalette; - if (typeof options === 'string') options = { - color: options, - transparent: true - }; - if (options.onSelect == null && callBack != null) options.onSelect = callBack; - // add remove transarent color - if (options.transparent && pal[0][1] == '333333') { - pal[0].splice(1, 1); - pal[0].push(''); - } - if (!options.transparent && pal[0][1] != '333333') { - pal[0].splice(1, 0, '333333'); - pal[0].pop(); - } - if (options.color) options.color = String(options.color).toUpperCase(); - if (typeof options.color === 'string' && options.color.substr(0,1) === '#') options.color = options.color.substr(1); - if (options.fireChange == null) options.fireChange = true; - - if ($('#w2ui-overlay').length === 0) { - $(el).w2overlay(getColorHTML(options), options); - } else { // only refresh contents - $('#w2ui-overlay .w2ui-colors').parent().html(getColorHTML(options)); - $('#w2ui-overlay').show(); - } - // bind events - $('#w2ui-overlay .w2ui-color') - .off('.w2color') - .on('mousedown.w2color', function (event) { - var color = $(event.originalEvent.target).attr('name'); // should not have # - index = $(event.originalEvent.target).attr('index').split(':'); - if (el.tagName.toUpperCase() === 'INPUT') { - if (options.fireChange) $(el).change(); - $(el).next().find('>div').css('background-color', color); - } else { - $(el).data('_color', color); - } - if (typeof options.onSelect === 'function') options.onSelect(color); - }) - .on('mouseup.w2color', function () { - setTimeout(function () { - if ($("#w2ui-overlay").length > 0) $('#w2ui-overlay').removeData('keepOpen')[0].hide(); - }, 10); - }); - $('#w2ui-overlay .color-original') - .off('.w2color') - .on('click.w2color', function (event) { - // restore original color - var tmp = w2utils.parseColor($(event.target).css('background-color')); - if (tmp != null) { - rgb = tmp; - hsv = w2utils.rgb2hsv(rgb); - setColor(hsv); - updateSlides(); - refreshPalette(); - } - }); - $('#w2ui-overlay input') - .off('.w2color') - .on('mousedown.w2color', function (event) { - $('#w2ui-overlay').data('keepOpen', true); - setTimeout(function () { $('#w2ui-overlay').data('keepOpen', true); }, 10); - event.stopPropagation(); - }) - .on('change.w2color', function () { - var $el = $(this); - var val = parseFloat($el.val()); - var max = parseFloat($el.attr('max')); - if (isNaN(val)) val = 0; - if (max > 1) val = parseInt(val); - if (max > 0 && val > max) { - $el.val(max); - val = max; - } - if (val < 0) { - $el.val(0); - val = 0; - } - var name = $el.attr('name'); - var color = {}; - if (['r', 'g', 'b', 'a'].indexOf(name) !== -1) { - rgb[name] = val; - hsv = w2utils.rgb2hsv(rgb); - } else if (['h', 's', 'v'].indexOf(name) !== -1) { - color[name] = val; - } - setColor(color); - updateSlides(); - refreshPalette(); - }); - // advanced color events - var initial; - var hsv, rgb = w2utils.parseColor(options.color); - if (rgb == null) { - rgb = { r: 140, g: 150, b: 160, a: 1 }; - hsv = w2utils.rgb2hsv(rgb); - } - hsv = w2utils.rgb2hsv(rgb); - - var setColor = function (color, silent) { - if (color.h != null) hsv.h = color.h; - if (color.s != null) hsv.s = color.s; - if (color.v != null) hsv.v = color.v; - if (color.a != null) { rgb.a = color.a; hsv.a = color.a; } - rgb = w2utils.hsv2rgb(hsv); - // console.log(rgb) - var newColor = 'rgba('+ rgb.r +','+ rgb.g +','+ rgb.b +','+ rgb.a +')'; - var cl = [ - Number(rgb.r).toString(16).toUpperCase(), - Number(rgb.g).toString(16).toUpperCase(), - Number(rgb.b).toString(16).toUpperCase(), - (Math.round(Number(rgb.a)*255)).toString(16).toUpperCase() - ]; - cl.forEach(function (item, ind) { if (item.length === 1) cl[ind] = '0' + item; }); - newColor = cl[0] + cl[1] + cl[2] + cl[3]; - if (rgb.a === 1) { - newColor = cl[0] + cl[1] + cl[2]; - } - $('#w2ui-overlay .color-preview').css('background-color', '#'+newColor); - $('#w2ui-overlay input').each(function (index, el) { - if (el.name) { - if (rgb[el.name] != null) el.value = rgb[el.name]; - if (hsv[el.name] != null) el.value = hsv[el.name]; - if (el.name === 'a') el.value = rgb.a; - } - }); - if (!silent) { - if (el.tagName.toUpperCase() === 'INPUT') { - $(el).val(newColor).data('skipInit', true); - if (options.fireChange) $(el).change(); - $(el).next().find('>div').css('background-color', '#'+newColor); - } else { - $(el).data('_color', newColor); - } - if (typeof options.onSelect === 'function') options.onSelect(newColor); - } else { - $('#w2ui-overlay .color-original').css('background-color', '#'+newColor); - } - } - var updateSlides = function () { - var $el1 = $('#w2ui-overlay .palette .value1'); - var $el2 = $('#w2ui-overlay .rainbow .value2'); - var $el3 = $('#w2ui-overlay .alpha .value2'); - var offset1 = parseInt($el1.width()) / 2; - var offset2 = parseInt($el2.width()) / 2; - $el1.css({ 'left': hsv.s * 150 / 100 - offset1, 'top': (100 - hsv.v) * 125 / 100 - offset1}); - $el2.css('left', hsv.h/(360/150) - offset2); - $el3.css('left', rgb.a*150 - offset2); - } - var refreshPalette = function() { - var cl = w2utils.hsv2rgb(hsv.h, 100, 100); - var rgb = cl.r + ',' + cl.g + ',' + cl.b; - $('#w2ui-overlay .palette').css('background-image', - 'linear-gradient(90deg, rgba('+ rgb +',0) 0%, rgba(' + rgb + ',1) 100%)'); - } - var mouseDown = function (event) { - var $el = $(this).find('.value1, .value2'); - var offset = parseInt($el.width()) / 2; - if ($el.hasClass('move-x')) $el.css({ left: (event.offsetX - offset) + 'px' }); - if ($el.hasClass('move-y')) $el.css({ top: (event.offsetY - offset) + 'px' }); - initial = { - $el : $el, - x : event.pageX, - y : event.pageY, - width : $el.parent().width(), - height : $el.parent().height(), - left : parseInt($el.css('left')), - top : parseInt($el.css('top')) - }; - mouseMove(event); - $('body').off('.w2color') - .on(mMove, mouseMove) - .on(mUp, mouseUp); - }; - var mouseUp = function(event) { - $('body').off('.w2color'); - }; - var mouseMove = function(event) { - var $el = initial.$el; - var divX = event.pageX - initial.x; - var divY = event.pageY - initial.y; - var newX = initial.left + divX; - var newY = initial.top + divY; - var offset = parseInt($el.width()) / 2; - if (newX < -offset) newX = -offset; - if (newY < -offset) newY = -offset; - if (newX > initial.width - offset) newX = initial.width - offset; - if (newY > initial.height - offset) newY = initial.height - offset - if ($el.hasClass('move-x')) $el.css({ left : newX + 'px' }); - if ($el.hasClass('move-y')) $el.css({ top : newY + 'px' }); - - // move - var name = $el.parent().attr('name'); - var x = parseInt($el.css('left')) + offset; - var y = parseInt($el.css('top')) + offset; - if (name === 'palette') { - setColor({ - s: Math.round(x / initial.width * 100), - v: Math.round(100 - (y / initial.height * 100)) - }); - } - if (name === 'rainbow') { - var h = Math.round(360 / 150 * x); - setColor({ h: h }); - refreshPalette(); - } - if (name === 'alpha') { - setColor({ a: parseFloat(Number(x / 150).toFixed(2)) }); - } - } - if ($.fn._colorAdvanced === true || options.advanced === true) { - $('#w2ui-overlay .w2ui-color-tabs :nth-child(2)').click(); - $('#w2ui-overlay').removeData('keepOpen'); - } - setColor({}, true); - refreshPalette(); - updateSlides(); - - // Events of iOS - var mDown = 'mousedown.w2color'; - var mUp = 'mouseup.w2color'; - var mMove = 'mousemove.w2color'; - if (w2utils.isIOS) { - mDown = 'touchstart.w2color'; - mUp = 'touchend.w2color'; - mMove = 'touchmove.w2color '; - } - $('#w2ui-overlay .palette') - .off('.w2color') - .on('mousedown.w2color', mouseDown); - $('#w2ui-overlay .rainbow') - .off('.w2color') - .on('mousedown.w2color', mouseDown); - $('#w2ui-overlay .alpha') - .off('.w2color') - .on('mousedown.w2color', mouseDown); - - // keyboard navigation - el.nav = function (direction) { - switch (direction) { - case 'up': - index[0]--; - break; - case 'down': - index[0]++; - break; - case 'right': - index[1]++; - break; - case 'left': - index[1]--; - break; - } - if (index[0] < 0) index[0] = 0; - if (index[0] > pal.length - 2) index[0] = pal.length - 2; - if (index[1] < 0) index[1] = 0; - if (index[1] > pal[0].length - 1) index[1] = pal[0].length - 1; - - color = pal[index[0]][index[1]]; - $(el).data('_color', color); - return color; - }; - - function getColorHTML(options) { - var color = options.color, bor; - var html = '
'+ - '
'+ - ''; - for (var i = 0; i < pal.length; i++) { - html += ''; - for (var j = 0; j < pal[i].length; j++) { - if (pal[i][j] === 'FFFFFF') bor = ';border: 1px solid #efefef'; else bor = ''; - html += ''; - if (options.color == pal[i][j]) index = [i, j]; - } - html += ''; - if (i < 2) html += ''; - } - html += '
'+ - '
'+ (options.color == pal[i][j] ? '•' : ' ') + - '
'+ - '
'+ - '
'; - if (true) { - html += ''; - } - html += '
'+ - '
'+ - '
'+ - '
' + (typeof options.html == 'string' ? options.html : '') + '
' + - '
'+ - '
'+ - '
'; - return html; - } - }; -})(jQuery); - -/************************************************************************ -* Library: Web 2.0 UI for jQuery (using prototypical inheritance) -* - Following objects defined -* - w2grid - grid widget -* - $().w2grid - jQuery wrapper -* - Dependencies: jQuery, w2utils, w2toolbar, w2fields -* -* == NICE TO HAVE == -* - column autosize based on largest content -* - reorder columns/records -* - problem with .set() and arrays, array get extended too, but should be replaced -* - after edit stay on the same record option -* - if supplied array of ids, get should return array of records -* - allow functions in routeData (also add routeData to list/enum) -* - implement global routeData and all elements read from there -* - send parsed URL to the event if there is routeData -* - if you set searchData or sortData and call refresh() it should work -* - add selectType: 'none' so that no selection can be make but with mouse -* - reorder records with frozen columns -* - focus/blur for selectType = cell not display grayed out selection -* - frozen columns - - load more only on the right side - - scrolling on frozen columns is not working only on regular columns -* - copy or large number of records is slow -* - reusable search component (see https://github.com/vitmalina/w2ui/issues/914#issuecomment-107340524) -* - allow enum in inline edit (see https://github.com/vitmalina/w2ui/issues/911#issuecomment-107341193) -* - if record has no recid, then it should be index in the aray (should not be 0) -* -* == KNOWN ISSUES == -* - bug: vs_start = 100 and more then 500 records, when scrolling empty sets -* - row drag and drop has bugs -* - Shift-click/Ctrl-click/Ctrl-Shift-Click selection is not as robust as it should be -* -* == 1.5 changes -* - $('#grid').w2grid() - if called w/o argument then it returns grid object -* - added statusRange : true, -* statusBuffered : false, -* statusRecordID : true, -* statusSelection : true, -* statusResponse : true, -* statusSort : true, -* statusSearch : true, -* - change selectAll() and selectNone() - return time it took -* - added vs_start and vs_extra -* - added update(cells) - updates only data in the grid (or cells) -* - add to docs onColumnDragStart, onColumnDragEnd -* - onSelect and onSelect should fire 1 time for selects with shift or selectAll(), selectNone() -* - record.w2ui.style[field_name] -* - use column field for style: { 1: 'color: red' } -* - added focus(), blur(), onFocus, onBlur -* - search.simple - if false, will not show up in simple search -* - search.operator - default operator to use with search field -* - search.operators - array of operators for the search -* - search.hidden - could not be cleared by the user -* - search.value - only for hidden searches -* - if .search(val) - search all fields -* - refactor reorderRow (not finished) -* - return JSON can now have summary array -* - frozen columns -* - added selectionSave, selectionRestore - for internal use -* - added additional search filter options for int, float, date, time -* - added getLineHTML -* - added lineNumberWidth -* - add searches.style -* - getColumn without params returns fields of all columns -* - getSearch without params returns fields of all searches -* - added column.tooltip -* - added hasFocus, refactored w2utils.keyboard -* - do not clear selection when clicked and it was not in focus -* - added record.w2ui.colspan -* - editable area extends with typing -* - removed onSubmit and onDeleted - now it uses onSave and onDelete -* - column.seachable - can be an object, which will create search -* - added null, not null filters -* - update(cells) - added argument cells -* - scrollIntoView(..., ..., instant) - added third argument -* - added onResizeDblClick -* - added onColumnDblClick -* - implemented showBubble -* - added show.searchAll -* - added show.searchHiddenMsg -* - added w2grid.operators -* - added w2grid.operatorsMap -* - move events into prototype -* - move rec.summary, rec.style, rec.editable -> into rec.w2ui.summary, rec.w2ui.style, rec.w2ui.editable -* - record: { - recid - field1 - ... - fieldN - w2ui: { - colspan: { field: 5, ...} - editable: true/false - hideCheckBox: true/false, - changes: { - field: chagned_value, - .... - }, - children: [ - // similar to records array - // can have sub children - ] - parent_recid: (internally set, id of the parent record, when children are copied to records array) - summary: true/false - style: 'string' - for entire row OR { field: 'string', ...} - per field - class: 'string' - for entire row OR { field: 'string', ...} - per field - } - } -* - added this.show.toolbarInput -* - disableCVS -* - added nestedFields: use field name containing dots as separator to look into objects -* - grid.message -* - added noReset option to localSort() -* - onColumnSelect -* - need to update PHP example -* - added scrollToColumn(field) -* - textSearch: 'begins' (default), 'contains', 'is', ... -* - added refreshBody -* - added response.total = -1 (or not present) to indicate that number of records is unknown -* - message(.., callBack) - added callBack -* - grid.msgEmpty -* - field.render(..., data) -- added last argument which is what grid thinks should be there -* - field.render can return { html, class, style } as an object -* - onSearchOpen (onSearch will have mutli and reset flags) -* - added httpHeaders -* - col.editable can be a function which will be called with the same args as col.render() -* - col.clipboardCopy - display icon to copy to clipboard -* - clipboardCopy - new function on grid level -* - getCellEditable(index, col_ind) -- return an 'editable' descriptor if cell is really editable -* - added stateId -* - rec.w2ui.class (and rec.w2ui.class { fname: '...' }) -* - columnTooltip -* - expendable grids are still working -* - added search.type = 'color' -* - added getFirst -* - added stateColProps -* - added stateColDefaults -* - deprecated search.caption -> search.label -* - deprecated column.caption -> column.text -* - deprecated columnGroup.caption -> columnGroup.text -* - moved a lot of properties into prototype -* - showExtraOnSearch -* - added sortMap, searchMap -* - added column.hideable -* - added updateColumn -* - column.info { - icon : string|function|object, - style : string|function|object, - render : function, - fields : array|object, - showOn : 'mouseover|mouseenter|...', - hideOn : 'mouseout|mouseleave|...', - options : {} - will be passed to w2tag (for example options.potions = 'top') - } -* - added msgDeleteBtn -* - grid.toolbar.item batch -* - order.column -* - fixed select/unselect, not it can take array of ids -* - menuClick - changed parameters -* - column.text can be a function -* - columnGroup.text can be a function -* -************************************************************************/ - -(function ($) { - var w2grid = function(options) { - - // public properties - this.name = null; - this.box = null; // HTML element that hold this element - this.columns = []; // { field, text, size, attr, render, hidden, gridMinWidth, editable } - this.columnGroups = []; // { span: int, text: 'string', master: true/false } - this.records = []; // { recid: int(requied), field1: 'value1', ... fieldN: 'valueN', style: 'string', changes: object } - this.summary = []; // arry of summary records, same structure as records array - this.searches = []; // { type, label, field, inTag, outTag, hidden } - this.sortMap = {}; // remap sort Fields - this.toolbar = {}; // if not empty object; then it is toolbar object - this.ranges = []; - this.menu = []; - this.searchData = []; - this.sortData = []; - this.total = 0; // server total - this.recid = null; // field from records to be used as recid - - // internal - this.last = { - field : '', - label : '', - logic : 'OR', - search : '', - searchIds : [], - selection : { - indexes : [], - columns : {} - }, - multi : false, - scrollTop : 0, - scrollLeft : 0, - colStart : 0, // for column virtual scrolling - colEnd : 0, - sortData : null, - sortCount : 0, - xhr : null, - loaded : false, - range_start : null, - range_end : null, - sel_ind : null, - sel_col : null, - sel_type : null, - edit_col : null, - isSafari : (/^((?!chrome|android).)*safari/i).test(navigator.userAgent) - } - $.extend(true, this, w2obj.grid); - this.show = $.extend(true, {}, w2grid.prototype.show); - this.postData = $.extend(true, {}, w2grid.prototype.postData); - this.routeData = $.extend(true, {}, w2grid.prototype.routeData); - this.httpHeaders = $.extend(true, {}, w2grid.prototype.httpHeaders); - this.buttons = $.extend(true, {}, w2grid.prototype.buttons); - this.operators = $.extend(true, {}, w2grid.prototype.operators); - this.operatorsMap = $.extend(true, {}, w2grid.prototype.operatorsMap); - this.stateColProps = $.extend(true, {}, w2grid.prototype.stateColProps); - this.stateColDefaults = $.extend(true, {}, w2grid.prototype.stateColDefaults); - - $.extend(true, this, options); - } - - // ==================================================== - // -- Registers as a jQuery plugin - - $.fn.w2grid = function(method) { - if ($.isPlainObject(method)) { - // check name parameter - if (!w2utils.checkName(method, 'w2grid')) return; - // remember items - var columns = method.columns; - var columnGroups = method.columnGroups; - var records = method.records; - var searches = method.searches; - var searchData = method.searchData; - var sortData = method.sortData; - // extend items - var object = new w2grid(method); - $.extend(object, { records: [], columns: [], searches: [], sortData: [], searchData: [], handlers: [] }); - - // reassign variables - var p; - if (columns) for (p = 0; p < columns.length; p++) object.columns[p] = $.extend(true, {}, columns[p]); - if (columnGroups) for (p = 0; p < columnGroups.length; p++) object.columnGroups[p] = $.extend(true, {}, columnGroups[p]); - if (searches) for (p = 0; p < searches.length; p++) object.searches[p] = $.extend(true, {}, searches[p]); - if (searchData) for (p = 0; p < searchData.length; p++) object.searchData[p] = $.extend(true, {}, searchData[p]); - if (sortData) for (p = 0; p < sortData.length; p++) object.sortData[p] = $.extend(true, {}, sortData[p]); - - // check if there are records without recid - if (records) for (var r = 0; r < records.length; r++) { - if (records[r][object.recid] != null) { - records[r].recid = records[r][object.recid]; - } - if (records[r].recid == null) { - console.log('ERROR: Cannot add records without recid. (obj: '+ object.name +')'); - return; - } - object.records[r] = $.extend(true, {}, records[r]); - } - // add searches - for (var i = 0; i < object.columns.length; i++) { - var col = object.columns[i]; - var search = col.searchable; - if (search == null || search === false || object.getSearch(col.field) != null) continue; - if ($.isPlainObject(search)) { - object.addSearch($.extend({ field: col.field, label: col.text, type: 'text' }, search)); - } else { - var stype = col.searchable, attr = ''; - if (col.searchable === true) { stype = 'text'; attr = 'size="20"'; } - object.addSearch({ field: col.field, label: col.text, type: stype, attr: attr }); - } - } - // register new object - w2ui[object.name] = object; - // init toolbar - object.initToolbar(); - object.updateToolbar(); - // render if necessary - if ($(this).length !== 0) { - object.render($(this)[0]); - } - return object; - - } else { - var obj = w2ui[$(this).attr('name')]; - if (!obj) return null; - if (arguments.length > 0) { - if (obj[method]) obj[method].apply(obj, Array.prototype.slice.call(arguments, 1)); - return this; - } else { - return obj; - } - } - } - - // ==================================================== - // -- Implementation of core functionality - - w2grid.prototype = { - header : '', - url : '', - limit : 100, - offset : 0, // how many records to skip (for infinite scroll) when pulling from server - postData : {}, - routeData : {}, - httpHeaders : {}, - show: { - header : false, - toolbar : false, - footer : false, - columnHeaders : true, - lineNumbers : false, - orderColumn : false, - expandColumn : false, - selectColumn : false, - emptyRecords : true, - toolbarReload : true, - toolbarColumns : true, - toolbarSearch : true, - toolbarInput : true, - toolbarAdd : false, - toolbarEdit : false, - toolbarDelete : false, - toolbarSave : false, - searchAll : true, - searchHiddenMsg : false, - statusRange : true, - statusBuffered : false, - statusRecordID : true, - statusSelection : true, - statusResponse : true, - statusSort : false, - statusSearch : false, - recordTitles : true, - selectionBorder : true, - skipRecords : true, - saveRestoreState: true - }, - stateId : null, // Custom state name for stateSave, stateRestore and stateReset - hasFocus : false, - autoLoad : true, // for infinite scroll - fixedBody : true, // if false; then grid grows with data - recordHeight : 24, // should be in prototype - lineNumberWidth : null, - keyboard : true, - selectType : 'row', // can be row|cell - multiSearch : true, - multiSelect : true, - multiSort : true, - reorderColumns : false, - reorderRows : false, - showExtraOnSearch : 0, // show extra records before and after on search - markSearch : true, - columnTooltip : 'top|bottom', // can be normal, top, bottom, left, right - disableCVS : false, // disable Column Virtual Scroll - textSearch : 'begins', // default search type for text - nestedFields : true, // use field name containing dots as separator to look into object - vs_start : 150, - vs_extra : 15, - style : '', - method : null, // if defined, then overwrited ajax method - dataType : null, // if defined, then overwrited w2utils.settings.dataType - parser : null, - - // these column properties will be saved in stateSave() - stateColProps: { - text : false, - field : true, - size : true, - min : false, - max : false, - gridMinWidth : false, - sizeCorrected : false, - sizeCalculated : true, - sizeOriginal : true, - sizeType : true, - hidden : true, - sortable : false, - searchable : false, - clipboardCopy : false, - resizable : false, - hideable : false, - attr : false, - style : false, - render : false, - title : false, - editable : false, - frozen : true, - info : false, - }, - - // these are the stateSave() fallback values if the property to save is not a property of the column object - stateColDefaults: { - text : '', // column text - field : '', // field name to map column to a record - size : null, // size of column in px or % - min : 20, // minimum width of column in px - max : null, // maximum width of column in px - gridMinWidth : null, // minimum width of the grid when column is visible - sizeCorrected : null, // read only, corrected size (see explanation below) - sizeCalculated : null, // read only, size in px (see explanation below) - sizeOriginal : null, - sizeType : null, - hidden : false, // indicates if column is hidden - sortable : false, // indicates if column is sortable - searchable : false, // indicates if column is searchable, bool/string: int,float,date,... - clipboardCopy : false, - resizable : true, // indicates if column is resizable - hideable : true, // indicates if column can be hidden - attr : '', // string that will be inside the tag - style : '', // additional style for the td tag - render : null, // string or render function - title : null, // string or function for the title property for the column cells - editable : {}, // editable object if column fields are editable - frozen : false, // indicates if the column is fixed to the left - info : null // info bubble, can be bool/object - }, - - msgDelete : 'Are you sure you want to delete NN records?', - msgDeleteBtn : 'Delete', - msgNotJSON : 'Returned data is not in valid JSON format.', - msgAJAXerror : 'AJAX error. See console for more details.', - msgRefresh : 'Refreshing...', - msgNeedReload : 'Your remote data source record count has changed, reloading from the first record.', - msgEmpty : '', // if not blank, then it is message when server returns no records - - buttons: { - 'reload' : { type: 'button', id: 'w2ui-reload', icon: 'w2ui-icon-reload', tooltip: 'Reload data in the list' }, - 'columns' : { type: 'drop', id: 'w2ui-column-on-off', icon: 'w2ui-icon-columns', tooltip: 'Show/hide columns', arrow: false, html: '' }, - 'search' : { type: 'html', id: 'w2ui-search', - html: '
' - }, - 'search-go': { type: 'drop', id: 'w2ui-search-advanced', icon: 'w2ui-icon-search', text: 'Search', tooltip: 'Open Search Fields' }, - 'add' : { type: 'button', id: 'w2ui-add', text: 'Add New', tooltip: 'Add new record', icon: 'w2ui-icon-plus' }, - 'edit' : { type: 'button', id: 'w2ui-edit', text: 'Edit', tooltip: 'Edit selected record', icon: 'w2ui-icon-pencil', disabled: true }, - 'delete' : { type: 'button', id: 'w2ui-delete', text: 'Delete', tooltip: 'Delete selected records', icon: 'w2ui-icon-cross', disabled: true }, - 'save' : { type: 'button', id: 'w2ui-save', text: 'Save', tooltip: 'Save changed records', icon: 'w2ui-icon-check' } - }, - - operators: { // for search fields - "text" : ['is', 'begins', 'contains', 'ends'], - "number" : ['=', 'between', '>', '<', '>=', '<='], - "date" : ['is', 'between', { oper: 'less', text: 'before'}, { oper: 'more', text: 'after' }], - "list" : ['is'], - "hex" : ['is', 'between'], - "color" : ['is', 'begins', 'contains', 'ends'], - "enum" : ['in', 'not in'] - // -- all possible - // "text" : ['is', 'begins', 'contains', 'ends'], - // "number" : ['is', 'between', 'less:less than', 'more:more than', 'null:is null', 'not null:is not null'], - // "list" : ['is', 'null:is null', 'not null:is not null'], - // "enum" : ['in', 'not in', 'null:is null', 'not null:is not null'] - }, - - operatorsMap: { - "text" : "text", - "int" : "number", - "float" : "number", - "money" : "number", - "currency" : "number", - "percent" : "number", - "hex" : "hex", - "alphanumeric" : "text", - "color" : "color", - "date" : "date", - "time" : "date", - "datetime" : "date", - "list" : "list", - "combo" : "text", - "enum" : "enum", - "file" : "enum", - "select" : "list", - "radio" : "list", - "checkbox" : "list", - "toggle" : "list" - }, - - // events - onAdd : null, - onEdit : null, - onRequest : null, // called on any server event - onLoad : null, - onDelete : null, - onSave : null, - onSelect : null, - onUnselect : null, - onClick : null, - onDblClick : null, - onContextMenu : null, - onMenuClick : null, // when context menu item selected - onColumnClick : null, - onColumnDblClick : null, - onColumnResize : null, - onColumnAutoResize : null, - onSort : null, - onSearch : null, - onSearchOpen : null, - onChange : null, // called when editable record is changed - onRestore : null, // called when editable record is restored - onExpand : null, - onCollapse : null, - onError : null, - onKeydown : null, - onToolbar : null, // all events from toolbar - onColumnOnOff : null, - onCopy : null, - onPaste : null, - onSelectionExtend : null, - onEditField : null, - onRender : null, - onRefresh : null, - onReload : null, - onResize : null, - onDestroy : null, - onStateSave : null, - onStateRestore : null, - onFocus : null, - onBlur : null, - onReorderRow : null, - - add: function (record, first) { - if (!$.isArray(record)) record = [record]; - var added = 0; - for (var i = 0; i < record.length; i++) { - var rec = record[i]; - if (rec[this.recid] != null) { - rec.recid = rec[this.recid]; - } - if (rec.recid == null) { - console.log('ERROR: Cannot add record without recid. (obj: '+ this.name +')'); - continue; - } - if (rec.w2ui && rec.w2ui.summary === true) { - if (first) this.summary.unshift(rec); else this.summary.push(rec); - } else { - if (first) this.records.unshift(rec); else this.records.push(rec); - } - added++; - } - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - this.total = this.records.length; - this.localSort(false, true); - this.localSearch(); - // do not call this.refresh(), this is unnecessary, heavy, and messes with the toolbar. - this.refreshBody(); - this.resizeRecords(); - return added; - } - this.refresh(); // ?? should it be reload? - return added; - }, - - find: function (obj, returnIndex) { - if (obj == null) obj = {}; - var recs = []; - var hasDots = false; - // check if property is nested - needed for speed - for (var o in obj) if (String(o).indexOf('.') != -1) hasDots = true; - // look for an item - for (var i = 0; i < this.records.length; i++) { - var match = true; - for (var o in obj) { - var val = this.records[i][o]; - if (hasDots && String(o).indexOf('.') != -1) val = this.parseField(this.records[i], o); - if (obj[o] == 'not-null') { - if (val == null || val === '') match = false; - } else { - if (obj[o] != val) match = false; - } - } - if (match && returnIndex !== true) recs.push(this.records[i].recid); - if (match && returnIndex === true) recs.push(i); - } - return recs; - }, - - set: function (recid, record, noRefresh) { // does not delete existing, but overrides on top of it - if ((typeof recid == 'object') && (recid !== null)) { - noRefresh = record; - record = recid; - recid = null; - } - // update all records - if (recid == null) { - for (var i = 0; i < this.records.length; i++) { - $.extend(true, this.records[i], record); // recid is the whole record - } - if (noRefresh !== true) this.refresh(); - } else { // find record to update - var ind = this.get(recid, true); - if (ind == null) return false; - var isSummary = (this.records[ind] && this.records[ind].recid == recid ? false : true); - if (isSummary) { - $.extend(true, this.summary[ind], record); - } else { - $.extend(true, this.records[ind], record); - } - if (noRefresh !== true) this.refreshRow(recid, ind); // refresh only that record - } - return true; - }, - - get: function (recid, returnIndex) { - // search records - if ($.isArray(recid)) { - var recs = []; - for (var i = 0; i < recid.length; i++) { - var v = this.get(recid[i], returnIndex); - if (v !== null) - recs.push(v); - } - return recs; - } else { - // get() must be fast, implements a cache to bypass loop over all records - // most of the time. - var idCache = this.last.idCache; - if (!idCache) { - this.last.idCache = idCache = {}; - } - var i = idCache[recid]; - if (typeof(i) === "number") { - if (i >= 0 && i < this.records.length && this.records[i].recid == recid) { - if (returnIndex === true) return i; else return this.records[i]; - } - // summary indexes are stored as negative numbers, try them now. - i = ~i; - if (i >= 0 && i < this.summary.length && this.summary[i].recid == recid) { - if (returnIndex === true) return i; else return this.summary[i]; - } - // wrong index returned, clear cache - this.last.idCache = idCache = {}; - } - for (var i = 0; i < this.records.length; i++) { - if (this.records[i].recid == recid) { - idCache[recid] = i; - if (returnIndex === true) return i; else return this.records[i]; - } - } - // search summary - for (var i = 0; i < this.summary.length; i++) { - if (this.summary[i].recid == recid) { - idCache[recid] = ~i; - if (returnIndex === true) return i; else return this.summary[i]; - } - } - return null; - } - }, - - getFirst: function () { - if (this.records.length == 0) return null; - var recid = this.records[0].recid; - var tmp = this.last.searchIds; - if (this.searchData.length > 0) { - if (Array.isArray(tmp) && tmp.length > 0) { - recid = this.records[tmp[0]].recid; - } else { - recid = null; - } - } - return recid; - }, - - remove: function () { - var removed = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.records.length-1; r >= 0; r--) { - if (this.records[r].recid == arguments[a]) { this.records.splice(r, 1); removed++; } - } - for (var r = this.summary.length-1; r >= 0; r--) { - if (this.summary[r].recid == arguments[a]) { this.summary.splice(r, 1); removed++; } - } - } - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - this.localSort(false, true); - this.localSearch(); - } - this.refresh(); - return removed; - }, - - addColumn: function (before, columns) { - var added = 0; - if (arguments.length == 1) { - columns = before; - before = this.columns.length; - } else { - if (typeof before == 'string') before = this.getColumn(before, true); - if (before == null) before = this.columns.length; - } - if (!$.isArray(columns)) columns = [columns]; - for (var i = 0; i < columns.length; i++) { - this.columns.splice(before, 0, columns[i]); - // if column is searchable, add search field - if (columns[i].searchable) { - var stype = columns[i].searchable; - var attr = ''; - if (columns[i].searchable === true) { stype = 'text'; attr = 'size="20"'; } - this.addSearch({ field: columns[i].field, label: columns[i].label, type: stype, attr: attr }); - } - before++; - added++; - } - this.refresh(); - return added; - }, - - removeColumn: function () { - var removed = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.columns.length-1; r >= 0; r--) { - if (this.columns[r].field == arguments[a]) { - if (this.columns[r].searchable) this.removeSearch(arguments[a]); - this.columns.splice(r, 1); - removed++; - } - } - } - this.refresh(); - return removed; - }, - - getColumn: function (field, returnIndex) { - // no arguments - return fields of all columns - if (arguments.length === 0) { - var ret = []; - for (var i = 0; i < this.columns.length; i++) ret.push(this.columns[i].field); - return ret; - } - // find column - for (var i = 0; i < this.columns.length; i++) { - if (this.columns[i].field == field) { - if (returnIndex === true) return i; else return this.columns[i]; - } - } - return null; - }, - - updateColumn: function (names, updates) { - var obj = this; - var effected = 0; - names = (Array.isArray(names) ? names : [names]); - names.forEach(function (colName) { - obj.columns.forEach(function (col) { - if (col.field == colName) { - var _updates = $.extend(true, {}, updates); - Object.keys(_updates).forEach(function (key) { - // if it is a function - if (typeof _updates[key] == 'function') { - _updates[key] = _updates[key](col); - } - if (col[key] != _updates[key]) effected++ - }) - $.extend(true, col, _updates) - } - }) - }); - if (effected > 0) { - this.refresh(); // need full refresh due to colgroups not resiging properly - } - return effected; - }, - - toggleColumn: function () { - return this.updateColumn(Array.from(arguments), { hidden: function (col) { return !col.hidden } }); - }, - - showColumn: function () { - return this.updateColumn(Array.from(arguments), { hidden: false }); - }, - - hideColumn: function () { - return this.updateColumn(Array.from(arguments), { hidden: true }); - }, - - addSearch: function (before, search) { - var added = 0; - if (arguments.length == 1) { - search = before; - before = this.searches.length; - } else { - if (typeof before == 'string') before = this.getSearch(before, true); - if (before == null) before = this.searches.length; - } - if (!$.isArray(search)) search = [search]; - for (var i = 0; i < search.length; i++) { - this.searches.splice(before, 0, search[i]); - before++; - added++; - } - this.searchClose(); - return added; - }, - - removeSearch: function () { - var removed = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.searches.length-1; r >= 0; r--) { - if (this.searches[r].field == arguments[a]) { this.searches.splice(r, 1); removed++; } - } - } - this.searchClose(); - return removed; - }, - - getSearch: function (field, returnIndex) { - // no arguments - return fields of all searches - if (arguments.length === 0) { - var ret = []; - for (var i = 0; i < this.searches.length; i++) ret.push(this.searches[i].field); - return ret; - } - // find search - for (var i = 0; i < this.searches.length; i++) { - if (this.searches[i].field == field) { - if (returnIndex === true) return i; else return this.searches[i]; - } - } - return null; - }, - - toggleSearch: function () { - var effected = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.searches.length-1; r >= 0; r--) { - if (this.searches[r].field == arguments[a]) { - this.searches[r].hidden = !this.searches[r].hidden; - effected++; - } - } - } - this.searchClose(); - return effected; - }, - - showSearch: function () { - var shown = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.searches.length-1; r >= 0; r--) { - if (this.searches[r].field == arguments[a] && this.searches[r].hidden !== false) { - this.searches[r].hidden = false; - shown++; - } - } - } - this.searchClose(); - return shown; - }, - - hideSearch: function () { - var hidden = 0; - for (var a = 0; a < arguments.length; a++) { - for (var r = this.searches.length-1; r >= 0; r--) { - if (this.searches[r].field == arguments[a] && this.searches[r].hidden !== true) { - this.searches[r].hidden = true; - hidden++; - } - } - } - this.searchClose(); - return hidden; - }, - - getSearchData: function (field) { - for (var i = 0; i < this.searchData.length; i++) { - if (this.searchData[i].field == field) return this.searchData[i]; - } - return null; - }, - - localSort: function (silent, noResetRefresh) { - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (url) { - console.log('ERROR: grid.localSort can only be used on local data source, grid.url should be empty.'); - return; - } - if ($.isEmptyObject(this.sortData)) return; - var time = (new Date()).getTime(); - var obj = this; - // process date fields - obj.selectionSave(); - obj.prepareData(); - if (!noResetRefresh) { - obj.reset(); - } - // process sortData - for (var i = 0; i < this.sortData.length; i++) { - var column = this.getColumn(this.sortData[i].field); - if (!column) return; - if (typeof column.render == 'string') { - if (['date', 'age'].indexOf(column.render.split(':')[0]) != -1) { - this.sortData[i]['field_'] = column.field + '_'; - } - if (['time'].indexOf(column.render.split(':')[0]) != -1) { - this.sortData[i]['field_'] = column.field + '_'; - } - } - } - - // prepare paths and process sort - preparePaths(); - this.records.sort(function (a, b) { - return compareRecordPaths(a, b); - }); - cleanupPaths(); - - obj.selectionRestore(noResetRefresh); - time = (new Date()).getTime() - time; - if (silent !== true && obj.show.statusSort) { - setTimeout(function () { - obj.status(w2utils.lang('Sorting took') + ' ' + time/1000 + ' ' + w2utils.lang('sec')); - }, 10); - } - return time; - - // grab paths before sorting for efficiency and because calling obj.get() - // while sorting 'obj.records' is unsafe, at least on webkit - function preparePaths() { - for (var i = 0; i < obj.records.length; i++) { - var rec = obj.records[i]; - if (rec.w2ui && rec.w2ui.parent_recid != null) { - rec.w2ui._path = getRecordPath(rec); - } - } - } - - // cleanup and release memory allocated by preparePaths() - function cleanupPaths() { - for (var i = 0; i < obj.records.length; i++) { - var rec = obj.records[i]; - if (rec.w2ui && rec.w2ui.parent_recid != null) { - rec.w2ui._path = null; - } - } - } - - // compare two paths, from root of tree to given records - function compareRecordPaths(a, b) { - if ((!a.w2ui || a.w2ui.parent_recid == null) && (!b.w2ui || b.w2ui.parent_recid == null)) { - return compareRecords(a, b); // no tree, fast path - } - var pa = getRecordPath(a); - var pb = getRecordPath(b); - for (var i = 0; i < Math.min(pa.length, pb.length); i++) { - var diff = compareRecords(pa[i], pb[i]); - if (diff !== 0) return diff; // different subpath - } - if (pa.length > pb.length) return 1; - if (pa.length < pb.length) return -1; - console.log('ERROR: two paths should not be equal.'); - return 0; - } - - // return an array of all records from root to and including 'rec' - function getRecordPath(rec) { - if (!rec.w2ui || rec.w2ui.parent_recid == null) return [rec]; - if (rec.w2ui._path) - return rec.w2ui._path; - // during actual sort, we should never reach this point - var subrec = obj.get(rec.w2ui.parent_recid); - if (!subrec) { - console.log('ERROR: no parent record: '+rec.w2ui.parent_recid); - return [rec]; - } - return (getRecordPath(subrec).concat(rec)); - } - - // compare two records according to sortData and finally recid - function compareRecords(a, b) { - if (a === b) return 0; // optimize, same object - for (var i = 0; i < obj.sortData.length; i++) { - var fld = obj.sortData[i].field; - var sortFld = (obj.sortData[i].field_) ? obj.sortData[i].field_ : fld; - var aa = a[sortFld]; - var bb = b[sortFld]; - if (String(fld).indexOf('.') != -1) { - aa = obj.parseField(a, sortFld); - bb = obj.parseField(b, sortFld); - } - var col = obj.getColumn(fld); - if (col && col.editable != null) { // for drop editable fields and drop downs - if ($.isPlainObject(aa) && aa.text) aa = aa.text; - if ($.isPlainObject(bb) && bb.text) bb = bb.text; - } - var ret = compareCells(aa, bb, i, obj.sortData[i].direction, col.sortMode || 'default'); - if (ret !== 0) return ret; - } - // break tie for similar records, - // required to have consistent ordering for tree paths - var ret = compareCells(a.recid, b.recid, -1, 'asc'); - return ret; - } - - // compare two values, aa and bb, producing consistent ordering - function compareCells(aa, bb, i, direction, sortMode) { - // if both objects are strictly equal, we're done - if (aa === bb) - return 0; - // all nulls, empty and undefined on bottom - if ((aa == null || aa === "") && (bb != null && bb !== "")) - return 1; - if ((aa != null && aa !== "") && (bb == null || bb === "")) - return -1; - var dir = (direction.toLowerCase() === 'asc') ? 1 : -1; - // for different kind of objects, sort by object type - if (typeof aa != typeof bb) - return (typeof aa > typeof bb) ? dir : -dir; - // for different kind of classes, sort by classes - if (aa.constructor.name != bb.constructor.name) - return (aa.constructor.name > bb.constructor.name) ? dir : -dir; - // if we're dealing with non-null objects, call valueOf(). - // this mean that Date() or custom objects will compare properly. - if (aa && typeof aa == 'object') - aa = aa.valueOf(); - if (bb && typeof bb == 'object') - bb = bb.valueOf(); - // if we're still dealing with non-null objects that have - // a useful Object => String conversion, convert to string. - var defaultToString = {}.toString; - if (aa && typeof aa == 'object' && aa.toString != defaultToString) - aa = String(aa); - if (bb && typeof bb == 'object' && bb.toString != defaultToString) - bb = String(bb); - // do case-insensitive string comparison - if (typeof aa == 'string') - aa = $.trim(aa.toLowerCase()); - if (typeof bb == 'string') - bb = $.trim(bb.toLowerCase()); - - switch (sortMode) { - case 'natural': - sortMode = w2utils.naturalCompare; - break; - } - - if (typeof sortMode == 'function') { - return sortMode(aa,bb) * dir; - } - - // compare both objects - if (aa > bb) - return dir; - if (aa < bb) - return -dir; - return 0; - } - }, - - localSearch: function (silent) { - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (url) { - console.log('ERROR: grid.localSearch can only be used on local data source, grid.url should be empty.'); - return; - } - var time = (new Date()).getTime(); - var obj = this; - var defaultToString = {}.toString; - var duplicateMap = {}; - this.total = this.records.length; - // mark all records as shown - this.last.searchIds = []; - // prepare date/time fields - this.prepareData(); - // hide records that did not match - if (this.searchData.length > 0 && !url) { - this.total = 0; - for (var i = 0; i < this.records.length; i++) { - var rec = this.records[i]; - var match = searchRecord(rec); - if (match) { - if (rec && rec.w2ui) addParent(rec.w2ui.parent_recid); - if (this.showExtraOnSearch > 0) { - var before = this.showExtraOnSearch; - var after = this.showExtraOnSearch; - if (i < before) before = i; - if (i + after > this.records.length) after = this.records.length - i; - if (before > 0) { - for (var j = i - before; j < i; j++) { - if (this.last.searchIds.indexOf(j) < 0) - this.last.searchIds.push(j); - } - } - if (this.last.searchIds.indexOf(i) < 0) this.last.searchIds.push(i); - if (after > 0) { - for (var j = (i + 1) ; j <= (i + after ) ; j++) { - if (this.last.searchIds.indexOf(j) < 0) this.last.searchIds.push(j); - } - } - } else { - this.last.searchIds.push(i); - } - } - } - this.total = this.last.searchIds.length; - } - time = (new Date()).getTime() - time; - if (silent !== true && obj.show.statusSearch) { - setTimeout(function () { - obj.status(w2utils.lang('Search took') + ' ' + time/1000 + ' ' + w2utils.lang('sec')); - }, 10); - } - return time; - - // check if a record (or one of its closed children) matches the search data - function searchRecord(rec) { - var fl = 0; - var orEqual = false; - for (var j = 0; j < obj.searchData.length; j++) { - var sdata = obj.searchData[j]; - var search = obj.getSearch(sdata.field); - if (sdata == null) continue; - if (search == null) search = { field: sdata.field, type: sdata.type }; - var val1b = obj.parseField(rec, search.field); - var val1 = (val1b !== null && val1b !== undefined && - (typeof val1b != "object" || val1b.toString != defaultToString)) ? - String(val1b).toLowerCase() : ""; // do not match a bogus string - if (sdata.value != null) { - if (!$.isArray(sdata.value)) { - var val2 = String(sdata.value).toLowerCase(); - } else { - var val2 = sdata.value[0]; - var val3 = sdata.value[1]; - } - } - switch (sdata.operator) { - case '=': - case 'is': - if (obj.parseField(rec, search.field) == sdata.value) fl++; // do not hide record - else if (search.type == 'date') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatDate(tmp, 'yyyy-mm-dd'); - var val2 = w2utils.formatDate(w2utils.isDate(val2, w2utils.settings.dateFormat, true), 'yyyy-mm-dd'); - if (val1 == val2) fl++; - } - else if (search.type == 'time') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatTime(tmp, 'hh24:mi'); - var val2 = w2utils.formatTime(val2, 'hh24:mi'); - if (val1 == val2) fl++; - } - else if (search.type == 'datetime') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatDateTime(tmp, 'yyyy-mm-dd|hh24:mm:ss'); - var val2 = w2utils.formatDateTime(w2utils.isDateTime(val2, w2utils.settings.datetimeFormat, true), 'yyyy-mm-dd|hh24:mm:ss'); - if (val1 == val2) fl++; - } - break; - case 'between': - if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1) { - if (parseFloat(obj.parseField(rec, search.field)) >= parseFloat(val2) && parseFloat(obj.parseField(rec, search.field)) <= parseFloat(val3)) fl++; - } - else if (search.type == 'date') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.isDate(tmp, w2utils.settings.dateFormat, true); - var val2 = w2utils.isDate(val2, w2utils.settings.dateFormat, true); - var val3 = w2utils.isDate(val3, w2utils.settings.dateFormat, true); - if (val3 != null) val3 = new Date(val3.getTime() + 86400000); // 1 day - if (val1 >= val2 && val1 < val3) fl++; - } - else if (search.type == 'time') { - var val1 = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val2 = w2utils.isTime(val2, true); - var val3 = w2utils.isTime(val3, true); - val2 = (new Date()).setHours(val2.hours, val2.minutes, val2.seconds ? val2.seconds : 0, 0); - val3 = (new Date()).setHours(val3.hours, val3.minutes, val3.seconds ? val3.seconds : 0, 0); - if (val1 >= val2 && val1 < val3) fl++; - } - else if (search.type == 'datetime') { - var val1 = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val2 = w2utils.isDateTime(val2, w2utils.settings.datetimeFormat, true); - var val3 = w2utils.isDateTime(val3, w2utils.settings.datetimeFormat, true); - if (val3) val3 = new Date(val3.getTime() + 86400000); // 1 day - if (val1 >= val2 && val1 < val3) fl++; - } - break; - case '<=': - orEqual = true - case '<': - case 'less': - if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1) { - var val1 = parseFloat(obj.parseField(rec, search.field)); - var val2 = parseFloat(sdata.value); - if (val1 < val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'date') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.isDate(tmp, w2utils.settings.dateFormat, true); - var val2 = w2utils.isDate(val2, w2utils.settings.dateFormat, true); - if (val1 < val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'time') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatTime(tmp, 'hh24:mi'); - var val2 = w2utils.formatTime(val2, 'hh24:mi'); - if (val1 < val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'datetime') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatDateTime(tmp, 'yyyy-mm-dd|hh24:mm:ss'); - var val2 = w2utils.formatDateTime(w2utils.isDateTime(val2, w2utils.settings.datetimeFormat, true), 'yyyy-mm-dd|hh24:mm:ss'); - if (val1.length == val2.length && (val1 < val2 || (orEqual && val1 === val2))) fl++; - } - break; - case '>=': - orEqual = true - case '>': - case 'more': - if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1) { - var val1 = parseFloat(obj.parseField(rec, search.field)); - var val2 = parseFloat(sdata.value); - if (val1 > val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'date') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.isDate(tmp, w2utils.settings.dateFormat, true); - var val2 = w2utils.isDate(val2, w2utils.settings.dateFormat, true); - if (val1 > val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'time') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatTime(tmp, 'hh24:mi'); - var val2 = w2utils.formatTime(val2, 'hh24:mi'); - if (val1 > val2 || (orEqual && val1 === val2)) fl++; - } - else if (search.type == 'datetime') { - var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field)); - var val1 = w2utils.formatDateTime(tmp, 'yyyy-mm-dd|hh24:mm:ss'); - var val2 = w2utils.formatDateTime(w2utils.isDateTime(val2, w2utils.settings.datetimeFormat, true), 'yyyy-mm-dd|hh24:mm:ss'); - if (val1.length == val2.length && (val1 > val2 || (orEqual && val1 === val2))) fl++; - } - break; - case 'in': - var tmp = sdata.value; - if (sdata.svalue) tmp = sdata.svalue; - if ((tmp.indexOf(w2utils.isFloat(val1b) ? parseFloat(val1b) : val1b) !== -1) || tmp.indexOf(val1) !== -1) fl++; - break; - case 'not in': - var tmp = sdata.value; - if (sdata.svalue) tmp = sdata.svalue; - if (!((tmp.indexOf(w2utils.isFloat(val1b) ? parseFloat(val1b) : val1b) !== -1) || tmp.indexOf(val1) !== -1)) fl++; - break; - case 'begins': - case 'begins with': // need for back compatib. - if (val1.indexOf(val2) === 0) fl++; // do not hide record - break; - case 'contains': - if (val1.indexOf(val2) >= 0) fl++; // do not hide record - break; - case 'null': - if (obj.parseField(rec, search.field) == null) fl++; // do not hide record - break; - case 'not null': - if (obj.parseField(rec, search.field) != null) fl++; // do not hide record - break; - case 'ends': - case 'ends with': // need for back compatib. - var lastIndex = val1.lastIndexOf(val2); - if (lastIndex !== -1 && lastIndex == val1.length - val2.length) fl++; // do not hide record - break; - } - } - if ((obj.last.logic == 'OR' && fl !== 0) || - (obj.last.logic == 'AND' && fl == obj.searchData.length)) - return true; - if (rec.w2ui && rec.w2ui.children && rec.w2ui.expanded !== true) { - // there are closed children, search them too. - for (var r = 0; r < rec.w2ui.children.length; r++) { - var subRec = rec.w2ui.children[r]; - if (searchRecord(subRec)) - return true; - } - } - return false; - } - - // add parents nodes recursively - function addParent(recid) { - if (recid === undefined) - return; - if (duplicateMap[recid]) - return; // already visited - duplicateMap[recid] = true; - var i = obj.get(recid, true); - if (i == null) - return; - if ($.inArray(i, obj.last.searchIds) != -1) - return; - var rec = obj.records[i]; - if (rec && rec.w2ui) - addParent(rec.w2ui.parent_recid); - obj.last.searchIds.push(i); - } - }, - - getRangeData: function (range, extra) { - var rec1 = this.get(range[0].recid, true); - var rec2 = this.get(range[1].recid, true); - var col1 = range[0].column; - var col2 = range[1].column; - - var res = []; - if (col1 == col2) { // one row - for (var r = rec1; r <= rec2; r++) { - var record = this.records[r]; - var dt = record[this.columns[col1].field] || null; - if (extra !== true) { - res.push(dt); - } else { - res.push({ data: dt, column: col1, index: r, record: record }); - } - } - } else if (rec1 == rec2) { // one line - var record = this.records[rec1]; - for (var i = col1; i <= col2; i++) { - var dt = record[this.columns[i].field] || null; - if (extra !== true) { - res.push(dt); - } else { - res.push({ data: dt, column: i, index: rec1, record: record }); - } - } - } else { - for (var r = rec1; r <= rec2; r++) { - var record = this.records[r]; - res.push([]); - for (var i = col1; i <= col2; i++) { - var dt = record[this.columns[i].field]; - if (extra !== true) { - res[res.length-1].push(dt); - } else { - res[res.length-1].push({ data: dt, column: i, index: r, record: record }); - } - } - } - } - return res; - }, - - addRange: function (ranges) { - var added = 0; - if (this.selectType == 'row') return added; - if (!$.isArray(ranges)) ranges = [ranges]; - // if it is selection - for (var i = 0; i < ranges.length; i++) { - if (typeof ranges[i] != 'object') ranges[i] = { name: 'selection' }; - if (ranges[i].name == 'selection') { - if (this.show.selectionBorder === false) continue; - var sel = this.getSelection(); - if (sel.length === 0) { - this.removeRange('selection'); - continue; - } else { - var first = sel[0]; - var last = sel[sel.length-1]; - } - } else { // other range - var first = ranges[i].range[0]; - var last = ranges[i].range[1]; - } - if (first) { - var rg = { - name: ranges[i].name, - range: [{ recid: first.recid, column: first.column }, { recid: last.recid, column: last.column }], - style: ranges[i].style || '' - }; - // add range - var ind = false; - for (var j = 0; j < this.ranges.length; j++) if (this.ranges[j].name == ranges[i].name) { ind = j; break; } - if (ind !== false) { - this.ranges[ind] = rg; - } else { - this.ranges.push(rg); - } - added++; - } - } - this.refreshRanges(); - return added; - }, - - removeRange: function () { - var removed = 0; - for (var a = 0; a < arguments.length; a++) { - var name = arguments[a]; - $('#grid_'+ this.name +'_'+ name).remove(); - $('#grid_'+ this.name +'_f'+ name).remove(); - for (var r = this.ranges.length-1; r >= 0; r--) { - if (this.ranges[r].name == name) { - this.ranges.splice(r, 1); - removed++; - } - } - } - return removed; - }, - - refreshRanges: function () { - if (this.ranges.length === 0) return; - var obj = this; - var time = (new Date()).getTime(); - var rec1 = $('#grid_'+ this.name +'_frecords'); - var rec2 = $('#grid_'+ this.name +'_records'); - for (var i = 0; i < this.ranges.length; i++) { - var rg = this.ranges[i]; - var first = rg.range[0]; - var last = rg.range[1]; - if (first.index == null) first.index = this.get(first.recid, true); - if (last.index == null) last.index = this.get(last.recid, true); - var td1 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(first.recid) + ' td[col="'+ first.column +'"]'); - var td2 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(last.recid) + ' td[col="'+ last.column +'"]'); - var td1f = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(first.recid) + ' td[col="'+ first.column +'"]'); - var td2f = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(last.recid) + ' td[col="'+ last.column +'"]'); - var _lastColumn = last.column; - // adjustment due to column virtual scroll - if (first.column < this.last.colStart && last.column > this.last.colStart) { - td1 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(first.recid) + ' td[col="start"]'); - } - if (first.column < this.last.colEnd && last.column > this.last.colEnd) { - _lastColumn = '"end"'; - td2 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(last.recid) + ' td[col="end"]'); - } - // if virtual scrolling kicked in - var index_top = parseInt($('#grid_'+ this.name +'_rec_top').next().attr('index')); - var index_bottom = parseInt($('#grid_'+ this.name +'_rec_bottom').prev().attr('index')); - var index_ftop = parseInt($('#grid_'+ this.name +'_frec_top').next().attr('index')); - var index_fbottom = parseInt($('#grid_'+ this.name +'_frec_bottom').prev().attr('index')); - if (td1.length === 0 && first.index < index_top && last.index > index_top) { - td1 = $('#grid_'+ this.name +'_rec_top').next().find('td[col='+ first.column +']'); - } - if (td2.length === 0 && last.index > index_bottom && first.index < index_bottom) { - td2 = $('#grid_'+ this.name +'_rec_bottom').prev().find('td[col='+ _lastColumn +']'); - } - if (td1f.length === 0 && first.index < index_ftop && last.index > index_ftop) { // frozen - td1f = $('#grid_'+ this.name +'_frec_top').next().find('td[col='+ first.column +']'); - } - if (td2f.length === 0 && last.index > index_fbottom && first.index < index_fbottom) { // frozen - td2f = $('#grid_'+ this.name +'_frec_bottom').prev().find('td[col='+ last.column +']'); - } - - // do not show selection cell if it is editable - var edit = $(this.box).find('#grid_'+ this.name + '_editable'); - var tmp = edit.find('.w2ui-input'); - var tmp1 = tmp.attr('recid'); - var tmp2 = tmp.attr('column'); - if (rg.name == 'selection' && rg.range[0].recid == tmp1 && rg.range[0].column == tmp2) continue; - - // frozen regular columns range - var $range = $('#grid_'+ this.name +'_f'+ rg.name); - if (td1f.length > 0 || td2f.length > 0) { - if ($range.length === 0) { - rec1.append('
'+ - (rg.name == 'selection' ? '
' : '')+ - '
'); - $range = $('#grid_'+ this.name +'_f'+ rg.name); - } else { - $range.attr('style', rg.style); - $range.find('.w2ui-selection-resizer').show(); - } - if (td2f.length === 0) { - td2f = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(last.recid) +' td:last-child'); - if (td2f.length === 0) td2f = $('#grid_'+ this.name +'_frec_bottom td:first-child'); - $range.css('border-right', '0px'); - $range.find('.w2ui-selection-resizer').hide(); - } - if (first.recid != null && last.recid != null && td1f.length > 0 && td2f.length > 0) { - var _left = (td1f.position().left - 0 + rec1.scrollLeft()); - var _top = (td1f.position().top - 0 + rec1.scrollTop()); - $range.show().css({ - left : (_left > 0 ? _left : 0) + 'px', - top : (_top > 0 ? _top : 0) + 'px', - width : (td2f.position().left - td1f.position().left + td2f.width() + 2) + 'px', - height : (td2f.position().top - td1f.position().top + td2f.height() + 1) + 'px' - }); - } else { - $range.hide(); - } - } else { - $range.hide(); - } - // regular columns range - var $range = $('#grid_'+ this.name +'_'+ rg.name); - if (td1.length > 0 || td2.length > 0) { - if ($range.length === 0) { - rec2.append('
'+ - (rg.name == 'selection' ? '
' : '')+ - '
'); - $range = $('#grid_'+ this.name +'_'+ rg.name); - } else { - $range.attr('style', rg.style); - } - if (td1.length === 0) { - td1 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(first.recid) +' td:first-child'); - if (td1.length === 0) td1 = $('#grid_'+ this.name +'_rec_top td:first-child'); - } - if (td2f.length !== 0) { - $range.css('border-left', '0px'); - } - if (first.recid != null && last.recid != null && td1.length > 0 && td2.length > 0) { - var _left = (td1.position().left - 0 + rec2.scrollLeft()); - var _top = (td1.position().top - 0 + rec2.scrollTop()); - $range.show().css({ - left : (_left > 0 ? _left : 0) + 'px', - top : (_top > 0 ? _top : 0) + 'px', - width : (td2.position().left - td1.position().left + td2.width() + 2) + 'px', - height : (td2.position().top - td1.position().top + td2.height() + 1) + 'px' - }); - } else { - $range.hide(); - } - } else { - $range.hide(); - } - } - - // add resizer events - $(this.box).find('.w2ui-selection-resizer') - .off('mousedown').on('mousedown', mouseStart) - .off('dblclick').on('dblclick', function (event) { - var edata = obj.trigger({ phase: 'before', type: 'resizerDblClick', target: obj.name, originalEvent: event }); - if (edata.isCancelled === true) return; - obj.trigger($.extend(edata, { phase: 'after' })); - }); - var edata = { phase: 'before', type: 'selectionExtend', target: obj.name, originalRange: null, newRange: null }; - - return (new Date()).getTime() - time; - - function mouseStart (event) { - var sel = obj.getSelection(); - obj.last.move = { - type : 'expand', - x : event.screenX, - y : event.screenY, - divX : 0, - divY : 0, - recid : sel[0].recid, - column : sel[0].column, - originalRange : [{ recid: sel[0].recid, column: sel[0].column }, { recid: sel[sel.length-1].recid, column: sel[sel.length-1].column }], - newRange : [{ recid: sel[0].recid, column: sel[0].column }, { recid: sel[sel.length-1].recid, column: sel[sel.length-1].column }] - }; - $(document) - .off('.w2ui-' + obj.name) - .on('mousemove.w2ui-' + obj.name, mouseMove) - .on('mouseup.w2ui-' + obj.name, mouseStop); - // do not blur grid - event.preventDefault(); - } - - function mouseMove (event) { - var mv = obj.last.move; - if (!mv || mv.type != 'expand') return; - mv.divX = (event.screenX - mv.x); - mv.divY = (event.screenY - mv.y); - // find new cell - var recid, column; - var tmp = event.originalEvent.target; - if (tmp.tagName.toUpperCase() != 'TD') tmp = $(tmp).parents('td')[0]; - if ($(tmp).attr('col') != null) column = parseInt($(tmp).attr('col')); - tmp = $(tmp).parents('tr')[0]; - recid = $(tmp).attr('recid'); - // new range - if (mv.newRange[1].recid == recid && mv.newRange[1].column == column) return; - var prevNewRange = $.extend({}, mv.newRange); - mv.newRange = [{ recid: mv.recid, column: mv.column }, { recid: recid, column: column }]; - // event before - edata = obj.trigger($.extend(edata, { originalRange: mv.originalRange, newRange : mv.newRange })); - if (edata.isCancelled === true) { - mv.newRange = prevNewRange; - edata.newRange = prevNewRange; - return; - } else { - // default behavior - obj.removeRange('grid-selection-expand'); - obj.addRange({ - name : 'grid-selection-expand', - range : edata.newRange, - style : 'background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);' - }); - } - } - - function mouseStop (event) { - // default behavior - obj.removeRange('grid-selection-expand'); - delete obj.last.move; - $(document).off('.w2ui-' + obj.name); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - } - }, - - select: function () { - if (arguments.length === 0) return 0; - var time = (new Date).getTime(); - var selected = 0; - var sel = this.last.selection; - if (!this.multiSelect) this.selectNone(); - // if too manu arguments > 150k, then it errors off - var args = Array.prototype.slice.call(arguments) - if (Array.isArray(args[0])) args = args[0] - // event before - var tmp = { phase: 'before', type: 'select', target: this.name }; - if (args.length == 1) { - tmp.multiple = false; - if ($.isPlainObject(args[0])) { - tmp.recid = args[0].recid; - tmp.column = args[0].column; - } else { - tmp.recid = args[0]; - } - } else { - tmp.multiple = true; - tmp.recids = args; - } - var edata = this.trigger(tmp); - if (edata.isCancelled === true) return 0; - - // default action - if (this.selectType == 'row') { - for (var a = 0; a < args.length; a++) { - var recid = typeof args[a] == 'object' ? args[a].recid : args[a]; - var index = this.get(recid, true); - if (index == null) continue; - var recEl1 = null; - var recEl2 = null; - if (this.searchData.length !== 0 || (index + 1 >= this.last.range_start && index + 1 <= this.last.range_end)) { - recEl1 = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)); - recEl2 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)); - } - if (this.selectType == 'row') { - if (sel.indexes.indexOf(index) != -1) continue; - sel.indexes.push(index); - if (recEl1 && recEl2) { - recEl1.addClass('w2ui-selected').data('selected', 'yes').find('.w2ui-col-number').addClass('w2ui-row-selected'); - recEl2.addClass('w2ui-selected').data('selected', 'yes').find('.w2ui-col-number').addClass('w2ui-row-selected'); - recEl1.find('.w2ui-grid-select-check').prop("checked", true); - } - selected++; - } - } - } else { - // normalize for performance - var new_sel = {}; - for (var a = 0; a < args.length; a++) { - var recid = typeof args[a] == 'object' ? args[a].recid : args[a]; - var column = typeof args[a] == 'object' ? args[a].column : null; - new_sel[recid] = new_sel[recid] || []; - if ($.isArray(column)) { - new_sel[recid] = column; - } else if (w2utils.isInt(column)) { - new_sel[recid].push(column); - } else { - for (var i = 0; i < this.columns.length; i++) { if (this.columns[i].hidden) continue; new_sel[recid].push(parseInt(i)); } - } - } - // add all - var col_sel = []; - for (var recid in new_sel) { - var index = this.get(recid, true); - if (index == null) continue; - var recEl1 = null; - var recEl2 = null; - if (index + 1 >= this.last.range_start && index + 1 <= this.last.range_end) { - recEl1 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)); - recEl2 = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)); - } - var s = sel.columns[index] || []; - // default action - if (sel.indexes.indexOf(index) == -1) { - sel.indexes.push(index); - } - // anly only those that are new - for (var t = 0; t < new_sel[recid].length; t++) { - if (s.indexOf(new_sel[recid][t]) == -1) s.push(new_sel[recid][t]); - } - s.sort(function(a, b) { return a-b; }); // sort function must be for numerical sort - for (var t = 0; t < new_sel[recid].length; t++) { - var col = new_sel[recid][t]; - if (col_sel.indexOf(col) == -1) col_sel.push(col); - if (recEl1) { - recEl1.find('#grid_'+ this.name +'_data_'+ index +'_'+ col).addClass('w2ui-selected'); - recEl1.find('.w2ui-col-number').addClass('w2ui-row-selected'); - recEl1.data('selected', 'yes'); - recEl1.find('.w2ui-grid-select-check').prop("checked", true); - } - if (recEl2) { - recEl2.find('#grid_'+ this.name +'_data_'+ index +'_'+ col).addClass('w2ui-selected'); - recEl2.find('.w2ui-col-number').addClass('w2ui-row-selected'); - recEl2.data('selected', 'yes'); - recEl2.find('.w2ui-grid-select-check').prop("checked", true); - } - selected++; - } - // save back to selection object - sel.columns[index] = s; - } - // select columns (need here for speed) - for (var c = 0; c < col_sel.length; c++) { - $(this.box).find('#grid_'+ this.name +'_column_'+ col_sel[c] +' .w2ui-col-header').addClass('w2ui-col-selected'); - } - } - // need to sort new selection for speed - sel.indexes.sort(function(a, b) { return a-b; }); - // all selected? - var areAllSelected = (this.records.length > 0 && sel.indexes.length == this.records.length), - areAllSearchedSelected = (sel.indexes.length > 0 && this.searchData.length !== 0 && sel.indexes.length == this.last.searchIds.length); - if (areAllSelected || areAllSearchedSelected) { - $('#grid_'+ this.name +'_check_all').prop('checked', true); - } else { - $('#grid_'+ this.name +'_check_all').prop('checked', false); - } - this.status(); - this.addRange('selection'); - this.updateToolbar(sel, areAllSelected); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return selected; - }, - - unselect: function () { - var unselected = 0; - var sel = this.last.selection; - // if too manu arguments > 150k, then it errors off - var args = Array.prototype.slice.call(arguments) - if (Array.isArray(args[0])) args = args[0] - // event before - var tmp = { phase: 'before', type: 'unselect', target: this.name }; - if (args.length == 1) { - tmp.multiple = false; - if ($.isPlainObject(args[0])) { - tmp.recid = args[0].recid; - tmp.column = args[0].column; - } else { - tmp.recid = args[0]; - } - } else { - tmp.multiple = true; - tmp.recids = args - } - var edata = this.trigger(tmp); - if (edata.isCancelled === true) return 0; - - for (var a = 0; a < args.length; a++) { - var recid = typeof args[a] == 'object' ? args[a].recid : args[a]; - var record = this.get(recid); - if (record == null) continue; - var index = this.get(record.recid, true); - var recEl1 = $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)); - var recEl2 = $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)); - if (this.selectType == 'row') { - if (sel.indexes.indexOf(index) == -1) continue; - // default action - sel.indexes.splice(sel.indexes.indexOf(index), 1); - recEl1.removeClass('w2ui-selected w2ui-inactive').removeData('selected').find('.w2ui-col-number').removeClass('w2ui-row-selected'); - recEl2.removeClass('w2ui-selected w2ui-inactive').removeData('selected').find('.w2ui-col-number').removeClass('w2ui-row-selected'); - if (recEl1.length != 0) { - recEl1[0].style.cssText = 'height: '+ this.recordHeight +'px; ' + recEl1.attr('custom_style'); - recEl2[0].style.cssText = 'height: '+ this.recordHeight +'px; ' + recEl2.attr('custom_style'); - } - recEl1.find('.w2ui-grid-select-check').prop("checked", false); - unselected++; - } else { - var col = args[a].column; - if (!w2utils.isInt(col)) { // unselect all columns - var cols = []; - for (var i = 0; i < this.columns.length; i++) { if (this.columns[i].hidden) continue; cols.push({ recid: recid, column: i }); } - return this.unselect(cols); - } - var s = sel.columns[index]; - if (!$.isArray(s) || s.indexOf(col) == -1) continue; - // default action - s.splice(s.indexOf(col), 1); - $('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)).find(' > td[col='+ col +']').removeClass('w2ui-selected w2ui-inactive'); - $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)).find(' > td[col='+ col +']').removeClass('w2ui-selected w2ui-inactive'); - // check if any row/column still selected - var isColSelected = false; - var isRowSelected = false; - var tmp = this.getSelection(); - for (var i = 0; i < tmp.length; i++) { - if (tmp[i].column == col) isColSelected = true; - if (tmp[i].recid == recid) isRowSelected = true; - } - if (!isColSelected) { - $(this.box).find('.w2ui-grid-columns td[col='+ col +'] .w2ui-col-header, .w2ui-grid-fcolumns td[col='+ col +'] .w2ui-col-header').removeClass('w2ui-col-selected'); - } - if (!isRowSelected) { - $('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)).find('.w2ui-col-number').removeClass('w2ui-row-selected'); - } - unselected++; - if (s.length === 0) { - delete sel.columns[index]; - sel.indexes.splice(sel.indexes.indexOf(index), 1); - recEl1.removeData('selected'); - recEl1.find('.w2ui-grid-select-check').prop("checked", false); - recEl2.removeData('selected'); - } - } - } - // all selected? - var areAllSelected = (this.records.length > 0 && sel.indexes.length == this.records.length), - areAllSearchedSelected = (sel.indexes.length > 0 && this.searchData.length !== 0 && sel.indexes.length == this.last.searchIds.length); - if (areAllSelected || areAllSearchedSelected) { - $('#grid_'+ this.name +'_check_all').prop('checked', true); - } else { - $('#grid_'+ this.name +'_check_all').prop('checked', false); - } - // show number of selected - this.status(); - this.addRange('selection'); - this.updateToolbar(sel, areAllSelected); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return unselected; - }, - - selectAll: function () { - var time = (new Date()).getTime(); - if (this.multiSelect === false) return; - // event before - var edata = this.trigger({ phase: 'before', type: 'select', target: this.name, all: true }); - if (edata.isCancelled === true) return; - // default action - var url = (typeof this.url != 'object' ? this.url : this.url.get); - var sel = this.last.selection; - var cols = []; - for (var i = 0; i < this.columns.length; i++) cols.push(i); - // if local data source and searched - sel.indexes = []; - if (!url && this.searchData.length !== 0) { - // local search applied - for (var i = 0; i < this.last.searchIds.length; i++) { - sel.indexes.push(this.last.searchIds[i]); - if (this.selectType != 'row') sel.columns[this.last.searchIds[i]] = cols.slice(); // .slice makes copy of the array - } - } else { - var buffered = this.records.length; - if (this.searchData.length != 0 && !url) buffered = this.last.searchIds.length; - for (var i = 0; i < buffered; i++) { - sel.indexes.push(i); - if (this.selectType != 'row') sel.columns[i] = cols.slice(); // .slice makes copy of the array - } - } - // add selected class - if (this.selectType == 'row') { - $(this.box).find('.w2ui-grid-records tr').not('.w2ui-empty-record') - .addClass('w2ui-selected').data('selected', 'yes').find('.w2ui-col-number').addClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-frecords tr').not('.w2ui-empty-record') - .addClass('w2ui-selected').data('selected', 'yes').find('.w2ui-col-number').addClass('w2ui-row-selected'); - $(this.box).find('input.w2ui-grid-select-check').prop('checked', true); - } else { - $(this.box).find('.w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header').addClass('w2ui-col-selected'); - $(this.box).find('.w2ui-grid-records tr .w2ui-col-number').addClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-records tr').not('.w2ui-empty-record') - .find('.w2ui-grid-data').not('.w2ui-col-select').addClass('w2ui-selected').data('selected', 'yes'); - $(this.box).find('.w2ui-grid-frecords tr .w2ui-col-number').addClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-frecords tr').not('.w2ui-empty-record') - .find('.w2ui-grid-data').not('.w2ui-col-select').addClass('w2ui-selected').data('selected', 'yes'); - $(this.box).find('input.w2ui-grid-select-check').prop('checked', true); - } - // enable/disable toolbar buttons - var sel = this.getSelection(true); - if (sel.length == 1) this.toolbar.enable('w2ui-edit'); else this.toolbar.disable('w2ui-edit'); - if (sel.length >= 1) this.toolbar.enable('w2ui-delete'); else this.toolbar.disable('w2ui-delete'); - this.addRange('selection'); - $('#grid_'+ this.name +'_check_all').prop('checked', true); - this.status(); - this.updateToolbar({ indexes: sel }, true); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return (new Date()).getTime() - time; - }, - - selectNone: function () { - var time = (new Date()).getTime(); - // event before - var edata = this.trigger({ phase: 'before', type: 'unselect', target: this.name, all: true }); - if (edata.isCancelled === true) return; - // default action - var sel = this.last.selection; - // remove selected class - if (this.selectType == 'row') { - $(this.box).find('.w2ui-grid-records tr.w2ui-selected').removeClass('w2ui-selected w2ui-inactive').removeData('selected') - .find('.w2ui-col-number').removeClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-frecords tr.w2ui-selected').removeClass('w2ui-selected w2ui-inactive').removeData('selected') - .find('.w2ui-col-number').removeClass('w2ui-row-selected'); - $(this.box).find('input.w2ui-grid-select-check').prop('checked', false); - } else { - $(this.box).find('.w2ui-grid-columns td .w2ui-col-header, .w2ui-grid-fcolumns td .w2ui-col-header').removeClass('w2ui-col-selected'); - $(this.box).find('.w2ui-grid-records tr .w2ui-col-number').removeClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-frecords tr .w2ui-col-number').removeClass('w2ui-row-selected'); - $(this.box).find('.w2ui-grid-data.w2ui-selected').removeClass('w2ui-selected w2ui-inactive').removeData('selected'); - $(this.box).find('input.w2ui-grid-select-check').prop('checked', false); - } - sel.indexes = []; - sel.columns = {}; - this.toolbar.disable('w2ui-edit', 'w2ui-delete'); - this.removeRange('selection'); - $('#grid_'+ this.name +'_check_all').prop('checked', false); - this.status(); - this.updateToolbar(sel, false); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return (new Date()).getTime() - time; - }, - - updateToolbar: function (sel, areAllSelected) { - var obj = this - var cnt = sel && sel.indexes ? sel.indexes.length : 0 - this.toolbar.items.forEach(function (item) { - _checkItem(item, '') - if (Array.isArray(item.items)) { - item.items.forEach(function (it) { - _checkItem(it, item.id + ':') - }) - } - }) - - function _checkItem(item, prefix) { - if (item.batch === 0) { - if (cnt > 0) obj.toolbar.enable(prefix + item.id); else obj.toolbar.disable(prefix + item.id) - } - if (item.batch != null && !isNaN(item.batch) && item.batch > 0) { - if (cnt == item.batch) obj.toolbar.enable(prefix + item.id); else obj.toolbar.disable(prefix + item.id) - } - if (typeof item.batch == 'function') { - item.batch(obj.selectType == 'cell' ? sel : (sel ? sel.indexes : null)) - } - } - }, - - getSelection: function (returnIndex) { - var ret = []; - var sel = this.last.selection; - if (this.selectType == 'row') { - for (var i = 0; i < sel.indexes.length; i++) { - if (!this.records[sel.indexes[i]]) continue; - if (returnIndex === true) ret.push(sel.indexes[i]); else ret.push(this.records[sel.indexes[i]].recid); - } - return ret; - } else { - for (var i = 0; i < sel.indexes.length; i++) { - var cols = sel.columns[sel.indexes[i]]; - if (!this.records[sel.indexes[i]]) continue; - for (var j = 0; j < cols.length; j++) { - ret.push({ recid: this.records[sel.indexes[i]].recid, index: parseInt(sel.indexes[i]), column: cols[j] }); - } - } - return ret; - } - }, - - search: function (field, value) { - var obj = this; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - var searchData = []; - var last_multi = this.last.multi; - var last_logic = this.last.logic; - var last_field = this.last.field; - var last_search = this.last.search; - var hasHiddenSearches = false; - // add hidden searches - for (var i = 0; i < this.searches.length; i++) { - if (!this.searches[i].hidden || this.searches[i].value == null) continue; - searchData.push({ - field : this.searches[i].field, - operator : this.searches[i].operator || 'is', - type : this.searches[i].type, - value : this.searches[i].value || '' - }); - hasHiddenSearches = true; - } - // 1: search() - advanced search (reads from popup) - if (arguments.length === 0) { - last_search = ''; - // advanced search - for (var i = 0; i < this.searches.length; i++) { - var search = this.searches[i]; - var operator = $('#grid_'+ this.name + '_operator_'+ i).val(); - var field1 = $('#grid_'+ this.name + '_field_'+ i); - var field2 = $('#grid_'+ this.name + '_field2_'+ i); - var value1 = field1.val(); - var value2 = field2.val(); - var svalue = null; - var text = null; - - if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1) { - var fld1 = field1.data('w2field'); - var fld2 = field2.data('w2field'); - if (fld1) value1 = fld1.clean(value1); - if (fld2) value2 = fld2.clean(value2); - } - if (['list', 'enum'].indexOf(search.type) != -1) { - value1 = field1.data('selected') || {}; - if ($.isArray(value1)) { - svalue = []; - for (var j = 0; j < value1.length; j++) { - svalue.push(w2utils.isFloat(value1[j].id) ? parseFloat(value1[j].id) : String(value1[j].id).toLowerCase()); - delete value1[j].hidden; - } - if ($.isEmptyObject(value1)) value1 = ''; - } else { - text = value1.text || ''; - value1 = value1.id || ''; - } - } - if ((value1 !== '' && value1 != null) || (value2 != null && value2 !== '')) { - var tmp = { - field : search.field, - type : search.type, - operator : operator - }; - if (operator == 'between') { - $.extend(tmp, { value: [value1, value2] }); - } else if (operator == 'in' && typeof value1 == 'string') { - $.extend(tmp, { value: value1.split(',') }); - } else if (operator == 'not in' && typeof value1 == 'string') { - $.extend(tmp, { value: value1.split(',') }); - } else { - $.extend(tmp, { value: value1 }); - } - if (svalue) $.extend(tmp, { svalue: svalue }); - if (text) $.extend(tmp, { text: text }); - - // conver date to unix time - try { - if (search.type == 'date' && operator == 'between') { - tmp.value[0] = value1; // w2utils.isDate(value1, w2utils.settings.dateFormat, true).getTime(); - tmp.value[1] = value2; // w2utils.isDate(value2, w2utils.settings.dateFormat, true).getTime(); - } - if (search.type == 'date' && operator == 'is') { - tmp.value = value1; // w2utils.isDate(value1, w2utils.settings.dateFormat, true).getTime(); - } - } catch (e) { - - } - searchData.push(tmp); - last_multi = true; // if only hidden searches, then do not set - } - } - last_logic = 'AND'; - } - // 2: search(field, value) - regular search - if (typeof field == 'string') { - // if only one argument - search all - if (arguments.length == 1) { - value = field; - field = 'all'; - } - last_field = field; - last_search = value; - last_multi = false; - last_logic = (hasHiddenSearches ? 'AND' : 'OR'); - // loop through all searches and see if it applies - if (value != null) { - if (field.toLowerCase() == 'all') { - // if there are search fields loop thru them - if (this.searches.length > 0) { - for (var i = 0; i < this.searches.length; i++) { - var search = this.searches[i]; - if (search.type == 'text' || (search.type == 'alphanumeric' && w2utils.isAlphaNumeric(value)) - || (search.type == 'int' && w2utils.isInt(value)) || (search.type == 'float' && w2utils.isFloat(value)) - || (search.type == 'percent' && w2utils.isFloat(value)) || ((search.type == 'hex' || search.type == 'color') && w2utils.isHex(value)) - || (search.type == 'currency' && w2utils.isMoney(value)) || (search.type == 'money' && w2utils.isMoney(value)) - || (search.type == 'date' && w2utils.isDate(value)) || (search.type == 'time' && w2utils.isTime(value)) - || (search.type == 'datetime' && w2utils.isDateTime(value)) || (search.type == 'datetime' && w2utils.isDate(value)) - || (search.type == 'enum' && w2utils.isAlphaNumeric(value)) || (search.type == 'list' && w2utils.isAlphaNumeric(value)) - ) { - var tmp = { - field : search.field, - type : search.type, - operator : (search.operator != null ? search.operator : (search.type == 'text' ? this.textSearch : 'is')), - value : value - }; - if ($.trim(value) != '') searchData.push(tmp); - } - // range in global search box - if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1 && $.trim(String(value)).split('-').length == 2) { - var t = $.trim(String(value)).split('-'); - var tmp = { - field : search.field, - type : search.type, - operator : (search.operator != null ? search.operator : 'between'), - value : [t[0], t[1]] - }; - searchData.push(tmp); - } - // lists fiels - if (['list', 'enum'].indexOf(search.type) != -1) { - var new_values = []; - if (search.options == null) search.options = {}; - if (!Array.isArray(search.options.items)) search.options.items = []; - for (var j = 0; j < search.options.items; j++) { - var tmp = search.options.items[j]; - try { - var re = new RegExp(value, 'i'); - if (re.test(tmp)) new_values.push(j); - if (tmp.text && re.test(tmp.text)) new_values.push(tmp.id); - } catch (e) {} - } - if (new_values.length > 0) { - var tmp = { - field : search.field, - type : search.type, - operator : (search.operator != null ? search.operator : 'in'), - value : new_values - }; - searchData.push(tmp); - } - } - } - } else { - // no search fields, loop thru columns - for (var i = 0; i < this.columns.length; i++) { - var tmp = { - field : this.columns[i].field, - type : 'text', - operator : this.textSearch, - value : value - }; - searchData.push(tmp); - } - } - } else { - var el = $('#grid_'+ this.name +'_search_all'); - var search = this.getSearch(field); - if (search == null) search = { field: field, type: 'text' }; - if (search.field == field) this.last.label = search.label; - if (value !== '') { - var op = this.textSearch; - var val = value; - if (['date', 'time', 'datetime'].indexOf(search.type) != -1) op = 'is'; - if (['list', 'enum'].indexOf(search.type) != -1) { - op = 'is'; - var tmp = el.data('selected'); - if (tmp && !$.isEmptyObject(tmp)) val = tmp.id; else val = ''; - } - if (search.type == 'int' && value !== '') { - op = 'is'; - if (String(value).indexOf('-') != -1) { - var tmp = value.split('-'); - if (tmp.length == 2) { - op = 'between'; - val = [parseInt(tmp[0]), parseInt(tmp[1])]; - } - } - if (String(value).indexOf(',') != -1) { - var tmp = value.split(','); - op = 'in'; - val = []; - for (var i = 0; i < tmp.length; i++) val.push(tmp[i]); - } - } - if (search.operator != null) op = search.operator; - var tmp = { - field : search.field, - type : search.type, - operator : op, - value : val - }; - searchData.push(tmp); - } - } - } - } - // 3: search([ { field, value, [operator,] [type] }, { field, value, [operator,] [type] } ], logic) - submit whole structure - if ($.isArray(field)) { - var logic = 'AND'; - if (typeof value == 'string') { - logic = value.toUpperCase(); - if (logic != 'OR' && logic != 'AND') logic = 'AND'; - } - last_search = ''; - last_multi = true; - last_logic = logic; - for (var i = 0; i < field.length; i++) { - var data = field[i]; - if (typeof data.value == 'number') data.operator = 'is'; - if (typeof data.value == 'string') data.operator = this.textSearch; - if ($.isArray(data.value)) data.operator = 'in' - // merge current field and search if any - searchData.push(data); - } - } - // event before - var edata = this.trigger({ - phase: 'before', type: 'search', target: this.name, multi: (arguments.length === 0 ? true : false), - searchField: (field ? field : 'multi'), searchValue: (field ? value : 'multi'), - searchData: searchData, searchLogic: last_logic }); - if (edata.isCancelled === true) return; - // default action - this.searchData = edata.searchData; - this.last.field = last_field; - this.last.search = last_search; - this.last.multi = last_multi; - this.last.logic = edata.searchLogic; - this.last.scrollTop = 0; - this.last.scrollLeft = 0; - this.last.selection.indexes = []; - this.last.selection.columns = {}; - // -- clear all search field - this.searchClose(); - // apply search - if (url) { - this.last.xhr_offset = 0; - this.reload(); - } else { - // local search - this.localSearch(); - this.refresh(); - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - searchOpen: function () { - if (!this.box) return; - if (this.searches.length === 0) return; - var obj = this; - var it = obj.toolbar.get('w2ui-search-advanced'); - var btn = '#tb_'+ obj.toolbar.name +'_item_'+ w2utils.escapeId(it.id) +' table.w2ui-button'; - // event before - var edata = this.trigger({ phase: 'before', type: 'searchOpen', target: this.name }); - if (edata.isCancelled === true) { - setTimeout(function () { obj.toolbar.uncheck('w2ui-search-advanced'); }, 1); - return; - } - // show search - $('#tb_'+ this.name +'_toolbar_item_w2ui-search-advanced').w2overlay({ - html : this.getSearchesHTML(), - name : this.name + '-searchOverlay', - left : -10, - 'class' : 'w2ui-grid-searches', - onShow : function () { - obj.initSearches(); - $('#w2ui-overlay-'+ obj.name +'-searchOverlay .w2ui-grid-searches').data('grid-name', obj.name); - var sfields = $('#w2ui-overlay-'+ this.name +'-searchOverlay .w2ui-grid-searches *[rel=search]'); - if (sfields.length > 0) sfields[0].focus(); - if (!it.checked) { - it.checked = true; - $(btn).addClass('checked'); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }, - onHide: function () { - it.checked = false; - $(btn).removeClass('checked'); - } - }); - }, - - searchClose: function () { - var obj = this; - if (!this.box) return; - if (this.searches.length === 0) return; - if (this.toolbar) this.toolbar.uncheck('w2ui-search-advanced', 'w2ui-column-on-off'); - // hide search - $().w2overlay({ name: this.name + '-searchOverlay' }); - }, - - searchReset: function (noRefresh) { - var searchData = []; - var hasHiddenSearches = false; - // add hidden searches - for (var i = 0; i < this.searches.length; i++) { - if (!this.searches[i].hidden || this.searches[i].value == null) continue; - searchData.push({ - field : this.searches[i].field, - operator : this.searches[i].operator || 'is', - type : this.searches[i].type, - value : this.searches[i].value || '' - }); - hasHiddenSearches = true; - } - // event before - var edata = this.trigger({ phase: 'before', type: 'search', reset: true, target: this.name, searchData: searchData }); - if (edata.isCancelled === true) return; - // default action - this.searchData = edata.searchData; - this.last.search = ''; - this.last.logic = (hasHiddenSearches ? 'AND' : 'OR'); - // --- do not reset to All Fields (I think) - if (this.searches.length > 0) { - if (!this.multiSearch || !this.show.searchAll) { - var tmp = 0; - while (tmp < this.searches.length && (this.searches[tmp].hidden || this.searches[tmp].simple === false)) tmp++; - if (tmp >= this.searches.length) { - // all searches are hidden - this.last.field = ''; - this.last.label = ''; - } else { - this.last.field = this.searches[tmp].field; - this.last.label = this.searches[tmp].label; - } - } else { - this.last.field = 'all'; - this.last.label = w2utils.lang('All Fields'); - } - } - this.last.multi = false; - this.last.xhr_offset = 0; - // reset scrolling position - this.last.scrollTop = 0; - this.last.scrollLeft = 0; - this.last.selection.indexes = []; - this.last.selection.columns = {}; - // -- clear all search field - this.searchClose(); - $('#grid_'+ this.name +'_search_all').val('').removeData('selected'); - // apply search - if (!noRefresh) this.reload(); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - searchShowFields: function (forceHide) { - var obj = this; - var el = $('#grid_'+ this.name +'_search_all'); - if (forceHide === true) { - $(el).w2overlay({ name: obj.name + '-searchFields' }); - return; - } - var html = '
'; - for (var s = -1; s < this.searches.length; s++) { - var search = this.searches[s]; - var sField = (search ? search.field : null); - var column = this.getColumn(sField); - var disable = false; - var msg = 'This column is hidden'; - if (this.show.searchHiddenMsg == true && s != -1 && (column == null || (column.hidden === true && column.hideable !== false))) { - disable = true; - if (column == null) { - msg = 'This column does not exist' - } - } - if (s == -1) { // -1 is All Fields search - if (!this.multiSearch || !this.show.searchAll) continue; - search = { field: 'all', label: w2utils.lang('All Fields') }; - } else { - if (column != null && column.hideable === false) continue; - // don't show hidden searches - if (this.searches[s].hidden === true || this.searches[s].simple === false) continue; - } - if (search.label == null && search.caption != null) { - console.log('NOTICE: grid search.caption property is deprecated, please use search.label. Search ->', search); - search.label = search.caption; - } - - html += ''+ - ' '+ - ' '+ - ''; - } - html += "
'+ - ' '+ - ' '+ search.label +'
"; - - var overName = obj.name + '-searchFields'; - if ($('#w2ui-overlay-'+ overName).length == 1) html = ''; // hide if visible - // need timer otherwise does nto show with list type - setTimeout(function () { - $(el).w2overlay({ html: html, name: overName, left: -10 }); - }, 1); - }, - - initAllField: function (field, value) { - var el = $('#grid_'+ this.name +'_search_all'); - if (field == 'all') { - var search = { field: 'all', label: w2utils.lang('All Fields') }; - el.w2field('clear'); - // el.change(); // triggering change will cause grid calling remote url twice - } else { - var search = this.getSearch(field); - if (search == null) return; - var st = search.type; - if (['enum', 'select'].indexOf(st) != -1) st = 'list'; - el.w2field(st, $.extend({}, search.options, { suffix: '', autoFormat: false, selected: value })); - if (['list', 'enum', 'date', 'time', 'datetime'].indexOf(search.type) != -1) { - this.last.search = ''; - this.last.item = ''; - el.val(''); - $('#grid_'+ this.name +'_searchClear').hide() - } - } - // update field - if (this.last.search != '') { - this.last.label = search.label; - this.search(search.field, this.last.search); - } else { - this.last.field = search.field; - this.last.label = search.label; - } - el.attr('placeholder', w2utils.lang(search.label || search.caption || search.field)); - $().w2overlay({ name: this.name + '-searchFields' }); - }, - - // clears records and related params - clear: function (noRefresh) { - this.total = 0; - this.records = []; - this.summary = []; - this.last.xhr_offset = 0; // need this for reload button to work on remote data set - this.last.idCache = {}; // optimization to free memory - this.reset(true); - // refresh - if (!noRefresh) this.refresh(); - }, - - // clears scroll position, selection, ranges - reset: function (noRefresh) { - // position - this.last.scrollTop = 0; - this.last.scrollLeft = 0; - this.last.selection = { indexes: [], columns: {} }; - this.last.range_start = null; - this.last.range_end = null; - // additional - $('#grid_'+ this.name +'_records').prop('scrollTop', 0); - // refresh - if (!noRefresh) this.refresh(); - }, - - skip: function (offset, callBack) { - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (url) { - this.offset = parseInt(offset); - if (this.offset > this.total) this.offset = this.total - this.limit; - if (this.offset < 0 || !w2utils.isInt(this.offset)) this.offset = 0; - this.clear(true); - this.reload(callBack); - } else { - console.log('ERROR: grid.skip() can only be called when you have remote data source.'); - } - }, - - load: function (url, callBack) { - if (url == null) { - console.log('ERROR: You need to provide url argument when calling .load() method of "'+ this.name +'" object.'); - return; - } - // default action - this.clear(true); - this.request('get', {}, url, callBack); - }, - - reload: function (callBack) { - var grid = this; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - grid.selectionSave(); - if (url) { - // need to remember selection (not just last.selection object) - this.load(url, function () { - grid.selectionRestore(); - if (typeof callBack == 'function') callBack(); - }); - } else { - this.reset(true); - this.localSearch(); - this.selectionRestore(); - if (typeof callBack == 'function') callBack({ status: 'success' }); - } - }, - - request: function (cmd, add_params, url, callBack) { - if (add_params == null) add_params = {}; - if (url == '' || url == null) url = this.url; - if (url == '' || url == null) return; - // build parameters list - if (!w2utils.isInt(this.offset)) this.offset = 0; - if (!w2utils.isInt(this.last.xhr_offset)) this.last.xhr_offset = 0; - // add list params - var params = { - limit : this.limit, - offset : parseInt(this.offset) + parseInt(this.last.xhr_offset), - searchLogic : this.last.logic, - search: this.searchData.map(function (search) { - var _search = $.extend({}, search); - if (this.searchMap && this.searchMap[_search.field]) _search.field = this.searchMap[_search.field]; - return _search; - }.bind(this)), - sort: this.sortData.map(function (sort) { - var _sort = $.extend({}, sort); - if (this.sortMap && this.sortMap[_sort.field]) _sort.field = this.sortMap[_sort.field]; - return _sort; - }.bind(this)) - } - if (this.searchData.length === 0) { - delete params['search']; - delete params['searchLogic']; - } - if (this.sortData.length === 0) { - delete params['sort']; - } - // append other params - $.extend(params, this.postData); - $.extend(params, add_params); - // other actions - if (cmd == 'delete' || cmd == 'save') { - delete params['limit']; - delete params['offset']; - params['action'] = cmd - if (cmd == 'delete') { - params[this.recid || 'recid'] = this.getSelection(); - } - } - // event before - if (cmd == 'get') { - var edata = this.trigger({ phase: 'before', type: 'request', target: this.name, url: url, postData: params, httpHeaders: this.httpHeaders }); - if (edata.isCancelled === true) { if (typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); return; } - } else { - var edata = { url: url, postData: params, httpHeaders: this.httpHeaders }; - } - // call server to get data - var obj = this; - if (this.last.xhr_offset === 0) { - this.lock(w2utils.lang(this.msgRefresh), true); - } - if (this.last.xhr) try { this.last.xhr.abort(); } catch (e) {} - // URL - url = (typeof edata.url != 'object' ? edata.url : edata.url.get); - if (cmd == 'save' && typeof edata.url == 'object') url = edata.url.save; - if (cmd == 'delete' && typeof edata.url == 'object') url = edata.url.remove; - // process url with routeData - if (!$.isEmptyObject(obj.routeData)) { - var info = w2utils.parseRoute(url); - if (info.keys.length > 0) { - for (var k = 0; k < info.keys.length; k++) { - if (obj.routeData[info.keys[k].name] == null) continue; - url = url.replace((new RegExp(':'+ info.keys[k].name, 'g')), obj.routeData[info.keys[k].name]); - } - } - } - // ajax options - var ajaxOptions = { - type : 'GET', - url : url, - data : edata.postData, - headers : edata.httpHeaders, - dataType : 'json' // expected data type from server - }; - - var dataType = this.dataType || w2utils.settings.dataType - switch (dataType) { - case 'HTTP': - ajaxOptions.data = (typeof ajaxOptions.data == 'object' ? String($.param(ajaxOptions.data, false)).replace(/%5B/g, '[').replace(/%5D/g, ']') : ajaxOptions.data); - break; - case 'HTTPJSON': - ajaxOptions.data = { request: JSON.stringify(ajaxOptions.data) }; - break; - case 'RESTFULL': - ajaxOptions.type = 'GET'; - if (cmd == 'save') ajaxOptions.type = 'PUT'; // so far it is always update - if (cmd == 'delete') ajaxOptions.type = 'DELETE'; - ajaxOptions.data = (typeof ajaxOptions.data == 'object' ? String($.param(ajaxOptions.data, false)).replace(/%5B/g, '[').replace(/%5D/g, ']') : ajaxOptions.data); - break; - case 'RESTFULLJSON': - ajaxOptions.type = 'GET'; - if (cmd == 'save') ajaxOptions.type = 'PUT'; // so far it is always update - if (cmd == 'delete') ajaxOptions.type = 'DELETE'; - ajaxOptions.data = JSON.stringify(ajaxOptions.data); - ajaxOptions.contentType = 'application/json'; - break; - case 'JSON': - ajaxOptions.type = 'POST'; - ajaxOptions.data = JSON.stringify(ajaxOptions.data); - ajaxOptions.contentType = 'application/json'; - break; - } - if (this.method) ajaxOptions.type = this.method; - - this.last.xhr_cmd = cmd; - this.last.xhr_start = (new Date()).getTime(); - this.last.loaded = false; - this.last.xhr = $.ajax(ajaxOptions) - .done(function (data, status, xhr) { - obj.requestComplete(status, xhr, cmd, callBack); - }) - .fail(function (xhr, status, error) { - // trigger event - var errorObj = { status: status, error: error, rawResponseText: xhr.responseText }; - var edata2 = obj.trigger({ phase: 'before', type: 'error', error: errorObj, xhr: xhr }); - if (edata2.isCancelled === true) return; - // default behavior - if (status != 'abort') { // it can be aborted by the grid itself - var data; - try { data = typeof xhr.responseJSON === 'object' ? xhr.responseJSON : $.parseJSON(xhr.responseText); } catch (e) {} - console.log('ERROR: Server communication failed.', - '\n EXPECTED:', { status: 'success', total: 5, records: [{ recid: 1, field: 'value' }] }, - '\n OR:', { status: 'error', message: 'error message' }, - '\n RECEIVED:', typeof data == 'object' ? data : xhr.responseText); - obj.requestComplete('error', xhr, cmd, callBack); - } - // event after - obj.trigger($.extend(edata2, { phase: 'after' })); - }); - if (cmd == 'get') { - // event after - this.trigger($.extend(edata, { phase: 'after' })); - } - }, - - requestComplete: function(status, xhr, cmd, callBack) { - var obj = this; - this.unlock(); - setTimeout(function () { - if (obj.show.statusResponse) { - obj.status(w2utils.lang('Server Response') + ' ' + ((new Date()).getTime() - obj.last.xhr_start)/1000 +' ' + w2utils.lang('sec')); - } - }, 10); - this.last.pull_more = false; - this.last.pull_refresh = true; - - // event before - var event_name = 'load'; - if (this.last.xhr_cmd == 'save') event_name = 'save'; - if (this.last.xhr_cmd == 'delete') event_name = 'delete'; - var edata = this.trigger({ phase: 'before', target: this.name, type: event_name, xhr: xhr, status: status }); - if (edata.isCancelled === true) { - if (typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); - return; - } - // parse server response - var data; - if (status != 'error') { - // default action - if (typeof obj.parser == 'function') { - data = obj.parser(xhr.responseJSON); - if (typeof data != 'object') { - console.log('ERROR: Your parser did not return proper object'); - } - } else { - data = xhr.responseJSON; - if (data == null) { - data = { - status : 'error', - message : w2utils.lang(this.msgNotJSON), - responseText : xhr.responseText - }; - } else if (Array.isArray(data)) { - // if it is plain array, assume these are records - data = { - status : 'success', - records : data, - total : data.length - } - } - } - if (Array.isArray(data.records)) { - // make sure each record has recid - data.records.forEach(function (rec, ind) { - if (obj.recid) { - rec.recid = obj.parseField(rec, obj.recid); - } - if (rec.recid == null) { - rec.recid = 'recid-' + ind; - } - }) - } - if (data['status'] == 'error') { - obj.error(data['message']); - } else { - if (cmd == 'get') { - if (data.total == null) data.total = -1; - if (data.records == null) { - data.records = []; - } - if (data.records.length == this.limit) { - this.last.xhr_hasMore = true; - } else { - this.last.xhr_hasMore = false; - this.total = this.offset + this.last.xhr_offset + data.records.length; - } - if (this.last.xhr_offset === 0) { - this.records = []; - this.summary = []; - if (w2utils.isInt(data.total)) this.total = parseInt(data.total); - } else { - if (data.total != -1 && parseInt(data.total) != parseInt(this.total)) { - this.message(w2utils.lang(this.msgNeedReload), function () { - delete this.last.xhr_offset; - this.reload(); - }.bind(this)); - return; - } - } - // records - if (data.records) { - for (var r = 0; r < data.records.length; r++) { - this.records.push(data.records[r]); - } - } - // summary records (if any) - if (data.summary) { - this.summary = []; - for (var r = 0; r < data.summary.length; r++) { - this.summary.push(data.summary[r]); - } - } - } - if (cmd == 'delete') { - this.reset(); // unselect old selections - this.reload(); - return; - } - } - } else { - data = { - status : 'error', - message : w2utils.lang(this.msgAJAXerror), - responseText : xhr.responseText - }; - obj.error(w2utils.lang(this.msgAJAXerror)); - } - // event after - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - this.localSort(); - this.localSearch(); - } - this.total = parseInt(this.total); - // do not refresh if loading on infinite scroll - if (this.last.xhr_offset === 0) { - this.refresh(); - } else { - this.scroll(); - this.resize(); - } - // call back - if (typeof callBack == 'function') callBack(data); // need to be befor event:after - // after event - this.trigger($.extend(edata, { phase: 'after' })); - this.last.loaded = true; - }, - - error: function (msg) { - var obj = this; - // let the management of the error outside of the grid - var edata = this.trigger({ target: this.name, type: 'error', message: msg , xhr: this.last.xhr }); - if (edata.isCancelled === true) { - if (typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); - return; - } - this.message(msg); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - getChanges: function (recordsBase) { - var changes = []; - if (typeof recordsBase == 'undefined') { - var recordsBase = this.records; - } - - for (var r = 0; r < recordsBase.length; r++) { - var rec = recordsBase[r]; - if (rec.w2ui) { - if (rec.w2ui.changes != null) { - var obj = {} - obj[this.recid || 'recid'] = rec.recid - changes.push($.extend(true, obj, rec.w2ui.changes)); - } - - // recursively look for changes in non-expanded children - if (rec.w2ui.expanded !== true && rec.w2ui.children && rec.w2ui.children.length) { - $.merge(changes, this.getChanges(rec.w2ui.children)) - } - } - } - return changes; - }, - - mergeChanges: function () { - var changes = this.getChanges(); - for (var c = 0; c < changes.length; c++) { - var record = this.get(changes[c].recid); - for (var s in changes[c]) { - if (s == 'recid') continue; // do not allow to change recid - if (typeof changes[c][s] === "object") changes[c][s] = changes[c][s].text; - try { - if (s.indexOf('.') != -1) { - eval("record['" + s.replace(/\./g, "']['") + "'] = changes[c][s]") - } else { - record[s] = changes[c][s]; - } - } catch (e) { - console.log('ERROR: Cannot merge. ', e.message || '', e); - } - if (record.w2ui) delete record.w2ui.changes; - } - } - this.refresh(); - }, - - // =================================================== - // -- Action Handlers - - save: function (callBack) { - var obj = this; - var changes = this.getChanges(); - var url = (typeof this.url != 'object' ? this.url : this.url.save); - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'save', changes: changes }); - if (edata.isCancelled === true) { - if (url && typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); - return; - } - if (url) { - this.request('save', { 'changes' : edata.changes }, null, - function (data) { - if (data.status !== 'error') { - // only merge changes, if save was successful - obj.mergeChanges(); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - // call back - if (typeof callBack == 'function') callBack(data); - } - ); - } else { - this.mergeChanges(); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - } - }, - - editField: function (recid, column, value, event) { - var obj = this; - if (this.last.inEditMode === true) { // already editing - if (event.keyCode == 13) { - var index = this.last._edit.index; - var column = this.last._edit.column; - var recid = this.last._edit.recid; - this.editChange({ type: 'custom', value: this.last._edit.value }, this.get(recid, true), column, event); - var next = event.shiftKey ? this.prevRow(index, column) : this.nextRow(index, column); - if (next != null && next != index) { - setTimeout(function () { - if (obj.selectType != 'row') { - obj.selectNone(); - obj.select({ recid: obj.records[next].recid, column: column }); - } else { - obj.editField(obj.records[next].recid, column, null, event); - } - }, 1); - } - this.last.inEditMode = false; - } else { - // when 2 chars entered fast - var $input = $(this.box).find('div.w2ui-edit-box .w2ui-input'); - if ($input.length > 0 && $input[0].tagName == 'DIV') { - $input.text($input.text() + value); - w2utils.setCursorPosition($input[0], $input.text().length); - } - } - return; - } - var index = obj.get(recid, true); - var edit = obj.getCellEditable(index, column); - if (!edit) return; - var rec = obj.records[index]; - var col = obj.columns[column]; - var prefix = (col.frozen === true ? '_f' : '_'); - if (['enum', 'file'].indexOf(edit.type) != -1) { - console.log('ERROR: input types "enum" and "file" are not supported in inline editing.'); - return; - } - // event before - var edata = obj.trigger({ phase: 'before', type: 'editField', target: obj.name, recid: recid, column: column, value: value, - index: index, originalEvent: event }); - if (edata.isCancelled === true) return; - value = edata.value; - // default behaviour - this.last.inEditMode = true; - this.last._edit = { value: value, index: index, column: column, recid: recid }; - this.selectNone(); - this.select({ recid: recid, column: column }); - if (['checkbox', 'check'].indexOf(edit.type) != -1) return; - // create input element - var tr = $('#grid_'+ obj.name + prefix +'rec_' + w2utils.escapeId(recid)); - var el = tr.find('[col='+ column +'] > div'); - // clear previous if any - $(this.box).find('div.w2ui-edit-box').remove(); - // for spreadsheet - insert into selection - if (this.selectType != 'row') { - $('#grid_'+ this.name + prefix + 'selection') - .attr('id', 'grid_'+ this.name + '_editable') - .removeClass('w2ui-selection') - .addClass('w2ui-edit-box') - .prepend('
') - .find('.w2ui-selection-resizer') - .remove(); - el = $('#grid_'+ this.name + '_editable >div:first-child'); - } - if (edit.inTag == null) edit.inTag = ''; - if (edit.outTag == null) edit.outTag = ''; - if (edit.style == null) edit.style = ''; - if (edit.items == null) edit.items = []; - var val = (rec.w2ui && rec.w2ui.changes && rec.w2ui.changes[col.field] != null ? w2utils.stripTags(rec.w2ui.changes[col.field]) : w2utils.stripTags(rec[col.field])); - if (val == null) val = ''; - var old_value = (typeof val != 'object' ? val : ''); - if (edata.old_value != null) old_value = edata.old_value; - if (value != null) val = value; - var addStyle = (col.style != null ? col.style + ';' : ''); - if (typeof col.render == 'string' && ['number', 'int', 'float', 'money', 'percent', 'size'].indexOf(col.render.split(':')[0]) != -1) { - addStyle += 'text-align: right;'; - } - // normalize items - if (edit.items.length > 0 && !$.isPlainObject(edit.items[0])) { - edit.items = w2obj.field.prototype.normMenu(edit.items); - } - switch (edit.type) { - - case 'select': - var html = ''; - for (var i = 0; i < edit.items.length; i++) { - html += ''; - } - el.addClass('w2ui-editable') - .html('' + edit.outTag); - setTimeout(function () { - el.find('select') - .on('change', function (event) { - delete obj.last.move; - }) - .on('blur', function (event) { - if ($(this).data('keep-open') == true) return; - obj.editChange.call(obj, this, index, column, event); - }); - }, 10); - break; - - case 'div': - var $tmp = tr.find('[col='+ column +'] > div'); - var font = 'font-family: '+ $tmp.css('font-family') + '; font-size: '+ $tmp.css('font-size') + ';'; - el.addClass('w2ui-editable') - .html('
' + edit.outTag); - if (value == null) el.find('div.w2ui-input').text(typeof val != 'object' ? val : ''); - // add blur listener - var input = el.find('div.w2ui-input').get(0); - setTimeout(function () { - var tmp = input; - $(tmp).on('blur', function (event) { - if ($(this).data('keep-open') == true) return; - obj.editChange.call(obj, tmp, index, column, event); - }); - }, 10); - if (value != null) $(input).text(typeof val != 'object' ? val : ''); - break; - - default: - var $tmp = tr.find('[col='+ column +'] > div'); - var font = 'font-family: '+ $tmp.css('font-family') + '; font-size: '+ $tmp.css('font-size'); - el.addClass('w2ui-editable') - .html('' + edit.outTag); - // issue #499 - if (edit.type == 'number') { - val = w2utils.formatNumber(val); - } - if (edit.type == 'date') { - val = w2utils.formatDate(w2utils.isDate(val, edit.format, true) || new Date(), edit.format); - } - if (value == null) el.find('input').val(typeof val != 'object' ? val : ''); - // init w2field - var input = el.find('input').get(0); - $(input).w2field(edit.type, $.extend(edit, { selected: val })); - // add blur listener - setTimeout(function () { - var tmp = input; - if (edit.type == 'list') { - tmp = $($(input).data('w2field').helpers.focus).find('input'); - if (typeof val != 'object' && val != '') tmp.val(val).css({ opacity: 1 }).prev().css({ opacity: 1 }); - el.find('input').on('change', function (event) { - obj.editChange.call(obj, input, index, column, event); - }); - } - $(tmp).on('blur', function (event) { - if ($(this).data('keep-open') == true) return; - obj.editChange.call(obj, input, index, column, event); - }); - }, 10); - if (value != null) $(input).val(typeof val != 'object' ? val : ''); - } - - setTimeout(function () { - if (!obj.last.inEditMode) return; - el.find('input, select, div.w2ui-input') - .data('old_value', old_value) - .on('mousedown', function (event) { - event.stopPropagation(); - }) - .on('click', function (event) { - if (edit.type == 'div') { - expand.call(el.find('div.w2ui-input')[0], null); - } else { - expand.call(el.find('input, select')[0], null); - } - }) - .on('paste', function (event) { - // clean paste to be plain text - var e = event.originalEvent; - event.preventDefault(); - var text = e.clipboardData.getData("text/plain"); - document.execCommand("insertHTML", false, text); - }) - .on('keydown', function (event) { - var el = this; - var val = (el.tagName.toUpperCase() == 'DIV' ? $(el).text() : $(el).val()); - switch (event.keyCode) { - case 8: // backspace; - if (edit.type == 'list' && !$(input).data('w2field')) { // cancel backspace when deleting element - event.preventDefault(); - } - break; - case 9: - case 13: - event.preventDefault(); - break; - case 37: - if (w2utils.getCursorPosition(el) === 0) { - event.preventDefault(); - } - break; - case 39: - if (w2utils.getCursorPosition(el) == val.length) { - w2utils.setCursorPosition(el, val.length); - event.preventDefault(); - } - break; - } - // need timeout so, this handler is executed last - setTimeout(function () { - switch (event.keyCode) { - case 9: // tab - var next_rec = recid; - var next_col = event.shiftKey ? obj.prevCell(index, column, true) : obj.nextCell(index, column, true); - // next or prev row - if (next_col == null) { - var tmp = event.shiftKey ? obj.prevRow(index, column) : obj.nextRow(index, column); - if (tmp != null && tmp != index) { - next_rec = obj.records[tmp].recid; - // find first editable row - for (var c = 0; c < obj.columns.length; c++) { - var edit = obj.getCellEditable(index, c); - if (edit != null && ['checkbox', 'check'].indexOf(edit.type) == -1) { - next_col = parseInt(c); - if (!event.shiftKey) break; - } - } - } - - } - if (next_rec === false) next_rec = recid; - if (next_col == null) next_col = column; - // init new or same record - el.blur(); - setTimeout(function () { - if (obj.selectType != 'row') { - obj.selectNone(); - obj.select({ recid: next_rec, column: next_col }); - } else { - obj.editField(next_rec, next_col, null, event); - } - }, 1); - if (event.preventDefault) event.preventDefault(); - break; - - case 13: // enter - el.blur(); - var next = event.shiftKey ? obj.prevRow(index, column) : obj.nextRow(index, column); - if (next != null && next != index) { - setTimeout(function () { - if (obj.selectType != 'row') { - obj.selectNone(); - obj.select({ recid: obj.records[next].recid, column: column }); - } else { - obj.editField(obj.records[next].recid, column, null, event); - } - }, 1); - } - if (el.tagName.toUpperCase() == 'DIV') { - event.preventDefault(); - } - break; - - case 27: // escape - var old = obj.parseField(rec, col.field); - if (rec.w2ui && rec.w2ui.changes && rec.w2ui.changes[col.field] != null) old = rec.w2ui.changes[col.field]; - if ($(el).data('old_value') != null) old = $(el).data('old_value'); - if (el.tagName.toUpperCase() == 'DIV') { - $(el).text(old != null ? old : ''); - } else { - el.value = old != null ? old : ''; - } - el.blur(); - setTimeout(function () { obj.select({ recid: recid, column: column }); }, 1); - break; - } - // if input too small - expand - expand.call(el, event); - }, 1); - }) - .on('keyup', function (event) { - expand.call(this, event); - }); - // focus and select - setTimeout(function () { - if (!obj.last.inEditMode) return; - var tmp = el.find('.w2ui-input'); - var len = ($(tmp).val() != null ? $(tmp).val().length : 0); - if (edit.type == 'div') len = $(tmp).text().length; - if (tmp.length > 0) { - tmp.focus(); - clearTimeout(obj.last.kbd_timer); // keep focus - if (tmp[0].tagName.toUpperCase() != 'SELECT') w2utils.setCursorPosition(tmp[0], len); - tmp[0].resize = expand; - expand.call(tmp[0], null); - } - }, 50); - // event after - obj.trigger($.extend(edata, { phase: 'after', input: el.find('input, select, div.w2ui-input') })); - }, 5); // needs to be 5-10 - return; - - function expand(event) { - try { - var val = (this.tagName.toUpperCase() == 'DIV' ? $(this).text() : this.value); - var $sel = $('#grid_'+ obj.name + '_editable'); - var style = 'font-family: '+ $(this).css('font-family') + '; font-size: '+ $(this).css('font-size') + '; white-space: pre;'; - var width = w2utils.getStrWidth(val, style); - if (width + 20 > $sel.width()) { - $sel.width(width + 20); - } - } catch (e) { - } - } - }, - - editChange: function (el, index, column, event) { - var obj = this; - // keep focus - setTimeout(function () { - var $input = $(obj.box).find('#grid_'+ obj.name + '_focus'); - if (!$input.is(':focus')) $input.focus(); - }, 10); - // all other fields - var summary = index < 0; - index = index < 0 ? -index - 1 : index; - var records = summary ? this.summary : this.records; - var rec = records[index]; - var col = this.columns[column]; - var tr = $('#grid_'+ this.name + (col.frozen === true ? '_frec_' : '_rec_') + w2utils.escapeId(rec.recid)); - var new_val = (el.tagName && el.tagName.toUpperCase() == 'DIV' ? $(el).text() : el.value); - var old_val = this.parseField(rec, col.field); - var tmp = $(el).data('w2field'); - if (tmp) { - if (tmp.type == 'list') new_val = $(el).data('selected'); - if ($.isEmptyObject(new_val) || new_val == null) new_val = ''; - if (!$.isPlainObject(new_val)) new_val = tmp.clean(new_val); - } - if (el.type == 'checkbox') { - if (rec.w2ui && rec.w2ui.editable === false) el.checked = !el.checked; - new_val = el.checked; - } - // change/restore event - var edata = { - phase: 'before', type: 'change', target: this.name, input_id: el.id, recid: rec.recid, index: index, column: column, - originalEvent: (event.originalEvent ? event.originalEvent : event), - value_new: new_val, - value_previous: (rec.w2ui && rec.w2ui.changes && rec.w2ui.changes.hasOwnProperty(col.field) ? rec.w2ui.changes[col.field]: old_val), - value_original: old_val - }; - if ($(event.target).data('old_value') != null) edata.value_previous = $(event.target).data('old_value'); - // if (old_val == null) old_val = ''; -- do not uncomment, error otherwise - while (true) { - new_val = edata.value_new; - if ((typeof new_val != 'object' && String(old_val) != String(new_val)) || - (typeof new_val == 'object' && new_val && new_val.id != old_val && (typeof old_val != 'object' || old_val == null || new_val.id != old_val.id))) { - // change event - edata = this.trigger($.extend(edata, { type: 'change', phase: 'before' })); - if (edata.isCancelled !== true) { - if (new_val !== edata.value_new) { - // re-evaluate the type of change to be made - continue; - } - // default action - rec.w2ui = rec.w2ui || {}; - rec.w2ui.changes = rec.w2ui.changes || {}; - rec.w2ui.changes[col.field] = edata.value_new; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - } - } else { - // restore event - edata = this.trigger($.extend(edata, { type: 'restore', phase: 'before' })); - if (edata.isCancelled !== true) { - if (new_val !== edata.value_new) { - // re-evaluate the type of change to be made - continue; - } - // default action - if (rec.w2ui && rec.w2ui.changes) delete rec.w2ui.changes[col.field]; - if (rec.w2ui && $.isEmptyObject(rec.w2ui.changes)) delete rec.w2ui.changes; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - } - } - break; - } - // refresh cell - var cell = $(tr).find('[col='+ column +']'); - if (!summary) { - if (rec.w2ui && rec.w2ui.changes && rec.w2ui.changes[col.field] != null) { - cell.addClass('w2ui-changed'); - } else { - cell.removeClass('w2ui-changed'); - } - // update cell data - cell.replaceWith(this.getCellHTML(index, column, summary)); - } - // remove - $(this.box).find('div.w2ui-edit-box').remove(); - // enable/disable toolbar search button - if (this.show.toolbarSave) { - if (this.getChanges().length > 0) this.toolbar.enable('w2ui-save'); else this.toolbar.disable('w2ui-save'); - } - obj.last.inEditMode = false; - }, - - "delete": function (force) { - var time = (new Date()).getTime(); - var obj = this; - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'delete', force: force }); - if (force) this.message(); // close message - if (edata.isCancelled === true) return; - force = edata.force; - // hide all tooltips - setTimeout(function () { $().w2tag(); }, 20); - // default action - var recs = this.getSelection(); - if (recs.length === 0) return; - if (this.msgDelete != '' && !force) { - this.message({ - width : 380, - height : 170, - body : '
' + - w2utils.lang(obj.msgDelete).replace('NN', recs.length).replace('records', (recs.length == 1 ? 'record' : 'records')) + - '
', - buttons : (w2utils.settings.macButtonOrder - ? '' + - '' - : '' + - '' - ), - onOpen: function (event) { - var inputs = $(this.box).find('input, textarea, select, button'); - inputs.off('.message') - .on('blur.message', function (evt) { - // last input - if (inputs.index(evt.target) + 1 === inputs.length) { - inputs.get(0).focus(); - evt.preventDefault(); - } - }) - .on('keydown.message', function (evt) { - if (evt.keyCode == 27) obj.message(); // esc - }); - setTimeout(function () { - $(this.box).find('.w2ui-btn.btn-default').focus(); - clearTimeout(obj.last.kbd_timer); - }.bind(this), 50); - } - }); - return; - } - // call delete script - var url = (typeof this.url != 'object' ? this.url : this.url.remove); - if (url) { - this.request('delete'); - } else { - if (typeof recs[0] != 'object') { - this.selectNone(); - this.remove.apply(this, recs); - } else { - // clear cells - for (var r = 0; r < recs.length; r++) { - var fld = this.columns[recs[r].column].field; - var ind = this.get(recs[r].recid, true); - var rec = this.records[ind]; - if (ind != null && fld != 'recid') { - this.records[ind][fld] = ''; - if (rec.w2ui && rec.w2ui.changes) delete rec.w2ui.changes[fld]; - // -- style should not be deleted - // if (rec.style != null && $.isPlainObject(rec.style) && rec.style[recs[r].column]) { - // delete rec.style[recs[r].column]; - // } - } - } - this.update(); - } - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - click: function (recid, event) { - var time = (new Date()).getTime(); - var column = null; - var obj = this; - if (this.last.cancelClick == true || (event && event.altKey)) return; - if ((typeof recid == 'object') && (recid !== null)) { - column = recid.column; - recid = recid.recid; - } - if (event == null) event = {}; - // check for double click - if (time - parseInt(this.last.click_time) < 350 && this.last.click_recid == recid && event.type == 'click') { - this.dblClick(recid, event); - return; - } - // hide bubble - if (this.last.bubbleEl) { - $(this.last.bubbleEl).w2tag(); - this.last.bubbleEl = null; - } - this.last.click_time = time; - var last_recid = this.last.click_recid; - this.last.click_recid = recid; - // column user clicked on - if (column == null && event.target) { - var tmp = event.target; - if (tmp.tagName.toUpperCase() != 'TD') tmp = $(tmp).parents('td')[0]; - if ($(tmp).attr('col') != null) column = parseInt($(tmp).attr('col')); - } - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'click', recid: recid, column: column, originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - var obj = this; - var sel = this.getSelection(); - $('#grid_'+ this.name +'_check_all').prop("checked", false); - var ind = this.get(recid, true); - var record = this.records[ind]; - var selectColumns = []; - obj.last.sel_ind = ind; - obj.last.sel_col = column; - obj.last.sel_recid = recid; - obj.last.sel_type = 'click'; - // multi select with shif key - if (event.shiftKey && sel.length > 0 && obj.multiSelect) { - if (sel[0].recid) { - var start = this.get(sel[0].recid, true); - var end = this.get(recid, true); - if (column > sel[0].column) { - var t1 = sel[0].column; - var t2 = column; - } else { - var t1 = column; - var t2 = sel[0].column; - } - for (var c = t1; c <= t2; c++) selectColumns.push(c); - } else { - var start = this.get(last_recid, true); - var end = this.get(recid, true); - } - var sel_add = []; - if (start > end) { var tmp = start; start = end; end = tmp; } - var url = (typeof this.url != 'object' ? this.url : this.url.get); - for (var i = start; i <= end; i++) { - if (this.searchData.length > 0 && !url && $.inArray(i, this.last.searchIds) == -1) continue; - if (this.selectType == 'row') { - sel_add.push(this.records[i].recid); - } else { - for (var sc = 0; sc < selectColumns.length; sc++) { - sel_add.push({ recid: this.records[i].recid, column: selectColumns[sc] }); - } - } - //sel.push(this.records[i].recid); - } - this.select(sel_add); - } else { - var last = this.last.selection; - var flag = (last.indexes.indexOf(ind) != -1 ? true : false); - var fselect = false; - // if clicked on the checkbox - if ($(event.target).parents('td').hasClass('w2ui-col-select')) fselect = true; - // clear other if necessary - if (((!event.ctrlKey && !event.shiftKey && !event.metaKey && !fselect) || !this.multiSelect) && !this.showSelectColumn) { - if (this.selectType != 'row' && $.inArray(column, last.columns[ind]) == -1) flag = false; - if (sel.length > 300) this.selectNone(); else this.unselect(sel); - if (flag === true && sel.length == 1) { - this.unselect({ recid: recid, column: column }); - } else { - this.select({ recid: recid, column: column }); - } - } else { - var isChecked = $(event.target).parents('tr').find('.w2ui-grid-select-check').is(':checked'); - if (this.selectType != 'row' && $.inArray(column, last.columns[ind]) == -1 && !isChecked) flag = false; - if (flag === true) { - this.unselect({ recid: recid, column: column }); - } else { - this.select({ recid: recid, column: column }); - } - } - } - this.status(); - obj.initResize(); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - columnClick: function (field, event) { - // event before - var edata = this.trigger({ phase: 'before', type: 'columnClick', target: this.name, field: field, originalEvent: event }); - if (edata.isCancelled === true) return; - // default behaviour - if (this.selectType == 'row') { - var column = this.getColumn(field); - if (column && column.sortable) this.sort(field, null, (event && (event.ctrlKey || event.metaKey) ? true : false) ); - if (edata.field == 'line-number') { - if (this.getSelection().length >= this.records.length) { - this.selectNone(); - } else { - this.selectAll(); - } - } - } else { - if (event.altKey){ - var column = this.getColumn(field); - if (column && column.sortable) this.sort(field, null, (event && (event.ctrlKey || event.metaKey) ? true : false) ); - } - // select entire column - if (edata.field == 'line-number') { - if (this.getSelection().length >= this.records.length) { - this.selectNone(); - } else { - this.selectAll(); - } - } else { - if (!event.shiftKey && !event.metaKey && !event.ctrlKey) { - this.selectNone(); - } - var tmp = this.getSelection(); - var column = this.getColumn(edata.field, true); - var sel = []; - var cols = []; - // check if there was a selection before - if (tmp.length != 0 && event.shiftKey) { - var start = column; - var end = tmp[0].column; - if (start > end) { - start = tmp[0].column; - end = column; - } - for (var i=start; i<=end; i++) cols.push(i); - } else { - cols.push(column); - } - var edata = this.trigger({ phase: 'before', type: 'columnSelect', target: this.name, columns: cols }); - if (edata.isCancelled !== true) { - for (var i = 0; i < this.records.length; i++) { - sel.push({ recid: this.records[i].recid, column: cols }); - } - this.select(sel); - } - this.trigger($.extend(edata, { phase: 'after' })); - } - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - columnDblClick: function (field, event) { - // event before - var edata = this.trigger({ phase: 'before', type: 'columnDblClick', target: this.name, field: field, originalEvent: event }); - if (edata.isCancelled === true) return; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - focus: function (event) { - var obj = this; - // event before - var edata = this.trigger({ phase: 'before', type: 'focus', target: this.name, originalEvent: event }); - if (edata.isCancelled === true) return false; - // default behaviour - this.hasFocus = true; - $(this.box).removeClass('w2ui-inactive').find('.w2ui-inactive').removeClass('w2ui-inactive'); - setTimeout(function () { - var $input = $(obj.box).find('#grid_'+ obj.name + '_focus'); - if (!$input.is(':focus')) $input.focus(); - }, 10); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - blur: function (event) { - // event before - var edata = this.trigger({ phase: 'before', type: 'blur', target: this.name, originalEvent: event }); - if (edata.isCancelled === true) return false; - // default behaviour - this.hasFocus = false; - $(this.box).addClass('w2ui-inactive').find('.w2ui-selected').addClass('w2ui-inactive'); - $(this.box).find('.w2ui-selection').addClass('w2ui-inactive'); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - keydown: function (event) { - // this method is called from w2utils - var obj = this; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (obj.keyboard !== true) return; - // trigger event - var edata = obj.trigger({ phase: 'before', type: 'keydown', target: obj.name, originalEvent: event }); - if (edata.isCancelled === true) return; - // default behavior - if ($(this.box).find('>.w2ui-message').length > 0) { - // if there are messages - if (event.keyCode == 27) this.message(); - return - } - var empty = false; - var records = $('#grid_'+ obj.name +'_records'); - var sel = obj.getSelection(); - if (sel.length === 0) empty = true; - var recid = sel[0] || null; - var columns = []; - var recid2 = sel[sel.length-1]; - if (typeof recid == 'object' && recid != null) { - recid = sel[0].recid; - columns = []; - var ii = 0; - while (true) { - if (!sel[ii] || sel[ii].recid != recid) break; - columns.push(sel[ii].column); - ii++; - } - recid2 = sel[sel.length-1].recid; - } - var ind = obj.get(recid, true); - var ind2 = obj.get(recid2, true); - var rec = obj.get(recid); - var recEL = $('#grid_'+ obj.name +'_rec_'+ (ind != null ? w2utils.escapeId(obj.records[ind].recid) : 'none')); - var cancel = false; - var key = event.keyCode; - var shiftKey = event.shiftKey; - - switch (key) { - case 8: // backspace - case 46: // delete - // delete if button is visible - obj["delete"](); - cancel = true; - event.stopPropagation(); - break; - - case 27: // escape - obj.selectNone(); - cancel = true; - break; - - case 65: // cmd + A - if (!event.metaKey && !event.ctrlKey) break; - obj.selectAll(); - cancel = true; - break; - - case 13: // enter - // if expandable columns - expand it - if (this.selectType == 'row' && obj.show.expandColumn === true) { - if (recEL.length <= 0) break; - obj.toggle(recid, event); - cancel = true; - } else { // or enter edit - for (var c = 0; c < this.columns.length; c++) { - var edit = this.getCellEditable(ind, c); - if (edit) { - columns.push(parseInt(c)); - break; - } - } - // edit last column that was edited - if (this.selectType == 'row' && this.last._edit && this.last._edit.column) { - columns = [this.last._edit.column]; - } - if (columns.length > 0) { - obj.editField(recid, columns[0], null, event); - cancel = true; - } - } - break; - - case 37: // left - if (empty) { // no selection - selectTopRecord(); - break; - } - if (this.selectType == 'row') { - if (recEL.length <= 0) break; - var tmp = this.records[ind].w2ui || {}; - if (tmp && tmp.parent_recid != null && (!Array.isArray(tmp.children) || tmp.children.length === 0 || !tmp.expanded)) { - obj.unselect(recid); - obj.collapse(tmp.parent_recid, event); - obj.select(tmp.parent_recid); - } else { - obj.collapse(recid, event); - } - } else { - var prev = obj.prevCell(ind, columns[0]); - if (!shiftKey && prev == null) { - this.selectNone(); - prev = 0; - } - if (prev != null) { - if (shiftKey && obj.multiSelect) { - if (tmpUnselect()) return; - var tmp = []; - var newSel = []; - var unSel = []; - if (columns.indexOf(this.last.sel_col) === 0 && columns.length > 1) { - for (var i = 0; i < sel.length; i++) { - if (tmp.indexOf(sel[i].recid) == -1) tmp.push(sel[i].recid); - unSel.push({ recid: sel[i].recid, column: columns[columns.length-1] }); - } - obj.unselect(unSel); - obj.scrollIntoView(ind, columns[columns.length-1], true); - } else { - for (var i = 0; i < sel.length; i++) { - if (tmp.indexOf(sel[i].recid) == -1) tmp.push(sel[i].recid); - newSel.push({ recid: sel[i].recid, column: prev }); - } - obj.select(newSel); - obj.scrollIntoView(ind, prev, true); - } - } else { - event.metaKey = false; - obj.click({ recid: recid, column: prev }, event); - obj.scrollIntoView(ind, prev, true); - } - } else { - // if selected more then one, then select first - if (!shiftKey) { - if (sel.length > 1) { - obj.selectNone(); - } else { - for (var s = 1; s < sel.length; s++) obj.unselect(sel[s]); - } - } - } - } - cancel = true; - break; - - case 39: // right - if (empty) { - selectTopRecord(); - break; - } - if (this.selectType == 'row') { - if (recEL.length <= 0) break; - obj.expand(recid, event); - } else { - var next = obj.nextCell(ind, columns[columns.length-1]); // columns is an array of selected columns - if (!shiftKey && next == null) { - this.selectNone(); - next = this.columns.length-1; - } - if (next != null) { - if (shiftKey && key == 39 && obj.multiSelect) { - if (tmpUnselect()) return; - var tmp = []; - var newSel = []; - var unSel = []; - if (columns.indexOf(this.last.sel_col) == columns.length-1 && columns.length > 1) { - for (var i = 0; i < sel.length; i++) { - if (tmp.indexOf(sel[i].recid) == -1) tmp.push(sel[i].recid); - unSel.push({ recid: sel[i].recid, column: columns[0] }); - } - obj.unselect(unSel); - obj.scrollIntoView(ind, columns[0], true); - } else { - for (var i = 0; i < sel.length; i++) { - if (tmp.indexOf(sel[i].recid) == -1) tmp.push(sel[i].recid); - newSel.push({ recid: sel[i].recid, column: next }); - } - obj.select(newSel); - obj.scrollIntoView(ind, next, true); - } - } else { - event.metaKey = false; - obj.click({ recid: recid, column: next }, event); - obj.scrollIntoView(ind, next, true); - } - } else { - // if selected more then one, then select first - if (!shiftKey) { - if (sel.length > 1) { - obj.selectNone(); - } else { - for (var s = 0; s < sel.length-1; s++) obj.unselect(sel[s]); - } - } - } - } - cancel = true; - break; - - case 38: // up - if (empty) selectTopRecord(); - if (recEL.length <= 0) break; - // move to the previous record - var prev = obj.prevRow(ind, columns[0]); - if (!shiftKey && prev == null) { - if (this.searchData.length != 0 && !url) { - prev = this.last.searchIds[0]; - } else { - prev = 0; - } - } - if (prev != null) { - if (shiftKey && obj.multiSelect) { // expand selection - if (tmpUnselect()) return; - if (obj.selectType == 'row') { - if (obj.last.sel_ind > prev && obj.last.sel_ind != ind2) { - obj.unselect(obj.records[ind2].recid); - } else { - obj.select(obj.records[prev].recid); - } - } else { - if (obj.last.sel_ind > prev && obj.last.sel_ind != ind2) { - prev = ind2; - var tmp = []; - for (var c = 0; c < columns.length; c++) tmp.push({ recid: obj.records[prev].recid, column: columns[c] }); - obj.unselect(tmp); - } else { - var tmp = []; - for (var c = 0; c < columns.length; c++) tmp.push({ recid: obj.records[prev].recid, column: columns[c] }); - obj.select(tmp); - } - } - } else { // move selected record - if (sel.length > 300) this.selectNone(); else this.unselect(sel); - obj.click({ recid: obj.records[prev].recid, column: columns[0] }, event); - } - obj.scrollIntoView(prev); - if (event.preventDefault) event.preventDefault(); - } else { - // if selected more then one, then select first - if (!shiftKey) { - if (sel.length > 1) { - obj.selectNone(); - } else { - for (var s = 1; s < sel.length; s++) obj.unselect(sel[s]); - } - } - } - break; - - case 40: // down - if (empty) selectTopRecord(); - if (recEL.length <= 0) break; - // move to the next record - var next = obj.nextRow(ind2, columns[0]); - if (!shiftKey && next == null) { - if (this.searchData.length != 0 && !url) { - next = this.last.searchIds[this.last.searchIds.length - 1]; - } else { - next = this.records.length - 1; - } - } - if (next != null) { - if (shiftKey && obj.multiSelect) { // expand selection - if (tmpUnselect()) return; - if (obj.selectType == 'row') { - if (this.last.sel_ind < next && this.last.sel_ind != ind) { - obj.unselect(obj.records[ind].recid); - } else { - obj.select(obj.records[next].recid); - } - } else { - if (this.last.sel_ind < next && this.last.sel_ind != ind) { - next = ind; - var tmp = []; - for (var c = 0; c < columns.length; c++) tmp.push({ recid: obj.records[next].recid, column: columns[c] }); - obj.unselect(tmp); - } else { - var tmp = []; - for (var c = 0; c < columns.length; c++) tmp.push({ recid: obj.records[next].recid, column: columns[c] }); - obj.select(tmp); - } - } - } else { // move selected record - if (sel.length > 300) this.selectNone(); else this.unselect(sel); - obj.click({ recid: obj.records[next].recid, column: columns[0] }, event); - } - obj.scrollIntoView(next); - cancel = true; - } else { - // if selected more then one, then select first - if (!shiftKey) { - if (sel.length > 1) { - obj.selectNone(); - } else { - for (var s = 0; s < sel.length-1; s++) obj.unselect(sel[s]); - } - } - } - break; - - // copy & paste - - case 17: // ctrl key - case 91: // cmd key - // SLOW: 10k records take 7.0 - if (empty) break; - // in Safari need to copy to buffer on cmd or ctrl key (otherwise does not work) - if (obj.last.isSafari) { - obj.last.copy_event = obj.copy(false, event); - $('#grid_'+ obj.name + '_focus').val(obj.last.copy_event.text).select(); - } - break; - - case 67: // - c - // this fill trigger event.onComplete - if (event.metaKey || event.ctrlKey) { - if (obj.last.isSafari) { - obj.copy(obj.last.copy_event, event); - } else { - obj.last.copy_event = obj.copy(false, event); - $('#grid_'+ obj.name + '_focus').val(obj.last.copy_event.text).select(); - obj.copy(obj.last.copy_event, event); - } - } - break; - - case 88: // x - cut - if (empty) break; - if (event.ctrlKey || event.metaKey) { - if (obj.last.isSafari) { - obj.copy(obj.last.copy_event, event); - } else { - obj.last.copy_event = obj.copy(false, event); - $('#grid_'+ obj.name + '_focus').val(obj.last.copy_event.text).select(); - obj.copy(obj.last.copy_event, event); - } - } - break; - } - var tmp = [32, 187, 189, 192, 219, 220, 221, 186, 222, 188, 190, 191]; // other typable chars - for (var i=48; i<=111; i++) tmp.push(i); // 0-9,a-z,A-Z,numpad - if (tmp.indexOf(key) != -1 && !event.ctrlKey && !event.metaKey && !cancel) { - if (columns.length === 0) columns.push(0); - cancel = false; - // move typed key into edit - setTimeout(function () { - var focus = $('#grid_'+ obj.name + '_focus'); - var key = focus.val(); - focus.val(''); - obj.editField(recid, columns[0], key, event); - }, 1); - } - if (cancel) { // cancel default behaviour - if (event.preventDefault) event.preventDefault(); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - - function selectTopRecord() { - var ind = Math.floor(records[0].scrollTop / obj.recordHeight) + 1; - if (!obj.records[ind] || ind < 2) ind = 0; - obj.select({ recid: obj.records[ind].recid, column: 0}); - } - - function tmpUnselect () { - if (obj.last.sel_type != 'click') return false; - if (obj.selectType != 'row') { - obj.last.sel_type = 'key'; - if (sel.length > 1) { - for (var s = 0; s < sel.length; s++) { - if (sel[s].recid == obj.last.sel_recid && sel[s].column == obj.last.sel_col) { - sel.splice(s, 1); - break; - } - } - obj.unselect(sel); - return true; - } - return false; - } else { - obj.last.sel_type = 'key'; - if (sel.length > 1) { - sel.splice(sel.indexOf(obj.records[obj.last.sel_ind].recid), 1); - obj.unselect(sel); - return true; - } - return false; - } - } - }, - - scrollIntoView: function (ind, column, instant) { - var buffered = this.records.length; - if (this.searchData.length != 0 && !this.url) buffered = this.last.searchIds.length; - if (buffered === 0) return; - if (ind == null) { - var sel = this.getSelection(); - if (sel.length === 0) return; - if ($.isPlainObject(sel[0])) { - ind = sel[0].index; - column = sel[0].column; - } else { - ind = this.get(sel[0], true); - } - } - var records = $('#grid_'+ this.name +'_records'); - // if all records in view - var len = this.last.searchIds.length; - if (len > 0) ind = this.last.searchIds.indexOf(ind); // if search is applied - - // vertical - if (records.height() < this.recordHeight * (len > 0 ? len : buffered) && records.length > 0) { - // scroll to correct one - var t1 = Math.floor(records[0].scrollTop / this.recordHeight); - var t2 = t1 + Math.floor(records.height() / this.recordHeight); - if (ind == t1) { - if (instant === true) { - records.prop({ 'scrollTop': records.scrollTop() - records.height() / 1.3 }); - } else { - records.stop(); - records.animate({ 'scrollTop': records.scrollTop() - records.height() / 1.3 }, 250, 'linear'); - } - } - if (ind == t2) { - if (instant === true) { - records.prop({ 'scrollTop': records.scrollTop() + records.height() / 1.3 }); - } else { - records.stop(); - records.animate({ 'scrollTop': records.scrollTop() + records.height() / 1.3 }, 250, 'linear'); - } - } - if (ind < t1 || ind > t2) { - if (instant === true) { - records.prop({ 'scrollTop': (ind - 1) * this.recordHeight }); - } else { - records.stop(); - records.animate({ 'scrollTop': (ind - 1) * this.recordHeight }, 250, 'linear'); - } - } - } - - // horizontal - if (column != null) { - var x1 = 0; - var x2 = 0; - var sb = w2utils.scrollBarSize(); - for (var i = 0; i <= column; i++) { - var col = this.columns[i]; - if (col.frozen || col.hidden) continue; - x1 = x2; - x2 += parseInt(col.sizeCalculated); - } - if (records.width() < x2 - records.scrollLeft()) { // right - if (instant === true) { - records.prop({ 'scrollLeft': x1 - sb }); - } else { - records.animate({ 'scrollLeft': x1 - sb }, 250, 'linear'); - } - } else if (x1 < records.scrollLeft()) { // left - if (instant === true) { - records.prop({ 'scrollLeft': x2 - records.width() + sb * 2 }); - } else { - records.animate({ 'scrollLeft': x2 - records.width() + sb * 2 }, 250, 'linear'); - } - } - } - }, - - dblClick: function (recid, event) { - // find columns - var column = null; - if ((typeof recid == 'object') && (recid !== null)) { - column = recid.column; - recid = recid.recid; - } - if (event == null) event = {}; - // column user clicked on - if (column == null && event.target) { - var tmp = event.target; - if (tmp.tagName.toUpperCase() != 'TD') tmp = $(tmp).parents('td')[0]; - column = parseInt($(tmp).attr('col')); - } - var index = this.get(recid, true); - var rec = this.records[index]; - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'dblClick', recid: recid, column: column, originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - this.selectNone(); - var edit = this.getCellEditable(index, column); - if (edit) { - this.editField(recid, column, null, event); - } else { - this.select({ recid: recid, column: column }); - if (this.show.expandColumn || (rec.w2ui && Array.isArray(rec.w2ui.children))) this.toggle(recid); - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - contextMenu: function (recid, column, event) { - var obj = this; - if (obj.last.userSelect == 'text') return; - if (event == null) event = { offsetX: 0, offsetY: 0, target: $('#grid_'+ obj.name +'_rec_'+ recid)[0] }; - if (event.offsetX == null) { - event.offsetX = event.layerX - event.target.offsetLeft; - event.offsetY = event.layerY - event.target.offsetTop; - } - if (w2utils.isFloat(recid)) recid = parseFloat(recid); - var sel = this.getSelection(); - if (this.selectType == 'row') { - if (sel.indexOf(recid) == -1) obj.click(recid); - } else { - var $tmp = $(event.target); - if ($tmp[0].tagName.toUpperCase() != 'TD') $tmp = $(event.target).parents('td'); - var selected = false; - column = $tmp.attr('col'); - // check if any selected sel in the right row/column - for (var i=0; i 0) { - $(obj.box).find(event.target) - .w2menu(obj.menu, { - originalEvent: event, - contextMenu: true, - onSelect: function (event) { - obj.menuClick(recid, event); - } - } - ); - } - // cancel event - if (event.preventDefault) event.preventDefault(); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }, - - menuClick: function (recid, event) { - var obj = this; - // event before - var edata = obj.trigger({ - phase: 'before', type: 'menuClick', target: obj.name, - originalEvent: event.originalEvent, menuEvent: event, - recid: recid, menuIndex: event.index, menuItem: event.item - }); - if (edata.isCancelled === true) return; - // default action - // -- empty - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }, - - toggle: function (recid) { - var rec = this.get(recid); - rec.w2ui = rec.w2ui || {}; - if (rec.w2ui.expanded === true) return this.collapse(recid); else return this.expand(recid); - }, - - expand: function (recid) { - var obj = this; - var ind = this.get(recid, true); - var rec = this.records[ind]; - rec.w2ui = rec.w2ui || {}; - var id = w2utils.escapeId(recid); - var children = rec.w2ui.children; - if (Array.isArray(children)) { - if (rec.w2ui.expanded === true || children.length === 0) return false; // already shown - var edata = this.trigger({ phase: 'before', type: 'expand', target: this.name, recid: recid }); - if (edata.isCancelled === true) return false; - rec.w2ui.expanded = true; - children.forEach(function (child) { - child.w2ui = child.w2ui || {}; - child.w2ui.parent_recid = rec.recid; - if (child.w2ui.children == null) child.w2ui.children = []; - }); - this.records.splice.apply(this.records, [ind + 1, 0].concat(children)); - this.total += children.length; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - this.localSort(true, true); - if (this.searchData.length > 0) { - this.localSearch(true); - } - } - this.refresh(); - this.trigger($.extend(edata, { phase: 'after' })); - } else { - if ($('#grid_'+ this.name +'_rec_'+ id +'_expanded_row').length > 0 || this.show.expandColumn !== true) return false; - if (rec.w2ui.expanded == 'none') return false; - // insert expand row - $('#grid_'+ this.name +'_rec_'+ id).after( - ''+ - ' '+ - '
'+ - ' '+ - ' '+ - ''); - - $('#grid_'+ this.name +'_frec_'+ id).after( - ''+ - (this.show.lineNumbers ? '' : '') + - ' '+ - '
'+ - ' '+ - ''); - - // event before - var edata = this.trigger({ phase: 'before', type: 'expand', target: this.name, recid: recid, - box_id: 'grid_'+ this.name +'_rec_'+ recid +'_expanded', fbox_id: 'grid_'+ this.name +'_frec_'+ id +'_expanded' }); - if (edata.isCancelled === true) { - $('#grid_'+ this.name +'_rec_'+ id +'_expanded_row').remove(); - $('#grid_'+ this.name +'_frec_'+ id +'_expanded_row').remove(); - return false; - } - // expand column - var row1 = $(this.box).find('#grid_'+ this.name +'_rec_'+ recid +'_expanded'); - var row2 = $(this.box).find('#grid_'+ this.name +'_frec_'+ recid +'_expanded'); - var innerHeight = row1.find('> div:first-child').height(); - if (row1.height() < innerHeight) { - row1.css({ height: innerHeight + 'px' }); - } - if (row2.height() < innerHeight) { - row2.css({ height: innerHeight + 'px' }); - } - // default action - $('#grid_'+ this.name +'_rec_'+ id).attr('expanded', 'yes').addClass('w2ui-expanded'); - $('#grid_'+ this.name +'_frec_'+ id).attr('expanded', 'yes').addClass('w2ui-expanded'); - // $('#grid_'+ this.name +'_rec_'+ id +'_expanded_row').show(); - $('#grid_'+ this.name +'_cell_'+ this.get(recid, true) +'_expand div').html('-'); - rec.w2ui.expanded = true; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - this.resizeRecords(); - } - return true; - }, - - collapse: function (recid) { - var obj = this; - var ind = this.get(recid, true); - var rec = this.records[ind]; - rec.w2ui = rec.w2ui || {}; - var id = w2utils.escapeId(recid); - var children = rec.w2ui.children; - if (Array.isArray(children)) { - if (rec.w2ui.expanded !== true) return false; // already hidden - var edata = this.trigger({ phase: 'before', type: 'collapse', target: this.name, recid: recid }); - if (edata.isCancelled === true) return false; - clearExpanded(rec); - var stops = []; - for (var r = rec; r != null; r = this.get(r.w2ui.parent_recid)) - stops.push(r.w2ui.parent_recid); - // stops contains 'undefined' plus the ID of all nodes in the path from 'rec' to the tree root - var start = ind + 1; - var end = start; - while (true) { - if (this.records.length <= end + 1 || this.records[end+1].w2ui == null || - stops.indexOf(this.records[end+1].w2ui.parent_recid) >= 0) { - break; - } - end++; - } - this.records.splice(start, end - start + 1); - this.total -= end - start + 1; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - if (this.searchData.length > 0) { - this.localSearch(true); - } - } - this.refresh(); - obj.trigger($.extend(edata, { phase: 'after' })); - } else { - if ($('#grid_'+ this.name +'_rec_'+ id +'_expanded_row').length === 0 || this.show.expandColumn !== true) return false; - // event before - var edata = this.trigger({ phase: 'before', type: 'collapse', target: this.name, recid: recid, - box_id: 'grid_'+ this.name +'_rec_'+ id +'_expanded', fbox_id: 'grid_'+ this.name +'_frec_'+ id +'_expanded' }); - if (edata.isCancelled === true) return false; - // default action - $('#grid_'+ this.name +'_rec_'+ id).removeAttr('expanded').removeClass('w2ui-expanded'); - $('#grid_'+ this.name +'_frec_'+ id).removeAttr('expanded').removeClass('w2ui-expanded'); - $('#grid_'+ this.name +'_cell_'+ this.get(recid, true) +'_expand div').html('+'); - $('#grid_'+ obj.name +'_rec_'+ id +'_expanded').css('height', '0px'); - $('#grid_'+ obj.name +'_frec_'+ id +'_expanded').css('height', '0px'); - setTimeout(function () { - $('#grid_'+ obj.name +'_rec_'+ id +'_expanded_row').remove(); - $('#grid_'+ obj.name +'_frec_'+ id +'_expanded_row').remove(); - rec.w2ui.expanded = false; - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - obj.resizeRecords(); - }, 300); - } - return true; - - function clearExpanded(rec) { - rec.w2ui.expanded = false; - for (var i = 0; i < rec.w2ui.children.length; i++) { - var subRec = rec.w2ui.children[i]; - if (subRec.w2ui.expanded) { - clearExpanded(subRec); - } - } - } - }, - - sort: function (field, direction, multiField) { // if no params - clears sort - // event before - var edata = this.trigger({ phase: 'before', type: 'sort', target: this.name, field: field, direction: direction, multiField: multiField }); - if (edata.isCancelled === true) return; - // check if needed to quit - if (field != null) { - // default action - var sortIndex = this.sortData.length; - for (var s = 0; s < this.sortData.length; s++) { - if (this.sortData[s].field == field) { sortIndex = s; break; } - } - if (direction == null) { - if (this.sortData[sortIndex] == null) { - direction = 'asc'; - } else { - if(this.sortData[sortIndex].direction == null) { - this.sortData[sortIndex].direction = ''; - } - switch (this.sortData[sortIndex].direction.toLowerCase()) { - case 'asc' : direction = 'desc'; break; - case 'desc' : direction = 'asc'; break; - default : direction = 'asc'; break; - } - } - } - if (this.multiSort === false) { this.sortData = []; sortIndex = 0; } - if (multiField != true) { this.sortData = []; sortIndex = 0; } - // set new sort - if (this.sortData[sortIndex] == null) this.sortData[sortIndex] = {}; - this.sortData[sortIndex].field = field; - this.sortData[sortIndex].direction = direction; - } else { - this.sortData = []; - } - // if local - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!url) { - this.localSort(true, true); - if (this.searchData.length > 0) this.localSearch(true); - // reset vertical scroll - this.last.scrollTop = 0; - $('#grid_'+ this.name +'_records').prop('scrollTop', 0); - // event after - this.trigger($.extend(edata, { phase: 'after', direction: direction })); - this.refresh(); - } else { - // event after - this.trigger($.extend(edata, { phase: 'after', direction: direction })); - this.last.xhr_offset = 0; - this.reload(); - } - }, - - copy: function (flag, oEvent) { - if ($.isPlainObject(flag)) { - // event after - this.trigger($.extend(flag, { phase: 'after' })); - return flag.text; - } - // generate text to copy - var sel = this.getSelection(); - if (sel.length === 0) return ''; - var text = ''; - if (typeof sel[0] == 'object') { // cell copy - // find min/max column - var minCol = sel[0].column; - var maxCol = sel[0].column; - var recs = []; - for (var s = 0; s < sel.length; s++) { - if (sel[s].column < minCol) minCol = sel[s].column; - if (sel[s].column > maxCol) maxCol = sel[s].column; - if (recs.indexOf(sel[s].index) == -1) recs.push(sel[s].index); - } - recs.sort(function(a, b) { return a-b; }); // sort function must be for numerical sort - for (var r = 0 ; r < recs.length; r++) { - var ind = recs[r]; - for (var c = minCol; c <= maxCol; c++) { - var col = this.columns[c]; - if (col.hidden === true) continue; - text += this.getCellCopy(ind, c) + '\t'; - } - text = text.substr(0, text.length-1); // remove last \t - text += '\n'; - } - } else { // row copy - // copy headers - for (var c = 0; c < this.columns.length; c++) { - var col = this.columns[c]; - if (col.hidden === true) continue; - var colName = (col.text ? col.text : col.field); - if (col.text && col.text.length < 3 && col.tooltip) colName = col.tooltip; // if column name is less then 3 char and there is tooltip - use it - text += '"' + w2utils.stripTags(colName) + '"\t'; - } - text = text.substr(0, text.length-1); // remove last \t - text += '\n'; - // copy selected text - for (var s = 0; s < sel.length; s++) { - var ind = this.get(sel[s], true); - for (var c = 0; c < this.columns.length; c++) { - var col = this.columns[c]; - if (col.hidden === true) continue; - text += '"' + this.getCellCopy(ind, c) + '"\t'; - } - text = text.substr(0, text.length-1); // remove last \t - text += '\n'; - } - } - text = text.substr(0, text.length - 1); - - // if called without params - if (flag == null) { - // before event - var edata = this.trigger({ phase: 'before', type: 'copy', target: this.name, text: text, - cut: (oEvent.keyCode == 88 ? true : false), originalEvent: oEvent }); - if (edata.isCancelled === true) return ''; - text = edata.text; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return text; - } else if (flag === false) { // only before event - // before event - var edata = this.trigger({ phase: 'before', type: 'copy', target: this.name, text: text, - cut: (oEvent.keyCode == 88 ? true : false), originalEvent: oEvent }); - if (edata.isCancelled === true) return ''; - text = edata.text; - return edata; - } - }, - - /** - * Gets value to be copied to the clipboard - * @param ind index of the record - * @param col_ind index of the column - * @returns the displayed value of the field's record associated with the cell - */ - getCellCopy: function(ind, col_ind) { - return w2utils.stripTags(this.getCellHTML(ind, col_ind)); - }, - - paste: function (text) { - var sel = this.getSelection(); - var ind = this.get(sel[0].recid, true); - var col = sel[0].column; - // before event - var edata = this.trigger({ phase: 'before', type: 'paste', target: this.name, text: text, index: ind, column: col }); - if (edata.isCancelled === true) return; - text = edata.text; - // default action - if (this.selectType == 'row' || sel.length === 0) { - console.log('ERROR: You can paste only if grid.selectType = \'cell\' and when at least one cell selected.'); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return; - } - var newSel = []; - var text = text.split('\n'); - for (var t = 0; t < text.length; t++) { - var tmp = text[t].split('\t'); - var cnt = 0; - var rec = this.records[ind]; - var cols = []; - if (rec == null) continue; - for (var dt = 0; dt < tmp.length; dt++) { - if (!this.columns[col + cnt]) continue; - this.setCellPaste(rec, col + cnt, tmp[dt]); - cols.push(col + cnt); - cnt++; - } - for (var c = 0; c < cols.length; c++) newSel.push({ recid: rec.recid, column: cols[c] }); - ind++; - } - this.selectNone(); - this.select(newSel); - this.refresh(); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - /** - * Sets record field using clipboard text - * @param rec record - * @param col_ind column index - * @param paste sub part of the pasted text - */ - setCellPaste: function(rec, col_ind, paste) { - var field = this.columns[col_ind].field; - rec.w2ui = rec.w2ui || {}; - rec.w2ui.changes = rec.w2ui.changes || {}; - rec.w2ui.changes[field] = paste; - }, - - // ================================================== - // --- Common functions - - resize: function () { - var obj = this; - var time = (new Date()).getTime(); - // make sure the box is right - if (!this.box || $(this.box).attr('name') != this.name) return; - // determine new width and height - $(this.box).find('> div.w2ui-grid-box') - .css('width', $(this.box).width()) - .css('height', $(this.box).height()); - // event before - var edata = this.trigger({ phase: 'before', type: 'resize', target: this.name }); - if (edata.isCancelled === true) return; - // resize - obj.resizeBoxes(); - obj.resizeRecords(); - if (obj.toolbar && obj.toolbar.resize) obj.toolbar.resize(); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return (new Date()).getTime() - time; - }, - - update: function (cells) { - var time = (new Date()).getTime(); - if (this.box == null) return 0; - if (cells == null) { - for (var index = this.last.range_start - 1; index <= this.last.range_end - 1; index++) { - if (index < 0) continue; - var rec = this.records[index] || {}; - if (!rec.w2ui) rec.w2ui = {}; - for (var column = 0; column < this.columns.length; column++) { - var row = $(this.box).find('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(rec.recid)); - var cell = $(this.box).find('#grid_'+ this.name + '_data_'+ index +'_'+ column); - cell.replaceWith(this.getCellHTML(index, column, false)); - cell = $(this.box).find('#grid_'+ this.name + '_data_'+ index +'_'+ column); // need to reselect as it was replaced - // assign style - if (rec.w2ui.style != null && !$.isEmptyObject(rec.w2ui.style)) { - if (typeof rec.w2ui.style == 'string') { - row.attr('style', rec.w2ui.style); - } - if ($.isPlainObject(rec.w2ui.style) && typeof rec.w2ui.style[column] == 'string') { - cell.attr('style', rec.w2ui.style[column]); - } - } else { - cell.attr('style', ''); - } - // assign class - if (rec.w2ui.class != null && !$.isEmptyObject(rec.w2ui.class)) { - if (typeof rec.w2ui.class == 'string') { - row.addClass(rec.w2ui.class); - } - if ($.isPlainObject(rec.w2ui.class) && typeof rec.w2ui.class[column] == 'string') { - cell.addClass(rec.w2ui.class[column]); - } - } - } - } - - } else { - - for (var i = 0; i < cells.length; i++) { - var index = cells[i].index; - var column = cells[i].column; - if (index < 0) continue; - if (index == null || column == null) { - console.log('ERROR: Wrong argument for grid.update(cells), cells should be [{ index: X, column: Y }, ...]'); - continue; - } - var rec = this.records[index] || {}; - var row = $(this.box).find('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(rec.recid)); - var cell = $(this.box).find('#grid_'+ this.name + '_data_'+ index +'_'+ column); - if (!rec.w2ui) rec.w2ui = {}; - cell.replaceWith(this.getCellHTML(index, column, false)); - cell = $(this.box).find('#grid_'+ this.name + '_data_'+ index +'_'+ column); // need to reselect as it was replaced - // assign style - if (rec.w2ui.style != null && !$.isEmptyObject(rec.w2ui.style)) { - if (typeof rec.w2ui.style == 'string') { - row.attr('style', rec.w2ui.style); - } - if ($.isPlainObject(rec.w2ui.style) && typeof rec.w2ui.style[column] == 'string') { - cell.attr('style', rec.w2ui.style[column]); - } - } else { - cell.attr('style', ''); - } - // assign class - if (rec.w2ui.class != null && !$.isEmptyObject(rec.w2ui.class)) { - if (typeof rec.w2ui.class == 'string') { - row.addClass(rec.w2ui.class); - } - if ($.isPlainObject(rec.w2ui.class) && typeof rec.w2ui.class[column] == 'string') { - cell.addClass(rec.w2ui.class[column]); - } - } - } - } - return (new Date()).getTime() - time; - }, - - refreshCell: function (recid, field) { - var index = this.get(recid, true); - var col_ind = this.getColumn(field, true); - var isSummary = (this.records[index] && this.records[index].recid == recid ? false : true); - var cell = $(this.box).find((isSummary ? '.w2ui-grid-summary ' : '') + '#grid_'+ this.name + '_data_'+ index +'_'+ col_ind); - if (cell.length == 0) return false; - // set cell html and changed flag - cell.replaceWith(this.getCellHTML(index, col_ind, isSummary)); - }, - - refreshRow: function (recid, ind) { - var tr1 = $(this.box).find('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)); - var tr2 = $(this.box).find('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)); - if (tr1.length > 0) { - if (ind == null) ind = this.get(recid, true); - var line = tr1.attr('line'); - var isSummary = (this.records[ind] && this.records[ind].recid == recid ? false : true); - // if it is searched, find index in search array - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (this.searchData.length > 0 && !url) for (var s = 0; s < this.last.searchIds.length; s++) if (this.last.searchIds[s] == ind) ind = s; - var rec_html = this.getRecordHTML(ind, line, isSummary); - $(tr1).replaceWith(rec_html[0]); - $(tr2).replaceWith(rec_html[1]); - // apply style to row if it was changed in render functions - var st = (this.records[ind].w2ui ? this.records[ind].w2ui.style : ''); - if (typeof st == 'string') { - var tr1 = $(this.box).find('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid)); - var tr2 = $(this.box).find('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid)); - tr1.attr('custom_style', st); - tr2.attr('custom_style', st); - if (tr1.hasClass('w2ui-selected')) { - st = st.replace('background-color', 'none'); - } - tr1[0].style.cssText = 'height: '+ this.recordHeight + 'px;' + st; - tr2[0].style.cssText = 'height: '+ this.recordHeight + 'px;' + st; - } - if (isSummary) { - this.resize(); - } - } - }, - - refresh: function () { - var obj = this; - var time = (new Date()).getTime(); - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (this.total <= 0 && !url && this.searchData.length === 0) { - this.total = this.records.length; - } - this.toolbar.disable('w2ui-edit', 'w2ui-delete'); - if (!this.box) return; - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'refresh' }); - if (edata.isCancelled === true) return; - // -- header - if (this.show.header) { - $('#grid_'+ this.name +'_header').html(this.header +' ').show(); - } else { - $('#grid_'+ this.name +'_header').hide(); - } - // -- toolbar - if (this.show.toolbar) { - // if select-collumn is checked - no toolbar refresh - if (this.toolbar && this.toolbar.get('w2ui-column-on-off') && this.toolbar.get('w2ui-column-on-off').checked) { - // no action - } else { - $('#grid_'+ this.name +'_toolbar').show(); - // refresh toolbar all but search field - if (typeof this.toolbar == 'object') { - var tmp = this.toolbar.items; - for (var t = 0; t < tmp.length; t++) { - if (tmp[t].id == 'w2ui-search' || tmp[t].type == 'break') continue; - this.toolbar.refresh(tmp[t].id); - } - } - } - } else { - $('#grid_'+ this.name +'_toolbar').hide(); - } - // -- make sure search is closed - this.searchClose(); - // search placeholder - var el = $('#grid_'+ obj.name +'_search_all'); - if (!this.multiSearch && this.last.field == 'all' && this.searches.length > 0) { - this.last.field = this.searches[0].field; - this.last.label = this.searches[0].label; - } - for (var s = 0; s < this.searches.length; s++) { - if (this.searches[s].field == this.last.field) this.last.label = this.searches[s].label; - } - if (this.last.multi) { - el.attr('placeholder', '[' + w2utils.lang('Multiple Fields') + ']'); - el.w2field('clear'); - } else { - el.attr('placeholder', w2utils.lang(this.last.label)); - } - if (el.val() != this.last.search) { - var val = this.last.search; - var tmp = el.data('w2field'); - if (tmp) val = tmp.format(val); - el.val(val); - } - - // -- body - obj.refreshBody(); - - // -- footer - if (this.show.footer) { - $('#grid_'+ this.name +'_footer').html(this.getFooterHTML()).show(); - } else { - $('#grid_'+ this.name +'_footer').hide(); - } - // show/hide clear search link - var $clear = $('#grid_'+ this.name +'_searchClear'); - $clear.hide(); - this.searchData.some(function (item) { - var tmp = obj.getSearch(item.field); - if (obj.last.multi || (tmp && !tmp.hidden && ['list', 'enum'].indexOf(tmp.type) == -1)) { - $clear.show(); - return true; - } - }); - // all selected? - var sel = this.last.selection, - areAllSelected = (this.records.length > 0 && sel.indexes.length == this.records.length), - areAllSearchedSelected = (sel.indexes.length > 0 && this.searchData.length !== 0 && sel.indexes.length == this.last.searchIds.length); - if (areAllSelected || areAllSearchedSelected) { - $('#grid_'+ this.name +'_check_all').prop('checked', true); - } else { - $('#grid_'+ this.name +'_check_all').prop('checked', false); - } - // show number of selected - this.status(); - // collapse all records - var rows = obj.find({ 'w2ui.expanded': true }, true); - for (var r = 0; r < rows.length; r++) { - var tmp = obj.records[rows[r]].w2ui; - if (tmp && !Array.isArray(tmp.children)) { - tmp.expanded = false; - } - } - // mark selection - if (obj.markSearch) { - setTimeout(function () { - // mark all search strings - var search = []; - for (var s = 0; s < obj.searchData.length; s++) { - var sdata = obj.searchData[s]; - var fld = obj.getSearch(sdata.field); - if (!fld || fld.hidden) continue; - var ind = obj.getColumn(sdata.field, true); - search.push({ field: sdata.field, search: sdata.value, col: ind }); - } - if (search.length > 0) { - search.forEach(function (item) { - $(obj.box).find('td[col="'+ item.col +'"]').not('.w2ui-head').w2marker(item.search); - }); - } - }, 50); - } - // enable/disable toolbar search button - if (this.show.toolbarSave) { - if (this.getChanges().length > 0) this.toolbar.enable('w2ui-save'); else this.toolbar.disable('w2ui-save'); - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - obj.resize(); - obj.addRange('selection'); - setTimeout(function () { // allow to render first - obj.resize(); // needed for horizontal scroll to show (do not remove) - obj.scroll(); - }, 1); - - if ( obj.reorderColumns && !obj.last.columnDrag ) { - obj.last.columnDrag = obj.initColumnDrag(); - } else if ( !obj.reorderColumns && obj.last.columnDrag ) { - obj.last.columnDrag.remove(); - } - return (new Date()).getTime() - time; - }, - - refreshBody: function () { - // -- separate summary - var obj = this, - tmp = this.find({ 'w2ui.summary': true }, true); - if (tmp.length > 0) { - for (var t = 0; t < tmp.length; t++) this.summary.push(this.records[tmp[t]]); - for (var t = tmp.length-1; t >= 0; t--) this.records.splice(tmp[t], 1); - } - - // -- body - this.scroll(); // need to calculate virtual scolling for columns - var recHTML = this.getRecordsHTML(); - var colHTML = this.getColumnsHTML(); - var bodyHTML = - '
'+ - recHTML[0] + - '
'+ - '
' + - recHTML[1] + - '
'+ - '
'+ - // Columns need to be after to be able to overlap - '
'+ - ' '+ colHTML[0] +'
'+ - '
'+ - '
'+ - ' '+ colHTML[1] +'
'+ - '
'; - - var gridBody = $('#grid_'+ this.name +'_body', obj.box).html(bodyHTML), - records = $('#grid_'+ this.name +'_records', obj.box); - var frecords = $('#grid_'+ this.name +'_frecords', obj.box); - var self = this; - if (this.selectType == 'row') { - records - .on('mouseover mouseout', 'tr', function(event) { - $('#grid_'+ self.name +'_frec_' + w2utils.escapeId($(this).attr('recid'))).toggleClass('w2ui-record-hover', event.type == 'mouseover') - }) - frecords - .on('mouseover mouseout', 'tr', function(event) { - $('#grid_'+ self.name +'_rec_' + w2utils.escapeId($(this).attr('recid'))).toggleClass('w2ui-record-hover', event.type == 'mouseover') - }) - } - if(w2utils.isIOS) - records.add(frecords) - .on('click', 'tr', function(ev) { - self.dblClick($(this).attr('recid'), ev); - }) - else - records.add(frecords) - .on('click', 'tr', function(ev) { - self.click($(this).attr('recid'), ev); - }) - .on('contextmenu', 'tr', function(ev) { - self.contextMenu($(this).attr('recid'), null, ev); - }) - - // enable scrolling on frozen records, - gridBody.data('scrolldata', { lastTime: 0, lastDelta: 0, time: 0 }) - .find('.w2ui-grid-frecords') - .on("mousewheel DOMMouseScroll ", function(event) { - event.preventDefault(); - - var e = event.originalEvent, - scrolldata = gridBody.data('scrolldata'), - recordsContainer = $(this).siblings('.w2ui-grid-records').addBack().filter('.w2ui-grid-records'), - amount = typeof e.wheelDelta != null ? e.wheelDelta * -1 / 120 : (e.detail || e.deltaY) / 3, // normalizing scroll speed - newScrollTop = recordsContainer.scrollTop(); - - scrolldata.time = +new Date(); - - if (scrolldata.lastTime < scrolldata.time - 150) { - scrolldata.lastDelta = 0; - } - - scrolldata.lastTime = scrolldata.time; - scrolldata.lastDelta += amount; - - if (Math.abs(scrolldata.lastDelta) < 1) { - amount = 0; - } else { - amount = Math.round(scrolldata.lastDelta); - } - gridBody.data('scrolldata', scrolldata); - - // make scroll amount dependent on visible rows - amount *= (Math.round(records.height() / obj.recordHeight) - 1) * obj.recordHeight / 4; - recordsContainer.stop().animate({ 'scrollTop': newScrollTop + amount }, 250, 'linear'); - }); - - if (this.records.length === 0 && this.msgEmpty) { - $('#grid_'+ this.name +'_body') - .append('
'+ this.msgEmpty +'
'); - } else if ($('#grid_'+ this.name +'_empty_msg').length > 0) { - $('#grid_'+ this.name +'_empty_msg').remove(); - } - // show summary records - if (this.summary.length > 0) { - var sumHTML = this.getSummaryHTML(); - $('#grid_'+ this.name +'_fsummary').html(sumHTML[0]).show(); - $('#grid_'+ this.name +'_summary').html(sumHTML[1]).show(); - } else { - $('#grid_'+ this.name +'_fsummary').hide(); - $('#grid_'+ this.name +'_summary').hide(); - } - }, - - render: function (box) { - var obj = this; - var time = (new Date()).getTime(); - if (box != null) { - if ($(this.box).find('#grid_'+ this.name +'_body').length > 0) { - $(this.box) - .removeAttr('name') - .removeClass('w2ui-reset w2ui-grid w2ui-inactive') - .html(''); - } - this.box = box; - } - if (!this.box) return; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'render', box: box }); - if (edata.isCancelled === true) return; - // reset needed if grid existed - this.reset(true); - // --- default search field - if (!this.last.field) { - if (!this.multiSearch || !this.show.searchAll) { - var tmp = 0; - while (tmp < this.searches.length && (this.searches[tmp].hidden || this.searches[tmp].simple === false)) tmp++; - if (tmp >= this.searches.length) { - // all searches are hidden - this.last.field = ''; - this.last.label = ''; - } else { - this.last.field = this.searches[tmp].field; - this.last.label = this.searches[tmp].label; - } - } else { - this.last.field = 'all'; - this.last.label = w2utils.lang('All Fields'); - } - } - // insert elements - $(this.box) - .attr('name', this.name) - .addClass('w2ui-reset w2ui-grid w2ui-inactive') - .html('
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - ' '+ - ' '+ // readonly needed on android not to open keyboard - '
'); - if (this.selectType != 'row') $(this.box).addClass('w2ui-ss'); - if ($(this.box).length > 0) $(this.box)[0].style.cssText += this.style; - // init toolbar - this.initToolbar(); - if (this.toolbar != null) this.toolbar.render($('#grid_'+ this.name +'_toolbar')[0]); - // reinit search_all - if (this.last.field && this.last.field != 'all') { - var sd = this.searchData; - setTimeout(function () { obj.initAllField(obj.last.field, (sd.length == 1 ? sd[0].value : null)); }, 1); - } - // init footer - $('#grid_'+ this.name +'_footer').html(this.getFooterHTML()); - // refresh - if (!this.last.state) this.last.state = this.stateSave(true); // initial default state - this.stateRestore(); - if (url) { this.clear(); this.refresh(); } // show empty grid (need it) - should it be only for remote data source - // if hidden searches - apply it - var hasHiddenSearches = false; - for (var i = 0; i < this.searches.length; i++) { - if (this.searches[i].hidden) { hasHiddenSearches = true; break; } - } - if (hasHiddenSearches) { - this.searchReset(false); // will call reload - if (!url) setTimeout(function () { obj.searchReset(); }, 1); - } else { - this.reload(); - } - // focus - $(this.box).find('#grid_'+ this.name + '_focus') - .on('focus', function (event) { - clearTimeout(obj.last.kbd_timer); - if (!obj.hasFocus) obj.focus(); - }) - .on('blur', function (event) { - clearTimeout(obj.last.kbd_timer); - obj.last.kbd_timer = setTimeout(function () { - if (obj.hasFocus) { obj.blur(); } - }, 100); // need this timer to be 100 ms - }) - .on('paste', function (event) { - var cd = (event.originalEvent.clipboardData ? event.originalEvent.clipboardData : null) - if (cd && cd.types && cd.types.indexOf('text/plain') != -1) { - event.preventDefault() - var text = cd.getData('text/plain'); - if (text.indexOf('\r') != -1 && text.indexOf('\n') == -1) { - text = text.replace(/\r/g, '\n'); - } - w2ui[obj.name].paste(text); - } else { - // for older browsers - var el = this; - setTimeout(function () { w2ui[obj.name].paste(el.value); el.value = ''; }, 1) - } - }) - .on('keydown', function (event) { - w2ui[obj.name].keydown.call(w2ui[obj.name], event); - }); - // init mouse events for mouse selection - var edataCol; // event for column select - $(this.box).off('mousedown').on('mousedown', mouseStart); - this.updateToolbar() - // event after - this.trigger($.extend(edata, { phase: 'after' })); - // attach to resize event - if ($('.w2ui-layout').length === 0) { // if there is layout, it will send a resize event - $(window) - .off('resize.w2ui-'+ obj.name) - .on('resize.w2ui-'+ obj.name, function (event) { - if (w2ui[obj.name] == null) { - $(window).off('resize.w2ui-'+ obj.name) - } else { - w2ui[obj.name].resize(); - } - }); - } - return (new Date()).getTime() - time; - - function mouseStart (event) { - if (event.which != 1) return; // if not left mouse button - // restore css user-select - if (obj.last.userSelect == 'text') { - delete obj.last.userSelect; - $(obj.box).find('.w2ui-grid-body').css(w2utils.cssPrefix('user-select', 'none')); - } - // regular record select - if (obj.selectType == 'row' && ($(event.target).parents().hasClass('w2ui-head') || $(event.target).hasClass('w2ui-head'))) return; - if (obj.last.move && obj.last.move.type == 'expand') return; - // if altKey - alow text selection - if (event.altKey) { - $(obj.box).find('.w2ui-grid-body').css(w2utils.cssPrefix('user-select', 'text')); - obj.selectNone(); - obj.last.move = { type: 'text-select' }; - obj.last.userSelect = 'text'; - } else { - var tmp = event.target; - var pos = { - x: event.offsetX - 10, - y: event.offsetY - 10 - } - var tmps = false; - while (tmp) { - if (tmp.classList && tmp.classList.contains('w2ui-grid')) break; - if (tmp.tagName && tmp.tagName.toUpperCase() == 'TD') tmps = true; - if (tmp.tagName && tmp.tagName.toUpperCase() != 'TR' && tmps == true) { - pos.x += tmp.offsetLeft; - pos.y += tmp.offsetTop; - } - tmp = tmp.parentNode; - } - - obj.last.move = { - x : event.screenX, - y : event.screenY, - divX : 0, - divY : 0, - focusX : pos.x, - focusY : pos.y, - recid : $(event.target).parents('tr').attr('recid'), - column : parseInt(event.target.tagName.toUpperCase() == 'TD' ? $(event.target).attr('col') : $(event.target).parents('td').attr('col')), - type : 'select', - ghost : false, - start : true - }; - if (obj.last.move.recid == null) obj.last.move.type = 'select-column'; - // set focus to grid - var target = event.target; - var $input = $(obj.box).find('#grid_'+ obj.name + '_focus'); - // move input next to cursor so screen does not jump - if (obj.last.move) { - var sLeft = obj.last.move.focusX; - var sTop = obj.last.move.focusY; - var $owner = $(target).parents('table').parent(); - if ($owner.hasClass('w2ui-grid-records') || $owner.hasClass('w2ui-grid-frecords') - || $owner.hasClass('w2ui-grid-columns') || $owner.hasClass('w2ui-grid-fcolumns') - || $owner.hasClass('w2ui-grid-summary')) { - sLeft = obj.last.move.focusX - $(obj.box).find('#grid_'+ obj.name +'_records').scrollLeft(); - sTop = obj.last.move.focusY - $(obj.box).find('#grid_'+ obj.name +'_records').scrollTop(); - } - if ($(target).hasClass('w2ui-grid-footer') || $(target).parents('div.w2ui-grid-footer').length > 0) { - sTop = $(obj.box).find('#grid_'+ obj.name +'_footer').position().top; - } - // if clicked on toolbar - if ($owner.hasClass('w2ui-scroll-wrapper') && $owner.parent().hasClass('w2ui-toolbar')) { - sLeft = obj.last.move.focusX - $owner.scrollLeft(); - } - $input.css({ - left: sLeft - 10, - top : sTop - }); - } - // if toolbar input is clicked - setTimeout(function () { - if (['INPUT', 'TEXTAREA', 'SELECT'].indexOf(target.tagName.toUpperCase()) != -1) { - $(target).focus(); - } else { - if (!$input.is(':focus')) $input.focus(); - } - }, 50); - // disable click select for this condition - if (!obj.multiSelect && !obj.reorderRows && obj.last.move.type == 'drag') { - delete obj.last.move; - } - } - if (obj.reorderRows == true) { - var el = event.target; - if (el.tagName.toUpperCase() != 'TD') el = $(el).parents('td')[0]; - if ($(el).hasClass('w2ui-col-number') || $(el).hasClass('w2ui-col-order')) { - obj.selectNone(); - obj.last.move.reorder = true; - // supress hover - var eColor = $(obj.box).find('.w2ui-even.w2ui-empty-record').css('background-color'); - var oColor = $(obj.box).find('.w2ui-odd.w2ui-empty-record').css('background-color'); - $(obj.box).find('.w2ui-even td').not('.w2ui-col-number').css('background-color', eColor); - $(obj.box).find('.w2ui-odd td').not('.w2ui-col-number').css('background-color', oColor); - // display empty record and ghost record - var mv = obj.last.move; - if (!mv.ghost) { - var row = $('#grid_'+ obj.name + '_rec_'+ mv.recid); - var tmp = row.parents('table').find('tr:first-child').clone(); - mv.offsetY = event.offsetY; - mv.from = mv.recid; - mv.pos = row.position(); - mv.ghost = $(row).clone(true); - mv.ghost.removeAttr('id'); - row.find('td').remove(); - row.append('
'); - var recs = $(obj.box).find('.w2ui-grid-records'); - recs.append('
'); - recs.append('
'); - $('#grid_'+ obj.name + '_ghost').append(tmp).append(mv.ghost); - } - var ghost = $('#grid_'+ obj.name + '_ghost'); - var recs = $(obj.box).find('.w2ui-grid-records'); - ghost.css({ - top : mv.pos.top + recs.scrollTop(), - left : mv.pos.left, - "border-top" : '1px solid #aaa', - "border-bottom" : '1px solid #aaa' - }); - } else { - obj.last.move.reorder = false; - } - } - $(document) - .on('mousemove.w2ui-' + obj.name, mouseMove) - .on('mouseup.w2ui-' + obj.name, mouseStop); - // needed when grid grids are nested, see issue #1275 - event.stopPropagation(); - } - - function mouseMove (event) { - var mv = obj.last.move; - if (!mv || ['select', 'select-column'].indexOf(mv.type) == -1) return; - mv.divX = (event.screenX - mv.x); - mv.divY = (event.screenY - mv.y); - if (Math.abs(mv.divX) <= 1 && Math.abs(mv.divY) <= 1) return; // only if moved more then 1px - obj.last.cancelClick = true; - if (obj.reorderRows == true && obj.last.move.reorder) { - var recs = $(obj.box).find('.w2ui-grid-records'); - var tmp = $(event.target).parents('tr'); - var recid = tmp.attr('recid'); - if (recid == '-none-') recid = 'bottom'; - if (recid != mv.from) { - var row1 = $('#grid_'+ obj.name + '_rec_'+ mv.recid); - var row2 = $('#grid_'+ obj.name + '_rec_'+ recid); - $(obj.box).find('.insert-before'); - row2.addClass('insert-before'); - // MOVABLE GHOST - // if (event.screenY - mv.lastY < 0) row1.after(row2); else row2.after(row1); - mv.lastY = event.screenY; - mv.to = recid; - // line to insert before - var pos = row2.position() - var ghost_line = $('#grid_'+ obj.name + '_ghost_line'); - if (pos) { - ghost_line.css({ - top : pos.top + recs.scrollTop(), - left : mv.pos.left, - 'border-top': '2px solid #769EFC' - }); - } else { - ghost_line.css({ - 'border-top': '2px solid transparent' - }); - } - } - var ghost = $('#grid_'+ obj.name + '_ghost'); - ghost.css({ - top : mv.pos.top + mv.divY + recs.scrollTop(), - left : mv.pos.left - }); - return; - } - if (mv.start && mv.recid) { - obj.selectNone(); - mv.start = false; - } - var newSel= []; - var recid = (event.target.tagName.toUpperCase() == 'TR' ? $(event.target).attr('recid') : $(event.target).parents('tr').attr('recid')); - if (recid == null) { - // select by dragging columns - if (obj.selectType == 'row') return; - if (obj.last.move && obj.last.move.type == 'select') return; - var col = parseInt($(event.target).parents('td').attr('col')); - if (isNaN(col)) { - obj.removeRange('column-selection'); - $(obj.box).find('.w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header').removeClass('w2ui-col-selected'); - $(obj.box).find('.w2ui-col-number').removeClass('w2ui-row-selected'); - delete mv.colRange; - } else { - // add all columns in between - var newRange = col + '-' + col; - if (mv.column < col) newRange = mv.column + '-' + col; - if (mv.column > col) newRange = col + '-' + mv.column; - // array of selected columns - var cols = []; - var tmp = newRange.split('-'); - for (var ii = parseInt(tmp[0]); ii <= parseInt(tmp[1]); ii++) { - cols.push(ii) - } - if (mv.colRange != newRange) { - edataCol = obj.trigger({ phase: 'before', type: 'columnSelect', target: obj.name, columns: cols, isCancelled: false }); // initial isCancelled - if (edataCol.isCancelled !== true) { - if (mv.colRange == null) obj.selectNone(); - // highlight columns - var tmp = newRange.split('-'); - $(obj.box).find('.w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header').removeClass('w2ui-col-selected'); - for (var j = parseInt(tmp[0]); j <= parseInt(tmp[1]); j++) { - $(obj.box).find('#grid_'+ obj.name +'_column_' + j + ' .w2ui-col-header').addClass('w2ui-col-selected'); - } - $(obj.box).find('.w2ui-col-number').not('.w2ui-head').addClass('w2ui-row-selected'); - // show new range - mv.colRange = newRange; - obj.removeRange('column-selection'); - obj.addRange({ - name : 'column-selection', - range : [{ recid: obj.records[0].recid, column: tmp[0] }, { recid: obj.records[obj.records.length-1].recid, column: tmp[1] }], - style : 'background-color: rgba(90, 145, 234, 0.1)' - }); - } - } - } - - } else { // regular selection - - var ind1 = obj.get(mv.recid, true); - // this happens when selection is started on summary row - if (ind1 == null || (obj.records[ind1] && obj.records[ind1].recid != mv.recid)) return; - var ind2 = obj.get(recid, true); - // this happens when selection is extended into summary row (a good place to implement scrolling) - if (ind2 == null) return; - var col1 = parseInt(mv.column); - var col2 = parseInt(event.target.tagName.toUpperCase() == 'TD' ? $(event.target).attr('col') : $(event.target).parents('td').attr('col')); - if (isNaN(col1) && isNaN(col2)) { // line number select entire record - col1 = 0; - col2 = obj.columns.length-1; - } - if (ind1 > ind2) { var tmp = ind1; ind1 = ind2; ind2 = tmp; } - // check if need to refresh - var tmp = 'ind1:'+ ind1 +',ind2;'+ ind2 +',col1:'+ col1 +',col2:'+ col2; - if (mv.range == tmp) return; - mv.range = tmp; - for (var i = ind1; i <= ind2; i++) { - if (obj.last.searchIds.length > 0 && obj.last.searchIds.indexOf(i) == -1) continue; - if (obj.selectType != 'row') { - if (col1 > col2) { var tmp = col1; col1 = col2; col2 = tmp; } - var tmp = []; - for (var c = col1; c <= col2; c++) { - if (obj.columns[c].hidden) continue; - newSel.push({ recid: obj.records[i].recid, column: parseInt(c) }); - } - } else { - newSel.push(obj.records[i].recid); - } - } - if (obj.selectType != 'row') { - var sel = obj.getSelection(); - // add more items - var tmp = []; - for (var ns = 0; ns < newSel.length; ns++) { - var flag = false; - for (var s = 0; s < sel.length; s++) if (newSel[ns].recid == sel[s].recid && newSel[ns].column == sel[s].column) flag = true; - if (!flag) tmp.push({ recid: newSel[ns].recid, column: newSel[ns].column }); - } - obj.select(tmp); - // remove items - var tmp = []; - for (var s = 0; s < sel.length; s++) { - var flag = false; - for (var ns = 0; ns < newSel.length; ns++) if (newSel[ns].recid == sel[s].recid && newSel[ns].column == sel[s].column) flag = true; - if (!flag) tmp.push({ recid: sel[s].recid, column: sel[s].column }); - } - obj.unselect(tmp); - } else { - if (obj.multiSelect) { - var sel = obj.getSelection(); - for (var ns = 0; ns < newSel.length; ns++) { - if (sel.indexOf(newSel[ns]) == -1) obj.select(newSel[ns]); // add more items - } - for (var s = 0; s < sel.length; s++) { - if (newSel.indexOf(sel[s]) == -1) obj.unselect(sel[s]); // remove items - } - } - } - } - } - - function mouseStop (event) { - var mv = obj.last.move; - setTimeout(function () { delete obj.last.cancelClick; }, 1); - if ($(event.target).parents().hasClass('.w2ui-head') || $(event.target).hasClass('.w2ui-head')) return; - if (mv && ['select', 'select-column'].indexOf(mv.type) != -1) { - if (mv.colRange != null && edataCol.isCancelled !== true) { - var tmp = mv.colRange.split('-'); - var sel = []; - for (var i = 0; i < obj.records.length; i++) { - var cols = [] - for (var j = parseInt(tmp[0]); j <= parseInt(tmp[1]); j++) cols.push(j); - sel.push({ recid: obj.records[i].recid, column: cols }); - } - obj.removeRange('column-selection'); - obj.trigger($.extend(edataCol, { phase: 'after' })); - obj.select(sel); - } - if (obj.reorderRows == true && obj.last.move.reorder) { - // event - var edata = obj.trigger({ phase: 'before', target: obj.name, type: 'reorderRow', recid: mv.from, moveAfter: mv.to }); - if (edata.isCancelled === true) { - $('#grid_'+ obj.name + '_ghost').remove(); - $('#grid_'+ obj.name + '_ghost_line').remove(); - obj.refresh(); - delete obj.last.move; - return; - } - // default behavior - var ind1 = obj.get(mv.from, true); - var ind2 = obj.get(mv.to, true); - if (mv.to == 'bottom') ind2 = obj.records.length; // end of list - var tmp = obj.records[ind1]; - // swap records - if (ind1 != null && ind2 != null) { - obj.records.splice(ind1, 1); - if (ind1 > ind2) { - obj.records.splice(ind2, 0, tmp); - } else { - obj.records.splice(ind2 - 1, 0, tmp); - } - } - $('#grid_'+ obj.name + '_ghost').remove(); - $('#grid_'+ obj.name + '_ghost_line').remove(); - obj.refresh(); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - } - } - delete obj.last.move; - $(document).off('.w2ui-' + obj.name); - } - }, - - destroy: function () { - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'destroy' }); - if (edata.isCancelled === true) return; - // remove all events - $(this.box).off(); - // clean up - if (typeof this.toolbar == 'object' && this.toolbar.destroy) this.toolbar.destroy(); - if ($(this.box).find('#grid_'+ this.name +'_body').length > 0) { - $(this.box) - .removeAttr('name') - .removeClass('w2ui-reset w2ui-grid w2ui-inactive') - .html(''); - } - delete w2ui[this.name]; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - // =========================================== - // --- Internal Functions - - initColumnOnOff: function () { - if (!this.show.toolbarColumns) return; - var obj = this; - // line number - var col_html = '
'+ - ''+ - ''+ - ' '+ - ' '+ - ''; - // columns - for (var c = 0; c < this.columns.length; c++) { - var col = this.columns[c]; - var tmp = this.columns[c].text; - if (col.hideable === false) continue; - if (!tmp && this.columns[c].tooltip) tmp = this.columns[c].tooltip; - if (!tmp) tmp = '- column '+ (parseInt(c) + 1) +' -'; - col_html += - ''+ - ' '+ - ' '+ - ''; - } - var url = (typeof this.url != 'object' ? this.url : this.url.get); - // devider - if ((url && obj.show.skipRecords) || obj.show.saveRestoreState) { - col_html += ''; - } - // skip records - if (url && obj.show.skipRecords) { - col_html += - ''; - } - // save/restore state - if (obj.show.saveRestoreState) { - col_html += ''+ - ''; - } - col_html += "
'+ - ' '+ - ' '+ - ' '+ - '
'+ - ' '+ - ' '+ - ' '+ - '
'+ - '
'+ w2utils.lang('Skip') + - ' '+ w2utils.lang('Records')+ - '
'+ - '
'+ - '
'+ w2utils.lang('Save Grid State') + '
'+ - '
'+ - '
'+ w2utils.lang('Restore Default State') + '
'+ - '
"; - this.toolbar.get('w2ui-column-on-off').html = col_html; - }, - - /** - * - * @param box, grid object - * @returns {{remove: Function}} contains a closure around all events to ensure they are removed from the dom - */ - initColumnDrag: function ( box ) { - //throw error if using column groups - if ( this.columnGroups && this.columnGroups.length ) throw 'Draggable columns are not currently supported with column groups.'; - - var obj = this, - _dragData = {}; - _dragData.lastInt = null; - _dragData.pressed = false; - _dragData.timeout = null;_dragData.columnHead = null; - - //attach original event listener - $(obj.box).on('mousedown', dragColStart); - $(obj.box).on('mouseup', catchMouseup); - - function catchMouseup(){ - _dragData.pressed = false; - clearTimeout( _dragData.timeout ); - } - /** - * - * @param event, mousedown - * @returns {boolean} false, preventsDefault - */ - function dragColStart ( event ) { - if ( _dragData.timeout ) clearTimeout( _dragData.timeout ); - var self = this; - _dragData.pressed = true; - - _dragData.timeout = setTimeout(function(){ - // When dragging a column for reordering, a quick release and a secondary - // click may result in a bug where the column is ghosted to the screen, - // but can no longer be docked back into the header. It simply floats and you - // can no longer interact with it. - // The erronius event thats fired will have _dragData.numberPreColumnsPresent === 0 - // populated, wheras a valid event will not. - // if we see the erronius event, dont allow that second click to register, which results - // in the floating column remaining under the mouse's control. - if ( !_dragData.pressed || _dragData.numberPreColumnsPresent === 0 ) return; - - var edata, - columns, - selectedCol, - origColumn, - origColumnNumber, - invalidPreColumns = [ 'w2ui-col-number', 'w2ui-col-expand', 'w2ui-col-select' ], - invalidPostColumns = [ 'w2ui-head-last' ], - invalidColumns = invalidPreColumns.concat( invalidPostColumns ), - preColumnsSelector = '.w2ui-col-number, .w2ui-col-expand, .w2ui-col-select', - preColHeadersSelector = '.w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select'; - - // do nothing if it is not a header - if ( !$( event.originalEvent.target ).parents().hasClass( 'w2ui-head' ) ) return; - - // do nothing if it is an invalid column - for ( var i = 0, l = invalidColumns.length; i < l; i++ ){ - if ( $( event.originalEvent.target ).parents().hasClass( invalidColumns[ i ] ) ) return; - } - - _dragData.numberPreColumnsPresent = $( obj.box ).find( preColHeadersSelector ).length; - - //start event for drag start - _dragData.columnHead = origColumn = $( event.originalEvent.target ).parents( '.w2ui-head' ); - _dragData.originalPos = origColumnNumber = parseInt( origColumn.attr( 'col' ), 10); - edata = obj.trigger({ type: 'columnDragStart', phase: 'before', originalEvent: event, origColumnNumber: origColumnNumber, target: origColumn[0] }); - if ( edata.isCancelled === true ) return false; - - columns = _dragData.columns = $( obj.box ).find( '.w2ui-head:not(.w2ui-head-last)' ); - - //add events - $( document ).on( 'mouseup', dragColEnd ); - $( document ).on( 'mousemove', dragColOver ); - - //_dragData.columns.css({ overflow: 'visible' }).children( 'div' ).css({ overflow: 'visible' }); - - //configure and style ghost image - _dragData.ghost = $( self ).clone( true ); - - //hide other elements on ghost except the grid body - $( _dragData.ghost ).find( '[col]:not([col="' + _dragData.originalPos + '"]), .w2ui-toolbar, .w2ui-grid-header' ).remove(); - $( _dragData.ghost ).find( preColumnsSelector ).remove(); - $( _dragData.ghost ).find( '.w2ui-grid-body' ).css({ top: 0 }); - - selectedCol = $( _dragData.ghost ).find( '[col="' + _dragData.originalPos + '"]' ); - $( document.body ).append( _dragData.ghost ); - - $( _dragData.ghost ).css({ - width: 0, - height: 0, - margin: 0, - position: 'fixed', - zIndex: 999999, - opacity: 0 - }).addClass( '.w2ui-grid-ghost' ).animate({ - width: selectedCol.width(), - height: $(obj.box).find('.w2ui-grid-body:first').height(), - left : event.pageX, - top : event.pageY, - opacity: 0.8 - }, 0 ); - - //establish current offsets - _dragData.offsets = []; - for ( var i = 0, l = columns.length; i < l; i++ ) { - _dragData.offsets.push( $( columns[ i ] ).offset().left ); - } - - //conclude event - obj.trigger( $.extend( edata, { phase: 'after' } ) ); - }, 150 );//end timeout wrapper - } - - function dragColOver ( event ) { - if ( !_dragData.pressed ) return; - - var cursorX = event.originalEvent.pageX, - cursorY = event.originalEvent.pageY, - offsets = _dragData.offsets, - lastWidth = $( '.w2ui-head:not(.w2ui-head-last)' ).width(); - - _dragData.targetInt = Math.max(_dragData.numberPreColumnsPresent,targetIntersection( cursorX, offsets, lastWidth )); - - markIntersection( _dragData.targetInt ); - trackGhost( cursorX, cursorY ); - } - - function dragColEnd ( event ) { - _dragData.pressed = false; - - var edata, - target, - selected, - columnConfig, - targetColumn, - ghosts = $( '.w2ui-grid-ghost' ); - - //start event for drag start - edata = obj.trigger({ type: 'columnDragEnd', phase: 'before', originalEvent: event, target: _dragData.columnHead[0] }); - if ( edata.isCancelled === true ) return false; - - selected = obj.columns[ _dragData.originalPos ]; - columnConfig = obj.columns; - targetColumn = $( _dragData.columns[ Math.min(_dragData.lastInt, _dragData.columns.length - 1) ] ); - target = (_dragData.lastInt < _dragData.columns.length) ? parseInt(targetColumn.attr('col')) : columnConfig.length; - - if ( target !== _dragData.originalPos + 1 && target !== _dragData.originalPos && targetColumn && targetColumn.length ) { - $( _dragData.ghost ).animate({ - top: $( obj.box ).offset().top, - left: targetColumn.offset().left, - width: 0, - height: 0, - opacity: 0.2 - }, 300, function(){ - $( this ).remove(); - ghosts.remove(); - }); - - columnConfig.splice( target, 0, $.extend( {}, selected ) ); - columnConfig.splice( columnConfig.indexOf( selected ), 1); - - } else { - $( _dragData.ghost ).remove(); - ghosts.remove(); - } - - //_dragData.columns.css({ overflow: '' }).children( 'div' ).css({ overflow: '' }); - - $( document ).off( 'mouseup', dragColEnd ); - $( document ).off( 'mousemove', dragColOver ); - if ( _dragData.marker ) _dragData.marker.remove(); - _dragData = {}; - - obj.refresh(); - - //conclude event - obj.trigger( $.extend( edata, { phase: 'after', targetColumnNumber: target - 1 } ) ); - } - - function markIntersection( intersection ){ - if ( !_dragData.marker && !_dragData.markerLeft ) { - _dragData.marker = $('
' + - '
' + - '
' + - '
'); - _dragData.markerLeft = $('
' + - '
' + - '
' + - '
'); - } - - if ( !_dragData.lastInt || _dragData.lastInt !== intersection ){ - _dragData.lastInt = intersection; - _dragData.marker.remove(); - _dragData.markerLeft.remove(); - $('.w2ui-head').removeClass('w2ui-col-intersection'); - - //if the current intersection is greater than the number of columns add the marker to the end of the last column only - if ( intersection >= _dragData.columns.length ) { - $( _dragData.columns[ _dragData.columns.length - 1 ] ).children( 'div:last' ).append( _dragData.marker.addClass( 'right' ).removeClass( 'left' ) ); - $( _dragData.columns[ _dragData.columns.length - 1 ] ).addClass('w2ui-col-intersection'); - } else if ( intersection <= _dragData.numberPreColumnsPresent ) { - //if the current intersection is on the column numbers place marker on first available column only - $( _dragData.columns[ _dragData.numberPreColumnsPresent ] ).prepend( _dragData.marker.addClass( 'left' ).removeClass( 'right' ) ).css({ position: 'relative' }); - $( _dragData.columns[ _dragData.numberPreColumnsPresent ] ).prev().addClass('w2ui-col-intersection'); - } else { - //otherwise prepend the marker to the targeted column and append it to the previous column - $( _dragData.columns[intersection] ).children( 'div:last' ).prepend( _dragData.marker.addClass( 'left' ).removeClass( 'right' ) ); - $( _dragData.columns[intersection] ).prev().children( 'div:last' ).append( _dragData.markerLeft.addClass( 'right' ).removeClass( 'left' ) ).css({ position: 'relative' }); - $( _dragData.columns[intersection - 1] ).addClass('w2ui-col-intersection'); - } - } - } - - function targetIntersection( cursorX, offsets, lastWidth ){ - if ( cursorX <= offsets[0] ) { - return 0; - } else if ( cursorX >= offsets[offsets.length - 1] + lastWidth ) { - return offsets.length; - } else { - for ( var i = 0, l = offsets.length; i < l; i++ ) { - var thisOffset = offsets[ i ]; - var nextOffset = offsets[ i + 1 ] || offsets[ i ] + lastWidth; - var midpoint = ( nextOffset - offsets[ i ]) / 2 + offsets[ i ]; - - if ( cursorX > thisOffset && cursorX <= midpoint ) { - return i; - } else if ( cursorX > midpoint && cursorX <= nextOffset ) { - return i + 1; - } - } - return intersection; - } - } - - function trackGhost( cursorX, cursorY ){ - $( _dragData.ghost ).css({ - left: cursorX - 10, - top: cursorY - 10 - }); - } - - //return an object to remove drag if it has ever been enabled - return { - remove: function(){ - $( obj.box ).off( 'mousedown', dragColStart ); - $( obj.box ).off( 'mouseup', catchMouseup ); - $( obj.box ).find( '.w2ui-head' ).removeAttr( 'draggable' ); - obj.last.columnDrag = false; - } - }; - }, - - columnOnOff: function (event, field) { - var $el = $(event.target).parents('tr').find('.w2ui-column-check'); - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'columnOnOff', field: field, originalEvent: event }); - if (edata.isCancelled === true) return; - // regular processing - var obj = this; - var hide = (!event.shiftKey && !event.metaKey && !event.ctrlKey && !$(event.target).hasClass('w2ui-column-check')); - // collapse expanded rows - var rows = obj.find({ 'w2ui.expanded': true }, true); - for (var r = 0; r < rows.length; r++) { - var tmp = this.records[r].w2ui; - if (tmp && !Array.isArray(tmp.children)) { - this.records[r].w2ui.expanded = false; - } - } - // show/hide - if (field == 'line-numbers') { - this.show.lineNumbers = !this.show.lineNumbers; - if (this.show.lineNumbers) { - $el.addClass('w2ui-icon-check').removeClass('w2ui-icon-empty'); - } else { - $el.addClass('w2ui-icon-empty').removeClass('w2ui-icon-check'); - } - this.refreshBody(); - this.resizeRecords(); - } else { - var col = this.getColumn(field); - if (col.hidden) { - $el.addClass('w2ui-icon-check').removeClass('w2ui-icon-empty'); - setTimeout(function () { - obj.showColumn(col.field); - }, hide ? 0 : 50); - } else { - $el.addClass('w2ui-icon-empty').removeClass('w2ui-icon-check'); - setTimeout(function () { - obj.hideColumn(col.field); - }, hide ? 0 : 50); - } - } - if (hide) { - setTimeout(function () { - $().w2overlay({ name: obj.name + '_toolbar' }); - }, 40); - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - scrollToColumn: function (field) { - if (field == null) - return; - var sWidth = 0; - var found = false; - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.field == field) { - found = true; - break; - } - if (col.frozen || col.hidden) - continue; - var cSize = parseInt(col.sizeCalculated ? col.sizeCalculated : col.size); - sWidth += cSize; - } - if (!found) - return; - this.last.scrollLeft = sWidth+1; - this.scroll(); - }, - - initToolbar: function () { - var obj = this; - // -- if toolbar is true - if (this.toolbar['render'] == null) { - var tmp_items = this.toolbar.items || []; - this.toolbar.items = []; - this.toolbar = $().w2toolbar($.extend(true, {}, this.toolbar, { name: this.name +'_toolbar', owner: this })); - - // ============================================= - // ------ Toolbar Generic buttons - - if (this.show.toolbarReload) { - this.toolbar.items.push($.extend(true, {}, this.buttons['reload'])); - } - if (this.show.toolbarColumns) { - this.toolbar.items.push($.extend(true, {}, this.buttons['columns'])); - } - if (this.show.toolbarReload || this.show.toolbarColumns) { - this.toolbar.items.push({ type: 'break', id: 'w2ui-break0' }); - } - if (this.show.toolbarInput) { - var html = - ''; - this.toolbar.items.push({ type: 'html', id: 'w2ui-search', html: html }); - } - if (this.show.toolbarSearch && this.multiSearch && this.searches.length > 0) { - this.toolbar.items.push($.extend(true, {}, this.buttons['search-go'])); - } - if ((this.show.toolbarSearch || this.show.toolbarInput) - && (this.show.toolbarAdd || this.show.toolbarEdit || this.show.toolbarDelete || this.show.toolbarSave)) { - this.toolbar.items.push({ type: 'break', id: 'w2ui-break1' }); - } - if (this.show.toolbarAdd && Array.isArray(tmp_items) - && tmp_items.map(function (item) { return item.id }).indexOf(this.buttons['add'].id) == -1) { - this.toolbar.items.push($.extend(true, {}, this.buttons['add'])); - } - if (this.show.toolbarEdit && Array.isArray(tmp_items) - && tmp_items.map(function (item) { return item.id }).indexOf(this.buttons['edit'].id) == -1) { - this.toolbar.items.push($.extend(true, {}, this.buttons['edit'])); - } - if (this.show.toolbarDelete && Array.isArray(tmp_items) - && tmp_items.map(function (item) { return item.id }).indexOf(this.buttons['delete'].id) == -1) { - this.toolbar.items.push($.extend(true, {}, this.buttons['delete'])); - } - if (this.show.toolbarSave && Array.isArray(tmp_items) - && tmp_items.map(function (item) { return item.id }).indexOf(this.buttons['save'].id) == -1) { - if (this.show.toolbarAdd || this.show.toolbarDelete || this.show.toolbarEdit) { - this.toolbar.items.push({ type: 'break', id: 'w2ui-break2' }); - } - this.toolbar.items.push($.extend(true, {}, this.buttons['save'])); - } - // add original buttons - if (tmp_items) for (var i = 0; i < tmp_items.length; i++) this.toolbar.items.push(tmp_items[i]); - - // ============================================= - // ------ Toolbar onClick processing - - var obj = this; - this.toolbar.on('click', function (event) { - var edata = obj.trigger({ phase: 'before', type: 'toolbar', target: event.target, originalEvent: event }); - if (edata.isCancelled === true) return; - var id = event.target; - switch (id) { - case 'w2ui-reload': - var edata2 = obj.trigger({ phase: 'before', type: 'reload', target: obj.name }); - if (edata2.isCancelled === true) return false; - obj.reload(); - obj.trigger($.extend(edata2, { phase: 'after' })); - break; - case 'w2ui-column-on-off': - obj.initColumnOnOff(); - obj.initResize(); - obj.resize(); - break; - case 'w2ui-search-advanced': - var it = this.get(id); - if (it.checked) { - obj.searchClose(); - } else { - obj.searchOpen(); - } - // need to cancel event in order to user custom searchOpen/close functions - obj.toolbar.tooltipHide('w2ui-search-advanced'); - event.preventDefault(); - break; - case 'w2ui-add': - // events - var edata2 = obj.trigger({ phase: 'before', target: obj.name, type: 'add', recid: null }); - if (edata2.isCancelled === true) return false; - obj.trigger($.extend(edata2, { phase: 'after' })); - // hide all tooltips - setTimeout(function () { $().w2tag(); }, 20); - break; - case 'w2ui-edit': - var sel = obj.getSelection(); - var recid = null; - if (sel.length == 1) recid = sel[0]; - // events - var edata2 = obj.trigger({ phase: 'before', target: obj.name, type: 'edit', recid: recid }); - if (edata2.isCancelled === true) return false; - obj.trigger($.extend(edata2, { phase: 'after' })); - // hide all tooltips - setTimeout(function () { $().w2tag(); }, 20); - break; - case 'w2ui-delete': - obj["delete"](); - break; - case 'w2ui-save': - obj.save(); - break; - } - // no default action - obj.trigger($.extend(edata, { phase: 'after' })); - }) - this.toolbar.on('refresh', function (event) { - if (event.target == 'w2ui-search') { - var sd = obj.searchData; - setTimeout(function () { - obj.initAllField(obj.last.field, (sd.length == 1 ? sd[0].value : null)); - }, 1); - } - }) - } - }, - - initResize: function () { - var obj = this; - //if (obj.resizing === true) return; - $(this.box).find('.w2ui-resizer') - .off('.grid-col-resize') - .on('click.grid-col-resize', function (event) { - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - if (event.preventDefault) event.preventDefault(); - }) - .on('mousedown.grid-col-resize', function (event) { - if (!event) event = window.event; - obj.resizing = true; - obj.last.tmp = { - x : event.screenX, - y : event.screenY, - gx : event.screenX, - gy : event.screenY, - col : parseInt($(this).attr('name')) - }; - // find tds that will be resized - obj.last.tmp.tds = $('#grid_'+ obj.name +'_body table tr:first-child td[col='+ obj.last.tmp.col +']') - - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - if (event.preventDefault) event.preventDefault(); - // fix sizes - for (var c = 0; c < obj.columns.length; c++) { - if (obj.columns[c].hidden) continue; - if (obj.columns[c].sizeOriginal == null) obj.columns[c].sizeOriginal = obj.columns[c].size; - obj.columns[c].size = obj.columns[c].sizeCalculated; - } - var edata = { phase: 'before', type: 'columnResize', target: obj.name, column: obj.last.tmp.col, field: obj.columns[obj.last.tmp.col].field }; - edata = obj.trigger($.extend(edata, { resizeBy: 0, originalEvent: event })); - // set move event - var timer; - var mouseMove = function (event) { - if (obj.resizing != true) return; - if (!event) event = window.event; - // event before - edata = obj.trigger($.extend(edata, { resizeBy: (event.screenX - obj.last.tmp.gx), originalEvent: event })); - if (edata.isCancelled === true) { edata.isCancelled = false; return; } - // default action - obj.last.tmp.x = (event.screenX - obj.last.tmp.x); - obj.last.tmp.y = (event.screenY - obj.last.tmp.y); - var newWidth =(parseInt(obj.columns[obj.last.tmp.col].size) + obj.last.tmp.x) + 'px' - obj.columns[obj.last.tmp.col].size = newWidth; - if (timer) clearTimeout(timer) - timer = setTimeout(function () { - obj.resizeRecords() - obj.scroll() - }, 100) - // quick resize - obj.last.tmp.tds.css({ width: newWidth }) - // reset - obj.last.tmp.x = event.screenX; - obj.last.tmp.y = event.screenY; - }; - var mouseUp = function (event) { - delete obj.resizing; - $(document).off('.grid-col-resize'); - obj.resizeRecords(); - obj.scroll(); - // event after - obj.trigger($.extend(edata, { phase: 'after', originalEvent: event })); - }; - - $(document) - .off('.grid-col-resize') - .on('mousemove.grid-col-resize', mouseMove) - .on('mouseup.grid-col-resize', mouseUp); - }) - .on('dblclick.grid-col-resize', function(event) { - var colId = parseInt($(this).attr('name')), - col = obj.columns[colId], - maxDiff = 0; - - if (col.autoResize === false) { - return true; - } - - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - if (event.preventDefault) event.preventDefault(); - $('.w2ui-grid-records td[col="' + colId + '"] > div', obj.box).each(function() { - var thisDiff = this.offsetWidth - this.scrollWidth; - - if (thisDiff < maxDiff) { - maxDiff = thisDiff - 3; // 3px buffer needed for Firefox - } - }); - - // event before - var edata = { phase: 'before', type: 'columnAutoResize', target: obj.name, column: col, field: col.field }; - edata = obj.trigger($.extend(edata, { resizeBy: Math.abs(maxDiff), originalEvent: event })); - if (edata.isCancelled === true) { edata.isCancelled = false; return; } - - if (maxDiff < 0) { - col.size = Math.min(parseInt(col.size) + Math.abs(maxDiff), col.max || Infinity) + 'px'; - obj.resizeRecords(); - obj.resizeRecords(); // Why do we have to call it twice in order to show the scrollbar? - obj.scroll(); - } - - // event after - obj.trigger($.extend(edata, { phase: 'after', originalEvent: event })); - }) - .each(function (index, el) { - var td = $(el).parent(); - $(el).css({ - "height" : td.height(), - "margin-left" : (td.width() - 3) + 'px' - }); - }); - }, - - resizeBoxes: function () { - // elements - var header = $('#grid_'+ this.name +'_header'); - var toolbar = $('#grid_'+ this.name +'_toolbar'); - var fsummary = $('#grid_'+ this.name +'_fsummary'); - var summary = $('#grid_'+ this.name +'_summary'); - var footer = $('#grid_'+ this.name +'_footer'); - var body = $('#grid_'+ this.name +'_body'); - - if (this.show.header) { - header.css({ - top: '0px', - left: '0px', - right: '0px' - }); - } - - if (this.show.toolbar) { - toolbar.css({ - top: ( 0 + (this.show.header ? w2utils.getSize(header, 'height') : 0) ) + 'px', - left: '0px', - right: '0px' - }); - } - if (this.summary.length > 0) { - fsummary.css({ - bottom: ( 0 + (this.show.footer ? w2utils.getSize(footer, 'height') : 0) ) + 'px' - }); - summary.css({ - bottom: ( 0 + (this.show.footer ? w2utils.getSize(footer, 'height') : 0) ) + 'px', - right: '0px' - }); - } - if (this.show.footer) { - footer.css({ - bottom: '0px', - left: '0px', - right: '0px' - }); - } - body.css({ - top: ( 0 + (this.show.header ? w2utils.getSize(header, 'height') : 0) + (this.show.toolbar ? w2utils.getSize(toolbar, 'height') : 0) ) + 'px', - bottom: ( 0 + (this.show.footer ? w2utils.getSize(footer, 'height') : 0) + (this.summary.length > 0 ? w2utils.getSize(summary, 'height') : 0) ) + 'px', - left: '0px', - right: '0px' - }); - }, - - resizeRecords: function () { - var obj = this; - // remove empty records - $(this.box).find('.w2ui-empty-record').remove(); - // -- Calculate Column size in PX - var box = $(this.box); - var grid = $(this.box).find('> div.w2ui-grid-box'); - var header = $('#grid_'+ this.name +'_header'); - var toolbar = $('#grid_'+ this.name +'_toolbar'); - var summary = $('#grid_'+ this.name +'_summary'); - var fsummary = $('#grid_'+ this.name +'_fsummary'); - var footer = $('#grid_'+ this.name +'_footer'); - var body = $('#grid_'+ this.name +'_body'); - var columns = $('#grid_'+ this.name +'_columns'); - var fcolumns = $('#grid_'+ this.name +'_fcolumns'); - var records = $('#grid_'+ this.name +'_records'); - var frecords = $('#grid_'+ this.name +'_frecords'); - var scroll1 = $('#grid_'+ this.name +'_scroll1'); - var lineNumberWidth = String(this.total).length * 8 + 10; - if (lineNumberWidth < 34) lineNumberWidth = 34; // 3 digit width - if (this.lineNumberWidth != null) lineNumberWidth = this.lineNumberWidth; - - var bodyOverflowX = false; - var bodyOverflowY = false; - var sWidth = 0; - for (var i = 0; i < obj.columns.length; i++) { - if (obj.columns[i].frozen || obj.columns[i].hidden) continue; - var cSize = parseInt(obj.columns[i].sizeCalculated ? obj.columns[i].sizeCalculated : obj.columns[i].size); - sWidth += cSize; - } - if (records.width() < sWidth) bodyOverflowX = true; - if (body.height() - columns.height() < $(records).find('>table').height() + (bodyOverflowX ? w2utils.scrollBarSize() : 0)) bodyOverflowY = true; - - // body might be expanded by data - if (!this.fixedBody) { - // allow it to render records, then resize - var calculatedHeight = w2utils.getSize(columns, 'height') - + w2utils.getSize($('#grid_'+ obj.name +'_records table'), 'height') - + (bodyOverflowX ? w2utils.scrollBarSize() : 0); - obj.height = calculatedHeight - + w2utils.getSize(grid, '+height') - + (obj.show.header ? w2utils.getSize(header, 'height') : 0) - + (obj.show.toolbar ? w2utils.getSize(toolbar, 'height') : 0) - + (summary.css('display') != 'none' ? w2utils.getSize(summary, 'height') : 0) - + (obj.show.footer ? w2utils.getSize(footer, 'height') : 0); - grid.css('height', obj.height); - body.css('height', calculatedHeight); - box.css('height', w2utils.getSize(grid, 'height') + w2utils.getSize(box, '+height')); - } else { - // fixed body height - var calculatedHeight = grid.height() - - (this.show.header ? w2utils.getSize(header, 'height') : 0) - - (this.show.toolbar ? w2utils.getSize(toolbar, 'height') : 0) - - (summary.css('display') != 'none' ? w2utils.getSize(summary, 'height') : 0) - - (this.show.footer ? w2utils.getSize(footer, 'height') : 0); - body.css('height', calculatedHeight); - } - - var buffered = this.records.length; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (this.searchData.length != 0 && !url) buffered = this.last.searchIds.length; - // apply overflow - if (!this.fixedBody) { bodyOverflowY = false; } - if (bodyOverflowX || bodyOverflowY) { - columns.find('> table > tbody > tr:nth-child(1) td.w2ui-head-last').css('width', w2utils.scrollBarSize()).show(); - records.css({ - top: ((this.columnGroups.length > 0 && this.show.columns ? 1 : 0) + w2utils.getSize(columns, 'height')) +'px', - "-webkit-overflow-scrolling": "touch", - "overflow-x": (bodyOverflowX ? 'auto' : 'hidden'), - "overflow-y": (bodyOverflowY ? 'auto' : 'hidden') - }); - } else { - columns.find('> table > tbody > tr:nth-child(1) td.w2ui-head-last').hide(); - records.css({ - top: ((this.columnGroups.length > 0 && this.show.columns ? 1 : 0) + w2utils.getSize(columns, 'height')) +'px', - overflow: 'hidden' - }); - if (records.length > 0) { this.last.scrollTop = 0; this.last.scrollLeft = 0; } // if no scrollbars, always show top - } - if (bodyOverflowX) { - frecords.css('margin-bottom', w2utils.scrollBarSize()); - scroll1.show(); - } else { - frecords.css('margin-bottom', 0); - scroll1.hide(); - } - frecords.css({ overflow: 'hidden', top: records.css('top') }); - if (this.show.emptyRecords && !bodyOverflowY) { - var max = Math.floor(records.height() / this.recordHeight) - 1; - var leftover = 0; - if (records[0]) leftover = records[0].scrollHeight - max * this.recordHeight; - if (leftover >= this.recordHeight) { - leftover -= this.recordHeight; - max++; - } - if (this.fixedBody) { - for (var di = buffered; di < max; di++) { - addEmptyRow(di, this.recordHeight, this); - } - addEmptyRow(max, leftover, this); - } - } - - function addEmptyRow(row, height, grid) { - var html1 = ''; - var html2 = ''; - var htmlp = ''; - html1 += ''; - html2 += ''; - if (grid.show.lineNumbers) html1 += ''; - if (grid.show.selectColumn) html1 += ''; - if (grid.show.expandColumn) html1 += ''; - html2 += ''; - if (grid.show.orderColumn) html2 += ''; - for (var j = 0; j < grid.columns.length; j++) { - var col = grid.columns[j]; - if ((col.hidden || j < grid.last.colStart || j > grid.last.colEnd) && !col.frozen) continue; - htmlp = ''; - if (col.frozen) html1 += htmlp; else html2 += htmlp; - } - html1 += ' '; - html2 += ' '; - $('#grid_'+ grid.name +'_frecords > table').append(html1); - $('#grid_'+ grid.name +'_records > table').append(html2); - } - if (body.length > 0) { - var width_max = parseInt(body.width()) - - (bodyOverflowY ? w2utils.scrollBarSize() : 0) - - (this.show.lineNumbers ? lineNumberWidth : 0) - // - (this.show.orderColumn ? 26 : 0) - - (this.show.selectColumn ? 26 : 0) - - (this.show.expandColumn ? 26 : 0) - - 1; // left is 1xp due to border width - var width_box = width_max; - var percent = 0; - // gridMinWidth processing - var restart = false; - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.gridMinWidth > 0) { - if (col.gridMinWidth > width_box && col.hidden !== true) { - col.hidden = true; - restart = true; - } - if (col.gridMinWidth < width_box && col.hidden === true) { - col.hidden = false; - restart = true; - } - } - } - if (restart === true) { - this.refresh(); - return; - } - // assign PX column s - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.hidden) continue; - if (String(col.size).substr(String(col.size).length-2).toLowerCase() == 'px') { - width_max -= parseFloat(col.size); - this.columns[i].sizeCalculated = col.size; - this.columns[i].sizeType = 'px'; - } else { - percent += parseFloat(col.size); - this.columns[i].sizeType = '%'; - delete col.sizeCorrected; - } - } - // if sum != 100% -- reassign proportionally - if (percent != 100 && percent > 0) { - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.hidden) continue; - if (col.sizeType == '%') { - col.sizeCorrected = Math.round(parseFloat(col.size) * 100 * 100 / percent) / 100 + '%'; - } - } - } - // calculate % columns - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.hidden) continue; - if (col.sizeType == '%') { - if (this.columns[i].sizeCorrected != null) { - // make it 1px smaller, so margin of error can be calculated correctly - this.columns[i].sizeCalculated = Math.floor(width_max * parseFloat(col.sizeCorrected) / 100) - 1 + 'px'; - } else { - // make it 1px smaller, so margin of error can be calculated correctly - this.columns[i].sizeCalculated = Math.floor(width_max * parseFloat(col.size) / 100) - 1 + 'px'; - } - } - } - } - // fix margin of error that is due percentage calculations - var width_cols = 0; - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - if (col.hidden) continue; - if (col.min == null) col.min = 20; - if (parseInt(col.sizeCalculated) < parseInt(col.min)) col.sizeCalculated = col.min + 'px'; - if (parseInt(col.sizeCalculated) > parseInt(col.max)) col.sizeCalculated = col.max + 'px'; - width_cols += parseInt(col.sizeCalculated); - } - var width_diff = parseInt(width_box) - parseInt(width_cols); - if (width_diff > 0 && percent > 0) { - var i = 0; - while (true) { - var col = this.columns[i]; - if (col == null) { i = 0; continue; } - if (col.hidden || col.sizeType == 'px') { i++; continue; } - col.sizeCalculated = (parseInt(col.sizeCalculated) + 1) + 'px'; - width_diff--; - if (width_diff === 0) break; - i++; - } - } else if (width_diff > 0) { - columns.find('> table > tbody > tr:nth-child(1) td.w2ui-head-last').css('width', w2utils.scrollBarSize()).show(); - } - - // find width of frozen columns - var fwidth = 1; - if (this.show.lineNumbers) fwidth += lineNumberWidth; - if (this.show.selectColumn) fwidth += 26; - // if (this.show.orderColumn) fwidth += 26; - if (this.show.expandColumn) fwidth += 26; - for (var i = 0; i < this.columns.length; i++) { - if (this.columns[i].hidden) continue; - if (this.columns[i].frozen) fwidth += parseInt(this.columns[i].sizeCalculated); - } - fcolumns.css('width', fwidth); - frecords.css('width', fwidth); - fsummary.css('width', fwidth); - scroll1.css('width', fwidth); - columns.css('left', fwidth); - records.css('left', fwidth); - summary.css('left', fwidth); - - // resize columns - columns.find('> table > tbody > tr:nth-child(1) td') - .add(fcolumns.find('> table > tbody > tr:nth-child(1) td')) - .each(function (index, el) { - // line numbers - if ($(el).hasClass('w2ui-col-number')) { - $(el).css('width', lineNumberWidth); - } - // records - var ind = $(el).attr('col'); - if (ind != null) { - if (ind == 'start') { - var width = 0; - for (var i = 0; i < obj.last.colStart; i++) { - if (!obj.columns[i] || obj.columns[i].frozen || obj.columns[i].hidden) continue; - width += parseInt(obj.columns[i].sizeCalculated); - } - $(el).css('width', width + 'px'); - } - if (obj.columns[ind]) $(el).css('width', obj.columns[ind].sizeCalculated); - } - // last column - if ($(el).hasClass('w2ui-head-last')) { - if (obj.last.colEnd + 1 < obj.columns.length) { - var width = 0; - for (var i = obj.last.colEnd + 1; i < obj.columns.length; i++) { - if (!obj.columns[i] || obj.columns[i].frozen || obj.columns[i].hidden) continue; - width += parseInt(obj.columns[i].sizeCalculated); - } - $(el).css('width', width + 'px'); - } else { - $(el).css('width', w2utils.scrollBarSize() + (width_diff > 0 && percent === 0 ? width_diff : 0) + 'px'); - } - } - }); - // if there are column groups - hide first row (needed for sizing) - if (columns.find('> table > tbody > tr').length == 3) { - columns.find('> table > tbody > tr:nth-child(1) td') - .add(fcolumns.find('> table > tbody > tr:nth-child(1) td')) - .html('').css({ - 'height' : '0px', - 'border' : '0px', - 'padding': '0px', - 'margin' : '0px' - }); - } - // resize records - records.find('> table > tbody > tr:nth-child(1) td') - .add(frecords.find('> table > tbody > tr:nth-child(1) td')) - .each(function (index, el) { - // line numbers - if ($(el).hasClass('w2ui-col-number')) { - $(el).css('width', lineNumberWidth); - } - // records - var ind = $(el).attr('col'); - if (ind != null) { - if (ind == 'start') { - var width = 0; - for (var i = 0; i < obj.last.colStart; i++) { - if (!obj.columns[i] || obj.columns[i].frozen || obj.columns[i].hidden) continue; - width += parseInt(obj.columns[i].sizeCalculated); - } - $(el).css('width', width + 'px'); - } - if (obj.columns[ind]) $(el).css('width', obj.columns[ind].sizeCalculated); - } - // last column - if ($(el).hasClass('w2ui-grid-data-last') && $(el).parents('.w2ui-grid-frecords').length === 0) { // not in frecords - if (obj.last.colEnd + 1 < obj.columns.length) { - var width = 0; - for (var i = obj.last.colEnd + 1; i < obj.columns.length; i++) { - if (!obj.columns[i] || obj.columns[i].frozen || obj.columns[i].hidden) continue; - width += parseInt(obj.columns[i].sizeCalculated); - } - $(el).css('width', width + 'px'); - } else { - $(el).css('width', (width_diff > 0 && percent === 0 ? width_diff : 0) + 'px'); - } - } - }); - // resize summary - summary.find('> table > tbody > tr:nth-child(1) td') - .add(fsummary.find('> table > tbody > tr:nth-child(1) td')) - .each(function (index, el) { - // line numbers - if ($(el).hasClass('w2ui-col-number')) { - $(el).css('width', lineNumberWidth); - } - // records - var ind = $(el).attr('col'); - if (ind != null) { - if (ind == 'start') { - var width = 0; - for (var i = 0; i < obj.last.colStart; i++) { - if (!obj.columns[i] || obj.columns[i].frozen || obj.columns[i].hidden) continue; - width += parseInt(obj.columns[i].sizeCalculated); - } - $(el).css('width', width + 'px'); - } - if (obj.columns[ind]) $(el).css('width', obj.columns[ind].sizeCalculated); - } - // last column - if ($(el).hasClass('w2ui-grid-data-last') && $(el).parents('.w2ui-grid-frecords').length === 0) { // not in frecords - $(el).css('width', w2utils.scrollBarSize() + (width_diff > 0 && percent === 0 ? width_diff : 0) + 'px'); - } - }); - this.initResize(); - this.refreshRanges(); - // apply last scroll if any - if ((this.last.scrollTop || this.last.scrollLeft) && records.length > 0) { - columns.prop('scrollLeft', this.last.scrollLeft); - records.prop('scrollTop', this.last.scrollTop); - records.prop('scrollLeft', this.last.scrollLeft); - } - }, - - getSearchesHTML: function () { - var obj = this; - var html = ''; - var showBtn = false; - for (var i = 0; i < this.searches.length; i++) { - var s = this.searches[i]; - s.type = String(s.type).toLowerCase(); - if (s.hidden) continue; - var btn = ''; - if (showBtn == false) { - btn = ''; - showBtn = true; - } - if (s.inTag == null) s.inTag = ''; - if (s.outTag == null) s.outTag = ''; - if (s.style == null) s.style = ''; - if (s.type == null) s.type = 'text'; - if (s.label == null && s.caption != null) { - console.log('NOTICE: grid search.caption property is deprecated, please use search.label. Search ->', s) - s.label = s.caption; - } - var operator = - ''; - - html += ''+ - ' ' + - ' ' + - ' '+ - ' ' + - ''; - } - html += ''+ - ' '+ - '
'+ btn +''+ (s.label || '') +''+ operator +''; - - switch (s.type) { - case 'text': - case 'alphanumeric': - case 'hex': - case 'color': - case 'list': - case 'combo': - case 'enum': - var tmpStyle = 'width: 250px;'; - if (['hex', 'color'].indexOf(s.type) != -1) tmpStyle = 'width: 90px;'; - html += ''; - break; - - case 'int': - case 'float': - case 'money': - case 'currency': - case 'percent': - case 'date': - case 'time': - case 'datetime': - var tmpStyle = 'width: 90px;'; - if (s.type == 'datetime') tmpStyle = 'width: 140px;'; - html += ''+ - ''; - break; - - case 'select': - html += ''; - break; - - } - html += s.outTag + - '
'+ - '
'+ - ' '+ - ' '+ - '
'+ - '
'; - return html; - - function getOperators(type, fieldOperators) { - var html = ''; - var operators = obj.operators[obj.operatorsMap[type]]; - if (fieldOperators != null) operators = fieldOperators; - for (var i = 0; i < operators.length; i++) { - var oper = operators[i]; - var text = oper; - if (Array.isArray(oper)) { - text = oper[1]; - oper = oper[0]; - if (text == null) text = oper; - } else if ($.isPlainObject(oper)) { - text = oper.text; - oper = oper.oper; - } - html += '\n'; - } - return html; - } - }, - - initOperator: function (el, search_ind) { - var obj = this; - var search = obj.searches[search_ind]; - var range = $('#grid_'+ obj.name + '_range_'+ search_ind); - var fld1 = $('#grid_'+ obj.name +'_field_'+ search_ind); - var fld2 = fld1.parent().find('span input'); - fld1.show(); - range.hide(); - switch ($(el).val()) { - case 'between': - range.show(); - fld2.w2field(search.type, search.options); - break; - case 'not null': - case 'null': - fld1.hide(); - fld1.val('1'); // need to insert something for search to activate - fld1.change(); - break; - } - }, - - initSearches: function () { - var obj = this; - // init searches - for (var s = 0; s < this.searches.length; s++) { - var search = this.searches[s]; - var sdata = this.getSearchData(search.field); - search.type = String(search.type).toLowerCase(); - var operators = obj.operators[obj.operatorsMap[search.type]]; - if (search.operators) operators = search.operators; - var operator = operators[0]; // default operator - if ($.isPlainObject(operator)) operator = operator.oper; - if (typeof search.options != 'object') search.options = {}; - if (search.type == 'text') operator = this.textSearch; - // only accept search.operator if it is valid - for (var i = 0; i < operators.length; i++) { - var oper = operators[i]; - if ($.isPlainObject(oper)) oper = oper.oper; - if (search.operator == oper) { - operator = search.operator; - break; - } - } - // init types - switch (search.type) { - case 'text': - case 'alphanumeric': - $('#grid_'+ this.name +'_field_' + s).w2field(search.type, search.options); - break; - - case 'int': - case 'float': - case 'hex': - case 'color': - case 'money': - case 'currency': - case 'percent': - case 'date': - case 'time': - case 'datetime': - $('#grid_'+ this.name +'_field_'+s).w2field(search.type, search.options); - $('#grid_'+ this.name +'_field2_'+s).w2field(search.type, search.options); - setTimeout(function () { // convert to date if it is number - $('#grid_'+ obj.name +'_field_'+s).keydown(); - $('#grid_'+ obj.name +'_field2_'+s).keydown(); - }, 1); - break; - - case 'list': - case 'combo': - case 'enum': - var options = search.options; - if (search.type == 'list') options.selected = {}; - if (search.type == 'enum') options.selected = []; - if (sdata) options.selected = sdata.value; - $('#grid_'+ this.name +'_field_'+s).w2field(search.type, $.extend({ openOnFocus: true }, options)); - if (sdata && sdata.text != null) $('#grid_'+ this.name +'_field_'+s).data('selected', {id: sdata.value, text: sdata.text}); - break; - - case 'select': - // build options - var options = ''; - for (var i = 0; i < search.options.items.length; i++) { - var si = search.options.items[i]; - if ($.isPlainObject(search.options.items[i])) { - var val = si.id; - var txt = si.text; - if (val == null && si.value != null) val = si.value; - if (txt == null && si.text != null) txt = si.text; - if (val == null) val = ''; - options += ''; - } else { - options += ''; - } - } - $('#grid_'+ this.name +'_field_'+s).html(options); - break; - } - if (sdata != null) { - if (sdata.type == 'int' && ['in', 'not in'].indexOf(sdata.operator) != -1) { - $('#grid_'+ this.name +'_field_'+ s).w2field('clear').val(sdata.value); - } - $('#grid_'+ this.name +'_operator_'+ s).val(sdata.operator).trigger('change'); - if (!$.isArray(sdata.value)) { - if (sdata.value != null) $('#grid_'+ this.name +'_field_'+ s).val(sdata.value).trigger('change'); - } else { - if (['in', 'not in'].indexOf(sdata.operator) != -1) { - $('#grid_'+ this.name +'_field_'+ s).val(sdata.value).trigger('change'); - } else { - $('#grid_'+ this.name +'_field_'+ s).val(sdata.value[0]).trigger('change'); - $('#grid_'+ this.name +'_field2_'+ s).val(sdata.value[1]).trigger('change'); - } - } - } else { - $('#grid_'+ this.name +'_operator_'+s).val(operator).trigger('change'); - } - } - // add on change event - $('#w2ui-overlay-'+ this.name +'-searchOverlay .w2ui-grid-searches *[rel=search]').on('keypress', function (evnt) { - if (evnt.keyCode == 13) { - obj.search(); - $().w2overlay({ name: obj.name + '-searchOverlay' }); - } - }); - }, - - getColumnsHTML: function () { - var obj = this; - var html1 = ''; - var html2 = ''; - if (this.show.columnHeaders) { - if (this.columnGroups.length > 0) { - var tmp1 = getColumns(true); - var tmp2 = getGroups(); - var tmp3 = getColumns(false); - html1 = tmp1[0] + tmp2[0] + tmp3[0]; - html2 = tmp1[1] + tmp2[1] + tmp3[1]; - } else { - var tmp = getColumns(true); - html1 = tmp[0]; - html2 = tmp[1]; - } - } - return [html1, html2]; - - function getGroups () { - var html1 = ''; - var html2 = ''; - var tmpf = ''; - // add empty group at the end - var tmp = obj.columnGroups.length - 1; - if (obj.columnGroups[tmp].text == null && obj.columnGroups[tmp].caption != null) { - console.log('NOTICE: grid columnGroup.caption property is deprecated, please use columnGroup.text. Group -> ', obj.columnGroups[tmp]); - obj.columnGroups[tmp].text = obj.columnGroups[tmp].caption; - } - if (obj.columnGroups[obj.columnGroups.length-1].text != '') obj.columnGroups.push({ text: '' }); - - if (obj.show.lineNumbers) { - html1 += ''+ - '
 
'+ - ''; - } - if (obj.show.selectColumn) { - html1 += ''+ - '
 
'+ - ''; - } - if (obj.show.expandColumn) { - html1 += ''+ - '
 
'+ - ''; - } - var ii = 0; - html2 += ''; - if (obj.show.orderColumn) { - html2 += ''+ - '
 
'+ - ''; - } - for (var i=0; i', col); - col.text = col.caption; - } - var colspan = 0; - for (var jj = ii; jj < ii + colg.span; jj++) { - if (obj.columns[jj] && !obj.columns[jj].hidden) { - colspan++; - } - } - if (i == obj.columnGroups.length-1) { - colspan = 100; // last column - } - if (colspan <= 0) { - // do nothing here, all columns in the group are hidden. - } else if (colg.master === true) { - var sortStyle = ''; - for (var si = 0; si < obj.sortData.length; si++) { - if (obj.sortData[si].field == col.field) { - if ((obj.sortData[si].direction || '').toLowerCase() === 'asc') sortStyle = 'w2ui-sort-up'; - if ((obj.sortData[si].direction || '').toLowerCase() === 'desc') sortStyle = 'w2ui-sort-down'; - } - } - var resizer = ""; - if (col.resizable !== false) { - resizer = '
'; - } - var text = (typeof col.text == 'function' ? col.text(col) : col.text); - tmpf = ''+ - resizer + - '
'+ - '
'+ - (!text ? ' ' : text) + - '
'+ - ''; - if (col && col.frozen) html1 += tmpf; else html2 += tmpf; - } else { - var gText = (typeof colg.text == 'function' ? colg.text(colg) : colg.text); - tmpf = ''+ - '
'+ - (!gText ? ' ' : gText) + - '
'+ - ''; - if (col && col.frozen) html1 += tmpf; else html2 += tmpf; - } - ii += colg.span; - } - html1 += ''; // need empty column for border-right - html2 += ''; - return [html1, html2]; - } - - function getColumns (master) { - var html1 = ''; - var html2 = ''; - if (obj.show.lineNumbers) { - html1 += ''+ - '
#
'+ - ''; - } - if (obj.show.selectColumn) { - html1 += ''+ - '
'+ - ' '+ - '
'+ - ''; - } - if (obj.show.expandColumn) { - html1 += ''+ - '
 
'+ - ''; - } - var ii = 0; - var id = 0; - var colg; - html2 += ''; - if (obj.show.orderColumn) { - html2 += ''+ - '
 
'+ - ''; - } - for (var i = 0; i < obj.columns.length; i++) { - var col = obj.columns[i]; - if (col.text == null && col.caption != null) { - console.log('NOTICE: grid column.caption property is deprecated, please use column.text. Column -> ', col); - col.text = col.caption; - } - if (col.size == null) col.size = '100%'; - if (i == id) { // always true on first iteration - colg = obj.columnGroups[ii++] || {}; - id = id + colg.span; - } - if ((i < obj.last.colStart || i > obj.last.colEnd) && !col.frozen) - continue; - if (col.hidden) - continue; - if (colg.master !== true || master) { // grouping of columns - var colCellHTML = obj.getColumnCellHTML(i); - if (col && col.frozen) html1 += colCellHTML; else html2 += colCellHTML; - } - } - html1 += '
 
'; - html2 += '
 
'; - html1 += ''; - html2 += ''; - return [html1, html2]; - } - }, - - getColumnCellHTML: function (i) { - var col = this.columns[i]; - if (col == null) return ''; - // reorder style - var reorderCols = (this.reorderColumns && (!this.columnGroups || !this.columnGroups.length)) ? ' w2ui-reorder-cols-head ' : ''; - // sort style - var sortStyle = ''; - for (var si = 0; si < this.sortData.length; si++) { - if (this.sortData[si].field == col.field) { - if ((this.sortData[si].direction || '').toLowerCase() === 'asc') sortStyle = 'w2ui-sort-up'; - if ((this.sortData[si].direction || '').toLowerCase() === 'desc') sortStyle = 'w2ui-sort-down'; - } - } - // col selected - var tmp = this.last.selection.columns; - var selected = false; - for (var t in tmp) { - for (var si = 0; si < tmp[t].length; si++) { - if (tmp[t][si] == i) selected = true; - } - } - var text = (typeof col.text == 'function' ? col.text(col) : col.text); - var html = ''+ - (col.resizable !== false ? '
' : '') + - '
'+ - '
'+ - (!text ? ' ' : text) + - '
'+ - ''; - - return html - }, - - columnTooltipShow: function (ind) { - if (this.columnTooltip == 'normal') return; - var $el = $(this.box).find('#grid_'+ this.name + '_column_'+ ind); - var item = this.columns[ind]; - var pos = this.columnTooltip; - $el.prop('_mouse_over', true); - setTimeout(function () { - if ($el.prop('_mouse_over') === true && $el.prop('_mouse_tooltip') !== true) { - $el.prop('_mouse_tooltip', true); - // show tooltip - $el.w2tag(item.tooltip, { position: pos, top: 5 }); - } - }, 1); - }, - - columnTooltipHide: function (ind) { - if (this.columnTooltip == 'normal') return; - var $el = $(this.box).find('#grid_'+ this.name + '_column_'+ ind); - var item = this.columns[ind]; - $el.removeProp('_mouse_over'); - setTimeout(function () { - if ($el.prop('_mouse_over') !== true && $el.prop('_mouse_tooltip') === true) { - $el.removeProp('_mouse_tooltip'); - // hide tooltip - $el.w2tag(); - } - }, 1); - }, - - getRecordsHTML: function () { - var buffered = this.records.length; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (this.searchData.length != 0 && !url) buffered = this.last.searchIds.length; - // larger number works better with chrome, smaller with FF. - if (buffered > this.vs_start) this.last.show_extra = this.vs_extra; else this.last.show_extra = this.vs_start; - var records = $('#grid_'+ this.name +'_records'); - var limit = Math.floor((records.height() || 0) / this.recordHeight) + this.last.show_extra + 1; - if (!this.fixedBody || limit > buffered) limit = buffered; - // always need first record for resizing purposes - var rec_html = this.getRecordHTML(-1, 0); - var html1 = '' + rec_html[0]; - var html2 = '
' + rec_html[1]; - // first empty row with height - html1 += ''+ - ' '+ - ''; - html2 += ''+ - ' '+ - ''; - for (var i = 0; i < limit; i++) { - rec_html = this.getRecordHTML(i, i+1); - html1 += rec_html[0]; - html2 += rec_html[1]; - } - var h2 = (buffered - limit) * this.recordHeight; - html1 += '' + - ' '+ - ''+ - ''+ - ' '+ - ''+ - '
'; - html2 += '' + - ' '+ - ''+ - ''+ - ' '+ - ''+ - ''; - this.last.range_start = 0; - this.last.range_end = limit; - return [html1, html2]; - }, - - getSummaryHTML: function () { - if (this.summary.length === 0) return; - var rec_html = this.getRecordHTML(-1, 0); // need this in summary too for colspan to work properly - var html1 = '' + rec_html[0]; - var html2 = '
' + rec_html[1]; - for (var i = 0; i < this.summary.length; i++) { - rec_html = this.getRecordHTML(i, i+1, true); - html1 += rec_html[0]; - html2 += rec_html[1]; - } - html1 += '
'; - html2 += ''; - return [html1, html2]; - }, - - scroll: function (event) { - var time = (new Date()).getTime(); - var obj = this; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - var records = $('#grid_'+ this.name +'_records'); - var frecords = $('#grid_'+ this.name +'_frecords'); - // sync scroll positions - if (event) { - var sTop = event.target.scrollTop; - var sLeft = event.target.scrollLeft; - obj.last.scrollTop = sTop; - obj.last.scrollLeft = sLeft; - $('#grid_'+ obj.name +'_columns')[0].scrollLeft = sLeft; - $('#grid_'+ obj.name +'_summary')[0].scrollLeft = sLeft; - frecords[0].scrollTop = sTop; - } - // hide bubble - if (this.last.bubbleEl) { - $(this.last.bubbleEl).w2tag(); - this.last.bubbleEl = null; - } - // column virtual scroll - var colStart = null; - var colEnd = null; - if (obj.disableCVS || obj.columnGroups.length > 0) { - // disable virtual scroll - colStart = 0; - colEnd = obj.columns.length - 1; - } else { - var sWidth = records.width(); - var cLeft = 0; - for (var i = 0; i < obj.columns.length; i++) { - if (obj.columns[i].frozen || obj.columns[i].hidden) continue; - var cSize = parseInt(obj.columns[i].sizeCalculated ? obj.columns[i].sizeCalculated : obj.columns[i].size); - if (cLeft + cSize + 30 > obj.last.scrollLeft && colStart == null) colStart = i; - if (cLeft + cSize - 30 > obj.last.scrollLeft + sWidth && colEnd == null) colEnd = i; - cLeft += cSize; - } - if (colEnd == null) colEnd = obj.columns.length - 1; - } - if (colStart != null) { - if (colStart < 0) colStart = 0; - if (colEnd < 0) colEnd = 0; - if (colStart == colEnd) { - if (colStart > 0) colStart--; else colEnd++; // show at least one column - } - // --------- - if (colStart != obj.last.colStart || colEnd != obj.last.colEnd) { - var $box = $(obj.box); - var deltaStart = Math.abs(colStart - obj.last.colStart); - var deltaEnd = Math.abs(colEnd - obj.last.colEnd) - // add/remove columns for small jumps - if (deltaStart < 5 && deltaEnd < 5) { - var $cfirst = $box.find('.w2ui-grid-columns #grid_'+ obj.name +'_column_start'); - var $clast = $box.find('.w2ui-grid-columns .w2ui-head-last'); - var $rfirst = $box.find('#grid_'+ obj.name +'_records .w2ui-grid-data-spacer'); - var $rlast = $box.find('#grid_'+ obj.name +'_records .w2ui-grid-data-last'); - var $sfirst = $box.find('#grid_'+ obj.name +'_summary .w2ui-grid-data-spacer'); - var $slast = $box.find('#grid_'+ obj.name +'_summary .w2ui-grid-data-last'); - // remove on left - if (colStart > obj.last.colStart) { - for (var i = obj.last.colStart; i < colStart; i++) { - $box.find('#grid_'+ obj.name +'_columns #grid_'+ obj.name +'_column_'+ i).remove(); // column - $box.find('#grid_'+ obj.name +'_records td[col="'+ i +'"]').remove(); // record - $box.find('#grid_'+ obj.name +'_summary td[col="'+ i +'"]').remove(); // summary - } - } - // remove on right - if (colEnd < obj.last.colEnd) { - for (var i = obj.last.colEnd; i > colEnd; i--) { - $box.find('#grid_'+ obj.name +'_columns #grid_'+ obj.name +'_column_'+ i).remove(); // column - $box.find('#grid_'+ obj.name +'_records td[col="'+ i +'"]').remove(); // record - $box.find('#grid_'+ obj.name +'_summary td[col="'+ i +'"]').remove(); // summary - } - } - // add on left - if (colStart < obj.last.colStart) { - for (var i = obj.last.colStart - 1; i >= colStart; i--) { - if (obj.columns[i] && (obj.columns[i].frozen || obj.columns[i].hidden)) continue; - $cfirst.after(obj.getColumnCellHTML(i)); // column - // record - $rfirst.each(function (ind, el) { - var index = $(el).parent().attr('index'); - var td = ''; // width column - if (index != null) td = obj.getCellHTML(parseInt(index), i, false); - $(el).after(td); - }); - // summary - $sfirst.each(function (ind, el) { - var index = $(el).parent().attr('index'); - var td = ''; // width column - if (index != null) td = obj.getCellHTML(parseInt(index), i, true); - $(el).after(td); - }); - } - } - // add on right - if (colEnd > obj.last.colEnd) { - for (var i = obj.last.colEnd + 1; i <= colEnd; i++) { - if (obj.columns[i] && (obj.columns[i].frozen || obj.columns[i].hidden)) continue; - $clast.before(obj.getColumnCellHTML(i)); // column - // record - $rlast.each(function (ind, el) { - var index = $(el).parent().attr('index'); - var td = ''; // width column - if (index != null) td = obj.getCellHTML(parseInt(index), i, false); - $(el).before(td); - }); - // summary - $slast.each(function (ind, el) { - var index = $(el).parent().attr('index') || -1; - var td = obj.getCellHTML(parseInt(index), i, true); - $(el).before(td); - }); - } - } - obj.last.colStart = colStart; - obj.last.colEnd = colEnd; - obj.resizeRecords(); - } else { - obj.last.colStart = colStart; - obj.last.colEnd = colEnd; - // dot not just call obj.refresh(); - var colHTML = this.getColumnsHTML(); - var recHTML = this.getRecordsHTML(); - var sumHTML = this.getSummaryHTML(); - var $columns = $box.find('#grid_'+ this.name +'_columns'); - var $records = $box.find('#grid_'+ this.name +'_records'); - var $frecords = $box.find('#grid_'+ this.name +'_frecords'); - var $summary = $box.find('#grid_'+ this.name +'_summary'); - $columns.find('tbody').html(colHTML[1]); - $frecords.html(recHTML[0]); - $records.prepend(recHTML[1]); - if (sumHTML != null) $summary.html(sumHTML[1]); - // need timeout to clean up (otherwise scroll problem) - setTimeout(function () { - $records.find('> table').not('table:first-child').remove(); - if ($summary[0]) $summary[0].scrollLeft = obj.last.scrollLeft; - }, 1); - obj.resizeRecords(); - } - } - } - // perform virtual scroll - var buffered = this.records.length; - if (buffered > this.total) buffered = this.total; - if (this.searchData.length != 0 && !url) buffered = this.last.searchIds.length; - if (buffered === 0 || records.length === 0 || records.height() === 0) return; - if (buffered > this.vs_start) this.last.show_extra = this.vs_extra; else this.last.show_extra = this.vs_start; - // update footer - var t1 = Math.round(records[0].scrollTop / this.recordHeight + 1); - var t2 = t1 + (Math.round(records.height() / this.recordHeight) - 1); - if (t1 > buffered) t1 = buffered; - if (t2 >= buffered - 1) t2 = buffered; - $('#grid_'+ this.name + '_footer .w2ui-footer-right').html( - (obj.show.statusRange ? w2utils.formatNumber(this.offset + t1) + '-' + w2utils.formatNumber(this.offset + t2) + - (this.total != -1 ? ' ' + w2utils.lang('of') + ' ' + w2utils.formatNumber(this.total) : '') : '') + - (url && obj.show.statusBuffered ? ' ('+ w2utils.lang('buffered') + ' '+ w2utils.formatNumber(buffered) + - (this.offset > 0 ? ', skip ' + w2utils.formatNumber(this.offset) : '') + ')' : '') - ); - // only for local data source, else no extra records loaded - if (!url && (!this.fixedBody || (this.total != -1 && this.total <= this.vs_start))) return; - // regular processing - var start = Math.floor(records[0].scrollTop / this.recordHeight) - this.last.show_extra; - var end = start + Math.floor(records.height() / this.recordHeight) + this.last.show_extra * 2 + 1; - // var div = start - this.last.range_start; - if (start < 1) start = 1; - if (end > this.total && this.total != -1) end = this.total; - var tr1 = records.find('#grid_'+ this.name +'_rec_top'); - var tr2 = records.find('#grid_'+ this.name +'_rec_bottom'); - var tr1f = frecords.find('#grid_'+ this.name +'_frec_top'); - var tr2f = frecords.find('#grid_'+ this.name +'_frec_bottom'); - // if row is expanded - if (String(tr1.next().prop('id')).indexOf('_expanded_row') != -1) { - tr1.next().remove(); - tr1f.next().remove(); - } - if (this.total > end && String(tr2.prev().prop('id')).indexOf('_expanded_row') != -1) { - tr2.prev().remove(); - tr2f.prev().remove(); - } - var first = parseInt(tr1.next().attr('line')); - var last = parseInt(tr2.prev().attr('line')); - //$('#log').html('buffer: '+ this.buffered +' start-end: ' + start + '-'+ end + ' ===> first-last: ' + first + '-' + last); - if (first < start || first == 1 || this.last.pull_refresh) { // scroll down - if (end <= last + this.last.show_extra - 2 && end != this.total) return; - this.last.pull_refresh = false; - // remove from top - while (true) { - var tmp1 = frecords.find('#grid_'+ this.name +'_frec_top').next(); - var tmp2 = records.find('#grid_'+ this.name +'_rec_top').next(); - if (tmp2.attr('line') == 'bottom') break; - if (parseInt(tmp2.attr('line')) < start) { tmp1.remove(); tmp2.remove(); } else break; - } - // add at bottom - var tmp = records.find('#grid_'+ this.name +'_rec_bottom').prev(); - var rec_start = tmp.attr('line'); - if (rec_start == 'top') rec_start = start; - for (var i = parseInt(rec_start) + 1; i <= end; i++) { - if (!this.records[i-1]) continue; - var tmp2 = this.records[i-1].w2ui; - if (tmp2 && !Array.isArray(tmp2.children)) { - tmp2.expanded = false; - } - var rec_html = this.getRecordHTML(i-1, i); - tr2.before(rec_html[1]); - tr2f.before(rec_html[0]); - } - markSearch(); - setTimeout(function() { obj.refreshRanges(); }, 0); - } else { // scroll up - if (start >= first - this.last.show_extra + 2 && start > 1) return; - // remove from bottom - while (true) { - var tmp1 = frecords.find('#grid_'+ this.name +'_frec_bottom').prev(); - var tmp2 = records.find('#grid_'+ this.name +'_rec_bottom').prev(); - if (tmp2.attr('line') == 'top') break; - if (parseInt(tmp2.attr('line')) > end) { tmp1.remove(); tmp2.remove(); } else break; - } - // add at top - var tmp = records.find('#grid_'+ this.name +'_rec_top').next(); - var rec_start = tmp.attr('line'); - if (rec_start == 'bottom') rec_start = end; - for (var i = parseInt(rec_start) - 1; i >= start; i--) { - if (!this.records[i-1]) continue; - var tmp2 = this.records[i-1].w2ui; - if (tmp2 && !Array.isArray(tmp2.children)) { - tmp2.expanded = false; - } - var rec_html = this.getRecordHTML(i-1, i); - tr1.after(rec_html[1]); - tr1f.after(rec_html[0]); - } - markSearch(); - setTimeout(function() { obj.refreshRanges(); }, 0); - } - // first/last row size - var h1 = (start - 1) * obj.recordHeight; - var h2 = (buffered - end) * this.recordHeight; - if (h2 < 0) h2 = 0; - tr1.css('height', h1 + 'px'); - tr1f.css('height', h1 + 'px'); - tr2.css('height', h2 + 'px'); - tr2f.css('height', h2 + 'px'); - obj.last.range_start = start; - obj.last.range_end = end; - // load more if needed - var s = Math.floor(records[0].scrollTop / this.recordHeight); - var e = s + Math.floor(records.height() / this.recordHeight); - if (e + 10 > buffered && this.last.pull_more !== true && (buffered < this.total - this.offset || (this.total == -1 && this.last.xhr_hasMore))) { - if (this.autoLoad === true) { - this.last.pull_more = true; - this.last.xhr_offset += this.limit; - this.request('get'); - } - // scroll function - var more = $('#grid_'+ this.name +'_rec_more, #grid_'+ this.name +'_frec_more'); - more.show() - .eq(1) // only main table - .off('.load-more') - .on('click.load-more', function () { - // show spinner - $(this).find('td').html('
'); - // load more - obj.last.pull_more = true; - obj.last.xhr_offset += obj.limit; - obj.request('get'); - }) - .find('td') - .html(obj.autoLoad - ? '
' - : '
'+ w2utils.lang('Load') + ' ' + obj.limit + ' ' + w2utils.lang('More') + '...
' - ) - } - - function markSearch() { - // mark search - if (!obj.markSearch) return; - clearTimeout(obj.last.marker_timer); - obj.last.marker_timer = setTimeout(function () { - // mark all search strings - var search = []; - for (var s = 0; s < obj.searchData.length; s++) { - var sdata = obj.searchData[s]; - var fld = obj.getSearch(sdata.field); - if (!fld || fld.hidden) continue; - var ind = obj.getColumn(sdata.field, true); - search.push({ field: sdata.field, search: sdata.value, col: ind }); - } - if (search.length > 0) { - search.forEach(function (item) { - $(obj.box).find('td[col="'+ item.col +'"]').not('.w2ui-head').w2marker(item.search); - }); - } - }, 50); - } - }, - - getRecordHTML: function (ind, lineNum, summary) { - var tmph = ''; - var rec_html1 = ''; - var rec_html2 = ''; - var sel = this.last.selection; - var record; - // first record needs for resize purposes - if (ind == -1) { - rec_html1 += ''; - rec_html2 += ''; - if (this.show.lineNumbers) rec_html1 += ''; - if (this.show.selectColumn) rec_html1 += ''; - if (this.show.expandColumn) rec_html1 += ''; - rec_html2 += ''; - if (this.show.orderColumn) rec_html2 += ''; - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - tmph = ''; - if (col.frozen && !col.hidden) { - rec_html1 += tmph; - } else { - if (col.hidden || i < this.last.colStart || i > this.last.colEnd) continue; - rec_html2 += tmph; - } - } - rec_html1 += ''; - rec_html2 += ''; - rec_html1 += ''; - rec_html2 += ''; - return [rec_html1, rec_html2]; - } - // regular record - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (summary !== true) { - if (this.searchData.length > 0 && !url) { - if (ind >= this.last.searchIds.length) return ''; - ind = this.last.searchIds[ind]; - record = this.records[ind]; - } else { - if (ind >= this.records.length) return ''; - record = this.records[ind]; - } - } else { - if (ind >= this.summary.length) return ''; - record = this.summary[ind]; - } - if (!record) return ''; - if (record.recid == null && this.recid != null) { - var rid = this.parseField(record, this.recid) - if (rid != null) record.recid = rid; - } - var id = w2utils.escapeId(record.recid); - var isRowSelected = false; - if (sel.indexes.indexOf(ind) != -1) isRowSelected = true; - var rec_style = (record.w2ui ? record.w2ui.style : ''); - if (rec_style == null || typeof rec_style != 'string') rec_style = ''; - var rec_class = (record.w2ui ? record.w2ui.class : ''); - if (rec_class == null || typeof rec_class != 'string') rec_class = ''; - // render TR - rec_html1 += ''; - rec_html2 += ''; - if (this.show.lineNumbers) { - rec_html1 += ''+ - (summary !== true ? this.getLineHTML(lineNum, record) : '') + - ''; - } - if (this.show.selectColumn) { - var hideCB = false; - if (record && record.w2ui && record.w2ui.hideCheckBox === true) hideCB = true; - rec_html1 += - ''+ - (summary !== true && !(record.w2ui && record.w2ui.hideCheckBox === true) ? - '
'+ - ' '+ - '
' - : - '' ) + - ''; - } - if (this.show.expandColumn) { - var tmp_img = ''; - if (record.w2ui && record.w2ui.expanded === true) tmp_img = '-'; else tmp_img = '+'; - if (record.w2ui && record.w2ui.expanded == 'none') tmp_img = ''; - if (record.w2ui && record.w2ui.expanded == 'spinner') tmp_img = '
'; - rec_html1 += - ''+ - (summary !== true ? - '
'+ - ' '+ tmp_img +'
' - : - '' ) + - ''; - } - // insert empty first column - rec_html2 += ''; - if (this.show.orderColumn) { - rec_html2 += - ''+ - (summary !== true ? '
 
' : '' ) + - ''; - } - var col_ind = 0; - var col_skip = 0; - while (true) { - var col_span = 1; - var col = this.columns[col_ind]; - if (col == null) break; - if (col.hidden) { - col_ind++; - if (col_skip > 0) col_skip--; - continue; - } - if (col_skip > 0) { - col_ind++; - if (this.columns[col_ind] == null) break; - record.w2ui.colspan[this.columns[col_ind-1].field] = 0; // need it for other methods - col_skip--; - continue; - } else if (record.w2ui) { - var tmp1 = record.w2ui.colspan; - var tmp2 = this.columns[col_ind].field; - if (tmp1 && tmp1[tmp2] === 0) { - delete tmp1[tmp2]; // if no longer colspan then remove 0 - } - } - // column virtual scroll - if ((col_ind < this.last.colStart || col_ind > this.last.colEnd) && !col.frozen) { - col_ind++; - continue; - } - if (record.w2ui) { - if (typeof record.w2ui.colspan == 'object') { - var span = parseInt(record.w2ui.colspan[col.field]) || null; - if (span > 1) { - // if there are hidden columns, then no colspan on them - var hcnt = 0; - for (var i = col_ind; i < col_ind + span; i++) { - if (i >= this.columns.length) break; - if (this.columns[i].hidden) hcnt++; - } - col_span = span - hcnt; - col_skip = span - 1; - } - } - } - var rec_cell = this.getCellHTML(ind, col_ind, summary, col_span); - if (col.frozen) rec_html1 += rec_cell; else rec_html2 += rec_cell; - col_ind++; - } - rec_html1 += ''; - rec_html2 += ''; - rec_html1 += ''; - rec_html2 += ''; - return [rec_html1, rec_html2]; - }, - - getLineHTML: function(lineNum) { - return '
' + lineNum + '
'; - }, - - getCellHTML: function (ind, col_ind, summary, col_span) { - var obj = this; - var col = this.columns[col_ind]; - if (col == null) return ''; - var record = (summary !== true ? this.records[ind] : this.summary[ind]); - var data = (ind !== -1 ? this.getCellValue(ind, col_ind, summary) : ''); - var edit = (ind !== -1 ? this.getCellEditable(ind, col_ind) : ''); - var style = 'max-height: '+ parseInt(this.recordHeight) +'px;' + (col.clipboardCopy ? 'margin-right: 20px' : ''); - var isChanged = !summary && record && record.w2ui && record.w2ui.changes && record.w2ui.changes[col.field] != null; - var addStyle = ''; - var addClass = ''; - var sel = this.last.selection; - var isRowSelected = false; - var infoBubble = ''; - if (sel.indexes.indexOf(ind) != -1) isRowSelected = true; - if (col_span == null) { - if (record && record.w2ui && record.w2ui.colspan && record.w2ui.colspan[col.field]) { - col_span = record.w2ui.colspan[col.field]; - } else { - col_span = 1; - } - } - // expand icon - if (col_ind === 0 && record && record.w2ui && Array.isArray(record.w2ui.children)) { - var level = 0; - var subrec = this.get(record.w2ui.parent_recid, true); - while (true) { - if (subrec != null) { - level++ - var tmp = this.records[subrec].w2ui; - if (tmp != null && tmp.parent_recid != null) { - subrec = this.get(tmp.parent_recid, true); - } else { - break; - } - } else { - break; - } - } - if (record.w2ui.parent_recid){ - for (var i = 0; i < level; i++) { - infoBubble += ''; - } - } - infoBubble += ''; - } - // info bubble - if (col.info === true) col.info = {}; - if (col.info != null) { - var infoIcon = 'w2ui-icon-info'; - if (typeof col.info.icon == 'function') { - infoIcon = col.info.icon(record); - } else if (typeof col.info.icon == 'object') { - infoIcon = col.info.icon[this.parseField(record, col.field)] || '' - } else if (typeof col.info.icon == 'string') { - infoIcon = col.info.icon; - } - var infoStyle = col.info.style || ''; - if (typeof col.info.style == 'function') { - infoStyle = col.info.style(record); - } else if (typeof col.info.style == 'object') { - infoStyle = col.info.style[this.parseField(record, col.field)] || ''; - } else if (typeof col.info.style == 'string') { - infoStyle = col.info.style; - } - infoBubble += ''; - } - if (col.render != null && ind !== -1) { - if (typeof col.render == 'function') { - var html = col.render.call(this, record, ind, col_ind, data); - if (html != null && typeof html == 'object') { - data = $.trim(html.html || ''); - addClass = html.class || ''; - addStyle = html.style || ''; - } else { - data = $.trim(html); - } - if (data.length < 4 || data.substr(0, 4).toLowerCase() != '' + infoBubble + String(data) + ''; - } - } - // if it is an object - if (typeof col.render == 'object') { - var dsp = col.render[data]; - if (dsp == null || dsp === '') dsp = data; - data = '
' + infoBubble + String(dsp) + '
'; - } - // formatters - if (typeof col.render == 'string') { - var t = col.render.toLowerCase().indexOf(':'); - var tmp = []; - if (t == -1) { - tmp[0] = col.render.toLowerCase(); - tmp[1] = ''; - } else { - tmp[0] = col.render.toLowerCase().substr(0, t); - tmp[1] = col.render.toLowerCase().substr(t+1); - } - // formatters - var func = w2utils.formatters[tmp[0]]; - if (col.options && col.options.autoFormat === false) { - func = null; - } - data = (typeof func == 'function' ? func(data, tmp[1], record) : ''); - data = '
' + infoBubble + String(data) + '
'; - } - } else { - // if editable checkbox - if (edit && ['checkbox', 'check'].indexOf(edit.type) != -1) { - var changeInd = summary ? -(ind + 1) : ind; - style += 'text-align: center;'; - data = ''; - infoBubble = ''; - } - data = '
' + infoBubble + String(data) + '
'; - } - if (data == null) data = ''; - // --> cell TD - if (typeof col.render == 'string') { - var tmp = col.render.toLowerCase().split(':'); - if (['number', 'int', 'float', 'money', 'currency', 'percent', 'size'].indexOf(tmp[0]) != -1) addStyle += 'text-align: right;'; - } - if (record && record.w2ui) { - if (typeof record.w2ui.style == 'object') { - if (typeof record.w2ui.style[col_ind] == 'string') addStyle += record.w2ui.style[col_ind] + ';'; - if (typeof record.w2ui.style[col.field] == 'string') addStyle += record.w2ui.style[col.field] + ';'; - } - if (typeof record.w2ui.class == 'object') { - if (typeof record.w2ui.class[col_ind] == 'string') addClass += record.w2ui.class[col_ind] + ' '; - if (typeof record.w2ui.class[col.field] == 'string') addClass += record.w2ui.class[col.field] + ' '; - } - } - var isCellSelected = false; - if (isRowSelected && $.inArray(col_ind, sel.columns[ind]) != -1) isCellSelected = true; - var clipboardTxt = (typeof col.clipboardCopy == 'string' ? col.clipboardCopy : 'Copy to clipboard') - var clipboardIcon = '' - // data - data = ' 1 ? 'colspan="'+ col_span + '"' : '') + - '>' + data + (w2utils.stripTags(data) != '' && col.clipboardCopy && clipboardTxt ? clipboardIcon : '') +''; - // summary top row - if (ind === -1 && summary === true) { - data = ' 1 ? 'colspan="'+ col_span + '"' : '') + - '>'; - } - return data; - - function getTitle(cellData){ - var title = ""; - if (obj.show.recordTitles) { - if (col.title != null) { - if (typeof col.title == 'function') title = col.title.call(obj, record, ind, col_ind); - if (typeof col.title == 'string') title = col.title; - } else { - title = w2utils.stripTags(String(cellData).replace(/"/g, "''")); - } - } - return (title != null) ? String(title) : ""; - } - }, - - clipboardCopy: function (ind, col_ind) { - var rec = this.records[ind] - var col = this.columns[col_ind] - var txt = (col ? this.parseField(rec, col.field) : ''); - if (typeof col.clipboardCopy == 'function') { - txt = col.clipboardCopy(rec) - } - $('#grid_' + this.name + '_focus').text(txt).select(); - document.execCommand('copy'); - }, - - showBubble: function (ind, col_ind) { - var html = ''; - var info = this.columns[col_ind].info; - var rec = this.records[ind]; - var el = $(this.box).find('#grid_'+ this.name +'_data_'+ ind +'_'+ col_ind + ' .w2ui-info'); - if (this.last.bubbleEl) $(this.last.bubbleEl).w2tag(); - this.last.bubbleEl = el; - // if no fields defined - show all - if (info.fields == null) { - info.fields = []; - for (var i = 0; i < this.columns.length; i++) { - var col = this.columns[i]; - info.fields.push(col.field + (typeof col.render == 'string' ? ':' + col.render : '')); - } - } - var fields = info.fields; - if (typeof fields == 'function') { - fields = fields(rec, ind, col_ind); // custom renderer - } - // generate html - if (typeof info.render == 'function') { - html = info.render(rec, ind, col_ind); - - } else if ($.isArray(fields)) { - // display mentioned fields - html = ''; - for (var i = 0; i < fields.length; i++) { - var tmp = String(fields[i]).split(':'); - if (tmp[0] == '' || tmp[0] == '-' || tmp[0] == '--' || tmp[0] == '---') { - html += ''; - continue; - } - var col = this.getColumn(tmp[0]); - if (col == null) col = { field: tmp[0], caption: tmp[0] }; // if not found in columns - var val = (col ? this.parseField(rec, col.field) : ''); - if (tmp.length > 1) { - if (w2utils.formatters[tmp[1]]) { - val = w2utils.formatters[tmp[1]](val, tmp[2] || null, rec); - } else { - console.log('ERROR: w2utils.formatters["'+ tmp[1] + '"] does not exists.') - } - } - if (info.showEmpty !== true && (val == null || val == '')) continue; - if (info.maxLength != null && typeof val == 'string' && val.length > info.maxLength) val = val.substr(0, info.maxLength) + '...'; - html += ''; - } - html += '
' + col.text + '' + ((val === 0 ? '0' : val) || '') + '
'; - } else if ($.isPlainObject(fields)) { - // display some fields - html = ''; - for (var caption in fields) { - var fld = fields[caption]; - if (fld == '' || fld == '-' || fld == '--' || fld == '---') { - html += ''; - continue; - } - var tmp = String(fld).split(':'); - var col = this.getColumn(tmp[0]); - if (col == null) col = { field: tmp[0], caption: tmp[0] }; // if not found in columns - var val = (col ? this.parseField(rec, col.field) : ''); - if (tmp.length > 1) { - if (w2utils.formatters[tmp[1]]) { - val = w2utils.formatters[tmp[1]](val, tmp[2] || null, rec); - } else { - console.log('ERROR: w2utils.formatters["'+ tmp[1] + '"] does not exists.') - } - } - if (typeof fld == 'function') { - val = fld(rec, ind, col_ind); - } - if (info.showEmpty !== true && (val == null || val == '')) continue; - if (info.maxLength != null && typeof val == 'string' && val.length > info.maxLength) val = val.substr(0, info.maxLength) + '...'; - html += ''; - } - html += '
' + caption + '' + (val || '') + '
'; - } - $(el).w2tag($.extend({ - html : html, - left : -4, - position : 'bottom|top', - className : 'w2ui-info-bubble', - style : '', - hideOnClick : true - }, info.options || {})); - }, - - // return null or the editable object if the given cell is editable - getCellEditable: function (ind, col_ind) { - var col = this.columns[col_ind]; - var rec = this.records[ind]; - if (!rec || !col) return null; - var edit = (rec.w2ui ? rec.w2ui.editable : null); - if (edit === false) return null; - if (edit == null || edit === true) { - edit = (col ? col.editable : null); - if (typeof(edit) === 'function') { - var data = this.getCellValue(ind, col_ind, false); - // same arguments as col.render() - edit = edit.call(this, rec, ind, col_ind, data); - } - } - return edit; - }, - - getCellValue: function (ind, col_ind, summary) { - var col = this.columns[col_ind]; - var record = (summary !== true ? this.records[ind] : this.summary[ind]); - var data = this.parseField(record, col.field); - if (record && record.w2ui && record.w2ui.changes && record.w2ui.changes[col.field] != null) { - data = record.w2ui.changes[col.field]; - } - if ($.isPlainObject(data) /*&& col.editable*/) { //It can be an object btw - if (col.options && col.options.items) { - val=col.options.items.find(function(item){ return item.id==data.id}); - if (val) data=val.text; - else data=data.id; - } else { - if (data.text != null) data = data.text; - if (data.id != null) data = data.id; - } - } - if (data == null) data = ''; - return data; - }, - - getFooterHTML: function () { - return '
'+ - ' '+ - ' '+ - ' '+ - '
'; - }, - - status: function (msg) { - if (msg != null) { - $('#grid_'+ this.name +'_footer').find('.w2ui-footer-left').html(msg); - } else { - // show number of selected - var msgLeft = ''; - var sel = this.getSelection(); - if (sel.length > 0) { - if (this.show.statusSelection && sel.length > 1) { - msgLeft = String(sel.length).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + ' ' + w2utils.lang('selected'); - } - if (this.show.statusRecordID && sel.length == 1) { - var tmp = sel[0]; - if (typeof tmp == 'object') tmp = tmp.recid + ', '+ w2utils.lang('Column') +': '+ tmp.column; - msgLeft = w2utils.lang('Record ID') + ': '+ tmp + ' '; - } - } - $('#grid_'+ this.name +'_footer .w2ui-footer-left').html(msgLeft); - // toolbar - if (sel.length == 1) this.toolbar.enable('w2ui-edit'); else this.toolbar.disable('w2ui-edit'); - if (sel.length >= 1) this.toolbar.enable('w2ui-delete'); else this.toolbar.disable('w2ui-delete'); - } - }, - - lock: function (msg, showSpinner) { - var obj = this; - var args = Array.prototype.slice.call(arguments, 0); - args.unshift(this.box); - setTimeout(function () { - // hide empty msg if any - $(obj.box).find('#grid_'+ obj.name +'_empty_msg').remove(); - w2utils.lock.apply(window, args); - }, 10); - }, - - unlock: function (speed) { - var box = this.box; - setTimeout(function () { - // do not unlock if there is a message - if ($(box).find('.w2ui-message').not('.w2ui-closing').length > 0) return; - w2utils.unlock(box, speed); - }, 25); // needed timer so if server fast, it will not flash - }, - - stateSave: function (returnOnly) { - var obj = this; - if (!w2utils.hasLocalStorage) return null; - var state = { - columns : [], - show : $.extend({}, this.show), - last : { - search : this.last.search, - multi : this.last.multi, - logic : this.last.logic, - label : this.last.label, - field : this.last.field, - scrollTop : this.last.scrollTop, - scrollLeft : this.last.scrollLeft - }, - sortData : [], - searchData : [] - }; - var prop_val; - for (var i = 0; i < this.columns.length; i++) { - var col = obj.columns[i]; - var col_save_obj = {}; - // iterate properties to save - Object.keys(obj.stateColProps).forEach(function(prop, idx) { - if(obj.stateColProps[prop]){ - // check if the property is defined on the column - if(col[prop] !== undefined){ - prop_val = col[prop]; - } else { - // use fallback or null - prop_val = obj.stateColDefaults[prop] || null; - } - col_save_obj[prop] = prop_val; - } - }); - state.columns.push(col_save_obj); - } - for (var i = 0; i < this.sortData.length; i++) state.sortData.push($.extend({}, this.sortData[i])); - for (var i = 0; i < this.searchData.length; i++) state.searchData.push($.extend({}, this.searchData[i])); - // save into local storage - if (returnOnly !== true) { - // event before - var edata = this.trigger({ phase: 'before', type: 'stateSave', target: this.name, state: state }); - if (edata.isCancelled === true) { if (typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); return; } - try { - var savedState = $.parseJSON(localStorage.w2ui || '{}'); - if (!savedState) savedState = {}; - if (!savedState.states) savedState.states = {}; - savedState.states[(this.stateId || this.name)] = state; - localStorage.w2ui = JSON.stringify(savedState); - } catch (e) { - delete localStorage.w2ui; - return null; - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - } - return state; - }, - - stateRestore: function (newState) { - var obj = this; - var url = (typeof this.url != 'object' ? this.url : this.url.get); - if (!newState) { - // read it from local storage - try { - if (!w2utils.hasLocalStorage) return false; - var tmp = $.parseJSON(localStorage.w2ui || '{}'); - if (!tmp) tmp = {}; - if (!tmp.states) tmp.states = {}; - newState = tmp.states[(this.stateId || this.name)]; - } catch (e) { - delete localStorage.w2ui; - return null; - } - } - // event before - var edata = this.trigger({ phase: 'before', type: 'stateRestore', target: this.name, state: newState }); - if (edata.isCancelled === true) { if (typeof callBack == 'function') callBack({ status: 'error', message: 'Request aborted.' }); return; } - // default behavior - if ($.isPlainObject(newState)) { - $.extend(this.show, newState.show); - $.extend(this.last, newState.last); - var sTop = this.last.scrollTop; - var sLeft = this.last.scrollLeft; - for (var c = 0; c < newState.columns.length; c++) { - var tmp = newState.columns[c]; - var col_index = this.getColumn(tmp.field, true); - if (col_index !== null) { - $.extend(this.columns[col_index], tmp); - // restore column order from saved state - if (c !== col_index) this.columns.splice(c, 0, this.columns.splice(col_index, 1)[0]); - } - } - this.sortData.splice(0, this.sortData.length); - for (var c = 0; c < newState.sortData.length; c++) this.sortData.push(newState.sortData[c]); - this.searchData.splice(0, this.searchData.length); - for (var c = 0; c < newState.searchData.length; c++) this.searchData.push(newState.searchData[c]); - // apply sort and search - setTimeout(function () { - // needs timeout as records need to be populated - // ez 10.09.2014 this --> - if (!url) { - if (obj.sortData.length > 0) obj.localSort(); - if (obj.searchData.length > 0) obj.localSearch(); - } - obj.last.scrollTop = sTop; - obj.last.scrollLeft = sLeft; - obj.refresh(); - }, 1); - } - // event after - this.trigger($.extend(edata, { phase: 'after' })); - return true; - }, - - stateReset() { - var obj = this; - this.stateRestore(this.last.state); - // remove from local storage - if (w2utils.hasLocalStorage) { - try { - var tmp = $.parseJSON(localStorage.w2ui || '{}'); - if (tmp.states && tmp.states[(this.stateId || this.name)]) { - delete tmp.states[(this.stateId || this.name)]; - } - localStorage.w2ui = JSON.stringify(tmp); - } catch (e) { - delete localStorage.w2ui; - return null; - } - } - }, - - parseField: function (obj, field) { - if (this.nestedFields) { - var val = ''; - try { // need this to make sure no error in fields - val = obj; - var tmp = String(field).split('.'); - for (var i = 0; i < tmp.length; i++) { - val = val[tmp[i]]; - } - } catch (event) { - val = ''; - } - return val; - } else { - return obj ? obj[field] : ''; - } - }, - - prepareData: function () { - var obj = this; - - // loops thru records and prepares date and time objects - for (var r = 0; r < this.records.length; r++) { - var rec = this.records[r]; - prepareRecord(rec); - } - - // prepare date and time objects for the 'rec' record and its closed children - function prepareRecord(rec) { - for (var c = 0; c < obj.columns.length; c++) { - var column = obj.columns[c]; - if (rec[column.field] == null || typeof column.render != 'string') continue; - // number - if (['number', 'int', 'float', 'money', 'currency', 'percent'].indexOf(column.render.split(':')[0]) != -1) { - if (typeof rec[column.field] != 'number') rec[column.field] = parseFloat(rec[column.field]); - } - // date - if (['date', 'age'].indexOf(column.render.split(':')[0]) != -1) { - if (!rec[column.field + '_']) { - var dt = rec[column.field]; - if (w2utils.isInt(dt)) dt = parseInt(dt); - rec[column.field + '_'] = new Date(dt); - } - } - // time - if (['time'].indexOf(column.render) != -1) { - if (w2utils.isTime(rec[column.field])) { // if string - var tmp = w2utils.isTime(rec[column.field], true); - var dt = new Date(); - dt.setHours(tmp.hours, tmp.minutes, (tmp.seconds ? tmp.seconds : 0), 0); // sets hours, min, sec, mills - if (!rec[column.field + '_']) rec[column.field + '_'] = dt; - } else { // if date object - var tmp = rec[column.field]; - if (w2utils.isInt(tmp)) tmp = parseInt(tmp); - var tmp = (tmp != null ? new Date(tmp) : new Date()); - var dt = new Date(); - dt.setHours(tmp.getHours(), tmp.getMinutes(), tmp.getSeconds(), 0); // sets hours, min, sec, mills - if (!rec[column.field + '_']) rec[column.field + '_'] = dt; - } - } - } - - if (rec.w2ui && rec.w2ui.children && rec.w2ui.expanded !== true) { - // there are closed children, prepare them too. - for (var r = 0; r < rec.w2ui.children.length; r++) { - var subRec = rec.w2ui.children[r]; - prepareRecord(subRec); - } - } - } - }, - - nextCell: function (index, col_ind, editable) { - var check = col_ind + 1; - if (check >= this.columns.length) return null; - var tmp = this.records[index].w2ui; - var ccol = this.columns[col_ind]; - // if (tmp && tmp.colspan[ccol.field]) check += parseInt(tmp.colspan[ccol.field]) -1; // colspan of a column - var col = this.columns[check]; - var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); - if (col == null) return null; - if (col && col.hidden || span === 0) return this.nextCell(index, check, editable); - if (editable) { - var edit = this.getCellEditable(index, col_ind); - if (edit == null || ['checkbox', 'check'].indexOf(edit.type) != -1) { - return this.nextCell(index, check, editable); - } - } - return check; - }, - - prevCell: function (index, col_ind, editable) { - var check = col_ind - 1; - if (check < 0) return null; - var tmp = this.records[index].w2ui; - var col = this.columns[check]; - var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); - if (col == null) return null; - if (col && col.hidden || span === 0) return this.prevCell(index, check, editable); - if (editable) { - var edit = this.getCellEditable(index, col_ind); - if (edit == null || ['checkbox', 'check'].indexOf(edit.type) != -1) { - return this.prevCell(index, check, editable); - } - } - return check; - }, - - nextRow: function (ind, col_ind) { - var sids = this.last.searchIds; - var ret = null; - if ((ind + 1 < this.records.length && sids.length === 0) // if there are more records - || (sids.length > 0 && ind < sids[sids.length-1])) { - ind++; - if (sids.length > 0) while (true) { - if ($.inArray(ind, sids) != -1 || ind > this.records.length) break; - ind++; - } - // colspan - var tmp = this.records[ind].w2ui; - var col = this.columns[col_ind]; - var span = (tmp && tmp.colspan && col != null && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); - if (span === 0) { - ret = this.nextRow(ind, col_ind); - } else { - ret = ind; - } - } - return ret; - }, - - prevRow: function (ind, col_ind) { - var sids = this.last.searchIds; - var ret = null; - if ((ind > 0 && sids.length === 0) // if there are more records - || (sids.length > 0 && ind > sids[0])) { - ind--; - if (sids.length > 0) while (true) { - if ($.inArray(ind, sids) != -1 || ind < 0) break; - ind--; - } - // colspan - var tmp = this.records[ind].w2ui; - var col = this.columns[col_ind]; - var span = (tmp && tmp.colspan && col != null && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); - if (span === 0) { - ret = this.prevRow(ind, col_ind); - } else { - ret = ind; - } - } - return ret; - }, - - selectionSave() { - this.last._selection = this.getSelection(); - return this.last._selection; - }, - - selectionRestore: function (noRefresh) { - var time = (new Date()).getTime(); - this.last.selection = { indexes: [], columns: {} }; - var sel = this.last.selection; - var lst = this.last._selection; - if (lst) for (var i = 0; i < lst.length; i++) { - if ($.isPlainObject(lst[i])) { - // selectType: cell - var tmp = this.get(lst[i].recid, true); - if (tmp != null) { - if (sel.indexes.indexOf(tmp) == -1) sel.indexes.push(tmp); - if (!sel.columns[tmp]) sel.columns[tmp] = []; - sel.columns[tmp].push(lst[i].column); - } - } else { - // selectType: row - var tmp = this.get(lst[i], true); - if (tmp != null) sel.indexes.push(tmp); - } - } - delete this.last._selection; - if (noRefresh !== true) this.refresh(); - return (new Date()).getTime() - time; - }, - - message: function(options, callBack) { - if (typeof options == 'string') { - options = { - width : (options.length < 300 ? 350 : 550), - height : (options.length < 300 ? 170: 250), - body : '
' + options + '
', - buttons : '', - onOpen : function (event) { - setTimeout(function () { - $(this.box).find('.w2ui-btn').focus(); - }, 25); - }, - onClose: function (even) { - if (typeof callBack == 'function') callBack(); - } - }; - } - w2utils.message.call(this, { - box : this.box, - path : 'w2ui.' + this.name, - title : '.w2ui-grid-header:visible', - body : '.w2ui-grid-box' - }, options); - } - } - - $.extend(w2grid.prototype, w2utils.event); - w2obj.grid = w2grid; -})(jQuery); - -/************************************************************************ -* Library: Web 2.0 UI for jQuery (using prototypical inheritance) -* - Following objects defined -* - w2layout - layout widget -* - $().w2layout - jQuery wrapper -* - Dependencies: jQuery, w2utils, w2toolbar, w2tabs -* -* == changes -* - negative values for left, right panel -* - onResize for layout as well as onResizing -* - panel.callBack - one time -* - layout.html().replaced(function () {}) -* -* == NICE TO HAVE == -* - onResize for the panel -* - add more panel title positions (left=rotated, right=rotated, bottom) -* - bug: when you assign content before previous transition completed. -* -************************************************************************/ - -(function ($) { - var w2layout = function (options) { - this.box = null; // DOM Element that holds the element - this.name = null; // unique name for w2ui - this.panels = []; - this.tmp = {}; - this.padding = 1; // panel padding - this.resizer = 4; // resizer width or height - this.style = ''; - - $.extend(true, this, w2obj.layout, options); - }; - - var w2panels = ['top', 'left', 'main', 'preview', 'right', 'bottom']; - - // ==================================================== - // -- Registers as a jQuery plugin - - $.fn.w2layout = function(method) { - if ($.isPlainObject(method)) { - // check name parameter - if (!w2utils.checkName(method, 'w2layout')) return; - var panels = method.panels || []; - var object = new w2layout(method); - $.extend(object, { handlers: [], panels: [] }); - // add defined panels - for (var p = 0, len = panels.length; p < len; p++) { - object.panels[p] = $.extend(true, {}, w2layout.prototype.panel, panels[p]); - if ($.isPlainObject(object.panels[p].tabs) || $.isArray(object.panels[p].tabs)) initTabs(object, panels[p].type); - if ($.isPlainObject(object.panels[p].toolbar) || $.isArray(object.panels[p].toolbar)) initToolbar(object, panels[p].type); - } - // add all other panels - for (var p1 = 0; p1 < w2panels.length; p1++) { - if (object.get(w2panels[p1]) != null) continue; - object.panels.push($.extend(true, {}, w2layout.prototype.panel, { type: w2panels[p1], hidden: (w2panels[p1] !== 'main'), size: 50 })); - } - w2ui[object.name] = object; - if ($(this).length > 0) { - object.render($(this)[0]); - } - return object; - - } else { - var obj = w2ui[$(this).attr('name')]; - if (!obj) return null; - if (arguments.length > 0) { - if (obj[method]) obj[method].apply(obj, Array.prototype.slice.call(arguments, 1)); - return this; - } else { - return obj; - } - } - - function initTabs(object, panel, tabs) { - var pan = object.get(panel); - if (pan != null && tabs == null) tabs = pan.tabs; - if (pan == null || tabs == null) return false; - // instanciate tabs - if ($.isArray(tabs)) tabs = { tabs: tabs }; - $().w2destroy(object.name + '_' + panel + '_tabs'); // destroy if existed - pan.tabs = $().w2tabs($.extend({}, tabs, { owner: object, name: object.name + '_' + panel + '_tabs' })); - pan.show.tabs = true; - return true; - } - - function initToolbar(object, panel, toolbar) { - var pan = object.get(panel); - if (pan != null && toolbar == null) toolbar = pan.toolbar; - if (pan == null || toolbar == null) return false; - // instanciate toolbar - if ($.isArray(toolbar)) toolbar = { items: toolbar }; - $().w2destroy(object.name + '_' + panel + '_toolbar'); // destroy if existed - pan.toolbar = $().w2toolbar($.extend({}, toolbar, { owner: object, name: object.name + '_' + panel + '_toolbar' })); - pan.show.toolbar = true; - return true; - } - }; - - // ==================================================== - // -- Implementation of core functionality - - w2layout.prototype = { - onShow : null, - onHide : null, - onResizing : null, - onResizerClick: null, - onRender : null, - onRefresh : null, - onContent : null, - onResize : null, - onDestroy : null, - - // default setting for a panel - panel: { - type : null, // left, right, top, bottom - title : '', - size : 100, // width or height depending on panel name - minSize : 20, - maxSize : false, - hidden : false, - resizable : false, - overflow : 'auto', - style : '', - content : '', // can be String or Object with .render(box) method - tabs : null, - toolbar : null, - width : null, // read only - height : null, // read only - show : { - toolbar : false, - tabs : false - }, - callBack : null, // function to call when content is overwritten - onRefresh : null, - onShow : null, - onHide : null - }, - - // alias for content - content: function (panel, data, transition) { - console.log('NOTICE: layout.content method is deprecated, please use layout.html() instead'); - return this.html(panel, data, transition); - }, - - html: function (panel, data, transition) { - var obj = this; - var p = this.get(panel); - var promise = { - panel : panel, - html : p.content, - error : false, - cancelled : false, - removed : function (callBack) { - if (typeof callBack == 'function') { - p.callBack = callBack - } - } - } - if (typeof p.callBack == 'function') { - p.callBack({ panel: panel, content: p.content, new_content: data, transition: transition || 'none' }); - p.callBack = null; // this is one time call back only - } - // if it is CSS panel - if (panel == 'css') { - $('#layout_'+ obj.name +'_panel_css').html(''); - promise.status = true; - return promise; - } - if (p == null) { - console.log('ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css') - promise.error = true; - return promise; - } - if (data == null) { - return promise; - } - // event before - var edata = this.trigger({ phase: 'before', type: 'content', target: panel, object: p, content: data, transition: transition }); - if (edata.isCancelled === true) { - promise.cancelled = true; - return promise; - } - - if (data instanceof jQuery) { - console.log('ERROR: You can not pass jQuery object to w2layout.content() method'); - return promise; - } - var pname = '#layout_'+ this.name + '_panel_'+ p.type; - var current = $(pname + '> .w2ui-panel-content'); - var panelTop = 0; - if (current.length > 0) { - $(pname).scrollTop(0); - panelTop = $(current).position().top; - } - if (p.content === '') { - p.content = data; - this.refresh(panel); - } else { - p.content = data; - if (!p.hidden) { - if (transition != null && transition !== '') { - // apply transition - var div1 = $(pname + '> .w2ui-panel-content'); - div1.after('
'); - var div2 = $(pname + '> .w2ui-panel-content.new-panel'); - div1.css('top', panelTop); - div2.css('top', panelTop); - if (typeof data == 'object') { - data.box = div2[0]; // do not do .render(box); - data.render(); - } else { - div2.html(data); - } - w2utils.transition(div1[0], div2[0], transition, function () { - div1.remove(); - div2.removeClass('new-panel'); - div2.css('overflow', p.overflow); - // make sure only one content left - $(pname + '> .w2ui-panel-content').slice(1).remove() - // IE Hack - obj.resize(); - if (window.navigator.userAgent.indexOf('MSIE') != -1) setTimeout(function () { obj.resize(); }, 100); - }); - } - } - this.refresh(panel); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - // IE Hack - obj.resize(); - if (window.navigator.userAgent.indexOf('MSIE') != -1) setTimeout(function () { obj.resize(); }, 100); - return promise; - }, - - message: function(panel, options) { - var obj = this; - if (typeof options == 'string') { - options = { - width : (options.length < 300 ? 350 : 550), - height : (options.length < 300 ? 170: 250), - body : '
' + options + '
', - buttons : '', - onOpen : function (event) { - setTimeout(function () { - $(this.box).find('.w2ui-btn').focus(); - }, 25); - } - }; - } - var p = this.get(panel); - var $el = $('#layout_'+ this.name + '_panel_'+ p.type); - var oldOverflow = $el.css('overflow'); - var oldOnClose; - if (options) { - if (options.onClose) oldOnClose = options.onClose; - options.onClose = function (event) { - if (typeof oldOnClose == 'function') oldOnClose(event); - event.done(function () { - $('#layout_'+ obj.name + '_panel_'+ p.type).css('overflow', oldOverflow); - }); - }; - } - $('#layout_'+ this.name + '_panel_'+ p.type).css('overflow', 'hidden'); - w2utils.message.call(this, { - box : $('#layout_'+ this.name + '_panel_'+ p.type), - param : panel, - path : 'w2ui.' + this.name, - title : '.w2ui-panel-title:visible', - body : '.w2ui-panel-content' - }, options); - }, - - load: function (panel, url, transition, onLoad) { - var obj = this; - if (panel == 'css') { - $.get(url, function (data, status, xhr) { // should always be $.get as it is template - obj.html(panel, xhr.responseText); - if (onLoad) onLoad(); - }); - return true; - } - if (this.get(panel) != null) { - $.get(url, function (data, status, xhr) { // should always be $.get as it is template - obj.html(panel, xhr.responseText, transition); - if (onLoad) onLoad(); - // IE Hack - obj.resize(); - if (window.navigator.userAgent.indexOf('MSIE') != -1) setTimeout(function () { obj.resize(); }, 100); - }); - return true; - } - return false; - }, - - sizeTo: function (panel, size, instant) { - var obj = this; - var pan = obj.get(panel); - if (pan == null) return false; - // resize - $(obj.box).find(' > div > .w2ui-panel') - .css(w2utils.cssPrefix('transition', (instant !== true ? '.2s' : '0s'))); - setTimeout(function () { - obj.set(panel, { size: size }); - }, 1); - // clean - setTimeout(function () { - $(obj.box).find(' > div > .w2ui-panel').css(w2utils.cssPrefix('transition', '0s')); - obj.resize(); - }, 500); - return true; - }, - - show: function (panel, immediate) { - var obj = this; - // event before - var edata = this.trigger({ phase: 'before', type: 'show', target: panel, object: this.get(panel), immediate: immediate }); - if (edata.isCancelled === true) return; - - var p = obj.get(panel); - if (p == null) return false; - p.hidden = false; - if (immediate === true) { - $('#layout_'+ obj.name +'_panel_'+panel).css({ 'opacity': '1' }); - obj.trigger($.extend(edata, { phase: 'after' })); - obj.resize(); - } else { - // resize - $('#layout_'+ obj.name +'_panel_'+panel).css({ 'opacity': '0' }); - $(obj.box).find(' > div > .w2ui-panel').css(w2utils.cssPrefix('transition', '.2s')); - setTimeout(function () { obj.resize(); }, 1); - // show - setTimeout(function() { - $('#layout_'+ obj.name +'_panel_'+ panel).css({ 'opacity': '1' }); - }, 250); - // clean - setTimeout(function () { - $(obj.box).find(' > div > .w2ui-panel').css(w2utils.cssPrefix('transition', '0s')); - obj.trigger($.extend(edata, { phase: 'after' })); - obj.resize(); - }, 500); - } - return true; - }, - - hide: function (panel, immediate) { - var obj = this; - // event before - var edata = this.trigger({ phase: 'before', type: 'hide', target: panel, object: this.get(panel), immediate: immediate }); - if (edata.isCancelled === true) return; - - var p = obj.get(panel); - if (p == null) return false; - p.hidden = true; - if (immediate === true) { - $('#layout_'+ obj.name +'_panel_'+panel).css({ 'opacity': '0' }); - obj.trigger($.extend(edata, { phase: 'after' })); - obj.resize(); - } else { - // hide - $(obj.box).find(' > div > .w2ui-panel').css(w2utils.cssPrefix('transition', '.2s')); - $('#layout_'+ obj.name +'_panel_'+panel).css({ 'opacity': '0' }); - setTimeout(function () { obj.resize(); }, 1); - // clean - setTimeout(function () { - $(obj.box).find(' > div > .w2ui-panel').css(w2utils.cssPrefix('transition', '0s')); - obj.trigger($.extend(edata, { phase: 'after' })); - obj.resize(); - }, 500); - } - return true; - }, - - toggle: function (panel, immediate) { - var p = this.get(panel); - if (p == null) return false; - if (p.hidden) return this.show(panel, immediate); else return this.hide(panel, immediate); - }, - - set: function (panel, options) { - var ind = this.get(panel, true); - if (ind == null) return false; - $.extend(this.panels[ind], options); - // refresh only when content changed - if (options.content != null || options.resizable != null) { - this.refresh(panel); - } - // show/hide resizer - this.resize(); // resize is needed when panel size is changed - return true; - }, - - get: function (panel, returnIndex) { - for (var p = 0; p < this.panels.length; p++) { - if (this.panels[p].type == panel) { - if (returnIndex === true) return p; else return this.panels[p]; - } - } - return null; - }, - - el: function (panel) { - var el = $('#layout_'+ this.name +'_panel_'+ panel +'> .w2ui-panel-content'); - if (el.length != 1) return null; - return el[0]; - }, - - hideToolbar: function (panel) { - var pan = this.get(panel); - if (!pan) return; - pan.show.toolbar = false; - $('#layout_'+ this.name +'_panel_'+ panel +'> .w2ui-panel-toolbar').hide(); - this.resize(); - }, - - showToolbar: function (panel) { - var pan = this.get(panel); - if (!pan) return; - pan.show.toolbar = true; - $('#layout_'+ this.name +'_panel_'+ panel +'> .w2ui-panel-toolbar').show(); - this.resize(); - }, - - toggleToolbar: function (panel) { - var pan = this.get(panel); - if (!pan) return; - if (pan.show.toolbar) this.hideToolbar(panel); else this.showToolbar(panel); - }, - - assignToolbar: function (panel, toolbar) { - if (typeof toolbar == 'string' && w2ui[toolbar] != null) toolbar = w2ui[toolbar]; - var pan = this.get(panel); - pan.toolbar = toolbar; - var tmp = $(this.box).find(panel +'> .w2ui-panel-toolbar'); - if (pan.toolbar != null) { - if (tmp.find('[name='+ pan.toolbar.name +']').length === 0) { - tmp.w2render(pan.toolbar); - } else if (pan.toolbar != null) { - pan.toolbar.refresh(); - } - toolbar.owner = this; - this.showToolbar(panel); - this.refresh(panel); - } else { - tmp.html(''); - this.hideToolbar(panel); - } - }, - - hideTabs: function (panel) { - var pan = this.get(panel); - if (!pan) return; - pan.show.tabs = false; - $('#layout_'+ this.name +'_panel_'+ panel +'> .w2ui-panel-tabs').hide(); - this.resize(); - }, - - showTabs: function (panel) { - var pan = this.get(panel); - if (!pan) return; - pan.show.tabs = true; - $('#layout_'+ this.name +'_panel_'+ panel +'> .w2ui-panel-tabs').show(); - this.resize(); - }, - - toggleTabs: function (panel) { - var pan = this.get(panel); - if (!pan) return; - if (pan.show.tabs) this.hideTabs(panel); else this.showTabs(panel); - }, - - render: function (box) { - var obj = this; - // if (window.getSelection) window.getSelection().removeAllRanges(); // clear selection - var time = (new Date()).getTime(); - // event before - var edata = obj.trigger({ phase: 'before', type: 'render', target: obj.name, box: box }); - if (edata.isCancelled === true) return; - - if (box != null) { - if ($(obj.box).find('#layout_'+ obj.name +'_panel_main').length > 0) { - $(obj.box) - .removeAttr('name') - .removeClass('w2ui-layout') - .html(''); - } - obj.box = box; - } - if (!obj.box) return false; - $(obj.box) - .attr('name', obj.name) - .addClass('w2ui-layout') - .html('
'); - if ($(obj.box).length > 0) $(obj.box)[0].style.cssText += obj.style; - // create all panels - for (var p1 = 0; p1 < w2panels.length; p1++) { - var pan = obj.get(w2panels[p1]); - var html = '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'; - $(obj.box).find(' > div').append(html); - // tabs are rendered in refresh() - } - $(obj.box).find(' > div') - .append('
'); - obj.refresh(); // if refresh is not called here, the layout will not be available right after initialization - // process event - obj.trigger($.extend(edata, { phase: 'after' })); - // reinit events - setTimeout(function () { // needed this timeout to allow browser to render first if there are tabs or toolbar - initEvents(); - obj.resize(); - }, 0); - return (new Date()).getTime() - time; - - function initEvents() { - obj.tmp.events = { - resize : function (event) { - if (w2ui[obj.name] == null) { - $(window).off('resize.w2ui-'+ obj.name); - } else { - w2ui[obj.name].resize(); - } - }, - resizeStart : resizeStart, - mouseMove : resizeMove, - mouseUp : resizeStop - }; - $(window).on('resize.w2ui-'+ obj.name, obj.tmp.events.resize); - } - - function resizeStart(type, evnt) { - if (!obj.box) return; - if (!evnt) evnt = window.event; - $(document).off('mousemove', obj.tmp.events.mouseMove).on('mousemove', obj.tmp.events.mouseMove); - $(document).off('mouseup', obj.tmp.events.mouseUp).on('mouseup', obj.tmp.events.mouseUp); - obj.tmp.resize = { - type : type, - x : evnt.screenX, - y : evnt.screenY, - diff_x : 0, - diff_y : 0, - value : 0 - }; - // lock all panels - for (var p1 = 0; p1 < w2panels.length; p1++) { - var $tmp = $(obj.el(w2panels[p1])).parent().find('.w2ui-lock'); - if ($tmp.length > 0) { - $tmp.attr('locked', 'previous'); - } else { - obj.lock(w2panels[p1], { opacity: 0 }); - } - } - if (type == 'left' || type == 'right') { - obj.tmp.resize.value = parseInt($('#layout_'+ obj.name +'_resizer_'+ type)[0].style.left); - } - if (type == 'top' || type == 'preview' || type == 'bottom') { - obj.tmp.resize.value = parseInt($('#layout_'+ obj.name +'_resizer_'+ type)[0].style.top); - } - } - - function resizeStop(evnt) { - if (!obj.box) return; - if (!evnt) evnt = window.event; - $(document).off('mousemove', obj.tmp.events.mouseMove); - $(document).off('mouseup', obj.tmp.events.mouseUp); - if (obj.tmp.resize == null) return; - // unlock all panels - for (var p1 = 0; p1 < w2panels.length; p1++) { - var $tmp = $(obj.el(w2panels[p1])).parent().find('.w2ui-lock'); - if ($tmp.attr('locked') == 'previous') { - $tmp.removeAttr('locked'); - } else { - obj.unlock(w2panels[p1]); - } - } - // set new size - if (obj.tmp.diff_x !== 0 || obj.tmp.resize.diff_y !== 0) { // only recalculate if changed - var ptop = obj.get('top'); - var pbottom = obj.get('bottom'); - var panel = obj.get(obj.tmp.resize.type); - var height = parseInt($(obj.box).height()); - var width = parseInt($(obj.box).width()); - var str = String(panel.size); - var ns, nd; - switch (obj.tmp.resize.type) { - case 'top': - ns = parseInt(panel.sizeCalculated) + obj.tmp.resize.diff_y; - nd = 0; - break; - case 'bottom': - ns = parseInt(panel.sizeCalculated) - obj.tmp.resize.diff_y; - nd = 0; - break; - case 'preview': - ns = parseInt(panel.sizeCalculated) - obj.tmp.resize.diff_y; - nd = (ptop && !ptop.hidden ? ptop.sizeCalculated : 0) + - (pbottom && !pbottom.hidden ? pbottom.sizeCalculated : 0); - break; - case 'left': - ns = parseInt(panel.sizeCalculated) + obj.tmp.resize.diff_x; - nd = 0; - break; - case 'right': - ns = parseInt(panel.sizeCalculated) - obj.tmp.resize.diff_x; - nd = 0; - break; - } - // set size - if (str.substr(str.length-1) == '%') { - panel.size = Math.floor(ns * 100 / (panel.type == 'left' || panel.type == 'right' ? width : height - nd) * 100) / 100 + '%'; - } else { - if (String(panel.size).substr(0, 1) == '-') { - panel.size = parseInt(panel.size) - panel.sizeCalculated + ns; - } else { - panel.size = ns; - } - } - obj.resize(); - } - $('#layout_'+ obj.name + '_resizer_'+ obj.tmp.resize.type).removeClass('active'); - delete obj.tmp.resize; - } - - function resizeMove(evnt) { - if (!obj.box) return; - if (!evnt) evnt = window.event; - if (obj.tmp.resize == null) return; - var panel = obj.get(obj.tmp.resize.type); - // event before - var tmp = obj.tmp.resize; - var edata = obj.trigger({ phase: 'before', type: 'resizing', target: obj.name, object: panel, originalEvent: evnt, - panel: tmp ? tmp.type : 'all', diff_x: tmp ? tmp.diff_x : 0, diff_y: tmp ? tmp.diff_y : 0 }); - if (edata.isCancelled === true) return; - - var p = $('#layout_'+ obj.name + '_resizer_'+ tmp.type); - var resize_x = (evnt.screenX - tmp.x); - var resize_y = (evnt.screenY - tmp.y); - var mainPanel = obj.get('main'); - - if (!p.hasClass('active')) p.addClass('active'); - - switch (tmp.type) { - case 'left': - if (panel.minSize - resize_x > panel.width) { - resize_x = panel.minSize - panel.width; - } - if (panel.maxSize && (panel.width + resize_x > panel.maxSize)) { - resize_x = panel.maxSize - panel.width; - } - if (mainPanel.minSize + resize_x > mainPanel.width) { - resize_x = mainPanel.width - mainPanel.minSize; - } - break; - - case 'right': - if (panel.minSize + resize_x > panel.width) { - resize_x = panel.width - panel.minSize; - } - if (panel.maxSize && (panel.width - resize_x > panel.maxSize)) { - resize_x = panel.width - panel.maxSize; - } - if (mainPanel.minSize - resize_x > mainPanel.width) { - resize_x = mainPanel.minSize - mainPanel.width; - } - break; - - case 'top': - if (panel.minSize - resize_y > panel.height) { - resize_y = panel.minSize - panel.height; - } - if (panel.maxSize && (panel.height + resize_y > panel.maxSize)) { - resize_y = panel.maxSize - panel.height; - } - if (mainPanel.minSize + resize_y > mainPanel.height) { - resize_y = mainPanel.height - mainPanel.minSize; - } - break; - - case 'preview': - case 'bottom': - if (panel.minSize + resize_y > panel.height) { - resize_y = panel.height - panel.minSize; - } - if (panel.maxSize && (panel.height - resize_y > panel.maxSize)) { - resize_y = panel.height - panel.maxSize; - } - if (mainPanel.minSize - resize_y > mainPanel.height) { - resize_y = mainPanel.minSize - mainPanel.height; - } - break; - } - tmp.diff_x = resize_x; - tmp.diff_y = resize_y; - - switch (tmp.type) { - case 'top': - case 'preview': - case 'bottom': - tmp.diff_x = 0; - if (p.length > 0) p[0].style.top = (tmp.value + tmp.diff_y) + 'px'; - break; - - case 'left': - case 'right': - tmp.diff_y = 0; - if (p.length > 0) p[0].style.left = (tmp.value + tmp.diff_x) + 'px'; - break; - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - } - }, - - refresh: function (panel) { - var obj = this; - // if (window.getSelection) window.getSelection().removeAllRanges(); // clear selection - if (panel == null) panel = null; - var time = (new Date()).getTime(); - // event before - var edata = obj.trigger({ phase: 'before', type: 'refresh', target: (panel != null ? panel : obj.name), object: obj.get(panel) }); - if (edata.isCancelled === true) return; - // obj.unlock(panel); - if (typeof panel == 'string') { - var p = obj.get(panel); - if (p == null) return; - var pname = '#layout_'+ obj.name + '_panel_'+ p.type; - var rname = '#layout_'+ obj.name +'_resizer_'+ p.type; - // apply properties to the panel - $(pname).css({ display: p.hidden ? 'none' : 'block' }); - if (p.resizable) $(rname).show(); else $(rname).hide(); - // insert content - if (typeof p.content == 'object' && typeof p.content.render === 'function') { - p.content.box = $(pname +'> .w2ui-panel-content')[0]; - setTimeout(function () { - // need to remove unnecessary classes - if ($(pname +'> .w2ui-panel-content').length > 0) { - $(pname +'> .w2ui-panel-content') - .removeClass() - .removeAttr('name') - .addClass('w2ui-panel-content') - .css('overflow', p.overflow)[0].style.cssText += ';' + p.style; - } - if (p.content && typeof p.content.render == 'function') { - p.content.render(); // do not do .render(box); - } - }, 1); - } else { - // need to remove unnecessary classes - if ($(pname +'> .w2ui-panel-content').length > 0) { - $(pname +'> .w2ui-panel-content') - .removeClass() - .removeAttr('name') - .addClass('w2ui-panel-content') - .html(p.content) - .css('overflow', p.overflow)[0].style.cssText += ';' + p.style; - } - } - // if there are tabs and/or toolbar - render it - var tmp = $(obj.box).find(pname +'> .w2ui-panel-tabs'); - if (p.show.tabs) { - if (tmp.find('[name='+ p.tabs.name +']').length === 0 && p.tabs != null) tmp.w2render(p.tabs); else p.tabs.refresh(); - } else { - tmp.html('').removeClass('w2ui-tabs').hide(); - } - tmp = $(obj.box).find(pname +'> .w2ui-panel-toolbar'); - if (p.show.toolbar) { - if (tmp.find('[name='+ p.toolbar.name +']').length === 0 && p.toolbar != null) tmp.w2render(p.toolbar); else p.toolbar.refresh(); - } else { - tmp.html('').removeClass('w2ui-toolbar').hide(); - } - // show title - tmp = $(obj.box).find(pname +'> .w2ui-panel-title'); - if (p.title) { - tmp.html(p.title).show(); - } else { - tmp.html('').hide(); - } - } else { - if ($('#layout_'+ obj.name +'_panel_main').length === 0) { - obj.render(); - return; - } - obj.resize(); - // refresh all of them - for (var p1 = 0; p1 < this.panels.length; p1++) { obj.refresh(this.panels[p1].type); } - } - obj.trigger($.extend(edata, { phase: 'after' })); - return (new Date()).getTime() - time; - }, - - resize: function () { - // if (window.getSelection) window.getSelection().removeAllRanges(); // clear selection - if (!this.box) return false; - var time = (new Date()).getTime(); - // event before - var tmp = this.tmp.resize; - var edata = this.trigger({ phase: 'before', type: 'resize', target: this.name, - panel: tmp ? tmp.type : 'all', diff_x: tmp ? tmp.diff_x : 0, diff_y: tmp ? tmp.diff_y : 0 }); - if (edata.isCancelled === true) return; - if (this.padding < 0) this.padding = 0; - - // layout itself - var width = parseInt($(this.box).width()); - var height = parseInt($(this.box).height()); - $(this.box).find(' > div').css({ - width : width + 'px', - height : height + 'px' - }); - var obj = this; - // panels - var pmain = this.get('main'); - var pprev = this.get('preview'); - var pleft = this.get('left'); - var pright = this.get('right'); - var ptop = this.get('top'); - var pbottom = this.get('bottom'); - var smain = true; // main always on - var sprev = (pprev != null && pprev.hidden !== true ? true : false); - var sleft = (pleft != null && pleft.hidden !== true ? true : false); - var sright = (pright != null && pright.hidden !== true ? true : false); - var stop = (ptop != null && ptop.hidden !== true ? true : false); - var sbottom = (pbottom != null && pbottom.hidden !== true ? true : false); - var l, t, w, h, e; - // calculate % - for (var p = 0; p < w2panels.length; p++) { - if (w2panels[p] === 'main') continue; - tmp = this.get(w2panels[p]); - if (!tmp) continue; - var str = String(tmp.size || 0); - if (str.substr(str.length-1) == '%') { - var tmph = height; - if (tmp.type == 'preview') { - tmph = tmph - - (ptop && !ptop.hidden ? ptop.sizeCalculated : 0) - - (pbottom && !pbottom.hidden ? pbottom.sizeCalculated : 0); - } - tmp.sizeCalculated = parseInt((tmp.type == 'left' || tmp.type == 'right' ? width : tmph) * parseFloat(tmp.size) / 100); - } else { - tmp.sizeCalculated = parseInt(tmp.size); - } - tmp.sizeCalculated = Math.max(tmp.sizeCalculated, parseInt(tmp.minSize)); - } - // negative size - if (String(pright.size).substr(0, 1) == '-') { - if (sleft && String(pleft.size).substr(0, 1) == '-') { - console.log('ERROR: you cannot have both left panel.size and right panel.size be negative.'); - } else { - pright.sizeCalculated = width - (sleft ? pleft.sizeCalculated : 0) + parseInt(pright.size); - } - } - if (String(pleft.size).substr(0, 1) == '-') { - if (sright && pright.size.substr(0, 1) == '-') { - console.log('ERROR: you cannot have both left panel.size and right panel.size be negative.'); - } else { - pleft.sizeCalculated = width - (sright ? pright.sizeCalculated : 0) + parseInt(pleft.size); - } - } - // top if any - if (ptop != null && ptop.hidden !== true) { - l = 0; - t = 0; - w = width; - h = ptop.sizeCalculated; - $('#layout_'+ this.name +'_panel_top').css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }).show(); - ptop.width = w; - ptop.height = h; - // resizer - if (ptop.resizable) { - t = ptop.sizeCalculated - (this.padding === 0 ? this.resizer : 0); - h = (this.resizer > this.padding ? this.resizer : this.padding); - $('#layout_'+ this.name +'_resizer_top').show().css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px', - 'cursor': 'ns-resize' - }).off('mousedown').on('mousedown', function (event) { - // event before - var edata = obj.trigger({ phase: 'before', type: 'resizerClick', target: 'top', originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - w2ui[obj.name].tmp.events.resizeStart('top', event); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - return false; - }); - } - } else { - $('#layout_'+ this.name +'_panel_top').hide(); - $('#layout_'+ this.name +'_resizer_top').hide(); - } - // left if any - if (pleft != null && pleft.hidden !== true) { - l = 0; - t = 0 + (stop ? ptop.sizeCalculated + this.padding : 0); - w = pleft.sizeCalculated; - h = height - (stop ? ptop.sizeCalculated + this.padding : 0) - - (sbottom ? pbottom.sizeCalculated + this.padding : 0); - e = $('#layout_'+ this.name +'_panel_left'); - if (window.navigator.userAgent.indexOf('MSIE') != -1 && e.length > 0 && e[0].clientHeight < e[0].scrollHeight) w += 17; // IE hack - e.css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }).show(); - pleft.width = w; - pleft.height = h; - // resizer - if (pleft.resizable) { - l = pleft.sizeCalculated - (this.padding === 0 ? this.resizer : 0); - w = (this.resizer > this.padding ? this.resizer : this.padding); - $('#layout_'+ this.name +'_resizer_left').show().css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px', - 'cursor': 'ew-resize' - }).off('mousedown').on('mousedown', function (event) { - // event before - var edata = obj.trigger({ phase: 'before', type: 'resizerClick', target: 'left', originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - w2ui[obj.name].tmp.events.resizeStart('left', event); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - return false; - }); - } - } else { - $('#layout_'+ this.name +'_panel_left').hide(); - $('#layout_'+ this.name +'_resizer_left').hide(); - } - // right if any - if (pright != null && pright.hidden !== true) { - l = width - pright.sizeCalculated; - t = 0 + (stop ? ptop.sizeCalculated + this.padding : 0); - w = pright.sizeCalculated; - h = height - (stop ? ptop.sizeCalculated + this.padding : 0) - - (sbottom ? pbottom.sizeCalculated + this.padding : 0); - $('#layout_'+ this.name +'_panel_right').css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }).show(); - pright.width = w; - pright.height = h; - // resizer - if (pright.resizable) { - l = l - this.padding; - w = (this.resizer > this.padding ? this.resizer : this.padding); - $('#layout_'+ this.name +'_resizer_right').show().css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px', - 'cursor': 'ew-resize' - }).off('mousedown').on('mousedown', function (event) { - // event before - var edata = obj.trigger({ phase: 'before', type: 'resizerClick', target: 'right', originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - w2ui[obj.name].tmp.events.resizeStart('right', event); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - return false; - }); - } - } else { - $('#layout_'+ this.name +'_panel_right').hide(); - $('#layout_'+ this.name +'_resizer_right').hide(); - } - // bottom if any - if (pbottom != null && pbottom.hidden !== true) { - l = 0; - t = height - pbottom.sizeCalculated; - w = width; - h = pbottom.sizeCalculated; - $('#layout_'+ this.name +'_panel_bottom').css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }).show(); - pbottom.width = w; - pbottom.height = h; - // resizer - if (pbottom.resizable) { - t = t - (this.padding === 0 ? 0 : this.padding); - h = (this.resizer > this.padding ? this.resizer : this.padding); - $('#layout_'+ this.name +'_resizer_bottom').show().css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px', - 'cursor': 'ns-resize' - }).off('mousedown').on('mousedown', function (event) { - // event before - var edata = obj.trigger({ phase: 'before', type: 'resizerClick', target: 'bottom', originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - w2ui[obj.name].tmp.events.resizeStart('bottom', event); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - return false; - }); - } - } else { - $('#layout_'+ this.name +'_panel_bottom').hide(); - $('#layout_'+ this.name +'_resizer_bottom').hide(); - } - // main - always there - l = 0 + (sleft ? pleft.sizeCalculated + this.padding : 0); - t = 0 + (stop ? ptop.sizeCalculated + this.padding : 0); - w = width - (sleft ? pleft.sizeCalculated + this.padding : 0) - - (sright ? pright.sizeCalculated + this.padding: 0); - h = height - (stop ? ptop.sizeCalculated + this.padding : 0) - - (sbottom ? pbottom.sizeCalculated + this.padding : 0) - - (sprev ? pprev.sizeCalculated + this.padding : 0); - e = $('#layout_'+ this.name +'_panel_main'); - if (window.navigator.userAgent.indexOf('MSIE') != -1 && e.length > 0 && e[0].clientHeight < e[0].scrollHeight) w += 17; // IE hack - e.css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }); - pmain.width = w; - pmain.height = h; - - // preview if any - if (pprev != null && pprev.hidden !== true) { - l = 0 + (sleft ? pleft.sizeCalculated + this.padding : 0); - t = height - (sbottom ? pbottom.sizeCalculated + this.padding : 0) - pprev.sizeCalculated; - w = width - (sleft ? pleft.sizeCalculated + this.padding : 0) - - (sright ? pright.sizeCalculated + this.padding : 0); - h = pprev.sizeCalculated; - e = $('#layout_'+ this.name +'_panel_preview'); - if (window.navigator.userAgent.indexOf('MSIE') != -1 && e.length > 0 && e[0].clientHeight < e[0].scrollHeight) w += 17; // IE hack - e.css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px' - }).show(); - pprev.width = w; - pprev.height = h; - // resizer - if (pprev.resizable) { - t = t - (this.padding === 0 ? 0 : this.padding); - h = (this.resizer > this.padding ? this.resizer : this.padding); - $('#layout_'+ this.name +'_resizer_preview').show().css({ - 'display': 'block', - 'left': l + 'px', - 'top': t + 'px', - 'width': w + 'px', - 'height': h + 'px', - 'cursor': 'ns-resize' - }).off('mousedown').on('mousedown', function (event) { - // event before - var edata = obj.trigger({ phase: 'before', type: 'resizerClick', target: 'preview', originalEvent: event }); - if (edata.isCancelled === true) return; - // default action - w2ui[obj.name].tmp.events.resizeStart('preview', event); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - return false; - }); - } - } else { - $('#layout_'+ this.name +'_panel_preview').hide(); - $('#layout_'+ this.name +'_resizer_preview').hide(); - } - - // display tabs and toolbar if needed - for (var p1 = 0; p1 < w2panels.length; p1++) { - var pan = this.get(w2panels[p1]); - var tmp2 = '#layout_'+ this.name +'_panel_'+ w2panels[p1] +' > .w2ui-panel-'; - var tabHeight = 0; - if (pan) { - if (pan.title) { - tabHeight += w2utils.getSize($(tmp2 + 'title').css({ top: tabHeight + 'px', display: 'block' }), 'height'); - } - if (pan.show.tabs) { - if (pan.tabs != null && w2ui[this.name +'_'+ w2panels[p1] +'_tabs']) w2ui[this.name +'_'+ w2panels[p1] +'_tabs'].resize(); - tabHeight += w2utils.getSize($(tmp2 + 'tabs').css({ top: tabHeight + 'px', display: 'block' }), 'height'); - } - if (pan.show.toolbar) { - if (pan.toolbar != null && w2ui[this.name +'_'+ w2panels[p1] +'_toolbar']) w2ui[this.name +'_'+ w2panels[p1] +'_toolbar'].resize(); - tabHeight += w2utils.getSize($(tmp2 + 'toolbar').css({ top: tabHeight + 'px', display: 'block' }), 'height'); - } - } - $(tmp2 + 'content').css({ display: 'block' }).css({ top: tabHeight + 'px' }); - } - // send resize to all objects - clearTimeout(this._resize_timer); - this._resize_timer = setTimeout(function () { - for (var e in w2ui) { - if (typeof w2ui[e].resize == 'function') { - // sent to all none-layouts - if (w2ui[e].panels == null) w2ui[e].resize(); - // only send to nested layouts - var parent = $(w2ui[e].box).parents('.w2ui-layout'); - if (parent.length > 0 && parent.attr('name') == obj.name) w2ui[e].resize(); - } - } - }, 100); - this.trigger($.extend(edata, { phase: 'after' })); - return (new Date()).getTime() - time; - }, - - destroy: function () { - // event before - var edata = this.trigger({ phase: 'before', type: 'destroy', target: this.name }); - if (edata.isCancelled === true) return; - if (w2ui[this.name] == null) return false; - // clean up - if ($(this.box).find('#layout_'+ this.name +'_panel_main').length > 0) { - $(this.box) - .removeAttr('name') - .removeClass('w2ui-layout') - .html(''); - } - delete w2ui[this.name]; - // event after - this.trigger($.extend(edata, { phase: 'after' })); - if (this.tmp.events && this.tmp.events.resize) $(window).off('resize', this.tmp.events.resize); - return true; - }, - - lock: function (panel, msg, showSpinner) { - if (w2panels.indexOf(panel) == -1) { - console.log('ERROR: First parameter needs to be the a valid panel name.'); - return; - } - var args = Array.prototype.slice.call(arguments, 0); - args[0] = '#layout_'+ this.name + '_panel_' + panel; - w2utils.lock.apply(window, args); - }, - - unlock: function (panel, speed) { - if (w2panels.indexOf(panel) == -1) { - console.log('ERROR: First parameter needs to be the a valid panel name.'); - return; - } - var nm = '#layout_'+ this.name + '_panel_' + panel; - w2utils.unlock(nm, speed); - } - }; - - $.extend(w2layout.prototype, w2utils.event); - w2obj.layout = w2layout; -})(jQuery); - -/************************************************************************ -* Library: Web 2.0 UI for jQuery (using prototypical inheritance) -* - Following objects defined -* - w2popup - popup widget -* - $().w2popup - jQuery wrapper -* - Dependencies: jQuery, w2utils -* -* == changes -* - added onMove event -* - w2prompt.options.ok_class, cancel_class -* - w2confirm.options.onOpen, w2confirm.options.onClose -* - w2prompt.options.onOpen, w2prompt.options.onClose -* - w2popup.actions, w2popup.action, w2popup.onAction -* - w2popup.onMsgOpen, w2popup.onMsgClose -* - options.multiple -* -* == NICE TO HAVE == -* - hide overlay on esc -* - make popup width/height in % -* -************************************************************************/ - -var w2popup = {}; - -(function ($) { - - // ==================================================== - // -- Registers as a jQuery plugin - - $.fn.w2popup = function(method, options) { - if (method == null) { - options = {}; - method = 'open'; - } - if ($.isPlainObject(method)) { - options = method; - method = 'open'; - } - method = method.toLowerCase(); - if (method === 'load' && typeof options === 'string') { - options = $.extend({ url: options }, arguments.length > 2 ? arguments[2] : {}); - } - if (method === 'open' && options.url != null) method = 'load'; - options = options || {}; - // load options from markup - var dlgOptions = {}; - if ($(this).length > 0 && method == 'open') { - if ($(this).find('div[rel=title], div[rel=body], div[rel=buttons]').length > 0) { - // remember previous tempalte - if ($('#w2ui-popup').length > 0) { - var tmp = $('#w2ui-popup').data('options'); - w2popup._prev = { - template : w2popup._template, - title : tmp.title, - body : tmp.body, - buttons : tmp.buttons - }; - } - w2popup._template = this; - - if ($(this).find('div[rel=title]').length > 0) { - dlgOptions['title'] = $(this).find('div[rel=title]'); - } - if ($(this).find('div[rel=body]').length > 0) { - dlgOptions['body'] = $(this).find('div[rel=body]'); - dlgOptions['style'] = $(this).find('div[rel=body]')[0].style.cssText; - } - if ($(this).find('div[rel=buttons]').length > 0) { - dlgOptions['buttons'] = $(this).find('div[rel=buttons]'); - } - } else { - dlgOptions['title'] = ' '; - dlgOptions['body'] = $(this).html(); - } - if (parseInt($(this).css('width')) !== 0) dlgOptions['width'] = parseInt($(this).css('width')); - //if the popup will have a title bar, we must add the height of title bar to the popup height - var hasTitlebar = options.title || (options.showClose || options.showClose === undefined) || (options.showMax || options.showMax === undefined) ; - if (parseInt($(this).css('height')) !== 0) dlgOptions['height'] = parseInt($(this).css('height')) + (hasTitlebar?32:0); - } - // show popup - return w2popup[method]($.extend({}, dlgOptions, options)); - }; - - // ==================================================== - // -- Implementation of core functionality (SINGLETON) - - w2popup = { - defaults: { - title : '', - body : '', - buttons : '', - style : '', - color : '#000', - opacity : 0.4, - speed : 0.3, - modal : false, - maximized : false, - keyboard : true, // will close popup on esc if not modal - width : 500, - height : 300, - showClose : true, - showMax : false, - transition: null, - multiple : false // if popup already open, opens as a message - }, - status : 'closed', // string that describes current status - handlers : [], - onOpen : null, - onClose : null, - onMax : null, - onMin : null, - onToggle : null, - onKeydown : null, - - open: function (options) { - var obj = this; - var orig_options = $.extend(true, {}, options); - if (w2popup.status == 'closing') { - setTimeout(function () { obj.open.call(obj, options); }, 100); - return; - } - // get old options and merge them - var old_options = $('#w2ui-popup').data('options'); - var options = $.extend({}, this.defaults, old_options, { title: '', body : '', buttons: '' }, options, { maximized: false }); - // need timer because popup might not be open - setTimeout(function () { $('#w2ui-popup').data('options', options); }, 100); - // if new - reset event handlers - if ($('#w2ui-popup').length === 0) { - // w2popup.handlers = []; // if commented, allows to add w2popup.on() for all - w2popup.onMax = null; - w2popup.onMin = null; - w2popup.onToggle = null; - w2popup.onOpen = null; - w2popup.onClose = null; - w2popup.onKeydown = null; - w2popup.onAction = null; - } - if (options.onOpen) w2popup.onOpen = options.onOpen; - if (options.onClose) w2popup.onClose = options.onClose; - if (options.onMax) w2popup.onMax = options.onMax; - if (options.onMin) w2popup.onMin = options.onMin; - if (options.onToggle) w2popup.onToggle = options.onToggle; - if (options.onKeydown) w2popup.onKeydown = options.onKeydown; - if (options.onAction) w2popup.onAction = options.onAction; - options.width = parseInt(options.width); - options.height = parseInt(options.height); - - var maxW, maxH; - if (window.innerHeight == undefined) { - maxW = parseInt(document.documentElement.offsetWidth); - maxH = parseInt(document.documentElement.offsetHeight); - if (w2utils.engine === 'IE7') { maxW += 21; maxH += 4; } - } else { - maxW = parseInt(window.innerWidth); - maxH = parseInt(window.innerHeight); - } - if (maxW - 10 < options.width) options.width = maxW - 10; - if (maxH - 10 < options.height) options.height = maxH - 10; - var top = (maxH - options.height) / 2 * 0.6; - var left = (maxW - options.width) / 2; - - // convert action arrays into buttons - if (options.actions != null) { - options.buttons = ''; - Object.keys(options.actions).forEach(function (action) { - var handler = options.actions[action]; - if (typeof handler == 'function') { - options.buttons += '' - } - if (typeof handler == 'object') { - options.buttons += '' - } - if (typeof handler == 'string') { - options.buttons += handler - } - }); - } - - // check if message is already displayed - if ($('#w2ui-popup').length === 0) { - // trigger event - var edata = this.trigger({ phase: 'before', type: 'open', target: 'popup', options: options, present: false }); - if (edata.isCancelled === true) return; - w2popup.status = 'opening'; - // output message - w2popup.lockScreen(options); - var btn = ''; - if (options.showClose) { - btn += '
Close
'; - } - if (options.showMax) { - btn += '
Max
'; - } - // first insert just body - var msg = '
'; - $('body').append(msg); - // parse rel=* - var parts = $('#w2ui-popup'); - if (parts.find('div[rel=title], div[rel=body], div[rel=buttons]').length > 0) { - // title - var tmp = parts.find('div[rel=title]'); - if (tmp.length > 0) { options.title = tmp.html(); tmp.remove(); } - // buttons - var tmp = parts.find('div[rel=buttons]'); - if (tmp.length > 0) { options.buttons = tmp.html(); tmp.remove(); } - // body - var tmp = parts.find('div[rel=body]'); - if (tmp.length > 0) options.body = tmp.html(); else options.body = parts.html(); - } - // then content - var msg = '
' + btn + '
'+ - '
'+ - '
' + - '
'+ - '
'+ - '
'+ - ''; // this is needed to keep focus in popup - $('#w2ui-popup').html(msg); - - if (options.title) $('#w2ui-popup .w2ui-popup-title').append(options.title); - if (options.buttons) $('#w2ui-popup .w2ui-popup-buttons').append(options.buttons); - if (options.body) $('#w2ui-popup .w2ui-popup-body').append(options.body); - - // allow element to render - setTimeout(function () { - $('#w2ui-popup') - .css(w2utils.cssPrefix({ - 'transition': options.speed + 's opacity, ' + options.speed + 's -webkit-transform' - })) - .removeClass("w2ui-popup-opening"); - obj.focus(); - }, 1); - // clean transform - setTimeout(function () { - $('#w2ui-popup').css(w2utils.cssPrefix('transform', '')); - }, options.speed * 1000); - // event after - w2popup.status = 'open'; - obj.trigger($.extend(edata, { phase: 'after' })); - - } else if (options.multiple === true) { - // popup is not compatible with w2popup.message - w2popup.message(orig_options) - } else { - // if was from template and now not - if (w2popup._prev == null && w2popup._template != null) obj.restoreTemplate(); - - // trigger event - var edata = this.trigger({ phase: 'before', type: 'open', target: 'popup', options: options, present: true }); - if (edata.isCancelled === true) return; - // check if size changed - w2popup.status = 'opening'; - if (old_options != null) { - if (!old_options.maximized && (old_options['width'] != options['width'] || old_options['height'] != options['height'])) { - w2popup.resize(options.width, options.height); - } - options.prevSize = options.width + 'px:' + options.height + 'px'; - options.maximized = old_options.maximized; - } - // show new items - var cloned = $('#w2ui-popup .w2ui-box').clone(); - cloned.removeClass('w2ui-box').addClass('w2ui-box-temp').find('.w2ui-popup-body').empty().append(options.body); - // parse rel=* - if (typeof options.body == 'string' && cloned.find('div[rel=title], div[rel=body], div[rel=buttons]').length > 0) { - // title - var tmp = cloned.find('div[rel=title]'); - if (tmp.length > 0) { options['title'] = tmp.html(); tmp.remove(); } - // buttons - var tmp = cloned.find('div[rel=buttons]'); - if (tmp.length > 0) { options['buttons'] = tmp.html(); tmp.remove(); } - // body - var tmp = cloned.find('div[rel=body]'); - if (tmp.length > 0) options['body'] = tmp.html(); else options['body'] = cloned.html(); - // set proper body - cloned.html(options.body); - } - $('#w2ui-popup .w2ui-box').after(cloned); - - if (options.buttons) { - $('#w2ui-popup .w2ui-popup-buttons').show().html('').append(options.buttons); - $('#w2ui-popup .w2ui-popup-body').removeClass('w2ui-popup-no-buttons'); - $('#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp').css('bottom', ''); - } else { - $('#w2ui-popup .w2ui-popup-buttons').hide().html(''); - $('#w2ui-popup .w2ui-popup-body').addClass('w2ui-popup-no-buttons'); - $('#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp').css('bottom', '0px'); - } - if (options.title) { - $('#w2ui-popup .w2ui-popup-title') - .show() - .html((options.showClose ? '
Close
' : '') + - (options.showMax ? '
Max
' : '')) - .append(options.title); - $('#w2ui-popup .w2ui-popup-body').removeClass('w2ui-popup-no-title'); - $('#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp').css('top', ''); - } else { - $('#w2ui-popup .w2ui-popup-title').hide().html(''); - $('#w2ui-popup .w2ui-popup-body').addClass('w2ui-popup-no-title'); - $('#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp').css('top', '0px'); - } - // transition - var div_old = $('#w2ui-popup .w2ui-box')[0]; - var div_new = $('#w2ui-popup .w2ui-box-temp')[0]; - w2utils.transition(div_old, div_new, options.transition, function () { - // clean up - obj.restoreTemplate(); - $(div_old).remove(); - $(div_new).removeClass('w2ui-box-temp').addClass('w2ui-box'); - var $body = $(div_new).find('.w2ui-popup-body'); - if ($body.length == 1) $body[0].style.cssText = options.style; - // remove max state - $('#w2ui-popup').data('prev-size', null); - // focus on first button - obj.focus(); - }); - // call event onOpen - w2popup.status = 'open'; - obj.trigger($.extend(edata, { phase: 'after' })); - } - - // save new options - options._last_focus = $(':focus'); - // keyboard events - if (options.keyboard) $(document).on('keydown', this.keydown); - - // initialize move - var tmp = { - resizing : false, - mvMove : mvMove, - mvStop : mvStop - }; - $('#w2ui-popup .w2ui-popup-title').on('mousedown', function (event) { - if (!w2popup.get().maximized) mvStart(event); - }); - - return this; - - // handlers - function mvStart(evnt) { - if (!evnt) evnt = window.event; - w2popup.status = 'moving'; - tmp.resizing = true; - tmp.isLocked = $('#w2ui-popup > .w2ui-lock').length == 1 ? true : false; - tmp.x = evnt.screenX; - tmp.y = evnt.screenY; - tmp.pos_x = $('#w2ui-popup').position().left; - tmp.pos_y = $('#w2ui-popup').position().top; - if (!tmp.isLocked) w2popup.lock({ opacity: 0 }); - $(document).on('mousemove', tmp.mvMove); - $(document).on('mouseup', tmp.mvStop); - if (evnt.stopPropagation) evnt.stopPropagation(); else evnt.cancelBubble = true; - if (evnt.preventDefault) evnt.preventDefault(); else return false; - } - - function mvMove(evnt) { - if (tmp.resizing != true) return; - if (!evnt) evnt = window.event; - tmp.div_x = evnt.screenX - tmp.x; - tmp.div_y = evnt.screenY - tmp.y; - // trigger event - var edata = w2popup.trigger({ phase: 'before', type: 'move', target: 'popup', div_x: tmp.div_x, div_y: tmp.div_y }); - if (edata.isCancelled === true) return; - // default behavior - $('#w2ui-popup').css(w2utils.cssPrefix({ - 'transition': 'none', - 'transform' : 'translate3d('+ tmp.div_x +'px, '+ tmp.div_y +'px, 0px)' - })); - // event after - w2popup.trigger($.extend(edata, { phase: 'after'})); - } - - function mvStop(evnt) { - if (tmp.resizing != true) return; - if (!evnt) evnt = window.event; - w2popup.status = 'open'; - tmp.div_x = (evnt.screenX - tmp.x); - tmp.div_y = (evnt.screenY - tmp.y); - $('#w2ui-popup').css({ - 'left': (tmp.pos_x + tmp.div_x) + 'px', - 'top' : (tmp.pos_y + tmp.div_y) + 'px' - }).css(w2utils.cssPrefix({ - 'transition': 'none', - 'transform' : 'translate3d(0px, 0px, 0px)' - })); - tmp.resizing = false; - $(document).off('mousemove', tmp.mvMove); - $(document).off('mouseup', tmp.mvStop); - if (!tmp.isLocked) w2popup.unlock(); - } - }, - - action: function (action, msgId) { - var obj = this; - var options = $('#w2ui-popup').data('options'); - if (msgId != null) { - options = $('#w2ui-message' + msgId).data('options'); - obj = { - parent: this, - options: options, - close: function () { - w2popup.message({ msgId: msgId }) - } - } - } - var act = options.actions[action]; - var click = act; - if ($.isPlainObject(act) && act.onClick) click = act.onClick; - // event before - var edata = this.trigger({ phase: 'before', target: action, msgId: msgId, type: 'action', action: act, originalEvent: event }); - if (edata.isCancelled === true) return; - // default actions - if (typeof click === 'function') click.call(obj, event); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - keydown: function (event) { - var options = $('#w2ui-popup').data('options'); - if (options && !options.keyboard) return; - // trigger event - var edata = w2popup.trigger({ phase: 'before', type: 'keydown', target: 'popup', options: options, originalEvent: event }); - if (edata.isCancelled === true) return; - // default behavior - switch (event.keyCode) { - case 27: - event.preventDefault(); - if ($('#w2ui-popup .w2ui-message').length > 0) w2popup.message(); else w2popup.close(); - break; - } - // event after - w2popup.trigger($.extend(edata, { phase: 'after'})); - }, - - close: function (options) { - var obj = this; - var options = $.extend({}, $('#w2ui-popup').data('options'), options); - if ($('#w2ui-popup').length === 0 || this.status == 'closed') return; - if (this.status == 'opening') { - setTimeout(function () { w2popup.close(); }, 100); - return; - } - // trigger event - var edata = this.trigger({ phase: 'before', type: 'close', target: 'popup', options: options }); - if (edata.isCancelled === true) return; - // default behavior - w2popup.status = 'closing'; - $('#w2ui-popup') - .css(w2utils.cssPrefix({ - 'transition': options.speed + 's opacity, ' + options.speed + 's -webkit-transform' - })) - .addClass("w2ui-popup-closing"); - w2popup.unlockScreen(options); - setTimeout(function () { - // return template - obj.restoreTemplate(); - $('#w2ui-popup').remove(); - w2popup.status = 'closed'; - // restore active - if (options._last_focus && options._last_focus.length > 0) options._last_focus.focus(); - // event after - obj.trigger($.extend(edata, { phase: 'after'})); - }, options.speed * 1000); - // remove keyboard events - if (options.keyboard) $(document).off('keydown', this.keydown); - }, - - toggle: function () { - var obj = this; - var options = $('#w2ui-popup').data('options'); - // trigger event - var edata = this.trigger({ phase: 'before', type: 'toggle', target: 'popup', options: options }); - if (edata.isCancelled === true) return; - // defatul action - if (options.maximized === true) w2popup.min(); else w2popup.max(); - // event after - setTimeout(function () { - obj.trigger($.extend(edata, { phase: 'after'})); - }, (options.speed * 1000) + 50); - }, - - max: function () { - var obj = this; - var options = $('#w2ui-popup').data('options'); - if (options.maximized === true) return; - // trigger event - var edata = this.trigger({ phase: 'before', type: 'max', target: 'popup', options: options }); - if (edata.isCancelled === true) return; - // default behavior - w2popup.status = 'resizing'; - options.prevSize = $('#w2ui-popup').css('width') + ':' + $('#w2ui-popup').css('height'); - // do resize - w2popup.resize(10000, 10000, function () { - w2popup.status = 'open'; - options.maximized = true; - obj.trigger($.extend(edata, { phase: 'after'})); - // resize gird, form, layout inside popup - $('#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout').each(function () { - var name = $(this).attr('name'); - if (w2ui[name] && w2ui[name].resize) w2ui[name].resize(); - }) - }); - }, - - min: function () { - var obj = this; - var options = $('#w2ui-popup').data('options'); - if (options.maximized !== true) return; - var size = options.prevSize.split(':'); - // trigger event - var edata = this.trigger({ phase: 'before', type: 'min', target: 'popup', options: options }); - if (edata.isCancelled === true) return; - // default behavior - w2popup.status = 'resizing'; - // do resize - w2popup.resize(parseInt(size[0]), parseInt(size[1]), function () { - w2popup.status = 'open'; - options.maximized = false; - options.prevSize = null; - obj.trigger($.extend(edata, { phase: 'after'})); - // resize gird, form, layout inside popup - $('#w2ui-popup .w2ui-grid, #w2ui-popup .w2ui-form, #w2ui-popup .w2ui-layout').each(function () { - var name = $(this).attr('name'); - if (w2ui[name] && w2ui[name].resize) w2ui[name].resize(); - }) - }); - }, - - get: function () { - return $('#w2ui-popup').data('options'); - }, - - set: function (options) { - w2popup.open(options); - }, - - clear: function() { - $('#w2ui-popup .w2ui-popup-title').html(''); - $('#w2ui-popup .w2ui-popup-body').html(''); - $('#w2ui-popup .w2ui-popup-buttons').html(''); - }, - - Reset() { - w2popup.open(w2popup.defaults); - }, - - load: function (options) { - w2popup.status = 'loading'; - if (options.url == null) { - console.log('ERROR: The url parameter is empty.'); - return; - } - var tmp = String(options.url).split('#'); - var url = tmp[0]; - var selector = tmp[1]; - if (options == null) options = {}; - // load url - var html = $('#w2ui-popup').data(url); - if (html != null) { - popup(html, selector); - } else { - $.get(url, function (data, status, obj) { // should always be $.get as it is template - popup(obj.responseText, selector); - $('#w2ui-popup').data(url, obj.responseText); // remember for possible future purposes - }); - } - function popup(html, selector) { - delete options.url; - $('body').append(''); - if (selector != null && $('#w2ui-tmp #'+selector).length > 0) { - $('#w2ui-tmp #' + selector).w2popup(options); - } else { - $('#w2ui-tmp > div').w2popup(options); - } - // link styles - if ($('#w2ui-tmp > style').length > 0) { - var style = $('
').append($('#w2ui-tmp > style').clone()).html(); - if ($('#w2ui-popup #div-style').length === 0) { - $('#w2ui-popup').append('
'); - } - $('#w2ui-popup #div-style').html(style); - } - $('#w2ui-tmp').remove(); - } - }, - - message: function (options) { - var obj = this; - $().w2tag(); // hide all tags - if (!options) options = { width: 200, height: 100 }; - var pWidth = parseInt($('#w2ui-popup').width()); - var pHeight = parseInt($('#w2ui-popup').height()); - options.originalWidth = options.width; - options.originalHeight = options.height; - if (parseInt(options.width) < 10) options.width = 10; - if (parseInt(options.height) < 10) options.height = 10; - if (options.hideOnClick == null) options.hideOnClick = false; - var poptions = $('#w2ui-popup').data('options') || {}; - var titleHeight = parseInt($('#w2ui-popup > .w2ui-popup-title').css('height')); - if (options.width == null || options.width > poptions.width - 10) { - options.width = poptions.width - 10; - } - if (options.height == null || options.height > poptions.height - titleHeight - 5) { - options.height = poptions.height - titleHeight - 5; // need margin from bottom only - } - // negative value means margin - if (options.originalHeight < 0) options.height = pHeight + options.originalHeight - titleHeight; - if (options.originalWidth < 0) options.width = pWidth + options.originalWidth * 2; // x 2 because there is left and right margin - - var head = $('#w2ui-popup .w2ui-popup-title'); - var msgCount = $('#w2ui-popup .w2ui-message').length; - - // convert action arrays into buttons - if (options.actions != null) { - options.buttons = ''; - Object.keys(options.actions).forEach(function (action) { - var handler = options.actions[action]; - if (typeof handler == 'function') { - options.buttons += '' - } - if (typeof handler == 'object') { - options.buttons += '' - } - if (typeof handler == 'string') { - options.buttons += handler - } - }); - } - - // remove message - if ($.trim(options.html) === '' && $.trim(options.body) === '' && $.trim(options.buttons) === '') { - var $msg = $('#w2ui-popup .w2ui-message').last(); - if (options.msgId != null) { - $msg = $('#w2ui-message'+ options.msgId); - } - var options = $msg.data('options') || {}; - // message close event - var edata = obj.trigger({ phase: 'before', type: 'msgClose', msgId: $msg.attr('data-msgId'), target: 'popup', options: options }); - if (edata.isCancelled === true) return; - // start hide transition - $msg.css(w2utils.cssPrefix({ - 'transition': '0.15s', - 'transform': 'translateY(-' + options.height + 'px)' - })); - var $focus = $('#w2ui-popup .w2ui-message'); - $focus = $($focus[$focus.length - 2]) - .css('z-index', 1500) - .data('msg-focus'); - if ($focus && $focus.length > 0) $focus.focus(); else obj.focus(); - if (msgCount == 1) w2popup.unlock(150); - setTimeout(function () { - $msg.remove(); - // default action - if (typeof options.onClose == 'function') { - options.onClose(edata); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }, 150); - } else { - if ($.trim(options.body) !== '' || $.trim(options.buttons) !== '') { - options.html = '
'+ options.body +'
'+ - '
'+ options.buttons +'
'; - } - // hide previous messages - $('#w2ui-popup .w2ui-message').css('z-index', 1390).data('msg-focus', $(':focus')); - head.css('z-index', 1501); - if (options.close == null) { - options.close = function () { - w2popup.message({ msgId: msgCount }) - } - } - // add message - $('#w2ui-popup .w2ui-box') - .before(''); - $('#w2ui-popup #w2ui-message'+ msgCount).data('options', options); - var display = $('#w2ui-popup #w2ui-message'+ msgCount).css('display'); - $('#w2ui-popup #w2ui-message'+ msgCount).css(w2utils.cssPrefix({ - 'transform': (display == 'none' ? 'translateY(-' + options.height + 'px)' : 'translateY(0px)') - })); - if (display == 'none') { - $('#w2ui-popup #w2ui-message'+ msgCount).show().html(options.html); - // timer needs to animation - setTimeout(function () { - $('#w2ui-popup #w2ui-message'+ msgCount).css( - $.extend( - w2utils.cssPrefix('transition', '.3s', false), - w2utils.cssPrefix({ - 'transform': (display == 'none' ? 'translateY(0px)' : 'translateY(-' + options.height + 'px)') - }) - ) - ); - }, 1); - // timer for lock - if (msgCount === 0) w2popup.lock(); - // message open event - var edata = obj.trigger({ phase: 'before', type: 'msgOpen', msgId: msgCount, target: 'popup', options: options }); - if (edata.isCancelled === true) return; - setTimeout(function() { - obj.focus(); - // has to be on top of lock - $('#w2ui-popup #w2ui-message'+ msgCount).css(w2utils.cssPrefix({ 'transition': '0s' })); - if (typeof options.onOpen == 'function') { - options.onOpen(edata); - } - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }, 350); - } - } - }, - - focus: function () { - var tmp = null; - var pop = $('#w2ui-popup'); - var sel = 'input:visible, button:visible, select:visible, textarea:visible, [contentEditable], .w2ui-input'; - // clear previous blur - $(pop).find(sel).off('.keep-focus'); - // in message or popup - var cnt = $('#w2ui-popup .w2ui-message').length - 1; - var msg = $('#w2ui-popup #w2ui-message' + cnt); - if (msg.length > 0) { - var btn =$(msg[msg.length - 1]).find('button'); - if (btn.length > 0) btn[0].focus(); - tmp = msg; - } else if (pop.length > 0) { - var btn = pop.find('.w2ui-popup-buttons button'); - if (btn.length > 0) btn[0].focus(); - tmp = pop; - } - // keep focus/blur inside popup - $(tmp).find(sel) - .on('blur.keep-focus', function (event) { - setTimeout(function () { - var focus = $(':focus'); - if ((focus.length > 0 && !$(tmp).find(sel).is(focus)) || focus.hasClass('w2ui-popup-hidden')) { - var el = $(tmp).find(sel); - if (el.length > 0) el[0].focus(); - } - }, 1); - }); - }, - - lock: function (msg, showSpinner) { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift($('#w2ui-popup')); - w2utils.lock.apply(window, args); - }, - - unlock: function (speed) { - w2utils.unlock($('#w2ui-popup'), speed); - }, - - // --- INTERNAL FUNCTIONS - - lockScreen: function (options) { - if ($('#w2ui-lock').length > 0) return false; - if (options == null) options = $('#w2ui-popup').data('options'); - if (options == null) options = {}; - options = $.extend({}, w2popup.defaults, options); - // show element - $('body').append('
'); - // lock screen - setTimeout(function () { - $('#w2ui-lock') - .css('opacity', options.opacity) - .css(w2utils.cssPrefix('transition', options.speed + 's opacity')); - }, 1); - // add events - if (options.modal == true) { - $('#w2ui-lock').on('mousedown', function () { - $('#w2ui-lock') - .css('opacity', '0.6') - .css(w2utils.cssPrefix('transition', '.1s')); - }); - $('#w2ui-lock').on('mouseup', function () { - setTimeout(function () { - $('#w2ui-lock') - .css('opacity', options.opacity) - .css(w2utils.cssPrefix('transition', '.1s')); - }, 100); - }); - } else { - $('#w2ui-lock').on('mousedown', function () { w2popup.close(); }); - } - return true; - }, - - unlockScreen: function (options) { - if ($('#w2ui-lock').length === 0) return false; - if (options == null) options = $('#w2ui-popup').data('options'); - if (options == null) options = {}; - options = $.extend({}, w2popup.defaults, options); - $('#w2ui-lock') - .css('opacity', '0') - .css(w2utils.cssPrefix('transition', options.speed + 's opacity')); - setTimeout(function () { - $('#w2ui-lock').remove(); - }, options.speed * 1000); - return true; - }, - - resizeMessages: function () { - var obj = this; - var options = $('#w2ui-popup').data('options'); - // see if there are messages and resize them - $('#w2ui-popup .w2ui-message').each(function () { - var moptions = $(this).data('options'); - var $popup = $('#w2ui-popup'); - if (parseInt(moptions.width) < 10) moptions.width = 10; - if (parseInt(moptions.height) < 10) moptions.height = 10; - var titleHeight = parseInt($popup.find('> .w2ui-popup-title').css('height')); - var pWidth = parseInt($popup.width()); - var pHeight = parseInt($popup.height()); - // recalc width - moptions.width = moptions.originalWidth; - if (moptions.width > pWidth - 10) { - moptions.width = pWidth - 10; - } - // recalc height - moptions.height = moptions.originalHeight; - if (moptions.height > pHeight - titleHeight - 5) { - moptions.height = pHeight - titleHeight - 5; - } - if (moptions.originalHeight < 0) moptions.height = pHeight + moptions.originalHeight - titleHeight; - if (moptions.originalWidth < 0) moptions.width = pWidth + moptions.originalWidth * 2; // x 2 because there is left and right margin - $(this).css({ - left : ((pWidth - moptions.width) / 2) + 'px', - width : moptions.width + 'px', - height : moptions.height + 'px' - }); - }); - }, - - resize: function (width, height, callBack) { - var obj = this; - var options = $('#w2ui-popup').data('options') || {}; - if (options.speed == null) options.speed = 0; - width = parseInt(width); - height = parseInt(height); - // calculate new position - var maxW, maxH; - if (window.innerHeight == undefined) { - maxW = parseInt(document.documentElement.offsetWidth); - maxH = parseInt(document.documentElement.offsetHeight); - if (w2utils.engine === 'IE7') { maxW += 21; maxH += 4; } - } else { - maxW = parseInt(window.innerWidth); - maxH = parseInt(window.innerHeight); - } - if (maxW - 10 < width) width = maxW - 10; - if (maxH - 10 < height) height = maxH - 10; - var top = (maxH - height) / 2 * 0.6; - var left = (maxW - width) / 2; - // resize there - $('#w2ui-popup') - .css(w2utils.cssPrefix({ - 'transition': options.speed + 's width, ' + options.speed + 's height, ' + options.speed + 's left, ' + options.speed + 's top' - })) - .css({ - 'top' : top, - 'left' : left, - 'width' : width, - 'height': height - }); - var tmp_int = setInterval(function () { obj.resizeMessages(); }, 10); // then messages resize nicely - setTimeout(function () { - clearInterval(tmp_int); - options.width = width; - options.height = height; - obj.resizeMessages(); - if (typeof callBack == 'function') callBack(); - }, (options.speed * 1000) + 50); // give extra 50 ms - }, - - /*********************** - * Internal - **/ - - // restores template - restoreTemplate: function () { - var options = $('#w2ui-popup').data('options'); - if (options == null) return; - var template = w2popup._template; - var title = options.title; - var body = options.body; - var buttons = options.buttons; - if (w2popup._prev) { - template = w2popup._prev.template; - title = w2popup._prev.title; - body = w2popup._prev.body; - buttons = w2popup._prev.buttons; - delete w2popup._prev; - } else { - delete w2popup._template; - } - if (template != null) { - var $tmp = $(template); - if ($tmp.length === 0) return; - if ($(body).attr('rel') == 'body') { - if (title) $tmp.append(title); - if (body) $tmp.append(body); - if (buttons) $tmp.append(buttons); - } else { - $tmp.append(body); - } - } - } - }; - - // merge in event handling - $.extend(w2popup, w2utils.event); - -})(jQuery); - -// ============================================ -// --- Common dialogs - -var w2alert = function (msg, title, callBack) { - var $ = jQuery; - if (title == null) title = w2utils.lang('Notification'); - if ($('#w2ui-popup').length > 0 && w2popup.status != 'closing') { - w2popup.message({ - width : 400, - height : 170, - body : '
' + msg + '
', - buttons : '', - onOpen: function () { - $('#w2ui-popup .w2ui-message .w2ui-popup-btn').focus(); - }, - onClose: function () { - if (typeof callBack == 'function') callBack(); - } - }); - } else { - w2popup.open({ - width : 450, - height : 220, - showMax : false, - showClose : false, - title : title, - body : '
' + msg + '
', - buttons : '', - onOpen: function (event) { - // do not use onComplete as it is slower - setTimeout(function () { $('#w2ui-popup .w2ui-popup-btn').focus(); }, 1); - }, - onKeydown: function (event) { - $('#w2ui-popup .w2ui-popup-btn').focus().addClass('clicked'); - }, - onClose: function () { - if (typeof callBack == 'function') callBack(); - } - }); - } - return { - ok: function (fun) { - callBack = fun; - return this; - }, - done: function (fun) { - callBack = fun; - return this; - } - }; -}; - -var w2confirm = function (msg, title, callBack) { - var $ = jQuery; - var options = {}; - var defaults = { - msg : '', - title : w2utils.lang('Confirmation'), - width : ($('#w2ui-popup').length > 0 ? 400 : 450), - height : ($('#w2ui-popup').length > 0 ? 170 : 220), - yes_text : 'Yes', - yes_class : '', - yes_style : '', - yes_callBack: null, - no_text : 'No', - no_class : '', - no_style : '', - no_callBack : null, - focus_to_no : false, - callBack : null - }; - if (arguments.length == 1 && typeof msg == 'object') { - $.extend(options, defaults, msg); - } else { - if (typeof title == 'function') { - $.extend(options, defaults, { - msg : msg, - callBack: title - }) - } else { - $.extend(options, defaults, { - msg : msg, - title : title, - callBack: callBack - }) - } - } - // if there is a yes/no button object - if (typeof options.btn_yes == 'object') { - options.yes_text = options.btn_yes.text || options.yes_text; - options.yes_class = options.btn_yes["class"] || options.yes_class; - options.yes_style = options.btn_yes.style || options.yes_style; - options.yes_callBack = options.btn_yes.callBack || options.yes_callBack; - } - if (typeof options.btn_no == 'object') { - options.no_text = options.btn_no.text || options.no_text; - options.no_class = options.btn_no["class"] || options.no_class; - options.no_style = options.btn_no.style || options.no_style; - options.no_callBack = options.btn_no.callBack || options.no_callBack; - } - if ($('#w2ui-popup').length > 0 && w2popup.status != 'closing' && w2popup.get()) { - if (options.width > w2popup.get().width) options.width = w2popup.get().width; - if (options.height > (w2popup.get().height - 50)) options.height = w2popup.get().height - 50; - w2popup.message({ - width : options.width, - height : options.height, - body : '
' + options.msg + '
', - buttons : (w2utils.settings.macButtonOrder - ? '' + - '' - : '' + - '' - ), - onOpen: function (event) { - $('#w2ui-popup .w2ui-message .w2ui-btn').on('click.w2confirm', function (event) { - w2popup._confirm_btn = event.target.id; - w2popup.message(); - }); - if (typeof options.onOpen == 'function') options.onOpen() - }, - onClose: function (event) { - // needed this because there might be other messages - $('#w2ui-popup .w2ui-message .w2ui-btn').off('click.w2confirm'); - // need to wait for message to slide up - setTimeout(function () { - if (typeof options.callBack == 'function') options.callBack(w2popup._confirm_btn); - if (w2popup._confirm_btn == 'Yes' && typeof options.yes_callBack == 'function') options.yes_callBack(); - if (w2popup._confirm_btn == 'No' && typeof options.no_callBack == 'function') options.no_callBack(); - }, 300); - if (typeof options.onClose == 'function') options.onClose() - } - // onKeydown will not work here - }); - - } else { - - if (!w2utils.isInt(options.height)) options.height = options.height + 50; - w2popup.open({ - width : options.width, - height : options.height, - title : options.title, - modal : true, - showClose : false, - body : '
' + options.msg + '
', - buttons : (w2utils.settings.macButtonOrder - ? '' + - '' - : '' + - '' - ), - onOpen: function (event) { - // do not use onComplete as it is slower - setTimeout(function () { - $('#w2ui-popup .w2ui-popup-btn').on('click', function (event) { - w2popup.close(); - if (typeof options.callBack == 'function') options.callBack(event.target.id); - if (event.target.id == 'Yes' && typeof options.yes_callBack == 'function') options.yes_callBack(); - if (event.target.id == 'No' && typeof options.no_callBack == 'function') options.no_callBack(); - }); - if(options.focus_to_no){ - $('#w2ui-popup .w2ui-popup-btn#No').focus(); - }else{ - $('#w2ui-popup .w2ui-popup-btn#Yes').focus(); - } - if (typeof options.onOpen == 'function') options.onOpen() - }, 1); - }, - onClose: function (event) { - if (typeof options.onClose == 'function') options.onClose() - }, - onKeydown: function (event) { - // if there are no messages - if ($('#w2ui-popup .w2ui-message').length === 0) { - switch (event.originalEvent.keyCode) { - case 13: // enter - $('#w2ui-popup .w2ui-popup-btn#Yes').focus().addClass('clicked'); // no need fo click as enter will do click - w2popup.close(); - break; - case 27: // esc - $('#w2ui-popup .w2ui-popup-btn#No').focus().click(); - w2popup.close(); - break; - } - } - } - }); - } - - return { - yes: function (fun) { - options.yes_callBack = fun; - return this; - }, - no: function (fun) { - options.no_callBack = fun; - return this; - } - }; -}; - -var w2prompt = function (label, title, callBack) { - var $ = jQuery; - var options = {}; - var defaults = { - title : w2utils.lang('Notification'), - width : ($('#w2ui-popup').length > 0 ? 400 : 450), - height : ($('#w2ui-popup').length > 0 ? 170 : 220), - label : '', - value : '', - attrs : '', - textarea : false, - ok_text : w2utils.lang('Ok'), - ok_class : '', - cancel_text : w2utils.lang('Cancel'), - cancel_class: '', - callBack : null, - onOpen : null, - onClose : null - } - w2popup.tmp = w2popup.tmp || {} - - if (arguments.length == 1 && typeof label == 'object') { - $.extend(options, defaults, label); - } else { - if (typeof title == 'function') { - $.extend(options, defaults, { - label : label, - callBack: title - }) - } else { - $.extend(options, defaults, { - label : label, - title : title, - callBack: callBack - }) - } - } - - if ($('#w2ui-popup').length > 0 && w2popup.status != 'closing' && w2popup.get()) { - if (options.width > w2popup.get().width) options.width = w2popup.get().width; - if (options.height > (w2popup.get().height - 50)) options.height = w2popup.get().height - 50; - w2popup.message({ - width : options.width, - height : options.height, - body : (options.textarea - ? '
'+ - '
' + options.label + '
'+ - ' '+ - '
' - : '
'+ - ' '+ - ' '+ - '
' - ), - buttons : (w2utils.settings.macButtonOrder - ? '' + - '' - : '' + - '' - ), - onOpen: function () { - $('#w2prompt').val(options.value).off('.w2prompt').on('keydown.w2prompt', function(event) { - if (event.keyCode == 13) { - $('#w2ui-popup .w2ui-message .w2ui-btn#Ok').click() - } - }); - $('#w2ui-popup .w2ui-message .w2ui-btn#Ok').off('.w2prompt').on('click.w2prompt', function (event) { - w2popup.tmp.btn = 'ok'; - w2popup.tmp.value = $('#w2prompt').val(); - w2popup.message(); - }); - $('#w2ui-popup .w2ui-message .w2ui-btn#Cancel').off('.w2prompt').on('click.w2prompt', function (event) { - w2popup.tmp.btn = 'cancel'; - w2popup.tmp.value = null; - w2popup.message(); - }); - // set focus - setTimeout(function () { $('#w2prompt').focus(); }, 100); - // some event - if (typeof options.onOpen == 'function') options.onOpen() - }, - onClose: function () { - // needed this because there might be other messages - $('#w2ui-popup .w2ui-message .w2ui-btn').off('click.w2prompt'); - // need to wait for message to slide up - setTimeout(function () { - btnClick(w2popup.tmp.btn, w2popup.tmp.value); - }, 300); - // some event - if (typeof options.onClose == 'function') options.onClose() - } - // onKeydown will not work here - }); - - } else { - - if (!w2utils.isInt(options.height)) options.height = options.height + 50; - w2popup.open({ - width : options.width, - height : options.height, - title : options.title, - modal : true, - showClose : false, - body : (options.textarea - ? '
'+ - '
' + options.label + '
'+ - ' '+ - '
' - : '
'+ - ' '+ - ' '+ - '
' - ), - buttons : (w2utils.settings.macButtonOrder - ? '' + - '' - : ''+ - '' - ), - onOpen: function (event) { - // do not use onComplete as it is slower - setTimeout(function () { - $('#w2prompt').val(options.value); - $('#w2prompt').w2field('text'); - $('#w2ui-popup .w2ui-popup-btn#Ok').on('click', function (event) { - w2popup.tmp.btn = 'ok'; - w2popup.tmp.value = $('#w2prompt').val(); - w2popup.close(); - }); - $('#w2ui-popup .w2ui-popup-btn#Cancel').on('click', function (event) { - w2popup.tmp.btn = 'cancel'; - w2popup.tmp.value = null; - w2popup.close(); - }); - $('#w2ui-popup .w2ui-popup-btn#Ok'); - // set focus - setTimeout(function () { $('#w2prompt').focus(); }, 100); - // some event - if (typeof options.onOpen == 'function') options.onOpen() - }, 1); - }, - onClose: function (event) { - // some event - btnClick(w2popup.tmp.btn, w2popup.tmp.value); - if (typeof options.onClose == 'function') options.onClose() - }, - onKeydown: function (event) { - // if there are no messages - if ($('#w2ui-popup .w2ui-message').length === 0) { - switch (event.originalEvent.keyCode) { - case 13: // enter - $('#w2ui-popup .w2ui-popup-btn#Ok').focus().addClass('clicked'); // no need fo click as enter will do click - break; - case 27: // esc - w2popup.tmp.btn = 'cancel'; - w2popup.tmp.value = null; - break; - } - } - } - }); - } - function btnClick(btn, value) { - if (btn == 'ok' && typeof options.ok_callBack == 'function') { - options.ok_callBack(value) - } - if (btn == 'cancel' && typeof options.cancel_callBack == 'function') { - options.cancel_callBack(value) - } - if (typeof options.callBack == 'function') { - options.callBack(btn, value); - } - } - return { - change: function (fun) { - $('#w2prompt').on('keyup', fun).keyup(); - return this; - }, - ok: function (fun) { - options.ok_callBack = fun; - return this; - }, - cancel: function (fun) { - options.cancel_callBack = fun; - return this; - } - }; -}; - -/************************************************************************ -* Library: Web 2.0 UI for jQuery (using prototypical inheritance) -* - Following objects defined -* - w2tabs - tabs widget -* - $().w2tabs - jQuery wrapper -* - Dependencies: jQuery, w2utils -* -* == NICE TO HAVE == -* - align = left, right, center ?? -* -* == 1.5 changes == -* - tab.caption - deprecated -* - getTabHTML() -* - refactored with display: flex -* - reorder -* - initReorder -* - dragMove -* - tmp -* -************************************************************************/ - -(function ($) { - var w2tabs = function (options) { - this.box = null; // DOM Element that holds the element - this.name = null; // unique name for w2ui - this.active = null; - this.reorder = false; - this.flow = 'down'; // can be down or up - this.tooltip = 'top|left'; // can be top, bottom, left, right - this.tabs = []; - this.routeData = {}; // data for dynamic routes - this.tmp = {}; // placeholder for internal variables - this.right = ''; - this.style = ''; - - $.extend(this, { handlers: [] }); - $.extend(true, this, w2obj.tabs, options); - }; - - // ==================================================== - // -- Registers as a jQuery plugin - - $.fn.w2tabs = function(method) { - if ($.isPlainObject(method)) { - // check name parameter - if (!w2utils.checkName(method, 'w2tabs')) return; - // extend tabs - var tabs = method.tabs || []; - var object = new w2tabs(method); - for (var i = 0; i < tabs.length; i++) { - object.tabs[i] = $.extend({}, w2tabs.prototype.tab, tabs[i]); - } - // register new object - w2ui[object.name] = object; - // render - if ($(this).length !== 0) { - object.render($(this)[0]); - } - return object; - } else { - var obj = w2ui[$(this).attr('name')]; - if (!obj) return null; - if (arguments.length > 0) { - if (obj[method]) obj[method].apply(obj, Array.prototype.slice.call(arguments, 1)); - return this; - } else { - return obj; - } - } - }; - - // ==================================================== - // -- Implementation of core functionality - - w2tabs.prototype = { - onClick : null, - onClose : null, - onRender : null, - onRefresh : null, - onResize : null, - onDestroy : null, - - tab : { - id : null, // command to be sent to all event handlers - text : null, - route : null, - hidden : false, - disabled : false, - closable : false, - tooltip : null, - style : '', - onClick : null, - onRefresh : null, - onClose : null - }, - - add: function (tab) { - return this.insert(null, tab); - }, - - insert: function (id, tab) { - if (!$.isArray(tab)) tab = [tab]; - // assume it is array - for (var i = 0; i < tab.length; i++) { - // checks - if (tab[i].id == null) { - console.log('ERROR: The parameter "id" is required but not supplied. (obj: '+ this.name +')'); - return; - } - if (!w2utils.checkUniqueId(tab[i].id, this.tabs, 'tabs', this.name)) return; - // add tab - var newTab = $.extend({}, w2tabs.prototype.tab, tab[i]); - if (id == null) { - this.tabs.push(newTab); - } else { - var middle = this.get(id, true); - var before = this.tabs[middle].id - this.insertTabHTML(before, newTab) - } - } - }, - - remove: function () { - var removed = 0; - for (var a = 0; a < arguments.length; a++) { - var tab = this.get(arguments[a]); - if (!tab) return false; - removed++; - // remove from array - this.tabs.splice(this.get(tab.id, true), 1); - // remove from screen - $(this.box).find('#tabs_'+ this.name +'_tab_'+ w2utils.escapeId(tab.id)).remove(); - } - this.resize(); - return removed; - }, - - select: function (id) { - if (this.active == id || this.get(id) == null) return false; - this.active = id; - this.refresh(); - return true; - }, - - set: function (id, tab) { - var index = this.get(id, true); - if (index == null) return false; - $.extend(this.tabs[index], tab); - this.refresh(id); - return true; - }, - - get: function (id, returnIndex) { - if (arguments.length === 0) { - var all = []; - for (var i1 = 0; i1 < this.tabs.length; i1++) { - if (this.tabs[i1].id != null) { - all.push(this.tabs[i1].id); - } - } - return all; - } else { - for (var i2 = 0; i2 < this.tabs.length; i2++) { - if (this.tabs[i2].id == id) { // need to be == since id can be numeric - return (returnIndex === true ? i2 : this.tabs[i2]); - } - } - } - return null; - }, - - show: function () { - var obj = this; - var shown = 0; - var tmp = []; - for (var a = 0; a < arguments.length; a++) { - var tab = this.get(arguments[a]); - if (!tab || tab.hidden === false) continue; - shown++; - tab.hidden = false; - tmp.push(tab.id); - } - setTimeout(function () { for (var t=0; t
' - ); - helper = $(obj.el).prev(); - helper - .css({ - 'color' : $(obj.el).css('color'), - 'font-family' : $(obj.el).css('font-family'), - 'font-size' : $(obj.el).css('font-size'), - 'padding-top' : $(obj.el).css('padding-top'), - 'padding-bottom' : $(obj.el).css('padding-bottom'), - 'padding-left' : $(obj.el).css('padding-left'), - 'padding-right' : 0, - 'margin-top' : (parseInt($(obj.el).css('margin-top'), 10) + 2) + 'px', - 'margin-bottom' : (parseInt($(obj.el).css('margin-bottom'), 10) + 1) + 'px', - 'margin-left' : $(obj.el).css('margin-left'), - 'margin-right' : 0 - }) - .on('click', function (event) { - if (obj.options.icon && typeof obj.onIconClick === 'function') { - // event before - var edata = obj.trigger({ phase: 'before', type: 'iconClick', target: obj.el, el: $(this).find('span.w2ui-icon')[0] }); - if (edata.isCancelled === true) return; - - // intentionally empty - - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - } else { - if (obj.type === 'list') { - $(obj.helpers.focus).find('input').focus(); - } else { - $(obj.el).focus(); - } - } - }); - $(obj.el).css('padding-left', (helper.width() + parseInt($(obj.el).css('padding-left'), 10)) + 'px'); - // remember helper - obj.helpers.prefix = helper; - } - }, 1); - }, - - addSuffix: function () { - var obj = this; - var helper, pr; - setTimeout(function () { - if (obj.type === 'clear') return; - var tmp = $(obj.el).data('tmp') || {}; - if (tmp['old-padding-right']) $(obj.el).css('padding-right', tmp['old-padding-right']); - tmp['old-padding-right'] = $(obj.el).css('padding-right'); - $(obj.el).data('tmp', tmp); - pr = parseInt($(obj.el).css('padding-right'), 10); - if (obj.options.arrows) { - // remove if already displayed - if (obj.helpers.arrows) $(obj.helpers.arrows).remove(); - // add fresh - $(obj.el).after( - '
 '+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'); - helper = $(obj.el).next(); - helper.css({ - 'color' : $(obj.el).css('color'), - 'font-family' : $(obj.el).css('font-family'), - 'font-size' : $(obj.el).css('font-size'), - 'height' : ($(obj.el).height() + parseInt($(obj.el).css('padding-top'), 10) + parseInt($(obj.el).css('padding-bottom'), 10) ) + 'px', - 'padding' : 0, - 'margin-top' : (parseInt($(obj.el).css('margin-top'), 10) + 1) + 'px', - 'margin-bottom' : 0, - 'border-left' : '1px solid silver' - }) - .css('margin-left', '-'+ (helper.width() + parseInt($(obj.el).css('margin-right'), 10) + 12) + 'px') - .on('mousedown', function (event) { - var body = $('body'); - body.on('mouseup', tmp); - body.data('_field_update_timer', setTimeout(update, 700)); - update(false); - // timer function - function tmp() { - clearTimeout(body.data('_field_update_timer')); - body.off('mouseup', tmp); - } - // update function - function update(notimer) { - $(obj.el).focus(); - obj.keyDown($.Event("keydown"), { - keyCode : ($(event.target).attr('type') === 'up' ? 38 : 40) - }); - if (notimer !== false) $('body').data('_field_update_timer', setTimeout(update, 60)); - } - }); - pr += helper.width() + 12; - $(obj.el).css('padding-right', pr + 'px'); - // remember helper - obj.helpers.arrows = helper; - } - if (obj.options.suffix !== '') { - // remove if already displayed - if (obj.helpers.suffix) $(obj.helpers.suffix).remove(); - // add fresh - $(obj.el).after( - '
'+ - obj.options.suffix + - '
'); - helper = $(obj.el).next(); - helper - .css({ - 'color' : $(obj.el).css('color'), - 'font-family' : $(obj.el).css('font-family'), - 'font-size' : $(obj.el).css('font-size'), - 'padding-top' : $(obj.el).css('padding-top'), - 'padding-bottom' : $(obj.el).css('padding-bottom'), - 'padding-left' : '3px', - 'padding-right' : $(obj.el).css('padding-right'), - 'margin-top' : (parseInt($(obj.el).css('margin-top'), 10) + 2) + 'px', - 'margin-bottom' : (parseInt($(obj.el).css('margin-bottom'), 10) + 1) + 'px' - }) - .on('click', function (event) { - if (obj.type === 'list') { - $(obj.helpers.focus).find('input').focus(); - } else { - $(obj.el).focus(); - } - }); - - helper.css('margin-left', '-'+ (w2utils.getSize(helper, 'width') + parseInt($(obj.el).css('margin-right'), 10) + 2) + 'px'); - pr += helper.width() + 3; - $(obj.el).css('padding-right', pr + 'px'); - // remember helper - obj.helpers.suffix = helper; - } - }, 1); - }, - - addFocus: function () { - var obj = this; - var options = this.options; - var width = 0; // 11 - show search icon, 0 do not show - var pholder; - // clean up & init - $(obj.helpers.focus).remove(); - // remember original tabindex - var tabIndex = parseInt($(obj.el).attr('tabIndex')); - if (!isNaN(tabIndex) && tabIndex !== -1) obj.el._tabIndex = tabIndex; - if (obj.el._tabIndex) tabIndex = obj.el._tabIndex; - if (tabIndex == null) tabIndex = -1; - if (isNaN(tabIndex)) tabIndex = 0; - // if there is id, add to search with "_search" - var searchId = ''; - if ($(obj.el).attr('id') != null) { - searchId = 'id="' + $(obj.el).attr('id') + '_search"' - } - // build helper - var html = - '
'+ - ' '+ - ' '+ - '
'; - $(obj.el).attr('tabindex', -1).before(html); - var helper = $(obj.el).prev(); - obj.helpers.focus = helper; - helper.css({ - width : $(obj.el).width(), - "margin-top" : $(obj.el).css('margin-top'), - "margin-left" : (parseInt($(obj.el).css('margin-left')) + parseInt($(obj.el).css('padding-left'))) + 'px', - "margin-bottom" : $(obj.el).css('margin-bottom'), - "margin-right" : $(obj.el).css('margin-right') - }) - .find('input') - .css({ - cursor : 'default', - width : '100%', - outline : 'none', - opacity : 1, - margin : 0, - border : '1px solid transparent', - padding : $(obj.el).css('padding-top'), - "padding-left" : 0, - "margin-left" : (width > 0 ? width + 6 : 0), - "background-color" : 'transparent' - }); - // INPUT events - helper.find('input') - .on('click', function (event) { - if ($('#w2ui-overlay').length === 0) obj.focus(event); - event.stopPropagation(); - }) - .on('focus', function (event) { - pholder = $(obj.el).attr('placeholder'); - $(obj.el).css({ 'outline': 'auto 5px #7DB4F3', 'outline-offset': '2px' }); - $(this).val(''); - $(obj.el).triggerHandler('focus'); - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - }) - .on('blur', function (event) { - $(obj.el).css('outline', 'none'); - $(this).val(''); - obj.refresh(); - $(obj.el).triggerHandler('blur'); - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - if (pholder != null) $(obj.el).attr('placeholder', pholder); - }) - .on('keydown', function (event) { - var el = this; - obj.keyDown(event); - setTimeout(function () { - if (el.value === '') $(obj.el).attr('placeholder', pholder); else $(obj.el).attr('placeholder', ''); - }, 10); - }) - .on('keyup', function (event) { obj.keyUp(event); }) - .on('keypress', function (event) { obj.keyPress(event); }); - // MAIN div - helper.on('click', function (event) { $(this).find('input').focus(); }); - obj.refresh(); - }, - - addMulti: function () { - var obj = this; - var options = this.options; - // clean up & init - $(obj.helpers.multi).remove(); - // build helper - var html = ''; - var margin = - 'margin-top : 0px; ' + - 'margin-bottom : 0px; ' + - 'margin-left : ' + $(obj.el).css('margin-left') + '; ' + - 'margin-right : ' + $(obj.el).css('margin-right') + '; '+ - 'width : ' + (w2utils.getSize(obj.el, 'width') - - parseInt($(obj.el).css('margin-left'), 10) - - parseInt($(obj.el).css('margin-right'), 10)) - + 'px;'; - // if there is id, add to search with "_search" - var searchId = ''; - if ($(obj.el).attr('id') != null) { - searchId = 'id="' + $(obj.el).attr('id') + '_search" ' - } - if (obj.type === 'enum') { - // remember original tabindex - var tabIndex = $(obj.el).attr('tabIndex'); - if (tabIndex && tabIndex !== -1) obj.el._tabIndex = tabIndex; - if (obj.el._tabIndex) tabIndex = obj.el._tabIndex; - if (tabIndex == null) tabIndex = 0; // default tabindex - - html = '
'+ - '
'+ - '
    '+ - '
  • '+ - ' '+ - '
  • '+ - '
'+ - '
'+ - '
'; - } - if (obj.type === 'file') { - html = '
'+ - '
'+ - ' '+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'; - } - // old bg and border - var tmp = $(obj.el).data('tmp') || {}; - tmp['old-background-color'] = $(obj.el).css('background-color'); - tmp['old-border-color'] = $(obj.el).css('border-color'); - $(obj.el).data('tmp', tmp); - - $(obj.el) - .before(html) - .css({ - 'background-color' : 'transparent', - 'border-color' : 'transparent' - }); - - var div = $(obj.el).prev(); - obj.helpers.multi = div; - if (obj.type === 'enum') { - $(obj.el).attr('tabindex', -1); - // INPUT events - div.find('input') - .on('click', function (event) { - if ($('#w2ui-overlay').length === 0) obj.focus(event); - $(obj.el).triggerHandler('click'); - }) - .on('focus', function (event) { - $(div).css({ 'outline': 'auto 5px #7DB4F3', 'outline-offset': '2px' }); - $(obj.el).triggerHandler('focus'); - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - }) - .on('blur', function (event) { - $(div).css('outline', 'none'); - $(obj.el).triggerHandler('blur'); - if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; - }) - .on('keyup', function (event) { obj.keyUp(event); }) - .on('keydown', function (event) { obj.keyDown(event); }) - .on('keypress', function (event) { obj.keyPress(event); }); - // MAIN div - div.on('click', function (event) { $(this).find('input').focus(); }); - } - if (obj.type === 'file') { - $(obj.el).css('outline', 'none'); - div.find('input') - .off('.drag') - .on('click.drag', function (event) { - event.stopPropagation(); - if ($(obj.el).prop('readonly') || $(obj.el).prop('disabled')) return; - $(obj.el).focus(); - }) - .on('dragenter.drag', function (event) { - if ($(obj.el).prop('readonly') || $(obj.el).prop('disabled')) return; - $(div).addClass('w2ui-file-dragover'); - }) - .on('dragleave.drag', function (event) { - if ($(obj.el).prop('readonly') || $(obj.el).prop('disabled')) return; - $(div).removeClass('w2ui-file-dragover'); - }) - .on('drop.drag', function (event) { - if ($(obj.el).prop('readonly') || $(obj.el).prop('disabled')) return; - $(div).removeClass('w2ui-file-dragover'); - var files = event.originalEvent.dataTransfer.files; - for (var i = 0, l = files.length; i < l; i++) obj.addFile.call(obj, files[i]); - $(obj.el).focus(); - // cancel to stop browser behaviour - event.preventDefault(); - event.stopPropagation(); - }) - .on('dragover.drag', function (event) { - // cancel to stop browser behaviour - event.preventDefault(); - event.stopPropagation(); - }) - .on('change.drag', function () { - $(obj.el).focus(); - if (typeof this.files !== "undefined") { - for (var i = 0, l = this.files.length; i < l; i++) { - obj.addFile.call(obj, this.files[i]); - } - } - }); - } - obj.refresh(); - }, - - addFile: function (file) { - var obj = this; - var options = this.options; - var selected = $(obj.el).data('selected'); - var newItem = { - name : file.name, - type : file.type, - modified : file.lastModifiedDate, - size : file.size, - content : null, - file : file - }; - var size = 0; - var cnt = 0; - var err; - if (selected) { - for (var s = 0; s < selected.length; s++) { - // check for dups - if (selected[s].name == file.name && selected[s].size == file.size) return; - size += selected[s].size; - cnt++; - } - } - // trigger event - var edata = obj.trigger({ phase: 'before', type: 'add', target: obj.el, file: newItem, total: cnt, totalSize: size }); - if (edata.isCancelled === true) return; - // check params - if (options.maxFileSize !== 0 && newItem.size > options.maxFileSize) { - err = 'Maximum file size is '+ w2utils.formatSize(options.maxFileSize); - if (options.silent === false) $(obj.el).w2tag(err); - console.log('ERROR: '+ err); - return; - } - if (options.maxSize !== 0 && size + newItem.size > options.maxSize) { - err = w2utils.lang('Maximum total size is') + ' ' + w2utils.formatSize(options.maxSize); - if (options.silent === false) { - $(obj.el).w2tag(err); - } else { - console.log('ERROR: '+ err); - } - return; - } - if (options.max !== 0 && cnt >= options.max) { - err = w2utils.lang('Maximum number of files is') + ' '+ options.max; - if (options.silent === false) { - $(obj.el).w2tag(err); - } else { - console.log('ERROR: '+ err); - } - return; - } - selected.push(newItem); - // read file as base64 - if (typeof FileReader !== "undefined" && options.readContent === true) { - var reader = new FileReader(); - // need a closure - reader.onload = (function () { - return function (event) { - var fl = event.target.result; - var ind = fl.indexOf(','); - newItem.content = fl.substr(ind+1); - obj.refresh(); - $(obj.el).trigger('input').trigger('change'); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - }; - })(); - reader.readAsDataURL(file); - } else { - obj.refresh(); - $(obj.el).trigger('input').trigger('change'); - obj.trigger($.extend(edata, { phase: 'after' })); - } - }, - - normMenu: function (menu, el) { - if ($.isArray(menu)) { - for (var m = 0; m < menu.length; m++) { - if (typeof menu[m] === 'string') { - menu[m] = { id: menu[m], text: menu[m] }; - } else if (menu[m] != null) { - if (menu[m].text != null && menu[m].id == null) menu[m].id = menu[m].text; - if (menu[m].text == null && menu[m].id != null) menu[m].text = menu[m].id; - if (menu[m].caption != null) menu[m].text = menu[m].caption; - } else { - menu[m] = { id: null, text: 'null' } - } - } - return menu; - } else if (typeof menu === 'function') { - return w2obj.field.prototype.normMenu.call(this, menu.call(this, el)); - } else if (typeof menu === 'object') { - var tmp = []; - for (var m in menu) tmp.push({ id: m, text: menu[m] }); - return tmp; - } - }, - - getMonthHTML: function (month, year, selected) { - var td = new Date(); - var months = w2utils.settings.fullmonths; - var daysCount = ['31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31']; - var today = td.getFullYear() + '/' + (Number(td.getMonth()) + 1) + '/' + td.getDate(); - var days = w2utils.settings.fulldays.slice(); // creates copy of the array - var sdays = w2utils.settings.shortdays.slice(); // creates copy of the array - if (w2utils.settings.weekStarts !== 'M') { - days.unshift(days.pop()); - sdays.unshift(sdays.pop()); - } - var options = this.options; - if (options == null) options = {}; - // normalize date - year = w2utils.isInt(year) ? parseInt(year) : td.getFullYear(); - month = w2utils.isInt(month) ? parseInt(month) : td.getMonth() + 1; - if (month > 12) { month -= 12; year++; } - if (month < 1 || month === 0) { month += 12; year--; } - if (year/4 == Math.floor(year/4)) { daysCount[1] = '29'; } else { daysCount[1] = '28'; } - options.current = month + '/' + year; - - // start with the required date - td = new Date(year, month-1, 1); - var weekDay = td.getDay(); - var dayTitle = ''; - for (var i = 0; i < sdays.length; i++) dayTitle += '' + sdays[i] + ''; - - var html = - '
'+ - ' '+ - ' '+ - months[month-1] +', '+ year + - '
'+ - ''+ - ' ' + dayTitle + ''+ - ' '; - - var day = 1; - if (w2utils.settings.weekStarts !== 'M') weekDay++; - if(this.type === 'datetime') { - var dt_sel = w2utils.isDateTime(selected, options.format, true); - selected = w2utils.formatDate(dt_sel, w2utils.settings.dateFormat); - } - for (var ci = 1; ci < 43; ci++) { - if (weekDay === 0 && ci == 1) { - for (var ti = 0; ti < 6; ti++) html += ''; - ci += 6; - } else { - if (ci < weekDay || day > daysCount[month-1]) { - html += ''; - if ((ci) % 7 === 0) html += ''; - continue; - } - } - var dt = year + '/' + month + '/' + day; - var DT = new Date(dt); - var className = ''; - if (DT.getDay() === 6) className = ' w2ui-saturday'; - if (DT.getDay() === 0) className = ' w2ui-sunday'; - if (dt == today) className += ' w2ui-today'; - - var dspDay = day; - var col = ''; - var bgcol = ''; - var tmp_dt, tmp_dt_fmt; - if(this.type === 'datetime') { - // var fm = options.format.split('|')[0].trim(); - // tmp_dt = w2utils.formatDate(dt, fm); - tmp_dt = w2utils.formatDateTime(dt, options.format); - tmp_dt_fmt = w2utils.formatDate(dt, w2utils.settings.dateFormat); - } else { - tmp_dt = w2utils.formatDate(dt, options.format); - tmp_dt_fmt = tmp_dt; - } - if (options.colored && options.colored[tmp_dt_fmt] !== undefined) { // if there is predefined colors for dates - var tmp = options.colored[tmp_dt_fmt].split(':'); - bgcol = 'background-color: ' + tmp[0] + ';'; - col = 'color: ' + tmp[1] + ';'; - } - html += ''; - if (ci % 7 === 0 || (weekDay === 0 && ci == 1)) html += ''; - day++; - } - html += '
  
'+ - dspDay + - '
'; - return html; - }, - - getYearHTML: function () { - var months = w2utils.settings.shortmonths; - var start_year = w2utils.settings.dateStartYear; - var end_year = w2utils.settings.dateEndYear; - var mhtml = ''; - var yhtml = ''; - for (var m = 0; m < months.length; m++) { - mhtml += '
'+ months[m] + '
'; - } - for (var y = start_year; y <= end_year; y++) { - yhtml += '
'+ y + '
'; - } - return '
'+ mhtml +'
'+ yhtml +'
'; - }, - - getHourHTML: function () { - var tmp = []; - var options = this.options; - if (options == null) options = { format: w2utils.settings.timeFormat }; - var h24 = (options.format.indexOf('h24') > -1); - for (var a = 0; a < 24; a++) { - var time = (a >= 12 && !h24 ? a - 12 : a) + ':00' + (!h24 ? (a < 12 ? ' am' : ' pm') : ''); - if (a == 12 && !h24) time = '12:00 pm'; - if (!tmp[Math.floor(a/8)]) tmp[Math.floor(a/8)] = ''; - var tm1 = this.fromMin(this.toMin(time)); - var tm2 = this.fromMin(this.toMin(time) + 59); - if (this.type === 'datetime') { - var dt = w2utils.isDateTime(this.el.value, options.format, true); - var fm = options.format.split('|')[0].trim(); - tm1 = w2utils.formatDate(dt, fm) + ' ' + tm1; - tm2 = w2utils.formatDate(dt, fm) + ' ' + tm2; - } - tmp[Math.floor(a/8)] += '
'+ time +'
'; - } - var html = - '
'+ - '
'+ w2utils.lang('Select Hour') +'
'+ - '
'+ - ' ' + - ' ' + - ' ' + - '
'+ tmp[0] +''+ tmp[1] +''+ tmp[2] +'
'+ - '
'; - return html; - }, - - getMinHTML: function (hour) { - if (hour == null) hour = 0; - var options = this.options; - if (options == null) options = { format: w2utils.settings.timeFormat }; - var h24 = (options.format.indexOf('h24') > -1); - var tmp = []; - for (var a = 0; a < 60; a += 5) { - var time = (hour > 12 && !h24 ? hour - 12 : hour) + ':' + (a < 10 ? 0 : '') + a + ' ' + (!h24 ? (hour < 12 ? 'am' : 'pm') : ''); - var tm = time; - var ind = a < 20 ? 0 : (a < 40 ? 1 : 2); - if (!tmp[ind]) tmp[ind] = ''; - if (this.type === 'datetime') { - var dt = w2utils.isDateTime(this.el.value, options.format, true); - var fm = options.format.split('|')[0].trim(); - tm = w2utils.formatDate(dt, fm) + ' ' + tm; - } - tmp[ind] += '
'+ time +'
'; - } - var html = - '
'+ - '
'+ w2utils.lang('Select Minute') +'
'+ - '
'+ - ' ' + - ' ' + - ' ' + - '
'+ tmp[0] +''+ tmp[1] +''+ tmp[2] +'
'+ - '
'; - return html; - }, - - toMin: function (str) { - if (typeof str !== 'string') return null; - var tmp = str.split(':'); - if (tmp.length === 2) { - tmp[0] = parseInt(tmp[0]); - tmp[1] = parseInt(tmp[1]); - if (str.indexOf('pm') !== -1 && tmp[0] !== 12) tmp[0] += 12; - } else { - return null; - } - return tmp[0] * 60 + tmp[1]; - }, - - fromMin: function (time) { - var ret = ''; - if (time >= 24 * 60) time = time % (24 * 60); - if (time < 0) time = 24 * 60 + time; - var hour = Math.floor(time/60); - var min = ((time % 60) < 10 ? '0' : '') + (time % 60); - var options = this.options; - if (options == null) options = { format: w2utils.settings.timeFormat }; - if (options.format.indexOf('h24') !== -1) { - ret = hour + ':' + min; - } else { - ret = (hour <= 12 ? hour : hour - 12) + ':' + min + ' ' + (hour >= 12 ? 'pm' : 'am'); - } - return ret; - } - }; - - $.extend(w2field.prototype, w2utils.event); - w2obj.field = w2field; - -}) (jQuery); - -/************************************************************************ -* Library: Web 2.0 UI for jQuery (using prototypical inheritance) -* - Following objects defined -* - w2form - form widget -* - $().w2form - jQuery wrapper -* - Dependencies: jQuery, w2utils, w2fields, w2tabs, w2toolbar -* -* == NICE TO HAVE == -* - include delta on save -* - form should read '; - switch (field.type) { - case 'pass': - case 'password': - input = ''; - break; - case 'check': - case 'checks': - if (field.options.items == null && field.html.items != null) field.options.items = field.html.items; - var items = field.options.items; - input = ''; - // normalized options - if (!$.isArray(items)) items = []; - if (items.length > 0) { - items = w2obj.field.prototype.normMenu.call(this, items, field); - } - // generate - for (var i = 0; i < items.length; i++) { - input += '
'; - } - break; - - case 'checkbox': - input = ''; - break; - case 'radio': - input = ''; - // normalized options - if (field.options.items == null && field.html.items != null) field.options.items = field.html.items; - var items = field.options.items; - if (!$.isArray(items)) items = []; - if (items.length > 0) { - items = w2obj.field.prototype.normMenu.call(this, items, field); - } - // generate - for (var i = 0; i < items.length; i++) { - input += '
'; - } - break; - case 'select': - input = ''; - break; - case 'textarea': - input = ''; - break; - case 'toggle': - input = '
'; - break; - case 'map': - case 'array': - field.html.key = field.html.key || {}; - field.html.value = field.html.value || {}; - field.html.tabindex_str = tabindex_str - input = '' + (field.html.text || '') + '' + - ''+ - '
'; - break; - case 'html': - case 'div': - case 'custom': - input = '
'+ - (field && field.html && field.html.html ? field.html.html : '') + - '
'; - break; - case 'empty': - input = (field && field.html ? (field.html.html || '') + (field.html.text || '') : ''); - break; - - } - if (group !== '') { - if(page != field.html.page || column != field.html.column || (field.html.group && (group != field.html.group))){ - pages[page][column] += '\n \n '; - group = ''; - } - } - if (field.html.group && (group != field.html.group)) { - var collapsable = ''; - if (field.html.groupCollapsable) { - collapsable = '' - } - html += '\n
' - + '\n
' - + collapsable + field.html.group + '
\n' - + '
'; - group = field.html.group; - } - if (field.html.anchor == null) { - var span = (field.html.span != null ? 'w2ui-span'+ field.html.span : '') - if (field.html.span == -1) span = 'w2ui-span-none'; - var label = '' + w2utils.lang(field.type != 'checkbox' ? field.html.label : field.html.text) +'' - if (!field.html.label) label = '' - html += '\n
'+ - '\n '+ label + - ((field.type === 'empty') ? input : '\n
'+ input + (field.type != 'array' && field.type != 'map' ? w2utils.lang(field.type != 'checkbox' ? field.html.text : '') : '') + '
') + - '\n
'; - } else { - pages[field.html.page].anchors = pages[field.html.page].anchors || {}; - pages[field.html.page].anchors[field.html.anchor] = '
'+ - ((field.type === 'empty') ? input : '
'+ w2utils.lang(field.type != 'checkbox' ? field.html.label : field.html.text) + input + w2utils.lang(field.type != 'checkbox' ? field.html.text : '') + '
') + - '
'; - } - if (pages[field.html.page] == null) pages[field.html.page] = {}; - if (pages[field.html.page][field.html.column] == null) pages[field.html.page][field.html.column] = ''; - pages[field.html.page][field.html.column] += html; - page = field.html.page; - column = field.html.column; - } - if (group !== '') pages[page][column] += '\n
\n
'; - if (this.tabs.tabs) { - for (var i = 0; i < this.tabs.tabs.length; i++) if (pages[i] == null) pages[i] = []; - } - // buttons if any - var buttons = ''; - if (!$.isEmptyObject(this.actions)) { - var addClass = ''; - buttons += '\n
'; - tabindex = this.tabindexBase + this.fields.length + 1; - - for (var a in this.actions) { // it is an object - var act = this.actions[a]; - var info = { text: '', style: '', "class": '' }; - if ($.isPlainObject(act)) { - if (act.text == null && act.caption != null) { - console.log('NOTICE: form action.caption property is deprecated, please use action.text. Action ->', act); - act.text = act.caption; - } - if (act.text) info.text = act.text; - if (act.style) info.style = act.style; - if (act["class"]) info['class'] = act['class']; - } else { - info.text = a; - if (['save', 'update', 'create'].indexOf(a.toLowerCase()) !== -1) info['class'] = 'w2ui-btn-blue'; else info['class'] = ''; - } - buttons += '\n '; - tabindex++; - } - buttons += '\n
'; - } - html = ''; - for (var p = 0; p < pages.length; p++){ - html += '
'; - if (pages[p].before) { - html += pages[p].before; - } - html += '
'; - Object.keys(pages[p]).sort().forEach(function (c, ind) { - if (c == parseInt(c)) { - html += '
' + (pages[p][c] || '') + '\n
'; - } - }) - html += '\n
'; - if (pages[p].after) { - html += pages[p].after; - } - html += '\n
'; - // process page anchors - if (pages[p].anchors) { - Object.keys(pages[p].anchors).forEach(function (key, ind) { - html = html.replace(key, pages[p].anchors[key]); - }); - } - } - html += buttons; - return html; - }, - - toggleGroup: function (groupName, show) { - var el = $(this.box).find('.w2ui-group-title[data-group="' + w2utils.base64encode(groupName) + '"]') - if (el.next().css('display') == 'none' && show !== true) { - el.next().slideDown(300); - el.next().next().remove() - el.find('span').addClass('w2ui-icon-collapse').removeClass('w2ui-icon-expand'); - } else { - el.next().slideUp(300); - var css = 'width: ' + el.next().css('width') + ';' - + 'padding-left: ' + el.next().css('padding-left') + ';' - + 'padding-right: ' + el.next().css('padding-right') + ';' - + 'margin-left: ' + el.next().css('margin-left') + ';' - + 'margin-right: ' + el.next().css('margin-right') + ';' - setTimeout(function () { el.next().after('
') }, 100) - el.find('span').addClass('w2ui-icon-expand').removeClass('w2ui-icon-collapse'); - } - }, - - action: function (action, event) { - var act = this.actions[action]; - var click = act; - if ($.isPlainObject(act) && act.onClick) click = act.onClick; - // event before - var edata = this.trigger({ phase: 'before', target: action, type: 'action', action: act, originalEvent: event }); - if (edata.isCancelled === true) return; - // default actions - if (typeof click === 'function') click.call(this, event); - // event after - this.trigger($.extend(edata, { phase: 'after' })); - }, - - resize: function () { - var obj = this; - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'resize' }); - if (edata.isCancelled === true) return; - // default behaviour - var main = $(this.box).find('> div.w2ui-form-box'); - var header = $(this.box).find('> div .w2ui-form-header'); - var toolbar = $(this.box).find('> div .w2ui-form-toolbar'); - var tabs = $(this.box).find('> div .w2ui-form-tabs'); - var page = $(this.box).find('> div .w2ui-page'); - var cpage = $(this.box).find('> div .w2ui-page.page-'+ this.page); - var dpage = $(this.box).find('> div .w2ui-page.page-'+ this.page + ' > div'); - var buttons = $(this.box).find('> div .w2ui-buttons'); - // if no height, calculate it - resizeElements(); - if (this.autosize) { //we don't need auto-size every time - if (parseInt($(this.box).height()) === 0 || $(this.box).data('auto-size') === true) { - $(this.box).height( - (header.length > 0 ? w2utils.getSize(header, 'height') : 0) + - ((typeof this.tabs === 'object' && $.isArray(this.tabs.tabs) && this.tabs.tabs.length > 0) ? w2utils.getSize(tabs, 'height') : 0) + - ((typeof this.toolbar === 'object' && $.isArray(this.toolbar.items) && this.toolbar.items.length > 0) ? w2utils.getSize(toolbar, 'height') : 0) + - (page.length > 0 ? w2utils.getSize(dpage, 'height') + w2utils.getSize(cpage, '+height') + 12 : 0) + // why 12 ??? - (buttons.length > 0 ? w2utils.getSize(buttons, 'height') : 0) - ); - $(this.box).data('auto-size', true); - } - resizeElements(); - } - if (this.toolbar && this.toolbar.resize) this.toolbar.resize(); - if (this.tabs && this.tabs.resize) this.tabs.resize(); - // event after - obj.trigger($.extend(edata, { phase: 'after' })); - - function resizeElements() { - // resize elements - main.width($(obj.box).width()).height($(obj.box).height()); - toolbar.css('top', (obj.header !== '' ? w2utils.getSize(header, 'height') : 0)); - tabs.css('top', (obj.header !== '' ? w2utils.getSize(header, 'height') : 0) - + ((typeof obj.toolbar === 'object' && $.isArray(obj.toolbar.items) && obj.toolbar.items.length > 0) ? w2utils.getSize(toolbar, 'height') : 0)); - page.css('top', (obj.header !== '' ? w2utils.getSize(header, 'height') : 0) - + ((typeof obj.toolbar === 'object' && $.isArray(obj.toolbar.items) && obj.toolbar.items.length > 0) ? w2utils.getSize(toolbar, 'height') + 5 : 0) - + ((typeof obj.tabs === 'object' && $.isArray(obj.tabs.tabs) && obj.tabs.tabs.length > 0) ? w2utils.getSize(tabs, 'height') + 5 : 0)); - page.css('bottom', (buttons.length > 0 ? w2utils.getSize(buttons, 'height') : 0)); - } - }, - - refresh: function () { - var time = (new Date()).getTime(); - var obj = this; - if (!this.box) return; - if (!this.isGenerated || $(this.box).html() == null) return; - // event before - var edata = this.trigger({ phase: 'before', target: this.name, type: 'refresh', page: this.page, field: field, fields: arguments }); - if (edata.isCancelled === true) return; - var fields = Array.from(this.fields.keys()); - if (arguments.length > 0) { - fields = Array.from(arguments) - .map(function (fld, ind) { - if (typeof fld != 'string') console.log('ERROR: Arguments in refresh functions should be field names') - return this.get(fld, true); // get index of field - }.bind(this)) - .filter(function (fld, ind) { - if (fld != null) return true; else return false; - }); - } else { - // update what page field belongs - $(this.box).find('input, textarea, select').each(function (index, el) { - var name = ($(el).attr('name') != null ? $(el).attr('name') : $(el).attr('id')); - var field = obj.get(name); - if (field) { - // find page - var div = $(el).closest('.w2ui-page'); - if (div.length > 0) { - for (var i = 0; i < 100; i++) { - if (div.hasClass('page-'+i)) { field.page = i; break; } - } - } - } - }); - // default action - $(this.box).find('.w2ui-page').hide(); - $(this.box).find('.w2ui-page.page-' + this.page).show(); - $(this.box).find('.w2ui-form-header').html(this.header); - // refresh tabs if needed - if (typeof this.tabs === 'object' && $.isArray(this.tabs.tabs) && this.tabs.tabs.length > 0) { - $('#form_'+ this.name +'_tabs').show(); - this.tabs.active = this.tabs.tabs[this.page].id; - this.tabs.refresh(); - } else { - $('#form_'+ this.name +'_tabs').hide(); - } - // refresh tabs if needed - if (typeof this.toolbar === 'object' && $.isArray(this.toolbar.items) && this.toolbar.items.length > 0) { - $('#form_'+ this.name +'_toolbar').show(); - this.toolbar.refresh(); - } else { - $('#form_'+ this.name +'_toolbar').hide(); - } - } - // refresh values of fields - for (var f = 0; f < fields.length; f++) { - var field = this.fields[fields[f]]; - if (field.name == null && field.field != null) field.name = field.field; - if (field.field == null && field.name != null) field.field = field.name; - field.$el = $(this.box).find('[name="'+ String(field.name).replace(/\\/g, '\\\\') +'"]'); - field.el = field.$el[0]; - if (field.el) field.el.id = field.name; - var tmp = $(field).data('w2field'); - if (tmp) tmp.clear(); - $(field.$el) - .off('.w2form') - .on('change.w2form', function (event) { - var that = this; - var field = obj.get(this.name); - if (field == null) return; - if ($(this).data('skip_change') == true) { - $(this).data('skip_change', false) - return - } - - var value_new = this.value; - var value_previous = obj.getValue(this.name); - if (value_previous == null) value_previous = '' - - if (['list', 'enum', 'file'].indexOf(field.type) !== -1 && $(this).data('selected')) { - var nv = $(this).data('selected'); - var cv = obj.getValue(this.name); - if ($.isArray(nv)) { - value_new = []; - for (var i = 0; i < nv.length; i++) value_new[i] = $.extend(true, {}, nv[i]); // clone array - } - if ($.isPlainObject(nv)) { - value_new = $.extend(true, {}, nv); // clone object - } - if ($.isArray(cv)) { - value_previous = []; - for (var i = 0; i < cv.length; i++) value_previous[i] = $.extend(true, {}, cv[i]); // clone array - } - if ($.isPlainObject(cv)) { - value_previous = $.extend(true, {}, cv); // clone object - } - } - if (['toggle', 'checkbox'].indexOf(field.type) !== -1) { - value_new = ($(this).prop('checked') ? ($(this).prop('value') === 'on' ? true : $(this).prop('value')) : false); - } - if (['check', 'checks'].indexOf(field.type) !== -1) { - if (!Array.isArray(value_previous)) value_previous = []; - value_new = value_previous.slice(); - var tmp = field.options.items[$(this).attr('data-index')]; - if ($(this).prop('checked')) { - value_new.push(tmp.id) - } else { - value_new.splice(value_new.indexOf(tmp.id), 1) - } - } - // clean extra chars - if (['int', 'float', 'percent', 'money', 'currency'].indexOf(field.type) !== -1) { - value_new = $(this).data('w2field').clean(value_new); - } - if (value_new === value_previous) return; - // event before - var edata2 = obj.trigger({ phase: 'before', target: this.name, type: 'change', value_new: value_new, value_previous: value_previous, originalEvent: event }); - if (edata2.isCancelled === true) { - edata2.value_new = obj.getValue(this.name) - if ($(this).val() !== edata2.value_new) { - $(this).data('skip_change', true) - // if not immediate, then ignore it - setTimeout(function () { $(that).data('skip_change', false) }, 10) - } - $(this).val(edata2.value_new); // return previous value - } - // default action - var val = edata2.value_new; - if (['enum', 'file'].indexOf(field.type) !== -1) { - if (val.length > 0) { - var fld = $(field.el).data('w2field').helpers.multi; - $(fld).removeClass('w2ui-error'); - } - } - if (val === '' || val == null - || ($.isArray(val) && val.length === 0) || ($.isPlainObject(val) && $.isEmptyObject(val))) { - val = null; - } - obj.setValue(this.name, val); - // event after - obj.trigger($.extend(edata2, { phase: 'after' })); - }) - .on('input.w2form', function (event) { - var val = this.value; - if (event.target.type == 'checkbox') { - val = event.target.checked; - } - // remember original - if (obj.original == null) { - if (!$.isEmptyObject(obj.record)) { - obj.original = $.extend(true, {}, obj.record); - } else { - obj.original = {}; - } - } - // event before - var edata2 = obj.trigger({ phase: 'before', target: this.name, type: 'input', value_new: val, originalEvent: event }); - if (edata2.isCancelled === true) return; - - // event after - obj.trigger($.extend(edata2, { phase: 'after' })); - }); - // required - if (field.required) { - $(field.el).parent().parent().addClass('w2ui-required'); - } else { - $(field.el).parent().parent().removeClass('w2ui-required'); - } - // disabled - if (field.disabled != null) { - var $fld = $(field.el); - if (field.disabled) { - if ($fld.data('w2ui-tabIndex') == null) { - $fld.data('w2ui-tabIndex', $fld.prop('tabIndex')); - } - $(field.el) - .prop('readonly', true) - .prop('tabindex', -1) - .closest('.w2ui-field') - .addClass('w2ui-disabled'); - } else { - $(field.el) - .prop('readonly', false) - .prop('tabIndex', $fld.data('w2ui-tabIndex')) - .closest('.w2ui-field') - .removeClass('w2ui-disabled'); - } - } - // hidden - var tmp = field.el; - if (!tmp) tmp = $(this.box).find('#' + field.field) - if (field.hidden) { - $(tmp).closest('.w2ui-field').hide(); - } else { - $(tmp).closest('.w2ui-field').show(); - } - } - // attach actions on buttons - $(this.box).find('button, input[type=button]').each(function (index, el) { - $(el).off('click').on('click', function (event) { - var action = this.value; - if (this.id) action = this.id; - if (this.name) action = this.name; - obj.action(action, event); - }); - }); - // init controls with record - for (var f = 0; f < fields.length; f++) { - var field = this.fields[fields[f]]; - var value = (this.getValue(field.name) != null ? this.getValue(field.name) : ''); - if (!field.el) continue; - if (!$(field.el).hasClass('w2ui-input')) $(field.el).addClass('w2ui-input'); - field.type = String(field.type).toLowerCase(); - if (!field.options) field.options = {}; - switch (field.type) { - case 'text': - case 'textarea': - case 'email': - case 'pass': - case 'password': - field.el.value = value; - break; - case 'int': - case 'float': - case 'money': - case 'currency': - case 'percent': - // issue #761 - field.el.value = value; - $(field.el).w2field($.extend({}, field.options, { type: field.type })); - break; - case 'hex': - case 'alphanumeric': - case 'color': - case 'date': - case 'time': - field.el.value = value; - $(field.el).w2field($.extend({}, field.options, { type: field.type })); - break; - case 'toggle': - if (w2utils.isFloat(value)) value = parseFloat(value); - $(field.el).prop('checked', (value ? true : false)); - this.setValue(field.name, (value ? value : false)); - break; - case 'radio': - $(field.$el).prop('checked', false).each(function (index, el) { - if ($(el).val() == value) $(el).prop('checked', true); - }); - break; - case 'checkbox': - $(field.el).prop('checked', value ? true : false); - if (field.disabled === true || field.disabled === false) { - $(field.el).prop('disabled', field.disabled ? true : false) - } - break; - case 'check': - case 'checks': - if (Array.isArray(value)) { - value.forEach(function (val) { - $(field.el).closest('div').find('[data-value="' + val + '"]').prop('checked', true) - }) - } - if (field.disabled) { - $(field.el).closest('div').find('input[type=checkbox]').prop('disabled', true) - } else { - $(field.el).closest('div').find('input[type=checkbox]').removeProp('disabled') - } - break; - // enums - case 'list': - case 'combo': - if (field.type === 'list') { - var tmp_value = ($.isPlainObject(value) ? value.id : ($.isPlainObject(field.options.selected) ? field.options.selected.id : value)); - // normalized options - if (!field.options.items) field.options.items = []; - var items = field.options.items; - if (typeof items == 'function') items = items(); - // find value from items - var isFound = false; - if (Array.isArray(items)) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (item.id == tmp_value) { - value = $.extend(true, {}, item); - obj.setValue(field.name, value); - isFound = true; - break; - } - } - } - if (!isFound && value != null && value !== '') { - field.$el.data('find_selected', value); - } - } else if (field.type === 'combo' && !$.isPlainObject(value)) { - field.el.value = value; - } else if ($.isPlainObject(value) && value.text != null) { - field.el.value = value.text; - } else { - field.el.value = ''; - } - if (!$.isPlainObject(value)) value = {}; - $(field.el).w2field($.extend({}, field.options, { type: field.type, selected: value })); - break; - case 'enum': - case 'file': - var sel = []; - var isFound = false; - if (!$.isArray(value)) value = []; - if (typeof field.options.items != 'function') { - if (!$.isArray(field.options.items)) { - field.options.items = []; - } - // find value from items - value.forEach(function (val) { - field.options.items.forEach(function (it) { - if (it && (it.id == val || ($.isPlainObject(val) && it.id == val.id))) { - sel.push($.isPlainObject(it) ? $.extend(true, {}, it) : it); - isFound = true - } - }) - }) - } - if (!isFound && value != null && value.length !== 0) { - field.$el.data('find_selected', value); - sel = value - } - var opt = $.extend({}, field.options, { type: field.type, selected: sel }) - Object.keys(field.options).forEach(function(key) { - if (typeof field.options[key] == 'function') { - opt[key] = field.options[key] - } - }) - $(field.el).w2field(opt); - break; - - // standard HTML - case 'select': - // generate options - var items = field.options.items; - if (items != null && items.length > 0) { - items = w2obj.field.prototype.normMenu.call(this, items, field); - $(field.el).html(''); - for (var it = 0; it < items.length; it++) { - $(field.el).append('";o.addClass("w2ui-editable").html('"+n.outTag),setTimeout(function(){o.find("select").on("change",function(e){delete c.last.move}).on("blur",function(e){1!=$(this).data("keep-open")&&c.editChange.call(c,this,h,u,e)})},10);break;case"div":var b="font-family: "+(_=l.find("[col="+u+"] > div")).css("font-family")+"; font-size: "+_.css("font-size")+";";o.addClass("w2ui-editable").html('
"+n.outTag),null==e&&o.find("div.w2ui-input").text("object"!=typeof g?g:"");var x=o.find("div.w2ui-input").get(0);setTimeout(function(){var t=x;$(t).on("blur",function(e){1!=$(this).data("keep-open")&&c.editChange.call(c,t,h,u,e)})},10),null!=e&&$(x).text("object"!=typeof g?g:"");break;default:var _,b="font-family: "+(_=l.find("[col="+u+"] > div")).css("font-family")+"; font-size: "+_.css("font-size");o.addClass("w2ui-editable").html('"+n.outTag),"number"==n.type&&(g=w2utils.formatNumber(g)),"date"==n.type&&(g=w2utils.formatDate(w2utils.isDate(g,n.format,!0)||new Date,n.format)),null==e&&o.find("input").val("object"!=typeof g?g:"");x=o.find("input").get(0);$(x).w2field(n.type,$.extend(n,{selected:g})),setTimeout(function(){var e=x;"list"==n.type&&(e=$($(x).data("w2field").helpers.focus).find("input"),"object"!=typeof g&&""!=g&&e.val(g).css({opacity:1}).prev().css({opacity:1}),o.find("input").on("change",function(e){c.editChange.call(c,x,h,u,e)})),$(e).on("blur",function(e){1!=$(this).data("keep-open")&&c.editChange.call(c,x,h,u,e)})},10),null!=e&&$(x).val("object"!=typeof g?g:"")}return void setTimeout(function(){c.last.inEditMode&&(o.find("input, select, div.w2ui-input").data("old_value",m).on("mousedown",function(e){e.stopPropagation()}).on("click",function(e){"div"==n.type?k.call(o.find("div.w2ui-input")[0],null):k.call(o.find("input, select")[0],null)}).on("paste",function(e){var t=e.originalEvent;e.preventDefault();var i=t.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,i)}).on("keydown",function(l){var o=this,e="DIV"==o.tagName.toUpperCase()?$(o).text():$(o).val();switch(l.keyCode){case 8:"list"!=n.type||$(x).data("w2field")||l.preventDefault();break;case 9:case 13:l.preventDefault();break;case 37:0===w2utils.getCursorPosition(o)&&l.preventDefault();break;case 39:w2utils.getCursorPosition(o)==e.length&&(w2utils.setCursorPosition(o,e.length),l.preventDefault())}setTimeout(function(){switch(l.keyCode){case 9:var e=d,t=l.shiftKey?c.prevCell(h,u,!0):c.nextCell(h,u,!0);if(null==t){var i=l.shiftKey?c.prevRow(h,u):c.nextRow(h,u);if(null!=i&&i!=h){e=c.records[i].recid;for(var s=0;si.width()&&i.width(n+20)}catch(e){}}},editChange:function(e,t,i,s){var n=this;setTimeout(function(){var e=$(n.box).find("#grid_"+n.name+"_focus");e.is(":focus")||e.focus()},10);var r=t<0;t=t<0?-t-1:t;var a=(r?this.summary:this.records)[t],l=this.columns[i],o=$("#grid_"+this.name+(!0===l.frozen?"_frec_":"_rec_")+w2utils.escapeId(a.recid)),d=e.tagName&&"DIV"==e.tagName.toUpperCase()?$(e).text():e.value,u=this.parseField(a,l.field),c=$(e).data("w2field");c&&("list"==c.type&&(d=$(e).data("selected")),!$.isEmptyObject(d)&&null!=d||(d=""),$.isPlainObject(d)||(d=c.clean(d))),"checkbox"==e.type&&(a.w2ui&&!1===a.w2ui.editable&&(e.checked=!e.checked),d=e.checked);var h={phase:"before",type:"change",target:this.name,input_id:e.id,recid:a.recid,index:t,column:i,originalEvent:s.originalEvent?s.originalEvent:s,value_new:d,value_previous:a.w2ui&&a.w2ui.changes&&a.w2ui.changes.hasOwnProperty(l.field)?a.w2ui.changes[l.field]:u,value_original:u};for(null!=$(s.target).data("old_value")&&(h.value_previous=$(s.target).data("old_value"));;){if("object"!=typeof(d=h.value_new)&&String(u)!=String(d)||"object"==typeof d&&d&&d.id!=u&&("object"!=typeof u||null==u||d.id!=u.id)){if(!0!==(h=this.trigger($.extend(h,{type:"change",phase:"before"}))).isCancelled){if(d!==h.value_new)continue;a.w2ui=a.w2ui||{},a.w2ui.changes=a.w2ui.changes||{},a.w2ui.changes[l.field]=h.value_new,this.trigger($.extend(h,{phase:"after"}))}}else if(!0!==(h=this.trigger($.extend(h,{type:"restore",phase:"before"}))).isCancelled){if(d!==h.value_new)continue;a.w2ui&&a.w2ui.changes&&delete a.w2ui.changes[l.field],a.w2ui&&$.isEmptyObject(a.w2ui.changes)&&delete a.w2ui.changes,this.trigger($.extend(h,{phase:"after"}))}break}var p=$(o).find("[col="+i+"]");r||(a.w2ui&&a.w2ui.changes&&null!=a.w2ui.changes[l.field]?p.addClass("w2ui-changed"):p.removeClass("w2ui-changed"),p.replaceWith(this.getCellHTML(t,i,r))),$(this.box).find("div.w2ui-edit-box").remove(),this.show.toolbarSave&&(0'+w2utils.lang(i.msgDelete).replace("NN",s.length).replace("records",1==s.length?"record":"records")+"",buttons:w2utils.settings.macButtonOrder?'":'",onOpen:function(e){var t=$(this.box).find("input, textarea, select, button");t.off(".message").on("blur.message",function(e){t.index(e.target)+1===t.length&&(t.get(0).focus(),e.preventDefault())}).on("keydown.message",function(e){27==e.keyCode&&i.message()}),setTimeout(function(){$(this.box).find(".w2ui-btn.btn-default").focus(),clearTimeout(i.last.kbd_timer)}.bind(this),50)}})}},click:function(e,t){var i=(new Date).getTime(),s=null;if(!(1==this.last.cancelClick||t&&t.altKey))if("object"==typeof e&&null!==e&&(s=e.column,e=e.recid),null==t&&(t={}),i-parseInt(this.last.click_time)<350&&this.last.click_recid==e&&"click"==t.type)this.dblClick(e,t);else{this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null),this.last.click_time=i;var n=this.last.click_recid;this.last.click_recid=e,null==s&&t.target&&("TD"!=(g=t.target).tagName.toUpperCase()&&(g=$(g).parents("td")[0]),null!=$(g).attr("col")&&(s=parseInt($(g).attr("col"))));var r=this.trigger({phase:"before",target:this.name,type:"click",recid:e,column:s,originalEvent:t});if(!0!==r.isCancelled){var a=this,l=this.getSelection();$("#grid_"+this.name+"_check_all").prop("checked",!1);var o=this.get(e,!0),d=(this.records[o],[]);if(a.last.sel_ind=o,a.last.sel_col=s,a.last.sel_recid=e,a.last.sel_type="click",t.shiftKey&&0l[0].column?(u=l[0].column,s):(u=s,l[0].column);for(var f=u;f<=c;f++)d.push(f)}else h=this.get(n,!0),p=this.get(e,!0);var g,m=[];p=this.records.length?this.selectNone():this.selectAll());else if(t.altKey&&(n=this.getColumn(e))&&n.sortable&&this.sort(e,null,!(!t||!t.ctrlKey&&!t.metaKey)),"line-number"==i.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{t.shiftKey||t.metaKey||t.ctrlKey||this.selectNone();var i,s=this.getSelection(),n=this.getColumn(i.field,!0),r=[],a=[];if(0!=s.length&&t.shiftKey){var l=n,o=s[0].column;o.w2ui-message").length)27==i.keyCode&&this.message();else{var n=!1,r=$("#grid_"+s.name+"_records"),a=s.getSelection();0===a.length&&(n=!0);var l=a[0]||null,o=[],d=a[a.length-1];if("object"==typeof l&&null!=l){l=a[0].recid,o=[];for(var u=0;a[u]&&a[u].recid==l;)o.push(a[u].column),u++;d=a[a.length-1].recid}var c=s.get(l,!0),h=s.get(d,!0),p=(s.get(l),$("#grid_"+s.name+"_rec_"+(null!=c?w2utils.escapeId(s.records[c].recid):"none"))),f=!1,g=i.keyCode,m=i.shiftKey;switch(g){case 8:case 46:s.delete(),f=!0,i.stopPropagation();break;case 27:s.selectNone(),f=!0;break;case 65:if(!i.metaKey&&!i.ctrlKey)break;s.selectAll(),f=!0;break;case 13:if("row"==this.selectType&&!0===s.show.expandColumn){if(p.length<=0)break;s.toggle(l,i),f=!0}else{for(var w=0;wv&&s.last.sel_ind!=h?s.unselect(s.records[h].recid):s.select(s.records[v].recid);else if(s.last.sel_ind>v&&s.last.sel_ind!=h){v=h;for(y=[],w=0;w
'),$("#grid_"+this.name+"_frec_"+n).after(''+(this.show.lineNumbers?'':"")+'
'),!0===(s=this.trigger({phase:"before",type:"expand",target:this.name,recid:e,box_id:"grid_"+this.name+"_rec_"+e+"_expanded",fbox_id:"grid_"+this.name+"_frec_"+n+"_expanded"})).isCancelled)return $("#grid_"+this.name+"_rec_"+n+"_expanded_row").remove(),$("#grid_"+this.name+"_frec_"+n+"_expanded_row").remove(),!1;var a=$(this.box).find("#grid_"+this.name+"_rec_"+e+"_expanded"),l=$(this.box).find("#grid_"+this.name+"_frec_"+e+"_expanded"),o=a.find("> div:first-child").height();a.height()a&&(a=i[o].column),-1==l.indexOf(i[o].index)&&l.push(i[o].index);l.sort(function(e,t){return e-t});for(var d=0;d div.w2ui-grid-box").css("width",$(this.box).width()).css("height",$(this.box).height());var i=this.trigger({phase:"before",type:"resize",target:this.name});if(!0!==i.isCancelled)return e.resizeBoxes(),e.resizeRecords(),e.toolbar&&e.toolbar.resize&&e.toolbar.resize(),this.trigger($.extend(i,{phase:"after"})),(new Date).getTime()-t}},update:function(e){var t=(new Date).getTime();if(null==this.box)return 0;if(null==e){for(var i=this.last.range_start-1;i<=this.last.range_end-1;i++)if(!(i<0)){(a=this.records[i]||{}).w2ui||(a.w2ui={});for(var s=0;s'+s[0]+'
"+s[1]+'
'+n[0]+'
'+n[1]+"
",l=$("#grid_"+this.name+"_body",a.box).html(r),o=$("#grid_"+this.name+"_records",a.box),d=$("#grid_"+this.name+"_frecords",a.box),u=this;"row"==this.selectType&&(o.on("mouseover mouseout","tr",function(e){$("#grid_"+u.name+"_frec_"+w2utils.escapeId($(this).attr("recid"))).toggleClass("w2ui-record-hover","mouseover"==e.type)}),d.on("mouseover mouseout","tr",function(e){$("#grid_"+u.name+"_rec_"+w2utils.escapeId($(this).attr("recid"))).toggleClass("w2ui-record-hover","mouseover"==e.type)})),w2utils.isIOS?o.add(d).on("click","tr",function(e){u.dblClick($(this).attr("recid"),e)}):o.add(d).on("click","tr",function(e){u.click($(this).attr("recid"),e)}).on("contextmenu","tr",function(e){u.contextMenu($(this).attr("recid"),null,e)}),l.data("scrolldata",{lastTime:0,lastDelta:0,time:0}).find(".w2ui-grid-frecords").on("mousewheel DOMMouseScroll ",function(e){e.preventDefault();var t=e.originalEvent,i=l.data("scrolldata"),s=$(this).siblings(".w2ui-grid-records").addBack().filter(".w2ui-grid-records"),n=null!=typeof t.wheelDelta?-1*t.wheelDelta/120:(t.detail||t.deltaY)/3,r=s.scrollTop();i.time=+new Date,i.lastTime
'+this.msgEmpty+"
"):0<$("#grid_"+this.name+"_empty_msg").length&&$("#grid_"+this.name+"_empty_msg").remove(),0=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[r].field,this.last.label=this.searches[r].label)}$(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid w2ui-inactive").html('
"),"row"!=this.selectType&&$(this.box).addClass("w2ui-ss"),0<$(this.box).length&&($(this.box)[0].style.cssText+=this.style),this.initToolbar(),null!=this.toolbar&&this.toolbar.render($("#grid_"+this.name+"_toolbar")[0]),this.last.field&&"all"!=this.last.field&&(i=this.searchData,setTimeout(function(){C.initAllField(C.last.field,1==i.length?i[0].value:null)},1)),$("#grid_"+this.name+"_footer").html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),s&&(this.clear(),this.refresh());for(var T,a=!1,l=0;l
'),(g=$(C.box).find(".w2ui-grid-records")).append('
'),g.append('
'),$("#grid_"+C.name+"_ghost").append(t).append(h.ghost)),f=$("#grid_"+C.name+"_ghost"),g=$(C.box).find(".w2ui-grid-records"),f.css({top:h.pos.top+g.scrollTop(),left:h.pos.left,"border-top":"1px solid #aaa","border-bottom":"1px solid #aaa"})):C.last.move.reorder=!1)}$(document).on("mousemove.w2ui-"+C.name,m).on("mouseup.w2ui-"+C.name,w),e.stopPropagation()}),this.updateToolbar(),this.trigger($.extend(n,{phase:"after"})),0===$(".w2ui-layout").length&&$(window).off("resize.w2ui-"+C.name).on("resize.w2ui-"+C.name,function(e){null==w2ui[C.name]?$(window).off("resize.w2ui-"+C.name):w2ui[C.name].resize()}),(new Date).getTime()-t}}function m(e){var t=C.last.move;if(t&&-1!=["select","select-column"].indexOf(t.type)&&(t.divX=e.screenX-t.x,t.divY=e.screenY-t.y,!(Math.abs(t.divX)<=1&&Math.abs(t.divY)<=1))){if(C.last.cancelClick=!0,1==C.reorderRows&&C.last.move.reorder){var i,s,n,r=$(C.box).find(".w2ui-grid-records");return"-none-"==(a=(c=$(e.target).parents("tr")).attr("recid"))&&(a="bottom"),a!=t.from&&($("#grid_"+C.name+"_rec_"+t.recid),i=$("#grid_"+C.name+"_rec_"+a),$(C.box).find(".insert-before"),i.addClass("insert-before"),t.lastY=e.screenY,t.to=a,s=i.position(),n=$("#grid_"+C.name+"_ghost_line"),s?n.css({top:s.top+r.scrollTop(),left:t.pos.left,"border-top":"2px solid #769EFC"}):n.css({"border-top":"2px solid transparent"})),void $("#grid_"+C.name+"_ghost").css({top:t.pos.top+t.divY+r.scrollTop(),left:t.pos.left})}t.start&&t.recid&&(C.selectNone(),t.start=!1);var a,l=[];if(null==(a="TR"==e.target.tagName.toUpperCase()?$(e.target).attr("recid"):$(e.target).parents("tr").attr("recid"))){if("row"==C.selectType)return;if(C.last.move&&"select"==C.last.move.type)return;var o=parseInt($(e.target).parents("td").attr("col"));if(isNaN(o))C.removeRange("column-selection"),$(C.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),$(C.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete t.colRange;else{var d=o+"-"+o;t.columno&&(d=o+"-"+t.column);for(var u=[],c=d.split("-"),h=parseInt(c[0]);h<=parseInt(c[1]);h++)u.push(h);if(t.colRange!=d&&!0!==(T=C.trigger({phase:"before",type:"columnSelect",target:C.name,columns:u,isCancelled:!1})).isCancelled){null==t.colRange&&C.selectNone();c=d.split("-");$(C.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(var p=parseInt(c[0]);p<=parseInt(c[1]);p++)$(C.box).find("#grid_"+C.name+"_column_"+p+" .w2ui-col-header").addClass("w2ui-col-selected");$(C.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),t.colRange=d,C.removeRange("column-selection"),C.addRange({name:"column-selection",range:[{recid:C.records[0].recid,column:c[0]},{recid:C.records[C.records.length-1].recid,column:c[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}else{var f=C.get(t.recid,!0);if(null==f||C.records[f]&&C.records[f].recid!=t.recid)return;var g=C.get(a,!0);if(null==g)return;var m=parseInt(t.column),w=parseInt("TD"==e.target.tagName.toUpperCase()?$(e.target).attr("col"):$(e.target).parents("td").attr("col"));isNaN(m)&&isNaN(w)&&(m=0,w=C.columns.length-1),g",i=0;i ")}var r="object"!=typeof this.url?this.url:this.url.get;(r&&e.show.skipRecords||e.show.saveRestoreState)&&(t+=''),r&&e.show.skipRecords&&(t+='"),e.show.saveRestoreState&&(t+='"),t+="
'+w2utils.lang("Skip")+' "+w2utils.lang("Records")+"
"+w2utils.lang("Save Grid State")+'
"+w2utils.lang("Restore Default State")+"
",this.toolbar.get("w2ui-column-on-off").html=t}},initColumnDrag:function(e){if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";var u=this,c={};function t(){c.pressed=!1,clearTimeout(c.timeout)}function i(o){c.timeout&&clearTimeout(c.timeout);var d=this;c.pressed=!0,c.timeout=setTimeout(function(){if(c.pressed&&0!==c.numberPreColumnsPresent){var e,t,i,s,n,r=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"].concat(["w2ui-head-last"]);if($(o.originalEvent.target).parents().hasClass("w2ui-head")){for(var a=0,l=r.length;a=t[t.length-1]+i)return t.length;for(var s=0,n=t.length;s
'),c.markerLeft=$('
'));c.lastInt&&c.lastInt===e||(c.lastInt=e,c.marker.remove(),c.markerLeft.remove(),$(".w2ui-head").removeClass("w2ui-col-intersection"),e>=c.columns.length?($(c.columns[c.columns.length-1]).children("div:last").append(c.marker.addClass("right").removeClass("left")),$(c.columns[c.columns.length-1]).addClass("w2ui-col-intersection")):e<=c.numberPreColumnsPresent?($(c.columns[c.numberPreColumnsPresent]).prepend(c.marker.addClass("left").removeClass("right")).css({position:"relative"}),$(c.columns[c.numberPreColumnsPresent]).prev().addClass("w2ui-col-intersection")):($(c.columns[e]).children("div:last").prepend(c.marker.addClass("left").removeClass("right")),$(c.columns[e]).prev().children("div:last").append(c.markerLeft.addClass("right").removeClass("left")).css({position:"relative"}),$(c.columns[e-1]).addClass("w2ui-col-intersection")))}(c.targetInt),r=t,a=i,$(c.ghost).css({left:r-10,top:a-10}))}function p(e){c.pressed=!1;var t,i,s,n,r=$(".w2ui-grid-ghost"),a=u.trigger({type:"columnDragEnd",phase:"before",originalEvent:e,target:c.columnHead[0]});if(!0===a.isCancelled)return!1;i=u.columns[c.originalPos],s=u.columns,n=$(c.columns[Math.min(c.lastInt,c.columns.length-1)]),(t=c.lastInt
'+this.buttons.search.html+'
',this.toolbar.items.push({type:"html",id:"w2ui-search",html:e})),this.show.toolbarSearch&&this.multiSearch&&0 div',r.box).each(function(){var e=this.offsetWidth-this.scrollWidth;e div.w2ui-grid-box"),i=$("#grid_"+this.name+"_header"),s=$("#grid_"+this.name+"_toolbar"),n=$("#grid_"+this.name+"_summary"),a=$("#grid_"+this.name+"_fsummary"),l=$("#grid_"+this.name+"_footer"),o=$("#grid_"+this.name+"_body"),d=$("#grid_"+this.name+"_columns"),u=$("#grid_"+this.name+"_fcolumns"),c=$("#grid_"+this.name+"_records"),h=$("#grid_"+this.name+"_frecords"),p=$("#grid_"+this.name+"_scroll1"),f=8*String(this.total).length+10;f<34&&(f=34),null!=this.lineNumberWidth&&(f=this.lineNumberWidth);for(var g,m=!1,w=!1,v=0,y=0;ytable").height()+(m?w2utils.scrollBarSize():0)&&(w=!0),this.fixedBody?(g=t.height()-(this.show.header?w2utils.getSize(i,"height"):0)-(this.show.toolbar?w2utils.getSize(s,"height"):0)-("none"!=n.css("display")?w2utils.getSize(n,"height"):0)-(this.show.footer?w2utils.getSize(l,"height"):0),o.css("height",g)):(g=w2utils.getSize(d,"height")+w2utils.getSize($("#grid_"+r.name+"_records table"),"height")+(m?w2utils.scrollBarSize():0),r.height=g+w2utils.getSize(t,"+height")+(r.show.header?w2utils.getSize(i,"height"):0)+(r.show.toolbar?w2utils.getSize(s,"height"):0)+("none"!=n.css("display")?w2utils.getSize(n,"height"):0)+(r.show.footer?w2utils.getSize(l,"height"):0),t.css("height",r.height),o.css("height",g),e.css("height",w2utils.getSize(t,"height")+w2utils.getSize(e,"+height")));var b=this.records.length,x="object"!=typeof this.url?this.url:this.url.get;if(0==this.searchData.length||x||(b=this.last.searchIds.length),this.fixedBody||(w=!1),m||w?(d.find("> table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show(),c.css({top:(0 table > tbody > tr:nth-child(1) td.w2ui-head-last").hide(),c.css({top:(0=this.recordHeight&&(k-=this.recordHeight,_++),this.fixedBody){for(var C=b;C<_;C++)T(C,this.recordHeight,this);T(_,k,this)}}function T(e,t,i){var s,n="",r="";n+='',r+='',i.show.lineNumbers&&(n+=''),i.show.selectColumn&&(n+=''),i.show.expandColumn&&(n+=''),r+='',i.show.orderColumn&&(r+='');for(var a=0;ai.last.colEnd)&&!l.frozen||(s='',l.frozen?n+=s:r+=s)}n+=' ',r+=' ',$("#grid_"+i.name+"_frecords > table").append(n),$("#grid_"+i.name+"_records > table").append(r)}if(0O&&!0!==R.hidden&&(D=R.hidden=!0),R.gridMinWidthparseInt(R.max)&&(R.sizeCalculated=R.max+"px"),I+=parseInt(R.sizeCalculated))}var E=parseInt(O)-parseInt(I);if(0 table > tbody > tr:nth-child(1) td.w2ui-head-last").css("width",w2utils.scrollBarSize()).show();var F=1;this.show.lineNumbers&&(F+=f),this.show.selectColumn&&(F+=26),this.show.expandColumn&&(F+=26);for(y=0;y table > tbody > tr:nth-child(1) td").add(u.find("> table > tbody > tr:nth-child(1) td")).each(function(e,t){$(t).hasClass("w2ui-col-number")&&$(t).css("width",f);var i=$(t).attr("col");if(null!=i){if("start"==i){for(var s=0,n=0;n table > tbody > tr").length&&d.find("> table > tbody > tr:nth-child(1) td").add(u.find("> table > tbody > tr:nth-child(1) td")).html("").css({height:"0px",border:"0px",padding:"0px",margin:"0px"}),c.find("> table > tbody > tr:nth-child(1) td").add(h.find("> table > tbody > tr:nth-child(1) td")).each(function(e,t){$(t).hasClass("w2ui-col-number")&&$(t).css("width",f);var i=$(t).attr("col");if(null!=i){if("start"==i){for(var s=0,n=0;n table > tbody > tr:nth-child(1) td").add(a.find("> table > tbody > tr:nth-child(1) td")).each(function(e,t){$(t).hasClass("w2ui-col-number")&&$(t).css("width",f);var i=$(t).attr("col");if(null!=i){if("start"==i){for(var s=0,n=0;n',t=!1,i=0;iX",t=!0),null==s.inTag&&(s.inTag=""),null==s.outTag&&(s.outTag=""),null==s.style&&(s.style=""),null==s.type&&(s.type="text"),null==s.label&&null!=s.caption&&(console.log("NOTICE: grid search.caption property is deprecated, please use search.label. Search ->",s),s.label=s.caption);var r='";switch(e+=' '+n+' '+(s.label||"")+' '+r+' ',s.type){case"text":case"alphanumeric":case"hex":case"color":case"list":case"combo":case"enum":var a="width: 250px;";-1!=["hex","color"].indexOf(s.type)&&(a="width: 90px;"),e+='";break;case"int":case"float":case"money":case"currency":case"percent":case"date":case"time":case"datetime":a="width: 90px;";"datetime"==s.type&&(a="width: 140px;"),e+='";break;case"select":e+='"}e+=s.outTag+" "}}return e+='
"},initOperator:function(e,t){var i=this.searches[t],s=$("#grid_"+this.name+"_range_"+t),n=$("#grid_"+this.name+"_field_"+t),r=n.parent().find("span input");switch(n.show(),s.hide(),$(e).val()){case"between":s.show(),r.w2field(i.type,i.options);break;case"not null":case"null":n.hide(),n.val("1"),n.change()}},initSearches:function(){for(var t=this,e=0;e--',a=0;a'+u+""):o+='"}$("#grid_"+this.name+"_field_"+e).html(o)}null!=s?("int"==s.type&&-1!=["in","not in"].indexOf(s.operator)&&$("#grid_"+this.name+"_field_"+e).w2field("clear").val(s.value),$("#grid_"+this.name+"_operator_"+e).val(s.operator).trigger("change"),$.isArray(s.value)?-1!=["in","not in"].indexOf(s.operator)?$("#grid_"+this.name+"_field_"+e).val(s.value).trigger("change"):($("#grid_"+this.name+"_field_"+e).val(s.value[0]).trigger("change"),$("#grid_"+this.name+"_field2_"+e).val(s.value[1]).trigger("change")):null!=s.value&&$("#grid_"+this.name+"_field_"+e).val(s.value).trigger("change")):$("#grid_"+this.name+"_operator_"+e).val(r).trigger("change")}$("#w2ui-overlay-"+this.name+"-searchOverlay .w2ui-grid-searches *[rel=search]").on("keypress",function(e){13==e.keyCode&&(t.search(),$().w2overlay({name:t.name+"-searchOverlay"}))})},getColumnsHTML:function(){var e,t,i,s,g=this,n="",r="";return this.show.columnHeaders&&(r=0 ",g.columnGroups[s]),g.columnGroups[s].text=g.columnGroups[s].caption);""!=g.columnGroups[g.columnGroups.length-1].text&&g.columnGroups.push({text:""});g.show.lineNumbers&&(e+='
 
');g.show.selectColumn&&(e+='
 
');g.show.expandColumn&&(e+='
 
');var n=0;t+='',g.show.orderColumn&&(t+='
 
');for(var r=0;r",l),l.text=l.caption);for(var o=0,d=n;d');var p="function"==typeof l.text?l.text(l):l.text;i='"+h+'
'+(p||" ")+"
",l&&l.frozen?e+=i:t+=i}else{var f="function"==typeof a.text?a.text(a):a.text;i='
'+(f||" ")+"
",l&&l.frozen?e+=i:t+=i}n+=a.span}return e+="",t+='',[e,t]}(),i=a(!1),n=e[0]+t[0]+i[0],e[1]+t[1]+i[1]):(n=(s=a(!0))[0],s[1])),[n,r];function a(e){var t="",i="";g.show.lineNumbers&&(t+='
#
"),g.show.selectColumn&&(t+='
"),g.show.expandColumn&&(t+='
 
');var s,n=0,r=0;i+='',g.show.orderColumn&&(i+='
 
');for(var a=0;a ",o),o.text=o.caption),null==o.size&&(o.size="100%"),a==r&&(r+=(s=g.columnGroups[n++]||{}).span),(ag.last.colEnd)&&!o.frozen||o.hidden||!0===s.master&&!e||(l=g.getColumnCellHTML(a),o&&o.frozen?t+=l:i+=l)}return t+='
 
',i+='
 
',[t+="",i+=""]}},getColumnCellHTML:function(e){var t=this.columns[e];if(null==t)return"";for(var i=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-reorder-cols-head ",s="",n=0;n"+(!1!==t.resizable?'
':"")+'
'+(o||" ")+"
"},columnTooltipShow:function(e){var t,i,s;"normal"!=this.columnTooltip&&(t=$(this.box).find("#grid_"+this.name+"_column_"+e),i=this.columns[e],s=this.columnTooltip,t.prop("_mouse_over",!0),setTimeout(function(){!0===t.prop("_mouse_over")&&!0!==t.prop("_mouse_tooltip")&&(t.prop("_mouse_tooltip",!0),t.w2tag(i.tooltip,{position:s,top:5}))},1))},columnTooltipHide:function(e){var t;"normal"!=this.columnTooltip&&(t=$(this.box).find("#grid_"+this.name+"_column_"+e),this.columns[e],t.removeProp("_mouse_over"),setTimeout(function(){!0!==t.prop("_mouse_over")&&!0===t.prop("_mouse_tooltip")&&(t.removeProp("_mouse_tooltip"),t.w2tag())},1))},getRecordsHTML:function(){var e=this.records.length,t="object"!=typeof this.url?this.url:this.url.get;0==this.searchData.length||t||(e=this.last.searchIds.length),e>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var i=$("#grid_"+this.name+"_records"),s=Math.floor((i.height()||0)/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||e"+n[0],a=""+n[1];r+='',a+='';for(var l=0;l
',a+=' ',this.last.range_start=0,this.last.range_end=s,[r,a]},getSummaryHTML:function(){if(0!==this.summary.length){for(var e=this.getRecordHTML(-1,0),t=""+e[0],i="
"+e[1],s=0;s
",i+=""]}},scroll:function(e){(new Date).getTime();var t,i,r=this,s="object"!=typeof this.url?this.url:this.url.get,n=$("#grid_"+this.name+"_records"),a=$("#grid_"+this.name+"_frecords");e&&(t=e.target.scrollTop,i=e.target.scrollLeft,r.last.scrollTop=t,r.last.scrollLeft=i,$("#grid_"+r.name+"_columns")[0].scrollLeft=i,$("#grid_"+r.name+"_summary")[0].scrollLeft=i,a[0].scrollTop=t),this.last.bubbleEl&&($(this.last.bubbleEl).w2tag(),this.last.bubbleEl=null);var l=null,o=null;if(r.disableCVS||0r.last.scrollLeft&&null==l&&(l=h),c+d-30>r.last.scrollLeft+u&&null==o&&(o=h),c+=d)}null==o&&(o=r.columns.length-1)}if(null!=l&&(l<0&&(l=0),o<0&&(o=0),l==o&&(0r.last.colStart)for(h=r.last.colStart;h';null!=i&&(s=r.getCellHTML(parseInt(i),h,!1)),$(t).after(s)}),b.each(function(e,t){var i=$(t).parent().attr("index"),s='';null!=i&&(s=r.getCellHTML(parseInt(i),h,!0)),$(t).after(s)}));if(o>r.last.colEnd)for(h=r.last.colEnd+1;h<=o;h++)r.columns[h]&&(r.columns[h].frozen||r.columns[h].hidden)||(w.before(r.getColumnCellHTML(h)),y.each(function(e,t){var i=$(t).parent().attr("index"),s='';null!=i&&(s=r.getCellHTML(parseInt(i),h,!1)),$(t).before(s)}),x.each(function(e,t){var i=$(t).parent().attr("index")||-1,s=r.getCellHTML(parseInt(i),h,!0);$(t).before(s)}));r.last.colStart=l,r.last.colEnd=o,r.resizeRecords()}else{r.last.colStart=l,r.last.colEnd=o;var _=this.getColumnsHTML(),k=this.getRecordsHTML(),C=this.getSummaryHTML(),T=p.find("#grid_"+this.name+"_columns"),S=p.find("#grid_"+this.name+"_records"),O=p.find("#grid_"+this.name+"_frecords"),z=p.find("#grid_"+this.name+"_summary");T.find("tbody").html(_[1]),O.html(k[0]),S.prepend(k[1]),null!=C&&z.html(C[1]),setTimeout(function(){S.find("> table").not("table:first-child").remove(),z[0]&&(z[0].scrollLeft=r.last.scrollLeft)},1),r.resizeRecords()}}var D=this.records.length;if(D>this.total&&(D=this.total),0==this.searchData.length||s||(D=this.last.searchIds.length),0!==D&&0!==n.length&&0!==n.height()){D>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;var I=Math.round(n[0].scrollTop/this.recordHeight+1),E=I+(Math.round(n.height()/this.recordHeight)-1);if(Dthis.total&&-1!=this.total&&(F=this.total);var j=n.find("#grid_"+this.name+"_rec_top"),A=n.find("#grid_"+this.name+"_rec_bottom"),M=a.find("#grid_"+this.name+"_frec_top"),N=a.find("#grid_"+this.name+"_frec_bottom");-1!=String(j.next().prop("id")).indexOf("_expanded_row")&&(j.next().remove(),M.next().remove()),this.total>F&&-1!=String(A.prev().prop("id")).indexOf("_expanded_row")&&(A.prev().remove(),N.prev().remove());var L,P=parseInt(j.next().attr("line")),H=parseInt(A.prev().attr("line"));if(P=P-this.last.show_extra+2&&1F))break;B.remove(),Y.remove()}"bottom"==(L=n.find("#grid_"+this.name+"_rec_top").next().attr("line"))&&(L=F);for(var Y,X,h=parseInt(L)-1;R<=h;h--){this.records[h-1]&&((Y=this.records[h-1].w2ui)&&!Array.isArray(Y.children)&&(Y.expanded=!1),X=this.getRecordHTML(h-1,h),j.after(X[1]),M.after(X[0]))}U(),setTimeout(function(){r.refreshRanges()},0)}var W=(R-1)*r.recordHeight,K=(D-F)*this.recordHeight;K<0&&(K=0),j.css("height",W+"px"),M.css("height",W+"px"),A.css("height",K+"px"),N.css("height",K+"px"),r.last.range_start=R,r.last.range_end=F,D
'),r.last.pull_more=!0,r.last.xhr_offset+=r.limit,r.request("get")}).find("td").html(r.autoLoad?'
':'
'+w2utils.lang("Load")+" "+r.limit+" "+w2utils.lang("More")+"...
"))}}function U(){r.markSearch&&(clearTimeout(r.last.marker_timer),r.last.marker_timer=setTimeout(function(){for(var e=[],t=0;t',r+='',this.show.lineNumbers&&(n+=''),this.show.selectColumn&&(n+=''),this.show.expandColumn&&(n+=''),r+='',this.show.orderColumn&&(r+='');for(var l=0;l';if((w=this.columns[l]).frozen&&!w.hidden)n+=o;else{if(w.hidden||lthis.last.colEnd)continue;r+=o}}return n+='',r+='',[n+="",r+=""]}var d,u="object"!=typeof this.url?this.url:this.url.get;if(!0!==i)if(0=this.last.searchIds.length)return"";e=this.last.searchIds[e],s=this.records[e]}else{if(e>=this.records.length)return"";s=this.records[e]}else{if(e>=this.summary.length)return"";s=this.summary[e]}if(!s)return"";null!=s.recid||null==this.recid||null!=(d=this.parseField(s,this.recid))&&(s.recid=d);w2utils.escapeId(s.recid);var c=!1;-1!=a.indexes.indexOf(e)&&(c=!0);var h=s.w2ui?s.w2ui.style:"";null!=h&&"string"==typeof h||(h="");var p,f=s.w2ui?s.w2ui.class:"";null!=f&&"string"==typeof f||(f=""),n+='",r+='",this.show.lineNumbers&&(n+='"+(!0!==i?this.getLineHTML(t,s):"")+""),this.show.selectColumn&&(s&&s.w2ui&&s.w2ui.hideCheckBox,n+=''+(!0===i||s.w2ui&&!0===s.w2ui.hideCheckBox?"":'
')+""),this.show.expandColumn&&(p="",p=s.w2ui&&!0===s.w2ui.expanded?"-":"+",s.w2ui&&"none"==s.w2ui.expanded&&(p=""),s.w2ui&&"spinner"==s.w2ui.expanded&&(p='
'),n+=''+(!0!==i?'
"+p+"
":"")+""),r+='',this.show.orderColumn&&(r+=''+(!0!==i?'
 
':"")+"");for(var g=0,m=0;;){var w,v,y,b=1;if(null==(w=this.columns[g]))break;if(w.hidden)g++,0this.last.colEnd)||w.frozen){if(s.w2ui&&"object"==typeof s.w2ui.colspan){var x=parseInt(s.w2ui.colspan[w.field])||null;if(1=this.columns.length);l++)this.columns[l].hidden&&_++;b=x-_,m=x-1}}var k=this.getCellHTML(e,g,i,b);w.frozen?n+=k:r+=k,g++}else g++}}return n+='',r+='',[n+="",r+=""]},getLineHTML:function(e){return"
"+e+"
"},getCellHTML:function(i,s,e,t){var n=this,r=this.columns[s];if(null==r)return"";var a,l,o,d,u,c,h,p=!0!==e?this.records[i]:this.summary[i],f=-1!==i?this.getCellValue(i,s,e):"",g=-1!==i?this.getCellEditable(i,s):"",m="max-height: "+parseInt(this.recordHeight)+"px;"+(r.clipboardCopy?"margin-right: 20px":""),w=!e&&p&&p.w2ui&&p.w2ui.changes&&null!=p.w2ui.changes[r.field],v="",y="",b=this.last.selection,x=!1,_="";if(-1!=b.indexes.indexOf(i)&&(x=!0),null==t&&(t=p&&p.w2ui&&p.w2ui.colspan&&p.w2ui.colspan[r.field]?p.w2ui.colspan[r.field]:1),0===s&&p&&p.w2ui&&Array.isArray(p.w2ui.children)){for(var k,C=0,T=this.get(p.w2ui.parent_recid,!0);null!=T;){if(C++,null==(k=this.records[T].w2ui)||null==k.parent_recid)break;T=this.get(k.parent_recid,!0)}if(p.w2ui.parent_recid)for(var S=0;S
';_+='"}!0===r.info&&(r.info={}),null!=r.info&&(a="w2ui-icon-info","function"==typeof r.info.icon?a=r.info.icon(p):"object"==typeof r.info.icon?a=r.info.icon[this.parseField(p,r.field)]||"":"string"==typeof r.info.icon&&(a=r.info.icon),l=r.info.style||"","function"==typeof r.info.style?l=r.info.style(p):"object"==typeof r.info.style?l=r.info.style[this.parseField(p,r.field)]||"":"string"==typeof r.info.style&&(l=r.info.style),_+='"),null!=r.render&&-1!==i?("function"==typeof r.render&&(null!=(o=r.render.call(this,p,i,s,f))&&"object"==typeof o?(f=$.trim(o.html||""),y=o.class||"",v=o.style||""):f=$.trim(o),(f.length<4||"'+_+String(f)+"")),"object"==typeof r.render&&(null!=(d=r.render[f])&&""!==d||(d=f),f='
'+_+String(d)+"
"),"string"==typeof r.render&&(k=[],-1==(u=r.render.toLowerCase().indexOf(":"))?(k[0]=r.render.toLowerCase(),k[1]=""):(k[0]=r.render.toLowerCase().substr(0,u),k[1]=r.render.toLowerCase().substr(u+1)),c=w2utils.formatters[k[0]],r.options&&!1===r.options.autoFormat&&(c=null),f='
'+_+String(f)+"
")):(g&&-1!=["checkbox","check"].indexOf(g.type)&&(h=e?-(i+1):i,m+="text-align: center;",f='',_=""),f='
'+_+String(f)+"
"),null==f&&(f=""),"string"==typeof r.render&&(k=r.render.toLowerCase().split(":"),-1!=["number","int","float","money","currency","percent","size"].indexOf(k[0])&&(v+="text-align: right;")),p&&p.w2ui&&("object"==typeof p.w2ui.style&&("string"==typeof p.w2ui.style[s]&&(v+=p.w2ui.style[s]+";"),"string"==typeof p.w2ui.style[r.field]&&(v+=p.w2ui.style[r.field]+";")),"object"==typeof p.w2ui.class&&("string"==typeof p.w2ui.class[s]&&(y+=p.w2ui.class[s]+" "),"string"==typeof p.w2ui.class[r.field]&&(y+=p.w2ui.class[r.field]+" ")));var O=!1;x&&-1!=$.inArray(s,b.columns[i])&&(O=!0);var z="string"==typeof r.clipboardCopy?r.clipboardCopy:"Copy to clipboard",D="',f='"+f+(""!=w2utils.stripTags(f)&&r.clipboardCopy&&z?D:"")+"";return-1===i&&!0===e&&(f='"),f;function I(e){var t="";return n.show.recordTitles&&(null!=r.title?("function"==typeof r.title&&(t=r.title.call(n,p,i,s)),"string"==typeof r.title&&(t=r.title)):t=w2utils.stripTags(String(e).replace(/"/g,"''"))),null!=t?String(t):""}},clipboardCopy:function(e,t){var i=this.records[e],s=this.columns[t],n=s?this.parseField(i,s.field):"";"function"==typeof s.clipboardCopy&&(n=s.clipboardCopy(i)),$("#grid_"+this.name+"_focus").text(n).select(),document.execCommand("copy")},showBubble:function(e,t){var i="",s=this.columns[t].info,n=this.records[e],r=$(this.box).find("#grid_"+this.name+"_data_"+e+"_"+t+" .w2ui-info");if(this.last.bubbleEl&&$(this.last.bubbleEl).w2tag(),this.last.bubbleEl=r,null==s.fields){s.fields=[];for(var a=0;as.maxLength&&(c=c.substr(0,s.maxLength)+"..."),i+=""+l.text+""+((0===c?"0":c)||"")+"")):i+='
'}i+=""}else if($.isPlainObject(o)){for(var d in i='',o){var u,c,h=o[d];""!=h&&"-"!=h&&"--"!=h&&"---"!=h?(u=String(h).split(":"),null==(l=this.getColumn(u[0]))&&(l={field:u[0],caption:u[0]}),c=l?this.parseField(n,l.field):"",1s.maxLength&&(c=c.substr(0,s.maxLength)+"..."),i+="")):i+=''}i+="
"+d+""+(c||"")+"
"}$(r).w2tag($.extend({html:i,left:-4,position:"bottom|top",className:"w2ui-info-bubble",style:"",hideOnClick:!0},s.options||{}))},getCellEditable:function(e,t){var i=this.columns[t],s=this.records[e];if(!s||!i)return null;var n,r=s.w2ui?s.w2ui.editable:null;return!1===r?null:(null!=r&&!0!==r||"function"==typeof(r=i?i.editable:null)&&(n=this.getCellValue(e,t,!1),r=r.call(this,s,e,t,n)),r)},getCellValue:function(e,t,i){var s=this.columns[t],n=!0!==i?this.records[e]:this.summary[e],r=this.parseField(n,s.field);return n&&n.w2ui&&n.w2ui.changes&&null!=n.w2ui.changes[s.field]&&(r=n.w2ui.changes[s.field]),$.isPlainObject(r)&&(s.options&&s.options.items?(val=s.options.items.find(function(e){return e.id==r.id}),r=val?val.text:r.id):(null!=r.text&&(r=r.text),null!=r.id&&(r=r.id))),null==r&&(r=""),r},getFooterHTML:function(){return'
'},status:function(e){var t,i,s;null!=e?$("#grid_"+this.name+"_footer").find(".w2ui-footer-left").html(e):(t="",0<(i=this.getSelection()).length&&(this.show.statusSelection&&1=this.columns.length)return null;var n=this.records[e].w2ui,r=(this.columns[t],this.columns[s]),a=n&&n.colspan&&!isNaN(n.colspan[r.field])?parseInt(n.colspan[r.field]):1;if(null==r)return null;if(r&&r.hidden||0===a)return this.nextCell(e,s,i);if(i){var l=this.getCellEditable(e,t);if(null==l||-1!=["checkbox","check"].indexOf(l.type))return this.nextCell(e,s,i)}return s},prevCell:function(e,t,i){var s=t-1;if(s<0)return null;var n=this.records[e].w2ui,r=this.columns[s],a=n&&n.colspan&&!isNaN(n.colspan[r.field])?parseInt(n.colspan[r.field]):1;if(null==r)return null;if(r&&r.hidden||0===a)return this.prevCell(e,s,i);if(i){var l=this.getCellEditable(e,t);if(null==l||-1!=["checkbox","check"].indexOf(l.type))return this.prevCell(e,s,i)}return s},nextRow:function(e,t){var i=this.last.searchIds,s=null;if(e+1this.records.length);)e++;var n=this.records[e].w2ui,r=this.columns[t],s=0===(n&&n.colspan&&null!=r&&!isNaN(n.colspan[r.field])?parseInt(n.colspan[r.field]):1)?this.nextRow(e,t):e}return s},prevRow:function(e,t){var i=this.last.searchIds,s=null;if(0i[0]){if(e--,0'+e+"",buttons:'",onOpen:function(e){setTimeout(function(){$(this.box).find(".w2ui-btn").focus()},25)},onClose:function(e){"function"==typeof t&&t()}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-grid-header:visible",body:".w2ui-grid-box"},e)}},$.extend(w2grid.prototype,w2utils.event),w2obj.grid=w2grid}(jQuery),function(z){function l(e){this.box=null,this.name=null,this.panels=[],this.tmp={},this.padding=1,this.resizer=4,this.style="",z.extend(!0,this,w2obj.layout,e)}var D=["top","left","main","preview","right","bottom"];z.fn.w2layout=function(e){if(z.isPlainObject(e)){if(!w2utils.checkName(e,"w2layout"))return;var t=e.panels||[],i=new l(e);z.extend(i,{handlers:[],panels:[]});for(var s=0,n=t.length;s"+t+""),r.status=!0,r;if(null==n)return console.log("ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css"),r.error=!0,r;if(null==t)return r;var a=this.trigger({phase:"before",type:"content",target:e,object:n,content:t,transition:i});if(!0===a.isCancelled)return r.cancelled=!0,r;if(t instanceof jQuery)return console.log("ERROR: You can not pass jQuery object to w2layout.content() method"),r;var l,o,d="#layout_"+this.name+"_panel_"+n.type,u=z(d+"> .w2ui-panel-content"),c=0;return 0 .w2ui-panel-content")).after('
'),o=z(d+"> .w2ui-panel-content.new-panel"),l.css("top",c),o.css("top",c),"object"==typeof t?(t.box=o[0],t.render()):o.html(t),w2utils.transition(l[0],o[0],i,function(){l.remove(),o.removeClass("new-panel"),o.css("overflow",n.overflow),z(d+"> .w2ui-panel-content").slice(1).remove(),s.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){s.resize()},100)}))),this.refresh(e),s.trigger(z.extend(a,{phase:"after"})),s.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){s.resize()},100),r},message:function(e,t){var i=this;"string"==typeof t&&(t={width:t.length<300?350:550,height:t.length<300?170:250,body:'
'+t+"
",buttons:'",onOpen:function(e){setTimeout(function(){z(this.box).find(".w2ui-btn").focus()},25)}});var s,n=this.get(e),r=z("#layout_"+this.name+"_panel_"+n.type).css("overflow");t&&(t.onClose&&(s=t.onClose),t.onClose=function(e){"function"==typeof s&&s(e),e.done(function(){z("#layout_"+i.name+"_panel_"+n.type).css("overflow",r)})}),z("#layout_"+this.name+"_panel_"+n.type).css("overflow","hidden"),w2utils.message.call(this,{box:z("#layout_"+this.name+"_panel_"+n.type),param:e,path:"w2ui."+this.name,title:".w2ui-panel-title:visible",body:".w2ui-panel-content"},t)},load:function(s,e,n,r){var a=this;return"css"==s?(z.get(e,function(e,t,i){a.html(s,i.responseText),r&&r()}),!0):null!=this.get(s)&&(z.get(e,function(e,t,i){a.html(s,i.responseText,n),r&&r(),a.resize(),-1!=window.navigator.userAgent.indexOf("MSIE")&&setTimeout(function(){a.resize()},100)}),!0)},sizeTo:function(e,t,i){var s=this;return null!=s.get(e)&&(z(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",!0!==i?".2s":"0s")),setTimeout(function(){s.set(e,{size:t})},1),setTimeout(function(){z(s.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),s.resize()},500),!0)},show:function(e,t){var i=this,s=this.trigger({phase:"before",type:"show",target:e,object:this.get(e),immediate:t});if(!0!==s.isCancelled){var n=i.get(e);return null==n?!1:(!(n.hidden=!1)===t?(z("#layout_"+i.name+"_panel_"+e).css({opacity:"1"}),i.trigger(z.extend(s,{phase:"after"})),i.resize()):(z("#layout_"+i.name+"_panel_"+e).css({opacity:"0"}),z(i.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),setTimeout(function(){i.resize()},1),setTimeout(function(){z("#layout_"+i.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(function(){z(i.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),i.trigger(z.extend(s,{phase:"after"})),i.resize()},500)),!0)}},hide:function(e,t){var i=this,s=this.trigger({phase:"before",type:"hide",target:e,object:this.get(e),immediate:t});if(!0!==s.isCancelled){var n=i.get(e);return null==n?!1:((n.hidden=!0)===t?(z("#layout_"+i.name+"_panel_"+e).css({opacity:"0"}),i.trigger(z.extend(s,{phase:"after"})),i.resize()):(z(i.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition",".2s")),z("#layout_"+i.name+"_panel_"+e).css({opacity:"0"}),setTimeout(function(){i.resize()},1),setTimeout(function(){z(i.box).find(" > div > .w2ui-panel").css(w2utils.cssPrefix("transition","0s")),i.trigger(z.extend(s,{phase:"after"})),i.resize()},500)),!0)}},toggle:function(e,t){var i=this.get(e);return null!=i&&(i.hidden?this.show(e,t):this.hide(e,t))},set:function(e,t){var i=this.get(e,!0);return null!=i&&(z.extend(this.panels[i],t),null==t.content&&null==t.resizable||this.refresh(e),this.resize(),!0)},get:function(e,t){for(var i=0;i .w2ui-panel-content");return 1!=t.length?null:t[0]},hideToolbar:function(e){var t=this.get(e);t&&(t.show.toolbar=!1,z("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").hide(),this.resize())},showToolbar:function(e){var t=this.get(e);t&&(t.show.toolbar=!0,z("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").show(),this.resize())},toggleToolbar:function(e){var t=this.get(e);t&&(t.show.toolbar?this.hideToolbar(e):this.showToolbar(e))},assignToolbar:function(e,t){"string"==typeof t&&null!=w2ui[t]&&(t=w2ui[t]);var i=this.get(e);i.toolbar=t;var s=z(this.box).find(e+"> .w2ui-panel-toolbar");null!=i.toolbar?(0===s.find("[name="+i.toolbar.name+"]").length?s.w2render(i.toolbar):null!=i.toolbar&&i.toolbar.refresh(),(t.owner=this).showToolbar(e),this.refresh(e)):(s.html(""),this.hideToolbar(e))},hideTabs:function(e){var t=this.get(e);t&&(t.show.tabs=!1,z("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").hide(),this.resize())},showTabs:function(e){var t=this.get(e);t&&(t.show.tabs=!0,z("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").show(),this.resize())},toggleTabs:function(e){var t=this.get(e);t&&(t.show.tabs?this.hideTabs(e):this.showTabs(e))},render:function(e){var c=this,t=(new Date).getTime(),i=c.trigger({phase:"before",type:"render",target:c.name,box:e});if(!0!==i.isCancelled){if(null!=e&&(0"),0
';z(c.box).find(" > div").append(n)}return z(c.box).find(" > div").append('
'),c.refresh(),c.trigger(z.extend(i,{phase:"after"})),setTimeout(function(){c.tmp.events={resize:function(e){null==w2ui[c.name]?z(window).off("resize.w2ui-"+c.name):w2ui[c.name].resize()},resizeStart:r,mouseMove:l,mouseUp:a},z(window).on("resize.w2ui-"+c.name,c.tmp.events.resize),c.resize()},0),(new Date).getTime()-t}function r(e,t){if(c.box){t=t||window.event,z(document).off("mousemove",c.tmp.events.mouseMove).on("mousemove",c.tmp.events.mouseMove),z(document).off("mouseup",c.tmp.events.mouseUp).on("mouseup",c.tmp.events.mouseUp),c.tmp.resize={type:e,x:t.screenX,y:t.screenY,diff_x:0,diff_y:0,value:0};for(var i=0;it.width&&(r=t.minSize-t.width),t.maxSize&&t.width+r>t.maxSize&&(r=t.maxSize-t.width),l.minSize+r>l.width&&(r=l.width-l.minSize);break;case"right":t.minSize+r>t.width&&(r=t.width-t.minSize),t.maxSize&&t.width-r>t.maxSize&&(r=t.width-t.maxSize),l.minSize-r>l.width&&(r=l.minSize-l.width);break;case"top":t.minSize-a>t.height&&(a=t.minSize-t.height),t.maxSize&&t.height+a>t.maxSize&&(a=t.maxSize-t.height),l.minSize+a>l.height&&(a=l.height-l.minSize);break;case"preview":case"bottom":t.minSize+a>t.height&&(a=t.height-t.minSize),t.maxSize&&t.height-a>t.maxSize&&(a=t.height-t.maxSize),l.minSize-a>l.height&&(a=l.minSize-l.height)}switch(i.diff_x=r,i.diff_y=a,i.type){case"top":case"preview":case"bottom":(i.diff_x=0) .w2ui-panel-content")[0],setTimeout(function(){0 .w2ui-panel-content").length&&(z(r+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",n.overflow)[0].style.cssText+=";"+n.style),n.content&&"function"==typeof n.content.render&&n.content.render()},1)):0 .w2ui-panel-content").length&&(z(r+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(n.content).css("overflow",n.overflow)[0].style.cssText+=";"+n.style);var l=z(t.box).find(r+"> .w2ui-panel-tabs");n.show.tabs?0===l.find("[name="+n.tabs.name+"]").length&&null!=n.tabs?l.w2render(n.tabs):n.tabs.refresh():l.html("").removeClass("w2ui-tabs").hide(),l=z(t.box).find(r+"> .w2ui-panel-toolbar"),n.show.toolbar?0===l.find("[name="+n.toolbar.name+"]").length&&null!=n.toolbar?l.w2render(n.toolbar):n.toolbar.refresh():l.html("").removeClass("w2ui-toolbar").hide(),l=z(t.box).find(r+"> .w2ui-panel-title"),n.title?l.html(n.title).show():l.html("").hide()}else{if(0===z("#layout_"+t.name+"_panel_main").length)return void t.render();t.resize();for(var o=0;o div").css({width:s+"px",height:n+"px"});for(var r,a,l,o,d,u,c,h=this,p=this.get("main"),f=this.get("preview"),g=this.get("left"),m=this.get("right"),w=this.get("top"),v=this.get("bottom"),y=null!=f&&!0!==f.hidden,b=null!=g&&!0!==g.hidden,x=null!=m&&!0!==m.hidden,_=null!=w&&!0!==w.hidden,k=null!=v&&!0!==v.hidden,C=0;Cthis.padding?this.resizer:this.padding,z("#layout_"+this.name+"_resizer_top").show().css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){var t=h.trigger({phase:"before",type:"resizerClick",target:"top",originalEvent:e});if(!0!==t.isCancelled)return w2ui[h.name].tmp.events.resizeStart("top",e),h.trigger(z.extend(t,{phase:"after"})),!1}))):(z("#layout_"+this.name+"_panel_top").hide(),z("#layout_"+this.name+"_resizer_top").hide()),null!=g&&!0!==g.hidden?(a=(r=0)+(_?w.sizeCalculated+this.padding:0),l=g.sizeCalculated,o=n-(_?w.sizeCalculated+this.padding:0)-(k?v.sizeCalculated+this.padding:0),d=z("#layout_"+this.name+"_panel_left"),-1!=window.navigator.userAgent.indexOf("MSIE")&&0this.padding?this.resizer:this.padding,z("#layout_"+this.name+"_resizer_left").show().css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){var t=h.trigger({phase:"before",type:"resizerClick",target:"left",originalEvent:e});if(!0!==t.isCancelled)return w2ui[h.name].tmp.events.resizeStart("left",e),h.trigger(z.extend(t,{phase:"after"})),!1}))):(z("#layout_"+this.name+"_panel_left").hide(),z("#layout_"+this.name+"_resizer_left").hide()),null!=m&&!0!==m.hidden?(r=s-m.sizeCalculated,a=0+(_?w.sizeCalculated+this.padding:0),l=m.sizeCalculated,o=n-(_?w.sizeCalculated+this.padding:0)-(k?v.sizeCalculated+this.padding:0),z("#layout_"+this.name+"_panel_right").css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px"}).show(),m.width=l,m.height=o,m.resizable&&(r-=this.padding,l=this.resizer>this.padding?this.resizer:this.padding,z("#layout_"+this.name+"_resizer_right").show().css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){var t=h.trigger({phase:"before",type:"resizerClick",target:"right",originalEvent:e});if(!0!==t.isCancelled)return w2ui[h.name].tmp.events.resizeStart("right",e),h.trigger(z.extend(t,{phase:"after"})),!1}))):(z("#layout_"+this.name+"_panel_right").hide(),z("#layout_"+this.name+"_resizer_right").hide()),null!=v&&!0!==v.hidden?(r=0,a=n-v.sizeCalculated,l=s,o=v.sizeCalculated,z("#layout_"+this.name+"_panel_bottom").css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px"}).show(),v.width=l,v.height=o,v.resizable&&(a-=0===this.padding?0:this.padding,o=this.resizer>this.padding?this.resizer:this.padding,z("#layout_"+this.name+"_resizer_bottom").show().css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){var t=h.trigger({phase:"before",type:"resizerClick",target:"bottom",originalEvent:e});if(!0!==t.isCancelled)return w2ui[h.name].tmp.events.resizeStart("bottom",e),h.trigger(z.extend(t,{phase:"after"})),!1}))):(z("#layout_"+this.name+"_panel_bottom").hide(),z("#layout_"+this.name+"_resizer_bottom").hide()),r=0+(b?g.sizeCalculated+this.padding:0),a=0+(_?w.sizeCalculated+this.padding:0),l=s-(b?g.sizeCalculated+this.padding:0)-(x?m.sizeCalculated+this.padding:0),o=n-(_?w.sizeCalculated+this.padding:0)-(k?v.sizeCalculated+this.padding:0)-(y?f.sizeCalculated+this.padding:0),d=z("#layout_"+this.name+"_panel_main"),-1!=window.navigator.userAgent.indexOf("MSIE")&&0this.padding?this.resizer:this.padding,z("#layout_"+this.name+"_resizer_preview").show().css({display:"block",left:r+"px",top:a+"px",width:l+"px",height:o+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){var t=h.trigger({phase:"before",type:"resizerClick",target:"preview",originalEvent:e});if(!0!==t.isCancelled)return w2ui[h.name].tmp.events.resizeStart("preview",e),h.trigger(z.extend(t,{phase:"after"})),!1}))):(z("#layout_"+this.name+"_panel_preview").hide(),z("#layout_"+this.name+"_resizer_preview").hide());for(var T=0;T .w2ui-panel-",O=0;S&&(S.title&&(O+=w2utils.getSize(z($+"title").css({top:O+"px",display:"block"}),"height")),S.show.tabs&&(null!=S.tabs&&w2ui[this.name+"_"+D[T]+"_tabs"]&&w2ui[this.name+"_"+D[T]+"_tabs"].resize(),O+=w2utils.getSize(z($+"tabs").css({top:O+"px",display:"block"}),"height")),S.show.toolbar&&(null!=S.toolbar&&w2ui[this.name+"_"+D[T]+"_toolbar"]&&w2ui[this.name+"_"+D[T]+"_toolbar"].resize(),O+=w2utils.getSize(z($+"toolbar").css({top:O+"px",display:"block"}),"height"))),z($+"content").css({display:"block"}).css({top:O+"px"})}return clearTimeout(this._resize_timer),this._resize_timer=setTimeout(function(){for(var e in w2ui){var t;"function"==typeof w2ui[e].resize&&(null==w2ui[e].panels&&w2ui[e].resize(),0<(t=z(w2ui[e].box).parents(".w2ui-layout")).length&&t.attr("name")==h.name&&w2ui[e].resize())}},100),this.trigger(z.extend(i,{phase:"after"})),(new Date).getTime()-e}},destroy:function(){var e=this.trigger({phase:"before",type:"destroy",target:this.name});if(!0!==e.isCancelled)return null!=w2ui[this.name]&&(0"+e+""),"object"==typeof t&&(i.buttons+='"),"string"==typeof t&&(i.buttons+=t)})),0===m("#w2ui-popup").length){if(!0===(a=this.trigger({phase:"before",type:"open",target:"popup",options:i,present:!1})).isCancelled)return;w2popup.status="opening",w2popup.lockScreen(i);var d="";i.showClose&&(d+='
Close
'),i.showMax&&(d+='
Max
');var u='
';m("body").append(u);var c=m("#w2ui-popup");0'+d+'
';m("#w2ui-popup").html(u),i.title&&m("#w2ui-popup .w2ui-popup-title").append(i.title),i.buttons&&m("#w2ui-popup .w2ui-popup-buttons").append(i.buttons),i.body&&m("#w2ui-popup .w2ui-popup-body").append(i.body),setTimeout(function(){m("#w2ui-popup").css(w2utils.cssPrefix({transition:i.speed+"s opacity, "+i.speed+"s -webkit-transform"})).removeClass("w2ui-popup-opening"),t.focus()},1),setTimeout(function(){m("#w2ui-popup").css(w2utils.cssPrefix("transform",""))},1e3*i.speed),w2popup.status="open",t.trigger(m.extend(a,{phase:"after"}))}else if(!0===i.multiple)w2popup.message(e);else{if(null==w2popup._prev&&null!=w2popup._template&&t.restoreTemplate(),!0===(a=this.trigger({phase:"before",type:"open",target:"popup",options:i,present:!0})).isCancelled)return;w2popup.status="opening",null!=r&&(r.maximized||r.width==i.width&&r.height==i.height||w2popup.resize(i.width,i.height),i.prevSize=i.width+"px:"+i.height+"px",i.maximized=r.maximized);var h=m("#w2ui-popup .w2ui-box").clone();h.removeClass("w2ui-box").addClass("w2ui-box-temp").find(".w2ui-popup-body").empty().append(i.body),"string"==typeof i.body&&0Close':"")+(i.showMax?'
Max
':"")).append(i.title),m("#w2ui-popup .w2ui-popup-body").removeClass("w2ui-popup-no-title"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","")):(m("#w2ui-popup .w2ui-popup-title").hide().html(""),m("#w2ui-popup .w2ui-popup-body").addClass("w2ui-popup-no-title"),m("#w2ui-popup .w2ui-box, #w2ui-popup .w2ui-box-temp").css("top","0px"));var p=m("#w2ui-popup .w2ui-box")[0],f=m("#w2ui-popup .w2ui-box-temp")[0];w2utils.transition(p,f,i.transition,function(){t.restoreTemplate(),m(p).remove(),m(f).removeClass("w2ui-box-temp").addClass("w2ui-box");var e=m(f).find(".w2ui-popup-body");1==e.length&&(e[0].style.cssText=i.style),m("#w2ui-popup").data("prev-size",null),t.focus()}),w2popup.status="open",t.trigger(m.extend(a,{phase:"after"}))}i._last_focus=m(":focus"),i.keyboard&&m(document).on("keydown",this.keydown);var g={resizing:!1,mvMove:function(e){if(1!=g.resizing)return;e=e||window.event;g.div_x=e.screenX-g.x,g.div_y=e.screenY-g.y;var t=w2popup.trigger({phase:"before",type:"move",target:"popup",div_x:g.div_x,div_y:g.div_y});if(!0===t.isCancelled)return;m("#w2ui-popup").css(w2utils.cssPrefix({transition:"none",transform:"translate3d("+g.div_x+"px, "+g.div_y+"px, 0px)"})),w2popup.trigger(m.extend(t,{phase:"after"}))},mvStop:function(e){if(1!=g.resizing)return;e=e||window.event;w2popup.status="open",g.div_x=e.screenX-g.x,g.div_y=e.screenY-g.y,m("#w2ui-popup").css({left:g.pos_x+g.div_x+"px",top:g.pos_y+g.div_y+"px"}).css(w2utils.cssPrefix({transition:"none",transform:"translate3d(0px, 0px, 0px)"})),g.resizing=!1,m(document).off("mousemove",g.mvMove),m(document).off("mouseup",g.mvStop),g.isLocked||w2popup.unlock()}};return m("#w2ui-popup .w2ui-popup-title").on("mousedown",function(e){w2popup.get().maximized||function(e){e=e||window.event;w2popup.status="moving",g.resizing=!0,g.isLocked=1==m("#w2ui-popup > .w2ui-lock").length,g.x=e.screenX,g.y=e.screenY,g.pos_x=m("#w2ui-popup").position().left,g.pos_y=m("#w2ui-popup").position().top,g.isLocked||w2popup.lock({opacity:0});m(document).on("mousemove",g.mvMove),m(document).on("mouseup",g.mvStop),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0;{if(!e.preventDefault)return;e.preventDefault()}}(e)}),this}setTimeout(function(){t.open.call(t,i)},100)},action:function(e,t){var i=this,s=m("#w2ui-popup").data("options");null!=t&&(i={parent:this,options:s=m("#w2ui-message"+t).data("options"),close:function(){w2popup.message({msgId:t})}});var n=s.actions[e],r=n;m.isPlainObject(n)&&n.onClick&&(r=n.onClick);var a=this.trigger({phase:"before",target:e,msgId:t,type:"action",action:n,originalEvent:event});!0!==a.isCancelled&&("function"==typeof r&&r.call(i,event),this.trigger(m.extend(a,{phase:"after"})))},keydown:function(e){var t,i=m("#w2ui-popup").data("options");i&&!i.keyboard||!0!==(t=w2popup.trigger({phase:"before",type:"keydown",target:"popup",options:i,originalEvent:e})).isCancelled&&(27===e.keyCode&&(e.preventDefault(),0
':i.prefix="",l.addPrefix(),t=l.helpers.focus.find("input"),""===x(t).val()?(x(t).css("text-indent","-9999em").prev().css("opacity",0),x(l.el).val(o&&null!=o.text?w2utils.lang(o.text):"")):(x(t).css("text-indent",0).prev().css("opacity",1),x(l.el).val(""),setTimeout(function(){l.helpers.prefix&&l.helpers.prefix.hide();var e="position: absolute; opacity: 0; margin: 4px 0px 0px 2px; background-position: left !important;";i.icon?(x(t).css("margin-left","17px"),x(l.helpers.focus).find(".icon-search").attr("style",e+"width: 11px !important; opacity: 1; display: block")):(x(t).css("margin-left","0px"),x(l.helpers.focus).find(".icon-search").attr("style",e+"width: 0px !important; opacity: 0; display: none"))},1)),x(l.el).prop("readonly")||x(l.el).prop("disabled")?setTimeout(function(){x(l.helpers.prefix).css("opacity","0.6"),x(l.helpers.suffix).css("opacity","0.6")},1):setTimeout(function(){x(l.helpers.prefix).css("opacity","1"),x(l.helpers.suffix).css("opacity","1")},1))},1)),-1!==["enum","file"].indexOf(this.type)){var t="";if(o)for(var s=0;s  '):'
  
'+("enum"===l.type?n.text:n.name+' - '+w2utils.formatSize(n.size)+"");t+='
  • '+r+"
  • "}var a,d=l.helpers.multi,u=d.find("ul");d.attr("style",d.attr("style")+";"+i.style),x(l.el).css("z-index","-1"),x(l.el).prop("readonly")||x(l.el).prop("disabled")?setTimeout(function(){d[0].scrollTop=0,d.addClass("w2ui-readonly").find("li").css("opacity","0.9").parent().find("li.nomouse").hide().find("input").prop("readonly",!0).parents("ul").find(".w2ui-list-remove").hide()},1):setTimeout(function(){d.removeClass("w2ui-readonly").find("li").css("opacity","1").parent().find("li.nomouse").show().find("input").prop("readonly",!1).parents("ul").find(".w2ui-list-remove").show()},1),d.find(".w2ui-enum-placeholder").remove(),u.find("li").not("li.nomouse").remove(),""!==t?u.prepend(t):null!=x(l.el).attr("placeholder")&&""===d.find("input").val()&&(a="padding-top: "+x(this.el).css("padding-top")+";padding-left: "+x(this.el).css("padding-left")+"; box-sizing: "+x(this.el).css("box-sizing")+"; line-height: "+x(this.el).css("line-height")+"; font-size: "+x(this.el).css("font-size")+"; font-family: "+x(this.el).css("font-family")+"; ",d.prepend('
    '+x(l.el).attr("placeholder")+"
    ")),d.off("scroll.w2field").on("scroll.w2field",function(e){var t=l.trigger({phase:"before",type:"scroll",target:l.el,originalEvent:e});!0!==t.isCancelled&&l.trigger(x.extend(t,{phase:"after"}))}).find("li").data("mouse","out").on("click",function(e){var t,i,s,n,r="LI"===e.target.tagName.toUpperCase()?e.target:x(e.target).parents("LI"),a=o[x(r).attr("index")];if(!x(r).hasClass("nomouse"))if(e.stopPropagation(),x(e.target).hasClass("w2ui-list-remove")){if(x(l.el).prop("readonly")||x(l.el).prop("disabled"))return;if(!0===(t=l.trigger({phase:"before",type:"remove",target:l.el,originalEvent:e.originalEvent,item:a})).isCancelled)return;x().w2overlay(),o.splice(x(e.target).attr("index"),1),x(l.el).trigger("input").trigger("change"),x(e.target).parent().fadeOut("fast"),setTimeout(function(){l.refresh(),l.trigger(x.extend(t,{phase:"after"}))},300)}else{if(!0===(t=l.trigger({phase:"before",type:"click",target:l.el,originalEvent:e.originalEvent,item:a})).isCancelled)return;"file"===l.type&&(i="",/image/i.test(a.type)&&(i='
    '),n='style="padding: 3px"',i+='
    "+w2utils.lang("Name")+":"+a.name+"
    "+w2utils.lang("Size")+":"+w2utils.formatSize(a.size)+"
    "+w2utils.lang("Type")+": '+a.type+"
    "+w2utils.lang("Modified")+":"+w2utils.date(a.modified)+"
    ",x("#w2ui-overlay").remove(),x(r).w2overlay(i)),l.trigger(x.extend(t,{phase:"after"}))}}).on("mouseover",function(e){var t="LI"===e.target.tagName.toUpperCase()?e.target:x(e.target).parents("LI");if(!x(t).hasClass("nomouse")){if("out"===x(t).data("mouse")){var i=o[x(e.target).attr("index")],s=l.trigger({phase:"before",type:"mouseOver",target:l.el,originalEvent:e.originalEvent,item:i});if(!0===s.isCancelled)return;l.trigger(x.extend(s,{phase:"after"}))}x(t).data("mouse","over")}}).on("mouseout",function(i){var s="LI"===i.target.tagName.toUpperCase()?i.target:x(i.target).parents("LI");x(s).hasClass("nomouse")||(x(s).data("mouse","leaving"),setTimeout(function(){if("leaving"===x(s).data("mouse")){x(s).data("mouse","out");var e=o[x(i.target).attr("index")],t=l.trigger({phase:"before",type:"mouseOut",target:l.el,originalEvent:i.originalEvent,item:e});if(!0===t.isCancelled)return;l.trigger(x.extend(t,{phase:"after"}))}},0))}),x(this.el).height("auto");var c=x(d).find("> div.w2ui-multi-items").height()+2*w2utils.getSize(d,"+height");c<26&&(c=26),c>i.maxHeight&&(c=i.maxHeight),0',r.addSuffix()),s&&r.addPrefix(),r.tmp.current_width=a)},clean:function(e){if("number"==typeof e)return e;var t=this.options;return e=String(e).trim(),-1!==["int","float","money","currency","percent"].indexOf(this.type)&&("string"==typeof e&&(t.autoFormat&&-1!==["money","currency"].indexOf(this.type)&&(e=String(e).replace(t.moneyRE,"")),t.autoFormat&&"percent"===this.type&&(e=String(e).replace(t.percentRE,"")),t.autoFormat&&-1!==["int","float"].indexOf(this.type)&&(e=String(e).replace(t.numberRE,"")),e=e.replace(/\s+/g,"").replace(w2utils.settings.groupSymbol,"").replace(w2utils.settings.decimalSymbol,".")),parseFloat(e)==e&&(null!=t.min&&et.max&&(e=t.max,x(this.el).val(t.max))),e=""!==e&&w2utils.isFloat(e)?Number(e):""),e},format:function(e){var t=this.options;if(t.autoFormat&&""!==e)switch(this.type){case"money":case"currency":""!==(e=w2utils.formatNumber(e,t.currencyPrecision,t.groupSymbol))&&(e=t.currencyPrefix+e+t.currencySuffix);break;case"percent":""!==(e=w2utils.formatNumber(e,t.precision,t.groupSymbol))&&(e+="%");break;case"float":e=w2utils.formatNumber(e,t.precision,t.groupSymbol);break;case"int":e=w2utils.formatNumber(e,0,t.groupSymbol)}return e},change:function(e){var t,i,s,n=this,r=n.options;if(-1!==["int","float","money","currency","percent"].indexOf(this.type)){var a=x(this.el).val(),l=this.format(this.clean(x(this.el).val()));if(""!==a&&a!=l)return x(this.el).val(l).trigger("input").change(),e.stopPropagation(),e.preventDefault(),!1}"color"===this.type&&("rgb"!==(t=x(this.el).val()).substr(0,3).toLowerCase()&&(t="#"+t,8!==(i=x(this.el).val().length)&&6!==i&&3!==i&&(t="")),x(this.el).next().find("div").css("background-color",t),x(this.el).hasClass("has-focus")&&!0!==x(this.el).data("skipInit")&&this.updateOverlay()),-1!==["list","enum","file"].indexOf(this.type)&&(n.refresh(),setTimeout(function(){n.refresh()},5)),-1!==["date","time","datetime"].indexOf(this.type)&&(s=parseInt(n.el.value),w2utils.isInt(n.el.value)&&3e3=s.min||null==s.min?Number((a-l).toFixed(12)):s.min;x(i.el).val(o).trigger("input").change(),r=!0}r&&(e.preventDefault(),setTimeout(function(){i.el.setSelectionRange(i.el.value.length,i.el.value.length)},0))}if("date"===i.type){if(!s.keyboard||x(i.el).prop("readonly")||x(i.el).prop("disabled"))return;var d=864e5,l=1;switch((e.ctrlKey||e.metaKey)&&(l=10),(h=w2utils.isDate(x(i.el).val(),s.format,!0))||(h=new Date,d=0),n){case 38:if(e.shiftKey)break;var u=w2utils.formatDate(h.getTime()+d,s.format);10==l&&(u=w2utils.formatDate(new Date(h.getFullYear(),h.getMonth()+1,h.getDate()),s.format)),x(i.el).val(u).trigger("input").change(),r=!0;break;case 40:if(e.shiftKey)break;u=w2utils.formatDate(h.getTime()-d,s.format);10==l&&(u=w2utils.formatDate(new Date(h.getFullYear(),h.getMonth()-1,h.getDate()),s.format)),x(i.el).val(u).trigger("input").change(),r=!0}r&&(e.preventDefault(),setTimeout(function(){i.el.setSelectionRange(i.el.value.length,i.el.value.length),i.updateOverlay()},0))}if("time"===i.type){if(!s.keyboard||x(i.el).prop("readonly")||x(i.el).prop("disabled"))return;var l=e.ctrlKey||e.metaKey?60:1,a=x(i.el).val(),c=i.toMin(a)||i.toMin((new Date).getHours()+":"+((new Date).getMinutes()-1));switch(n){case 38:if(e.shiftKey)break;c+=l,r=!0;break;case 40:if(e.shiftKey)break;c-=l,r=!0}r&&(x(i.el).val(i.fromMin(c)).trigger("input").change(),e.preventDefault(),setTimeout(function(){i.el.setSelectionRange(i.el.value.length,i.el.value.length)},0))}if("datetime"===i.type){if(!s.keyboard||x(i.el).prop("readonly")||x(i.el).prop("disabled"))return;d=864e5,l=1;(e.ctrlKey||e.metaKey)&&(l=10);var h,p=x(i.el).val();switch((h=w2utils.isDateTime(p,this.options.format,!0))||(h=new Date,d=0),n){case 38:if(e.shiftKey)break;u=w2utils.formatDateTime(h.getTime()+d,s.format);10==l&&(u=w2utils.formatDateTime(new Date(h.getFullYear(),h.getMonth()+1,h.getDate()),s.format)),x(i.el).val(u).trigger("input").change(),r=!0;break;case 40:if(e.shiftKey)break;u=w2utils.formatDateTime(h.getTime()-d,s.format);10==l&&(u=w2utils.formatDateTime(new Date(h.getFullYear(),h.getMonth()-1,h.getDate()),s.format)),x(i.el).val(u).trigger("input").change(),r=!0}r&&(e.preventDefault(),setTimeout(function(){i.el.setSelectionRange(i.el.value.length,i.el.value.length),i.updateOverlay()},0))}if("color"===i.type){if(x(i.el).prop("readonly")||x(i.el).prop("disabled"))return;if((e.ctrlKey||e.metaKey)&&!e.shiftKey){var f,g=null;switch(n){case 38:g="up";break;case 40:g="down";break;case 39:g="right";break;case 37:g="left"}i.el.nav&&null!=g&&(f=i.el.nav(g),x(i.el).val(f).trigger("input").change(),e.preventDefault())}}if(-1!==["list","combo","enum"].indexOf(i.type)){if(x(i.el).prop("readonly")||x(i.el).prop("disabled"))return;var m=x(i.el).data("selected"),w=x(i.el),v=!1;switch(-1!==["list","enum"].indexOf(i.type)&&("list"===i.type&&(w=x(i.helpers.focus).find("input")),"enum"===i.type&&(w=x(i.helpers.multi).find("input")),-1==[37,38,39,40].indexOf(n)&&setTimeout(function(){i.refresh()},1),86==e.keyCode&&(e.ctrlKey||e.metaKey)&&setTimeout(function(){i.refresh(),i.search(),i.request()},50)),n){case 27:"list"===i.type&&(""!==w.val()&&w.val(""),e.stopPropagation());break;case 37:case 39:break;case 13:if(0===x("#w2ui-overlay").length)break;var y=s.items[s.index];if("enum"===i.type)if(null!=y){if(!0===(b=i.trigger({phase:"before",type:"add",target:i.el,originalEvent:e.originalEvent,item:y})).isCancelled)return;y=b.item,m.length>=s.max&&0=s.max&&0=s.items.length&&(s.index=s.items.length-1),i.updateOverlay(v),e.preventDefault(),void setTimeout(function(){var e;"enum"===i.type||"list"===i.type?(e=w.get(0)).setSelectionRange(e.value.length,e.value.length):i.el.setSelectionRange(i.el.value.length,i.el.value.length)},0);"enum"===i.type&&w.width(8*(w.val().length+2)+"px")}},keyUp:function(e){if(-1!==["list","combo","enum"].indexOf(this.type)){if(x(this.el).prop("readonly")||x(this.el).prop("disabled"))return;if(-1==[16,17,18,20,37,39,91].indexOf(e.keyCode)){var t=x(this.helpers.focus).find("input");0===t.length&&(t=x(this.el));var i=this.trigger({phase:"before",type:"search",originalEvent:e,target:t,search:t.val()});if(!0===i.isCancelled)return;this.tmp.force_hide||this.request(),1==t.val().length&&this.refresh(),0!==x("#w2ui-overlay").length&&-1!=[38,40].indexOf(e.keyCode)||this.search(),this.trigger(x.extend(i,{phase:"after"}))}}},clearCache:function(){this.options.items=[],this.tmp.xhr_loading=!1,this.tmp.xhr_search="",this.tmp.xhr_total=-1},request:function(e){var t,l=this,o=this.options,d=x(l.el).val()||"";if(o.url){if("enum"===l.type&&(d=0===(t=x(l.helpers.multi).find("input")).length?"":t.val()),"list"===l.type&&(t=x(l.helpers.focus).find("input"),d=0===t.length?"":t.val()),0!==o.minLength&&d.lengthl.tmp.xhr_search.length||d.length>=l.tmp.xhr_search.length&&d.substr(0,l.tmp.xhr_search.length)!==l.tmp.xhr_search||d.lengtho.cacheMax&&e.records.splice(o.cacheMax,1e5),null==o.recId&&null!=o.recid&&(o.recId=o.recid),(o.recId||o.recText)&&e.records.forEach(function(e){"string"==typeof o.recId&&(e.id=e[o.recId]),"function"==typeof o.recId&&(e.id=o.recId(e)),"string"==typeof o.recText&&(e.text=e[o.recText]),"function"==typeof o.recText&&(e.text=o.recText(e))}),l.tmp.xhr_loading=!1,l.tmp.xhr_search=d,l.tmp.xhr_total=e.records.length,l.tmp.lastError="",o.items=l.normMenu(e.records),""===d&&0===e.records.length?l.tmp.emptySet=!0:l.tmp.emptySet=!1,(s=x(l.el).data("find_selected"))&&(Array.isArray(s)?(n=[],s.forEach(function(t){var i=!1;o.items.forEach(function(e){(e.id==t||t&&t.id==e.id)&&(n.push(x.extend(!0,{},e)),i=!0)}),i||n.push(t)})):(n=s,o.items.forEach(function(e){(e.id==s||s&&s.id==e.id)&&(n=e)})),x(l.el).data("selected",n).removeData("find_selected").trigger("input").change()),l.search(),l.trigger(x.extend(r,{phase:"after"}))):console.log("ERROR: server did not return proper structure. It should return",{status:"success",records:[{id:1,text:"item"}]}))}).fail(function(e,t,i){var s,n={status:t,error:i,rawResponseText:e.responseText},r=l.trigger({phase:"before",type:"error",target:l.el,search:d,error:n,xhr:e});if(!0!==r.isCancelled){if("abort"!==t){try{s=x.parseJSON(e.responseText)}catch(e){}console.log("ERROR: Server communication failed.","\n EXPECTED:",{status:"success",records:[{id:1,text:"item"}]},"\n OR:",{status:"error",message:"error message"},"\n RECEIVED:","object"==typeof s?s:e.responseText)}l.tmp.xhr_loading=!1,l.tmp.xhr_search=d,l.tmp.xhr_total=0,l.tmp.emptySet=!0,l.tmp.lastError=r.error||"Server communication failed",o.items=[],l.clearCache(),l.search(),l.updateOverlay(!1),l.trigger(x.extend(r,{phase:"after"}))}}),l.trigger(x.extend(i,{phase:"after"})))},e)}}},search:function(){var e=this,t=this.options,i=x(e.el).val(),s=e.el,n=[],r=x(e.el).data("selected");if("enum"===e.type)for(var a in s=x(e.helpers.multi).find("input"),i=s.val(),r)r[a]&&n.push(r[a].id);else if("list"===e.type)for(var a in s=x(e.helpers.focus).find("input"),i=s.val(),r)r[a]&&n.push(r[a].id);var l=t.items;if(!0!==e.tmp.xhr_loading){for(var o=0,d=0;d',{css:{"background-color":"#f5f5f5"},onShow:function(e){w2utils.isIE&&x(".w2ui-calendar").on("mousedown",function(e){var t=x(e.target);1===t.length&&"w2ui-jump-year"===t[0].id&&x("#w2ui-overlay").data("keepOpen",!0)})}}),(s=w2utils.isDate(x(n.el).val(),n.options.format,!0))&&(t=s.getMonth()+1,i=s.getFullYear()),function i(e,t){x("#w2ui-overlay > div > div").html(n.getMonthHTML(e,t,x(n.el).val())),x("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){var e,t;x(this).next().hasClass("w2ui-calendar-jump")?x(this).next().remove():(x(this).after('
    '),x(this).next().hide().html(n.getYearHTML()).fadeIn(200),setTimeout(function(){x("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){x(this).hasClass("w2ui-jump-month")&&(x(this).parent().find(".w2ui-jump-month").removeClass("selected"),x(this).addClass("selected"),t=x(this).attr("name")),x(this).hasClass("w2ui-jump-year")&&(x(this).parent().find(".w2ui-jump-year").removeClass("selected"),x(this).addClass("selected"),e=x(this).attr("name")),null!=e&&null!=t&&(x("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){i(parseInt(t)+1,e)},100))}),x("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1))}),x("#w2ui-overlay .w2ui-date").on("mousedown",function(){var e=x(this).attr("date");x(n.el).val(e).trigger("input").change(),x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"})}).on("mouseup",function(){setTimeout(function(){0',{css:{"background-color":"#fff"}});var a="h24"===this.options.format;x("#w2ui-overlay > div").html(n.getHourHTML()),x("#w2ui-overlay .w2ui-time").on("mousedown",function(e){x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var t=x(this).attr("hour");x(n.el).val((12',{css:{"background-color":"#fff"}}),x("#w2ui-overlay > div").html(n.getMinHTML(t)),x("#w2ui-overlay .w2ui-time").on("mousedown",function(){x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"});var e=x(this).attr("min");x(n.el).val((12',{css:{"background-color":"#f5f5f5"},onShow:function(e){w2utils.isIE&&x(".w2ui-calendar").on("mousedown",function(e){var t=x(e.target);1===t.length&&"w2ui-jump-year"===t[0].id&&x("#w2ui-overlay").data("keepOpen",!0)})}}),(s=w2utils.isDateTime(x(n.el).val(),n.options.format,!0))&&(t=s.getMonth()+1,i=s.getFullYear());var l=null;!function i(e,t){x("#w2ui-overlay > div > div").html(n.getMonthHTML(e,t,x(n.el).val())+(r.btn_now?'
    '+w2utils.lang("Current Date & Time")+"
    ":"")),x("#w2ui-overlay .w2ui-calendar-title").on("mousedown",function(){var e,t;x(this).next().hasClass("w2ui-calendar-jump")?x(this).next().remove():(x(this).after('
    '),x(this).next().hide().html(n.getYearHTML()).fadeIn(200),setTimeout(function(){x("#w2ui-overlay .w2ui-calendar-jump").find(".w2ui-jump-month, .w2ui-jump-year").on("click",function(){x(this).hasClass("w2ui-jump-month")&&(x(this).parent().find(".w2ui-jump-month").removeClass("selected"),x(this).addClass("selected"),t=x(this).attr("name")),x(this).hasClass("w2ui-jump-year")&&(x(this).parent().find(".w2ui-jump-year").removeClass("selected"),x(this).addClass("selected"),e=x(this).attr("name")),null!=e&&null!=t&&(x("#w2ui-overlay .w2ui-calendar-jump").fadeOut(100),setTimeout(function(){i(parseInt(t)+1,e)},100))}),x("#w2ui-overlay .w2ui-calendar-jump >:last-child").prop("scrollTop",2e3)},1))}),x("#w2ui-overlay .w2ui-date").on("mousedown",function(){var e=x(this).attr("date");x(n.el).val(e).trigger("input").change(),x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),l=new Date(x(this).attr("data-date"))}).on("mouseup",function(){var i,t;0',{css:{"background-color":"#fff"}});n.options.format;x("#w2ui-overlay > div").html(n.getHourHTML()),x("#w2ui-overlay .w2ui-time").on("mousedown",function(e){x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),i=x(this).attr("hour"),l.setHours(i);var t=w2utils.formatDateTime(l,n.options.format);x(n.el).val(t).trigger("input").change()}),null==n.options.noMinutes||!1===n.options.noMinutes?x("#w2ui-overlay .w2ui-time").on("mouseup",function(){var e=x(this).attr("hour");0',{css:{"background-color":"#fff"}}),x("#w2ui-overlay > div").html(n.getMinHTML(e)),x("#w2ui-overlay .w2ui-time").on("mousedown",function(){x(this).css({"background-color":"#B6D5FB","border-color":"#aaa"}),t=x(this).attr("min"),l.setHours(i,t);var e=w2utils.formatDateTime(l,n.options.format);x(n.el).val(e).trigger("input").change()}).on("mouseup",function(){setTimeout(function(){0'+h+"";var p=x.extend(!0,{},r,{search:!1,render:r.renderDrop,maxHeight:r.maxDropHeight,maxWidth:r.maxDropWidth,msgNoItems:h,onSelect:function(i){if("enum"===n.type){var e=x(n.el).data("selected");if(i.item){var s,t=n.trigger({phase:"before",type:"add",target:n.el,originalEvent:i.originalEvent,item:i.item});if(!0===t.isCancelled)return;e.length>=r.max&&0'+i.options.prefix+""),(e=x(i.el).prev()).css({color:x(i.el).css("color"),"font-family":x(i.el).css("font-family"),"font-size":x(i.el).css("font-size"),"padding-top":x(i.el).css("padding-top"),"padding-bottom":x(i.el).css("padding-bottom"),"padding-left":x(i.el).css("padding-left"),"padding-right":0,"margin-top":parseInt(x(i.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(x(i.el).css("margin-bottom"),10)+1+"px","margin-left":x(i.el).css("margin-left"),"margin-right":0}).on("click",function(e){if(i.options.icon&&"function"==typeof i.onIconClick){var t=i.trigger({phase:"before",type:"iconClick",target:i.el,el:x(this).find("span.w2ui-icon")[0]});if(!0===t.isCancelled)return;i.trigger(x.extend(t,{phase:"after"}))}else"list"===i.type?x(i.helpers.focus).find("input").focus():x(i.el).focus()}),x(i.el).css("padding-left",e.width()+parseInt(x(i.el).css("padding-left"),10)+"px"),i.helpers.prefix=e))},1)},addSuffix:function(){var t,i,n=this;setTimeout(function(){var e;"clear"!==n.type&&((e=x(n.el).data("tmp")||{})["old-padding-right"]&&x(n.el).css("padding-right",e["old-padding-right"]),e["old-padding-right"]=x(n.el).css("padding-right"),x(n.el).data("tmp",e),i=parseInt(x(n.el).css("padding-right"),10),n.options.arrows&&(n.helpers.arrows&&x(n.helpers.arrows).remove(),x(n.el).after('
     
    '),(t=x(n.el).next()).css({color:x(n.el).css("color"),"font-family":x(n.el).css("font-family"),"font-size":x(n.el).css("font-size"),height:x(n.el).height()+parseInt(x(n.el).css("padding-top"),10)+parseInt(x(n.el).css("padding-bottom"),10)+"px",padding:0,"margin-top":parseInt(x(n.el).css("margin-top"),10)+1+"px","margin-bottom":0,"border-left":"1px solid silver"}).css("margin-left","-"+(t.width()+parseInt(x(n.el).css("margin-right"),10)+12)+"px").on("mousedown",function(t){var i=x("body");function s(e){x(n.el).focus(),n.keyDown(x.Event("keydown"),{keyCode:"up"===x(t.target).attr("type")?38:40}),!1!==e&&x("body").data("_field_update_timer",setTimeout(s,60))}i.on("mouseup",function e(){clearTimeout(i.data("_field_update_timer"));i.off("mouseup",e)}),i.data("_field_update_timer",setTimeout(s,700)),s(!1)}),i+=t.width()+12,x(n.el).css("padding-right",i+"px"),n.helpers.arrows=t),""!==n.options.suffix&&(n.helpers.suffix&&x(n.helpers.suffix).remove(),x(n.el).after('
    '+n.options.suffix+"
    "),(t=x(n.el).next()).css({color:x(n.el).css("color"),"font-family":x(n.el).css("font-family"),"font-size":x(n.el).css("font-size"),"padding-top":x(n.el).css("padding-top"),"padding-bottom":x(n.el).css("padding-bottom"),"padding-left":"3px","padding-right":x(n.el).css("padding-right"),"margin-top":parseInt(x(n.el).css("margin-top"),10)+2+"px","margin-bottom":parseInt(x(n.el).css("margin-bottom"),10)+1+"px"}).on("click",function(e){"list"===n.type?x(n.helpers.focus).find("input").focus():x(n.el).focus()}),t.css("margin-left","-"+(w2utils.getSize(t,"width")+parseInt(x(n.el).css("margin-right"),10)+2)+"px"),i+=t.width()+3,x(n.el).css("padding-right",i+"px"),n.helpers.suffix=t))},1)},addFocus:function(){var i,s=this;this.options;x(s.helpers.focus).remove();var e=parseInt(x(s.el).attr("tabIndex"));isNaN(e)||-1===e||(s.el._tabIndex=e),s.el._tabIndex&&(e=s.el._tabIndex),null==e&&(e=-1),isNaN(e)&&(e=0);var t="";null!=x(s.el).attr("id")&&(t='id="'+x(s.el).attr("id")+'_search"');var n='
    ';x(s.el).attr("tabindex",-1).before(n);var r=x(s.el).prev();(s.helpers.focus=r).css({width:x(s.el).width(),"margin-top":x(s.el).css("margin-top"),"margin-left":parseInt(x(s.el).css("margin-left"))+parseInt(x(s.el).css("padding-left"))+"px","margin-bottom":x(s.el).css("margin-bottom"),"margin-right":x(s.el).css("margin-right")}).find("input").css({cursor:"default",width:"100%",outline:"none",opacity:1,margin:0,border:"1px solid transparent",padding:x(s.el).css("padding-top"),"padding-left":0,"margin-left":0,"background-color":"transparent"}),r.find("input").on("click",function(e){0===x("#w2ui-overlay").length&&s.focus(e),e.stopPropagation()}).on("focus",function(e){i=x(s.el).attr("placeholder"),x(s.el).css({outline:"auto 5px #7DB4F3","outline-offset":"2px"}),x(this).val(""),x(s.el).triggerHandler("focus"),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}).on("blur",function(e){x(s.el).css("outline","none"),x(this).val(""),s.refresh(),x(s.el).triggerHandler("blur"),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,null!=i&&x(s.el).attr("placeholder",i)}).on("keydown",function(e){var t=this;s.keyDown(e),setTimeout(function(){""===t.value?x(s.el).attr("placeholder",i):x(s.el).attr("placeholder","")},10)}).on("keyup",function(e){s.keyUp(e)}).on("keypress",function(e){s.keyPress(e)}),r.on("click",function(e){x(this).find("input").focus()}),s.refresh()},addMulti:function(){var n=this;this.options;x(n.helpers.multi).remove();var e,t="",i="margin-top : 0px; margin-bottom : 0px; margin-left : "+x(n.el).css("margin-left")+"; margin-right : "+x(n.el).css("margin-right")+"; width : "+(w2utils.getSize(n.el,"width")-parseInt(x(n.el).css("margin-left"),10)-parseInt(x(n.el).css("margin-right"),10))+"px;",s="";null!=x(n.el).attr("id")&&(s='id="'+x(n.el).attr("id")+'_search" '),"enum"===n.type&&((e=x(n.el).attr("tabIndex"))&&-1!==e&&(n.el._tabIndex=e),n.el._tabIndex&&(e=n.el._tabIndex),null==e&&(e=0),t='
    '),"file"===n.type&&(t='
    ');var r=x(n.el).data("tmp")||{};r["old-background-color"]=x(n.el).css("background-color"),r["old-border-color"]=x(n.el).css("border-color"),x(n.el).data("tmp",r),x(n.el).before(t).css({"background-color":"transparent","border-color":"transparent"});var a=x(n.el).prev();n.helpers.multi=a,"enum"===n.type&&(x(n.el).attr("tabindex",-1),a.find("input").on("click",function(e){0===x("#w2ui-overlay").length&&n.focus(e),x(n.el).triggerHandler("click")}).on("focus",function(e){x(a).css({outline:"auto 5px #7DB4F3","outline-offset":"2px"}),x(n.el).triggerHandler("focus"),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}).on("blur",function(e){x(a).css("outline","none"),x(n.el).triggerHandler("blur"),e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}).on("keyup",function(e){n.keyUp(e)}).on("keydown",function(e){n.keyDown(e)}).on("keypress",function(e){n.keyPress(e)}),a.on("click",function(e){x(this).find("input").focus()})),"file"===n.type&&(x(n.el).css("outline","none"),a.find("input").off(".drag").on("click.drag",function(e){e.stopPropagation(),x(n.el).prop("readonly")||x(n.el).prop("disabled")||x(n.el).focus()}).on("dragenter.drag",function(e){x(n.el).prop("readonly")||x(n.el).prop("disabled")||x(a).addClass("w2ui-file-dragover")}).on("dragleave.drag",function(e){x(n.el).prop("readonly")||x(n.el).prop("disabled")||x(a).removeClass("w2ui-file-dragover")}).on("drop.drag",function(e){if(!x(n.el).prop("readonly")&&!x(n.el).prop("disabled")){x(a).removeClass("w2ui-file-dragover");for(var t=e.originalEvent.dataTransfer.files,i=0,s=t.length;ii.maxFileSize)return t="Maximum file size is "+w2utils.formatSize(i.maxFileSize),!1===i.silent&&x(s.el).w2tag(t),void console.log("ERROR: "+t);if(0!==i.maxSize&&a+r.size>i.maxSize)return t=w2utils.lang("Maximum total size is")+" "+w2utils.formatSize(i.maxSize),void(!1===i.silent?x(s.el).w2tag(t):console.log("ERROR: "+t));if(0!==i.max&&l>=i.max)return t=w2utils.lang("Maximum number of files is")+" "+i.max,void(!1===i.silent?x(s.el).w2tag(t):console.log("ERROR: "+t));n.push(r),"undefined"!=typeof FileReader&&!0===i.readContent?((d=new FileReader).onload=function(e){var t=e.target.result,i=t.indexOf(",");r.content=t.substr(i+1),s.refresh(),x(s.el).trigger("input").trigger("change"),s.trigger(x.extend(u,{phase:"after"}))},d.readAsDataURL(e)):(s.refresh(),x(s.el).trigger("input").trigger("change"),s.trigger(x.extend(u,{phase:"after"})))}},normMenu:function(e,t){if(x.isArray(e)){for(var i=0;i'+o[h]+"";var p,f='
    '+n[e-1]+", "+t+'
    '+c+"",g=1;"M"!==w2utils.settings.weekStarts&&u++,"datetime"===this.type&&(p=w2utils.isDateTime(i,d.format,!0),i=w2utils.formatDate(p,w2utils.settings.dateFormat));for(var m=1;m<43;m++){if(0===u&&1==m){for(var w=0;w<6;w++)f+='';m+=6}else if(mr[e-1]){f+='',m%7==0&&(f+="");continue}var v=t+"/"+e+"/"+g,y=new Date(v),b="";6===y.getDay()&&(b=" w2ui-saturday"),0===y.getDay()&&(b=" w2ui-sunday"),v==a&&(b+=" w2ui-today");var x,_,k=g,C="",T="",S="datetime"===this.type?(x=w2utils.formatDateTime(v,d.format),w2utils.formatDate(v,w2utils.settings.dateFormat)):x=w2utils.formatDate(v,d.format);d.colored&&void 0!==d.colored[S]&&(T="background-color: "+(_=d.colored[S].split(":"))[0]+";",C="color: "+_[1]+";"),f+='",(m%7==0||0===u&&1==m)&&(f+=""),g++}return f+="
      
    '+k+"
    "},getYearHTML:function(){for(var e=w2utils.settings.shortmonths,t=w2utils.settings.dateStartYear,i=w2utils.settings.dateEndYear,s="",n="",r=0;r'+e[r]+"";for(var a=t;a<=i;a++)n+='
    '+a+"
    ";return'
    '+s+'
    '+n+"
    "},getHourHTML:function(){var e=[],t=this.options;null==t&&(t={format:w2utils.settings.timeFormat});for(var i=-1'+n+""}return'
    '+w2utils.lang("Select Hour")+'
    '+e[0]+" "+e[1]+" "+e[2]+"
    "},getMinHTML:function(e){null==e&&(e=0);var t=this.options;null==t&&(t={format:w2utils.settings.timeFormat});for(var i=-1'+l+""}return'
    '+w2utils.lang("Select Minute")+'
    '+s[0]+" "+s[1]+" "+s[2]+"
    "},toMin:function(e){if("string"!=typeof e)return null;var t=e.split(":");return 2!==t.length?null:(t[0]=parseInt(t[0]),t[1]=parseInt(t[1]),-1!==e.indexOf("pm")&&12!==t[0]&&(t[0]+=12),60*t[0]+t[1])},fromMin:function(e){1440<=e&&(e%=1440),e<0&&(e=1440+e);var t=Math.floor(e/60),i=(e%60<10?"0":"")+e%60,s=this.options;return null==s&&(s={format:w2utils.settings.timeFormat}),-1!==s.format.indexOf("h24")?t+":"+i:(t<=12?t:t-12)+":"+i+" "+(12<=t?"pm":"am")}},x.extend(n.prototype,w2utils.event),w2obj.field=n}(jQuery),function(b){function h(e){this.name=null,this.header="",this.box=null,this.url="",this.routeData={},this.formURL="",this.formHTML="",this.page=0,this.recid=0,this.fields=[],this.actions={},this.record={},this.original=null,this.postData={},this.httpHeaders={},this.method=null,this.toolbar={},this.tabs={},this.style="",this.focus=0,this.autosize=!0,this.nestedFields=!0,this.multipart=!1,this.tabindexBase=0,this.isGenerated=!1,this.last={xhr:null,errors:[]},b.extend(!0,this,w2obj.form,e)}b.fn.w2form=function(e){if(b.isPlainObject(e)){var t=this;if(!w2utils.checkName(e,"w2form"))return;var i=e.record,s=e.original,n=e.fields,r=e.toolbar,a=e.tabs,l=new h(e);if(b.extend(l,{record:{},original:null,fields:[],tabs:{},toolbar:{},handlers:[]}),b.isArray(a)){b.extend(!0,l.tabs,{tabs:[]});for(var o=0;o",c),c.field=c.name),l.fields[u]=c}for(var u in i)b.isPlainObject(i[u])?l.record[u]=b.extend(!0,{},i[u]):l.record[u]=i[u];for(var u in s)b.isPlainObject(s[u])?l.original[u]=b.extend(!0,{},s[u]):l.original[u]=s[u];return 0'+l.formHTML+""),b(l.box).html(l.formHTML),l.isGenerated=!0,l.render(l.box)),l}return(t=w2ui[b(this).attr("name")])?0'+e+"",buttons:'",onOpen:function(e){setTimeout(function(){b(e.box).find(".w2ui-btn").focus()},25)}}),w2utils.message.call(this,{box:this.box,path:"w2ui."+this.name,title:".w2ui-form-header:visible",body:".w2ui-form-box"},e)},validate:function(e){null==e&&(e=!0),b().w2tag();for(var t=[],i=0;i'),setTimeout(function(){var e={cmd:"save"};e.recid=c.recid,e.name=c.name,b.extend(e,c.postData),b.extend(e,d),c.multipart||c.fields.forEach(function(e){"file"===e.type&&Array.isArray(c.getValue(e.field))&&c.getValue(e.field).forEach(function(e){delete e.file})}),e.record=b.extend(!0,{},c.record);var t=c.trigger({phase:"before",type:"submit",target:c.name,url:c.url,postData:e,httpHeaders:c.httpHeaders});if(!0!==t.isCancelled){var i=t.url;if("object"==typeof t.url&&t.url.save&&(i=t.url.save),c.last.xhr)try{c.last.xhr.abort()}catch(e){}if(!b.isEmptyObject(c.routeData)){var s=w2utils.parseRoute(i);if(0",o),o.html.label=o.html.caption),null==o.html.label&&(o.html.label=o.field),o.html=b.extend(!0,{label:"",span:6,attr:"",text:"",style:"",page:0,column:0},o.html),null==e&&(e=o.html.page),null==t&&(t=o.html.column);var d,u,c,h='";switch(o.type){case"pass":case"password":h='";break;case"check":case"checks":null==o.options.items&&null!=o.html.items&&(o.options.items=o.html.items);var p=o.options.items,h="";b.isArray(p)||(p=[]),0  '+p[f].text+"
    ";break;case"checkbox":h='";break;case"radio":h="",null==o.options.items&&null!=o.html.items&&(o.options.items=o.html.items);p=o.options.items;b.isArray(p)||(p=[]),0  '+p[f].text+"
    ";break;case"select":h='";break;case"textarea":h='";break;case"toggle":h='
    ';break;case"map":case"array":o.html.key=o.html.key||{},o.html.value=o.html.value||{},o.html.tabindex_str=n,h=''+(o.html.text||"")+'
    ';break;case"html":case"div":case"custom":h='
    "+(o&&o.html&&o.html.html?o.html.html:"")+"
    ";break;case"empty":h=o&&o.html?(o.html.html||"")+(o.html.text||""):""}""!==a&&(e!=o.html.page||t!=o.html.column||o.html.group&&a!=o.html.group)&&(r[e][t]+="\n \n ",a=""),o.html.group&&a!=o.html.group&&(d="",o.html.groupCollapsable&&(d=''),i+='\n
    \n
    "+d+o.html.group+'
    \n
    ',a=o.html.group),null==o.html.anchor?(u=null!=o.html.span?"w2ui-span"+o.html.span:"",-1==o.html.span&&(u="w2ui-span-none"),c=""+w2utils.lang("checkbox"!=o.type?o.html.label:o.html.text)+"",o.html.label||(c=""),i+='\n
    \n '+c+("empty"===o.type?h:"\n
    "+h+("array"!=o.type&&"map"!=o.type?w2utils.lang("checkbox"!=o.type?o.html.text:""):"")+"
    ")+"\n
    "):(r[o.html.page].anchors=r[o.html.page].anchors||{},r[o.html.page].anchors[o.html.anchor]='
    '+("empty"===o.type?h:"
    "+w2utils.lang("checkbox"!=o.type?o.html.label:o.html.text)+h+w2utils.lang("checkbox"!=o.type?o.html.text:"")+"
    ")+"
    "),null==r[o.html.page]&&(r[o.html.page]={}),null==r[o.html.page][o.html.column]&&(r[o.html.page][o.html.column]=""),r[o.html.page][o.html.column]+=i,e=o.html.page,t=o.html.column}if(""!==a&&(r[e][t]+="\n
    \n
    "),this.tabs.tabs)for(f=0;f",w),w.text=w.caption),w.text&&(v.text=w.text),w.style&&(v.style=w.style),w.class&&(v.class=w.class)):(v.text=m,-1!==["save","update","create"].indexOf(m.toLowerCase())?v.class="w2ui-btn-blue":v.class=""),g+='\n ",s++}g+="\n"}i="";for(var y=0;y',r[y].before&&(i+=r[y].before),i+='
    ',Object.keys(r[y]).sort().forEach(function(e,t){e==parseInt(e)&&(i+='
    '+(r[y][e]||"")+"\n
    ")}),i+="\n
    ",r[y].after&&(i+=r[y].after),i+="\n",r[y].anchors&&Object.keys(r[y].anchors).forEach(function(e,t){i=i.replace(e,r[y].anchors[e])});return i+=g},toggleGroup:function(e,t){var i,s=b(this.box).find('.w2ui-group-title[data-group="'+w2utils.base64encode(e)+'"]');"none"==s.next().css("display")&&!0!==t?(s.next().slideDown(300),s.next().next().remove(),s.find("span").addClass("w2ui-icon-collapse").removeClass("w2ui-icon-expand")):(s.next().slideUp(300),i="width: "+s.next().css("width")+";padding-left: "+s.next().css("padding-left")+";padding-right: "+s.next().css("padding-right")+";margin-left: "+s.next().css("margin-left")+";margin-right: "+s.next().css("margin-right")+";",setTimeout(function(){s.next().after('
    ')},100),s.find("span").addClass("w2ui-icon-expand").removeClass("w2ui-icon-collapse"))},action:function(e,t){var i=this.actions[e],s=i;b.isPlainObject(i)&&i.onClick&&(s=i.onClick);var n=this.trigger({phase:"before",target:e,type:"action",action:i,originalEvent:t});!0!==n.isCancelled&&("function"==typeof s&&s.call(this,t),this.trigger(b.extend(n,{phase:"after"})))},resize:function(){var e,t,i,s,n,r,a,l,o=this,d=this.trigger({phase:"before",target:this.name,type:"resize"});function u(){e.width(b(o.box).width()).height(b(o.box).height()),i.css("top",""!==o.header?w2utils.getSize(t,"height"):0),s.css("top",(""!==o.header?w2utils.getSize(t,"height"):0)+("object"==typeof o.toolbar&&b.isArray(o.toolbar.items)&&0 div.w2ui-form-box"),t=b(this.box).find("> div .w2ui-form-header"),i=b(this.box).find("> div .w2ui-form-toolbar"),s=b(this.box).find("> div .w2ui-form-tabs"),n=b(this.box).find("> div .w2ui-page"),r=b(this.box).find("> div .w2ui-page.page-"+this.page),a=b(this.box).find("> div .w2ui-page.page-"+this.page+" > div"),l=b(this.box).find("> div .w2ui-buttons"),u(),this.autosize&&(0!==parseInt(b(this.box).height())&&!0!==b(this.box).data("auto-size")||(b(this.box).height((0'+l[g].text+"'+(e.html.key.text||"")+''+(e.html.value.text||"")+"";t.append(n)},g.el.mapRefresh=function(h,p){var e,s,n,r=1;"map"==g.type&&(b.isPlainObject(h)||(h={}),null==h._order&&(h._order=Object.keys(h)),e=h._order),"array"==g.type&&(Array.isArray(h)||(h=[]),e=h.map(function(e){return e.key})),e.forEach(function(t){s=p.find("#"+w2utils.escapeId(g.name)+"_key_"+r),n=p.find("#"+w2utils.escapeId(g.name)+"_value_"+r),0!=s.length&&0!=n.length||(g.el.mapAdd(g,p,r),s=p.find("#"+w2utils.escapeId(g.name)+"_key_"+r),n=p.find("#"+w2utils.escapeId(g.name)+"_value_"+r));var e,i=h[t];"array"!=g.type||0<(e=h.filter(function(e){return e.key==t})).length&&(i=e[0].value),s.val(t),n.val(i),!0!==g.disabled&&!1!==g.disabled||(s.prop("readOnly",!!g.disabled),n.prop("readOnly",!!g.disabled)),s.parents(".w2ui-map-field").attr("data-key",t),r++});var t=p.find("#"+w2utils.escapeId(g.name)+"_key_"+r).parent(),i=p.find("#"+w2utils.escapeId(g.name)+"_key_"+(r+1)).parent();0!==t.length||s&&(!0===s.prop("readOnly")||!0===s.prop("disabled"))||g.el.mapAdd(g,p,r),1==t.length&&1==i.length&&(t.removeAttr("data-key"),t.find(".key").val(i.find(".key").val()),t.find(".value").val(i.find(".value").val()),i.remove()),!0!==g.disabled&&!1!==g.disabled||(t.find(".key").prop("readOnly",!!g.disabled),t.find(".value").prop("readOnly",!!g.disabled)),b(g.el).next().find("input.w2ui-map").off(".mapChange").on("keyup.mapChange",function(e){var t=b(e.target).parents(".w2ui-map-field");13==e.keyCode&&t.next().find("input.key").focus()}).on("change.mapChange",function(){var e=b(event.target).parents(".w2ui-map-field"),i=e.attr("data-key"),t=e.find(".key").val(),s=e.find(".value").val(),n={},r={},a=null,l=null;n[t]=s,"array"==g.type&&(h.forEach(function(e,t){e.key==i&&(l=t)}),a=h[l]),null!=i&&"map"==g.type&&(r[i]=h[i]),null!=i&&"array"==g.type&&(r[i]=a.value);var o=f.trigger({phase:"before",target:g.field,type:"change",originalEvent:event,value_new:n,value_previous:r});if(!0!==o.isCancelled){if("map"==g.type){delete h[i];var d=h._order.indexOf(i);if(""!=t){if(null!=h[t]){for(var u,c=0;u=t+ ++c,null!=h[u];);t=u,e.find(".key").val(u)}h[t]=s,e.attr("data-key",t),-1!=d?h._order[d]=t:h._order.push(t)}else h._order.splice(d,1),e.find(".value").val("")}else"array"==g.type&&(""!=t?null==a?h.push({key:t,value:s}):(a.key=t,a.value=s):h.splice(l,1));f.setValue(g.field,h),g.el.mapRefresh(h,p),f.trigger(b.extend(o,{phase:"after"}))}})},g.el.mapRefresh(a,b(g.el).parent().find(".w2ui-map-container"))}(this,r);break;case"div":case"custom":b(r.el).html(a);break;case"html":case"empty":break;default:b(r.el).val(a),b(r.el).w2field(b.extend({},r.options,{type:r.type}))}}for(var m=b(this.box).find(".w2ui-page"),u=0;u *").length&&b(m[u]).wrapInner("
    ");return this.trigger(b.extend(t,{phase:"after"})),this.resize(),(new Date).getTime()-e}}},render:function(e){var t=(new Date).getTime(),i=this;if("object"==typeof e&&(0'+this.header+"":"")+' '+this.formHTML+"";return b(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-form").html(n),0 input, select, textarea, div > label:nth-child(1) > :radio").not(".file-input");b(t[e]).is(":hidden")&&t.length>=e;)e++;t[e]&&t[e].focus()},destroy:function(){var e=this.trigger({phase:"before",target:this.name,type:"destroy"});!0!==e.isCancelled&&("object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),"object"==typeof this.tabs&&this.tabs.destroy&&this.tabs.destroy(),0 { + query('#w2overlay-context-menu .w2ui-grid-skip') + .off('.w2ui-grid') + .on('click.w2ui-grid', evt => { + evt.stopPropagation() + }) + .on('keypress', evt => { + if (evt.keyCode == 13) { + this.skip(evt.target.value) + this.toolbar.click('w2ui-column-on-off') // close menu + } + }) + }) + .select((event) => { + let id = event.detail.item.id + if (['w2ui-stateSave', 'w2ui-stateReset'].includes(id)) { + this[id.substring(5)]() + } else if (id == 'w2ui-skip') { + // empty + } else { + this.columnOnOff(event, event.detail.item.id) + } + clearTimeout(this.last.kbd_timer) // keep grid in focus + }) + clearTimeout(this.last.kbd_timer) // keep grid in focus + } + event.preventDefault() + edata.finish() + } focus(event) { // event before let edata = this.trigger('focus', { target: this.name, originalEvent: event }) @@ -14385,7 +14425,7 @@ class w2grid extends w2base { }) .select((event) => { clearTimeout(this.last.kbd_timer) // keep grid in focus - this.contextMenuClick(recid, event) + this.contextMenuClick(recid, column, event) }) clearTimeout(this.last.kbd_timer) // keep grid in focus } @@ -14394,9 +14434,10 @@ class w2grid extends w2base { // event after edata.finish() } - contextMenuClick(recid, event) { + contextMenuClick(recid, column, event) { // event before - let edata = this.trigger('contextMenuClick', { target: this.name, recid, originalEvent: event.detail.originalEvent, + let edata = this.trigger('contextMenuClick', { + target: this.name, recid, column, originalEvent: event.detail.originalEvent, menuEvent: event, menuIndex: event.detail.index, menuItem: event.detail.item }) if (edata.isCancelled === true) return @@ -15247,40 +15288,7 @@ class w2grid extends w2base { this.columnDblClick(col.field, event) break case 'contextmenu': - if (this.show.columnMenu) { - w2menu.show({ - type: 'check', - anchor: document.body, - originalEvent: event, - items: this.initColumnOnOff() - }) - .then(() => { - query('#w2overlay-context-menu .w2ui-grid-skip') - .off('.w2ui-grid') - .on('click.w2ui-grid', evt => { - evt.stopPropagation() - }) - .on('keypress', evt => { - if (evt.keyCode == 13) { - this.skip(evt.target.value) - this.toolbar.click('w2ui-column-on-off') // close menu - } - }) - }) - .select((event) => { - let id = event.detail.item.id - if (['w2ui-stateSave', 'w2ui-stateReset'].includes(id)) { - this[id.substring(5)]() - } else if (id == 'w2ui-skip') { - // empty - } else { - this.columnOnOff(event, event.detail.item.id) - } - clearTimeout(this.last.kbd_timer) // keep grid in focus - }) - clearTimeout(this.last.kbd_timer) // keep grid in focus - } - event.preventDefault() + this.columnContextMenu(col.field, event) break } }) @@ -17215,7 +17223,7 @@ class w2grid extends w2base { w2tooltip.show({ name: this.name + '-column-tooltip', anchor: $el.get(0), - html: item.tooltip, + html: item?.tooltip, position: pos, }) } diff --git a/dist/w2ui.es6.min.js b/dist/w2ui-2.0.es6.min.js similarity index 80% rename from dist/w2ui.es6.min.js rename to dist/w2ui-2.0.es6.min.js index 9e814bbdb..8cde2175c 100644 --- a/dist/w2ui.es6.min.js +++ b/dist/w2ui-2.0.es6.min.js @@ -1,4 +1,4 @@ -/* w2ui 2.0.x (nightly) (4/20/2023, 8:03:53 AM) (c) http://w2ui.com, vitmalina@gmail.com */ +/* w2ui 2.0.0 (4/26/2023, 10:40:17 AM) (c) http://w2ui.com, vitmalina@gmail.com */ class w2event{constructor(e,t){Object.assign(this,{type:t.type??null,detail:t,owner:e,target:t.target??null,phase:t.phase??"before",object:t.object??null,execute:null,isStopped:!1,isCancelled:!1,onComplete:null,listeners:[]}),delete t.type,delete t.target,delete t.object,this.complete=new Promise((e,t)=>{this._resolve=e,this._reject=t}),this.complete.catch(()=>{})}finish(e){e&&w2utils.extend(this.detail,e),this.phase="after",this.owner.trigger.call(this.owner,this)}done(e){this.listeners.push(e)}preventDefault(){this._reject(),this.isCancelled=!0}stopPropagation(){this.isStopped=!0}}class w2base{constructor(e){if(this.activeEvents=[],this.listeners=[],void 0!==e){if(!w2utils.checkName(e))return;w2ui[e]=this}this.debug=!1}on(e,r){return(e="string"==typeof e?e.split(/[,\s]+/):[e]).forEach(e=>{var t,i,s,l="string"==typeof e?e:e.type+":"+e.execute+"."+e.scope;"string"==typeof e&&([i,t]=e.split("."),[i,s]=i.replace(":complete",":after").replace(":done",":after").split(":"),e={type:i,execute:s??"before",scope:t}),(e=w2utils.extend({type:null,execute:"before",onComplete:null},e)).type?r?(Array.isArray(this.listeners)||(this.listeners=[]),this.listeners.push({name:l,edata:e,handler:r}),this.debug&&console.log("w2base: add event",{name:l,edata:e,handler:r})):console.log("ERROR: You must specify event handler function when calling .on() method of "+this.name):console.log("ERROR: You must specify event type when calling .on() method of "+this.name)}),this}off(e,r){return(e="string"==typeof e?e.split(/[,\s]+/):[e]).forEach(i=>{var e,t,s,l="string"==typeof i?i:i.type+":"+i.execute+"."+i.scope;if("string"==typeof i&&([t,e]=i.split("."),[t,s]=t.replace(":complete",":after").replace(":done",":after").split(":"),i={type:t||"*",execute:s||"",scope:e||""}),(i=w2utils.extend({type:null,execute:null,onComplete:null},i)).type||i.scope){r=r||null;let t=0;this.listeners=this.listeners.filter(e=>"*"!==i.type&&i.type!==e.edata.type||""!==i.execute&&i.execute!==e.edata.execute||""!==i.scope&&i.scope!==e.edata.scope||null!=i.handler&&i.handler!==e.edata.handler||(t++,!1)),this.debug&&console.log(`w2base: remove event (${t})`,{name:l,edata:i,handler:r})}else console.log("ERROR: You must specify event type when calling .off() method of "+this.name)}),this}trigger(e,i){if(1==arguments.length?i=e:(i.type=e,i.target=i.target??this),w2utils.isPlainObject(i)&&"after"==i.phase){if(!(i=this.activeEvents.find(e=>e.type==i.type&&e.target==i.target)))return void console.log(`ERROR: Cannot find even handler for "${i.type}" on "${i.target}".`);console.log("NOTICE: This syntax \"edata.trigger({ phase: 'after' })\" is outdated. Use edata.finish() instead.")}else i instanceof w2event||(i=new w2event(this,i),this.activeEvents.push(i));let s,t,l;Array.isArray(this.listeners)||(this.listeners=[]),this.debug&&console.log(`w2base: trigger "${i.type}:${i.phase}"`,i);for(let e=this.listeners.length-1;0<=e;e--){let t=this.listeners[e];if(!(null==t||t.edata.type!==i.type&&"*"!==t.edata.type||t.edata.target!==i.target&&null!=t.edata.target||t.edata.execute!==i.phase&&"*"!==t.edata.execute&&"*"!==t.edata.phase)&&(Object.keys(t.edata).forEach(e=>{null==i[e]&&null!=t.edata[e]&&(i[e]=t.edata[e])}),s=[],l=new RegExp(/\((.*?)\)/).exec(String(t.handler).split("=>")[0]),2===(s=l?l[1].split(/\s*,\s*/):s).length?(t.handler.call(this,i.target,i),this.debug&&console.log(" - call (old)",t.handler)):(t.handler.call(this,i),this.debug&&console.log(" - call",t.handler)),!0===i.isStopped||!0===i.stop))return i}e="on"+i.type.substr(0,1).toUpperCase()+i.type.substr(1);if(!("before"===i.phase&&"function"==typeof this[e]&&(t=this[e],s=[],l=new RegExp(/\((.*?)\)/).exec(String(t).split("=>")[0]),2===(s=l?l[1].split(/\s*,\s*/):s).length?(t.call(this,i.target,i),this.debug&&console.log(" - call: on[Event] (old)",t)):(t.call(this,i),this.debug&&console.log(" - call: on[Event]",t)),!0===i.isStopped||!0===i.stop)||null!=i.object&&"before"===i.phase&&"function"==typeof i.object[e]&&(t=i.object[e],s=[],l=new RegExp(/\((.*?)\)/).exec(String(t).split("=>")[0]),2===(s=l?l[1].split(/\s*,\s*/):s).length?(t.call(this,i.target,i),this.debug&&console.log(" - call: edata.object (old)",t)):(t.call(this,i),this.debug&&console.log(" - call: edata.object",t)),!0===i.isStopped||!0===i.stop)||"after"!==i.phase)){"function"==typeof i.onComplete&&i.onComplete.call(this,i);for(let e=0;e{this[t]=e})}static _fragment(e){let i=document.createElement("template");return i.innerHTML=e,i.content.childNodes.forEach(e=>{var t=Query._scriptConvert(e);t!=e&&i.content.replaceChild(t,e)}),i.content}static _scriptConvert(e){let t=e=>{var t=e.ownerDocument.createElement("script"),i=(t.text=e.text,e.attributes);for(let e=0;e{e.parentNode.replaceChild(t(e),e)}),e}static _fixProp(e){var t={cellpadding:"cellPadding",cellspacing:"cellSpacing",class:"className",colspan:"colSpan",contenteditable:"contentEditable",for:"htmlFor",frameborder:"frameBorder",maxlength:"maxLength",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"};return t[e]||e}_insert(l,i){let r=[],a=this.length;if(!(a<1)){let e=this;if("string"==typeof i)this.each(e=>{var t=Query._fragment(i);r.push(...t.childNodes),e[l](t)});else if(i instanceof Query){let s=1==a;i.each(i=>{this.each(e=>{var t=s?i:i.cloneNode(!0);r.push(t),e[l](t),Query._scriptConvert(t)})}),s||i.remove()}else{if(!(i instanceof Node))throw new Error(`Incorrect argument for "${l}(html)". It expects one string argument.`);this.each(e=>{var t=1===a?i:Query._fragment(i.outerHTML);r.push(...1===a?[i]:t.childNodes),e[l](t)}),1{e=Array.from(e.querySelectorAll(t));0{(e===t||"string"==typeof t&&e.matches&&e.matches(t)||"function"==typeof t&&t(e))&&i.push(e)}),new Query(i,this.context,this)}next(){let t=[];return this.each(e=>{e=e.nextElementSibling;e&&t.push(e)}),new Query(t,this.context,this)}prev(){let t=[];return this.each(e=>{e=e.previousElementSibling;e&&t.push(e)}),new Query(t,this.context,this)}shadow(e){let t=[];this.each(e=>{e.shadowRoot&&t.push(e.shadowRoot)});var i=new Query(t,this.context,this);return e?i.find(e):i}closest(t){let i=[];return this.each(e=>{e=e.closest(t);e&&i.push(e)}),new Query(i,this.context,this)}host(t){let i=[],s=e=>e.parentNode?s(e.parentNode):e,l=e=>{e=s(e);i.push(e.host||e),e.host&&t&&l(e.host)};return this.each(e=>{l(e)}),new Query(i,this.context,this)}parent(e){return this.parents(e,!0)}parents(e,t){let i=[],s=e=>{if(-1==i.indexOf(e)&&i.push(e),!t&&e.parentNode)return s(e.parentNode)};this.each(e=>{e.parentNode&&s(e.parentNode)});var l=new Query(i,this.context,this);return e?l.filter(e):l}add(e){e=e instanceof Query?e.nodes:Array.isArray(e)?e:[e];return new Query(this.nodes.concat(e),this.context,this)}each(i){return this.nodes.forEach((e,t)=>{i(e,t,this)}),this}append(e){return this._insert("append",e)}prepend(e){return this._insert("prepend",e)}after(e){return this._insert("after",e)}before(e){return this._insert("before",e)}replace(e){return this._insert("replaceWith",e)}remove(){return this.each(e=>{e.remove()}),this}css(e,t){let s=e;var i,l=arguments.length;return 0===l||1===l&&"string"==typeof e?this[0]?(l=this[0].style,"string"==typeof e?(i=l.getPropertyPriority(e),l.getPropertyValue(e)+(i?"!"+i:"")):Object.fromEntries(this[0].style.cssText.split(";").filter(e=>!!e).map(e=>e.split(":").map(e=>e.trim())))):void 0:("object"!=typeof e&&((s={})[e]=t),this.each((i,e)=>{Object.keys(s).forEach(e=>{var t=String(s[e]).toLowerCase().includes("!important")?"important":"";i.style.setProperty(e,String(s[e]).replace(/\!important/i,""),t)})}),this)}addClass(e){return this.toggleClass(e,!0),this}removeClass(e){return this.toggleClass(e,!1),this}toggleClass(t,s){return"string"==typeof t&&(t=t.split(/[,\s]+/)),this.each(i=>{let e=t;(e=null==e&&!1===s?Array.from(i.classList):e).forEach(t=>{if(""!==t){let e=null!=s?s?"add":"remove":"toggle";i.classList[e](t)}})}),this}hasClass(e){if(null==(e="string"==typeof e?e.split(/[,\s]+/):e)&&0{i=i||e.every(e=>Array.from(t.classList??[]).includes(e))}),i}on(e,s,l){"function"==typeof s&&(l=s,s=void 0);let r;return s?.delegate&&(r=s.delegate,delete s.delegate),(e=e.split(/[,\s]+/)).forEach(e=>{let[t,i]=String(e).toLowerCase().split(".");if(r){let i=l;l=e=>{var t=query(e.target).parents(r);0{this._save(e,"events",[{event:t,scope:i,callback:l,options:s}]),e.addEventListener(t,l,s)})}),this}off(e,t,r){return"function"==typeof t&&(r=t,t=void 0),(e=(e??"").split(/[,\s]+/)).forEach(e=>{let[s,l]=String(e).toLowerCase().split(".");this.each(t=>{if(Array.isArray(t._mQuery?.events))for(let e=t._mQuery.events.length-1;0<=e;e--){var i=t._mQuery.events[e];null==l||""===l?i.event!=s&&""!==s||i.callback!=r&&null!=r||(t.removeEventListener(i.event,i.callback,i.options),t._mQuery.events.splice(e,1)):i.event!=s&&""!==s||i.scope!=l||(t.removeEventListener(i.event,i.callback,i.options),t._mQuery.events.splice(e,1))}})}),this}trigger(e,t){let i;return i=e instanceof Event||e instanceof CustomEvent?e:new(["click","dblclick","mousedown","mouseup","mousemove"].includes(e)?MouseEvent:["keydown","keyup","keypress"].includes(e)?KeyboardEvent:Event)(e,t),this.each(e=>{e.dispatchEvent(i)}),this}attr(t,i){if(void 0===i&&"string"==typeof t)return this[0]?this[0].getAttribute(t):void 0;{let e={};return"object"==typeof t?e=t:e[t]=i,this.each(i=>{Object.entries(e).forEach(([e,t])=>{i.setAttribute(e,t)})}),this}}removeAttr(){return this.each(t=>{Array.from(arguments).forEach(e=>{t.removeAttribute(e)})}),this}prop(t,i){if(void 0===i&&"string"==typeof t)return this[0]?this[0][t]:void 0;{let e={};return"object"==typeof t?e=t:e[t]=i,this.each(i=>{Object.entries(e).forEach(([e,t])=>{e=Query._fixProp(e);i[e]=t,"innerHTML"==e&&Query._scriptConvert(i)})}),this}}removeProp(){return this.each(t=>{Array.from(arguments).forEach(e=>{delete t[Query._fixProp(e)]})}),this}data(i,t){if(i instanceof Object)Object.entries(i).forEach(e=>{this.data(e[0],e[1])});else{if(i&&-1!=i.indexOf("-")&&console.error(`Key "${i}" contains "-" (dash). Dashes are not allowed in property names. Use camelCase instead.`),!(arguments.length<2))return this.each(e=>{null!=t?e.dataset[i]=t instanceof Object?JSON.stringify(t):t:delete e.dataset[i]}),this;if(this[0]){let t=Object.assign({},this[0].dataset);return Object.keys(t).forEach(e=>{if(t[e].startsWith("[")||t[e].startsWith("{"))try{t[e]=JSON.parse(t[e])}catch(e){}}),i?t[i]:t}}}removeData(e){return"string"==typeof e&&(e=e.split(/[,\s]+/)),this.each(t=>{e.forEach(e=>{delete t.dataset[e]})}),this}show(){return this.toggle(!0)}hide(){return this.toggle(!1)}toggle(r){return this.each(e=>{var t,i=e.style.display,s=getComputedStyle(e).display,l="none"==i||"none"==s;!l||null!=r&&!0!==r||(t=e instanceof HTMLTableRowElement?"table-row":e instanceof HTMLTableCellElement?"table-cell":"block",e.style.display=e._mQuery?.prevDisplay??(i==s&&"none"!=s?"":t),this._save(e,"prevDisplay",null)),l||null!=r&&!1!==r||("none"!=s&&this._save(e,"prevDisplay",s),e.style.setProperty("display","none"))})}empty(){return this.html("")}html(e){return this.prop("innerHTML",e)}text(e){return this.prop("textContent",e)}val(e){return this.prop("value",e)}change(){return this.trigger("change")}click(){return this.trigger("click")}}let query=function(e,t){if("function"!=typeof e)return new Query(e,t);"complete"==document.readyState?e():window.addEventListener("load",e)},w2ui=(query.html=e=>{e=Query._fragment(e);return query(e.children,e)},query.version=Query.version,{});class Utils{constructor(){this.version="2.0.x",this.tmp={},this.settings=this.extend({},{dataType:"HTTPJSON",dateStartYear:1950,dateEndYear:2030,macButtonOrder:!1,warnNoPhrase:!1},w2locale,{phrases:null}),this.i18nCompare=Intl.Collator().compare,this.hasLocalStorage=function(){var e="w2ui_test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}(),this.isMac=/Mac/i.test(navigator.platform),this.isMobile=/(iphone|ipod|ipad|mobile|android)/i.test(navigator.userAgent),this.isIOS=/(iphone|ipod|ipad)/i.test(navigator.platform),this.isAndroid=/(android)/i.test(navigator.userAgent),this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this.formatters={number(e,t){return 20'+w2utils.formatDate(i,t)+""},datetime(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";let i=w2utils.isDateTime(e,t,!0);return''+w2utils.formatDateTime(i,t)+""},time(e,t){if(""===t&&(t=w2utils.settings.timeFormat),null==e||0===e||""===e)return"";let i=w2utils.isDateTime(e,t="h24"===(t="h12"===t?"hh:mi pm":t)?"h24:mi":t,!0);return''+w2utils.formatTime(e,t)+""},timestamp(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";let i=w2utils.isDateTime(e,t,!0);return(i=!1===i?w2utils.isDate(e,t,!0):i).toString?i.toString():""},gmt(e,t){if(""===t&&(t=w2utils.settings.datetimeFormat),null==e||0===e||""===e)return"";let i=w2utils.isDateTime(e,t,!0);return(i=!1===i?w2utils.isDate(e,t,!0):i).toUTCString?i.toUTCString():""},age(e,t){if(null==e||0===e||""===e)return"";let i=w2utils.isDateTime(e,null,!0);return''+w2utils.age(e)+(t?" "+t:"")+""},interval(e,t){return null==e||0===e||""===e?"":w2utils.interval(e)+(t?" "+t:"")},toggle(e,t){return e?"Yes":""},password(t,e){let i="";for(let e=0;ei||!this.isInt(e[0])||2'+(r=l==e?this.lang("Yesterday"):r)+""}formatSize(e){var t;return this.isFloat(e)&&""!==e?0===(e=parseFloat(e))?0:(t=parseInt(Math.floor(Math.log(e)/Math.log(1024))),(Math.floor(e/Math.pow(1024,t)*10)/10).toFixed(0===t?0:1)+" "+(["Bt","KB","MB","GB","TB","PB","EB","ZB"][t]||"??")):""}formatNumber(e,t,i){return null==e||""===e||"object"==typeof e?"":(i={minimumFractionDigits:parseInt(t),maximumFractionDigits:parseInt(t),useGrouping:!!i},(null==t||t<0)&&(i.minimumFractionDigits=0,i.maximumFractionDigits=20),parseFloat(e).toLocaleString(this.settings.locale,i))}formatDate(e,t){if(t=t||this.settings.dateFormat,""===e||null==e||"object"==typeof e&&!e.getMonth)return"";let i=new Date(e);var s,l;return this.isInt(e)&&(i=new Date(Number(e))),"Invalid Date"===String(i)?"":(e=i.getFullYear(),s=i.getMonth(),l=i.getDate(),t.toLowerCase().replace("month",this.settings.fullmonths[s]).replace("mon",this.settings.shortmonths[s]).replace(/yyyy/g,("000"+e).slice(-4)).replace(/yyy/g,("000"+e).slice(-4)).replace(/yy/g,("0"+e).slice(-2)).replace(/(^|[^a-z$])y/g,"$1"+e).replace(/mm/g,("0"+(s+1)).slice(-2)).replace(/dd/g,("0"+l).slice(-2)).replace(/th/g,1==l?"st":"th").replace(/th/g,2==l?"nd":"th").replace(/th/g,3==l?"rd":"th").replace(/(^|[^a-z$])m/g,"$1"+(s+1)).replace(/(^|[^a-z$])d/g,"$1"+l))}formatTime(e,t){if(t=t||this.settings.timeFormat,""===e||null==e||"object"==typeof e&&!e.getMonth)return"";let i=new Date(e);if(this.isInt(e)&&(i=new Date(Number(e))),this.isTime(e)&&(e=this.isTime(e,!0),(i=new Date).setHours(e.hours),i.setMinutes(e.minutes)),"Invalid Date"===String(i))return"";let s="am",l=i.getHours();e=i.getHours();let r=i.getMinutes(),a=i.getSeconds();return r<10&&(r="0"+r),a<10&&(a="0"+a),-1===t.indexOf("am")&&-1===t.indexOf("pm")||(12<=l&&(s="pm"),12{i[t]=this.stripSpaces(e)}):(i=this.extend({},i),Object.keys(i).forEach(e=>{i[e]=this.stripSpaces(i[e])}))}return i}stripTags(i){if(null!=i)switch(typeof i){case"number":break;case"string":i=String(i).replace(/<(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*>/gi,"");break;case"object":Array.isArray(i)?(i=this.extend([],i)).forEach((e,t)=>{i[t]=this.stripTags(e)}):(i=this.extend({},i),Object.keys(i).forEach(e=>{i[e]=this.stripTags(i[e])}))}return i}encodeTags(i){if(null!=i)switch(typeof i){case"number":break;case"string":i=String(i).replace(/&/g,"&").replace(/>/g,">").replace(/{i[t]=this.encodeTags(e)}):(i=this.extend({},i),Object.keys(i).forEach(e=>{i[e]=this.encodeTags(i[e])}))}return i}decodeTags(i){if(null!=i)switch(typeof i){case"number":break;case"string":i=String(i).replace(/>/g,">").replace(/</g,"<").replace(/"/g,'"').replace(/&/g,"&");break;case"object":Array.isArray(i)?(i=this.extend([],i)).forEach((e,t)=>{i[t]=this.decodeTags(e)}):(i=this.extend({},i),Object.keys(i).forEach(e=>{i[e]=this.decodeTags(i[e])}))}return i}escapeId(e){return""===e||null==e?"":(e+"").replace(/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,(e,t)=>t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e)}unescapeId(e){return""===e||null==e?"":e.replace(/\\[\da-fA-F]{1,6}[\x20\t\r\n\f]?|\\([^\r\n\f])/g,(e,t)=>{e="0x"+e.slice(1)-65536;return t||(e<0?String.fromCharCode(65536+e):String.fromCharCode(e>>10|55296,1023&e|56320))})}base64encode(e){return btoa(e)}base64decode(e){return atob(e)}async sha256(e){e=(new TextEncoder).encode(e);return crypto.subtle.digest("SHA-256",e).then(e=>{return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,"0")).join("")})}transition(r,a,n,o){return new Promise((e,t)=>{var i=getComputedStyle(r);let s=parseInt(i.width),l=parseInt(i.height);if(r&&a){switch(r.parentNode.style.cssText+="perspective: 900px; overflow: hidden;",r.style.cssText+="; position: absolute; z-index: 1019; backface-visibility: hidden",a.style.cssText+="; position: absolute; z-index: 1020; backface-visibility: hidden",n){case"slide-left":r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; transform: translate3d("+s+"px, 0, 0)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",r.style.cssText+="transition: 0.5s; transform: translate3d(-"+s+"px, 0, 0)"},1);break;case"slide-right":r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; transform: translate3d(-"+s+"px, 0, 0)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: translate3d(0px, 0, 0)",r.style.cssText+="transition: 0.5s; transform: translate3d("+s+"px, 0, 0)"},1);break;case"slide-down":r.style.cssText+="overflow: hidden; z-index: 1; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; z-index: 0; transform: translate3d(0, 0, 0)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",r.style.cssText+="transition: 0.5s; transform: translate3d(0, "+l+"px, 0)"},1);break;case"slide-up":r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; transform: translate3d(0, "+l+"px, 0)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)",r.style.cssText+="transition: 0.5s; transform: translate3d(0, 0, 0)"},1);break;case"flip-left":r.style.cssText+="overflow: hidden; transform: rotateY(0deg)",a.style.cssText+="overflow: hidden; transform: rotateY(-180deg)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: rotateY(0deg)",r.style.cssText+="transition: 0.5s; transform: rotateY(180deg)"},1);break;case"flip-right":r.style.cssText+="overflow: hidden; transform: rotateY(0deg)",a.style.cssText+="overflow: hidden; transform: rotateY(180deg)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: rotateY(0deg)",r.style.cssText+="transition: 0.5s; transform: rotateY(-180deg)"},1);break;case"flip-down":r.style.cssText+="overflow: hidden; transform: rotateX(0deg)",a.style.cssText+="overflow: hidden; transform: rotateX(180deg)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: rotateX(0deg)",r.style.cssText+="transition: 0.5s; transform: rotateX(-180deg)"},1);break;case"flip-up":r.style.cssText+="overflow: hidden; transform: rotateX(0deg)",a.style.cssText+="overflow: hidden; transform: rotateX(-180deg)",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: rotateX(0deg)",r.style.cssText+="transition: 0.5s; transform: rotateX(180deg)"},1);break;case"pop-in":r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(.8); opacity: 0;",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; transform: scale(1); opacity: 1;",r.style.cssText+="transition: 0.5s;"},1);break;case"pop-out":r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); transform: scale(1); opacity: 1;",a.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0); opacity: 0;",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; opacity: 1;",r.style.cssText+="transition: 0.5s; transform: scale(1.7); opacity: 0;"},1);break;default:r.style.cssText+="overflow: hidden; transform: translate3d(0, 0, 0)",a.style.cssText+="overflow: hidden; translate3d(0, 0, 0); opacity: 0;",query(a).show(),setTimeout(()=>{a.style.cssText+="transition: 0.5s; opacity: 1;",r.style.cssText+="transition: 0.5s"},1)}setTimeout(()=>{"slide-down"===n&&(query(r).css("z-index","1019"),query(a).css("z-index","1020")),a&&query(a).css({opacity:"1"}).css({transition:"",transform:""}),r&&query(r).css({opacity:"1"}).css({transition:"",transform:""}),"function"==typeof o&&o(),e()},500)}else console.log("ERROR: Cannot do transition when one of the divs is null")})}lock(l,r={}){if(null!=l){"string"==typeof r&&(r={msg:r}),arguments[2]&&(r.spinner=arguments[2]),r=this.extend({spinner:!1},r),l?.[0]instanceof Node&&(l=Array.isArray(l)?l:l.get()),r.msg||0===r.msg||(r.msg=""),this.unlock(l);var a=query(l).get(0);let e=a.scrollWidth,t=a.scrollHeight,i=("BODY"==a.tagName&&(e`+'
    '),query(l).find(".w2ui-lock"));a=query(l).find(".w2ui-lock-msg"),l=(r.msg||a.css({"background-color":"transparent","background-image":"none",border:"0px","box-shadow":"none"}),!0===r.spinner&&(r.msg=`
    `+r.msg),r.msg?a.html(r.msg).css("display","block"):a.remove(),null!=r.opacity&&i.css("opacity",r.opacity),i.css({display:"block"}),r.bgColor&&i.css({"background-color":r.bgColor}),getComputedStyle(i.get(0)));let s=l.opacity??.15;i.on("mousedown",function(){"function"==typeof r.onClick?r.onClick():i.css({transition:".2s",opacity:1.5*s})}).on("mouseup",function(){"function"!=typeof r.onClick&&i.css({transition:".2s",opacity:s})}).on("mousewheel",function(e){e&&(e.stopPropagation(),e.preventDefault())})}}unlock(e,t){var i;null!=e&&(clearTimeout(e._prevUnlock),e?.[0]instanceof Node&&(e=Array.isArray(e)?e:e.get()),this.isInt(t)&&0{query(e).find(".w2ui-lock").remove()},t)):query(e).find(".w2ui-lock").remove(),query(e).find(".w2ui-lock-msg").remove())}message(r,s){let e,t,l;var i=()=>{var e=query(r?.box).find(".w2ui-message");0!=e.length&&"function"==typeof(s=e.get(0)._msg_options||{})?.close&&s.close()};let a=e=>{var t,i=e.box._msg_prevFocus;query(r.box).find(".w2ui-message").length<=1?r.owner?r.owner.unlock(r.param,150):this.unlock(r.box,150):query(r.box).find(`#w2ui-message-${r.owner?.name}-`+(e.msgIndex-1)).css("z-index",1500),i?0<(t=query(i).closest(".w2ui-message")).length?t.get(0)._msg_options.setFocus(i):i.focus():"function"==typeof r.owner?.focus&&r.owner.focus(),query(e.box).remove(),0===e.msgIndex&&(c.css("z-index",e.tmp.zIndex),query(r.box).css("overflow",e.tmp.overflow)),e.trigger&&l.finish()};if("object"!=typeof(s="string"!=typeof s&&"number"!=typeof s?s:{width:String(s).length<300?350:550,height:String(s).length<300?170:250,text:String(s)}))return void i();null!=s.text&&(s.body=`
    ${s.text}
    `),null==s.width&&(s.width=350),null==s.height&&(s.height=170),null==s.hideOn&&(s.hideOn=["esc"]),null==s.on&&(h=s,s=new w2base,w2utils.extend(s,h)),s.on("open",e=>{w2utils.bindEvents(query(s.box).find(".w2ui-eaction"),s),query(e.detail.box).find("button, input, textarea, [name=hidden-first]").off(".message").on("keydown.message",function(e){27==e.keyCode&&s.hideOn.includes("esc")&&(s.cancelAction?s.action(s.cancelAction):s.close())}),setTimeout(()=>s.setFocus(s.focus),300)}),s.off(".prom");let n={self:s,action(e){return s.on("action.prom",e),n},close(e){return s.on("close.prom",e),n},open(e){return s.on("open.prom",e),n},then(e){return s.on("open:after.prom",e),n}},o=(null==s.actions&&null==s.buttons&&null==s.html&&(s.actions={Ok(e){e.detail.self.close()}}),s.off(".buttons"),null!=s.actions&&(s.buttons="",Object.keys(s.actions).forEach(e=>{var t=s.actions[e];let i=e;"function"==typeof t&&(s.buttons+=``),"object"==typeof t&&(s.buttons+=``,i=Array.isArray(s.actions)?t.text:e),"string"==typeof t&&(s.buttons+=``,i=t),"string"==typeof i&&(i=i[0].toLowerCase()+i.substr(1).replace(/\s+/g,"")),n[i]=function(t){return s.on("action.buttons",e=>{e.detail.action[0].toLowerCase()+e.detail.action.substr(1).replace(/\s+/g,"")==i&&t(e)}),n}})),Array("html","body","buttons").forEach(e=>{s[e]=String(s[e]??"").trim()}),""===s.body&&""===s.buttons||(s.html=`
    ${s.body||""}
    @@ -294,7 +294,7 @@ class w2event{constructor(e,t){Object.assign(this,{type:t.type??null,detail:t,ow
    ${this.right}
    -
    `,query(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(e),0{this.resize()}),this.last.observeResize.observe(this.box),i.finish(),this.refresh(),this.resize(),Date.now()-t)}initReorder(e,a){if(this.reorder){let t=this,i=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(e)),s=this.get(e,!0),l=query(i.get(0).cloneNode(!0)),r;l.attr("id","#tabs_"+this.name+"_tab_ghost"),this.last.moving={index:s,indexFrom:s,$tab:i,$ghost:l,divX:0,left:i.get(0).getBoundingClientRect().left,parentX:query(this.box).get(0).getBoundingClientRect().left,x:a.pageX,opacity:i.css("opacity")},query(document).off(".w2uiTabReorder").on("mousemove.w2uiTabReorder",function(e){if(!t.last.reordering){if(!0===(r=t.trigger("reorder",{target:t.tabs[s].id,indexFrom:s,tab:t.tabs[s]})).isCancelled)return;w2tooltip.hide(this.name+"_tooltip"),t.last.reordering=!0,l.addClass("moving"),l.css({"pointer-events":"none",position:"absolute",left:i.get(0).getBoundingClientRect().left}),i.css("opacity",0),query(t.box).find(".w2ui-scroll-wrapper").append(l.get(0)),query(t.box).find(".w2ui-tab-close").hide()}t.last.moving.divX=e.pageX-t.last.moving.x,l.css("left",t.last.moving.left-t.last.moving.parentX+t.last.moving.divX+"px"),t.dragMove(e)}).on("mouseup.w2uiTabReorder",function(){query(document).off(".w2uiTabReorder"),l.css({transition:"0.1s",left:t.last.moving.$tab.get(0).getBoundingClientRect().left-t.last.moving.parentX}),query(t.box).find(".w2ui-tab-close").show(),setTimeout(()=>{l.remove(),i.css({opacity:t.last.moving.opacity}),t.last.reordering&&r.finish({indexTo:t.last.moving.index}),t.last.reordering=!1},100)})}}scroll(n,o){return new Promise((e,t)=>{var i=query(this.box).find(".w2ui-scroll-wrapper"),s=i.get(0).scrollLeft,l=i.find(".w2ui-tabs-right").get(0),r=i.parent().get(0).getBoundingClientRect().width,a=s+parseInt(l.offsetLeft)+parseInt(l.clientWidth);switch(n){case"left":{let e=s-r+50;e<=0&&(e=0),i.get(0).scrollTo({top:0,left:e,behavior:o?"atuo":"smooth"});break}case"right":{let e=s+r-50;e>=a-r&&(e=a-r),i.get(0).scrollTo({top:0,left:e,behavior:o?"atuo":"smooth"});break}}setTimeout(()=>{this.resize(),e()},o?0:350)})}scrollIntoView(i,s){return new Promise((e,t)=>{null==i&&(i=this.active),null!=this.get(i)&&(query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(i)).get(0).scrollIntoView({block:"start",inline:"center",behavior:s?"atuo":"smooth"}),setTimeout(()=>{this.resize(),e()},s?0:500))})}resize(){var e=Date.now();if(null!=this.box){var t,i,s,l,r=this.trigger("resize",{target:this.name});if(!0!==r.isCancelled)return(t=query(this.box)).find(".w2ui-scroll-left, .w2ui-scroll-right").hide(),i=t.find(".w2ui-scroll-wrapper").get(0),l=t.find(".w2ui-tabs-right"),(s=t.get(0).getBoundingClientRect().width)<(l=0{window.location.hash=t},1)}e.finish()}}clickClose(e,t){var i=this.get(e);if(null==i||i.disabled)return!1;let s=this.trigger("close",{target:e,object:i,tab:i,originalEvent:t});!0!==s.isCancelled&&(this.animateClose(e).then(()=>{this.remove(e),s.finish(),this.refresh()}),t)&&t.stopPropagation()}animateClose(r){return new Promise((e,t)=>{var i=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r)),s=parseInt(i.get(0).clientWidth||0);let l=i.replace(`
    `);setTimeout(()=>{l.css({width:"0px"})},1),setTimeout(()=>{l.remove(),this.resize(),e()},500)})}animateInsert(t,r){return new Promise((i,e)=>{let s=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t)),l=query.html(this.getTabHTML(r.id));if(0==s.length)(s=query(this.box).find("#tabs_tabs_right")).before(l),this.resize();else{l.css({opacity:0}),query(this.box).find("#tabs_tabs_right").before(l.get(0));let e=query(this.box).find("#"+l.attr("id")).get(0).clientWidth??0,t=query.html('
    ');s.before(t),l.hide(),t.before(l[0]),setTimeout(()=>{t.css({width:e+"px"})},1),setTimeout(()=>{t.remove(),l.css({opacity:1}).show(),this.refresh(r.id),this.resize(),i()},500)}})}}let w2panels=["top","left","main","preview","right","bottom"];class w2layout extends w2base{constructor(e){super(e.name),this.box=null,this.name=null,this.panels=[],this.last={},this.padding=1,this.resizer=4,this.style="",this.onShow=null,this.onHide=null,this.onResizing=null,this.onResizerClick=null,this.onRender=null,this.onRefresh=null,this.onChange=null,this.onResize=null,this.onDestroy=null,this.panel_template={type:null,title:"",size:100,minSize:20,maxSize:!1,hidden:!1,resizable:!1,overflow:"auto",style:"",html:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},removed:null,onRefresh:null,onShow:null,onHide:null},Object.assign(this,e),Array.isArray(this.panels)||(this.panels=[]),this.panels.forEach((e,t)=>{var i,s,l;this.panels[t]=w2utils.extend({},this.panel_template,e),(w2utils.isPlainObject(e.tabs)||Array.isArray(e.tabs))&&function(e,t,i){var s=e.get(t);null!=s&&null==i&&(i=s.tabs);if(null==s||null==i)return;Array.isArray(i)&&(i={tabs:i});var l=e.name+"_"+t+"_tabs";w2ui[l]&&w2ui[l].destroy();s.tabs=new w2tabs(w2utils.extend({},i,{owner:e,name:e.name+"_"+t+"_tabs"})),s.show.tabs=!0}(this,e.type),(w2utils.isPlainObject(e.toolbar)||Array.isArray(e.toolbar))&&(t=this,e=e.type,i=void 0,null!=(s=t.get(e))&&null==i&&(i=s.toolbar),null!=s)&&null!=i&&(Array.isArray(i)&&(i={items:i}),l=t.name+"_"+e+"_toolbar",w2ui[l]&&w2ui[l].destroy(),s.toolbar=new w2toolbar(w2utils.extend({},i,{owner:t,name:t.name+"_"+e+"_toolbar"})),s.show.toolbar=!0)}),w2panels.forEach(e=>{null==this.get(e)&&this.panels.push(w2utils.extend({},this.panel_template,{type:e,hidden:"main"!==e,size:50}))}),"string"==typeof this.box&&(this.box=query(this.box).get(0)),this.box&&this.render(this.box)}html(l,r,a){let n=this.get(l);var e={panel:l,html:n.html,error:!1,cancelled:!1,removed(e){"function"==typeof e&&(n.removed=e)}};if("function"==typeof n.removed&&(n.removed({panel:l,html:n.html,html_new:r,transition:a||"none"}),n.removed=null),"css"==l)query(this.box).find("#layout_"+this.name+"_panel_css").html(""),e.status=!0;else if(null==n)console.log("ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css"),e.error=!0;else if(null!=r){var t=this.trigger("change",{target:l,panel:n,html_new:r,transition:a});if(!0===t.isCancelled)e.cancelled=!0;else{let i="#layout_"+this.name+"_panel_"+n.type;var o=query(this.box).find(i+"> .w2ui-panel-content");let s=0;if(0 .w2ui-panel-content"),t=(e.after('
    '),query(this.box).find(i+"> .w2ui-panel-content.new-panel"));e.css("top",s),t.css("top",s),"object"==typeof r?(r.box=t[0],r.render()):t.hide().html(r),w2utils.transition(e[0],t[0],a,()=>{e.remove(),t.removeClass("new-panel"),t.css("overflow",n.overflow),query(query(this.box).find(i+"> .w2ui-panel-content").get(1)).remove(),query(this.box).removeClass("animating"),this.refresh(l)})}else this.refresh(l);t.finish()}}return e}message(e,t){var i=this.get(e);let s=query(this.box).find("#layout_"+this.name+"_panel_"+i.type),l=s.css("overflow");s.css("overflow","hidden");i=w2utils.message({owner:this,box:s.get(0),after:".w2ui-panel-title",param:e},t);return i&&i.self.on("close:after",()=>{s.css("overflow",l)}),i}confirm(e,t){var i=this.get(e);let s=query(this.box).find("#layout_"+this.name+"_panel_"+i.type),l=s.css("overflow");s.css("overflow","hidden");i=w2utils.confirm({owner:this,box:s.get(0),after:".w2ui-panel-title",param:e},t);return i&&i.self.on("close:after",()=>{s.css("overflow",l)}),i}load(i,s,l){return new Promise((t,e)=>{"css"!=i&&null==this.get(i)||null==s?e():fetch(s).then(e=>e.text()).then(e=>{this.resize(),t(this.html(i,e,l))})})}sizeTo(e,t,i){return null!=this.get(e)&&(query(this.box).find(":scope > div > .w2ui-panel").css("transition",!0!==i?".2s":"0s"),setTimeout(()=>{this.set(e,{size:t})},1),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),this.resize()},300),!0)}show(e,t){let i=this.trigger("show",{target:e,thisect:this.get(e),immediate:t});var s;if(!0!==i.isCancelled)return null!=(s=this.get(e))&&(!(s.hidden=!1)===t?(query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"1"}),i.finish(),this.resize()):(query(this.box).addClass("animating"),query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),query(this.box).find(":scope > div > .w2ui-panel").css("transition",".2s"),setTimeout(()=>{this.resize()},1),setTimeout(()=>{query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),query(this.box).removeClass("animating"),i.finish(),this.resize()},300)),!0)}hide(e,t){let i=this.trigger("hide",{target:e,object:this.get(e),immediate:t});var s;if(!0!==i.isCancelled)return null!=(s=this.get(e))&&((s.hidden=!0)===t?(query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),i.finish(),this.resize()):(query(this.box).addClass("animating"),query(this.box).find(":scope > div > .w2ui-panel").css("transition",".2s"),query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),setTimeout(()=>{this.resize()},1),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),query(this.box).removeClass("animating"),i.finish(),this.resize()},300)),!0)}toggle(e,t){var i=this.get(e);return null!=i&&(i.hidden?this.show(e,t):this.hide(e,t))}set(e,t){var i=this.get(e,!0);return null!=i&&(w2utils.extend(this.panels[i],t),null==t.html&&null==t.resizable||this.refresh(e),this.resize(),!0)}get(t,i){for(let e=0;e .w2ui-panel-content");return 1!=e.length?null:e[0]}hideToolbar(e){var t=this.get(e);t&&(t.show.toolbar=!1,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").hide(),this.resize())}showToolbar(e){var t=this.get(e);t&&(t.show.toolbar=!0,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").show(),this.resize())}toggleToolbar(e){var t=this.get(e);t&&(t.show.toolbar?this.hideToolbar(e):this.showToolbar(e))}assignToolbar(e,t){"string"==typeof t&&null!=w2ui[t]&&(t=w2ui[t]);var i=this.get(e),s=(i.toolbar=t,query(this.box).find(e+"> .w2ui-panel-toolbar"));null!=i.toolbar?(0===s.find("[name="+i.toolbar.name+"]").length?i.toolbar.render(s.get(0)):null!=i.toolbar&&i.toolbar.refresh(),(t.owner=this).showToolbar(e),this.refresh(e)):(s.html(""),this.hideToolbar(e))}hideTabs(e){var t=this.get(e);t&&(t.show.tabs=!1,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").hide(),this.resize())}showTabs(e){var t=this.get(e);t&&(t.show.tabs=!0,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").show(),this.resize())}toggleTabs(e){var t=this.get(e);t&&(t.show.tabs?this.hideTabs(e):this.showTabs(e))}render(e){var t=Date.now();let o=this;"string"==typeof e&&(e=query(e).get(0));var i=this.trigger("render",{target:this.name,box:e??this.box});if(!0!==i.isCancelled){if(null!=e&&(0"),0
    ';query(this.box).find(":scope > div").append(s)}return query(this.box).find(":scope > div").append('
    '),this.refresh(),this.last.observeResize=new ResizeObserver(()=>{this.resize()}),this.last.observeResize.observe(this.box),i.finish(),setTimeout(()=>{o.last.events={resizeStart:l,mouseMove:a,mouseUp:r},this.resize()},0),Date.now()-t}function l(e,t){o.box&&(t=t||window.event,query(document).off("mousemove",o.last.events.mouseMove).on("mousemove",o.last.events.mouseMove),query(document).off("mouseup",o.last.events.mouseUp).on("mouseup",o.last.events.mouseUp),o.last.resize={type:e,x:t.screenX,y:t.screenY,diff_x:0,diff_y:0,value:0},w2panels.forEach(e=>{var t=query(o.el(e)).find(".w2ui-lock");0{var t=query(o.el(e)).find(".w2ui-lock");"yes"==t.data("locked")?t.removeData("locked"):o.unlock(e)}),0!==o.last.diff_x||0!==o.last.resize.diff_y){var s=o.get("top"),l=o.get("bottom"),r=o.get(o.last.resize.type),i=w2utils.getSize(query(o.box),"width"),a=w2utils.getSize(query(o.box),"height"),n=String(r.size);let e,t;switch(o.last.resize.type){case"top":e=parseInt(r.sizeCalculated)+o.last.resize.diff_y,t=0;break;case"bottom":e=parseInt(r.sizeCalculated)-o.last.resize.diff_y,t=0;break;case"preview":e=parseInt(r.sizeCalculated)-o.last.resize.diff_y,t=(s&&!s.hidden?s.sizeCalculated:0)+(l&&!l.hidden?l.sizeCalculated:0);break;case"left":e=parseInt(r.sizeCalculated)+o.last.resize.diff_x,t=0;break;case"right":e=parseInt(r.sizeCalculated)-o.last.resize.diff_x,t=0}"%"==n.substr(n.length-1)?r.size=Math.floor(100*e/("left"==r.type||"right"==r.type?i:a-t)*100)/100+"%":"-"==String(r.size).substr(0,1)?r.size=parseInt(r.size)-r.sizeCalculated+e:r.size=e,o.resize()}query(o.box).find("#layout_"+o.name+"_resizer_"+o.last.resize.type).removeClass("active"),delete o.last.resize}}function a(i){if(o.box&&(i=i||window.event,null!=o.last.resize)){var s=o.get(o.last.resize.type),l=o.last.resize,r=o.trigger("resizing",{target:o.name,object:s,originalEvent:i,panel:l?l.type:"all",diff_x:l?l.diff_x:0,diff_y:l?l.diff_y:0});if(!0!==r.isCancelled){var a=query(o.box).find("#layout_"+o.name+"_resizer_"+l.type);let e=i.screenX-l.x,t=i.screenY-l.y;var n=o.get("main");switch(a.hasClass("active")||a.addClass("active"),l.type){case"left":s.minSize-e>s.width&&(e=s.minSize-s.width),s.maxSize&&s.width+e>s.maxSize&&(e=s.maxSize-s.width),n.minSize+e>n.width&&(e=n.width-n.minSize);break;case"right":s.minSize+e>s.width&&(e=s.width-s.minSize),s.maxSize&&s.width-e>s.maxSize&&(e=s.width-s.maxSize),n.minSize-e>n.width&&(e=n.minSize-n.width);break;case"top":s.minSize-t>s.height&&(t=s.minSize-s.height),s.maxSize&&s.height+t>s.maxSize&&(t=s.maxSize-s.height),n.minSize+t>n.height&&(t=n.height-n.minSize);break;case"preview":case"bottom":s.minSize+t>s.height&&(t=s.height-s.minSize),s.maxSize&&s.height-t>s.maxSize&&(t=s.height-s.maxSize),n.minSize-t>n.height&&(t=n.minSize-n.height)}switch(l.diff_x=e,l.diff_y=t,l.type){case"top":case"preview":case"bottom":(l.diff_x=0) .w2ui-panel-content")[0],setTimeout(()=>{0 .w2ui-panel-content").length&&(query(l.box).find(t+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",e.overflow)[0].style.cssText+=";"+e.style),e.html&&"function"==typeof e.html.render&&e.html.render()},1)):0 .w2ui-panel-content").length&&(query(l.box).find(t+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(e.html).css("overflow",e.overflow)[0].style.cssText+=";"+e.style);let i=query(l.box).find(t+"> .w2ui-panel-tabs");e.show.tabs?0===i.find("[name="+e.tabs.name+"]").length&&null!=e.tabs?e.tabs.render(i.get(0)):e.tabs.refresh():i.html("").removeClass("w2ui-tabs").hide(),i=query(l.box).find(t+"> .w2ui-panel-toolbar"),e.show.toolbar?0===i.find("[name="+e.toolbar.name+"]").length&&null!=e.toolbar?e.toolbar.render(i.get(0)):e.toolbar.refresh():i.html("").removeClass("w2ui-toolbar").hide(),i=query(l.box).find(t+"> .w2ui-panel-title"),e.title?i.html(e.title).show():i.html("").hide()}else{if(0===query(l.box).find("#layout_"+l.name+"_panel_main").length)return void l.render();l.resize();for(let e=0;ethis.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_top").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"top",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("top",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_top").hide(),query(this.box).find("#layout_"+this.name+"_resizer_top").hide()),null!=c&&!0!==c.hidden?(e=0,t=0+(b?f.sizeCalculated+this.padding:0),s=c.sizeCalculated,l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_left").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),c.width=s,c.height=l,c.resizable&&(e=c.sizeCalculated-(0===this.padding?this.resizer:0),s=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_left").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"left",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("left",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_left").hide(),query(this.box).find("#layout_"+this.name+"_resizer_left").hide()),null!=p&&!0!==p.hidden?(e=o-p.sizeCalculated,t=0+(b?f.sizeCalculated+this.padding:0),s=p.sizeCalculated,l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_right").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),p.width=s,p.height=l,p.resizable&&(e-=this.padding,s=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_right").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"right",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("right",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_right").hide(),query(this.box).find("#layout_"+this.name+"_resizer_right").hide()),null!=m&&!0!==m.hidden?(e=0,t=h-m.sizeCalculated,s=o,l=m.sizeCalculated,query(this.box).find("#layout_"+this.name+"_panel_bottom").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),m.width=s,m.height=l,m.resizable&&(t-=0===this.padding?0:this.padding,l=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_bottom").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"bottom",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("bottom",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_bottom").hide(),query(this.box).find("#layout_"+this.name+"_resizer_bottom").hide()),e=0+(y?c.sizeCalculated+this.padding:0),t=0+(b?f.sizeCalculated+this.padding:0),s=o-(y?c.sizeCalculated+this.padding:0)-(w?p.sizeCalculated+this.padding:0),l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0)-(g?u.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_main").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),d.width=s,d.height=l,null!=u&&!0!==u.hidden?(e=0+(y?c.sizeCalculated+this.padding:0),t=h-(v?m.sizeCalculated+this.padding:0)-u.sizeCalculated,s=o-(y?c.sizeCalculated+this.padding:0)-(w?p.sizeCalculated+this.padding:0),l=u.sizeCalculated,query(this.box).find("#layout_"+this.name+"_panel_preview").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),u.width=s,u.height=l,u.resizable&&(t-=0===this.padding?0:this.padding,l=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_preview").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"preview",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("preview",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_preview").hide(),query(this.box).find("#layout_"+this.name+"_resizer_preview").hide());for(let t=0;t .w2ui-panel-";let e=0;q&&(q.title&&(_=query(this.box).find(C+"title").css({top:e+"px",display:"block"}),e+=w2utils.getSize(_,"height")),q.show.tabs&&(_=query(this.box).find(C+"tabs").css({top:e+"px",display:"block"}),e+=w2utils.getSize(_,"height")),q.show.toolbar)&&(q=query(this.box).find(C+"toolbar").css({top:e+"px",display:"block"}),e+=w2utils.getSize(q,"height")),query(this.box).find(C+"content").css({display:"block"}).css({top:e+"px"})}return n.finish(),Date.now()-r}}destroy(){var e=this.trigger("destroy",{target:this.name});if(!0!==e.isCancelled)return null!=w2ui[this.name]&&(0'},add:{type:"button",id:"w2ui-add",text:"Add New",tooltip:"Add new record",icon:"w2ui-icon-plus"},edit:{type:"button",id:"w2ui-edit",text:"Edit",tooltip:"Edit selected record",icon:"w2ui-icon-pencil",batch:1,disabled:!0},delete:{type:"button",id:"w2ui-delete",text:"Delete",tooltip:"Delete selected records",icon:"w2ui-icon-cross",batch:!0,disabled:!0},save:{type:"button",id:"w2ui-save",text:"Save",tooltip:"Save changed records",icon:"w2ui-icon-check"}},this.operators={text:["is","begins","contains","ends"],number:["=","between",">","<",">=","<="],date:["is",{oper:"less",text:"before"},{oper:"more",text:"since"},"between"],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},this.defaultOperator={text:"begins",number:"=",date:"is",list:"is",enum:"in",hex:"begins",color:"begins"},this.operatorsMap={text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},this.onAdd=null,this.onEdit=null,this.onRequest=null,this.onLoad=null,this.onDelete=null,this.onSave=null,this.onSelect=null,this.onClick=null,this.onDblClick=null,this.onContextMenu=null,this.onContextMenuClick=null,this.onColumnClick=null,this.onColumnDblClick=null,this.onColumnResize=null,this.onColumnAutoResize=null,this.onSort=null,this.onSearch=null,this.onSearchOpen=null,this.onChange=null,this.onRestore=null,this.onExpand=null,this.onCollapse=null,this.onError=null,this.onKeydown=null,this.onToolbar=null,this.onColumnOnOff=null,this.onCopy=null,this.onPaste=null,this.onSelectionExtend=null,this.onEditField=null,this.onRender=null,this.onRefresh=null,this.onReload=null,this.onResize=null,this.onDestroy=null,this.onStateSave=null,this.onStateRestore=null,this.onFocus=null,this.onBlur=null,this.onReorderRow=null,this.onSearchSave=null,this.onSearchRemove=null,this.onSearchSelect=null,this.onColumnSelect=null,this.onColumnDragStart=null,this.onColumnDragEnd=null,this.onResizerDblClick=null,this.onMouseEnter=null,this.onMouseLeave=null,w2utils.extend(this,e),Array.isArray(this.records)){let i=[];this.records.forEach((e,t)=>{null!=e[this.recid]&&(e.recid=e[this.recid]),null==e.recid&&console.log("ERROR: Cannot add records without recid. (obj: "+this.name+")"),!0===e.w2ui?.summary&&(this.summary.push(e),i.push(t))}),i.sort();for(let e=i.length-1;0<=e;e--)this.records.splice(i[e],1)}Array.isArray(this.columns)&&this.columns.forEach((i,e)=>{i=w2utils.extend({},this.colTemplate,i);e=(this.columns[e]=i).searchable;if(null!=e&&!1!==e&&null==this.getSearch(i.field))if(w2utils.isPlainObject(e))this.addSearch(w2utils.extend({field:i.field,label:i.text,type:"text"},e));else{let e=i.searchable,t="";!0===i.searchable&&(e="text",t='size="20"'),this.addSearch({field:i.field,label:i.text,type:e,attr:t})}}),Array.isArray(this.defaultSearches)&&this.defaultSearches.forEach((e,t)=>{e.id="default-"+t,e.icon??="w2ui-icon-search"});e=this.cache("searches");Array.isArray(e)&&e.forEach(e=>{this.savedSearches.push({id:e.id??"none",text:e.text??"none",icon:"w2ui-icon-search",remove:!0,logic:e.logic??"AND",data:e.data??[]})}),"string"==typeof this.box&&(this.box=query(this.box).get(0)),this.box&&this.render(this.box)}add(t,i){Array.isArray(t)||(t=[t]);let s=0;for(let e=0;ethis.records.length&&(n=this.records.length);for(let i=a;i{this.columns.forEach(i=>{if(i.field==e){let t=w2utils.clone(s);Object.keys(t).forEach(e=>{"function"==typeof t[e]&&(t[e]=t[e](i)),i[e]!=t[e]&&l++}),w2utils.extend(i,t)}})}),0{if(!(e.w2ui&&null!=e.w2ui.parent_recid||t.w2ui&&null!=t.w2ui.parent_recid))return o(e,t);var i=a(e),s=a(t);for(let e=0;es.length?1:i.length{this.status(w2utils.lang("Sorting took ${count} seconds",{count:e/1e3}))},10),e;function a(e){var t;return e.w2ui&&null!=e.w2ui.parent_recid?e.w2ui._path||((t=n.get(e.w2ui.parent_recid))?a(t).concat(e):(console.log("ERROR: no parent record: "+e.w2ui.parent_recid),[e])):[e]}function o(s,l){if(s===l)return 0;for(let i=0;it.constructor.name?s:-s;e&&"object"==typeof e&&(e=e.valueOf()),t&&"object"==typeof t&&(t=t.valueOf());var r={}.toString;switch(e&&"object"==typeof e&&e.toString!=r&&(e=String(e)),t&&"object"==typeof t&&t.toString!=r&&(t=String(t)),"string"==typeof e&&(e=e.toLowerCase().trim()),"string"==typeof t&&(t=t.toLowerCase().trim()),l){case"natural":l=w2utils.naturalCompare;break;case"i18n":l=w2utils.i18nCompare}return"function"==typeof l?l(e,t)*s:t=parseFloat(n)&&parseFloat(c.parseField(l,s.field))<=parseFloat(o)&&r++:"date"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.isDate(h,w2utils.settings.dateFormat,!0),n=w2utils.isDate(n,w2utils.settings.dateFormat,!0),null!=(o=w2utils.isDate(o,w2utils.settings.dateFormat,!0))&&(o=new Date(o.getTime()+864e5)),a>=n&&a=n&&a=n)&&a=":d=!0;case">":case"more":-1!=["int","float","money","currency","percent"].indexOf(s.type)?(a=parseFloat(c.parseField(l,s.field)),n=parseFloat(i.value),(a>n||d&&a===n)&&r++):"date"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.isDate(h,w2utils.settings.dateFormat,!0),n=w2utils.isDate(n,w2utils.settings.dateFormat,!0),(a>n||d&&a===n)&&r++):"time"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.formatTime(h,"hh24:mi"),n=w2utils.formatTime(n,"hh24:mi"),(a>n||d&&a===n)&&r++):"datetime"==s.type&&(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.formatDateTime(h,"yyyy-mm-dd|hh24:mm:ss"),n=w2utils.formatDateTime(w2utils.isDateTime(n,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss"),a.length==n.length)&&(a>n||d&&a===n)&&r++;break;case"in":h=i.value,-1===(h=i.svalue?i.svalue:h).indexOf(w2utils.isFloat(t)?parseFloat(t):t)&&-1===h.indexOf(a)||r++;break;case"not in":h=i.value,-1===(h=i.svalue?i.svalue:h).indexOf(w2utils.isFloat(t)?parseFloat(t):t)&&-1===h.indexOf(a)&&r++;break;case"begins":case"begins with":0===a.indexOf(n)&&r++;break;case"contains":0<=a.indexOf(n)&&r++;break;case"null":null==c.parseField(l,s.field)&&r++;break;case"not null":null!=c.parseField(l,s.field)&&r++;break;case"ends":case"ends with":let e=a.lastIndexOf(n);-1!==e&&e==a.length-n.length&&r++}}}if("OR"==c.last.logic&&0!==r||"AND"==c.last.logic&&r==c.searchData.length)return!0;if(l.w2ui?.children&&!0!==l.w2ui?.expanded)for(let t=0;tthis.records.length&&(i=this.records.length-s),0{this.status(w2utils.lang("Search took ${count} seconds",{count:e/1e3}))},10),e}}getRangeData(e,i){var s=this.get(e[0].recid,!0),l=this.get(e[1].recid,!0),r=e[0].column,a=e[1].column,n=[];if(r==a)for(let e=s;e<=l;e++){var t=this.records[e],o=t[this.columns[r].field]||null;n.push(!0!==i?o:{data:o,column:r,index:e,record:t})}else if(s==l){var h=this.records[s];for(let e=r;e<=a;e++){var d=h[this.columns[e].field]||null;n.push(!0!==i?d:{data:d,column:e,index:s,record:h})}}else for(let t=s;t<=l;t++){var u=this.records[t];n.push([]);for(let e=r;e<=a;e++){var c=u[this.columns[e].field];!0!==i?n[n.length-1].push(c):n[n.length-1].push({data:c,column:e,index:t,record:u})}}return n}addRange(s){let e=0,l,r;if("row"!=this.selectType){Array.isArray(s)||(s=[s]);for(let i=0;ithis.last.colStart&&(e=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(u.recid)+' td[col="start"]')),u.columnthis.last.colEnd&&(t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(c.recid)+' td[col="end"]'),l='"end"');var p=parseInt(query(this.box).find("#grid_"+this.name+"_rec_top").next().attr("index")),f=parseInt(query(this.box).find("#grid_"+this.name+"_rec_bottom").prev().attr("index")),m=parseInt(query(this.box).find("#grid_"+this.name+"_frec_top").next().attr("index")),g=parseInt(query(this.box).find("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===e.length&&u.indexp&&(e=query(this.box).find("#grid_"+this.name+"_rec_top").next().find('td[col="'+u.column+'"]')),0===t.length&&c.index>f&&u.indexm&&(i=query(this.box).find("#grid_"+this.name+"_frec_top").next().find('td[col="'+u.column+'"]')),0===s.length&&c.index>g&&u.index'+("selection"==d.name?'
    ':"")+""),a=query(this.box).find("#grid_"+this.name+"_f"+d.name)):(a.attr("style",d.style),a.find(".w2ui-selection-resizer").show()),0===s.length&&(0===(s=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(c.recid)+" td:last-child")).length&&(s=query(this.box).find("#grid_"+this.name+"_frec_bottom td:first-child")),a.css("border-right","0px"),a.find(".w2ui-selection-resizer").hide()),null!=u.recid)&&null!=c.recid&&0'+("selection"==d.name?'
    ':"")+""),a=query(this.box).find("#grid_"+this.name+"_"+d.name)):a.attr("style",d.style),0===e.length&&0===(e=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(u.recid)+" td:first-child")).length&&(e=query(this.box).find("#grid_"+this.name+"_rec_top td:first-child")),0!==s.length&&a.css("border-left","0px"),null!=u.recid)&&null!=c.recid&&0{e=this.trigger("resizerDblClick",{target:this.name,originalEvent:e});!0!==e.isCancelled&&e.finish()});let n={target:this.name,originalRange:null,newRange:null};return Date.now()-e;function i(s){var l=r.last.move;if(l&&"expand"==l.type){l.divX=s.screenX-l.x,l.divY=s.screenY-l.y;let e,t,i=s.target;"TD"!=i.tagName.toUpperCase()&&(i=query(i).closest("td")[0]),null!=(t=null!=query(i).attr("col")?parseInt(query(i).attr("col")):t)&&(i=query(i).closest("tr")[0],e=r.records[query(i).attr("index")].recid,l.newRange[1].recid!=e||l.newRange[1].column!=t)&&(s=w2utils.clone(l.newRange),l.newRange=[{recid:l.recid,column:l.column},{recid:e,column:t}],n.detail&&(n.detail.newRange=w2utils.clone(l.newRange),n.detail.originalRange=w2utils.clone(l.originalRange)),!0===(n=r.trigger("selectionExtend",n)).isCancelled?(l.newRange=s,n.detail.newRange=s):(r.removeRange("grid-selection-expand"),r.addRange({name:"grid-selection-expand",range:l.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"})))}}function s(e){r.removeRange("grid-selection-expand"),delete r.last.move,query("body").off(".w2ui-"+r.name),n.finish&&n.finish()}}}select(){if(0===arguments.length)return 0;let s=0;var l=this.last.selection;this.multiSelect||this.selectNone(!0);let t=Array.from(arguments);Array.isArray(t[0])&&(t=t[0]);var e={target:this.name},e=(1==t.length?(e.multiple=!1,w2utils.isPlainObject(t[0])?e.clicked={recid:t[0].recid,column:t[0].column}:e.recid=t[0]):(e.multiple=!0,e.clicked={recids:t}),this.trigger("select",e));if(!0===e.isCancelled)return 0;if("row"==this.selectType)for(let e=0;e=this.last.range_start&&r+1<=this.last.range_end)&&(e=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(i)),t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(i))),"row"==this.selectType&&-1==l.indexes.indexOf(r)&&(l.indexes.push(r),e&&t&&(e.addClass("w2ui-selected").find(".w2ui-col-number").addClass("w2ui-row-selected"),t.addClass("w2ui-selected").find(".w2ui-col-number").addClass("w2ui-row-selected"),e.find(".w2ui-grid-select-check").prop("checked",!0)),s++)}}else{var a={};for(let e=0;e=this.last.range_start&&u+1<=this.last.range_end&&(t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(h)),i=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(h)));var c=l.columns[u]||[];-1==l.indexes.indexOf(u)&&l.indexes.push(u);for(let e=0;ee-t);for(let e=0;ee-t);var f=0 td[col="${h}"]`).removeClass("w2ui-selected w2ui-inactive"),query(this.box).find(`#grid_${this.name}_frec_${w2utils.escapeId(r)} > td[col="${h}"]`).removeClass("w2ui-selected w2ui-inactive");let t=!1,i=!1;var d=this.getSelection();for(let e=0;e{i(t,""),Array.isArray(t.items)&&t.items.forEach(e=>{i(e,t.id+":")})}),this.show.toolbarSave&&(0{this.initSearches(),this.last.search_opened=!0;let t=query(`#w2overlay-${this.name}-search-overlay`);t.data("gridName",this.name).off(".grid-search").on("click.grid-search",()=>{t.find("input, select").each(e=>{e=query(e).data("tooltipName");e&&e.forEach(e=>{w2tooltip.hide(e)})})}),w2utils.bindEvents(t.find("select, input, button"),this);var i=query(`#w2overlay-${this.name}-search-overlay *[rel=search]`);0{t.removeClass("checked"),this.last.search_opened=!1})}}}searchClose(){w2tooltip.hide(this.name+"-search-overlay")}searchFieldTooltip(e,t,i){var e=this.searches[e],s=this.searchData[t];let l=s.operator,r=("less"==(l="more"==l&&"date"==s.type?"since":l)&&"date"==s.type&&(l="before"),""),a=s.value;Array.isArray(s.value)?(s.value.forEach(e=>{r+=`${e.text||e}`}),"date"==s.type&&(r="",s.value.forEach(e=>{r+=`${w2utils.formatDate(e)}`}))):"date"==s.type&&(a=w2utils.formatDateTime(a)),w2tooltip.hide(this.name+"-search-props"),w2tooltip.show({name:this.name+"-search-props",anchor:i,class:"w2ui-white",hideOn:"doc-click",html:` +
    `,query(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-tabs").html(e),0{this.resize()}),this.last.observeResize.observe(this.box),i.finish(),this.refresh(),this.resize(),Date.now()-t)}initReorder(e,a){if(this.reorder){let t=this,i=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(e)),s=this.get(e,!0),l=query(i.get(0).cloneNode(!0)),r;l.attr("id","#tabs_"+this.name+"_tab_ghost"),this.last.moving={index:s,indexFrom:s,$tab:i,$ghost:l,divX:0,left:i.get(0).getBoundingClientRect().left,parentX:query(this.box).get(0).getBoundingClientRect().left,x:a.pageX,opacity:i.css("opacity")},query(document).off(".w2uiTabReorder").on("mousemove.w2uiTabReorder",function(e){if(!t.last.reordering){if(!0===(r=t.trigger("reorder",{target:t.tabs[s].id,indexFrom:s,tab:t.tabs[s]})).isCancelled)return;w2tooltip.hide(this.name+"_tooltip"),t.last.reordering=!0,l.addClass("moving"),l.css({"pointer-events":"none",position:"absolute",left:i.get(0).getBoundingClientRect().left}),i.css("opacity",0),query(t.box).find(".w2ui-scroll-wrapper").append(l.get(0)),query(t.box).find(".w2ui-tab-close").hide()}t.last.moving.divX=e.pageX-t.last.moving.x,l.css("left",t.last.moving.left-t.last.moving.parentX+t.last.moving.divX+"px"),t.dragMove(e)}).on("mouseup.w2uiTabReorder",function(){query(document).off(".w2uiTabReorder"),l.css({transition:"0.1s",left:t.last.moving.$tab.get(0).getBoundingClientRect().left-t.last.moving.parentX}),query(t.box).find(".w2ui-tab-close").show(),setTimeout(()=>{l.remove(),i.css({opacity:t.last.moving.opacity}),t.last.reordering&&r.finish({indexTo:t.last.moving.index}),t.last.reordering=!1},100)})}}scroll(n,o){return new Promise((e,t)=>{var i=query(this.box).find(".w2ui-scroll-wrapper"),s=i.get(0).scrollLeft,l=i.find(".w2ui-tabs-right").get(0),r=i.parent().get(0).getBoundingClientRect().width,a=s+parseInt(l.offsetLeft)+parseInt(l.clientWidth);switch(n){case"left":{let e=s-r+50;e<=0&&(e=0),i.get(0).scrollTo({top:0,left:e,behavior:o?"atuo":"smooth"});break}case"right":{let e=s+r-50;e>=a-r&&(e=a-r),i.get(0).scrollTo({top:0,left:e,behavior:o?"atuo":"smooth"});break}}setTimeout(()=>{this.resize(),e()},o?0:350)})}scrollIntoView(i,s){return new Promise((e,t)=>{null==i&&(i=this.active),null!=this.get(i)&&(query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(i)).get(0).scrollIntoView({block:"start",inline:"center",behavior:s?"atuo":"smooth"}),setTimeout(()=>{this.resize(),e()},s?0:500))})}resize(){var e=Date.now();if(null!=this.box){var t,i,s,l,r=this.trigger("resize",{target:this.name});if(!0!==r.isCancelled)return(t=query(this.box)).find(".w2ui-scroll-left, .w2ui-scroll-right").hide(),i=t.find(".w2ui-scroll-wrapper").get(0),l=t.find(".w2ui-tabs-right"),(s=t.get(0).getBoundingClientRect().width)<(l=0{window.location.hash=t},1)}e.finish()}}clickClose(e,t){var i=this.get(e);if(null==i||i.disabled)return!1;let s=this.trigger("close",{target:e,object:i,tab:i,originalEvent:t});!0!==s.isCancelled&&(this.animateClose(e).then(()=>{this.remove(e),s.finish(),this.refresh()}),t)&&t.stopPropagation()}animateClose(r){return new Promise((e,t)=>{var i=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(r)),s=parseInt(i.get(0).clientWidth||0);let l=i.replace(`
    `);setTimeout(()=>{l.css({width:"0px"})},1),setTimeout(()=>{l.remove(),this.resize(),e()},500)})}animateInsert(t,r){return new Promise((i,e)=>{let s=query(this.box).find("#tabs_"+this.name+"_tab_"+w2utils.escapeId(t)),l=query.html(this.getTabHTML(r.id));if(0==s.length)(s=query(this.box).find("#tabs_tabs_right")).before(l),this.resize();else{l.css({opacity:0}),query(this.box).find("#tabs_tabs_right").before(l.get(0));let e=query(this.box).find("#"+l.attr("id")).get(0).clientWidth??0,t=query.html('
    ');s.before(t),l.hide(),t.before(l[0]),setTimeout(()=>{t.css({width:e+"px"})},1),setTimeout(()=>{t.remove(),l.css({opacity:1}).show(),this.refresh(r.id),this.resize(),i()},500)}})}}let w2panels=["top","left","main","preview","right","bottom"];class w2layout extends w2base{constructor(e){super(e.name),this.box=null,this.name=null,this.panels=[],this.last={},this.padding=1,this.resizer=4,this.style="",this.onShow=null,this.onHide=null,this.onResizing=null,this.onResizerClick=null,this.onRender=null,this.onRefresh=null,this.onChange=null,this.onResize=null,this.onDestroy=null,this.panel_template={type:null,title:"",size:100,minSize:20,maxSize:!1,hidden:!1,resizable:!1,overflow:"auto",style:"",html:"",tabs:null,toolbar:null,width:null,height:null,show:{toolbar:!1,tabs:!1},removed:null,onRefresh:null,onShow:null,onHide:null},Object.assign(this,e),Array.isArray(this.panels)||(this.panels=[]),this.panels.forEach((e,t)=>{var i,s,l;this.panels[t]=w2utils.extend({},this.panel_template,e),(w2utils.isPlainObject(e.tabs)||Array.isArray(e.tabs))&&function(e,t,i){var s=e.get(t);null!=s&&null==i&&(i=s.tabs);if(null==s||null==i)return;Array.isArray(i)&&(i={tabs:i});var l=e.name+"_"+t+"_tabs";w2ui[l]&&w2ui[l].destroy();s.tabs=new w2tabs(w2utils.extend({},i,{owner:e,name:e.name+"_"+t+"_tabs"})),s.show.tabs=!0}(this,e.type),(w2utils.isPlainObject(e.toolbar)||Array.isArray(e.toolbar))&&(t=this,e=e.type,i=void 0,null!=(s=t.get(e))&&null==i&&(i=s.toolbar),null!=s)&&null!=i&&(Array.isArray(i)&&(i={items:i}),l=t.name+"_"+e+"_toolbar",w2ui[l]&&w2ui[l].destroy(),s.toolbar=new w2toolbar(w2utils.extend({},i,{owner:t,name:t.name+"_"+e+"_toolbar"})),s.show.toolbar=!0)}),w2panels.forEach(e=>{null==this.get(e)&&this.panels.push(w2utils.extend({},this.panel_template,{type:e,hidden:"main"!==e,size:50}))}),"string"==typeof this.box&&(this.box=query(this.box).get(0)),this.box&&this.render(this.box)}html(l,r,a){let n=this.get(l);var e={panel:l,html:n.html,error:!1,cancelled:!1,removed(e){"function"==typeof e&&(n.removed=e)}};if("function"==typeof n.removed&&(n.removed({panel:l,html:n.html,html_new:r,transition:a||"none"}),n.removed=null),"css"==l)query(this.box).find("#layout_"+this.name+"_panel_css").html(""),e.status=!0;else if(null==n)console.log("ERROR: incorrect panel name. Panel name can be main, left, right, top, bottom, preview or css"),e.error=!0;else if(null!=r){var t=this.trigger("change",{target:l,panel:n,html_new:r,transition:a});if(!0===t.isCancelled)e.cancelled=!0;else{let i="#layout_"+this.name+"_panel_"+n.type;var o=query(this.box).find(i+"> .w2ui-panel-content");let s=0;if(0 .w2ui-panel-content"),t=(e.after('
    '),query(this.box).find(i+"> .w2ui-panel-content.new-panel"));e.css("top",s),t.css("top",s),"object"==typeof r?(r.box=t[0],r.render()):t.hide().html(r),w2utils.transition(e[0],t[0],a,()=>{e.remove(),t.removeClass("new-panel"),t.css("overflow",n.overflow),query(query(this.box).find(i+"> .w2ui-panel-content").get(1)).remove(),query(this.box).removeClass("animating"),this.refresh(l)})}else this.refresh(l);t.finish()}}return e}message(e,t){var i=this.get(e);let s=query(this.box).find("#layout_"+this.name+"_panel_"+i.type),l=s.css("overflow");s.css("overflow","hidden");i=w2utils.message({owner:this,box:s.get(0),after:".w2ui-panel-title",param:e},t);return i&&i.self.on("close:after",()=>{s.css("overflow",l)}),i}confirm(e,t){var i=this.get(e);let s=query(this.box).find("#layout_"+this.name+"_panel_"+i.type),l=s.css("overflow");s.css("overflow","hidden");i=w2utils.confirm({owner:this,box:s.get(0),after:".w2ui-panel-title",param:e},t);return i&&i.self.on("close:after",()=>{s.css("overflow",l)}),i}load(i,s,l){return new Promise((t,e)=>{"css"!=i&&null==this.get(i)||null==s?e():fetch(s).then(e=>e.text()).then(e=>{this.resize(),t(this.html(i,e,l))})})}sizeTo(e,t,i){return null!=this.get(e)&&(query(this.box).find(":scope > div > .w2ui-panel").css("transition",!0!==i?".2s":"0s"),setTimeout(()=>{this.set(e,{size:t})},1),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),this.resize()},300),!0)}show(e,t){let i=this.trigger("show",{target:e,thisect:this.get(e),immediate:t});var s;if(!0!==i.isCancelled)return null!=(s=this.get(e))&&(!(s.hidden=!1)===t?(query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"1"}),i.finish(),this.resize()):(query(this.box).addClass("animating"),query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),query(this.box).find(":scope > div > .w2ui-panel").css("transition",".2s"),setTimeout(()=>{this.resize()},1),setTimeout(()=>{query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"1"})},250),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),query(this.box).removeClass("animating"),i.finish(),this.resize()},300)),!0)}hide(e,t){let i=this.trigger("hide",{target:e,object:this.get(e),immediate:t});var s;if(!0!==i.isCancelled)return null!=(s=this.get(e))&&((s.hidden=!0)===t?(query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),i.finish(),this.resize()):(query(this.box).addClass("animating"),query(this.box).find(":scope > div > .w2ui-panel").css("transition",".2s"),query(this.box).find("#layout_"+this.name+"_panel_"+e).css({opacity:"0"}),setTimeout(()=>{this.resize()},1),setTimeout(()=>{query(this.box).find(":scope > div > .w2ui-panel").css("transition","0s"),query(this.box).removeClass("animating"),i.finish(),this.resize()},300)),!0)}toggle(e,t){var i=this.get(e);return null!=i&&(i.hidden?this.show(e,t):this.hide(e,t))}set(e,t){var i=this.get(e,!0);return null!=i&&(w2utils.extend(this.panels[i],t),null==t.html&&null==t.resizable||this.refresh(e),this.resize(),!0)}get(t,i){for(let e=0;e .w2ui-panel-content");return 1!=e.length?null:e[0]}hideToolbar(e){var t=this.get(e);t&&(t.show.toolbar=!1,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").hide(),this.resize())}showToolbar(e){var t=this.get(e);t&&(t.show.toolbar=!0,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-toolbar").show(),this.resize())}toggleToolbar(e){var t=this.get(e);t&&(t.show.toolbar?this.hideToolbar(e):this.showToolbar(e))}assignToolbar(e,t){"string"==typeof t&&null!=w2ui[t]&&(t=w2ui[t]);var i=this.get(e),s=(i.toolbar=t,query(this.box).find(e+"> .w2ui-panel-toolbar"));null!=i.toolbar?(0===s.find("[name="+i.toolbar.name+"]").length?i.toolbar.render(s.get(0)):null!=i.toolbar&&i.toolbar.refresh(),(t.owner=this).showToolbar(e),this.refresh(e)):(s.html(""),this.hideToolbar(e))}hideTabs(e){var t=this.get(e);t&&(t.show.tabs=!1,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").hide(),this.resize())}showTabs(e){var t=this.get(e);t&&(t.show.tabs=!0,query(this.box).find("#layout_"+this.name+"_panel_"+e+"> .w2ui-panel-tabs").show(),this.resize())}toggleTabs(e){var t=this.get(e);t&&(t.show.tabs?this.hideTabs(e):this.showTabs(e))}render(e){var t=Date.now();let o=this;"string"==typeof e&&(e=query(e).get(0));var i=this.trigger("render",{target:this.name,box:e??this.box});if(!0!==i.isCancelled){if(null!=e&&(0"),0
    ';query(this.box).find(":scope > div").append(s)}return query(this.box).find(":scope > div").append('
    '),this.refresh(),this.last.observeResize=new ResizeObserver(()=>{this.resize()}),this.last.observeResize.observe(this.box),i.finish(),setTimeout(()=>{o.last.events={resizeStart:l,mouseMove:a,mouseUp:r},this.resize()},0),Date.now()-t}function l(e,t){o.box&&(t=t||window.event,query(document).off("mousemove",o.last.events.mouseMove).on("mousemove",o.last.events.mouseMove),query(document).off("mouseup",o.last.events.mouseUp).on("mouseup",o.last.events.mouseUp),o.last.resize={type:e,x:t.screenX,y:t.screenY,diff_x:0,diff_y:0,value:0},w2panels.forEach(e=>{var t=query(o.el(e)).find(".w2ui-lock");0{var t=query(o.el(e)).find(".w2ui-lock");"yes"==t.data("locked")?t.removeData("locked"):o.unlock(e)}),0!==o.last.diff_x||0!==o.last.resize.diff_y){var s=o.get("top"),l=o.get("bottom"),r=o.get(o.last.resize.type),i=w2utils.getSize(query(o.box),"width"),a=w2utils.getSize(query(o.box),"height"),n=String(r.size);let e,t;switch(o.last.resize.type){case"top":e=parseInt(r.sizeCalculated)+o.last.resize.diff_y,t=0;break;case"bottom":e=parseInt(r.sizeCalculated)-o.last.resize.diff_y,t=0;break;case"preview":e=parseInt(r.sizeCalculated)-o.last.resize.diff_y,t=(s&&!s.hidden?s.sizeCalculated:0)+(l&&!l.hidden?l.sizeCalculated:0);break;case"left":e=parseInt(r.sizeCalculated)+o.last.resize.diff_x,t=0;break;case"right":e=parseInt(r.sizeCalculated)-o.last.resize.diff_x,t=0}"%"==n.substr(n.length-1)?r.size=Math.floor(100*e/("left"==r.type||"right"==r.type?i:a-t)*100)/100+"%":"-"==String(r.size).substr(0,1)?r.size=parseInt(r.size)-r.sizeCalculated+e:r.size=e,o.resize()}query(o.box).find("#layout_"+o.name+"_resizer_"+o.last.resize.type).removeClass("active"),delete o.last.resize}}function a(i){if(o.box&&(i=i||window.event,null!=o.last.resize)){var s=o.get(o.last.resize.type),l=o.last.resize,r=o.trigger("resizing",{target:o.name,object:s,originalEvent:i,panel:l?l.type:"all",diff_x:l?l.diff_x:0,diff_y:l?l.diff_y:0});if(!0!==r.isCancelled){var a=query(o.box).find("#layout_"+o.name+"_resizer_"+l.type);let e=i.screenX-l.x,t=i.screenY-l.y;var n=o.get("main");switch(a.hasClass("active")||a.addClass("active"),l.type){case"left":s.minSize-e>s.width&&(e=s.minSize-s.width),s.maxSize&&s.width+e>s.maxSize&&(e=s.maxSize-s.width),n.minSize+e>n.width&&(e=n.width-n.minSize);break;case"right":s.minSize+e>s.width&&(e=s.width-s.minSize),s.maxSize&&s.width-e>s.maxSize&&(e=s.width-s.maxSize),n.minSize-e>n.width&&(e=n.minSize-n.width);break;case"top":s.minSize-t>s.height&&(t=s.minSize-s.height),s.maxSize&&s.height+t>s.maxSize&&(t=s.maxSize-s.height),n.minSize+t>n.height&&(t=n.height-n.minSize);break;case"preview":case"bottom":s.minSize+t>s.height&&(t=s.height-s.minSize),s.maxSize&&s.height-t>s.maxSize&&(t=s.height-s.maxSize),n.minSize-t>n.height&&(t=n.minSize-n.height)}switch(l.diff_x=e,l.diff_y=t,l.type){case"top":case"preview":case"bottom":(l.diff_x=0) .w2ui-panel-content")[0],setTimeout(()=>{0 .w2ui-panel-content").length&&(query(l.box).find(t+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").css("overflow",e.overflow)[0].style.cssText+=";"+e.style),e.html&&"function"==typeof e.html.render&&e.html.render()},1)):0 .w2ui-panel-content").length&&(query(l.box).find(t+"> .w2ui-panel-content").removeClass().removeAttr("name").addClass("w2ui-panel-content").html(e.html).css("overflow",e.overflow)[0].style.cssText+=";"+e.style);let i=query(l.box).find(t+"> .w2ui-panel-tabs");e.show.tabs?0===i.find("[name="+e.tabs.name+"]").length&&null!=e.tabs?e.tabs.render(i.get(0)):e.tabs.refresh():i.html("").removeClass("w2ui-tabs").hide(),i=query(l.box).find(t+"> .w2ui-panel-toolbar"),e.show.toolbar?0===i.find("[name="+e.toolbar.name+"]").length&&null!=e.toolbar?e.toolbar.render(i.get(0)):e.toolbar.refresh():i.html("").removeClass("w2ui-toolbar").hide(),i=query(l.box).find(t+"> .w2ui-panel-title"),e.title?i.html(e.title).show():i.html("").hide()}else{if(0===query(l.box).find("#layout_"+l.name+"_panel_main").length)return void l.render();l.resize();for(let e=0;ethis.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_top").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"top",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("top",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_top").hide(),query(this.box).find("#layout_"+this.name+"_resizer_top").hide()),null!=c&&!0!==c.hidden?(e=0,t=0+(b?f.sizeCalculated+this.padding:0),s=c.sizeCalculated,l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_left").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),c.width=s,c.height=l,c.resizable&&(e=c.sizeCalculated-(0===this.padding?this.resizer:0),s=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_left").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"left",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("left",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_left").hide(),query(this.box).find("#layout_"+this.name+"_resizer_left").hide()),null!=p&&!0!==p.hidden?(e=o-p.sizeCalculated,t=0+(b?f.sizeCalculated+this.padding:0),s=p.sizeCalculated,l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_right").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),p.width=s,p.height=l,p.resizable&&(e-=this.padding,s=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_right").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ew-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"right",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("right",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_right").hide(),query(this.box).find("#layout_"+this.name+"_resizer_right").hide()),null!=m&&!0!==m.hidden?(e=0,t=h-m.sizeCalculated,s=o,l=m.sizeCalculated,query(this.box).find("#layout_"+this.name+"_panel_bottom").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),m.width=s,m.height=l,m.resizable&&(t-=0===this.padding?0:this.padding,l=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_bottom").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"bottom",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("bottom",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_bottom").hide(),query(this.box).find("#layout_"+this.name+"_resizer_bottom").hide()),e=0+(y?c.sizeCalculated+this.padding:0),t=0+(b?f.sizeCalculated+this.padding:0),s=o-(y?c.sizeCalculated+this.padding:0)-(w?p.sizeCalculated+this.padding:0),l=h-(b?f.sizeCalculated+this.padding:0)-(v?m.sizeCalculated+this.padding:0)-(g?u.sizeCalculated+this.padding:0),query(this.box).find("#layout_"+this.name+"_panel_main").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),d.width=s,d.height=l,null!=u&&!0!==u.hidden?(e=0+(y?c.sizeCalculated+this.padding:0),t=h-(v?m.sizeCalculated+this.padding:0)-u.sizeCalculated,s=o-(y?c.sizeCalculated+this.padding:0)-(w?p.sizeCalculated+this.padding:0),l=u.sizeCalculated,query(this.box).find("#layout_"+this.name+"_panel_preview").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px"}),u.width=s,u.height=l,u.resizable&&(t-=0===this.padding?0:this.padding,l=this.resizer>this.padding?this.resizer:this.padding,query(this.box).find("#layout_"+this.name+"_resizer_preview").css({display:"block",left:e+"px",top:t+"px",width:s+"px",height:l+"px",cursor:"ns-resize"}).off("mousedown").on("mousedown",function(e){e.preventDefault();var t=i.trigger("resizerClick",{target:"preview",originalEvent:e});if(!0!==t.isCancelled)return w2ui[i.name].last.events.resizeStart("preview",e),t.finish(),!1}))):(query(this.box).find("#layout_"+this.name+"_panel_preview").hide(),query(this.box).find("#layout_"+this.name+"_resizer_preview").hide());for(let t=0;t .w2ui-panel-";let e=0;q&&(q.title&&(_=query(this.box).find(C+"title").css({top:e+"px",display:"block"}),e+=w2utils.getSize(_,"height")),q.show.tabs&&(_=query(this.box).find(C+"tabs").css({top:e+"px",display:"block"}),e+=w2utils.getSize(_,"height")),q.show.toolbar)&&(q=query(this.box).find(C+"toolbar").css({top:e+"px",display:"block"}),e+=w2utils.getSize(q,"height")),query(this.box).find(C+"content").css({display:"block"}).css({top:e+"px"})}return n.finish(),Date.now()-r}}destroy(){var e=this.trigger("destroy",{target:this.name});if(!0!==e.isCancelled)return null!=w2ui[this.name]&&(0'},add:{type:"button",id:"w2ui-add",text:"Add New",tooltip:"Add new record",icon:"w2ui-icon-plus"},edit:{type:"button",id:"w2ui-edit",text:"Edit",tooltip:"Edit selected record",icon:"w2ui-icon-pencil",batch:1,disabled:!0},delete:{type:"button",id:"w2ui-delete",text:"Delete",tooltip:"Delete selected records",icon:"w2ui-icon-cross",batch:!0,disabled:!0},save:{type:"button",id:"w2ui-save",text:"Save",tooltip:"Save changed records",icon:"w2ui-icon-check"}},this.operators={text:["is","begins","contains","ends"],number:["=","between",">","<",">=","<="],date:["is",{oper:"less",text:"before"},{oper:"more",text:"since"},"between"],list:["is"],hex:["is","between"],color:["is","begins","contains","ends"],enum:["in","not in"]},this.defaultOperator={text:"begins",number:"=",date:"is",list:"is",enum:"in",hex:"begins",color:"begins"},this.operatorsMap={text:"text",int:"number",float:"number",money:"number",currency:"number",percent:"number",hex:"hex",alphanumeric:"text",color:"color",date:"date",time:"date",datetime:"date",list:"list",combo:"text",enum:"enum",file:"enum",select:"list",radio:"list",checkbox:"list",toggle:"list"},this.onAdd=null,this.onEdit=null,this.onRequest=null,this.onLoad=null,this.onDelete=null,this.onSave=null,this.onSelect=null,this.onClick=null,this.onDblClick=null,this.onContextMenu=null,this.onContextMenuClick=null,this.onColumnClick=null,this.onColumnDblClick=null,this.onColumnContextMenu=null,this.onColumnResize=null,this.onColumnAutoResize=null,this.onSort=null,this.onSearch=null,this.onSearchOpen=null,this.onChange=null,this.onRestore=null,this.onExpand=null,this.onCollapse=null,this.onError=null,this.onKeydown=null,this.onToolbar=null,this.onColumnOnOff=null,this.onCopy=null,this.onPaste=null,this.onSelectionExtend=null,this.onEditField=null,this.onRender=null,this.onRefresh=null,this.onReload=null,this.onResize=null,this.onDestroy=null,this.onStateSave=null,this.onStateRestore=null,this.onFocus=null,this.onBlur=null,this.onReorderRow=null,this.onSearchSave=null,this.onSearchRemove=null,this.onSearchSelect=null,this.onColumnSelect=null,this.onColumnDragStart=null,this.onColumnDragEnd=null,this.onResizerDblClick=null,this.onMouseEnter=null,this.onMouseLeave=null,w2utils.extend(this,e),Array.isArray(this.records)){let i=[];this.records.forEach((e,t)=>{null!=e[this.recid]&&(e.recid=e[this.recid]),null==e.recid&&console.log("ERROR: Cannot add records without recid. (obj: "+this.name+")"),!0===e.w2ui?.summary&&(this.summary.push(e),i.push(t))}),i.sort();for(let e=i.length-1;0<=e;e--)this.records.splice(i[e],1)}Array.isArray(this.columns)&&this.columns.forEach((i,e)=>{i=w2utils.extend({},this.colTemplate,i);e=(this.columns[e]=i).searchable;if(null!=e&&!1!==e&&null==this.getSearch(i.field))if(w2utils.isPlainObject(e))this.addSearch(w2utils.extend({field:i.field,label:i.text,type:"text"},e));else{let e=i.searchable,t="";!0===i.searchable&&(e="text",t='size="20"'),this.addSearch({field:i.field,label:i.text,type:e,attr:t})}}),Array.isArray(this.defaultSearches)&&this.defaultSearches.forEach((e,t)=>{e.id="default-"+t,e.icon??="w2ui-icon-search"});e=this.cache("searches");Array.isArray(e)&&e.forEach(e=>{this.savedSearches.push({id:e.id??"none",text:e.text??"none",icon:"w2ui-icon-search",remove:!0,logic:e.logic??"AND",data:e.data??[]})}),"string"==typeof this.box&&(this.box=query(this.box).get(0)),this.box&&this.render(this.box)}add(t,i){Array.isArray(t)||(t=[t]);let s=0;for(let e=0;ethis.records.length&&(n=this.records.length);for(let i=a;i{this.columns.forEach(i=>{if(i.field==e){let t=w2utils.clone(s);Object.keys(t).forEach(e=>{"function"==typeof t[e]&&(t[e]=t[e](i)),i[e]!=t[e]&&l++}),w2utils.extend(i,t)}})}),0{if(!(e.w2ui&&null!=e.w2ui.parent_recid||t.w2ui&&null!=t.w2ui.parent_recid))return o(e,t);var i=a(e),s=a(t);for(let e=0;es.length?1:i.length{this.status(w2utils.lang("Sorting took ${count} seconds",{count:e/1e3}))},10),e;function a(e){var t;return e.w2ui&&null!=e.w2ui.parent_recid?e.w2ui._path||((t=n.get(e.w2ui.parent_recid))?a(t).concat(e):(console.log("ERROR: no parent record: "+e.w2ui.parent_recid),[e])):[e]}function o(s,l){if(s===l)return 0;for(let i=0;it.constructor.name?s:-s;e&&"object"==typeof e&&(e=e.valueOf()),t&&"object"==typeof t&&(t=t.valueOf());var r={}.toString;switch(e&&"object"==typeof e&&e.toString!=r&&(e=String(e)),t&&"object"==typeof t&&t.toString!=r&&(t=String(t)),"string"==typeof e&&(e=e.toLowerCase().trim()),"string"==typeof t&&(t=t.toLowerCase().trim()),l){case"natural":l=w2utils.naturalCompare;break;case"i18n":l=w2utils.i18nCompare}return"function"==typeof l?l(e,t)*s:t=parseFloat(n)&&parseFloat(c.parseField(l,s.field))<=parseFloat(o)&&r++:"date"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.isDate(h,w2utils.settings.dateFormat,!0),n=w2utils.isDate(n,w2utils.settings.dateFormat,!0),null!=(o=w2utils.isDate(o,w2utils.settings.dateFormat,!0))&&(o=new Date(o.getTime()+864e5)),a>=n&&a=n&&a=n)&&a=":d=!0;case">":case"more":-1!=["int","float","money","currency","percent"].indexOf(s.type)?(a=parseFloat(c.parseField(l,s.field)),n=parseFloat(i.value),(a>n||d&&a===n)&&r++):"date"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.isDate(h,w2utils.settings.dateFormat,!0),n=w2utils.isDate(n,w2utils.settings.dateFormat,!0),(a>n||d&&a===n)&&r++):"time"==s.type?(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.formatTime(h,"hh24:mi"),n=w2utils.formatTime(n,"hh24:mi"),(a>n||d&&a===n)&&r++):"datetime"==s.type&&(h=c.parseField(l,s.field+"_")instanceof Date?c.parseField(l,s.field+"_"):c.parseField(l,s.field),a=w2utils.formatDateTime(h,"yyyy-mm-dd|hh24:mm:ss"),n=w2utils.formatDateTime(w2utils.isDateTime(n,w2utils.settings.datetimeFormat,!0),"yyyy-mm-dd|hh24:mm:ss"),a.length==n.length)&&(a>n||d&&a===n)&&r++;break;case"in":h=i.value,-1===(h=i.svalue?i.svalue:h).indexOf(w2utils.isFloat(t)?parseFloat(t):t)&&-1===h.indexOf(a)||r++;break;case"not in":h=i.value,-1===(h=i.svalue?i.svalue:h).indexOf(w2utils.isFloat(t)?parseFloat(t):t)&&-1===h.indexOf(a)&&r++;break;case"begins":case"begins with":0===a.indexOf(n)&&r++;break;case"contains":0<=a.indexOf(n)&&r++;break;case"null":null==c.parseField(l,s.field)&&r++;break;case"not null":null!=c.parseField(l,s.field)&&r++;break;case"ends":case"ends with":let e=a.lastIndexOf(n);-1!==e&&e==a.length-n.length&&r++}}}if("OR"==c.last.logic&&0!==r||"AND"==c.last.logic&&r==c.searchData.length)return!0;if(l.w2ui?.children&&!0!==l.w2ui?.expanded)for(let t=0;tthis.records.length&&(i=this.records.length-s),0{this.status(w2utils.lang("Search took ${count} seconds",{count:e/1e3}))},10),e}}getRangeData(e,i){var s=this.get(e[0].recid,!0),l=this.get(e[1].recid,!0),r=e[0].column,a=e[1].column,n=[];if(r==a)for(let e=s;e<=l;e++){var t=this.records[e],o=t[this.columns[r].field]||null;n.push(!0!==i?o:{data:o,column:r,index:e,record:t})}else if(s==l){var h=this.records[s];for(let e=r;e<=a;e++){var d=h[this.columns[e].field]||null;n.push(!0!==i?d:{data:d,column:e,index:s,record:h})}}else for(let t=s;t<=l;t++){var u=this.records[t];n.push([]);for(let e=r;e<=a;e++){var c=u[this.columns[e].field];!0!==i?n[n.length-1].push(c):n[n.length-1].push({data:c,column:e,index:t,record:u})}}return n}addRange(s){let e=0,l,r;if("row"!=this.selectType){Array.isArray(s)||(s=[s]);for(let i=0;ithis.last.colStart&&(e=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(u.recid)+' td[col="start"]')),u.columnthis.last.colEnd&&(t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(c.recid)+' td[col="end"]'),l='"end"');var p=parseInt(query(this.box).find("#grid_"+this.name+"_rec_top").next().attr("index")),f=parseInt(query(this.box).find("#grid_"+this.name+"_rec_bottom").prev().attr("index")),m=parseInt(query(this.box).find("#grid_"+this.name+"_frec_top").next().attr("index")),g=parseInt(query(this.box).find("#grid_"+this.name+"_frec_bottom").prev().attr("index"));0===e.length&&u.indexp&&(e=query(this.box).find("#grid_"+this.name+"_rec_top").next().find('td[col="'+u.column+'"]')),0===t.length&&c.index>f&&u.indexm&&(i=query(this.box).find("#grid_"+this.name+"_frec_top").next().find('td[col="'+u.column+'"]')),0===s.length&&c.index>g&&u.index'+("selection"==d.name?'
    ':"")+""),a=query(this.box).find("#grid_"+this.name+"_f"+d.name)):(a.attr("style",d.style),a.find(".w2ui-selection-resizer").show()),0===s.length&&(0===(s=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(c.recid)+" td:last-child")).length&&(s=query(this.box).find("#grid_"+this.name+"_frec_bottom td:first-child")),a.css("border-right","0px"),a.find(".w2ui-selection-resizer").hide()),null!=u.recid)&&null!=c.recid&&0'+("selection"==d.name?'
    ':"")+""),a=query(this.box).find("#grid_"+this.name+"_"+d.name)):a.attr("style",d.style),0===e.length&&0===(e=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(u.recid)+" td:first-child")).length&&(e=query(this.box).find("#grid_"+this.name+"_rec_top td:first-child")),0!==s.length&&a.css("border-left","0px"),null!=u.recid)&&null!=c.recid&&0{e=this.trigger("resizerDblClick",{target:this.name,originalEvent:e});!0!==e.isCancelled&&e.finish()});let n={target:this.name,originalRange:null,newRange:null};return Date.now()-e;function i(s){var l=r.last.move;if(l&&"expand"==l.type){l.divX=s.screenX-l.x,l.divY=s.screenY-l.y;let e,t,i=s.target;"TD"!=i.tagName.toUpperCase()&&(i=query(i).closest("td")[0]),null!=(t=null!=query(i).attr("col")?parseInt(query(i).attr("col")):t)&&(i=query(i).closest("tr")[0],e=r.records[query(i).attr("index")].recid,l.newRange[1].recid!=e||l.newRange[1].column!=t)&&(s=w2utils.clone(l.newRange),l.newRange=[{recid:l.recid,column:l.column},{recid:e,column:t}],n.detail&&(n.detail.newRange=w2utils.clone(l.newRange),n.detail.originalRange=w2utils.clone(l.originalRange)),!0===(n=r.trigger("selectionExtend",n)).isCancelled?(l.newRange=s,n.detail.newRange=s):(r.removeRange("grid-selection-expand"),r.addRange({name:"grid-selection-expand",range:l.newRange,style:"background-color: rgba(100,100,100,0.1); border: 2px dotted rgba(100,100,100,0.5);"})))}}function s(e){r.removeRange("grid-selection-expand"),delete r.last.move,query("body").off(".w2ui-"+r.name),n.finish&&n.finish()}}}select(){if(0===arguments.length)return 0;let s=0;var l=this.last.selection;this.multiSelect||this.selectNone(!0);let t=Array.from(arguments);Array.isArray(t[0])&&(t=t[0]);var e={target:this.name},e=(1==t.length?(e.multiple=!1,w2utils.isPlainObject(t[0])?e.clicked={recid:t[0].recid,column:t[0].column}:e.recid=t[0]):(e.multiple=!0,e.clicked={recids:t}),this.trigger("select",e));if(!0===e.isCancelled)return 0;if("row"==this.selectType)for(let e=0;e=this.last.range_start&&r+1<=this.last.range_end)&&(e=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(i)),t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(i))),"row"==this.selectType&&-1==l.indexes.indexOf(r)&&(l.indexes.push(r),e&&t&&(e.addClass("w2ui-selected").find(".w2ui-col-number").addClass("w2ui-row-selected"),t.addClass("w2ui-selected").find(".w2ui-col-number").addClass("w2ui-row-selected"),e.find(".w2ui-grid-select-check").prop("checked",!0)),s++)}}else{var a={};for(let e=0;e=this.last.range_start&&u+1<=this.last.range_end&&(t=query(this.box).find("#grid_"+this.name+"_rec_"+w2utils.escapeId(h)),i=query(this.box).find("#grid_"+this.name+"_frec_"+w2utils.escapeId(h)));var c=l.columns[u]||[];-1==l.indexes.indexOf(u)&&l.indexes.push(u);for(let e=0;ee-t);for(let e=0;ee-t);var f=0 td[col="${h}"]`).removeClass("w2ui-selected w2ui-inactive"),query(this.box).find(`#grid_${this.name}_frec_${w2utils.escapeId(r)} > td[col="${h}"]`).removeClass("w2ui-selected w2ui-inactive");let t=!1,i=!1;var d=this.getSelection();for(let e=0;e{i(t,""),Array.isArray(t.items)&&t.items.forEach(e=>{i(e,t.id+":")})}),this.show.toolbarSave&&(0{this.initSearches(),this.last.search_opened=!0;let t=query(`#w2overlay-${this.name}-search-overlay`);t.data("gridName",this.name).off(".grid-search").on("click.grid-search",()=>{t.find("input, select").each(e=>{e=query(e).data("tooltipName");e&&e.forEach(e=>{w2tooltip.hide(e)})})}),w2utils.bindEvents(t.find("select, input, button"),this);var i=query(`#w2overlay-${this.name}-search-overlay *[rel=search]`);0{t.removeClass("checked"),this.last.search_opened=!1})}}}searchClose(){w2tooltip.hide(this.name+"-search-overlay")}searchFieldTooltip(e,t,i){var e=this.searches[e],s=this.searchData[t];let l=s.operator,r=("less"==(l="more"==l&&"date"==s.type?"since":l)&&"date"==s.type&&(l="before"),""),a=s.value;Array.isArray(s.value)?(s.value.forEach(e=>{r+=`${e.text||e}`}),"date"==s.type&&(r="",s.value.forEach(e=>{r+=`${w2utils.formatDate(e)}`}))):"date"==s.type&&(a=w2utils.formatDateTime(a)),w2tooltip.hide(this.name+"-search-props"),w2tooltip.show({name:this.name+"-search-props",anchor:i,class:"w2ui-white",hideOn:"doc-click",html:`
    ${e.label} ${w2utils.lang(l)} @@ -315,7 +315,7 @@ class w2event{constructor(e,t){Object.assign(this,{type:t.type??null,detail:t,ow
    `+h.text)),(l=e.find("div.w2ui-input").get(0)).innerText="object"!=typeof t?t:"",null!=c?w2utils.setCursorPosition(l,l.innerText.length):w2utils.setCursorPosition(l,0,l.innerText.length)):(e.addClass("w2ui-editable").html(w2utils.stripSpaces(``+h.text)),l=e.find("input").get(0),"number"==h.type&&(t=w2utils.formatNumber(t)),"date"==h.type&&(t=w2utils.formatDate(w2utils.isDate(t,h.format,!0)||new Date,h.format)),l.value="object"!=typeof t?t:"",y=e=>{var t=this.last._edit?.escKey;let i=!1;var s=query(l).data("tooltipName");s&&null!=w2tooltip.get(s[0])?.selected&&(i=!0),!this.last.inEditMode||t||!r.includes(h.type)||e.detail.overlay.anchor?.id!=this.last._edit.input?.id&&"list"!=h.type||(this.editChange(),this.editDone(void 0,void 0,{keyCode:i?13:0}))},new w2field(w2utils.extend({},h,{el:l,selected:t,onSelect:y,onHide:y})),null==c&&l&&l.select()),Object.assign(this.last._edit,{input:l,edit:h}),query(l).off(".w2ui-editable").on("blur.w2ui-editable",e=>{var t,i;this.last.inEditMode&&(t=this.last._edit.edit.type,i=query(l).data("tooltipName"),r.includes(t)&&i||(this.editChange(l,o,u,e),this.editDone()))}).on("mousedown.w2ui-editable",e=>{e.stopPropagation()}).on("click.w2ui-editable",e=>{w.call(l,e)}).on("paste.w2ui-editable",e=>{e.preventDefault();e=e.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,e)}).on("keyup.w2ui-editable",e=>{w.call(l,e)}).on("keydown.w2ui-editable",i=>{switch(i.keyCode){case 8:"list"!=h.type||l._w2field||i.preventDefault();break;case 9:case 13:i.preventDefault();break;case 27:var e=query(l).data("tooltipName");e&&0{switch(i.keyCode){case 9:var e=i.shiftKey?f.prevCell(o,u,!0):f.nextCell(o,u,!0);null!=e&&(t=f.records[e.index].recid,this.editChange(l,o,u,i),this.editDone(o,u,i),"row"!=f.selectType?(f.selectNone(!0),f.select({recid:t,column:e.colIndex})):f.editField(t,e.colIndex,null,i),i.preventDefault)&&i.preventDefault();break;case 13:{let e=!1;var t=query(l).data("tooltipName");t&&null!=w2tooltip.get(t[0]).selected&&(e=!0),t&&e||(this.editChange(l,o,u,i),this.editDone(o,u,i));break}case 27:{this.last._edit.escKey=!1;let e=f.parseField(a,n.field);null!=a.w2ui?.changes?.[n.field]&&(e=a.w2ui.changes[n.field]),null!=l._prevValue&&(e=l._prevValue),"DIV"==l.tagName?l.innerText=null!=e?e:"":l.value=null!=e?e:"",this.editDone(o,u,i),setTimeout(()=>{f.select({recid:d,column:u})},1);break}}w(l)},1)}),l&&(l._prevValue=i),"list"!=h.type&&setTimeout(()=>{this.last.inEditMode&&l&&(l.focus(),clearTimeout(this.last.kbd_timer),(l.resize=w)(l))},50),g.finish({input:l})}}}}}editChange(e,t,i,s){e=e??this.last._edit.input,t=t??this.last._edit.index,i=i??this.last._edit.column,s=s??{};var l=(t<0?this.summary:this.records)[t=t<0?-t-1:t],r=this.columns[i];let a="DIV"==e?.tagName?e.innerText:e.value;var n=e._w2field,o=(n&&("list"==n.type&&(a=n.selected),0!==Object.keys(a).length&&null!=a||(a=""),w2utils.isPlainObject(a)||(a=n.clean(a))),"checkbox"==e.type&&(!1===l.w2ui?.editable&&(e.checked=!e.checked),a=e.checked),this.parseField(l,r.field)),h=l.w2ui?.changes&&l.w2ui.changes.hasOwnProperty(r.field)?l.w2ui.changes[r.field]:o;let d={target:this.name,input:e,recid:l.recid,index:t,column:i,originalEvent:s,value:{new:a,previous:h,original:o}},u=(null!=s.target?._prevValue&&(d.value.previous=s.target._prevValue),0);for(;u<20;){if(u++,"object"!=typeof(a=d.value.new)&&String(o)!=String(a)||"object"==typeof a&&a&&a.id!=o&&("object"!=typeof o||null==o||a.id!=o.id)){if(!0!==(d=this.trigger("change",d)).isCancelled){if(a!==d.detail.value.new)continue;(""!==d.detail.value.new&&null!=d.detail.value.new||""!==h&&null!=h)&&(l.w2ui=l.w2ui??{},l.w2ui.changes=l.w2ui.changes??{},l.w2ui.changes[r.field]=d.detail.value.new),d.finish()}}else if(!0!==(d=this.trigger("restore",d)).isCancelled){if(a!==d.detail.value.new)continue;l.w2ui?.changes&&(delete l.w2ui.changes[r.field],0===Object.keys(l.w2ui.changes).length)&&delete l.w2ui.changes,d.finish()}break}}editDone(t,i,s){if(t=t??this.last._edit.index,i=i??this.last._edit.column,s=s??{},this.advanceOnEdit&&13==s.keyCode){let e=s.shiftKey?this.prevRow(t,i,1):this.nextRow(t,i,1);null==e&&(e=t),setTimeout(()=>{"row"!=this.selectType?(this.selectNone(!0),this.select({recid:this.records[e].recid,column:i})):this.editField(this.records[e].recid,i,null,s)},1)}var e=t<0,l=query(this.last._edit.tr).find('[col="'+i+'"]'),r=this.records[t],a=this.columns[i];this.last.inEditMode=!1,this.last._edit=null,e||(null!=r.w2ui?.changes?.[a.field]?l.addClass("w2ui-changed"):l.removeClass("w2ui-changed"),l.replace(this.getCellHTML(t,i,e))),query(this.box).find("div.w2ui-edit-box").remove(),this.updateToolbar(),setTimeout(()=>{var e=query(this.box).find(`#grid_${this.name}_focus`).get(0);document.activeElement===e||this.last.inEditMode||e.focus()},10)}delete(e){var t=this.trigger("delete",{target:this.name,force:e});if(e&&this.message(),!0!==t.isCancelled){e=t.detail.force;var i=this.getSelection();if(0!==i.length)if(""==this.msgDelete||e){if("object"!=typeof this.url?this.url:this.url.remove)this.request("delete");else if("object"!=typeof i[0])this.selectNone(),this.remove.apply(this,i);else{for(let e=0;e{e.detail.self.close(),this.delete(!0)}).no(e=>{e.detail.self.close()})}}click(l,r){var a=Date.now();let n=null;if(!(1==this.last.cancelClick||r&&r.altKey))if("object"==typeof l&&null!==l&&(n=l.column,l=l.recid),null==r&&(r={}),a-parseInt(this.last.click_time)<350&&this.last.click_recid==l&&"click"==r.type)this.dblClick(l,r);else{this.last.bubbleEl&&(this.last.bubbleEl=null),this.last.click_time=a;a=this.last.click_recid;if(this.last.click_recid=l,null==n&&r.target){let e=r.target;"TD"!=e.tagName&&(e=query(e).closest("td")[0]),null!=query(e).attr("col")&&(n=parseInt(query(e).attr("col")))}var o=this.trigger("click",{target:this.name,recid:l,column:n,originalEvent:r});if(!0!==o.isCancelled){var h=this.getSelection(),d=(query(this.box).find("#grid_"+this.name+"_check_all").prop("checked",!1),this.get(l,!0)),u=[];this.last.sel_ind=d,this.last.sel_col=n,this.last.sel_recid=l,this.last.sel_type="click";let e,i,t,s;if(r.shiftKey&&0h[0].column?(t=h[0].column,n):(t=n,h[0].column);for(let e=t;e<=s;e++)u.push(e)}else e=this.get(a,!0),i=this.get(l,!0);var c=[],p=(e>i&&(a=e,e=i,i=a),this.url?.get?this.url.get:this.url);for(let t=e;t<=i;t++)if(!(0=this.records.length?this.selectNone():this.selectAll())}else if(t.altKey&&(l=this.getColumn(s))&&l.sortable&&this.sort(s,null,!(!t||!t.ctrlKey&&!t.metaKey)),"line-number"==e.detail.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{t.shiftKey||t.metaKey||t.ctrlKey||this.selectNone(!0);var l=this.getSelection(),s=this.getColumn(e.detail.field,!0),i=[],r=[];if(0!=l.length&&t.shiftKey){let t=s,i=l[0].column;t>i&&(t=l[0].column,i=s);for(let e=t;e<=i;e++)r.push(e)}else r.push(s);if(!0!==(e=this.trigger("columnSelect",{target:this.name,columns:r})).isCancelled){for(let e=0;e{var e=query(this.box).find(`#grid_${this.name}_focus`).get(0);e&&document.activeElement!=e&&e.focus()},10),e.finish()}blur(e){e=this.trigger("blur",{target:this.name,originalEvent:e});if(!0===e.isCancelled)return!1;this.hasFocus=!1,query(this.box).addClass("w2ui-inactive").find(".w2ui-selected").addClass("w2ui-inactive"),query(this.box).find(".w2ui-selection").addClass("w2ui-inactive"),e.finish()}keydown(c){let p=this,f="object"!=typeof this.url?this.url:this.url.get;if(!0===p.keyboard){var m=p.trigger("keydown",{target:p.name,originalEvent:c});if(!0!==m.isCancelled)if(0t&&p.last.sel_ind!=l?p.unselect(p.records[l].recid):p.select(p.records[t].recid);else if(p.last.sel_ind>t&&p.last.sel_ind!=l){t=l;var i=[];for(let e=0;e{var e=query(p.box).find("#grid_"+p.name+"_focus"),t=e.val();e.val(""),p.editField(a,n[0],t,c)},1)),d&&c.preventDefault&&c.preventDefault(),m.finish()}}}scrollIntoView(e,s,t,i){let l=this.records.length;if(0!==(l=0==this.searchData.length||this.url?l:this.last.searchIds.length)){if(null==e){var r=this.getSelection();if(0===r.length)return;w2utils.isPlainObject(r[0])?(e=r[0].index,s=r[0].column):e=this.get(r[0],!0)}var r=query(this.box).find(`#grid_${this.name}_records`),a=r[0].clientWidth,n=r[0].clientHeight,o=r[0].scrollTop,h=r[0].scrollLeft,d=this.last.searchIds.length;if(0{clearTimeout(this.last.kbd_timer),this.contextMenuClick(i,e)}),clearTimeout(this.last.kbd_timer)),e.preventDefault(),t.finish())}}contextMenuClick(e,t){e=this.trigger("contextMenuClick",{target:this.name,recid:e,originalEvent:t.detail.originalEvent,menuEvent:t,menuIndex:t.detail.index,menuItem:t.detail.item});!0!==e.isCancelled&&e.finish()}toggle(e){var t=this.get(e);if(null!=t)return t.w2ui=t.w2ui??{},!0===t.w2ui.expanded?this.collapse(e):this.expand(e)}expand(e,t){var i=this.get(e,!0);let s=this.records[i];s.w2ui=s.w2ui??{};var l=w2utils.escapeId(e),r=s.w2ui.children;let a;if(Array.isArray(r)){if(!0===s.w2ui.expanded||0===r.length)return!1;if(!0===(a=this.trigger("expand",{target:this.name,recid:e})).isCancelled)return!1;s.w2ui.expanded=!0,r.forEach(e=>{e.w2ui=e.w2ui??{},e.w2ui.parent_recid=s.recid,null==e.w2ui.children&&(e.w2ui.children=[])}),this.records.splice.apply(this.records,[i+1,0].concat(r)),-1!==this.total&&(this.total+=r.length),("object"!=typeof this.url?this.url:this.url.get)||(this.localSort(!0,!0),0 + field="${n.field}" recid="${d}" column="${u}" ${h.attr}>`+h.text)),l=e.find("input").get(0),"number"==h.type&&(t=w2utils.formatNumber(t)),"date"==h.type&&(t=w2utils.formatDate(w2utils.isDate(t,h.format,!0)||new Date,h.format)),l.value="object"!=typeof t?t:"",y=e=>{var t=this.last._edit?.escKey;let i=!1;var s=query(l).data("tooltipName");s&&null!=w2tooltip.get(s[0])?.selected&&(i=!0),!this.last.inEditMode||t||!r.includes(h.type)||e.detail.overlay.anchor?.id!=this.last._edit.input?.id&&"list"!=h.type||(this.editChange(),this.editDone(void 0,void 0,{keyCode:i?13:0}))},new w2field(w2utils.extend({},h,{el:l,selected:t,onSelect:y,onHide:y})),null==c&&l&&l.select()),Object.assign(this.last._edit,{input:l,edit:h}),query(l).off(".w2ui-editable").on("blur.w2ui-editable",e=>{var t,i;this.last.inEditMode&&(t=this.last._edit.edit.type,i=query(l).data("tooltipName"),r.includes(t)&&i||(this.editChange(l,o,u,e),this.editDone()))}).on("mousedown.w2ui-editable",e=>{e.stopPropagation()}).on("click.w2ui-editable",e=>{w.call(l,e)}).on("paste.w2ui-editable",e=>{e.preventDefault();e=e.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,e)}).on("keyup.w2ui-editable",e=>{w.call(l,e)}).on("keydown.w2ui-editable",i=>{switch(i.keyCode){case 8:"list"!=h.type||l._w2field||i.preventDefault();break;case 9:case 13:i.preventDefault();break;case 27:var e=query(l).data("tooltipName");e&&0{switch(i.keyCode){case 9:var e=i.shiftKey?f.prevCell(o,u,!0):f.nextCell(o,u,!0);null!=e&&(t=f.records[e.index].recid,this.editChange(l,o,u,i),this.editDone(o,u,i),"row"!=f.selectType?(f.selectNone(!0),f.select({recid:t,column:e.colIndex})):f.editField(t,e.colIndex,null,i),i.preventDefault)&&i.preventDefault();break;case 13:{let e=!1;var t=query(l).data("tooltipName");t&&null!=w2tooltip.get(t[0]).selected&&(e=!0),t&&e||(this.editChange(l,o,u,i),this.editDone(o,u,i));break}case 27:{this.last._edit.escKey=!1;let e=f.parseField(a,n.field);null!=a.w2ui?.changes?.[n.field]&&(e=a.w2ui.changes[n.field]),null!=l._prevValue&&(e=l._prevValue),"DIV"==l.tagName?l.innerText=null!=e?e:"":l.value=null!=e?e:"",this.editDone(o,u,i),setTimeout(()=>{f.select({recid:d,column:u})},1);break}}w(l)},1)}),l&&(l._prevValue=i),"list"!=h.type&&setTimeout(()=>{this.last.inEditMode&&l&&(l.focus(),clearTimeout(this.last.kbd_timer),(l.resize=w)(l))},50),g.finish({input:l})}}}}}editChange(e,t,i,s){e=e??this.last._edit.input,t=t??this.last._edit.index,i=i??this.last._edit.column,s=s??{};var l=(t<0?this.summary:this.records)[t=t<0?-t-1:t],r=this.columns[i];let a="DIV"==e?.tagName?e.innerText:e.value;var n=e._w2field,o=(n&&("list"==n.type&&(a=n.selected),0!==Object.keys(a).length&&null!=a||(a=""),w2utils.isPlainObject(a)||(a=n.clean(a))),"checkbox"==e.type&&(!1===l.w2ui?.editable&&(e.checked=!e.checked),a=e.checked),this.parseField(l,r.field)),h=l.w2ui?.changes&&l.w2ui.changes.hasOwnProperty(r.field)?l.w2ui.changes[r.field]:o;let d={target:this.name,input:e,recid:l.recid,index:t,column:i,originalEvent:s,value:{new:a,previous:h,original:o}},u=(null!=s.target?._prevValue&&(d.value.previous=s.target._prevValue),0);for(;u<20;){if(u++,"object"!=typeof(a=d.value.new)&&String(o)!=String(a)||"object"==typeof a&&a&&a.id!=o&&("object"!=typeof o||null==o||a.id!=o.id)){if(!0!==(d=this.trigger("change",d)).isCancelled){if(a!==d.detail.value.new)continue;(""!==d.detail.value.new&&null!=d.detail.value.new||""!==h&&null!=h)&&(l.w2ui=l.w2ui??{},l.w2ui.changes=l.w2ui.changes??{},l.w2ui.changes[r.field]=d.detail.value.new),d.finish()}}else if(!0!==(d=this.trigger("restore",d)).isCancelled){if(a!==d.detail.value.new)continue;l.w2ui?.changes&&(delete l.w2ui.changes[r.field],0===Object.keys(l.w2ui.changes).length)&&delete l.w2ui.changes,d.finish()}break}}editDone(t,i,s){if(t=t??this.last._edit.index,i=i??this.last._edit.column,s=s??{},this.advanceOnEdit&&13==s.keyCode){let e=s.shiftKey?this.prevRow(t,i,1):this.nextRow(t,i,1);null==e&&(e=t),setTimeout(()=>{"row"!=this.selectType?(this.selectNone(!0),this.select({recid:this.records[e].recid,column:i})):this.editField(this.records[e].recid,i,null,s)},1)}var e=t<0,l=query(this.last._edit.tr).find('[col="'+i+'"]'),r=this.records[t],a=this.columns[i];this.last.inEditMode=!1,this.last._edit=null,e||(null!=r.w2ui?.changes?.[a.field]?l.addClass("w2ui-changed"):l.removeClass("w2ui-changed"),l.replace(this.getCellHTML(t,i,e))),query(this.box).find("div.w2ui-edit-box").remove(),this.updateToolbar(),setTimeout(()=>{var e=query(this.box).find(`#grid_${this.name}_focus`).get(0);document.activeElement===e||this.last.inEditMode||e.focus()},10)}delete(e){var t=this.trigger("delete",{target:this.name,force:e});if(e&&this.message(),!0!==t.isCancelled){e=t.detail.force;var i=this.getSelection();if(0!==i.length)if(""==this.msgDelete||e){if("object"!=typeof this.url?this.url:this.url.remove)this.request("delete");else if("object"!=typeof i[0])this.selectNone(),this.remove.apply(this,i);else{for(let e=0;e{e.detail.self.close(),this.delete(!0)}).no(e=>{e.detail.self.close()})}}click(l,r){var a=Date.now();let n=null;if(!(1==this.last.cancelClick||r&&r.altKey))if("object"==typeof l&&null!==l&&(n=l.column,l=l.recid),null==r&&(r={}),a-parseInt(this.last.click_time)<350&&this.last.click_recid==l&&"click"==r.type)this.dblClick(l,r);else{this.last.bubbleEl&&(this.last.bubbleEl=null),this.last.click_time=a;a=this.last.click_recid;if(this.last.click_recid=l,null==n&&r.target){let e=r.target;"TD"!=e.tagName&&(e=query(e).closest("td")[0]),null!=query(e).attr("col")&&(n=parseInt(query(e).attr("col")))}var o=this.trigger("click",{target:this.name,recid:l,column:n,originalEvent:r});if(!0!==o.isCancelled){var h=this.getSelection(),d=(query(this.box).find("#grid_"+this.name+"_check_all").prop("checked",!1),this.get(l,!0)),u=[];this.last.sel_ind=d,this.last.sel_col=n,this.last.sel_recid=l,this.last.sel_type="click";let e,i,t,s;if(r.shiftKey&&0h[0].column?(t=h[0].column,n):(t=n,h[0].column);for(let e=t;e<=s;e++)u.push(e)}else e=this.get(a,!0),i=this.get(l,!0);var c=[],p=(e>i&&(a=e,e=i,i=a),this.url?.get?this.url.get:this.url);for(let t=e;t<=i;t++)if(!(0=this.records.length?this.selectNone():this.selectAll())}else if(t.altKey&&(l=this.getColumn(s))&&l.sortable&&this.sort(s,null,!(!t||!t.ctrlKey&&!t.metaKey)),"line-number"==e.detail.field)this.getSelection().length>=this.records.length?this.selectNone():this.selectAll();else{t.shiftKey||t.metaKey||t.ctrlKey||this.selectNone(!0);var l=this.getSelection(),s=this.getColumn(e.detail.field,!0),i=[],r=[];if(0!=l.length&&t.shiftKey){let t=s,i=l[0].column;t>i&&(t=l[0].column,i=s);for(let e=t;e<=i;e++)r.push(e)}else r.push(s);if(!0!==(e=this.trigger("columnSelect",{target:this.name,columns:r})).isCancelled){for(let e=0;e{query("#w2overlay-context-menu .w2ui-grid-skip").off(".w2ui-grid").on("click.w2ui-grid",e=>{e.stopPropagation()}).on("keypress",e=>{13==e.keyCode&&(this.skip(e.target.value),this.toolbar.click("w2ui-column-on-off"))})}).select(e=>{var t=e.detail.item.id;["w2ui-stateSave","w2ui-stateReset"].includes(t)?this[t.substring(5)]():"w2ui-skip"!=t&&this.columnOnOff(e,e.detail.item.id),clearTimeout(this.last.kbd_timer)}),clearTimeout(this.last.kbd_timer)),t.preventDefault(),e.finish())}focus(e){e=this.trigger("focus",{target:this.name,originalEvent:e});if(!0===e.isCancelled)return!1;this.hasFocus=!0,query(this.box).removeClass("w2ui-inactive").find(".w2ui-inactive").removeClass("w2ui-inactive"),setTimeout(()=>{var e=query(this.box).find(`#grid_${this.name}_focus`).get(0);e&&document.activeElement!=e&&e.focus()},10),e.finish()}blur(e){e=this.trigger("blur",{target:this.name,originalEvent:e});if(!0===e.isCancelled)return!1;this.hasFocus=!1,query(this.box).addClass("w2ui-inactive").find(".w2ui-selected").addClass("w2ui-inactive"),query(this.box).find(".w2ui-selection").addClass("w2ui-inactive"),e.finish()}keydown(c){let p=this,f="object"!=typeof this.url?this.url:this.url.get;if(!0===p.keyboard){var m=p.trigger("keydown",{target:p.name,originalEvent:c});if(!0!==m.isCancelled)if(0t&&p.last.sel_ind!=l?p.unselect(p.records[l].recid):p.select(p.records[t].recid);else if(p.last.sel_ind>t&&p.last.sel_ind!=l){t=l;var i=[];for(let e=0;e{var e=query(p.box).find("#grid_"+p.name+"_focus"),t=e.val();e.val(""),p.editField(a,n[0],t,c)},1)),d&&c.preventDefault&&c.preventDefault(),m.finish()}}}scrollIntoView(e,s,t,i){let l=this.records.length;if(0!==(l=0==this.searchData.length||this.url?l:this.last.searchIds.length)){if(null==e){var r=this.getSelection();if(0===r.length)return;w2utils.isPlainObject(r[0])?(e=r[0].index,s=r[0].column):e=this.get(r[0],!0)}var r=query(this.box).find(`#grid_${this.name}_records`),a=r[0].clientWidth,n=r[0].clientHeight,o=r[0].scrollTop,h=r[0].scrollLeft,d=this.last.searchIds.length;if(0{clearTimeout(this.last.kbd_timer),this.contextMenuClick(i,s,e)}),clearTimeout(this.last.kbd_timer)),e.preventDefault(),t.finish())}}contextMenuClick(e,t,i){e=this.trigger("contextMenuClick",{target:this.name,recid:e,column:t,originalEvent:i.detail.originalEvent,menuEvent:i,menuIndex:i.detail.index,menuItem:i.detail.item});!0!==e.isCancelled&&e.finish()}toggle(e){var t=this.get(e);if(null!=t)return t.w2ui=t.w2ui??{},!0===t.w2ui.expanded?this.collapse(e):this.expand(e)}expand(e,t){var i=this.get(e,!0);let s=this.records[i];s.w2ui=s.w2ui??{};var l=w2utils.escapeId(e),r=s.w2ui.children;let a;if(Array.isArray(r)){if(!0===s.w2ui.expanded||0===r.length)return!1;if(!0===(a=this.trigger("expand",{target:this.name,recid:e})).isCancelled)return!1;s.w2ui.expanded=!0,r.forEach(e=>{e.w2ui=e.w2ui??{},e.w2ui.parent_recid=s.recid,null==e.w2ui.children&&(e.w2ui.children=[])}),this.records.splice.apply(this.records,[i+1,0].concat(r)),-1!==this.total&&(this.total+=r.length),("object"!=typeof this.url?this.url:this.url.get)||(this.localSort(!0,!0),0
    @@ -340,7 +340,7 @@ class w2event{constructor(e,t){Object.assign(this,{type:t.type??null,detail:t,ow `,query(this.box).find(`#grid_${this.name}_searches`).html(r),query(this.box).find(`#grid_${this.name}_search_logic`).html(w2utils.lang("AND"==this.last.logic?"All":"Any"))}else query(this.box).find(".w2ui-grid-toolbar").css("height",this.last.toolbar_height+"px").find(".w2ui-grid-searches").remove();this.searchSelected?(query(this.box).find(`#grid_${this.name}_search_all`).val(" ").prop("readOnly",!0),query(this.box).find(`#grid_${this.name}_search_name`).show().find(".name-text").html(this.searchSelected.text)):(query(this.box).find(`#grid_${this.name}_search_all`).prop("readOnly",!1),query(this.box).find(`#grid_${this.name}_search_name`).hide().find(".name-text").html("")),w2utils.bindEvents(query(this.box).find(`#grid_${this.name}_searches .w2ui-action, #grid_${this.name}_searches button`),this)}refreshBody(){this.scroll();var e=this.getRecordsHTML(),t=this.getColumnsHTML(),e='
    '+e[0]+'
    '+e[1]+'
    '+t[0]+'
    '+t[1]+"
    "+``;let l=query(this.box).find(`#grid_${this.name}_body`,this.box).html(e);t=query(this.box).find(`#grid_${this.name}_records`,this.box),e=query(this.box).find(`#grid_${this.name}_frecords`,this.box);"row"==this.selectType&&(t.on("mouseover mouseout",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");query(this.box).find(`#grid_${this.name}_frec_`+w2utils.escapeId(t)).toggleClass("w2ui-record-hover","mouseover"==e.type)}),e.on("mouseover mouseout",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");query(this.box).find(`#grid_${this.name}_rec_`+w2utils.escapeId(t)).toggleClass("w2ui-record-hover","mouseover"==e.type)})),w2utils.isIOS?t.append(e).on("click",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");this.dblClick(t,e)}):t.add(e).on("click",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");"-none-"!=t&&this.click(t,e)}).on("contextmenu",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid"),i=query(e.target).closest("td"),i=parseInt(i.attr("col")??-1);this.showContextMenu(t,i,e)}).on("mouseover",{delegate:"tr"},e=>{this.last.rec_out=!1;let t=query(e.delegate).attr("index"),i=query(e.delegate).attr("recid");t!==this.last.rec_over&&(this.last.rec_over=t,setTimeout(()=>{delete this.last.rec_out,this.trigger("mouseEnter",{target:this.name,originalEvent:e,index:t,recid:i}).finish()}))}).on("mouseout",{delegate:"tr"},t=>{let i=query(t.delegate).attr("index"),s=query(t.delegate).attr("recid");this.last.rec_out=!0,setTimeout(()=>{let e=()=>{this.trigger("mouseLeave",{target:this.name,originalEvent:t,index:i,recid:s}).finish()};i!==this.last.rec_over&&e(),setTimeout(()=>{this.last.rec_out&&(delete this.last.rec_out,delete this.last.rec_over,e())})})}),l.data("scroll",{lastDelta:0,lastTime:0}).find(".w2ui-grid-frecords").on("mousewheel DOMMouseScroll ",e=>{e.preventDefault();var t=l.data("scroll"),i=l.find(".w2ui-grid-records"),e=null!=typeof e.wheelDelta?-e.wheelDelta:e.detail||e.deltaY,s=i.prop("scrollTop");t.lastDelta+=e,e=Math.round(t.lastDelta),l.data("scroll",t),i.get(0).scroll({top:s+e,behavior:"smooth"})}),t.off(".body-global").on("scroll.body-global",{delegate:".w2ui-grid-records"},e=>{this.scroll(e)}),query(this.box).find(".w2ui-grid-body").off(".body-global").on("click.body-global dblclick.body-global contextmenu.body-global",{delegate:"td.w2ui-head"},e=>{var t=query(e.delegate).attr("col"),i=this.columns[t]??{field:t};switch(e.type){case"click":this.columnClick(i.field,e);break;case"dblclick":this.columnDblClick(i.field,e);break;case"contextmenu":this.show.columnMenu&&(w2menu.show({type:"check",anchor:document.body,originalEvent:e,items:this.initColumnOnOff()}).then(()=>{query("#w2overlay-context-menu .w2ui-grid-skip").off(".w2ui-grid").on("click.w2ui-grid",e=>{e.stopPropagation()}).on("keypress",e=>{13==e.keyCode&&(this.skip(e.target.value),this.toolbar.click("w2ui-column-on-off"))})}).select(e=>{var t=e.detail.item.id;["w2ui-stateSave","w2ui-stateReset"].includes(t)?this[t.substring(5)]():"w2ui-skip"!=t&&this.columnOnOff(e,e.detail.item.id),clearTimeout(this.last.kbd_timer)}),clearTimeout(this.last.kbd_timer)),e.preventDefault()}}).on("mouseover.body-global",{delegate:".w2ui-col-header"},e=>{let t=query(e.delegate).parent().attr("col");this.columnTooltipShow(t,e),query(e.delegate).off(".tooltip").on("mouseleave.tooltip",()=>{this.columnTooltipHide(t,e)})}).on("click.body-global",{delegate:"input.w2ui-select-all"},e=>{e.delegate.checked?this.selectAll():this.selectNone(),e.stopPropagation(),clearTimeout(this.last.kbd_timer)}).on("click.body-global",{delegate:".w2ui-show-children, .w2ui-col-expand"},e=>{e.stopPropagation(),this.toggle(query(e.target).parents("tr").attr("recid"))}).on("click.body-global mouseover.body-global",{delegate:".w2ui-info"},e=>{var t=query(e.delegate).closest("td"),i=t.parent(),s=this.columns[t.attr("col")],l=i.parents(".w2ui-grid-body").hasClass("w2ui-grid-summary");["mouseenter","mouseover"].includes(s.info?.showOn?.toLowerCase())&&"mouseover"==e.type?this.showBubble(i.attr("index"),t.attr("col"),l).then(()=>{query(e.delegate).off(".tooltip").on("mouseleave.tooltip",()=>{w2tooltip.hide(this.name+"-bubble")})}):"click"==e.type&&(w2tooltip.hide(this.name+"-bubble"),this.showBubble(i.attr("index"),t.attr("col"),l))}).on("mouseover.body-global",{delegate:".w2ui-clipboard-copy"},l=>{if(!l.delegate._tooltipShow){let t=query(l.delegate).parent(),i=t.parent();var e=this.columns[t.attr("col")];let s=i.parents(".w2ui-grid-body").hasClass("w2ui-grid-summary");w2tooltip.show({name:this.name+"-bubble",anchor:l.delegate,html:w2utils.lang("string"==typeof e.clipboardCopy?e.clipboardCopy:"Copy to clipboard"),position:"top|bottom",offsetY:-2}).hide(e=>{l.delegate._tooltipShow=!1,query(l.delegate).off(".tooltip")}),query(l.delegate).off(".tooltip").on("mouseleave.tooltip",e=>{w2tooltip.hide(this.name+"-bubble")}).on("click.tooltip",e=>{e.stopPropagation(),w2tooltip.update(this.name+"-bubble",w2utils.lang("Copied")),this.clipboardCopy(i.attr("index"),t.attr("col"),s)}),l.delegate._tooltipShow=!0}}).on("click.body-global",{delegate:".w2ui-editable-checkbox"},e=>{var t=query(e.delegate).data();this.editChange.call(this,e.delegate,t.changeind,t.colind,e),this.updateToolbar()}),0===this.records.length&&this.msgEmpty?query(this.box).find(`#grid_${this.name}_body`).append(`
    ${w2utils.lang(this.msgEmpty)}
    `):0=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[e].field,this.last.label=this.searches[e].label)}if(query(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid w2ui-inactive").html('
    "),"row"!=this.selectType&&query(this.box).addClass("w2ui-ss"),0{this.searchInitInput(this.last.field,1==e.length?e[0].value:null)},1)}query(this.box).find(`#grid_${this.name}_footer`).html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),e&&(this.clear(),this.refresh());let t=!1;for(let e=0;e{this.searchReset()},1)):this.reload(),query(this.box).find(`#grid_${this.name}_focus`).on("focus",e=>{clearTimeout(this.last.kbd_timer),this.hasFocus||this.focus()}).on("blur",e=>{clearTimeout(this.last.kbd_timer),this.last.kbd_timer=setTimeout(()=>{this.hasFocus&&this.blur()},100)}).on("paste",i=>{var s=i.clipboardData||null;if(s){let e=s.items,t=[];for(var l in e=2==e.length&&2==(e=2==e.length&&"file"==e[1].kind?[e[1]]:e).length&&"text/plain"==e[0].type&&"text/html"==e[1].type?[e[1]]:e){l=e[l];if("file"===l.kind){var r=l.getAsFile();t.push({kind:"file",data:r})}else if("string"===l.kind&&("text/plain"===l.type||"text/html"===l.type)){i.preventDefault();let e=s.getData("text/plain");-1!=e.indexOf("\r")&&-1==e.indexOf("\n")&&(e=e.replace(/\r/g,"\n")),t.push({kind:"text/html"==l.type?"html":"text",data:e})}}1===t.length&&"file"!=t[0].kind&&(t=t[0].data),w2ui[this.name].paste(t,i),i.preventDefault()}}).on("keydown",function(e){w2ui[p.name].keydown.call(w2ui[p.name],e)});let c;return query(this.box).off("mousedown.mouseStart").on("mousedown.mouseStart",function(l){if(1==l.which&&("text"==p.last.userSelect&&(p.last.userSelect="",query(p.box).find(".w2ui-grid-body").css("user-select","none")),!("row"==p.selectType&&(query(l.target).parents().hasClass("w2ui-head")||query(l.target).hasClass("w2ui-head"))||p.last.move&&"expand"==p.last.move.type))){if(l.altKey)query(p.box).find(".w2ui-grid-body").css("user-select","text"),p.selectNone(),p.last.move={type:"text-select"},p.last.userSelect="text";else{let e=l.target;var r={x:l.offsetX-10,y:l.offsetY-10};let t=!1;for(;e&&(!e.classList||!e.classList.contains("w2ui-grid"));)e.tagName&&"TD"==e.tagName.toUpperCase()&&(t=!0),e.tagName&&"TR"!=e.tagName.toUpperCase()&&1==t&&(r.x+=e.offsetLeft,r.y+=e.offsetTop),e=e.parentNode;p.last.move={x:l.screenX,y:l.screenY,divX:0,divY:0,focusX:r.x,focusY:r.y,recid:query(l.target).parents("tr").attr("recid"),column:parseInt(("TD"==l.target.tagName.toUpperCase()?query(l.target):query(l.target).parents("td")).attr("col")),type:"select",ghost:!1,start:!0},null==p.last.move.recid&&(p.last.move.type="select-column");let i=l.target,s=query(p.box).find("#grid_"+p.name+"_focus");if(p.last.move){let e=p.last.move.focusX,t=p.last.move.focusY;var a=query(i).parents("table").parent();(a.hasClass("w2ui-grid-records")||a.hasClass("w2ui-grid-frecords")||a.hasClass("w2ui-grid-columns")||a.hasClass("w2ui-grid-fcolumns")||a.hasClass("w2ui-grid-summary"))&&(e=p.last.move.focusX-query(p.box).find("#grid_"+p.name+"_records").prop("scrollLeft"),t=p.last.move.focusY-query(p.box).find("#grid_"+p.name+"_records").prop("scrollTop")),(query(i).hasClass("w2ui-grid-footer")||0{p.last.inEditMode||(["INPUT","TEXTAREA","SELECT"].includes(i.tagName)?i.focus():s.get(0)!==document.active&&s.get(0)?.focus({preventScroll:!0}))},50),p.multiSelect||p.reorderRows||"drag"!=p.last.move.type||delete p.last.move}if(1==p.reorderRows){let e=l.target;var t,i,s,n;"TD"!=e.tagName.toUpperCase()&&(e=query(e).parents("td")[0]),query(e).hasClass("w2ui-col-number")||query(e).hasClass("w2ui-col-order")?(p.selectNone(),p.last.move.reorder=!0,a=query(p.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),t=query(p.box).find(".w2ui-odd.w2ui-empty-record").css("background-color"),query(p.box).find(".w2ui-even td").filter(":not(.w2ui-col-number)").css("background-color",a),query(p.box).find(".w2ui-odd td").filter(":not(.w2ui-col-number)").css("background-color",t),t=p.last.move,i=query(p.box).find(".w2ui-grid-records"),t.ghost||(s=query(p.box).find(`#grid_${p.name}_rec_`+t.recid),n=s.parents("table").find("tr:first-child").get(0).cloneNode(!0),t.offsetY=l.offsetY,t.from=t.recid,t.pos={top:s.get(0).offsetTop-1,left:s.get(0).offsetLeft},t.ghost=query(s.get(0).cloneNode(!0)),t.ghost.removeAttr("id"),t.ghost.find("td").css({"border-top":"1px solid silver","border-bottom":"1px solid silver"}),s.find("td").remove(),s.append(`
    `),i.append('
    '),i.append('
    '),query(p.box).find("#grid_"+p.name+"_ghost").append(n).append(t.ghost)),query(p.box).find("#grid_"+p.name+"_ghost").css({top:t.pos.top+"px",left:t.pos.left+"px"})):p.last.move.reorder=!1}query(document).on("mousemove.w2ui-"+p.name,o).on("mouseup.w2ui-"+p.name,h),l.stopPropagation()}}),this.updateToolbar(),s.finish(),this.last.observeResize=new ResizeObserver(()=>{this.resize()}),this.last.observeResize.observe(this.box),Date.now()-i;function o(t){if(t.target.tagName){var r=p.last.move;if(r&&-1!=["select","select-column"].indexOf(r.type)&&(r.divX=t.screenX-r.x,r.divY=t.screenY-r.y,!(Math.abs(r.divX)<=1&&Math.abs(r.divY)<=1)))if(p.last.cancelClick=!0,1==p.reorderRows&&p.last.move.reorder){let e=query(t.target).parents("tr").attr("recid");(e="-none-"==e?"bottom":e)!=r.from&&(n=query(p.box).find("#grid_"+p.name+"_rec_"+e),query(p.box).find(".insert-before"),n.addClass("insert-before"),r.lastY=t.screenY,r.to=e,n={top:n.get(0)?.offsetTop,left:n.get(0)?.offsetLeft},query(p.box).find("#grid_"+p.name+"_ghost_line").css({top:n.top+"px",left:r.pos.left+"px","border-top":"2px solid #769EFC"})),void query(p.box).find("#grid_"+p.name+"_ghost").css({top:r.pos.top+r.divY+"px",left:r.pos.left+"px"})}else{r.start&&r.recid&&(p.selectNone(),r.start=!1);var a=[],n=("TR"==t.target.tagName.toUpperCase()?query(t.target):query(t.target).parents("tr")).attr("recid");if(null==n){if("row"!=p.selectType&&(!p.last.move||"select"!=p.last.move.type)){var o=parseInt(query(t.target).parents("td").attr("col"));if(isNaN(o))p.removeRange("column-selection"),query(p.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),query(p.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete r.colRange;else{let e=o+"-"+o;r.columno?o+"-"+r.column:e).split("-");for(let e=parseInt(s[0]);e<=parseInt(s[1]);e++)i.push(e);if(r.colRange!=e&&!0!==(c=p.trigger("columnSelect",{target:p.name,columns:i})).isCancelled){null==r.colRange&&p.selectNone();var l=e.split("-");query(p.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(let e=parseInt(l[0]);e<=parseInt(l[1]);e++)query(p.box).find("#grid_"+p.name+"_column_"+e+" .w2ui-col-header").addClass("w2ui-col-selected");query(p.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),r.colRange=e,p.removeRange("column-selection"),p.addRange({name:"column-selection",range:[{recid:p.records[0].recid,column:l[0]},{recid:p.records[p.records.length-1].recid,column:l[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}}else{let l=p.get(r.recid,!0);if(!(null==l||p.records[l]&&p.records[l].recid!=r.recid)){let e=p.get(n,!0);if(null!=e){let i=parseInt(r.column),s=parseInt(("TD"==t.target.tagName.toUpperCase()?query(t.target):query(t.target).parents("td")).attr("col"));isNaN(i)&&isNaN(s)&&(i=0,s=p.columns.length-1),l>e&&(o=l,l=e,e=o);var h,n="ind1:"+l+",ind2;"+e+",col1:"+i+",col2:"+s;if(r.range!=n){r.range=n;for(let t=l;t<=e;t++)if(!(0s&&(h=i,i=s,s=h);for(let e=i;e<=s;e++)p.columns[e].hidden||a.push({recid:p.records[t].recid,column:parseInt(e)})}else a.push(p.records[t].recid);if("row"!=p.selectType){var d=p.getSelection();let e=[];for(let i=0;i{delete p.last.cancelClick},1),!query(t.target).parents().hasClass(".w2ui-head")&&!query(t.target).hasClass(".w2ui-head")){if(i&&-1!=["select","select-column"].indexOf(i.type)){if(null!=i.colRange&&!0!==c.isCancelled){var s=i.colRange.split("-"),l=[];for(let e=0;ee?p.records.splice(e,0,i):p.records.splice(e-1,0,i)),p.sortData=[],query(p.box).find(`#grid_${p.name}_columns .w2ui-col-header`).removeClass("w2ui-col-sorted"),n(),t.finish()}else n()}delete p.last.move,query(document).off(".w2ui-"+p.name)}}function n(){query(p.box).find(`#grid_${p.name}_ghost`).remove(),query(p.box).find(`#grid_${p.name}_ghost_line`).remove(),p.refresh(),delete p.last.move}}}destroy(){var e=this.trigger("destroy",{target:this.name});!0!==e.isCancelled&&(query(this.box).off(),"object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),0`+w2utils.lang("records"),i.push({id:"w2ui-skip",text:e,group:!1,icon:"w2ui-icon-empty"})),this.show.saveRestoreState&&i.push({id:"w2ui-stateSave",text:w2utils.lang("Save Grid State"),icon:"w2ui-icon-empty",group:!1},{id:"w2ui-stateReset",text:w2utils.lang("Restore Default State"),icon:"w2ui-icon-empty",group:!1});let t=[];return i.forEach(e=>{e.text=w2utils.lang(e.text),e.checked&&t.push(e.id)}),this.toolbar.set("w2ui-column-on-off",{selected:t,items:i}),i}initColumnDrag(e){if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";let r=this,a={pressed:!1,targetPos:null,columnHead:null},n=(t,e)=>{var i=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"];!0!==e&&i.push("w2ui-head-last");for(let e=0;e{var e=query(r.box).find(".w2ui-grid-ghost");query(r.box).find(".w2ui-intersection-marker").hide(),query(a.ghost).remove(),e.remove(),query(document).off(".colDrag"),a={}};if(e.pageX==a.initialX&&e.pageY==a.initialY)r.columnClick(r.columns[a.originalPos].field,e),s();else{if(!0===(e=r.trigger("columnDragEnd",{originalEvent:e,target:a.columnHead[0],dragData:a})).isCancelled)return!1;t=r.columns[a.originalPos],i=r.columns,a.originalPos!=a.targetPos&&null!=a.targetPos&&(i.splice(a.targetPos,0,w2utils.clone(t)),i.splice(i.indexOf(t),1)),s(),r.refresh(),e.finish({targetColumn:NaN})}}}return query(r.box).off(".colDrag").on("mousedown.colDrag",function(e){if(!a.pressed&&0!==a.numberPreColumnsPresent&&0===e.button){var i,t;if(query(e.target).parents().hasClass("w2ui-head")&&!n(e.target)){if(a.pressed=!0,a.initialX=e.pageX,a.initialY=e.pageY,a.numberPreColumnsPresent=query(r.box).find(".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select").length,a.columnHead=s=query(e.target).closest(".w2ui-head"),a.originalPos=t=parseInt(s.attr("col"),10),!0===(t=r.trigger("columnDragStart",{originalEvent:e,origColumnNumber:t,target:s[0]})).isCancelled)return!1;i=a.columns=query(r.box).find(".w2ui-head:not(.w2ui-head-last)"),query(document).on("mouseup.colDrag",h),query(document).on("mousemove.colDrag",o);var s=r.columns[a.originalPos],s=w2utils.lang("function"==typeof s.text?s.text(s):s.text);a.ghost=query.html(`${s}`)[0],query(document.body).append(a.ghost),query(a.ghost).css({display:"none",left:e.pageX,top:e.pageY,opacity:1,margin:"3px 0 0 20px",padding:"3px","background-color":"white",position:"fixed","z-index":999999}).addClass(".w2ui-grid-ghost"),a.offsets=[];for(let e=0,t=i.length;e`;let l=query(this.box).find(`#grid_${this.name}_body`,this.box).html(e);t=query(this.box).find(`#grid_${this.name}_records`,this.box),e=query(this.box).find(`#grid_${this.name}_frecords`,this.box);"row"==this.selectType&&(t.on("mouseover mouseout",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");query(this.box).find(`#grid_${this.name}_frec_`+w2utils.escapeId(t)).toggleClass("w2ui-record-hover","mouseover"==e.type)}),e.on("mouseover mouseout",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");query(this.box).find(`#grid_${this.name}_rec_`+w2utils.escapeId(t)).toggleClass("w2ui-record-hover","mouseover"==e.type)})),w2utils.isIOS?t.append(e).on("click",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");this.dblClick(t,e)}):t.add(e).on("click",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid");"-none-"!=t&&this.click(t,e)}).on("contextmenu",{delegate:"tr"},e=>{var t=query(e.delegate).attr("recid"),i=query(e.target).closest("td"),i=parseInt(i.attr("col")??-1);this.showContextMenu(t,i,e)}).on("mouseover",{delegate:"tr"},e=>{this.last.rec_out=!1;let t=query(e.delegate).attr("index"),i=query(e.delegate).attr("recid");t!==this.last.rec_over&&(this.last.rec_over=t,setTimeout(()=>{delete this.last.rec_out,this.trigger("mouseEnter",{target:this.name,originalEvent:e,index:t,recid:i}).finish()}))}).on("mouseout",{delegate:"tr"},t=>{let i=query(t.delegate).attr("index"),s=query(t.delegate).attr("recid");this.last.rec_out=!0,setTimeout(()=>{let e=()=>{this.trigger("mouseLeave",{target:this.name,originalEvent:t,index:i,recid:s}).finish()};i!==this.last.rec_over&&e(),setTimeout(()=>{this.last.rec_out&&(delete this.last.rec_out,delete this.last.rec_over,e())})})}),l.data("scroll",{lastDelta:0,lastTime:0}).find(".w2ui-grid-frecords").on("mousewheel DOMMouseScroll ",e=>{e.preventDefault();var t=l.data("scroll"),i=l.find(".w2ui-grid-records"),e=null!=typeof e.wheelDelta?-e.wheelDelta:e.detail||e.deltaY,s=i.prop("scrollTop");t.lastDelta+=e,e=Math.round(t.lastDelta),l.data("scroll",t),i.get(0).scroll({top:s+e,behavior:"smooth"})}),t.off(".body-global").on("scroll.body-global",{delegate:".w2ui-grid-records"},e=>{this.scroll(e)}),query(this.box).find(".w2ui-grid-body").off(".body-global").on("click.body-global dblclick.body-global contextmenu.body-global",{delegate:"td.w2ui-head"},e=>{var t=query(e.delegate).attr("col"),i=this.columns[t]??{field:t};switch(e.type){case"click":this.columnClick(i.field,e);break;case"dblclick":this.columnDblClick(i.field,e);break;case"contextmenu":this.columnContextMenu(i.field,e)}}).on("mouseover.body-global",{delegate:".w2ui-col-header"},e=>{let t=query(e.delegate).parent().attr("col");this.columnTooltipShow(t,e),query(e.delegate).off(".tooltip").on("mouseleave.tooltip",()=>{this.columnTooltipHide(t,e)})}).on("click.body-global",{delegate:"input.w2ui-select-all"},e=>{e.delegate.checked?this.selectAll():this.selectNone(),e.stopPropagation(),clearTimeout(this.last.kbd_timer)}).on("click.body-global",{delegate:".w2ui-show-children, .w2ui-col-expand"},e=>{e.stopPropagation(),this.toggle(query(e.target).parents("tr").attr("recid"))}).on("click.body-global mouseover.body-global",{delegate:".w2ui-info"},e=>{var t=query(e.delegate).closest("td"),i=t.parent(),s=this.columns[t.attr("col")],l=i.parents(".w2ui-grid-body").hasClass("w2ui-grid-summary");["mouseenter","mouseover"].includes(s.info?.showOn?.toLowerCase())&&"mouseover"==e.type?this.showBubble(i.attr("index"),t.attr("col"),l).then(()=>{query(e.delegate).off(".tooltip").on("mouseleave.tooltip",()=>{w2tooltip.hide(this.name+"-bubble")})}):"click"==e.type&&(w2tooltip.hide(this.name+"-bubble"),this.showBubble(i.attr("index"),t.attr("col"),l))}).on("mouseover.body-global",{delegate:".w2ui-clipboard-copy"},l=>{if(!l.delegate._tooltipShow){let t=query(l.delegate).parent(),i=t.parent();var e=this.columns[t.attr("col")];let s=i.parents(".w2ui-grid-body").hasClass("w2ui-grid-summary");w2tooltip.show({name:this.name+"-bubble",anchor:l.delegate,html:w2utils.lang("string"==typeof e.clipboardCopy?e.clipboardCopy:"Copy to clipboard"),position:"top|bottom",offsetY:-2}).hide(e=>{l.delegate._tooltipShow=!1,query(l.delegate).off(".tooltip")}),query(l.delegate).off(".tooltip").on("mouseleave.tooltip",e=>{w2tooltip.hide(this.name+"-bubble")}).on("click.tooltip",e=>{e.stopPropagation(),w2tooltip.update(this.name+"-bubble",w2utils.lang("Copied")),this.clipboardCopy(i.attr("index"),t.attr("col"),s)}),l.delegate._tooltipShow=!0}}).on("click.body-global",{delegate:".w2ui-editable-checkbox"},e=>{var t=query(e.delegate).data();this.editChange.call(this,e.delegate,t.changeind,t.colind,e),this.updateToolbar()}),0===this.records.length&&this.msgEmpty?query(this.box).find(`#grid_${this.name}_body`).append(`
    ${w2utils.lang(this.msgEmpty)}
    `):0=this.searches.length?(this.last.field="",this.last.label=""):(this.last.field=this.searches[e].field,this.last.label=this.searches[e].label)}if(query(this.box).attr("name",this.name).addClass("w2ui-reset w2ui-grid w2ui-inactive").html('
    "),"row"!=this.selectType&&query(this.box).addClass("w2ui-ss"),0{this.searchInitInput(this.last.field,1==e.length?e[0].value:null)},1)}query(this.box).find(`#grid_${this.name}_footer`).html(this.getFooterHTML()),this.last.state||(this.last.state=this.stateSave(!0)),this.stateRestore(),e&&(this.clear(),this.refresh());let t=!1;for(let e=0;e{this.searchReset()},1)):this.reload(),query(this.box).find(`#grid_${this.name}_focus`).on("focus",e=>{clearTimeout(this.last.kbd_timer),this.hasFocus||this.focus()}).on("blur",e=>{clearTimeout(this.last.kbd_timer),this.last.kbd_timer=setTimeout(()=>{this.hasFocus&&this.blur()},100)}).on("paste",i=>{var s=i.clipboardData||null;if(s){let e=s.items,t=[];for(var l in e=2==e.length&&2==(e=2==e.length&&"file"==e[1].kind?[e[1]]:e).length&&"text/plain"==e[0].type&&"text/html"==e[1].type?[e[1]]:e){l=e[l];if("file"===l.kind){var r=l.getAsFile();t.push({kind:"file",data:r})}else if("string"===l.kind&&("text/plain"===l.type||"text/html"===l.type)){i.preventDefault();let e=s.getData("text/plain");-1!=e.indexOf("\r")&&-1==e.indexOf("\n")&&(e=e.replace(/\r/g,"\n")),t.push({kind:"text/html"==l.type?"html":"text",data:e})}}1===t.length&&"file"!=t[0].kind&&(t=t[0].data),w2ui[this.name].paste(t,i),i.preventDefault()}}).on("keydown",function(e){w2ui[p.name].keydown.call(w2ui[p.name],e)});let c;return query(this.box).off("mousedown.mouseStart").on("mousedown.mouseStart",function(l){if(1==l.which&&("text"==p.last.userSelect&&(p.last.userSelect="",query(p.box).find(".w2ui-grid-body").css("user-select","none")),!("row"==p.selectType&&(query(l.target).parents().hasClass("w2ui-head")||query(l.target).hasClass("w2ui-head"))||p.last.move&&"expand"==p.last.move.type))){if(l.altKey)query(p.box).find(".w2ui-grid-body").css("user-select","text"),p.selectNone(),p.last.move={type:"text-select"},p.last.userSelect="text";else{let e=l.target;var r={x:l.offsetX-10,y:l.offsetY-10};let t=!1;for(;e&&(!e.classList||!e.classList.contains("w2ui-grid"));)e.tagName&&"TD"==e.tagName.toUpperCase()&&(t=!0),e.tagName&&"TR"!=e.tagName.toUpperCase()&&1==t&&(r.x+=e.offsetLeft,r.y+=e.offsetTop),e=e.parentNode;p.last.move={x:l.screenX,y:l.screenY,divX:0,divY:0,focusX:r.x,focusY:r.y,recid:query(l.target).parents("tr").attr("recid"),column:parseInt(("TD"==l.target.tagName.toUpperCase()?query(l.target):query(l.target).parents("td")).attr("col")),type:"select",ghost:!1,start:!0},null==p.last.move.recid&&(p.last.move.type="select-column");let i=l.target,s=query(p.box).find("#grid_"+p.name+"_focus");if(p.last.move){let e=p.last.move.focusX,t=p.last.move.focusY;var a=query(i).parents("table").parent();(a.hasClass("w2ui-grid-records")||a.hasClass("w2ui-grid-frecords")||a.hasClass("w2ui-grid-columns")||a.hasClass("w2ui-grid-fcolumns")||a.hasClass("w2ui-grid-summary"))&&(e=p.last.move.focusX-query(p.box).find("#grid_"+p.name+"_records").prop("scrollLeft"),t=p.last.move.focusY-query(p.box).find("#grid_"+p.name+"_records").prop("scrollTop")),(query(i).hasClass("w2ui-grid-footer")||0{p.last.inEditMode||(["INPUT","TEXTAREA","SELECT"].includes(i.tagName)?i.focus():s.get(0)!==document.active&&s.get(0)?.focus({preventScroll:!0}))},50),p.multiSelect||p.reorderRows||"drag"!=p.last.move.type||delete p.last.move}if(1==p.reorderRows){let e=l.target;var t,i,s,n;"TD"!=e.tagName.toUpperCase()&&(e=query(e).parents("td")[0]),query(e).hasClass("w2ui-col-number")||query(e).hasClass("w2ui-col-order")?(p.selectNone(),p.last.move.reorder=!0,a=query(p.box).find(".w2ui-even.w2ui-empty-record").css("background-color"),t=query(p.box).find(".w2ui-odd.w2ui-empty-record").css("background-color"),query(p.box).find(".w2ui-even td").filter(":not(.w2ui-col-number)").css("background-color",a),query(p.box).find(".w2ui-odd td").filter(":not(.w2ui-col-number)").css("background-color",t),t=p.last.move,i=query(p.box).find(".w2ui-grid-records"),t.ghost||(s=query(p.box).find(`#grid_${p.name}_rec_`+t.recid),n=s.parents("table").find("tr:first-child").get(0).cloneNode(!0),t.offsetY=l.offsetY,t.from=t.recid,t.pos={top:s.get(0).offsetTop-1,left:s.get(0).offsetLeft},t.ghost=query(s.get(0).cloneNode(!0)),t.ghost.removeAttr("id"),t.ghost.find("td").css({"border-top":"1px solid silver","border-bottom":"1px solid silver"}),s.find("td").remove(),s.append(`
    `),i.append('
    '),i.append('
    '),query(p.box).find("#grid_"+p.name+"_ghost").append(n).append(t.ghost)),query(p.box).find("#grid_"+p.name+"_ghost").css({top:t.pos.top+"px",left:t.pos.left+"px"})):p.last.move.reorder=!1}query(document).on("mousemove.w2ui-"+p.name,o).on("mouseup.w2ui-"+p.name,h),l.stopPropagation()}}),this.updateToolbar(),s.finish(),this.last.observeResize=new ResizeObserver(()=>{this.resize()}),this.last.observeResize.observe(this.box),Date.now()-i;function o(t){if(t.target.tagName){var r=p.last.move;if(r&&-1!=["select","select-column"].indexOf(r.type)&&(r.divX=t.screenX-r.x,r.divY=t.screenY-r.y,!(Math.abs(r.divX)<=1&&Math.abs(r.divY)<=1)))if(p.last.cancelClick=!0,1==p.reorderRows&&p.last.move.reorder){let e=query(t.target).parents("tr").attr("recid");(e="-none-"==e?"bottom":e)!=r.from&&(n=query(p.box).find("#grid_"+p.name+"_rec_"+e),query(p.box).find(".insert-before"),n.addClass("insert-before"),r.lastY=t.screenY,r.to=e,n={top:n.get(0)?.offsetTop,left:n.get(0)?.offsetLeft},query(p.box).find("#grid_"+p.name+"_ghost_line").css({top:n.top+"px",left:r.pos.left+"px","border-top":"2px solid #769EFC"})),void query(p.box).find("#grid_"+p.name+"_ghost").css({top:r.pos.top+r.divY+"px",left:r.pos.left+"px"})}else{r.start&&r.recid&&(p.selectNone(),r.start=!1);var a=[],n=("TR"==t.target.tagName.toUpperCase()?query(t.target):query(t.target).parents("tr")).attr("recid");if(null==n){if("row"!=p.selectType&&(!p.last.move||"select"!=p.last.move.type)){var o=parseInt(query(t.target).parents("td").attr("col"));if(isNaN(o))p.removeRange("column-selection"),query(p.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected"),query(p.box).find(".w2ui-col-number").removeClass("w2ui-row-selected"),delete r.colRange;else{let e=o+"-"+o;r.columno?o+"-"+r.column:e).split("-");for(let e=parseInt(s[0]);e<=parseInt(s[1]);e++)i.push(e);if(r.colRange!=e&&!0!==(c=p.trigger("columnSelect",{target:p.name,columns:i})).isCancelled){null==r.colRange&&p.selectNone();var l=e.split("-");query(p.box).find(".w2ui-grid-columns .w2ui-col-header, .w2ui-grid-fcolumns .w2ui-col-header").removeClass("w2ui-col-selected");for(let e=parseInt(l[0]);e<=parseInt(l[1]);e++)query(p.box).find("#grid_"+p.name+"_column_"+e+" .w2ui-col-header").addClass("w2ui-col-selected");query(p.box).find(".w2ui-col-number").not(".w2ui-head").addClass("w2ui-row-selected"),r.colRange=e,p.removeRange("column-selection"),p.addRange({name:"column-selection",range:[{recid:p.records[0].recid,column:l[0]},{recid:p.records[p.records.length-1].recid,column:l[1]}],style:"background-color: rgba(90, 145, 234, 0.1)"})}}}}else{let l=p.get(r.recid,!0);if(!(null==l||p.records[l]&&p.records[l].recid!=r.recid)){let e=p.get(n,!0);if(null!=e){let i=parseInt(r.column),s=parseInt(("TD"==t.target.tagName.toUpperCase()?query(t.target):query(t.target).parents("td")).attr("col"));isNaN(i)&&isNaN(s)&&(i=0,s=p.columns.length-1),l>e&&(o=l,l=e,e=o);var h,n="ind1:"+l+",ind2;"+e+",col1:"+i+",col2:"+s;if(r.range!=n){r.range=n;for(let t=l;t<=e;t++)if(!(0s&&(h=i,i=s,s=h);for(let e=i;e<=s;e++)p.columns[e].hidden||a.push({recid:p.records[t].recid,column:parseInt(e)})}else a.push(p.records[t].recid);if("row"!=p.selectType){var d=p.getSelection();let e=[];for(let i=0;i{delete p.last.cancelClick},1),!query(t.target).parents().hasClass(".w2ui-head")&&!query(t.target).hasClass(".w2ui-head")){if(i&&-1!=["select","select-column"].indexOf(i.type)){if(null!=i.colRange&&!0!==c.isCancelled){var s=i.colRange.split("-"),l=[];for(let e=0;ee?p.records.splice(e,0,i):p.records.splice(e-1,0,i)),p.sortData=[],query(p.box).find(`#grid_${p.name}_columns .w2ui-col-header`).removeClass("w2ui-col-sorted"),n(),t.finish()}else n()}delete p.last.move,query(document).off(".w2ui-"+p.name)}}function n(){query(p.box).find(`#grid_${p.name}_ghost`).remove(),query(p.box).find(`#grid_${p.name}_ghost_line`).remove(),p.refresh(),delete p.last.move}}}destroy(){var e=this.trigger("destroy",{target:this.name});!0!==e.isCancelled&&(query(this.box).off(),"object"==typeof this.toolbar&&this.toolbar.destroy&&this.toolbar.destroy(),0`+w2utils.lang("records"),i.push({id:"w2ui-skip",text:e,group:!1,icon:"w2ui-icon-empty"})),this.show.saveRestoreState&&i.push({id:"w2ui-stateSave",text:w2utils.lang("Save Grid State"),icon:"w2ui-icon-empty",group:!1},{id:"w2ui-stateReset",text:w2utils.lang("Restore Default State"),icon:"w2ui-icon-empty",group:!1});let t=[];return i.forEach(e=>{e.text=w2utils.lang(e.text),e.checked&&t.push(e.id)}),this.toolbar.set("w2ui-column-on-off",{selected:t,items:i}),i}initColumnDrag(e){if(this.columnGroups&&this.columnGroups.length)throw"Draggable columns are not currently supported with column groups.";let r=this,a={pressed:!1,targetPos:null,columnHead:null},n=(t,e)=>{var i=["w2ui-col-number","w2ui-col-expand","w2ui-col-select"];!0!==e&&i.push("w2ui-head-last");for(let e=0;e{var e=query(r.box).find(".w2ui-grid-ghost");query(r.box).find(".w2ui-intersection-marker").hide(),query(a.ghost).remove(),e.remove(),query(document).off(".colDrag"),a={}};if(e.pageX==a.initialX&&e.pageY==a.initialY)r.columnClick(r.columns[a.originalPos].field,e),s();else{if(!0===(e=r.trigger("columnDragEnd",{originalEvent:e,target:a.columnHead[0],dragData:a})).isCancelled)return!1;t=r.columns[a.originalPos],i=r.columns,a.originalPos!=a.targetPos&&null!=a.targetPos&&(i.splice(a.targetPos,0,w2utils.clone(t)),i.splice(i.indexOf(t),1)),s(),r.refresh(),e.finish({targetColumn:NaN})}}}return query(r.box).off(".colDrag").on("mousedown.colDrag",function(e){if(!a.pressed&&0!==a.numberPreColumnsPresent&&0===e.button){var i,t;if(query(e.target).parents().hasClass("w2ui-head")&&!n(e.target)){if(a.pressed=!0,a.initialX=e.pageX,a.initialY=e.pageY,a.numberPreColumnsPresent=query(r.box).find(".w2ui-head.w2ui-col-number, .w2ui-head.w2ui-col-expand, .w2ui-head.w2ui-col-select").length,a.columnHead=s=query(e.target).closest(".w2ui-head"),a.originalPos=t=parseInt(s.attr("col"),10),!0===(t=r.trigger("columnDragStart",{originalEvent:e,origColumnNumber:t,target:s[0]})).isCancelled)return!1;i=a.columns=query(r.box).find(".w2ui-head:not(.w2ui-head-last)"),query(document).on("mouseup.colDrag",h),query(document).on("mousemove.colDrag",o);var s=r.columns[a.originalPos],s=w2utils.lang("function"==typeof s.text?s.text(s):s.text);a.ghost=query.html(`${s}`)[0],query(document.body).append(a.ghost),query(a.ghost).css({display:"none",left:e.pageX,top:e.pageY,opacity:1,margin:"3px 0 0 20px",padding:"3px","background-color":"white",position:"fixed","z-index":999999}).addClass(".w2ui-grid-ghost"),a.offsets=[];for(let e=0,t=i.length;e ${this.buttons.search.html}
    @@ -388,7 +388,7 @@ class w2event{constructor(e,t){Object.assign(this,{type:t.type??null,detail:t,ow `}getOperators(e,t){let i=this.operators[this.operatorsMap[e]]||[],s=(null!=t&&Array.isArray(t)&&(i=t),"");return i.forEach(e=>{let t=e,i=e;Array.isArray(e)?(t=e[1],i=e[0]):w2utils.isPlainObject(e)&&(t=e.text,i=e.oper),null==t&&(t=e),s+=` -`}),s}initOperator(e){let i;var t=this.searches[e],s=this.getSearchData(t.field),l=query(`#w2overlay-${this.name}-search-overlay`),r=l.find(`#grid_${this.name}_range_`+e);let a=l.find(`#grid_${this.name}_field_`+e),n=l.find(`#grid_${this.name}_field2_`+e);var o=l.find(`#grid_${this.name}_operator_`+e).val();switch(a.show(),r.hide(),o){case"between":r.show();break;case"null":case"not null":a.hide(),a.val(o),a.trigger("change")}switch(t.type){case"text":case"alphanumeric":var h=a[0]._w2field;h&&h.reset();break;case"int":case"float":case"hex":case"color":case"money":case"currency":case"percent":case"date":case"time":case"datetime":a[0]._w2field||(new w2field(t.type,{el:a[0],...t.options}),new w2field(t.type,{el:n[0],...t.options}),setTimeout(()=>{a.trigger("keydown"),n.trigger("keydown")},1));break;case"list":case"combo":case"enum":i=t.options,"list"==t.type&&(i.selected={}),"enum"==t.type&&(i.selected=[]),s&&(i.selected=s.value),a[0]._w2field||(h=new w2field(t.type,{el:a[0],...i}),s&&null!=s.text&&h.set({id:s.value,text:s.text}));break;case"select":i='';for(let e=0;e'+t+""}else i+='"}a.html(i)}}initSearches(){var s=query(`#w2overlay-${this.name}-search-overlay`);for(let t=0;t{w2utils.isPlainObject(e)&&(i[t]=e.oper)}),r&&r.operator&&(e=r.operator);var l=this.defaultOperator[this.operatorsMap[l.type]],l=(-1==i.indexOf(e)&&(e=l),s.find(`#grid_${this.name}_operator_`+t).val(e),this.initOperator(t),s.find(`#grid_${this.name}_field_`+t)),a=s.find(`#grid_${this.name}_field2_`+t);null!=r&&(Array.isArray(r.value)?["in","not in"].includes(r.operator)?l[0]._w2field.set(r.value):(l.val(r.value[0]).trigger("change"),a.val(r.value[1]).trigger("change")):null!=r.value&&l.val(r.value).trigger("change"))}s.find(".w2ui-grid-search-advanced *[rel=search]").on("keypress",e=>{13==e.keyCode&&(this.search(),w2tooltip.hide(this.name+"-search-overlay"))})}getColumnsHTML(){let h=this,e="",t="";var i,s,l;return this.show.columnHeaders&&(t=0 ",h.columnGroups[e]),h.columnGroups[e].text=h.columnGroups[e].caption);""!=h.columnGroups[h.columnGroups.length-1].text&&h.columnGroups.push({text:""});h.show.lineNumbers&&(t+='
     
    ');h.show.selectColumn&&(t+='
     
    ');h.show.expandColumn&&(t+='
     
    ');let r=0;s+=``,h.reorderRows&&(s+='
     
    ');for(let e=0;e",n),n.text=n.caption);let i=0;for(let e=r;e
    `);var o=w2utils.lang("function"==typeof n.text?n.text(n):n.text);l=``+e+`
    `+`
    `+(o||" ")+"
    "}else{o=w2utils.lang("function"==typeof a.text?a.text(a):a.text);l=``+`
    ${o||" "}
    `+""}n&&n.frozen?t+=l:s+=l}r+=a.span}return t+="",s+=``,[t,s]}(),s=r(!1),e=l[0]+i[0]+s[0],l[1]+i[1]+s[1]):(l=r(!0),e=l[0],l[1])),[e,t];function r(t){let i="",s="",l=(h.show.lineNumbers&&(i+='
    #
    '),h.show.selectColumn&&(i+='
    '+`
    "),h.show.expandColumn&&(i+='
     
    '),0),r=0,a;s+=``,h.reorderRows&&(s+='
     
    ');for(let e=0;e ",o),o.text=o.caption),null==o.size&&(o.size="100%"),e==r&&(a=h.columnGroups[l++]||{},r+=a.span),(eh.last.colEnd)&&!o.frozen||o.hidden||!0===a.main&&!t||(n=h.getColumnCellHTML(e),o&&o.frozen?i+=n:s+=n)}return i+='
     
    ',s+='
     
    ',i+="",s+="",[i,s]}}getColumnCellHTML(t){var i=this.columns[t];if(null==i)return"";var e=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-col-reorderable ";let s="";for(let e=0;e'+(!1!==i.resizable?'
    ':"")+'
    '+(n||" ")+"
    "}columnTooltipShow(e,t){var i=query(this.box).find("#grid_"+this.name+"_column_"+e),e=this.columns[e],s=this.columnTooltip;w2tooltip.show({name:this.name+"-column-tooltip",anchor:i.get(0),html:e.tooltip,position:s})}columnTooltipHide(e,t){w2tooltip.hide(this.name+"-column-tooltip")}getRecordsHTML(){let e=this.records.length;var t="object"!=typeof this.url?this.url:this.url.get,t=((e=0==this.searchData.length||t?e:this.last.searchIds.length)>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start,query(this.box).find(`#grid_${this.name}_records`));let i=Math.floor((t.get(0)?.clientHeight||0)/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||i>e)&&(i=e);var s=this.getRecordHTML(-1,0);let l=""+s[0],r="
    "+s[1];l+='',r+='';for(let e=0;e
    ',r+=' ',this.last.range_start=0,this.last.range_end=i,[l,r]}getSummaryHTML(){if(0!==this.summary.length){var s=this.getRecordHTML(-1,0);let t=""+s[0],i="
    "+s[1];for(let e=0;ethis.last.scrollLeft&&null==l&&(l=e),t+s-30>this.last.scrollLeft+a&&null==r&&(r=e),t+=s);null==r&&(r=this.columns.length-1)}if(null!=l&&(l<0&&(l=0),r<0&&(r=0),l==r&&(0this.last.colStart)for(let e=this.last.colStart;er;e--)n.find("#grid_"+this.name+"_columns #grid_"+this.name+"_column_"+e).remove(),n.find("#grid_"+this.name+'_records td[col="'+e+'"]').remove(),n.find("#grid_"+this.name+'_summary td[col="'+e+'"]').remove();if(l=l;s--)this.columns[s]&&(this.columns[s].frozen||this.columns[s].hidden)||(e.after(this.getColumnCellHTML(s)),f.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!1)),query(e).after(i)}),g.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!0)),query(e).after(i)}));if(r>this.last.colEnd)for(let s=this.last.colEnd+1;s<=r;s++)this.columns[s]&&(this.columns[s].frozen||this.columns[s].hidden)||(t.before(this.getColumnCellHTML(s)),m.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!1)),query(e).before(i)}),y.each(e=>{var t=query(e).parent().attr("index")||-1,t=this.getCellHTML(parseInt(t),s,!0);query(e).before(t)}));this.last.colStart=l,this.last.colEnd=r}else{this.last.colStart=l,this.last.colEnd=r;var o=this.getColumnsHTML(),w=this.getRecordsHTML(),c=this.getSummaryHTML(),p=n.find(`#grid_${this.name}_columns`);let e=n.find(`#grid_${this.name}_records`);var b=n.find(`#grid_${this.name}_frecords`);let t=n.find(`#grid_${this.name}_summary`);p.find("tbody").html(o[1]),b.html(w[0]),e.prepend(w[1]),null!=c&&t.html(c[1]),setTimeout(()=>{e.find(":scope > table").filter(":not(table:first-child)").remove(),t[0]&&(t[0].scrollLeft=this.last.scrollLeft)},1)}this.resizeRecords()}let v=this.records.length;if(v>this.total&&-1!==this.total&&(v=this.total),0!==(v=0==this.searchData.length||i?v:this.last.searchIds.length)&&0!==d.length&&0!==d.prop("clientHeight")){v>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;let e=Math.round(d.prop("scrollTop")/this.recordHeight+1),t=e+(Math.round(d.prop("clientHeight")/this.recordHeight)-1);if(e>v&&(e=v),t>=v-1&&(t=v),query(this.box).find("#grid_"+this.name+"_footer .w2ui-footer-right").html((this.show.statusRange?w2utils.formatNumber(this.offset+e)+"-"+w2utils.formatNumber(this.offset+t)+(-1!=this.total?" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total):""):"")+(i&&this.show.statusBuffered?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(v)+(0this.total&&-1!=this.total&&(i=this.total);var x=d.find("#grid_"+this.name+"_rec_top"),_=d.find("#grid_"+this.name+"_rec_bottom"),q=u.find("#grid_"+this.name+"_frec_top"),C=u.find("#grid_"+this.name+"_frec_bottom"),p=(-1!=String(x.next().prop("id")).indexOf("_expanded_row")&&(x.next().remove(),q.next().remove()),this.total>i&&-1!=String(_.prev().prop("id")).indexOf("_expanded_row")&&(_.prev().remove(),C.prev().remove()),parseInt(x.next().attr("line"))),o=parseInt(_.prev().attr("line"));let e,s,l,r,a;if(p=p-this.last.show_extra+2&&1i))break;s.remove(),l.remove()}e=d.find("#grid_"+this.name+"_rec_top").next(),"bottom"==(r=e.attr("line"))&&(r=i);for(let e=parseInt(r)-1;e>=t;e--)this.records[e-1]&&((l=this.records[e-1].w2ui)&&!Array.isArray(l.children)&&(l.expanded=!1),a=this.getRecordHTML(e-1,e),x.after(a[1]),q.after(a[0]))}k(),setTimeout(()=>{this.refreshRanges()},0);b=(t-1)*this.recordHeight;let n=(v-i)*this.recordHeight;function k(){h.markSearch&&(clearTimeout(h.last.marker_timer),h.last.marker_timer=setTimeout(()=>{var t=[];for(let e=0;e{var t=query(h.box).find('td[col="'+e.col+'"]:not(.w2ui-head)');w2utils.marker(t,e.search)})},50))}n<0&&(n=0),x.css("height",b+"px"),q.css("height",b+"px"),_.css("height",n+"px"),C.css("height",n+"px"),this.last.range_start=t,this.last.range_end=i,Math.floor(d.prop("scrollTop")/this.recordHeight)+Math.floor(d.prop("clientHeight")/this.recordHeight)+10>v&&!0!==this.last.pull_more&&(v
    '),h.last.pull_more=!0,h.last.fetch.offset+=h.limit,h.request("load")}).find("td").html(h.autoLoad?'
    ':'
    '+w2utils.lang("Load ${count} more...",{count:h.limit})+"
    "))}}}getRecordHTML(r,a,n){let o="",h="";var d=this.last.selection;let u;if(-1==r){o+='
    ',h+='',this.show.lineNumbers&&(o+=''),this.show.selectColumn&&(o+=''),this.show.expandColumn&&(o+=''),h+='',this.reorderRows&&(h+='');for(let e=0;e';t.frozen&&!t.hidden?o+=i:t.hidden||ethis.last.colEnd||(h+=i)}o+='',h+=''}else{var c="object"!=typeof this.url?this.url:this.url.get;if(!0!==n){if(0=this.last.searchIds.length)return"";r=this.last.searchIds[r]}else if(r>=this.records.length)return"";u=this.records[r]}else{if(r>=this.summary.length)return"";u=this.summary[r]}if(!u)return"";null==u.recid&&null!=this.recid&&null!=(c=this.parseField(u,this.recid))&&(u.recid=c);let e=!1,t=(-1!=d.indexes.indexOf(r)&&(e=!0),u.w2ui?u.w2ui.style:""),i=(null!=t&&"string"==typeof t||(t=""),u.w2ui?u.w2ui.class:"");if(null!=i&&"string"==typeof i||(i=""),o+='",h+='",this.show.lineNumbers&&(o+='"),this.show.selectColumn&&(o+='"),this.show.expandColumn){let e="";e=!0===u.w2ui?.expanded?"-":"+","none"!=u.w2ui?.expanded&&Array.isArray(u.w2ui?.children)&&u.w2ui?.children.length||(e="+"),"spinner"==u.w2ui?.expanded&&(e='
    '),o+='"}h+='',this.reorderRows&&(h+='");let s=0,l=0;for(;;){let e=1;var p,f=this.columns[s];if(null==f)break;if(f.hidden)s++,0this.last.colEnd)||f.frozen){if(u.w2ui&&"object"==typeof u.w2ui.colspan){var m=parseInt(u.w2ui.colspan[f.field])||null;if(1=this.columns.length);e++)this.columns[e].hidden&&t++;e=m-t,l=m-1}}var g=this.getCellHTML(r,s,n,e);f.frozen?o+=g:h+=g}s++}}o+='',h+=''}return o+="",h+="",[o,h]}getLineHTML(e){return"
    "+e+"
    "}getCellHTML(i,s,l,e){let r=this,a=this.columns[s];if(null==a)return"";let n=(!0!==l?this.records:this.summary)[i],{value:t,style:o,className:h,attr:d,divAttr:u}=this.getCellValue(i,s,l,!0);var c=-1!==i?this.getCellEditable(i,s):"";let p="max-height: "+parseInt(this.recordHeight)+"px;"+(a.clipboardCopy?"margin-right: 20px":"");var f=!l&&n?.w2ui?.changes&&null!=n.w2ui.changes[a.field],m=this.last.selection;let g=!1,y="";if(-1!=m.indexes.indexOf(i)&&(g=!0),null==e&&(e=n?.w2ui?.colspan&&n.w2ui.colspan[a.field]?n.w2ui.colspan[a.field]:1),0===s&&Array.isArray(n?.w2ui?.children)){let t=0,e=this.get(n.w2ui.parent_recid,!0);for(;;){if(null==e)break;t++;var w=this.records[e].w2ui;if(null==w||null==w.parent_recid)break;e=this.get(w.parent_recid,!0)}if(n.w2ui.parent_recid)for(let e=0;e';var b=0`}if(!0===a.info&&(a.info={}),null!=a.info){let e="w2ui-icon-info",t=("function"==typeof a.info.icon?e=a.info.icon(n,{self:this,index:i,colIndex:s,summary:!!l}):"object"==typeof a.info.icon?e=a.info.icon[this.parseField(n,a.field)]||"":"string"==typeof a.info.icon&&(e=a.info.icon),a.info.style||"");"function"==typeof a.info.style?t=a.info.style(n,{self:this,index:i,colIndex:s,summary:!!l}):"object"==typeof a.info.style?t=a.info.style[this.parseField(n,a.field)]||"":"string"==typeof a.info.style&&(t=a.info.style),y+=``}let v=t,x=(c&&-1!=["checkbox","check"].indexOf(c.type)&&(p+="text-align: center;",v=`{a.trigger("keydown"),n.trigger("keydown")},1));break;case"list":case"combo":case"enum":i=t.options,"list"==t.type&&(i.selected={}),"enum"==t.type&&(i.selected=[]),s&&(i.selected=s.value),a[0]._w2field||(h=new w2field(t.type,{el:a[0],...i}),s&&null!=s.text&&h.set({id:s.value,text:s.text}));break;case"select":i='';for(let e=0;e'+t+""}else i+='"}a.html(i)}}initSearches(){var s=query(`#w2overlay-${this.name}-search-overlay`);for(let t=0;t{w2utils.isPlainObject(e)&&(i[t]=e.oper)}),r&&r.operator&&(e=r.operator);var l=this.defaultOperator[this.operatorsMap[l.type]],l=(-1==i.indexOf(e)&&(e=l),s.find(`#grid_${this.name}_operator_`+t).val(e),this.initOperator(t),s.find(`#grid_${this.name}_field_`+t)),a=s.find(`#grid_${this.name}_field2_`+t);null!=r&&(Array.isArray(r.value)?["in","not in"].includes(r.operator)?l[0]._w2field.set(r.value):(l.val(r.value[0]).trigger("change"),a.val(r.value[1]).trigger("change")):null!=r.value&&l.val(r.value).trigger("change"))}s.find(".w2ui-grid-search-advanced *[rel=search]").on("keypress",e=>{13==e.keyCode&&(this.search(),w2tooltip.hide(this.name+"-search-overlay"))})}getColumnsHTML(){let h=this,e="",t="";var i,s,l;return this.show.columnHeaders&&(t=0 ",h.columnGroups[e]),h.columnGroups[e].text=h.columnGroups[e].caption);""!=h.columnGroups[h.columnGroups.length-1].text&&h.columnGroups.push({text:""});h.show.lineNumbers&&(t+='');h.show.selectColumn&&(t+='');h.show.expandColumn&&(t+='');let r=0;s+=``,h.reorderRows&&(s+='');for(let e=0;e",n),n.text=n.caption);let i=0;for(let e=r;e`);var o=w2utils.lang("function"==typeof n.text?n.text(n):n.text);l=`"}else{o=w2utils.lang("function"==typeof a.text?a.text(a):a.text);l=`"}n&&n.frozen?t+=l:s+=l}r+=a.span}return t+="",s+=``,[t,s]}(),s=r(!1),e=l[0]+i[0]+s[0],l[1]+i[1]+s[1]):(l=r(!0),e=l[0],l[1])),[e,t];function r(t){let i="",s="",l=(h.show.lineNumbers&&(i+=''),h.show.selectColumn&&(i+='"),h.show.expandColumn&&(i+=''),0),r=0,a;s+=``,h.reorderRows&&(s+='');for(let e=0;e ",o),o.text=o.caption),null==o.size&&(o.size="100%"),e==r&&(a=h.columnGroups[l++]||{},r+=a.span),(eh.last.colEnd)&&!o.frozen||o.hidden||!0===a.main&&!t||(n=h.getColumnCellHTML(e),o&&o.frozen?i+=n:s+=n)}return i+='',s+='',i+="",s+="",[i,s]}}getColumnCellHTML(t){var i=this.columns[t];if(null==i)return"";var e=!this.reorderColumns||this.columnGroups&&this.columnGroups.length?"":" w2ui-col-reorderable ";let s="";for(let e=0;e'+(!1!==i.resizable?'
    ':"")+'
    '+(n||" ")+"
    "}columnTooltipShow(e,t){var i=query(this.box).find("#grid_"+this.name+"_column_"+e),e=this.columns[e],s=this.columnTooltip;w2tooltip.show({name:this.name+"-column-tooltip",anchor:i.get(0),html:e?.tooltip,position:s})}columnTooltipHide(e,t){w2tooltip.hide(this.name+"-column-tooltip")}getRecordsHTML(){let e=this.records.length;var t="object"!=typeof this.url?this.url:this.url.get,t=((e=0==this.searchData.length||t?e:this.last.searchIds.length)>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start,query(this.box).find(`#grid_${this.name}_records`));let i=Math.floor((t.get(0)?.clientHeight||0)/this.recordHeight)+this.last.show_extra+1;(!this.fixedBody||i>e)&&(i=e);var s=this.getRecordHTML(-1,0);let l="
    "+(!0!==n?this.getLineHTML(a,u):"")+"'+(!0===n||u.w2ui&&!0===u.w2ui.hideCheckBox?"":'
    ')+"
    '+(!0!==n?`
    ${e}
    `:"")+"
    '+(!0!==n?'
     
    ':"")+"
     
     
     
     
    `+e+`
    `+`
    `+(o||" ")+"
    `+`
    ${o||" "}
    `+"
    #
    '+`
     
     
     
     
    "+s[0],r="
    "+s[1];l+='',r+='';for(let e=0;e
    ',r+=' ',this.last.range_start=0,this.last.range_end=i,[l,r]}getSummaryHTML(){if(0!==this.summary.length){var s=this.getRecordHTML(-1,0);let t=""+s[0],i="
    "+s[1];for(let e=0;ethis.last.scrollLeft&&null==l&&(l=e),t+s-30>this.last.scrollLeft+a&&null==r&&(r=e),t+=s);null==r&&(r=this.columns.length-1)}if(null!=l&&(l<0&&(l=0),r<0&&(r=0),l==r&&(0this.last.colStart)for(let e=this.last.colStart;er;e--)n.find("#grid_"+this.name+"_columns #grid_"+this.name+"_column_"+e).remove(),n.find("#grid_"+this.name+'_records td[col="'+e+'"]').remove(),n.find("#grid_"+this.name+'_summary td[col="'+e+'"]').remove();if(l=l;s--)this.columns[s]&&(this.columns[s].frozen||this.columns[s].hidden)||(e.after(this.getColumnCellHTML(s)),f.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!1)),query(e).after(i)}),g.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!0)),query(e).after(i)}));if(r>this.last.colEnd)for(let s=this.last.colEnd+1;s<=r;s++)this.columns[s]&&(this.columns[s].frozen||this.columns[s].hidden)||(t.before(this.getColumnCellHTML(s)),m.each(e=>{var t=query(e).parent().attr("index");let i='';null!=t&&(i=this.getCellHTML(parseInt(t),s,!1)),query(e).before(i)}),y.each(e=>{var t=query(e).parent().attr("index")||-1,t=this.getCellHTML(parseInt(t),s,!0);query(e).before(t)}));this.last.colStart=l,this.last.colEnd=r}else{this.last.colStart=l,this.last.colEnd=r;var o=this.getColumnsHTML(),w=this.getRecordsHTML(),c=this.getSummaryHTML(),p=n.find(`#grid_${this.name}_columns`);let e=n.find(`#grid_${this.name}_records`);var b=n.find(`#grid_${this.name}_frecords`);let t=n.find(`#grid_${this.name}_summary`);p.find("tbody").html(o[1]),b.html(w[0]),e.prepend(w[1]),null!=c&&t.html(c[1]),setTimeout(()=>{e.find(":scope > table").filter(":not(table:first-child)").remove(),t[0]&&(t[0].scrollLeft=this.last.scrollLeft)},1)}this.resizeRecords()}let v=this.records.length;if(v>this.total&&-1!==this.total&&(v=this.total),0!==(v=0==this.searchData.length||i?v:this.last.searchIds.length)&&0!==d.length&&0!==d.prop("clientHeight")){v>this.vs_start?this.last.show_extra=this.vs_extra:this.last.show_extra=this.vs_start;let e=Math.round(d.prop("scrollTop")/this.recordHeight+1),t=e+(Math.round(d.prop("clientHeight")/this.recordHeight)-1);if(e>v&&(e=v),t>=v-1&&(t=v),query(this.box).find("#grid_"+this.name+"_footer .w2ui-footer-right").html((this.show.statusRange?w2utils.formatNumber(this.offset+e)+"-"+w2utils.formatNumber(this.offset+t)+(-1!=this.total?" "+w2utils.lang("of")+" "+w2utils.formatNumber(this.total):""):"")+(i&&this.show.statusBuffered?" ("+w2utils.lang("buffered")+" "+w2utils.formatNumber(v)+(0this.total&&-1!=this.total&&(i=this.total);var x=d.find("#grid_"+this.name+"_rec_top"),_=d.find("#grid_"+this.name+"_rec_bottom"),q=u.find("#grid_"+this.name+"_frec_top"),C=u.find("#grid_"+this.name+"_frec_bottom"),p=(-1!=String(x.next().prop("id")).indexOf("_expanded_row")&&(x.next().remove(),q.next().remove()),this.total>i&&-1!=String(_.prev().prop("id")).indexOf("_expanded_row")&&(_.prev().remove(),C.prev().remove()),parseInt(x.next().attr("line"))),o=parseInt(_.prev().attr("line"));let e,s,l,r,a;if(p=p-this.last.show_extra+2&&1i))break;s.remove(),l.remove()}e=d.find("#grid_"+this.name+"_rec_top").next(),"bottom"==(r=e.attr("line"))&&(r=i);for(let e=parseInt(r)-1;e>=t;e--)this.records[e-1]&&((l=this.records[e-1].w2ui)&&!Array.isArray(l.children)&&(l.expanded=!1),a=this.getRecordHTML(e-1,e),x.after(a[1]),q.after(a[0]))}k(),setTimeout(()=>{this.refreshRanges()},0);b=(t-1)*this.recordHeight;let n=(v-i)*this.recordHeight;function k(){h.markSearch&&(clearTimeout(h.last.marker_timer),h.last.marker_timer=setTimeout(()=>{var t=[];for(let e=0;e{var t=query(h.box).find('td[col="'+e.col+'"]:not(.w2ui-head)');w2utils.marker(t,e.search)})},50))}n<0&&(n=0),x.css("height",b+"px"),q.css("height",b+"px"),_.css("height",n+"px"),C.css("height",n+"px"),this.last.range_start=t,this.last.range_end=i,Math.floor(d.prop("scrollTop")/this.recordHeight)+Math.floor(d.prop("clientHeight")/this.recordHeight)+10>v&&!0!==this.last.pull_more&&(v
    '),h.last.pull_more=!0,h.last.fetch.offset+=h.limit,h.request("load")}).find("td").html(h.autoLoad?'
    ':'
    '+w2utils.lang("Load ${count} more...",{count:h.limit})+"
    "))}}}getRecordHTML(r,a,n){let o="",h="";var d=this.last.selection;let u;if(-1==r){o+='
    ',h+='',this.show.lineNumbers&&(o+=''),this.show.selectColumn&&(o+=''),this.show.expandColumn&&(o+=''),h+='',this.reorderRows&&(h+='');for(let e=0;e';t.frozen&&!t.hidden?o+=i:t.hidden||ethis.last.colEnd||(h+=i)}o+='',h+=''}else{var c="object"!=typeof this.url?this.url:this.url.get;if(!0!==n){if(0=this.last.searchIds.length)return"";r=this.last.searchIds[r]}else if(r>=this.records.length)return"";u=this.records[r]}else{if(r>=this.summary.length)return"";u=this.summary[r]}if(!u)return"";null==u.recid&&null!=this.recid&&null!=(c=this.parseField(u,this.recid))&&(u.recid=c);let e=!1,t=(-1!=d.indexes.indexOf(r)&&(e=!0),u.w2ui?u.w2ui.style:""),i=(null!=t&&"string"==typeof t||(t=""),u.w2ui?u.w2ui.class:"");if(null!=i&&"string"==typeof i||(i=""),o+='",h+='",this.show.lineNumbers&&(o+='"),this.show.selectColumn&&(o+='"),this.show.expandColumn){let e="";e=!0===u.w2ui?.expanded?"-":"+","none"!=u.w2ui?.expanded&&Array.isArray(u.w2ui?.children)&&u.w2ui?.children.length||(e="+"),"spinner"==u.w2ui?.expanded&&(e='
    '),o+='"}h+='',this.reorderRows&&(h+='");let s=0,l=0;for(;;){let e=1;var p,f=this.columns[s];if(null==f)break;if(f.hidden)s++,0this.last.colEnd)||f.frozen){if(u.w2ui&&"object"==typeof u.w2ui.colspan){var m=parseInt(u.w2ui.colspan[f.field])||null;if(1=this.columns.length);e++)this.columns[e].hidden&&t++;e=m-t,l=m-1}}var g=this.getCellHTML(r,s,n,e);f.frozen?o+=g:h+=g}s++}}o+='',h+=''}return o+="",h+="",[o,h]}getLineHTML(e){return"
    "+e+"
    "}getCellHTML(i,s,l,e){let r=this,a=this.columns[s];if(null==a)return"";let n=(!0!==l?this.records:this.summary)[i],{value:t,style:o,className:h,attr:d,divAttr:u}=this.getCellValue(i,s,l,!0);var c=-1!==i?this.getCellEditable(i,s):"";let p="max-height: "+parseInt(this.recordHeight)+"px;"+(a.clipboardCopy?"margin-right: 20px":"");var f=!l&&n?.w2ui?.changes&&null!=n.w2ui.changes[a.field],m=this.last.selection;let g=!1,y="";if(-1!=m.indexes.indexOf(i)&&(g=!0),null==e&&(e=n?.w2ui?.colspan&&n.w2ui.colspan[a.field]?n.w2ui.colspan[a.field]:1),0===s&&Array.isArray(n?.w2ui?.children)){let t=0,e=this.get(n.w2ui.parent_recid,!0);for(;;){if(null==e)break;t++;var w=this.records[e].w2ui;if(null==w||null==w.parent_recid)break;e=this.get(w.parent_recid,!0)}if(n.w2ui.parent_recid)for(let e=0;e';var b=0`}if(!0===a.info&&(a.info={}),null!=a.info){let e="w2ui-icon-info",t=("function"==typeof a.info.icon?e=a.info.icon(n,{self:this,index:i,colIndex:s,summary:!!l}):"object"==typeof a.info.icon?e=a.info.icon[this.parseField(n,a.field)]||"":"string"==typeof a.info.icon&&(e=a.info.icon),a.info.style||"");"function"==typeof a.info.style?t=a.info.style(n,{self:this,index:i,colIndex:s,summary:!!l}):"object"==typeof a.info.style?t=a.info.style[this.parseField(n,a.field)]||"":"string"==typeof a.info.style&&(t=a.info.style),y+=``}let v=t,x=(c&&-1!=["checkbox","check"].indexOf(c.type)&&(p+="text-align: center;",v=``,y=""),null==(v=`
    ${y}${String(v)}
    `)&&(v=""),"string"==typeof a.render&&(b=a.render.toLowerCase().split(":"),-1!=["number","int","float","money","currency","percent","size"].indexOf(b[0]))&&(o+="text-align: right;"),n?.w2ui&&("object"==typeof n.w2ui.style&&("string"==typeof n.w2ui.style[s]&&(o+=n.w2ui.style[s]+";"),"string"==typeof n.w2ui.style[a.field])&&(o+=n.w2ui.style[a.field]+";"),"object"==typeof n.w2ui.class)&&("string"==typeof n.w2ui.class[s]&&(h+=n.w2ui.class[s]+" "),"string"==typeof n.w2ui.class[a.field])&&(h+=n.w2ui.class[a.field]+" "),!1);g&&m.columns[i]?.includes(s)&&(x=!0);let _;return a.clipboardCopy&&(_=''),v='
    ",v=-1===i&&!0===l?'":v}clipboardCopy(e,t,i){var s=(i?this.summary:this.records)[e],l=this.columns[t];let r=l?this.parseField(s,l.field):"";"function"==typeof l.clipboardCopy&&(r=l.clipboardCopy(s,{self:this,index:e,colIndex:t,summary:!!i})),query(this.box).find("#grid_"+this.name+"_focus").text(r).get(0).select(),document.execCommand("copy")}showBubble(s,l,r){var a=this.columns[l].info;if(a){let i="";var n=this.records[s],e=query(this.box).find(`${r?".w2ui-grid-summary":""} #grid_${this.name}_data_${s}_${l} .w2ui-info`);if(this.last.bubbleEl&&w2tooltip.hide(this.name+"-bubble"),this.last.bubbleEl=e,null==a.fields){a.fields=[];for(let e=0;e';else{let e=this.getColumn(h[0]),t=(e=null==e?{field:h[0],caption:h[0]}:e)?this.parseField(n,e.field):"";1a.maxLength&&(t=t.substr(0,a.maxLength)+"..."),i+="")}}i+="
    "+(!0!==n?this.getLineHTML(a,u):"")+"'+(!0===n||u.w2ui&&!0===u.w2ui.hideCheckBox?"":'
    ')+"
    '+(!0!==n?`
    ${e}
    `:"")+"
    '+(!0!==n?'
     
    ':"")+"
    "+v+(_&&w2utils.stripTags(v)?_:"")+"
    "+e.text+""+((0===t?"0":t)||"")+"
    "}else if(w2utils.isPlainObject(t)){for(var d in i='',t){var u=t[d];if(""==u||"-"==u||"--"==u||"---"==u)i+='';else{var c=String(u).split(":");let e=this.getColumn(c[0]),t=(e=null==e?{field:c[0],caption:c[0]}:e)?this.parseField(n,e.field):"";1a.maxLength&&(t=t.substr(0,a.maxLength)+"..."),i+="")}}i+="
    "+d+""+((0===t?"0":t)||"")+"
    "}return w2tooltip.show(w2utils.extend({name:this.name+"-bubble",html:i,anchor:e.get(0),position:"top|bottom",class:"w2ui-info-bubble",style:"",hideOn:["doc-click"]},a.options??{})).hide(()=>[this.last.bubbleEl=null])}}getCellEditable(e,t){var i=this.columns[t],s=this.records[e];if(!s||!i)return null;let l=s.w2ui?s.w2ui.editable:null;return!1===l?null:(null!=l&&!0!==l||"function"==typeof(l=0 '}status(i){if(null!=i)query(this.box).find(`#grid_${this.name}_footer`).find(".w2ui-footer-left").html(i);else{let t="";i=this.getSelection();if(0{query(this.box).find("#grid_"+this.name+"_empty_msg").remove(),w2utils.lock(...i)},10)}unlock(e){setTimeout(()=>{query(this.box).find(".w2ui-message").hasClass("w2ui-closing")||w2utils.unlock(this.box,e)},25)}stateSave(e){var t={columns:[],show:w2utils.clone(this.show),last:{search:this.last.search,multi:this.last.multi,logic:this.last.logic,label:this.last.label,field:this.last.field,scrollTop:this.last.scrollTop,scrollLeft:this.last.scrollLeft},sortData:[],searchData:[]};let l;for(let e=0;e{this.stateColProps[e]&&(l=void 0!==i[e]?i[e]:this.colTemplate[e]||null,s[e]=l)}),t.columns.push(s)}for(let e=0;e{s||(0=this.columns.length)return null==(e=this.nextRow(e))?e:this.nextCell(e,-1,i);var s=this.records[e].w2ui,l=this.columns[t],s=s&&s.colspan&&!isNaN(s.colspan[l.field])?parseInt(s.colspan[l.field]):1;if(null==l)return null;if(l&&l.hidden||0===s)return this.nextCell(e,t,i);if(i){l=this.getCellEditable(e,t);if(null==l||-1!=["checkbox","check"].indexOf(l.type))return this.nextCell(e,t,i)}return{index:e,colIndex:t}}prevCell(e,t,i){t-=1;if(t<0)return null==(e=this.prevRow(e))?e:this.prevCell(e,this.columns.length,i);if(t<0)return null;var s=this.records[e].w2ui,l=this.columns[t],s=s&&s.colspan&&!isNaN(s.colspan[l.field])?parseInt(s.colspan[l.field]):1;if(null==l)return null;if(l&&l.hidden||0===s)return this.prevCell(e,t,i);if(i){l=this.getCellEditable(e,t);if(null==l||-1!=["checkbox","check"].indexOf(l.type))return this.prevCell(e,t,i)}return{index:e,colIndex:t}}nextRow(e,t,i){var s=this.last.searchIds;let l=null;if(-1==(i=null==i?1:i))return this.records.length-1;if(e+ithis.records.length)break;e+=i}var r=this.records[e].w2ui,a=this.columns[t],r=r&&r.colspan&&null!=a&&!isNaN(r.colspan[a.field])?parseInt(r.colspan[a.field]):1;l=0===r?this.nextRow(e,t,i):e}return l}prevRow(e,t,i){var s=this.last.searchIds;let l=null;if(-1==(i=null==i?1:i))return 0;if(0<=e-i&&0===s.length||0s[0]){if(e-=i,0{-1==i.indexOf(e)&&-1!=["label","attr","style","text","span","page","column","anchor","group","groupStyle","groupTitleStyle","groupCollapsible"].indexOf(e)&&(t.html[e]=t[e],delete t[e])}),t}function h(t,i){let s=["style","html"];Object.keys(t).forEach(e=>{-1==s.indexOf(e)&&-1!=["span","column","attr","text","label"].indexOf(e)&&t[e]&&!i.html[e]&&(i.html[e]=t[e])})}r=[],Object.keys(e).forEach(i=>{let s=e[i];if("group"==s.type){if(s.text=i,w2utils.isPlainObject(s.fields)){let i=s.fields;s.fields=[],Object.keys(i).forEach(e=>{let t=i[e];t.field=e,s.fields.push(o(t))})}r.push(s)}else if("tab"==s.type){let e={id:i,text:i},t=(s.style&&(e.style=s.style),n.push(e),l(s.fields).fields);t.forEach(e=>{e.html=e.html||{},e.html.page=n.length-1,h(s,e)}),r.push(...t)}else s.field=i,r.push(o(s))})}r.forEach(s=>{if("group"==s.type){let i={group:s.text||"",groupStyle:s.style||"",groupTitleStyle:s.titleStyle||"",groupCollapsible:!0===s.collapsible};Array.isArray(s.fields)&&s.fields.forEach(e=>{let t=w2utils.clone(e);null==t.html&&(t.html={}),w2utils.extend(t.html,i),Array("span","column","attr","label","page").forEach(e=>{null==t.html[e]&&null!=s[e]&&(t.html[e]=s[e])}),null==t.field&&null!=t.name&&(console.log("NOTICE: form field.name property is deprecated, please use field.field. Field ->",s),t.field=t.name),a.push(t)})}else{let e=w2utils.clone(s);null==e.field&&null!=e.name&&(console.log("NOTICE: form field.name property is deprecated, please use field.field. Field ->",s),e.field=e.name),a.push(e)}});return{fields:a,tabs:n}}(r),this.fields=e.fields,!n)&&0e.text()).then(e=>{this.formHTML=e,this.isGenerated=!0,this.box&&this.render(this.box)}):this.formURL||this.formHTML?this.formHTML&&(this.isGenerated=!0):(this.formHTML=this.generateHTML(),this.isGenerated=!0),"string"==typeof this.box&&(this.box=query(this.box).get(0)),this.box&&this.render(this.box)}get(t,i){if(0===arguments.length){var s=[];for(let e=0;ee[t],s)}catch(e){}return e}return this.record[t]}setValue(e,l){if((""===l||null==l||Array.isArray(l)&&0===l.length||w2utils.isPlainObject(l)&&0==Object.keys(l).length)&&(l=null),!this.nestedFields)return this.record[e]=l,!0;try{let s=this.record;return String(e).split(".").map((e,t,i)=>{i.length-1!==t?s=s[e]||(s[e]={},s[e]):s[e]=l}),!0}catch(e){return!1}}getFieldValue(e){let s=this.get(e);if(null!=s){var l=s.el;let t=this.getValue(e);e=this.getValue(e,!0);let i=l.value;["int","float","percent","money","currency"].includes(s.type)&&(i=s.w2field.clean(i)),["radio"].includes(s.type)&&(r=query(l).closest("div").find("input:checked").get(0),i=r?s.options.items[query(r).data("index")].id:null),["toggle","checkbox"].includes(s.type)&&(i=l.checked),-1!==["check","checks"].indexOf(s.type)&&(i=[],0<(r=query(l).closest("div").find("input:checked")).length&&r.each(e=>{e=s.options.items[query(e).data("index")];i.push(e.id)}),Array.isArray(t)||(t=[]));var r=l._w2field?.selected;if(["list","enum","file"].includes(s.type)&&r){var a=r,n=t;if(Array.isArray(a)){i=[];for(let e=0;e{var t=query(e).find(".w2ui-map.key").val(),e=query(e).find(".w2ui-map.value").val();"map"==s.type?i[t]=e:i.push(e)})),{current:i,previous:t,original:e}}}setFieldValue(e,r){let a=this.get(e);if(null!=a){var s=a.el;switch(a.type){case"toggle":case"checkbox":s.checked=!!r;break;case"radio":{r=r?.id??r;let i=query(s).closest("div").find("input");a.options.items.forEach((e,t)=>{e.id===r&&i.filter(`[data-index="${t}"]`).prop("checked",!0)});break}case"check":case"checks":{r=(r=Array.isArray(r)?r:null!=r?[r]:[]).map(e=>e?.id??e);let i=query(s).closest("div").find("input");a.options.items.forEach((e,t)=>{i.filter(`[data-index="${t}"]`).prop("checked",!!r.includes(e.id))});break}case"list":case"combo":let t=r;null==t?.id&&Array.isArray(a.options?.items)&&a.options.items.forEach(e=>{e.id===r&&(t=e)}),t!=r&&this.setValue(a.name,t),"list"==a.type?(a.w2field.selected=t,a.w2field.refresh()):a.el.value=t?.text??r;break;case"enum":case"file":{let s=[...r=Array.isArray(r)?r:null!=r?[r]:[]],l=!1;s.forEach((t,i)=>{null==t?.id&&Array.isArray(a.options.items)&&a.options.items.forEach(e=>{e.id==t&&(s[i]=e,l=!0)})}),l&&this.setValue(a.name,s),a.w2field.selected=s,a.w2field.refresh();break}case"map":case"array":"map"!=a.type||null!=r&&w2utils.isPlainObject(r)||(this.setValue(a.field,{}),r=this.getValue(a.field)),"array"!=a.type||null!=r&&Array.isArray(r)||(this.setValue(a.field,[]),r=this.getValue(a.field));var i=query(a.el).parent().find(".w2ui-map-container");a.el.mapRefresh(r,i);break;case"div":case"custom":query(s).html(r);break;case"html":case"empty":break;default:s.value=r??""}}}show(){var t=[];for(let e=0;e{!function(e){let t=!0;return e.each(e=>{"none"!=e.style.display&&(t=!1)}),t}(query(e).find(".w2ui-field"))?query(e).show():query(e).hide()})}change(){Array.from(arguments).forEach(e=>{e=this.get(e);e.$el&&e.$el.change()})}reload(e){return("object"!=typeof this.url?this.url:this.url.get)&&null!=this.recid?this.request(e):("function"==typeof e&&e(),new Promise(e=>{e()}))}clear(){0!=arguments.length?Array.from(arguments).forEach(e=>{let s=this.record;String(e).split(".").map((e,t,i)=>{i.length-1!==t?s=s[e]:delete s[e]}),this.refresh(e)}):(this.recid=null,this.record={},this.original=null,this.refresh(),this.hideErrors())}error(e){var t=this.trigger("error",{target:this.name,message:e,fetchCtrl:this.last.fetchCtrl,fetchOptions:this.last.fetchOptions});!0!==t.isCancelled&&(setTimeout(()=>{this.message(e)},1),t.finish())}message(e){return w2utils.message({owner:this,box:this.box,after:".w2ui-form-header"},e)}confirm(e){return w2utils.confirm({owner:this,box:this.box,after:".w2ui-form-header"},e)}validate(e){null==e&&(e=!0);var t=[];for(let e=0;e{var i=w2utils.extend({anchorClass:"w2ui-error",class:"w2ui-light",position:"right|left",hideOn:["input"]},t.options);if(null!=t.field){let e=t.field.el;"radio"===t.field.type?e=query(t.field.el).closest("div").get(0):["enum","file"].includes(t.field.type),w2tooltip.show(w2utils.extend({anchor:e,name:`${this.name}-${t.field.field}-error`,html:t.error},i))}}),query(e[0].field.$el).parents(".w2ui-page").off(".hideErrors").on("scroll.hideErrors",e=>{this.hideErrors()}))}hideErrors(){this.fields.forEach(e=>{w2tooltip.hide(`${this.name}-${e.field}-error`)})}getChanges(){let e={};return e=null!=this.original&&"object"==typeof this.original&&0!==Object.keys(this.record).length?function e(t,i,s){if(Array.isArray(t)&&Array.isArray(i))for(;t.length{if(-1!=["list","combo","enum"].indexOf(e.type)){var t={nestedFields:!0,record:s};let i=this.getValue.call(t,e.field);w2utils.isPlainObject(i)&&null!=i.id&&this.setValue.call(t,e.field,i.id),Array.isArray(i)&&i.forEach((e,t)=>{w2utils.isPlainObject(e)&&e.id&&(i[t]=e.id)})}var i;"map"==e.type&&(t={nestedFields:!0,record:s},(t=this.getValue.call(t,e.field))._order)&&delete t._order,"file"==e.type&&(t={nestedFields:!0,record:s},(i=this.getValue.call(t,e.field)??[]).forEach(e=>{delete e.file,delete e.modified}),this.setValue.call(t,e.field,i))}),!0===e&&Object.keys(s).forEach(e=>{this.get(e)||delete s[e]}),s}request(e,i){let s=this,l,r;var a=new Promise((e,t)=>{l=e,r=t});if("function"==typeof e&&(i=e,e=null),null==e&&(e={}),this.url&&("object"!=typeof this.url||this.url.get)){var n={action:"get"},e=(n.recid=this.recid,n.name=this.name,w2utils.extend(n,this.postData),w2utils.extend(n,e),this.trigger("request",{target:this.name,url:this.url,httpMethod:"GET",postData:n,httpHeaders:this.httpHeaders}));if(!0!==e.isCancelled){this.record={},this.original=null,this.lock(w2utils.lang(this.msgRefresh));let t=e.detail.url;if("object"==typeof t&&t.get&&(t=t.get),this.last.fetchCtrl)try{this.last.fetchCtrl.abort()}catch(e){}if(0!=Object.keys(this.routeData).length){var o=w2utils.parseRoute(t);if(0{200!=e?.status?e&&h(e):e.json().catch(h).then(e=>{var t=s.trigger("load",{target:s.name,fetchCtrl:this.last.fetchCtrl,fetchOptions:this.last.fetchOptions,data:e});!0!==t.isCancelled&&(null==e.error&&"error"===e.status&&(e.error=!0),e.record||Object.assign(e,{record:w2utils.clone(e)}),!0===e.error?s.error(w2utils.lang(e.message??this.msgServerError)):s.record=w2utils.clone(e.record),s.unlock(),t.finish(),s.refresh(),s.setFocus(),"function"==typeof i&&i(e),l(e))})}),e.finish(),a;function h(e){var t;"AbortError"!==e.name&&(s.unlock(),!0!==(t=s.trigger("error",{response:e,fetchCtrl:s.last.fetchCtrl,fetchOptions:s.last.fetchOptions})).isCancelled)&&(e.status&&200!=e.status?s.error(e.status+": "+e.statusText):(console.log("ERROR: Server request failed.",e,". ","Expected Response:",{error:!1,record:{field1:1,field2:"item"}},"OR:",{error:!0,message:"Error description"}),s.error(String(e))),t.finish(),r(e))}}}}submit(e,t){return this.save(e,t)}save(e,i){let s=this,l,r;var a=new Promise((e,t)=>{l=e,r=t}),n=("function"==typeof e&&(i=e,e=null),s.validate(!0));if(0===n.length)if(null==e&&(e={}),!s.url||"object"==typeof s.url&&!s.url.save)console.log("ERROR: Form cannot be saved because no url is defined.");else{s.lock(w2utils.lang(s.msgSaving)+' ');n={action:"save"},e=(n.recid=s.recid,n.name=s.name,w2utils.extend(n,s.postData),w2utils.extend(n,e),n.record=w2utils.clone(s.record),s.trigger("submit",{target:s.name,url:s.url,httpMethod:this.method??"POST",postData:n,httpHeaders:s.httpHeaders}));if(!0!==e.isCancelled){let t=e.detail.url;if("object"==typeof t&&t.save&&(t=t.save),s.last.fetchCtrl&&s.last.fetchCtrl.abort(),0{s.unlock(),200!=e?.status?h(e??{}):e.json().catch(h).then(e=>{var t=s.trigger("save",{target:s.name,fetchCtrl:this.last.fetchCtrl,fetchOptions:this.last.fetchOptions,data:e});!0!==t.isCancelled&&(!0===e.error?s.error(w2utils.lang(e.message??this.msgServerError)):s.original=null,t.finish(),s.refresh(),"function"==typeof i&&i(e),l(e))})}),e.finish(),a;function h(e){var t;"AbortError"!==e?.name&&(s.unlock(),!0!==(t=s.trigger("error",{response:e,fetchCtrl:s.last.fetchCtrl,fetchOptions:s.last.fetchOptions})).isCancelled)&&(e.status&&200!=e.status?s.error(e.status+": "+e.statusText):(console.log("ERROR: Server request failed.",e,". ","Expected Response:",{error:!1,record:{field1:1,field2:"item"}},"OR:",{error:!0,message:"Error description"}),s.error(String(e))),t.finish(),r())}}}}lock(e,t){var i=Array.from(arguments);i.unshift(this.box),w2utils.lock(...i)}unlock(e){var t=this.box;w2utils.unlock(t,e)}lockPage(e,t,i){e=query(this.box).find(".page-"+e);return!!e.length&&(w2utils.lock(e,t,i),!0)}unlockPage(e,t){e=query(this.box).find(".page-"+e);return!!e.length&&(w2utils.unlock(e,t),!0)}goto(e){this.page!==e&&(null!=e&&(this.page=e),!0===query(this.box).data("autoSize")&&(query(this.box).get(0).clientHeight=0),this.refresh())}generateHTML(){let s=[],t="",l,r,a,n;for(let e=0;e",h),h.html.label=h.html.caption),null==h.html.label&&(h.html.label=h.field),h.html=w2utils.extend({label:"",span:6,attr:"",text:"",style:"",page:0,column:0},h.html),null==l&&(l=h.html.page),null==r&&(r=h.html.column);let i=``;switch(h.type){case"pass":case"password":i=i.replace('type="text"','type="password"');break;case"checkbox":i=`