/** * Class Description * @namespace FIRSTCLASS.apps * @module Music Folder * @requires * @optional * @title */ /** * Constructor definition * @class Music * @constructor * @param {Object} config (required) the configuration object * @param {HTMLElement} config.domElement (required) the DOM Element to load into * @param {FIRSTCLASS.util.DataSource} config.dataSource (required) the DataSource to bind to */ FIRSTCLASS.apps.Music = function(config) { var that = this; this._domElement = null; this._dataSource = null; this._dataTable = null; this._listView = null; this._config = config; this._domElement = this._config.div; this._dataSource = new FIRSTCLASS.util.DataSource({containerBaseUrl: this._config.baseUrl, autoLoad: true, watchForNew: false, loadUnreadImmediate: true}); this._dataSource.addRowListener({ onRow:function(row, dataSource) { that._config.onLoaded(); }, onFillCompleted:function(row, dataSource) { that._config.onLoaded(); } }); this._domElement.innerHTML = ""; this.iconFormatter = function(elCell, oRecord, oColumn, oData) { var row = oRecord.getData(); YAHOO.util.Dom.addClass(elCell, "col5"); elCell.innerHTML = ""; }; var finsishConstructOnFirstRow = { onRow: function(row, dataSource, atEnd) { var myColumnDefs = [ {key:"col5", label:"Icon", formatter:that.iconFormatter, sortable:true, resizeable:true}, {key:"col8301", label:"Title", sortable:true, resizeable:true}, {key:"col8302", label:"Albumn", sortable:true, resizeable:true}, {key:"col8303", label:"Artist", sortable:true, resizeable:true}, {key:"col8304", label:"Track", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true}, {key:"col8305", label:"Genre", sortable:true, resizeable:true}, {key:"col8306", label:"Year", sortable:true, resizeable:true}, {key:"col8307", label:"Bitrate", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true}, {key:"col8308", label:"Time", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true}, {key:"col2", label:"Date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true} ]; var yahooDS = that._dataSource.getYAHOOUtilDataSource(); that._dataTable = new YAHOO.widget.DataTable(that._domElement, myColumnDefs, yahooDS, {caption:"Music"}); var lvConfig = { domElement: that._domElement, dataSource: that._dataSource, objTypePriority: [FIRSTCLASS.objTypes.file], fillOnScroll: true, threading: { format: "bydate" }, rowFilter: function(row) { return (row.typedef.objtype.id == FIRSTCLASS.objTypes.file) }, rowHandler: new FIRSTCLASS.layout.MusicHandler(that._dataSource,that._dataTable) }; if (config.onResize) { lvConfig.onResize = config.onResize; } // that._listView = new FIRSTCLASS.layout.ListView(lvConfig); FIRSTCLASS.session.setActiveApplication(that, "music"); dataSource.removeRowListener(finsishConstructOnFirstRow); } }; this._dataSource.addRowListener(finsishConstructOnFirstRow); }; /** * Public static variables definitions */ /** * Property Comment, describe it here * * @property * @type * @default */ //FIRSTCLASS.apps.Music. = ; /** * Private member variables * * Private variables are identified by the convention of naming them with a leading underscore. * i.e. this._privateVariable */ /** * Variable Comment, describe it here * * @property _ * @type * @default */ FIRSTCLASS.apps.Music.prototype._dataSource = null; FIRSTCLASS.apps.Music.prototype._domElement = null; /** * Public member variables */ /** * Variable Comment, describe it here * * @property * @type * @default */ //FIRSTCLASS.apps.Music.prototype. = ; /** * Public Static Method Definitions */ /** * Method Comment, describe it here * * @Method Music. * @param {} paramname * @param ... * @return {} * @static */ //FIRSTCLASS.apps.Documents. = function() { //}; /** * Public method definitions */ /** * Method Comment, describe it here * * @Method Music. * @param {} paramname * @param ... * @return {} */ //FIRSTCLASS.apps.Documents.prototype. = function() { //}; FIRSTCLASS.layout.MusicHandler = function(dataSource,dataTable) { if(!FIRSTCLASS.layout.MusicHandler._rowTemplate) { FIRSTCLASS.layout.MusicHandler._rowTemplate = document.createElement("div"); FIRSTCLASS.layout.MusicHandler._rowTemplate.innerHTML = " "; } this._dataSource = dataSource; this._dataTable = dataTable; }; FIRSTCLASS.layout.MusicHandler.prototype.drawRow = function(row) { this._dataTable.addRow(); var newElement = FIRSTCLASS.layout.MusicHandler.prototype.updateRow(row,FIRSTCLASS.layout.MusicHandler._rowTemplate.cloneNode(true)); newElement._dataSource = this._dataSource; newElement._dataTable = this._dataTable; newElement._iconURI = row.icon.uri; var that = this; YAHOO.util.Event.addListener(newElement, "click", function(evt) { that._dataSource.fetchItem(row); }); return newElement; }; FIRSTCLASS.layout.MusicHandler.prototype.updateRow = function(row, element) { /* var img = element.firstChild; var text = element.lastChild; img.src = row.icon.uri; var name = ""; if (typeof row.col8301!="undefined" && row.col8301!=null && row.col8301!="") name = row.col8301; if (typeof row.col8303!="undefined" && row.col8303!=null && row.col8303!="") { if (name!="") { name += " / "; name += row.col8303; } } if (name=="" && (typeof row.name=="undefined" || row.name==null || row.name=="")) name = row.name; if(row.online) { text.innerHTML = ""+name+""; } else { text.innerHTML = name; } var that = this; YAHOO.util.Event.addListener(img, "click", function(evt) { that._dataSource.fetchItem(row); }); */ return element; }; FIRSTCLASS.layout.MusicHandler.prototype.generateUniqueId = function(row) { return row.uid; }; YAHOO.register("fcMusic", FIRSTCLASS.apps.Music, {version: "0.0.1", build: "1"}); /* YAHOO.util.Event.addListener(window, "load", function() { YAHOO.example.CustomFormatting = new function() { // Define a custom formatter for the Column labeled "flag" // draws an up icon if value of field3 is greater than 100, // otherwise renders a down icon this.myCustomFormatter = function(elCell, oRecord, oColumn, oData) { YAHOO.util.Dom.addClass(elCell, "flag"); if(oRecord.getData("field3") > 100) { elCell.innerHTML = ' '; } else { elCell.innerHTML = ' '; } }; // Override the built-in formatter YAHOO.widget.DataTable.formatEmail = function(elCell, oRecord, oColumn, oData) { var user = oData; elCell.innerHTML = "" + user + ""; }; var myColumnDefs = [ {key:"flag", formatter:this.myCustomFormatter}, // use custom formatter {key:"radio", formatter:YAHOO.widget.DataTable.formatRadio}, // use the built-in radio formatter {key:"check", formatter:YAHOO.widget.DataTable.formatCheckbox}, // use the built-in checkbox formatter {key:"button", label:"Show record data", formatter:YAHOO.widget.DataTable.formatButton}, // use the built-in button formatter {key:"field1", sortable:true}, {key:"field2", sortable:true, formatter:YAHOO.widget.DataTable.formatDate}, // use the built-in date formatter {key:"field3", sortable:true}, {key:"field4", sortable:true, formatter:YAHOO.widget.DataTable.formatCurrency}, // use the built-in currency formatter {key:"field5", sortable:true, formatter:YAHOO.widget.DataTable.formatEmail}, // use the overridden email formatter {key:"field6", sortable:true, formatter:YAHOO.widget.DataTable.formatLink} // use the built-in link formatter ]; this.myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.multitypes); this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; this.myDataSource.responseSchema = { resultsList: "items", // Use the parse methods to populate the RecordSet with the right data types fields: [ {key:"field1", parser:YAHOO.util.DataSource.parseString}, // point to the string parser {key:"field2", parser:YAHOO.util.DataSource.parseDate}, // point to the date parser {key:"field3", parser:YAHOO.util.DataSource.parseNumber}, // point to the number parser {key:"field4", parser:YAHOO.util.DataSource.parseNumber}, // point to the number parser {key:"field5"}, // this is already string data so no parser needed {key:"field6"} // this is already string data so no parser needed ] }; this.myDataTable = new YAHOO.widget.DataTable("formatting", myColumnDefs, this.myDataSource); var lastSelectedRadioRecord = null; this.myDataTable.subscribe("radioClickEvent", function(oArgs){ if(lastSelectedRadioRecord) { lastSelectedRadioRecord.setData("radio",false); } var elRadio = oArgs.target; var elRecord = this.getRecord(elRadio); elRecord.setData("radio",true); lastSelectedRadioRecord = elRecord; var name = elRecord.getData("field5"); }); this.myDataTable.subscribe("checkboxClickEvent", function(oArgs){ var elCheckbox = oArgs.target; var elRecord = this.getRecord(elCheckbox); elRecord.setData("check",elCheckbox.checked); var name = elRecord.getData("field5"); }); this.myDataTable.subscribe("buttonClickEvent", function(oArgs){ var oRecord = this.getRecord(oArgs.target); alert(YAHOO.lang.dump(oRecord.getData())); }); }; }); */