Просмотр исходного кода

removed js context view, moved context away from global

Rafał Pitoń 9 лет назад
Родитель
Сommit
b6c75c1d4e

+ 11 - 7
misago/frontend/misago/app.js

@@ -7,12 +7,6 @@
     var ns = Object.getPrototypeOf(this);
     var ns = Object.getPrototypeOf(this);
     var self = this;
     var self = this;
 
 
-    // Context data
-    this.context = {
-      // Empty settings
-      SETTINGS: {}
-    };
-
     // Services init/destroy
     // Services init/destroy
     this._initServices = function(services) {
     this._initServices = function(services) {
       var orderedServices = new ns.OrderedList(services).order(false);
       var orderedServices = new ns.OrderedList(services).order(false);
@@ -41,15 +35,25 @@
       });
       });
     };
     };
 
 
+    // Context data
+    this.context = {
+      // Empty settings
+      SETTINGS: {}
+    };
+
     // App init/destory
     // App init/destory
     this.setup = false;
     this.setup = false;
-    this.init = function(setup) {
+    this.init = function(setup, context) {
       this.setup = {
       this.setup = {
         fixture: ns.get(setup, 'fixture', null),
         fixture: ns.get(setup, 'fixture', null),
         test: ns.get(setup, 'test', false),
         test: ns.get(setup, 'test', false),
         api: ns.get(setup, 'api', '/api/')
         api: ns.get(setup, 'api', '/api/')
       };
       };
 
 
+      if (context && context.length) {
+        this.context: context;
+      }
+
       this._initServices(ns._services);
       this._initServices(ns._services);
     };
     };
 
 

+ 2 - 3
misago/templates/misago/base.html

@@ -1,4 +1,4 @@
-{% load pipeline i18n staticfiles %}
+{% load pipeline i18n staticfiles misago_json %}
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html lang="{{ LANGUAGE_CODE }}">
 <html lang="{{ LANGUAGE_CODE }}">
   <head>
   <head>
@@ -46,11 +46,10 @@
     <script type="text/javascript" src="{% static 'misago/js/misago.js' %}"></script>
     <script type="text/javascript" src="{% static 'misago/js/misago.js' %}"></script>
     <script type="text/javascript">
     <script type="text/javascript">
       var misago = new Misago();
       var misago = new Misago();
-      {% include "misago/frontend_context.js" %}
       misago.init({
       misago.init({
         fixture: 'misago-fixture',
         fixture: 'misago-fixture',
         api: '{% url 'misago:api:api-root' %}'
         api: '{% url 'misago:api:api-root' %}'
-      });
+      }, {{ frontend_context|as_json }});
     </script>
     </script>
 
 
   </body>
   </body>

+ 0 - 2
misago/templates/misago/frontend_context.js

@@ -1,2 +0,0 @@
-{% load misago_json %}
-misago.context = {{ frontend_context|as_json }};