@maplat/ui 0.10.6 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +223 -223
  2. package/README.md +128 -91
  3. package/assets/locales/de/translation.json +71 -0
  4. package/{locales → assets/locales}/en/translation.json +70 -64
  5. package/{locales → assets/locales}/ja/translation.json +70 -64
  6. package/{locales → assets/locales}/ko/translation.json +71 -65
  7. package/assets/locales/vi/translation.json +71 -0
  8. package/{locales → assets/locales}/zh/translation.json +71 -65
  9. package/{locales → assets/locales}/zh-TW/translation.json +71 -65
  10. package/assets/parts/attr.png +0 -0
  11. package/assets/parts/border.png +0 -0
  12. package/assets/parts/compass.png +0 -0
  13. package/assets/parts/gps.png +0 -0
  14. package/assets/parts/help.png +0 -0
  15. package/assets/parts/hide_marker.png +0 -0
  16. package/assets/parts/home.png +0 -0
  17. package/assets/parts/marker_list.png +0 -0
  18. package/assets/parts/share.png +0 -0
  19. package/dist/absolute_url.d.ts +1 -0
  20. package/dist/assets/locales/de/translation.json +71 -0
  21. package/dist/assets/locales/en/translation.json +70 -64
  22. package/dist/assets/locales/ja/translation.json +70 -64
  23. package/dist/assets/locales/ko/translation.json +71 -65
  24. package/dist/assets/locales/vi/translation.json +71 -0
  25. package/dist/assets/locales/zh/translation.json +71 -65
  26. package/dist/assets/locales/zh-TW/translation.json +71 -65
  27. package/dist/contextmenu.d.ts +5 -0
  28. package/dist/function.d.ts +2 -0
  29. package/dist/icons.d.ts +7 -0
  30. package/dist/index.d.ts +65 -0
  31. package/dist/maplat-ui.es.js +33551 -0
  32. package/dist/maplat-ui.umd.js +4934 -0
  33. package/dist/maplat_control.d.ts +55 -0
  34. package/dist/pointer_images.d.ts +2 -0
  35. package/dist/swiper_ex.d.ts +2 -0
  36. package/dist/types.d.ts +185 -0
  37. package/dist/ui_init.d.ts +4 -0
  38. package/dist/ui_marker.d.ts +9 -0
  39. package/dist/ui_utils.d.ts +9 -0
  40. package/less/bootstrap.less +7010 -7010
  41. package/less/contextmenu.css +8 -0
  42. package/less/font-awesome.less +51 -31
  43. package/less/iziToast.less +1732 -1732
  44. package/less/maplat-specific.less +1038 -652
  45. package/less/swiper4.css +715 -0
  46. package/less/ui.less +11 -11
  47. package/less/ui_packed.less +10 -10
  48. package/package.json +80 -79
  49. package/src/{absolute_url.js → absolute_url.ts} +1 -1
  50. package/src/contextmenu/base.ts +170 -0
  51. package/src/contextmenu/constants.ts +66 -0
  52. package/src/contextmenu/cssVars.ts +13 -0
  53. package/src/contextmenu/helpers/dom.ts +295 -0
  54. package/src/contextmenu/helpers/mix.ts +120 -0
  55. package/src/contextmenu/html.ts +161 -0
  56. package/src/contextmenu/internal.ts +293 -0
  57. package/src/contextmenu.ts +40 -0
  58. package/src/function.ts +36 -0
  59. package/src/icons.ts +46 -0
  60. package/src/index.ts +521 -0
  61. package/src/maplat_control.ts +629 -0
  62. package/src/pointer_images.ts +101 -0
  63. package/src/{service-worker.js → service-worker/index.ts} +5 -6
  64. package/src/swiper_augment.d.ts +13 -0
  65. package/src/{swiper_ex.js → swiper_ex.ts} +14 -10
  66. package/src/types.d.ts +31 -0
  67. package/src/types.ts +202 -0
  68. package/src/ui_init.ts +1175 -0
  69. package/src/ui_marker.ts +376 -0
  70. package/src/ui_utils.ts +87 -0
  71. package/dist/assets/fonts/a8c0074cf70b152b56105e6c4b227bd8.woff +0 -0
  72. package/dist/assets/fonts/cfeff2e898a64ebe7e6b5ec078b174c3.woff +0 -0
  73. package/dist/assets/images/09c3ce5a86d600e24f8e85de3a019853.png +0 -0
  74. package/dist/assets/images/0beac2cb41dfab43ddfd9df80b32b85d.png +0 -0
  75. package/dist/assets/images/1354b4f40dd58bb0f2a4871cb4ff81d8.png +0 -0
  76. package/dist/assets/images/2a61e310e46b50b5f8ddd5e905ba9db9.png +0 -0
  77. package/dist/assets/images/3131423d782cd3ea89a81247065e7f9d.png +0 -0
  78. package/dist/assets/images/41b2cf0fa604d3f196ca52337d238219.jpg +0 -0
  79. package/dist/assets/images/558bc7e8b9b6c5f41a7141cddb8cdb5e.png +0 -0
  80. package/dist/assets/images/56f7003805ed02f8a21199947651db2e.png +0 -0
  81. package/dist/assets/images/5ba349e3596aca094c41c56966b45dc7.png +0 -0
  82. package/dist/assets/images/6111b8076a2cf81c73f0e46f41a3af60.png +0 -0
  83. package/dist/assets/images/6345ee67d554fbfbf484ba4035ad19d9.jpg +0 -0
  84. package/dist/assets/images/649fce122b354de2ac725ba5f2661955.png +0 -0
  85. package/dist/assets/images/6a580287dea82c2fb9b214321a375145.png +0 -0
  86. package/dist/assets/images/6c5dba7f7d76e74c3a8c7c5b1c3fc544.png +0 -0
  87. package/dist/assets/images/6e1f2f2f6fed3c5cddeb925e7ae75aba.png +0 -0
  88. package/dist/assets/images/799a0177b0dc540682fa4a2e349a8f4f.png +0 -0
  89. package/dist/assets/images/7bef6f357e921c43f4f800cfcb757872.png +0 -0
  90. package/dist/assets/images/7d9d643a903df6f57b8b7386316021e5.png +0 -0
  91. package/dist/assets/images/7df82bae917b68159f84998182f2fdc6.png +0 -0
  92. package/dist/assets/images/8e5d0335f6598b8d874ba23ea9fb295f.png +0 -0
  93. package/dist/assets/images/90c32e751366be22777f3fe40a53fe06.png +0 -0
  94. package/dist/assets/images/9247459937b9c882303962e42bd8d989.png +0 -0
  95. package/dist/assets/images/927c34e7b9b2f95c82ba477993117eaf.png +0 -0
  96. package/dist/assets/images/95e9ca8285131f8ccb6da5052093173c.png +0 -0
  97. package/dist/assets/images/9a243e0cb0fc43e2a016d5d3aaa330d5.png +0 -0
  98. package/dist/assets/images/9ac6d81f417d6a5626b7c8d5a087c32b.png +0 -0
  99. package/dist/assets/images/9d3a01c866095b8b3e8e63f9cf11dd51.png +0 -0
  100. package/dist/assets/images/9df733bcb29a746cb16b47eedea9fc3a.png +0 -0
  101. package/dist/assets/images/acc6eab0ba9c470ae20fb4b74135e865.png +0 -0
  102. package/dist/assets/images/b9ae27f0a01228380dff76a33b605707.jpg +0 -0
  103. package/dist/assets/images/ba48b220f61a6e1028f1854326f43acd.png +0 -0
  104. package/dist/assets/images/bf67cc860289b85c0402a4d4f890a3bd.png +0 -0
  105. package/dist/assets/images/c49f2344772e33256ba24d64b59b20d1.png +0 -0
  106. package/dist/assets/images/ca6b77b234b18e7bb9b1ccda774da286.png +0 -0
  107. package/dist/assets/images/cd213169df16398b0017450e31788d73.png +0 -0
  108. package/dist/assets/images/f101a0974972eeab41189185a5c5b225.png +0 -0
  109. package/dist/assets/images/f115726e6249018905cca51653e1262c.png +0 -0
  110. package/dist/assets/images/f7acb820d978ab2dd69e8bf695c574d1.png +0 -0
  111. package/dist/assets/images/ffea4dd10bf2506aa1e0cd4c61426b42.png +0 -0
  112. package/dist/assets/maplat.css +0 -19
  113. package/dist/assets/maplat.css.map +0 -1
  114. package/dist/assets/maplat.js +0 -3
  115. package/dist/assets/maplat.js.LICENSE.txt +0 -43
  116. package/dist/assets/maplat.js.map +0 -1
  117. package/dist/index.html +0 -125
  118. package/dist/service-worker.js +0 -3
  119. package/dist/service-worker.js.LICENSE.txt +0 -1
  120. package/dist/service-worker.js.map +0 -1
  121. package/fonts/clarenbd-webfont.woff +0 -0
  122. package/fonts/fontawesome-webfont.woff +0 -0
  123. package/legacy/bootstrap-native.js +0 -1935
  124. package/legacy/detect-element-resize.js +0 -153
  125. package/legacy/iziToast.js +0 -1301
  126. package/legacy/page.js +0 -1153
  127. package/legacy/qrcode.js +0 -616
  128. package/legacy/sprintf.js +0 -285
  129. package/less/font-face.less +0 -11
  130. package/less/font-face_packed.less +0 -11
  131. package/parts/attr.png +0 -0
  132. package/parts/blue_marker.png +0 -0
  133. package/parts/bluedot.png +0 -0
  134. package/parts/bluedot_small.png +0 -0
  135. package/parts/bluedot_transparent.png +0 -0
  136. package/parts/border.png +0 -0
  137. package/parts/compass.png +0 -0
  138. package/parts/defaultpin.png +0 -0
  139. package/parts/defaultpin_selected.png +0 -0
  140. package/parts/gps.png +0 -0
  141. package/parts/gsi.jpg +0 -0
  142. package/parts/gsi_ortho.jpg +0 -0
  143. package/parts/help.png +0 -0
  144. package/parts/hide_marker.png +0 -0
  145. package/parts/home.png +0 -0
  146. package/parts/osm.jpg +0 -0
  147. package/parts/red_marker.png +0 -0
  148. package/parts/redcircle.png +0 -0
  149. package/parts/share.png +0 -0
  150. package/src/contextmenu.js +0 -29
  151. package/src/freeze_locales.js +0 -337
  152. package/src/function.js +0 -22
  153. package/src/index.js +0 -1778
  154. package/src/index_packed.js +0 -8
  155. package/src/maplat_control.js +0 -808
  156. package/src/pointer_images.js +0 -81
  157. /package/{parts → assets/parts}/Maplat.png +0 -0
  158. /package/{parts → assets/parts}/all_right_reserved.png +0 -0
  159. /package/{parts → assets/parts}/basemap.png +0 -0
  160. /package/{parts → assets/parts}/cc0.png +0 -0
  161. /package/{parts → assets/parts}/cc_by-nc-nd.png +0 -0
  162. /package/{parts → assets/parts}/cc_by-nc-sa.png +0 -0
  163. /package/{parts → assets/parts}/cc_by-nc.png +0 -0
  164. /package/{parts → assets/parts}/cc_by-nd.png +0 -0
  165. /package/{parts → assets/parts}/cc_by-sa.png +0 -0
  166. /package/{parts → assets/parts}/cc_by.png +0 -0
  167. /package/{parts → assets/parts}/favicon.png +0 -0
  168. /package/{parts → assets/parts}/fullscreen.png +0 -0
  169. /package/{parts → assets/parts}/loading.png +0 -0
  170. /package/{parts → assets/parts}/loading_image.png +0 -0
  171. /package/{parts → assets/parts}/minus.png +0 -0
  172. /package/{parts → assets/parts}/no_image.png +0 -0
  173. /package/{parts → assets/parts}/overlay.png +0 -0
  174. /package/{parts → assets/parts}/pd.png +0 -0
  175. /package/{parts → assets/parts}/plus.png +0 -0
  176. /package/{parts → assets/parts}/slider.png +0 -0
