@fintatech/fintachart 3.1.0

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 (341) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.md +63 -0
  3. package/README.md +151 -0
  4. package/THIRD_PARTY_NOTICES.md +38 -0
  5. package/basic-objects.html +165 -0
  6. package/css/FintaChart.min.css +1 -0
  7. package/css/external/jqNumericField.min.css +1 -0
  8. package/css/external/spectrum.min.css +7 -0
  9. package/css/external/toastr.min.css +1 -0
  10. package/custom-indicator.html +209 -0
  11. package/d.ts/FintaChart.d.ts +24313 -0
  12. package/d.ts/frameworks/Intl.d.ts +115 -0
  13. package/d.ts/frameworks/bootstrap.d.ts +128 -0
  14. package/d.ts/frameworks/bootstrap.v3.datetimepicker.d.ts +10 -0
  15. package/d.ts/frameworks/detectizr.d.ts +27 -0
  16. package/d.ts/frameworks/dom-to-image-more.d.ts +17 -0
  17. package/d.ts/frameworks/html2canvas.d.ts +101 -0
  18. package/d.ts/frameworks/i18nextXHRBackend.d.ts +42 -0
  19. package/d.ts/frameworks/jquery-i18next.d.ts +14 -0
  20. package/d.ts/frameworks/jquery-ui.d.ts +1914 -0
  21. package/d.ts/frameworks/jquery.d.ts +3779 -0
  22. package/d.ts/frameworks/jquery.ui.touch-punch.d.ts +12 -0
  23. package/d.ts/frameworks/moment-node.d.ts +485 -0
  24. package/d.ts/frameworks/moment.d.ts +10 -0
  25. package/d.ts/frameworks/tinycolor.d.ts +377 -0
  26. package/d.ts/frameworks-modified/bootstrap-select.d.ts +18 -0
  27. package/d.ts/frameworks-modified/i18next.d.ts +148 -0
  28. package/d.ts/frameworks-modified/jquery.autocolumnlist.d.ts +17 -0
  29. package/d.ts/frameworks-modified/jquery.resizable.d.ts +20 -0
  30. package/d.ts/frameworks-modified/spectrum.d.ts +294 -0
  31. package/d.ts/frameworks-modified/switchery.d.ts +69 -0
  32. package/d.ts/frameworks-modified/toastr.d.ts +224 -0
  33. package/data/offline-market-history/EUR_CAD/Day/1.csv +2001 -0
  34. package/data/offline-market-history/EUR_CAD/Hour/1.csv +1702 -0
  35. package/data/offline-market-history/EUR_CAD/Hour/4.csv +442 -0
  36. package/data/offline-market-history/EUR_CAD/Minute/1.csv +2001 -0
  37. package/data/offline-market-history/EUR_CAD/Minute/15.csv +2001 -0
  38. package/data/offline-market-history/EUR_CAD/Minute/5.csv +2001 -0
  39. package/data/offline-market-history/EUR_CAD/Monthly/1.csv +175 -0
  40. package/data/offline-market-history/EUR_CAD/Weekly/1.csv +752 -0
  41. package/data/offline-market-history/EUR_CAD/Yearly/1.csv +16 -0
  42. package/data/offline-market-history/EUR_GBP/Day/1.csv +2001 -0
  43. package/data/offline-market-history/EUR_GBP/Hour/1.csv +1702 -0
  44. package/data/offline-market-history/EUR_GBP/Hour/4.csv +442 -0
  45. package/data/offline-market-history/EUR_GBP/Minute/1.csv +2001 -0
  46. package/data/offline-market-history/EUR_GBP/Minute/15.csv +2001 -0
  47. package/data/offline-market-history/EUR_GBP/Minute/5.csv +2001 -0
  48. package/data/offline-market-history/EUR_GBP/Monthly/1.csv +199 -0
  49. package/data/offline-market-history/EUR_GBP/Weekly/1.csv +860 -0
  50. package/data/offline-market-history/EUR_GBP/Yearly/1.csv +18 -0
  51. package/data/predefined-templates/EMAAndMACDTemplate.json +100 -0
  52. package/data/predefined-templates/bigTreeTemplate.json +137 -0
  53. package/data/predefined-templates/multiIndicator.json +136 -0
  54. package/data/predefined-templates/renkoTemplate.json +50 -0
  55. package/data/predefined-templates/standartCandleTemplate.json +73 -0
  56. package/fonts/calibri/calibri.svg +3707 -0
  57. package/fonts/calibri/calibri.ttf +0 -0
  58. package/fonts/calibri/calibri.woff +0 -0
  59. package/fonts/courier-new/courier-new.svg +633 -0
  60. package/fonts/courier-new/courier-new.ttf +0 -0
  61. package/fonts/courier-new/courier-new.woff +0 -0
  62. package/fonts/open-sans-cyrillic/open-sans-cyrillic.svg +475 -0
  63. package/fonts/open-sans-cyrillic/open-sans-cyrillic.ttf +0 -0
  64. package/fonts/open-sans-cyrillic/open-sans-cyrillic.woff +0 -0
  65. package/fonts/open-sans-cyrillic-ext/open-sans-cyrillic-ext.svg +567 -0
  66. package/fonts/open-sans-cyrillic-ext/open-sans-cyrillic-ext.ttf +0 -0
  67. package/fonts/open-sans-cyrillic-ext/open-sans-cyrillic-ext.woff +0 -0
  68. package/fonts/open-sans-greek/open-sans-greek.svg +603 -0
  69. package/fonts/open-sans-greek/open-sans-greek.ttf +0 -0
  70. package/fonts/open-sans-greek/open-sans-greek.woff +0 -0
  71. package/fonts/open-sans-greek-ext/open-sans-greek-ext.svg +42 -0
  72. package/fonts/open-sans-greek-ext/open-sans-greek-ext.ttf +0 -0
  73. package/fonts/open-sans-greek-ext/open-sans-greek-ext.woff +0 -0
  74. package/fonts/open-sans-latin/open-sans-latin.svg +1863 -0
  75. package/fonts/open-sans-latin/open-sans-latin.ttf +0 -0
  76. package/fonts/open-sans-latin/open-sans-latin.woff +0 -0
  77. package/fonts/open-sans-latin-ext/open-sans-latin-ext.svg +1686 -0
  78. package/fonts/open-sans-latin-ext/open-sans-latin-ext.ttf +0 -0
  79. package/fonts/open-sans-latin-ext/open-sans-latin-ext.woff +0 -0
  80. package/fonts/open-sans-vietnamese/open-sans-vietnamese.svg +375 -0
  81. package/fonts/open-sans-vietnamese/open-sans-vietnamese.ttf +0 -0
  82. package/fonts/open-sans-vietnamese/open-sans-vietnamese.woff +0 -0
  83. package/fonts/rubik-medium/Rubik-Medium.svg +8831 -0
  84. package/fonts/rubik-medium/Rubik-Medium.ttf +0 -0
  85. package/fonts/rubik-medium/Rubik-Medium.woff +0 -0
  86. package/fonts/rubik-regular/Rubik-Regular.svg +8885 -0
  87. package/fonts/rubik-regular/Rubik-Regular.ttf +0 -0
  88. package/fonts/rubik-regular/Rubik-Regular.woff +0 -0
  89. package/fonts/source-sans-pro-latin/source-sans-pro-latin.svg +2642 -0
  90. package/fonts/source-sans-pro-latin/source-sans-pro-latin.ttf +0 -0
  91. package/fonts/source-sans-pro-latin/source-sans-pro-latin.woff +0 -0
  92. package/fonts/source-sans-pro-latin-ext/source-sans-pro-latin-ext.svg +1572 -0
  93. package/fonts/source-sans-pro-latin-ext/source-sans-pro-latin-ext.ttf +0 -0
  94. package/fonts/source-sans-pro-latin-ext/source-sans-pro-latin-ext.woff +0 -0
  95. package/fonts/source-sans-pro-vietnamese/source-sans-pro-vietnamese.svg +428 -0
  96. package/fonts/source-sans-pro-vietnamese/source-sans-pro-vietnamese.ttf +0 -0
  97. package/fonts/source-sans-pro-vietnamese/source-sans-pro-vietnamese.woff +0 -0
  98. package/htmldialogs/ChartContextMenu.html +3 -0
  99. package/htmldialogs/ChartTypeSettingsDialog.html +231 -0
  100. package/htmldialogs/CheckboxIndicatorParameterControl.html +9 -0
  101. package/htmldialogs/CompareInstrumentSettings.html +61 -0
  102. package/htmldialogs/ComparingContextMenu.html +8 -0
  103. package/htmldialogs/ConfirmDialog.html +28 -0
  104. package/htmldialogs/DemoModePopup.html +24 -0
  105. package/htmldialogs/FillPlotStyleControl.html +28 -0
  106. package/htmldialogs/HotkeysSettings.html +28 -0
  107. package/htmldialogs/IndicatorContextMenu.html +18 -0
  108. package/htmldialogs/IndicatorSettingsDialog.html +38 -0
  109. package/htmldialogs/IndicatorsDialog.html +39 -0
  110. package/htmldialogs/IndicatorsOverview_en.html +1694 -0
  111. package/htmldialogs/IndicatorsOverview_ua.html +9 -0
  112. package/htmldialogs/InstrumentSearchDialog.html +22 -0
  113. package/htmldialogs/LinePlotStyleControl.html +33 -0
  114. package/htmldialogs/MainSettings.html +292 -0
  115. package/htmldialogs/MarketEventPopup.html +27 -0
  116. package/htmldialogs/MarketEventsSettingsDialog.html +22 -0
  117. package/htmldialogs/NumericIndicatorParameter.html +8 -0
  118. package/htmldialogs/OpenChart.html +6 -0
  119. package/htmldialogs/PatternSettingsControl.html +26 -0
  120. package/htmldialogs/PatternsIndicatorSettingsDialog.html +30 -0
  121. package/htmldialogs/PatternsSettingsParameterControl.html +12 -0
  122. package/htmldialogs/PositionShapeContextMenu.html +9 -0
  123. package/htmldialogs/QuantityPopup.html +7 -0
  124. package/htmldialogs/Scrollbar.html +6 -0
  125. package/htmldialogs/SelectableIndicatorParameter.html +9 -0
  126. package/htmldialogs/ShapeContextMenu.html +7 -0
  127. package/htmldialogs/ShapeFibonacciSettingsDialog.html +261 -0
  128. package/htmldialogs/ShapePositionSettingsDialog.html +351 -0
  129. package/htmldialogs/ShapeSettingsDialog.html +521 -0
  130. package/htmldialogs/TimeFrameChangePopup.html +11 -0
  131. package/htmldialogs/TimeIndicatorParameterControl.html +89 -0
  132. package/htmldialogs/Toolbar.html +1710 -0
  133. package/htmldialogs/TooltipView.html +151 -0
  134. package/htmldialogs/TradingContextMenu.html +2 -0
  135. package/img/ContextMenuCheckbox.png +0 -0
  136. package/img/cross-hairs.cur +0 -0
  137. package/img/eu.png +0 -0
  138. package/img/favicon/favicon.ico +0 -0
  139. package/img/fist.cur +0 -0
  140. package/img/point.cur +0 -0
  141. package/img/svg-icons/Illustration-License-b.svg +1 -0
  142. package/img/svg-icons/Illustration-License-w.svg +1 -0
  143. package/img/svg-icons/abcd-label-pattern.svg +1 -0
  144. package/img/svg-icons/abcd-pattern.svg +1 -0
  145. package/img/svg-icons/add.svg +1 -0
  146. package/img/svg-icons/adjust-OHLC.svg +1 -0
  147. package/img/svg-icons/adjust-all.svg +1 -0
  148. package/img/svg-icons/andrews-pitchfork.svg +1 -0
  149. package/img/svg-icons/arrow-down.svg +1 -0
  150. package/img/svg-icons/arrow-left.svg +3 -0
  151. package/img/svg-icons/arrow-right.svg +3 -0
  152. package/img/svg-icons/arrow-type-type.svg +3 -0
  153. package/img/svg-icons/arrow-up.svg +1 -0
  154. package/img/svg-icons/arrow.svg +1 -0
  155. package/img/svg-icons/balloon.svg +1 -0
  156. package/img/svg-icons/brand-x.svg +1 -0
  157. package/img/svg-icons/calculator.svg +15 -0
  158. package/img/svg-icons/chartType-area.svg +1 -0
  159. package/img/svg-icons/chartType-bars.svg +1 -0
  160. package/img/svg-icons/chartType-candles-volume.svg +1 -0
  161. package/img/svg-icons/chartType-candles.svg +1 -0
  162. package/img/svg-icons/chartType-colored-bars.svg +1 -0
  163. package/img/svg-icons/chartType-equi-volume-shadow.svg +1 -0
  164. package/img/svg-icons/chartType-equi-volume.svg +1 -0
  165. package/img/svg-icons/chartType-heikin-ashi.svg +1 -0
  166. package/img/svg-icons/chartType-hollow-candles.svg +1 -0
  167. package/img/svg-icons/chartType-kagi.svg +1 -0
  168. package/img/svg-icons/chartType-line-break.svg +1 -0
  169. package/img/svg-icons/chartType-line.svg +1 -0
  170. package/img/svg-icons/chartType-point-figure.svg +1 -0
  171. package/img/svg-icons/chartType-range-bars.svg +1 -0
  172. package/img/svg-icons/chartType-renko.svg +1 -0
  173. package/img/svg-icons/chevron-right-double.svg +3 -0
  174. package/img/svg-icons/chevron.svg +3 -0
  175. package/img/svg-icons/circle.svg +1 -0
  176. package/img/svg-icons/close-floating-toolbar.svg +1 -0
  177. package/img/svg-icons/close-pane.svg +1 -0
  178. package/img/svg-icons/close-rect.svg +4 -0
  179. package/img/svg-icons/close-windows.svg +1 -0
  180. package/img/svg-icons/close.svg +4 -0
  181. package/img/svg-icons/compare.svg +1 -0
  182. package/img/svg-icons/copy.svg +1 -0
  183. package/img/svg-icons/cursorType-arrow-with-labels.svg +1 -0
  184. package/img/svg-icons/cursorType-arrow.svg +3 -0
  185. package/img/svg-icons/cursorType-crosshairs.svg +1 -0
  186. package/img/svg-icons/cursorType-point.svg +1 -0
  187. package/img/svg-icons/cyclic-lines.svg +1 -0
  188. package/img/svg-icons/default-screen.svg +11 -0
  189. package/img/svg-icons/demo-popup-bg.svg +1 -0
  190. package/img/svg-icons/diamond.svg +1 -0
  191. package/img/svg-icons/dot.svg +1 -0
  192. package/img/svg-icons/drag.svg +1 -0
  193. package/img/svg-icons/elliott-wave-pattern.svg +1 -0
  194. package/img/svg-icons/ellipse.svg +1 -0
  195. package/img/svg-icons/error-channel.svg +1 -0
  196. package/img/svg-icons/export.svg +1 -0
  197. package/img/svg-icons/extended-line.svg +3 -0
  198. package/img/svg-icons/fibonacci-arcs.svg +1 -0
  199. package/img/svg-icons/fibonacci-ellipses.svg +1 -0
  200. package/img/svg-icons/fibonacci-extensions.svg +1 -0
  201. package/img/svg-icons/fibonacci-fan.svg +1 -0
  202. package/img/svg-icons/fibonacci-retracements.svg +1 -0
  203. package/img/svg-icons/fibonacci-time-zones.svg +1 -0
  204. package/img/svg-icons/fintatech.svg +1 -0
  205. package/img/svg-icons/free-hand.svg +1 -0
  206. package/img/svg-icons/full-screen.svg +11 -0
  207. package/img/svg-icons/full-windows.svg +12 -0
  208. package/img/svg-icons/gann-fan.svg +1 -0
  209. package/img/svg-icons/general-delete.svg +3 -0
  210. package/img/svg-icons/head-shoulders-pattern.svg +1 -0
  211. package/img/svg-icons/horizontal-line.svg +1 -0
  212. package/img/svg-icons/horizontal-ray.svg +3 -0
  213. package/img/svg-icons/html-code.svg +1 -0
  214. package/img/svg-icons/image.svg +5 -0
  215. package/img/svg-icons/images.svg +1 -0
  216. package/img/svg-icons/in-shape-mode.svg +1 -0
  217. package/img/svg-icons/insert-indicator.svg +1 -0
  218. package/img/svg-icons/kings-crown-pattern.svg +1 -0
  219. package/img/svg-icons/latest-position.svg +1 -0
  220. package/img/svg-icons/line-segment.svg +1 -0
  221. package/img/svg-icons/link.svg +5 -0
  222. package/img/svg-icons/lock.svg +3 -0
  223. package/img/svg-icons/magnet-mode.svg +1 -0
  224. package/img/svg-icons/measure.svg +1 -0
  225. package/img/svg-icons/multiply-link.svg +5 -0
  226. package/img/svg-icons/note.svg +1 -0
  227. package/img/svg-icons/number-label-pattern.svg +1 -0
  228. package/img/svg-icons/open-OHLC-pane.svg +1 -0
  229. package/img/svg-icons/options.svg +1 -0
  230. package/img/svg-icons/period.svg +1 -0
  231. package/img/svg-icons/polygon.svg +1 -0
  232. package/img/svg-icons/polyline.svg +1 -0
  233. package/img/svg-icons/position-long.svg +90 -0
  234. package/img/svg-icons/position-long_og.svg +81 -0
  235. package/img/svg-icons/position-short.svg +90 -0
  236. package/img/svg-icons/position-short_og.svg +89 -0
  237. package/img/svg-icons/quadrant-lines.svg +1 -0
  238. package/img/svg-icons/raff-regression.svg +1 -0
  239. package/img/svg-icons/ray.svg +3 -0
  240. package/img/svg-icons/rectangle.svg +1 -0
  241. package/img/svg-icons/redo-new.svg +3 -0
  242. package/img/svg-icons/redo.svg +1 -0
  243. package/img/svg-icons/remove-all-indicators.svg +1 -0
  244. package/img/svg-icons/remove-all-shapes.svg +1 -0
  245. package/img/svg-icons/replay-jump.svg +1 -0
  246. package/img/svg-icons/replay-pause.svg +1 -0
  247. package/img/svg-icons/replay-play.svg +1 -0
  248. package/img/svg-icons/replay-skip-end.svg +1 -0
  249. package/img/svg-icons/replay-skip-one.svg +1 -0
  250. package/img/svg-icons/save-as-image.svg +1 -0
  251. package/img/svg-icons/screenshot.svg +5 -0
  252. package/img/svg-icons/scroll-bottom.svg +1 -0
  253. package/img/svg-icons/scroll-left.svg +1 -0
  254. package/img/svg-icons/scroll-right.svg +1 -0
  255. package/img/svg-icons/scroll-top.svg +1 -0
  256. package/img/svg-icons/search.svg +1 -0
  257. package/img/svg-icons/speed-lines.svg +1 -0
  258. package/img/svg-icons/square.svg +1 -0
  259. package/img/svg-icons/star.svg +4 -0
  260. package/img/svg-icons/stash.svg +4 -0
  261. package/img/svg-icons/stick-to-bar.svg +1 -0
  262. package/img/svg-icons/stick-to-close.svg +1 -0
  263. package/img/svg-icons/stick-to-high.svg +1 -0
  264. package/img/svg-icons/stick-to-low.svg +1 -0
  265. package/img/svg-icons/stick-to-open.svg +1 -0
  266. package/img/svg-icons/sticky-mode-off.svg +1 -0
  267. package/img/svg-icons/tcdPane-alert-indicator.svg +1 -0
  268. package/img/svg-icons/tcdPane-close.svg +1 -0
  269. package/img/svg-icons/tcdPane-down.svg +1 -0
  270. package/img/svg-icons/tcdPane-expand-closed.svg +1 -0
  271. package/img/svg-icons/tcdPane-expand.svg +1 -0
  272. package/img/svg-icons/tcdPane-maximize.svg +1 -0
  273. package/img/svg-icons/tcdPane-options.svg +1 -0
  274. package/img/svg-icons/tcdPane-remove-indicator.svg +1 -0
  275. package/img/svg-icons/tcdPane-restore.svg +1 -0
  276. package/img/svg-icons/tcdPane-toggle.svg +1 -0
  277. package/img/svg-icons/tcdPane-up.svg +1 -0
  278. package/img/svg-icons/template-delete.svg +1 -0
  279. package/img/svg-icons/template-edit.svg +1 -0
  280. package/img/svg-icons/template-ok.svg +1 -0
  281. package/img/svg-icons/template.svg +1 -0
  282. package/img/svg-icons/text-editor-b.svg +1 -0
  283. package/img/svg-icons/text-editor-i.svg +1 -0
  284. package/img/svg-icons/text-editor-u.svg +1 -0
  285. package/img/svg-icons/text.svg +1 -0
  286. package/img/svg-icons/tirone-levels.svg +1 -0
  287. package/img/svg-icons/toggle-shapes.svg +1 -0
  288. package/img/svg-icons/trade-manager.svg +1 -0
  289. package/img/svg-icons/trend-angle.svg +1 -0
  290. package/img/svg-icons/trend-channel.svg +1 -0
  291. package/img/svg-icons/triangle-pattern.svg +1 -0
  292. package/img/svg-icons/triangle.svg +1 -0
  293. package/img/svg-icons/undo-new.svg +3 -0
  294. package/img/svg-icons/undo.svg +1 -0
  295. package/img/svg-icons/unlock.svg +3 -0
  296. package/img/svg-icons/vertical-line.svg +1 -0
  297. package/img/svg-icons/visibleProfile.svg +1 -0
  298. package/img/svg-icons/web-link.svg +1 -0
  299. package/img/svg-icons/x.svg +3 -0
  300. package/img/svg-icons/xabcd-pattern.svg +1 -0
  301. package/img/svg-icons/zoom-by-area.svg +1 -0
  302. package/img/svg-icons/zoom.svg +1 -0
  303. package/img/usa.png +0 -0
  304. package/index-dark.html +132 -0
  305. package/index.html +229 -0
  306. package/localization/en.json +1646 -0
  307. package/localization/uk.json +1597 -0
  308. package/multiple-charts.html +162 -0
  309. package/package.json +62 -0
  310. package/scripts/FintaChart.min.js +70 -0
  311. package/scripts/frameworks/Intl.min.js +4 -0
  312. package/scripts/frameworks/bootstrap.v3.datetimepicker.min.js +2605 -0
  313. package/scripts/frameworks/detectizr.min.js +1 -0
  314. package/scripts/frameworks/dom-to-image-more.min.js +3 -0
  315. package/scripts/frameworks/i18nextXHRBackend.min.js +1 -0
  316. package/scripts/frameworks/jquery-i18next.min.js +1 -0
  317. package/scripts/frameworks/jquery-ui.min.js +8 -0
  318. package/scripts/frameworks/jquery.min.js +3 -0
  319. package/scripts/frameworks/jquery.ui.touch-punch.min.js +1 -0
  320. package/scripts/frameworks/moment.min.js +1216 -0
  321. package/scripts/frameworks-modified/bootstrap-select.js +1024 -0
  322. package/scripts/frameworks-modified/i18next.js +2075 -0
  323. package/scripts/frameworks-modified/jquery.autocolumnlist.js +48 -0
  324. package/scripts/frameworks-modified/jquery.resizable.js +229 -0
  325. package/scripts/frameworks-modified/spectrum.js +2279 -0
  326. package/scripts/frameworks-modified/switchery.js +1957 -0
  327. package/scripts/frameworks-modified/toastr.js +414 -0
  328. package/scripts/jsdataadapters/fileDataAdapter.js +129 -0
  329. package/scripts/jsdataadapters/restDataAdapter.js +149 -0
  330. package/scripts/jsdataadapters/webSocketDataAdapter.js +114 -0
  331. package/scripts/miscs/templateFileDataAdapter.js +17 -0
  332. package/scripts/themes/beetTheme.js +2999 -0
  333. package/scripts/themes/darkTheme.js +3004 -0
  334. package/scripts/themes/defaultTheme.js +3095 -0
  335. package/scripts/themes/fintatechDarkTheme.js +3005 -0
  336. package/scripts/themes/grayTheme.js +3004 -0
  337. package/scripts/themes/oliveTheme.js +3004 -0
  338. package/scripts/themes/orangeTheme.js +3004 -0
  339. package/scripts/themes/purpleTheme.js +3004 -0
  340. package/scripts/themes/skyTheme.js +3009 -0
  341. package/scripts/themes/tealTheme.js +3004 -0
