Merge from trunk 10682

This commit is contained in:
Yuriy Artamonov 2013-03-28 14:00:50 +00:00
parent 134c530b72
commit a28d699978
5 changed files with 99 additions and 22 deletions

View File

@ -499,7 +499,7 @@ table .footnote {
/* ToC panel */
a.toc-btn{
a.toc-btn {
position: fixed;
background-color: #404040;
opacity:0.5;
@ -543,6 +543,22 @@ a.toc-btn.active {
border-top-left-radius: 15px;
}
.toc-search,
.toc-search .toc-search-label {
color: #c0c0c0;
font-family: 'Arial', 'Verdana', sans-serif;
font-size: 14px;
}
#toc-panel a.toc-search-result {
color: #ffffff;
font-weight: bold;
}
#toc-panel a.toc-search-hidden {
display: none;
}
div#toc-panel a, div#toc-panel p {
color: #c0c0c0;
}

View File

@ -15,14 +15,21 @@
</xsl:template>
<xsl:variable name="headercode">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// use template from document for panel
var tocPanel = $('div#toc-panel-template').clone()[0];
tocPanel.id = 'toc-panel';
$('div.book').add('<a href="#" id="toc-btn" class="toc-btn">. . .</a>').appendTo(document.body);
$('div.book').add('<div id="toc-panel" class="toc-panel"></div>').appendTo(document.body);
$('div#toc-panel-template').remove();
$('div.toc').clone().appendTo('#toc-panel');
$('div.book').add('<a class="toc-btn" id="toc-btn" href="#">. . .</a>').appendTo(document.body);
$('div.book').add(tocPanel).appendTo(document.body);
var tocPanelContent = $('div.toc').clone();
tocPanelContent[0].id = 'toc-panel-content';
tocPanelContent.appendTo('#toc-panel');
var panel = $('#toc-panel');
var button = $('#toc-btn');
@ -41,11 +48,66 @@
panel.bind('mousedown', function(e) {
e.stopPropagation();
});
var searchBox = $('#toc-search-box')[0];
var searchQuery = '';
setInterval(function() {
if (searchQuery != searchBox.value) {
searchQuery = searchBox.value;
if (!searchQuery) searchQuery = '';
$('#toc-panel-content a').each(function() {
if (searchQuery == '') {
$(this).removeClass('toc-search-result');
$(this).removeClass('toc-search-hidden');
} else {
var innerText = $(this).text();
if (innerText) {
if (innerText.toLowerCase().indexOf(searchQuery.toLowerCase()) >= 0) {
$(this).addClass('toc-search-result');
$(this).removeClass('toc-search-hidden');
} else {
$(this).addClass('toc-search-hidden');
$(this).removeClass('toc-search-result');
}
}
}
});
// trace path from root to node
if (searchQuery != '') {
$('#toc-panel-content a').each(function() {
if ($(this).hasClass('toc-search-result')) {
var parent = this.parentNode;
while (parent != tocPanel) {
if (parent.tagName.toLowerCase() == 'dd')
$(parent).prev('dt').find('a').removeClass('toc-search-hidden');
parent = parent.parentNode;
}
}
});
}
}
}, 300);
});
</script>
</xsl:variable>
<xsl:template name="user.header.content">
<div id="toc-panel-template" class="toc-panel">
<div style="display: table; width:100%">
<div class="toc-search" style="display: table-row">
<div class="toc-search-label" style="display: table-cell">Поиск</div>
<div style="display: table-cell">
<input id="toc-search-box" type="text" style="width: 100%"/>
</div>
</div>
</div>
</div>
<xsl:copy-of select="$headercode"/>
</xsl:template>

View File

@ -1,11 +1,7 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Dmitry Abramov
* Created: 19.12.2008 15:15:51
* $Id$
*/
package com.haulmont.cuba.gui.xml.layout;
@ -31,6 +27,7 @@ import java.util.regex.Pattern;
* @version $Id$
*/
public class LayoutLoader {
protected ComponentLoader.Context context;
private ComponentsFactory factory;
private LayoutLoaderConfig config;
@ -38,9 +35,11 @@ public class LayoutLoader {
private Locale locale;
private String messagesPack;
private static final Pattern ASSIGN_PATTERN = Pattern.compile("<assign\\s+name\\s*=\\s*\"(.+)\"\\s+value\\s*=\\s*\"(.+)\"\\s*");
public static final Pattern COMMENT_PATTERN = Pattern.compile("<!--.*?-->", Pattern.DOTALL);
private static final Pattern DS_CONTEXT_PATTERN = Pattern.compile("<dsContext>(\\p{ASCII}+)</dsContext>");
public static final Pattern ASSIGN_PATTERN = Pattern.compile("<assign\\s+name\\s*=\\s*\"(.+)\"\\s+value\\s*=\\s*\"(.+)\"\\s*");
public static final Pattern DS_CONTEXT_PATTERN = Pattern.compile("<dsContext>.+?</dsContext>", Pattern.DOTALL);
public static Document parseDescriptor(InputStream stream, Map<String, Object> params) {
if (stream == null)
@ -50,9 +49,11 @@ public class LayoutLoader {
try {
String template = IOUtils.toString(stream, "UTF-8");
Matcher matcher = COMMENT_PATTERN.matcher(template);
template = matcher.replaceAll("");
Map<String, Object> templateParams = new HashMap<>(params);
Matcher matcher;
matcher = ASSIGN_PATTERN.matcher(template);
while (matcher.find()) {
templateParams.put(matcher.group(1), matcher.group(2));
@ -60,13 +61,11 @@ public class LayoutLoader {
matcher = DS_CONTEXT_PATTERN.matcher(template);
if (matcher.find()) {
final String dsContext = matcher.group(1);
template = DS_CONTEXT_PATTERN.matcher(template).replaceFirst("");
Document dsContextDocument = Dom4j.readDocument(matcher.group());
// dsContext queries may have their own templates which are processed later
template = matcher.replaceFirst("");
template = TemplateHelper.processTemplate(template, templateParams);
document = Dom4j.readDocument(template);
final Document dsContextDocument = Dom4j.readDocument("<dsContext>" + dsContext + "</dsContext>");
document.getRootElement().add(dsContextDocument.getRootElement());
} else {
template = TemplateHelper.processTemplate(template, templateParams);

View File

@ -12,6 +12,8 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.annotation.ManagedBean;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;
@ -19,11 +21,13 @@ import java.util.Map;
* @author artamonov
* @version $Id$
*/
@ManagedBean(DomainAliasesResolver.NAME)
public class DefaultDomainAliasesResolver implements DomainAliasesResolver {
private Map<String, String> aliases = new HashMap<>();
private Log log = LogFactory.getLog(DomainAliasesResolver.class);
@Inject
public DefaultDomainAliasesResolver(Configuration configuration) {
WebConfig webConfig = configuration.getConfig(WebConfig.class);
String aliasesConfig = webConfig.getActiveDirectoryAliases();

View File

@ -20,10 +20,6 @@
<bean id="cuba_AuthProvider" class="${cuba.web.activeDirectoryAuthClass}"/>
<bean id="cuba_DomainResolver" class="com.haulmont.cuba.web.sys.auth.DefaultDomainAliasesResolver">
<constructor-arg index="0" ref="cuba_Configuration"/>
</bean>
<bean id="cuba_PasswordEncryption" class="com.haulmont.cuba.core.sys.PasswordEncryptionImpl">
<property name="encryptionModule" ref="${cuba.passwordEncryptionModule}"/>
</bean>