App.views.AlbumsList = Ext.extend(Ext.Panel, {
    id: 'albumPanel',
    cls: 'album-panel',
    loadingText: 'Loading Slideshows...',
    layout: 'fit',
    initComponent: function() {

        var list = {
            xtype: 'list',
            id: 'albumList',
            itemTpl: '{photo} {formatted_name}',
            fullscreen: true,
            layout: 'fit',
            /*monitorOrientation: true,
            onItemDisclosure: true,*/
            loadingText: 'Loading Slideshows...',
            singleSelect: true,
            store: App.stores.Albums,
            listeners: {
                scope: this,
                itemtap: this.onItemTapAction
            }
        }

        var topBar = {
            xtype: 'toolbar',
            title: 'Slideshows',
            dock: 'top',
            items: [{ 
                iconCls: 'refresh',
                iconMask: true,
                handler: function() {
                    Ext.dispatch({
                        controller: 'Albums',
                        action: 'refresh'
                    });
                }   
            }, { xtype: 'spacer' },{ 
                iconCls: 'settings',
                iconMask: true,
                handler: function() {
                    Ext.dispatch({
                        controller: 'Settings',
                        action: 'index'
                    });
                }   
            }]  
        }

        /*var bottomBar = {
            height: 50,
            title: 'The Latest',
            html: '<iframe src =\"admob.html" width=\"100%\" height=\"50\" frameBorder=\"0\" scrolling=\"no\"></iframe>',
            id: 'feedTab',
            border: false,
            dock: 'bottom'
        }*/

        this.items = [list];
        //this.dockedItems = [topBar, bottomBar];
        this.dockedItems = [topBar];
    
        App.views.AlbumsList.superclass.initComponent.call(this);
    },

    onItemTapAction: function(data_view, idx, item, evt) {
        //console.log('hello');
        var record = data_view.getRecord(item);
        
        Ext.dispatch({
            controller: 'Albums',
            action: 'startSlideshow',
            record: record
        });
    }
});

Ext.reg('App.views.AlbumsList', App.views.AlbumsList);

