Adding Google Chrome Framework for IE<9

This commit is contained in:
Pablo Luna 2011-03-13 16:24:26 +00:00
parent 331652ad74
commit 1b04d1effc
6 changed files with 60 additions and 3 deletions

View File

@ -18,6 +18,7 @@
package com.wisemapping.controller;
import com.wisemapping.filter.UserAgent;
import com.wisemapping.model.MindMap;
import com.wisemapping.security.Utils;
import org.springframework.web.servlet.ModelAndView;
@ -38,19 +39,26 @@ public class MindmapEditorController extends BaseMultiActionController {
public ModelAndView open(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView view;
UserAgent userAgent = UserAgent.create(httpServletRequest);
if(userAgent.needsGCF()){
view = new ModelAndView("installCFG");
}
else{
final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER);
final int mapId = Integer.parseInt(mindmapId);
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
// Mark as try mode...
final ModelAndView view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
view.addObject("editorTryMode", false);
final boolean showHelp = isWelcomeMap(mindmap);
view.addObject("showHelp", showHelp);
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
view.addObject(MAP_XML_PARAM, xmlMap);
view.addObject("user", Utils.getUser());
}
return view;
}

View File

@ -30,6 +30,7 @@ public class UserAgent implements Serializable {
private Product product;
private OS os;
private final org.apache.commons.logging.Log logger = LogFactory.getLog(UserAgent.class.getName());
private boolean hasGCFInstalled = false;
public static void main(final String argv[]) {
UserAgent explorer = UserAgent.create("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
@ -65,6 +66,10 @@ public class UserAgent implements Serializable {
return this.versionMajor > mayor || (mayor == this.versionMajor && this.versionVariation >= variation);
}
public boolean isVersionLessThan(final int mayor) {
return this.versionMajor < mayor;
}
public int getVersionMajor() {
return versionMajor;
}
@ -127,6 +132,7 @@ public class UserAgent implements Serializable {
// Explorer Parse ...
this.product = Product.EXPLORER;
this.hasGCFInstalled = productDetails.indexOf("chromeframe")!=-1;
} else if (userAgentHeader.indexOf("iCab") != -1 || userAgentHeader.indexOf("Safari") != -1) {
// Safari:
//Formats: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1
@ -334,4 +340,9 @@ public class UserAgent implements Serializable {
return result;
}
public boolean needsGCF(){
final UserAgent.Product product = this.getProduct();
return product == UserAgent.Product.EXPLORER && this.isVersionLessThan(9) && this.getOs() == UserAgent.OS.WINDOWS && !this.hasGCFInstalled;
}
}

View File

@ -15,6 +15,7 @@
<definition name="closeDialog" page="/jsp/closeDialog.jsp"/>
<definition name="embeddedViewError" page="/jsp/embeddedViewError.jsp"/>
<definition name="mindmapPrint" page="/jsp/mindmapPrint.jsp"/>
<definition name="installCFG" page="/jsp/installCFG.jsp"/>
<!-- Template Declaration -->
<definition name="pageTemplate" page="/jsp/template.jsp">

View File

@ -23,7 +23,7 @@ function afterCoreLoading()
// Uncomment for debug ...
if (core.UserAgent.isVMLSupported())
{
$import("../js/mindplot.vml.js");
// $import("../js/mindplot.vml.js");
} else
{
$import("../js/mindplot.svg.js");

View File

@ -0,0 +1,33 @@
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
</head>
<body>
<div style="width:100%; font-size:130%;">
you need to install Google Chrome Frame.
<br/>
<div id="div"> click here</div>
</div>
<div id="prompt">
<!-- if IE without GCF, prompt goes here -->
</div>
<script>
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
$(document).ready(function(){
$("#div").click(function(event){
$(".chromeFrameOverlayContent").css("display","block");
$(".chromeFrameOverlayUnderlay").css("display","block");
});
});
window.attachEvent("onload", function() {
CFInstall.check({
mode: "overlay" // the default
});
});
</script>
</body>
</html>

View File

@ -12,6 +12,10 @@
</c:url>
<html>
<head>
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<!-- Internet Explorer 8 Hack -->
<meta http-equiv="Content-type" value="text/html;charset=UTF-8">
<title><spring:message code="SITE.TITLE"/> - ${mindmap.title} </title>