- handle: function(event, data) {
- console.log('handle', this, event, data);
- if (event == 'text-changed') {
- this.freeze('Niezsynchronizowany');
- // this.unfreeze();
- } else if (event == 'xml-freeze') {
- this.freeze('Ładowanie XMLa...');
- } else if (event == 'xml-unfreeze') {
- this.editor.setCode(this.model.get('text'));
- this.unfreeze();
+ 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();
+ },
+
+ getHotkey: function(event) {
+ var code = event.keyCode;
+ if(!((code >= 97 && code <= 122)
+ || (code >= 65 && code <= 90)) ) return null;
+
+ var ch = String.fromCharCode(code & 0xff).toLowerCase();
+ /* # console.log(ch.charCodeAt(0), '#', buttons); */
+
+ var buttons = $('.buttontoolbarview-button[title='+ch+']', this.element);
+ var mod = 0;
+
+ if(event.altKey) mod |= 0x01;
+ if(event.ctrlKey) mod |= 0x02;
+ if(event.shiftKey) mod |= 0x04;
+
+ if(buttons.length) {
+ var match = null;
+
+ buttons.each(function() {
+ if( parseInt($(this).attr('ui:hotkey_mod')) == mod ) {
+ match = this;
+ return;
+ }
+ })
+
+ return match;
+ }
+ else {
+ return null;
+ }
+ },
+
+ isHotkey: function() {
+ /* console.log(arguments); */
+ if(this.getHotkey.apply(this, arguments))
+ return true;
+ else
+ return false;
+ },
+
+ hotkeyPressed: function() {
+ var button = this.getHotkey.apply(this, arguments);
+ this.buttonToolbar.buttonPressed({
+ target: button
+ });