From: Coleman Watts Date: Fri, 9 Dec 2016 20:40:31 +0000 (-0500) Subject: CRM-19723 - Allow rotation of icons X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0b4d4209a85c03563352a7ff408644f8bbfdfd47;p=civicrm-core.git CRM-19723 - Allow rotation of icons --- diff --git a/css/crm-i.css b/css/crm-i.css index c8ec92a346..ddf6dc54fe 100644 --- a/css/crm-i.css +++ b/css/crm-i.css @@ -11,7 +11,6 @@ is loaded before font-awesome.css so that .fa-XXX classes can modify it. */ text-rendering: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - transform: translate(0, 0); } i.crm-i { diff --git a/js/crm.admin.js b/js/crm.admin.js index f555df2b36..2884ae90f0 100644 --- a/js/crm.admin.js +++ b/js/crm.admin.js @@ -10,6 +10,12 @@ }); // Hack to get the strings in this lazy-loaded file translated ts('None'); + ts('Normal'); + ts('Rotate right'); + ts('Rotate left'); + ts('Rotate 180'); + ts('Flip horizontal'); + ts('Flip vertical'); }); - }) + }); })(CRM.$); diff --git a/js/jquery/jquery.crmIconPicker.js b/js/jquery/jquery.crmIconPicker.js index 7e76f53881..885d1b2b88 100644 --- a/js/jquery/jquery.crmIconPicker.js +++ b/js/jquery/jquery.crmIconPicker.js @@ -25,25 +25,47 @@ if ($(this).hasClass('iconpicker-widget')) { return; } + var $input = $(this), - button = $('').button({ - label: $(this).val() || ts('None'), - icons: {primary: $(this).val()} - }).attr('title', $input.attr('title')); - $input.hide().addClass('iconpicker-widget').after(button).change(function() { - button.button('option', { - label: $(this).val() || ts('None'), - icons: {primary: $(this).val()} + $button = $('').button().attr('title', $input.attr('title')), + $style = $(''), + options = [ + {key: 'fa-rotate-90', value: ts('Rotate right')}, + {key: 'fa-rotate-270', value: ts('Rotate left')}, + {key: 'fa-rotate-180', value: ts('Rotate 180')}, + {key: 'fa-flip-horizontal', value: ts('Flip horizontal')}, + {key: 'fa-flip-vertical', value: ts('Flip vertical')} + ]; + + function formatButton() { + var split = $input.val().split(' '); + $button.button('option', { + label: split[0] || ts('None'), + icons: {primary: $input.val()} }); + $style.toggle(!!split[0]).val(split[1] || ''); + } + + $input.hide().addClass('iconpicker-widget').after($style).after($button).change(formatButton); + + CRM.utils.setOptions($style, options, ts('Normal')); + + formatButton(); + + $style.change(function() { + if ($input.val()) { + var split = $input.val().split(' '), + style = $style.val(); + $input.val(split[0] + (style ? ' ' + style : '')).change(); + } }); - button.click(function(e) { + $button.click(function(e) { var dialog; function displayIcons() { var term = $('input[name=search]', dialog).val().replace(/-/g, '').toLowerCase(), - $place = $('div.icons', dialog); - $place.html(''); + $place = $('div.icons', dialog).html(''); $.each(icons, function(i, icon) { if (!term.length || icon.replace(/-/g, '').indexOf(term) > -1) { var item = $('').button({ @@ -69,8 +91,9 @@ } function pickIcon(e) { - var newIcon = $(this).attr('title'); - $input.val(newIcon).change(); + var newIcon = $(this).attr('title'), + style = $style.val(); + $input.val(newIcon + (style ? ' ' + style : '')).change(); dialog.dialog('close'); e.preventDefault(); } @@ -89,6 +112,7 @@ loadIcons().done(displayDialog); e.preventDefault(); }); + }); }; }(CRM.$, CRM._));