Configuration

Contents

  1. Configuration variable
  2. Function setApijsLang
  3. Function setApijsConfig
  4. Function setApijsRewrites

Configuration variable

The following configuration correspond to the default configuration.

var apijs = {
   config: {
      # application language
      ## English (EN), French (FR), German (DE),
      ## Italian (IT), Portuguese (PT), Russian (RU), Spanish (ES)
      ## auto: uses if possible the web page language, if not, use English
      ## auto-fr: uses if possible the web page language, if not, use French
      ## fr: set language to French
      lang: 'auto',
      # enable the debug mode
      debug: false,
      # TheDialog
      dialog: {
         # enable the dialog closing by an outside click
         closeOnClick: false,
         # enable the navigation restriction in the dialog box
         restrictNavigation: true
      },
      # TheSlideshow
      slideshow: {
         # prefixs of album container identifiers (id)
         ids: 'slideshow',
         # enable the update of the url anchor
         anchor: true
      },
      # TheUpload
      upload: {
         tokenName: 'authenticity_token',
         tokenValue: null
      }
   }
};

Besides of containing the configuration, this variable also contains all the JavaScript application.

Function setApijsLang

This function is automatically called when it is defined, and allows the addition of a new language. When a key word doesn't exist in the current language translation set, it will be search in the English one.

function setApijsLang() {
   apijs.i18n.data.xy = {};
   apijs.i18n.data.xy.buttonCancel = 'xyz';
   apijs.config.lang = 'xy';
}

Warning: the call of this function is not caught with try {...} catch (e) { }.

Function setApijsConfig

This function is automatically called when it is defined, and allows to modify the configuration.

function setApijsConfig() {
   apijs.config.debug = true;
   apijs.config.dialog.closeOnClick = true;
}

Warning: the call of this function is not caught with try {...} catch (e) { }.

Function setApijsRewrites

This function is automatically called when it is defined, and allow to modify behavior by default.

Indeed, if you want to modify a feature behavior, it is possible to overload the core methods, in order to rewrite it as you want. The following example rewrites the method which defines the dialog box title in order to display an alert.

function setApijsRewrites() {
   apijs.dialog.htmlTitle = function (title) {
       alert(title);
   };
}

Warning: the call of this function is not caught with try {...} catch (e) { }.