(.*?)<\/n>/g.exec(t)
+ t = r === null ? t : r[1]
- nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths[c] = m;
- nuSetBrowseColumns(nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths)
+ const $div = $(div)
+ nuSetObjectBounds($div, obj.top, obj.left, obj.width, obj.height)
+ .css('text-align', obj.align)
+ .addClass('nuWord')
+ .html(nuTranslate(t))
- } else {
- console.log('Offset size exceeds limit');
- }
+ if (nuGlobalAccess()) {
+ $div.attr('ondblclick', 'nuOptionsListAction("nuobject", "' + obj.object_id + '")')
+ }
- }
+ if (r !== null) {
+ $div.css('font-weight', 'normal')
+ }
- }
+ nuAddInputIcon(id, obj.input_icon)
+ nuSetAccess(id, obj.read)
+ nuAddStyle(id, obj)
+ return Number(obj.width)
}
-function nuAlign(a) {
+function nuRUNGetOnClickEvent (obj) {
+ let result = ''
+ const runTarget = obj.run_target || '0'
- const alignmentMap = {
- l: 'left',
- r: 'right',
- c: 'center'
- };
+ const stopClick = runTarget == '0' ? 'nuStopClick(event);' : ''
+ const jsPopup = `nuPopup('${obj.form_id}','${obj.record_id}','${obj.filter}')`
+ const jsForm = `nuForm('${obj.form_id}','${obj.record_id}','${obj.filter}', '','${runTarget}')`
+ const runAction = runTarget == '3' ? jsPopup : jsForm
- return alignmentMap[a] || '';
+ const runType = obj.run_type
+ if (runType == 'F') {
+ result = stopClick + runAction
+ } else
+ if (runType == 'R') {
+ result = "nuRunReport('" + obj.record_id + "')"
+ } else
+ if (runType == 'P') {
+ result = obj.run_hidden
+ ? `nuRunPHPHidden('${obj.record_id}')`
+ : `nuRunPHP('${obj.record_id}')`
+ }
+ return result
}
-function nuBrowseTable() {
-
- var bc = window.nuFORM.getCurrent();
- var col = bc.browse_columns;
- var row = bc.browse_rows;
- var rows = bc.rows;
- var h = bc.row_height;
- var t = parseInt($('#nuBrowseTitle0').css('height'), 10) - h - 2;
- var l = 7;
- // var borderLeft;
- // var borderRight;
-
- const brCount = bc.browse_rows;
- const $record = $('#nuRECORD');
- let incWidth = 0;
-
- for (let r = 0; r < rows; r++) {
+function nuRUN (w, i, l, p, prop) {
+ const obj = prop.objects[i]
+ const id = p + obj.id
+ let tagName = 'button'
- l = 7;
- t = t + h + 7;
+ if (obj.parent_type == 'g') {
+ obj.left = l
+ obj.top = 3
+ }
- if (brCount == 0 && r > 0) {
+ if (obj.run_method != 'b') {
+ tagName = 'iframe'
+ if (obj.parent_type !== 'g') {
+ nuLabel(w, i, p, prop)
+ }
+ }
- let noData;
- let firstCellClass;
+ const div = nuCreateElementWithId(tagName, id, p + 'nuRECORD')
+ const $div = $(div)
- let $firstCell = $('#nucell_0_0');
+ nuAddDataTab(id, obj.tab, p)
- if (nuCurrentProperties().search.length == 0) {
- noData = 'No data to display';
- firstCellClass = 'nuBrowseNoData';
- window.nuBrowseNoData = true;
- } else {
- noData = 'No search results found';
- firstCellClass = 'nuBrowseNoResults';
- window.nuBrowseNoSearchResults = true;
- }
+ nuSetObjectBounds($div, obj.top, obj.left, obj.width, obj.height).css('text-align', obj.align)
+ .attr('data-nu-object-id', w.objects[i].object_id)
+ .attr('data-nu-prefix', p)
- $firstCell.html(nuTranslate(noData)).addClass(firstCellClass);
+ if (obj.run_method == 'b') {
+ $div.attr({
+ type: 'button',
+ value: nuTranslate(obj.label),
+ onclick: nuRUNGetOnClickEvent(obj)
+ })
+ .html(nuTranslate(obj.label))
+ .addClass('nuButton')
- break;
+ nuAddInputIcon(id, obj.input_icon)
+ } else {
+ window.nuOPENER.push(new nuOpener(obj.run_type, obj.form_id, obj.record_id, obj.filter, obj.parameters))
- }
+ const open = window.nuOPENER[window.nuOPENER.length - 1]
+ const url = window.location.pathname + '?i=2&opener=' + open.id
- for (let c = 0; c < col.length; c++) {
+ $div.attr('src', url).removeClass('').addClass('nuIframe')
+ }
- var w = Number(col[c].width);
- var a = nuAlign(col[c].align);
- var rw = r;
- var column = c;
- var id = 'nucell_' + rw + '_' + c;
- var div = document.createElement('div');
- div.setAttribute('id', id);
+ nuAddJSObjectEvents(id, obj.js)
+ nuSetAccess(id, obj.read)
+ nuAddStyle(id, obj)
- $record.append(div);
+ return Number(obj.width)
+}
- var $id = $('#' + id);
+function nuSELECT (w, i, l, p, prop) {
+ let obj = prop.objects[i]
+ const id = p + obj.id
- // borderLeft = borderLeft !== true && w !== 0 ? true : false;
+ obj = nuLabelOrPosition(obj, w, i, l, p, prop)
+
+ const sel = nuCreateElementWithId('select', id, p + 'nuRECORD')
- $id.attr('data-nu-row', rw)
- .attr('data-nu-column', column)
- .addClass('nuCell' + ((r / 2) == parseInt(r / 2, 10) ? 'Even' : 'Odd'))
- // .addClass(borderLeft ? 'nuBrowseBorderLeft' : '')
- // .addClass(c == col.length -1 ? 'nuBrowseBorderRight' : '')
- .addClass(w == 0 ? '' : 'nuBrowseTable')
- .css({
- 'text-align': a,
- 'overflow': 'hidden',
- 'width': w,
- 'top': t,
- 'left': l,
- 'height': h,
- 'position': 'absolute'
- });
+ $sel = $(sel)
+
+ if (w.objects[i].value != '' && nuRecordId() == '-1') {
+ $sel.addClass('nuEdited')
+ }
- if (w == 0) {
- $id.hide();
- }
+ nuAddDataTab(id, obj.tab, p)
- if (w < 0) {
+ if (obj.multiple == 1) {
+ $sel.attr('multiple', 'multiple')
+ }
+
+ if (obj.select2 == 1) {
+ const select2Id = nuSetSelect2(id, obj)
+ nuAddDataTab(select2Id, obj.tab, p)
+ };
+
+ $sel.css({
+ top: Number(obj.top),
+ left: Number(obj.left),
+ width: Number(obj.width),
+ position: 'absolute'
+ })
+ .attr('onfocus', 'nuLookupFocus(event)')
+ .attr('onchange', 'nuChange(event)')
+ .attr('data-nu-field', obj.id)
+ .attr('data-nu-object-id', w.objects[i].object_id)
+ .attr('data-nu-format', '')
+ .attr('data-nu-subform-sort', 1)
+ .attr('data-nu-data', '')
+ .attr('data-nu-label', w.objects[i].label)
+ .attr('data-nu-prefix', p)
- $id
- .css('padding', 0)
- .css('border-width', 0);
+ $sel.css('height', Number(obj.height))
- }
+ const s = String(w.objects[i].value)
+ let a = []
+
+ if (w.objects[i].multiple == 0 || w.objects[i].multiple === null) {
+ a = [s]
+ }
+
+ if (s.substr(0, 1) + s.substr(-1) == '[]') {
+ eval('a = ' + s)
+ }
+
+ $sel.append('')
- if (r < row.length) {
+ let hasSelected = false
+ if (obj.options !== null) {
+ for (let n = 0; n < obj.options.length; n++) {
+ const opt = String(obj.options[n][1]) // .replaceAll(' ', ' ');
- const value = col[c].format == '' ? row[r][c + 1] : nuFORM.addFormatting(row[r][c + 1], col[c].format);
- $id
- .html(value)
- .attr('data-nu-primary-key', row[r][0])
- .attr('onclick', 'nuSelectBrowse(event, this)')
- .hover(
+ if (a.indexOf(String(obj.options[n][0])) == -1) {
+ $sel.append('')
+ } else {
+ $sel.append('')
+ hasSelected = true
+ }
+ }
+ }
- function () {
+ nuAddJSObjectEvents(id, obj.js)
+
+ nuSetAccess(id, obj.read)
- if (window.nuBROWSERESIZE.moving_element == '') {
- if (this.offsetWidth < this.scrollWidth && !$(this).is('[title]')) {
- $(this).attr('title', $(this).html().replace(/(<([^>]+)>)/ig, '')); // Remove HTML tags
- }
+ if (obj.read == 1) {
+ nuDisable(id)
+ }
- $("[data-nu-row]").addClass('nuBrowseTable').removeClass('nuSelectBrowse');
+ nuAddStyle(id, obj)
- window.nuBROWSEROW = -1;
+ return Number(obj.width)
+}
- const dataRow = $(this).attr('data-nu-row');
- $("[data-nu-row='" + dataRow + "']").not('.nuCellColored').addClass('nuSelectBrowse').removeClass('nuBrowseTable');
- }
+function nuSUBFORMAddCSS (id, SF) {
+ nuSetObjectBounds($('#' + id), SF.top, SF.left, SF.width, Number(SF.height) + 2)
+ .css({
+ 'overflow-x': 'hidden',
+ 'overflow-y': 'hidden'
+ })
+ .attr('data-nu-object-id', SF.object_id)
+ .attr('data-nu-foreign-key-name', SF.foreign_key_name)
+ .attr('data-nu-primary-key-name', SF.primary_key_name)
+ .attr('data-nu-subform', 'true')
+ .attr('data-nu-add', SF.add)
+ .attr('data-nu-delete', SF.delete)
+ .addClass('nuSubform')
+}
- }, function () {
+function nuSUBFORMScrollDivAddCSS (id, SF, scrId, rowTop, rowWidth) {
+ nuSetObjectBounds($('#' + scrId), rowTop, 0, Number(rowWidth) + 1, Number(SF.height) - rowTop + 1)
+ .css({
+ 'border-width': 10,
+ 'overflow-x': 'hidden',
+ 'overflow-y': 'scroll',
+ position: 'absolute'
+ })
+
+ if (rowWidth > Number(SF.width)) {
+ $('#' + id).css('overflow-x', 'scroll')
+ $('#' + scrId).css('height', SF.height - rowTop - 25)
+ }
+}
+
+function nuSUBFORMnuTabHolderAddCSS (tabId, rowTop, rowWidth) {
+ nuSetObjectBounds($('#' + tabId), 0, 0, rowWidth, rowTop)
+ .css({
+ 'overflow-x': 'hidden',
+ 'overflow-y': 'hidden',
+ position: 'absolute',
+ padding: '12px 0px 0px 0px'
+ })
+ .addClass('nuTabHolder')
+ .attr('data-nu-subform', tabId)
+ .prepend(' ')
+}
+
+function nuSUBFORMnuRECORDAddCSS (frmId, rowTop, rowWidth, rowHeight, even) {
+ nuSetObjectBounds($('#' + frmId), rowTop, 0, rowWidth, rowHeight)
+ .addClass('nuSubform' + even)
+}
+
+function nuCreateElementWithId (tagName, id, parentElement) {
+ const newElement = document.createElement(tagName)
+ newElement.setAttribute('id', id)
+ if (parentElement !== undefined) {
+ document.getElementById(parentElement).appendChild(newElement)
+ }
- if (window.nuBROWSERESIZE.moving_element == '') {
- $("[data-nu-row]").addClass('nuBrowseTable').removeClass('nuSelectBrowse');
+ return newElement
+}
- window.nuBROWSEROW = -1;
+function nuGetSubformDimensions (SF) {
+ const sfTypeGrid = SF.subform_type == 'g'
+ const sfType = sfTypeGrid ? 'grid' : 'edit'
+ const rowHeight = Number(SF.dimensions[sfType].height + (sfTypeGrid ? 0 : 10))
+ let rowWidth = Number(SF.dimensions[sfType].width + (sfTypeGrid ? 55 : 10))
+ rowWidth = SF.delete == '1' ? rowWidth - 3 : rowWidth - 25
+ rowTop = sfTypeGrid ? 52 : 33
- const dataRow = $(this).attr('data-nu-row');
- $("[data-nu-row='" + dataRow + "']").addClass('nuBrowseTable').removeClass('nuSelectBrowse');
- }
+ return { rowHeight, rowWidth, rowTop }
+}
- });
+function nuSUBFORM (w, i, l, p, prop) {
+ const SF = prop.objects[i] // -- First row
+ const subformRows = w.objects[i] // -- All rows
- }
+ const id = p + SF.id
+ nuCreateElementWithId('div', id, p + 'nuRECORD') // -- Edit Form Id
- if (r == 0 && c == 0) {
- incWidth = nuTotalWidth(id) - w;
- }
+ nuLabelOrPosition(SF, w, i, l, p, prop)
+ nuAddDataTab(id, SF.tab, p)
+ nuSUBFORMAddCSS(id, SF)
+ nuAddJSObjectEvents(id, SF.js)
- l = l + (w == 0 ? 0 : w + incWidth);
+ if (SF.forms[0] !== undefined) {
+ nuGetSubformRowSize(SF.forms[0].objects, SF, id)
+ }
- }
+ const sfDimensions = nuGetSubformDimensions(SF)
+ const rowHeight = sfDimensions.rowHeight
+ const rowWidth = sfDimensions.rowWidth
+ let rowTop = sfDimensions.rowTop
- }
+ const tabId = id + 'nuTabHolder'
+ const tabDiv = document.createElement('div')
+ tabDiv.setAttribute('id', tabId)
+ $('#' + id).prepend(tabDiv)
- const last = '◄';
- const next = '►';
+ nuSUBFORMnuTabHolderAddCSS(tabId, rowTop, rowWidth)
- const pg = ' Page ';
- const cu = '';
- const pagesOf = ' / ' + (bc.pages == 0 ? 1 : bc.pages) + ' ';
+ if (SF.subform_type == 'f') {
+ nuAddEditTabs(id, SF.forms[0])
+ } else {
+ if (subformRows.forms.length > 0) {
+ const tab0 = subformRows.forms[0].tabs[0]
+ nuTABHELP[tab0.id] = tab0.help
+ nuFORMHELP[SF.id] = tab0.help
+ }
+ }
- var footerTop = t + h + 10;
- var divFooter = document.createElement('div');
- divFooter.setAttribute('id', 'nuBrowseFooter');
+ nuOptions(id, SF.sf_form_id, 'subform', w.global_access)
- $record.append(divFooter);
+ const scrId = id + 'scrollDiv'
+ const scrDiv = nuCreateElementWithId('div', scrId, id)
+ scrDiv.setAttribute('class', 'nuSubformScrollDiv')
- $(divFooter)
- .addClass('nuBrowseFooter')
- .html(last + pg + cu + pagesOf + next)
- .css({
- 'text-align': 'center',
- 'width': l - 7,
- 'top': footerTop,
- 'left': 7,
- 'height': 25,
- 'position': 'absolute',
- 'padding': '5px 0px',
- });
+ nuSUBFORMScrollDivAddCSS(id, SF, scrId, rowTop, rowWidth)
- nuHighlightSearch();
- nuBrowseBorders();
+ rowTop = 0
+ let prefix
- h = footerTop + 130;
- const pDoc = window.parent.document;
+ for (let c = 0; c < subformRows.forms.length; c++) {
+ prefix = id + nuPad3(c)
+ const frmId = prefix + 'nuRECORD'
+ nuCreateElementWithId('div', frmId, scrId)
- $('#nuDragDialog', pDoc).css({
- 'height': h + 30,
- 'visibility': 'visible',
- 'overflow': 'hidden'
- });
- $('#nuWindow', pDoc).css({
- 'height': h - 14
- });
+ nuSUBFORMnuRECORDAddCSS(frmId, rowTop, rowWidth, rowHeight, c % 2 == 0 ? '1' : '0')
+ nuBuildEditObjects(subformRows.forms[c], prefix, SF, SF.forms[0])
+ SF.forms[c].deletable = SF.delete == '1' ? '1' : '0'
+ nuRecordProperties(SF.forms[c], prefix, rowWidth - 40)
- $('body').css('height', h - 30);
- $record.css('height', 0).css('width', 0);
+ rowTop = Number(rowTop) + Number(rowHeight)
+ }
-}
+ if (prefix != '') {
+ if (SF.add == 1) {
+ nuNewRowObject(String(prefix))
+ } else {
+ $('#' + prefix + 'nuRECORD').hide()
+ }
+ }
-function nuBrowseTitleMultiLine() {
+ nuSetAccess(id, SF.read)
+ nuAddStyle(id, SF)
- $('#nuActionHolder').css({ 'height': '40px' });
- $('.nuBrowseTitle').css('top', "-20px");
+ return Number(SF.width)
}
+function nuNewRowObject (p) {
+ const sf = p.substr(0, p.length - 3)
+ if ($('#' + p + 'nuRECORD').length == 0) {
+ return
+ }
-function nuSetBrowseColumnWidth(column, width) {
+ const html = document.getElementById(p + 'nuRECORD').outerHTML
- var cw = this;
- if (nuIsIframe()) {
- cw = parent.$("#" + window.frameElement.id)[0].contentWindow;
- }
- cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths[column] = width;
- cw.nuSetBrowseColumns(cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths);
+ window.nuSUBFORMROW[sf] = String(html.nuReplaceAll(p, '#nuSubformRowNumber#', true))
+ $("[id^='" + p + "']").addClass('nuEdit')
}
-function nuBrowseAdditionalNavButtons() {
-
- if (nuFormType() == 'browse') {
-
- const disabled = {
- 'opacity': '0.3',
- 'pointer-events': 'none'
- };
-
- const currentPage = Number($('#browsePage').val());
- const lastPage = nuCurrentProperties().pages;
-
- let html = ' ';
- $(html).insertBefore("#nuLast");
-
- html = ' ';
- $(html).insertAfter("#nuNext");
-
-
- if (currentPage == 1) {
- $('#nuFirst').css(disabled);
- $('#nuLast').css(disabled);
- }
-
- if (currentPage == lastPage) {
- $('#nuNext').css(disabled);
- $('#nuEnd').css(disabled);
- }
- }
-
+function nuSubformObject (id) {
+ return nuFORM.subform(id)
}
-function nuClickSearchColumn(e) {
-
- var c = e.target.id.substr(12);
- $('#nuSearchList' + c).click();
- nuSetSearchColumn();
-
+function nuSubformRowId (t) {
+ return $(t).parent().attr('data-nu-primary-key')
}
-function nuSetSearchColumn() {
-
- var nosearch = [];
-
- $('.nuSearchCheckbox').each(function (index) {
-
- if (!$(this).is(':checked')) {
-
- nosearch.push(index);
-
- $('#nusort_' + index)
- .addClass('nuNoSearch');
-
- } else {
-
- $('#nusort_' + index)
- .removeClass('nuNoSearch');
- }
-
- });
-
- window.nuFORM.setProperty('nosearch_columns', nosearch);
-
+function nuSubformRowNumber (id) {
+ return $('#' + id).attr('data-nu-prefix').slice(-3)
}
-function nuSetNoSearchColumns(columnsArr) {
-
- const s = nuFORM.getCurrent().nosearch_columns;
- columnsArr = s.concat(columnsArr);
-
- for (let i = 0; i < columnsArr.length; i++) {
- $('#nusort_' + columnsArr[i]).addClass('nuNoSearch');
- }
-
- nuFORM.setProperty('nosearch_columns', columnsArr);
-
+function nuSubformRowObject (id, column) {
+ const formCode = $('#' + id).attr('data-nu-form')
+ return $('#' + formCode + nuSubformRowNumber(id) + column)
}
-function nuSetSearchColumns(columnsArr) {
-
- const numBrowseColumns = $(".nuBrowseTitle").length;
- let arr = [];
-
- for (let i = 0; i <= numBrowseColumns; i++) {
- if (!columnsArr.includes(i)) {
- arr.push(i);
- }
- }
-
- nuSetNoSearchColumns(arr);
-
+function nuSubformValue (t, id) {
+ const p = $(t).attr('data-nu-prefix')
+ return $('#' + p + id).val()
}
-function nuSearchColumnsReset() {
+function nuSubformColumnArray (id, column, includeDeleted = false) {
+ const a = []
+ const sf = nuSubformObject(id)
+ const c = Number.isInteger(column) ? column : sf.fields.indexOf(column)
- for (let i = 0; i < $(".nuBrowseTitle").length; i++) {
- $('#nusort_' + i).removeClass('nuNoSearch');
- }Â Â Â Â
-
- nuFORM.setProperty('nosearch_columns', []);
+ for (let i = 0; i < sf.rows.length; i++) {
+ if (sf.deleted[i] == 0 || includeDeleted) {
+ const rv = sf.rows[i][c]
+ a.push(rv)
+ }
+ }
+ return a
}
-function nuSearchPressed(e) {
-
- if (!e) { e = window.event; }
-
- if (e.key == 'Enter' && window.nuBROWSEROW == -1) {
-
- e.preventDefault();
- $('#nuSearchButton').click();
-
- } else if (e.key == 'Enter' && window.nuBROWSEROW != -1) {
-
- e.preventDefault();
- const i = '#nucell_' + window.nuBROWSEROW + '_0';
-
- nuSelectBrowse('', $(i)[0]);
-
- } else {
-
- window.nuBROWSEROW = -1;
- $("[data-nu-row]").addClass('nuBrowseTable');
- $("[data-nu-row]").removeClass('nuSelectBrowse');
-
- }
+function nuSubformDisable (sf, ob) {
+ if (ob === undefined || ob === '') {
+ $("[data-nu-form='" + sf + "']").nuDisable()
+ return
+ }
+ for (let i = 0; i < nuSubformObject(sf).rows.length; i++) {
+ nuDisable(sf + nuPad3(i) + ob)
+ }
}
-function nuArrowPressed(e) {
-
- if (!e) { e = window.event; }
-
- const rows = $("[data-nu-column='0'][data-nu-primary-key]").length - 1;
-
- if (e.key == 'ArrowUp') {
-
- if (window.nuBROWSEROW == -1) {
- window.nuBROWSEROW = rows;
- } else {
- window.nuBROWSEROW = window.nuBROWSEROW - 1;
- }
-
- $("[data-nu-row]").addClass('nuBrowseTable').removeClass('nuSelectBrowse');
- $("[data-nu-row='" + window.nuBROWSEROW + "']").addClass('nuSelectBrowse').removeClass('nuBrowseTable');
-
- }
-
- if (e.key == 'ArrowDown') {
-
- if (window.nuBROWSEROW == rows) {
- window.nuBROWSEROW = -1;
- } else {
- window.nuBROWSEROW = window.nuBROWSEROW + 1;
- }
-
- $("[data-nu-row]").addClass('nuBrowseTable').removeClass('nuSelectBrowse');
- $("[data-nu-row='" + window.nuBROWSEROW + "']").addClass('nuSelectBrowse').removeClass('nuBrowseTable');
-
- }
+function nuSubformEnable (sf, ob, enable) {
+ if (ob === undefined || ob === '') {
+ $("[data-nu-form='" + sf + "']").nuEnable(enable)
+ return
+ }
+ for (let i = 0; i < nuSubformObject(sf).rows.length; i++) {
+ nuEnable(sf + nuPad3(i) + ob, enable)
+ }
}
+function nuSubformHide (sf, ob) {
+ if (ob === undefined || ob === '') {
+ $("[data-nu-form='" + sf + "']").nuHide()
+ return
+ }
-function nuSearchAction(S, F) {
-
- if (arguments.length > 0) {
- $('#nuSearchField').val(S);
- }
- if (arguments.length == 2) {
- $('#nuFilter').val(F);
- }
-
- var s = String($('#nuSearchField').val()).nuReplaceAll("'", "'", true);
- var f = String($('#nuFilter').val()).nuReplaceAll("'", "'", true);
-
- if (window.nuOnSearchActionGlobal) {
- let o = { search: s, filter: f };
- if (nuOnSearchActionGlobal(o) === false) { return; }
- s = o.search;
- f = o.filter;
- }
-
- if (window.nuOnSearchAction) {
- let o = { search: s, filter: f };
- if (nuOnSearchAction(o) === false) { return; }
- s = o.search;
- f = o.filter;
- }
-
- window.nuFORM.setProperty('search', s);
- window.nuFORM.setProperty('filter', f);
-
- const caller = nuSearchAction.caller === null ? '' : nuSearchAction.caller.name;
- if ((arguments.length === 0 && caller != 'nuGetPage') || arguments.length >= 1) {
- window.nuFORM.setProperty('page_number', 0);
- }
-
- nuDisable('nuSearchField');
- nuGetBreadcrumb();
-
+ for (let i = 0; i < nuSubformObject(sf).rows.length; i++) {
+ nuHide(sf + nuPad3(i) + ob)
+ }
}
-function nuAddAction() {
-
- const bc = window.nuFORM.getCurrent();
-
- if (window.nuOnAddAction) {
- if (nuOnAddAction(bc) == false) return;
- }
-
- nuForm(bc.redirect_form_id, '-1');
+function nuSubformShow (sf, ob, show) {
+ if (ob === undefined || ob === '') {
+ $("[data-nu-form='" + sf + "']").nuShow(true, false)
+ return
+ }
+ for (let i = 0; i < nuSubformObject(sf).rows.length; i++) {
+ nuShow(sf + nuPad3(i) + ob, show, false)
+ }
}
-function nuRunPHPAction(code) {
- nuRunPHP(code);
+function nuSubformHideHeader (id) {
+ const scrollDiv = $('#' + id + 'scrollDiv')
+ scrollDiv.css({ top: 0, height: $('#' + id).cssNumber('height') })
}
-function nuRunReportAction(code) {
- nuRunReport(code);
-}
+function nuSubformLastRow (t) {
+ const i = String($('#' + t.id).parent().attr('id'))
+ const p = i.substr(0, i.length - 17)
+ const s = parseInt(i.substr(11, 3), 10) + 1
+ const n = $('#' + p + nuPad3(s) + 'nuRECORD').length
-function nuEmailReportAction(code) {
- nuEmailReport(code);
+ return n == 0
}
-function nuSortBrowse(c) {
-
- var l = window.nuFORM.getCurrent();
- l.filter = $('#nuFilter').val();
- l.page_number = 0;
-
- if (c == l.sort) {
- l.sort_direction = l.sort_direction == 'asc' ? 'desc' : 'asc';
- } else {
-
- l.sort = c;
- l.sort_direction = 'asc';
-
- }
-
- nuSearchAction();
+function nuSubformFocusLastRow (id, f) {
+ const sf = nuSubformObject(id)
+ const c = f === undefined ? sf.fields[1] : sf.fields.indexOf(f)
+ const r = sf.rows.length - 1
+ $('#' + id + nuPad3(r) + c).focus()
}
-function nuGetPage(p) {
-
- let P = parseInt('00' + p, 10);
-
- if (p > nuCurrentProperties().pages || p === 0) return;
-
- let current = window.nuFORM.getCurrent();
+function nuSubformSetHeight (i, height, minHeight, maxHeight) {
+ const div = $('#' + i + 'scrollDiv')
+ const sf = $('#' + i)
- if (P == 0) {
- P = 1;
- }
+ let h = sf.data('nu-org-height')
+ if (h === undefined || h === null) {
+ div.data('nu-org-height', div.height())
+ sf.data('nu-org-height', sf.height())
+ sf.data('nu-org-z-index', sf.css('z-index'))
- if (P > current.pages) {
- P = current.pages;
- }
+ if (height === undefined || height === null) {
+ h = window.innerHeight - sf.cssNumber('Top') - nuDialogHeadersHeight() - 50
+ } else {
+ h = height
+ }
- current.page_number = P - 1;
+ if (maxHeight !== undefined && h > maxHeight) h = maxHeight
+ if (minHeight !== undefined && h < minHeight) h = minHeight
- nuSearchAction();
+ sf.height(h)
+ const hh = $('#' + i + 'nuTabHolder').height() + 1
+ div.height(h - hh)
+ sf.css('z-index', 1)
+ } else {
+ sf.height(h)
+ div.height(div.data('nu-org-height'))
+ sf.data('nu-org-height', null)
+ sf.css('z-index', div.data('nu-org-z-index'))
+ }
}
-function nuPopulateLookup(fm, target, setFocus) {
-
- var p = String($('#' + target).attr('data-nu-prefix'));
- var f = fm.lookup_values;
-
- window.nuSubformRow = Number(p.slice(-3));
-
- for (var i = 0; i < f.length; i++) {
-
- var id = String(f[i][0]);
- var $id = $('#' + id);
-
- if (id.substring(0, p.length) != p) {
- $id = $('#' + p + id);
- }
-
- $id.addClass('nuEdited');
-
- if ($id.attr('type') == 'checkbox') {
-
- $id.prop('checked', f[i][1] == '1');
-
- } else {
+function nuSubformRearrangeColumns (sf, fields, row, maintainWidth) {
+ function obj (p) {
+ return $("[id$='" + p + "']")
+ }
- $id.val(f[i][1]);
+ let width = 3
+ let totalwidth = $('#' + sf).cssNumber('width')
- if ($id.attr('data-nu-format') !== undefined) {
+ if (row !== '') row = nuPad3(row)
- nuReformat($id[0]);
- $id.addClass('nuEdited');
- $('#' + p + 'nuDelete').prop('checked', false);
+ nuHide(sf)
- if (window.nuOnLookupPopulatedGlobal) {
- nuOnLookupPopulatedGlobal(id, p);
- }
+ for (let i = 1; i < fields.length; i++) {
+ const p = row + fields[i][0]
+ const p0 = '000' + fields[i][0]
- if (window.nuOnLookupPopulated) {
- nuOnLookupPopulated(id, p);
- }
+ if (fields[i][1] == '0') {
+ const h0 = obj(p0)
+ if (!h0.is('[nu-subform-column-hidden]')) {
+ h0.attr('nu-subform-column-hidden', '')
+ const h = obj(p)
+ totalwidth -= h.cssNumber('width')
+ h.nuHide()
+ }
+ } else {
+ if (obj(p0).attr('data-nu-type') == 'lookup') {
+ obj(p + 'code').css('left', width)
+ width = obj('code').cssNumber('width') + width + 6
+ obj(p + 'button').css('left', width)
+ width += 19
+ obj(p + 'description').css('left', width)
+ width = obj('description').cssNumber('width') + width + 6
+ } else {
+ obj(p).css('left', width)
+ width = obj(p0).cssNumber('width') + width + 6
+ }
+ }
+ }
- }
-
- }
-
- if (i == 1 && setFocus !== false) {
- $id.focus();
- }
-
- }
-
- window.nuLOOKUPSTATE[$('#' + target).attr('data-nu-object-id')] = 'found';
-
- nuCalculateForm();
-
- eval(fm.lookup_javascript);
-
- $('#dialogClose').click();
+ if (maintainWidth !== false) {
+ $('#' + sf + 'scrollDiv').css('width', totalwidth - 1)
+ $('#' + sf).css('width', totalwidth)
+ }
+ nuShow(sf)
}
-function nuChooseOneLookupRecord(e, fm) {
-
- var o = new nuLookupObject(e.target.id);
- var i = o.id_id;
- var t = document.getElementById(e.target.id);
- var like = nuEncode(fm.lookup_like);
-
- if (fm.lookup_values.length == 0) {
- nuGetLookupId('', i);
- }
-
- if (fm.lookup_values.length == 1) {
+function nuSubformHideColumns (sfId, columns, maintainWidth) {
+ const fields = []
+ nuSubformObject(sfId).fields.forEach(function (col) {
+ fields.push([col, columns.indexOf(col) !== -1 ? '0' : '1'])
+ })
- if (e.target.value.toUpperCase() == String(fm.lookup_values[0][1]).toUpperCase()) {
- nuGetLookupId(fm.lookup_values[0][0], i);
- } else {
- nuBuildLookup(t, e.target.value);
- }
+ nuSubformRearrangeColumns(sfId, fields, '', maintainWidth)
+}
- }
+function nuSubformColumnUnique (id, column, label) {
+ const arr = nuSubformColumnArray(id, column)
- if (fm.lookup_values.length > 1) {
- nuBuildLookup(t, e.target.value, like);
- }
+ if (arr.includes('') || !nuArrayIsUnique(arr)) {
+ return nuTranslate(label) + ' ' + nuTranslate('must be both unique and not blank')
+ }
+ return true
}
-function nuLookupObject(id, set, value) {
-
- if ($('#' + id).length == 0) {
-
- this.id_id = '';
- this.code_id = '';
- this.description_id = '';
- this.id_value = '';
- this.code_value = '';
- this.description_value = '';
+function nuSubformTitleArray (sfName) {
+ return
+ $('#' + sfName).children().filter('.nuSubformTitle').map(function () {
+ return this.getAttribute('data-nu-field')
+ }).get()
+}
+
+function nuSubformMoveFocus (activeElement, d) {
+ const row = activeElement.attr('data-nu-prefix').slice(-3)
+ const nextRow = $('#' + activeElement.attr('data-nu-form') + nuPad3(Number(row) + d) + activeElement.attr('id').substr(activeElement.attr('data-nu-form').length + 3))
+ if (nextRow.length == 1 && !nextRow.prop('disabled')) nextRow.focus()
- return;
+ return true
+}
- }
+function nuSubformHandleArrowKeyEvent (e) {
+ const activeElement = $(document.activeElement)
+ const nuScroll = activeElement.hasClass('nuScroll')
- var i = nuValidLookupId(id, 'code');
- i = nuValidLookupId(i, 'description');
- this.id_id = i;
- this.code_id = i + 'code';
- this.description_id = i + 'description';
- this.id_value = $('#' + this.id_id).val();
- this.code_value = $('#' + this.code_id).val();
- this.description_value = $('#' + this.description_id).val();
-
- if (arguments.length == 3 && set == 'id') {
- $('#' + this.id).val(value);
- }
- if (arguments.length == 3 && set == 'code') {
- $('#' + this.code).val(value);
- }
- if (arguments.length == 3 && set == 'description') {
- $('#' + this.description).val(value);
- }
+ let result
+ switch (e.key) {
+ case 'ArrowUp':
+ result = !nuScroll && nuSubformMoveFocus(activeElement, -1)
+ break
+ case 'Enter':
+ result = nuSubformMoveFocus(activeElement, 1)
+ break
+ case 'ArrowDown':
+ result = !nuScroll && nuSubformMoveFocus(activeElement, 1)
+ break
+ default:
+ result = false
+ }
+ return result
}
-function nuValidLookupId(id, fld) {
-
- var i = String(id);
- var f = String(fld);
- var il = i.length;
- var fl = f.length;
-
- if (i.substr(il - fl) === f) {
-
- i = i.substr(0, il - fl);
-
- if ($('#' + i + f).length == 1 && $('#' + i + f + f).length == 1) {
+// Subform filtering
- i = i + f;
+function nuSubformAddFilter (filter) {
+ for (const sfName in filter) {
+ if (Object.prototype.hasOwnProperty.call(filter, sfName)) {
+ nuSubformFiltersAdd(sfName, filter[sfName])
+ }
+ }
+
+ function nuSubformFilterId (sfName, columnId) {
+ return sfName + columnId + '_filter'
+ }
+
+ function nuSubformFilterValue (sfName, columnId, type) {
+ const filterId = nuSubformFilterId(sfName, columnId)
+ return nuGetValue(filterId, type === 'select' ? 'text' : 'value')
+ }
+
+ function nuSubformFilterOptionAll (sfName, columnId) {
+ const filterId = nuSubformFilterId(sfName, columnId)
+ return $('#' + filterId + ' option:selected').attr('data-nu-all') === 'true'
+ }
+
+ function nuSubformFilterArray (sfName, arrColumns) {
+ const arr = {}
+ const isArray = Array.isArray(arrColumns)
+
+ for (let columnId in arrColumns) {
+ if (isArray) columnId = arrColumns[columnId]
+ arr[columnId] = {}
+ arr[columnId].type = isArray ? 'select' : arrColumns[columnId].type
+ arr[columnId].value = nuSubformFilterValue(sfName, columnId, arr[columnId].type)
+ arr[columnId].all = nuSubformFilterOptionAll(sfName, columnId)
+ }
+
+ return arr
+ }
+
+ function nuSubformFilterSortOptions (sfName, columnId) {
+ const filterId = nuSubformFilterId(sfName, columnId)
+ $(filterId).html($(filterId + " option:not('[data-nu-persistent]')").sort(function (a, b) {
+ return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
+ }))
+ }
+
+ function nuSubformFiltersAdd (sfName, arrColumns) {
+ const isArray = Array.isArray(arrColumns)
+ for (let columnId in arrColumns) {
+ if (Object.prototype.hasOwnProperty.call(arrColumns, columnId)) {
+ if (isArray) { columnId = arrColumns[columnId] }
+
+ const prop = arrColumns[columnId]
+ const float = prop === undefined || prop.float === undefined ? 'center' : prop.float
+
+ let width = $('#' + sfName + '000' + columnId).width() - 3
+ width = prop === undefined || prop.width === undefined ? width : prop.width
+
+ const style = {
+ width: width + 'px',
+ float
+ }
+
+ const columnTitle = '#title_' + sfName + columnId
+ const filterId = nuSubformFilterId(sfName, columnId)
+ const type = prop === undefined || prop.type === undefined ? 'select' : prop.type
+ const obj = nuSubformFilterAddObject(type, sfName, columnId, filterId, prop)
+
+ $(columnTitle).append('
')
+
+ obj.appendTo(columnTitle).css(style)
+ if (prop !== undefined && prop.placeholder) obj.nuSetPlaceholder(prop.placeholder)
+ }
+ }
+ }
+
+ function nuSubformFilterAddObject (type, sfName, columnId, filterId, prop) {
+ let obj
+ if (type == 'select') {
+ obj = nuSubformFilterAddSelect(sfName, columnId, filterId, prop)
+ } else if (type === 'search') {
+ obj = nuSubformFilterAddSearch(sfName, columnId, filterId, prop)
+ }
+
+ return obj
+ }
+
+ function nuSubformFilterAddSelect (sfName, columnId, filterId, prop) {
+ const propAll = prop === undefined || prop.all === undefined ? '(' + nuTranslate('All') + ')' : prop.all
+ let optionAll = []
+ if (propAll !== false) { optionAll = nuSubformFilterCreateSelectOption('', propAll, true, true, true) }
+
+ const propBlank = prop === undefined || prop.blank === undefined ? true : prop.blank
+ let optionBlank = []
+ if (propBlank !== false) { optionBlank = nuSubformFilterCreateSelectOption('', '', true, false, false) }
+
+ return $('', {
+ id: filterId,
+ class: 'nuSubformFilter',
+ on: {
+ change: function () {
+ nuSubformFilterRows(sfName, nuSubformFilterArray(sfName, filter[sfName]))
+ },
+ focus: function () {
+ nuSubformFilterAddValues(sfName, 'select', columnId)
+ nuSubformFilterSortOptions(sfName, columnId)
+ }
+ },
+ append: [
+ optionAll,
+ optionBlank
+ ]
+
+ })
+ }
+
+ function nuSubformFilterAddSearch (sfName, columnId, filterId, prop) {
+ const propDatalist = prop === undefined || prop.datalist === undefined ? true : prop.datalist
+
+ return $('', {
+ type: 'search',
+ class: 'nuSubformFilter',
+ on: {
+ input: function () {
+ nuSubformFilterRows(sfName, nuSubformFilterArray(sfName, filter[sfName]))
+ },
+ focus: function () {
+ if (propDatalist === true) { nuSubformFilterAddValues(sfName, 'search', columnId) }
+ }
+ },
+ id: filterId
+ })
+ }
+
+ function nuSubformFilterCreateSelectOption (_value, _text, persistent, all, _selected) {
+ return $('', {
+ value: _value,
+ text: _text,
+ 'data-nu-persistent': persistent,
+ 'data-nu-all': all,
+ selected: _selected === true ? 'selected' : false
+ })
+ }
+
+ function nuSubformFilterCellValue (sfName, columnId, row) {
+ const id = sfName + nuPad3(row) + columnId
+ const obj = $('#' + id)
+ let text = obj.nuGetValue(obj.is('select') ? 'text' : 'value')
+
+ if (obj.hasClass('nuHiddenLookup')) {
+ text = $('#' + id + 'code').nuGetValue()
+ }
+
+ return text
+ }
+
+ function nuSubformFilterAddValues (sfName, type, columnId) {
+ const sf = nuSubformObject(sfName)
+ const columnIndex = sf.fields.indexOf(columnId)
+ const filterId = nuSubformFilterId(sfName, columnId)
+ const filterObj = $('#' + filterId)
+ const selectedIndex = filterObj.prop('selectedIndex')
+ const arr = []
+
+ filterObj.find('option').not('[data-nu-persistent]').remove()
+
+ for (let row = 0; row < sf.rows.length - 1; row++) {
+ let value = sf.rows[row][columnIndex]
+ let text = nuSubformFilterCellValue(sfName, columnId, row)
+
+ if (type === 'select') {
+ if ($('#' + filterId + " option[value='" + value + "']").length == 0) {
+ let add = true
+
+ if (window.nuSubformFilterOnAddValue) {
+ const result = nuSubformFilterOnAddValue(sfName, add, text, value)
+ value = result.value
+ text = result.text
+ add = result.add
+ }
+
+ if (add) $('#' + filterId).append(new Option(text, value))
+ }
+ } else if (type === 'search') {
+ if (arr.indexOf(text) === -1) {
+ arr.push(text)
+ }
+ }
+ }
+
+ if (window.nuSubformFilterOnAddValues) {
+ nuSubformFilterOnAddValues(sfName, filterId)
+ }
+
+ if (type === 'select') {
+ filterObj.prop('selectedIndex', selectedIndex)
+ } else if (type === 'search') {
+ arr.sort(nuAscendingSortColumn)
+ nuAddDatalist(filterId, arr)
+ }
+ }
+
+ function nuSubformSortTop (a, b) {
+ if (a.top < b.top) {
+ return -1
+ }
+ if (a.top > b.top) {
+ return 1
+ }
+
+ return 0
+ }
+
+ function nuSubformFilterRows (sfName, arrFilter) {
+ const arr = []
+
+ const lastRow = nuSubformObject(sfName).rows.length
+ const nuNoAdd = $('#' + sfName).attr('data-nu-add') == '0' ? 1 : 0
+
+ let r = 0
+ $("[ID^='" + sfName + "'][ID$='nuRECORD']").each(function () {
+ const rec = $(this)
+
+ // Restore positions:
+ let top = rec.data('nu-top-position')
+ if (top) {
+ rec.css('top', top)
+ if (nuNoAdd == '1' && lastRow !== r) rec.show()
+ }
+
+ // Get positions
+ top = rec.cssNumber('top')
+ const o = { obj: rec.attr('id'), top }
+ rec.data('nu-top-position', top) // save top position
+
+ arr.push(o)
+ r++
+ })
+
+ const rows = arr.sort(nuSubformSortTop)
+
+ const rowHeight = $('#' + sfName + '000nuRECORD').cssNumber('height')
+ let rowTop = 0
+ let hideCount = 0
+
+ for (let row = 0; row < rows.length - nuNoAdd; row++) {
+ let hide = false
+ const rec = $('#' + rows[row].obj)
+
+ if (arrFilter !== null) {
+ for (const columnId in arrFilter) {
+ const data = []
+ data.val = nuSubformFilterCellValue(sfName, columnId, row)
+ data.filter = arrFilter[columnId].value
+ data.type = arrFilter[columnId].type
+ data.optionAll = arrFilter[columnId].all
+ data.optionBlank = data.filter == '' && data.type == 'search'
+ data.isMatch = (data.type == 'search' && data.val.toLowerCase().includes(data.filter.toLowerCase())) ||
+ (data.type == 'select' && (data.val.toLowerCase() == data.filter.toLowerCase() || data.optionAll))
+
+ if (window.nuSubformOnFilterRows) {
+ hide = nuSubformOnFilterRows(sfName, data, row, rows.length)
+ } else {
+ if (!data.isMatch && !data.optionBlank && rows.length - 1 !== row) {
+ hide = true
+ break
+ } else {
+ hide = false
+ }
+ }
+ }
+ }
+
+ if (hide === false) {
+ rec.css('top', rowTop).show()
+ rowTop = rowTop + rowHeight + 1
+ } else {
+ hideCount++
+ rec.hide()
+ }
+ }
+
+ $('#' + sfName).data('nu-filtered', hideCount > 0)
+ }
+}
- }
+// END Subform filtering
- }
+function nuSortSubform (sfName, c, e) {
+ if (!e.target.classList.contains('nuSubformTitle')) return
- return i;
+ const sf = []
+ const obj = nuSubformObject(sfName)
+ const so = obj.fields[c]
+ const count = obj.rows.length
+ let h = 0
+ let t = false
+ const objSf = $('#' + sfName)
+ const noAdd = objSf.attr('data-nu-add') == '0'
-}
+ const records = $("[ID^='" + sfName + "'][ID$='nuRECORD']")
+ const newRecord = records.last()
+ const newRecordId = newRecord.attr('id')
-function nuHighlightSearch() {
+ records.each(function (index) {
+ const id = this.id
- var bc = window.nuFORM.getCurrent();
+ if (id !== newRecordId) { // exclude new record
+ const f = this.id.replaceAll('nuRECORD', '')
+ h = parseInt($(this).css('height'), 10)
- if (bc.search === undefined) return;
- if (bc.search.length == 0) return;
+ const objF = $('#' + f + so)
+ t = objF.hasClass('input_number') || objF.hasClass('input_nuNumber') || objF.hasClass('nuCalculator')
+ let v = objF.val()
+ const m = objF.attr('data-nu-format')
+ const l = objF.hasClass('nuHiddenLookup')
- var exclude = bc.nosearch_columns;
+ if (m != '') {
+ v = nuFORM.removeFormatting(v, m)
+ }
- var search = String(bc.search)
- .split(' ')
- .filter(function (a) { return (a != '' && a.substr(0, 1) != '-') })
- .sort(function (a, b) { return (a.length > b.length) });
+ if (l) {
+ v = $('#' + f + so + 'code').val()
+ }
- $('.nuBrowseTable').each(function (index) {
+ const o = { form: id, value: v }
+ if (!(index == count && noAdd)) sf.push(o)
+ }
+ })
- var col = Number(String($(this).attr('data-nu-column')));
+ let rows
+ if ($(e.target).attr('data-nu-order') == 'asc') {
+ rows = t ? sf.sort(nuDecendingSortNumberColumn) : sf.sort(nuDecendingSortColumn)
+ $(e.target).attr('data-nu-order', 'desc')
+ } else {
+ rows = t ? sf.sort(nuAscendingSortNumberColumn) : sf.sort(nuAscendingSortColumn)
+ $(e.target).attr('data-nu-order', 'asc')
+ }
- if (exclude.indexOf(col) == -1) {
+ let top = 0
- for (var i = 0; i < search.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
+ $('#' + rows[i].form).css('top', top).data('nu-top-position', top) // save top position
+ top = top + h
+ }
- $(this).nuHighlight(search[i]);
+ newRecord.css('top', top).data('nu-top-position', top)
- }
+ if (objSf.data('nu-filtered') === true) {
+ objSf.find('.nuSubformFilter').first().change()
+ }
+}
+
+function nuRefreshSelectObject (selectId, formId, removeBlank) {
+ nuSubformRefreshSelectObject('', selectId, formId, removeBlank)
+}
+
+function nuSubformRefreshSelectObject (prefix, selectId, formId, removeBlank) {
+ formId = nuDefine(formId)
+
+ const p = 'NUREFRESHSELECTOBJECT'
+ nuSetProperty(p + '_prefix', prefix)
+ nuSetProperty(p + '_selectid', selectId)
+ nuSetProperty(p + '_formid', formId)
+ nuSetProperty(p + '_removeblank', removeBlank === true ? '1' : '0')
- }
+ nuRunPHPHidden(p, 0)
+}
- });
+function nuRefreshDisplayObject (displayId, formId) {
+ nuSubformRefreshDisplayObject('', displayId, formId)
+}
+function nuSubformRefreshDisplayObject (prefix, displayId, formId) {
+ formId = nuDefine(formId)
+
+ const p = 'NUREFRESHDISPLAYOBJECT'
+ nuSetProperty(p + '_prefix', prefix)
+ nuSetProperty(p + '_displayid', displayId)
+ nuSetProperty(p + '_formid', formId)
+
+ nuRunPHPHidden(p, 0)
}
-function nuChange(e) {
-
- if (e.target.id.substr(-8) == 'nuDelete') {
+function nuGetClipboardText (e) {
+ let cb
+ let clipText = ''
+ if (window.clipboardData && window.clipboardData.getData) {
+ cb = window.clipboardData
+ clipText = cb.getData('Text')
+ } else if (e.clipboardData && e.clipboardData.getData) {
+ cb = e.clipboardData
+ clipText = cb.getData('text/plain')
+ } else {
+ cb = e.originalEvent.clipboardData
+ clipText = cb.getData('text/plain')
+ }
+ return clipText
+}
- var sfid = $(e.target).parent().parent().parent()[0].id;
- var click = $('#' + sfid).attr('data-nu-clickdelete');
+function nuSubformUndoPaste (t) {
+ if (confirm(nuTranslate('Undo the last paste? (The values before the insertion will be restored)?'))) {
+ $('[data-prevalue]').each(function () {
+ const v = $(this).attr('data-prevalue')
+ $(this).val(v).change()
+ })
+ nuHide($(this).attr('id'))
+ }
+}
+
+function nuSubformPaste (e, jsonObj) {
+ const id = e.target.id
+
+ const sfId = $('#' + id).attr('data-nu-form')
+ const field = $('#' + id).attr('data-nu-field')
+ const dRow = parseInt($('#' + String(id)).attr('data-nu-prefix').slice(-3), 10)
- eval(click);
+ const obj = nuSubformObject(sfId)
+ const dColStart = obj.fields.indexOf(field)
- nuHasBeenEdited();
- nuCalculateForm();
+ const sNumRows = jsonObj.length
+ const sNumCols = Object.keys(jsonObj[0]).length
- return;
+ let sc = 0
+ for (let c = dColStart; c < (dColStart + sNumCols); c++) {
+ let sr = 0
+ for (let r = dRow; r < parseInt(dRow + sNumRows, 10); r++) {
+ const dest = $('#' + sfId + nuPad3(r) + obj.fields[c])
+ dest.attr('data-prevalue', dest.val())
+ dest.val(jsonObj[sr][sc]).change()
+ sr++
+ }
+ sc++
+ }
+}
- }
+function nuGetClipboardRows (clipText) {
+ const clipRows = clipText.split('\n')
+ for (let i = 0; i < clipRows.length; i++) {
+ clipRows[i] = clipRows[i].split('\t')
+ }
+ return clipRows
+}
- nuSetSaved(false);
+function nuGetClipboardJson (clipRows) {
+ const jsonObj = []
+ for (let i = 0; i < clipRows.length - 1; i++) {
+ const item = {}
+ for (let j = 0; j < clipRows[i].length; j++) {
+ if (clipRows[i][j] != '\r') {
+ item[j] = clipRows[i][j]
+ }
+ }
+ jsonObj.push(item)
+ }
+ return jsonObj
+}
- var t = $('#' + e.target.id)[0];
- var p = $('#' + t.id).attr('data-nu-prefix');
+function nuSubformEnableMultiPaste (subformId, selector, undoButton) {
+ $(selector).not('.nuReadonly').on('paste', function (e) {
+ const clipText = nuGetClipboardText(e)
- nuReformat(t);
+ if (clipText.indexOf('\t') >= 0 || clipText.indexOf('\n') >= 0) {
+ const clipRows = nuGetClipboardRows(clipText)
+ const jsonObj = nuGetClipboardJson(clipRows)
- $('#' + p + 'nuDelete').prop('checked', false);
- $('#' + t.id).addClass('nuEdited');
- nuHasBeenEdited();
+ e.stopPropagation()
+ e.preventDefault()
+
+ if (confirm(nuTranslate('Paste Data? Existing data might get overwritten'))) {
+ $('[data-nu-form="' + subformId + '"]').removeAttr('data-prevalue')
+ nuSubformPaste(e, jsonObj)
+
+ if (undoButton) {
+ nuShow(undoButton)
+ }
+
+ window.nuNEW = 0
+ }
+ }
+ })
+}
+
+function nuSubformHeaderToSeparatedString (fields, delimiter, includeId) {
+ const start = includeId == true ? 0 : 1
+ let h = ''
+
+ for (let i = start; i < fields.length - 1; i++) {
+ h += fields[i] + delimiter
+ }
+ return h + '\n'
+}
+
+function nuSubformRowToSeparatedString (rows, delimiter, includeId) {
+ const processRow = function (row, includeId) {
+ let finalVal = ''
+
+ const start = includeId == true ? 0 : 1
+ for (let j = start; j < row.length - 1; j++) {
+ let innerValue = row[j] === null ? '' : row[j].toString()
+ if (row[j] instanceof Date) {
+ innerValue = row[j].toLocaleString()
+ }
+ let result = innerValue.replace(/"/g, '""')
+ if (result.search(/("|,|\n)/g) >= 0) { result = '"' + result + '"' }
+ if (j > start) { finalVal += delimiter }
+ finalVal += result
+ }
+ return finalVal + '\n'
+ }
+
+ let output = ''
+
+ for (let i = 0; i < rows.length - 1; i++) {
+ output += processRow(rows[i], includeId)
+ }
+
+ return output
+}
+
+function nuCopyToClipboard (s) {
+ navigator.clipboard.writeText(s).then(function () {
+ return true
+ }, function () {
+ return false
+ })
+}
- $('#nuCalendar').remove();
- $('#' + t.id).removeClass('nuValidate');
- nuCalculateForm();
+/**
+ * Copy the data of a Subform to the Clipboard
+ *
+ * @param {string} i - Subform Object ID
+ * @param {string} delimiter - Delimiter for the data. Default: \t (tabulator)
+ * @param {bool} [includeHeader] - true to include the header (titles)
+ * @param {bool} [includeId] - true to include the Id (Primary Key)
+ *
+ */
- if (p == '') { return; }
+function nuSubformToClipboard (i, delimiter, includeHeader, includeId) {
+ const obj = nuSubformObject(i)
- nuAddSubformRow(t, e);
+ let s = ''
-}
+ if (!delimiter) {
+ delimiter = '\t'
+ }
-function nuChooseEventList() {
+ if (!includeId) {
+ includeId = false
+ }
- if ($('#sob_all_type').val() == 'subform') {
- return ['beforeinsertrow', 'afterinsertrow', 'clickdelete'];
- }
+ if (includeHeader === true) {
+ s = nuSubformHeaderToSeparatedString(obj.fields, delimiter, includeId)
+ }
- return ['onchange', 'oninput', 'onclick', 'onblur', 'onnuload', 'onfocus', 'onkeydown'];
+ s += nuSubformRowToSeparatedString(obj.rows, delimiter, includeId)
+ nuCopyToClipboard(s)
}
-function nuChangeFile(e) {
+function nuRecordHolderObject (t) {
+ const h = 'nuRECORD'
+ const p = $('#' + t.id).parent()
+ const i = String(p.attr('id'))
+ let c = 0
- if (e.target.id.substr(-8) == 'nuDelete') {
+ this.form = i.substr(0, i.length - 3 - h.length)
+ this.strNo = i.substr(this.form.length, 3)
+ this.intNo = Number(this.strNo)
- nuHasBeenEdited();
- return;
+ while ($('#' + this.form + nuPad3(this.intNo + c) + h).length != 0) { c++ }
- }
+ this.rows = this.intNo + c
+ this.top = (p.outerHeight() * this.rows)
+ let s = this.form + nuPad3(this.intNo + 1) + h
+ this.last = $('#' + s).length == 0
+ s = this.form + nuPad3(this.rows - 1)
+ this.html = window.nuSUBFORMROW[s]
+ this.even = parseInt(this.rows / 2, 10) == this.rows / 2 ? '0' : '1'
+}
- var theFile = e.target.id;
- var theTextarea = theFile.substr(0, theFile.length - 5);
+function nuAddSubformRow (t, e) {
+ if ($('#' + t.id).parent().parent().parent().attr('data-nu-add') == 0) { return }
- if ($('#' + theFile).val() == '') { return; }
+ const sfid = $('#' + t.id).parent().parent().parent()[0].id
+ const before = $('#' + sfid).attr('data-nu-beforeinsertrow')
+ const after = $('#' + sfid).attr('data-nu-afterinsertrow')
- var a = $('#' + theFile)[0].files[0];
- var r = new FileReader();
+ const nuCancel = false
- r.onload = function () {
+ eval(before)
- var f = btoa(r.result);
- var o = { 'file': f, 'name': a.name, 'size': a.size, 'type': a.type };
- var j = JSON.stringify(o);
+ if (nuCancel) { return }
- if (window.nuOnFileLoad) {
- if (nuOnFileLoad(theFile, o) === false) { return; }
- } else {
- if (j.length > 600000) {
+ if (e !== false) { e.stopPropagation() }
- nuMessage([nuTranslate('File is too large, cannot be saved. Must be under 300Kb')]);
- return;
+ const o = new nuRecordHolderObject(t)
- }
- }
+ if (!o.last) { return }
- $('#' + theTextarea).val(j).addClass('nuEdited');
+ const h = window.nuSUBFORMROW[o.form].nuReplaceAll('#nuSubformRowNumber#', o.form + nuPad3(o.rows), true)
- };
+ $('#' + o.form + 'scrollDiv').append(h)
- r.readAsDataURL(a);
+ $('#' + o.form + nuPad3(o.rows) + 'nuRECORD').addClass('nuSubform' + o.even).css('top', o.top)
+ $('#' + o.form + nuPad3(o.rows)).attr('data-nu-primary-key', '-1')
+ $('#' + o.form + nuPad3(o.rows) + 'nuDelete').prop('checked', true)
+ $('#' + o.form + nuPad3(o.rows - 1) + 'nuDelete').prop('checked', false)
- var t = $('#' + theFile)[0];
- var p = $('#' + theTextarea).attr('data-nu-prefix');
+ $("[id^='" + o.form + nuPad3(o.rows) + "']").removeClass('nuEdited')
- $('#' + p + 'nuDelete').prop('checked', false);
- $('#' + theTextarea).addClass('nuEdited');
+ const ts = $('.nuTabSelected')
+ ts.attr('nu-data-clicked-by-system', '')
+ ts.click()
- nuHasBeenEdited();
+ $('#' + o.form + nuPad3(o.rows) + 'nuRECORD > .nuLookupButton')
+ .on('click', function () {
+ nuBuildLookup(this, '')
+ })
- if (p == '') { return; }
+ // Copy Datalist from previous row
- nuAddSubformRow(t, e);
+ const objlist1 = $('#' + o.form + nuPad3(o.rows - 1) + 'nuRECORD').children().filter('[list]')
+ if (objlist1.length !== 0) {
+ const objlist2 = $('#' + o.form + nuPad3(o.rows) + 'nuRECORD').children().filter('[list]')
+ objlist2.each(function (i) {
+ $(this).attr('list', objlist1.eq(i).attr('list'))
+ })
+ }
-}
+ const objSelect = $('#' + o.form + nuPad3(o.rows) + 'nuRECORD > .select2-hidden-accessible')
-function nuCalculateForm(setAsEdited) { //-- calculate subform 'calcs' first
+ if (objSelect.length > 0) {
+ objSelect.each(function () {
+ const objSelect2 = $('#' + this.id + '_select2')
+ const pos = objSelect2.position()
+ const obj = {
+ width: objSelect2.width(),
+ top: pos.top,
+ left: pos.left
+ }
- if (window.nuEnableCalculation == false) return;
-
- var subformFirst = function (a, b) {
+ objSelect2.remove()
- var A = $('#' + a.id).hasClass('nuSubformObject') ? 0 : 1000;
- var B = $('#' + b.id).hasClass('nuSubformObject') ? 0 : 1000;
- a = parseInt($('#' + a.id).attr('data-nu-calc-order'), 10);
- b = parseInt($('#' + b.id).attr('data-nu-calc-order'), 10);
+ nuSetSelect2(this.id, obj)
+ })
+ }
- if (setAsEdited === undefined) {
- $('#' + a.id).addClass('nuEdited');
- }
+ eval(after)
+}
- return (a + A) - (b + B);
+function nuLabelGetValidationClass (validationId) {
+ const classMap = {
+ 0: 'nuNone',
+ 1: 'nuBlank',
+ 2: 'nuDuplicate',
+ 3: 'nuDuplicateOrBlank'
+ }
- }
+ return classMap[validationId]
+}
- var f = $("[data-nu-formula]");
+function nuLabel (w, i, p, prop) {
+ const obj = prop.objects[i]
+ if (obj.label == '' || obj.display == 0 || obj.label == 'Insert-Snippet') {
+ return
+ }
- f.sort(subformFirst);
+ const id = 'label_' + p + obj.id
+ const objLabel = document.createElement('label')
+ const label = nuTranslate(String(obj.label))
+ const lwidth = nuGetWordWidth(label, 'label')
- f.each(function (index) { //-- start with calculations inside a subform
+ objLabel.setAttribute('id', id)
- $(this).addClass('nuEdited');
+ const forId = obj.type == 'lookup' ? p + obj.id + 'code' : p + obj.id
+ objLabel.setAttribute('for', forId)
- var formula = $(this).attr('data-nu-formula');
- var fmt = $(this).attr('data-nu-format');
- var v = 0;
+ $('#' + p + 'nuRECORD').append(objLabel) // -- Edit Form Id
- if (formula != '') {
- eval('var v = ' + formula);
- }
+ nuAddDataTab(id, obj.tab, p)
- var fixed = nuFORM.addFormatting(v, fmt);
+ const $label = $('#' + id)
+ $label.css({
+ top: Number(obj.top),
+ left: Number(obj.left) - lwidth + -17,
+ width: Number(lwidth + 12)
+ })
+ .html(label)
- $(this).val(fixed);
+ if (nuGlobalAccess()) { $label.attr('ondblclick', 'nuOptionsListAction("nuobject", "' + obj.object_id + '")') }
- if (window.nuCalculated) {
- nuCalculated(this, v, fixed);
- }
+ if (label == ' ') {
+ label.innerHTML = ' '
+ }
- });
+ $label.addClass(nuLabelGetValidationClass(obj.valid))
+ return objLabel
}
-function nuHasBeenEdited() {
-
- $('.nuSaveButton').addClass('nuSaveButtonEdited');
- nuFORM.edited = true;
- nuSetSaved(false);
+function nuPopulateLookup3 (v, p) {
+ for (let i = 0; i < v.length; i++) {
+ const fieldname = String(v[i][0]).replace('#ROW#', p)
+ $('#' + fieldname).val(v[i][1])
+ }
}
-function nuHasNotBeenEdited() {
+function nuAddHolder (t) {
+ const d = document.createElement('div')
- $('.nuSaveButton').removeClass('nuSaveButtonEdited');
- nuFORM.edited = false;
- nuSetSaved(true);
+ d.setAttribute('id', t)
+ $('body').append(d)
+ $('#' + t).addClass(t)
}
-function nuDeleteAction() {
+function nuGetWordWidth (w, objClass) {
+ if (!objClass) {
+ objClass = 'nuSection'
+ }
- if (confirm(nuTranslate("Delete This Record?"))) {
-
- $('#nuDelete').prop('checked', true);
- nuUpdateData('delete');
-
- }
+ const W = 'nuTestWidth'
+ const h = '<' + 'div' + " id='" + W + "' style='position:absolute;visible:hidden;width:auto'>" + nuEscapeHTML(w) + '' + 'div' + '>'
+ $('body').append(h)
+ const obj = $('#' + W)
+ obj.addClass(objClass)
+ const l = parseInt(obj.css('width'), 10)
+ obj.remove()
+ return l + 5
}
-function nuDeleteAllAction() {
+function nuGetSubformRowSize (o, SF, id) {
+ let l = -3
+ let w = 0
- if (confirm(nuTranslate("Delete All Records?"))) {
+ for (let i = 0; i < o.length; i++) {
+ const descriptionWidth = Number(o[i].description_width)
+ const oType = o[i].type
- $('#nuDelete').prop('checked', true);
- nuUpdateData('delete', 'all');
+ const B = oType == 'lookup' ? 26 : 0 // -- lookup button
+ const D = oType == 'lookup' ? descriptionWidth : 0 // -- lookup description
- }
+ if (oType == 'select') {
+ w = Number(o[i].width) + B + D - 4
+ } else {
+ w = Number(o[i].width) + B + D
+ }
+ if (SF.subform_type == 'g') { // -- grid
+ nuBuildSubformTitle(o[i], l, w, id, i)
+ l = l + w + (o[i].read == 2 ? 0 : 6)
+ }
+ }
}
-function nuCloneAction() {
+function nuBuildSubformTitle (o, l, w, id, col) {
+ const titleId = 'title_' + id + o.id
+ const div = document.createElement('div')
+ let label = nuTranslate(o.label)
- nuSetProperty('CLONED_RECORD', 1);
- nuSetProperty('CLONED_RECORD_ID', nuRecordId());
+ if (o.read == 2) {
+ label = ''
+ }
- window.nuTimesSaved = 0;
+ div.setAttribute('id', titleId)
- $('[data-nu-primary-key]').each(function () {
+ $('#' + id).append(div)
- $(this).attr('data-nu-primary-key', '-1');
+ const oTitle = $('#' + titleId)
+ oTitle.css({
+ top: 0,
+ left: Number(l) + 9,
+ width: Number(w),
+ height: 50,
+ 'text-align': 'center',
+ position: 'absolute'
+ })
+ .html(label)
+ .attr('data-nu-field', o.id)
+ .attr('data-nu-subform', id)
+ .attr('data-nu-order', 'asc')
+ .addClass('nuTabHolder nuSubformTitle')
+ .addClass(o.input == 'number' || o.input == 'nuNumber' ? 'number' : 'text')
- });
+ oTitle.on('click', e => {
+ if (window.onSubformTitleClick) {
+ if (onSubformTitleClick(e.target.parentElement.id, e) !== false) {
+ nuSortSubform(id, col + 1, e)
+ }
+ } else {
+ nuSortSubform(id, col + 1, e)
+ }
+ })
- $('[data-nu-field]').each(function () {
+ if (nuGlobalAccess()) {
+ oTitle.on('dblclick', e => {
+ nuOptionsListAction('nuobject', o.object_id)
+ })
+ }
- $(this).addClass('nuEdited');
-
- });
-
- window.nuFORM.setProperty('record_id', -1);
+ if (o.valid == 1) { oTitle.addClass('nuBlank') }
+ if (o.valid == 2) { oTitle.addClass('nuDuplicate') }
+}
- $('#nuCloneButton').css('visibility', 'hidden');
- $('#nuDeleteButton').css('visibility', 'hidden');
+function nuBuildSubformDeleteTitle (l, id, subform_id) {
+ const titleId = id + 'DeleteSF'
+ const div = document.createElement('div')
- $('.nuSaveButton')
- .css('background-color', 'red')
- .css('visibility', 'visible');
+ div.setAttribute('id', titleId)
+
+ $('#' + id).append(div)
+
+ $('#' + titleId).css({
+ top: 0,
+ left: Number(l) - 12,
+ width: 52,
+ height: 50,
+ 'text-align': 'center',
+ 'font-size': 10,
+ padding: 0,
+ position: 'absolute'
+ })
+ .html('
Delete')
+ .addClass('nuTabHolder')
+ .attr('onclick', 'nuPopup("' + subform_id + '", "-2");')
+}
+
+function nuAddBreadcrumbs () {
+ const breadcrumbLength = window.nuFORM.breadcrumbs.length
+ const iStart = nuMainForm() ? 1 : 0
+
+ for (let i = iStart; i < breadcrumbLength; i++) {
+ nuAddBreadcrumb(i)
+ }
+}
+
+function nuGetTitleNew (bc, title = 'New') {
+ if (nuFormType() == 'edit' && bc.form_type != 'launch' && nuIsNewRecord()) {
+ const fId = bc.form_id
+ const breadcrumbLength = nuFORM.breadcrumbs.length
+ const pId = breadcrumbLength < 2 ? '' : nuFORM.breadcrumbs[breadcrumbLength - 2].form_id
+ return fId !== pId ? `${nuTranslate(bc.form_description)} (${title})` : title
+ }
+
+ return false
+}
+
+function nuAddBreadcrumb (i) {
+ const isLast = (i + 1 == window.nuFORM.breadcrumbs.length) // -- last breadcrumb
+ const bc = window.nuFORM.breadcrumbs[i]
+ const id = 'nuBreadcrumb' + i
+ const div = document.createElement('div')
+ const h = '
'
+
+ div.setAttribute('id', id)
+
+ $('#nuBreadcrumbHolder').append(div)
+ const $id = $('#' + id)
+
+ const title = bc.title
+
+ /* DEV
+ if (bc.form_code.startsWith('nu')) {
+ title = nuGetTitleNew('New') || title;
+ }
+ */
- nuCLONE = true;
- nuEmptyNoClone();
+ $id.css('font-size', 14)
+ .html(h + nuTranslate(title))
- var b = $('.nuBreadcrumb').length;
- var nb = $('.nuNotBreadcrumb').not('#nuLogout').length;
+ if (isLast) {
+ $id.addClass('nuNotBreadcrumb')
+ } else {
+ $id.addClass('nuBreadcrumb')
+ .attr('onclick', 'nuGetBreadcrumb(' + i + ')')
+ }
- var bc = b == 0 && nb == 0 ? $('#nuHomeGap') : $('#nuBreadcrumb' + b);
- bc.append(' ' + nuTranslate('Cloning') + ' ');
+ if (i == 0) {
+ $('#nuarrow0').remove()
+ }
+}
- if (window.nuOnClone) {
- nuOnClone();
- }
+function nuMainForm () {
+ if (opener) {
+ try {
+ return nuDocumentID == opener.nuDocumentID
+ } catch (error) {
+ return false
+ }
+ }
+ return nuDocumentID == parent.nuDocumentID
}
-function nuEmptyNoClone() {
+function nuSetBrowseTitle (title) {
+ nuSetTitle(title, true)
+}
- var c = nuSERVERRESPONSE.noclone;
+function nuSetTitle (title, browse) {
+ if (nuFormType() == 'browse' && !browse == true) {
+ return
+ }
- if (c === null) return;
+ title = nuEscapeHTML(title)
- for (var i = 0; i < c.length; i++) {
+ nuFORM.setProperty('title', title)
- if (c[i].subform) {
+ const $breadcrumb = $('.nuBreadcrumb')
+ const $notBreadcrumb = $('.nuNotBreadcrumb')
- $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform1').remove();
- $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform0').each(function () {
+ if ($breadcrumb.length === 0 && !nuIsIframe()) {
+ if ($notBreadcrumb.length > 0) {
+ $notBreadcrumb.html(title)
+ } else {
+ $('#nuHomeGap').append(title)
+ }
+ } else {
+ const bc = $breadcrumb.length + $notBreadcrumb.length - 1
+ const h = '
'
- if ($(this)[0].id != c[i].id + '000nuRECORD') {
- $(this).remove();
- }
+ $('#nuBreadcrumb' + bc).html(h + title)
+ }
+}
- });
+function nuAddEditTabs (p, w) {
+ if (nuFormType() == 'edit') {
+ nuSetStartingTab(p, w)
+ }
- var k = $('#' + c[i].id + '000nuRECORD').children();
+ for (let i = 0; i < w.tabs.length; i++) {
+ nuEditTab(p, w.tabs[i], i)
+ }
- for (var s = 0; s < k.length; s++) {
+ let l = 7
- if ($('#' + k[s].id).hasClass('nuEdited')) {
+ for (let i = 0; i < w.browse_columns.length; i++) {
+ l = nuBrowseTitle(w.browse_columns, i, l, w.browse_title_multiline)
- $('#' + k[s].id).val('');
+ if (w.browse_columns[i].width != '0') {
+ p = i
+ }
+ }
- if ($('#' + k[s].id + 'button').length == 1) {
+ const f = nuFORM.getProperty('nosearch_columns')
- $('#' + k[s].id + 'code').val('');
- $('#' + k[s].id + 'description').val('');
+ for (let i = 0; i < f.length; i++) {
+ $('#nusort_' + f[i]).addClass('nuNoSearch')
+ }
- }
+ window.nuBrowseWidth = l
- }
+ nuDetach()
- }
+ if (w.browse_columns.length > 0) {
+ nuBrowseTable()
+ nuOptions('nuBrowseTitle' + p, w.form_id, 'browse', w.global_access)
+ }
+}
- $('#' + c[i].id + '000nuDelete').prop('checked', true);
- $('#' + c[i].id + '001nuRECORD').remove();
+function nuSetStartingTab (p, w) {
+ const t = window.nuFORM.getProperty('tab_start')
- } else {
+ if (w.tabs.length == 0) {
+ nuFORMHELP[p] = ''
+ return
+ }
- if ($('#' + c[i].id).length == 1) {
- $('#' + c[i].id).val('').change();
- }
+ nuFORMHELP[p] = nuTABHELP[w.tabs[0].id]
- }
+ for (let i = 0; i < t.length; i++) {
+ nuFORMHELP[p] = nuTABHELP[w.tabs[0].id]
- }
+ if (t[i].prefix == p) { return }
+ }
+ t.push(new nuStartingTab(p))
}
-function nuIsClone() {
- return nuCLONE;
-}
+function nuGetStartingTab () {
+ const w = nuRecordId() == -2 ? parent.window : window
+ const t = w.nuFORM.getProperty('tab_start')
-function nuIsNewRecord() {
- return nuRecordId() == -1 && !nuCLONE;
-}
+ for (let i = 0; i < t.length; i++) {
+ const ts = $('#' + t[i].prefix + 'nuTab' + t[i].tabNumber)
+ ts.addClass('nuTabSelected')
+ ts.attr('nu-data-clicked-by-system', '')
-function nuSaveAction(close) {
+ ts.click()
+ }
+}
- if (nuCurrentProperties().form_type == 'launch' || nuLookingUp()) return;
+function nuSetTab (pthis) {
+ const t = window.nuFORM.getProperty('tab_start')
- if (nuNoDuplicates()) {
+ for (let i = 0; i < t.length; i++) {
+ if (t[i].prefix == $('#' + pthis.id).attr('data-nu-form-filter')) {
+ const ts = $('#' + t[i].prefix + 'nuTab' + t[i].tabNumber)
- nuSaveScrollPositions();
- nuUpdateData('save', close ? 'close' : null);
+ ts.addClass('nuTabSelected')
+ ts.attr('nu-data-clicked-by-system')
- }
+ ts.click()
+ }
+ }
+}
+function nuStartingTab (p) {
+ this.prefix = p
+ this.tabNumber = 0
}
-function nuSavingProgressMessage() {
+function nuEditTab (p, t, i) {
+ const tabId = p + 'nuTab' + i
+ const div = document.createElement('div')
+ div.setAttribute('id', tabId)
- var e = document.createElement('div');
+ $('#' + p + 'nuTabHolder').append(div)
+ $('#' + tabId)
+ .html(nuTranslate(t.title))
+ .addClass('nuTab')
+ .addClass('nuDragNoSelect')
+ .attr('data-nu-tab-filter', i)
+ .attr('data-nu-form-filter', p)
+ .attr('data-nu-tab-id', t.id)
+ .attr('onclick', 'nuSelectTab(this, true)')
- e.setAttribute('id', 'nuProgressUpdate');
+ if (t.access !== undefined) {
+ if (t.access == '2') nuHide('nuTab' + i)
+ if (t.access == '3') {
+ if (!nuGlobalAccess()) {
+ nuHide('nuTab' + i)
+ } else {
+ $('#' + 'nuTab' + i).addClass('nuTabAccessHiddenUser')
+ }
+ }
+ }
+
+ window.nuTABHELP[t.id] = t.help
+}
+
+function nuOptions (p, f, t, access) {
+ const R = nuRecordId()
- $('#nuActionHolder').append(e);
- $('#' + e.id).html('');
- $('#' + e.id).addClass('nuUpdateMessageProgress');
- $('#' + e.id).css('position', 'absolute');
- $('#' + e.id).css('left', (($('#nuActionHolder').width() / 2) - ($('#nuProgressUpdate').width() / 2)) + 'px');
- $('#' + e.id).show();
+ if (R != '-2') {
+ const id = p + 'nuOptions'
+ const img = document.createElement('l')
+
+ img.setAttribute('id', id)
- $('.nuActionButton').hide();
+ if (t == 'subform') {
+ if (nuAllowChanges(f) && nuGlobalAccess()) {
+ $('#' + p).prepend(img)
+
+ $('#' + id)
+ .attr('title', nuTranslate('Options'))
+ .attr('onclick', 'nuGetOptionsList("' + f + '", this, "' + p + '", "' + access + '", "' + t + '")')
+ .addClass('nuIcon nuOptionsSubform')
+ }
+ } else {
+ $('#nuBreadcrumbHolder').prepend('').prepend(img)
+
+ $('#' + id)
+ .attr('title', 'Options')
+ .attr('onclick', 'nuGetOptionsList("' + f + '", this, "' + p + '", "' + access + '", "' + t + '")')
+ .addClass('nuIcon nuOptions')
+ }
+ }
+}
+
+function nuAllowChanges (f) {
+ return nuSERVERRESPONSE.form_access == 0 || String(f).substr(0, 2) != 'nu' || f == 'nuuserhome'
+}
+
+function nuHideOptionsItemShortcutKeys () {
+ $('.nuOptionsItemShortcutKey').css('visibility', 'hidden')
+}
+
+function nuGetOptionsList (f, t, p, a, type) {
+ // f: form ID
+ // a: global_access
+
+ const id = 'nuOptionsListBox'
+ if ($('#' + id).length !== 0) {
+ $('#nuOptionsListBox').remove()
+ return
+ }
+
+ const list = []
+
+ const buttons = nuSERVERRESPONSE.buttons
+ const objects = nuSERVERRESPONSE.objects
+ const canChange = nuAllowChanges(f)
+ const admin = a == 1
+
+ const hasHelp = nuFORMHELP[p] != '' && nuFORMHELP[p] !== undefined && type != 'subform'
+ const formType = nuFormType()[0]
+ const typeEdit = formType == 'e'
+ const typeBrowse = formType == 'b'
+ const typeSf = type == 'subform'
+
+ const typeLaunch = nuFORM.getCurrent().form_type != 'launch'
+ const labelId = '#label_' + $('#' + p + 'scrollDiv').parent().attr('id')
+
+ const items = {
+ Divider: ['', '', '', ''],
+ AddObject: ['Add Object', 'nuPopup("nuobject","-1","")', 'fa fa-plus', 'H'],
+ ArrangeObjects: ['Arrange Objects', 'nuPopup("' + f + '", "-2")', 'fas fa-arrows-alt', 'A'],
+ FormProperties: ['Form Properties', 'nuOptionsListAction("nuform", "' + f + '")', 'fa-cog', 'F'],
+ SearchableColumns: ['Searchable Columns', 'nuGetSearchList()', 'fa-columns', 'C'],
+ SubformObject: [nuTranslate('Subform Object'), '$("' + labelId + '").dblclick()', 'fa-cog', ''],
+ FormObjectList: ['Form Object List', 'nuOptionsListAction("nuobject", "", "' + f + '")', 'fa-th-list', 'O'],
+ Search: ['Search', 'nuSearchAction();', 'fas fa-search', 'S'],
+ Add: ['Add', 'nuAddAction();', 'fas fa-plus', 'A'],
+ Print: ['Print', 'nuPrintAction();', 'fas fa-print', 'P'],
+ Save: ['Save', 'nuSaveAction();', 'far fa-save', 'S'],
+ Delete: ['Delete', 'nuDeleteAction();', 'far fa-trash-alt', 'Y'],
+ Clone: ['Clone', 'nuCloneAction();', 'far fa-clone', 'C'],
+ Refresh: ['Refresh', 'if (nuGlobalAccess()) {nuRunPHPHidden("NUSETREFRESHCACHE", 0);} else {nuGetBreadcrumb();}', 'fas fa-sync-alt', 'R'],
+ Help: ['Help', nuFORMHELP[p], 'fa-question-circle', '?'],
+ ChangePassword: ['Change Password', 'nuPopup("nupassword", "", "")', 'fa-password', 'Q'],
+ DebugResults: ['nuDebug Results', 'nuOptionsListAction("nudebug", "")', 'fa-bug', 'D'],
+ Database: ['Database', 'nuVendorLogin("PMA")', 'fa-database', 'E'],
+ Sessions: ['Sessions', 'nuForm("nusession","","", "", 2)', 'fas fa-key', 'I'],
+ FileManager: ['File Manager', 'nuVendorLogin("TFM");', 'far fa-file-code', 'Q'],
+ Backup: ['Backup', 'nuRunBackup();', 'far fa-hdd', 'B'],
+ Setup: ['Setup', 'nuForm("nusetup","1","", "", 2)', 'fa-cogs', 'U'],
+ FormInfo: ['Form Info', 'nuShowFormInfo();', 'fa-info', 'M'],
+ Logout: ['Log out', 'nuAskLogout();', 'fas fa-sign-out-alt', 'L']
+ }
+
+ if (typeEdit && admin && canChange) {
+ if (objects.length > 0) {
+ list.push(items.ArrangeObjects)
+ }
+ if (!typeSf) {
+ list.push(items.AddObject)
+ list.push(items.Divider)
+ }
+ }
+
+ if (typeBrowse) list.push(items.SearchableColumns)
+ if (admin && canChange) list.push(items.FormProperties)
+
+ if (typeSf && canChange) {
+ list.push(items.SubformObject)
+ }
+
+ if (admin && canChange) list.push(items.FormObjectList)
+
+ if (!typeSf && admin) list.push(items.Divider)
+
+ if (typeBrowse) {
+ list.push(items.Search)
+ if (buttons.Add == '1') { list.push(items.Add) }
+ if (buttons.Print == '1' && nuFORM.getCurrent().browse_rows.length > 0) { list.push(items.Print) }
+ }
+
+ if (typeLaunch && typeEdit && type != 'subform') {
+ const data_mode = nuFORM.getCurrent().data_mode
+ if (buttons.Save == '1' && data_mode !== 0) { list.push(items.Save) }
+ if (buttons.Delete == '1' && !nuIsNewRecord()) { list.push(items.Delete) }
+ if (buttons.Clone == '1' && !nuIsNewRecord()) { list.push(items.Clone) }
+ }
+
+ if (hasHelp) {
+ list.push(items.Help)
+ }
+
+ if (!typeSf) {
+ list.push(items.Refresh)
+ if (admin) list.push(items.Divider)
+ }
+
+ if (!admin) {
+ list.push(items.Divider)
+ list.push(items.ChangePassword)
+ }
+
+ if (admin && !typeSf) {
+ list.push(items.DebugResults)
+ list.push(items.Divider)
+ list.push(items.Database)
+ list.push(items.Sessions)
+ list.push(items.FileManager)
+ list.push(items.Backup)
+ list.push(items.Setup)
+ list.push(items.FormInfo)
+ }
+
+ if (!typeSf && nuIsMobile()) {
+ list.push(items.Divider)
+ list.push(items.Logout)
+ }
+
+ if (list.length == 0) { return }
+
+ const div = document.createElement('div')
+ div.setAttribute('id', id)
+ $('body').append(div)
+
+ $('#' + id)
+ .css({
+ top: 0,
+ height: 20 + (list.length * 20),
+ width: 30
+ })
+ .html(' ' + nuTranslate('Options') + '<\span>')
+ .addClass('nuOptionsList')
+
+ nuBuildOptionsList(list, p, type)
+
+ if (nuIsMobile()) nuHideOptionsItemShortcutKeys()
+ $('[data-nu-option-title]').css('padding', 3)
+ nuDragElement($('#nuOptionsListBox')[0], 30)
+}
+
+function nuBuildOptionsList (l, p, type) { // -- loop through adding options to menu
+ const iprop = { position: 'absolute', 'text-align': 'left', width: 15, height: 15 }
+ let width = 0
+
+ for (let i = 0; i < l.length; i++) {
+ if (l[i][0] != '') l[i][0] = nuTranslate(l[i][0]) // Text
+ l[i][3] = nuCtrlCmdShiftName(l[i][3]) // Shortcut
+ }
+
+ for (let i = 0; i < l.length; i++) {
+ width = Math.max((nuGetWordWidth(l[i][0]) + nuGetWordWidth(l[i][3])), width)
+ }
+
+ for (let i = 0; i < l.length; i++) {
+ const t = l[i][0] // Text
+ const f = l[i][1] // onclick
+ const c = l[i][2] // Icon
+ const k = l[i][3] // Shortcut
+ const itemtop = 30 + (i * 20)
+
+ // Add Icon
+
+ const icon = document.createElement('i')
+ const icon_id = 'nuOptionList' + i.toString()
+
+ icon.setAttribute('id', icon_id)
+
+ $('#nuOptionsListBox').append(icon)
+
+ $('#' + icon.id)
+ .css(iprop)
+ .css({ top: itemtop, left: 9 })
+ .addClass('fa')
+ .addClass(c)
+ .addClass('nuOptionList')
+
+ // Add Option Text
+
+ const isDivider = t == ''
+
+ const desc = document.createElement(isDivider ? 'hr' : 'div')
+ const desc_id = 'nuOptionText' + i.toString()
+
+ desc.setAttribute('id', desc_id)
-}
+ $('#nuOptionsListBox').append(desc)
+ let style = { position: 'absolute', 'text-align': 'left', height: (isDivider ? 0 : 15) }
-function nuUpdateMessage(msg) {
+ if (isDivider) {
+ $('#' + desc.id)
+ .css(style)
+ .css({ top: itemtop - 4, left: 30 })
+ .html(t)
+ .attr('onclick', f)
+ .addClass('nuOptionsItem-divider')
+ } else {
+ $('#' + desc.id)
+ .css(style)
+ .css({ top: itemtop - 4, left: 30 })
+ .html(t)
+ .attr('onclick', f)
+ .attr('data-nu-option-title', t)
+ .addClass('nuOptionsItem')
+ }
- $("#nuProgressUpdate").hide();
+ // Add ahortcut
+ if (k !== '') {
+ const shortcut_key = document.createElement('div')
+ const shortcut_key_id = 'nuOptionTextShortcutKey' + i.toString()
- var e = document.createElement('div');
+ shortcut_key.setAttribute('id', shortcut_key_id)
- e.setAttribute('id', 'nuNowUpdated');
+ if (type !== 'subform') {
+ $('#nuOptionsListBox').append(shortcut_key)
+ }
- $('#nuActionHolder').append(e);
- $('#' + e.id).html(nuTranslate(msg));
- $('#' + e.id).addClass('nuUpdateMessage');
- $('#' + e.id).css('position', 'absolute');
- $('#' + e.id).css('left', (($('#nuActionHolder').width() / 2) - ($('#nuNowUpdated').width() / 2)) + 'px');
- $("#nuNowUpdated").fadeToggle(3000);
+ style = { position: 'absolute', 'text-align': 'left', height: 15, width: 50 }
- $('.nuActionButton').show();
+ $('#' + shortcut_key.id)
+ .css(style)
+ .css({ top: itemtop - 2, right: 10 })
+ .html(k)
+ .attr('onclick', f)
+ .addClass('nuOptionsItemShortcutKey')
+ }
+ }
-}
+ const off = $('#' + p + 'nuOptions').offset()
+ let top = off.top
+ let left = off.left
+ let reduce = 0
-function nuAbortSave() {
+ if (type == 'browse') {
+ left = 12
+ }
+
+ if (type == 'form') {
+ top = off.top - 6
+ left = 10
+ }
+
+ if (type == 'subform') {
+ top = off.top - 70
+ left = off.left
+ reduce = 55
+ }
- $("#nuProgressUpdate").hide();
- $('.nuActionButton').show();
+ $('#nuOptionsListBox').css({
+ height: 40 + (l.length * 20),
+ width: 50 + width - reduce,
+ left,
+ top: top + 70
+ })
+ $('.nuOptionsItem').css({ width: width - 57, padding: '0px 0px 0px 3px' })
+ $('.nuOptionsItem-divider').css({ width: 35 + width - reduce - 7, left: 0 })
}
-function nuSetSaved(v) {
+function nuSelectAllTabs (pthis) {
+ const t = pthis.value
- if (window.nuOnSetSaved) {
- nuOnSetSaved(v);
- }
+ window.nuRESPONSIVE.setTabsColumn(t)
- window.nuSAVED = v;
+ if (t != '') {
+ nuSelectTab($('#' + t)[0])
+ }
}
-function nuFormsUnsaved() {
+function nuSelectTab (tab, byUser) {
+ if (window.nuOnSelectTab) {
+ if (nuOnSelectTab(tab) == false) return
+ }
- let c = 0;
- $.each($('iframe'), function () {
- let t = $(this)[0];
+ if (byUser === undefined) byUser = false
- try {
- if (typeof t.contentWindow.nuIsSaved === 'function') {
- if (!t.contentWindow.nuIsSaved()) {
- c++;
- }
- }
- } catch (e) {
- // catch "DOMException: Blocked a frame with origin"
- }
- })
+ const $tabId = $('#' + tab.id)
- if (!nuIsSaved()) c++;
- return c;
+ byUser = !!(byUser === true && !$tabId.is('[nu-data-clicked-by-system]'))
-}
+ if (byUser) nuSaveScrollPositions()
-function nuAddJavaScript(js) {
+ $tabId.removeAttr('nu-data-clicked-by-system')
- var s = document.createElement('script');
- s.innerHTML = "\n\n" + js + "\n\n";
+ $('.nuTabTitleColumn').remove()
- $('body').append(s);
+ const filt = $tabId.attr('data-nu-tab-filter')
+ const form = $tabId.attr('data-nu-form-filter')
+ const tabId = $tabId.attr('data-nu-tab-id')
+
+ window.nuFORMHELP[form] = window.nuTABHELP[tabId]
-}
+ const t = nuFORM.getProperty('tab_start')
-function nuAddFormStyle(style) {
+ for (let i = 0; i < t.length; i++) {
+ if (t[i].prefix == form) {
+ t[i].tabNumber = filt
+ }
+ }
- if (style !== '') {
- style = style.replace(/((';
- $('#nuRECORD').append(span);
- }
+ // Treating nuIframes and nuHtml differently as anything that needs to calculate size can't be display: none when the page loads
+ $("[data-nu-form='" + form + "']:not('.nuIframe, .nuHtml')").hide()
+ $(".nuIframe[data-nu-form='" + form + "']").css('visibility', 'hidden')
+ $(".nuHtml[data-nu-form='" + form + "']").css('visibility', 'hidden')
+ $("[data-nu-form-filter='" + form + "']").removeClass('nuTabSelected')
-}
+ $("[data-nu-form='" + form + "'][data-nu-tab='" + filt + "']:not([data-nu-lookup-id]):not('.nuIframe, .nuHtml')").show()
+ $(".nuIframe[data-nu-form='" + form + "'][data-nu-tab='" + filt + "']").css('visibility', 'visible')
+ $(".nuHtml[data-nu-form='" + form + "'][data-nu-tab='" + filt + "']").css('visibility', 'visible')
+ $('#' + tab.id).addClass('nuTabSelected')
-function nuHashFromEditForm() {
+ if (byUser) nuRestoreScrollPositions()
- var A = {};
- var S = nuSubformObject('');
- var B = nuFORM.getCurrent();
+ if (byUser === true) {
+ const s = $('.nuTabSelected')
+ let obj = null
+ const ae = document.activeElement
- if (S.rows.length == 0) { return A; }
+ if (s.is('[nu-data-active-element]')) {
+ const id = s.attr('nu-data-active-element')
+ if (id !== '' && ae.id !== id) $('#' + id).nuFocusWithoutScrolling()
+ } else {
+ obj = nuGetFirstObject(nuSERVERRESPONSE.objects, tab.id.replace('nuTab', ''))
+ if (obj !== null && ae.id !== obj.attr('id')) {
+ obj.nuFocusWithoutScrolling()
+ try {
+ if ((obj.is('textarea') || obj.is('input')) && !obj.is(':checkbox')) {
+ obj.prop({ selectionStart: 0, selectionEnd: 0 })
+ }
+ } catch (e) {
+ console.log('Failed to set selectionStart', obj)
+ }
+ }
+ }
+ }
- for (var key in B) {
- A[key] = B[key];
- }
+ if (window.nuOnTabSelected) {
+ nuOnTabSelected(tab)
+ }
+}
- for (var i = 0; i < S.fields.length; i++) {
- A[S.fields[i]] = S.rows[0][i];
- }
+function nuSelectTabByTitle (s) {
+ const tabs = JSON.parse(JSON.stringify(nuSERVERRESPONSE)).tabs
+ const l = tabs.findIndex(data => data.title.replace(/\|/g, '') === s)
+ if (l > -1) nuSelectTab($('#' + 'nuTab' + l)[0])
+}
+
+function nuRemoveTabs (t) {
+ for (let i = 0; i < arguments.length; i++) {
+ $('#nuTab' + arguments[i]).remove()
+ }
+}
- return A;
+function nuHideTabByTitle (s) {
+ nuShowTabByTitle(s, false)
+}
+function nuShowTabByTitle (s, visible) {
+ const tabs = JSON.parse(JSON.stringify(nuSERVERRESPONSE)).tabs
+ const l = tabs.findIndex(data => data.title.replace(/\|/g, '') === s)
+ if (l > -1) nuShow('nuTab' + l, visible)
}
-function nuDetach() {
+function nuShowTabById (id, visible) {
+ const obj = $('div#' + id)
+ if (obj.length == 1) {
+ obj.nuShow(visible)
+ } else {
+ $('div[data-nu-tab-id=' + id + ']').filter('.nuTab').nuShow(visible)
+ }
+}
- $('.nuDragLineV').each(function () {
- $(this).appendTo('body')
+function nuHideTabById (id) {
+ nuShowTabById(id, false)
+}
- });
+function nuHideTabs () {
+ for (let i = 0; i < arguments.length; i++) {
+ if (arguments[i] === parseInt(arguments[i], 10)) {
+ $('#nuTab' + arguments[i]).hide()
+ } else {
+ nuHideTabByTitle(arguments[i])
+ }
+ }
+}
+function nuAddDataTab (i, t, p) {
+ const P = String(p)
+ const f = P.substr(0, P.length - 3)
+ $('#' + i).attr('data-nu-tab', t).attr('data-nu-form', f)
}
-function nuSearchableList() {
+function nuBrowseTitle (b, i, l, m) {
+ const bc = window.nuFORM.getCurrent()
+ const un = bc.nosearch_columns.indexOf(i)
+ const id = 'nuBrowseTitle' + i
+ const w = Number(b[i].width)
+ const a = b[i].align
+ const div = document.createElement('div')
+ const ar = { l: 'left', c: 'center', r: 'right' }
- const bc = window.nuFORM.getCurrent();
- const col = bc.browse_columns;
- const no = bc.nosearch_columns;
- var div = document.createElement('div');
+ div.setAttribute('id', id)
- div.setAttribute('id', 'nuSearchableDialog');
+ let sp = ' ' + nuTranslate(b[i].title) + ' '
- $('body').append(div);
+ if (bc.sort == i) {
+ if (a == 'l') {
+ if (bc.sort_direction == 'asc') {
+ sp = ' ' + nuTranslate(b[i].title) + ' '
+ } else {
+ sp = ' ' + nuTranslate(b[i].title) + ' '
+ }
+ } else {
+ if (bc.sort_direction == 'asc') {
+ sp = ' ' + nuTranslate(b[i].title) + ' '
+ } else {
+ sp = ' ' + nuTranslate(b[i].title) + ' '
+ }
+ }
+ }
- $('#nuSearchableDialog')
- .addClass('nuSearchableDialog')
- .css('width', 150)
- .css('height', 30 + (col.length * 20))
- .css('top', 10)
- .css('left', 10);
+ $('#nuRECORD').append(div)
- for (let i = 0; i < col.length; i++) {
+ const titleClass = m == '1' ? 'nuBrowseTitleMultiline nuBrowseTitle' : 'nuBrowseTitle'
- var input = document.createElement('input');
- const search = no.indexOf(i) == -1 ? false : true;
+ const obj = $('#' + id)
- input.setAttribute('id', 'nuSearchableCheckbox' + i);
+ obj
+ .html(sp)
+ .addClass(titleClass)
+ .css({
+ 'text-align': ar[a],
+ overflow: 'visible',
+ width: w,
+ left: l
+ })
- $('#nuSearchableDialog').append(input);
+ obj.attr('data-nu-title-id', b[i].id)
- $('#' + 'nuSearchableCheckbox' + i)
- .append(input)
- .addClass('nuSearchableDialog')
- .css('left', 5)
- .css('height', 25)
- .css('top', 10 + (i * 27))
- .checked = search;
+ if (w == 0) {
+ obj.hide()
+ }
- if (search) {
- $('#' + 'nuSearchableCheckbox' + i)
- .addClass('nuNoSearch');
- }
+ // $('#nusort_' + i)[0].addEventListener('touchstart', function(event) { nuSortBrowse(i);}, { passive: true });
- var span = document.createElement('span');
+ $('#nusearch_' + i).attr('checked', un == -1)
- span.setAttribute('id', 'nuSearchableTitle' + i);
+ return l + nuTotalWidth(id)
+}
- $('#nuSearchableDialog').append(input);
+function nuTitleDrag (i) {
+ const bc = window.nuFORM.getCurrent()
+ const h = bc.row_height
+ const div = document.createElement('div')
- $('#' + 'nuSearchableTitle' + i)
- .append(span)
- .addClass('nuSearchableDialog')
- .css('width', 25)
- .css('left', 25)
- .css('height', 25)
- .css('top', 10 + (i * 20))
- .html(col[i].title);
+ div.setAttribute('id', 'nuTitleDrag' + i)
- }
+ $('#' + 'nuBrowseTitle' + i).append(div)
+ $('#' + div.id)
+ .addClass('nuDragLineV')
+ .css('height', h)
+ .attr('onmousedown', 'nuDragBrowseDown(event)')
+ .attr('onmousemove', 'nuDragBrowseMove(event)')
+ .attr('onmouseup', 'nuDragBrowseUp(event)')
}
-function nuWidestTitle(c) {
+function nuDragBrowseDown (e) {
+ const t = parseInt($('#nuBrowseTitle0').css('top'), 10)
+ const f = parseInt($('#nuBrowseFooter').css('top'), 10)
- var w = 120;
+ window.nuDRAGLINEVSTART = e.pageX
+ window.nuDRAGLINEVID = e.target.id
- for (let i = 0; i < c.length; i++) {
+ $('#' + e.target.id).css('height', f - t)
+}
- const t = String(c[i].title).replaceAll('
', ' ').replaceAll('', ' ');
- w = Math.max(nuGetWordWidth(t), w);
+function nuDragBrowseMove (e) {
+ if (window.nuDRAGLINEVID == '' || e.buttons != 1) { return }
- }
+ $('#' + nuDRAGLINEVID).css('left', e.x)
+}
- return w + 70;
+function nuDragBrowseUp (e) {
+ const h = parseInt($('#nuBrowseTitle0').css('height'), 10)
+ $('#' + e.target.id).css('height', h)
+ window.nuDRAGLINEVID = ''
}
-function nuGetSearchList() {
+function nuBrowseColumnSize (e) {
+ $('#' + e.target.id).css('height', 400)
+}
- var c = nuFORM.getProperty('browse_columns');
- var d = document.createElement('div');
+function nuResizeBrowseColumns (force) {
+ const w = nuArrayColumn(nuSERVERRESPONSE.browse_columns, 'width').map(Number)
+ let t = 0
+ const p = nuTotalWidth('nucell_0_0') - $('#nucell_0_0').width() // -- padding
- $('#nuOptionsListBox').remove();
+ if ((nuFORM.getCurrent().refreshed != 0 && force !== true) && nuMainForm()) { return }
- var widest = nuWidestTitle(c) + 20;
+ if (nuMainForm()) {
+ for (var i = 0; i < w.length; i++) {
+ t = t + w[i]
+ }
- d.setAttribute('id', 'nuSearchList');
+ for (var i = 0; i < w.length; i++) {
+ w[i] = parseInt((window.innerWidth - 30) * w[i] / t, 10) - p
+ }
+ } else {
+ const W = nuTotalWidth('nuBrowseFooter') + 22
- $('body').append(d);
+ $('#nuDragDialog', window.parent.document).css('width', W + 14)
+ $('#nuWindow', window.parent.document).css('width', W)
- $('#' + d.id).css({
- 'width': widest + 20,
- 'height': 10 + (c.length * 30),
- 'top': 138,
- 'left': (window.innerWidth - widest) < 0 ? 0 : 50,
- 'position': 'absolute',
- 'text-align': 'left'
- })
- .html(' ' + nuTranslate('Include When Searching') + '<\span>')
- .addClass('nuOptionsList');
+ $('body').css('width', W)
+ }
- for (var i = 0; i < c.length; i++) {
+ if (nuFORM.getCurrent().refreshed != 0 && force !== true) { return }
- var isChecked = true;
+ nuSetBrowseColumns(w)
+}
- if ($.inArray(i, nuFORM.getCurrent().nosearch_columns) != '-1') {
- isChecked = false;
- }
+function nuSetBrowseColumns (c) {
+ const p = nuTotalWidth('nucell_0_0') - $('#nucell_0_0').width() // -- padding
+ let l = 7
- var p = document.createElement('input');
+ for (let i = 0; i < c.length; i++) {
+ $('[data-nu-column="' + i + '"]').css({
+ left: l,
+ width: c[i]
+ })
+ $('#nuBrowseTitle' + i).css({
+ left: l,
+ width: c[i]
+ })
+ l = l + c[i] + (c[i] == 0 ? 0 : p)
+ }
- p.setAttribute('id', 'nuSearchList' + i);
- p.setAttribute('type', 'checkbox');
+ $('#nuBrowseFooter').css('width', l - 7)
- $('#' + d.id).append(p);
+ nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths = c
- $('#' + p.id).css({
- 'width': 20,
- 'height': 25,
- 'top': 30 + (i * 25),
- 'left': 5,
- 'position': 'absolute',
- 'text-align': 'left'
- })
- .prop('checked', isChecked)
- .attr('onclick', 'nuSetSearchColumn();')
- .addClass('nuSearchCheckbox');
+ if (nuCurrentProperties().browse_filtered_rows == 0) {
+ $('#nucell_0_0').css({
+ width: l - 22,
+ 'z-index': '2'
- var t = document.createElement('div');
- var nobr = String(c[i].title).nuReplaceAll('
', ' ').nuReplaceAll('', ' ');;
+ })
- t.setAttribute('id', 'nuSearchText' + i);
+ $("div[id^='nucell_']").not('#nucell_0_0').hide()
+ }
+}
- $('#' + d.id).append(t);
+function nuGetColumWidths () {
+ const a = []
- $('#' + t.id).css({
- 'height': 25,
- 'top': 33 + (i * 25),
- 'left': 40,
- 'position': 'absolute',
- 'text-align': 'left'
- })
- .attr('onclick', 'nuClickSearchColumn(event);')
- .addClass('nuOptionsItem')
- .html(nobr)
- .click(function () {
+ $("div[id^='nuBrowseTitle']").each(function (index) {
+ a.push(parseInt($(this).css('width'), 10))
+ })
- var cb = $('#nuSearchList' + i).attr('checked');
+ return a
+}
- $('#' + 'nuSearchList' + i).attr('checked', !cb);
+function nuDownBrowseResize (e, p) {
+ e.preventDefault()
- nuSetSearchColumn();
+ window.nuBROWSERESIZE.mouse_down = true
+ window.nuBROWSERESIZE.pointer = p
- });
+ const target = e.target.id.replace('nusort_', 'nuBrowseTitle')
- if (i < 9) {
+ window.nuBROWSERESIZE.moving_element = target
+ window.nuBROWSERESIZE.x_position = e.clientX
- var shortcut_key = document.createElement('div');
- var shortcut_key_id = 'nuSearchTextShortcutKey' + i.toString();
+ $('#' + target).addClass('nuBrowseResize')
+}
- shortcut_key.setAttribute('id', shortcut_key_id);
+function nuEndBrowseResize (e) {
+ window.nuBROWSERESIZE.mouse_down = false
+ window.nuBROWSERESIZE.moving_element = ''
+ $('.nuBrowseTitle').removeClass('nuBrowseResize')
+}
- $('#nuSearchList').append(shortcut_key);
+function nuDragBrowseColumn (e, p) {
+ if (e.target.id === '') return // not on ctxmenu
- var prop = { 'position': 'absolute', 'text-align': 'left', 'height': 15, 'width': 50 };
+ e.preventDefault()
- $('#' + shortcut_key.id)
- .css(prop)
- .css({ 'top': 37 + (i * 25), 'right': 10 })
- .html(nuCtrlCmdShiftName(i+1))
- .addClass('nuOptionsItemShortcutKey');
+ if (window.nuBROWSERESIZE.mouse_down) {
+ window.nuBROWSERESIZE.pointer = p // added
+ const id = window.nuBROWSERESIZE.moving_element
+ const offset_limit = 100000000
+ const min_offset = 2
+ let x = e.pageX
- }
+ if (window.nuBROWSERESIZE.pointer == 'finger_touch') {
+ x = e.changedTouches[0].clientX
+ }
- }
+ const x_offset = x - window.nuBROWSERESIZE.x_position
- $('.nuOptionsItem').css({ 'width': widest - 90, 'padding': '3px 0px 0px 3px' });
- $('#nuSearchList').css({ 'height': 50 + (c.length * 25) });
+ window.nuBROWSERESIZE.x_position = x
- nuDragElement($('#nuSearchList')[0], 30);
+ if (x !== 0 && Math.abs(x_offset) > min_offset) {
+ if (x_offset < offset_limit) {
+ const c = Number(id.substr(13))
- if (nuIsMobile()) nuHideOptionsItemShortcutKeys();
+ let m = nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths[c] + x_offset
+ if (m < 40) { m = 40 }
+ nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths[c] = m
+ nuSetBrowseColumns(nuFORM.breadcrumbs[nuFORM.breadcrumbs.length - 1].column_widths)
+ } else {
+ console.log('Offset size exceeds limit')
+ }
+ }
+ }
}
-function nuTotal(f) {
- return Number(nuFORM.calc(f));
+function nuAlign (a) {
+ const alignmentMap = {
+ l: 'left',
+ r: 'right',
+ c: 'center'
+ }
+
+ return alignmentMap[a] || ''
}
-function nuMessage(o, timeout, callback) {
+function nuBrowseTable () {
+ const bc = window.nuFORM.getCurrent()
+ const col = bc.browse_columns
+ const row = bc.browse_rows
+ const rows = bc.rows
+ let h = bc.row_height
+ let t = parseInt($('#nuBrowseTitle0').css('height'), 10) - h - 2
+ let l = 7
+ // var borderLeft;
+ // var borderRight;
- window.nuHideMessage = false;
+ const brCount = bc.browse_rows
+ const $record = $('#nuRECORD')
+ let incWidth = 0
- const par = window.document;
+ for (let r = 0; r < rows; r++) {
+ l = 7
+ t = t + h + 7
- $('#nuMessageDiv', par).remove();
+ if (brCount == 0 && r > 0) {
+ let noData
+ let firstCellClass
- if (o.length == 0) { return; }
+ const $firstCell = $('#nucell_0_0')
- if (!$.isArray(o)) {
- let tmp = o;
- o = [];
- o.push(tmp);
- }
+ if (nuCurrentProperties().search.length == 0) {
+ noData = 'No data to display'
+ firstCellClass = 'nuBrowseNoData'
+ window.nuBrowseNoData = true
+ } else {
+ noData = 'No search results found'
+ firstCellClass = 'nuBrowseNoResults'
+ window.nuBrowseNoSearchResults = true
+ }
+
+ $firstCell.html(nuTranslate(noData)).addClass(firstCellClass)
+
+ break
+ }
+
+ for (let c = 0; c < col.length; c++) {
+ const w = Number(col[c].width)
+ const a = nuAlign(col[c].align)
+ const rw = r
+ const column = c
+ const id = 'nucell_' + rw + '_' + c
+ const div = document.createElement('div')
+ div.setAttribute('id', id)
+
+ $record.append(div)
+
+ const $id = $('#' + id)
+
+ // borderLeft = borderLeft !== true && w !== 0 ? true : false;
+
+ $id.attr('data-nu-row', rw)
+ .attr('data-nu-column', column)
+ .addClass('nuCell' + ((r / 2) == parseInt(r / 2, 10) ? 'Even' : 'Odd'))
+ // .addClass(borderLeft ? 'nuBrowseBorderLeft' : '')
+ // .addClass(c == col.length -1 ? 'nuBrowseBorderRight' : '')
+ .addClass(w == 0 ? '' : 'nuBrowseTable')
+ .css({
+ 'text-align': a,
+ overflow: 'hidden',
+ width: w,
+ top: t,
+ left: l,
+ height: h,
+ position: 'absolute'
+ })
+
+ if (w == 0) {
+ $id.hide()
+ }
+
+ if (w < 0) {
+ $id
+ .css('padding', 0)
+ .css('border-width', 0)
+ }
+
+ if (r < row.length) {
+ const value = col[c].format == '' ? row[r][c + 1] : nuFORM.addFormatting(row[r][c + 1], col[c].format)
+ $id
+ .html(value)
+ .attr('data-nu-primary-key', row[r][0])
+ .attr('onclick', 'nuSelectBrowse(event, this)')
+ .hover(
+
+ function () {
+ if (window.nuBROWSERESIZE.moving_element == '') {
+ if (this.offsetWidth < this.scrollWidth && !$(this).is('[title]')) {
+ $(this).attr('title', $(this).html().replace(/(<([^>]+)>)/ig, '')) // Remove HTML tags
+ }
+
+ $('[data-nu-row]').addClass('nuBrowseTable').removeClass('nuSelectBrowse')
+
+ window.nuBROWSEROW = -1
+
+ const dataRow = $(this).attr('data-nu-row')
+ $("[data-nu-row='" + dataRow + "']").not('.nuCellColored').addClass('nuSelectBrowse').removeClass('nuBrowseTable')
+ }
+ }, function () {
+ if (window.nuBROWSERESIZE.moving_element == '') {
+ $('[data-nu-row]').addClass('nuBrowseTable').removeClass('nuSelectBrowse')
+
+ window.nuBROWSEROW = -1
+
+ const dataRow = $(this).attr('data-nu-row')
+ $("[data-nu-row='" + dataRow + "']").addClass('nuBrowseTable').removeClass('nuSelectBrowse')
+ }
+ })
+ }
+
+ if (r == 0 && c == 0) {
+ incWidth = nuTotalWidth(id) - w
+ }
+
+ l = l + (w == 0 ? 0 : w + incWidth)
+ }
+ }
+
+ const last = '◄'
+ const next = '►'
+
+ const pg = ' Page '
+ const cu = ''
+ const pagesOf = ' / ' + (bc.pages == 0 ? 1 : bc.pages) + ' '
+
+ const footerTop = t + h + 10
+ const divFooter = document.createElement('div')
+ divFooter.setAttribute('id', 'nuBrowseFooter')
+
+ $record.append(divFooter)
+
+ $(divFooter)
+ .addClass('nuBrowseFooter')
+ .html(last + pg + cu + pagesOf + next)
+ .css({
+ 'text-align': 'center',
+ width: l - 7,
+ top: footerTop,
+ left: 7,
+ height: 25,
+ position: 'absolute',
+ padding: '5px 0px'
+ })
+
+ nuHighlightSearch()
+ nuBrowseBorders()
+
+ h = footerTop + 130
+ const pDoc = window.parent.document
+
+ $('#nuDragDialog', pDoc).css({
+ height: h + 30,
+ visibility: 'visible',
+ overflow: 'hidden'
+ })
+ $('#nuWindow', pDoc).css({
+ height: h - 14
+ })
+
+ $('body').css('height', h - 30)
+ $record.css('height', 0).css('width', 0)
+}
- let widest = 5;
- for (let i = 0; i < o.length; i++) {
- widest = Math.max(widest, nuGetWordWidth(o[i]));
- }
+function nuBrowseTitleMultiLine () {
+ $('#nuActionHolder').css({ height: '40px' })
+ $('.nuBrowseTitle').css('top', '-20px')
+}
- widest = Math.min(widest + 200, 1000);
- let w = window.visualViewport.width - 42; //-- subtract padding, border
- let l = Math.max(0, $(this).scrollLeft() + (w - widest) / 2);
- w = Math.min(w, widest);
+function nuSetBrowseColumnWidth (column, width) {
+ let cw = this
+ if (nuIsIframe()) {
+ cw = parent.$('#' + window.frameElement.id)[0].contentWindow
+ }
+ cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths[column] = width
+ cw.nuSetBrowseColumns(cw.nuFORM.breadcrumbs[cw.nuFORM.breadcrumbs.length - 1].column_widths)
+}
- $('body', par).append("
");
+function nuBrowseAdditionalNavButtons () {
+ if (nuFormType() == 'browse') {
+ const disabled = {
+ opacity: '0.3',
+ 'pointer-events': 'none'
+ }
- let msgDiv = $('#nuMessageDiv', par);
+ const currentPage = Number($('#browsePage').val())
+ const lastPage = nuCurrentProperties().pages
- for (let i = 0; i < o.length; i++) {
- msgDiv.append(o[i]).append('
');
- }
+ let html = ' '
+ $(html).insertBefore('#nuLast')
- if (timeout !== undefined) {
- setTimeout(function () {
- $('#nuMessageDiv', par).fadeOut("slow");
+ html = ' '
+ $(html).insertAfter('#nuNext')
- if (callback !== undefined) {
- callback();
- }
+ if (currentPage == 1) {
+ $('#nuFirst').css(disabled)
+ $('#nuLast').css(disabled)
+ }
- }, timeout);
- }
+ if (currentPage == lastPage) {
+ $('#nuNext').css(disabled)
+ $('#nuEnd').css(disabled)
+ }
+ }
+}
+
+function nuClickSearchColumn (e) {
+ const c = e.target.id.substr(12)
+ $('#nuSearchList' + c).click()
+ nuSetSearchColumn()
+}
- nuDragElement(msgDiv[0], 30);
+function nuSetSearchColumn () {
+ const nosearch = []
- return msgDiv;
+ $('.nuSearchCheckbox').each(function (index) {
+ if (!$(this).is(':checked')) {
+ nosearch.push(index)
-}
+ $('#nusort_' + index)
+ .addClass('nuNoSearch')
+ } else {
+ $('#nusort_' + index)
+ .removeClass('nuNoSearch')
+ }
+ })
-function nuWindowPosition() {
+ window.nuFORM.setProperty('nosearch_columns', nosearch)
+}
- const p = window.parent.document;
+function nuSetNoSearchColumns (columnsArr) {
+ const s = nuFORM.getCurrent().nosearch_columns
+ columnsArr = s.concat(columnsArr)
- var d = $('#nuDragDialog', p);
+ for (let i = 0; i < columnsArr.length; i++) {
+ $('#nusort_' + columnsArr[i]).addClass('nuNoSearch')
+ }
- const l = parseInt(d.css('left'), 10);
- const t = parseInt(d.css('top'), 10);
- var w = parseInt(d.css('width'), 10);
- var h = parseInt(d.css('height'), 10);
+ nuFORM.setProperty('nosearch_columns', columnsArr)
+}
- window.nuDialogSize = { left: l, top: t, width: w, height: h };
+function nuSetSearchColumns (columnsArr) {
+ const numBrowseColumns = $('.nuBrowseTitle').length
+ const arr = []
- d = $('#nuWindow', p);
+ for (let i = 0; i <= numBrowseColumns; i++) {
+ if (!columnsArr.includes(i)) {
+ arr.push(i)
+ }
+ }
- w = parseInt(d.css('width'), 10);
- h = parseInt(d.css('height'), 10);
+ nuSetNoSearchColumns(arr)
+}
- window.nuWindowSize = { width: w, height: h };
+function nuSearchColumnsReset () {
+ for (let i = 0; i < $('.nuBrowseTitle').length; i++) {
+ $('#nusort_' + i).removeClass('nuNoSearch')
+ }
+ nuFORM.setProperty('nosearch_columns', [])
}
-function nuNoDuplicates() {
+function nuSearchPressed (e) {
+ if (!e) { e = window.event }
- window.nuDuplicate = true;
+ if (e.key == 'Enter' && window.nuBROWSEROW == -1) {
+ e.preventDefault()
+ $('#nuSearchButton').click()
+ } else if (e.key == 'Enter' && window.nuBROWSEROW != -1) {
+ e.preventDefault()
+ const i = '#nucell_' + window.nuBROWSEROW + '_0'
- $('.nuTabHolder.nuDuplicate').each(function () {
+ nuSelectBrowse('', $(i)[0])
+ } else {
+ window.nuBROWSEROW = -1
+ $('[data-nu-row]').addClass('nuBrowseTable')
+ $('[data-nu-row]').removeClass('nuSelectBrowse')
+ }
+}
- var t = $(this).html();
- var f = $(this).attr('data-nu-field');
- var s = $(this).attr('data-nu-subform');
- var sf = nuSubformObject(s);
- var a = [];
- var c = sf.fields.indexOf(f);
+function nuArrowPressed (e) {
+ if (!e) { e = window.event }
- for (var i = 0; i < sf.rows.length; i++) {
+ const rows = $("[data-nu-column='0'][data-nu-primary-key]").length - 1
- if (sf.deleted[i] == 0) {
+ if (e.key == 'ArrowUp') {
+ if (window.nuBROWSEROW == -1) {
+ window.nuBROWSEROW = rows
+ } else {
+ window.nuBROWSEROW = window.nuBROWSEROW - 1
+ }
- var rv = sf.rows[i][c];
+ $('[data-nu-row]').addClass('nuBrowseTable').removeClass('nuSelectBrowse')
+ $("[data-nu-row='" + window.nuBROWSEROW + "']").addClass('nuSelectBrowse').removeClass('nuBrowseTable')
+ }
- if (a.indexOf(rv) != -1) {
+ if (e.key == 'ArrowDown') {
+ if (window.nuBROWSEROW == rows) {
+ window.nuBROWSEROW = -1
+ } else {
+ window.nuBROWSEROW = window.nuBROWSEROW + 1
+ }
- nuMessage(['Duplicate ' + t + ' on row ' + i + '']);
- window.nuDuplicate = false;
- return;
+ $('[data-nu-row]').addClass('nuBrowseTable').removeClass('nuSelectBrowse')
+ $("[data-nu-row='" + window.nuBROWSEROW + "']").addClass('nuSelectBrowse').removeClass('nuBrowseTable')
+ }
+}
- }
+function nuSearchAction (S, F) {
+ if (arguments.length > 0) {
+ $('#nuSearchField').val(S)
+ }
+ if (arguments.length == 2) {
+ $('#nuFilter').val(F)
+ }
- a.push(sf.rows[i][c]);
+ let s = String($('#nuSearchField').val()).nuReplaceAll("'", ''', true)
+ let f = String($('#nuFilter').val()).nuReplaceAll("'", ''', true)
- }
+ if (window.nuOnSearchActionGlobal) {
+ const o = { search: s, filter: f }
+ if (nuOnSearchActionGlobal(o) === false) { return }
+ s = o.search
+ f = o.filter
+ }
- }
+ if (window.nuOnSearchAction) {
+ const o = { search: s, filter: f }
+ if (nuOnSearchAction(o) === false) { return }
+ s = o.search
+ f = o.filter
+ }
- });
+ window.nuFORM.setProperty('search', s)
+ window.nuFORM.setProperty('filter', f)
- return window.nuDuplicate;
+ const caller = nuSearchAction.caller === null ? '' : nuSearchAction.caller.name
+ if ((arguments.length === 0 && caller != 'nuGetPage') || arguments.length >= 1) {
+ window.nuFORM.setProperty('page_number', 0)
+ }
+ nuDisable('nuSearchField')
+ nuGetBreadcrumb()
}
-function nuFormType() {
+function nuAddAction () {
+ const bc = window.nuFORM.getCurrent()
- if (nuFORM.getCurrent() == undefined) { return ''; }
- return nuRecordId() == '' ? 'browse' : 'edit';
+ if (window.nuOnAddAction) {
+ if (nuOnAddAction(bc) == false) return
+ }
+ nuForm(bc.redirect_form_id, '-1')
}
-function nuFormId() {
+function nuRunPHPAction (code) {
+ nuRunPHP(code)
+}
- if (nuFORM.getCurrent() == undefined) { return ''; }
- return nuFORM.getCurrent().form_id;
+function nuRunReportAction (code) {
+ nuRunReport(code)
+}
+function nuEmailReportAction (code) {
+ nuEmailReport(code)
}
-function nuRecordId() {
+function nuSortBrowse (c) {
+ const l = window.nuFORM.getCurrent()
+ l.filter = $('#nuFilter').val()
+ l.page_number = 0
- if (nuFORM.getCurrent() == undefined) { return ''; }
- return nuFORM.getCurrent().record_id;
+ if (c == l.sort) {
+ l.sort_direction = l.sort_direction == 'asc' ? 'desc' : 'asc'
+ } else {
+ l.sort = c
+ l.sort_direction = 'asc'
+ }
+ nuSearchAction()
}
-function nuBuildFastReport() {
+function nuGetPage (p) {
+ let P = parseInt('00' + p, 10)
- var sf = nuSubformObject('fast_report_sf');
- var left = 3;
- var rows = sf.rows;
- window.nuNextID = 0;
- window.nuREPORT = JSON.parse(JSON.stringify(window.nuREPORTdefault));
+ if (p > nuCurrentProperties().pages || p === 0) return
- for (var i = 0; i < rows.length; i++) {
+ const current = window.nuFORM.getCurrent()
- if (sf.deleted[i] == '0') {
+ if (P == 0) {
+ P = 1
+ }
- var title = rows[i][1];
- var field = rows[i][2];
- var width = Number(rows[i][3]);
- var sum = rows[i][4];
- var align = sum == 0 ? 'left' : 'right';
+ if (P > current.pages) {
+ P = current.pages
+ }
- var o = JSON.parse(JSON.stringify(window.nuOBJECT)); //-- title
- o.left = Number(left);
- o.width = width;
- o.top = 70;
- o.fieldName = title;
- o.objectType = 'label';
- o.textAlign = align;
+ current.page_number = P - 1
- nuFastObject(2, 0, o);
+ nuSearchAction()
+}
- o = JSON.parse(JSON.stringify(window.nuOBJECT)); //-- field
- o.left = Number(left);
- o.width = width;
- o.fieldName = field;
- o.textAlign = align;
+function nuPopulateLookup (fm, target, setFocus) {
+ const p = String($('#' + target).attr('data-nu-prefix'))
+ const f = fm.lookup_values
- nuFastObject(0, 0, o);
+ window.nuSubformRow = Number(p.slice(-3))
- if (align == 'right') {
+ for (let i = 0; i < f.length; i++) {
+ const id = String(f[i][0])
+ let $id = $('#' + id)
- o = JSON.parse(JSON.stringify(window.nuOBJECT)); //-- sum
- o.left = Number(left);
- o.width = width;
- o.fieldName = 'SUM(' + field + ')';
- o.textAlign = align;
+ if (id.substring(0, p.length) != p) {
+ $id = $('#' + p + id)
+ }
- nuFastObject(1, 1, o);
+ $id.addClass('nuEdited')
- }
+ if ($id.attr('type') == 'checkbox') {
+ $id.prop('checked', f[i][1] == '1')
+ } else {
+ $id.val(f[i][1])
- left = left + width + 2;
+ if ($id.attr('data-nu-format') !== undefined) {
+ nuReformat($id[0])
+ $id.addClass('nuEdited')
+ $('#' + p + 'nuDelete').prop('checked', false)
- }
+ if (window.nuOnLookupPopulatedGlobal) {
+ nuOnLookupPopulatedGlobal(id, p)
+ }
- }
+ if (window.nuOnLookupPopulated) {
+ nuOnLookupPopulated(id, p)
+ }
+ }
+ }
- nuFastReportFormat(left);
+ if (i == 1 && setFocus !== false) {
+ $id.focus()
+ }
+ }
- $('#fieldlist').val(JSON.stringify(window.nuREPORT));
+ window.nuLOOKUPSTATE[$('#' + target).attr('data-nu-object-id')] = 'found'
- nuFORM.setProperty('nuREPORT', window.nuREPORT);
+ nuCalculateForm()
-}
+ eval(fm.lookup_javascript)
-function nuFastObject(g, s, o) {
+ $('#dialogClose').click()
+}
- o.id = 'obj' + nuPad3(window.nuNextID);
- o.name = o.id;
- o.left = Number(o.left) + 2;
+function nuChooseOneLookupRecord (e, fm) {
+ const o = new nuLookupObject(e.target.id)
+ const i = o.id_id
+ const t = document.getElementById(e.target.id)
+ const like = nuEncode(fm.lookup_like)
- nuREPORT.groups[g].sections[s].objects.push(o);
+ if (fm.lookup_values.length == 0) {
+ nuGetLookupId('', i)
+ }
- window.nuNextID++;
+ if (fm.lookup_values.length == 1) {
+ if (e.target.value.toUpperCase() == String(fm.lookup_values[0][1]).toUpperCase()) {
+ nuGetLookupId(fm.lookup_values[0][0], i)
+ } else {
+ nuBuildLookup(t, e.target.value)
+ }
+ }
+ if (fm.lookup_values.length > 1) {
+ nuBuildLookup(t, e.target.value, like)
+ }
}
-function nuNewFastObject() {
-
- var o = JSON.parse(JSON.stringify(window.nuOBJECT));
- o.id = 'obj' + nuPad3(window.nuNextID);
- o.name = o.id;
+function nuLookupObject (id, set, value) {
+ if ($('#' + id).length == 0) {
+ this.id_id = ''
+ this.code_id = ''
+ this.description_id = ''
+ this.id_value = ''
+ this.code_value = ''
+ this.description_value = ''
- window.nuNextID++;
+ return
+ }
- return o;
+ let i = nuValidLookupId(id, 'code')
+ i = nuValidLookupId(i, 'description')
+ this.id_id = i
+ this.code_id = i + 'code'
+ this.description_id = i + 'description'
+ this.id_value = $('#' + this.id_id).val()
+ this.code_value = $('#' + this.code_id).val()
+ this.description_value = $('#' + this.description_id).val()
+ if (arguments.length == 3 && set == 'id') {
+ $('#' + this.id).val(value)
+ }
+ if (arguments.length == 3 && set == 'code') {
+ $('#' + this.code).val(value)
+ }
+ if (arguments.length == 3 && set == 'description') {
+ $('#' + this.description).val(value)
+ }
}
-function nuFastReportFormat(width) {
-
- var o = nuNewFastObject(); //-- report title
- o.left = 2;
- o.top = 10;
- o.width = 300;
- o.height = 30;
- o.fontWeight = 'b';
- o.fontSize = '20';
- o.objectType = 'label';
- nuREPORT.width = 297;
- nuREPORT.height = 210;
- var pageWidth = 290 * 4;
- var sf = nuSubformObject('fast_report_sf');
-
- nuREPORT.orientation = 'L';
- nuREPORT.groups[3].sortField = sf.rows[0][2];
- nuREPORT.groups[2].sections[0].height = 100;
- nuREPORT.groups[2].sections[0].objects.push(o);
+function nuValidLookupId (id, fld) {
+ let i = String(id)
+ const f = String(fld)
+ const il = i.length
+ const fl = f.length
- o = nuNewFastObject(); //-- underline titles
- o.left = 2;
- o.top = 93;
- o.width = width;
- o.height = 1;
- o.borderWidth = 1;
- o.objectType = 'label';
- o.fieldName = 'KEEP EXACT HEIGHT';
+ if (i.substr(il - fl) === f) {
+ i = i.substr(0, il - fl)
- nuREPORT.groups[2].sections[0].objects.push(o);
+ if ($('#' + i + f).length == 1 && $('#' + i + f + f).length == 1) {
+ i = i + f
+ }
+ }
- o = nuNewFastObject(); //-- page footer
- o.left = 2;
- o.top = 3;
- o.width = pageWidth;
- o.height = 1;
- o.borderWidth = 1;
- o.objectType = 'label';
- o.fieldName = 'KEEP EXACT HEIGHT';
+ return i
+}
- nuREPORT.groups[2].sections[1].objects.push(o);
+function nuHighlightSearch () {
+ const bc = window.nuFORM.getCurrent()
- o = nuNewFastObject(); //-- page footer date
- o.left = 2;
- o.top = 9;
- o.width = 600;
- o.fieldName = 'Printed : #day#-#month#-20#year# #hour#:#minute#:#second#';
- o.objectType = 'label';
+ if (bc.search === undefined) return
+ if (bc.search.length == 0) return
- nuREPORT.groups[2].sections[1].objects.push(o);
+ const exclude = bc.nosearch_columns
- o = nuNewFastObject(); //-- page footer page no.
- o.top = 9;
- o.left = pageWidth - 200;
- o.width = 200;
- o.textAlign = 'right';
- o.fieldName = 'Page #page# of #pages#';
- o.objectType = 'label';
+ const search = String(bc.search)
+ .split(' ')
+ .filter(function (a) { return (a != '' && a.substr(0, 1) != '-') })
+ .sort(function (a, b) { return (a.length > b.length) })
- nuREPORT.groups[2].sections[1].objects.push(o);
+ $('.nuBrowseTable').each(function (index) {
+ const col = Number(String($(this).attr('data-nu-column')))
- if (nuREPORT.groups[1].sections[1].objects.length > 0) {
+ if (exclude.indexOf(col) == -1) {
+ for (let i = 0; i < search.length; i++) {
+ $(this).nuHighlight(search[i])
+ }
+ }
+ })
+}
- nuNewFastObject(); //-- overline sums
- o.left = 2;
- o.top = 3;
- o.width = width;
- o.height = 1;
- o.borderWidth = 1;
- o.objectType = 'label';
- o.fieldName = 'KEEP EXACT HEIGHT';
+function nuChange (e) {
+ if (e.target.id.substr(-8) == 'nuDelete') {
+ const sfid = $(e.target).parent().parent().parent()[0].id
+ const click = $('#' + sfid).attr('data-nu-clickdelete')
- nuREPORT.groups[1].sections[1].objects.push(o);
+ eval(click)
- }
+ nuHasBeenEdited()
+ nuCalculateForm()
-}
+ return
+ }
-function nuRedefine_nuSelectBrowse() {
+ nuSetSaved(false)
- nuSelectBrowse = function (e, t) {
+ const t = $('#' + e.target.id)[0]
+ const p = $('#' + t.id).attr('data-nu-prefix')
- const y = window.nuBrowseFunction; //-- browse, lookup or custom function name
- const pk = $('#' + t.id).attr('data-nu-primary-key');
- const formId = window.nuFORM.getProperty('form_id');
- const formIdRedirect = window.nuFORM.getProperty('redirect_form_id');
- const formType = window.nuFORM.getProperty('form_type');
- const ro = window.nuFORM.getProperty('redirect_other_form_id');
+ nuReformat(t)
- if (formType == 'browse' && ro == '' && parent.$('#nuDragDialog').length == 0) {
- nuSelectBrowse = function (e, t) { }
- return;
- }
+ $('#' + p + 'nuDelete').prop('checked', false)
+ $('#' + t.id).addClass('nuEdited')
+ nuHasBeenEdited()
- nuCursor('progress');
+ $('#nuCalendar').remove()
+ $('#' + t.id).removeClass('nuValidate')
+ nuCalculateForm()
- if (y == 'browse') {
+ if (p == '') { return }
- nuForm(formIdRedirect == '' ? formId : formIdRedirect, pk);
+ nuAddSubformRow(t, e)
+}
- } else if (y == 'lookup') {
+function nuChooseEventList () {
+ if ($('#sob_all_type').val() == 'subform') {
+ return ['beforeinsertrow', 'afterinsertrow', 'clickdelete']
+ }
- window.parent.nuGetLookupId(pk, window.nuTARGET); //-- called from parent window
+ return ['onchange', 'oninput', 'onclick', 'onblur', 'onnuload', 'onfocus', 'onkeydown']
+}
- } else {
+function nuChangeFile (e) {
+ if (e.target.id.substr(-8) == 'nuDelete') {
+ nuHasBeenEdited()
+ return
+ }
- window[y](e);
+ const theFile = e.target.id
+ const theTextarea = theFile.substr(0, theFile.length - 5)
- }
+ if ($('#' + theFile).val() == '') { return }
- if ((nuIsMacintosh() ? e.metaKey : e.ctrlKey) == false) {
- nuSelectBrowse = function (e, t) { } //-- so that it doesn't run twice.
- }
+ const a = $('#' + theFile)[0].files[0]
+ const r = new FileReader()
- }
+ r.onload = function () {
+ const f = btoa(r.result)
+ const o = { file: f, name: a.name, size: a.size, type: a.type }
+ const j = JSON.stringify(o)
-}
+ if (window.nuOnFileLoad) {
+ if (nuOnFileLoad(theFile, o) === false) { return }
+ } else {
+ if (j.length > 600000) {
+ nuMessage([nuTranslate('File is too large, cannot be saved. Must be under 300Kb')])
+ return
+ }
+ }
-function nuSetVerticalTabs() {
+ $('#' + theTextarea).val(j).addClass('nuEdited')
+ }
- let tabHolder = $('#nuTabHolder');
- tabHolder.css('display', 'inline-block');
- $('.nuTab').css('display', 'block');
- $('#nuRecord').css('display', 'inline-block');
- $('.nuTab').css('padding', '8px 2px 0px 2px');
- tabHolder.css('height', window.innerHeight);
+ r.readAsDataURL(a)
- var w = 0;
+ const t = $('#' + theFile)[0]
+ const p = $('#' + theTextarea).attr('data-nu-prefix')
- var s = ' ';
- $('.nuTab').each(function () {
- $(this).html($(this).html().includes(s) ? $(this).html() : s + $(this).html());
- w = Math.max(w, nuGetWordWidth($(this).html()));
+ $('#' + p + 'nuDelete').prop('checked', false)
+ $('#' + theTextarea).addClass('nuEdited')
- });
+ nuHasBeenEdited()
- tabHolder.css('width', w + 30);
- $('.nuTab').css('width', w + 30);
+ if (p == '') { return }
- window.nuVerticalTabs = true;
+ nuAddSubformRow(t, e)
}
-function nuHasBeenSaved() {
+function nuCalculateForm (setAsEdited) { // -- calculate subform 'calcs' first
+ if (window.nuEnableCalculation == false) return
- return window.nuTimesSaved;
+ const subformFirst = function (a, b) {
+ const A = $('#' + a.id).hasClass('nuSubformObject') ? 0 : 1000
+ const B = $('#' + b.id).hasClass('nuSubformObject') ? 0 : 1000
+ a = parseInt($('#' + a.id).attr('data-nu-calc-order'), 10)
+ b = parseInt($('#' + b.id).attr('data-nu-calc-order'), 10)
-}
+ if (setAsEdited === undefined) {
+ $('#' + a.id).addClass('nuEdited')
+ }
-function nuResponseDefault() {
+ return (a + A) - (b + B)
+ }
- if (nuFormType() == 'edit') {
- nuRESPONSIVE.resetDefault('', false);
- }
+ const f = $('[data-nu-formula]')
-}
+ f.sort(subformFirst)
-function nuResponseWrap() {
+ f.each(function (index) { // -- start with calculations inside a subform
+ $(this).addClass('nuEdited')
- if (nuFormType() == 'edit') {
- nuRESPONSIVE.setTabsColumn('', false);
- }
+ const formula = $(this).attr('data-nu-formula')
+ const fmt = $(this).attr('data-nu-format')
+ const v = 0
-}
+ if (formula != '') {
+ eval('var v = ' + formula)
+ }
-function nuResponseNoWrap() {
+ const fixed = nuFORM.addFormatting(v, fmt)
- if (nuFormType() == 'edit') {
- nuRESPONSIVE.setTabsColumn('', true);
- }
+ $(this).val(fixed)
+ if (window.nuCalculated) {
+ nuCalculated(this, v, fixed)
+ }
+ })
}
-function nuResponsiveWrap(width, wrap) {
-
- if (window.innerWidth >= width) {
- nuResponseDefault();
- }
-
- if (window.innerWidth < width) {
+function nuHasBeenEdited () {
+ $('.nuSaveButton').addClass('nuSaveButtonEdited')
+ nuFORM.edited = true
+ nuSetSaved(false)
+}
- if (window.innerWidth < wrap) {
- nuResponseWrap();
- } else {
- nuResponseNoWrap();
- }
+function nuHasNotBeenEdited () {
+ $('.nuSaveButton').removeClass('nuSaveButtonEdited')
+ nuFORM.edited = false
+ nuSetSaved(true)
+}
- }
+function nuDeleteAction () {
+ if (confirm(nuTranslate('Delete This Record?'))) {
+ $('#nuDelete').prop('checked', true)
+ nuUpdateData('delete')
+ }
+}
+function nuDeleteAllAction () {
+ if (confirm(nuTranslate('Delete All Records?'))) {
+ $('#nuDelete').prop('checked', true)
+ nuUpdateData('delete', 'all')
+ }
}
-function nuBrowseBorders() {
+function nuCloneAction () {
+ nuSetProperty('CLONED_RECORD', 1)
+ nuSetProperty('CLONED_RECORD_ID', nuRecordId())
- var r = nuSERVERRESPONSE.rows;
- var c = nuSERVERRESPONSE.browse_columns.length;
+ window.nuTimesSaved = 0
- for (var i = 0; i < c; i++) {
+ $('[data-nu-primary-key]').each(function () {
+ $(this).attr('data-nu-primary-key', '-1')
+ })
- $('#nucell_0_' + i).addClass('nuBrowseBorderTop');
- $('#nucell_' + (r - 1) + '_' + i).addClass('nuBrowseBorderBottom');
+ $('[data-nu-field]').each(function () {
+ $(this).addClass('nuEdited')
+ })
- }
+ window.nuFORM.setProperty('record_id', -1)
-}
+ $('#nuCloneButton').css('visibility', 'hidden')
+ $('#nuDeleteButton').css('visibility', 'hidden')
-function nuObjectPosition(id) {
+ $('.nuSaveButton')
+ .css('background-color', 'red')
+ .css('visibility', 'visible')
- const $id = $('#' + id);
- const t = parseInt($id.css('top'), 10);
- const l = parseInt($id.css('left'), 10);
- const h = parseInt($id.css('height'), 10);
- const w = parseInt($id.css('width'), 10);
+ nuCLONE = true
+ nuEmptyNoClone()
- const b = t + h; // bottom
- const r = l + w; // right
+ const b = $('.nuBreadcrumb').length
+ const nb = $('.nuNotBreadcrumb').not('#nuLogout').length
- return {t, l, h, w, b, r};
+ const bc = b == 0 && nb == 0 ? $('#nuHomeGap') : $('#nuBreadcrumb' + b)
+ bc.append(' ' + nuTranslate('Cloning') + ' ')
+ if (window.nuOnClone) {
+ nuOnClone()
+ }
}
-function nuFormWH() {
-
- let width = 0;
- let height = 0;
- let s = '[data-nu-object-id][data-nu-prefix=""], [data-nu-subform=true]';
+function nuEmptyNoClone () {
+ const c = nuSERVERRESPONSE.noclone
- if (nuSERVERRESPONSE.record_id == -2) {
- s = '[data-nu-object-id]';
- }
+ if (c === null) return
- $(s).each(function () {
+ for (var i = 0; i < c.length; i++) {
+ if (c[i].subform) {
+ $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform1').remove()
+ $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform0').each(function () {
+ if ($(this)[0].id != c[i].id + '000nuRECORD') {
+ $(this).remove()
+ }
+ })
- let {t, l, h, w} = nuObjectPosition($(this).attr('id'));
+ const k = $('#' + c[i].id + '000nuRECORD').children()
- width = Math.max(width, w + l);
- height = Math.max(height, h + t);
+ for (let s = 0; s < k.length; s++) {
+ if ($('#' + k[s].id).hasClass('nuEdited')) {
+ $('#' + k[s].id).val('')
- });
+ if ($('#' + k[s].id + 'button').length == 1) {
+ $('#' + k[s].id + 'code').val('')
+ $('#' + k[s].id + 'description').val('')
+ }
+ }
+ }
- return { 'width': width, 'height': height };
+ $('#' + c[i].id + '000nuDelete').prop('checked', true)
+ $('#' + c[i].id + '001nuRECORD').remove()
+ } else {
+ if ($('#' + c[i].id).length == 1) {
+ $('#' + c[i].id).val('').change()
+ }
+ }
+ }
+}
+function nuIsClone () {
+ return nuCLONE
}
-function nuResizeFormDialogCoordinates() {
+function nuIsNewRecord () {
+ return nuRecordId() == -1 && !nuCLONE
+}
- const wh = nuFormWH();
- let w = wh.width;
- let h = wh.height;
+function nuSaveAction (close) {
+ if (nuCurrentProperties().form_type == 'launch' || nuLookingUp()) return
- w = w + 40;
- h = h + nuDialogHeadersHeight() + 50;
+ if (nuNoDuplicates()) {
+ nuSaveScrollPositions()
+ nuUpdateData('save', close ? 'close' : null)
+ }
+}
- const parentDocument = window.parent.document;
- const windowInnerHeight = window.innerHeight;
- const $body = $('body');
+function nuSavingProgressMessage () {
+ const e = document.createElement('div')
- let dragDlg = $('#nuDragDialog', parentDocument);
- if (dragDlg.length == 0) { return; }
+ e.setAttribute('id', 'nuProgressUpdate')
- dragDlg.css('visibility', 'visible');
- dragDlg.css('width', w + 12);
- $('#nuWindow', parentDocument).css('width', w);
- $body.css('width', w);
+ $('#nuActionHolder').append(e)
+ $('#' + e.id).html('')
+ $('#' + e.id).addClass('nuUpdateMessageProgress')
+ $('#' + e.id).css('position', 'absolute')
+ $('#' + e.id).css('left', (($('#nuActionHolder').width() / 2) - ($('#nuProgressUpdate').width() / 2)) + 'px')
+ $('#' + e.id).show()
- dragDlg.css('height', h + 50).css('visibility', 'visible');
- $('#nuWindow', parentDocument).css('height', h + 10);
- $body.css('height', windowInnerHeight);
+ $('.nuActionButton').hide()
+}
- if (h < windowInnerHeight) {
- $body.css('height', '100%');
- } else {
- $body.css('height', h);
- }
+function nuUpdateMessage (msg) {
+ $('#nuProgressUpdate').hide()
- if (w > window.innerWidth) {
+ const e = document.createElement('div')
- let html = window.innerHTML;
- $('#nuBreadcrumbHolder').css('width', html);
- $('#nuTabHolder').css('width', html);
- $('#nuActionHolder').css('width', html);
+ e.setAttribute('id', 'nuNowUpdated')
- }
+ $('#nuActionHolder').append(e)
+ $('#' + e.id).html(nuTranslate(msg))
+ $('#' + e.id).addClass('nuUpdateMessage')
+ $('#' + e.id).css('position', 'absolute')
+ $('#' + e.id).css('left', (($('#nuActionHolder').width() / 2) - ($('#nuNowUpdated').width() / 2)) + 'px')
+ $('#nuNowUpdated').fadeToggle(3000)
+ $('.nuActionButton').show()
}
-function nuClickTab(t, s) {
-
- t = "nuTab" + t;
-
- if (arguments.length == 2) {
- t = s + t;
- }
+function nuAbortSave () {
+ $('#nuProgressUpdate').hide()
+ $('.nuActionButton').show()
+}
- nuSelectTab($('#' + t)[0]);
+function nuSetSaved (v) {
+ if (window.nuOnSetSaved) {
+ nuOnSetSaved(v)
+ }
+ window.nuSAVED = v
}
-function nuFilterRun(id, filter) {
+function nuFormsUnsaved () {
+ let c = 0
+ $.each($('iframe'), function () {
+ const t = $(this)[0]
- const r = JSON.parse(JSON.stringify(nuSERVERRESPONSE));
- let o = -1;
+ try {
+ if (typeof t.contentWindow.nuIsSaved === 'function') {
+ if (!t.contentWindow.nuIsSaved()) {
+ c++
+ }
+ }
+ } catch (e) {
+ // catch "DOMException: Blocked a frame with origin"
+ }
+ })
- for (let i = 0; i < r.objects.length; i++) {
+ if (!nuIsSaved()) c++
+ return c
+}
- const obj = r.objects[i];
- if (obj.id == id) {
+function nuAddJavaScript (js) {
+ const s = document.createElement('script')
+ s.innerHTML = '\n\n' + js + '\n\n'
- if (filter) {
- if (obj.filter == filter) { return; }
- obj.filter = filter;
+ $('body').append(s)
+}
- }
+function nuAddFormStyle (style) {
+ if (style !== '') {
+ style = style.replace(/(('
+ $('#nuRECORD').append(span)
+ }
+}
- o = i;
+function nuHashFromEditForm () {
+ const A = {}
+ const S = nuSubformObject('')
+ const B = nuFORM.getCurrent()
- }
+ if (S.rows.length == 0) { return A }
- }
+ for (const key in B) {
+ A[key] = B[key]
+ }
- if (o == -1) { return; }
+ for (let i = 0; i < S.fields.length; i++) {
+ A[S.fields[i]] = S.rows[0][i]
+ }
- nuRUN(r, o, '', '', r);
+ return A
+}
+function nuDetach () {
+ $('.nuDragLineV').each(function () {
+ $(this).appendTo('body')
+ })
}
-function nuRecordRun(id, filter) {
+function nuSearchableList () {
+ const bc = window.nuFORM.getCurrent()
+ const col = bc.browse_columns
+ const no = bc.nosearch_columns
+ const div = document.createElement('div')
- const r = JSON.parse(JSON.stringify(nuSERVERRESPONSE));
- let o = -1;
+ div.setAttribute('id', 'nuSearchableDialog')
- for (let i = 0; i < r.objects.length; i++) {
+ $('body').append(div)
- const obj = r.objects[i];
- if (obj.id == id) {
+ $('#nuSearchableDialog')
+ .addClass('nuSearchableDialog')
+ .css('width', 150)
+ .css('height', 30 + (col.length * 20))
+ .css('top', 10)
+ .css('left', 10)
- if (filter) {
- if (obj.record_id == filter) { return; }
- obj.record_id = filter;
- }
+ for (let i = 0; i < col.length; i++) {
+ const input = document.createElement('input')
+ const search = no.indexOf(i) != -1
- o = i;
+ input.setAttribute('id', 'nuSearchableCheckbox' + i)
- }
+ $('#nuSearchableDialog').append(input)
- }
+ $('#' + 'nuSearchableCheckbox' + i)
+ .append(input)
+ .addClass('nuSearchableDialog')
+ .css('left', 5)
+ .css('height', 25)
+ .css('top', 10 + (i * 27))
+ .checked = search
- if (o == -1) { return; }
+ if (search) {
+ $('#' + 'nuSearchableCheckbox' + i)
+ .addClass('nuNoSearch')
+ }
- nuRUN(r, o, '', '', r);
+ const span = document.createElement('span')
-}
+ span.setAttribute('id', 'nuSearchableTitle' + i)
-function nuGetIframeValue(f, o, method) {
+ $('#nuSearchableDialog').append(input)
- const obj = $('#' + f).contents().find('#' + o)
- return (!method || method == 'val') ? obj.val() : obj.html();
+ $('#' + 'nuSearchableTitle' + i)
+ .append(span)
+ .addClass('nuSearchableDialog')
+ .css('width', 25)
+ .css('left', 25)
+ .css('height', 25)
+ .css('top', 10 + (i * 20))
+ .html(col[i].title)
+ }
}
-function nuSetIframeValue(f, o, v, method) {
+function nuWidestTitle (c) {
+ let w = 120
- const obj = $('#' + f).contents().find('#' + o)
- return (!method || method == 'val') ? obj.val(v) : obj.html(v);
+ for (let i = 0; i < c.length; i++) {
+ const t = String(c[i].title).replaceAll('
', ' ').replaceAll('
', ' ')
+ w = Math.max(nuGetWordWidth(t), w)
+ }
+ return w + 70
}
-function nuLookingUp() {
+function nuGetSearchList () {
+ const c = nuFORM.getProperty('browse_columns')
+ const d = document.createElement('div')
- for (let lu in window.nuLOOKUPSTATE) {
-
- if (window.nuLOOKUPSTATE[lu] == 'looking') {
-
- nuMessage([nuTranslate('A Lookup is still being populated...')]);
- return true;
-
- }
+ $('#nuOptionsListBox').remove()
- }
+ const widest = nuWidestTitle(c) + 20
- return false;
+ d.setAttribute('id', 'nuSearchList')
-}
+ $('body').append(d)
-function nuPortraitScreen(columns) {
+ $('#' + d.id).css({
+ width: widest + 20,
+ height: 10 + (c.length * 30),
+ top: 138,
+ left: (window.innerWidth - widest) < 0 ? 0 : 50,
+ position: 'absolute',
+ 'text-align': 'left'
+ })
+ .html(' ' + nuTranslate('Include When Searching') + '<\span>')
+ .addClass('nuOptionsList')
- function nuPortraitScreenObjDimensions(id, jId) {
+ for (var i = 0; i < c.length; i++) {
+ let isChecked = true
- let height = jId.outerHeight()
+ if ($.inArray(i, nuFORM.getCurrent().nosearch_columns) != '-1') {
+ isChecked = false
+ }
- if (jId.is('[data-select2-id]')) {
- height = jId.data('nu-org-height') + 50;
- }
+ const p = document.createElement('input')
- if (!jId.is("[nu-mobileview-hidden]")) {
- width = Math.max(width, jId.outerWidth());
- }
+ p.setAttribute('id', 'nuSearchList' + i)
+ p.setAttribute('type', 'checkbox')
- let heightLabel = $('#label_' + id).length == 0 ? 0 : $('#label_' + id).outerHeight()
+ $('#' + d.id).append(p)
- return { height, width, heightLabel }
+ $('#' + p.id).css({
+ width: 20,
+ height: 25,
+ top: 30 + (i * 25),
+ left: 5,
+ position: 'absolute',
+ 'text-align': 'left'
+ })
+ .prop('checked', isChecked)
+ .attr('onclick', 'nuSetSearchColumn();')
+ .addClass('nuSearchCheckbox')
- }
+ const t = document.createElement('div')
+ const nobr = String(c[i].title).nuReplaceAll('
', ' ').nuReplaceAll('', ' ')
- $('#nubody').css('transform', 'scale(1)');
+ t.setAttribute('id', 'nuSearchText' + i)
- if (nuFormType() == 'browse') { return; }
+ $('#' + d.id).append(t)
- $('.nuBuilderLink').remove();
- if (arguments.length == 0) { columns = 1; }
+ $('#' + t.id).css({
+ height: 25,
+ top: 33 + (i * 25),
+ left: 40,
+ position: 'absolute',
+ 'text-align': 'left'
+ })
+ .attr('onclick', 'nuClickSearchColumn(event);')
+ .addClass('nuOptionsItem')
+ .html(nobr)
+ .click(function () {
+ const cb = $('#nuSearchList' + i).attr('checked')
- $('.nuPortraitTab').remove();
+ $('#' + 'nuSearchList' + i).attr('checked', !cb)
- const obj = nuSERVERRESPONSE.objects;
- var lw = columns == 1 ? 0 : nuPortraitLabelWidth(obj);
- var top = 0;
- var b = -1;
- var width = 0;
- let oWidth = 0;
- let oTop = 0;
+ nuSetSearchColumn()
+ })
- for (let i = 0; i < obj.length; i++) {
+ if (i < 9) {
+ const shortcut_key = document.createElement('div')
+ const shortcut_key_id = 'nuSearchTextShortcutKey' + i.toString()
- let oType = obj[i].type;
+ shortcut_key.setAttribute('id', shortcut_key_id)
- let id = obj[i].id;
- let jId = $('#' + id);
+ $('#nuSearchList').append(shortcut_key)
+ const prop = { position: 'absolute', 'text-align': 'left', height: 15, width: 50 }
- let { height, width, heightLabel } = nuPortraitScreenObjDimensions(id, jId)
+ $('#' + shortcut_key.id)
+ .css(prop)
+ .css({ top: 37 + (i * 25), right: 10 })
+ .html(nuCtrlCmdShiftName(i + 1))
+ .addClass('nuOptionsItemShortcutKey')
+ }
+ }
- const jtab = $('#nuTab' + obj[i].tab);
- let tabVisible = jtab.nuIsVisible()
+ $('.nuOptionsItem').css({ width: widest - 90, padding: '3px 0px 0px 3px' })
+ $('#nuSearchList').css({ height: 50 + (c.length * 25) })
- if (obj[i].tab != b && tabVisible && ! window.nuPortraitScreenShowTabTitles == false ) {
+ nuDragElement($('#nuSearchList')[0], 30)
- if ($('.nuTab').length > 1) {
- b = obj[i].tab;
- const l = jtab.html();
- const d = '
' + l + '
';
- $('#nuRECORD').append(d);
- const OH = $('#nuPort' + b).outerHeight()
+ if (nuIsMobile()) nuHideOptionsItemShortcutKeys()
+}
- top = top + OH + 5;
- }
+function nuTotal (f) {
+ return Number(nuFORM.calc(f))
+}
- }
+function nuMessage (o, timeout, callback) {
+ window.nuHideMessage = false
- tabVisible = jtab.nuIsVisible() || $('.nuTab').length == 1;
+ const par = window.document
- if (jId.is("[nu-mobileview-hidden]") || !tabVisible) {
+ $('#nuMessageDiv', par).remove()
- const objComponents = nuObjectComponents(id);
+ if (o.length == 0) { return }
- for (let c = 0; c < objComponents.length; c++) {
- let comp = $('#' + objComponents[c]);
- comp.attr('nu-mobileview-hidden', '');
- comp.hide();
- }
+ if (!$.isArray(o)) {
+ const tmp = o
+ o = []
+ o.push(tmp)
+ }
- } else {
+ let widest = 5
+ for (let i = 0; i < o.length; i++) {
+ widest = Math.max(widest, nuGetWordWidth(o[i]))
+ }
- if (obj[i].read != 2) {
+ widest = Math.min(widest + 200, 1000)
+ let w = window.visualViewport.width - 42 // -- subtract padding, border
+ const l = Math.max(0, $(this).scrollLeft() + (w - widest) / 2)
+ w = Math.min(w, widest)
- if (oType == 'contentbox') {
- jId.attr('nu-mobileview-hidden', '');
- jId.hide();
- } else {
+ $('body', par).append("")
- $('#label_' + id).css({ 'top': top + 2, 'left': 7, 'text-align': 'left', 'font-weight': 700 });
+ const msgDiv = $('#nuMessageDiv', par)
- const sameRow = jId.is('[data-nu-same-row]');
- if (columns == 1 && !sameRow) {
- top = top + heightLabel + 5;
- }
+ for (let i = 0; i < o.length; i++) {
+ msgDiv.append(o[i]).append('
')
+ }
- if (jId.is('[data-select2-id]')) {
- jId = $('#' + id + '_select2');
- }
+ if (timeout !== undefined) {
+ setTimeout(function () {
+ $('#nuMessageDiv', par).fadeOut('slow')
- if (sameRow) {
- const spacing = jId.attr('data-nu-same-row') || 0
- jId.css({ 'top': oTop, 'left': Number(oWidth) + Number(spacing) });
- } else {
- jId.css({ 'top': top, 'left': lw + 10 });
- }
+ if (callback !== undefined) {
+ callback()
+ }
+ }, timeout)
+ }
- if (oType == 'lookup') {
+ nuDragElement(msgDiv[0], 30)
- const w = $('#' + id + 'code').outerWidth()
- const d = $('#' + id + 'description').outerWidth()
- width = Math.max(width, w + d + 30);
+ return msgDiv
+}
- $('#' + id + 'code').css({ 'top': top, 'left': lw + 10 });
- $('#' + id + 'button').css({ 'top': top, 'left': lw + w + 15 });
- top += 35;
- $('#' + id + 'description').css({ 'top': top, 'left': lw + 10, 'width': w - 5 });
+function nuWindowPosition () {
+ const p = window.parent.document
- } else if (obj[i].input == 'file') {
- top += 5;
- $('#' + id + '_file').css({ 'top': top, 'left': lw + 10 });
- top += 5;
- }
+ let d = $('#nuDragDialog', p)
- oWidth = lw + 10 + Number(obj[i].width);
- oTop = top;
+ const l = parseInt(d.css('left'), 10)
+ const t = parseInt(d.css('top'), 10)
+ let w = parseInt(d.css('width'), 10)
+ let h = parseInt(d.css('height'), 10)
- if (!sameRow) {
- top = top + height + 5;
- }
+ window.nuDialogSize = { left: l, top: t, width: w, height: h }
- }
+ d = $('#nuWindow', p)
- }
+ w = parseInt(d.css('width'), 10)
+ h = parseInt(d.css('height'), 10)
- }
- }
+ window.nuWindowSize = { width: w, height: h }
+}
- $("[data-nu-tab!='x'][data-nu-form='']:not([data-nu-lookup-id]):not([nu-mobileview-hidden])").show();
- $('#nuTabHolder').hide();
+function nuNoDuplicates () {
+ window.nuDuplicate = true
- top = top + 50;
+ $('.nuTabHolder.nuDuplicate').each(function () {
+ const t = $(this).html()
+ const f = $(this).attr('data-nu-field')
+ const s = $(this).attr('data-nu-subform')
+ const sf = nuSubformObject(s)
+ const a = []
+ const c = sf.fields.indexOf(f)
- $('#nuRECORD').append('
');
+ for (let i = 0; i < sf.rows.length; i++) {
+ if (sf.deleted[i] == 0) {
+ const rv = sf.rows[i][c]
- if (columns == 1) {
- $('label').css('text-align', 'right').css({ 'width': width, 'text-align': 'left', 'left': 12 });
- } else {
- $('label').css('text-align', 'left').css('width', lw);
- }
+ if (a.indexOf(rv) != -1) {
+ nuMessage(['Duplicate ' + t + ' on row ' + i + ''])
+ window.nuDuplicate = false
+ return
+ }
- var objectWidth = width + lw + 50;
- var screenWidth = window.innerWidth;
- var scale = screenWidth / (objectWidth);
+ a.push(sf.rows[i][c])
+ }
+ }
+ })
- $('#nubody').css('width', objectWidth).css('transform', 'scale(' + scale + ')')
- $('html,body').scrollTop(0).scrollLeft(0);
- window.scrollTo(0, 0);
+ return window.nuDuplicate
+}
- $('#nuBreadcrumbHolder').css('width', window.visualViewport.width);
+function nuFormType () {
+ if (nuFORM.getCurrent() == undefined) { return '' }
+ return nuRecordId() == '' ? 'browse' : 'edit'
+}
- return scale;
+function nuFormId () {
+ if (nuFORM.getCurrent() == undefined) { return '' }
+ return nuFORM.getCurrent().form_id
+}
+function nuRecordId () {
+ if (nuFORM.getCurrent() == undefined) { return '' }
+ return nuFORM.getCurrent().record_id
}
-function nuMobileView(mobileView) {
+function nuBuildFastReport () {
+ const sf = nuSubformObject('fast_report_sf')
+ let left = 3
+ const rows = sf.rows
+ window.nuNextID = 0
+ window.nuREPORT = JSON.parse(JSON.stringify(window.nuREPORTdefault))
- if (nuUXOptions.nuMobileView && mobileView == '1') {
- if (nuFormType() == 'edit') {
- nuPortraitScreen();
- $('button').css('text-align', 'left');
- } else {
- $('#nuBreadcrumbHolder').css('width', window.visualViewport.width);
- }
- }
+ for (let i = 0; i < rows.length; i++) {
+ if (sf.deleted[i] == '0') {
+ const title = rows[i][1]
+ const field = rows[i][2]
+ const width = Number(rows[i][3])
+ const sum = rows[i][4]
+ const align = sum == 0 ? 'left' : 'right'
-}
+ let o = JSON.parse(JSON.stringify(window.nuOBJECT)) // -- title
+ o.left = Number(left)
+ o.width = width
+ o.top = 70
+ o.fieldName = title
+ o.objectType = 'label'
+ o.textAlign = align
-function nuPortraitLabelWidth(o) {
+ nuFastObject(2, 0, o)
- var w = 0
- $('label').css('width', '');
+ o = JSON.parse(JSON.stringify(window.nuOBJECT)) // -- field
+ o.left = Number(left)
+ o.width = width
+ o.fieldName = field
+ o.textAlign = align
- for (var i = 0; i < o.length; i++) {
- w = nuGetWordWidth($('#label_' + o[i].id).html());
- }
+ nuFastObject(0, 0, o)
- return w + 15;
+ if (align == 'right') {
+ o = JSON.parse(JSON.stringify(window.nuOBJECT)) // -- sum
+ o.left = Number(left)
+ o.width = width
+ o.fieldName = 'SUM(' + field + ')'
+ o.textAlign = align
-}
+ nuFastObject(1, 1, o)
+ }
+
+ left = left + width + 2
+ }
+ }
-function nuGetBrowsePaginationInfo() {
+ nuFastReportFormat(left)
- const r = $("div[id^='nucell_']" + "[id$='_1']").length; // Number of Rows per page
+ $('#fieldlist').val(JSON.stringify(window.nuREPORT))
- const cf = nuFORM.getCurrent();
+ nuFORM.setProperty('nuREPORT', window.nuREPORT)
+}
+
+function nuFastObject (g, s, o) {
+ o.id = 'obj' + nuPad3(window.nuNextID)
+ o.name = o.id
+ o.left = Number(o.left) + 2
+
+ nuREPORT.groups[g].sections[s].objects.push(o)
+
+ window.nuNextID++
+}
+
+function nuNewFastObject () {
+ const o = JSON.parse(JSON.stringify(window.nuOBJECT))
+ o.id = 'obj' + nuPad3(window.nuNextID)
+ o.name = o.id
+
+ window.nuNextID++
+
+ return o
+}
+
+function nuFastReportFormat (width) {
+ let o = nuNewFastObject() // -- report title
+ o.left = 2
+ o.top = 10
+ o.width = 300
+ o.height = 30
+ o.fontWeight = 'b'
+ o.fontSize = '20'
+ o.objectType = 'label'
+ nuREPORT.width = 297
+ nuREPORT.height = 210
+ const pageWidth = 290 * 4
+ const sf = nuSubformObject('fast_report_sf')
+
+ nuREPORT.orientation = 'L'
+ nuREPORT.groups[3].sortField = sf.rows[0][2]
+ nuREPORT.groups[2].sections[0].height = 100
+ nuREPORT.groups[2].sections[0].objects.push(o)
+
+ o = nuNewFastObject() // -- underline titles
+ o.left = 2
+ o.top = 93
+ o.width = width
+ o.height = 1
+ o.borderWidth = 1
+ o.objectType = 'label'
+ o.fieldName = 'KEEP EXACT HEIGHT'
+
+ nuREPORT.groups[2].sections[0].objects.push(o)
+
+ o = nuNewFastObject() // -- page footer
+ o.left = 2
+ o.top = 3
+ o.width = pageWidth
+ o.height = 1
+ o.borderWidth = 1
+ o.objectType = 'label'
+ o.fieldName = 'KEEP EXACT HEIGHT'
+
+ nuREPORT.groups[2].sections[1].objects.push(o)
- const c = cf.page_number; // Current page number
- const f = cf.browse_filtered_rows; // Number of records in the table after filtering
- const p = cf.pages; // Total number of pages
+ o = nuNewFastObject() // -- page footer date
+ o.left = 2
+ o.top = 9
+ o.width = 600
+ o.fieldName = 'Printed : #day#-#month#-20#year# #hour#:#minute#:#second#'
+ o.objectType = 'label'
- var e; // Row number of the last record on the current page
- var s; // Row number of the first record on the current page
+ nuREPORT.groups[2].sections[1].objects.push(o)
- if (c == 0 && f > 0 && p == 1) {
- s = 1;
- e = f;
- } else
- if (p == c + 1 || f == 0) {
- s = f == 0 ? 0 : c * r + 1;
- e = f;
- } else
- if (c == 0 && p > 1) {
- s = 1;
- e = r;
- } else
- if (c > 0 && c < p) {
- e = (c + 1) * r;
- s = e - r + 1;
- }
+ o = nuNewFastObject() // -- page footer page no.
+ o.top = 9
+ o.left = pageWidth - 200
+ o.width = 200
+ o.textAlign = 'right'
+ o.fieldName = 'Page #page# of #pages#'
+ o.objectType = 'label'
- return {
- startRow: s,
- endRow: e,
- totalRows: f // filtered rows
- };
+ nuREPORT.groups[2].sections[1].objects.push(o)
+
+ if (nuREPORT.groups[1].sections[1].objects.length > 0) {
+ nuNewFastObject() // -- overline sums
+ o.left = 2
+ o.top = 3
+ o.width = width
+ o.height = 1
+ o.borderWidth = 1
+ o.objectType = 'label'
+ o.fieldName = 'KEEP EXACT HEIGHT'
+ nuREPORT.groups[1].sections[1].objects.push(o)
+ }
}
-function nuShowBrowsePaginationInfo(f) {
-
- if (nuFormType() == 'browse') {
+function nuRedefine_nuSelectBrowse () {
+ nuSelectBrowse = function (e, t) {
+ const y = window.nuBrowseFunction // -- browse, lookup or custom function name
+ const pk = $('#' + t.id).attr('data-nu-primary-key')
+ const formId = window.nuFORM.getProperty('form_id')
+ const formIdRedirect = window.nuFORM.getProperty('redirect_form_id')
+ const formType = window.nuFORM.getProperty('form_type')
+ const ro = window.nuFORM.getProperty('redirect_other_form_id')
+
+ if (formType == 'browse' && ro == '' && parent.$('#nuDragDialog').length == 0) {
+ nuSelectBrowse = function (e, t) { }
+ return
+ }
+
+ nuCursor('progress')
+
+ if (y == 'browse') {
+ nuForm(formIdRedirect == '' ? formId : formIdRedirect, pk)
+ } else if (y == 'lookup') {
+ window.parent.nuGetLookupId(pk, window.nuTARGET) // -- called from parent window
+ } else {
+ window[y](e)
+ }
+
+ if ((nuIsMacintosh() ? e.metaKey : e.ctrlKey) == false) {
+ nuSelectBrowse = function (e, t) { } // -- so that it doesn't run twice.
+ }
+ }
+}
+
+function nuSetVerticalTabs () {
+ const tabHolder = $('#nuTabHolder')
+ tabHolder.css('display', 'inline-block')
+ $('.nuTab').css('display', 'block')
+ $('#nuRecord').css('display', 'inline-block')
+ $('.nuTab').css('padding', '8px 2px 0px 2px')
+ tabHolder.css('height', window.innerHeight)
- var {
- startRow
- , endRow
- , totalRows
- } = nuGetBrowsePaginationInfo();
+ let w = 0
- if (f === 'default')
- f = '{StartRow} - {EndRow} ' + nuTranslate('of') + ' ' + '{TotalRows}';
+ const s = ' '
+ $('.nuTab').each(function () {
+ $(this).html($(this).html().includes(s) ? $(this).html() : s + $(this).html())
+ w = Math.max(w, nuGetWordWidth($(this).html()))
+ })
- const p = f.nuFormat({ StartRow: startRow, EndRow: endRow, TotalRows: totalRows });
+ tabHolder.css('width', w + 30)
+ $('.nuTab').css('width', w + 30)
- $('#nuBrowseFooter').append('');
+ window.nuVerticalTabs = true
+}
- }
+function nuHasBeenSaved () {
+ return window.nuTimesSaved
+}
+function nuResponseDefault () {
+ if (nuFormType() == 'edit') {
+ nuRESPONSIVE.resetDefault('', false)
+ }
}
-function nuPrintEditForm(hideObjects, showObjects) {
+function nuResponseWrap () {
+ if (nuFormType() == 'edit') {
+ nuRESPONSIVE.setTabsColumn('', false)
+ }
+}
- // hide some elements before calling the print dialog
- $('#nuBreadcrumbHolder').hide();
- $('#nuTabHolder').hide();
- $('.nuActionButton').hide();
+function nuResponseNoWrap () {
+ if (nuFormType() == 'edit') {
+ nuRESPONSIVE.setTabsColumn('', true)
+ }
+}
- if (!hideObjects) {
- hideObjects = [];
- }
+function nuResponsiveWrap (width, wrap) {
+ if (window.innerWidth >= width) {
+ nuResponseDefault()
+ }
- if (!showObjects) {
- showObjects = [];
- }
+ if (window.innerWidth < width) {
+ if (window.innerWidth < wrap) {
+ nuResponseWrap()
+ } else {
+ nuResponseNoWrap()
+ }
+ }
+}
- for (let i = 0; i < hideObjects.length; i++) {
- nuHide(hideObjects[i]);
- }
+function nuBrowseBorders () {
+ const r = nuSERVERRESPONSE.rows
+ const c = nuSERVERRESPONSE.browse_columns.length
- for (let i = 0; i < showObjects.length; i++) {
- nuShow(hideObjects[i]);
- }
+ for (let i = 0; i < c; i++) {
+ $('#nucell_0_' + i).addClass('nuBrowseBorderTop')
+ $('#nucell_' + (r - 1) + '_' + i).addClass('nuBrowseBorderBottom')
+ }
+}
- window.onafterprint = function () {
- $(window).off('mousemove', window.onafterprint);
+function nuObjectPosition (id) {
+ const $id = $('#' + id)
+ const t = parseInt($id.css('top'), 10)
+ const l = parseInt($id.css('left'), 10)
+ const h = parseInt($id.css('height'), 10)
+ const w = parseInt($id.css('width'), 10)
- // Show the elements again when the dialog closes
- $('#nuBreadcrumbHolder').show();
- $('#nuTabHolder').show();
- $('.nuActionButton').show();
+ const b = t + h // bottom
+ const r = l + w // right
+ return { t, l, h, w, b, r }
+}
- for (let i = 0; i < hideObjects.length; i++) {
- nuShow(hideObjects[i]);
- }
+function nuFormWH () {
+ let width = 0
+ let height = 0
+ let s = '[data-nu-object-id][data-nu-prefix=""], [data-nu-subform=true]'
- for (let i = 0; i < showObjects.length; i++) {
- nuHide(hideObjects[i]);
- }
+ if (nuSERVERRESPONSE.record_id == -2) {
+ s = '[data-nu-object-id]'
+ }
- };
+ $(s).each(function () {
+ const { t, l, h, w } = nuObjectPosition($(this).attr('id'))
- window.print();
+ width = Math.max(width, w + l)
+ height = Math.max(height, h + t)
+ })
- setTimeout(function () {
- $(window).one('mousemove', window.onafterprint);
- }, 1);
+ return { width, height }
}
-function nuAddBrowseAdditionalNavButtons() {
+function nuResizeFormDialogCoordinates () {
+ const wh = nuFormWH()
+ let w = wh.width
+ let h = wh.height
- if (nuFormType() == 'browse') {
+ w = w + 40
+ h = h + nuDialogHeadersHeight() + 50
- var disabled = {
- 'opacity': '0.3',
- 'pointer-events': 'none'
- };
+ const parentDocument = window.parent.document
+ const windowInnerHeight = window.innerHeight
+ const $body = $('body')
- var currentPage = Number($('#browsePage').val());
- var lastPage = nuCurrentProperties().pages;
+ const dragDlg = $('#nuDragDialog', parentDocument)
+ if (dragDlg.length == 0) { return }
- var html = ' ';
- $(html).insertBefore("#nuLast");
+ dragDlg.css('visibility', 'visible')
+ dragDlg.css('width', w + 12)
+ $('#nuWindow', parentDocument).css('width', w)
+ $body.css('width', w)
- html = ' ';
- $(html).insertAfter("#nuNext");
+ dragDlg.css('height', h + 50).css('visibility', 'visible')
+ $('#nuWindow', parentDocument).css('height', h + 10)
+ $body.css('height', windowInnerHeight)
- if (currentPage == 1) {
- $('#nuFirst').css(disabled);
- $('#nuLast').css(disabled);
- }
+ if (h < windowInnerHeight) {
+ $body.css('height', '100%')
+ } else {
+ $body.css('height', h)
+ }
- if (currentPage == lastPage) {
- $('#nuNext').css(disabled);
- $('#nuEnd').css(disabled);
- }
- }
+ if (w > window.innerWidth) {
+ const html = window.innerHTML
+ $('#nuBreadcrumbHolder').css('width', html)
+ $('#nuTabHolder').css('width', html)
+ $('#nuActionHolder').css('width', html)
+ }
+}
+
+function nuClickTab (t, s) {
+ t = 'nuTab' + t
+
+ if (arguments.length == 2) {
+ t = s + t
+ }
+ nuSelectTab($('#' + t)[0])
}
-function nuPromptModal() {
+function nuFilterRun (id, filter) {
+ const r = JSON.parse(JSON.stringify(nuSERVERRESPONSE))
+ let o = -1
- this.render = function (text, caption, defaultValue, format, fctn) {
+ for (let i = 0; i < r.objects.length; i++) {
+ const obj = r.objects[i]
+ if (obj.id == id) {
+ if (filter) {
+ if (obj.filter == filter) { return }
+ obj.filter = filter
+ }
- let winW = window.innerWidth;
- let winH = window.innerHeight;
- let modal = document.getElementById('nupromptmodal');
- let nuprompt = document.getElementById('nuprompt');
- modal.style.display = "block";
- modal.style.height = winH + "px";
- nuprompt.style.left = (winW / 2) - (560 * 0.5) + "px";
- nuprompt.style.top = "5px";
- nuprompt.style.display = "block";
- document.getElementById('nuprompthead').innerHTML = caption;
- let body = document.getElementById('nupromptbody');
- body.innerHTML = text;
- body.innerHTML += '
';
- document.getElementById('nupromptfoot').innerHTML = ' ';
+ o = i
+ }
+ }
- let value1 = document.getElementById("prompt_value1");
- value1.value = defaultValue === undefined ? '' : defaultValue;
- value1.focus();
+ if (o == -1) { return }
- }
+ nuRUN(r, o, '', '', r)
+}
- $('#prompt_value1').focus();
+function nuRecordRun (id, filter) {
+ const r = JSON.parse(JSON.stringify(nuSERVERRESPONSE))
+ let o = -1
- this.inputkeyup = function (e, fctn) {
- if (e.which == 13) { //-- Enter
- this.ok(fctn);
- } else if (e.which == 27) { //-- ESC
- this.cancel(fctn);
- }
- }
+ for (let i = 0; i < r.objects.length; i++) {
+ const obj = r.objects[i]
+ if (obj.id == id) {
+ if (filter) {
+ if (obj.record_id == filter) { return }
+ obj.record_id = filter
+ }
- this.cancel = function (fctn) {
- window[fctn](null, false);
- document.getElementById('nupromptmodal').style.display = "none";
- document.getElementById('nuprompt').style.display = "none";
- }
+ o = i
+ }
+ }
- this.ok = function (fctn) {
- var prompt_value1 = document.getElementById('prompt_value1').value;
- window[fctn](prompt_value1, true);
- document.getElementById('nupromptmodal').style.display = "none";
- document.getElementById('nuprompt').style.display = "none";
- }
+ if (o == -1) { return }
+ nuRUN(r, o, '', '', r)
}
-function nuOnPromptClose(val, ok) {
+function nuGetIframeValue (f, o, method) {
+ const obj = $('#' + f).contents().find('#' + o)
+ return (!method || method == 'val') ? obj.val() : obj.html()
}
-function nuPrompt(text, caption, defaultValue, format, fctn) {
-
- if ($('#nupromptmodal').length == 0) {
+function nuSetIframeValue (f, o, v, method) {
+ const obj = $('#' + f).contents().find('#' + o)
+ return (!method || method == 'val') ? obj.val(v) : obj.html(v)
+}
- let nuPromptDiv =
- `
+function nuLookingUp () {
+ for (const lu in window.nuLOOKUPSTATE) {
+ if (window.nuLOOKUPSTATE[lu] == 'looking') {
+ nuMessage([nuTranslate('A Lookup is still being populated...')])
+ return true
+ }
+ }
- `;
+ return false
+}
- $('body').append(nuPromptDiv);
- promot = new nuPromptModal();
+function nuPortraitScreen (columns) {
+ function nuPortraitScreenObjDimensions (id, jId) {
+ let height = jId.outerHeight()
- }
+ if (jId.is('[data-select2-id]')) {
+ height = jId.data('nu-org-height') + 50
+ }
- fctn = nuDefine(fctn, 'nuOnPromptClose');
+ if (!jId.is('[nu-mobileview-hidden]')) {
+ width = Math.max(width, jId.outerWidth())
+ }
- promot.render(text, caption, defaultValue, format, fctn);
+ const heightLabel = $('#label_' + id).length == 0 ? 0 : $('#label_' + id).outerHeight()
-}
+ return { height, width, heightLabel }
+ }
-function nuAddBrowseTitleSelect(index, data, w) {
+ $('#nubody').css('transform', 'scale(1)')
- if (!$.isArray(data)) return;
+ if (nuFormType() == 'browse') { return }
- var id = "nuBrowseTitle" + index + "_select";
- var list = document.createElement('select');
- list.setAttribute("id", id);
+ $('.nuBuilderLink').remove()
+ if (arguments.length == 0) { columns = 1 }
- if (w === undefined) {
- w = nuCurrentProperties().column_widths == 0 ? nuCurrentProperties().browse_columns[index].width : nuCurrentProperties().column_widths[index] - 3;
- }
+ $('.nuPortraitTab').remove()
- list.setAttribute('style', 'width:' + w + 'px');
+ const obj = nuSERVERRESPONSE.objects
+ const lw = columns == 1 ? 0 : nuPortraitLabelWidth(obj)
+ let top = 0
+ let b = -1
+ var width = 0
+ let oWidth = 0
+ let oTop = 0
- var is1DArray = data[0][0] === undefined;
- data.forEach(function (a) {
- var opt = document.createElement('option');
- opt.value = is1DArray ? a : a[0];
- opt.innerHTML = is1DArray ? a : a[1];
- list.appendChild(opt);
- });
+ for (let i = 0; i < obj.length; i++) {
+ const oType = obj[i].type
- var obj = $('#nuBrowseTitle' + index);
- obj.append('
').append(list);
+ const id = obj[i].id
+ let jId = $('#' + id)
- $('#' + id).on('change', function () {
- nuSetProperty(this.id, this.value);
- nuSearchAction();
- });
+ let { height, width, heightLabel } = nuPortraitScreenObjDimensions(id, jId)
- obj.on('mousedown', '> select', function (e) {
- e.stopPropagation();
- });
+ const jtab = $('#nuTab' + obj[i].tab)
+ let tabVisible = jtab.nuIsVisible()
- $("#" + id).val(nuGetProperty(id));
+ if (obj[i].tab != b && tabVisible && !window.nuPortraitScreenShowTabTitles == false) {
+ if ($('.nuTab').length > 1) {
+ b = obj[i].tab
+ const l = jtab.html()
+ const d = '' + l + '
'
+ $('#nuRECORD').append(d)
+ const OH = $('#nuPort' + b).outerHeight()
- return $('#' + id);
+ top = top + OH + 5
+ }
+ }
-}
+ tabVisible = jtab.nuIsVisible() || $('.nuTab').length == 1
-function nuDatalistValueRestoreValue(i) {
+ if (jId.is('[nu-mobileview-hidden]') || !tabVisible) {
+ const objComponents = nuObjectComponents(id)
- let t = $('#' + i);
- if (t.val() === '') {
+ for (let c = 0; c < objComponents.length; c++) {
+ const comp = $('#' + objComponents[c])
+ comp.attr('nu-mobileview-hidden', '')
+ comp.hide()
+ }
+ } else {
+ if (obj[i].read != 2) {
+ if (oType == 'contentbox') {
+ jId.attr('nu-mobileview-hidden', '')
+ jId.hide()
+ } else {
+ $('#label_' + id).css({ top: top + 2, left: 7, 'text-align': 'left', 'font-weight': 700 })
- if (t.attr('org-placeholder') !== t.attr('placeholder')) {
- t.val(t.attr('placeholder'));
- }
+ const sameRow = jId.is('[data-nu-same-row]')
+ if (columns == 1 && !sameRow) {
+ top = top + heightLabel + 5
+ }
- t.attr('placeholder', '');
- if (t.val() === '') {
- t.attr('placeholder', t.attr('org-placeholder'));
- }
+ if (jId.is('[data-select2-id]')) {
+ jId = $('#' + id + '_select2')
+ }
- }
+ if (sameRow) {
+ const spacing = jId.attr('data-nu-same-row') || 0
+ jId.css({ top: oTop, left: Number(oWidth) + Number(spacing) })
+ } else {
+ jId.css({ top, left: lw + 10 })
+ }
+
+ if (oType == 'lookup') {
+ const w = $('#' + id + 'code').outerWidth()
+ const d = $('#' + id + 'description').outerWidth()
+ width = Math.max(width, w + d + 30)
+
+ $('#' + id + 'code').css({ top, left: lw + 10 })
+ $('#' + id + 'button').css({ top, left: lw + w + 15 })
+ top += 35
+ $('#' + id + 'description').css({ top, left: lw + 10, width: w - 5 })
+ } else if (obj[i].input == 'file') {
+ top += 5
+ $('#' + id + '_file').css({ top, left: lw + 10 })
+ top += 5
+ }
+
+ oWidth = lw + 10 + Number(obj[i].width)
+ oTop = top
+
+ if (!sameRow) {
+ top = top + height + 5
+ }
+ }
+ }
+ }
+ }
+
+ $("[data-nu-tab!='x'][data-nu-form='']:not([data-nu-lookup-id]):not([nu-mobileview-hidden])").show()
+ $('#nuTabHolder').hide()
+
+ top = top + 50
+
+ $('#nuRECORD').append('
')
+
+ if (columns == 1) {
+ $('label').css('text-align', 'right').css({ width, 'text-align': 'left', left: 12 })
+ } else {
+ $('label').css('text-align', 'left').css('width', lw)
+ }
+
+ const objectWidth = width + lw + 50
+ const screenWidth = window.innerWidth
+ const scale = screenWidth / (objectWidth)
+
+ $('#nubody').css('width', objectWidth).css('transform', 'scale(' + scale + ')')
+ $('html,body').scrollTop(0).scrollLeft(0)
+ window.scrollTo(0, 0)
+
+ $('#nuBreadcrumbHolder').css('width', window.visualViewport.width)
+
+ return scale
+}
+
+function nuMobileView (mobileView) {
+ if (nuUXOptions.nuMobileView && mobileView == '1') {
+ if (nuFormType() == 'edit') {
+ nuPortraitScreen()
+ $('button').css('text-align', 'left')
+ } else {
+ $('#nuBreadcrumbHolder').css('width', window.visualViewport.width)
+ }
+ }
+}
+
+function nuPortraitLabelWidth (o) {
+ let w = 0
+ $('label').css('width', '')
+
+ for (let i = 0; i < o.length; i++) {
+ w = nuGetWordWidth($('#label_' + o[i].id).html())
+ }
+
+ return w + 15
+}
+
+function nuGetBrowsePaginationInfo () {
+ const r = $("div[id^='nucell_']" + "[id$='_1']").length // Number of Rows per page
+
+ const cf = nuFORM.getCurrent()
+
+ const c = cf.page_number // Current page number
+ const f = cf.browse_filtered_rows // Number of records in the table after filtering
+ const p = cf.pages // Total number of pages
+
+ let e // Row number of the last record on the current page
+ let s // Row number of the first record on the current page
+
+ if (c == 0 && f > 0 && p == 1) {
+ s = 1
+ e = f
+ } else
+ if (p == c + 1 || f == 0) {
+ s = f == 0 ? 0 : c * r + 1
+ e = f
+ } else
+ if (c == 0 && p > 1) {
+ s = 1
+ e = r
+ } else
+ if (c > 0 && c < p) {
+ e = (c + 1) * r
+ s = e - r + 1
+ }
+ return {
+ startRow: s,
+ endRow: e,
+ totalRows: f // filtered rows
+ }
+}
+
+function nuShowBrowsePaginationInfo (f) {
+ if (nuFormType() == 'browse') {
+ const {
+ startRow
+ , endRow
+ , totalRows
+ } = nuGetBrowsePaginationInfo()
+
+ if (f === 'default') { f = '{StartRow} - {EndRow} ' + nuTranslate('of') + ' ' + '{TotalRows}' }
+
+ const p = f.nuFormat({ StartRow: startRow, EndRow: endRow, TotalRows: totalRows })
+
+ $('#nuBrowseFooter').append('')
+ }
}
-// Show all dropdown items when clicking on the datalist arrow down button
-function nuDatalistShowAllOnArrowClick(i) {
-
- $('#' + i)
- .on('click', function (e) {
- let t = $(this);
- if ((t.width() - (e.clientX - t.offset().left)) < 14) {
- if (t.val() !== "") {
- t.attr('placeholder', t.val());
- t.val('');
- }
- } else {
- nuDatalistValueRestoreValue(i)
- }
- })
+function nuPrintEditForm (hideObjects, showObjects) {
+ // hide some elements before calling the print dialog
+ $('#nuBreadcrumbHolder').hide()
+ $('#nuTabHolder').hide()
+ $('.nuActionButton').hide()
+
+ if (!hideObjects) {
+ hideObjects = []
+ }
+
+ if (!showObjects) {
+ showObjects = []
+ }
+
+ for (let i = 0; i < hideObjects.length; i++) {
+ nuHide(hideObjects[i])
+ }
+
+ for (let i = 0; i < showObjects.length; i++) {
+ nuShow(hideObjects[i])
+ }
+
+ window.onafterprint = function () {
+ $(window).off('mousemove', window.onafterprint)
+
+ // Show the elements again when the dialog closes
+ $('#nuBreadcrumbHolder').show()
+ $('#nuTabHolder').show()
+ $('.nuActionButton').show()
+
+ for (let i = 0; i < hideObjects.length; i++) {
+ nuShow(hideObjects[i])
+ }
+
+ for (let i = 0; i < showObjects.length; i++) {
+ nuHide(hideObjects[i])
+ }
+ }
+
+ window.print()
+
+ setTimeout(function () {
+ $(window).one('mousemove', window.onafterprint)
+ }, 1)
+}
+
+function nuAddBrowseAdditionalNavButtons () {
+ if (nuFormType() == 'browse') {
+ const disabled = {
+ opacity: '0.3',
+ 'pointer-events': 'none'
+ }
+
+ const currentPage = Number($('#browsePage').val())
+ const lastPage = nuCurrentProperties().pages
+
+ let html = ' '
+ $(html).insertBefore('#nuLast')
+
+ html = ' '
+ $(html).insertAfter('#nuNext')
+
+ if (currentPage == 1) {
+ $('#nuFirst').css(disabled)
+ $('#nuLast').css(disabled)
+ }
+
+ if (currentPage == lastPage) {
+ $('#nuNext').css(disabled)
+ $('#nuEnd').css(disabled)
+ }
+ }
+}
+
+function nuPromptModal () {
+ this.render = function (text, caption, defaultValue, format, fctn) {
+ const winW = window.innerWidth
+ const winH = window.innerHeight
+ const modal = document.getElementById('nupromptmodal')
+ const nuprompt = document.getElementById('nuprompt')
+ modal.style.display = 'block'
+ modal.style.height = winH + 'px'
+ nuprompt.style.left = (winW / 2) - (560 * 0.5) + 'px'
+ nuprompt.style.top = '5px'
+ nuprompt.style.display = 'block'
+ document.getElementById('nuprompthead').innerHTML = caption
+ const body = document.getElementById('nupromptbody')
+ body.innerHTML = text
+ body.innerHTML += '
'
+ document.getElementById('nupromptfoot').innerHTML = ' '
+
+ const value1 = document.getElementById('prompt_value1')
+ value1.value = defaultValue === undefined ? '' : defaultValue
+ value1.focus()
+ }
+
+ $('#prompt_value1').focus()
+
+ this.inputkeyup = function (e, fctn) {
+ if (e.which == 13) { // -- Enter
+ this.ok(fctn)
+ } else if (e.which == 27) { // -- ESC
+ this.cancel(fctn)
+ }
+ }
+
+ this.cancel = function (fctn) {
+ window[fctn](null, false)
+ document.getElementById('nupromptmodal').style.display = 'none'
+ document.getElementById('nuprompt').style.display = 'none'
+ }
+
+ this.ok = function (fctn) {
+ const prompt_value1 = document.getElementById('prompt_value1').value
+ window[fctn](prompt_value1, true)
+ document.getElementById('nupromptmodal').style.display = 'none'
+ document.getElementById('nuprompt').style.display = 'none'
+ }
+}
+
+function nuOnPromptClose (val, ok) {
+}
+
+function nuPrompt (text, caption, defaultValue, format, fctn) {
+ if ($('#nupromptmodal').length == 0) {
+ const nuPromptDiv =
+ `
- .on('mouseleave', function () {
- nuDatalistValueRestoreValue(this.id);
- })
+ `
+ $('body').append(nuPromptDiv)
+ promot = new nuPromptModal()
+ }
- .on('mouseenter', function () {
- if (!$(this).is("[org-placeholder]")) $(this).attr('org-placeholder', $(this).attr('placeholder'));
- })
+ fctn = nuDefine(fctn, 'nuOnPromptClose')
+ promot.render(text, caption, defaultValue, format, fctn)
}
-function nuSetSelect2(id, obj) {
+function nuAddBrowseTitleSelect (index, data, w) {
+ if (!$.isArray(data)) return
- let $id = $('#' + id);
+ const id = 'nuBrowseTitle' + index + '_select'
+ const list = document.createElement('select')
+ list.setAttribute('id', id)
- $id.attr('date-nu-select2', 1);
+ if (w === undefined) {
+ w = nuCurrentProperties().column_widths == 0 ? nuCurrentProperties().browse_columns[index].width : nuCurrentProperties().column_widths[index] - 3
+ }
- let select2Id = $('#' + id).attr('id') + "_select2";
+ list.setAttribute('style', 'width:' + w + 'px')
- let lang = (nuSERVERRESPONSE.language === null ? 'en' : nuSERVERRESPONSE.language.toLowerCase());
- let select2OptionsDefault = {
- dropdownParent: $('#nuRECORD'),
- selectionCssClass: select2Id,
- theme: nuUXOptions.nuSelect2Theme ? nuUXOptions.nuSelect2Theme : 'default',
- language: lang
- // placeholder: $id.attr('placeholder')
- };
+ const is1DArray = data[0][0] === undefined
+ data.forEach(function (a) {
+ const opt = document.createElement('option')
+ opt.value = is1DArray ? a : a[0]
+ opt.innerHTML = is1DArray ? a : a[1]
+ list.appendChild(opt)
+ })
- let objSelect2OptionsDefault = { options: select2OptionsDefault };
- let select2UserOptions = [];
+ const obj = $('#nuBrowseTitle' + index)
+ obj.append('
').append(list)
- if (typeof window.nuOnSetSelect2Options === 'function') {
- select2UserOptions = window.nuOnSetSelect2Options(id, objSelect2OptionsDefault);
- }
+ $('#' + id).on('change', function () {
+ nuSetProperty(this.id, this.value)
+ nuSearchAction()
+ })
- let select2Options = Object.assign(select2UserOptions, objSelect2OptionsDefault.options);
- // select2Options = {...objSelect2OptionsDefault.options, ...select2UserOptions};
+ obj.on('mousedown', '> select', function (e) {
+ e.stopPropagation()
+ })
- $id.data('nu-org-height', $id.outerHeight());
+ $('#' + id).val(nuGetProperty(id))
- $id.select2(select2Options);
+ return $('#' + id)
+}
- $('.' + select2Id).parent().parent().css({
- position: 'absolute',
- width: Number(obj.width),
- top: Number(obj.top),
- left: Number(obj.left)
- }).attr('id', select2Id);
+function nuDatalistValueRestoreValue (i) {
+ const t = $('#' + i)
+ if (t.val() === '') {
+ if (t.attr('org-placeholder') !== t.attr('placeholder')) {
+ t.val(t.attr('placeholder'))
+ }
+ t.attr('placeholder', '')
+ if (t.val() === '') {
+ t.attr('placeholder', t.attr('org-placeholder'))
+ }
+ }
+}
+// Show all dropdown items when clicking on the datalist arrow down button
+function nuDatalistShowAllOnArrowClick (i) {
+ $('#' + i)
+ .on('click', function (e) {
+ const t = $(this)
+ if ((t.width() - (e.clientX - t.offset().left)) < 14) {
+ if (t.val() !== '') {
+ t.attr('placeholder', t.val())
+ t.val('')
+ }
+ } else {
+ nuDatalistValueRestoreValue(i)
+ }
+ })
- return select2Id;
+ .on('mouseleave', function () {
+ nuDatalistValueRestoreValue(this.id)
+ })
+ .on('mouseenter', function () {
+ if (!$(this).is('[org-placeholder]')) $(this).attr('org-placeholder', $(this).attr('placeholder'))
+ })
}
-function nuGetFirstObject(objects, tabNr) {
+function nuSetSelect2 (id, obj) {
+ const $id = $('#' + id)
- if (objects.length > 0) {
+ $id.attr('date-nu-select2', 1)
- let obj0Id = null;
+ const select2Id = $('#' + id).attr('id') + '_select2'
- for (let i = 0; i < objects.length; i++) {
+ const lang = (nuSERVERRESPONSE.language === null ? 'en' : nuSERVERRESPONSE.language.toLowerCase())
+ const select2OptionsDefault = {
+ dropdownParent: $('#nuRECORD'),
+ selectionCssClass: select2Id,
+ theme: nuUXOptions.nuSelect2Theme ? nuUXOptions.nuSelect2Theme : 'default',
+ language: lang
+ // placeholder: $id.attr('placeholder')
+ }
- let id = objects[i].id;
- let obj = $('#' + id);
+ const objSelect2OptionsDefault = { options: select2OptionsDefault }
+ let select2UserOptions = []
- if (tabNr == -1 || obj.attr('data-nu-tab') == tabNr) {
- if (nuIsEnabled(id) && (nuIsVisible(id) || nuIsVisible(id + 'code') || nuIsVisible(id + '_select2'))) {
+ if (typeof window.nuOnSetSelect2Options === 'function') {
+ select2UserOptions = window.nuOnSetSelect2Options(id, objSelect2OptionsDefault)
+ }
- let c = obj.attr("class");
- if (c === undefined || !obj.attr("class").containsAny(['nuReadonly', 'nuHtml', 'nuImage', 'nuWord', 'nuCalculator', 'nuContentBoxContainer'])) {
- obj0Id = objects[i].id;
- break;
- }
- }
- }
+ const select2Options = Object.assign(select2UserOptions, objSelect2OptionsDefault.options)
+ // select2Options = {...objSelect2OptionsDefault.options, ...select2UserOptions};
- }
+ $id.data('nu-org-height', $id.outerHeight())
- if (obj0Id !== null) {
+ $id.select2(select2Options)
- let obj0Code = $('#' + obj0Id + 'code');
- if (obj0Code.length !== 0) {
- return obj0Code;
- }
+ $('.' + select2Id).parent().parent().css({
+ position: 'absolute',
+ width: Number(obj.width),
+ top: Number(obj.top),
+ left: Number(obj.left)
+ }).attr('id', select2Id)
- let select2 = $('#' + obj0Id + '_select2');
- return select2.length == 0 ? $('#' + obj0Id) : select2.children(":first").children(":first");
+ return select2Id
+}
- }
+function nuGetFirstObject (objects, tabNr) {
+ if (objects.length > 0) {
+ let obj0Id = null
- }
+ for (let i = 0; i < objects.length; i++) {
+ const id = objects[i].id
+ const obj = $('#' + id)
- return null;
+ if (tabNr == -1 || obj.attr('data-nu-tab') == tabNr) {
+ if (nuIsEnabled(id) && (nuIsVisible(id) || nuIsVisible(id + 'code') || nuIsVisible(id + '_select2'))) {
+ const c = obj.attr('class')
+ if (c === undefined || !obj.attr('class').containsAny(['nuReadonly', 'nuHtml', 'nuImage', 'nuWord', 'nuCalculator', 'nuContentBoxContainer'])) {
+ obj0Id = objects[i].id
+ break
+ }
+ }
+ }
+ }
-}
+ if (obj0Id !== null) {
+ const obj0Code = $('#' + obj0Id + 'code')
+ if (obj0Code.length !== 0) {
+ return obj0Code
+ }
-function nuAccessFormSetButtonIcons(force) {
+ const select2 = $('#' + obj0Id + '_select2')
+ return select2.length == 0 ? $('#' + obj0Id) : select2.children(':first').children(':first')
+ }
+ }
- function setInnerHTML(element, icon) {
- element.innerHTML = '
 ';
- }
+ return null
+}
- if (nuIsMobile() || force === true) {
- setInnerHTML(title_accformslf_add_button, 'fas fa-plus');
- setInnerHTML(title_accformslf_print_button, 'fas fa-print');
- setInnerHTML(title_accformslf_save_button, 'fas fa-save');
- setInnerHTML(title_accformslf_clone_button, 'fas fa-clone');
- setInnerHTML(title_accformslf_delete_button, 'fas fa-trash-alt');
- }
+function nuAccessFormSetButtonIcons (force) {
+ function setInnerHTML (element, icon) {
+ element.innerHTML = '
 '
+ }
+ if (nuIsMobile() || force === true) {
+ setInnerHTML(title_accformslf_add_button, 'fas fa-plus')
+ setInnerHTML(title_accformslf_print_button, 'fas fa-print')
+ setInnerHTML(title_accformslf_save_button, 'fas fa-save')
+ setInnerHTML(title_accformslf_clone_button, 'fas fa-clone')
+ setInnerHTML(title_accformslf_delete_button, 'fas fa-trash-alt')
+ }
}
-function nuSetBrowseNoDataMessage(str) {
- $('.nuBrowseNoData').html(nuTranslate(str));
+function nuSetBrowseNoDataMessage (str) {
+ $('.nuBrowseNoData').html(nuTranslate(str))
}
-function nuSetBrowseNoSearchResultsMessage(str) {
- $('.nuBrowseNoResults').html(nuTranslate(str));
+function nuSetBrowseNoSearchResultsMessage (str) {
+ $('.nuBrowseNoResults').html(nuTranslate(str))
}
-function nuSetSaveButtonPosition(t, l, h, w, fs) {
+function nuSetSaveButtonPosition (t, l, h, w, fs) {
+ const sb = $('#nuSaveButton')
+ sb.appendTo('div#nuRECORD')
- var sb = $('#nuSaveButton');
- sb.appendTo('div#nuRECORD');
+ // not defined or 0
+ if (!w) w = sb.cssNumber('width')
+ if (!h) h = sb.cssNumber('height')
- // not defined or 0
- if (!w) w = sb.cssNumber("width");
- if (!h) h = sb.cssNumber("height");
+ sb.css({
+ top: t + 'px',
+ left: l + 'px',
+ width: w + 'px',
+ position: 'absolute',
+ height: h + 'px',
+ margin: 'unset'
+ })
- sb.css({
- "top": t + "px",
- "left": l + "px",
- "width": w + "px",
- "position": "absolute",
- "height": h + "px",
- "margin": "unset"
- });
+ sb.attr('data-nu-tab', '0')
+ sb.attr('data-nu-form', '')
- sb.attr('data-nu-tab', '0');
- sb.attr('data-nu-form', '');
-
- if (fs) sb[0].style.fontSize = fs + "px";
- if (nuSelectedTabNumber() !== '0') sb.css('display', 'none');
-
- return sb;
+ if (fs) sb[0].style.fontSize = fs + 'px'
+ if (nuSelectedTabNumber() !== '0') sb.css('display', 'none')
+ return sb
}
-function nuAttachSaveButtonTo(i, dx, dy, h, w, fs) {
-
- var sb = $('#nuSaveButton');
- var dest = $('#' + i);
-
- if (dest === undefined || nuDebugOut(dest, i)) return false;
+function nuAttachSaveButtonTo (i, dx, dy, h, w, fs) {
+ const sb = $('#nuSaveButton')
+ const dest = $('#' + i)
- dest.after(sb);
+ if (dest === undefined || nuDebugOut(dest, i)) return false
- if (!dx || dx == 0) dx = 0;
- if (!dy || dy == 0) dy = 0;
- if (!w || w == 0) w = sb.cssNumber("width");
- if (!h || h == 0) h = sb.cssNumber("height");
+ dest.after(sb)
- sb.css({
- "top": dest.cssNumber("top") + dest.cssNumber("height") + 15 + dy,
- "left": dest.cssNumber("left") + dx,
- "width": w,
- "position": "absolute",
- "height": h,
- "margin": "unset"
- });
+ if (!dx || dx == 0) dx = 0
+ if (!dy || dy == 0) dy = 0
+ if (!w || w == 0) w = sb.cssNumber('width')
+ if (!h || h == 0) h = sb.cssNumber('height')
- sb.attr('data-nu-tab', '0');
- sb.attr('data-nu-form', '');
+ sb.css({
+ top: dest.cssNumber('top') + dest.cssNumber('height') + 15 + dy,
+ left: dest.cssNumber('left') + dx,
+ width: w,
+ position: 'absolute',
+ height: h,
+ margin: 'unset'
+ })
- if (fs) sb[0].style.fontSize = fs + "px";
- if (nuSelectedTabNumber() !== '0') sb.css('display', 'none');
+ sb.attr('data-nu-tab', '0')
+ sb.attr('data-nu-form', '')
- return sb;
+ if (fs) sb[0].style.fontSize = fs + 'px'
+ if (nuSelectedTabNumber() !== '0') sb.css('display', 'none')
+ return sb
}