Example #1
0
        public static IScriptStatementContext AddString(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] string jsString)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");

            return(scriptStatement.AddFormat(@"""{0}""", jsString.ToJsString()));
        }
Example #2
0
        public static IScriptStatementContext AddWithEnd(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] string js)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(js, "js");

            return(scriptStatement.AddFormat("{0};\r\n", js));
        }
Example #3
0
        public static IScriptStatementContext AddSelector(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] string selector)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(selector, "selector");

            return(scriptStatement.AddFormat(@"$$$({0})", selector));
        }
Example #4
0
        public static IScriptStatementContext AddFunc(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] string jsInner)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(jsInner, "jsInner");

            return(scriptStatement.AddFormat("function() {{ {0} }}", jsInner));
        }
Example #5
0
        public static IScriptStatementContext AddSelectorFormat(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] string selector, [NotNull] params object[] args)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(selector, "selector");
            CodeContracts.ArgumentNotNull(args, "args");

            return(scriptStatement.AddFormat(@"$$$({0})", selector.FormatWith(args)));
        }
Example #6
0
        public static IScriptStatementContext AddDocumentReady(
            [NotNull] this IScriptStatementContext scriptStatement, [NotNull] Action <IScriptFunctionContext> buildInner)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(buildInner, "buildInner");

            var function = scriptStatement.ScriptBuilder.CreateFunction(false);

            buildInner(function);

            scriptStatement.AddFormat("$$$().ready({0})", function.Build());

            return(scriptStatement);
        }
Example #7
0
        public static IScriptStatementContext AddIf(
            [NotNull] this IScriptStatementContext scriptStatement,
            [NotNull] string condition,
            [NotNull] Action <IScriptStatementContext> doInner)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(condition, "condition");
            CodeContracts.ArgumentNotNull(doInner, "doInner");

            var newStatementContext = scriptStatement.ScriptBuilder.CreateStatement(false);

            doInner(newStatementContext);

            return(scriptStatement.AddFormat(
                       "if ({0}) {{\r\n{1}\r\n}}", condition, newStatementContext.ScriptStatement.Build(scriptStatement.ScriptBuilder)));
        }
Example #8
0
        public static IScriptStatementContext AddCall(
            [NotNull] this IScriptStatementContext scriptStatement,
            [NotNull] string functionName,
            [NotNull] params object[] parameters)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(functionName, "functionName");
            CodeContracts.ArgumentNotNull(parameters, "parameters");

            scriptStatement.AddFormat("{0}(", functionName);

            AddParameters(scriptStatement, true, parameters);

            scriptStatement.Add(")");

            return(scriptStatement);
        }
Example #9
0
        public static IScriptStatementContext AddArray(
            [NotNull] this IScriptStatementContext scriptStatement,
            [NotNull] string arrayName,
            [NotNull] params object[] parameters)
        {
            CodeContracts.ArgumentNotNull(scriptStatement, "scriptStatement");
            CodeContracts.ArgumentNotNull(arrayName, "arrayName");

            scriptStatement.AddLine();
            scriptStatement.AddFormat("var {0} = Array(", arrayName);

            AddParameters(scriptStatement, false, parameters);

            scriptStatement.Add(");");

            scriptStatement.AddLine();

            return(scriptStatement);
        }