silk.postings = ( xb.core.object.extend( { ctor: function( config ) { var self = this; this.config = config; this.resources = {}; this.__eventHandlers = { "ready": [] }; }, load: function( resource ) { var self = this; resource.data = []; console.log( "silk.postings.resource::load", resource.config ); var config = this.config[ resource.config.name ]; this.resources[ resource.config.name ] = resource; var params = {}; // resource.loadURL( config.json, null, function( data ) { var data = ( data === null ) ? {} : data; data[ "postings-categories" ] = resource.getDataView( "postings-categories", data ); data[ "postings-filters" ] = resource.getDataView( "postings-filters", data ); data[ "postings-items" ] = resource.getDataView( "postings-items", data ); for ( var view in config.views ) { if ( data[ view ] instanceof silk.data ) { continue; } data[ view ] = resource.getDataView( view, data ); } resource.load( data ); resource.select( {} ); resource.isReady = true; var handlers = self.__eventHandlers[ "ready" ]; for ( var i = 0, il = handlers.length; i < il; i++ ) { handlers[ i ]( resource.config.name, resource ); } } ); }, on: function( evt, evtHandler ) { if ( this.__eventHandlers[ evt ] instanceof Array ) { if ( typeof( evtHandler ) === "function" ) { this.__eventHandlers[ evt ].push( evtHandler ); } } }, select: function() { for ( var n in this.resources ) { this.resources[ n ].select( {} ); } }, get: function( resource, name ) { var config = this.config[ resource.config.name ]; if ( typeof( name ) !== "undefined" ) { config = config[ name ]; } return config; } } ) )( postings_config );