Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar icon issue99 (incomplete implementation) #105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var imageResize = require("gulp-image-resize");
var zip = require("gulp-zip");
var jade = require("gulp-jade");
var spritesmith = require("gulp.spritesmith");
var rename = require("gulp-rename");
var request = require("request-promise-native");
var fs = require("fs-extra");

Expand All @@ -22,12 +23,25 @@ var static = [
"./data/emoji/owl.png",
"./data/emoji/heart.png"
];
var emojiName = 'smiley'

gulp.task("emoji", function() {
return gulp.src(static).pipe(gulp.dest(BUILD_DIR + "./img/emoji/"));
});

gulp.task("sources", function() {
let toolbarEmoji = `data/emoji/${emojiName}.png`;
[64, 48, 32, 24, 16].forEach(function(size) {
output = `icon${size}.png`
gulp.src(toolbarEmoji)
.pipe(imageResize({
width: size,
height: size
}))
.pipe(rename(output))
.pipe(gulp.dest("icons")
);
});
gulp.src([
"./src/**/*",
"!./src/popup.jade",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"gulp": "^3.9.0",
"gulp-image-resize": "^0.12.0",
"gulp-jade": "^1.1.0",
"gulp-rename": "^3.10.10",
"gulp-zip": "^4.0.0",
"gulp.spritesmith": "^6.5.0",
"imagemin-pngquant": "^4.2.2",
Expand Down
7 changes: 7 additions & 0 deletions src/popup.jade
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ html
input#insert-name(type="radio", name="default-copy", value="insertname")
label(for="insert-name") Insert :name: into active input
hr
p.setting-title Change Toolbar Emoji
p.setting
input#toolbar-emoji(type="text", name="change-toolbarbutton", value="")
input#toolbar-emoji-button(type="button", value="Change")
br
label(for="toolbar-emoji") (only paste)
hr
span.setting-title History
button#clear-history-button.detail-button(title="Clear history")
i.ion-trash-b
Expand Down
28 changes: 27 additions & 1 deletion src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
r.selectNode(copyDiv);
let s = window.getSelection();
s.removeAllRanges();
s.addRange(r);
s.addRange(r);
document.execCommand("copy");
document.body.removeChild(copyDiv);
};
Expand Down Expand Up @@ -71,6 +71,11 @@
let copyImg = document.getElementById("copy-img");
let insertName = document.getElementById("insert-name");

let toolbarEmoji = document.getElementById("toolbar-emoji");
let toolbarEmojiButton = document.getElementById("toolbar-emoji-button");
let defaultToolbarEmoji = "smiley";
let errorMessage = document.getElementById("error-message");

let whatToCopy = "name";
let lastCopyValue = "";

Expand Down Expand Up @@ -355,6 +360,23 @@
}
});

// customize toolbar emoji
getLocal("toolbar-emoji", function(inputName) {
if (inputName == undefined) {
toolbarEmoji.setAttribute("value", defaultToolbarEmoji);
} else {
inputName = inputName.replace(/:/g,'');
let exists = (emojis.filter(function(emoji) {
return emoji.name.includes(inputName)
})).length == 1 ? true : false;
if (exists) {
emojiName = inputName;
toolbarEmoji.setAttribute("value", emojiName);
} else {
toolbarEmoji.setAttribute("value", defaultToolbarEmoji);
}
}
});
}, false);

copyName.addEventListener("click", function () {
Expand All @@ -379,6 +401,10 @@
setLocal("copy-setting", "copyimg");
});

toolbarEmojiButton.addEventListener("click", function () {
setLocal("toolbar-emoji", toolbarEmoji.value);
});

let alphaNum = /[a-zA-Z0-9]/;
document.addEventListener("keydown", function(event) {
if (event.target === searchInput) {
Expand Down