001    /**
002     * Copyright (c) 2000-2013 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.servlet.taglib.FileAvailabilityUtil;
019    import com.liferay.portal.kernel.util.StringUtil;
020    import com.liferay.portal.theme.ThemeDisplay;
021    
022    import javax.servlet.jsp.JspWriter;
023    
024    /**
025     * @author Scott Lee
026     * @author Shuyang Zhou
027     */
028    public class IconHelpTag extends IconTag {
029    
030            @Override
031            protected String getPage() {
032                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
033                            return _PAGE;
034                    }
035                    else {
036                            return null;
037                    }
038            }
039    
040            @Override
041            protected int processEndTag() throws Exception {
042                    ThemeDisplay themeDisplay = (ThemeDisplay)pageContext.getAttribute(
043                            "themeDisplay");
044    
045                    JspWriter jspWriter = pageContext.getOut();
046    
047                    String id = StringUtil.randomId();
048    
049                    jspWriter.write("<span class=\"taglib-icon-help\"><img alt=\"\" ");
050                    jspWriter.write("aria-labelledby=\"");
051                    jspWriter.write(id);
052                    jspWriter.write("\" ");
053                    jspWriter.write("onBlur=\"Liferay.Portal.ToolTip.hide();\" ");
054                    jspWriter.write("onFocus=\"Liferay.Portal.ToolTip.show(this);\" ");
055                    jspWriter.write("onMouseOver=\"Liferay.Portal.ToolTip.show(this);\" ");
056                    jspWriter.write("src=\"");
057                    jspWriter.write(themeDisplay.getPathThemeImages());
058                    jspWriter.write("/portlet/help.png\" tabIndex=\"0\" ");
059                    jspWriter.write("/><span ");
060                    jspWriter.write("class=\"hide-accessible tooltip-text\" ");
061                    jspWriter.write("id=\"");
062                    jspWriter.write(id);
063                    jspWriter.write("\" >");
064                    jspWriter.write(LanguageUtil.get(pageContext, getMessage()));
065                    jspWriter.write("</span></span>");
066    
067                    return EVAL_PAGE;
068            }
069    
070            private static final String _PAGE = "/html/taglib/ui/icon_help/page.jsp";
071    
072    }