diff --git a/dist/bootree.css b/dist/bootree.css new file mode 100644 index 0000000..476c67f --- /dev/null +++ b/dist/bootree.css @@ -0,0 +1,2664 @@ +.bt-button { + background-color: #f5f5f5; + border: 1px solid #ddd; + color: #000; + border-radius: 3px; + padding: 6px 10px; + cursor: pointer; +} + +.bt-unselectable { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.bt-row { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; +} + +.bt-margin-left-5 { + margin-left: 5px; +} + +.bt-margin-left-10 { + margin-left: 10px; +} + +.bt-width-full { + width: 100%; +} + +.bt-cursor-pointer { + cursor: pointer; +} + +.bt-text-align-center { + text-align: center; +} + +.bt-font-size-16 { + font-size: 16px; +} + +.bt-hidden { + display: none; +} + +/** Material Design */ +.bt-button-md { + background: 0 0; + border: none; + border-radius: 2px; + color: rgba(0, 0, 0, 0.87); + position: relative; + height: 36px; + margin: 0; + min-width: 64px; + padding: 0 16px; + display: inline-block; + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 1rem; + font-weight: 500; + text-transform: uppercase; + letter-spacing: 0; + overflow: hidden; + will-change: box-shadow; + transition: box-shadow .2s cubic-bezier(.4,0,1,1),background-color .2s cubic-bezier(.4,0,.2,1),color .2s cubic-bezier(.4,0,.2,1); + outline: none; + cursor: pointer; + text-decoration: none; + text-align: center; + line-height: 36px; + vertical-align: middle; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.bt-button-md:hover { + background-color: rgba(158,158,158,.2); +} + +.bt-button-md:disabled { + color: rgba(0,0,0,.26); + background: 0 0; +} + +.bt-button-md .material-icons, +.bt-button-md .bt-icon { + vertical-align: middle; + /*font-size: 1.3rem; + margin-right: 4px;*/ +} + +.bt-button-md.bt-button-md-icon { + width: 24px; + height: 31px; + min-width: 24px; + padding: 0px; + display: table; +} + +.bt-button-md.bt-button-md-icon .material-icons, +.bt-button-md.bt-button-md-icon .bt-icon { + display: table-cell; + margin-right: 0px; + width: 24px; + height: 24px; +} + +.bt-button-md.active { + background-color: rgba(158,158,158,.4); +} + +.bt-button-md-group { + position: relative; + display: inline-block; + vertical-align: middle; +} + +.bt-textbox-md { + border: none; + border-bottom: 1px solid rgba(0,0,0,.42); + display: block; + font-family: "Helvetica","Arial",sans-serif; + font-size: 16px; + line-height: 16px; + padding: 4px 0px; + margin: 0; + width: 100%; + background: 0 0; + text-align: left; + color: rgba(0,0,0,.87); +} + +.bt-textbox-md:focus, +.bt-textbox-md:active { + border-bottom: 2px solid rgba(0,0,0,.42); + outline: none; +} + +.bt-textbox-md::placeholder { + color: #8e8e8e; +} + +.bt-textbox-md:-ms-input-placeholder { + color: #8e8e8e; +} + +.bt-textbox-md::-ms-input-placeholder { + color: #8e8e8e; +} + +.bt-md-spacer-24 { + min-width: 24px; + width: 24px; + display: inline-block; +} + +.bt-md-spacer-32 { + min-width: 32px; + width: 32px; + display: inline-block; +} + +.bt-modal { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 2; + display: none; + overflow: hidden; + -webkit-overflow-scrolling: touch; + outline: 0; + background-color: rgba(0, 0, 0, 0.54118); + transition: 200ms ease opacity; + will-change: opacity; +} + +/* List */ +ul.bt-list li [data-role="wrapper"] { + display: table; + width: 100%; +} + +ul.bt-list li [data-role="checkbox"] { + display: table-cell; + vertical-align:middle; + text-align:center; +} + +ul.bt-list li [data-role="image"] { + display: table-cell; + vertical-align:middle; + text-align:center; +} + +ul.bt-list li [data-role="display"] { + display: table-cell; + vertical-align:middle; + cursor: pointer; +} + +ul.bt-list li [data-role="display"]:empty:before { + content: "\200b"; /* unicode zero width space character */ +} + +/* List - Bootstrap */ +ul.bt-list-bootstrap { + padding-left: 0px; + margin-bottom: 0px; +} + +ul.bt-list-bootstrap li { + padding: 0px; +} + +ul.bt-list-bootstrap li [data-role="wrapper"] { + padding: 0px 10px; +} + +ul.bt-list-bootstrap li [data-role="checkbox"] { + width: 24px; + padding: 3px; +} + +ul.bt-list-bootstrap li [data-role="image"] { + width: 24px; + height: 24px; +} + +ul.bt-list-bootstrap li [data-role="display"] { + padding: 8px 0px 8px 4px; +} + +.list-group-item.active ul li, .list-group-item.active:focus ul li, .list-group-item.active:hover ul li { + text-shadow: none; + color:initial; +} + +/* List - Material Design */ +ul.bt-list-md { + padding: 0px; + list-style: none; + list-style-type: none; + line-height: 24px; + letter-spacing: 0; + color: #616161; /* Gray 700 */ +} + +ul.bt-list-md li { + display: list-item; + list-style-type: none; + padding: 0px; + min-height: unset; + box-sizing: border-box; + align-items: center; + cursor: default; + overflow: hidden; + + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: .04em; + line-height: 1; + + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +ul.bt-list-md li [data-role="checkbox"] { + height: 24px; + width: 24px; +} + +ul.bt-list-md li [data-role="image"] { + height: 24px; + width: 24px; +} + +ul.bt-list-md li [data-role="display"] { + padding: 8px 0px 8px 5px; + order: 0; + flex-grow: 2; + text-decoration: none; + box-sizing: border-box; + align-items: center; + text-align: left; + color: rgba(0,0,0,.87); +} + +ul.bt-list-md li.disabled>[data-role="wrapper"]>[data-role="display"] { + color: #9E9E9E; /* Gray 500 */ +} + +.bt-list-md-active { + /* background: #E8EAF6; */ + background: rgba(0,0,0,.12); + color: #3f51b5; +} + + +/* Picker */ +.bt-picker { + position: absolute; + z-index: 1202; + background-color: #fff; +} + +.bt-picker .selected { + color: #fff; +} + +/* Material Design */ +.bt-picker-md { + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: .04em; + line-height: 1; + color: rgba(0,0,0,.87); + border: 1px solid #E0E0E0; +} + +.bt-modal .bt-picker-md { + border: 0px; +} + +.bt-picker-md [role="header"] { + color: rgba(255, 255, 255, 0.54); + display: flex; + background: #2196f3; + align-items: baseline; + user-select: none; + justify-content: center; +} + +.bt-picker-md [role="footer"] { + float: right; + padding: 10px; +} + +.bt-picker-md [role="footer"] button.bt-button-md { + color: #2196f3; + font-weight: bold; + font-size: 13px; +} + +/* Bootstrap */ +.bt-picker-bootstrap { + border-radius: 4px; + border: 1px solid #E0E0E0; +} + +.bt-picker-bootstrap .selected { + color: #888; +} + +.bt-picker-bootstrap [role="header"] { + background: #eee; + color: #AAA; +} +@font-face { + font-family: 'gijgo-material'; + src: url('../fonts/gijgo-material.eot?235541'); + src: url('../fonts/gijgo-material.eot?235541#iefix') format('embedded-opentype'), url('../fonts/gijgo-material.ttf?235541') format('truetype'), url('../fonts/gijgo-material.woff?235541') format('woff'), url('../fonts/gijgo-material.svg?235541#gijgo-material') format('svg'); + font-weight: normal; + font-style: normal; +} + +.bt-icon { + /* use !important to prevent issues with browser extensions that change fonts */ + font-family: 'gijgo-material' !important; + font-size: 24px; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + /* Enable Ligatures ================ */ + letter-spacing: 0; + -webkit-font-feature-settings: "liga"; + -moz-font-feature-settings: "liga=1"; + -moz-font-feature-settings: "liga"; + -ms-font-feature-settings: "liga" 1; + font-feature-settings: "liga"; + -webkit-font-variant-ligatures: discretionary-ligatures; + font-variant-ligatures: discretionary-ligatures; + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.bt-icon.undo:before { + content: "\e900"; +} + +.bt-icon.vertical-align-top:before { + content: "\e901"; +} + +.bt-icon.vertical-align-center:before { + content: "\e902"; +} + +.bt-icon.vertical-align-bottom:before { + content: "\e903"; +} + +.bt-icon.arrow-dropup:before { + content: "\e904"; +} + +.bt-icon.clock:before { + content: "\e905"; +} + +.bt-icon.refresh:before { + content: "\e906"; +} + +.bt-icon.last-page:before { + content: "\e907"; +} + +.bt-icon.first-page:before { + content: "\e908"; +} + +.bt-icon.cancel:before { + content: "\e909"; +} + +.bt-icon.clear:before { + content: "\e90a"; +} + +.bt-icon.check-circle:before { + content: "\e90b"; +} + +.bt-icon.delete:before { + content: "\e90c"; +} + +.bt-icon.arrow-upward:before { + content: "\e90d"; +} + +.bt-icon.arrow-forward:before { + content: "\e90e"; +} + +.bt-icon.arrow-downward:before { + content: "\e90f"; +} + +.bt-icon.arrow-back:before { + content: "\e910"; +} + +.bt-icon.list-numbered:before { + content: "\e911"; +} + +.bt-icon.list-bulleted:before { + content: "\e912"; +} + +.bt-icon.indent-increase:before { + content: "\e913"; +} + +.bt-icon.indent-decrease:before { + content: "\e914"; +} + +.bt-icon.redo:before { + content: "\e915"; +} + +.bt-icon.align-right:before { + content: "\e916"; +} + +.bt-icon.align-left:before { + content: "\e917"; +} + +.bt-icon.align-justify:before { + content: "\e918"; +} + +.bt-icon.align-center:before { + content: "\e919"; +} + +.bt-icon.strikethrough:before { + content: "\e91a"; +} + +.bt-icon.italic:before { + content: "\e91b"; +} + +.bt-icon.underlined:before { + content: "\e91c"; +} + +.bt-icon.bold:before { + content: "\e91d"; +} + +.bt-icon.arrow-dropdown:before { + content: "\e91e"; +} + +.bt-icon.done:before { + content: "\e91f"; +} + +.bt-icon.pencil:before { + content: "\e920"; +} + +.bt-icon.minus:before { + content: "\e921"; +} + +.bt-icon.plus:before { + content: "\e922"; +} + +.bt-icon.chevron-up:before { + content: "\e923"; +} + +.bt-icon.chevron-right:before { + content: "\e924"; +} + +.bt-icon.chevron-down:before { + content: "\e925"; +} + +.bt-icon.chevron-left:before { + content: "\e926"; +} + +.bt-icon.event:before { + content: "\e927"; +} +.bt-draggable { + cursor: move; +} +.bt-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; + -ms-touch-action: none; + touch-action: none; + z-index: 1203; +} + +.bt-resizable-n { + cursor: n-resize; + height: 7px; + width: 100%; + top: -5px; + left: 0; +} +.bt-resizable-e { + cursor: e-resize; + width: 7px; + right: -5px; + top: 0; + height: 100%; +} +.bt-resizable-s { + cursor: s-resize; + height: 7px; + width: 100%; + bottom: -5px; + left: 0; +} +.bt-resizable-w { + cursor: w-resize; + width: 7px; + left: -5px; + top: 0; + height: 100%; +} +.bt-resizable-se { + cursor: se-resize; + width: 12px; + height: 12px; + right: 1px; + bottom: 1px; +} +.bt-resizable-sw { + cursor: sw-resize; + width: 9px; + height: 9px; + left: -5px; + bottom: -5px; +} +.bt-resizable-nw { + cursor: nw-resize; + width: 9px; + height: 9px; + left: -5px; + top: -5px; +} +.bt-resizable-ne { + cursor: ne-resize; + width: 9px; + height: 9px; + right: -5px; + top: -5px; +} + +.bt-dialog-footer { + position: absolute; + bottom: 0px; + width: 100%; + margin-top: 0px; +} + +.bt-dialog-scrollable [data-role="body"] { + overflow-x: hidden; + overflow-y: scroll; +} + +/** Bootstrap 3 **/ +.bt-dialog-bootstrap { + overflow: hidden; + z-index: 1202; +} + +.bt-dialog-bootstrap [data-role="title"] { + display: inline; +} +.bt-dialog-bootstrap [data-role="close"] { + line-height: 1.42857143; +} + +/** Bootstrap 4 **/ +.bt-dialog-bootstrap4 { + overflow: hidden; + z-index: 1202; +} + +.bt-dialog-bootstrap4 [data-role="title"] { + display: inline; +} +.bt-dialog-bootstrap4 [data-role="close"] { + line-height: 1.5; +} + +/** Material Design **/ +.bt-dialog-md { + background-color: #FFF; + overflow: hidden; + border: none; + box-shadow: 0 11px 15px -7px rgba(0,0,0,.2), 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12); + box-sizing: border-box; + position: relative; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-background-clip: padding-box; + background-clip: padding-box; + outline: 0; + z-index: 1202; +} + +.bt-dialog-md-header { + padding: 24px 24px 0px 24px; + font-family: "Roboto","Helvetica","Arial",sans-serif; +} + +.bt-dialog-md-title { + margin: 0; + font-weight: 400; + display: inline; + line-height: 28px; + font-size: 20px; +} + +.bt-dialog-md-close { + -webkit-appearance: none; + padding: 0; + cursor: pointer; + background: 0 0; + border: 0; + float: right; + line-height: 28px; + font-size: 28px; +} + +.bt-dialog-md-body { + padding: 20px 24px 24px 24px; + color: rgba(0,0,0,.54); + font-family: "Helvetica","Arial",sans-serif; + font-size: 14px; + font-weight: 400; + line-height: 20px; +} + +.bt-dialog-md-footer { + padding: 8px 8px 8px 24px; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row-reverse; + -ms-flex-direction: row-reverse; + flex-direction: row-reverse; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + + box-sizing: border-box; +} + +.bt-dialog-md-footer>*:first-child { + margin-right: 0; +} + +.bt-dialog-md-footer>* { + margin-right: 8px; + height: 36px; +} +DIV.bt-grid-wrapper { + margin: auto; + position: relative; + clear:both; + z-index: 1; +} + +TABLE.bt-grid { + margin: auto; + border-collapse: collapse; + width: 100%; + table-layout: fixed; +} + +TABLE.bt-grid THEAD TH [data-role="selectAll"] { + margin: auto; +} + +TABLE.bt-grid THEAD TH [data-role="title"] { + display: inline-block; +} + +TABLE.bt-grid THEAD TH [data-role="sorticon"] { + display: inline-block; +} + +TABLE.bt-grid THEAD TH { + overflow: hidden; + text-overflow: ellipsis; +} + +TABLE.bt-grid.autogrow-header-row THEAD TH { + overflow: auto; + text-overflow: initial; + white-space: pre-wrap; + -ms-word-break: break-word; + word-break: break-word; +} + +TABLE.bt-grid > tbody > tr > td { + overflow: hidden; + position: relative; +} + +table.bt-grid tbody div[data-role="display"] { + vertical-align: middle; + text-indent: 0; + white-space: pre-wrap; + -ms-word-break: break-word; + word-break: break-word; +} + +table.bt-grid.fixed-body-rows tbody div[data-role="display"] { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + -ms-word-break: initial; + word-break: initial; +} + +table.bt-grid tfoot DIV[data-role="display"] { + vertical-align: middle; + text-indent: 0; + display: flex; +} + +TABLE.bt-grid .fa { + padding: 2px; +} + +TABLE.bt-grid > tbody > tr > td > div { + padding: 2px; + overflow: hidden; +} + +DIV.bt-grid-wrapper DIV.bt-grid-loading-cover +{ + background: #BBBBBB; + opacity: 0.5; + position: absolute; + vertical-align: middle; +} + +DIV.bt-grid-wrapper DIV.bt-grid-loading-text +{ + position: absolute; + font-weight: bold; +} + +/* Bootstrap Theme */ +table.bt-grid-bootstrap thead th { + background-color: #f5f5f5; + vertical-align:middle; +} + +table.bt-grid-bootstrap thead th [data-role="sorticon"] { + margin-left: 5px; +} + +table.bt-grid-bootstrap thead th [data-role="sorticon"] i.bt-icon, +table.bt-grid-bootstrap thead th [data-role="sorticon"] i.material-icons { + position: absolute; + font-size: 20px; + top: 15px; +} + +table.bt-grid-bootstrap tbody tr td div[data-role="display"] { + padding: 0px; +} + +.bt-grid-bootstrap-4 .bt-checkbox-bootstrap { + display: inline-block; + padding-top: 2px; +} + +/* Material Design Theme */ +.bt-grid-md { + position: relative; + border: 1px solid rgba(0,0,0,.12); + border-collapse: collapse; + white-space: nowrap; + font-size: 13px; + font-family: "Roboto","Helvetica","Arial",sans-serif; + background-color: #fff; +} + +.bt-grid-md td:first-of-type, .bt-grid-md th:first-of-type { + padding-left: 24px; +} + +.bt-grid-md th { + position: relative; + vertical-align: bottom; + font-weight: 700; + line-height: 31px; + letter-spacing: 0; + height: 56px; + font-size: 12px; + color: rgba(0,0,0,.54); + padding-bottom: 8px; + box-sizing: border-box; + padding: 12px 18px; + text-align: right; +} + +.bt-grid-md td { + position: relative; + height: 48px; + border-top: 1px solid rgba(0,0,0,.12); + border-bottom: 1px solid rgba(0,0,0,.12); + padding: 12px 18px; + box-sizing: border-box; + text-align: left; + color: rgba(0,0,0,.87); +} + +.bt-grid-md tbody tr { + position: relative; + height: 48px; + transition-duration: .28s; + transition-timing-function: cubic-bezier(.4,0,.2,1); + transition-property: background-color; +} + +.bt-grid-md tbody tr:hover { + background-color: #EEEEEE; /* Gray 200 */ +} + +.bt-grid-md tbody tr.bt-grid-md-select { + background-color: #F5F5F5; /* Grey 100 */ +} + + +table.bt-grid-md thead th [data-role="sorticon"] { + margin-left: 5px; +} + +table.bt-grid-md thead th [data-role="sorticon"] i.bt-icon, +table.bt-grid-md thead th [data-role="sorticon"] i.material-icons { + position: absolute; + font-size: 16px; + top: 19px; +} + +table.bt-grid-md thead th.bt-grid-select-all { + padding-bottom: 3px; +} +/* Hide all prioritized columns by default */ +@media only all { + th.display-1120, + td.display-1120, + th.display-960, + td.display-960, + th.display-800, + td.display-800, + th.display-640, + td.display-640, + th.display-480, + td.display-480, + th.display-320, + td.display-320 { + display: none; + } +} + +/* Show at 320px (20em x 16px) */ +@media screen and (min-width: 20em) { + TABLE.bt-grid-bootstrap th.display-320, + TABLE.bt-grid-bootstrap td.display-320 { + display: table-cell; + } +} +/* Show at 480px (30em x 16px) */ +@media screen and (min-width: 30em) { + TABLE.bt-grid-bootstrap th.display-480, + TABLE.bt-grid-bootstrap td.display-480 { + display: table-cell; + } +} +/* Show at 640px (40em x 16px) */ +@media screen and (min-width: 40em) { + TABLE.bt-grid-bootstrap th.display-640, + TABLE.bt-grid-bootstrap td.display-640 { + display: table-cell; + } +} +/* Show at 800px (50em x 16px) */ +@media screen and (min-width: 50em) { + TABLE.bt-grid-bootstrap th.display-800, + TABLE.bt-grid-bootstrap td.display-800 { + display: table-cell; + } +} +/* Show at 960px (60em x 16px) */ +@media screen and (min-width: 60em) { + TABLE.bt-grid-bootstrap th.display-960, + TABLE.bt-grid-bootstrap td.display-960 { + display: table-cell; + } +} +/* Show at 1,120px (70em x 16px) */ +@media screen and (min-width: 70em) { + TABLE.bt-grid-bootstrap th.display-1120, + TABLE.bt-grid-bootstrap td.display-1120 { + display: table-cell; + } +} + +/* Material Design Theme */ +.bt-grid-md tfoot tr th { + padding-right: 14px; +} + +.bt-grid-md tfoot tr[data-role="pager"] .bt-grid-mdl-pager-label { + padding-left: 5px; + padding-right: 5px; +} + +.bt-grid-md tfoot tr[data-role="pager"] .bt-dropdown-md { + margin-left: 12px; +} + +.bt-grid-md tfoot tr[data-role="pager"] .bt-dropdown-md [role="presenter"] { + font-size: 12px; + font-weight: bold; + color: rgba(0,0,0,.54); +} + +.bt-grid-md tfoot tr[data-role="pager"] .bt-dropdown-md [role="presenter"] [role="display"] { + text-align: right; +} + +.bt-grid-md tfoot tr[data-role="pager"] .bt-grid-md-limit-select { + margin-left: 10px; + font-size: 12px; + font-weight: bold; + color: rgba(0,0,0,.54); +} + +/* Bootstrap */ +.bt-grid-bootstrap tfoot tr[data-role="pager"] th { + line-height: 30px; + background-color: #f5f5f5; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th > div > div { + margin-right: 5px; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th > div > button { + margin-right: 5px; +} + +.bt-grid-bootstrap-4 tfoot tr[data-role="pager"] th > div button { + height: 34px; +} + +.bt-grid-bootstrap-4 tfoot tr[data-role="pager"] th div .bt-dropdown-bootstrap-4 .bt-dropdown-expander-mi .bt-icon { + top: 5px; +} + +.bt-grid-bootstrap-3 tfoot tr[data-role="pager"] th > div > input { + margin-right: 5px; + width: 40px; + text-align: right; + display: inline-block; + font-weight: bold; +} + +.bt-grid-bootstrap-4 tfoot tr[data-role="pager"] th > div > div.input-group { + width: 40px; +} + +.bt-grid-bootstrap-4 tfoot tr[data-role="pager"] th > div > div.input-group input { + text-align: right; + font-weight: bold; + height: 34px; + padding-top: 2px; + padding-bottom: 6px; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th > div > select { + display: inline-block; + margin-right: 5px; + width: 60px; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th .bt-dropdown-bootstrap .bt-list-bootstrap [data-role="display"] { + line-height: 14px; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th .bt-dropdown-bootstrap [role="presenter"] [role="display"] { + font-weight: bold; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th .bt-dropdown-bootstrap-3 [role="presenter"] { + padding: 2px 8px; +} + +.bt-grid-bootstrap tfoot tr[data-role="pager"] th .bt-dropdown-bootstrap-4 [role="presenter"] { + padding: 1px 8px; +} +.bt-grid thead tr th div.bt-grid-column-resizer-wrapper { + position: relative; + width: 100%; + height: 0px; + top: 0px; + left: 0px; + padding: 0px; +} + +span.bt-grid-column-resizer { + position: absolute; + right: 0px; + width: 10px; + top: -100px; + height: 300px; + z-index: 1202; + cursor: e-resize; +} + +.bt-grid-resize-cursor { + cursor: e-resize; +} +.bt-grid-md tbody tr.bt-grid-top-border td { + border-top: 2px solid #777; +} +.bt-grid-md tbody tr.bt-grid-bottom-border td { + border-bottom: 2px solid #777; +} + +.bt-grid-bootstrap tbody tr.bt-grid-top-border td { + border-top: 2px solid #777; +} +.bt-grid-bootstrap tbody tr.bt-grid-bottom-border td { + border-bottom: 2px solid #777; +} +.bt-grid-md thead tr th.bt-grid-left-border, +.bt-grid-md tbody tr td.bt-grid-left-border +{ + border-left: 3px solid #777; +} +.bt-grid-md thead tr th.bt-grid-right-border, +.bt-grid-md tbody tr td.bt-grid-right-border +{ + border-right: 3px solid #777; +} + +.bt-grid-bootstrap thead tr th.bt-grid-left-border, +.bt-grid-bootstrap tbody tr td.bt-grid-left-border +{ + border-left: 5px solid #ddd; +} +.bt-grid-bootstrap thead tr th.bt-grid-right-border, +.bt-grid-bootstrap tbody tr td.bt-grid-right-border +{ + border-right: 5px solid #ddd; +} +.bt-dirty { + position: absolute; + top: 0px; + left: 0px; + border-style: solid; + border-width: 3px; + border-color: #f00 transparent transparent #f00; + padding: 0; + overflow: hidden; + vertical-align: top; +} + +/* Material Design */ +.bt-grid-md tbody tr td.bt-grid-management-column { + padding: 3px; +} + +.bt-grid-md tbody tr td[data-mode="edit"] { + padding: 0px 18px; +} + +.bt-grid-md tbody .bt-dropdown-md [role="presenter"] [role="display"] { + padding: 0px; +} + +/* Bootstrap */ +.bt-grid-bootstrap tbody tr td[data-mode="edit"] { + padding: 0px; +} + +.bt-grid-bootstrap tbody tr td[data-mode="edit"] [data-role="edit"] { + padding: 0px; +} + +/* Bootstrap 3 */ +.bt-grid-bootstrap-3 tbody tr td.bt-grid-management-column { + padding: 3px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] { + height: 38px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] [data-role="edit"] input[type="text"] { + height: 37px; + padding: 8px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] .bt-dropdown-bootstrap [role="presenter"] { + border: 0px; + border-radius: 0px; + height: 37px; + padding-left: 8px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap { + height: 37px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="input"] { + height: 37px; + border:0px; + border-radius: 0px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="right-icon"] { + border:0px; + border-radius: 0px; +} + +.bt-grid-bootstrap-3 tbody tr td[data-mode="edit"] .bt-checkbox-bootstrap { + display: inline-block; + padding-top: 10px; + height: 32px; +} + +/* Bootstrap 4 */ +.bt-grid-bootstrap-4 tbody tr td.bt-grid-management-column { + padding: 6px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] [data-role="edit"] input[type="text"] { + height: 48px; + padding-left: 12px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-dropdown-bootstrap [role="presenter"] { + border: 0px; + border-radius: 0px; + height: 48px; + padding-left: 12px; + font-family: -apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-dropdown-bootstrap-4 [role="expander"].bt-dropdown-expander-mi .bt-icon, +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-dropdown-bootstrap-4 [role="expander"].bt-dropdown-expander-mi .material-icons { + top: 13px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap { + height: 48px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="input"] { + height: 48px; + border:0px; + border-radius: 0px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="right-icon"] { + background-color: #fff; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="right-icon"] button { + border: 0px; + border-radius: 0px; + width: 43px; + position: relative; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="right-icon"] .bt-icon, +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-datepicker-bootstrap [role="right-icon"] .material-icons { + top: 13px; + left: 10px; + font-size: 24px; +} + +.bt-grid-bootstrap-4 tbody tr td[data-mode="edit"] .bt-checkbox-bootstrap { + display: inline-block; + padding-top: 15px; + height: 42px; +} +.bt-grid-md thead tr[data-role="filter"] th { + border-top: 1px solid rgba(0,0,0,.12); +} + +div.bt-grid-wrapper div.bt-grid-bootstrap-toolbar { + background-color: #f5f5f5; + padding: 8px; + font-weight: bold; + border: 1px solid #ddd; +} + +div.bt-grid-wrapper div.bt-grid-bootstrap-4-toolbar { + background-color: #f5f5f5; + padding: 12px; + font-weight: bold; + border: 1px solid #ddd; +} + +div.bt-grid-wrapper div.bt-grid-md-toolbar { + font-weight: bold; + font-size: 24px; + font-family: "Helvetica","Arial",sans-serif; + background-color: rgb(255, 255, 255); + + border-top: 1px solid rgba(0,0,0,.12); + border-left: 1px solid rgba(0,0,0,.12); + border-right: 1px solid rgba(0,0,0,.12); + border-bottom: 0px; + border-collapse: collapse; + + padding: 0 18px 0px 18px; + line-height: 56px; +} +table.bt-grid-scrollable tbody { + overflow-y: auto; + overflow-x: hidden; + display: block; +} + +/* Material Design */ +table.bt-grid-md.bt-grid-scrollable { + border-bottom: 0px; +} + +table.bt-grid-md.bt-grid-scrollable tbody { + border-right: 1px solid rgba(0,0,0,.12); + border-bottom: 1px solid rgba(0,0,0,.12); +} + +table.bt-grid-md.bt-grid-scrollable tfoot { + border-bottom: 1px solid rgba(0,0,0,.12); +} + +/* Bootstrap 3 */ +table.bt-grid-bootstrap.bt-grid-scrollable { + border-bottom: 0px; +} + +table.bt-grid-bootstrap.bt-grid-scrollable tbody { + border-right: 1px solid #ddd; + border-bottom: 1px solid #ddd; +} + +table.bt-grid-bootstrap.bt-grid-scrollable tbody tr[data-role="row"]:first-child td { + border-top: 0px; +} + +table.bt-grid-bootstrap.bt-grid-scrollable tbody tr[data-role="row"] td:first-child { + border-left: 0px; +} + +table.bt-grid-bootstrap.bt-grid-scrollable tbody tr[data-role="row"] td:last-child { + border-right: 0px; +} + +table.bt-grid-bootstrap.bt-grid-scrollable tfoot { + border-bottom: 1px solid #ddd; +} + +ul.bt-list li [data-role="spacer"] { + display: table-cell; +} + +ul.bt-list li [data-role="expander"] { + display: table-cell; + vertical-align:middle; + text-align:center; + cursor: pointer; +} + +[data-type="tree"] ul li [data-role="expander"].bt-tree-material-icons-expander { + width: 24px; +} + +[data-type="tree"] ul li [data-role="expander"].bt-tree-font-awesome-expander { + width: 24px; +} + +[data-type="tree"] ul li [data-role="expander"].bt-tree-glyphicons-expander { + width: 24px; +} + +[data-type="tree"] ul li [data-role="expander"].bt-tree-glyphicons-expander .glyphicon { + top: 4px; + height: 24px; +} + +/* Bootstrap Theme */ +.bt-tree-bootstrap-3 ul.bt-list-bootstrap li { + border: 0px; + border-radius: 0px; + color: #333; +} + +.bt-tree-bootstrap-3 ul.bt-list-bootstrap li.active { + color: #fff; +} + +.bt-tree-bootstrap-3 ul.bt-list-bootstrap li.disabled { + color: #777; + background-color: #eee; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li { + border: 0px; + border-radius: 0px; + color: #212529; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li.active { + color: #fff; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li.disabled { + color: #868e96; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li ul.bt-list-bootstrap { + width: 100%; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li { + border: 1px solid #ddd; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li ul.bt-list-bootstrap li { + border-left: 0px; + border-right: 0px; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li ul.bt-list-bootstrap li:first-child { + border-top-left-radius: 0px; + border-top-right-radius: 0px; +} + +.bt-tree-bootstrap-border ul.bt-list-bootstrap li ul.bt-list-bootstrap li:last-child { + border-bottom: 0px; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; +} + +ul.bt-list-bootstrap li [data-role="expander"].bt-tree-material-icons-expander { + padding-top: 8px; + padding-bottom: 4px; +} + +ul.bt-list-bootstrap li [data-role="expander"].bt-tree-material-icons-expander .bt-icon { + width: 24px; + height: 24px; +} + +/* Material Design Theme */ +ul.bt-list-md li.disabled > [data-role="wrapper"] > [data-role="expander"] { + color: #9E9E9E; /* Gray 500 */ +} + +.bt-tree-md-border ul.bt-list-md li { + border: 1px solid #616161; /* Gray 700 */ + margin-bottom: -1px; +} + +.bt-tree-md-border ul.bt-list-md li ul.bt-list-md li { + border-left: 0px; + border-right: 0px; +} + +.bt-tree-md-border ul.bt-list-md li ul.bt-list-md li:last-child { + border-bottom: 0px; +} +.bt-tree-drop-above { + border-top: 1px solid #000; +} + +.bt-tree-drop-below { + border-bottom: 1px solid #000; +} + +.bt-tree-bootstrap-3 ul.bt-list-bootstrap li [data-role="wrapper"].drop-above { + border-top: 2px solid #000; +} + +.bt-tree-bootstrap-3 ul.bt-list-bootstrap li [data-role="wrapper"].drop-below { + border-bottom: 2px solid #000; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li [data-role="wrapper"].drop-above { + border-top: 2px solid #000; +} + +.bt-tree-bootstrap-4 ul.bt-list-bootstrap li [data-role="wrapper"].drop-below { + border-bottom: 2px solid #000; +} + +.bt-tree-drag-el { + padding: 0px; + margin: 0px; + z-index: 1203; +} + +.bt-tree-drag-el li { + padding: 0px; + margin: 0px; +} + +.bt-tree-drag-el [data-role="wrapper"] { + cursor: move; + display: table; +} + +.bt-tree-drag-el [data-role="indicator"] { + width: 14px; + padding: 0px 3px; + display: table-cell; + vertical-align: middle; + text-align: center; +} + +.bt-tree-bootstrap-drag-el li.list-group-item { + border: 0px; + background: unset; +} + +.bt-tree-bootstrap-drag-el [data-role="indicator"] { + width: 24px; + height: 24px; + padding: 0px; +} + +.bt-tree-md-drag-el [data-role="indicator"] { + width: 24px; + height: 24px; + padding: 0px; +} +/* Bootstrap */ +.bt-checkbox-bootstrap { + min-width: 0; + font-size: 0; + font-weight: normal; + margin: 0px; + text-align: center; + width: 18px; + height: 18px; + position: relative; + display: inline; +} + +.bt-checkbox-bootstrap input[type="checkbox"] { + display: none; + margin-bottom: -12px; +} + +.bt-checkbox-bootstrap span { + background: #fff; + display: block; + content: " "; + width: 18px; + height: 18px; + line-height: 11px; + font-size: 11px; + padding: 2px; + color: #555555; + border: 1px solid #CCCCCC; + border-radius: 3px; + transition: box-shadow 0.2s linear, border-color 0.2s linear; + cursor: pointer; + margin: auto; +} + +.bt-checkbox-bootstrap input[type="checkbox"]:focus + span:before { + outline: 0; + box-shadow: 0 0 0 0 #66afe9, 0 0 6px rgba(102, 175, 233, .6); + border-color: #66afe9; +} + +.bt-checkbox-bootstrap input[type="checkbox"][disabled] + span { + opacity: 0.6; + cursor: not-allowed; +} + +/* Bootstrap 4 */ +.bt-checkbox-bootstrap.bt-checkbox-bootstrap-4 span { + line-height: 16px; + padding: 0px; +} + +.bt-checkbox-bootstrap-4.bt-checkbox-material-icons input[type="checkbox"]:checked + span:after { + font-size: 16px; +} + +.bt-checkbox-bootstrap-4.bt-checkbox-material-icons input[type="checkbox"]:indeterminate + span:after { + font-size: 16px; +} + +/* Material Design */ +.bt-checkbox-md { + min-width: 0; + font-size: 0; + font-weight: normal; + margin: 0px; + text-align: center; + width: 16px; + height: 16px; + position: relative; +} + +.bt-checkbox-md input[type="checkbox"] { + display: none; + margin-bottom: -12px; +} + +.bt-checkbox-md span { + display: inline-block; + box-sizing: border-box; + width: 16px; + height: 16px; + margin: 0; + cursor: pointer; + overflow: hidden; + border: 2px solid #616161; /* Gray 700 */ + border-radius: 2px; + z-index: 2; +} + +.bt-checkbox-md input[type="checkbox"]:checked + span { + border: 2px solid #536DFE; /* Indigo A200 */ +} + +.bt-checkbox-md input[type="checkbox"]:checked + span:after { + color: #FFF; + background-color: #536DFE; /* Indigo A200 */ + position: absolute; + left: 1px; + top: -15px; +} + +.bt-checkbox-md input[type="checkbox"]:indeterminate + span { + border: 2px solid #616161; /* Gray 700 */ +} + +.bt-checkbox-md input[type="checkbox"]:indeterminate + span:after { + color: #616161;/*color: rgba(0, 0, 0, 1);*/ + position: absolute; + left: 1px; + top: -15px; +} + +.bt-checkbox-md input[type="checkbox"][disabled] + span { + border: 2px solid #9E9E9E; +} + +.bt-checkbox-md input[type="checkbox"][disabled] + span:after { + background-color: #9E9E9E; +} + +.bt-checkbox-md input[type="checkbox"][disabled]:indeterminate + span:after { + color: #FFFFFF; +} + +/* Material Icons */ +.bt-checkbox-material-icons input[type="checkbox"]:checked + span:after { + content: "\e91f"; + font-size: 14px; + font-weight: bold; + white-space: pre; +} + +.bt-checkbox-material-icons input[type="checkbox"]:indeterminate + span:after { + content: "\e921"; + font-size: 14px; + font-weight: bold; + white-space: pre; +} + +/* Glyphicons */ +.bt-checkbox-glyphicons input[type="checkbox"]:checked + span:after { + display: inline-block; + font-family: 'Glyphicons Halflings'; + content: "\e013 "; +} + +.bt-checkbox-glyphicons input[type="checkbox"]:indeterminate + span:after { + display: inline-block; + font-family: 'Glyphicons Halflings'; + content: "\2212 "; + padding-right: 1px; +} + +/* fontawesome */ +.bt-checkbox-fontawesome .fa { + font-size: 14px; +} + +.bt-checkbox-fontawesome input[type="checkbox"]:checked + span:before { + content: "\f00c "; +} + +.bt-checkbox-fontawesome input[type="checkbox"]:indeterminate + span:before { + content: "\f068 "; +} +.bt-editor [role="body"] { + overflow: auto; + outline: 0px solid transparent; + box-sizing: border-box; +} + +/* Material Design */ +.bt-editor-md { + padding: 7px; + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 14px; + font-weight: 500; + letter-spacing: 0; + border: 1px solid rgba(158,158,158,.2); +} + +.bt-editor-md [role="toolbar"] { + margin-bottom: 7px; +} + +.bt-editor-md [role="toolbar"] .bt-button-md { + min-width: 54px; + margin-right: 5px; +} + +.bt-editor-md [role="toolbar"] .bt-button-md .bt-icon { + width: 24px; + height: 24px; +} + +.bt-editor-md [role="body"] { + border: 1px solid rgba(158,158,158,.2); +} + +.bt-editor-md p { + margin: 0; + padding: 0; +} + +.bt-editor-md blockquote { + font-size: 14px; +} + +/* Bootstrap */ +.bt-editor-bootstrap { + padding: 7px; + border: 1px solid #eceeef; +} + +.bt-editor-bootstrap [role="toolbar"] { + margin-bottom: 7px; +} + +.bt-editor-bootstrap [role="toolbar"] .btn-group { + margin-right: 10px; +} + +.bt-editor-bootstrap [role="toolbar"] button { + height: 36px; +} + +.bt-editor-bootstrap [role="body"] { + border: 1px solid #eceeef; +} + +.bt-editor-bootstrap p { + margin: 0; + padding: 0; +} + +.bt-editor-bootstrap blockquote { + font-size: 14px; +} +.bt-dropdown { + position: relative; + border-collapse: separate; +} + +.bt-dropdown [role="presenter"] { + display: table; + cursor: pointer; + outline: none; + position: relative; +} + +.bt-dropdown [role="presenter"] [role="display"] { + display: table-cell; + text-align: left; + width: 100%; +} + +.bt-dropdown [role="presenter"] [role="expander"] { + display: table-cell; + vertical-align:middle; + text-align:center; + width: 24px; + height: 24px; +} + +/* Material Design */ +.bt-dropdown-md [role="presenter"] { + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: .04em; + line-height: 1; + color: rgba(0,0,0,.87); + padding: 0px; + border: 0px; + border-bottom: 1px solid rgba(0,0,0,.42); + background: transparent; +} + +.bt-dropdown-md [role="presenter"]:focus, +.bt-dropdown-md [role="presenter"]:active { + border-bottom: 2px solid rgba(0,0,0,.42); +} + +.bt-dropdown-md [role="presenter"] [role="display"] { + padding: 4px 0px; + line-height: 18px; +} + +.bt-dropdown-md [role="presenter"] [role="display"] .placeholder { + color: #8e8e8e; +} + +.bt-dropdown-list-md { + position: absolute; + top: 0px; + left: 0px; + background-color: #f5f5f5; + color: #000; + margin: 0px; + z-index: 1202; +} + +.bt-dropdown-list-md li:hover, .bt-dropdown-list-md li.active { + background-color: #eee; +} + +/* Bootstrap */ +.bt-dropdown-bootstrap [role="presenter"] [role="display"] { + padding-right: 5px; +} + +.bt-dropdown-bootstrap [role="presenter"] [role="expander"] { + padding-left: 5px; +} + +.bt-dropdown-bootstrap [role="presenter"] [role="expander"].bt-dropdown-expander-mi { + width: 24px; +} + +.bt-dropdown-bootstrap-3 [role="presenter"] [role="display"] { + line-height: 20px; +} + +.bt-dropdown-bootstrap-3 [role="presenter"] [role="display"] .placeholder { + color: #9999b3; +} + +.bt-dropdown-bootstrap-3 [role="presenter"] [role="expander"] { + width: 20px; + height: 20px; +} + +.bt-dropdown-bootstrap-3 [role="presenter"] [role="expander"].bt-dropdown-expander-mi .bt-icon, +.bt-dropdown-bootstrap-3 [role="presenter"] [role="expander"].bt-dropdown-expander-mi .material-icons { + top: 5px; + right: 10px; + position: absolute; +} + +.bt-dropdown-bootstrap-4 [role="presenter"] { + border: 1px solid #ced4da; +} + +.bt-dropdown-bootstrap-4 [role="presenter"] [role="display"] { + line-height: 24px; +} + +.bt-dropdown-bootstrap-4 [role="presenter"] [role="expander"].bt-dropdown-expander-mi .bt-icon, +.bt-dropdown-bootstrap-4 [role="presenter"] [role="expander"].bt-dropdown-expander-mi .material-icons { + top: 7px; + right: 10px; + position: absolute; +} + +.bt-dropdown-list-bootstrap { + position: absolute; + top: 32px; + left: 0px; + margin: 0px; + z-index: 1202; +} +.bt-datepicker [role="input"]::-ms-clear { + display: none; +} + +.bt-datepicker [role="right-icon"] { + cursor: pointer; +} + +.bt-picker div[role="navigator"] { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; +} + +.bt-picker div[role="navigator"] div { + cursor: pointer; + position: relative; + flex-basis: 0; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; + max-width: 100%; +} + +.bt-picker div[role="navigator"] div[role="period"] { + width: 100%; + text-align: center; +} + +/* Material Design */ +.bt-datepicker-md { + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: .04em; + line-height: 1; + color: rgba(0,0,0,.87); + position: relative; +} + +.bt-datepicker-md [role="right-icon"] { + cursor: pointer; + position: absolute; + right: 0px; + top: 0px; + font-size: 24px; +} + +.bt-datepicker-md.small .bt-textbox-md { + font-size: 14px; +} + +.bt-datepicker-md.small .bt-icon { + font-size: 22px; +} + +.bt-datepicker-md.large .bt-textbox-md { + font-size: 18px; +} + +.bt-datepicker-md.large .bt-icon { + font-size: 28px; +} + +.bt-picker-md.datepicker [role="header"] { + padding: 20px 20px; + display: block; +} + +.bt-picker-md.datepicker [role="header"] [role="year"] { + font-size: 17px; + padding-bottom: 5px; + cursor: pointer; +} + +.bt-picker-md.datepicker [role="header"] [role="date"] { + font-size: 36px; + cursor: pointer; +} + +.bt-picker-md div[role="navigator"] { + height: 42px; + line-height: 42px; +} + +.bt-picker div[role="navigator"] div[role="period"] { + font-weight: bold; + font-size: 15px; +} + +.bt-picker-md div[role="navigator"] div:first-child { + max-width: 42px; +} + +.bt-picker-md div[role="navigator"] div:last-child { + max-width: 42px; +} + +.bt-picker-md div[role="navigator"] div i.bt-icon, +.bt-picker-md div[role="navigator"] div i.material-icons { + position: absolute; + top: 8px; +} + +.bt-picker-md div[role="navigator"] div:first-child i.bt-icon, +.bt-picker-md div[role="navigator"] div:first-child i.material-icons { + left: 10px; +} + +.bt-picker-md div[role="navigator"] div:last-child i.bt-icon, +.bt-picker-md div[role="navigator"] div:last-child i.material-icons { + right: 11px; +} + +.bt-picker-md table thead { + color: #9E9E9E; /* Gray 500 */ +} + +.bt-picker-md table tr th div, +.bt-picker-md table tr td div { + display: block; + width: 40px; + height: 40px; + line-height: 40px; + font-size: 13px; + text-align: center; + vertical-align: middle; +} + +[type="year"].bt-picker-md table tr td div, +[type="decade"].bt-picker-md table tr td div, +[type="century"].bt-picker-md table tr td div { + width: 73px; + height: 73px; + line-height: 73px; + cursor: pointer; +} + +.bt-picker-md table tr td.bt-cursor-pointer div:hover { + background: #EEEEEE; + border-radius: 50%; + color: rgba(0,0,0,.87); +} + +.bt-picker-md table tr td.other-month div, +.bt-picker-md table tr td.disabled div { + color: #BDBDBD; /* Gray 400 */ +} + +.bt-picker-md table tr td.focused div { + background: #E0E0E0; /* Gray 300 */ + border-radius: 50%; +} + +.bt-picker-md table tr td.today div { + color: #1976D2; +} + +.bt-picker-md table tr td.selected.bt-cursor-pointer div { + color: #FFFFFF; + background: #1976D2; /* Blue 700 */ + border-radius: 50%; +} + +.bt-picker-md table tr td.calendar-week div { + font-weight: bold; +} + +/* Bootstrap */ +.bt-datepicker-bootstrap :focus, +.bt-datepicker-bootstrap :active { + box-shadow: none; +} + +.bt-picker-bootstrap { + border: 1px solid rgba(0,0,0,0.15); + border-radius: 4px; + padding: 4px; +} + +.bt-modal .bt-picker-bootstrap { + padding: 0px; +} + +.bt-picker-bootstrap.datepicker [role="header"] { + padding: 10px 20px; + display: block; +} + +.bt-picker-bootstrap.datepicker [role="header"] [role="year"] { + font-size: 15px; + cursor: pointer; +} + +.bt-picker-bootstrap [role="header"] [role="date"] { + font-size: 24px; + cursor: pointer; +} + +.bt-modal .bt-picker-bootstrap.datepicker [role="body"] { + padding: 15px; +} + +.bt-picker-bootstrap div[role="navigator"] { + height: 30px; + line-height: 30px; + text-align: center; +} + +.bt-picker-bootstrap div[role="navigator"] div:first-child { + max-width: 30px; +} + +.bt-picker-bootstrap div[role="navigator"] div:last-child { + max-width: 30px; +} + +.bt-picker-bootstrap table tr td div, +.bt-picker-bootstrap table tr th div { + display: block; + width: 30px; + height: 30px; + line-height: 30px; + text-align: center; + vertical-align: middle; +} + +[type="year"].bt-picker-bootstrap table tr td div, +[type="decade"].bt-picker-bootstrap table tr td div, +[type="century"].bt-picker-bootstrap table tr td div { + width: 53px; + height: 53px; + line-height: 53px; + cursor: pointer; +} + +.bt-picker-bootstrap table tr th div i, +.bt-picker-bootstrap table tr th div span { + line-height: 30px; +} + +.bt-picker-bootstrap div[role="navigator"] .bt-icon, +.bt-picker-bootstrap div[role="navigator"] .material-icons { + margin: 3px; +} + +.bt-picker-bootstrap table tr td.focused div, +.bt-picker-bootstrap table tr td.bt-cursor-pointer div:hover { + background: #EEEEEE; + border-radius: 4px; + color: #212529; +} + +.bt-picker-bootstrap table tr td.today div { + color: #204d74; + font-weight: bold; +} + +.bt-picker-bootstrap table tr td.selected.bt-cursor-pointer div { + color: #fff; + background-color: #204d74; + border-color: #122b40; + border-radius: 4px; +} + +.bt-picker-bootstrap table tr td.other-month div, +.bt-picker-bootstrap table tr td.disabled div { + color: #777; +} + +/* Bootstrap 3 */ +.bt-datepicker-bootstrap span[role="right-icon"].input-group-addon { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + border-left: 0px; + position: relative; + /*width: 38px;*/ +} + +.bt-datepicker-bootstrap span[role="right-icon"].input-group-addon .bt-icon, +.bt-datepicker-bootstrap span[role="right-icon"].input-group-addon .material-icons { + position: absolute; + top: 7px; + left: 7px; +} + +/* Bootstrap 4 */ +.bt-datepicker-bootstrap [role="right-icon"] button { + width: 38px; + position: relative; + border: 1px solid #ced4da; +} + +.bt-datepicker-bootstrap [role="right-icon"] button:hover { + color: #6c757d; + background-color: transparent; +} + +.bt-datepicker-bootstrap.input-group-sm [role="right-icon"] button { + width: 30px; +} + +.bt-datepicker-bootstrap.input-group-lg [role="right-icon"] button { + width: 48px; +} + +.bt-datepicker-bootstrap [role="right-icon"] button .bt-icon, +.bt-datepicker-bootstrap [role="right-icon"] button .material-icons { + position: absolute; + font-size: 21px; + top: 9px; + left: 9px; +} + +.bt-datepicker-bootstrap.input-group-sm [role="right-icon"] button .bt-icon, +.bt-datepicker-bootstrap.input-group-sm [role="right-icon"] button .material-icons { + top: 6px; + left: 6px; + font-size: 19px; +} + +.bt-datepicker-bootstrap.input-group-lg [role="right-icon"] button .bt-icon, +.bt-datepicker-bootstrap.input-group-lg [role="right-icon"] button .material-icons { + font-size: 27px; + top: 10px; + left: 10px; +} +.bt-timepicker [role="input"]::-ms-clear { + display: none; +} + +.bt-timepicker [role="right-icon"] { + cursor: pointer; +} + +.bt-picker.timepicker [role="header"] { + font-size: 58px; + padding: 20px 0; + line-height: 58px; + + display: flex; + align-items: baseline; + user-select: none; + justify-content: center; +} + +.bt-picker.timepicker [role="header"] div { + cursor: pointer; + width: 66px; + text-align: right; +} + +.bt-picker [role="header"] [role="mode"] { + position: relative; + width: 0px; +} + +.bt-picker [role="header"] [role="mode"] span { + position: absolute; + left: 7px; + line-height: 18px; + font-size: 18px; +} + +.bt-picker [role="header"] [role="mode"] span[role="am"] { + top: 7px; +} + +.bt-picker [role="header"] [role="mode"] span[role="pm"] { + bottom: 7px; +} + +.bt-picker [role="body"] [role="dial"] { + width: 256px; + color: rgba(0, 0, 0, 0.87); + height: 256px; + position: relative; + background: #eeeeee; + border-radius: 50%; + margin: 10px; +} + +.bt-picker [role="body"] [role="hour"] { + top: calc(50% - 16px); + left: calc(50% - 16px); + width: 32px; + height: 32px; + cursor: pointer; + position: absolute; + font-size: 14px; + text-align: center; + line-height: 32px; + user-select: none; + pointer-events: none; +} + +.bt-picker [role="body"] [role="hour"].selected { + color: rgba(255, 255, 255, 1); +} + +.bt-picker [role="body"] [role="arrow"] { + top: calc(50% - 1px); + left: 50%; + width: calc(50% - 20px); + height: 2px; + position: absolute; + pointer-events: none; + transform-origin: left center; + transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1); + width: calc(50% - 52px); +} + +.bt-picker .arrow-begin { + top: -3px; + left: -4px; + width: 8px; + height: 8px; + position: absolute; + border-radius: 50%; +} + +.bt-picker .arrow-end { + top: -15px; + right: -16px; + width: 0; + height: 0; + position: absolute; + box-sizing: content-box; + border-width: 16px; + border-radius: 50%; +} + +/* Material Design */ +.bt-timepicker-md { + font-family: "Roboto","Helvetica","Arial",sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: .04em; + line-height: 1; + color: rgba(0,0,0,.87); + position: relative; +} + +.bt-timepicker-md.small .bt-textbox-md { + font-size: 14px; +} + +.bt-timepicker-md.small .bt-icon { + font-size: 22px; +} + +.bt-timepicker-md.large .bt-textbox-md { + font-size: 18px; +} + +.bt-timepicker-md.large .bt-icon { + font-size: 28px; +} + +.bt-timepicker-md [role="right-icon"] { + cursor: pointer; + position: absolute; + right: 0px; + top: 0px; + font-size: 24px; +} + +.bt-picker-md .arrow-begin { + background-color: #2196f3; +} +.bt-picker-md .arrow-end { + border: 16px solid #2196f3; +} + +.bt-picker-md [role="body"] [role="arrow"] { + background-color: #2196f3; +} + +/* Bootstrap */ +.bt-timepicker-bootstrap :focus, +.bt-timepicker-bootstrap :active { + box-shadow: none; +} + +.bt-picker-bootstrap [role="body"] [role="arrow"] { + background-color: #888; +} + +.bt-picker-bootstrap .arrow-begin { + background-color: #888; +} + +.bt-picker-bootstrap .arrow-end { + border: 16px solid #888; +} + +/* Bootstrap 3 */ +.bt-timepicker-bootstrap .input-group-addon { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + border-left: 0px; + position: relative; + width: 38px; +} + +.bt-timepicker-bootstrap.input-group-sm .input-group-addon { + width: 30px; +} + +.bt-timepicker-bootstrap.input-group-lg .input-group-addon { + width: 46px; +} + +.bt-timepicker-bootstrap .input-group-addon .bt-icon, +.bt-timepicker-bootstrap .input-group-addon .material-icons { + position: absolute; + font-size: 21px; + top: 6px; + left: 8px; +} + +.bt-timepicker-bootstrap.input-group-sm .input-group-addon .bt-icon, +.bt-timepicker-bootstrap.input-group-sm .input-group-addon .material-icons { + font-size: 19px; + top: 5px; + left: 5px; +} + +.bt-timepicker-bootstrap.input-group-lg .input-group-addon .bt-icon, +.bt-timepicker-bootstrap.input-group-lg .input-group-addon .material-icons { + font-size: 27px; + top: 10px; + left: 10px; +} + +/* Bootstrap 4 */ +.bt-timepicker-bootstrap [role="right-icon"] button { + width: 38px; + position: relative; +} + +.bt-timepicker-bootstrap.input-group-sm [role="right-icon"] button { + width: 30px; +} + +.bt-timepicker-bootstrap.input-group-lg [role="right-icon"] button { + width: 48px; +} + +.bt-timepicker-bootstrap [role="right-icon"] button .bt-icon, +.bt-timepicker-bootstrap [role="right-icon"] button .material-icons { + position: absolute; + font-size: 21px; + top: 7px; + left: 9px; +} + +.bt-timepicker-bootstrap.input-group-sm [role="right-icon"] button .bt-icon, +.bt-timepicker-bootstrap.input-group-sm [role="right-icon"] button .material-icons { + top: 4px; + left: 6px; + font-size: 19px; +} + +.bt-timepicker-bootstrap.input-group-lg [role="right-icon"] button .bt-icon, +.bt-timepicker-bootstrap.input-group-lg [role="right-icon"] button .material-icons { + font-size: 27px; + top: 8px; + left: 10px; +} +.bt-picker.datetimepicker [role="header"] [role="date"] { + padding-bottom: 5px; + text-align: center; + cursor: pointer; +} + +.bt-picker [role="switch"] { + align-items: baseline; + user-select: none; + position: relative; +} + +.bt-picker [role="switch"] [role="calendarMode"] { + cursor: pointer; + position: absolute; + bottom: 2px; + left: 0px; +} + +.bt-picker [role="switch"] [role="time"] { + width: 100%; + text-align: center; +} + +.bt-picker [role="switch"] [role="time"] div { + display: inline; + cursor: pointer; +} + +.bt-picker [role="switch"] [role="calendarMode"] { + cursor: pointer; +} + +.bt-picker [role="switch"] [role="clockMode"] { + position: absolute; + right: 0px; + bottom: 3px; + cursor: pointer; +} + +/* Material Design */ +.bt-picker-md.datetimepicker [role="header"] { + font-size: 36px; + padding: 10px 20px; + display: block; +} + +.bt-picker-md [role="switch"] { + color: rgba(255, 255, 255, 0.54); + background: #2196f3; + font-size: 32px; +} + +/* Bootstrap */ +.bt-picker-bootstrap.datetimepicker [role="header"] { + font-size: 36px; + padding: 10px 20px; + display: block; +} + +.bt-picker-bootstrap.datetimepicker [role="header"] [role="time"] { + font-size: 22px; +} + +.bt-slider { + position: relative; + padding: 8px 6px; +} + +.bt-slider [role="track"] { + width: 100%; +} + +.bt-slider [role="progress"] { + position: absolute; + z-index: 1001; +} + +.bt-slider [role="handle"] { + position: absolute; +} + +.bt-slider-md [role="track"] { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + color: #fff; + text-align: center; + background-color: #e9ecef; + height: 2px; + background-color: rgba(0,0,0,.26); +} + +.bt-slider-md [role="progress"] { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + color: #fff; + text-align: center; + height: 2px; + background-color: #536DFE; /* Indigo A200 */ + top: 8px; + left: 6px; +} + +.bt-slider-md [role="handle"] { + top: 3px; + left: 0px; + width: 12px; + height: 12px; + background-color: #536DFE; /* Indigo A200 */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0); + filter: none; + -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); + box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); + border: 0px solid transparent; + border-radius: 50%; + cursor: pointer; + z-index: 1002; +} + +/* Bootstrap */ +.bt-slider-bootstrap [role="track"] { + border-radius: 4px; + height: 10px; +} + +.bt-slider-bootstrap [role="progress"] { + height: 10px; + border-radius: 4px; + top: 8px; + left: 6px; + transition: none; +} + +.bt-slider-bootstrap [role="handle"] { + top: 2px; + left: 0px; + width: 20px; + height: 20px; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0); + filter: none; + -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); + box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); + border: 0px solid transparent; + border-radius: 50%; + cursor: pointer; + z-index: 1002; +} + +.bt-slider-bootstrap-3 [role="handle"] { + background-color: #337ab7; + background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%); + background-image: -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%); + background-image: linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%); + background-repeat: repeat-x; +} + +.bt-slider-bootstrap-4 [role="handle"] { + background-color: #007bff; + background-image: -webkit-linear-gradient(top, #007bff 0%, #2e6da4 100%); + background-image: -o-linear-gradient(top, #007bff 0%, #2e6da4 100%); + background-image: linear-gradient(to bottom, #007bff 0%, #2e6da4 100%); + background-repeat: repeat-x; +} \ No newline at end of file diff --git a/dist/bootree.js b/dist/bootree.js new file mode 100644 index 0000000..85b427d --- /dev/null +++ b/dist/bootree.js @@ -0,0 +1,16962 @@ +/* + * BooTree JavaScript Library v1.9.6 + * https://jaideepghosh.github.io/BooTree/ + * + */ +var bt = {}; + +bt.widget = function () { + var self = this; + + self.xhr = null; + + self.generateGUID = function () { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); + }; + + self.mouseX = function (e) { + if (e) { + if (e.pageX) { + return e.pageX; + } else if (e.clientX) { + return e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); + } else if (e.touches && e.touches.length) { + return e.touches[0].pageX; + } else if (e.changedTouches && e.changedTouches.length) { + return e.changedTouches[0].pageX; + } else if (e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length) { + return e.originalEvent.touches[0].pageX; + } else if (e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches.length) { + return e.originalEvent.touches[0].pageX; + } + } + return null; + }; + + self.mouseY = function (e) { + if (e) { + if (e.pageY) { + return e.pageY; + } else if (e.clientY) { + return e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); + } else if (e.touches && e.touches.length) { + return e.touches[0].pageY; + } else if (e.changedTouches && e.changedTouches.length) { + return e.changedTouches[0].pageY; + } else if (e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length) { + return e.originalEvent.touches[0].pageY; + } else if (e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches.length) { + return e.originalEvent.touches[0].pageY; + } + } + return null; + }; +}; + +bt.widget.prototype.init = function (jsConfig, type) { + var option, clientConfig, fullConfig; + + this.attr('data-type', type); + clientConfig = $.extend(true, {}, this.getHTMLConfig() || {}); + $.extend(true, clientConfig, jsConfig || {}); + fullConfig = this.getConfig(clientConfig, type); + this.attr('data-guid', fullConfig.guid); + this.data(fullConfig); + + // Initialize events configured as options + for (option in fullConfig) { + if (bt[type].events.hasOwnProperty(option)) { + this.on(option, fullConfig[option]); + delete fullConfig[option]; + } + } + + // Initialize all plugins + for (plugin in bt[type].plugins) { + if (bt[type].plugins.hasOwnProperty(plugin)) { + bt[type].plugins[plugin].configure(this, fullConfig, clientConfig); + } + } + + return this; +}; + +bt.widget.prototype.getConfig = function (clientConfig, type) { + var config, uiLibrary, iconsLibrary, plugin; + + config = $.extend(true, {}, bt[type].config.base); + + uiLibrary = clientConfig.hasOwnProperty('uiLibrary') ? clientConfig.uiLibrary : config.uiLibrary; + if (bt[type].config[uiLibrary]) { + $.extend(true, config, bt[type].config[uiLibrary]); + } + + iconsLibrary = clientConfig.hasOwnProperty('iconsLibrary') ? clientConfig.iconsLibrary : config.iconsLibrary; + if (bt[type].config[iconsLibrary]) { + $.extend(true, config, bt[type].config[iconsLibrary]); + } + + for (plugin in bt[type].plugins) { + if (bt[type].plugins.hasOwnProperty(plugin)) { + $.extend(true, config, bt[type].plugins[plugin].config.base); + if (bt[type].plugins[plugin].config[uiLibrary]) { + $.extend(true, config, bt[type].plugins[plugin].config[uiLibrary]); + } + if (bt[type].plugins[plugin].config[iconsLibrary]) { + $.extend(true, config, bt[type].plugins[plugin].config[iconsLibrary]); + } + } + } + + $.extend(true, config, clientConfig); + + if (!config.guid) { + config.guid = this.generateGUID(); + } + + return config; +} + +bt.widget.prototype.getHTMLConfig = function () { + var result = this.data(), + attrs = this[0].attributes; + if (attrs['width']) { + result.width = attrs['width'].value; + } + if (attrs['height']) { + result.height = attrs['height'].value; + } + if (attrs['value']) { + result.value = attrs['value'].value; + } + if (attrs['align']) { + result.align = attrs['align'].value; + } + if (result && result.source) { + result.dataSource = result.source; + delete result.source; + } + return result; +}; + +bt.widget.prototype.createDoneHandler = function () { + var $widget = this; + return function (response) { + if (typeof (response) === 'string' && JSON) { + response = JSON.parse(response); + } + bt[$widget.data('type')].methods.render($widget, response); + }; +}; + +bt.widget.prototype.createErrorHandler = function () { + var $widget = this; + return function (response) { + if (response && response.statusText && response.statusText !== 'abort') { + alert(response.statusText); + } + }; +}; + +bt.widget.prototype.reload = function (params) { + var ajaxOptions, result, data = this.data(), type = this.data('type'); + if (data.dataSource === undefined) { + bt[type].methods.useHtmlDataSource(this, data); + } + $.extend(data.params, params); + if ($.isArray(data.dataSource)) { + result = bt[type].methods.filter(this); + bt[type].methods.render(this, result); + } else if (typeof(data.dataSource) === 'string') { + ajaxOptions = { url: data.dataSource, data: data.params }; + if (this.xhr) { + this.xhr.abort(); + } + this.xhr = $.ajax(ajaxOptions).done(this.createDoneHandler()).fail(this.createErrorHandler()); + } else if (typeof (data.dataSource) === 'object') { + if (!data.dataSource.data) { + data.dataSource.data = {}; + } + $.extend(data.dataSource.data, data.params); + ajaxOptions = $.extend(true, {}, data.dataSource); //clone dataSource object + if (ajaxOptions.dataType === 'json' && typeof(ajaxOptions.data) === 'object') { + ajaxOptions.data = JSON.stringify(ajaxOptions.data); + } + if (!ajaxOptions.success) { + ajaxOptions.success = this.createDoneHandler(); + } + if (!ajaxOptions.error) { + ajaxOptions.error = this.createErrorHandler(); + } + if (this.xhr) { + this.xhr.abort(); + } + this.xhr = $.ajax(ajaxOptions); + } + return this; +} + +bt.documentManager = { + events: {}, + + subscribeForEvent: function (eventName, widgetId, callback) { + if (!bt.documentManager.events[eventName] || bt.documentManager.events[eventName].length === 0) { + bt.documentManager.events[eventName] = [{ widgetId: widgetId, callback: callback }]; + $(document).on(eventName, bt.documentManager.executeCallbacks); + } else if (!bt.documentManager.events[eventName][widgetId]) { + bt.documentManager.events[eventName].push({ widgetId: widgetId, callback: callback }); + } else { + throw 'Event ' + eventName + ' for widget with guid="' + widgetId + '" is already attached.'; + } + }, + + executeCallbacks: function (e) { + var callbacks = bt.documentManager.events[e.type]; + if (callbacks) { + for (var i = 0; i < callbacks.length; i++) { + callbacks[i].callback(e); + } + } + }, + + unsubscribeForEvent: function (eventName, widgetId) { + var success = false, + events = bt.documentManager.events[eventName]; + if (events) { + for (var i = 0; i < events.length; i++) { + if (events[i].widgetId === widgetId) { + events.splice(i, 1); + success = true; + if (events.length === 0) { + $(document).off(eventName); + delete bt.documentManager.events[eventName]; + } + } + } + } + if (!success) { + throw 'The "' + eventName + '" for widget with guid="' + widgetId + '" can\'t be removed.'; + } + } +}; + +/** + * @widget Core + * @plugin Base + */ +bt.core = { + messages: { + 'en-us': { + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], + monthShortNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + weekDaysMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], + weekDaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + weekDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + am: 'AM', + pm: 'PM', + ok: 'Ok', + cancel: 'Cancel' + } + }, + + /** + * @method + * @example String.1 + *
+ * + * @example String.2 + *
+ * + * @example String.dd.mmm.yyyy + *
+ * + * @example String.dd.mmmm.yyyy + *
+ * + * @example String.HH:MM + *
+ * + * @example ASP.NET.JSON.Date + *
+ * + * @example UNIX.Timestamp + *
+ * + */ + parseDate: function (value, format, locale) { + var i, year = 0, month = 0, date = 0, hour = 0, minute = 0, dateParts, formatParts, result; + + if (value && typeof value === 'string') { + if (/^\d+$/.test(value)) { + result = new Date(value); + } else if (value.indexOf('/Date(') > -1) { + result = new Date(parseInt(value.substr(6), 10)); + } else if (value) { + dateParts = value.split(/[\s,-\.//\:]+/); + formatParts = format.split(/[\s,-\.//\:]+/); + for (i = 0; i < formatParts.length; i++) { + if (['d', 'dd'].indexOf(formatParts[i]) > -1) { + date = parseInt(dateParts[i], 10); + } else if (['m', 'mm'].indexOf(formatParts[i]) > -1) { + month = parseInt(dateParts[i], 10) - 1; + } else if ('mmm' === formatParts[i]) { + month = bt.core.messages[locale || 'en-us'].monthShortNames.indexOf(dateParts[i]); + } else if ('mmmm' === formatParts[i]) { + month = bt.core.messages[locale || 'en-us'].monthNames.indexOf(dateParts[i]); + } else if (['yy', 'yyyy'].indexOf(formatParts[i]) > -1) { + year = parseInt(dateParts[i], 10); + if (formatParts[i] === 'yy') { + year += 2000; + } + } else if (['h', 'hh', 'H', 'HH'].indexOf(formatParts[i]) > -1) { + hour = parseInt(dateParts[i], 10); + } else if (['M', 'MM'].indexOf(formatParts[i]) > -1) { + minute = parseInt(dateParts[i], 10); + } + } + result = new Date(year, month, date, hour, minute); + } + } else if (typeof value === 'number') { + result = new Date(value); + } else if (value instanceof Date) { + result = value; + } + + return result; + }, + + /** + * @method + * @example Sample.1 + *
+ * + * @example Sample.2 + *
+ * + * @example Sample.dd.mmm.yyyy + *
+ * + * @example Sample.dd.mmmm.yyyy + *
+ * + * @example Sample.5 + *
+ * + * @example Sample.6 + *
+ * + * @example Short.WeekDay + *
+ * + * @example Full.WeekDay + *
+ * + */ + formatDate: function (date, format, locale) { + var result = '', separator, tmp, + formatParts = format.split(/[\s,-\.//\:]+/), + separators = format.split(/s+|M+|H+|h+|t+|T+|d+|m+|y+/); + + separators = separators.splice(1, separators.length - 2); + + for (i = 0; i < formatParts.length; i++) { + separator = (separators[i] || ''); + switch (formatParts[i]) { + case 's': + result += date.getSeconds() + separator; + break; + case 'ss': + result += bt.core.pad(date.getSeconds()) + separator; + break; + case 'M': + result += date.getMinutes() + separator; + break; + case 'MM': + result += bt.core.pad(date.getMinutes()) + separator; + break; + case 'H': + result += date.getHours() + separator; + break; + case 'HH': + result += bt.core.pad(date.getHours()) + separator; + break; + case 'h': + tmp = date.getHours() > 12 ? date.getHours() % 12 : date.getHours(); + result += tmp + separator; + break; + case 'hh': + tmp = date.getHours() > 12 ? date.getHours() % 12 : date.getHours(); + result += bt.core.pad(tmp) + separator; + break; + case 'tt': + result += (date.getHours() >= 12 ? 'pm' : 'am') + separator; + break; + case 'TT': + result += (date.getHours() >= 12 ? 'PM' : 'AM') + separator; + break; + case 'd': + result += date.getDate() + separator; + break; + case 'dd': + result += bt.core.pad(date.getDate()) + separator; + break; + case 'ddd': + result += bt.core.messages[locale || 'en-us'].weekDaysShort[date.getDay()] + separator; + break; + case 'dddd': + result += bt.core.messages[locale || 'en-us'].weekDays[date.getDay()] + separator; + break; + case 'm' : + result += (date.getMonth() + 1) + separator; + break; + case 'mm': + result += bt.core.pad(date.getMonth() + 1) + separator; + break; + case 'mmm': + result += bt.core.messages[locale || 'en-us'].monthShortNames[date.getMonth()] + separator; + break; + case 'mmmm': + result += bt.core.messages[locale || 'en-us'].monthNames[date.getMonth()] + separator; + break; + case 'yy' : + result += date.getFullYear().toString().substr(2) + separator; + break; + case 'yyyy': + result += date.getFullYear() + separator; + break; + } + } + + return result; + }, + + pad: function (val, len) { + val = String(val); + len = len || 2; + while (val.length < len) { + val = '0' + val; + } + return val; + }, + + center: function ($dialog) { + var left = ($(window).width() / 2) - ($dialog.width() / 2), + top = ($(window).height() / 2) - ($dialog.height() / 2); + $dialog.css('position', 'absolute'); + $dialog.css('left', left > 0 ? left : 0); + $dialog.css('top', top > 0 ? top : 0); + }, + + isIE: function () { + return !!navigator.userAgent.match(/Trident/g) || !!navigator.userAgent.match(/MSIE/g); + }, + + setChildPosition: function (mainEl, childEl) { + var mainElRect = mainEl.getBoundingClientRect(), + mainElHeight = bt.core.height(mainEl, true), + childElHeight = bt.core.height(childEl, true), + mainElWidth = bt.core.width(mainEl, true), + childElWidth = bt.core.width(childEl, true), + scrollY = window.scrollY || window.pageYOffset || 0, + scrollX = window.scrollX || window.pageXOffset || 0; + + if ((mainElRect.top + mainElHeight + childElHeight) > window.innerHeight && mainElRect.top > childElHeight) { + childEl.style.top = Math.round(mainElRect.top + scrollY - childElHeight - 3) + 'px'; + } else { + childEl.style.top = Math.round(mainElRect.top + scrollY + mainElHeight + 3) + 'px'; + } + + if (mainElRect.left + childElWidth > document.body.clientWidth) { + childEl.style.left = Math.round(mainElRect.left + scrollX + mainElWidth - childElWidth) + 'px'; + } else { + childEl.style.left = Math.round(mainElRect.left + scrollX) + 'px'; + } + }, + + height: function (el, margin) { + var result, style = window.getComputedStyle(el); + + if (style.boxSizing === 'border-box') { // border-box include padding and border within the height + result = parseInt(style.height, 10); + } else { + result = parseInt(style.height, 10); + result += parseInt(style.paddingTop || 0, 10) + parseInt(style.paddingBottom || 0, 10); + result += parseInt(style.borderTop || 0, 10) + parseInt(style.borderBottom || 0, 10); + } + + if (margin) { + result += parseInt(style.marginTop || 0, 10) + parseInt(style.marginBottom || 0, 10); + } + + return result; + }, + + width: function (el, margin) { + var result, style = window.getComputedStyle(el); + + if (style.boxSizing === 'border-box') { // border-box include padding and border within the width + result = parseInt(style.width, 10); + } else { + result = parseInt(style.width, 10); + result += parseInt(style.paddingLeft || 0, 10) + parseInt(style.paddingRight || 0, 10); + result += parseInt(style.borderLeft || 0, 10) + parseInt(style.borderRight || 0, 10); + } + + if (margin) { + result += parseInt(style.marginLeft || 0, 10) + parseInt(style.marginRight || 0, 10); + } + + return result; + }, + + addClasses: function (el, classes) { + var i, arr; + if (classes) { + arr = classes.split(' '); + for (i = 0; i < arr.length; i++) { + el.classList.add(arr[i]); + } + } + }, + + position: function (elem, padding, margin) { + var box = elem.getBoundingClientRect(), + body = document.body, + bodyStyle = window.getComputedStyle(body), + docEl = document.documentElement, + scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop, + scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft, + clientTop = docEl.clientTop || body.clientTop || 0, + clientLeft = docEl.clientLeft || body.clientLeft || 0, + top = Math.round(box.top + scrollTop - clientTop), + left = Math.round(box.left + scrollLeft - clientLeft); + + if (padding) { + top += parseInt(bodyStyle.paddingTop || 0, 10); + left += parseInt(bodyStyle.paddingLeft || 0, 10); + } + if (margin) { + top += parseInt(bodyStyle.marginTop || 0, 10); + left += parseInt(bodyStyle.marginLeft || 0, 10); + } + + return { top: top, left: left, bottom: top + bt.core.height(elem), right: left + bt.core.width(elem) }; + } +}; +/* global window alert jQuery */ +/** + * @widget Dialog + * @plugin Base + */ +bt.dialog = { + plugins: {}, + messages: {} +}; + +bt.dialog.config = { + base: { + /** If set to true, the dialog will automatically open upon initialization. + * If false, the dialog will stay hidden until the open() method is called. + * @type boolean + * @default true + * @example True + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example False + * + * + * + */ + autoOpen: true, + + /** Specifies whether the dialog should have a close button in right part of dialog header. + * @type boolean + * @default true + * @example True + *
+ *

Dialog

+ *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ *
+ * + * + *
+ *
+ * + * @example False + *
+ *

Dialog

+ *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ *
+ * + * + *
+ *
+ * + */ + closeButtonInHeader: true, + + /** Specifies whether the dialog should close when it has focus and the user presses the escape (ESC) key. + * @type boolean + * @default true + * @example True + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example False + * + * + */ + closeOnEscape: true, + + /** If set to true, the dialog will be draggable by the title bar. + * @type boolean + * @default true + * @example True + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example False + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + */ + draggable: true, + + /** The height of the dialog. + * @additionalinfo Support string and number values. The number value sets the height in pixels. + * The only supported string value is "auto" which will allow the dialog height to adjust based on its content. + * @type (number|string) + * @default "auto" + * @example Short.Text + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example Long.Text.Material.Design + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ * + * @example Long.Text.Bootstrap3 + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ * + * @example Long.Text.Bootstrap4 + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ * + */ + height: 'auto', + + /** The language that needs to be in use. + * @type string + * @default 'en-us' + * @example French.Default + * + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example French.Custom + * + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + */ + locale: 'en-us', + + /** The maximum height in pixels to which the dialog can be resized. + * @type number + * @default undefined + * @example sample + *
The maximum height of this dialog is set to 300 px. Try to resize it for testing.
+ * + */ + maxHeight: undefined, + + /** The maximum width in pixels to which the dialog can be resized. + * @type number + * @default undefined + * @example sample + *
The maximum width of this dialog is set to 400 px. Try to resize it for testing.
+ * + */ + maxWidth: undefined, + + /** The minimum height in pixels to which the dialog can be resized. + * @type number + * @default undefined + * @example sample + *
The minimum height of this dialog is set to 200 px. Try to resize it for testing.
+ * + */ + minHeight: undefined, + + /** The minimum width in pixels to which the dialog can be resized. + * @type number + * @default undefined + * @example sample + *
The minimum width of this dialog is set to 200 px. Try to resize it for testing.
+ * + */ + minWidth: undefined, + + /** If set to true, the dialog will have modal behavior. + * Modal dialogs create an overlay below the dialog, but above other page elements and you can't interact with them. + * @type boolean + * @default false + * @example True.Material.Design + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example True.Bootstrap.4 + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example False + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + */ + modal: false, + + /** If set to true, the dialog will be resizable. + * @type boolean + * @default false + * @example True + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example False + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + */ + resizable: false, + + /** If set to true, add vertical scroller to the dialog body. + * @type Boolean + * @default false + * @example Bootstrap.3 + *
+ *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ *
+ * + * + *
+ *
+ * + * @example Bootstrap.4 + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ * + * @example Material.Design + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor quam in magna vulputate, vitae laoreet odio ultrices. Phasellus at efficitur magna. Mauris purus dolor, egestas quis leo et, vulputate dictum mauris. Vivamus maximus lectus sollicitudin lorem blandit tempor. Maecenas eget posuere mi. Suspendisse id hendrerit nibh. Morbi eu odio euismod, venenatis ipsum in, egestas nunc. Mauris dignissim metus ac risus porta eleifend. Aliquam tempus libero orci, id placerat odio vehicula eu. Donec tincidunt justo dolor, sit amet tempus turpis varius sit amet. Suspendisse ut ex blandit, hendrerit enim tristique, iaculis ipsum. Vivamus venenatis dolor justo, eget scelerisque lacus dignissim quis. Duis imperdiet ex at aliquet cursus. Proin non ultricies leo. Fusce quam diam, laoreet quis fringilla vitae, viverra id magna. Nam laoreet sem in volutpat rhoncus.
+ * + */ + scrollable: false, + + /** The title of the dialog. Can be also set through the title attribute of the html element. + * @type String + * @default "Dialog" + * @example Js.Config + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example Html.Config + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + */ + title: undefined, + + /** The name of the UI library that is going to be in use. Currently we support Material Design and Bootstrap. + * @additionalinfo The css file for bootstrap should be manually included if you use bootstrap. + * @type string (bootstrap|materialdesign) + * @default undefined + * @example Bootstrap.3 + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example Bootstrap.4 + *
+ *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ *
+ * + * + *
+ *
+ * + * @example Material.Design + *
+ *
+ * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + *
+ *
+ * + * + *
+ *
+ * + */ + uiLibrary: undefined, + + /** The width of the dialog. + * @type number + * @default 300 + * @example Fixed.Width + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * @example Auto.Width + *
+ * + *
+ * + */ + width: 300, + + style: { + modal: 'bt-modal', + content: 'bt-dialog-md', + header: 'bt-dialog-md-header bt-unselectable', + headerTitle: 'bt-dialog-md-title', + headerCloseButton: 'bt-dialog-md-close', + body: 'bt-dialog-md-body', + footer: 'bt-dialog-footer bt-dialog-md-footer' + } + }, + + bootstrap: { + style: { + modal: 'modal', + content: 'modal-content bt-dialog-bootstrap', + header: 'modal-header', + headerTitle: 'modal-title', + headerCloseButton: 'close', + body: 'modal-body', + footer: 'bt-dialog-footer modal-footer' + } + }, + + bootstrap4: { + style: { + modal: 'modal', + content: 'modal-content bt-dialog-bootstrap4', + header: 'modal-header', + headerTitle: 'modal-title', + headerCloseButton: 'close', + body: 'modal-body', + footer: 'bt-dialog-footer modal-footer' + } + } +}; +/** + * @widget Dialog + * @plugin Base + */ +bt.dialog.events = { + /** + * Triggered when the dialog is initialized. + * + * @event initialized + * @param {object} e - event data + * @example sample + * + * + * + */ + initialized: function ($dialog) { + $dialog.trigger("initialized"); + }, + + /** + * Triggered before the dialog is opened. + * @event opening + * @param {object} e - event data + * @example sample + * + * + * + */ + opening: function ($dialog) { + $dialog.trigger("opening"); + }, + + /** + * Triggered when the dialog is opened. + * @event opened + * @param {object} e - event data + * @example sample + * + * + * + */ + opened: function ($dialog) { + $dialog.trigger("opened"); + }, + + /** + * Triggered before the dialog is closed. + * @event closing + * @param {object} e - event data + * @example sample + * + * + * + */ + closing: function ($dialog) { + $dialog.trigger("closing"); + }, + + /** + * Triggered when the dialog is closed. + * @event closed + * @param {object} e - event data + * @example sample + * + * + * + */ + closed: function ($dialog) { + $dialog.trigger("closed"); + }, + + /** + * Triggered while the dialog is being dragged. + * @event drag + * @param {object} e - event data + * @example sample + * + *
+ * + */ + drag: function ($dialog) { + $dialog.trigger("drag"); + }, + + /** + * Triggered when the user starts dragging the dialog. + * @event dragStart + * @param {object} e - event data + * @example sample + * + *
+ * + */ + dragStart: function ($dialog) { + $dialog.trigger("dragStart"); + }, + + /** + * Triggered after the dialog has been dragged. + * @event dragStop + * @param {object} e - event data + * @example sample + * + *
+ * + */ + dragStop: function ($dialog) { + $dialog.trigger("dragStop"); + }, + + /** + * Triggered while the dialog is being resized. + * @event resize + * @param {object} e - event data + * @example sample + * + *
+ * + */ + resize: function ($dialog) { + $dialog.trigger("resize"); + }, + + /** + * Triggered when the user starts resizing the dialog. + * @event resizeStart + * @param {object} e - event data + * @example sample + * + *
+ * + */ + resizeStart: function ($dialog) { + $dialog.trigger("resizeStart"); + }, + + /** + * Triggered after the dialog has been resized. + * @event resizeStop + * @param {object} e - event data + * @example sample + * + *
+ * + */ + resizeStop: function ($dialog) { + $dialog.trigger("resizeStop"); + } +}; + +bt.dialog.methods = { + + init: function (jsConfig) { + bt.widget.prototype.init.call(this, jsConfig, 'dialog'); + + bt.dialog.methods.localization(this); + bt.dialog.methods.initialize(this); + bt.dialog.events.initialized(this); + return this; + }, + + localization: function($dialog) { + var data = $dialog.data(); + if (typeof (data.title) === 'undefined') { + data.title = bt.dialog.messages[data.locale].DefaultTitle; + } + }, + + getHTMLConfig: function () { + var result = bt.widget.prototype.getHTMLConfig.call(this), + attrs = this[0].attributes; + if (attrs['title']) { + result.title = attrs['title'].value; + } + return result; + }, + + initialize: function ($dialog) { + var data = $dialog.data(), + $header, $body, $footer; + + $dialog.addClass(data.style.content); + + bt.dialog.methods.setSize($dialog); + + if (data.closeOnEscape) { + $(document).keyup(function (e) { + if (e.keyCode === 27) { + $dialog.close(); + } + }); + } + + $body = $dialog.children('div[data-role="body"]'); + if ($body.length === 0) { + $body = $('
').addClass(data.style.body); + $dialog.wrapInner($body); + } else { + $body.addClass(data.style.body); + } + + $header = bt.dialog.methods.renderHeader($dialog); + + $footer = $dialog.children('div[data-role="footer"]').addClass(data.style.footer); + + $dialog.find('[data-role="close"]').on('click', function () { + $dialog.close(); + }); + + if (bt.draggable) { + if (data.draggable) { + bt.dialog.methods.draggable($dialog, $header); + } + if (data.resizable) { + bt.dialog.methods.resizable($dialog); + } + } + + if (data.scrollable && data.height) { + $dialog.addClass('bt-dialog-scrollable'); + $dialog.on('opened', function () { + var $body = $dialog.children('div[data-role="body"]'); + $body.css('height', data.height - $header.outerHeight() - ($footer.length ? $footer.outerHeight() : 0)); + }); + } + + bt.core.center($dialog); + + if (data.modal) { + $dialog.wrapAll('
'); + } + + if (data.autoOpen) { + $dialog.open(); + } + }, + + setSize: function ($dialog) { + var data = $dialog.data(); + if (data.width) { + $dialog.css("width", data.width); + } + if (data.height) { + $dialog.css("height", data.height); + } + }, + + renderHeader: function ($dialog) { + var $header, $title, $closeButton, data = $dialog.data(); + $header = $dialog.children('div[data-role="header"]'); + if ($header.length === 0) { + $header = $('
'); + $dialog.prepend($header); + } + $header.addClass(data.style.header); + + $title = $header.find('[data-role="title"]'); + if ($title.length === 0) { + $title = $('

' + data.title + '

'); + $header.append($title); + } + $title.addClass(data.style.headerTitle); + + $closeButton = $header.find('[data-role="close"]'); + if ($closeButton.length === 0 && data.closeButtonInHeader) { + $closeButton = $(''); + $closeButton.addClass(data.style.headerCloseButton); + $header.append($closeButton); + } else if ($closeButton.length > 0 && data.closeButtonInHeader === false) { + $closeButton.hide(); + } else { + $closeButton.addClass(data.style.headerCloseButton); + } + + return $header; + }, + + draggable: function ($dialog, $header) { + $dialog.appendTo('body'); + $header.addClass('bt-draggable'); + $dialog.draggable({ + handle: $header, + start: function () { + $dialog.addClass('bt-unselectable'); + bt.dialog.events.dragStart($dialog); + }, + stop: function () { + $dialog.removeClass('bt-unselectable'); + bt.dialog.events.dragStop($dialog); + } + }); + }, + + resizable: function ($dialog) { + var config = { + 'drag': bt.dialog.methods.resize, + 'start': function () { + $dialog.addClass('bt-unselectable'); + bt.dialog.events.resizeStart($dialog); + }, + 'stop': function () { + this.removeAttribute('style'); + $dialog.removeClass('bt-unselectable'); + bt.dialog.events.resizeStop($dialog); + } + }; + $dialog.append($('
').draggable($.extend(true, { horizontal: false }, config))); + $dialog.append($('
').draggable($.extend(true, { vertical: false }, config))); + $dialog.append($('
').draggable($.extend(true, { horizontal: false }, config))); + $dialog.append($('
').draggable($.extend(true, { vertical: false }, config))); + $dialog.append($('
').draggable($.extend(true, {}, config))); + $dialog.append($('
').draggable($.extend(true, {}, config))); + $dialog.append($('
').draggable($.extend(true, {}, config))); + $dialog.append($('
').draggable($.extend(true, {}, config))); + }, + + resize: function (e, newPosition) { + var $el, $dialog, position, data, height, width, top, left, result = false; + + $el = $(this); + $dialog = $el.parent(); + position = bt.core.position(this); + offset = { top: newPosition.top - position.top, left: newPosition.left - position.left }; + data = $dialog.data(); + + // TODO: Include margins in the calculations + if ($el.hasClass('bt-resizable-n')) { + height = $dialog.height() - offset.top; + top = $dialog.offset().top + offset.top; + } else if ($el.hasClass('bt-resizable-e')) { + width = $dialog.width() + offset.left; + } else if ($el.hasClass('bt-resizable-s')) { + height = $dialog.height() + offset.top; + } else if ($el.hasClass('bt-resizable-w')) { + width = $dialog.width() - offset.left; + left = $dialog.offset().left + offset.left; + } else if ($el.hasClass('bt-resizable-ne')) { + height = $dialog.height() - offset.top; + top = $dialog.offset().top + offset.top; + width = $dialog.width() + offset.left; + } else if ($el.hasClass('bt-resizable-nw')) { + height = $dialog.height() - offset.top; + top = $dialog.offset().top + offset.top; + width = $dialog.width() - offset.left; + left = $dialog.offset().left + offset.left; + } else if ($el.hasClass('bt-resizable-se')) { + height = $dialog.height() + offset.top; + width = $dialog.width() + offset.left; + } else if ($el.hasClass('bt-resizable-sw')) { + height = $dialog.height() + offset.top; + width = $dialog.width() - offset.left; + left = $dialog.offset().left + offset.left; + } + + if (height && (!data.minHeight || height >= data.minHeight) && (!data.maxHeight || height <= data.maxHeight)) { + $dialog.height(height); + if (top) { + $dialog.css('top', top); + } + result = true; + } + + if (width && (!data.minWidth || width >= data.minWidth) && (!data.maxWidth || width <= data.maxWidth)) { + $dialog.width(width); + if (left) { + $dialog.css('left', left); + } + result = true; + } + + if (result) { + bt.dialog.events.resize($dialog); + } + + return result; + }, + + open: function ($dialog, title) { + var $footer; + bt.dialog.events.opening($dialog); + $dialog.css('display', 'block'); + $dialog.closest('div[data-role="modal"]').css('display', 'block'); + $footer = $dialog.children('div[data-role="footer"]'); + if ($footer.length && $footer.outerHeight()) { + $dialog.children('div[data-role="body"]').css('margin-bottom', $footer.outerHeight()); + } + if (title !== undefined) { + $dialog.find('[data-role="title"]').html(title); + } + bt.dialog.events.opened($dialog); + return $dialog; + }, + + close: function ($dialog) { + if ($dialog.is(':visible')) { + bt.dialog.events.closing($dialog); + $dialog.css('display', 'none'); + $dialog.closest('div[data-role="modal"]').css('display', 'none'); + bt.dialog.events.closed($dialog); + } + return $dialog; + }, + + isOpen: function ($dialog) { + return $dialog.is(':visible'); + }, + + content: function ($dialog, html) { + var $body = $dialog.children('div[data-role="body"]'); + if (typeof (html) === "undefined") { + return $body.html(); + } else { + return $body.html(html); + } + }, + + destroy: function ($dialog, keepHtml) { + var data = $dialog.data(); + if (data) { + if (keepHtml === false) { + $dialog.remove(); + } else { + $dialog.close(); + $dialog.off(); + $dialog.removeData(); + $dialog.removeAttr('data-type'); + $dialog.removeClass(data.style.content); + $dialog.find('[data-role="header"]').removeClass(data.style.header); + $dialog.find('[data-role="title"]').removeClass(data.style.headerTitle); + $dialog.find('[data-role="close"]').remove(); + $dialog.find('[data-role="body"]').removeClass(data.style.body); + $dialog.find('[data-role="footer"]').removeClass(data.style.footer); + } + + } + return $dialog; + } +}; +/** + * @widget Dialog + * @plugin Base + */ +bt.dialog.widget = function ($element, jsConfig) { + var self = this, + methods = bt.dialog.methods; + + /** + * Opens the dialog. + * @method + * @param {String} title - The dialog title. + * @fires opening, opened + * @return dialog + * @example Sample + * + * + * + * @example Title + * + * + * + */ + self.open = function (title) { + return methods.open(this, title); + } + + /** + * Close the dialog. + * @method + * @fires closing, closed + * @return dialog + * @example sample + * + * + * + * + */ + self.close = function () { + return methods.close(this); + } + + /** + * Check if the dialog is currently open. + * @method + * @return boolean + * @example sample + * + * + * + * + * + */ + self.isOpen = function () { + return methods.isOpen(this); + } + + /** + * Gets or set the content of a dialog. Supports chaining when used as a setter. + * @method + * @param {String} content - The content of the Dialog. + * @return String|Dialog + * @example sample + *
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
+ * + * + * + */ + self.content = function (content) { + return methods.content(this, content); + } + + /** + * Destroy the dialog. + * @method + * @param {boolean} keepHtml - If this flag is set to false, the dialog html markup will be removed from the HTML dom tree. + * @return void + * @example Keep.HTML.Markup + * + * + * + * + * @example Remove.HTML.Markup + * + * + * + * + */ + self.destroy = function (keepHtml) { + return methods.destroy(this, keepHtml); + } + + $.extend($element, self); + if ('dialog' !== $element.attr('data-type')) { + methods.init.call($element, jsConfig); + } + + return $element; +}; + +bt.dialog.widget.prototype = new bt.widget(); +bt.dialog.widget.constructor = bt.dialog.widget; + +bt.dialog.widget.prototype.getHTMLConfig = bt.dialog.methods.getHTMLConfig; + +(function ($) { + $.fn.dialog = function (method) { + var $widget; + if (this && this.length) { + if (typeof method === 'object' || !method) { + return new bt.dialog.widget(this, method); + } else { + $widget = new bt.dialog.widget(this, null); + if ($widget[method]) { + return $widget[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + throw 'Method ' + method + ' does not exist.'; + } + } + } + }; +})(jQuery); +bt.dialog.messages['en-us'] = { + Close: 'Close', + DefaultTitle: 'Dialog' +}; +/* global window alert jQuery */ +/** + * @widget Draggable + * @plugin Base + */ +bt.draggable = { + plugins: {} +}; + +bt.draggable.config = { + base: { + /** If specified, restricts dragging from starting unless the mousedown occurs on the specified element. + * Only elements that descend from the draggable element are permitted. + * @type jquery element + * @default undefined + * @example sample + * + *
+ *
Handle for dragging
+ *
+ * + */ + handle: undefined, + + /** If set to false, restricts dragging on vertical direction. + * @type Boolean + * @default true + * @example sample + * + *
+ * drag me
+ * (dragging on vertical direction is disabled) + *
+ * + */ + vertical: true, + + /** If set to false, restricts dragging on horizontal direction. + * @type Boolean + * @default true + * @example sample + * + *
+ * drag me
+ * (dragging on horizontal direction is disabled) + *
+ * + */ + horizontal: true, + + /** Constrains dragging to within the bounds of the specified element. + * @type Element + * @default undefined + * @example sample + * + *
+ *
drag me
+ *
+ * + */ + containment: undefined + } +}; + +bt.draggable.methods = { + init: function (jsConfig) { + var $handleEl, data, $dragEl = this; + + bt.widget.prototype.init.call(this, jsConfig, 'draggable'); + data = this.data(); + $dragEl.attr('data-draggable', 'true'); + + $handleEl = bt.draggable.methods.getHandleElement($dragEl); + + $handleEl.on('touchstart mousedown', function (e) { + var position = bt.core.position($dragEl[0]); + $dragEl[0].style.top = position.top + 'px'; + $dragEl[0].style.left = position.left + 'px'; + $dragEl[0].style.position = 'fixed'; + + $dragEl.attr('draggable-dragging', true); + $dragEl.removeAttr('draggable-x').removeAttr('draggable-y'); + bt.documentManager.subscribeForEvent('touchmove', $dragEl.data('guid'), bt.draggable.methods.createMoveHandler($dragEl, $handleEl, data)); + bt.documentManager.subscribeForEvent('mousemove', $dragEl.data('guid'), bt.draggable.methods.createMoveHandler($dragEl, $handleEl, data)); + }); + + bt.documentManager.subscribeForEvent('mouseup', $dragEl.data('guid'), bt.draggable.methods.createUpHandler($dragEl)); + bt.documentManager.subscribeForEvent('touchend', $dragEl.data('guid'), bt.draggable.methods.createUpHandler($dragEl)); + bt.documentManager.subscribeForEvent('touchcancel', $dragEl.data('guid'), bt.draggable.methods.createUpHandler($dragEl)); + + return $dragEl; + }, + + getHandleElement: function ($dragEl) { + var $handle = $dragEl.data('handle'); + return ($handle && $handle.length) ? $handle : $dragEl; + }, + + createUpHandler: function ($dragEl) { + return function (e) { + if ($dragEl.attr('draggable-dragging') === 'true') { + $dragEl.attr('draggable-dragging', false); + bt.documentManager.unsubscribeForEvent('mousemove', $dragEl.data('guid')); + bt.documentManager.unsubscribeForEvent('touchmove', $dragEl.data('guid')); + bt.draggable.events.stop($dragEl, { x: $dragEl.mouseX(e), y: $dragEl.mouseY(e) }); + } + }; + }, + + createMoveHandler: function ($dragEl, $handleEl, data) { + return function (e) { + var mouseX, mouseY, offsetX, offsetY, prevX, prevY; + if ($dragEl.attr('draggable-dragging') === 'true') { + mouseX = Math.round($dragEl.mouseX(e)); + mouseY = Math.round($dragEl.mouseY(e)); + prevX = $dragEl.attr('draggable-x'); + prevY = $dragEl.attr('draggable-y'); + if (prevX && prevY) { + offsetX = data.horizontal ? mouseX - parseInt(prevX, 10) : 0; + offsetY = data.vertical ? mouseY - parseInt(prevY, 10) : 0; + bt.draggable.methods.move($dragEl[0], data, offsetX, offsetY, mouseX, mouseY); + } else { + bt.draggable.events.start($dragEl, mouseX, mouseY); + } + $dragEl.attr('draggable-x', mouseX); + $dragEl.attr('draggable-y', mouseY); + } + } + }, + + move: function (dragEl, data, offsetX, offsetY, mouseX, mouseY) { + var contPosition, maxTop, maxLeft, + position = bt.core.position(dragEl), + newTop = position.top + offsetY, + newLeft = position.left + offsetX; + + if (data.containment) { + contPosition = bt.core.position(data.containment); + maxTop = contPosition.top + bt.core.height(data.containment) - bt.core.height(dragEl); + maxLeft = contPosition.left + bt.core.width(data.containment) - bt.core.width(dragEl); + if (newTop > contPosition.top && newTop < maxTop) { + if (contPosition.top >= mouseY || contPosition.bottom <= mouseY) { + newTop = position.top; + } + } else { + if (newTop <= contPosition.top) { + newTop = contPosition.top + 1; + } else { + newTop = maxTop - 1; + } + } + if (newLeft > contPosition.left && newLeft < maxLeft) { + if (contPosition.left >= mouseX || contPosition.right <= mouseX) { + newLeft = position.left; + } + } else { + if (newLeft <= contPosition.left) { + newLeft = contPosition.left + 1; + } else { + newLeft = maxLeft - 1; + } + } + } + + if (false !== bt.draggable.events.drag($(dragEl), newTop, newLeft, mouseX, mouseY)) { + dragEl.style.top = newTop + 'px'; + dragEl.style.left = newLeft + 'px'; + } + }, + + destroy: function ($dragEl) { + if ($dragEl.attr('data-draggable') === 'true') { + bt.documentManager.unsubscribeForEvent('mouseup', $dragEl.data('guid')); + $dragEl.removeData(); + $dragEl.removeAttr('data-guid'); + $dragEl.removeAttr('data-draggable'); + $dragEl.off('drag').off('start').off('stop'); + bt.draggable.methods.getHandleElement($dragEl).off('mousedown'); + } + return $dragEl; + } +}; + +bt.draggable.events = { + /** + * Triggered while the mouse is moved during the dragging, immediately before the current move happens. + * + * @event drag + * @param {object} e - event data + * @param {object} newPosition - New position of the draggable element as { top, left } object. + * @param {object} mousePosition - Current mouse position as { x, y } object. + * @example sample + * + *
drag me
+ * + */ + drag: function ($dragEl, newTop, newLeft, mouseX, mouseY) { + return $dragEl.triggerHandler('drag', [{ top: newTop, left: newLeft }, { x: mouseX, y: mouseY }]); + }, + + /** + * Triggered when dragging starts. + * + * @event start + * @param {object} e - event data + * @param {object} mousePosition - Current mouse position as { x, y } object. + * @example sample + * + *
+ * drag me + *
+ * + */ + start: function ($dragEl, mouseX, mouseY) { + $dragEl.triggerHandler('start', [{ x: mouseX, y: mouseY }]); + }, + + /** + * Triggered when dragging stops. + * + * @event stop + * @param {object} e - event data + * @param {object} mousePosition - Current mouse position as { x, y } object. + * @example sample + * + *
+ * drag me + *
+ * + */ + stop: function ($dragEl, mousePosition) { + $dragEl.triggerHandler('stop', [mousePosition]); + } +}; + +bt.draggable.widget = function ($element, jsConfig) { + var self = this, + methods = bt.draggable.methods; + + if (!$element.destroy) { + /** Remove draggable functionality from the element. + * @method + * @return jquery element + * @example sample + * + * + *
Drag Me
+ * + */ + self.destroy = function () { + return methods.destroy(this); + }; + } + + $.extend($element, self); + if ('true' !== $element.attr('data-draggable')) { + methods.init.call($element, jsConfig); + } + + return $element; +}; + +bt.draggable.widget.prototype = new bt.widget(); +bt.draggable.widget.constructor = bt.draggable.widget; + +(function ($) { + $.fn.draggable = function (method) { + var $widget; + if (this && this.length) { + if (typeof method === 'object' || !method) { + return new bt.draggable.widget(this, method); + } else { + $widget = new bt.draggable.widget(this, null); + if ($widget[method]) { + return $widget[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + throw 'Method ' + method + ' does not exist.'; + } + } + } + }; +})(jQuery); +/* global window alert jQuery */ +/** + * @widget Droppable + * @plugin Base + */ +bt.droppable = { + plugins: {} +}; + +bt.droppable.config = { + /** If specified, the class will be added to the droppable while draggable is being hovered over the droppable. + * @type string + * @default undefined + * @example sample + * + *
Drop Here
+ *
Drag Me
+ * + */ + hoverClass: undefined +}; + +bt.droppable.methods = { + init: function (jsConfig) { + var $dropEl = this; + + bt.widget.prototype.init.call(this, jsConfig, 'droppable'); + $dropEl.attr('data-droppable', 'true'); + + bt.documentManager.subscribeForEvent('mousedown', $dropEl.data('guid'), bt.droppable.methods.createMouseDownHandler($dropEl)); + bt.documentManager.subscribeForEvent('mousemove', $dropEl.data('guid'), bt.droppable.methods.createMouseMoveHandler($dropEl)); + bt.documentManager.subscribeForEvent('mouseup', $dropEl.data('guid'), bt.droppable.methods.createMouseUpHandler($dropEl)); + + return $dropEl; + }, + + createMouseDownHandler: function ($dropEl) { + return function (e) { + $dropEl.isDragging = true; + } + }, + + createMouseMoveHandler: function ($dropEl) { + return function (e) { + if ($dropEl.isDragging) { + var hoverClass = $dropEl.data('hoverClass'), + mousePosition = { + x: $dropEl.mouseX(e), + y: $dropEl.mouseY(e) + }, + newIsOver = bt.droppable.methods.isOver($dropEl, mousePosition); + if (newIsOver != $dropEl.isOver) { + if (newIsOver) { + if (hoverClass) { + $dropEl.addClass(hoverClass); + } + bt.droppable.events.over($dropEl, mousePosition); + } else { + if (hoverClass) { + $dropEl.removeClass(hoverClass); + } + bt.droppable.events.out($dropEl); + } + } + $dropEl.isOver = newIsOver; + } + } + }, + + createMouseUpHandler: function ($dropEl) { + return function (e) { + var mousePosition = { + left: $dropEl.mouseX(e), + top: $dropEl.mouseY(e) + }; + $dropEl.isDragging = false; + if (bt.droppable.methods.isOver($dropEl, mousePosition)) { + bt.droppable.events.drop($dropEl); + } + } + }, + + isOver: function ($dropEl, mousePosition) { + var offsetTop = $dropEl.offset().top, + offsetLeft = $dropEl.offset().left; + return mousePosition.x > offsetLeft && mousePosition.x < (offsetLeft + $dropEl.outerWidth(true)) + && mousePosition.y > offsetTop && mousePosition.y < (offsetTop + $dropEl.outerHeight(true)); + }, + + destroy: function ($dropEl) { + if ($dropEl.attr('data-droppable') === 'true') { + bt.documentManager.unsubscribeForEvent('mousedown', $dropEl.data('guid')); + bt.documentManager.unsubscribeForEvent('mousemove', $dropEl.data('guid')); + bt.documentManager.unsubscribeForEvent('mouseup', $dropEl.data('guid')); + $dropEl.removeData(); + $dropEl.removeAttr('data-guid'); + $dropEl.removeAttr('data-droppable'); + $dropEl.off('drop').off('over').off('out'); + } + return $dropEl; + } +}; + +bt.droppable.events = { + /** Triggered when a draggable element is dropped. + * @event drop + * @param {object} e - event data + * @example sample + * + *
Drop Here
+ *
Drag Me
+ * + */ + drop: function ($dropEl, offsetX, offsetY) { + $dropEl.trigger('drop', [{ top: offsetY, left: offsetX }]); + }, + + /** Triggered when a draggable element is dragged over the droppable. + * @event over + * @param {object} e - event data + * @param {object} mousePosition - Current mouse position as { top, left } object. + * @example sample + * + *
Drop Here
+ *
Drag Me
+ * + */ + over: function ($dropEl, mousePosition) { + $dropEl.trigger('over', [mousePosition]); + }, + + /** Triggered when a draggable element is dragged out of the droppable. + * @event out + * @param {object} e - event data + * @example sample + * + *
Drop Here
+ *
Drag Me
+ * + */ + out: function ($dropEl) { + $dropEl.trigger('out'); + } +}; + +bt.droppable.widget = function ($element, jsConfig) { + var self = this, + methods = bt.droppable.methods; + + self.isOver = false; + self.isDragging = false; + + /** Removes the droppable functionality. + * @method + * @return jquery element + * @example sample + * + * + *

+ * + *
Drop Here
+ *
Drag Me
+ * + */ + self.destroy = function () { + return methods.destroy(this); + } + + self.isOver = function (mousePosition) { + return methods.isOver(this, mousePosition); + } + + $.extend($element, self); + if ('true' !== $element.attr('data-droppable')) { + methods.init.call($element, jsConfig); + } + + return $element; +}; + +bt.droppable.widget.prototype = new bt.widget(); +bt.droppable.widget.constructor = bt.droppable.widget; + +(function ($) { + $.fn.droppable = function (method) { + var $widget; + if (this && this.length) { + if (typeof method === 'object' || !method) { + return new bt.droppable.widget(this, method); + } else { + $widget = new bt.droppable.widget(this, null); + if ($widget[method]) { + return $widget[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + throw 'Method ' + method + ' does not exist.'; + } + } + } + }; +})(jQuery); +/* global window alert jQuery bt */ +/** + * @widget Grid + * @plugin Base + */ +bt.grid = { + plugins: {}, + messages: {} +}; + +bt.grid.config = { + base: { + /** The data source for the grid. + * @additionalinfo If set to string, then the grid is going to use this string as a url for ajax requests to the server.
+ * If set to object, then the grid is going to use this object as settings for the jquery ajax function.
+ * If set to array, then the grid is going to use the array as data for rows. + * @type (string|object|array) + * @default undefined + * @example Remote.JS.Configuration + *
+ * + * @example Remote.Html.Configuration + * + * + * + * + * + * + * + * + *
#NamePlaceOfBirth
+ * + * @example Local.DataSource + *
+ * + * @example Html.DataSource + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
#NamePlace Of Birth
1Hristo StoichkovPlovdiv, Bulgaria
2Ronaldo Luis Nazario de LimaRio de Janeiro, Brazil
3David PlattChadderton, Lancashire, England
+ * + * @example Remote.Custom.Render + *
+ * + * @example Remote.Custom.Error + *
+ * + */ + dataSource: undefined, + + /** An array that holds the configurations of each column from the grid. + * @type array + * @example JS.Configuration + *
+ * + */ + columns: [], + + /** Auto generate column for each field in the datasource when set to true. + * @type array + * @example sample + *
+ * + */ + autoGenerateColumns: false, + + /** An object that holds the default configuration settings of each column from the grid. + * @type object + * @example sample + *
+ * + */ + defaultColumnSettings: { + + /** If set to true the column will not be displayed in the grid. By default all columns are displayed. + * @alias column.hidden + * @type boolean + * @default false + * @example sample + *
+ * + */ + hidden: false, + + /** The width of the column. Numeric values are treated as pixels. + * If the width is undefined the width of the column is not set and depends on the with of the table(grid). + * @alias column.width + * @type number|string + * @default undefined + * @example sample + *
+ * + */ + width: undefined, + + /** Indicates if the column is sortable. + * If set to true the user can click the column header and sort the grid by the column source field. + * @alias column.sortable + * @type boolean|object + * @default false + * @example Remote + *
+ * + * @example Local.Custom + *
+ * + * @example Remote.Bootstrap.3 + *
+ * + * @example Remote.Bootstrap.4.Material.Icons + *
+ * + * @example Remote.Bootstrap.4.FontAwesome + *
+ * + */ + sortable: false, + + /** Indicates the type of the column. + * @alias column.type + * @type text|checkbox|icon + * @default 'text' + * @example Bootstrap.3.Icon + *
+ * + * @example Bootstrap.4.Icon + *
+ * + * @example Bootstrap.3.Checkbox + *
+ * + * @example Bootstrap.4.Checkbox + *
+ * + */ + type: 'text', + + /** The caption that is going to be displayed in the header of the grid. + * @alias column.title + * @type string + * @default undefined + * @example sample + *
+ * + */ + title: undefined, + + /** The field name to which the column is bound. + * If the column.title is not defined this value is used as column.title. + * @alias column.field + * @type string + * @default undefined + * @example sample + *
+ * + */ + field: undefined, + + /** This setting control the alignment of the text in the cell. + * @alias column.align + * @type left|right|center|justify|initial|inherit + * @default undefined + * @example Material.Design + *
+ * + * @example Bootstrap.4 + *
+ * + */ + align: undefined, + + /** The name(s) of css class(es) that are going to be applied to all cells inside that column, except the header cell. + * @alias column.cssClass + * @type string + * @default undefined + * @example sample + *
+ * + * + */ + cssClass: undefined, + + /** The name(s) of css class(es) that are going to be applied to the header cell of that column. + * @alias column.headerCssClass + * @type string + * @default undefined + * @example sample + *
+ * + * + */ + headerCssClass: undefined, + + /** The text for the cell tooltip. + * @alias column.tooltip + * @type string + * @default undefined + * @example sample + *
+ * + */ + tooltip: undefined, + + /** Css class for icon that is going to be in use for the cell. + * This setting can be in use only with combination of type icon. + * @alias column.icon + * @type string + * @default undefined + * @example sample + *
+ * + */ + icon: undefined, + + /** Configuration object with event names as keys and functions as values that are going to be bind to each cell from the column. + * Each function is going to receive event information as a parameter with info in the 'data' field for id, field name and record data. + * @alias column.events + * @type object + * @default undefined + * @example javascript.configuration + *
+ * + * @example html.configuration + * + * + * + * + * + * + * + * + * + *
IDNamePlace Of Birth
+ * + */ + events: undefined, + + /** Format the date when the type of the column is date. + * @additionalinfo d - Day of the month as digits; no leading zero for single-digit days.
+ * dd - Day of the month as digits; leading zero for single-digit days.
+ * m - Month as digits; no leading zero for single-digit months.
+ * mm - Month as digits; leading zero for single-digit months.
+ * yy - Year as last two digits; leading zero for years less than 10.
+ * yyyy - Year represented by four digits.
+ * s - Seconds; no leading zero for single-digit seconds.
+ * ss - Seconds; leading zero for single-digit seconds.
+ * M - Minutes; no leading zero for single-digit minutes. Uppercase MM to avoid conflict with months.
+ * MM - Minutes; leading zero for single-digit minutes. Uppercase MM to avoid conflict with months.
+ * H - Hours; no leading zero for single-digit hours (24-hour clock).
+ * HH - Hours; leading zero for single-digit hours (24-hour clock).
+ * h - Hours; no leading zero for single-digit hours (12-hour clock).
+ * hh - Hours; leading zero for single-digit hours (12-hour clock).
+ * tt - Lowercase, two-character time marker string: am or pm.
+ * TT - Uppercase, two-character time marker string: AM or PM.
+ * @alias column.format + * @type string + * @default 'mm/dd/yyyy' + * @example sample + *
+ * + */ + format: 'mm/dd/yyyy', + + /** Number of decimal digits after the decimal point. + * @alias column.decimalDigits + * @type number + * @default undefined + */ + decimalDigits: undefined, + + /** Template for the content in the column. + * Use curly brackets '{}' to wrap the names of data source columns from server response. + * @alias column.tmpl + * @type string + * @default undefined + * @example sample + *
+ * + */ + tmpl: undefined, + + /** If set to true stop event propagation when event occur. + * @alias column.stopPropagation + * @type boolean + * @default false + * @example sample + *
+ * + */ + stopPropagation: false, + + /** A renderer is an 'interceptor' function which can be used to transform data (value, appearance, etc.) before it is rendered. + * @additionalinfo If the renderer function return a value, then this value is going to be automatically set as value of the cell.
+ * If the renderer function doesn't return a value, then you have to set the content of the cell manually. + * @alias column.renderer + * @type function + * @default undefined + * @param {string} value - the record field value + * @param {object} record - the data of the row record + * @param {object} $cell - the current table cell presented as jquery object + * @param {object} $displayEl - inner div element for display of the cell value presented as jquery object + * @param {string} id - the id of the record + * @example sample + *
+ * + */ + renderer: undefined, + + /** Function which can be used to customize filtering with local data (javascript sourced data). + * @additionalinfo The default filtering is not case sensitive. The filtering with remote data sources needs to be handled on the server. + * @alias column.filter + * @type function + * @default undefined + * @param {string} value - the record field value + * @param {string} searchStr - the search string + * @example example + *   + *   + *

+ *
+ * + */ + filter: undefined + }, + + mapping: { + /** The name of the object in the server response, that contains array with records, that needs to be display in the grid. + * @alias mapping.dataField + * @type string + * @default "records" + */ + dataField: 'records', + + /** The name of the object in the server response, that contains the number of all records on the server. + * @alias mapping.totalRecordsField + * @type string + * @default "total" + */ + totalRecordsField: 'total' + }, + + params: {}, + + paramNames: { + + /** The name of the parameter that is going to send the name of the column for sorting. + * The "sortable" setting for at least one column should be enabled in order this parameter to be in use. + * @alias paramNames.sortBy + * @type string + * @default "sortBy" + */ + sortBy: 'sortBy', + + /** The name of the parameter that is going to send the direction for sorting. + * The "sortable" setting for at least one column should be enabled in order this parameter to be in use. + * @alias paramNames.direction + * @type string + * @default "direction" + */ + direction: 'direction' + }, + + /** The name of the UI library that is going to be in use. Currently we support Bootstrap 3, Bootstrap 4 and Material Design. + * @additionalinfo The css files for Bootstrap or Material Design should be manually included to the page where the grid is in use. + * @type (materialdesign|bootstrap|bootstrap4) + * @default 'materialdesign' + * @example Material.Design.With.Icons + *
+ * + * @example Material.Design.Without.Icons + *
+ * + * @example Bootstrap.3 + *
+ * + * @example Bootstrap.4.Font.Awesome + *
+ * + */ + uiLibrary: 'materialdesign', + + /** The name of the icons library that is going to be in use. Currently we support Material Icons, Font Awesome and Glyphicons. + * @additionalinfo If you use Bootstrap 3 as uiLibrary, then the iconsLibrary is set to Glyphicons by default.
+ * If you use Material Design as uiLibrary, then the iconsLibrary is set to Material Icons by default.
+ * The css files for Material Icons, Font Awesome or Glyphicons should be manually included to the page where the grid is in use. + * @type (materialicons|fontawesome|glyphicons) + * @default 'materialicons' + * @example Font.Awesome + *
+ * + */ + iconsLibrary: 'materialicons', + + /** The type of the row selection.
+ * If the type is set to multiple the user will be able to select more then one row from the grid. + * @type (single|multiple) + * @default 'single' + * @example Multiple.Material.Design.Checkbox + *
+ * + * @example Multiple.Bootstrap.3.Checkbox + *
+ * + * @example Multiple.Bootstrap.4.Checkbox + *
+ * + * @example Single.Checkbox + *
+ * + */ + selectionType: 'single', + + /** The type of the row selection mechanism. + * @additionalinfo If this setting is set to "basic" when the user select a row, then this row will be highlighted.
+ * If this setting is set to "checkbox" a column with checkboxes will appear as first row of the grid and when the user select a row, then this row will be highlighted and the checkbox selected. + * @type (basic|checkbox) + * @default "basic" + * @example sample + *
+ * + */ + selectionMethod: 'basic', + + /** When this setting is enabled the content of the grid will be loaded automatically after the creation of the grid. + * @type boolean + * @default true + * @example disabled + *
+ * + * @example enabled + *
+ * + */ + autoLoad: true, + + /** The text that is going to be displayed if the grid is empty. + * @type string + * @default "No records found." + * @example sample + *
+ * + * @example localization + *
+ * + * + */ + notFoundText: undefined, + + /** Width of the grid. + * @type number + * @default undefined + * @example sample + *
+ * + */ + width: undefined, + + /** Minimum width of the grid. + * @type number + * @default undefined + */ + minWidth: undefined, + + /** This configuration option manage the behaviour of the header row height. + * Auto scale if set to to 'autogrow'. All body rows are with the same height if set to 'fixed'. + * @type ('autogrow'|'fixed') + * @default "fixed" + * @example AutoGrow + *
+ * + * @example Fixed + *
+ * + */ + headerRowHeight: 'fixed', + + /** This configuration option manage the behaviour of the body row height. + * Auto scale if set to to 'autogrow'. All body rows are with the same height if set to 'fixed'. + * @type ('autogrow'|'fixed') + * @default "autogrow" + * @example AutoGrow + *
+ * + * @example Fixed + *
+ * + */ + bodyRowHeight: 'autogrow', + + /** The size of the font in the grid. + * @type string + * @default undefined + * @example sample + *
+ * + */ + fontSize: undefined, + + /** Name of column that contains the record id. + * @additionalinfo If you set primary key, we assume that this number is unique for each records presented in the grid.
+ * For example this should contains the column with primary key from your relation db table.
+ * If the primaryKey is undefined, we autogenerate id for each record in the table by starting from 1. + * @type string + * @default undefined + * @example defined + *
+ * + * @example undefined + *
+ * + */ + primaryKey: undefined, + + /** The language that needs to be in use. + * @type string + * @default 'en-us' + * @example German.Bootstrap.Default + *
+ * + * @example French.MaterialDesign.Custom + *
+ * + */ + locale: 'en-us', + + defaultIconColumnWidth: 70, + defaultCheckBoxColumnWidth: 70, + + style: { + wrapper: 'bt-grid-wrapper', + table: 'bt-grid bt-grid-md', + loadingCover: 'bt-grid-loading-cover', + loadingText: 'bt-grid-loading-text', + header: { + cell: undefined, + sortable: 'bt-cursor-pointer bt-unselectable' + }, + content: { + rowSelected: 'bt-grid-md-select' + } + }, + + icons: { + asc: 'â–²', + desc: 'â–¼' + } + }, + + bootstrap: { + style: { + wrapper: 'bt-grid-wrapper', + table: 'bt-grid bt-grid-bootstrap bt-grid-bootstrap-3 table table-bordered table-hover', + content: { + rowSelected: 'active' + } + }, + + iconsLibrary: 'glyphicons', + + defaultIconColumnWidth: 34, + defaultCheckBoxColumnWidth: 36 + }, + + bootstrap4: { + style: { + wrapper: 'bt-grid-wrapper', + table: 'bt-grid bt-grid-bootstrap bt-grid-bootstrap-4 table table-bordered table-hover', + content: { + rowSelected: 'active' + } + }, + + defaultIconColumnWidth: 42, + defaultCheckBoxColumnWidth: 44 + }, + + materialicons: { + icons: { + asc: '', + desc: '' + } + }, + + fontawesome: { + icons: { + asc: '', + desc: '' + } + }, + + glyphicons: { + icons: { + asc: '', + desc: '' + } + } +}; + +/** + * @widget Grid + * @plugin Base + */ +bt.grid.events = { + /** + * Event fires before addition of an empty row to the grid. + * @event beforeEmptyRowInsert + * @param {object} e - event data + * @param {object} $row - The empty row as jquery object + * @example sample + *
+ * + */ + beforeEmptyRowInsert: function ($grid, $row) { + return $grid.triggerHandler('beforeEmptyRowInsert', [$row]); + }, + + /** + * Event fired before data binding takes place. + * + * @event dataBinding + * @param {object} e - event data + * @param {array} records - the list of records + * @example sample + *
+ * + */ + dataBinding: function ($grid, records) { + return $grid.triggerHandler('dataBinding', [records]); + }, + + /** + * Event fires after the loading of the data in the grid. + * + * @event dataBound + * @param {object} e - event data + * @param {array} records - the list of records + * @param {number} totalRecords - the number of the all records that can be presented in the grid + * @example sample + *
+ * + */ + dataBound: function ($grid, records, totalRecords) { + return $grid.triggerHandler('dataBound', [records, totalRecords]); + }, + + /** + * Event fires after insert of a row in the grid during the loading of the data. + * @event rowDataBound + * @param {object} e - event data + * @param {object} $row - the row presented as jquery object + * @param {string} id - the id of the record + * @param {object} record - the data of the row record + * @example sample + *
+ * + */ + rowDataBound: function ($grid, $row, id, record) { + return $grid.triggerHandler('rowDataBound', [$row, id, record]); + }, + + /** + * Event fires after insert of a cell in the grid during the loading of the data + * + * @event cellDataBound + * @param {object} e - event data + * @param {object} $displayEl - inner div element for display of the cell value presented as jquery object + * @param {string} id - the id of the record + * @param {object} column - the column configuration data + * @param {object} record - the data of the row record + * @example sample + *
+ * + */ + cellDataBound: function ($grid, $displayEl, id, column, record) { + return $grid.triggerHandler('cellDataBound', [$displayEl, id, column, record]); + }, + + /** + * Event fires on selection of row + * + * @event rowSelect + * @param {object} e - event data + * @param {object} $row - the row presented as jquery object + * @param {string} id - the id of the record + * @param {object} record - the data of the row record + * @example sample + *
+ * + */ + rowSelect: function ($grid, $row, id, record) { + return $grid.triggerHandler('rowSelect', [$row, id, record]); + }, + + /** + * Event fires on un selection of row + * + * @event rowUnselect + * @param {object} e - event data + * @param {object} $row - the row presented as jquery object + * @param {string} id - the id of the record + * @param {object} record - the data of the row record + * @example sample + *
+ * + */ + rowUnselect: function ($grid, $row, id, record) { + return $grid.triggerHandler('rowUnselect', [$row, id, record]); + }, + + /** + * Event fires before deletion of row in the grid. + * @event rowRemoving + * @param {object} e - event data + * @param {object} $row - the row presented as jquery object + * @param {string} id - the id of the record + * @param {object} record - the data of the row record + * @example sample + *

+ *
+ * + */ + rowRemoving: function ($grid, $row, id, record) { + return $grid.triggerHandler('rowRemoving', [$row, id, record]); + }, + + /** + * Event fires when the grid.destroy method is called. + * + * @event destroying + * @param {object} e - event data + * @example sample + * + *

+ *
+ * + */ + destroying: function ($grid) { + return $grid.triggerHandler('destroying'); + }, + + /** + * Event fires when column is hidding + * + * @event columnHide + * @param {object} e - event data + * @param {object} column - The data about the column that is hidding + * @example sample + *
+ * + */ + columnHide: function ($grid, column) { + return $grid.triggerHandler('columnHide', [column]); + }, + + /** + * Event fires when column is showing + * + * @event columnShow + * @param {object} e - event data + * @param {object} column - The data about the column that is showing + * @example sample + *
+ * + */ + columnShow: function ($grid, column) { + return $grid.triggerHandler('columnShow', [column]); + }, + + /** + * Event fires when grid is initialized. + * + * @event initialized + * @param {object} e - event data + * @example sample + *
+ * + */ + initialized: function ($grid) { + return $grid.triggerHandler('initialized'); + }, + + /** + * Event fires when the grid data is filtered. + * + * @additionalinfo This event is firing only when you use local dataSource, because the filtering with remote dataSource needs to be done on the server side. + * @event dataFiltered + * @param {object} e - event data + * @param {object} records - The records after the filtering. + * @example sample + *
+ * + */ + dataFiltered: function ($grid, records) { + return $grid.triggerHandler('dataFiltered', [records]); + } +}; + +/*global bt $*/ +bt.grid.methods = { + + init: function (jsConfig) { + bt.widget.prototype.init.call(this, jsConfig, 'grid'); + + bt.grid.methods.initialize(this); + + if (this.data('autoLoad')) { + this.reload(); + } + return this; + }, + + getConfig: function (jsConfig, type) { + var config = bt.widget.prototype.getConfig.call(this, jsConfig, type); + bt.grid.methods.setDefaultColumnConfig(config.columns, config.defaultColumnSettings); + return config; + }, + + setDefaultColumnConfig: function (columns, defaultColumnSettings) { + var column, i; + if (columns && columns.length) { + for (i = 0; i < columns.length; i++) { + column = $.extend(true, {}, defaultColumnSettings); + $.extend(true, column, columns[i]); + columns[i] = column; + } + } + }, + + getHTMLConfig: function () { + var result = bt.widget.prototype.getHTMLConfig.call(this); + result.columns = []; + this.find('thead > tr > th').each(function () { + var $el = $(this), + title = $el.text(), + config = bt.widget.prototype.getHTMLConfig.call($el); + config.title = title; + if (!config.field) { + config.field = title; + } + if (config.events) { + config.events = bt.grid.methods.eventsParser(config.events); + } + result.columns.push(config); + }); + return result; + }, + + eventsParser: function (events) { + var result = {}, list, i, key, func, position; + list = events.split(','); + for (i = 0; i < list.length; i++) { + position = list[i].indexOf(':'); + if (position > 0) { + key = $.trim(list[i].substr(0, position)); + func = $.trim(list[i].substr(position + 1, list[i].length)); + result[key] = eval('window.' + func); //window[func]; //TODO: eveluate functions from string + } + } + return result; + }, + + initialize: function ($grid) { + var data = $grid.data(), + $wrapper = $grid.parent('div[data-role="wrapper"]'); + + bt.grid.methods.localization(data); + + if ($wrapper.length === 0) { + $wrapper = $('
').addClass(data.style.wrapper); //The css class needs to be added before the wrapping, otherwise doesn't work. + $grid.wrap($wrapper); + } else { + $wrapper.addClass(data.style.wrapper); + } + + if (data.width) { + $grid.parent().css('width', data.width); + } + if (data.minWidth) { + $grid.css('min-width', data.minWidth); + } + if (data.fontSize) { + $grid.css('font-size', data.fontSize); + } + if (data.headerRowHeight === 'autogrow') { + $grid.addClass('autogrow-header-row'); + } + if (data.bodyRowHeight === 'fixed') { + $grid.addClass('fixed-body-rows'); + } + $grid.addClass(data.style.table); + if ('checkbox' === data.selectionMethod) { + data.columns.splice(bt.grid.methods.getColumnPositionNotInRole($grid), 0, { + title: '', + width: data.defaultCheckBoxColumnWidth, + align: 'center', + type: 'checkbox', + role: 'selectRow', + events: { + click: function (e) { + bt.grid.methods.setSelected($grid, e.data.id, $(this).closest('tr')); + } + }, + headerCssClass: 'bt-grid-select-all', + stopPropagation: true + }); + } + + if ($grid.children('tbody').length === 0) { + $grid.append($('')); + } + + bt.grid.methods.renderHeader($grid); + bt.grid.methods.appendEmptyRow($grid, ' '); + bt.grid.events.initialized($grid); + }, + + localization: function (data) { + if (!data.notFoundText) { + data.notFoundText = bt.grid.messages[data.locale].NoRecordsFound; + } + }, + + renderHeader: function ($grid) { + var data, columns, style, $thead, $row, $cell, $title, i, $checkAllBoxes; + + data = $grid.data(); + columns = data.columns; + style = data.style.header; + + $thead = $grid.children('thead'); + if ($thead.length === 0) { + $thead = $(''); + $grid.prepend($thead); + } + + $row = $(''); + for (i = 0; i < columns.length; i += 1) { + $cell = $(''); + if (columns[i].width) { + $cell.attr('width', columns[i].width); + } else if (columns[i].type === 'checkbox') { + $cell.attr('width', data.defaultIconColumnWidth); + } + $cell.addClass(style.cell); + if (columns[i].headerCssClass) { + $cell.addClass(columns[i].headerCssClass); + } + $cell.css('text-align', columns[i].align || 'left'); + if ('checkbox' === data.selectionMethod && 'multiple' === data.selectionType && + 'checkbox' === columns[i].type && 'selectRow' === columns[i].role) { + $checkAllBoxes = $cell.find('input[data-role="selectAll"]'); + if ($checkAllBoxes.length === 0) { + $checkAllBoxes = $(''); + $cell.append($checkAllBoxes); + $checkAllBoxes.checkbox({ uiLibrary: data.uiLibrary }); + } + $checkAllBoxes.off('click').on('click', function () { + if (this.checked) { + $grid.selectAll(); + } else { + $grid.unSelectAll(); + } + }); + } else { + $title = $('
').html(typeof (columns[i].title) === 'undefined' ? columns[i].field : columns[i].title); + $cell.append($title); + if (columns[i].sortable) { + $title.addClass(style.sortable); + $title.on('click', bt.grid.methods.createSortHandler($grid, columns[i])); + } + } + if (columns[i].hidden) { + $cell.hide(); + } + $row.append($cell); + } + + $thead.empty().append($row); + }, + + createSortHandler: function ($grid, column) { + return function () { + var data, params = {}; + if ($grid.count() > 0) { + data = $grid.data(); + params[data.paramNames.sortBy] = column.field; + column.direction = (column.direction === 'asc' ? 'desc' : 'asc'); + params[data.paramNames.direction] = column.direction; + $grid.reload(params); + } + }; + }, + + updateHeader: function ($grid) { + var $sortIcon, $cellTitle, + data = $grid.data(), + sortBy = data.params[data.paramNames.sortBy], + direction = data.params[data.paramNames.direction]; + + $grid.find('thead tr th [data-role="sorticon"]').remove(); + + if (sortBy) { + position = bt.grid.methods.getColumnPosition($grid.data('columns'), sortBy); + if (position > -1) { + $cellTitle = $grid.find('thead tr th:eq(' + position + ') div[data-role="title"]'); + $sortIcon = $('
').append(('desc' === direction) ? data.icons.desc : data.icons.asc); + $cellTitle.after($sortIcon); + } + } + }, + + useHtmlDataSource: function ($grid, data) { + var dataSource = [], i, j, $cells, record, + $rows = $grid.find('tbody tr[data-role != "empty"]'); + for (i = 0; i < $rows.length; i++) { + $cells = $($rows[i]).find('td'); + record = {}; + for (j = 0; j < $cells.length; j++) { + record[data.columns[j].field] = $($cells[j]).html(); + } + dataSource.push(record); + } + data.dataSource = dataSource; + }, + + startLoading: function ($grid) { + var $tbody, $cover, $loading, width, height, top, data; + bt.grid.methods.stopLoading($grid); + data = $grid.data(); + if (0 === $grid.outerHeight()) { + return; + } + $tbody = $grid.children('tbody'); + width = $tbody.outerWidth(false); + height = $tbody.outerHeight(false); + top = Math.abs($grid.parent().offset().top - $tbody.offset().top); + $cover = $('
').addClass(data.style.loadingCover).css({ + width: width, + height: height, + top: top + }); + $loading = $('
' + bt.grid.messages[data.locale].Loading + '
').addClass(data.style.loadingText); + $loading.insertAfter($grid); + $cover.insertAfter($grid); + $loading.css({ + top: top + (height / 2) - ($loading.outerHeight(false) / 2), + left: (width / 2) - ($loading.outerWidth(false) / 2) + }); + }, + + stopLoading: function ($grid) { + $grid.parent().find('div[data-role="loading-cover"]').remove(); + $grid.parent().find('div[data-role="loading-text"]').remove(); + }, + + appendEmptyRow: function ($grid, caption) { + var data, $row, $cell, $wrapper; + data = $grid.data(); + $row = $(''); + $cell = $('').css({ width: '100%', 'text-align': 'center' }); + $cell.attr('colspan', bt.grid.methods.countVisibleColumns($grid)); + $wrapper = $('
').html(caption || data.notFoundText); + $cell.append($wrapper); + $row.append($cell); + + bt.grid.events.beforeEmptyRowInsert($grid, $row); + + $grid.append($row); + }, + + autoGenerateColumns: function ($grid, records) { + var names, value, type, i, data = $grid.data(); + data.columns = []; + if (records.length > 0) { + names = Object.getOwnPropertyNames(records[0]); + for (i = 0; i < names.length; i++) { + value = records[0][names[i]]; + type = 'text'; + if (value) { + if (typeof value === 'number') { + type = 'number'; + } else if (value.indexOf('/Date(') > -1) { + type = 'date'; + } + } + data.columns.push({ field: names[i], type: type }); + } + bt.grid.methods.setDefaultColumnConfig(data.columns, data.defaultColumnSettings); + } + bt.grid.methods.renderHeader($grid); + }, + + loadData: function ($grid) { + var data, records, i, recLen, rowCount, $tbody, $rows, $row; + + data = $grid.data(); + records = $grid.getAll(); + bt.grid.events.dataBinding($grid, records); + recLen = records.length; + bt.grid.methods.stopLoading($grid); + + if (data.autoGenerateColumns) { + bt.grid.methods.autoGenerateColumns($grid, records); + } + + $tbody = $grid.children('tbody'); + if ('checkbox' === data.selectionMethod && 'multiple' === data.selectionType) { + $grid.find('thead input[data-role="selectAll"]').prop('checked', false); + } + $tbody.children('tr').not('[data-role="row"]').remove(); + if (0 === recLen) { + $tbody.empty(); + bt.grid.methods.appendEmptyRow($grid); + } + + $rows = $tbody.children('tr'); + + rowCount = $rows.length; + + for (i = 0; i < rowCount; i++) { + if (i < recLen) { + $row = $rows.eq(i); + bt.grid.methods.renderRow($grid, $row, records[i], i); + } else { + $tbody.find('tr[data-role="row"]:gt(' + (i - 1) + ')').remove(); + break; + } + } + + for (i = rowCount; i < recLen; i++) { + bt.grid.methods.renderRow($grid, null, records[i], i); + } + bt.grid.events.dataBound($grid, records, data.totalRecords); + }, + + getId: function (record, primaryKey, position) { + return (primaryKey && record[primaryKey]) ? record[primaryKey] : position; + }, + + renderRow: function ($grid, $row, record, position) { + var id, $cell, i, data, mode; + data = $grid.data(); + if (!$row || $row.length === 0) { + mode = 'create'; + $row = $(''); + $grid.children('tbody').append($row); + } else { + mode = 'update'; + $row.removeClass(data.style.content.rowSelected).removeAttr('data-selected').off('click'); + } + id = bt.grid.methods.getId(record, data.primaryKey, (position + 1)); + $row.attr('data-position', position + 1); + if (data.selectionMethod !== 'checkbox') { + $row.on('click', bt.grid.methods.createRowClickHandler($grid, id)); + } + for (i = 0; i < data.columns.length; i++) { + if (mode === 'update') { + $cell = $row.find('td:eq(' + i + ')'); + bt.grid.methods.renderCell($grid, $cell, data.columns[i], record, id); + } else { + $cell = bt.grid.methods.renderCell($grid, null, data.columns[i], record, id); + $row.append($cell); + } + } + bt.grid.events.rowDataBound($grid, $row, id, record); + }, + + renderCell: function ($grid, $cell, column, record, id, mode) { + var $displayEl, key; + + if (!$cell || $cell.length === 0) { + $cell = $(''); + $displayEl = $('
'); + column.align && $cell.css('text-align', column.align); + column.cssClass && $cell.addClass(column.cssClass); + $cell.append($displayEl); + mode = 'create'; + } else { + $displayEl = $cell.find('div[data-role="display"]'); + mode = 'update'; + } + + bt.grid.methods.renderDisplayElement($grid, $displayEl, column, record, id, mode); + + //remove all event handlers + if ('update' === mode) { + $cell.off(); + $displayEl.off(); + } + if (column.events) { + for (key in column.events) { + if (column.events.hasOwnProperty(key)) { + $cell.on(key, { id: id, field: column.field, record: record }, bt.grid.methods.createCellEventHandler(column, column.events[key])); + } + } + } + if (column.hidden) { + $cell.hide(); + } + + bt.grid.events.cellDataBound($grid, $displayEl, id, column, record); + + return $cell; + }, + + createCellEventHandler: function (column, func) { + return function (e) { + if (column.stopPropagation) { + e.stopPropagation(); + } + func.call(this, e); + }; + }, + + renderDisplayElement: function ($grid, $displayEl, column, record, id, mode) { + var text, $checkbox; + + if ('checkbox' === column.type && bt.checkbox) { + if ('create' === mode) { + $checkbox = $('').val(id).prop('checked', (record[column.field] ? true : false)); + column.role && $checkbox.attr('data-role', column.role); + $displayEl.append($checkbox); + $checkbox.checkbox({ uiLibrary: $grid.data('uiLibrary') }); + if (column.role === 'selectRow') { + $checkbox.on('click', function () { return false; }); + } else { + $checkbox.prop('disabled', true); + } + } else { + $displayEl.find('input[type="checkbox"]').val(id).prop('checked', (record[column.field] ? true : false)); + } + } else if ('icon' === column.type) { + if ('create' === mode) { + $displayEl.append($('').addClass(column.icon).css({ cursor: 'pointer' })); + $grid.data().uiLibrary === 'bootstrap' && $displayEl.children('span').addClass('glyphicon'); + column.stopPropagation = true; + } + } else if (column.tmpl) { + text = column.tmpl; + column.tmpl.replace(/\{(.+?)\}/g, function ($0, $1) { + text = text.replace($0, bt.grid.methods.formatText(record[$1], column)); + }); + $displayEl.html(text); + } else if (column.renderer && typeof (column.renderer) === 'function') { + text = column.renderer(record[column.field], record, $displayEl.parent(), $displayEl, id, $grid); + if (text) { + $displayEl.html(text); + } + } else { + record[column.field] = bt.grid.methods.formatText(record[column.field], column); + if (!column.tooltip && record[column.field]) { + $displayEl.attr('title', record[column.field]); + } + $displayEl.html(record[column.field]); + } + if (column.tooltip && 'create' === mode) { + $displayEl.attr('title', column.tooltip); + } + }, + + formatText: function (text, column) { + if (text && column.type === 'date') { + text = bt.core.formatDate(bt.core.parseDate(text, column.format), column.format); + } else { + text = (typeof (text) === 'undefined' || text === null) ? '' : text.toString(); + } + if (column.decimalDigits && text) { + text = parseFloat(text).toFixed(column.decimalDigits); + } + return text; + }, + + setRecordsData: function ($grid, response) { + var records = [], + totalRecords = 0, + data = $grid.data(); + if ($.isArray(response)) { + records = response; + totalRecords = response.length; + } else if (data && data.mapping && $.isArray(response[data.mapping.dataField])) { + records = response[data.mapping.dataField]; + totalRecords = response[data.mapping.totalRecordsField]; + if (!totalRecords || isNaN(totalRecords)) { + totalRecords = 0; + } + } + $grid.data('records', records); + $grid.data('totalRecords', totalRecords); + return records; + }, + + createRowClickHandler: function ($grid, id) { + return function () { + bt.grid.methods.setSelected($grid, id, $(this)); + }; + }, + + selectRow: function ($grid, data, $row, id) { + var $checkbox; + $row.addClass(data.style.content.rowSelected); + $row.attr('data-selected', 'true'); + if ('checkbox' === data.selectionMethod) { + $checkbox = $row.find('input[type="checkbox"][data-role="selectRow"]'); + $checkbox.length && !$checkbox.prop('checked') && $checkbox.prop('checked', true); + if ('multiple' === data.selectionType && $grid.getSelections().length === $grid.count(false)) { + $grid.find('thead input[data-role="selectAll"]').prop('checked', true); + } + } + return bt.grid.events.rowSelect($grid, $row, id, $grid.getById(id)); + }, + + unselectRow: function ($grid, data, $row, id) { + var $checkbox; + if ($row.attr('data-selected') === 'true') { + $row.removeClass(data.style.content.rowSelected); + if ('checkbox' === data.selectionMethod) { + $checkbox = $row.find('td input[type="checkbox"][data-role="selectRow"]'); + $checkbox.length && $checkbox.prop('checked') && $checkbox.prop('checked', false); + if ('multiple' === data.selectionType) { + $grid.find('thead input[data-role="selectAll"]').prop('checked', false); + } + } + $row.removeAttr('data-selected'); + return bt.grid.events.rowUnselect($grid, $row, id, $grid.getById(id)); + } + }, + + setSelected: function ($grid, id, $row) { + var data = $grid.data(); + if (!$row || !$row.length) { + $row = bt.grid.methods.getRowById($grid, id); + } + if ($row) { + if ($row.attr('data-selected') === 'true') { + bt.grid.methods.unselectRow($grid, data, $row, id); + } else { + if ('single' === data.selectionType) { + $row.siblings('[data-selected="true"]').each(function () { + var $row = $(this), + id = bt.grid.methods.getId($row, data.primaryKey, $row.data('position')); + bt.grid.methods.unselectRow($grid, data, $row, id); + }); + } + bt.grid.methods.selectRow($grid, data, $row, id); + } + } + return $grid; + }, + + selectAll: function ($grid) { + var data = $grid.data(); + $grid.find('tbody tr[data-role="row"]').each(function () { + var $row = $(this), + position = $row.data('position'), + record = $grid.get(position), + id = bt.grid.methods.getId(record, data.primaryKey, position); + bt.grid.methods.selectRow($grid, data, $row, id); + }); + $grid.find('thead input[data-role="selectAll"]').prop('checked', true); + return $grid; + }, + + unSelectAll: function ($grid) { + var data = $grid.data(); + $grid.find('tbody tr').each(function () { + var $row = $(this), + position = $row.data('position'), + record = $grid.get(position), + id = bt.grid.methods.getId(record, data.primaryKey, position); + bt.grid.methods.unselectRow($grid, data, $row, id); + $row.find('input[type="checkbox"][data-role="selectRow"]').prop('checked', false); + }); + $grid.find('thead input[data-role="selectAll"]').prop('checked', false); + return $grid; + }, + + getSelected: function ($grid) { + var result = null, selections, record, position; + selections = $grid.find('tbody>tr[data-selected="true"]'); + if (selections.length > 0) { + position = $(selections[0]).data('position'); + record = $grid.get(position); + result = bt.grid.methods.getId(record, $grid.data().primaryKey, position); + } + return result; + }, + + getSelectedRows: function ($grid) { + var data = $grid.data(); + return $grid.find('tbody>tr[data-selected="true"]'); + }, + + getSelections: function ($grid) { + var result = [], position, record, + data = $grid.data(), + $selections = bt.grid.methods.getSelectedRows($grid); + if (0 < $selections.length) { + $selections.each(function () { + position = $(this).data('position'); + record = $grid.get(position); + result.push(bt.grid.methods.getId(record, data.primaryKey, position)); + }); + } + return result; + }, + + getById: function ($grid, id) { + var result = null, i, primaryKey = $grid.data('primaryKey'), records = $grid.data('records'); + if (primaryKey) { + for (i = 0; i < records.length; i++) { + if (records[i][primaryKey] == id) { + result = records[i]; + break; + } + } + } else { + result = $grid.get(id); + } + return result; + }, + + getRecVPosById: function ($grid, id) { + var result = id, i, data = $grid.data(); + if (data.primaryKey) { + for (i = 0; i < data.dataSource.length; i++) { + if (data.dataSource[i][data.primaryKey] == id) { + result = i; + break; + } + } + } + return result; + }, + + getRowById: function ($grid, id) { + var records = $grid.getAll(false), + primaryKey = $grid.data('primaryKey'), + $result = undefined, + position, + i; + if (primaryKey) { + for (i = 0; i < records.length; i++) { + if (records[i][primaryKey] == id) { + position = i + 1; + break; + } + } + } else { + position = id; + } + if (position) { + $result = $grid.children('tbody').children('tr[data-position="' + position + '"]'); + } + return $result; + }, + + getByPosition: function ($grid, position) { + return $grid.getAll(false)[position - 1]; + }, + + getColumnPosition: function (columns, field) { + var position = -1, i; + for (i = 0; i < columns.length; i++) { + if (columns[i].field === field) { + position = i; + break; + } + } + return position; + }, + + getColumnInfo: function ($grid, field) { + var i, result = {}, data = $grid.data(); + for (i = 0; i < data.columns.length; i += 1) { + if (data.columns[i].field === field) { + result = data.columns[i]; + break; + } + } + return result; + }, + + getCell: function ($grid, id, field) { + var position, $row, $result = null; + position = bt.grid.methods.getColumnPosition($grid.data('columns'), field); + if (position > -1) { + $row = bt.grid.methods.getRowById($grid, id); + $result = $row.find('td:eq(' + position + ') div[data-role="display"]'); + } + return $result; + }, + + setCellContent: function ($grid, id, field, value) { + var column, $displayEl = bt.grid.methods.getCell($grid, id, field); + if ($displayEl) { + $displayEl.empty(); + if (typeof (value) === 'object') { + $displayEl.append(value); + } else { + column = bt.grid.methods.getColumnInfo($grid, field); + bt.grid.methods.renderDisplayElement($grid, $displayEl, column, $grid.getById(id), id, 'update'); + } + } + }, + + clone: function (source) { + var target = []; + $.each(source, function () { + target.push(this.clone()); + }); + return target; + }, + + getAll: function ($grid) { + return $grid.data('records'); + }, + + countVisibleColumns: function ($grid) { + var columns, count, i; + columns = $grid.data().columns; + count = 0; + for (i = 0; i < columns.length; i++) { + if (columns[i].hidden !== true) { + count++; + } + } + return count; + }, + + clear: function ($grid, showNotFoundText) { + var data = $grid.data(); + $grid.xhr && $grid.xhr.abort(); + $grid.children('tbody').empty(); + data.records = []; + bt.grid.methods.stopLoading($grid); + bt.grid.methods.appendEmptyRow($grid, showNotFoundText ? data.notFoundText : ' '); + bt.grid.events.dataBound($grid, [], 0); + return $grid; + }, + + render: function ($grid, response) { + if (response) { + bt.grid.methods.setRecordsData($grid, response); + bt.grid.methods.updateHeader($grid); + bt.grid.methods.loadData($grid); + } + return $grid; + }, + + filter: function ($grid) { + var field, column, + data = $grid.data(), + records = data.dataSource.slice(); + + if (data.params[data.paramNames.sortBy]) { + column = bt.grid.methods.getColumnInfo($grid, data.params[data.paramNames.sortBy]); + records.sort(column.sortable.sorter ? column.sortable.sorter(column.direction, column) : bt.grid.methods.createDefaultSorter(column.direction, column.field)); + } + + for (field in data.params) { + if (data.params[field] && !data.paramNames[field]) { + column = bt.grid.methods.getColumnInfo($grid, field); + records = $.grep(records, function (record) { + var value = record[field] || '', + searchStr = data.params[field] || ''; + return column && typeof (column.filter) === 'function' ? column.filter(value, searchStr) : (value.toUpperCase().indexOf(searchStr.toUpperCase()) > -1); + }); + } + } + + bt.grid.events.dataFiltered($grid, records); + + return records; + }, + + createDefaultSorter: function (direction, field) { + return function (recordA, recordB) { + var a = (recordA[field] || '').toString(), + b = (recordB[field] || '').toString(); + return (direction === 'asc') ? a.localeCompare(b) : b.localeCompare(a); + }; + }, + + destroy: function ($grid, keepTableTag, keepWrapperTag) { + var data = $grid.data(); + if (data) { + bt.grid.events.destroying($grid); + bt.grid.methods.stopLoading($grid); + $grid.xhr && $grid.xhr.abort(); + $grid.off(); + if (keepWrapperTag === false && $grid.parent('div[data-role="wrapper"]').length > 0) { + $grid.unwrap(); + } + $grid.removeData(); + if (keepTableTag === false) { + $grid.remove(); + } else { + $grid.removeClass().empty(); + } + $grid.removeAttr('data-type'); + } + return $grid; + }, + + showColumn: function ($grid, field) { + var data = $grid.data(), + position = bt.grid.methods.getColumnPosition(data.columns, field), + $cells; + + if (position > -1) { + $grid.find('thead>tr').each(function() { + $(this).children('th').eq(position).show(); + }); + $.each($grid.find('tbody>tr'), function () { + $(this).children('td').eq(position).show(); + }); + data.columns[position].hidden = false; + + $cells = $grid.find('tbody > tr[data-role="empty"] > td'); + if ($cells && $cells.length) { + $cells.attr('colspan', bt.grid.methods.countVisibleColumns($grid)); + } + + bt.grid.events.columnShow($grid, data.columns[position]); + } + + return $grid; + }, + + hideColumn: function ($grid, field) { + var data = $grid.data(), + position = bt.grid.methods.getColumnPosition(data.columns, field), + $cells; + + if (position > -1) { + $grid.find('thead>tr').each(function () { + $(this).children('th').eq(position).hide(); + }); + $.each($grid.find('tbody>tr'), function () { + $(this).children('td').eq(position).hide(); + }); + data.columns[position].hidden = true; + + $cells = $grid.find('tbody > tr[data-role="empty"] > td'); + if ($cells && $cells.length) { + $cells.attr('colspan', bt.grid.methods.countVisibleColumns($grid)); + } + + bt.grid.events.columnHide($grid, data.columns[position]); + } + + return $grid; + }, + + isLastRecordVisible: function () { + return true; + }, + + addRow: function ($grid, record) { + var data = $grid.data(); + data.totalRecords = $grid.data('totalRecords') + 1; + bt.grid.events.dataBinding($grid, [record]); + data.records.push(record); + if ($.isArray(data.dataSource)) { + data.dataSource.push(record); + } + if (data.totalRecords === 1) { + $grid.children('tbody').empty(); + } + if (bt.grid.methods.isLastRecordVisible($grid)) { + bt.grid.methods.renderRow($grid, null, record, $grid.count() - 1); + } + bt.grid.events.dataBound($grid, [record], data.totalRecords); + return $grid; + }, + + updateRow: function ($grid, id, record) { + var $row = bt.grid.methods.getRowById($grid, id), + data = $grid.data(), position; + data.records[$row.data('position') - 1] = record; + if ($.isArray(data.dataSource)) { + position = bt.grid.methods.getRecVPosById($grid, id); + data.dataSource[position] = record; + } + bt.grid.methods.renderRow($grid, $row, record, $row.index()); + return $grid; + }, + + removeRow: function ($grid, id) { + var position, + data = $grid.data(), + $row = bt.grid.methods.getRowById($grid, id); + + bt.grid.events.rowRemoving($grid, $row, id, $grid.getById(id)); + if ($.isArray(data.dataSource)) { + position = bt.grid.methods.getRecVPosById($grid, id); + data.dataSource.splice(position, 1); + } + $grid.reload(); + return $grid; + }, + + count: function ($grid, includeAllRecords) { + return includeAllRecords ? $grid.data().totalRecords : $grid.getAll().length; + }, + + getColumnPositionByRole: function ($grid, role) { + var i, result, columns = $grid.data('columns'); + for (i = 0; i < columns.length; i++) { + if (columns[i].role === role) { + result = i; + break; + } + } + return result; + }, + + getColumnPositionNotInRole: function ($grid) { + var i, result = 0, columns = $grid.data('columns'); + for (i = 0; i < columns.length; i++) { + if (!columns[i].role) { + result = i; + break; + } + } + return result; + } +}; + +/** + * @widget Grid + * @plugin Base + */ +bt.grid.widget = function ($grid, jsConfig) { + var self = this, + methods = bt.grid.methods; + + /** + * Reload the data in the grid from a data source. + * @method + * @param {object} params - An object that contains a list with parameters that are going to be send to the server. + * @fires beforeEmptyRowInsert, dataBinding, dataBound, cellDataBound + * @return grid + * @example sample + * + * + *

+ *
+ * + */ + self.reload = function (params) { + methods.startLoading(this); + return bt.widget.prototype.reload.call(this, params); + }; + + /** + * Clear the content in the grid. + * @method + * @param {boolean} showNotFoundText - Indicates if the "Not Found" text is going to show after the clearing of the grid. + * @return grid + * @example sample + * + *

+ *
+ * + */ + self.clear = function (showNotFoundText) { + return methods.clear(this, showNotFoundText); + }; + + /** + * Return the number of records in the grid. By default return only the records that are visible in the grid. + * @method + * @param {boolean} includeAllRecords - include records that are not visible when you are using local dataSource. + * @return number + * @example Local.DataSource + * + * + *

+ *
+ * + * @example Remote.DataSource + * + * + *

+ *
+ * + */ + self.count = function (includeAllRecords) { + return methods.count(this, includeAllRecords); + }; + + /** + * Render data in the grid + * @method + * @param {object} response - An object that contains the data that needs to be loaded in the grid. + * @fires beforeEmptyRowInsert, dataBinding, dataBound, cellDataBound + * @return grid + * @example sample + *
+ * + */ + self.render = function (response) { + return methods.render($grid, response); + }; + + /** + * Destroy the grid. This method remove all data from the grid and all events attached to the grid. + * @additionalinfo The grid table tag and wrapper tag are kept by default after the execution of destroy method, + * but you can remove them if you pass false to the keepTableTag and keepWrapperTag parameters. + * @method + * @param {boolean} keepTableTag - If this flag is set to false, the table tag will be removed from the HTML dom tree. + * @param {boolean} keepWrapperTag - If this flag is set to false, the table wrapper tag will be removed from the HTML dom tree. + * @fires destroying + * @return void + * @example keep.wrapper.and.table + * + * + *

+ *
+ * + * @example remove.wrapper.and.table + * + *

+ *
+ * + */ + self.destroy = function (keepTableTag, keepWrapperTag) { + return methods.destroy(this, keepTableTag, keepWrapperTag); + }; + + /** + * Select a row from the grid based on id parameter. + * @method + * @param {string} id - The id of the row that needs to be selected + * @return grid + * @example sample + * + * + *

+ *
+ * + */ + self.setSelected = function (id) { + return methods.setSelected(this, id); + }; + + /** + * Return the id of the selected record. + * If the multiple selection method is one this method is going to return only the id of the first selected record. + * @method + * @return string + * @example sample + * + *

+ *
+ * + */ + self.getSelected = function () { + return methods.getSelected(this); + }; + + /** + * Return an array with the ids of the selected record. + * @additionalinfo Specify primaryKey if you want to use field from the dataSource as identificator for selection. + * @method + * @return array + * @example With.Primary.Ket + * + *

+ *
+ * + * @example Without.Primary.Ket + * + *

+ *
+ * + */ + self.getSelections = function () { + return methods.getSelections(this); + }; + + /** + * Select all records from the grid. + * @method + * @return grid + * @example sample + * + *

+ *
+ * + */ + self.selectAll = function () { + return methods.selectAll(this); + }; + + /** + * Unselect all records from the grid. + * @method + * @return void + * @example sample + * + * + *

+ *
+ * + */ + self.unSelectAll = function () { + return methods.unSelectAll(this); + }; + + /** + * Return record by id of the record. + * @method + * @param {string} id - The id of the row that needs to be returned. + * @return object + * @example sample + * + *

+ *
+ * + */ + self.getById = function (id) { + return methods.getById(this, id); + }; + + /** + * Return record from the grid based on position. + * @method + * @param {number} position - The position of the row that needs to be return. + * @return object + * @example sample + * + *

+ *
+ * + */ + self.get = function (position) { + return methods.getByPosition(this, position); + }; + + /** + * Return an array with all records presented in the grid. + * @method + * @param {boolean} includeAllRecords - include records that are not visible when you are using local dataSource. + * @return number + * @example Local.DataSource + * + * + *

+ *
+ * + * @example Remote.DataSource + * + * + *

+ *
+ * + */ + self.getAll = function (includeAllRecords) { + return methods.getAll(this, includeAllRecords); + }; + + /** + * Show hidden column. + * @method + * @param {string} field - The name of the field bound to the column. + * @return grid + * @example sample + * + *

+ *
+ * + */ + self.showColumn = function (field) { + return methods.showColumn(this, field); + }; + + /** + * Hide column from the grid. + * @method + * @param {string} field - The name of the field bound to the column. + * @return grid + * @example sample + * + *

+ *
+ * + */ + self.hideColumn = function (field) { + return methods.hideColumn(this, field); + }; + + /** + * Add new row to the grid. + * @method + * @param {object} record - Object with data for the new record. + * @return grid + * @example without.pagination + * + *

+ *
+ * + * @example with.pagination + * + *

+ *
+ * + */ + self.addRow = function (record) { + return methods.addRow(this, record); + }; + + /** + * Update row data. + * @method + * @param {string} id - The id of the row that needs to be updated + * @param {object} record - Object with data for the new record. + * @return grid + * @example sample + *
+ * + */ + self.updateRow = function (id, record) { + return methods.updateRow(this, id, record); + }; + + //TODO: needs to be removed + self.setCellContent = function (id, index, value) { + methods.setCellContent(this, id, index, value); + }; + + /** + * Remove row from the grid + * @additionalinfo This method is design to work only with local datasources. If you use remote datasource, you need to send a request to the server to remove the row and then reload the data in the grid. + * @method + * @param {string} id - Id of the record that needs to be removed. + * @return grid + * @example Without.Pagination + *
+ * + * @example With.Pagination + *
+ * + */ + self.removeRow = function (id) { + return methods.removeRow(this, id); + }; + + $.extend($grid, self); + if ('grid' !== $grid.attr('data-type')) { + methods.init.call($grid, jsConfig); + } + + return $grid; +} + +bt.grid.widget.prototype = new bt.widget(); +bt.grid.widget.constructor = bt.grid.widget; + +bt.grid.widget.prototype.getConfig = bt.grid.methods.getConfig; +bt.grid.widget.prototype.getHTMLConfig = bt.grid.methods.getHTMLConfig; + +(function ($) { + $.fn.grid = function (method) { + var $widget; + if (this && this.length) { + if (typeof method === 'object' || !method) { + return new bt.grid.widget(this, method); + } else { + $widget = new bt.grid.widget(this, null); + if ($widget[method]) { + return $widget[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + throw 'Method ' + method + ' does not exist.'; + } + } + } + }; +})(jQuery); + +/** + * @widget Grid + * @plugin Fixed Header + */ +bt.grid.plugins.fixedHeader = { + config: { + base: { + + /** If set to true, add scroll to the table body + * @type boolean + * @default object + * @example Material.Design.Without.Pager + *
+ * + * @example Material.Design.With.Pager + *
+ * + * @example Bootstrap.3.Without.Pager + *
+ * + * @example Bootstrap.3.With.Pager + *
+ * + * @example Bootstrap.4 + *
+ * + */ + fixedHeader: false, + + height: 300 + } + }, + + private: { + init: function ($grid) { + var data = $grid.data(), + $tbody = $grid.children('tbody'), + $thead = $grid.children('thead'), + bodyHeight = data.height - $thead.outerHeight() - ($grid.children('tfoot').outerHeight() || 0); + $grid.addClass('bt-grid-scrollable'); + $tbody.css('width', $thead.outerWidth()); + $tbody.height(bodyHeight); + }, + + refresh: function ($grid) { + var i, width, + data = $grid.data(), + $tbody = $grid.children('tbody'), + $thead = $grid.children('thead'), + $tbodyCells = $grid.find('tbody tr[data-role="row"] td'), + $theadCells = $grid.find('thead tr[data-role="caption"] th'); + + if ($grid.children('tbody').height() < bt.grid.plugins.fixedHeader.private.getRowsHeight($grid)) { + $tbody.css('width', $thead.outerWidth() + bt.grid.plugins.fixedHeader.private.getScrollBarWidth() + (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 ? 1 : 0)); + } else { + $tbody.css('width', $thead.outerWidth()); + } + + for (i = 0; i < $theadCells.length; i++) { + width = $($theadCells[i]).outerWidth(); + if (i === 0 && bt.core.isIE()) { + width = width - 1; + } + $($tbodyCells[i]).attr('width', width); + } + }, + + getRowsHeight: function ($grid) { + var total = 0; + $grid.find('tbody tr').each(function () { + total += $(this).height(); + }); + return total; + }, + + getScrollBarWidth: function () { + var inner = document.createElement('p'); + inner.style.width = "100%"; + inner.style.height = "200px"; + + var outer = document.createElement('div'); + outer.style.position = "absolute"; + outer.style.top = "0px"; + outer.style.left = "0px"; + outer.style.visibility = "hidden"; + outer.style.width = "200px"; + outer.style.height = "150px"; + outer.style.overflow = "hidden"; + outer.appendChild(inner); + + document.body.appendChild(outer); + var w1 = inner.offsetWidth; + outer.style.overflow = 'scroll'; + var w2 = inner.offsetWidth; + if (w1 == w2) w2 = outer.clientWidth; + + document.body.removeChild(outer); + + return (w1 - w2); + } + }, + + public: { + }, + + events: { + }, + + configure: function ($grid, fullConfig, clientConfig) { + $.extend(true, $grid, bt.grid.plugins.fixedHeader.public); + var data = $grid.data(); + if (clientConfig.fixedHeader) { + $grid.on('initialized', function () { + bt.grid.plugins.fixedHeader.private.init($grid); + }); + $grid.on('dataBound', function () { + bt.grid.plugins.fixedHeader.private.refresh($grid); + }); + $grid.on('resize', function () { + bt.grid.plugins.fixedHeader.private.refresh($grid); + }); + } + } +}; + +/** + * @widget Grid + * @plugin Expand Collapse Rows + */ +bt.grid.plugins.expandCollapseRows = { + config: { + base: { + /** Template for the content in the detail section of the row. + * Automatically add expand collapse column as a first column in the grid during initialization. + * @type string + * @default undefined + * @example Material.Design + *
+ * + * @example Bootstrap.3 + *
+ * + * @example Bootstrap.4.Font.Awesome + *
+ * + */ + detailTemplate: undefined, + + /** If set try to persist the state of expanded rows. + * You need to specify primaryKey on the initialization of the grid in order to enable this feature. + * @default true + * @example True + *
+ *
+ *
+ *

Expand row, then change the page and return back to the page with expanded row in order to see that the expansion is kept.

+ *
+ *
+ *
+ *
+ * + */ + keepExpandedRows: true, + + expandedRows: [], + + icons: { + /** Expand row icon definition. + * @alias icons.expandRow + * @type String + * @default '' + * @example Plus.Minus.Icons + *
+ * + */ + expandRow: '', + + /** Collapse row icon definition. + * @alias icons.collapseRow + * @type String + * @default '' + * @example Plus.Minus.Icons + *
+ * + */ + collapseRow: '' + } + }, + + fontawesome: { + icons: { + expandRow: '', + collapseRow: '' + } + }, + + glyphicons: { + icons: { + expandRow: '', + collapseRow: '' + } + } + }, + + 'private': { + expandDetail: function ($grid, $cell, id) { + var $contentRow = $cell.closest('tr'), + $detailsRow = $(''), + $detailsCell = $(''), + $detailsWrapper = $('
'), + data = $grid.data(), + position = $contentRow.data('position'), + record = $grid.get(position), + plugin = bt.grid.plugins.expandCollapseRows; + + if (typeof (id) === undefined) { + id = bt.grid.methods.getId(record, data.primaryKey, record); + } + $detailsRow.append($detailsCell.append($detailsWrapper.append($contentRow.data('details')))); + $detailsRow.insertAfter($contentRow); + $cell.children('div[data-role="display"]').empty().append(data.icons.collapseRow); + $grid.updateDetails($contentRow); + plugin.private.keepSelection($grid, id); + plugin.events.detailExpand($grid, $detailsRow.find('td>div'), id); + }, + + collapseDetail: function ($grid, $cell, id) { + var $contentRow = $cell.closest('tr'), + $detailsRow = $contentRow.next('tr[data-role="details"]'), + data = $grid.data(), + plugin = bt.grid.plugins.expandCollapseRows; + + if (typeof (id) === undefined) { + id = bt.grid.methods.getId(record, data.primaryKey, record); + } + $detailsRow.remove(); + $cell.children('div[data-role="display"]').empty().append(data.icons.expandRow); + plugin.private.removeSelection($grid, id); + plugin.events.detailCollapse($grid, $detailsRow.find('td>div'), id); + }, + + keepSelection: function($grid, id) { + var data = $grid.data(); + if (data.keepExpandedRows) { + if ($.isArray(data.expandedRows)) { + if (data.expandedRows.indexOf(id) == -1) { + data.expandedRows.push(id); + } + } else { + data.expandedRows = [id]; + } + } + }, + + removeSelection: function ($grid, id) { + var data = $grid.data(); + if (data.keepExpandedRows && $.isArray(data.expandedRows) && data.expandedRows.indexOf(id) > -1) { + data.expandedRows.splice(data.expandedRows.indexOf(id), 1); + } + }, + + updateDetailsColSpan: function ($grid) { + var $cells = $grid.find('tbody > tr[data-role="details"] > td'); + if ($cells && $cells.length) { + $cells.attr('colspan', bt.grid.methods.countVisibleColumns($grid)); + } + } + }, + + 'public': { + + /** + * Collapse all grid rows. + * @method + * @return jQuery object + * @example Sample + * + * + *

+ *
+ * + */ + collapseAll: function () { + var $grid = this, data = $grid.data(), position; + + + if (typeof (data.detailTemplate) !== 'undefined') { + position = bt.grid.methods.getColumnPositionByRole($grid, 'expander'); + $grid.find('tbody tr[data-role="row"]').each(function () { + bt.grid.plugins.expandCollapseRows.private.collapseDetail($grid, $(this).find('td:eq(' + position + ')')); + }); + } + + if (typeof (data.grouping) !== 'undefined') { + $grid.find('tbody tr[role="group"]').each(function () { + bt.grid.plugins.grouping.private.collapseGroup(data, $(this).find('td:eq(0)')); + }); + } + return $grid; + }, + + /** + * Expand all grid rows. + * @method + * @return jQuery object + * @example Sample + * + * + *

+ *
+ * + */ + expandAll: function () { + var $grid = this, data = $grid.data(), position; + + if (typeof (data.detailTemplate) !== 'undefined') { + position = bt.grid.methods.getColumnPositionByRole($grid, 'expander'); + $grid.find('tbody tr[data-role="row"]').each(function () { + bt.grid.plugins.expandCollapseRows.private.expandDetail($grid, $(this).find('td:eq(' + position + ')')); + }); + } + + if (typeof (data.grouping) !== 'undefined') { + $grid.find('tbody tr[role="group"]').each(function () { + bt.grid.plugins.grouping.private.expandGroup(data, $(this).find('td:eq(0)')); + }); + } + return $grid; + }, + + //TODO: add documentation + updateDetails: function ($contentRow) { + var $grid = this, + $detailWrapper = $contentRow.data('details'), + content = $detailWrapper.html(), + record = $grid.get($contentRow.data('position')); + + if (record && content) { + $detailWrapper.html().replace(/\{(.+?)\}/g, function ($0, $1) { + var column = bt.grid.methods.getColumnInfo($grid, $1); + content = content.replace($0, bt.grid.methods.formatText(record[$1], column)); + }); + $detailWrapper.html(content); + } + return $grid; + } + }, + + 'events': { + /** + * Event fires when detail row is showing + * + * @event detailExpand + * @param {object} e - event data + * @param {object} detailWrapper - the detail wrapper as jQuery object + * @param {string} id - the id of the record + * @example sample + *
+ * + */ + detailExpand: function ($grid, $detailWrapper, id) { + $grid.triggerHandler('detailExpand', [$detailWrapper, id]); + }, + + /** + * Event fires when detail row is hiding + * + * @event detailCollapse + * @param {object} e - event data + * @param {object} detailWrapper - the detail wrapper as jQuery object + * @param {string} id - the id of the record + * @example sample + *
+ * + */ + detailCollapse: function ($grid, $detailWrapper, id) { + $grid.triggerHandler('detailCollapse', [$detailWrapper, id]); + } + }, + + 'configure': function ($grid) { + var column, data = $grid.data(); + + $.extend(true, $grid, bt.grid.plugins.expandCollapseRows.public); + + if (typeof (data.detailTemplate) !== 'undefined') { + column = { + title: '', + width: data.defaultIconColumnWidth, + align: 'center', + stopPropagation: true, + cssClass: 'bt-cursor-pointer bt-unselectable', + tmpl: data.icons.expandRow, + role: 'expander', + events: { + 'click': function (e) { + var $cell = $(this), methods = bt.grid.plugins.expandCollapseRows.private; + if ($cell.closest('tr').next().attr('data-role') === 'details') { + methods.collapseDetail($grid, $cell, e.data.id); + } else { + methods.expandDetail($grid, $(this), e.data.id); + } + } + } + }; + data.columns = [column].concat(data.columns); + + $grid.on('rowDataBound', function (e, $row, id, record) { + $row.data('details', $(data.detailTemplate)); + }); + $grid.on('columnShow', function (e, column) { + bt.grid.plugins.expandCollapseRows.private.updateDetailsColSpan($grid); + }); + $grid.on('columnHide', function (e, column) { + bt.grid.plugins.expandCollapseRows.private.updateDetailsColSpan($grid); + }); + $grid.on('rowRemoving', function (e, $row, id, record) { + bt.grid.plugins.expandCollapseRows.private.collapseDetail($grid, $row.children('td').first(), id); + }); + $grid.on('dataBinding', function () { + $grid.collapseAll(); + }); + $grid.on('pageChanging', function () { + $grid.collapseAll(); + }); + $grid.on('dataBound', function () { + var i, $cell, $row, position, data = $grid.data(); + if (data.keepExpandedRows && $.isArray(data.expandedRows)) { + for (i = 0; i < data.expandedRows.length; i++) { + $row = bt.grid.methods.getRowById($grid, data.expandedRows[i]); + if ($row && $row.length) { + position = bt.grid.methods.getColumnPositionByRole($grid, 'expander'); + $cell = $row.children('td:eq(' + position + ')'); + if ($cell && $cell.length) { + bt.grid.plugins.expandCollapseRows.private.expandDetail($grid, $cell); + } + } + } + } + }); + } + } +}; +/** + * @widget Grid + * @plugin Inline Editing + */ +bt.grid.plugins.inlineEditing = { + renderers: { + editManager: function (value, record, $cell, $displayEl, id, $grid) { + var data = $grid.data(), + $edit = $(data.inlineEditing.editButton).attr('key', id), + $delete = $(data.inlineEditing.deleteButton).attr('key', id), + $update = $(data.inlineEditing.updateButton).attr('key', id).hide(), + $cancel = $(data.inlineEditing.cancelButton).attr('key', id).hide(); + $edit.on('click', function (e) { + $grid.edit($(this).attr('key')); + }); + $delete.on('click', function (e) { + $grid.removeRow($(this).attr('key')); + }); + $update.on('click', function (e) { + $grid.update($(this).attr('key')); + }); + $cancel.on('click', function (e) { + $grid.cancel($(this).attr('key')); + }); + $displayEl.empty().append($edit).append($delete).append($update).append($cancel); + } + } +}; + +bt.grid.plugins.inlineEditing.config = { + base: { + defaultColumnSettings: { + /** Provides a way to set an editing UI for the column. + * @alias column.editor + * @type function|boolean + * @default undefined + * @example Material.Design + *
+ * + * @example Custom.With.Select2 + * + * + *
+ * + * @example Bootstrap.3 + *
+ * + * @example Bootstrap.4 + *
+ * + */ + editor: undefined, + + /** The name of the field in the grid data where the grid is going to set the new value. + * @additionalinfo This is usable when the editor is interface with key/value pairs like dropdowns where the key needs to be updated in a different field.. + * @alias column.editField + * @type String + * @default undefined + * @example Bootstrap.4 + *
+ * + */ + editField: undefined, + + /** Provides a way to specify a display mode for the column. + * @alias column.mode + * @type readEdit|editOnly|readOnly + * @default readEdit + * @example sample + *
+ * + */ + mode: 'readEdit' + }, + inlineEditing: { + + /** Inline editing mode. + * @alias inlineEditing.mode + * @type click|dblclick|command + * @default 'click' + * @example Double.Click + *
+ * + * @example Command + *
+ * + */ + mode: 'click', + + /** If set to true, add column with buttons for edit, delete, update and cancel at the end of the grid. + * @alias inlineEditing.managementColumn + * @type Boolean + * @default true + * @example True + *
+ * + * @example False + *
+ * + * @example Bootstrap + *
+ * + * @example Bootstrap.4 + *
+ * + */ + managementColumn: true, + + managementColumnConfig: { width: 300, role: 'managementColumn', align: 'center', renderer: bt.grid.plugins.inlineEditing.renderers.editManager, cssClass: 'bt-grid-management-column' } + } + }, + + bootstrap: { + inlineEditing: { + managementColumnConfig: { width: 200, role: 'managementColumn', align: 'center', renderer: bt.grid.plugins.inlineEditing.renderers.editManager, cssClass: 'bt-grid-management-column' } + } + }, + + bootstrap4: { + inlineEditing: { + managementColumnConfig: { width: 280, role: 'managementColumn', align: 'center', renderer: bt.grid.plugins.inlineEditing.renderers.editManager, cssClass: 'bt-grid-management-column' } + } + } +}; + +bt.grid.plugins.inlineEditing.private = { + localization: function (data) { + if (data.uiLibrary === 'bootstrap') { + data.inlineEditing.editButton = ''; + data.inlineEditing.deleteButton = ''; + data.inlineEditing.updateButton = ''; + data.inlineEditing.cancelButton = ''; + } else { + data.inlineEditing.editButton = ''; + data.inlineEditing.deleteButton = ''; + data.inlineEditing.updateButton = ''; + data.inlineEditing.cancelButton = ''; + } + }, + + editMode: function ($grid, $cell, column, record) { + var $displayContainer, $editorContainer, $editorField, value, config, data = $grid.data(); + if ($cell.attr('data-mode') !== 'edit') { + if (column.editor) { + bt.grid.plugins.inlineEditing.private.updateOtherCells($grid, column.mode); + $displayContainer = $cell.find('div[data-role="display"]').hide(); + $editorContainer = $cell.find('div[data-role="edit"]').show(); + if ($editorContainer.length === 0) { + $editorContainer = $('
'); + $cell.append($editorContainer); + } + value = record[column.editField || column.field]; + $editorField = $editorContainer.find('input, select, textarea').first(); + if ($editorField.length) { + column.type === 'checkbox' ? $editorField.prop('checked', value) : $editorField.val(value); + } else { + if (typeof (column.editor) === 'function') { + column.editor($editorContainer, value, record); + $editorField = $editorContainer.find('input, select, textarea').first(); + } else { + config = typeof column.editor === "object" ? column.editor : {}; + config.uiLibrary = data.uiLibrary; + config.iconsLibrary = data.iconsLibrary; + config.fontSize = $grid.css('font-size'); + if ('checkbox' === column.type && bt.checkbox) { + $editorField = $('').prop('checked', value); + $editorContainer.append($editorField); + $editorField.checkbox(config); + } else if ('date' === column.type && bt.datepicker) { + $editorField = $(''); + $editorContainer.append($editorField); + if (column.format) { + config.format = column.format; + } + $editorField = $editorField.datepicker(config); + if ($editorField.value) { + $editorField.value($displayContainer.html()); + } + } else if ('dropdown' === column.type && bt.dropdown) { + $editorField = $(''); + if (data.uiLibrary === 'materialdesign') { + $editorField.addClass('bt-textbox-md').css('font-size', $grid.css('font-size')); + } + $editorContainer.append($editorField); + } + } + if (data.inlineEditing.mode !== 'command' && column.mode !== 'editOnly') { + $editorField = $editorContainer.find('input, select, textarea').first(); + $editorField.on('keyup', function (e) { + if (e.keyCode === 13 || e.keyCode === 27) { + bt.grid.plugins.inlineEditing.private.displayMode($grid, $cell, column); + } + }); + } + } + if ($editorField.prop('tagName').toUpperCase() === "INPUT" && $editorField.prop('type').toUpperCase() === 'TEXT') { + bt.grid.plugins.inlineEditing.private.setCaretAtEnd($editorField[0]); + } else { + $editorField.focus(); + } + $cell.attr('data-mode', 'edit'); + } else if (column.role === 'managementColumn') { + $cell.find('[role="edit"]').hide(); + $cell.find('[role="delete"]').hide(); + $cell.find('[role="update"]').show(); + $cell.find('[role="cancel"]').show(); + } + } + }, + + setCaretAtEnd: function (elem) { + var elemLen; + if (elem) { + elemLen = elem.value.length; + if (document.selection) { // For IE Only + elem.focus(); + var oSel = document.selection.createRange(); + oSel.moveStart('character', -elemLen); + oSel.moveStart('character', elemLen); + oSel.moveEnd('character', 0); + oSel.select(); + } else if (elem.selectionStart || elem.selectionStart == '0') { // Firefox/Chrome + elem.selectionStart = elemLen; + elem.selectionEnd = elemLen; + elem.focus(); + } + } + }, + + displayMode: function ($grid, $cell, column, cancel) { + var $editorContainer, $displayContainer, $ele, newValue, newEditFieldValue, record, position, style = ''; + if (column.mode !== 'editOnly') { + if ($cell.attr('data-mode') === 'edit') { + $editorContainer = $cell.find('div[data-role="edit"]'); + $displayContainer = $cell.find('div[data-role="display"]'); + $ele = $editorContainer.find('input, select, textarea').first(); + if ($ele[0].tagName.toUpperCase() === "SELECT" && $ele[0].selectedIndex > -1) { + newValue = $ele[0].options[$ele[0].selectedIndex].innerHTML; + newEditFieldValue = $ele[0].value; + } else if ($ele[0].tagName.toUpperCase() === "INPUT" && $ele[0].type.toUpperCase() === "CHECKBOX") { + newValue = $ele[0].checked; + } else { + newValue = $ele.val(); + } + position = $cell.parent().data('position'); + record = $grid.get(position); + if (cancel !== true && newValue !== record[column.field]) { + record[column.field] = column.type === 'date' ? bt.core.parseDate(newValue, column.format) : newValue; + if (column.editField) { + record[column.editField] = newEditFieldValue || newValue; + } + if (column.mode !== 'editOnly') { + bt.grid.methods.renderDisplayElement($grid, $displayContainer, column, record, bt.grid.methods.getId(record, $grid.data('primaryKey'), position), 'update'); + if ($cell.find('span.bt-dirty').length === 0) { + $cell.prepend($('')); + } + } + bt.grid.plugins.inlineEditing.events.cellDataChanged($grid, $cell, column, record, newValue); + bt.grid.plugins.inlineEditing.private.updateChanges($grid, column, record, newValue); + } + $editorContainer.hide(); + $displayContainer.show(); + $cell.attr('data-mode', 'display'); + } + if (column.role === 'managementColumn') { + $cell.find('[role="update"]').hide(); + $cell.find('[role="cancel"]').hide(); + $cell.find('[role="edit"]').show(); + $cell.find('[role="delete"]').show(); + } + } + }, + + updateOtherCells: function($grid, mode) { + var data = $grid.data(); + if (data.inlineEditing.mode !== 'command' && mode !== 'editOnly') { + $grid.find('div[data-role="edit"]:visible').parent('td').each(function () { + var $cell = $(this), + column = data.columns[$cell.index()]; + bt.grid.plugins.inlineEditing.private.displayMode($grid, $cell, column); + }); + } + }, + + updateChanges: function ($grid, column, sourceRecord, newValue) { + var targetRecords, filterResult, newRecord, data = $grid.data(); + if (!data.guid) { + data.guid = bt.grid.plugins.inlineEditing.private.generateGUID(); + } + if (data.primaryKey) { + targetRecords = JSON.parse(sessionStorage.getItem('bt.grid.' + data.guid)); + if (targetRecords) { + filterResult = targetRecords.filter(function (record) { + return record[data.primaryKey] === sourceRecord[data.primaryKey]; + }); + } else { + targetRecords = []; + } + if (filterResult && filterResult.length === 1) { + filterResult[0][column.field] = newValue; + } else { + newRecord = {}; + newRecord[data.primaryKey] = sourceRecord[data.primaryKey]; + if (data.primaryKey !== column.field) { + newRecord[column.field] = newValue; + } + targetRecords.push(newRecord); + } + sessionStorage.setItem('bt.grid.' + data.guid, JSON.stringify(targetRecords)); + } + }, + + generateGUID: function () { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); + } +}; + +bt.grid.plugins.inlineEditing.public = { + /** + * Return array with all changes + * @method + * @return array + * @example sample + * + *

+ *
+ * + */ + getChanges: function () { + return JSON.parse(sessionStorage.getItem('bt.grid.' + this.data().guid)); + }, + + /** + * Enable edit mode for all editable cells within a row. + * @method + * @param {string} id - The id of the row that needs to be edited + * @return grid + * @example Edit.Row + * + *
+ * + */ + edit: function (id) { + var i, record = this.getById(id), + $cells = bt.grid.methods.getRowById(this, id).children('td'), + columns = this.data('columns'); + + for (i = 0; i < $cells.length; i++) { + bt.grid.plugins.inlineEditing.private.editMode(this, $($cells[i]), columns[i], record); + } + + return this; + }, + + /** + * Update all editable cells within a row, when the row is in edit mode. + * @method + * @param {string} id - The id of the row that needs to be updated + * @return grid + * @fires rowDataChanged + * @example Update.Row + * + *
+ * + */ + update: function (id) { + var i, record = this.getById(id), + $cells = bt.grid.methods.getRowById(this, id).children('td'), + columns = this.data('columns'); + + for (i = 0; i < $cells.length; i++) { + bt.grid.plugins.inlineEditing.private.displayMode(this, $($cells[i]), columns[i], false); + } + + bt.grid.plugins.inlineEditing.events.rowDataChanged(this, id, record); + + return this; + }, + + /** + * Cancel the edition of all editable cells, when the row is in edit mode. + * @method + * @param {string} id - The id of the row where you need to undo all changes + * @return grid + * @example Cancel.Row + * + *
+ * + */ + cancel: function (id) { + var i, record = this.getById(id), + $cells = bt.grid.methods.getRowById(this, id).children('td'), + columns = this.data('columns'); + + for (i = 0; i < $cells.length; i++) { + bt.grid.plugins.inlineEditing.private.displayMode(this, $($cells[i]), columns[i], true); + } + + return this; + } +}; + +bt.grid.plugins.inlineEditing.events = { + /** + * Event fires after inline edit of a cell in the grid. + * + * @event cellDataChanged + * @param {object} e - event data + * @param {object} $cell - the cell presented as jquery object + * @param {object} column - the column configuration data + * @param {object} record - the data of the row record + * @param {object} newValue - the new cell value + * @example sample + *
+ * + */ + cellDataChanged: function ($grid, $cell, column, record, oldValue, newValue) { + $grid.triggerHandler('cellDataChanged', [$cell, column, record, oldValue, newValue]); + }, + + /** + * Event fires after inline edit of a row in the grid. + * + * @event rowDataChanged + * @param {object} e - event data + * @param {object} id - the id of the record + * @param {object} record - the data of the row record + * @example sample + *
+ * + */ + rowDataChanged: function ($grid, id, record) { + $grid.triggerHandler('rowDataChanged', [id, record]); + } +}; + +bt.grid.plugins.inlineEditing.configure = function ($grid, fullConfig, clientConfig) { + var data = $grid.data(); + $.extend(true, $grid, bt.grid.plugins.inlineEditing.public); + if (clientConfig.inlineEditing) { + $grid.on('dataBound', function () { + $grid.find('span.bt-dirty').remove(); + }); + $grid.on('rowDataBound', function (e, $row, id, record) { + $grid.cancel(id); + }); + } + if (data.inlineEditing.mode === 'command') { + bt.grid.plugins.inlineEditing.private.localization(data); + if (fullConfig.inlineEditing.managementColumn) { + data.columns.push(fullConfig.inlineEditing.managementColumnConfig); + } + } else { + $grid.on('cellDataBound', function (e, $displayEl, id, column, record) { + if (column.editor) { + if (column.mode === 'editOnly') { + bt.grid.plugins.inlineEditing.private.editMode($grid, $displayEl.parent(), column, record); + } else { + $displayEl.parent('td').on(data.inlineEditing.mode === 'dblclick' ? 'dblclick' : 'click', function () { + bt.grid.plugins.inlineEditing.private.editMode($grid, $displayEl.parent(), column, record); + }); + } + } + }); + } +}; + +/** + * @widget Grid + * @plugin Optimistic Persistence + */ +bt.grid.plugins.optimisticPersistence = { + + config: { + base: { + optimisticPersistence: { + /** Array that contains a list with param names that needs to be saved in the localStorage. You need to specify guid on the initialization of the grid in order to enable this feature. + * @additionalinfo This feature is using HTML5 localStorage to store params and values. + * You can clear the data saved in localStorage when you clear your browser cache. + * @alias optimisticPersistence.localStorage + * @type array + * @default undefined + * @example sample + *

Change the page and/or page size and then refresh the grid.

+ *
+ * + */ + localStorage: undefined, + + /** Array that contains a list with param names that needs to be saved in the sessionStorage. You need to specify guid on the initialization of the grid in order to enable this feature. + * @additionalinfo This feature is using HTML5 sessionStorage to store params and values. + * You can clear the data saved in sessionStorage when you open and close the browser. + * @alias optimisticPersistence.sessionStorage + * @type array + * @default undefined + * @example sample + *

Change the page and/or page size and then refresh the grid.

+ *
+ * + */ + sessionStorage: undefined + } + } + }, + + private: { + applyParams: function ($grid) { + var data = $grid.data(), + params = {}, storage; + storage = JSON.parse(sessionStorage.getItem('bt.grid.' + data.guid)); + if (storage && storage.optimisticPersistence) { + $.extend(params, storage.optimisticPersistence); + } + storage = JSON.parse(localStorage.getItem('bt.grid.' + data.guid)); + if (storage && storage.optimisticPersistence) { + $.extend(params, storage.optimisticPersistence); + } + $.extend(data.params, params); + }, + + saveParams: function ($grid) { + var i, param, + data = $grid.data(), + storage = { optimisticPersistence: {} }; + + if (data.optimisticPersistence.sessionStorage) { + for (i = 0; i < data.optimisticPersistence.sessionStorage.length; i++) { + param = data.optimisticPersistence.sessionStorage[i]; + storage.optimisticPersistence[param] = data.params[param]; + } + storage = $.extend(true, JSON.parse(sessionStorage.getItem('bt.grid.' + data.guid)), storage); + sessionStorage.setItem('bt.grid.' + data.guid, JSON.stringify(storage)); + } + + if (data.optimisticPersistence.localStorage) { + storage = { optimisticPersistence: {} }; + for (i = 0; i < data.optimisticPersistence.localStorage.length; i++) { + param = data.optimisticPersistence.localStorage[i]; + storage.optimisticPersistence[param] = data.params[param]; + } + storage = $.extend(true, JSON.parse(localStorage.getItem('bt.grid.' + data.guid)), storage); + localStorage.setItem('bt.grid.' + data.guid, JSON.stringify(storage)); + } + } + }, + + configure: function ($grid, fullConfig, clientConfig) { + if (fullConfig.guid) { + if (fullConfig.optimisticPersistence.localStorage || fullConfig.optimisticPersistence.sessionStorage) { + bt.grid.plugins.optimisticPersistence.private.applyParams($grid); + $grid.on('dataBound', function (e) { + bt.grid.plugins.optimisticPersistence.private.saveParams($grid); + }); + } + } + } +}; +/** + * @widget Grid + * @plugin Pagination + */ +bt.grid.plugins.pagination = { + config: { + base: { + style: { + pager: { + panel: '', + stateDisabled: '', + activeButton: '' + } + }, + + paramNames: { + /** The name of the parameter that is going to send the number of the page. + * The pager should be enabled in order this parameter to be in use. + * @alias paramNames.page + * @type string + * @default "page" + */ + page: 'page', + + /** The name of the parameter that is going to send the maximum number of records per page. + * The pager should be enabled in order this parameter to be in use. + * @alias paramNames.limit + * @type string + * @default "limit" + */ + limit: 'limit' + }, + + pager: { + /** The maximum number of records that can be show by page. + * @alias pager.limit + * @type number + * @default 10 + * @example local.data + *
+ * + * @example remote.data + *
+ * + */ + limit: 10, + + /** Array that contains the possible page sizes of the grid. + * When this setting is set, then a drop down with the options for each page size is visualized in the pager. + * @alias pager.sizes + * @type array + * @default [5, 10, 20, 100] + * @example Bootstrap.3 + *
+ * + * @example Bootstrap.4.FontAwesome + *
+ * + * @example Bootstrap.4.Material.Icons + *
+ * + * @example Material.Design + *
+ * + */ + sizes: [5, 10, 20, 100], + + /** Array that contains a list with jquery objects that are going to be used on the left side of the pager. + * @alias pager.leftControls + * @type array + * @default array + * @example Font.Awesome + * + *
+ * + */ + leftControls: undefined, + + /** Array that contains a list with jquery objects that are going to be used on the right side of the pager. + * @alias pager.rightControls + * @type array + * @default array + */ + rightControls: undefined + } + }, + + bootstrap: { + style: { + pager: { + panel: '', + stateDisabled: '' + } + } + }, + + bootstrap4: { + style: { + pager: { + panel: 'btn-toolbar', + stateDisabled: '' + } + } + }, + + glyphicons: { + icons: { + first: '', + previous: '', + next: '', + last: '', + refresh: '' + } + }, + + materialicons: { + icons: { + first: '', + previous: '', + next: '', + last: '', + refresh: '' + } + }, + + fontawesome: { + icons: { + first: '', + previous: '', + next: '', + last: '', + refresh: '' + } + } + }, + + private: { + init: function ($grid) { + var $row, $cell, data, controls, $leftPanel, $rightPanel, $tfoot, leftControls, rightControls, i; + + data = $grid.data(); + + if (data.pager) { + if (!data.params[data.paramNames.page]) { + data.params[data.paramNames.page] = 1; + } + if (!data.params[data.paramNames.limit]) { + data.params[data.paramNames.limit] = data.pager.limit; + } + + bt.grid.plugins.pagination.private.localization(data); + + $row = $(''); + $cell = $(''); + $row.append($cell); + + $leftPanel = $('
').addClass(data.style.pager.panel).css({ 'float': 'left' }); + $rightPanel = $('
').addClass(data.style.pager.panel).css({ 'float': 'right' }); + + $cell.append($leftPanel).append($rightPanel); + + $tfoot = $('').append($row); + $grid.append($tfoot); + bt.grid.plugins.pagination.private.updatePagerColSpan($grid); + + leftControls = bt.grid.methods.clone(data.pager.leftControls); //clone array + $.each(leftControls, function () { + $leftPanel.append(this); + }); + + rightControls = bt.grid.methods.clone(data.pager.rightControls); //clone array + $.each(rightControls, function () { + $rightPanel.append(this); + }); + + controls = $grid.find('tfoot [data-role]'); + for (i = 0; i < controls.length; i++) { + bt.grid.plugins.pagination.private.initPagerControl($(controls[i]), $grid); + } + } + }, + + localization: function (data) { + if (data.uiLibrary === 'bootstrap') { + bt.grid.plugins.pagination.private.localizationBootstrap(data); + } else if (data.uiLibrary === 'bootstrap4') { + bt.grid.plugins.pagination.private.localizationBootstrap4(data); + } else { + bt.grid.plugins.pagination.private.localizationMaterialDesign(data); + } + }, + + localizationBootstrap: function (data) { + var msg = bt.grid.messages[data.locale]; + if (typeof (data.pager.leftControls) === 'undefined') { + data.pager.leftControls = [ + $('').attr('title', msg.FirstPageTooltip).attr('data-role', 'page-first'), + $('').attr('title', msg.PreviousPageTooltip).attr('data-role', 'page-previous'), + $('
' + msg.Page + '
'), + $(''), + $('
' + msg.Of + '
'), + $('
0
'), + $('').attr('title', msg.NextPageTooltip).attr('data-role', 'page-next'), + $('').attr('title', msg.LastPageTooltip).attr('data-role', 'page-last'), + $('').attr('title', msg.Refresh).attr('data-role', 'page-refresh'), + $('') + ]; + } + if (typeof (data.pager.rightControls) === 'undefined') { + data.pager.rightControls = [ + $('
' + msg.DisplayingRecords + '
'), + $('
0
'), + $('
-
'), + $('
0
'), + $('
' + msg.Of + '
'), + $('
0
') + ]; + } + }, + + localizationBootstrap4: function (data) { + var msg = bt.grid.messages[data.locale]; + if (typeof (data.pager.leftControls) === 'undefined') { + data.pager.leftControls = [ + $('').attr('title', msg.FirstPageTooltip).attr('data-role', 'page-first'), + $('').attr('title', msg.PreviousPageTooltip).attr('data-role', 'page-previous'), + $('
' + msg.Page + '
'), + $('
'), + $('
' + msg.Of + '
'), + $('
0
'), + $('').attr('title', msg.NextPageTooltip).attr('data-role', 'page-next'), + $('').attr('title', msg.LastPageTooltip).attr('data-role', 'page-last'), + $('').attr('title', msg.Refresh).attr('data-role', 'page-refresh'), + $('') + ]; + } + if (typeof (data.pager.rightControls) === 'undefined') { + data.pager.rightControls = [ + $('
' + msg.DisplayingRecords + ' 
'), + $('
0
'), + $('
-
'), + $('
0
'), + $('
' + msg.Of + '
'), + $('
0
') + ]; + } + }, + + localizationMaterialDesign: function (data) { + var msg = bt.grid.messages[data.locale]; + if (typeof (data.pager.leftControls) === 'undefined') { + data.pager.leftControls = []; + } + if (typeof (data.pager.rightControls) === 'undefined') { + data.pager.rightControls = [ + $('' + msg.RowsPerPage + ''), + $('
'), + $(' '), + $('0'), + $('-'), + $('0'), + $('' + msg.Of + ''), + $('0'), + $(' '), + $('').attr('title', msg.PreviousPageTooltip).attr('data-role', 'page-previous').addClass(data.icons.first ? 'bt-button-md-icon' : ''), + $(' '), + $('').attr('title', msg.NextPageTooltip).attr('data-role', 'page-next').addClass(data.icons.first ? 'bt-button-md-icon' : '') + ]; + } + }, + + initPagerControl: function ($control, $grid) { + var data = $grid.data(); + switch ($control.data('role')) { + case 'page-size': + if (data.pager.sizes && 0 < data.pager.sizes.length) { + $control.show(); + $.each(data.pager.sizes, function () { + $control.append($('