From fe68477d8b60bc9303dd2bcd542915ac05e3fac6 Mon Sep 17 00:00:00 2001 From: Joakim Reinert Date: Sat, 18 Apr 2015 23:55:22 +0200 Subject: Refactor lexer input setup --- data/js/application.js | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'data/js/application.js') diff --git a/data/js/application.js b/data/js/application.js index d0e7c649f..3118f96bb 100644 --- a/data/js/application.js +++ b/data/js/application.js @@ -1,22 +1,36 @@ (function () { 'use strict'; -define(['require', 'util', 'vendor'], function (require, Util) { - require(['script']); - var App = { - // Gets called for every request - initialize: function () { - this.setupLineHighlight(); - }, - // Gets called for every request on page load - onPageLoaded: function () { - Util.highlightLineFromHash(); - }, +define( + [ + 'require', + 'util', + 'lexer-input', + 'vendor' + ], + function (require, Util, LexerInput) { + require(['script']); + var App = { + // Gets called for every request (before page load) + initialize: function () { + this.setupLineHighlight(); + }, - setupLineHighlight: function () { - $(window).on('hashchange', Util.highlightLineFromHash); - } - }; + /* + * Gets called for every request after page load + * config contains app config attributes passed from php + */ + onPageLoaded: function (config) { + Util.highlightLineFromHash(); + LexerInput.initialize(config.lexers); + }, - return App; -}); + setupLineHighlight: function () { + $(window).on('hashchange', Util.highlightLineFromHash); + }, + + }; + + return App; + } +); })(); -- cgit v1.2.3-24-g4f1b