diff options
-rw-r--r-- | application/views/file/html_header.php | 7 | ||||
-rw-r--r-- | application/views/header.php | 5 | ||||
-rw-r--r-- | data/js/application.js | 5 | ||||
-rw-r--r-- | data/js/lexer-input.js | 10 | ||||
-rw-r--r-- | data/js/main.js | 2 |
5 files changed, 14 insertions, 15 deletions
diff --git a/application/views/file/html_header.php b/application/views/file/html_header.php index 520e2482a..a5a6da99f 100644 --- a/application/views/file/html_header.php +++ b/application/views/file/html_header.php @@ -3,14 +3,11 @@ $force_full_html = true; include(FCPATH."application/views/header.php"); ?> </div><!-- .container --> - <script type="text/javascript"> /* <![CDATA[ */ - window.appConfig = { - lexers: <?php echo json_encode($lexers); ?> - } + window.appConfig.lexers = <?php echo json_encode($lexers); ?>; /* ]]> */ -</script> +<script> <?php if (isset($error_message)) { include 'framgents/alert-wide.php'; diff --git a/application/views/header.php b/application/views/header.php index 27fdbb92f..89a3c8617 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -26,8 +26,11 @@ if (is_cli_client() && !isset($force_full_html)) { echo '<link href="'.link_with_mtime("/data/local/favicon.png").'" rel="shortcut icon">'; } ?> - <script> + <script type="text/javascript"> + /* <![CDATA[ */ var require = { baseUrl: '/data/js' }; + window.appConfig = {}; + /* ]]> */ </script> <script data-main="main" src="/data/js/vendor/require.js"></script> </head> diff --git a/data/js/application.js b/data/js/application.js index 76ed5ae55..06a53854d 100644 --- a/data/js/application.js +++ b/data/js/application.js @@ -21,12 +21,11 @@ define( * Gets called for every request after page load * config contains app config attributes passed from php */ - onPageLoaded: function (config) { - config = config || {}; + onPageLoaded: function () { Util.highlightLineFromHash(); Util.setTabwidthFromLocalStorage(); TabwidthInput.initialize(); - LexerInput.initialize(config.lexers); + LexerInput.initialize(); ThumbnailView.initialize(); this.configureTooltips(); this.setupToggleSelectAllEvent(); diff --git a/data/js/lexer-input.js b/data/js/lexer-input.js index a4d3c7058..85c4a5432 100644 --- a/data/js/lexer-input.js +++ b/data/js/lexer-input.js @@ -11,10 +11,10 @@ define(['util', 'underscore', 'jquery-ui'], function (Util, _) { var baseUrl = $(event.target).data('base-url'); this.switchLexer(ui.item.value, baseUrl); }, - setupAutocomplete: function (lexers) { + setupAutocomplete: function () { var lexerSource = []; - for (var key in lexers) { - lexerSource.push({ label: lexers[key], value: key }); + for (var key in appConfig.lexers) { + lexerSource.push({ label: appConfig.lexers[key], value: key }); } $('.lexer-form input').autocomplete({ @@ -37,8 +37,8 @@ define(['util', 'underscore', 'jquery-ui'], function (Util, _) { } }; var LexerInput = { - initialize: function (lexers) { - PrivateFunctions.setupAutocomplete(lexers); + initialize: function () { + PrivateFunctions.setupAutocomplete(); PrivateFunctions.setupEvents(); } }; diff --git a/data/js/main.js b/data/js/main.js index 92c016d79..5710dcb68 100644 --- a/data/js/main.js +++ b/data/js/main.js @@ -22,7 +22,7 @@ requirejs.config({ require(['application', 'jquery'], function (App, $) { App.initialize(); $(document).ready(function () { - App.onPageLoaded(window.appConfig); + App.onPageLoaded(); }); }); })(); |