您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

61 行
1.3 KiB

  1. // page container
  2. wn.provide('wn.pages');
  3. wn.provide('wn.views');
  4. wn.views.Container = Class.extend({
  5. init: function() {
  6. this.container = $('#body_div').get(0);
  7. this.page = null; // current page
  8. this.pagewidth = $('#body_div').width();
  9. this.pagemargin = 50;
  10. },
  11. add_page: function(label, onshow, onhide) {
  12. var page = $('<div class="content"></div>')
  13. .attr('id', "page-" + label)
  14. .appendTo(this.container).get(0);
  15. if(onshow)
  16. $(page).bind('show', onshow);
  17. if(onshow)
  18. $(page).bind('hide', onhide);
  19. page.label = label;
  20. wn.pages[label] = page;
  21. return page;
  22. },
  23. change_to: function(label) {
  24. if(this.page && this.page.label == label) {
  25. // don't trigger double events
  26. $(this.page).trigger('show');
  27. return;
  28. }
  29. var me = this;
  30. if(label.tagName) {
  31. // if sent the div, get the table
  32. var page = label;
  33. } else {
  34. var page = wn.pages[label];
  35. }
  36. if(!page) {
  37. console.log('Page not found ' + label);
  38. return;
  39. }
  40. // hide current
  41. if(this.page && this.page != page) {
  42. $(this.page).toggle(false);
  43. $(this.page).trigger('hide');
  44. }
  45. // show new
  46. if(!this.page || this.page != page) {
  47. this.page = page;
  48. //$(this.page).fadeIn();
  49. $(this.page).toggle(true);
  50. }
  51. this.page._route = window.location.hash;
  52. $(this.page).trigger('show');
  53. scroll(0,0);
  54. return this.page;
  55. }
  56. });