FEATURE: allow copying of color schemes to clipboard

This commit is contained in:
Sam Saffron
2017-04-18 09:37:55 -04:00
parent f968b4e662
commit a19c02f0d3
4 changed files with 38 additions and 0 deletions

View File

@@ -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'));