package votorola.a.web.wic; // Copyright 2012-2013, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import org.apache.wicket.AttributeModifier; import org.apache.wicket.markup.html.*; import org.apache.wicket.markup.html.basic.*; import org.apache.wicket.markup.html.panel.*; import votorola.a.*; import votorola.a.web.wic.*; import votorola.g.lang.*; /** Scripting for the Crossforum Theatre stage. See WP_D.css for an examples of * the associated styling. * * @see WC_Stage.html */ public @ThreadRestricted("wicket") final class WC_Stage extends Panel { /** Constructs a WC_Stage. * * @param moduleName the name of the GWT stage module, as for instance * "votorola.s.gwt.wic.DIn". * @param b the string builder that was returned from a previous call to * {@linkplain #appendLeader(VSession.User,VoteServer,VRequestCycle) * appendLeader}. To it, you must already have appended a function * voGWTConfig.s_gwt_stage_Stage_init in order to initialize the * stage. That function will be called in case of either {@linkplain * votorola.s.gwt.stage.TheatreInitializer#initFrom(Stage,boolean) initFrom} or * {@linkplain votorola.s.gwt.stage.TheatreInitializer#initTo(Stage) initTo}. */ public WC_Stage( final String id, final String moduleName, final StringBuilder b, final VRequestCycle cycle ) { super( id ); setRenderBodyOnly( true ); // s_gwt_stage_Stage_initFrom // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - b.append( "_temp = function( rPending )" + "{" + "var fThis = arguments.callee;" + "if( fThis.fWrapped ) fThis.fWrapped( rPending );" // admin's own config, if any + "voGWTConfig.s_gwt_stage_Stage_init();" + "};" + "_temp.fWrapped = voGWTConfig.s_gwt_stage_Stage_initFrom;" + "voGWTConfig.s_gwt_stage_Stage_initFrom = _temp;" // s_gwt_stage_Stage_initTo // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + "_temp = function( r, rPending )" + "{" + "var fThis = arguments.callee;" + "if( fThis.fWrapped ) fThis.fWrapped( r, rPending );" // admin's own config, if any + "voGWTConfig.s_gwt_stage_Stage_init();" + "};" + "_temp.fWrapped = voGWTConfig.s_gwt_stage_Stage_initTo;" + "voGWTConfig.s_gwt_stage_Stage_initTo = _temp;" // - - - + "delete _temp;" + "\n/*]]>*/" ); final Label label = new Label( "gwtGlue", b.toString() ); label.setEscapeModelStrings( false ); add( label ); final WebMarkupContainer script = new WebMarkupContainer( "stageModule" ); script.add( AttributeModifier.replace( "src", cycle.gwtContextLocation() + "/" + moduleName + "/" + moduleName + ".nocache.js" )); add( script ); } // ------------------------------------------------------------------------------------ /** Appends the leading portion of the script. */ public static StringBuilder appendLeader( final VSession.User userOrNull, final VoteServer vS, final VRequestCycle cycle ) { //// meta properties (copied from the first page to implement this) //// ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` // final WebMarkupContainer meta = new WebMarkupContainer( "gwtProperty" ); // meta.add( AttributeModifier.replace( "content", "locale=" + bunW.locale().toString() )); // add( meta ); ///// Here is the removed markup: . ///// Using locale.useragent instead of this. Both fail with Chrome as detailed ///// in AMod.gwt.xml, but useragent seems a cleaner, more general solution. final StringBuilder b = new StringBuilder( /*initial capacity, guess*/1000 ); b.append( "/*