diff --git a/kfet/static/kfet/js/kfet.api.js b/kfet/static/kfet/js/kfet.api.js index 4ca087dc..6b1f8fe3 100644 --- a/kfet/static/kfet/js/kfet.api.js +++ b/kfet/static/kfet/js/kfet.api.js @@ -4,65 +4,6 @@ * @license MIT */ -/** - * Get and store K-Psul config from API. - *

- * - * Config should be accessed statically only. - */ -class Config { - - /** - * Get or create config object. - * @private - * @return {object} object - config keys/values - */ - static _get_or_create_config() { - if (window.config === undefined) - window.config = {}; - return window.config; - } - - /** - * Get config from API. - * @param {jQueryAjaxComplete} [callback] - A function to be called when - * the request finishes. - */ - static reset(callback) { - $.getJSON(Urls['kfet.kpsul.get_settings']()) - .done(function(data) { - for (var key in data) { - Config.set(key, data[key]); - } - }) - .always(callback); - } - - /** - * Get value for key in config. - * @param {string} key - */ - static get(key) { - return this._get_or_create_config()[key]; - } - - /** - * Set value for key in config. - * @param {string} key - * @param {*} value - */ - static set(key, value) { - // API currently returns string for Decimal type - if (['addcost_amount', 'subvention_cof'].indexOf(key) > -1) - value = floatCheck(value); - this._get_or_create_config()[key] = value; - } - -} - - -/* ---------- ---------- */ - /** * Virtual namespace for models. diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index 0fb5c0e1..cf120fd4 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -40,6 +40,63 @@ function booleanCheck(v) { } +/** + * Get and store K-Psul config from API. + *

+ * + * Config should be accessed statically only. + */ +class Config { + + /** + * Get or create config object. + * @private + * @return {object} object - config keys/values + */ + static _get_or_create_config() { + if (window.config === undefined) + window.config = {}; + return window.config; + } + + /** + * Get config from API. + * @param {jQueryAjaxComplete} [callback] - A function to be called when + * the request finishes. + */ + static reset(callback) { + $.getJSON(Urls['kfet.kpsul.get_settings']()) + .done(function(data) { + for (var key in data) { + Config.set(key, data[key]); + } + }) + .always(callback); + } + + /** + * Get value for key in config. + * @param {string} key + */ + static get(key) { + return this._get_or_create_config()[key]; + } + + /** + * Set value for key in config. + * @param {string} key + * @param {*} value + */ + static set(key, value) { + // API currently returns string for Decimal type + if (['addcost_amount', 'subvention_cof'].indexOf(key) > -1) + value = floatCheck(value); + this._get_or_create_config()[key] = value; + } + +} + + $(document).ready(function() { $(window).scroll(function() { if ($(window).width() >= 768 && $(this).scrollTop() > 72.6) { diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index d69d6829..bdfdb673 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -13,7 +13,6 @@ - @@ -546,7 +545,7 @@ $(document).ready(function() { function amountEuroPurchase(article_data, nb) { var amount_euro = - article_data[3] * nb ; - if (Config.get('addcost_for') && Config.get('addcost_amount') && account_manager.account.trigramme != Config.get('addcost_for')) + if (Config.get('addcost_for') && Config.get('addcost_amount') && kpsul.account_manager.account.trigramme != Config.get('addcost_for')) amount_euro -= Config.get('addcost_amount') * nb; var reduc_divisor = 1; if (kpsul.account_manager.account.is_cof)