remove lodash dependency and add once helper
This commit is contained in:
parent
4e58b70a06
commit
2e9bc79cb9
2 changed files with 18 additions and 7 deletions
|
|
@ -32,6 +32,20 @@ let goldenlayout = (function () {
|
||||||
id: "inputComponent",
|
id: "inputComponent",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// helper function: only allow a function to be called once
|
||||||
|
function once(func) {
|
||||||
|
function _f() {
|
||||||
|
if (!_f.isCalled) {
|
||||||
|
_f.isCalled = true;
|
||||||
|
_f.res = func.apply(this, arguments);
|
||||||
|
}
|
||||||
|
return _f.res;
|
||||||
|
}
|
||||||
|
_f.prototype = func.prototype;
|
||||||
|
_f.isCalled = false;
|
||||||
|
return _f;
|
||||||
|
}
|
||||||
|
|
||||||
// helper function: filter vals out of array
|
// helper function: filter vals out of array
|
||||||
function filter (vals, array) {
|
function filter (vals, array) {
|
||||||
if( Array.isArray( vals ) && Array.isArray( array ) ) {
|
if( Array.isArray( vals ) && Array.isArray( array ) ) {
|
||||||
|
|
@ -248,8 +262,8 @@ let goldenlayout = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ensure only one handler is set up on the parent with _.once
|
// ensure only one handler is set up on the parent with once
|
||||||
var registerInputTabChangeHandler = _.once(function (tab) {
|
var registerInputTabChangeHandler = once(function (tab) {
|
||||||
tab.header.parent.on( "activeContentItemChanged", onActiveInputTabChange );
|
tab.header.parent.on( "activeContentItemChanged", onActiveInputTabChange );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -261,8 +275,8 @@ let goldenlayout = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// ensure only one handler is set up on the parent with _.once
|
// ensure only one handler is set up on the parent with once
|
||||||
var registerMainTabChangeHandler = _.once(function (tab) {
|
var registerMainTabChangeHandler = once(function (tab) {
|
||||||
tab.header.parent.on( "activeContentItemChanged", onActiveMainTabChange );
|
tab.header.parent.on( "activeContentItemChanged", onActiveMainTabChange );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ JQuery available.
|
||||||
|
|
||||||
<link rel="icon" type="image/x-icon" href="/static/website/images/evennia_logo.png" />
|
<link rel="icon" type="image/x-icon" href="/static/website/images/evennia_logo.png" />
|
||||||
|
|
||||||
<!-- Lodash -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js" integrity="sha256-qXBd/EfAdjOA2FGrGAG+b3YBn2tn5A6bhz+LSgYD96k=" crossorigin="anonymous"></script>
|
|
||||||
|
|
||||||
<!-- Import JQuery and warn if there is a problem -->
|
<!-- Import JQuery and warn if there is a problem -->
|
||||||
{% block jquery_import %}
|
{% block jquery_import %}
|
||||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue