+ this.parent.unfreeze();
+
+ this.editor.setCode(this.model.get('data'));
+ this.modelStateChanged('state', this.model.get('state'));
+
+ // editor.grabKeys(
+ // $.fbind(self, self.hotkeyPressed),
+ // $.fbind(self, self.isHotkey)
+ // );
+ },
+
+ editorDataChanged: function() {
+ this.model.set('data', this.editor.getCode());
+ },
+
+ modelDataChanged: function(property, value) {
+ if (this.editor.getCode() != value) {
+ this.editor.setCode(value);
+ }
+ },
+
+ modelStateChanged: function(property, value) {
+ if (value == 'synced' || value == 'dirty') {
+ this.unfreeze();
+ } else if (value == 'unsynced') {
+ this.freeze('Niezsynchronizowany...');
+ } else if (value == 'loading') {
+ this.freeze('Ładowanie...');
+ } else if (value == 'saving') {
+ this.freeze('Zapisywanie...');
+ } else if (value == 'error') {
+ this.freeze(this.model.get('error'));
+ }
+ },
+
+ dispose: function() {
+ this.model.removeObserver(this);
+ $(this.editor.frame).remove();
+ this._super();