/** * Create an If statement * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. */ public JSConditional (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen) { this (aTest); if (aThen != null) m_aThen.add (aThen); }
/** * Creates <tt>... else if(...) ...</tt> code. * * @param aBoolExp * The boolean expression * @return The conditional for the next "if" */ @Nonnull public JSConditional elseif (@Nonnull final IJSExpression aBoolExp) { return _else ()._if (aBoolExp); }
/** * Get the block that makes up body of this function * * @return Body of function */ @Nonnull public JSBlock body () { if (m_aBody == null) m_aBody = new JSBlock (); return m_aBody; }
/** * Get the block that makes up body of this function * * @return Body of function */ @Nonnull public JSBlock body () { if (m_aBody == null) m_aBody = new JSBlock ().newlineAtEnd (false); return m_aBody; }
aOnSubmit.body ().incrPrefix (aGlobalCnt); aOnSubmit.body ().incrPrefix (aLocalCnt); aOnCancel.body ().decrPrefix (aGlobalCnt); aOnCancel.body ().decrPrefix (aLocalCnt); aOnClick.body ()._if (aLocalCnt.eq (0))._then ()._return (true); aOnCompete.body ()._if (aGlobalCnt.decrPrefix ().eq (0))._then ().add (aForm.invoke ("submit")); aOnClick.body ().add (aUpload.invoke ("on").arg ("complete").arg (aOnCompete)); aOnClick.body ().invoke (aUpload, "fineUploader").arg ("uploadStoredFiles"); aOnClick.body ()._return (false);
ret.param ("end"); ret.param ("display"); final JSVar aAPI = ret.body ().var ("api", JSExpr.THIS.invoke ("api")); final JSVar aIntVal = ret.body ().var ("funcIntVal" + sSuffix, aColumn.getJSFuncIntVal ()); final JSVar aPrintSum = ret.body ().var ("funcPrintSum" + sSuffix, aColumn.getJSFuncPrintSum ()); final JSVar aParam2 = aFuncReduce.param ("b"); aFuncReduce.body () ._return (JSExpr.invoke (aIntVal).arg (aParam1).plus (JSExpr.invoke (aIntVal).arg (aParam2))); final JSVar aReduce = ret.body ().var ("funcReduce" + sSuffix, aFuncReduce); .var ("total" + sSuffix, aAPI.invoke ("column") .arg (aColumn.getCalcColumn ()) .var ("pagetotal" + sSuffix, aAPI.invoke ("column") .arg (aColumn.getCalcColumn ()) .add (JQuery.jQuery (aAPI.invoke ("column").arg (aColumn.getPrintColumn ()).invoke ("footer")) .html (JSExpr.invoke (aPrintSum).arg (aTotal).arg (aPageTotal)));
@Nonnull public static JSAnonymousFunction createFunctionIntVal (@Nullable final JSAnonymousFunction aValueCleanupFunc) { final JSAnonymousFunction aFuncIntVal = new JSAnonymousFunction (); final JSVar aVal = aFuncIntVal.param ("v"); // If string final JSBlock aIfString = aFuncIntVal.body ()._if (aVal.typeof ().eeq ("string"))._then (); if (aValueCleanupFunc != null) aIfString.assign (aVal, aValueCleanupFunc.invoke ().arg (aVal)); aIfString._return (JSGlobal.parseFloat (aVal)); // If number aFuncIntVal.body ()._if (aVal.typeof ().eeq ("number"))._then ()._return (aVal); // Assume 0 aFuncIntVal.body ()._return (0); return aFuncIntVal; }
@Nonnull @CodingStyleguideUnaware public JSBlock _break (@Nullable final JSLabel aLabel) { addStatement (new JSBreak (aLabel)); return this; }
/** * Create a break statement and add it to this block * * @return Created break block */ @Nonnull @CodingStyleguideUnaware public JSBlock _break () { return _break (null); }
@Nonnull @CodingStyleguideUnaware public JSBlock _continue () { return _continue (null); }
void generateBody (@Nonnull final JSFormatter aFormatter) { for (final IHasJSCode aJSCode : directMembers ()) { if (aJSCode instanceof IJSDeclaration) aFormatter.decl ((IJSDeclaration) aJSCode); else if (aJSCode instanceof IJSStatement) aFormatter.stmt ((IJSStatement) aJSCode); else if (aJSCode instanceof IHasJSCodeWithSettings) aFormatter.plain (((IHasJSCodeWithSettings) aJSCode).getJSCode (aFormatter.getSettings ())); else aFormatter.plain (aJSCode.getJSCode ()); } }
aBoth = aBoth.plus (sBothSuffix); aFuncPrintSum.body ()._return (JSOp.cond (aTotal.eq (aPageTotal), aTotal, aBoth)); return aFuncPrintSum;
aOnSubmit.body ().incrPrefix (aGlobalCnt); aOnSubmit.body ().incrPrefix (aLocalCnt); aOnCancel.body ().decrPrefix (aGlobalCnt); aOnCancel.body ().decrPrefix (aLocalCnt); aOnClick.body ()._if (aLocalCnt.eq (0))._then ()._return (true); aOnCompete.body ()._if (aGlobalCnt.decrPrefix ().eq (0))._then ().add (aForm.invoke ("submit")); aOnClick.body ().add (aUpload.invoke ("on").arg ("complete").arg (aOnCompete)); aOnClick.body ().invoke (aUpload, "fineUploader").arg ("uploadStoredFiles"); aOnClick.body ()._return (false);
/** * Get the block that makes up body of this function * * @return Body of function */ @Nonnull public JSBlock body () { if (m_aBody == null) m_aBody = new JSBlock ().newlineAtEnd (false); return m_aBody; }
@Nonnull @CodingStyleguideUnaware public JSBlock _break (@Nullable final JSLabel aLabel) { addStatement (new JSBreak (aLabel)); return this; }
/** * Create a break statement and add it to this block * * @return Created break block */ @Nonnull @CodingStyleguideUnaware public JSBlock _break () { return _break (null); }
@Nonnull @CodingStyleguideUnaware public JSBlock _continue () { return _continue (null); }
void generateBody (@Nonnull final JSFormatter aFormatter) { for (final IHasJSCode aJSCode : directMembers ()) { if (aJSCode instanceof IJSDeclaration) aFormatter.decl ((IJSDeclaration) aJSCode); else if (aJSCode instanceof IJSStatement) aFormatter.stmt ((IJSStatement) aJSCode); else if (aJSCode instanceof IHasJSCodeWithSettings) aFormatter.plain (((IHasJSCodeWithSettings) aJSCode).getJSCode (aFormatter.getSettings ())); else aFormatter.plain (aJSCode.getJSCode ()); } }
/** * Create an If statement * * @param aTest * {@link IJSExpression} to be tested to determine branching * @param aThen * "then" block content. May be <code>null</code>. */ public JSConditional (@Nonnull final IJSExpression aTest, @Nullable final IHasJSCode aThen) { this (aTest); if (aThen != null) m_aThen.add (aThen); }