Author: ivaynberg Date: Fri Sep 26 21:36:04 2008 New Revision: 699553 URL: http://svn.apache.org/viewvc?rev=699553&view=rev Log: WICKET-1786
Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js (with props) Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html?rev=699553&r1=699552&r2=699553&view=diff ============================================================================== --- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html (original) +++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.html Fri Sep 26 21:36:04 2008 @@ -42,6 +42,18 @@ document.postback.utcDSTOffset.value = (new Date(new Date().getFullYear(), 6, 1, 0, 0, 0, 0).getTimezoneOffset() / -60); document.postback.browserWidth.value = window.innerWidth || document.body.offsetWidth; document.postback.browserHeight.value = window.innerHeight || document.body.offsetHeight; + + // SVG detection + var svginfo = detectSVG(); + if(svginfo.support){ + var svgstate = null; + if(svginfo.support=="Builtin") + svgstate=svginfo.builtin + ',' + svginfo.builtinVersion; + else + svgstate=svginfo.plugin + ',' + svginfo.pluginVersion + ',' + svginfo.IID; + document.postback.SVGsupport.value = svgstate; + } + document.postback.submit(); } </script> @@ -63,6 +75,7 @@ <input type="text" wicket:id="utcDSTOffset" /> <input type="text" wicket:id="browserWidth" /> <input type="text" wicket:id="browserHeight" /> + <input type="text" wicket:id="SVGsupport" /> </form> </wicket:panel> </html> Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java?rev=699553&r1=699552&r2=699553&view=diff ============================================================================== --- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java (original) +++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/BrowserInfoForm.java Fri Sep 26 21:36:04 2008 @@ -17,6 +17,9 @@ package org.apache.wicket.markup.html.pages; import org.apache.wicket.IClusterable; +import org.apache.wicket.ResourceReference; +import org.apache.wicket.markup.html.IHeaderContributor; +import org.apache.wicket.markup.html.IHeaderResponse; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.markup.html.panel.Panel; @@ -32,7 +35,7 @@ /** * Form for posting JavaScript properties. */ -public class BrowserInfoForm extends Panel +public class BrowserInfoForm extends Panel implements IHeaderContributor { /** log. */ private static final Logger log = LoggerFactory.getLogger(BrowserInfoForm.class); @@ -99,6 +102,7 @@ form.add(new TextField("utcDSTOffset")); form.add(new TextField("browserWidth")); form.add(new TextField("browserHeight")); + form.add(new TextField("SVGsupport")); add(form); } @@ -122,6 +126,10 @@ } + public void renderHead(IHeaderResponse response) { + response.renderJavascriptReference(new ResourceReference(this.getClass(), "detectSVG.js")); + } + /** * Holds properties of the client. */ @@ -144,6 +152,7 @@ private String utcDSTOffset; private String browserWidth; private String browserHeight; + private String SVGsupport; /** * Gets browserHeight. @@ -310,6 +319,7 @@ properties.setScreenColorDepth(getInt(screenColorDepth)); properties.setUtcOffset(utcOffset); properties.setUtcDSTOffset(utcDSTOffset); + properties.setSVGsupport(SVGsupport); } /** @@ -500,5 +510,24 @@ } return intValue; } + + /** + * Sets SVGsupport + * + * @param SVGsupport + * SVGsupport + */ + public void setSVGsupport(String gsupport) { + SVGsupport = gsupport; + } + + /** + * Gets SVGsupport + * + * @return SVGsupport + */ + public String getSVGsupport() { + return SVGsupport; + } } -} \ No newline at end of file +} Added: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js?rev=699553&view=auto ============================================================================== --- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js (added) +++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js Fri Sep 26 21:36:04 2008 @@ -0,0 +1,41 @@ +// Javascript-based SVG support detection +// From http://thomas.tanrei.ca/modern-script-based-svg-detection/ +function detectSVG() +{ + var results = { support:null, plugin:null, builtin:null }; + var obj = null; + if ( navigator && navigator.mimeTypes && navigator.mimeTypes.length ) + { + for ( var mime in { "image/svg+xml":null, "image/svg":null, "image/svg-xml":null } ) + { + if ( navigator.mimeTypes[ mime ] && ( obj = navigator.mimeTypes[ mime ].enabledPlugin ) && obj ) + results = { plugin:( obj = obj.name.toLowerCase()) && obj.indexOf( "adobe" ) >= 0 ? "Adobe" : ( obj.indexOf( "renesis" ) >= 0 ? "Renesis" : "Unknown" ) }; + } + } + else if ( ( obj = document.createElement( "object" )) && obj && typeof obj.setAttribute( "type", "image/svg+xml" )) + { + if ( typeof obj.USE_SVGZ == "string" ) + results = { plugin:"Adobe", IID:"Adobe.SVGCtl", pluginVersion:obj.window && obj.window._window_impl ? ( obj.window.evalScript ? 6 : 3 ) : 2 }; + else if ( typeof obj.ReadyState == "number" && obj.ReadyState == 0 ) + results = { plugin:"Renesis", IID:"RenesisX.RenesisCtrl.1", pluginVersion:">=1.0" }; + else if ( obj.window && obj.window.getSVGViewerVersion().indexOf( "enesis" ) > 0 ) + results = { plugin:"Renesis", IID:"RenesisX.RenesisCtrl.1", pluginVersion:"<1.0" }; + } + results.IID = ( results.plugin == "Adobe" ? "Adobe.SVGCtl" : ( results.plugin == "Renesis" ? "renesisX.RenesisCtrl.1" : null )); + + // Does the browser support SVG natively? Gecko claims no support if a plugin is active, but still gives back an NSI interface. Safari 3 does not claim support but does - use devicePixelRatio + var claimed = !!window.devicePixelRatio || ( typeof SVGAngle == "object" || ( document && document.implementation && document.implementation.hasFeature( "org.w3c.dom.svg", "1.0" ))); + var nsi = window.Components && window.Components.interfaces && !!Components.interfaces.nsIDOMGetSVGDocument; + results.builtin = claimed ? ( !!window.opera ? "Opera" : ( nsi ? "Gecko" : "Safari" )) : ( !!window.opera && window.opera.version ? "Opera" : ( nsi ? "Gecko" : null )); + results.builtinVersion = results.builtin && !!window.opera ? parseFloat( window.opera.version()) : ( nsi ? ( typeof Iterator == "function" ? ( Array.reduce ? 3.0 : 2.0 ) : 1.5 ) : null ); + + // Which is active, the plugin or native support? Opera 9 makes it hard to tell.. + if ( !!window.opera && results.builtinVersion >= 9 && ( obj = document.createElement( "object" )) && obj && typeof obj.setAttribute( "type", "image/svg+xml" ) != "undefined" && document.appendChild( obj )) + { + results.support = obj.offsetWidth ? "Plugin" : "Builtin"; + document.removeChild( obj ); + } + else results.support = results.plugin && !claimed ? "Plugin" : ( results.builtin && claimed ? "Builtin" : null ); + + return results; +} Propchange: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/pages/detectSVG.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java?rev=699553&r1=699552&r2=699553&view=diff ============================================================================== --- wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java (original) +++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/ClientProperties.java Fri Sep 26 21:36:04 2008 @@ -93,6 +93,7 @@ private String utcDSTOffset; private String utcOffset; + private String SVGsupport; /** @@ -1051,6 +1052,20 @@ this.utcOffset = utcOffset; } + /** + * @return null if there is no SVG support, otherwise a String like "<Name>,<Version>" (e.g. "Gecko,2") + */ + public String getSVGsupport() { + return SVGsupport; + } + + /** + * @param svgsupport the SVGsupport to set + */ + public void setSVGsupport(String svgsupport) { + SVGsupport = svgsupport; + } + public String toString() { StringBuffer b = new StringBuffer();