From 22605e44021492f5442fce712846afa46fac200c Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 27 Apr 2015 11:30:05 -0300 Subject: [PATCH] adding requirejs config file --- index.html | 66 +++++++++--------------------------------------------------------- js/requirejs-config.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 js/requirejs-config.js diff --git a/index.html b/index.html index 0f317ab..d31469f 100644 --- a/index.html +++ b/index.html @@ -48,17 +48,16 @@ } function loadJavaScriptAsync(file_path){ - var head = document.getElementsByTagName('head')[0]; - var script_element = document.createElement('script'); - script_element.type = 'text/javascript'; - script_element.src = file_path; - head.appendChild(script_element); } function loadRequireJS(){ - loadJavaScriptAsync(makeJSURL('js/require.js')); + var head = document.getElementsByTagName('head')[0]; + var script_element = document.createElement('script'); + script_element.type = 'text/javascript'; + script_element.src = makeJSURL('js/require.js'); + script_element.setAttribute('data-main', makeJSURL('js/requirejs-config.js')); + head.appendChild(script_element); } - loadRequireJS(); loadCSSFiles(); @@ -301,58 +300,11 @@ - + diff --git a/js/requirejs-config.js b/js/requirejs-config.js new file mode 100644 index 0000000..2986a43 --- /dev/null +++ b/js/requirejs-config.js @@ -0,0 +1,49 @@ +var base = window.location.href; +var host = window.location.host; +var regex = new RegExp(".*" + host + '/', "g"); + +if(host){ + base = base.replace(regex,''); +}else{ + base = base.replace('index.html',''); +} +base = removeUrlParameters(base); + +requirejs.config({ + baseUrl: ( base + '/js/'), + paths: { + jquery: 'jquery-2.1.3.min', + jquery_ui: 'jquery-ui-1.11.4.custom/jquery-ui.min', + jquery_cookie: 'jquery.cookie', + handlebars: 'handlebars-v3.0.1', + handlebars_helpers: 'handlebars-helpers', + dotdotdot: 'jquery.dotdotdot.min', + jquery_maxlength: 'jquery.maxlength.min', + layout: 'layout', + main: 'main' + }, + shim: { + 'handlebars':{ + deps: ['jquery'], + exports: 'Handlebars' + }, + 'jquery_ui': { + deps: ['jquery'] + }, + 'dotdotdot': { + deps: ['jquery'] + }, + 'layout': { + deps: ['jquery'] + }, + 'jquery_maxlength': { + deps: ['jquery'] + }, + 'handlebars_helpers':{ + deps: ['handlebars'] + } + } +}); + +requirejs(['jquery', 'jquery_ui', 'jquery_cookie', 'handlebars', 'handlebars_helpers']); +requirejs(['dotdotdot', 'jquery_maxlength', 'layout', 'main']); -- libgit2 0.21.2