f003e878e3ef64e053f4daed87f7030ddfe93b10.svn-base 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. FeedViewer = {};
  7. Ext.onReady(function() {
  8. Ext.QuickTips.init();
  9. Ext.state.Manager.setProvider(new Ext.state.SessionProvider({
  10. state : Ext.appState
  11. }));
  12. var tpl = Ext.Template.from('preview-tpl', {
  13. compiled : true,
  14. getBody : function(v, all) {
  15. return Ext.util.Format.stripScripts(v
  16. || all.description);
  17. }
  18. });
  19. FeedViewer.getTemplate = function() {
  20. return tpl;
  21. }
  22. var feeds = new FeedPanel();
  23. var mainPanel = new MainPanel();
  24. feeds.on('feedselect', function(feed) {
  25. mainPanel.loadFeed(feed);
  26. });
  27. var viewport = new Ext.Viewport({
  28. layout : 'border',
  29. items : [new Ext.BoxComponent({ // raw element
  30. region : 'north',
  31. el : 'header',
  32. height : 32
  33. }), feeds, mainPanel]
  34. });
  35. // add some default feeds
  36. feeds.addFeed({
  37. url : 'http://feeds.feedburner.com/extblog',
  38. text : 'ExtJS.com Blog'
  39. }, false, true);
  40. feeds.addFeed({
  41. url : 'http://extjs.com/forum/external.php?type=RSS2',
  42. text : 'ExtJS.com Forums'
  43. }, true);
  44. feeds.addFeed({
  45. url : 'http://feeds.feedburner.com/ajaxian',
  46. text : 'Ajaxian'
  47. }, true);
  48. });
  49. // This is a custom event handler passed to preview panels so link open in a new
  50. // windw
  51. FeedViewer.LinkInterceptor = {
  52. render : function(p) {
  53. p.body.on({
  54. 'mousedown' : function(e, t) { // try to intercept the easy
  55. // way
  56. t.target = '_blank';
  57. },
  58. 'click' : function(e, t) { // if they tab + enter a link,
  59. // need to do it old fashioned
  60. // way
  61. if (String(t.target).toLowerCase() != '_blank') {
  62. e.stopEvent();
  63. window.open(t.href);
  64. }
  65. },
  66. delegate : 'a'
  67. });
  68. }
  69. };