aboutsummaryrefslogtreecommitdiff
path: root/js/document/text-document.js
blob: f74742ad8eac3adf8df6566bffe2bbbec1364eee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc.  All Rights Reserved.
</copyright> */

//BaseDocument Object for all files types and base class for HTML documents.

var Montage = require("montage/core/core").Montage;

var TextDocument = exports.TextDocument = Montage.create(Montage, {
	
	
	//TODO: Clean up, test
	
	
	
	
	
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	//Taken from text-document, which shouldn't be needed

	// PRIVATE MEMBERS
    _codeEditor: {
        value: {
            "editor": { value: null, enumerable: false },

        }
    },

    _editor: { value: null, enumerable: false },
    _hline: { value: null, enumerable: false },

    _textArea: {value: null, enumerable: false },
	
	_userDocument: {value: null, enumerable: false },
	
    _source: { value: null, enumerable: false},

    source: {
        get: function() { return this._source;},
        set: function(value) { this._source = value;}
    },

    // PUBLIC MEMBERS

    _savedLeftScroll: {value:null},
    _savedTopScroll: {value:null},

    //****************************************//
    //PUBLIC API


    // GETTERS / SETTERS

    savedLeftScroll:{
        get: function() { return this._savedLeftScroll; },
        set: function(value) { this._savedLeftScroll = value}
    },

    savedTopScroll:{
        get: function() { return this._savedTopScroll; },
        set: function(value) { this._savedTopScroll = value}
    },

    textArea: {
        get: function() { return this._textArea; },
        set: function(value) { this._textArea = value; }
    },
    editor: {
        get: function() { return this._editor; },
        set: function(value) { this._editor = value}
    },

    hline: {
        get: function() { return this._hline; },
        set: function(value) {this._hline = value; }
    },

    
    ////////////////////////////////////////////////////////////////////
	//
    initialize: {
    	value: function(file, uuid, textArea, container, callback) {
        	//
			this._userDocument = file;
			//
			this.init(file.name, file.uri, file.extension, container, uuid, callback);
	        //
    	    this.currentView = "code";
        	this.textArea = textArea;
        }
    },
    ////////////////////////////////////////////////////////////////////
    //
	save: {
		enumerable: false,
    	value: function () {
    		//TODO: Improve sequence
    		this.editor.save();
    		return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value};
    	}
	},
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	
	
	
    /** Private Members **/
    _name: { value: null, enumerable: false },
    _uri: { value: null, enumerable: false },
    _documentType: { value: null, enumerable: false },
    _container: {value: null, enumerable: false },
    _uuid: { value: null, enumerable: false },
    _isActive: { value: true, enumerable: false },
    _dirtyFlag: { value: false, enumerable: false },
    _callback: { value: null, enumerable: false },
    _currentView: { value: null, enumerable: false},

    /** Getters/Setters **/
    name: {
        get: function() { return this._name; },
        set: function(value) { this._name = value; }
    },

    uri: {
        get: function() { return this._uri; },
        set: function(value) { this._uri = value; }
    },

    documentType: {
        get: function() { return this._documentType; },
        set: function(value) { this._documentType = value;  }
    },

    container: {
        get: function() { return this._container; },
        set: function(value) { this._container = value; }
    },

    uuid: {
        get: function() { return this._uuid; },
        set: function(value) { this._uuid = value; }
    },

    isActive: {
        get: function() { return this._isActive; },
        set: function(value) { this._isActive = value; }
    },

    dirtyFlag: {
        get: function() { return this._dirtyFlag; },
        set: function(value) { this._dirtyFlag = value; }
    },

    callback: {
        get: function() { return this._callback; },
        set: function(value) { this._callback = value; }
    },

    currentView: {
        get: function() { return this._currentView; },
        set: function(value) { this._currentView = value }
    },

    /** Base Methods **/
    init: {
        value: function(name, uri, type, container, uuid, callback) {
            this.name = name;
            this.uri = uri;
            this.documentType = type;
            this.container = container;
            this.uuid = uuid;
            this.callback = callback;
        }
    },

    loadDocument: {
        value: function() {
            // Have the XHR here?
        }
    },

    markDocumentEditted:{
        value: function() {
            this.dirtyFlag = true;
        }
    },

    markDocumentUneditted:{
        value: function() {
            this.dirtyFlag = false;
        }
    }
});