/// <summary>
    /// Adds JavaScript code required for client-side compilation to the page.
    /// </summary>
    private void RegisterClientSideCompilationScript()
    {
        CssPreprocessor prep = CssStylesheetInfoProvider.GetCssPreprocessor(LanguageFieldValue);

        if (prep != null)
        {
            // Register client scripts
            if (prep.RegisterClientCompilationScripts != null)
            {
                prep.RegisterClientCompilationScripts();
            }
        }
        else
        {
            ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "CleanUpScript", "function GetCss() {}", true);
        }

        if (Editor != null)
        {
            ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "CompileScript", GetClientCompilationScript(Editor.ClientID, hidCompiledCss.ClientID), true);
        }
    }
示例#2
0
    /// <summary>
    /// Adds JavaScript code required for client-side compilation to the page.
    /// </summary>
    private void RegisterClientSideCompilationScript()
    {
        // Get dynamic language database value
        string originalLang = ValidationHelper.GetString(EditForm.GetDataValue("StylesheetDynamicLanguage"), CssStylesheetInfo.PLAIN_CSS);

        // Get dynamic language selected in the form
        string newLang = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicLanguage"), CssStylesheetInfo.PLAIN_CSS);

        CssPreprocessor prep = null;

        // Indicate post-back and that dynamic language has changed
        if (RequestHelper.IsPostBack() && !originalLang.EqualsCSafe(newLang, true))
        {
            /*
             * If the original language is plain CSS then load preprocessor according to new language. If the original language is dynamic then load
             * appropriate preprocessor and ignore selected new language.
             */
            prep = CssStylesheetInfoProvider.GetCssPreprocessor(originalLang) ?? CssStylesheetInfoProvider.GetCssPreprocessor(newLang);
        }
        else
        {
            prep = CssStylesheetInfoProvider.GetCssPreprocessor(newLang);
        }

        // Register client scripts for appropriate preprocessor
        if (prep != null)
        {
            if (prep.RegisterClientCompilationScripts != null)
            {
                prep.RegisterClientCompilationScripts(Page);
            }
        }

        if (Editor != null)
        {
            ScriptHelper.RegisterStartupScript(this, typeof(string), "CompileScript", CSSStylesheetNewControlExtender.GetClientCompilationScript(Editor.ClientID, hidCompiledCss.ClientID), true);
        }
    }