+ editorDidLoad: function(editor) {
+ $(editor.frame).css({width: '100%', height: '100%'});
+
+ this.model
+ .addObserver(this, 'data', this.modelDataChanged.bind(this))
+ .addObserver(this, 'synced', this.modelSyncChanged.bind(this));
+
+ this.parent.unfreeze();
+
+ this.editor.setCode(this.model.get('data'));
+ if (!this.model.get('synced')) {
+ this.parent.freeze('Niezsynchronizowany...');
+ this.model.load();
+ }
+
+ // 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);
+ }
+ },
+
+ modelSyncChanged: function(property, value) {
+ if (value) {
+ this.parent.unfreeze();
+ } else {
+ this.parent.freeze('Niezsynchronizowany...');
+ }
+ },