mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 02:36:54 +00:00 
			
		
		
		
	- Only refresh contextual number/datetime info/formatting where needed (closes #513) - Also refresh correlated stock journal entries on undo (closes #471) - Prefill "New amount" with the current stock amount on the inventory page (closes #434) - Ensure that the location_id of the stock and stock_log tables is never empty after migration 95 (references #421) - Load initial values of the /stockedit form server side to improve loading performance (references #421) - Use more or less the same input ordering as on the purchase page for the /stockedit page (references #421) - Also display the "Compact view" button on the shopping list page when FEATURE_FLAG_SHOPPINGLIST_MULTIPLE_LISTS is disabled (references #453) - Ensure that the currently active sidebar menu item is visible - Optimized sidebar menu item grouping/spacing - Properly order the API documentation route groups and put the "by-barcode" routes into a separate group - Updated dependencies - Pulled translations from Transifex - Prepared changelog for next release
		
			
				
	
	
		
			156 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| EmptyElementWhenMatches = function(selector, text)
 | |
| {
 | |
| 	if ($(selector).text() === text)
 | |
| 	{
 | |
| 		$(selector).text('');
 | |
| 	}
 | |
| };
 | |
| 
 | |
| String.prototype.contains = function(search)
 | |
| {
 | |
| 	return this.toLowerCase().indexOf(search.toLowerCase()) !== -1;
 | |
| };
 | |
| 
 | |
| String.prototype.isEmpty = function()
 | |
| {
 | |
| 	return (this.length === 0 || !this.trim());
 | |
| };
 | |
| 
 | |
| String.prototype.replaceAll = function(search, replacement)
 | |
| {
 | |
| 	return this.replace(new RegExp(search, "g"), replacement);
 | |
| };
 | |
| 
 | |
| GetUriParam = function(key)
 | |
| {
 | |
| 	var currentUri = decodeURIComponent(window.location.search.substring(1));
 | |
| 	var vars = currentUri.split('&');
 | |
| 
 | |
| 	for (i = 0; i < vars.length; i++)
 | |
| 	{
 | |
| 		var currentParam = vars[i].split('=');
 | |
| 
 | |
| 		if (currentParam[0] === key)
 | |
| 		{
 | |
| 			return currentParam[1] === undefined ? true : currentParam[1];
 | |
| 		}
 | |
| 	}
 | |
| };
 | |
| 
 | |
| UpdateUriParam = function(key, value)
 | |
| {
 | |
| 	var queryParameters = new URLSearchParams(location.search);
 | |
| 	queryParameters.set(key, value);
 | |
| 	window.history.replaceState({ }, "", decodeURIComponent(`${location.pathname}?${queryParameters}`));
 | |
| };
 | |
| 
 | |
| IsTouchInputDevice = function()
 | |
| {
 | |
| 	if (("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch)
 | |
| 	{
 | |
| 		return true;
 | |
| 	}
 | |
| 
 | |
| 	return false;
 | |
| }
 | |
| 
 | |
| BoolVal = function(test)
 | |
| {
 | |
| 	var anything = test.toString().toLowerCase();
 | |
| 	if (anything === true || anything === "true" || anything === "1" || anything === "on")
 | |
| 	{
 | |
| 		return true;
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		return false;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| GetFileNameFromPath = function(path)
 | |
| {
 | |
| 	return path.split("/").pop().split("\\").pop();
 | |
| }
 | |
| 
 | |
| GetFileExtension = function(pathOrFileName)
 | |
| {
 | |
| 	return pathOrFileName.split(".").pop();
 | |
| }
 | |
| 
 | |
| $.extend($.expr[":"],
 | |
| {
 | |
| 	"contains_case_insensitive": function(elem, i, match, array)
 | |
| 	{
 | |
| 		return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
 | |
| 	}
 | |
| });
 | |
| 
 | |
| FindObjectInArrayByPropertyValue = function(array, propertyName, propertyValue)
 | |
| {
 | |
| 	for (var i = 0; i < array.length; i++)
 | |
| 	{
 | |
| 		if (array[i][propertyName] == propertyValue)
 | |
| 		{
 | |
|             return array[i];
 | |
|         }
 | |
| 	}
 | |
| 	
 | |
|     return null;
 | |
| }
 | |
| 
 | |
| FindAllObjectsInArrayByPropertyValue = function(array, propertyName, propertyValue)
 | |
| {
 | |
| 	var returnArray = [];
 | |
| 	
 | |
| 	for (var i = 0; i < array.length; i++)
 | |
| 	{
 | |
| 		if (array[i][propertyName] == propertyValue)
 | |
| 		{
 | |
| 			returnArray.push(array[i]);
 | |
|         }
 | |
| 	}
 | |
| 	
 | |
| 	return returnArray;
 | |
| }
 | |
| 
 | |
| $.fn.hasAttr = function(name)
 | |
| {
 | |
| 	return this.attr(name) !== undefined;
 | |
| };
 | |
| 
 | |
| function IsJsonString(text)
 | |
| {
 | |
| 	try
 | |
| 	{
 | |
| 		JSON.parse(text);
 | |
| 	} catch(e)
 | |
| 	{
 | |
| 		return false;
 | |
| 	}
 | |
| 	return true;
 | |
| }
 | |
| 
 | |
| function Delay(callable, delayMilliseconds)
 | |
| {
 | |
| 	var timer = 0;
 | |
| 	return function()
 | |
| 	{
 | |
| 		var context = this;
 | |
| 		var args = arguments;
 | |
| 		
 | |
| 		clearTimeout(timer);
 | |
| 		timer = setTimeout(function()
 | |
| 		{
 | |
| 			callable.apply(context, args);
 | |
| 		}, delayMilliseconds || 0);
 | |
| 	};
 | |
| }
 | |
| 
 | |
| $.fn.isVisibleInViewport = function(extraHeightPadding = 0)
 | |
| {
 | |
| 	var elementTop = $(this).offset().top;
 | |
| 	var viewportTop = $(window).scrollTop() - extraHeightPadding;
 | |
| 	
 | |
| 	return elementTop + $(this).outerHeight() > viewportTop && elementTop < viewportTop + $(window).height();
 | |
| };
 |