@@ -0,0 +1,1024 @@
1
+ 'use strict';
2
+
3
+ var FintaChart;
4
+ (function (FintaChart) {
5
+ var External;
6
+ (function (External) {
7
+ var $ = window.jQuery;
8
+ var HtmlContainer = FintaChart.HtmlContainer;
9
+
10
+ var Selectpicker = (function() {
11
+
12
+ $.expr[':'].icontains = function(obj, index, meta) {
13
+ return $(obj).text().toUpperCase().indexOf(meta[3].toUpperCase()) >= 0;
14
+ };
15
+
16
+ var Selectpicker = function(element, options, e) {
17
+ if (e) {
18
+ e.stopPropagation();
19
+ e.preventDefault();
20
+ }
21
+ this.$element = $(element);
22
+
23
+ this.$newElement = null;
24
+ this.$button = null;
25
+ this.$menu = null;
26
+ this.$lis = null;
27
+
28
+ //Merge defaults, options and data-attributes to make our options
29
+ this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options);
30
+
31
+ //If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute
32
+ if (this.options.title === null) {
33
+ this.options.title = this.$element.attr('title');
34
+ }
35
+
36
+ //Expose public methods
37
+ this.val = Selectpicker.prototype.val;
38
+ this.render = Selectpicker.prototype.render;
39
+ this.refresh = Selectpicker.prototype.refresh;
40
+ this.setStyle = Selectpicker.prototype.setStyle;
41
+ this.selectAll = Selectpicker.prototype.selectAll;
42
+ this.deselectAll = Selectpicker.prototype.deselectAll;
43
+
44
+ this.init();
45
+ };
46
+
47
+ Selectpicker.prototype = {
48
+
49
+ constructor: Selectpicker,
50
+
51
+ init: function() {
52
+ var that = this,
53
+ id = this.$element.attr('id');
54
+
55
+ this.$element.hide();
56
+ this.multiple = this.$element.prop('multiple');
57
+ this.autofocus = this.$element.prop('autofocus');
58
+ this.$newElement = this.createView();
59
+ this.$element.after(this.$newElement);
60
+ this.$menu = this.$newElement.find('> .dropdown-menu');
61
+ this.$button = this.$newElement.find('> button');
62
+ this.$searchbox = this.$newElement.find('input');
63
+
64
+ if (id !== undefined) {
65
+ this.$button.attr('data-id', id);
66
+ $('label[for="' + id + '"]').click(function(e) {
67
+ e.preventDefault();
68
+ that.$button.focus();
69
+ });
70
+ }
71
+
72
+ this.checkDisabled();
73
+ this.clickListener();
74
+ if (this.options.liveSearch) this.liveSearchListener();
75
+ this.render();
76
+ this.liHeight();
77
+ this.setStyle();
78
+ this.setWidth();
79
+ if (this.options.container) this.selectPosition();
80
+ this.$menu.data('this', this);
81
+ this.$newElement.data('this', this);
82
+ },
83
+
84
+ createDropdown: function() {
85
+ //If we are multiple, then add the show-tick class by default
86
+ var multiple = this.multiple ? ' show-tick' : '';
87
+ var inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '';
88
+ var autofocus = this.autofocus ? ' autofocus' : '';
89
+ var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + '</div>' : '';
90
+ var searchbox = this.options.liveSearch ? '<div class="tcd-select-searchbox"><input type="text" class="input-block-level form-control" autocomplete="off" /></div>' : '';
91
+ var actionsbox = this.options.actionsBox ? '<div class="bs-actionsbox">' +
92
+ '<div class="btn-group btn-block">' +
93
+ '<button class="actions-btn bs-select-all btn btn-sm btn-default">' +
94
+ 'Select All' +
95
+ '</button>' +
96
+ '<button class="actions-btn bs-deselect-all btn btn-sm btn-default">' +
97
+ 'Deselect All' +
98
+ '</button>' +
99
+ '</div>' +
100
+ '</div>' : '';
101
+ var drop =
102
+ '<div class="btn-group tcd-select' + multiple + inputGroup + '">' +
103
+ '<button type="button" class="btn dropdown-toggle selectpicker" data-toggle="dropdown"'+ autofocus +'>' +
104
+ '<span class="filter-option pull-left"></span>&nbsp;' +
105
+ '<span class="caret"></span>' +
106
+ '</button>' +
107
+ '<div class="dropdown-menu open">' +
108
+ header +
109
+ searchbox +
110
+ actionsbox +
111
+ '<ul class="dropdown-menu inner selectpicker" role="menu">' +
112
+ '</ul>' +
113
+ '</div>' +
114
+ '</div>';
115
+
116
+ return $(drop);
117
+ },
118
+
119
+ createView: function() {
120
+ var $drop = this.createDropdown();
121
+ var $li = this.createLi();
122
+ $drop.find('ul').append($li);
123
+ return $drop;
124
+ },
125
+
126
+ reloadLi: function() {
127
+ //Remove all children.
128
+ this.destroyLi();
129
+ //Re build
130
+ var $li = this.createLi();
131
+ this.$menu.find('ul').append( $li );
132
+ },
133
+
134
+ destroyLi: function() {
135
+ this.$menu.find('li').remove();
136
+ },
137
+
138
+ createLi: function() {
139
+ var that = this,
140
+ _liA = [],
141
+ _liHtml = '';
142
+
143
+ this.$element.find('option').each(function() {
144
+ var $this = $(this),
145
+ i18nAttr = $(this).data('i18n') || '';
146
+
147
+ //Get the class and text for the option
148
+ var optionClass = $this.attr('class') || '';
149
+ var inline = $this.attr('style') || '';
150
+ var text = $this.data('content') ? $this.data('content') : $this.html();
151
+ var subtext = $this.data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.data('subtext') + '</small>' : '';
152
+ var icon = $this.data('icon') !== undefined ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
153
+ if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
154
+ icon = '<span>'+icon+'</span>';
155
+ }
156
+
157
+ if (!$this.data('content')) {
158
+ //Prepend any icon and append any subtext to the main text.
159
+ text = icon + '<span class="text" data-i18n="' + i18nAttr + '">' + text + subtext + '</span>';
160
+ // text = icon + '<span class="text">' + text + subtext + '</span>';
161
+ }
162
+
163
+ if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
164
+ _liA.push('<a style="min-height: 0; padding: 0"></a>');
165
+ } else if ($this.parent().is('optgroup') && $this.data('divider') !== true) {
166
+ if ($this.index() === 0) {
167
+ //Get the opt group label
168
+ var label = $this.parent().attr('label');
169
+ var labelSubtext = $this.parent().data('subtext') !== undefined ? '<small class="muted text-muted">'+$this.parent().data('subtext')+'</small>' : '';
170
+ var labelIcon = $this.parent().data('icon') ? '<i class="'+$this.parent().data('icon')+'"></i> ' : '';
171
+ label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
172
+
173
+ if ($this[0].index !== 0) {
174
+ _liA.push(
175
+ '<div class="div-contain"><div class="divider"></div></div>'+
176
+ '<dt>'+label+'</dt>'+
177
+ that.createA(text, 'opt ' + optionClass, inline )
178
+ );
179
+ } else {
180
+ _liA.push(
181
+ '<dt>'+label+'</dt>'+
182
+ that.createA(text, 'opt ' + optionClass, inline ));
183
+ }
184
+ } else {
185
+ _liA.push(that.createA(text, 'opt ' + optionClass, inline ));
186
+ }
187
+ } else if ($this.data('divider') === true) {
188
+ _liA.push('<div class="div-contain"><div class="divider"></div></div>');
189
+ } else if ($(this).data('hidden') === true) {
190
+ _liA.push('<a></a>');
191
+ } else {
192
+ _liA.push(that.createA(text, optionClass, inline ));
193
+ }
194
+ });
195
+
196
+ $.each(_liA, function(i, item) {
197
+ var hide = item === '<a></a>' ? 'class="hide is-hidden"' : '';
198
+ _liHtml += '<li rel="' + i + '"' + hide + '>' + item + '</li>';
199
+ });
200
+
201
+ //If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button
202
+ if (!this.multiple && this.$element.find('option:selected').length===0 && !this.options.title) {
203
+ this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
204
+ }
205
+
206
+ return $(_liHtml);
207
+ },
208
+
209
+ createA: function(text, classes, inline) {
210
+ return '<a tabindex="0" class="'+classes+'" style="'+inline+'">' +
211
+ text +
212
+ '<i class="' + this.options.iconBase + ' ' + this.options.tickIcon + ' icon-ok check-mark"></i>' +
213
+ '</a>';
214
+ },
215
+
216
+ render: function(updateLi) {
217
+ var that = this,
218
+ haveAttr = false;
219
+
220
+ //Update the LI to match the SELECT
221
+ if (updateLi !== false) {
222
+ this.$element.find('option').each(function(index) {
223
+ that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') );
224
+ that.setSelected(index, $(this).is(':selected') );
225
+ });
226
+ }
227
+
228
+ this.tabIndex();
229
+
230
+ var selectedItems = this.$element.find('option:selected').map(function() {
231
+ var $this = $(this),
232
+ attr = $this.data('i18n');
233
+ if (attr && attr.length) {
234
+ haveAttr = true;
235
+ return attr;
236
+ } else {
237
+ var icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '';
238
+ var subtext;
239
+ if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) {
240
+ subtext = ' <small class="muted text-muted">'+$this.data('subtext') +'</small>';
241
+ } else {
242
+ subtext = '';
243
+ }
244
+ if ($this.data('content') && that.options.showContent) {
245
+ return $this.data('content');
246
+ } else if ($this.attr('title') !== undefined) {
247
+ return $this.attr('title');
248
+ } else {
249
+ return icon + $this.html() + subtext;
250
+ }
251
+ }
252
+ }).toArray();
253
+
254
+ //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled
255
+ //Convert all the values into a comma delimited string
256
+ var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator);
257
+
258
+ //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
259
+ if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
260
+ var max = this.options.selectedTextFormat.split('>');
261
+ var notDisabled = this.options.hideDisabled ? ':not([disabled])' : '';
262
+ if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) {
263
+ title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length);
264
+ }
265
+ }
266
+
267
+ this.options.title = this.$element.attr('title');
268
+
269
+ //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
270
+ if (!title) {
271
+ title = this.options.title !== undefined ? this.options.title : this.options.noneSelectedText;
272
+ }
273
+
274
+ // Fix for title attr
275
+ this.$button.attr('title', "");
276
+ this.$newElement.find('.filter-option').removeAttr('data-i18n');
277
+ this.$button.removeAttr('data-i18n');
278
+
279
+ if (haveAttr) {
280
+ this.$newElement.find('.filter-option').text(this.$element.val()).attr('data-i18n', title);
281
+ this.$button.attr('data-i18n', '[title]' + title);
282
+ this.$button.attr('title', this.$element.val());
283
+ } else {
284
+ this.$newElement.find('.filter-option').html(title);
285
+ var manualData = this.$element.find('option:selected').data('manuali18');
286
+ if (manualData) {
287
+ this.$button.attr('data-i18n', "[title]" + manualData);
288
+ } else {
289
+ this.$button.attr('title',title);
290
+ }
291
+ }
292
+
293
+ //FIX: issue with set of value
294
+ this.$button.attr("data-selectValue", this.$element.val());
295
+ },
296
+
297
+ setStyle: function(style, status) {
298
+ if (this.$element.attr('class')) {
299
+ this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|validate\[.*\]/gi, ''));
300
+ }
301
+
302
+ var buttonClass = style ? style : this.options.style;
303
+
304
+ if (status == 'add') {
305
+ this.$button.addClass(buttonClass);
306
+ } else if (status == 'remove') {
307
+ this.$button.removeClass(buttonClass);
308
+ } else {
309
+ this.$button.removeClass(this.options.style);
310
+ this.$button.addClass(buttonClass);
311
+ }
312
+ },
313
+
314
+ liHeight: function() {
315
+ if (this.options.size === false) return;
316
+
317
+ var $selectClone = this.$menu.parent().clone().find('> .dropdown-toggle').prop('autofocus', false).end().appendTo('body'),
318
+ $menuClone = $selectClone.addClass('open').find('> .dropdown-menu'),
319
+ liHeight = $menuClone.find('li > a').outerHeight(),
320
+ headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0,
321
+ searchHeight = this.options.liveSearch ? $menuClone.find('.tcd-select-searchbox').outerHeight() : 0,
322
+ actionsHeight = this.options.actionsBox ? $menuClone.find('.bs-actionsbox').outerHeight() : 0;
323
+
324
+ $selectClone.remove();
325
+
326
+ this.$newElement
327
+ .data('liHeight', liHeight)
328
+ .data('headerHeight', headerHeight)
329
+ .data('searchHeight', searchHeight)
330
+ .data('actionsHeight', actionsHeight);
331
+ },
332
+
333
+ setSize: function() {
334
+ var that = this,
335
+ menu = this.$menu,
336
+ menuInner = menu.find('.inner'),
337
+ selectHeight = this.$newElement.outerHeight(),
338
+ liHeight = this.$newElement.data('liHeight'),
339
+ headerHeight = this.$newElement.data('headerHeight'),
340
+ searchHeight = this.$newElement.data('searchHeight'),
341
+ actionsHeight = this.$newElement.data('actionsHeight'),
342
+ divHeight = menu.find('li .divider').outerHeight(true),
343
+ menuPadding = parseInt(menu.css('padding-top')) +
344
+ parseInt(menu.css('padding-bottom')) +
345
+ parseInt(menu.css('border-top-width')) +
346
+ parseInt(menu.css('border-bottom-width')),
347
+ notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '',
348
+ $window = $(window),
349
+ menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2,
350
+ menuHeight,
351
+ selectOffsetTop,
352
+ selectOffsetBot,
353
+ posVert = function() {
354
+ selectOffsetTop = that.$newElement.offset().top - $window.scrollTop();
355
+ selectOffsetBot = $window.height() - selectOffsetTop - selectHeight;
356
+ };
357
+ posVert();
358
+ if (this.options.header) menu.css('padding-top', 0);
359
+
360
+ if (this.options.size == 'auto') {
361
+ var getSize = function() {
362
+ var minHeight,
363
+ lisVis = that.$lis.not('.hide');
364
+
365
+ posVert();
366
+ menuHeight = selectOffsetBot - menuExtras;
367
+
368
+ if (that.options.dropupAuto) {
369
+ that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && ((menuHeight - menuExtras) < menu.height()));
370
+ }
371
+ if (that.$newElement.hasClass('dropup')) {
372
+ menuHeight = selectOffsetTop - menuExtras;
373
+ }
374
+
375
+ if ((lisVis.length + lisVis.find('dt').length) > 3) {
376
+ minHeight = liHeight*3 + menuExtras - 2;
377
+ } else {
378
+ minHeight = 0;
379
+ }
380
+
381
+ menu.css({'max-height' : menuHeight + 'px', 'overflow' : 'hidden', 'min-height' : minHeight + headerHeight + searchHeight + actionsHeight + 'px'});
382
+ menuInner.css({'max-height' : menuHeight - headerHeight - searchHeight - actionsHeight - menuPadding + 'px', 'overflow-y' : 'auto', 'min-height' : Math.max(minHeight - menuPadding, 0) + 'px'});
383
+ };
384
+ getSize();
385
+ this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize);
386
+ $(window).off('resize.getSize').on('resize.getSize', getSize);
387
+ $(window).off('scroll.getSize').on('scroll.getSize', getSize);
388
+ } else if (this.options.size && this.options.size != 'auto' && menu.find('li'+notDisabled).length > this.options.size) {
389
+ var optIndex = menu.find('li'+notDisabled+' > *').filter(':not(.div-contain)').slice(0,this.options.size).last().parent().index();
390
+ var divLength = menu.find('li').slice(0,optIndex + 1).find('.div-contain').length;
391
+ menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding;
392
+ if (that.options.dropupAuto) {
393
+ this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight < menu.height()));
394
+ }
395
+ menu.css({'max-height' : menuHeight + headerHeight + searchHeight + actionsHeight + 'px', 'overflow' : 'hidden'});
396
+ menuInner.css({'max-height' : menuHeight - menuPadding + 'px', 'overflow-y' : 'auto'});
397
+ }
398
+ },
399
+
400
+ setWidth: function() {
401
+ if (this.options.width == 'auto') {
402
+ this.$menu.css('min-width', '0');
403
+
404
+ // Get correct width if element hidden
405
+ var selectClone = this.$newElement.clone().appendTo('body');
406
+ var ulWidth = selectClone.find('> .dropdown-menu').css('width');
407
+ var btnWidth = selectClone.css('width', 'auto').find('> button').css('width');
408
+ selectClone.remove();
409
+
410
+ // Set width to whatever's larger, button title or longest option
411
+ this.$newElement.css('width', Math.max(parseInt(ulWidth), parseInt(btnWidth)) + 'px');
412
+ } else if (this.options.width == 'fit') {
413
+ // Remove inline min-width so width can be changed from 'auto'
414
+ this.$menu.css('min-width', '');
415
+ this.$newElement.css('width', '').addClass('fit-width');
416
+ } else if (this.options.width) {
417
+ // Remove inline min-width so width can be changed from 'auto'
418
+ this.$menu.css('min-width', '');
419
+ this.$newElement.css('width', this.options.width);
420
+ } else {
421
+ // Remove inline min-width/width so width can be changed
422
+ this.$menu.css('min-width', '');
423
+ this.$newElement.css('width', '');
424
+ }
425
+ // Remove fit-width class if width is changed programmatically
426
+ if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
427
+ this.$newElement.removeClass('fit-width');
428
+ }
429
+ },
430
+
431
+ selectPosition: function() {
432
+ var that = this,
433
+ drop = '<div />',
434
+ $drop = $(drop),
435
+ pos,
436
+ actualHeight,
437
+ getPlacement = function($element) {
438
+ $drop.addClass($element.attr('class').replace(/form-control/gi, '')).toggleClass('dropup', $element.hasClass('dropup'));
439
+ pos = $element.offset();
440
+ actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight;
441
+ $drop.css({'top' : pos.top + actualHeight, 'left' : pos.left, 'width' : $element[0].offsetWidth, 'position' : 'absolute'});
442
+ };
443
+ this.$newElement.on('click', function() {
444
+ if (that.isDisabled()) {
445
+ return;
446
+ }
447
+ getPlacement($(this));
448
+
449
+ //FIX: issue with update of root container in full screen mode
450
+ // $drop.appendTo(that.options.container);
451
+ $drop.appendTo(FintaChart.HtmlContainer.container);
452
+
453
+ $drop.toggleClass('open', !$(this).hasClass('open'));
454
+ $drop.append(that.$menu);
455
+ });
456
+ $(window).resize(function() {
457
+ getPlacement(that.$newElement);
458
+ });
459
+ $(window).on('scroll', function() {
460
+ getPlacement(that.$newElement);
461
+ });
462
+ $('html').on('click', function(e) {
463
+ if ($(e.target).closest(that.$newElement).length < 1) {
464
+ $drop.removeClass('open');
465
+ }
466
+ });
467
+ $('html').on('mousedown', function (e) {
468
+ if ($('.tcd-select').has(e.target).length === 0)
469
+ $drop.removeClass('open');
470
+ });
471
+ $('html').on('DOMMouseScroll mousewheel', function (e) {
472
+ if ($('.tcd-select').has(e.target).length === 0)
473
+ $drop.removeClass('open');
474
+ });
475
+ },
476
+
477
+ mobile: function() {
478
+ this.$element.addClass('mobile-device').appendTo(this.$newElement);
479
+ if (this.options.container) this.$menu.hide();
480
+ },
481
+
482
+ refresh: function() {
483
+ this.$lis = null;
484
+ this.reloadLi();
485
+ this.render();
486
+ this.setWidth();
487
+ this.setStyle();
488
+ this.checkDisabled();
489
+ this.liHeight();
490
+ },
491
+
492
+ update: function() {
493
+ this.reloadLi();
494
+ this.setWidth();
495
+ this.setStyle();
496
+ this.checkDisabled();
497
+ this.liHeight();
498
+ },
499
+
500
+ setSelected: function(index, selected) {
501
+ if (this.$lis == null) this.$lis = this.$menu.find('li');
502
+ $(this.$lis[index]).toggleClass('selected', selected);
503
+ },
504
+
505
+ setDisabled: function(index, disabled) {
506
+ if (this.$lis == null) this.$lis = this.$menu.find('li');
507
+ if (disabled) {
508
+ $(this.$lis[index]).addClass('disabled').find('a').attr('href', '#').attr('tabindex', -1);
509
+ } else {
510
+ $(this.$lis[index]).removeClass('disabled').find('a').removeAttr('href').attr('tabindex', 0);
511
+ }
512
+ },
513
+
514
+ isDisabled: function() {
515
+ return this.$element.is(':disabled');
516
+ },
517
+
518
+ checkDisabled: function() {
519
+ var that = this;
520
+
521
+ if (this.isDisabled()) {
522
+ this.$button.addClass('disabled').attr('tabindex', -1);
523
+ } else {
524
+ if (this.$button.hasClass('disabled')) {
525
+ this.$button.removeClass('disabled');
526
+ }
527
+
528
+ if (this.$button.attr('tabindex') == -1) {
529
+ if (!this.$element.data('tabindex')) this.$button.removeAttr('tabindex');
530
+ }
531
+ }
532
+
533
+ this.$button.click(function() {
534
+ return !that.isDisabled();
535
+ });
536
+ },
537
+
538
+ tabIndex: function() {
539
+ if (this.$element.is('[tabindex]')) {
540
+ this.$element.data('tabindex', this.$element.attr('tabindex'));
541
+ this.$button.attr('tabindex', this.$element.data('tabindex'));
542
+ }
543
+ },
544
+
545
+ clickListener: function() {
546
+ var that = this;
547
+
548
+ $('body').on('touchstart.dropdown', '.dropdown-menu', function(e) {
549
+ e.stopPropagation();
550
+ });
551
+
552
+ this.$newElement.on('click', function() {
553
+ that.setSize();
554
+ if (!that.options.liveSearch && !that.multiple) {
555
+ setTimeout(function() {
556
+ that.$menu.find('.selected a').focus();
557
+ }, 10);
558
+ }
559
+ });
560
+
561
+ this.$menu.on('click', 'li a', function(e) {
562
+ var clickedIndex = $(this).parent().index(),
563
+ prevValue = that.$element.val(),
564
+ prevIndex = that.$element.prop('selectedIndex');
565
+
566
+ //Dont close on multi choice menu
567
+ if (that.multiple) {
568
+ e.stopPropagation();
569
+ }
570
+
571
+ e.preventDefault();
572
+
573
+ //Dont run if we have been disabled
574
+ if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) {
575
+ var $options = that.$element.find('option'),
576
+ $option = $options.eq(clickedIndex),
577
+ state = $option.prop('selected'),
578
+ $optgroup = $option.parent('optgroup'),
579
+ maxOptions = that.options.maxOptions,
580
+ maxOptionsGrp = $optgroup.data('maxOptions') || false;
581
+
582
+ //Deselect all others if not multi select box
583
+ if (!that.multiple) {
584
+ $options.prop('selected', false);
585
+ $option.prop('selected', true);
586
+ that.$menu.find('.selected').removeClass('selected');
587
+ that.setSelected(clickedIndex, true);
588
+ }
589
+ //Else toggle the one we have chosen if we are multi select.
590
+ else {
591
+ $option.prop('selected', !state);
592
+ that.setSelected(clickedIndex, !state);
593
+
594
+ if ((maxOptions !== false) || (maxOptionsGrp !== false)) {
595
+ var maxReached = maxOptions < $options.filter(':selected').length,
596
+ maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length,
597
+ maxOptionsArr = that.options.maxOptionsText,
598
+ maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
599
+ maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
600
+ $notify = $('<div class="notify"></div>');
601
+
602
+ if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
603
+ // If {var} is set in array, replace it
604
+ if (maxOptionsArr[2]) {
605
+ maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
606
+ maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
607
+ }
608
+
609
+ $option.prop('selected', false);
610
+
611
+ that.$menu.append($notify);
612
+
613
+ if (maxOptions && maxReached) {
614
+ $notify.append($('<div>' + maxTxt + '</div>'));
615
+ that.$element.trigger('maxReached.bs.select');
616
+ }
617
+
618
+ if (maxOptionsGrp && maxReachedGrp) {
619
+ $notify.append($('<div>' + maxTxtGrp + '</div>'));
620
+ that.$element.trigger('maxReachedGrp.bs.select');
621
+ }
622
+
623
+ setTimeout(function() {
624
+ that.setSelected(clickedIndex, false);
625
+ }, 10);
626
+
627
+ $notify.delay(750).fadeOut(300, function() { $(this).remove(); });
628
+ }
629
+ }
630
+ }
631
+
632
+ if (!that.multiple) {
633
+ that.$button.focus();
634
+ } else if (that.options.liveSearch) {
635
+ that.$searchbox.focus();
636
+ }
637
+
638
+ // Trigger select 'change'
639
+ if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) {
640
+ that.$element.change();
641
+ }
642
+ }
643
+ });
644
+
645
+ this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, .popover-title, .popover-title :not(.close)', function(e) {
646
+ if (e.target == this) {
647
+ e.preventDefault();
648
+ e.stopPropagation();
649
+ if (!that.options.liveSearch) {
650
+ that.$button.focus();
651
+ } else {
652
+ that.$searchbox.focus();
653
+ }
654
+ }
655
+ });
656
+
657
+ this.$menu.on('click', '.popover-title .close', function() {
658
+ that.$button.focus();
659
+ });
660
+
661
+ this.$searchbox.on('click', function(e) {
662
+ e.stopPropagation();
663
+ });
664
+
665
+
666
+ this.$menu.on('click', '.actions-btn', function(e) {
667
+ if (that.options.liveSearch) {
668
+ that.$searchbox.focus();
669
+ } else {
670
+ that.$button.focus();
671
+ }
672
+
673
+ e.preventDefault();
674
+ e.stopPropagation();
675
+
676
+ if ($(this).is('.bs-select-all')) {
677
+ that.selectAll();
678
+ } else {
679
+ that.deselectAll();
680
+ }
681
+ that.$element.change();
682
+ });
683
+
684
+ this.$element.change(function() {
685
+ that.render(false);
686
+ $('body')
687
+ .trigger('localize', [this.$newElement.find('.filter-option')])
688
+ .trigger('localize', [this.$menu])
689
+ .trigger('localize', [this.$button]);
690
+ }.bind(this));
691
+ },
692
+
693
+ liveSearchListener: function() {
694
+ var that = this,
695
+ no_results = $('<li class="no-results"></li>');
696
+
697
+ this.$newElement.on('click.dropdown.data-api', function() {
698
+ that.$menu.find('.active').removeClass('active');
699
+ if (!!that.$searchbox.val()) {
700
+ that.$searchbox.val('');
701
+ that.$lis.not('.is-hidden').removeClass('hide');
702
+ if (!!no_results.parent().length) no_results.remove();
703
+ }
704
+ if (!that.multiple) that.$menu.find('.selected').addClass('active');
705
+ setTimeout(function() {
706
+ that.$searchbox.focus();
707
+ }, 10);
708
+ });
709
+
710
+ this.$searchbox.on('input propertychange', function() {
711
+ if (that.$searchbox.val()) {
712
+ that.$lis.not('.is-hidden').removeClass('hide').find('a').not(':icontains(' + that.$searchbox.val() + ')').parent().addClass('hide');
713
+
714
+ if (!that.$menu.find('li').filter(':visible:not(.no-results)').length) {
715
+ if (!!no_results.parent().length) no_results.remove();
716
+ no_results.html(that.options.noneResultsText + ' "'+ that.$searchbox.val() + '"').show();
717
+ that.$menu.find('li').last().after(no_results);
718
+ } else if (!!no_results.parent().length) {
719
+ no_results.remove();
720
+ }
721
+
722
+ } else {
723
+ that.$lis.not('.is-hidden').removeClass('hide');
724
+ if (!!no_results.parent().length) no_results.remove();
725
+ }
726
+
727
+ that.$menu.find('li.active').removeClass('active');
728
+ that.$menu.find('li').filter(':visible:not(.divider)').eq(0).addClass('active').find('a').focus();
729
+ $(this).focus();
730
+ });
731
+
732
+ this.$menu.on('mouseenter', 'a', function(e) {
733
+ that.$menu.find('.active').removeClass('active');
734
+ $(e.currentTarget).parent().not('.disabled').addClass('active');
735
+ });
736
+
737
+ this.$menu.on('mouseleave', 'a', function() {
738
+ that.$menu.find('.active').removeClass('active');
739
+ });
740
+ },
741
+
742
+ val: function(value) {
743
+ if (value !== undefined) {
744
+ this.$element.val( value );
745
+
746
+ this.$element.change();
747
+ return this.$element;
748
+ } else {
749
+ return this.$element.val();
750
+ }
751
+ },
752
+
753
+ selectAll: function() {
754
+ if (this.$lis == null) this.$lis = this.$menu.find('li');
755
+ this.$element.find('option:enabled').prop('selected', true);
756
+ $(this.$lis).filter(':not(.disabled)').addClass('selected');
757
+ this.render(false);
758
+ },
759
+
760
+ deselectAll: function() {
761
+ if (this.$lis == null) this.$lis = this.$menu.find('li');
762
+ this.$element.find('option:enabled').prop('selected', false);
763
+ $(this.$lis).filter(':not(.disabled)').removeClass('selected');
764
+ this.render(false);
765
+ },
766
+
767
+ keydown: function(e) {
768
+ var $this,
769
+ $items,
770
+ $parent,
771
+ index,
772
+ next,
773
+ first,
774
+ last,
775
+ prev,
776
+ nextPrev,
777
+ that,
778
+ prevIndex,
779
+ isActive,
780
+ keyCodeMap = {
781
+ 32:' ', 48:'0', 49:'1', 50:'2', 51:'3', 52:'4', 53:'5', 54:'6', 55:'7', 56:'8', 57:'9', 59:';',
782
+ 65:'a', 66:'b', 67:'c', 68:'d', 69:'e', 70:'f', 71:'g', 72:'h', 73:'i', 74:'j', 75:'k', 76:'l',
783
+ 77:'m', 78:'n', 79:'o', 80:'p', 81:'q', 82:'r', 83:'s', 84:'t', 85:'u', 86:'v', 87:'w', 88:'x',
784
+ 89:'y', 90:'z', 96:'0', 97:'1', 98:'2', 99:'3', 100:'4', 101:'5', 102:'6', 103:'7', 104:'8', 105:'9'
785
+ };
786
+
787
+ $this = $(this);
788
+
789
+ $parent = $this.parent();
790
+
791
+ if ($this.is('input')) $parent = $this.parent().parent();
792
+
793
+ that = $parent.data('this');
794
+
795
+ if (that.options.liveSearch) $parent = $this.parent().parent();
796
+
797
+ if (that.options.container) $parent = that.$menu;
798
+
799
+ $items = $('[role=menu] li:not(.divider) a', $parent);
800
+
801
+ isActive = that.$menu.parent().hasClass('open');
802
+
803
+ if (!isActive && /([0-9]|[A-z])/.test(String.fromCharCode(e.keyCode))) {
804
+ if (!that.options.container) {
805
+ that.setSize();
806
+ that.$menu.parent().addClass('open');
807
+ isActive = that.$menu.parent().hasClass('open');
808
+ } else {
809
+ that.$newElement.trigger('click');
810
+ }
811
+ that.$searchbox.focus();
812
+ }
813
+
814
+ if (that.options.liveSearch) {
815
+ if (/(^9$|27)/.test(e.keyCode) && isActive && that.$menu.find('.active').length === 0) {
816
+ e.preventDefault();
817
+ that.$menu.parent().removeClass('open');
818
+ that.$button.focus();
819
+ }
820
+ $items = $('[role=menu] li:not(.divider):visible', $parent);
821
+ if (!$this.val() && !/(38|40)/.test(e.keyCode)) {
822
+ if ($items.filter('.active').length === 0) {
823
+ $items = that.$newElement.find('li').filter(':icontains(' + keyCodeMap[e.keyCode] + ')');
824
+ }
825
+ }
826
+ }
827
+
828
+ if (!$items.length) return;
829
+
830
+ if (/(38|40)/.test(e.keyCode)) {
831
+
832
+ index = $items.index($items.filter(':focus'));
833
+ first = $items.parent(':not(.disabled):visible').first().index();
834
+ last = $items.parent(':not(.disabled):visible').last().index();
835
+ next = $items.eq(index).parent().nextAll(':not(.disabled):visible').eq(0).index();
836
+ prev = $items.eq(index).parent().prevAll(':not(.disabled):visible').eq(0).index();
837
+ nextPrev = $items.eq(next).parent().prevAll(':not(.disabled):visible').eq(0).index();
838
+
839
+ if (that.options.liveSearch) {
840
+ $items.each(function(i) {
841
+ if ($(this).is(':not(.disabled)')) {
842
+ $(this).data('index', i);
843
+ }
844
+ });
845
+ index = $items.index($items.filter('.active'));
846
+ first = $items.filter(':not(.disabled):visible').first().data('index');
847
+ last = $items.filter(':not(.disabled):visible').last().data('index');
848
+ next = $items.eq(index).nextAll(':not(.disabled):visible').eq(0).data('index');
849
+ prev = $items.eq(index).prevAll(':not(.disabled):visible').eq(0).data('index');
850
+ nextPrev = $items.eq(next).prevAll(':not(.disabled):visible').eq(0).data('index');
851
+ }
852
+
853
+ prevIndex = $this.data('prevIndex');
854
+
855
+ if (e.keyCode == 38) {
856
+ if (that.options.liveSearch) index -= 1;
857
+ if (index != nextPrev && index > prev) index = prev;
858
+ if (index < first) index = first;
859
+ if (index == prevIndex) index = last;
860
+ }
861
+
862
+ if (e.keyCode == 40) {
863
+ if (that.options.liveSearch) index += 1;
864
+ if (index == -1) index = 0;
865
+ if (index != nextPrev && index < next) index = next;
866
+ if (index > last) index = last;
867
+ if (index == prevIndex) index = first;
868
+ }
869
+
870
+ $this.data('prevIndex', index);
871
+
872
+ if (!that.options.liveSearch) {
873
+ $items.eq(index).focus();
874
+ } else {
875
+ e.preventDefault();
876
+ if (!$this.is('.dropdown-toggle')) {
877
+ $items.removeClass('active');
878
+ $items.eq(index).addClass('active').find('a').focus();
879
+ $this.focus();
880
+ }
881
+ }
882
+
883
+ } else if (!$this.is('input')) {
884
+
885
+ var keyIndex = [],
886
+ count,
887
+ prevKey;
888
+
889
+ $items.each(function() {
890
+ if ($(this).parent().is(':not(.disabled)')) {
891
+ if ($.trim($(this).text().toLowerCase()).substring(0,1) == keyCodeMap[e.keyCode]) {
892
+ keyIndex.push($(this).parent().index());
893
+ }
894
+ }
895
+ });
896
+
897
+ count = $(document).data('keycount');
898
+ count++;
899
+ $(document).data('keycount',count);
900
+
901
+ prevKey = $.trim($(':focus').text().toLowerCase()).substring(0,1);
902
+
903
+ if (prevKey != keyCodeMap[e.keyCode]) {
904
+ count = 1;
905
+ $(document).data('keycount', count);
906
+ } else if (count >= keyIndex.length) {
907
+ $(document).data('keycount', 0);
908
+ if (count > keyIndex.length) count = 1;
909
+ }
910
+
911
+ $items.eq(keyIndex[count - 1]).focus();
912
+ }
913
+
914
+ // Select focused option if "Enter", "Spacebar", "Tab" are pressed inside the menu.
915
+ if (/(13|32|^9$)/.test(e.keyCode) && isActive) {
916
+ if (!/(32)/.test(e.keyCode)) e.preventDefault();
917
+ if (!that.options.liveSearch) {
918
+ $(':focus').click();
919
+ } else if (!/(32)/.test(e.keyCode)) {
920
+ that.$menu.find('.active a').click();
921
+ $this.focus();
922
+ }
923
+ $(document).data('keycount',0);
924
+ }
925
+
926
+ if ((/(^9$|27)/.test(e.keyCode) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode) && !isActive)) {
927
+ that.$menu.parent().removeClass('open');
928
+ that.$button.focus();
929
+ }
930
+
931
+ },
932
+
933
+ hide: function() {
934
+ this.$newElement.hide();
935
+ },
936
+
937
+ show: function() {
938
+ this.$newElement.show();
939
+ },
940
+
941
+ destroy: function() {
942
+ this.$newElement.remove();
943
+ this.$element.remove();
944
+ }
945
+ };
946
+
947
+ $.fn.selectpicker = function(option, event) {
948
+ //get the args of the outer function..
949
+ var args = arguments;
950
+ var value;
951
+ var chain = this.each(function() {
952
+ if ($(this).is('select')) {
953
+ var $this = $(this),
954
+ data = $this.data('selectpicker'),
955
+ options = typeof option == 'object' && option;
956
+
957
+ if (!data) {
958
+ $this.data('selectpicker', (data = new Selectpicker(this, options, event)));
959
+ } else if (options) {
960
+ for(var i in options) {
961
+ data.options[i] = options[i];
962
+ }
963
+ }
964
+
965
+ if (typeof option == 'string') {
966
+ //Copy the value of option, as once we shift the arguments
967
+ //it also shifts the value of option.
968
+ var property = option;
969
+ if (data[property] instanceof Function) {
970
+ [].shift.apply(args);
971
+ value = data[property].apply(data, args);
972
+ } else {
973
+ value = data.options[property];
974
+ }
975
+ }
976
+ }
977
+ });
978
+
979
+ if (value !== undefined) {
980
+ return value;
981
+ } else {
982
+ return chain;
983
+ }
984
+ };
985
+
986
+ $.fn.selectpicker.defaults = {
987
+ style: 'btn-default',
988
+ size: 'auto',
989
+ title: null,
990
+ selectedTextFormat : 'values',
991
+ noneSelectedText : 'Nothing selected',
992
+ noneResultsText : 'No results match',
993
+ countSelectedText: '{0} of {1} selected',
994
+ maxOptionsText: ['Limit reached ({n} {var} max)', 'Group limit reached ({n} {var} max)', ['items','item']],
995
+ width: false,
996
+ container: false,
997
+ hideDisabled: false,
998
+ showSubtext: false,
999
+ showIcon: true,
1000
+ showContent: true,
1001
+ dropupAuto: true,
1002
+ header: false,
1003
+ liveSearch: false,
1004
+ actionsBox: false,
1005
+ multipleSeparator: ', ',
1006
+ iconBase: 'glyphicon',
1007
+ tickIcon: 'glyphicon-ok',
1008
+ maxOptions: false
1009
+ };
1010
+
1011
+ $(document)
1012
+ .data('keycount', 0)
1013
+ .on('keydown', '.tcd-select [data-toggle=dropdown], .tcd-select [role=menu], .tcd-select-searchbox input', Selectpicker.prototype.keydown)
1014
+ .on('focusin.modal', '.tcd-select [data-toggle=dropdown], .tcd-select [role=menu], .tcd-select-searchbox input', function (e) { e.stopPropagation(); });
1015
+
1016
+ return Selectpicker;
1017
+ }());
1018
+
1019
+ External.Selectpicker = Selectpicker;
1020
+
1021
+ })(External = FintaChart.External || (FintaChart.External = {}));
1022
+ })(FintaChart || (FintaChart = {}));
1023
+
1024
+