001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.StringUtil;
019    import com.liferay.portal.kernel.util.WebKeys;
020    import com.liferay.portal.theme.ThemeDisplay;
021    import com.liferay.taglib.FileAvailabilityUtil;
022    import com.liferay.taglib.util.TagResourceBundleUtil;
023    
024    import java.util.ResourceBundle;
025    
026    import javax.servlet.jsp.JspWriter;
027    
028    /**
029     * @author Scott Lee
030     * @author Shuyang Zhou
031     */
032    public class IconHelpTag extends IconTag {
033    
034            @Override
035            protected String getPage() {
036                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
037                            return _PAGE;
038                    }
039                    else {
040                            return null;
041                    }
042            }
043    
044            @Override
045            protected int processEndTag() throws Exception {
046                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
047                            WebKeys.THEME_DISPLAY);
048    
049                    JspWriter jspWriter = pageContext.getOut();
050    
051                    jspWriter.write("<span class=\"taglib-icon-help\"><img alt=\"\" ");
052                    jspWriter.write("aria-labelledby=\"");
053    
054                    String id = StringUtil.randomId();
055    
056                    jspWriter.write(id);
057    
058                    jspWriter.write("\" ");
059                    jspWriter.write("onBlur=\"Liferay.Portal.ToolTip.hide();\" ");
060                    jspWriter.write("onFocus=\"Liferay.Portal.ToolTip.show(this);\" ");
061                    jspWriter.write("onMouseOver=\"Liferay.Portal.ToolTip.show(this);\" ");
062                    jspWriter.write("src=\"");
063                    jspWriter.write(themeDisplay.getPathThemeImages());
064                    jspWriter.write("/portlet/help.png\" tabIndex=\"0\" ");
065                    jspWriter.write("/><span ");
066                    jspWriter.write("class=\"hide-accessible tooltip-text\" ");
067                    jspWriter.write("id=\"");
068                    jspWriter.write(id);
069                    jspWriter.write("\" >");
070    
071                    ResourceBundle resourceBundle = TagResourceBundleUtil.getResourceBundle(
072                            pageContext);
073    
074                    jspWriter.write(LanguageUtil.get(resourceBundle, getMessage()));
075    
076                    jspWriter.write("</span></span>");
077    
078                    return EVAL_PAGE;
079            }
080    
081            private static final String _PAGE = "/html/taglib/ui/icon_help/page.jsp";
082    
083    }