21 lines
615 B
JavaScript
21 lines
615 B
JavaScript
(function () {
|
|
if (!window.BX || !BX.ajax || !BX.ajax.runAction) return;
|
|
var pending = null;
|
|
window.VinoState = {
|
|
first: function (name) {
|
|
if (!pending) {
|
|
pending = new Promise(function (resolve) {
|
|
BX.ajax.runAction('jinove:vinoteca.state.all', { method: 'GET' }).then(
|
|
function (response) { resolve((response && response.data) || {}); },
|
|
function () { resolve({}); }
|
|
);
|
|
});
|
|
}
|
|
return pending.then(function (all) {
|
|
if (!all[name]) throw new Error('state');
|
|
return { data: all[name] };
|
|
});
|
|
}
|
|
};
|
|
})();
|