BUGFIX: restore Mousetrap's bindGlobal plugin
cleared deprecated warnings in admin_customize_view
This commit is contained in:
parent
9a3c64535b
commit
7a82b65386
|
@ -11,42 +11,30 @@
|
|||
Discourse.AdminCustomizeView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/customize',
|
||||
classNames: ['customize'],
|
||||
headerActive: Ember.computed.equal('selected', 'header'),
|
||||
stylesheetActive: Ember.computed.equal('selected', 'stylesheet'),
|
||||
mobileHeaderActive: Ember.computed.equal('selected', 'mobileHeader'),
|
||||
mobileStylesheetActive: Ember.computed.equal('selected', 'mobileStylesheet'),
|
||||
selected: 'stylesheet',
|
||||
headerActive: Em.computed.equal('selected', 'header'),
|
||||
stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
|
||||
mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'),
|
||||
mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'),
|
||||
|
||||
init: function() {
|
||||
this._super();
|
||||
this.set('selected', 'stylesheet');
|
||||
},
|
||||
actions: {
|
||||
selectHeader: function() { this.set('selected', 'header'); },
|
||||
selectStylesheet: function() { this.set('selected', 'stylesheet'); },
|
||||
|
||||
selectHeader: function() {
|
||||
this.set('selected', 'header');
|
||||
},
|
||||
|
||||
selectStylesheet: function() {
|
||||
this.set('selected', 'stylesheet');
|
||||
},
|
||||
|
||||
selectMobileHeader: function() {
|
||||
this.set('selected', 'mobileHeader');
|
||||
},
|
||||
|
||||
selectMobileStylesheet: function() {
|
||||
this.set('selected', 'mobileStylesheet');
|
||||
selectMobileHeader: function() { this.set('selected', 'mobileHeader'); },
|
||||
selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); },
|
||||
},
|
||||
|
||||
didInsertElement: function() {
|
||||
var controller = this.get('controller');
|
||||
return Mousetrap.bindGlobal(['meta+s', 'ctrl+s'], function() {
|
||||
controller.save();
|
||||
Mousetrap.bindGlobal('mod+s', function() {
|
||||
controller.send("save");
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
return Mousetrap.unbindGlobal('meta+s', 'ctrl+s');
|
||||
Mousetrap.unbindGlobal('mod+s');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -951,3 +951,54 @@
|
|||
define(Mousetrap);
|
||||
}
|
||||
}) (window, document);
|
||||
|
||||
/**
|
||||
* adds a bindGlobal method to Mousetrap that allows you to
|
||||
* bind specific keyboard shortcuts that will still work
|
||||
* inside a text input field
|
||||
*
|
||||
* usage:
|
||||
* Mousetrap.bindGlobal('ctrl+s', _saveChanges);
|
||||
* Mousetrap.unbindGlobal('ctrl+s');
|
||||
*/
|
||||
/* global Mousetrap:true */
|
||||
Mousetrap = (function(Mousetrap) {
|
||||
var _globalCallbacks = {},
|
||||
_originalStopCallback = Mousetrap.stopCallback;
|
||||
|
||||
Mousetrap.stopCallback = function(e, element, combo, sequence) {
|
||||
if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _originalStopCallback(e, element, combo);
|
||||
};
|
||||
|
||||
Mousetrap.bindGlobal = function(keys, callback, action) {
|
||||
Mousetrap.bind(keys, callback, action);
|
||||
|
||||
if (keys instanceof Array) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
_globalCallbacks[keys[i]] = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_globalCallbacks[keys] = true;
|
||||
};
|
||||
|
||||
Mousetrap.unbindGlobal = function(keys, action) {
|
||||
Mousetrap.unbind(keys, action);
|
||||
|
||||
if (keys instanceof Array) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
_globalCallbacks[keys[i]] = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_globalCallbacks[keys] = false;
|
||||
};
|
||||
|
||||
return Mousetrap;
|
||||
}) (Mousetrap);
|
||||
|
|
Loading…
Reference in New Issue