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

Move jquery-minicolors to npm/webpack #12305

Merged
merged 7 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ coverage.all
/public/serviceworker.js
/public/css
/public/fonts
/public/img/webpack
/web_src/fomantic/build
/VERSION
/.air
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ FOMANTIC_DEST_DIR := web_src/fomantic/build
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) $(FOMANTIC_DEST)
WEBPACK_CONFIGS := webpack.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/serviceworker.js
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js

BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@babel/plugin-transform-runtime": "7.10.5",
"@babel/preset-env": "7.10.4",
"@babel/runtime": "7.10.5",
"@claviska/jquery-minicolors": "2.3.5",
"@primer/octicons": "10.0.0",
"babel-loader": "8.1.0",
"clipboard": "2.0.6",
Expand Down
18 changes: 0 additions & 18 deletions public/vendor/plugins/jquery.minicolors/LICENSE

This file was deleted.

323 changes: 0 additions & 323 deletions public/vendor/plugins/jquery.minicolors/jquery.minicolors.css

This file was deleted.

11 changes: 0 additions & 11 deletions public/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion routers/org/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func DeleteWebhook(ctx *context.Context) {
func Labels(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.labels")
ctx.Data["PageIsOrgSettingsLabels"] = true
ctx.Data["RequireMinicolors"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["LabelTemplates"] = models.LabelTemplates
ctx.HTML(200, tplSettingsLabels)
Expand Down
1 change: 0 additions & 1 deletion routers/repo/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func Labels(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.labels")
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsLabels"] = true
ctx.Data["RequireMinicolors"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["LabelTemplates"] = models.LabelTemplates
ctx.HTML(200, tplLabels)
Expand Down
3 changes: 0 additions & 3 deletions templates/base/footer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
{{end}}
{{end}}
<script src="{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}"></script>
{{if .RequireMinicolors}}
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js"></script>
{{end}}
{{template "custom/footer" .}}
</body>
</html>
4 changes: 0 additions & 4 deletions templates/base/head.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
UseServiceWorker: {{UseServiceWorker}},
csrf: '{{.CsrfToken}}',
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
U2F: {{if .RequireU2F}}true{{else}}false{{end}},
Expand Down Expand Up @@ -101,9 +100,6 @@
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
</style>
</noscript>
{{if .RequireMinicolors}}
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css">
{{end}}
<style class="list-search-style"></style>
{{if .PageIsUserProfile}}
<meta property="og:title" content="{{.Owner.Name}}" />
Expand Down
10 changes: 10 additions & 0 deletions web_src/js/features/colorpicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default async function createColorPicker($els) {
if (!$els || !$els.length) return;

await Promise.all([
import(/* webpackChunkName: "minicolors" */'@claviska/jquery-minicolors'),
import(/* webpackChunkName: "minicolors" */'@claviska/jquery-minicolors/jquery.minicolors.css'),
]);

$els.minicolors();
}
7 changes: 4 additions & 3 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import initServiceWorker from './features/serviceworker.js';
import initMarkdownAnchors from './markdown/anchors.js';
import renderMarkdownContent from './markdown/content.js';
import attachTribute from './features/tribute.js';
import createColorPicker from './features/colorpicker.js';
import createDropzone from './features/dropzone.js';
import initTableSort from './features/tablesort.js';
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
Expand Down Expand Up @@ -134,15 +135,15 @@ function initLabelEdit() {
$newLabelPanel.hide();
});

$('.color-picker').each(function () {
$(this).minicolors();
});
createColorPicker($('.color-picker'));

$('.precolors .color').on('click', function () {
const color_hex = $(this).data('color-hex');
$('.color-picker').val(color_hex);
$('.minicolors-swatch-color').css('background-color', color_hex);
});
$('.edit-label-button').on('click', function () {
$('.color-picker').minicolors('value', $(this).data('color'));
$('#label-modal-id').val($(this).data('id'));
$('.edit-label .new-label-input').val($(this).data('title'));
$('.edit-label .new-label-desc-input').val($(this).data('description'));
Expand Down
Loading