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