Hi Everyone,
Here's a helper unit for the IWCGJQNotification component. With it you should be able to compress your code down a bit if you use the same IWCGJQNotification component to display multiple messages and also switch easily between the notification personalities.
Please remember to submit code back to the board if you make it better.
Enjoy!
John
- Code: Select all
unit IWCGJQNotificationHelperUnit;
/// =================================================================================================
///
/// Author: John F. Sklavounos
/// Date: 2013-10-16
///
/// Ownership:
/// You are free to use and distribute this code as you see fit. I only ask that improvements be
/// returned to the community at http://www.cgdevtools.com/cgforum/viewforum.php?f=109
///
/// Abstract:
/// I find myself using primarily only a few properties and the ShowNotification procedure with this
/// component, so I thought it would be great to combine the functionality and make my code more
/// compact. Additionally, it makes it easy to switch between the NOTY and FreeOW personalities
/// because you only have to change the component's JQNotificationType property but not your calls! =)
///
/// Notes:
///
/// =================================================================================================
interface
uses
IWCGJQNotification;
type TIWCGJQNotificationHelper = class
class procedure ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pPosition: TIWCGJQNotificationNotyLayout; pTitle, pMessage: string); overload;
class procedure ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pTitle, pMessage: string); overload;
end;
implementation
class procedure TIWCGJQNotificationHelper.ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pTitle, pMessage: string);
begin
if pOwner.jqNotificationType = jqntFreeow then begin
with pOwner.JQNotificationFreeOWOptions do begin
IsError := (pType = jqnntError);
Title := pTitle;
Message := pMessage;
ShowNotification;
end;
end else begin
with pOwner.JQNotificationNotyOptions do begin
Type_ := pType;
Text := '<strong>' + pTitle + '</strong><br>' + pMessage +'';
ShowNotification;
end;
end;
end;
class procedure TIWCGJQNotificationHelper.ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pPosition: TIWCGJQNotificationNotyLayout; pTitle, pMessage: string);
begin
if pOwner.jqNotificationType = jqntFreeow then begin
with pOwner.JQNotificationFreeOWOptions do begin
case pPosition of
jqnnlBottom, jqnnlBottomCenter, jqnnlBottomLeft, jqnnlBottomRight:
Position := jqnpBottomRight;
jqnnlCenter, jqnnlCenterLeft, jqnnlCenterRight, jqnnlInline, jqnnlTop, jqnnlTopCenter, jqnnlTopLeft, jqnnlTopRight:
Position := jqnpTopRight;
end;
end;
end else begin
pOwner.JQNotificationNotyOptions.Layout := pPosition;
end;
ShowNotification(pOwner, pType, pTitle, pMessage);
end;
end.