1277f8f70df37b22756504458cc62d4346f9289c5393ad301968743f60f404e4c9035f844ea5ca63adc053702061903bdc8313c259ba244472bc6049f093e7 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // identity function for calling harmony imports with the correct context
  37. /******/ __webpack_require__.i = function(value) { return value; };
  38. /******/
  39. /******/ // define getter function for harmony exports
  40. /******/ __webpack_require__.d = function(exports, name, getter) {
  41. /******/ if(!__webpack_require__.o(exports, name)) {
  42. /******/ Object.defineProperty(exports, name, {
  43. /******/ configurable: false,
  44. /******/ enumerable: true,
  45. /******/ get: getter
  46. /******/ });
  47. /******/ }
  48. /******/ };
  49. /******/
  50. /******/ // getDefaultExport function for compatibility with non-harmony modules
  51. /******/ __webpack_require__.n = function(module) {
  52. /******/ var getter = module && module.__esModule ?
  53. /******/ function getDefault() { return module['default']; } :
  54. /******/ function getModuleExports() { return module; };
  55. /******/ __webpack_require__.d(getter, 'a', getter);
  56. /******/ return getter;
  57. /******/ };
  58. /******/
  59. /******/ // Object.prototype.hasOwnProperty.call
  60. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  61. /******/
  62. /******/ // __webpack_public_path__
  63. /******/ __webpack_require__.p = "";
  64. /******/
  65. /******/ // Load entry module and return exports
  66. /******/ return __webpack_require__(__webpack_require__.s = 3);
  67. /******/ })
  68. /************************************************************************/
  69. /******/ ([
  70. /* 0 */
  71. /***/ (function(module, exports, __webpack_require__) {
  72. "use strict";
  73. exports.__esModule = true;
  74. exports.spec = spec;
  75. exports.createDataArray = createDataArray;
  76. exports.getData = getData;
  77. exports.getTotalRows = getTotalRows;
  78. exports.getTotalColumns = getTotalColumns;
  79. exports.getTableWidth = getTableWidth;
  80. exports.range = range;
  81. exports.shimSelectionProperties = shimSelectionProperties;
  82. exports.getTableTopClone = getTableTopClone;
  83. exports.getTableLeftClone = getTableLeftClone;
  84. exports.getTableCornerClone = getTableCornerClone;
  85. exports.createSpreadsheetData = createSpreadsheetData;
  86. exports.spreadsheetColumnLabel = spreadsheetColumnLabel;
  87. exports.walkontableCalculateScrollbarWidth = walkontableCalculateScrollbarWidth;
  88. exports.getScrollbarWidth = getScrollbarWidth;
  89. function spec() {
  90. return currentSpec;
  91. };
  92. function createDataArray(rows, cols) {
  93. spec().data = [];
  94. rows = typeof rows === 'number' ? rows : 100;
  95. cols = typeof cols === 'number' ? cols : 4;
  96. for (var i = 0; i < rows; i++) {
  97. var row = [];
  98. if (cols > 0) {
  99. row.push(i);
  100. for (var j = 0; j < cols - 1; j++) {
  101. /* eslint-disable no-mixed-operators */
  102. /* eslint-disable no-bitwise */
  103. row.push(String.fromCharCode(65 + j % 20).toLowerCase() + (j / 20 | 0 || '')); // | 0 is parseInt - see http://jsperf.com/math-floor-vs-math-round-vs-parseint/18
  104. }
  105. }
  106. spec().data.push(row);
  107. }
  108. };
  109. function getData(row, col) {
  110. return spec().data[row][col];
  111. };
  112. function getTotalRows() {
  113. return spec().data.length;
  114. };
  115. function getTotalColumns() {
  116. return spec().data[0] ? spec().data[0].length : 0;
  117. };
  118. var currentSpec;
  119. beforeEach(function () {
  120. currentSpec = this;
  121. var matchers = {
  122. toBeInArray: function toBeInArray() {
  123. return {
  124. compare: function compare(actual, expected) {
  125. return {
  126. pass: Array.isArray(expected) && expected.indexOf(actual) > -1
  127. };
  128. }
  129. };
  130. },
  131. toBeFunction: function toBeFunction() {
  132. return {
  133. compare: function compare(actual, expected) {
  134. return {
  135. pass: typeof actual === 'function'
  136. };
  137. }
  138. };
  139. },
  140. toBeAroundValue: function toBeAroundValue() {
  141. return {
  142. compare: function compare(actual, expected, diff) {
  143. diff = diff || 1;
  144. var pass = actual >= expected - diff && actual <= expected + diff;
  145. var message = 'Expected ' + actual + ' to be around ' + expected + ' (between ' + (expected - diff) + ' and ' + (expected + diff) + ')';
  146. if (!pass) {
  147. message = 'Expected ' + actual + ' NOT to be around ' + expected + ' (between ' + (expected - diff) + ' and ' + (expected + diff) + ')';
  148. }
  149. return {
  150. pass: pass,
  151. message: message
  152. };
  153. }
  154. };
  155. }
  156. };
  157. jasmine.addMatchers(matchers);
  158. });
  159. afterEach(function () {
  160. window.scrollTo(0, 0);
  161. });
  162. function getTableWidth(elem) {
  163. return $(elem).outerWidth() || $(elem).find('tbody').outerWidth() || $(elem).find('thead').outerWidth(); // IE8 reports 0 as <table> offsetWidth
  164. };
  165. function range(from, to) {
  166. if (!arguments.length) {
  167. return [];
  168. }
  169. if (arguments.length == 1) {
  170. to = from;
  171. from = 0;
  172. }
  173. if (to > from) {
  174. from = [to, to = from][0]; // one-liner for swapping two values
  175. }
  176. var result = [];
  177. while (to++ < from) {
  178. result.push(to);
  179. }
  180. return result;
  181. };
  182. /**
  183. * Rewrite all existing selections from selections[0] etc. to selections.current etc
  184. * @param instance
  185. * @returns {object} modified instance
  186. */
  187. function shimSelectionProperties(instance) {
  188. if (instance.selections[0]) {
  189. instance.selections.current = instance.selections[0];
  190. }
  191. if (instance.selections[1]) {
  192. instance.selections.area = instance.selections[1];
  193. }
  194. if (instance.selections[2]) {
  195. instance.selections.highlight = instance.selections[2];
  196. }
  197. if (instance.selections[3]) {
  198. instance.selections.fill = instance.selections[3];
  199. }
  200. return instance;
  201. }
  202. function getTableTopClone() {
  203. return $('.ht_clone_top');
  204. }
  205. function getTableLeftClone() {
  206. return $('.ht_clone_left');
  207. }
  208. function getTableCornerClone() {
  209. return $('.ht_clone_top_left_corner');
  210. }
  211. function createSpreadsheetData(rows, columns) {
  212. var _rows = [],
  213. i,
  214. j;
  215. for (i = 0; i < rows; i++) {
  216. var row = [];
  217. for (j = 0; j < columns; j++) {
  218. row.push(spreadsheetColumnLabel(j) + (i + 1));
  219. }
  220. _rows.push(row);
  221. }
  222. return _rows;
  223. }
  224. var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  225. var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
  226. /**
  227. * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc.
  228. *
  229. * @param {Number} index Column index.
  230. * @returns {String}
  231. */
  232. function spreadsheetColumnLabel(index) {
  233. var dividend = index + 1;
  234. var columnLabel = '';
  235. var modulo = void 0;
  236. while (dividend > 0) {
  237. modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH;
  238. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  239. dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10);
  240. }
  241. return columnLabel;
  242. }
  243. function walkontableCalculateScrollbarWidth() {
  244. var inner = document.createElement('div');
  245. inner.style.height = '200px';
  246. inner.style.width = '100%';
  247. var outer = document.createElement('div');
  248. outer.style.boxSizing = 'content-box';
  249. outer.style.height = '150px';
  250. outer.style.left = '0px';
  251. outer.style.overflow = 'hidden';
  252. outer.style.position = 'absolute';
  253. outer.style.top = '0px';
  254. outer.style.width = '200px';
  255. outer.style.visibility = 'hidden';
  256. outer.appendChild(inner);
  257. (document.body || document.documentElement).appendChild(outer);
  258. var w1 = inner.offsetWidth;
  259. outer.style.overflow = 'scroll';
  260. var w2 = inner.offsetWidth;
  261. if (w1 == w2) {
  262. w2 = outer.clientWidth;
  263. }
  264. (document.body || document.documentElement).removeChild(outer);
  265. return w1 - w2;
  266. }
  267. var cachedScrollbarWidth;
  268. function getScrollbarWidth() {
  269. if (cachedScrollbarWidth === void 0) {
  270. cachedScrollbarWidth = walkontableCalculateScrollbarWidth();
  271. }
  272. return cachedScrollbarWidth;
  273. }
  274. /***/ }),
  275. /* 1 */,
  276. /* 2 */
  277. /***/ (function(module, exports) {
  278. module.exports = window;
  279. /***/ }),
  280. /* 3 */
  281. /***/ (function(module, exports, __webpack_require__) {
  282. "use strict";
  283. var _window = __webpack_require__(2);
  284. var _window2 = _interopRequireDefault(_window);
  285. var _common = __webpack_require__(0);
  286. var common = _interopRequireWildcard(_common);
  287. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  288. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  289. // Export all helpers to the window.
  290. /* eslint-disable import/no-unresolved */
  291. Object.keys(common).forEach(function (key) {
  292. _window2.default[key] = common[key];
  293. });
  294. /***/ })
  295. /******/ ]);
  296. //# sourceMappingURL=helpers.entry.js.map