Advertisement
Vadorequest

loader.ts

Nov 29th, 2013
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// <reference path="def/require.d.ts" />
  2. /// <reference path="Init.class.ts" />
  3.  
  4. /**
  5.  * paths    List of the files to load. (Cannot contains references TS classes)
  6.  *              key: New reference name of the file.
  7.  *              path: Relative path to /public/js/ of the file.
  8.  *
  9.  * shim     Config about the libraries (dependencies and more).
  10.  *          See http://requirejs.org/docs/api.html#config-shim
  11.  */
  12. require.config({
  13.     //urlArgs: "t=" +  (new Date()).getTime(),
  14.     paths: {
  15.         'jquery': 'lib/jquery-1.10.2.min',
  16.         'jqueryUiCore': 'lib/jquery.ui.core.min',
  17.         'jqueryUiEffect': 'lib/jquery.ui.effect.min',
  18.         'shared': '_shared.min'
  19.     },
  20.     shim: {
  21.         'jquery': {
  22.             exports: '$'
  23.         },
  24.         'jqueryUiCore': {
  25.             deps: ["jquery"],
  26.             exports: '$'
  27.         },
  28.         'jqueryUiEffect': {
  29.             deps: ["jquery"],
  30.             exports: "$"
  31.         },
  32.         'shared': {
  33.             exports: "shared"
  34.         }
  35.     }
  36. });
  37.  
  38.  
  39. /**
  40.  * [] Array of name that should be the same than those defined in the config.paths. Exception for the TS classes with reference in this file.
  41.  */
  42. require(['jquery', 'jqueryUiCore', 'jqueryUiEffect', 'Init.class', 'shared'],
  43.     ($, jqueryUiCore, jqueryUiEffect, _init, shared) => {
  44.         // Initialization.
  45.         var init = new _init.Init();
  46.  
  47.         // Make them public.
  48.         _exports([
  49.             shared.Message,
  50.             shared.ValidatorMessage
  51.         ]);
  52.  
  53.         /**
  54.          * Export an array of object to made them public on the browser.
  55.          * @param   objects - Array of objects. Class of function basically.
  56.          * @private
  57.          */
  58.         function _exports(objects){
  59.             for(var i in objects){
  60.                 _export(objects[i]);
  61.             }
  62.         }
  63.  
  64.         /**
  65.          *Export an object to the browser to make it public.
  66.          * @param o     Object to export.
  67.          * @param name  Customise the name. Optional.
  68.          * @private
  69.          */
  70.         function _export(o: any, name: any = ''){
  71.             if(!name){
  72.                 name = o.name;
  73.             }
  74.             window[name] = o;
  75.         }
  76.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement