grocy/js/viewjs/quantityunitpluraltesting.js
Katharina Bogad fd61d1ef62 viewjs: Wrap in fuctions
This commit's contents were auto-generated. They wrap all viewjs
in functions and define a common prologue.

New file contents:

```js
function VIEWNAMEView(Grocy, scope = null)
{
    var $scope = $;
    if(scope != null)
    {
        $scope = $(scope).find;
    }

    // original contents indented with \t

}
```
2021-06-22 22:56:57 +02:00

50 lines
958 B
JavaScript

function quantityunitpluraltestingView(Grocy, scope = null)
{
var $scope = $;
if (scope != null)
{
$scope = $(scope).find;
}
Grocy.Use("numberpicker");
$("#qu_id").change(function(event)
{
RefreshQuPluralTestingResult();
});
$("#amount").keyup(function(event)
{
RefreshQuPluralTestingResult();
});
$("#amount").change(function(event)
{
RefreshQuPluralTestingResult();
});
function RefreshQuPluralTestingResult()
{
var singularForm = $("#qu_id option:selected").data("singular-form");
var pluralForm = $("#qu_id option:selected").data("plural-form");
var amount = $("#amount").val();
if (singularForm.toString().isEmpty() || amount.toString().isEmpty())
{
return;
}
animateCSS("h2", "shake");
$("#result").text(__n(amount, singularForm, pluralForm));
}
if (GetUriParam("qu") !== undefined)
{
$("#qu_id").val(GetUriParam("qu"));
$("#qu_id").trigger("change");
}
$("#amount").focus();
}