Current File : /home/jvzmxxx/wiki/extensions/Flow/modules/flow/dm/mw.flow.dm.Content.js
( function ( $ ) {
	/**
	 * Flow Content class
	 *
	 * @class
	 *
	 * @constructor
	 * @param {Object} [representations]
	 * 	{
	 * 		content: "content in the default format",
	 * 		format: "name of the default format",
	 * 		"(other format name 1)": "content in the specified format"
	 * 		"(other format name n)": "content in the specified format"
	 * 	}
	 */
	mw.flow.dm.Content = function mwFlowContent( representations ) {
		// Mixin constructor
		OO.EventEmitter.call( this );

		// Initialize properties
		this.set( representations );
	};

	/* Inheritance */

	OO.mixinClass( mw.flow.dm.Content, OO.EventEmitter );

	/* Events */

	/**
	 * Change of content
	 *
	 * @event contentChange
	 */

	/* Methods */

	/**
	 * Get content representation for the specified format or the default format if none is specified.
	 *
	 * @param {string} [format=this.defaultFormat]; can be wikitext, html, fixed-html, topic-title-wikitext, topic-title-html, plaintext
	 * @return {string} Content
	 */
	mw.flow.dm.Content.prototype.get = function ( format ) {
		if ( !this.contentRepresentations ) {
			return null;
		}

		format = format || this.defaultFormat;

		if ( this.contentRepresentations.hasOwnProperty( format ) ) {
			return this.contentRepresentations[ format ];
		}
		return null;
	};

	/**
	 * Set content representations
	 *
	 * @param {Object} [representations]
	 * @fires contentChange
	 */
	mw.flow.dm.Content.prototype.set = function ( representations ) {
		this.defaultFormat = null;
		this.contentRepresentations = {};

		if ( representations ) {
			this.defaultFormat = representations.format;
			this.contentRepresentations[ this.defaultFormat ] = representations.content;

			for ( var format in representations ) {
				if ( representations.hasOwnProperty( format ) ) {
					this.contentRepresentations[ format ] = representations[ format ];
				}
			}
		}

		this.emit( 'contentChange' );
	};
}( jQuery ) );