Skip to content

Commit

Permalink
Fix #723: TimePicker icons for PrimeIcon themes.
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 7, 2019
1 parent 935f16a commit 1b046f4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,42 @@ PrimeFacesExt = {
$(document).trigger("PrimeFacesExt.themeChanged", newValue);
},

/**
* Gets the currently loaded PF Theme.
*/
getTheme : function() {
var themeLink = $('link[href*="' + PrimeFaces.RESOURCE_IDENTIFIER + '/theme.css"]');
// portlet
if (themeLink.length === 0) {
themeLink = $('link[href*="' + PrimeFaces.RESOURCE_IDENTIFIER + '=theme.css"]');
}

This comment has been minimized.

Copy link
@cocorossello

cocorossello Nov 14, 2019

Hi, this fails with omnifaces combined resource handler. Is there any workaround?

This comment has been minimized.

Copy link
@melloware

melloware Nov 15, 2019

Author Member

What exactly fails?

This comment has been minimized.

Copy link
@cocorossello

cocorossello Nov 15, 2019

NullPointerException in line 139 (themeLink.length is 0 as there is no link, it's in the combined resource).

Maybe just return a false in this case and user has to override if he is using CombinedResourceHandler?

This comment has been minimized.

Copy link
@melloware

melloware Nov 15, 2019

Author Member

Can you create a defect please

This comment has been minimized.

Copy link
@cocorossello

cocorossello Nov 18, 2019

I can't, there is no issue button in the project. Is it disabled now?

This comment has been minimized.

Copy link
@cocorossello

cocorossello Nov 18, 2019

I can try to make a PR. Is it ok if I return false or should I try to create a not visible
<i class="pi pi-check"></i>
and test the element size? It will be much slower in this case

This comment has been minimized.

This comment has been minimized.

Copy link
@cocorossello

cocorossello Nov 18, 2019

Ok, thanks, done

var themeURL = themeLink.attr('href'),
plainURL = themeURL.split('&')[0],
oldTheme = plainURL.split('ln=primefaces-')[1];

return oldTheme;
},

/**
* Does this theme use Prime Icons?
*/
isPrimeIconTheme: function(theme) {
var theme = PrimeFacesExt.getTheme();
switch (theme) {
case "nova-light":
case "nova-dark":
case "nova-colored":
case "luna-blue":
case "luna-amber":
case "luna-green":
case "luna-pink":
return true;
default:
return false;
};
},

/**
* The name of the PrimeFaces Extensions resource library.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,33 @@
.pe-timepicker-trigger .ui-icon-clock {
left: 50%;
}

body .ui-prime-icons .ui-icon {

This comment has been minimized.

Copy link
@jepsar

jepsar Oct 8, 2019

Member

If the class would have been set in core.js, we could have a generic CSS patch. Could be a new file or a resource handler appending to the theme.

This comment has been minimized.

Copy link
@jepsar

jepsar Oct 8, 2019

Member

This might be a new issue (in case we run into more components with icon issues).

This comment has been minimized.

Copy link
@melloware

melloware Oct 8, 2019

Author Member

Yep no problem feel free to rearrange to to make it the most useful/flexible!

font-family: 'primeicons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
display: inline-block;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-indent: 0px !important;
text-align: center;
background: none;
display: inline-block;
font-size: 1.25em;
}

body .ui-prime-icons .ui-icon-clock:before {
content: "\e940";
}

body .ui-prime-icons .ui-icon-triangle-1-n:before {
content: "\e933";
}

body .ui-prime-icons .ui-icon-triangle-1-s:before {
content: "\e930";
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ PrimeFaces.widget.ExtTimePicker = PrimeFaces.widget.BaseWidget.extend({
init : function(cfg) {
this.id = cfg.id;
this.jqId = PrimeFaces.escapeClientId(cfg.id);
this.container = $(this.jqId);
this.jqEl = cfg.modeInline ? this.jqId + '_inline' : this.jqId + '_input';
this.jq = $(this.jqEl);

// configure localized text
this.cfg = PrimeFacesExt.configureLocale('TimePicker', cfg);

// GitHub #723: Fix for PrimeIcon themes
if (PrimeFacesExt.isPrimeIconTheme()) {

This comment has been minimized.

Copy link
@jepsar

jepsar Oct 8, 2019

Member

I would do this in core.js and add the class to the body

This comment has been minimized.

Copy link
@melloware

melloware Oct 8, 2019

Author Member

You want to submit a PR? I checked this in so you would have a baseline to work from!

This comment has been minimized.

Copy link
@jepsar

jepsar Oct 8, 2019

Member

Just noticed this is already in the origin (not your fork). Yeah, I'll try to tidy up things CSS wise in a PR.

this.container.addClass('ui-prime-icons');
}

if (this.cfg.showPeriod) {
this.amHours = {};
this.pmHours = {};
Expand Down

0 comments on commit 1b046f4

Please sign in to comment.