mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: allow copying of color schemes to clipboard
This commit is contained in:
@@ -20,6 +20,31 @@ export default Ember.Controller.extend({
|
||||
color.undo();
|
||||
},
|
||||
|
||||
copyToClipboard() {
|
||||
$(".table.colors").hide();
|
||||
let area = $("<textarea id='copy-range'></textarea>");
|
||||
$(".table.colors").after(area);
|
||||
area.text(this.get("model").schemeJson());
|
||||
let range = document.createRange();
|
||||
range.selectNode(area[0]);
|
||||
window.getSelection().addRange(range);
|
||||
let successful = document.execCommand('copy');
|
||||
if (successful) {
|
||||
this.set("model.savingStatus", I18n.t("admin.customize.copied_to_clipboard"));
|
||||
} else {
|
||||
this.set("model.savingStatus", I18n.t("admin.customize.copy_to_clipboard_error"));
|
||||
}
|
||||
|
||||
setTimeout(()=>{
|
||||
this.set("model.savingStatus", null);
|
||||
}, 2000);
|
||||
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
$(".table.colors").show();
|
||||
$(area).remove();
|
||||
},
|
||||
|
||||
copy() {
|
||||
var newColorScheme = Em.copy(this.get('model'), true);
|
||||
newColorScheme.set('name', I18n.t('admin.customize.colors.copy_name_prefix') + ' ' + this.get('model.name'));
|
||||
|
||||
Reference in New Issue
Block a user