question_categories.tpl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {% extends app.template_style ~ "/layout/layout_2_col.tpl" %}
  2. {% block left_column %}
  3. <script>
  4. function loadQuestions(id) {
  5. var categoryUrl = '{{ url('admin_questions_get_categories', {id : ':s'}) }}';
  6. categoryUrl = categoryUrl.replace(':s', id);
  7. var questionContentUrl = '{{ url('admin_get_questions_by_category', {categoryId : ':s'}) }}';
  8. questionContentUrl = questionContentUrl.replace(':s', id);
  9. $('.questions').load(questionContentUrl);
  10. var parent = $('.load_categories li #'+id).parent();
  11. if (parent.find('span#'+id).length == 0) {
  12. var span = document.createElement('span');
  13. $(span).attr('id', id);
  14. $(span).load(categoryUrl);
  15. parent.append(span);
  16. }
  17. return false;
  18. }
  19. $(function() {
  20. {% if app.request.get('categoryId') %}
  21. var categoryId = '{{ app.request.get('categoryId') }}';
  22. loadQuestions(categoryId);
  23. {% endif %}
  24. $('.load_categories li').on('click', 'a', function() {
  25. $('.load_categories li').each(function() {
  26. $(this).removeClass('active');
  27. });
  28. $(this).parent().addClass('active');
  29. var url = $(this).attr('href');
  30. var id = url.replace(/[^\d\.]/g, '');
  31. loadQuestions(id);
  32. return false;
  33. });
  34. });
  35. </script>
  36. <div class="well sidebar-nav load_categories">
  37. <li class="nav-header">{{ "QuestionCategories" | get_lang }}</li>
  38. {{ category_tree }}
  39. <li class="nav-header">{{ "GlobalQuestionCategories" | get_lang }}</li>
  40. {{ global_category_tree }}
  41. </div>
  42. {% endblock %}
  43. {% block right_column %}
  44. <div class="questions">
  45. </div>
  46. {% endblock %}