gl-w-frontend
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -1,47 +0,1 @@ | ||
"use strict"; | ||
// import * as $ from 'jquery'; | ||
// import 'node_modules/jquery-ui-dist/jquery-ui.js'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_services_attachment_service_1 = require("./scripts/core/services/attachment/core-services-attachment.service"); | ||
var core_services_array_service_1 = require("./scripts/core/services/array/core-services-array.service"); | ||
var core_services_browser_service_1 = require("./scripts/core/services/browser/core-services-browser.service"); | ||
var core_services_combobox_service_1 = require("./scripts/core/services/combobox/core-services-combobox.service"); | ||
var core_services_elements_service_1 = require("./scripts/core/services/elements/core-services-elements.service"); | ||
// region Array | ||
var array = { removeArrayDuplicateLegacy: core_services_array_service_1.removeArrayDuplicateLegacy, sortByKey: core_services_array_service_1.sortByKey }; | ||
exports.array = array; | ||
var arraySort = { sortByKey: core_services_array_service_1.sortByKey }; | ||
exports.arraySort = arraySort; | ||
var arrayRemove = { removeArrayDuplicateLegacy: core_services_array_service_1.removeArrayDuplicateLegacy }; | ||
exports.arrayRemove = arrayRemove; | ||
// endregion | ||
// region Attachment | ||
var attachment = { validateFile: core_services_attachment_service_1.validateFile, validateFileSize: core_services_attachment_service_1.validateFileSize, textFileToUrlImage: core_services_attachment_service_1.textFileToUrlImage, parseAcceptFiles: core_services_attachment_service_1.parseAcceptFiles }; | ||
exports.attachment = attachment; | ||
var attachmentConvert = { textFileToUrlImage: core_services_attachment_service_1.textFileToUrlImage }; | ||
exports.attachmentConvert = attachmentConvert; | ||
var attachmentParse = { parseAcceptFiles: core_services_attachment_service_1.parseAcceptFiles }; | ||
exports.attachmentParse = attachmentParse; | ||
// endregion | ||
// region Browser | ||
var browser = { isIE: core_services_browser_service_1.isIE, isBeforeIE11: core_services_browser_service_1.isBeforeIE11, disableFullscreenListener: core_services_browser_service_1.disableFullscreenListener, fullscreenListener: core_services_browser_service_1.fullscreenListener, toggleFullScreen: core_services_browser_service_1.toggleFullScreen, hasFullscreen: core_services_browser_service_1.hasFullscreen }; | ||
exports.browser = browser; | ||
var browserVersion = { isIE: core_services_browser_service_1.isIE, isBeforeIE11: core_services_browser_service_1.isBeforeIE11 }; | ||
exports.browserVersion = browserVersion; | ||
var browserFullscreen = { disableFullscreenListener: core_services_browser_service_1.disableFullscreenListener, fullscreenListener: core_services_browser_service_1.fullscreenListener, toggleFullScreen: core_services_browser_service_1.toggleFullScreen, hasFullscreen: core_services_browser_service_1.hasFullscreen }; | ||
exports.browserFullscreen = browserFullscreen; | ||
// endregion | ||
// region ComboBox | ||
var comboBox = { initialize: core_services_combobox_service_1.initialize, loadData: core_services_combobox_service_1.loadData, dataByValue: core_services_combobox_service_1.dataByValue, disableInput: core_services_combobox_service_1.disableInput }; | ||
exports.comboBox = comboBox; | ||
var comboBoxCore = { initialize: core_services_combobox_service_1.initialize, loadData: core_services_combobox_service_1.loadData }; | ||
exports.comboBoxCore = comboBoxCore; | ||
var comboBoxData = { dataByValue: core_services_combobox_service_1.dataByValue }; | ||
exports.comboBoxData = comboBoxData; | ||
var comboBoxDom = { disableInput: core_services_combobox_service_1.disableInput }; | ||
exports.comboBoxDom = comboBoxDom; | ||
// endregion | ||
// region Elements | ||
var elements = { removeChildElements: core_services_elements_service_1.removeChildElements }; | ||
exports.elements = elements; | ||
//# sourceMappingURL=index.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var core_services_attachment_service_1=require("./scripts/core/services/attachment/core-services-attachment.service");var core_services_array_service_1=require("./scripts/core/services/array/core-services-array.service");var core_services_browser_service_1=require("./scripts/core/services/browser/core-services-browser.service");var core_services_combobox_service_1=require("./scripts/core/services/combobox/core-services-combobox.service");var core_services_elements_service_1=require("./scripts/core/services/elements/core-services-elements.service");var array={removeArrayDuplicateLegacy:core_services_array_service_1.removeArrayDuplicateLegacy,sortByKey:core_services_array_service_1.sortByKey};exports.array=array;var arraySort={sortByKey:core_services_array_service_1.sortByKey};exports.arraySort=arraySort;var arrayRemove={removeArrayDuplicateLegacy:core_services_array_service_1.removeArrayDuplicateLegacy};exports.arrayRemove=arrayRemove;var attachment={validateFile:core_services_attachment_service_1.validateFile,validateFileSize:core_services_attachment_service_1.validateFileSize,textFileToUrlImage:core_services_attachment_service_1.textFileToUrlImage,parseAcceptFiles:core_services_attachment_service_1.parseAcceptFiles};exports.attachment=attachment;var attachmentConvert={textFileToUrlImage:core_services_attachment_service_1.textFileToUrlImage};exports.attachmentConvert=attachmentConvert;var attachmentParse={parseAcceptFiles:core_services_attachment_service_1.parseAcceptFiles};exports.attachmentParse=attachmentParse;var browser={isIE:core_services_browser_service_1.isIE,isBeforeIE11:core_services_browser_service_1.isBeforeIE11,disableFullscreenListener:core_services_browser_service_1.disableFullscreenListener,fullscreenListener:core_services_browser_service_1.fullscreenListener,toggleFullScreen:core_services_browser_service_1.toggleFullScreen,hasFullscreen:core_services_browser_service_1.hasFullscreen};exports.browser=browser;var browserVersion={isIE:core_services_browser_service_1.isIE,isBeforeIE11:core_services_browser_service_1.isBeforeIE11};exports.browserVersion=browserVersion;var browserFullscreen={disableFullscreenListener:core_services_browser_service_1.disableFullscreenListener,fullscreenListener:core_services_browser_service_1.fullscreenListener,toggleFullScreen:core_services_browser_service_1.toggleFullScreen,hasFullscreen:core_services_browser_service_1.hasFullscreen};exports.browserFullscreen=browserFullscreen;var comboBox={initialize:core_services_combobox_service_1.initialize,loadData:core_services_combobox_service_1.loadData,dataByValue:core_services_combobox_service_1.dataByValue,disableInput:core_services_combobox_service_1.disableInput};exports.comboBox=comboBox;var comboBoxCore={initialize:core_services_combobox_service_1.initialize,loadData:core_services_combobox_service_1.loadData};exports.comboBoxCore=comboBoxCore;var comboBoxData={dataByValue:core_services_combobox_service_1.dataByValue};exports.comboBoxData=comboBoxData;var comboBoxDom={disableInput:core_services_combobox_service_1.disableInput};exports.comboBoxDom=comboBoxDom;var elements={removeChildElements:core_services_elements_service_1.removeChildElements};exports.elements=elements; |
@@ -1,26 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Remove items | ||
*/ | ||
exports.removeArrayDuplicateLegacy = function (array) { | ||
var unique = array.filter(function (item, index) { | ||
return array.indexOf(item) === index; | ||
}); | ||
return unique.sort(); | ||
}; | ||
/** | ||
* Sort Arrays | ||
*/ | ||
exports.sortByKey = function (array, key, asc) { | ||
return new Promise(function (resolve) { | ||
var _asc = asc ? 1 : -1; | ||
var sorted = array.sort(function (a, b) { | ||
var x = a[key]; | ||
var y = b[key]; | ||
return (x === y) ? 0 : ((x > y) ? _asc : -1 * _asc); | ||
}); | ||
resolve(sorted); | ||
}); | ||
}; | ||
//# sourceMappingURL=core-services-array.service.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.removeArrayDuplicateLegacy=function(array){var unique=array.filter(function(item,index){return array.indexOf(item)===index});return unique.sort()};exports.sortByKey=function(array,key,asc){return new Promise(function(resolve){var _asc=asc?1:-1;var sorted=array.sort(function(a,b){var x=a[key];var y=b[key];return x===y?0:x>y?_asc:-1*_asc});resolve(sorted)})}; |
@@ -1,68 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Convert | ||
**/ | ||
exports.textFileToUrlImage = function (file) { | ||
return new Promise(function (resolve) { | ||
var fileReader = new FileReader(); | ||
fileReader.addEventListener('load', function (e) { | ||
resolve(e.target.result); | ||
}); | ||
fileReader.readAsDataURL(file); | ||
}); | ||
}; | ||
/** | ||
* Parser | ||
**/ | ||
exports.parseAcceptFiles = function (accepts) { | ||
return accepts | ||
.replace(/image\//g, '') | ||
.replace(/x-/g, '') | ||
.replace(/\+xml/g, '') | ||
.replace(/ /g, '') | ||
.split(','); | ||
}; | ||
/** | ||
* Validate | ||
**/ | ||
exports.validateFile = function (input, accepts) { | ||
var fileName = input.value; | ||
var idxDot = fileName.lastIndexOf('.') + 1; | ||
var extFile = fileName.substr(idxDot, fileName.length).toLowerCase(); | ||
if (accepts.length === 1 && accepts[0] === '*') { | ||
return true; | ||
} | ||
for (var _i = 0, accepts_1 = accepts; _i < accepts_1.length; _i++) { | ||
var extension = accepts_1[_i]; | ||
if (extFile === extension) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
exports.validateFileSize = function (input) { | ||
if (input != null && input.files != null) { | ||
var fileSize = input.files[0].size / 1024; | ||
var maxSize = fileMaxSize(input); | ||
return fileSize <= maxSize; | ||
} | ||
else { | ||
console.error('Input is null.'); | ||
return false; | ||
} | ||
}; | ||
/** | ||
* The user must include the attribute 'data-maxsize' in mb(megabyte); | ||
* @param input | ||
*/ | ||
var fileMaxSize = function (input) { | ||
var fileName = input.attributes['data-maxsize'].nodeValue; | ||
if (fileName) { | ||
return parseInt(fileName, 10); | ||
} | ||
else { | ||
return 1024 * 45; | ||
} | ||
}; | ||
//# sourceMappingURL=core-services-attachment.service.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.textFileToUrlImage=function(file){return new Promise(function(resolve){var fileReader=new FileReader;fileReader.addEventListener("load",function(e){resolve(e.target.result)});fileReader.readAsDataURL(file)})};exports.parseAcceptFiles=function(accepts){return accepts.replace(/image\//g,"").replace(/x-/g,"").replace(/\+xml/g,"").replace(/ /g,"").split(",")};exports.validateFile=function(input,accepts){var fileName=input.value;var idxDot=fileName.lastIndexOf(".")+1;var extFile=fileName.substr(idxDot,fileName.length).toLowerCase();if(accepts.length===1&&accepts[0]==="*"){return true}for(var _i=0,accepts_1=accepts;_i<accepts_1.length;_i++){var extension=accepts_1[_i];if(extFile===extension){return true}}return false};exports.validateFileSize=function(input){if(input!=null&&input.files!=null){var fileSize=input.files[0].size/1024;var maxSize=fileMaxSize(input);return fileSize<=maxSize}else{console.error("Input is null.");return false}};var fileMaxSize=function(input){var fileName=input.attributes["data-maxsize"].nodeValue;if(fileName){return parseInt(fileName,10)}else{return 1024*45}}; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=core-services-browser.interfaces.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true}); |
@@ -1,86 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var screenfull = require("screenfull"); | ||
/** | ||
* Ffullscreen | ||
*/ | ||
exports.fullscreenListener = function (menuButton, alt, src, showLog) { | ||
if (showLog === void 0) { showLog = false; } | ||
if (screenfull.isEnabled) { | ||
// @ts-ignore | ||
screenfull.on('change', function () { | ||
// @ts-ignore | ||
if (screenfull.isFullscreen) { | ||
menuButton.src = src.exit; | ||
menuButton.alt = alt.exit; | ||
} | ||
else { | ||
menuButton.src = src.enter; | ||
menuButton.alt = alt.enter; | ||
} | ||
if (showLog) { | ||
// @ts-ignore | ||
var label = screenfull.isFullscreen ? 'enabled' : 'disabled'; | ||
console.log("Fullscreen " + label); | ||
} | ||
}); | ||
} | ||
else { | ||
console.log('This browser does not support fullscreen api'); | ||
} | ||
}; | ||
exports.disableFullscreenListener = function () { | ||
// @ts-ignore | ||
screenfull.off('change', function () { | ||
console.log('Fullscreen listener has been disabled'); | ||
}); | ||
}; | ||
exports.toggleFullScreen = function (menuButton, alt, src, showLog) { | ||
if (showLog === void 0) { showLog = false; } | ||
return new Promise(function (resolve, reject) { | ||
if (screenfull.isEnabled) { | ||
if (screenfull.isFullscreen) { | ||
screenfull.exit().then(function () { | ||
menuButton.src = src.enter; | ||
menuButton.alt = alt.enter; | ||
}).catch(function (error) { | ||
console.log(error); | ||
reject(error); | ||
}); | ||
} | ||
else { | ||
screenfull.request().then(function () { | ||
menuButton.src = src.exit; | ||
menuButton.alt = alt.exit; | ||
}).catch(function (error) { | ||
console.log(error); | ||
reject(error); | ||
}); | ||
} | ||
if (showLog) { | ||
// @ts-ignore | ||
var label = screenfull.isFullscreen ? 'enabled' : 'disabled'; | ||
console.log("Fullscreen " + label); | ||
} | ||
resolve({ src: menuButton.src, alt: menuButton.alt }); | ||
} | ||
else { | ||
resolve({ src: null, alt: null }); | ||
} | ||
}); | ||
}; | ||
exports.hasFullscreen = function () { | ||
return screenfull.isEnabled; | ||
}; | ||
/** | ||
* Version | ||
*/ | ||
exports.isIE = function () { | ||
var ua = window.navigator.userAgent; | ||
var msie = ua.indexOf('MSIE '); | ||
return msie > 0 || !!navigator.userAgent.match(/Trident.*rv:11\./); | ||
}; | ||
exports.isBeforeIE11 = function () { | ||
return navigator.appVersion.indexOf('MSIE 10') !== -1; | ||
}; | ||
//# sourceMappingURL=core-services-browser.service.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var screenfull=require("screenfull");exports.fullscreenListener=function(menuButton,alt,src,showLog){if(showLog===void 0){showLog=false}if(screenfull.isEnabled){screenfull.on("change",function(){if(screenfull.isFullscreen){menuButton.src=src.exit;menuButton.alt=alt.exit}else{menuButton.src=src.enter;menuButton.alt=alt.enter}if(showLog){var label=screenfull.isFullscreen?"enabled":"disabled";console.log("Fullscreen "+label)}})}else{console.log("This browser does not support fullscreen api")}};exports.disableFullscreenListener=function(){screenfull.off("change",function(){console.log("Fullscreen listener has been disabled")})};exports.toggleFullScreen=function(menuButton,alt,src,showLog){if(showLog===void 0){showLog=false}return new Promise(function(resolve,reject){if(screenfull.isEnabled){if(screenfull.isFullscreen){screenfull.exit().then(function(){menuButton.src=src.enter;menuButton.alt=alt.enter}).catch(function(error){console.log(error);reject(error)})}else{screenfull.request().then(function(){menuButton.src=src.exit;menuButton.alt=alt.exit}).catch(function(error){console.log(error);reject(error)})}if(showLog){var label=screenfull.isFullscreen?"enabled":"disabled";console.log("Fullscreen "+label)}resolve({src:menuButton.src,alt:menuButton.alt})}else{resolve({src:null,alt:null})}})};exports.hasFullscreen=function(){return screenfull.isEnabled};exports.isIE=function(){var ua=window.navigator.userAgent;var msie=ua.indexOf("MSIE ");return msie>0||!!navigator.userAgent.match(/Trident.*rv:11\./)};exports.isBeforeIE11=function(){return navigator.appVersion.indexOf("MSIE 10")!==-1}; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=core-services-combobox.interface.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true}); |
@@ -1,235 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import $ = require('jquery'); | ||
var $ = require("jquery"); | ||
require("../../../../../node_modules/jquery-ui-dist/jquery-ui.min"); | ||
var core_services_elements_service_1 = require("../elements/core-services-elements.service"); | ||
/** | ||
* This function is using Jquery and Jquery-ui and typescript is not available | ||
* To this function work is necessary the following imports, respectively: | ||
* import $ = require('jquery'); | ||
* import '../../../../../node_modules/jquery-ui-dist/jquery-ui.min'; | ||
*/ | ||
exports.initialize = function (combobox, callback, invalidCallback) { | ||
$.widget('custom.combobox', { | ||
_create: function () { | ||
// @ts-ignore | ||
this.wrapper = $('<span>') | ||
.addClass('custom-combobox') | ||
.insertAfter(this.element); | ||
this.element.hide(); | ||
this._createAutocomplete(); | ||
this._createShowAllButton(); | ||
// @ts-ignore | ||
this.input.attr('placeholder', this.element.attr('placeholder')); | ||
// @ts-ignore | ||
this.input.focus().blur(); | ||
}, | ||
_createAutocomplete: function () { | ||
var selected = this.element.children(':selected'); | ||
var value = selected.val() ? selected.text() : ''; | ||
// @ts-ignore | ||
this.input = $('<input>') | ||
// @ts-ignore | ||
.appendTo(this.wrapper) | ||
.val(value) | ||
.attr('title', '') | ||
.addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left " + this.element.attr('class')) | ||
.autocomplete({ | ||
delay: 0, | ||
minLength: 0, | ||
// @ts-ignore | ||
maxShowItems: 5, | ||
source: $.proxy(this, '_source') | ||
}) | ||
.tooltip({ | ||
classes: { 'ui-tooltip': 'ui-state-highlight' } | ||
}); | ||
// noinspection JSDeprecatedSymbols | ||
// @ts-ignore | ||
this.input.focus().blur(); | ||
// @ts-ignore | ||
// noinspection SpellCheckingInspection | ||
this._on(this.input, { | ||
autocompleteselect: function (event, ui) { | ||
ui.item.option.selected = true; | ||
// Get the value: ui.item.option.value | ||
// Get the text: ui.item.value | ||
callback(ui.item.option.value, ui.item.value); | ||
this._trigger('select', event, { | ||
item: ui.item.option | ||
}); | ||
}, | ||
disable: function () { | ||
this._disable(); | ||
}, | ||
enable: function () { | ||
this._enable(); | ||
}, | ||
autocompletechange: '_removeIfInvalid' | ||
}); | ||
}, | ||
_createShowAllButton: function () { | ||
// @ts-ignore | ||
var input = this.input; | ||
var wasOpen = false; | ||
$('<a>') | ||
.attr('tabIndex', -1) | ||
.attr('title', 'Mostrar todos os itens') | ||
.tooltip() | ||
// @ts-ignore | ||
.appendTo(this.wrapper) | ||
.button({ | ||
icons: { | ||
primary: 'ui-icon-triangle-1-s' | ||
}, | ||
text: false | ||
}) | ||
.removeClass('ui-corner-all') | ||
.on('mousedown', function () { | ||
wasOpen = input.autocomplete('widget').is(':visible'); | ||
}) | ||
.on('click', function () { | ||
wasOpen = input.autocomplete('widget').is(':visible'); | ||
input.trigger('focus'); | ||
// Close if already visible | ||
if (wasOpen) { | ||
return; | ||
} | ||
// Pass empty string as value to search for, displaying all results | ||
input.autocomplete('search', ''); | ||
}); | ||
}, | ||
_source: function (request, response) { | ||
// noinspection TypeScriptValidateJSTypes | ||
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), 'i'); | ||
// noinspection TypeScriptValidateJSTypes | ||
response(this.element.children('option').map(function () { | ||
// @ts-ignore | ||
var text = $(this).text(); | ||
// @ts-ignore | ||
if (this.value && (!request.term || matcher.test(text))) { | ||
return { | ||
label: text, | ||
value: text, | ||
// @ts-ignore | ||
option: this | ||
}; | ||
} | ||
else { | ||
return null; | ||
} | ||
})); | ||
}, | ||
_removeIfInvalid: function (event, ui) { | ||
// Selected an item, nothing to do | ||
if (ui.item) { | ||
return; | ||
} | ||
// Search for a match (case-insensitive) | ||
// @ts-ignore | ||
var value = this.input.val(); | ||
var valueLowerCase = value.toLowerCase(); | ||
var valid = false; | ||
this.element.children('option').each(function () { | ||
if ($(this).text().toLowerCase() === valueLowerCase) { | ||
// @ts-ignore | ||
this.selected = valid = true; | ||
return false; | ||
} | ||
}); | ||
// Found a match, nothing to do | ||
if (valid) { | ||
// Get the value: this.element.val() | ||
// Get the text: this.input.val() | ||
// @ts-ignore | ||
callback(this.element.val(), this.input.val()); | ||
return; | ||
} | ||
// Remove invalid value | ||
// noinspection TypeScriptValidateJSTypes | ||
// @ts-ignore | ||
this.input | ||
.val('') | ||
.attr('title', "O valor " + value + " n\u00E3o existe para este item!") | ||
.tooltip('open'); | ||
this.element.val(''); | ||
// @ts-ignore | ||
this._delay(function () { | ||
// @ts-ignore | ||
this.input.tooltip('close').attr('title', ''); | ||
}, 2500); | ||
// @ts-ignore | ||
this.input.autocomplete('instance').term = ''; | ||
// @ts-ignore | ||
invalidCallback(this.element.val(), this.input.val()); | ||
}, | ||
_destroy: function () { | ||
// @ts-ignore | ||
this.wrapper.remove(); | ||
this.element.show(); | ||
} | ||
}); | ||
// @ts-ignore | ||
$(combobox).combobox(); | ||
}; | ||
exports.loadData = function (combobox, data, keepValue) { | ||
return new Promise(function (resolve) { | ||
var parent = combobox.parentNode; | ||
if (parent != null) { | ||
var comboboxInput = parent.querySelector('input.custom-combobox-input'); | ||
core_services_elements_service_1.removeChildElements(combobox); | ||
if (!keepValue) { | ||
combobox.value = ''; | ||
comboboxInput.value = ''; | ||
} | ||
var emptyOption = document.createElement('option'); | ||
emptyOption.value = ''; | ||
combobox.appendChild(emptyOption); | ||
data.forEach(function (d) { | ||
var option = document.createElement('option'); | ||
option.value = d.value; | ||
option.innerText = d.text; | ||
combobox.appendChild(option); | ||
}); | ||
resolve(combobox); | ||
} | ||
else { | ||
console.error('Parent of current combobox is null'); | ||
resolve(null); | ||
} | ||
}); | ||
}; | ||
exports.dataByValue = function (arrayData, value) { | ||
var tempActionPlan = arrayData.filter(function (x) { return x.value === value; }); | ||
if (value == null || tempActionPlan.length === 0) { | ||
return ''; | ||
} | ||
else { | ||
return tempActionPlan[0].text; | ||
} | ||
}; | ||
exports.disableInput = function (combobox, disable) { | ||
var parent = combobox.parentNode; | ||
var input = parent.querySelector('input'); | ||
if (input == null) { | ||
console.error("Input not found on current combobox group: " + parent); | ||
} | ||
else { | ||
if (disable) { | ||
input.disabled = true; // this disables just the popup menu (widget), | ||
input.classList.add('ui-autocomplete-disabled'); | ||
input.classList.add('ui-state-disabled'); | ||
input.setAttribute('tabIndex', '-1'); | ||
input.setAttribute('aria-disabled', 'true'); | ||
} | ||
else { | ||
input.disabled = false; | ||
input.classList.remove('ui-state-disabled'); | ||
input.classList.remove('ui-autocomplete-disabled'); | ||
input.removeAttribute('tabIndex'); | ||
input.setAttribute('aria-disabled', 'false'); | ||
} | ||
} | ||
}; | ||
//# sourceMappingURL=core-services-combobox.service.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var $=require("jquery");require("../../../../../node_modules/jquery-ui-dist/jquery-ui.min");var core_services_elements_service_1=require("../elements/core-services-elements.service");exports.initialize=function(combobox,callback,invalidCallback){$.widget("custom.combobox",{_create:function(){this.wrapper=$("<span>").addClass("custom-combobox").insertAfter(this.element);this.element.hide();this._createAutocomplete();this._createShowAllButton();this.input.attr("placeholder",this.element.attr("placeholder"));this.input.focus().blur()},_createAutocomplete:function(){var selected=this.element.children(":selected");var value=selected.val()?selected.text():"";this.input=$("<input>").appendTo(this.wrapper).val(value).attr("title","").addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left "+this.element.attr("class")).autocomplete({delay:0,minLength:0,maxShowItems:5,source:$.proxy(this,"_source")}).tooltip({classes:{"ui-tooltip":"ui-state-highlight"}});this.input.focus().blur();this._on(this.input,{autocompleteselect:function(event,ui){ui.item.option.selected=true;callback(ui.item.option.value,ui.item.value);this._trigger("select",event,{item:ui.item.option})},disable:function(){this._disable()},enable:function(){this._enable()},autocompletechange:"_removeIfInvalid"})},_createShowAllButton:function(){var input=this.input;var wasOpen=false;$("<a>").attr("tabIndex",-1).attr("title","Mostrar todos os itens").tooltip().appendTo(this.wrapper).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").on("mousedown",function(){wasOpen=input.autocomplete("widget").is(":visible")}).on("click",function(){wasOpen=input.autocomplete("widget").is(":visible");input.trigger("focus");if(wasOpen){return}input.autocomplete("search","")})},_source:function(request,response){var matcher=new RegExp($.ui.autocomplete.escapeRegex(request.term),"i");response(this.element.children("option").map(function(){var text=$(this).text();if(this.value&&(!request.term||matcher.test(text))){return{label:text,value:text,option:this}}else{return null}}))},_removeIfInvalid:function(event,ui){if(ui.item){return}var value=this.input.val();var valueLowerCase=value.toLowerCase();var valid=false;this.element.children("option").each(function(){if($(this).text().toLowerCase()===valueLowerCase){this.selected=valid=true;return false}});if(valid){callback(this.element.val(),this.input.val());return}this.input.val("").attr("title","O valor "+value+" não existe para este item!").tooltip("open");this.element.val("");this._delay(function(){this.input.tooltip("close").attr("title","")},2500);this.input.autocomplete("instance").term="";invalidCallback(this.element.val(),this.input.val())},_destroy:function(){this.wrapper.remove();this.element.show()}});$(combobox).combobox()};exports.loadData=function(combobox,data,keepValue){return new Promise(function(resolve){var parent=combobox.parentNode;if(parent!=null){var comboboxInput=parent.querySelector("input.custom-combobox-input");core_services_elements_service_1.removeChildElements(combobox);if(!keepValue){combobox.value="";comboboxInput.value=""}var emptyOption=document.createElement("option");emptyOption.value="";combobox.appendChild(emptyOption);data.forEach(function(d){var option=document.createElement("option");option.value=d.value;option.innerText=d.text;combobox.appendChild(option)});resolve(combobox)}else{console.error("Parent of current combobox is null");resolve(null)}})};exports.dataByValue=function(arrayData,value){var tempActionPlan=arrayData.filter(function(x){return x.value===value});if(value==null||tempActionPlan.length===0){return""}else{return tempActionPlan[0].text}};exports.disableInput=function(combobox,disable){var parent=combobox.parentNode;var input=parent.querySelector("input");if(input==null){console.error("Input not found on current combobox group: "+parent)}else{if(disable){input.disabled=true;input.classList.add("ui-autocomplete-disabled");input.classList.add("ui-state-disabled");input.setAttribute("tabIndex","-1");input.setAttribute("aria-disabled","true")}else{input.disabled=false;input.classList.remove("ui-state-disabled");input.classList.remove("ui-autocomplete-disabled");input.removeAttribute("tabIndex");input.setAttribute("aria-disabled","false")}}}; |
@@ -1,21 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Remove | ||
*/ | ||
exports.removeChildElements = function (elementClassId) { | ||
if (typeof elementClassId === 'string') { | ||
var element = document.querySelector(elementClassId); | ||
if (element != null) { | ||
while (element.firstChild) { | ||
element.removeChild(element.firstChild); | ||
} | ||
} | ||
} | ||
else { | ||
while (elementClassId.firstChild) { | ||
elementClassId.removeChild(elementClassId.firstChild); | ||
} | ||
} | ||
}; | ||
//# sourceMappingURL=core-services-elements.service.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.removeChildElements=function(elementClassId){if(typeof elementClassId==="string"){var element=document.querySelector(elementClassId);if(element!=null){while(element.firstChild){element.removeChild(element.firstChild)}}}else{while(elementClassId.firstChild){elementClassId.removeChild(elementClassId.firstChild)}}}; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=core-services-menu.interfaces.js.map | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true}); |
{ | ||
"name": "gl-w-frontend", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Common code for using among web front-end development such as pure JavaScript, ES6+ and TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/", |
# gl-w-frontend # | ||
[![version](https://img.shields.io/badge/version-1.3.0-green.svg)](https://www.npmjs.com/package/gl-w-frontend) | ||
[![version](https://img.shields.io/badge/version-1.3.1-green.svg)](https://www.npmjs.com/package/gl-w-frontend) | ||
@@ -4,0 +4,0 @@ ### What is this repository for? ### |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
79039
57
847
4