index.js 809 B

12345678910111213141516171819202122232425262728
  1. // TODO - Add initial page loading and handlers
  2. (function($,History){
  3. var State = History.getState();
  4. $(document).ready(function(){
  5. if($.isEmptyObject(State.data)){
  6. History.pushState({
  7. type: 'template',
  8. id: 'index'
  9. },'Bugs','page-index');
  10. }
  11. $(window).on('statechange',function(){
  12. State = History.getState();
  13. switch(State.data.type){
  14. case 'template':
  15. $.get('api.php',State.data,function(d){
  16. $('#content').html(Handlebars.compile(d.template)(d.context)).mCustomScrollbar('destroy');
  17. $('#content,.scroll').mCustomScrollbar({
  18. theme: 'dark-2',
  19. scrollInertia: 0
  20. });
  21. },'json');
  22. break;
  23. default:
  24. alert("Something went wrong!\nYour current state:\n"+JSON.stringify(State));
  25. }
  26. }).trigger('statechange');
  27. });
  28. })(jQuery,History);