@@ -1,1935 +0,0 @@
1
- const Global = function() {};
2
-
3
- Global.prototype.dispatch = function() {
4
- // Native Javascript for Bootstrap 3 v2.0.23 | © dnp_theme | MIT-License
5
- (function (root, factory) {
6
- if (typeof define === 'function' && define.amd) {
7
- // AMD support:
8
- define([], factory);
9
- } else if (typeof module === 'object' && module.exports) {
10
- // CommonJS-like:
11
- module.exports = factory();
12
- } else {
13
- // Browser globals (root is window)
14
- var bsn = factory();
15
- root.Affix = bsn.Affix;
16
- root.Alert = bsn.Alert;
17
- root.Button = bsn.Button;
18
- root.Carousel = bsn.Carousel;
19
- root.Collapse = bsn.Collapse;
20
- root.Dropdown = bsn.Dropdown;
21
- root.Modal = bsn.Modal;
22
- root.Popover = bsn.Popover;
23
- root.ScrollSpy = bsn.ScrollSpy;
24
- root.Tab = bsn.Tab;
25
- root.Tooltip = bsn.Tooltip;
26
- }
27
- }(this, function () {
28
-
29
- /* Native Javascript for Bootstrap 3 | Internal Utility Functions
30
- ----------------------------------------------------------------*/
31
- "use strict";
32
-
33
- // globals
34
- var globalObject = typeof global !== 'undefined' ? global : this||window,
35
- DOC = document, HTML = DOC.documentElement, body = 'body', // allow the library to be used in <head>
36
-
37
- // Native Javascript for Bootstrap Global Object
38
- BSN = globalObject.BSN = {},
39
- supports = BSN.supports = [],
40
-
41
- // function toggle attributes
42
- dataToggle = 'data-toggle',
43
- dataDismiss = 'data-dismiss',
44
- dataSpy = 'data-spy',
45
- dataRide = 'data-ride',
46
-
47
- // components
48
- stringAffix = 'Affix',
49
- stringAlert = 'Alert',
50
- stringButton = 'Button',
51
- stringCarousel = 'Carousel',
52
- stringCollapse = 'Collapse',
53
- stringDropdown = 'Dropdown',
54
- stringModal = 'Modal',
55
- stringPopover = 'Popover',
56
- stringScrollSpy = 'ScrollSpy',
57
- stringTab = 'Tab',
58
- stringTooltip = 'Tooltip',
59
-
60
- // options DATA API
61
- databackdrop = 'data-backdrop',
62
- dataKeyboard = 'data-keyboard',
63
- dataTarget = 'data-target',
64
- dataInterval = 'data-interval',
65
- dataHeight = 'data-height',
66
- dataPause = 'data-pause',
67
- dataTitle = 'data-title',
68
- dataOriginalTitle = 'data-original-title',
69
- dataOriginalText = 'data-original-text',
70
- dataDismissible = 'data-dismissible',
71
- dataTrigger = 'data-trigger',
72
- dataAnimation = 'data-animation',
73
- dataContainer = 'data-container',
74
- dataPlacement = 'data-placement',
75
- dataDelay = 'data-delay',
76
- dataOffsetTop = 'data-offset-top',
77
- dataOffsetBottom = 'data-offset-bottom',
78
-
79
- // option keys
80
- backdrop = 'backdrop', keyboard = 'keyboard', delay = 'delay',
81
- content = 'content', target = 'target',
82
- interval = 'interval', pause = 'pause', animation = 'animation',
83
- placement = 'placement', container = 'container', root = 'root',
84
-
85
- // box model
86
- offsetTop = 'offsetTop', offsetBottom = 'offsetBottom',
87
- offsetLeft = 'offsetLeft',
88
- scrollTop = 'scrollTop', scrollLeft = 'scrollLeft',
89
- clientWidth = 'clientWidth', clientHeight = 'clientHeight',
90
- offsetWidth = 'offsetWidth', offsetHeight = 'offsetHeight',
91
- innerWidth = 'innerWidth', innerHeight = 'innerHeight',
92
- scrollHeight = 'scrollHeight', height = 'height',
93
-
94
- // aria
95
- ariaExpanded = 'aria-expanded',
96
- ariaHidden = 'aria-hidden',
97
-
98
- // event names
99
- clickEvent = 'click',
100
- hoverEvent = 'hover',
101
- keydownEvent = 'keydown',
102
- keyupEvent = 'keyup',
103
- resizeEvent = 'resize',
104
- scrollEvent = 'scroll',
105
- // originalEvents
106
- showEvent = 'show',
107
- shownEvent = 'shown',
108
- hideEvent = 'hide',
109
- hiddenEvent = 'hidden',
110
- closeEvent = 'close',
111
- closedEvent = 'closed',
112
- slidEvent = 'slid',
113
- slideEvent = 'slide',
114
- changeEvent = 'change',
115
-
116
- // other
117
- getAttribute = 'getAttribute',
118
- setAttribute = 'setAttribute',
119
- hasAttribute = 'hasAttribute',
120
- createElement = 'createElement',
121
- appendChild = 'appendChild',
122
- innerHTML = 'innerHTML',
123
- getElementsByTagName = 'getElementsByTagName',
124
- preventDefault = 'preventDefault',
125
- getBoundingClientRect = 'getBoundingClientRect',
126
- querySelectorAll = 'querySelectorAll',
127
- getElementsByCLASSNAME = 'getElementsByClassName',
128
-
129
- indexOf = 'indexOf',
130
- parentNode = 'parentNode',
131
- length = 'length',
132
- toLowerCase = 'toLowerCase',
133
- Transition = 'Transition',
134
- Webkit = 'Webkit',
135
- style = 'style',
136
- push = 'push',
137
- tabindex = 'tabindex',
138
- contains = 'contains',
139
-
140
- active = 'active',
141
- inClass = 'in',
142
- collapsing = 'collapsing',
143
- disabled = 'disabled',
144
- loading = 'loading',
145
- left = 'left',
146
- right = 'right',
147
- top = 'top',
148
- bottom = 'bottom',
149
-
150
- // IE8 browser detect
151
- isIE8 = !('opacity' in HTML[style]),
152
-
153
- // tooltip / popover
154
- mouseHover = ('onmouseleave' in DOC) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ],
155
- tipPositions = /\b(top|bottom|left|right)+/,
156
-
157
- // modal
158
- modalOverlay = 0,
159
- fixedTop = 'navbar-fixed-top',
160
- fixedBottom = 'navbar-fixed-bottom',
161
-
162
- // transitionEnd since 2.0.4
163
- supportTransitions = Webkit+Transition in HTML[style] || Transition[toLowerCase]() in HTML[style],
164
- transitionEndEvent = Webkit+Transition in HTML[style] ? Webkit[toLowerCase]()+Transition+'End' : Transition[toLowerCase]()+'end',
165
-
166
- // set new focus element since 2.0.3
167
- setFocus = function(element){
168
- element.focus ? element.focus() : element.setActive();
169
- },
170
-
171
- // class manipulation, since 2.0.0 requires polyfill.js
172
- addClass = function(element,classNAME) {
173
- element.classList.add(classNAME);
174
- },
175
- removeClass = function(element,classNAME) {
176
- element.classList.remove(classNAME);
177
- },
178
- hasClass = function(element,classNAME){ // since 2.0.0
179
- return element.classList[contains](classNAME);
180
- },
181
-
182
- // selection methods
183
- nodeListToArray = function(nodeList){
184
- var childItems = []; for (var i = 0, nll = nodeList[length]; i<nll; i++) { childItems[push]( nodeList[i] ) }
185
- return childItems;
186
- },
187
- getElementsByClassName = function(element,classNAME) { // getElementsByClassName IE8+
188
- var selectionMethod = isIE8 ? querySelectorAll : getElementsByCLASSNAME;
189
- return nodeListToArray(element[selectionMethod]( isIE8 ? '.' + classNAME.replace(/\s(?=[a-z])/g,'.') : classNAME ));
190
- },
191
- queryElement = function (selector, parent) {
192
- var lookUp = parent ? parent : DOC;
193
- return typeof selector === 'object' ? selector : lookUp.querySelector(selector);
194
- },
195
- getClosest = function (element, selector) { //element is the element and selector is for the closest parent element to find
196
- // source http://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/
197
- var firstChar = selector.charAt(0), selectorSubstring = selector.substr(1);
198
- if ( firstChar === '.' ) {// If selector is a class
199
- for ( ; element && element !== DOC; element = element[parentNode] ) { // Get closest match
200
- if ( queryElement(selector,element[parentNode]) !== null && hasClass(element,selectorSubstring) ) { return element; }
201
- }
202
- } else if ( firstChar === '#' ) { // If selector is an ID
203
- for ( ; element && element !== DOC; element = element[parentNode] ) { // Get closest match
204
- if ( element.id === selectorSubstring ) { return element; }
205
- }
206
- }
207
- return false;
208
- },
209
-
210
- // event attach jQuery style / trigger since 1.2.0
211
- on = function (element, event, handler) {
212
- element.addEventListener(event, handler, false);
213
- },
214
- off = function(element, event, handler) {
215
- element.removeEventListener(event, handler, false);
216
- },
217
- one = function (element, event, handler) { // one since 2.0.4
218
- on(element, event, function handlerWrapper(e){
219
- handler(e);
220
- off(element, event, handlerWrapper);
221
- });
222
- },
223
- emulateTransitionEnd = function(element,handler){ // emulateTransitionEnd since 2.0.4
224
- if (supportTransitions) { one(element, transitionEndEvent, function(e){ handler(e); }); }
225
- else { handler(); }
226
- },
227
- bootstrapCustomEvent = function (eventName, componentName, related) {
228
- var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName);
229
- OriginalCustomEvent.relatedTarget = related;
230
- this.dispatchEvent(OriginalCustomEvent);
231
- },
232
-
233
- // tooltip / popover stuff
234
- getScroll = function() { // also Affix and ScrollSpy uses it
235
- return {
236
- y : globalObject.pageYOffset || HTML[scrollTop],
237
- x : globalObject.pageXOffset || HTML[scrollLeft]
238
- }
239
- },
240
- styleTip = function(link,element,position,parent) { // both popovers and tooltips (target,tooltip/popover,placement,elementToAppendTo)
241
- var elementDimensions = { w : element[offsetWidth], h: element[offsetHeight] },
242
- windowWidth = (HTML[clientWidth] || DOC[body][clientWidth]),
243
- windowHeight = (HTML[clientHeight] || DOC[body][clientHeight]),
244
- rect = link[getBoundingClientRect](),
245
- scroll = parent === DOC[body] ? getScroll() : { x: parent[offsetLeft] + parent[scrollLeft], y: parent[offsetTop] + parent[scrollTop] },
246
- linkDimensions = { w: rect[right] - rect[left], h: rect[bottom] - rect[top] },
247
- arrow = queryElement('[class*="arrow"]',element),
248
- topPosition, leftPosition, arrowTop, arrowLeft,
249
-
250
- halfTopExceed = rect[top] + linkDimensions.h/2 - elementDimensions.h/2 < 0,
251
- halfLeftExceed = rect[left] + linkDimensions.w/2 - elementDimensions.w/2 < 0,
252
- halfRightExceed = rect[left] + elementDimensions.w/2 + linkDimensions.w/2 >= windowWidth,
253
- halfBottomExceed = rect[top] + elementDimensions.h/2 + linkDimensions.h/2 >= windowHeight,
254
- topExceed = rect[top] - elementDimensions.h < 0,
255
- leftExceed = rect[left] - elementDimensions.w < 0,
256
- bottomExceed = rect[top] + elementDimensions.h + linkDimensions.h >= windowHeight,
257
- rightExceed = rect[left] + elementDimensions.w + linkDimensions.w >= windowWidth;
258
-
259
- // recompute position
260
- position = (position === left || position === right) && leftExceed && rightExceed ? top : position; // first, when both left and right limits are exceeded, we fall back to top|bottom
261
- position = position === top && topExceed ? bottom : position;
262
- position = position === bottom && bottomExceed ? top : position;
263
- position = position === left && leftExceed ? right : position;
264
- position = position === right && rightExceed ? left : position;
265
-
266
- // apply styling to tooltip or popover
267
- if ( position === left || position === right ) { // secondary|side positions
268
- if ( position === left ) { // LEFT
269
- leftPosition = rect[left] + scroll.x - elementDimensions.w;
270
- } else { // RIGHT
271
- leftPosition = rect[left] + scroll.x + linkDimensions.w;
272
- }
273
-
274
- // adjust top and arrow
275
- if (halfTopExceed) {
276
- topPosition = rect[top] + scroll.y;
277
- arrowTop = linkDimensions.h/2;
278
- } else if (halfBottomExceed) {
279
- topPosition = rect[top] + scroll.y - elementDimensions.h + linkDimensions.h;
280
- arrowTop = elementDimensions.h - linkDimensions.h/2;
281
- } else {
282
- topPosition = rect[top] + scroll.y - elementDimensions.h/2 + linkDimensions.h/2;
283
- }
284
- } else if ( position === top || position === bottom ) { // primary|vertical positions
285
- if ( position === top) { // TOP
286
- topPosition = rect[top] + scroll.y - elementDimensions.h;
287
- } else { // BOTTOM
288
- topPosition = rect[top] + scroll.y + linkDimensions.h;
289
- }
290
- // adjust left | right and also the arrow
291
- if (halfLeftExceed) {
292
- leftPosition = 0;
293
- arrowLeft = rect[left] + linkDimensions.w/2;
294
- } else if (halfRightExceed) {
295
- leftPosition = windowWidth - elementDimensions.w*1.01;
296
- arrowLeft = elementDimensions.w - ( windowWidth - rect[left] ) + linkDimensions.w/2;
297
- } else {
298
- leftPosition = rect[left] + scroll.x - elementDimensions.w/2 + linkDimensions.w/2;
299
- }
300
- }
301
-
302
- // apply style to tooltip/popover and it's arrow
303
- element[style][top] = topPosition + 'px';
304
- element[style][left] = leftPosition + 'px';
305
-
306
- arrowTop && (arrow[style][top] = arrowTop + 'px');
307
- arrowLeft && (arrow[style][left] = arrowLeft + 'px');
308
-
309
- element.className[indexOf](position) === -1 && (element.className = element.className.replace(tipPositions,position));
310
- };
311
-
312
- BSN.version = '2.0.23';
313
-
314
- /* Native Javascript for Bootstrap 3 | Affix
315
- -------------------------------------------*/
316
-
317
- //AFFIX DEFINITION
318
- var Affix = function(element, options) {
319
-
320
- // initialization element
321
- element = queryElement(element);
322
-
323
- // set options
324
- options = options || {};
325
-
326
- // read DATA API
327
- var targetData = element[getAttribute](dataTarget),
328
- offsetTopData = element[getAttribute](dataOffsetTop),
329
- offsetBottomData = element[getAttribute](dataOffsetBottom),
330
-
331
- // component specific strings
332
- affix = 'affix', affixed = 'affixed', fn = 'function', update = 'update',
333
- affixTop = 'affix-top', affixedTop = 'affixed-top',
334
- affixBottom = 'affix-bottom', affixedBottom = 'affixed-bottom';
335
-
336
- this[target] = options[target] ? queryElement(options[target]) : queryElement(targetData) || null; // target is an object
337
- this[offsetTop] = options[offsetTop] ? options[offsetTop] : parseInt(offsetTopData) || 0; // offset option is an integer number or function to determine that number
338
- this[offsetBottom] = options[offsetBottom] ? options[offsetBottom]: parseInt(offsetBottomData) || 0;
339
-
340
- if ( !this[target] && !( this[offsetTop] || this[offsetBottom] ) ) { return; } // invalidate
341
-
342
- // internal bind
343
- var self = this,
344
-
345
- // constants
346
- pinOffsetTop, pinOffsetBottom, maxScroll, scrollY, pinnedTop, pinnedBottom,
347
- affixedToTop = false, affixedToBottom = false,
348
-
349
- // private methods
350
- getMaxScroll = function(){
351
- return Math.max( DOC[body][scrollHeight], DOC[body][offsetHeight], HTML[clientHeight], HTML[scrollHeight], HTML[offsetHeight] );
352
- },
353
- getOffsetTop = function () {
354
- if ( self[target] !== null ) {
355
- return self[target][getBoundingClientRect]()[top] + scrollY;
356
- } else if ( self[offsetTop] ) {
357
- return parseInt(typeof self[offsetTop] === fn ? self[offsetTop]() : self[offsetTop] || 0);
358
- }
359
- },
360
- getOffsetBottom = function () {
361
- if ( self[offsetBottom] ) {
362
- return maxScroll - element[offsetHeight] - parseInt( typeof self[offsetBottom] === fn ? self[offsetBottom]() : self[offsetBottom] || 0 );
363
- }
364
- },
365
- checkPosition = function () {
366
- maxScroll = getMaxScroll();
367
- scrollY = parseInt(getScroll().y,0);
368
- pinOffsetTop = getOffsetTop();
369
- pinOffsetBottom = getOffsetBottom();
370
- pinnedTop = ( parseInt(pinOffsetTop) - scrollY < 0) && (scrollY > parseInt(pinOffsetTop) );
371
- pinnedBottom = ( parseInt(pinOffsetBottom) - scrollY < 0) && (scrollY > parseInt(pinOffsetBottom) );
372
- },
373
- pinTop = function () {
374
- if ( !affixedToTop && !hasClass(element,affix) ) { // on loading a page halfway scrolled these events don't trigger in Chrome
375
- bootstrapCustomEvent.call(element, affix, affix);
376
- bootstrapCustomEvent.call(element, affixTop, affix);
377
- addClass(element,affix);
378
- affixedToTop = true;
379
- bootstrapCustomEvent.call(element, affixed, affix);
380
- bootstrapCustomEvent.call(element, affixedTop, affix);
381
- }
382
- },
383
- unPinTop = function () {
384
- if ( affixedToTop && hasClass(element,affix) ) {
385
- removeClass(element,affix);
386
- affixedToTop = false;
387
- }
388
- },
389
- pinBottom = function () {
390
- if ( !affixedToBottom && !hasClass(element, affixBottom) ) {
391
- bootstrapCustomEvent.call(element, affix, affix);
392
- bootstrapCustomEvent.call(element, affixBottom, affix);
393
- addClass(element,affixBottom);
394
- affixedToBottom = true;
395
- bootstrapCustomEvent.call(element, affixed, affix);
396
- bootstrapCustomEvent.call(element, affixedBottom, affix);
397
- }
398
- },
399
- unPinBottom = function () {
400
- if ( affixedToBottom && hasClass(element,affixBottom) ) {
401
- removeClass(element,affixBottom);
402
- affixedToBottom = false;
403
- }
404
- },
405
- updatePin = function () {
406
- if ( pinnedBottom ) {
407
- if ( pinnedTop ) { unPinTop(); }
408
- pinBottom();
409
- } else {
410
- unPinBottom();
411
- if ( pinnedTop ) { pinTop(); }
412
- else { unPinTop(); }
413
- }
414
- };
415
-
416
- // public method
417
- this[update] = function () {
418
- checkPosition();
419
- updatePin();
420
- };
421
-
422
- // init
423
- if ( !(stringAffix in element ) ) { // prevent adding event handlers twice
424
- on( globalObject, scrollEvent, self[update] );
425
- !isIE8 && on( globalObject, resizeEvent, self[update] );
426
- }
427
- element[stringAffix] = self;
428
-
429
- self[update]();
430
- };
431
-
432
- // AFFIX DATA API
433
- // =================
434
- supports[push]([stringAffix, Affix, '['+dataSpy+'="affix"]']);
435
-
436
-
437
-
438
- /* Native Javascript for Bootstrap 3 | Alert
439
- -------------------------------------------*/
440
-
441
- // ALERT DEFINITION
442
- // ================
443
- var Alert = function( element ) {
444
-
445
- // initialization element
446
- element = queryElement(element);
447
-
448
- // bind, target alert, duration and stuff
449
- var self = this, component = 'alert',
450
- alert = getClosest(element,'.'+component),
451
- triggerHandler = function(){ hasClass(alert,'fade') ? emulateTransitionEnd(alert,transitionEndHandler) : transitionEndHandler(); },
452
- // handlers
453
- clickHandler = function(e){
454
- alert = getClosest(e[target],'.'+component);
455
- element = queryElement('['+dataDismiss+'="'+component+'"]',alert);
456
- element && alert && (element === e[target] || element[contains](e[target])) && self.close();
457
- },
458
- transitionEndHandler = function(){
459
- bootstrapCustomEvent.call(alert, closedEvent, component);
460
- off(element, clickEvent, clickHandler); // detach it's listener
461
- alert[parentNode].removeChild(alert);
462
- };
463
-
464
- // public method
465
- this.close = function() {
466
- if ( alert && element && hasClass(alert,inClass) ) {
467
- bootstrapCustomEvent.call(alert, closeEvent, component);
468
- removeClass(alert,inClass);
469
- alert && triggerHandler();
470
- }
471
- };
472
-
473
- // init
474
- if ( !(stringAlert in element ) ) { // prevent adding event handlers twice
475
- on(element, clickEvent, clickHandler);
476
- }
477
- element[stringAlert] = self;
478
- };
479
-
480
- // ALERT DATA API
481
- // ==============
482
- supports[push]([stringAlert, Alert, '['+dataDismiss+'="alert"]']);
483
-
484
-
485
-
486
- /* Native Javascript for Bootstrap 3 | Button
487
- ---------------------------------------------*/
488
-
489
- // BUTTON DEFINITION
490
- // ===================
491
- var Button = function( element, option ) {
492
-
493
- // initialization element
494
- element = queryElement(element);
495
-
496
- // set option
497
- option = option || null;
498
-
499
- // constant
500
- var toggled = false, // toggled makes sure to prevent triggering twice the change.bs.button events
501
-
502
- // strings
503
- component = 'button',
504
- checked = 'checked',
505
- reset = 'reset',
506
- LABEL = 'LABEL',
507
- INPUT = 'INPUT',
508
-
509
- // private methods
510
- setState = function() {
511
- if ( !! option && option !== reset ) {
512
- if ( option === loading ) {
513
- addClass(element,disabled);
514
- element[setAttribute](disabled,disabled);
515
- element[setAttribute](dataOriginalText, element[innerHTML].trim()); // trim the text
516
- }
517
- element[innerHTML] = element[getAttribute]('data-'+option+'-text');
518
- }
519
- },
520
- resetState = function() {
521
- if (element[getAttribute](dataOriginalText)) {
522
- if ( hasClass(element,disabled) || element[getAttribute](disabled) === disabled ) {
523
- removeClass(element,disabled);
524
- element.removeAttribute(disabled);
525
- }
526
- element[innerHTML] = element[getAttribute](dataOriginalText);
527
- }
528
- },
529
- keyHandler = function(e){
530
- var key = e.which || e.keyCode;
531
- key === 32 && e[target] === DOC.activeElement && toggle(e);
532
- },
533
- preventScroll = function(e){
534
- var key = e.which || e.keyCode;
535
- key === 32 && e[preventDefault]();
536
- },
537
- toggle = function(e) {
538
- var label = e[target].tagName === LABEL ? e[target] : e[target][parentNode].tagName === LABEL ? e[target][parentNode] : null; // the .btn label
539
-
540
- if ( !label ) return; //react if a label or its immediate child is clicked
541
-
542
- var eventTarget = e[target], // the button itself, the target of the handler function
543
- labels = getElementsByClassName(eventTarget[parentNode],'btn'), // all the button group buttons
544
- input = label[getElementsByTagName](INPUT)[0];
545
-
546
- if ( !input ) return; //return if no input found
547
-
548
- // manage the dom manipulation
549
- if ( input.type === 'checkbox' ) { //checkboxes
550
- if ( !input[checked] ) {
551
- addClass(label,active);
552
- input[getAttribute](checked);
553
- input[setAttribute](checked,checked);
554
- input[checked] = true;
555
- } else {
556
- removeClass(label,active);
557
- input[getAttribute](checked);
558
- input.removeAttribute(checked);
559
- input[checked] = false;
560
- }
561
-
562
- if (!toggled) { // prevent triggering the event twice
563
- toggled = true;
564
- bootstrapCustomEvent.call(input, changeEvent, component); //trigger the change for the input
565
- bootstrapCustomEvent.call(element, changeEvent, component); //trigger the change for the btn-group
566
- }
567
- }
568
-
569
- if ( input.type === 'radio' && !toggled ) { // radio buttons
570
- if ( !input[checked] ) { // don't trigger if already active
571
- addClass(label,active);
572
- input[setAttribute](checked,checked);
573
- input[checked] = true;
574
- bootstrapCustomEvent.call(input, changeEvent, component); //trigger the change for the input
575
- bootstrapCustomEvent.call(element, changeEvent, component); //trigger the change for the btn-group
576
-
577
- toggled = true;
578
- for (var i = 0, ll = labels[length]; i<ll; i++) {
579
- var otherLabel = labels[i], otherInput = otherLabel[getElementsByTagName](INPUT)[0];
580
- if ( otherLabel !== label && hasClass(otherLabel,active) ) {
581
- removeClass(otherLabel,active);
582
- otherInput.removeAttribute(checked);
583
- otherInput[checked] = false;
584
- bootstrapCustomEvent.call(otherInput, changeEvent, component); // trigger the change
585
- }
586
- }
587
- }
588
- }
589
- setTimeout( function() { toggled = false; }, 50 );
590
- };
591
-
592
- // init
593
- if ( hasClass(element,'btn') ) { // when Button text is used we execute it as an instance method
594
- if ( option !== null ) {
595
- if ( option !== reset ) { setState(); }
596
- else { resetState(); }
597
- }
598
- } else { // if ( hasClass(element,'btn-group') ) // we allow the script to work outside btn-group component
599
-
600
- if ( !( stringButton in element ) ) { // prevent adding event handlers twice
601
- on( element, clickEvent, toggle );
602
- queryElement('['+tabindex+']',element) && on( element, keyupEvent, keyHandler ),
603
- on( element, keydownEvent, preventScroll );
604
- }
605
-
606
- // activate items on load
607
- var labelsToACtivate = getElementsByClassName(element, 'btn'), lbll = labelsToACtivate[length];
608
- for (var i=0; i<lbll; i++) {
609
- !hasClass(labelsToACtivate[i],active) && queryElement('input',labelsToACtivate[i])[getAttribute](checked)
610
- && addClass(labelsToACtivate[i],active);
611
- }
612
- element[stringButton] = this;
613
- }
614
- };
615
-
616
- // BUTTON DATA API
617
- // =================
618
- supports[push]( [ stringButton, Button, '['+dataToggle+'="buttons"]' ] );
619
-
620
-
621
- /* Native Javascript for Bootstrap 3 | Carousel
622
- ----------------------------------------------*/
623
-
624
- // CAROUSEL DEFINITION
625
- // ===================
626
- var Carousel = function( element, options ) {
627
-
628
- // initialization element
629
- element = queryElement( element );
630
-
631
- // set options
632
- options = options || {};
633
-
634
- // DATA API
635
- var intervalAttribute = element[getAttribute](dataInterval),
636
- intervalOption = options[interval],
637
- intervalData = intervalAttribute === 'false' ? 0 : parseInt(intervalAttribute),
638
- pauseData = element[getAttribute](dataPause) === hoverEvent || false,
639
- keyboardData = element[getAttribute](dataKeyboard) === 'true' || false,
640
-
641
- // strings
642
- component = 'carousel',
643
- paused = 'paused',
644
- direction = 'direction',
645
- dataSlideTo = 'data-slide-to';
646
-
647
- this[keyboard] = options[keyboard] === true || keyboardData;
648
- this[pause] = (options[pause] === hoverEvent || pauseData) ? hoverEvent : false; // false / hover
649
-
650
- this[interval] = typeof intervalOption === 'number' ? intervalOption
651
- : intervalData === 0 || intervalData === false ? 0
652
- : 5000; // bootstrap carousel default interval
653
-
654
- // bind, event targets
655
- var self = this, index = element.index = 0, timer = element.timer = 0,
656
- isSliding = false, // isSliding prevents click event handlers when animation is running
657
- slides = getElementsByClassName(element,'item'), total = slides[length],
658
- slideDirection = this[direction] = left,
659
- controls = getElementsByClassName(element,component+'-control'),
660
- leftArrow = controls[0], rightArrow = controls[1],
661
- indicator = queryElement( '.'+component+'-indicators', element ),
662
- indicators = indicator && indicator[getElementsByTagName]( "LI" ) || [];
663
-
664
- // handlers
665
- var pauseHandler = function () {
666
- if ( self[interval] !==false && !hasClass(element,paused) ) {
667
- addClass(element,paused);
668
- !isSliding && clearInterval( timer );
669
- }
670
- },
671
- resumeHandler = function() {
672
- if ( self[interval] !== false && hasClass(element,paused) ) {
673
- removeClass(element,paused);
674
- !isSliding && clearInterval( timer );
675
- !isSliding && self.cycle();
676
- }
677
- },
678
- indicatorHandler = function(e) {
679
- e[preventDefault]();
680
- if (isSliding) return;
681
-
682
- var eventTarget = e[target]; // event target | the current active item
683
-
684
- if ( eventTarget && !hasClass(eventTarget,active) && eventTarget[getAttribute](dataSlideTo) ) {
685
- index = parseInt( eventTarget[getAttribute](dataSlideTo), 10 );
686
- } else { return false; }
687
-
688
- self.slideTo( index ); //Do the slide
689
- },
690
- controlsHandler = function (e) {
691
- e[preventDefault]();
692
- if (isSliding) return;
693
-
694
- var eventTarget = e.currentTarget || e.srcElement;
695
-
696
- if ( eventTarget === rightArrow ) {
697
- index++;
698
- } else if ( eventTarget === leftArrow ) {
699
- index--;
700
- }
701
-
702
- self.slideTo( index ); //Do the slide
703
- },
704
- keyHandler = function (e) {
705
- if (isSliding) return;
706
- switch (e.which) {
707
- case 39:
708
- index++;
709
- break;
710
- case 37:
711
- index--;
712
- break;
713
- default: return;
714
- }
715
- self.slideTo( index ); //Do the slide
716
- },
717
- // private methods
718
- isElementInScrollRange = function () {
719
- var rect = element[getBoundingClientRect](),
720
- viewportHeight = globalObject[innerHeight] || HTML[clientHeight]
721
- return rect[top] <= viewportHeight && rect[bottom] >= 0; // bottom && top
722
- },
723
- setActivePage = function( pageIndex ) { //indicators
724
- for ( var i = 0, icl = indicators[length]; i < icl; i++ ) {
725
- removeClass(indicators[i],active);
726
- }
727
- if (indicators[pageIndex]) addClass(indicators[pageIndex], active);
728
- };
729
-
730
-
731
- // public methods
732
- this.cycle = function() {
733
- timer = setInterval(function() {
734
- isElementInScrollRange() && (index++, self.slideTo( index ) );
735
- }, this[interval]);
736
- };
737
- this.slideTo = function( next ) {
738
- if (isSliding) return; // when controled via methods, make sure to check again
739
- var activeItem = this.getActiveIndex(), // the current active
740
- orientation;
741
-
742
- // determine slideDirection first
743
- if ( (activeItem < next ) || (activeItem === 0 && next === total -1 ) ) {
744
- slideDirection = self[direction] = left; // next
745
- } else if ( (activeItem > next) || (activeItem === total - 1 && next === 0 ) ) {
746
- slideDirection = self[direction] = right; // prev
747
- }
748
-
749
- // find the right next index
750
- if ( next < 0 ) { next = total - 1; }
751
- else if ( next === total ){ next = 0; }
752
-
753
- // update index
754
- index = next;
755
-
756
- orientation = slideDirection === left ? 'next' : 'prev'; //determine type
757
- bootstrapCustomEvent.call(element, slideEvent, component, slides[next]); // here we go with the slide
758
-
759
- isSliding = true;
760
- clearInterval(timer);
761
- setActivePage( next );
762
-
763
- if ( supportTransitions && hasClass(element,'slide') ) {
764
-
765
- addClass(slides[next],orientation);
766
- slides[next][offsetWidth];
767
- addClass(slides[next],slideDirection);
768
- addClass(slides[activeItem],slideDirection);
769
-
770
- one(slides[activeItem], transitionEndEvent, function(e) {
771
- var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
772
- setTimeout(function(){
773
- isSliding = false;
774
-
775
- addClass(slides[next],active);
776
- removeClass(slides[activeItem],active);
777
-
778
- removeClass(slides[next],orientation);
779
- removeClass(slides[next],slideDirection);
780
- removeClass(slides[activeItem],slideDirection);
781
-
782
- bootstrapCustomEvent.call(element, slidEvent, component, slides[next]);
783
-
784
- if ( self[interval] && !hasClass(element,paused) ) {
785
- self.cycle();
786
- }
787
- },timeout+100);
788
- });
789
-
790
- } else {
791
- addClass(slides[next],active);
792
- slides[next][offsetWidth];
793
- removeClass(slides[activeItem],active);
794
- setTimeout(function() {
795
- isSliding = false;
796
- if ( self[interval] && !hasClass(element,paused) ) {
797
- self.cycle();
798
- }
799
- bootstrapCustomEvent.call(element, slidEvent, component, slides[next]); // here we go with the slid event
800
- }, 100 );
801
- }
802
- };
803
- this.getActiveIndex = function () {
804
- return slides[indexOf](getElementsByClassName(element,'item active')[0]) || 0;
805
- };
806
-
807
- // init
808
- if ( !(stringCarousel in element ) ) { // prevent adding event handlers twice
809
-
810
- if ( self[pause] && self[interval] ) {
811
- on( element, mouseHover[0], pauseHandler );
812
- on( element, mouseHover[1], resumeHandler );
813
- on( element, 'touchstart', pauseHandler );
814
- on( element, 'touchend', resumeHandler );
815
- }
816
-
817
- rightArrow && on( rightArrow, clickEvent, controlsHandler );
818
- leftArrow && on( leftArrow, clickEvent, controlsHandler );
819
-
820
- indicator && on( indicator, clickEvent, indicatorHandler );
821
- self[keyboard] && on( globalObject, keydownEvent, keyHandler );
822
-
823
- }
824
- if (self.getActiveIndex()<0) {
825
- slides[length] && addClass(slides[0],active);
826
- indicators[length] && setActivePage(0);
827
- }
828
-
829
- if ( self[interval] ){ self.cycle(); }
830
- element[stringCarousel] = self;
831
- };
832
-
833
- // CAROUSEL DATA API
834
- // =================
835
- supports[push]( [ stringCarousel, Carousel, '['+dataRide+'="carousel"]' ] );
836
-
837
-
838
- /* Native Javascript for Bootstrap 3 | Collapse
839
- -----------------------------------------------*/
840
-
841
- // COLLAPSE DEFINITION
842
- // ===================
843
- var Collapse = function( element, options ) {
844
-
845
- // initialization element
846
- element = queryElement(element);
847
-
848
- // set options
849
- options = options || {};
850
-
851
- // event targets and constants
852
- var accordion = null, collapse = null, self = this,
853
- isAnimating = false, // when true it will prevent click handlers
854
- accordionData = element[getAttribute]('data-parent'),
855
-
856
- // component strings
857
- component = 'collapse',
858
- collapsed = 'collapsed',
859
-
860
- // private methods
861
- openAction = function(collapseElement,toggle) {
862
- bootstrapCustomEvent.call(collapseElement, showEvent, component);
863
- isAnimating = true;
864
- addClass(collapseElement,collapsing);
865
- removeClass(collapseElement,component);
866
- collapseElement[style][height] = collapseElement[scrollHeight] + 'px';
867
-
868
- emulateTransitionEnd(collapseElement, function() {
869
- isAnimating = false;
870
- collapseElement[setAttribute](ariaExpanded,'true');
871
- toggle[setAttribute](ariaExpanded,'true');
872
- removeClass(collapseElement,collapsing);
873
- addClass(collapseElement, component);
874
- addClass(collapseElement, inClass);
875
- collapseElement[style][height] = '';
876
- bootstrapCustomEvent.call(collapseElement, shownEvent, component);
877
- });
878
- },
879
- closeAction = function(collapseElement,toggle) {
880
- bootstrapCustomEvent.call(collapseElement, hideEvent, component);
881
- isAnimating = true;
882
- collapseElement[style][height] = collapseElement[scrollHeight] + 'px'; // set height first
883
- removeClass(collapseElement,component);
884
- removeClass(collapseElement, inClass);
885
- addClass(collapseElement, collapsing);
886
- collapseElement[offsetWidth]; // force reflow to enable transition
887
- collapseElement[style][height] = '0px';
888
-
889
- emulateTransitionEnd(collapseElement, function() {
890
- isAnimating = false;
891
- collapseElement[setAttribute](ariaExpanded,'false');
892
- toggle[setAttribute](ariaExpanded,'false');
893
- removeClass(collapseElement,collapsing);
894
- addClass(collapseElement,component);
895
- collapseElement[style][height] = '';
896
- bootstrapCustomEvent.call(collapseElement, hiddenEvent, component);
897
- });
898
- },
899
- getTarget = function() {
900
- var href = element.href && element[getAttribute]('href'),
901
- parent = element[getAttribute](dataTarget),
902
- id = href || ( parent && parent.charAt(0) === '#' ) && parent;
903
- return id && queryElement(id);
904
- };
905
-
906
- // public methods
907
- this.toggle = function(e) {
908
- e[preventDefault]();
909
- if ( isAnimating ) return;
910
- if (!hasClass(collapse,inClass)) { self.show(); }
911
- else { self.hide(); }
912
- };
913
- this.hide = function() {
914
- closeAction(collapse,element);
915
- addClass(element,collapsed);
916
- };
917
- this.show = function() {
918
- if ( accordion ) {
919
- var activeCollapse = queryElement('.'+component+'.'+inClass,accordion),
920
- toggle = activeCollapse && (queryElement('['+dataToggle+'="'+component+'"]['+dataTarget+'="#'+activeCollapse.id+'"]',accordion)
921
- || queryElement('['+dataToggle+'="'+component+'"][href="#'+activeCollapse.id+'"]',accordion) ),
922
- correspondingCollapse = toggle && (toggle[getAttribute](dataTarget) || toggle.href);
923
- if ( activeCollapse && toggle && activeCollapse !== collapse ) {
924
- closeAction(activeCollapse,toggle);
925
- if ( correspondingCollapse.split('#')[1] !== collapse.id ) { addClass(toggle,collapsed); }
926
- else { removeClass(toggle,collapsed); }
927
- }
928
- }
929
-
930
- openAction(collapse,element);
931
- removeClass(element,collapsed);
932
- };
933
-
934
- // init
935
- if ( !(stringCollapse in element ) ) { // prevent adding event handlers twice
936
- on(element, clickEvent, self.toggle);
937
- }
938
- collapse = getTarget();
939
- accordion = queryElement(options.parent) || accordionData && getClosest(element, accordionData);
940
- element[stringCollapse] = self;
941
- };
942
-
943
- // COLLAPSE DATA API
944
- // =================
945
- supports[push]( [ stringCollapse, Collapse, '['+dataToggle+'="collapse"]' ] );
946
-
947
-
948
- /* Native Javascript for Bootstrap 3 | Dropdown
949
- ----------------------------------------------*/
950
-
951
- // DROPDOWN DEFINITION
952
- // ===================
953
- var Dropdown = function( element, option ) {
954
-
955
- // initialization element
956
- element = queryElement(element);
957
-
958
- // set option
959
- this.persist = option === true || element[getAttribute]('data-persist') === 'true' || false;
960
-
961
- // constants, event targets, strings
962
- var self = this, children = 'children',
963
- parent = element[parentNode],
964
- component = 'dropdown', open = 'open',
965
- relatedTarget = null,
966
- menu = queryElement('.dropdown-menu', parent),
967
- menuItems = (function(){
968
- var set = menu[children], newSet = [];
969
- for ( var i=0; i<set[length]; i++ ){
970
- set[i][children][length] && (set[i][children][0].tagName === 'A' && newSet[push](set[i]));
971
- }
972
- return newSet;
973
- })(),
974
-
975
- // preventDefault on empty anchor links
976
- preventEmptyAnchor = function(anchor){
977
- (anchor.href && anchor.href.slice(-1) === '#' || anchor[parentNode] && anchor[parentNode].href
978
- && anchor[parentNode].href.slice(-1) === '#') && this[preventDefault]();
979
- },
980
-
981
- // toggle dismissible events
982
- toggleDismiss = function(){
983
- var type = element[open] ? on : off;
984
- type(DOC, clickEvent, dismissHandler);
985
- type(DOC, keydownEvent, preventScroll);
986
- type(DOC, keyupEvent, keyHandler);
987
- },
988
-
989
- // handlers
990
- dismissHandler = function(e) {
991
- var eventTarget = e[target], hasData = eventTarget && (stringDropdown in eventTarget || stringDropdown in eventTarget[parentNode]);
992
- if ( (eventTarget === menu || menu[contains](eventTarget)) && (self.persist || hasData) ) { return; }
993
- else {
994
- relatedTarget = eventTarget === element || element[contains](eventTarget) ? element : null;
995
- hide();
996
- }
997
- preventEmptyAnchor.call(e,eventTarget);
998
- },
999
- clickHandler = function(e) {
1000
- relatedTarget = element;
1001
- show();
1002
- preventEmptyAnchor.call(e,e[target]);
1003
- },
1004
- preventScroll = function(e){
1005
- var key = e.which || e.keyCode;
1006
- if( key === 38 || key === 40 ) { e[preventDefault](); }
1007
- },
1008
- keyHandler = function(e){
1009
- var key = e.which || e.keyCode,
1010
- activeItem = DOC.activeElement,
1011
- idx = menuItems[indexOf](activeItem[parentNode]),
1012
- isSameElement = activeItem === element,
1013
- isInsideMenu = menu[contains](activeItem),
1014
- isMenuItem = activeItem[parentNode][parentNode] === menu;
1015
-
1016
- if ( isMenuItem || isSameElement ) { // navigate up | down
1017
- idx = isSameElement ? 0
1018
- : key === 38 ? (idx>1?idx-1:0)
1019
- : key === 40 ? (idx<menuItems[length]-1?idx+1:idx) : idx;
1020
- menuItems[idx] && setFocus(menuItems[idx][children][0]);
1021
- }
1022
- if ( (menuItems[length] && isMenuItem // menu has items
1023
- || !menuItems[length] && (isInsideMenu || isSameElement) // menu might be a form
1024
- || !isInsideMenu ) // or the focused element is not in the menu at all
1025
- && element[open] && key === 27 // menu must be open
1026
- ) {
1027
- self.toggle();
1028
- relatedTarget = null;
1029
- }
1030
- },
1031
-
1032
- // private methods
1033
- show = function() {
1034
- bootstrapCustomEvent.call(parent, showEvent, component, relatedTarget);
1035
- addClass(parent,open);
1036
- menu[setAttribute](ariaExpanded,true);
1037
- bootstrapCustomEvent.call(parent, shownEvent, component, relatedTarget);
1038
- element[open] = true;
1039
- off(element, clickEvent, clickHandler);
1040
- setTimeout(function(){
1041
- setFocus( menu[getElementsByTagName]('INPUT')[0] || element ); // focus the first input item | element
1042
- toggleDismiss();
1043
- },1);
1044
- },
1045
- hide = function() {
1046
- bootstrapCustomEvent.call(parent, hideEvent, component, relatedTarget);
1047
- removeClass(parent,open);
1048
- menu[setAttribute](ariaExpanded,false);
1049
- bootstrapCustomEvent.call(parent, hiddenEvent, component, relatedTarget);
1050
- element[open] = false;
1051
- toggleDismiss();
1052
- setFocus(element);
1053
- setTimeout(function(){ on(element, clickEvent, clickHandler); },1);
1054
- };
1055
-
1056
- // set initial state to closed
1057
- element[open] = false;
1058
-
1059
- // public methods
1060
- this.toggle = function() {
1061
- if (hasClass(parent,open) && element[open]) { hide(); }
1062
- else { show(); }
1063
- };
1064
-
1065
- // init
1066
- if (!(stringDropdown in element)) { // prevent adding event handlers twice
1067
- !tabindex in menu && menu[setAttribute](tabindex, '0'); // Fix onblur on Chrome | Safari
1068
- on(element, clickEvent, clickHandler);
1069
- }
1070
-
1071
- element[stringDropdown] = self;
1072
- };
1073
-
1074
- // DROPDOWN DATA API
1075
- // =================
1076
- supports[push]( [stringDropdown, Dropdown, '['+dataToggle+'="dropdown"]'] );
1077
-
1078
-
1079
- /* Native Javascript for Bootstrap 3 | Modal
1080
- -------------------------------------------*/
1081
-
1082
- // MODAL DEFINITION
1083
- // ===============
1084
- var Modal = function(element, options) { // element can be the modal/triggering button
1085
-
1086
- // the modal (both JavaScript / DATA API init) / triggering button element (DATA API)
1087
- element = queryElement(element);
1088
-
1089
- // determine modal, triggering element
1090
- var btnCheck = element[getAttribute](dataTarget)||element[getAttribute]('href'),
1091
- checkModal = queryElement( btnCheck ),
1092
- modal = hasClass(element,'modal') ? element : checkModal,
1093
-
1094
- // strings
1095
- component = 'modal',
1096
- staticString = 'static',
1097
- paddingLeft = 'paddingLeft',
1098
- paddingRight = 'paddingRight',
1099
- modalBackdropString = 'modal-backdrop';
1100
-
1101
- if ( hasClass(element,'modal') ) { element = null; } // modal is now independent of it's triggering element
1102
-
1103
- if ( !modal ) { return; } // invalidate
1104
-
1105
- // set options
1106
- options = options || {};
1107
-
1108
- this[keyboard] = options[keyboard] === false || modal[getAttribute](dataKeyboard) === 'false' ? false : true;
1109
- this[backdrop] = options[backdrop] === staticString || modal[getAttribute](databackdrop) === staticString ? staticString : true;
1110
- this[backdrop] = options[backdrop] === false || modal[getAttribute](databackdrop) === 'false' ? false : this[backdrop];
1111
- this[content] = options[content]; // JavaScript only
1112
- this[root] = options[root] || DOC[body];
1113
-
1114
- // bind, constants, event targets and other vars
1115
- var self = this, relatedTarget = null,
1116
- bodyIsOverflowing, modalIsOverflowing, scrollbarWidth, overlay,
1117
-
1118
- // also find fixed-top / fixed-bottom items
1119
- fixedItems = getElementsByClassName(HTML,fixedTop).concat(getElementsByClassName(HTML,fixedBottom)),
1120
-
1121
- // private methods
1122
- getWindowWidth = function() {
1123
- var htmlRect = HTML[getBoundingClientRect]();
1124
- return globalObject[innerWidth] || (htmlRect[right] - Math.abs(htmlRect[left]));
1125
- },
1126
- setScrollbar = function () {
1127
- var bodyStyle = self[root].currentStyle || globalObject.getComputedStyle(self[root]),
1128
- bodyPad = parseInt((bodyStyle[paddingRight]), 10), itemPad;
1129
- if (bodyIsOverflowing) {
1130
- self[root][style][paddingRight] = (bodyPad + scrollbarWidth) + 'px';
1131
- if (fixedItems[length]){
1132
- for (var i = 0; i < fixedItems[length]; i++) {
1133
- itemPad = (fixedItems[i].currentStyle || globalObject.getComputedStyle(fixedItems[i]))[paddingRight];
1134
- fixedItems[i][style][paddingRight] = ( parseInt(itemPad) + scrollbarWidth) + 'px';
1135
- }
1136
- }
1137
- }
1138
- },
1139
- resetScrollbar = function () {
1140
- self[root][style][paddingRight] = '';
1141
- if (fixedItems[length]){
1142
- for (var i = 0; i < fixedItems[length]; i++) {
1143
- fixedItems[i][style][paddingRight] = '';
1144
- }
1145
- }
1146
- },
1147
- measureScrollbar = function () { // thx walsh
1148
- var scrollDiv = DOC[createElement]('div'), scrollBarWidth;
1149
- scrollDiv.className = component+'-scrollbar-measure'; // this is here to stay
1150
- self[root][appendChild](scrollDiv);
1151
- scrollBarWidth = scrollDiv[offsetWidth] - scrollDiv[clientWidth];
1152
- self[root].removeChild(scrollDiv);
1153
- return scrollBarWidth;
1154
- },
1155
- checkScrollbar = function () {
1156
- bodyIsOverflowing = self[root][clientWidth] < getWindowWidth();
1157
- modalIsOverflowing = modal[scrollHeight] > HTML[clientHeight];
1158
- scrollbarWidth = measureScrollbar();
1159
- },
1160
- adjustDialog = function () {
1161
- modal[style][paddingLeft] = !bodyIsOverflowing && modalIsOverflowing ? scrollbarWidth + 'px' : '';
1162
- modal[style][paddingRight] = bodyIsOverflowing && !modalIsOverflowing ? scrollbarWidth + 'px' : '';
1163
- },
1164
- resetAdjustments = function () {
1165
- modal[style][paddingLeft] = '';
1166
- modal[style][paddingRight] = '';
1167
- },
1168
- createOverlay = function() {
1169
- modalOverlay = 1;
1170
-
1171
- var newOverlay = DOC[createElement]('div');
1172
- overlay = queryElement('.'+modalBackdropString);
1173
-
1174
- if ( overlay === null ) {
1175
- newOverlay[setAttribute]('class',modalBackdropString+' fade');
1176
- overlay = newOverlay;
1177
- self[root][appendChild](overlay);
1178
- }
1179
- },
1180
- removeOverlay = function() {
1181
- overlay = queryElement('.'+modalBackdropString);
1182
- if ( overlay && overlay !== null && typeof overlay === 'object' ) {
1183
- modalOverlay = 0;
1184
- self[root].removeChild(overlay); overlay = null;
1185
- }
1186
- bootstrapCustomEvent.call(modal, hiddenEvent, component);
1187
- },
1188
- keydownHandlerToggle = function() {
1189
- if (hasClass(modal,inClass)) {
1190
- on(DOC, keydownEvent, keyHandler);
1191
- } else {
1192
- off(DOC, keydownEvent, keyHandler);
1193
- }
1194
- },
1195
- resizeHandlerToggle = function() {
1196
- if (hasClass(modal,inClass)) {
1197
- on(globalObject, resizeEvent, self.update);
1198
- } else {
1199
- off(globalObject, resizeEvent, self.update);
1200
- }
1201
- },
1202
- dismissHandlerToggle = function() {
1203
- if (hasClass(modal,inClass)) {
1204
- on(modal, clickEvent, dismissHandler);
1205
- } else {
1206
- off(modal, clickEvent, dismissHandler);
1207
- }
1208
- },
1209
- // triggers
1210
- triggerShow = function() {
1211
- setFocus(modal);
1212
- bootstrapCustomEvent.call(modal, shownEvent, component, relatedTarget);
1213
- },
1214
- triggerHide = function() {
1215
- modal[style].display = '';
1216
- element && (setFocus(element));
1217
-
1218
- (function(){
1219
- if (!getElementsByClassName(DOC,component+' '+inClass)[0]) {
1220
- resetAdjustments();
1221
- resetScrollbar();
1222
- removeClass(self[root],component+'-open');
1223
- overlay && hasClass(overlay,'fade') ? (removeClass(overlay,inClass), emulateTransitionEnd(overlay,removeOverlay))
1224
- : removeOverlay();
1225
-
1226
- resizeHandlerToggle();
1227
- dismissHandlerToggle();
1228
- keydownHandlerToggle();
1229
- }
1230
- }());
1231
- },
1232
- // handlers
1233
- clickHandler = function(e) {
1234
- var clickTarget = e[target];
1235
- clickTarget = clickTarget[hasAttribute](dataTarget) || clickTarget[hasAttribute]('href') ? clickTarget : clickTarget[parentNode];
1236
- if ( clickTarget === element && !hasClass(modal,inClass) ) {
1237
- modal.modalTrigger = element;
1238
- relatedTarget = element;
1239
- self.show();
1240
- e[preventDefault]();
1241
- }
1242
- },
1243
- keyHandler = function(e) {
1244
- var key = e.which || e.keyCode; // keyCode for IE8
1245
- if (self[keyboard] && key == 27 && hasClass(modal,inClass)) {
1246
- self.hide();
1247
- }
1248
- },
1249
- dismissHandler = function(e) {
1250
- var clickTarget = e[target];
1251
- if ( hasClass(modal,inClass) && (clickTarget[parentNode][getAttribute](dataDismiss) === component
1252
- || clickTarget[getAttribute](dataDismiss) === component
1253
- || (clickTarget === modal && self[backdrop] !== staticString) ) ) {
1254
- self.hide(); relatedTarget = null;
1255
- e[preventDefault]();
1256
- }
1257
- };
1258
-
1259
- // public methods
1260
- this.toggle = function() {
1261
- if ( hasClass(modal,inClass) ) {this.hide();} else {this.show();}
1262
- };
1263
- this.show = function() {
1264
- bootstrapCustomEvent.call(modal, showEvent, component, relatedTarget);
1265
-
1266
- // we elegantly hide any opened modal
1267
- var currentOpen = getElementsByClassName(DOC,component+' in')[0];
1268
- currentOpen && currentOpen !== modal && currentOpen.modalTrigger[stringModal].hide();
1269
-
1270
- if ( this[backdrop] ) {
1271
- !modalOverlay && createOverlay();
1272
- }
1273
-
1274
- if ( overlay && modalOverlay && !hasClass(overlay,inClass)) {
1275
- overlay[offsetWidth]; // force reflow to enable trasition
1276
- addClass(overlay,inClass);
1277
- }
1278
-
1279
- (function() {
1280
- modal[style].display = 'block';
1281
-
1282
- checkScrollbar();
1283
- setScrollbar();
1284
- adjustDialog();
1285
-
1286
- addClass(self[root],component+'-open');
1287
- addClass(modal,inClass);
1288
- modal[setAttribute](ariaHidden, false);
1289
-
1290
- resizeHandlerToggle();
1291
- dismissHandlerToggle();
1292
- keydownHandlerToggle();
1293
-
1294
- hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerShow) : triggerShow();
1295
- }());
1296
- };
1297
- this.hide = function() {
1298
- bootstrapCustomEvent.call(modal, hideEvent, component);
1299
- overlay = queryElement('.'+modalBackdropString);
1300
-
1301
- removeClass(modal,inClass);
1302
- modal[setAttribute](ariaHidden, true);
1303
-
1304
- setTimeout(function(){
1305
- hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerHide) : triggerHide();
1306
- }, supportTransitions ? 150 : 0);
1307
- };
1308
- this.setContent = function( content ) {
1309
- queryElement('.'+component+'-content',modal)[innerHTML] = content;
1310
- };
1311
- this.update = function() {
1312
- if (hasClass(modal,inClass)) {
1313
- checkScrollbar();
1314
- setScrollbar();
1315
- adjustDialog();
1316
- }
1317
- };
1318
-
1319
- // init
1320
- // prevent adding event handlers over and over
1321
- // modal is independent of a triggering element
1322
- if ( !!element && !(stringModal in element) ) {
1323
- on(element, clickEvent, clickHandler);
1324
- }
1325
- if ( !!self[content] ) { self.setContent( self[content] ); }
1326
- !!element && (element[stringModal] = self);
1327
- };
1328
-
1329
- // DATA API
1330
- supports[push]( [ stringModal, Modal, '['+dataToggle+'="modal"]' ] );
1331
-
1332
- /* Native Javascript for Bootstrap 3 | Popover
1333
- ----------------------------------------------*/
1334
-
1335
- // POPOVER DEFINITION
1336
- // ==================
1337
- var Popover = function( element, options ) {
1338
-
1339
- // initialization element
1340
- element = queryElement(element);
1341
-
1342
- // set options
1343
- options = options || {};
1344
-
1345
- // DATA API
1346
- var triggerData = element[getAttribute](dataTrigger), // click / hover / focus
1347
- animationData = element[getAttribute](dataAnimation), // true / false
1348
- placementData = element[getAttribute](dataPlacement),
1349
- dismissibleData = element[getAttribute](dataDismissible),
1350
- delayData = element[getAttribute](dataDelay),
1351
- containerData = element[getAttribute](dataContainer),
1352
-
1353
- // internal strings
1354
- component = 'popover',
1355
- template = 'template',
1356
- trigger = 'trigger',
1357
- classString = 'class',
1358
- div = 'div',
1359
- fade = 'fade',
1360
- content = 'content',
1361
- dataContent = 'data-content',
1362
- dismissible = 'dismissible',
1363
- closeBtn = '<button type="button" class="close">×</button>',
1364
-
1365
- // check container
1366
- containerElement = queryElement(options[container]),
1367
- containerDataElement = queryElement(containerData),
1368
-
1369
- // maybe the element is inside a modal
1370
- modal = getClosest(element,'.modal'),
1371
-
1372
- // maybe the element is inside a fixed navbar
1373
- navbarFixedTop = getClosest(element,'.'+fixedTop),
1374
- navbarFixedBottom = getClosest(element,'.'+fixedBottom);
1375
-
1376
- // set instance options
1377
- this[template] = options[template] ? options[template] : null; // JavaScript only
1378
- this[trigger] = options[trigger] ? options[trigger] : triggerData || hoverEvent;
1379
- this[animation] = options[animation] && options[animation] !== fade ? options[animation] : animationData || fade;
1380
- this[placement] = options[placement] ? options[placement] : placementData || top;
1381
- this[delay] = parseInt(options[delay] || delayData) || 200;
1382
- this[dismissible] = options[dismissible] || dismissibleData === 'true' ? true : false;
1383
- this[container] = containerElement ? containerElement
1384
- : containerDataElement ? containerDataElement
1385
- : navbarFixedTop ? navbarFixedTop
1386
- : navbarFixedBottom ? navbarFixedBottom
1387
- : modal ? modal : DOC[body];
1388
-
1389
- // bind, content
1390
- var self = this,
1391
- titleString = element[getAttribute](dataTitle) || null,
1392
- contentString = element[getAttribute](dataContent) || null;
1393
-
1394
- if ( !contentString && !this[template] ) return; // invalidate
1395
-
1396
- // constants, vars
1397
- var popover = null, timer = 0, placementSetting = this[placement],
1398
-
1399
- // handlers
1400
- dismissibleHandler = function(e) {
1401
- if (popover !== null && e[target] === queryElement('.close',popover)) {
1402
- self.hide();
1403
- }
1404
- },
1405
-
1406
- // private methods
1407
- removePopover = function() {
1408
- self[container].removeChild(popover);
1409
- timer = null; popover = null;
1410
- },
1411
- createPopover = function() {
1412
- titleString = element[getAttribute](dataTitle); // check content again
1413
- contentString = element[getAttribute](dataContent);
1414
-
1415
- popover = DOC[createElement](div);
1416
-
1417
- if ( contentString !== null && self[template] === null ) { //create the popover from data attributes
1418
-
1419
- popover[setAttribute]('role','tooltip');
1420
-
1421
- if (titleString !== null) {
1422
- var popoverTitle = DOC[createElement]('h3');
1423
- popoverTitle[setAttribute](classString,component+'-title');
1424
-
1425
- popoverTitle[innerHTML] = self[dismissible] ? titleString + closeBtn : titleString;
1426
- popover[appendChild](popoverTitle);
1427
- }
1428
-
1429
- var popoverArrow = DOC[createElement](div), popoverContent = DOC[createElement](div);
1430
- popoverArrow[setAttribute](classString,'arrow'); popoverContent[setAttribute](classString,component+'-content');
1431
- popover[appendChild](popoverArrow); popover[appendChild](popoverContent);
1432
-
1433
- //set popover content
1434
- popoverContent[innerHTML] = self[dismissible] && titleString === null ? contentString + closeBtn : contentString;
1435
-
1436
- } else { // or create the popover from template
1437
- var popoverTemplate = DOC[createElement](div);
1438
- popoverTemplate[innerHTML] = self[template];
1439
- popover[innerHTML] = popoverTemplate.firstChild[innerHTML];
1440
- }
1441
-
1442
- //append to the container
1443
- self[container][appendChild](popover);
1444
- popover[style].display = 'block';
1445
- popover[setAttribute](classString, component+ ' ' + placementSetting + ' ' + self[animation]);
1446
- },
1447
- showPopover = function () {
1448
- !hasClass(popover,inClass) && ( addClass(popover,inClass) );
1449
- },
1450
- updatePopover = function() {
1451
- styleTip(element,popover,placementSetting,self[container]);
1452
- },
1453
-
1454
- // event toggle
1455
- dismissHandlerToggle = function(type){
1456
- if (clickEvent == self[trigger] || 'focus' == self[trigger]) {
1457
- !self[dismissible] && type( element, 'blur', self.hide );
1458
- }
1459
- self[dismissible] && type( DOC, clickEvent, dismissibleHandler );
1460
- !isIE8 && type( globalObject, resizeEvent, self.hide );
1461
- },
1462
-
1463
- // triggers
1464
- showTrigger = function() {
1465
- dismissHandlerToggle(on);
1466
- bootstrapCustomEvent.call(element, shownEvent, component);
1467
- },
1468
- hideTrigger = function() {
1469
- dismissHandlerToggle(off);
1470
- removePopover();
1471
- bootstrapCustomEvent.call(element, hiddenEvent, component);
1472
- };
1473
-
1474
- // public methods / handlers
1475
- this.toggle = function() {
1476
- if (popover === null) { self.show(); }
1477
- else { self.hide(); }
1478
- };
1479
- this.show = function() {
1480
- clearTimeout(timer);
1481
- timer = setTimeout( function() {
1482
- if (popover === null) {
1483
- placementSetting = self[placement]; // we reset placement in all cases
1484
- createPopover();
1485
- updatePopover();
1486
- showPopover();
1487
- bootstrapCustomEvent.call(element, showEvent, component);
1488
- !!self[animation] ? emulateTransitionEnd(popover, showTrigger) : showTrigger();
1489
- }
1490
- }, 20 );
1491
- };
1492
- this.hide = function() {
1493
- clearTimeout(timer);
1494
- timer = setTimeout( function() {
1495
- if (popover && popover !== null && hasClass(popover,inClass)) {
1496
- bootstrapCustomEvent.call(element, hideEvent, component);
1497
- removeClass(popover,inClass);
1498
- !!self[animation] ? emulateTransitionEnd(popover, hideTrigger) : hideTrigger();
1499
- }
1500
- }, self[delay] );
1501
- };
1502
-
1503
- // init
1504
- if ( !(stringPopover in element) ) { // prevent adding event handlers twice
1505
- if (self[trigger] === hoverEvent) {
1506
- on( element, mouseHover[0], self.show );
1507
- if (!self[dismissible]) { on( element, mouseHover[1], self.hide ); }
1508
- } else if (clickEvent == self[trigger] || 'focus' == self[trigger]) {
1509
- on( element, self[trigger], self.toggle );
1510
- }
1511
- }
1512
- element[stringPopover] = self;
1513
- };
1514
-
1515
- // POPOVER DATA API
1516
- // ================
1517
- supports[push]( [ stringPopover, Popover, '['+dataToggle+'="popover"]' ] );
1518
-
1519
-
1520
- /* Native Javascript for Bootstrap 3 | ScrollSpy
1521
- -----------------------------------------------*/
1522
-
1523
- // SCROLLSPY DEFINITION
1524
- // ====================
1525
- var ScrollSpy = function(element, options) {
1526
-
1527
- // initialization element, the element we spy on
1528
- element = queryElement(element);
1529
-
1530
- // DATA API
1531
- var targetData = queryElement(element[getAttribute](dataTarget)),
1532
- offsetData = element[getAttribute]('data-offset');
1533
-
1534
- // set options
1535
- options = options || {};
1536
- if ( !options[target] && !targetData ) { return; } // invalidate
1537
-
1538
- // event targets, constants
1539
- var self = this, spyTarget = options[target] && queryElement(options[target]) || targetData,
1540
- links = spyTarget && spyTarget[getElementsByTagName]('A'),
1541
- offset = parseInt(offsetData || options['offset']) || 10,
1542
- items = [], targetItems = [], scrollOffset,
1543
- scrollTarget = element[offsetHeight] < element[scrollHeight] ? element : globalObject, // determine which is the real scrollTarget
1544
- isWindow = scrollTarget === globalObject;
1545
-
1546
- // populate items and targets
1547
- for (var i=0, il=links[length]; i<il; i++) {
1548
- var href = links[i][getAttribute]('href'),
1549
- targetItem = href && href.charAt(0) === '#' && href.slice(-1) !== '#' && queryElement(href);
1550
- if ( !!targetItem ) {
1551
- items[push](links[i]);
1552
- targetItems[push](targetItem);
1553
- }
1554
- }
1555
-
1556
- // private methods
1557
- var updateItem = function(index) {
1558
- var parent = items[index][parentNode], // item's parent LI element
1559
- targetItem = targetItems[index], // the menu item targets this element
1560
- dropdown = getClosest(parent,'.dropdown'),
1561
- targetRect = isWindow && targetItem[getBoundingClientRect](),
1562
-
1563
- isActive = hasClass(parent,active) || false,
1564
-
1565
- topEdge = (isWindow ? targetRect[top] + scrollOffset : targetItem[offsetTop]) - offset,
1566
- bottomEdge = isWindow ? targetRect[bottom] + scrollOffset - offset : targetItems[index+1] ? targetItems[index+1][offsetTop] - offset : element[scrollHeight],
1567
-
1568
- inside = scrollOffset >= topEdge && bottomEdge > scrollOffset;
1569
-
1570
- if ( !isActive && inside ) {
1571
- if ( parent.tagName === 'LI' && !hasClass(parent,active) ) {
1572
- addClass(parent,active);
1573
- if (dropdown && !hasClass(dropdown,active) ) {
1574
- addClass(dropdown,active);
1575
- }
1576
- bootstrapCustomEvent.call(element, 'activate', 'scrollspy', items[index]);
1577
- }
1578
- } else if ( !inside ) {
1579
- if ( parent.tagName === 'LI' && hasClass(parent,active) ) {
1580
- removeClass(parent,active);
1581
- if (dropdown && hasClass(dropdown,active) && !getElementsByClassName(parent[parentNode],active).length ) {
1582
- removeClass(dropdown,active);
1583
- }
1584
- }
1585
- } else if ( !inside && !isActive || isActive && inside ) {
1586
- return;
1587
- }
1588
- },
1589
- updateItems = function(){
1590
- scrollOffset = isWindow ? getScroll().y : element[scrollTop];
1591
- for (var index=0, itl=items[length]; index<itl; index++) {
1592
- updateItem(index)
1593
- }
1594
- };
1595
-
1596
- // public method
1597
- this.refresh = function () {
1598
- updateItems();
1599
- }
1600
-
1601
- // init
1602
- if ( !(stringScrollSpy in element) ) { // prevent adding event handlers twice
1603
- on( scrollTarget, scrollEvent, self.refresh );
1604
- !isIE8 && on( globalObject, resizeEvent, self.refresh );
1605
- }
1606
- self.refresh();
1607
- element[stringScrollSpy] = self;
1608
- };
1609
-
1610
- // SCROLLSPY DATA API
1611
- // ==================
1612
- supports[push]( [ stringScrollSpy, ScrollSpy, '['+dataSpy+'="scroll"]' ] );
1613
-
1614
-
1615
- /* Native Javascript for Bootstrap 3 | Tab
1616
- -----------------------------------------*/
1617
-
1618
- // TAB DEFINITION
1619
- // ==============
1620
- var Tab = function( element, options ) {
1621
-
1622
- // initialization element
1623
- element = queryElement(element);
1624
-
1625
- // DATA API
1626
- var heightData = element[getAttribute](dataHeight),
1627
-
1628
- // strings
1629
- component = 'tab', height = 'height', float = 'float', isAnimating = 'isAnimating';
1630
-
1631
- // set options
1632
- options = options || {};
1633
- this[height] = supportTransitions ? (options[height] || heightData === 'true') : false; // filter legacy browsers
1634
-
1635
- // bind, event targets
1636
- var self = this, next,
1637
- tabs = getClosest(element,'.nav'),
1638
- tabsContentContainer = false,
1639
- dropdown = tabs && queryElement('.dropdown',tabs),
1640
- activeTab, activeContent, nextContent, containerHeight, equalContents, nextHeight,
1641
-
1642
- // trigger
1643
- triggerEnd = function(){
1644
- tabsContentContainer[style][height] = '';
1645
- removeClass(tabsContentContainer,collapsing);
1646
- tabs[isAnimating] = false;
1647
- },
1648
- triggerShow = function() {
1649
- if (tabsContentContainer) { // height animation
1650
- if ( equalContents ) {
1651
- triggerEnd();
1652
- } else {
1653
- setTimeout(function(){ // enables height animation
1654
- tabsContentContainer[style][height] = nextHeight + 'px'; // height animation
1655
- tabsContentContainer[offsetWidth];
1656
- emulateTransitionEnd(tabsContentContainer, triggerEnd);
1657
- },1);
1658
- }
1659
- } else {
1660
- tabs[isAnimating] = false;
1661
- }
1662
- bootstrapCustomEvent.call(next, shownEvent, component, activeTab);
1663
- },
1664
- triggerHide = function() {
1665
- if (tabsContentContainer) {
1666
- activeContent[style][float] = left;
1667
- nextContent[style][float] = left;
1668
- containerHeight = activeContent[scrollHeight];
1669
- }
1670
-
1671
- addClass(nextContent,active);
1672
- bootstrapCustomEvent.call(next, showEvent, component, activeTab);
1673
-
1674
- removeClass(activeContent,active);
1675
- bootstrapCustomEvent.call(activeTab, hiddenEvent, component, next);
1676
-
1677
- if (tabsContentContainer) {
1678
- nextHeight = nextContent[scrollHeight];
1679
- equalContents = nextHeight === containerHeight;
1680
- addClass(tabsContentContainer,collapsing);
1681
- tabsContentContainer[style][height] = containerHeight + 'px'; // height animation
1682
- tabsContentContainer[offsetHeight];
1683
- activeContent[style][float] = '';
1684
- nextContent[style][float] = '';
1685
- }
1686
-
1687
- if ( hasClass(nextContent, 'fade') ) {
1688
- setTimeout(function(){ // makes sure to go forward
1689
- addClass(nextContent,inClass);
1690
- emulateTransitionEnd(nextContent,triggerShow);
1691
- },20);
1692
- } else { triggerShow(); }
1693
- };
1694
-
1695
- if (!tabs) return; // invalidate
1696
-
1697
- // set default animation state
1698
- tabs[isAnimating] = false;
1699
-
1700
- // private methods
1701
- var getActiveTab = function() {
1702
- var activeTabs = getElementsByClassName(tabs,active), activeTab;
1703
- if ( activeTabs[length] === 1 && !hasClass(activeTabs[0],'dropdown') ) {
1704
- activeTab = activeTabs[0];
1705
- } else if ( activeTabs[length] > 1 ) {
1706
- activeTab = activeTabs[activeTabs[length]-1];
1707
- }
1708
- return activeTab[getElementsByTagName]('A')[0];
1709
- },
1710
- getActiveContent = function() {
1711
- return queryElement(getActiveTab()[getAttribute]('href'));
1712
- },
1713
- // handler
1714
- clickHandler = function(e) {
1715
- var href = e[target][getAttribute]('href');
1716
- e[preventDefault]();
1717
- next = e[target][getAttribute](dataToggle) === component || (href && href.charAt(0) === '#')
1718
- ? e[target] : e[target][parentNode]; // allow for child elements like icons to use the handler
1719
- !tabs[isAnimating] && !hasClass(next[parentNode],active) && self.show();
1720
- };
1721
-
1722
- // public method
1723
- this.show = function() { // the tab we clicked is now the next tab
1724
- next = next || element;
1725
- nextContent = queryElement(next[getAttribute]('href')); //this is the actual object, the next tab content to activate
1726
- activeTab = getActiveTab();
1727
- activeContent = getActiveContent();
1728
-
1729
- tabs[isAnimating] = true;
1730
- removeClass(activeTab[parentNode],active);
1731
- addClass(next[parentNode],active);
1732
-
1733
- if ( dropdown ) {
1734
- if ( !hasClass(element[parentNode][parentNode],'dropdown-menu') ) {
1735
- if (hasClass(dropdown,active)) removeClass(dropdown,active);
1736
- } else {
1737
- if (!hasClass(dropdown,active)) addClass(dropdown,active);
1738
- }
1739
- }
1740
-
1741
- bootstrapCustomEvent.call(activeTab, hideEvent, component, next);
1742
-
1743
- if (hasClass(activeContent, 'fade')) {
1744
- removeClass(activeContent,inClass);
1745
- emulateTransitionEnd(activeContent, triggerHide);
1746
- } else { triggerHide(); }
1747
- };
1748
-
1749
- // init
1750
- if ( !(stringTab in element) ) { // prevent adding event handlers twice
1751
- on(element, clickEvent, clickHandler);
1752
- }
1753
- if (self[height]) { tabsContentContainer = getActiveContent()[parentNode]; }
1754
- element[stringTab] = self;
1755
- };
1756
-
1757
- // TAB DATA API
1758
- // ============
1759
- supports[push]( [ stringTab, Tab, '['+dataToggle+'="tab"]' ] );
1760
-
1761
-
1762
- /* Native Javascript for Bootstrap 3 | Tooltip
1763
- ---------------------------------------------*/
1764
-
1765
- // TOOLTIP DEFINITION
1766
- // ==================
1767
- var Tooltip = function( element,options ) {
1768
-
1769
- // initialization element
1770
- element = queryElement(element);
1771
-
1772
- // set options
1773
- options = options || {};
1774
-
1775
- // DATA API
1776
- var animationData = element[getAttribute](dataAnimation),
1777
- placementData = element[getAttribute](dataPlacement),
1778
- delayData = element[getAttribute](dataDelay),
1779
- containerData = element[getAttribute](dataContainer),
1780
-
1781
- // strings
1782
- component = 'tooltip',
1783
- classString = 'class',
1784
- title = 'title',
1785
- fade = 'fade',
1786
- div = 'div',
1787
-
1788
- // check container
1789
- containerElement = queryElement(options[container]),
1790
- containerDataElement = queryElement(containerData),
1791
-
1792
- // maybe the element is inside a modal
1793
- modal = getClosest(element,'.modal'),
1794
-
1795
- // maybe the element is inside a fixed navbar
1796
- navbarFixedTop = getClosest(element,'.'+fixedTop),
1797
- navbarFixedBottom = getClosest(element,'.'+fixedBottom);
1798
-
1799
- // set instance options
1800
- this[animation] = options[animation] && options[animation] !== fade ? options[animation] : animationData || fade;
1801
- this[placement] = options[placement] ? options[placement] : placementData || top;
1802
- this[delay] = parseInt(options[delay] || delayData) || 200;
1803
- this[container] = containerElement ? containerElement
1804
- : containerDataElement ? containerDataElement
1805
- : navbarFixedTop ? navbarFixedTop
1806
- : navbarFixedBottom ? navbarFixedBottom
1807
- : modal ? modal : DOC[body];
1808
-
1809
- // bind, event targets, title and constants
1810
- var self = this, timer = 0, placementSetting = this[placement], tooltip = null,
1811
- titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle);
1812
-
1813
- if ( !titleString || titleString == "" ) return; // invalidate
1814
-
1815
- // private methods
1816
- var removeToolTip = function() {
1817
- self[container].removeChild(tooltip);
1818
- tooltip = null; timer = null;
1819
- },
1820
- createToolTip = function() {
1821
- titleString = element[getAttribute](title) || element[getAttribute](dataTitle) || element[getAttribute](dataOriginalTitle); // read the title again
1822
- if ( !titleString || titleString == "" ) return false; // invalidate
1823
-
1824
- tooltip = DOC[createElement](div);
1825
- tooltip[setAttribute]('role',component);
1826
-
1827
- var tooltipArrow = DOC[createElement](div), tooltipInner = DOC[createElement](div);
1828
- tooltipArrow[setAttribute](classString, component+'-arrow'); tooltipInner[setAttribute](classString,component+'-inner');
1829
-
1830
- tooltip[appendChild](tooltipArrow); tooltip[appendChild](tooltipInner);
1831
-
1832
- tooltipInner[innerHTML] = titleString;
1833
-
1834
- self[container][appendChild](tooltip);
1835
- tooltip[setAttribute](classString, component + ' ' + placementSetting + ' ' + self[animation]);
1836
- },
1837
- updateTooltip = function () {
1838
- styleTip(element,tooltip,placementSetting,self[container]);
1839
- },
1840
- showTooltip = function () {
1841
- !hasClass(tooltip,inClass) && ( addClass(tooltip,inClass) );
1842
- },
1843
- // triggers
1844
- showTrigger = function() {
1845
- bootstrapCustomEvent.call(element, shownEvent, component);
1846
- !isIE8 && on( globalObject, resizeEvent, self.hide );
1847
- },
1848
- hideTrigger = function() {
1849
- !isIE8 && off( globalObject, resizeEvent, self.hide );
1850
- removeToolTip();
1851
- bootstrapCustomEvent.call(element, hiddenEvent, component);
1852
- };
1853
-
1854
- // public methods
1855
- this.show = function() {
1856
- clearTimeout(timer);
1857
- timer = setTimeout( function() {
1858
- if (tooltip === null) {
1859
- placementSetting = self[placement]; // we reset placement in all cases
1860
- if(createToolTip() == false) return;
1861
- updateTooltip();
1862
- showTooltip();
1863
- bootstrapCustomEvent.call(element, showEvent, component);
1864
- !!self[animation] ? emulateTransitionEnd(tooltip, showTrigger) : showTrigger();
1865
- }
1866
- }, 20 );
1867
- };
1868
- this.hide = function() {
1869
- clearTimeout(timer);
1870
- timer = setTimeout( function() {
1871
- if (tooltip && hasClass(tooltip,inClass)) {
1872
- bootstrapCustomEvent.call(element, hideEvent, component);
1873
- removeClass(tooltip,inClass);
1874
- !!self[animation] ? emulateTransitionEnd(tooltip, hideTrigger) : hideTrigger();
1875
- }
1876
- }, self[delay]);
1877
- };
1878
- this.toggle = function() {
1879
- if (!tooltip) { self.show(); }
1880
- else { self.hide(); }
1881
- };
1882
-
1883
- // init
1884
- if ( !(stringTooltip in element) ) { // prevent adding event handlers twice
1885
- element[setAttribute](dataOriginalTitle,titleString);
1886
- element.removeAttribute(title);
1887
- on(element, mouseHover[0], self.show);
1888
- on(element, mouseHover[1], self.hide);
1889
- }
1890
- element[stringTooltip] = self;
1891
- };
1892
-
1893
- // TOOLTIP DATA API
1894
- // =================
1895
- supports[push]( [ stringTooltip, Tooltip, '['+dataToggle+'="tooltip"]' ] );
1896
-
1897
-
1898
-
1899
- /* Native Javascript for Bootstrap 3 | Initialize Data API
1900
- --------------------------------------------------------*/
1901
- var initializeDataAPI = function( constructor, collection ){
1902
- for (var i=0, l=collection[length]; i<l; i++) {
1903
- new constructor(collection[i]);
1904
- }
1905
- },
1906
- initCallback = BSN.initCallback = function(lookUp){
1907
- lookUp = lookUp || DOC;
1908
- for (var i=0, l=supports[length]; i<l; i++) {
1909
- initializeDataAPI( supports[i][1], lookUp[querySelectorAll] (supports[i][2]) );
1910
- }
1911
- };
1912
-
1913
- // bulk initialize all components
1914
- DOC[body] ? initCallback() : on( DOC, 'DOMContentLoaded', function(){ initCallback(); } );
1915
-
1916
- return {
1917
- Affix: Affix,
1918
- Alert: Alert,
1919
- Button: Button,
1920
- Carousel: Carousel,
1921
- Collapse: Collapse,
1922
- Dropdown: Dropdown,
1923
- Modal: Modal,
1924
- Popover: Popover,
1925
- ScrollSpy: ScrollSpy,
1926
- Tab: Tab,
1927
- Tooltip: Tooltip
1928
- };
1929
- }));
1930
- return this;
1931
- };
1932
-
1933
- const global = new Global().dispatch();
1934
-
1935
- export default global;