lib/dom/document.js
function Document(generator, config, logger, raw) {
        if (DEBUG_TO_RAW_CONVERSION) {
            debugLogObject("raw", raw);
        }

        events.EventEmitter.call(this);
        
        this._generator = generator;
        this._config = config;
        this._logger = logger;


        var property;
        for (property in raw) {
            if (raw.hasOwnProperty(property)) {
                switch (property) {
                case "id":
                    this._id = raw.id;
                    break;
                case "count":
                    this._count = raw.count;
                    break;
                case "timeStamp":
                    this._timeStamp = raw.timeStamp;
                    break;
                case "version":
                    this._version = raw.version;
                    break;
                case "file":
                    this._setFile(raw.file);
                    break;
                case "bounds":
                    this._setBounds(raw.bounds);
                    break;
                case "selection":
                    // Resolving the selection depends on the layers; set it in a later pass
                    break;
                case "resolution":
                    this._setResolution(raw.resolution);
                    break;
                case "globalLight":
                    this._setGlobalLight(raw.globalLight);
                    break;
                case "generatorSettings":
                    this._setGeneratorSettings(raw.generatorSettings);
                    break;
                case "layers":
                    this._setLayers(raw.layers);
                    break;
                case "comps":
                    this._setComps(raw.comps);
                    break;
                case "placed":
                    this._setPlaced(raw.placed);
                    break;
                case "mode":
                    this._setMode(raw.mode);
                    break;
                case "profile":
                case "depth":
                    // Do nothing for these properties
                    // TODO could profile be helpful for embedding color profile?
                    break;
                default:
                    this._logger.warn("Unhandled property in raw constructor:", property, raw[property]);
            }
            }
        }

        if (raw.hasOwnProperty("selection")) {
            this._setSelection(raw.selection);
        }

        if (DEBUG_TO_RAW_CONVERSION) {
            debugLogObject("document.toRaw", this.toRaw());
        }
    }
function Document(generator, config, logger, raw) {
        if (DEBUG_TO_RAW_CONVERSION) {
            debugLogObject("raw", raw);
        }

        events.EventEmitter.call(this);
        
        this._generator = generator;
        this._config = config;
        this._logger = logger;


        var property;
        for (property in raw) {
            if (raw.hasOwnProperty(property)) {
                switch (property) {
                case "id":
                    this._id = raw.id;
                    break;
                case "count":
                    this._count = raw.count;
                    break;
                case "timeStamp":
                    this._timeStamp = raw.timeStamp;
                    break;
                case "version":
                    this._version = raw.version;
                    break;
                case "file":
                    this._setFile(raw.file);
                    break;
                case "bounds":
                    this._setBounds(raw.bounds);
                    break;
                case "selection":
                    // Resolving the selection depends on the layers; set it in a later pass
                    break;
                case "resolution":
                    this._setResolution(raw.resolution);
                    break;
                case "globalLight":
                    this._setGlobalLight(raw.globalLight);
                    break;
                case "generatorSettings":
                    this._setGeneratorSettings(raw.generatorSettings);
                    break;
                case "layers":
                    this._setLayers(raw.layers);
                    break;
                case "comps":
                    this._setComps(raw.comps);
                    break;
                case "placed":
                    this._setPlaced(raw.placed);
                    break;
                case "mode":
                    this._setMode(raw.mode);
                    break;
                case "profile":
                case "depth":
                    // Do nothing for these properties
                    // TODO could profile be helpful for embedding color profile?
                    break;
                default:
                    this._logger.warn("Unhandled property in raw constructor:", property, raw[property]);
            }
            }
        }

        if (raw.hasOwnProperty("selection")) {
            this._setSelection(raw.selection);
        }

        if (DEBUG_TO_RAW_CONVERSION) {
            debugLogObject("document.toRaw", this.toRaw());
        }
    }
function Document ( generator , config , logger , raw ) { if ( DEBUG_TO_RAW_CONVERSION ) { debugLogObject ( "raw" , raw ) ; } events . EventEmitter . call ( this ) ; this . _generator = generator ; this . _config = config ; this . _logger = logger ; var property ; for ( property in raw ) { if ( raw . hasOwnProperty ( property ) ) { switch ( property ) { case "id" : this . _id = raw . id ; break ; case "count" : this . _count = raw . count ; break ; case "timeStamp" : this . _timeStamp = raw . timeStamp ; break ; case "version" : this . _version = raw . version ; break ; case "file" : this . _setFile ( raw . file ) ; break ; case "bounds" : this . _setBounds ( raw . bounds ) ; break ; case "selection" : // Resolving the selection depends on the layers; set it in a later pass break ; case "resolution" : this . _setResolution ( raw . resolution ) ; break ; case "globalLight" : this . _setGlobalLight ( raw . globalLight ) ; break ; case "generatorSettings" : this . _setGeneratorSettings ( raw . generatorSettings ) ; break ; case "layers" : this . _setLayers ( raw . layers ) ; break ; case "comps" : this . _setComps ( raw . comps ) ; break ; case "placed" : this . _setPlaced ( raw . placed ) ; break ; case "mode" : this . _setMode ( raw . mode ) ; break ; case "profile" : case "depth" : // Do nothing for these properties // TODO could profile be helpful for embedding color profile? break ; default : this . _logger . warn ( "Unhandled property in raw constructor:" , property , raw [ property ] ) ; } } } if ( raw . hasOwnProperty ( "selection" ) ) { this . _setSelection ( raw . selection ) ; } if ( DEBUG_TO_RAW_CONVERSION ) { debugLogObject ( "document.toRaw" , this . toRaw ( ) ) ; } }
Model of a Photoshop document.

@constructor
@param {Generator} generator
@param {object} config
@param {Logger} logger
@param {object} raw Raw description of the document
Model of a Photoshop document .