From 28b820241f0ace889f7aaf2356215520935b58b5 Mon Sep 17 00:00:00 2001 From: lepipele Date: Thu, 22 Mar 2018 00:07:30 -0500 Subject: [PATCH] Integrating dropdown for language selection So hard to find good jquery alternative that drops up --- BTCPayServer/BTCPayServer.csproj | 4 + BTCPayServer/Views/Invoice/Checkout.cshtml | 21 +- BTCPayServer/bundleconfig.json | 6 +- .../jquery.prettydropdowns.js | 490 ++++++++++++++++++ .../prettydropdowns.css | 206 ++++++++ 5 files changed, 722 insertions(+), 5 deletions(-) create mode 100644 BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/jquery.prettydropdowns.js create mode 100644 BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/prettydropdowns.css diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 39d8bf0fe..10a8bce74 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -8,12 +8,16 @@ + + + + diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 817f2dcad..5ee22c5a2 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -607,12 +607,27 @@ -
+
@* Not working because of nsSeparator: false, keySeparator: false, {{$t("nested.lang")}} >> *@ - English - Deutsch + +
diff --git a/BTCPayServer/bundleconfig.json b/BTCPayServer/bundleconfig.json index 64c877572..f9742337d 100644 --- a/BTCPayServer/bundleconfig.json +++ b/BTCPayServer/bundleconfig.json @@ -33,7 +33,8 @@ "inputFiles": [ "wwwroot/vendor/font-awesome/css/font-awesome.css", "wwwroot/css/css.css", - "wwwroot/css/normalizer.css" + "wwwroot/css/normalizer.css", + "wwwroot/vendor/jquery-prettydropdowns/prettydropdowns.css" ] }, { @@ -46,7 +47,8 @@ "wwwroot/vendor/i18next/i18next.js", "wwwroot/vendor/i18next/vue-i18next.js", "wwwroot/js/checkout/i18n-resources.js", - "wwwroot/js/checkout/core.js" + "wwwroot/js/checkout/core.js", + "wwwroot/vendor/jquery-prettydropdowns/jquery.prettydropdowns.js" ] } ] diff --git a/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/jquery.prettydropdowns.js b/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/jquery.prettydropdowns.js new file mode 100644 index 000000000..f5c59ca72 --- /dev/null +++ b/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/jquery.prettydropdowns.js @@ -0,0 +1,490 @@ +/*! + * jQuery Pretty Dropdowns Plugin v4.11.0 by T. H. Doan (http://thdoan.github.io/pretty-dropdowns/) + * + * jQuery Pretty Dropdowns by T. H. Doan is licensed under the MIT License. + * Read a copy of the license in the LICENSE file or at + * http://choosealicense.com/licenses/mit + */ + +(function($) { + $.fn.prettyDropdown = function(oOptions) { + + // Default options + oOptions = $.extend({ + classic: false, + customClass: 'arrow', + height: 50, + hoverIntent: 200, + multiDelimiter: '; ', + multiVerbosity: 99, + selectedMarker: '✓', + reverse: false, + afterLoad: function(){} + }, oOptions); + + oOptions.selectedMarker = ''; + // Validate options + if (isNaN(oOptions.height) || oOptions.height<8) oOptions.height = 8; + if (isNaN(oOptions.hoverIntent) || oOptions.hoverIntent<0) oOptions.hoverIntent = 200; + if (isNaN(oOptions.multiVerbosity)) oOptions.multiVerbosity = 99; + + // Translatable strings + var MULTI_NONE = 'None selected', + MULTI_PREFIX = 'Selected: ', + MULTI_POSTFIX = ' selected'; + + // Globals + var $current, + aKeys = [ + '0','1','2','3','4','5','6','7','8','9',,,,,,,, + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' + ], + nCount, + nHoverIndex, + nLastIndex, + nTimer, + nTimestamp, + + // Initiate pretty drop-downs + init = function(elSel) { + var $select = $(elSel), + nSize = elSel.size, + sId = elSel.name || elSel.id || '', + sLabelId; + // Exit if widget has already been initiated + if ($select.data('loaded')) return; + // Remove 'size' attribute to it doesn't affect vertical alignment + $select.data('size', nSize).removeAttr('size'); + // Set element + $dropdown.children(':not(.selected)').each(function(nIndex) { + $('optgroup, option', $select).eq(nIndex).prop('selected', $(this).children('span.checked').length>0); + }); + // Update selected values for multi-select menu + updateSelected($dropdown); + } else { + $selected.removeClass('selected').children('span.checked').remove(); + $li.addClass('selected').append(oOptions.selectedMarker); + if (!oOptions.classic) $dropdown.prepend($li); + $dropdown.removeClass('reverse').attr('aria-activedescendant', $li.attr('id')); + if ($selected.data('group') && !oOptions.classic) $dropdown.children('.label').filter(function() { + return $(this).text()===$selected.data('group'); + }).after($selected); + // Sync to reflect state changes + this.refresh = function(oOptions) { + return this.each(function() { + var $select = $(this); + $select.prevAll('ul').remove(); + $select.unwrap().data('loaded', false); + this.size = $select.data('size'); + init(this); + }); + }; + + return this.each(function() { + init(this); + }); + + }; +}(jQuery)); diff --git a/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/prettydropdowns.css b/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/prettydropdowns.css new file mode 100644 index 000000000..00b87a37f --- /dev/null +++ b/BTCPayServer/wwwroot/vendor/jquery-prettydropdowns/prettydropdowns.css @@ -0,0 +1,206 @@ +.prettydropdown { + position: relative; + min-width: 72px; /* 70px + borders */ + display: inline-block; +} + + .prettydropdown.loading { + min-width: 0; + } + + .prettydropdown > ul { + border-radius: 5px; + position: absolute; + top: 0; + left: 0; + background: #fff; + border: 1px solid #a9a9a9; + box-sizing: content-box; + color: #000; + cursor: pointer; + font: normal 18px Calibri, sans-serif; + list-style-type: none; + margin: 0; + padding: 0; + text-align: left; + -webkit-user-select: none; /* Chrome all / Safari all */ + -moz-user-select: none; /* Firefox all */ + -ms-user-select: none; /* IE 10+ */ + user-select: none; /* Likely future */ + z-index: 1; + } + + .prettydropdown.loading > ul { + visibility: hidden; + white-space: nowrap; + } + + .prettydropdown > ul:focus, .prettydropdown:not(.disabled) > ul:hover { + border-color: #7f7f7f; + } + + .prettydropdown:not(.disabled) > ul.active { + width: auto; + max-height: 400px !important; + border-color: #1e90ff; + overflow-x: hidden; + overflow-y: auto; + z-index: 99; + } + + .prettydropdown > ul.active:focus { + outline: none; + } + + .prettydropdown > ul.active.reverse { + top: auto; + bottom: 0; + } + + .prettydropdown > ul > li { + font-size: 14px; + position: relative; + min-width: 70px; + height: 48px; /* 50px - borders */ + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + box-sizing: border-box; + display: none; + line-height: 46px; /* 48px - borders */ + margin: 0; + padding-left: 0.8rem; + } + + .prettydropdown.loading > ul > li { + min-width: 0; + display: block; + padding-right: 0.8rem; + } + + .prettydropdown > ul:not(.active) > li:not(.selected):first-child { + color: transparent; /* Prevent FOUC */ + } + + .prettydropdown > ul > li:first-child, .prettydropdown > ul.active > li { + display: block; + } + + .prettydropdown > ul.active > li:not(.label):hover, .prettydropdown > ul.active > li.hover:not(.label), .prettydropdown > ul.active > li:first-child:hover:after { + background: #1e90ff; + color: #fff; + } + + .prettydropdown > ul.active > li.nohover { + background: inherit !important; + color: inherit !important; + } + + .prettydropdown > ul.active > li.hover:before, .prettydropdown > ul.active > li.nohover:after { + border-top-color: #fff !important; + } + + .prettydropdown > ul.active > li.hover:after, .prettydropdown > ul.active > li.nohover:before { + border-top-color: #1e90ff !important; + } + + .prettydropdown.arrow > ul > li.selected:before, .prettydropdown.arrow > ul > li.selected:after { + position: absolute; + top: 8px; + bottom: 0; + right: 8px; + height: 16px; + border: 8px solid transparent; /* Arrow size */ + box-sizing: border-box; + content: ''; + display: block; + margin: auto; + } + + .prettydropdown.arrow.small > ul > li.selected:before, .prettydropdown.arrow.small > ul > li.selected:after { + top: 4px; + height: 8px; + border-width: 4px; + } + + .prettydropdown.arrow > ul > li.selected:before { + border-top-color: #a9a9a9; /* Arrow color */ + } + + .prettydropdown.arrow > ul > li.selected:after { + top: 4px; /* Chevron thickness */ + border-top-color: #fff; /* Match background colour */ + } + + .prettydropdown.arrow.small > ul > li.selected:after { + top: 2px; /* Chevron thickness */ + } + + .prettydropdown.arrow.triangle > ul > li.selected:after { + content: none; + } + + .prettydropdown > ul:hover > li.selected:before { + border-top-color: #7f7f7f; + } + + .prettydropdown > ul.active > li.selected:before, + .prettydropdown > ul.active > li.selected:after { + border: none; + } + + .prettydropdown > ul:not(.active) > li > span.checked { + display: none; + } + + /* Multi-Select */ + .prettydropdown.multiple > ul > li.selected { + overflow: hidden; + padding-right: 2rem; + text-overflow: ellipsis; + white-space: nowrap; + } + + .prettydropdown > ul > li > span.checked { + clear: both; + float: right; + font-weight: bold; + margin-right: 0.8rem; + } + + /* Option Groups */ + .prettydropdown > ul > li.label { + cursor: default; + font-weight: bold; + } + + .prettydropdown > ul > li.label:first-child, + .prettydropdown.classic > ul > li.label ~ li.selected { + border-top: none; + } + + .prettydropdown > ul > li.label ~ li:not(.label):not(.selected), + .prettydropdown.classic > ul.active > li.label ~ li:not(.label) { + padding-left: 1.6rem; + } + + /* Classic Behavior */ + .prettydropdown.classic > ul:not(.active) > li.selected:not(:first-child) { + position: absolute; + top: 0; + display: block; + } + + /* Disabled */ + .prettydropdown.disabled, .prettydropdown > ul > li.disabled { + opacity: 0.3; + } + + .prettydropdown.disabled > ul > li, .prettydropdown > ul > li.disabled { + cursor: not-allowed; + } + + /* Divider Lines */ + .prettydropdown.multiple > ul > li.selected + li, .prettydropdown.multiple > ul.reverse > li.selected, + .prettydropdown > ul > li.label, .prettydropdown > ul > li.label ~ li.selected { + border-top-color: #dedede; + }