mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
BUGFIX: restore Mousetrap's bindGlobal plugin
cleared deprecated warnings in admin_customize_view
This commit is contained in:
parent
9a3c64535b
commit
7a82b65386
2 changed files with 64 additions and 25 deletions
|
@ -11,42 +11,30 @@
|
||||||
Discourse.AdminCustomizeView = Discourse.View.extend({
|
Discourse.AdminCustomizeView = Discourse.View.extend({
|
||||||
templateName: 'admin/templates/customize',
|
templateName: 'admin/templates/customize',
|
||||||
classNames: ['customize'],
|
classNames: ['customize'],
|
||||||
headerActive: Ember.computed.equal('selected', 'header'),
|
selected: 'stylesheet',
|
||||||
stylesheetActive: Ember.computed.equal('selected', 'stylesheet'),
|
headerActive: Em.computed.equal('selected', 'header'),
|
||||||
mobileHeaderActive: Ember.computed.equal('selected', 'mobileHeader'),
|
stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
|
||||||
mobileStylesheetActive: Ember.computed.equal('selected', 'mobileStylesheet'),
|
mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'),
|
||||||
|
mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'),
|
||||||
|
|
||||||
init: function() {
|
actions: {
|
||||||
this._super();
|
selectHeader: function() { this.set('selected', 'header'); },
|
||||||
this.set('selected', 'stylesheet');
|
selectStylesheet: function() { this.set('selected', 'stylesheet'); },
|
||||||
},
|
|
||||||
|
|
||||||
selectHeader: function() {
|
selectMobileHeader: function() { this.set('selected', 'mobileHeader'); },
|
||||||
this.set('selected', 'header');
|
selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); },
|
||||||
},
|
|
||||||
|
|
||||||
selectStylesheet: function() {
|
|
||||||
this.set('selected', 'stylesheet');
|
|
||||||
},
|
|
||||||
|
|
||||||
selectMobileHeader: function() {
|
|
||||||
this.set('selected', 'mobileHeader');
|
|
||||||
},
|
|
||||||
|
|
||||||
selectMobileStylesheet: function() {
|
|
||||||
this.set('selected', 'mobileStylesheet');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var controller = this.get('controller');
|
var controller = this.get('controller');
|
||||||
return Mousetrap.bindGlobal(['meta+s', 'ctrl+s'], function() {
|
Mousetrap.bindGlobal('mod+s', function() {
|
||||||
controller.save();
|
controller.send("save");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement: function() {
|
willDestroyElement: function() {
|
||||||
return Mousetrap.unbindGlobal('meta+s', 'ctrl+s');
|
Mousetrap.unbindGlobal('mod+s');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
51
vendor/assets/javascripts/mousetrap.js
vendored
51
vendor/assets/javascripts/mousetrap.js
vendored
|
@ -951,3 +951,54 @@
|
||||||
define(Mousetrap);
|
define(Mousetrap);
|
||||||
}
|
}
|
||||||
}) (window, document);
|
}) (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…
Add table
Add a link
Reference in a new issue