1 var _typeof = typeof Symbol ===
"function" && typeof Symbol.iterator ===
"symbol" ?
function (obj) {
return typeof obj; } :
function (obj) {
return obj && typeof Symbol ===
"function" && obj.constructor === Symbol && obj !== Symbol.prototype ?
"symbol" : typeof obj; };
5 var Edit =
function Edit(table) {
7 this.currentCell =
false;
8 this.mouseClick =
false;
9 this.recursionBlock =
false;
10 this.invalidEdit =
false;
14 Edit.prototype.initializeColumn =
function (column) {
19 check: column.definition.editable,
20 params: column.definition.editorParams || {}
24 switch (_typeof(column.definition.editor)) {
27 if (column.definition.editor ===
"tick") {
28 column.definition.editor =
"tickCross";
29 console.warn(
"DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor");
32 if (
self.editors[column.definition.editor]) {
33 config.editor =
self.editors[column.definition.editor];
35 console.warn(
"Editor Error - No such editor found: ", column.definition.editor);
40 config.editor = column.definition.editor;
45 if (column.definition.editor ===
true) {
47 if (typeof column.definition.formatter !==
"function") {
49 if (column.definition.formatter ===
"tick") {
50 column.definition.formatter =
"tickCross";
51 console.warn(
"DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor");
54 if (
self.editors[column.definition.formatter]) {
55 config.editor =
self.editors[column.definition.formatter];
57 config.editor =
self.editors[
"input"];
60 console.warn(
"Editor Error - Cannot auto lookup editor for a custom formatter: ", column.definition.formatter);
67 column.modules.edit = config;
71 Edit.prototype.getCurrentCell =
function () {
72 return this.currentCell ? this.currentCell.getComponent() :
false;
75 Edit.prototype.clearEditor =
function () {
76 var cell = this.currentCell,
79 this.invalidEdit =
false;
82 this.currentCell =
false;
84 cellEl = cell.getElement();
85 cellEl.classList.remove(
"tabulator-validation-fail");
86 cellEl.classList.remove(
"tabulator-editing");
87 while (cellEl.firstChild) {
88 cellEl.removeChild(cellEl.firstChild);
89 }cell.row.getElement().classList.remove(
"tabulator-row-editing");
93 Edit.prototype.cancelEdit =
function () {
95 if (this.currentCell) {
96 var cell = this.currentCell;
97 var component = this.currentCell.getComponent();
100 cell.setValueActual(cell.getValue());
102 if (cell.column.cellEvents.cellEditCancelled) {
103 cell.column.cellEvents.cellEditCancelled.call(this.table, component);
106 this.table.options.cellEditCancelled.call(this.table, component);
111 Edit.prototype.bindEditor =
function (cell) {
113 element = cell.getElement();
115 element.setAttribute(
"tabindex", 0);
117 element.addEventListener(
"click",
function (e) {
118 if (!element.classList.contains(
"tabulator-editing")) {
123 element.addEventListener(
"mousedown",
function (e) {
124 self.mouseClick =
true;
127 element.addEventListener(
"focus",
function (e) {
128 if (!
self.recursionBlock) {
129 self.edit(cell, e,
false);
134 Edit.prototype.focusCellNoEvent =
function (cell, block) {
135 this.recursionBlock =
true;
136 if (!(block && this.table.browser ===
"ie")) {
137 cell.getElement().focus();
139 this.recursionBlock =
false;
142 Edit.prototype.editCell =
function (cell, forceEdit) {
143 this.focusCellNoEvent(cell);
144 this.edit(cell,
false, forceEdit);
147 Edit.prototype.edit =
function (cell, e, forceEdit) {
150 rendered =
function rendered() {},
151 element = cell.getElement(),
157 if (this.currentCell) {
158 if (!this.invalidEdit) {
165 function success(value) {
167 if (
self.currentCell === cell) {
170 if (cell.column.modules.validate &&
self.table.modExists(
"validate")) {
171 valid =
self.table.modules.validate.validate(cell.column.modules.validate, cell.getComponent(), value);
174 if (valid ===
true) {
176 cell.setValue(value,
true);
178 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
179 self.table.modules.dataTree.checkForRestyle(cell);
184 self.invalidEdit =
true;
185 element.classList.add(
"tabulator-validation-fail");
186 self.focusCellNoEvent(cell,
true);
188 self.table.options.validationFailed.call(
self.table, cell.getComponent(), value, valid);
199 if (
self.currentCell === cell) {
202 if (
self.table.options.dataTree &&
self.table.modExists(
"dataTree")) {
203 self.table.modules.dataTree.checkForRestyle(cell);
210 function onRendered(callback) {
214 if (!cell.column.modules.edit.blocked) {
219 switch (_typeof(cell.column.modules.edit.check)) {
221 allowEdit = cell.column.modules.edit.check(cell.getComponent());
225 allowEdit = cell.column.modules.edit.check;
229 if (allowEdit || forceEdit) {
233 self.currentCell = cell;
235 component = cell.getComponent();
237 if (this.mouseClick) {
238 this.mouseClick =
false;
240 if (cell.column.cellEvents.cellClick) {
241 cell.column.cellEvents.cellClick.call(this.table, e, component);
245 if (cell.column.cellEvents.cellEditing) {
246 cell.column.cellEvents.cellEditing.call(this.table, component);
249 self.table.options.cellEditing.call(this.table, component);
251 params = typeof cell.column.modules.edit.params ===
"function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;
253 cellEditor = cell.column.modules.edit.editor.call(
self, component, onRendered, success, cancel, params);
256 if (cellEditor !==
false) {
258 if (cellEditor instanceof Node) {
259 element.classList.add(
"tabulator-editing");
260 cell.row.getElement().classList.add(
"tabulator-row-editing");
261 while (element.firstChild) {
262 element.removeChild(element.firstChild);
263 }element.appendChild(cellEditor);
269 var children = element.children;
271 for (var i = 0; i < children.length; i++) {
272 children[i].addEventListener(
"click",
function (e) {
277 console.warn(
"Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor);
288 this.mouseClick =
false;
293 this.mouseClick =
false;
300 Edit.prototype.editors = {
303 input:
function input(cell, onRendered, success, cancel, editorParams) {
306 var cellValue = cell.getValue(),
307 input = document.createElement(
"input");
309 input.setAttribute(
"type", editorParams.search ?
"search" :
"text");
311 input.style.padding =
"4px";
312 input.style.width =
"100%";
313 input.style.boxSizing =
"border-box";
315 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
316 for (var key in editorParams.elementAttributes) {
317 if (key.charAt(0) ==
"+") {
319 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
321 input.setAttribute(key, editorParams.elementAttributes[key]);
326 input.value = typeof cellValue !==
"undefined" ? cellValue :
"";
328 onRendered(
function () {
330 input.style.height =
"100%";
333 function onChange(e) {
334 if ((cellValue === null || typeof cellValue ===
"undefined") && input.value !==
"" || input.value != cellValue) {
336 if (success(input.value)) {
337 cellValue = input.value;
345 input.addEventListener(
"change", onChange);
346 input.addEventListener(
"blur", onChange);
349 input.addEventListener(
"keydown",
function (e) {
365 textarea:
function textarea(cell, onRendered, success, cancel, editorParams) {
367 cellValue = cell.getValue(),
368 vertNav = editorParams.verticalNavigation ||
"hybrid",
369 value = String(cellValue !== null && typeof cellValue !==
"undefined" ? cellValue :
""),
370 count = (value.match(/(?:\r\n|\r|\n)/g) || []).length + 1,
371 input = document.createElement(
"textarea"),
375 input.style.display =
"block";
376 input.style.padding =
"2px";
377 input.style.height =
"100%";
378 input.style.width =
"100%";
379 input.style.boxSizing =
"border-box";
380 input.style.whiteSpace =
"pre-wrap";
381 input.style.resize =
"none";
383 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
384 for (var key in editorParams.elementAttributes) {
385 if (key.charAt(0) ==
"+") {
387 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
389 input.setAttribute(key, editorParams.elementAttributes[key]);
396 onRendered(
function () {
398 input.style.height =
"100%";
401 function onChange(e) {
403 if ((cellValue === null || typeof cellValue ===
"undefined") && input.value !==
"" || input.value != cellValue) {
405 if (success(input.value)) {
406 cellValue = input.value;
409 setTimeout(
function () {
410 cell.getRow().normalizeHeight();
418 input.addEventListener(
"change", onChange);
419 input.addEventListener(
"blur", onChange);
421 input.addEventListener(
"keyup",
function () {
423 input.style.height =
"";
425 var heightNow = input.scrollHeight;
427 input.style.height = heightNow +
"px";
429 if (heightNow != scrollHeight) {
430 scrollHeight = heightNow;
431 cell.getRow().normalizeHeight();
435 input.addEventListener(
"keydown",
function (e) {
444 if (vertNav ==
"editor" || vertNav ==
"hybrid" && input.selectionStart) {
445 e.stopImmediatePropagation();
453 if (vertNav ==
"editor" || vertNav ==
"hybrid" && input.selectionStart !== input.value.length) {
454 e.stopImmediatePropagation();
465 number:
function number(cell, onRendered, success, cancel, editorParams) {
467 var cellValue = cell.getValue(),
468 vertNav = editorParams.verticalNavigation ||
"editor",
469 input = document.createElement(
"input");
471 input.setAttribute(
"type",
"number");
473 if (typeof editorParams.max !=
"undefined") {
474 input.setAttribute(
"max", editorParams.max);
477 if (typeof editorParams.min !=
"undefined") {
478 input.setAttribute(
"min", editorParams.min);
481 if (typeof editorParams.step !=
"undefined") {
482 input.setAttribute(
"step", editorParams.step);
486 input.style.padding =
"4px";
487 input.style.width =
"100%";
488 input.style.boxSizing =
"border-box";
490 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
491 for (var key in editorParams.elementAttributes) {
492 if (key.charAt(0) ==
"+") {
494 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
496 input.setAttribute(key, editorParams.elementAttributes[key]);
501 input.value = cellValue;
503 var blurFunc =
function blurFunc(e) {
507 onRendered(
function () {
509 input.removeEventListener(
"blur", blurFunc);
512 input.style.height =
"100%";
515 input.addEventListener(
"blur", blurFunc);
518 function onChange() {
519 var value = input.value;
521 if (!isNaN(value) && value !==
"") {
522 value = Number(value);
525 if (value != cellValue) {
526 if (success(value)) {
535 input.addEventListener(
"keydown",
function (e) {
549 if (vertNav ==
"editor") {
550 e.stopImmediatePropagation();
561 range:
function range(cell, onRendered, success, cancel, editorParams) {
563 var cellValue = cell.getValue(),
564 input = document.createElement(
"input");
566 input.setAttribute(
"type",
"range");
568 if (typeof editorParams.max !=
"undefined") {
569 input.setAttribute(
"max", editorParams.max);
572 if (typeof editorParams.min !=
"undefined") {
573 input.setAttribute(
"min", editorParams.min);
576 if (typeof editorParams.step !=
"undefined") {
577 input.setAttribute(
"step", editorParams.step);
581 input.style.padding =
"4px";
582 input.style.width =
"100%";
583 input.style.boxSizing =
"border-box";
585 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
586 for (var key in editorParams.elementAttributes) {
587 if (key.charAt(0) ==
"+") {
589 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
591 input.setAttribute(key, editorParams.elementAttributes[key]);
596 input.value = cellValue;
598 onRendered(
function () {
600 input.style.height =
"100%";
603 function onChange() {
604 var value = input.value;
606 if (!isNaN(value) && value !==
"") {
607 value = Number(value);
610 if (value != cellValue) {
611 if (success(value)) {
620 input.addEventListener(
"blur",
function (e) {
625 input.addEventListener(
"keydown",
function (e) {
642 select:
function select(cell, onRendered, success, cancel, editorParams) {
644 cellEl = cell.getElement(),
645 initialValue = cell.getValue(),
646 vertNav = editorParams.verticalNavigation ||
"editor",
647 initialDisplayValue = typeof initialValue !==
"undefined" || initialValue === null ? initialValue : typeof editorParams.defaultValue !==
"undefined" ? editorParams.defaultValue :
"",
648 input = document.createElement(
"input"),
649 listEl = document.createElement(
"div"),
655 this.table.rowManager.element.addEventListener(
"scroll", cancelItem);
657 if (Array.isArray(editorParams) || !Array.isArray(editorParams) && (typeof editorParams ===
"undefined" ?
"undefined" : _typeof(editorParams)) ===
"object" && !editorParams.values) {
658 console.warn(
"DEPRECATION WANRING - values for the select editor must now be passed into the values property of the editorParams object, not as the editorParams object");
659 editorParams = { values: editorParams };
662 function getUniqueColumnValues(field) {
664 data =
self.table.getData(),
668 column =
self.table.columnManager.getColumnByField(field);
670 column = cell.getColumn()._getSelf();
674 data.forEach(
function (row) {
675 var val = column.getFieldValue(row);
677 if (val !== null && typeof val !==
"undefined" && val !==
"") {
682 if (editorParams.sortValuesList) {
683 if (editorParams.sortValuesList ==
"asc") {
684 output = Object.keys(output).sort();
686 output = Object.keys(output).sort().reverse();
689 output = Object.keys(output);
692 console.warn(
"unable to find matching column to create select lookup list:", field);
698 function parseItems(inputValues, curentValue) {
700 var displayList = [];
702 function processComplexListItem(item) {
704 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(item.value, item.label) : item.label,
709 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
710 setCurrentItem(item);
714 displayList.push(item);
719 if (typeof inputValues ==
"function") {
720 inputValues = inputValues(cell);
723 if (Array.isArray(inputValues)) {
724 inputValues.forEach(
function (value) {
727 if ((typeof value ===
"undefined" ?
"undefined" : _typeof(value)) ===
"object") {
736 displayList.push(item);
738 value.options.forEach(
function (item) {
739 processComplexListItem(item);
742 processComplexListItem(value);
747 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
752 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
753 setCurrentItem(item);
757 displayList.push(item);
761 for (var key in inputValues) {
763 label: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
768 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
769 setCurrentItem(item);
773 displayList.push(item);
777 dataItems = dataList;
778 displayItems = displayList;
783 function fillList() {
784 while (listEl.firstChild) {
785 listEl.removeChild(listEl.firstChild);
786 }displayItems.forEach(
function (item) {
787 var el = item.element;
792 el = document.createElement(
"div");
793 el.classList.add(
"tabulator-edit-select-list-group");
795 el.innerHTML = item.label ===
"" ?
" " : item.label;
797 el = document.createElement(
"div");
798 el.classList.add(
"tabulator-edit-select-list-item");
800 el.innerHTML = item.label ===
"" ?
" " : item.label;
802 el.addEventListener(
"click",
function () {
803 setCurrentItem(item);
807 if (item === currentItem) {
808 el.classList.add(
"active");
812 el.addEventListener(
"mousedown",
function () {
815 setTimeout(
function () {
823 listEl.appendChild(el);
827 function setCurrentItem(item) {
829 if (currentItem && currentItem.element) {
830 currentItem.element.classList.remove(
"active");
834 input.value = item.label ===
" " ?
"" : item.label;
837 item.element.classList.add(
"active");
841 function chooseItem() {
844 if (initialValue !== currentItem.value) {
845 initialValue = currentItem.value;
846 success(currentItem.value);
852 function cancelItem() {
857 function showList() {
858 if (!listEl.parentNode) {
860 if (editorParams.values ===
true) {
861 parseItems(getUniqueColumnValues(), initialDisplayValue);
862 }
else if (typeof editorParams.values ===
"string") {
863 parseItems(getUniqueColumnValues(editorParams.values), initialDisplayValue);
865 parseItems(editorParams.values || [], initialDisplayValue);
868 var offset = Tabulator.prototype.helpers.elOffset(cellEl);
870 listEl.style.minWidth = cellEl.offsetWidth +
"px";
872 listEl.style.top = offset.top + cellEl.offsetHeight +
"px";
873 listEl.style.left = offset.left +
"px";
874 document.body.appendChild(listEl);
878 function hideList() {
879 if (listEl.parentNode) {
880 listEl.parentNode.removeChild(listEl);
883 removeScrollListener();
886 function removeScrollListener() {
887 self.table.rowManager.element.removeEventListener(
"scroll", cancelItem);
891 input.setAttribute(
"type",
"text");
893 input.style.padding =
"4px";
894 input.style.width =
"100%";
895 input.style.boxSizing =
"border-box";
896 input.style.cursor =
"default";
897 input.readOnly = this.currentCell !=
false;
899 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
900 for (var key in editorParams.elementAttributes) {
901 if (key.charAt(0) ==
"+") {
903 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
905 input.setAttribute(key, editorParams.elementAttributes[key]);
910 input.value = typeof initialValue !==
"undefined" || initialValue === null ? initialValue :
"";
921 input.addEventListener(
"keydown",
function (e) {
927 index = dataItems.indexOf(currentItem);
929 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index) {
930 e.stopImmediatePropagation();
935 setCurrentItem(dataItems[index - 1]);
942 index = dataItems.indexOf(currentItem);
944 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index < dataItems.length - 1) {
945 e.stopImmediatePropagation();
949 if (index < dataItems.length - 1) {
951 setCurrentItem(dataItems[0]);
953 setCurrentItem(dataItems[index + 1]);
962 e.stopImmediatePropagation();
979 input.addEventListener(
"blur",
function (e) {
985 input.addEventListener(
"focus",
function (e) {
990 listEl = document.createElement(
"div");
991 listEl.classList.add(
"tabulator-edit-select-list");
993 onRendered(
function () {
994 input.style.height =
"100%";
1002 autocomplete:
function autocomplete(cell, onRendered, success, cancel, editorParams) {
1004 cellEl = cell.getElement(),
1005 initialValue = cell.getValue(),
1006 vertNav = editorParams.verticalNavigation ||
"editor",
1007 initialDisplayValue = typeof initialValue !==
"undefined" || initialValue === null ? initialValue : typeof editorParams.defaultValue !==
"undefined" ? editorParams.defaultValue :
"",
1008 input = document.createElement(
"input"),
1009 listEl = document.createElement(
"div"),
1016 this.table.rowManager.element.addEventListener(
"scroll", cancelItem);
1018 function getUniqueColumnValues(field) {
1020 data =
self.table.getData(),
1024 column =
self.table.columnManager.getColumnByField(field);
1026 column = cell.getColumn()._getSelf();
1030 data.forEach(
function (row) {
1031 var val = column.getFieldValue(row);
1033 if (val !== null && typeof val !==
"undefined" && val !==
"") {
1038 if (editorParams.sortValuesList) {
1039 if (editorParams.sortValuesList ==
"asc") {
1040 output = Object.keys(output).sort();
1042 output = Object.keys(output).sort().reverse();
1045 output = Object.keys(output);
1048 console.warn(
"unable to find matching column to create autocomplete lookup list:", field);
1054 function parseItems(inputValues, curentValue) {
1057 if (Array.isArray(inputValues)) {
1058 inputValues.forEach(
function (value) {
1060 title: editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value,
1065 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
1066 setCurrentItem(item);
1069 itemList.push(item);
1072 for (var key in inputValues) {
1074 title: editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],
1079 if (item.value === curentValue || !isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue)) {
1080 setCurrentItem(item);
1083 itemList.push(item);
1087 if (editorParams.searchFunc) {
1088 itemList.forEach(
function (item) {
1096 allItems = itemList;
1099 function filterList(term, intialLoad) {
1104 if (editorParams.searchFunc) {
1106 allItems.forEach(
function (item) {
1107 searchObjs.push(item.search);
1110 searchResults = editorParams.searchFunc(term, searchObjs);
1112 searchResults.forEach(
function (result) {
1113 var match = allItems.find(
function (item) {
1114 return item.search === result;
1118 matches.push(match);
1124 if (editorParams.showListOnEmpty) {
1125 allItems.forEach(
function (item) {
1130 allItems.forEach(
function (item) {
1132 if (item.value !== null || typeof item.value !==
"undefined") {
1133 if (String(item.value).toLowerCase().indexOf(String(term).toLowerCase()) > -1 || String(item.title).toLowerCase().indexOf(String(term).toLowerCase()) > -1) {
1141 displayItems = matches;
1143 fillList(intialLoad);
1146 function fillList(intialLoad) {
1147 var current =
false;
1149 while (listEl.firstChild) {
1150 listEl.removeChild(listEl.firstChild);
1151 }displayItems.forEach(
function (item) {
1152 var el = item.element;
1155 el = document.createElement(
"div");
1156 el.classList.add(
"tabulator-edit-select-list-item");
1158 el.innerHTML = item.title;
1160 el.addEventListener(
"click",
function () {
1161 setCurrentItem(item);
1165 el.addEventListener(
"mousedown",
function () {
1168 setTimeout(
function () {
1175 if (intialLoad && item.value == initialValue) {
1176 input.value = item.title;
1177 item.element.classList.add(
"active");
1181 if (item === currentItem) {
1182 item.element.classList.add(
"active");
1187 listEl.appendChild(el);
1191 setCurrentItem(
false);
1195 function setCurrentItem(item, showInputValue) {
1196 if (currentItem && currentItem.element) {
1197 currentItem.element.classList.remove(
"active");
1202 if (item && item.element) {
1203 item.element.classList.add(
"active");
1207 function chooseItem() {
1211 if (initialValue !== currentItem.value) {
1212 initialValue = currentItem.value;
1213 input.value = currentItem.title;
1214 success(currentItem.value);
1219 if (editorParams.freetext) {
1220 initialValue = input.value;
1221 success(input.value);
1223 if (editorParams.allowEmpty && input.value ===
"") {
1224 initialValue = input.value;
1225 success(input.value);
1233 function cancelItem() {
1238 function showList() {
1239 if (!listEl.parentNode) {
1240 while (listEl.firstChild) {
1241 listEl.removeChild(listEl.firstChild);
1242 }
if (editorParams.values ===
true) {
1243 values = getUniqueColumnValues();
1244 }
else if (typeof editorParams.values ===
"string") {
1245 values = getUniqueColumnValues(editorParams.values);
1247 values = editorParams.values || [];
1250 parseItems(values, initialValue);
1252 var offset = Tabulator.prototype.helpers.elOffset(cellEl);
1254 listEl.style.minWidth = cellEl.offsetWidth +
"px";
1256 listEl.style.top = offset.top + cellEl.offsetHeight +
"px";
1257 listEl.style.left = offset.left +
"px";
1258 document.body.appendChild(listEl);
1262 function hideList() {
1263 if (listEl.parentNode) {
1264 listEl.parentNode.removeChild(listEl);
1267 removeScrollListener();
1270 function removeScrollListener() {
1271 self.table.rowManager.element.removeEventListener(
"scroll", cancelItem);
1275 input.setAttribute(
"type",
"search");
1277 input.style.padding =
"4px";
1278 input.style.width =
"100%";
1279 input.style.boxSizing =
"border-box";
1281 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
1282 for (var key in editorParams.elementAttributes) {
1283 if (key.charAt(0) ==
"+") {
1285 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
1287 input.setAttribute(key, editorParams.elementAttributes[key]);
1293 input.addEventListener(
"keydown",
function (e) {
1296 switch (e.keyCode) {
1299 index = displayItems.indexOf(currentItem);
1301 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index) {
1302 e.stopImmediatePropagation();
1303 e.stopPropagation();
1307 setCurrentItem(displayItems[index - 1]);
1309 setCurrentItem(
false);
1317 index = displayItems.indexOf(currentItem);
1319 if (vertNav ==
"editor" || vertNav ==
"hybrid" && index < displayItems.length - 1) {
1321 e.stopImmediatePropagation();
1322 e.stopPropagation();
1325 if (index < displayItems.length - 1) {
1327 setCurrentItem(displayItems[0]);
1329 setCurrentItem(displayItems[index + 1]);
1338 e.stopImmediatePropagation();
1339 e.stopPropagation();
1357 e.stopImmediatePropagation();
1362 input.addEventListener(
"keyup",
function (e) {
1364 switch (e.keyCode) {
1375 filterList(input.value);
1379 input.addEventListener(
"search",
function (e) {
1380 filterList(input.value);
1383 input.addEventListener(
"blur",
function (e) {
1389 input.addEventListener(
"focus",
function (e) {
1390 var value = initialDisplayValue;
1392 input.value = value;
1393 filterList(value,
true);
1397 listEl = document.createElement(
"div");
1398 listEl.classList.add(
"tabulator-edit-select-list");
1400 onRendered(
function () {
1401 input.style.height =
"100%";
1409 star:
function star(cell, onRendered, success, cancel, editorParams) {
1411 element = cell.getElement(),
1412 value = cell.getValue(),
1413 maxStars = element.getElementsByTagName(
"svg").length || 5,
1414 size = element.getElementsByTagName(
"svg")[0] ? element.getElementsByTagName(
"svg")[0].getAttribute(
"width") : 14,
1416 starsHolder = document.createElement(
"div"),
1417 star = document.createElementNS(
'http://www.w3.org/2000/svg',
"svg");
1420 function starChange(val) {
1421 stars.forEach(
function (star, i) {
1423 if (
self.table.browser ==
"ie") {
1424 star.setAttribute(
"class",
"tabulator-star-active");
1426 star.classList.replace(
"tabulator-star-inactive",
"tabulator-star-active");
1429 star.innerHTML =
'<polygon fill="#488CE9" stroke="#014AAE" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';
1431 if (
self.table.browser ==
"ie") {
1432 star.setAttribute(
"class",
"tabulator-star-inactive");
1434 star.classList.replace(
"tabulator-star-active",
"tabulator-star-inactive");
1437 star.innerHTML =
'<polygon fill="#010155" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';
1443 function buildStar(i) {
1445 var starHolder = document.createElement(
"span");
1446 var nextStar = star.cloneNode(
true);
1448 stars.push(nextStar);
1450 starHolder.addEventListener(
"mouseenter",
function (e) {
1451 e.stopPropagation();
1452 e.stopImmediatePropagation();
1456 starHolder.addEventListener(
"mousemove",
function (e) {
1457 e.stopPropagation();
1458 e.stopImmediatePropagation();
1461 starHolder.addEventListener(
"click",
function (e) {
1462 e.stopPropagation();
1463 e.stopImmediatePropagation();
1467 starHolder.appendChild(nextStar);
1468 starsHolder.appendChild(starHolder);
1472 function changeValue(val) {
1478 element.style.whiteSpace =
"nowrap";
1479 element.style.overflow =
"hidden";
1480 element.style.textOverflow =
"ellipsis";
1483 starsHolder.style.verticalAlign =
"middle";
1484 starsHolder.style.display =
"inline-block";
1485 starsHolder.style.padding =
"4px";
1488 star.setAttribute(
"width", size);
1489 star.setAttribute(
"height", size);
1490 star.setAttribute(
"viewBox",
"0 0 512 512");
1491 star.setAttribute(
"xml:space",
"preserve");
1492 star.style.padding =
"0 1px";
1494 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
1495 for (var key in editorParams.elementAttributes) {
1496 if (key.charAt(0) ==
"+") {
1498 starsHolder.setAttribute(key, starsHolder.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
1500 starsHolder.setAttribute(key, editorParams.elementAttributes[key]);
1506 for (var i = 1; i <= maxStars; i++) {
1511 value = Math.min(parseInt(value), maxStars);
1516 starsHolder.addEventListener(
"mousemove",
function (e) {
1520 starsHolder.addEventListener(
"click",
function (e) {
1524 element.addEventListener(
"blur",
function (e) {
1529 element.addEventListener(
"keydown",
function (e) {
1530 switch (e.keyCode) {
1533 changeValue(value + 1);
1538 changeValue(value - 1);
1557 progress:
function progress(cell, onRendered, success, cancel, editorParams) {
1558 var element = cell.getElement(),
1559 max = typeof editorParams.max ===
"undefined" ? element.getElementsByTagName(
"div")[0].getAttribute(
"max") || 100 : editorParams.max,
1560 min = typeof editorParams.min ===
"undefined" ? element.getElementsByTagName(
"div")[0].getAttribute(
"min") || 0 : editorParams.min,
1561 percent = (max - min) / 100,
1562 value = cell.getValue() || 0,
1563 handle = document.createElement(
"div"),
1564 bar = document.createElement(
"div"),
1569 function updateValue() {
1570 var calcVal = percent * Math.round(bar.offsetWidth / (element.clientWidth / 100)) + min;
1572 element.setAttribute(
"aria-valuenow", calcVal);
1573 element.setAttribute(
"aria-label", value);
1577 handle.style.position =
"absolute";
1578 handle.style.right =
"0";
1579 handle.style.top =
"0";
1580 handle.style.bottom =
"0";
1581 handle.style.width =
"5px";
1582 handle.classList.add(
"tabulator-progress-handle");
1585 bar.style.display =
"inline-block";
1586 bar.style.position =
"relative";
1591 bar.style.height =
"100%";
1592 bar.style.backgroundColor =
"#488CE9";
1593 bar.style.maxWidth =
"100%";
1594 bar.style.minWidth =
"0%";
1596 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
1597 for (var key in editorParams.elementAttributes) {
1598 if (key.charAt(0) ==
"+") {
1600 bar.setAttribute(key, bar.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
1602 bar.setAttribute(key, editorParams.elementAttributes[key]);
1608 element.style.padding =
"4px 4px";
1611 value = Math.min(parseFloat(value), max);
1612 value = Math.max(parseFloat(value), min);
1615 value = Math.round((value - min) / percent);
1617 bar.style.width = value +
"%";
1619 element.setAttribute(
"aria-valuemin", min);
1620 element.setAttribute(
"aria-valuemax", max);
1622 bar.appendChild(handle);
1624 handle.addEventListener(
"mousedown",
function (e) {
1625 mouseDrag = e.screenX;
1626 mouseDragWidth = bar.offsetWidth;
1629 handle.addEventListener(
"mouseover",
function () {
1630 handle.style.cursor =
"ew-resize";
1633 element.addEventListener(
"mousemove",
function (e) {
1635 bar.style.width = mouseDragWidth + e.screenX - mouseDrag +
"px";
1639 element.addEventListener(
"mouseup",
function (e) {
1641 e.stopPropagation();
1642 e.stopImmediatePropagation();
1645 mouseDragWidth =
false;
1652 element.addEventListener(
"keydown",
function (e) {
1653 switch (e.keyCode) {
1656 bar.style.width = bar.clientWidth + element.clientWidth / 100 +
"px";
1661 bar.style.width = bar.clientWidth - element.clientWidth / 100 +
"px";
1677 element.addEventListener(
"blur",
function () {
1685 tickCross:
function tickCross(cell, onRendered, success, cancel, editorParams) {
1686 var value = cell.getValue(),
1687 input = document.createElement(
"input"),
1688 tristate = editorParams.tristate,
1689 indetermValue = typeof editorParams.indeterminateValue ===
"undefined" ? null : editorParams.indeterminateValue,
1690 indetermState =
false;
1692 input.setAttribute(
"type",
"checkbox");
1693 input.style.marginTop =
"5px";
1694 input.style.boxSizing =
"border-box";
1696 if (editorParams.elementAttributes && _typeof(editorParams.elementAttributes) ==
"object") {
1697 for (var key in editorParams.elementAttributes) {
1698 if (key.charAt(0) ==
"+") {
1700 input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[
"+" + key]);
1702 input.setAttribute(key, editorParams.elementAttributes[key]);
1707 input.value = value;
1709 if (tristate && (typeof value ===
"undefined" || value === indetermValue || value ===
"")) {
1710 indetermState =
true;
1711 input.indeterminate =
true;
1714 if (this.table.browser !=
"firefox") {
1716 onRendered(
function () {
1721 input.checked = value ===
true || value ===
"true" || value ===
"True" || value === 1;
1723 function setValue(blur) {
1726 if (input.checked && !indetermState) {
1727 input.checked =
false;
1728 input.indeterminate =
true;
1729 indetermState =
true;
1730 return indetermValue;
1732 indetermState =
false;
1733 return input.checked;
1736 if (indetermState) {
1737 return indetermValue;
1739 return input.checked;
1743 return input.checked;
1748 input.addEventListener(
"change",
function (e) {
1749 success(setValue());
1752 input.addEventListener(
"blur",
function (e) {
1753 success(setValue(
true));
1757 input.addEventListener(
"keydown",
function (e) {
1758 if (e.keyCode == 13) {
1759 success(setValue());
1761 if (e.keyCode == 27) {
1770 Tabulator.prototype.registerModule(
"edit", Edit);