Exemplo n.º 1
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var objectWriter = ClientSideObjectWriterFactory.Create(Id, "tEditor", writer);

            objectWriter.Start();

            ClientEvents.SerializeTo(objectWriter);

            DefaultToolGroup.Tools.OfType <IEditorListTool>().Each(tool =>
            {
                if (!tool.Items.SequenceEqual(EditorDefaultOptions.Get(tool.Identifier)))
                {
                    objectWriter.AppendCollection(tool.Identifier, tool.Items);
                }
            });

            var urlBuilder = new EditorUrlBuilder(urlGenerator, ViewContext);

            FileBrowserSettings.SerializeTo("fileBrowser", objectWriter, urlBuilder);

            if (Encode.HasValue && !Encode.Value)
            {
                objectWriter.Append("encoded", Encode.Value);
            }

            if (StyleSheets.Items.Any())
            {
                var isSecured   = ViewContext.HttpContext.Request.IsSecureConnection;
                var canCompress = ViewContext.HttpContext.Request.CanCompress();

                var mergedGroup = resolver.Resolve(new ResolverContext
                {
                    ContentType         = "text/css",
                    HttpHandlerPath     = WebAssetHttpHandler.DefaultPath,
                    IsSecureConnection  = isSecured,
                    SupportsCompression = canCompress
                }, new WebAssetCollection("~/Content")
                {
                    StyleSheets
                });

                objectWriter.AppendCollection("stylesheets", mergedGroup);
            }

            Localization.SerializeTo("localization", objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Exemplo n.º 2
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var objectWriter = ClientSideObjectWriterFactory.Create(Id, "tEditor", writer);

            objectWriter.Start();

            ClientEvents.SerializeTo(objectWriter);

            DefaultToolGroup.Tools.OfType<IEditorListTool>().Each(tool =>
            {
                if (!tool.Items.SequenceEqual(EditorDefaultOptions.Get(tool.Identifier)))
                {
                    objectWriter.AppendCollection(tool.Identifier, tool.Items);
                }
            });

            var urlBuilder = new EditorUrlBuilder(urlGenerator, ViewContext);

            FileBrowserSettings.SerializeTo("fileBrowser", objectWriter, urlBuilder);

            if (Encode.HasValue && !Encode.Value)
            {
                objectWriter.Append("encoded", Encode.Value);
            }

            if (StyleSheets.Items.Any())
            {
                var isSecured = ViewContext.HttpContext.Request.IsSecureConnection;
                var canCompress = ViewContext.HttpContext.Request.CanCompress();

                var mergedGroup = resolver.Resolve(new ResolverContext
                {
                    ContentType = "text/css",
                    HttpHandlerPath = WebAssetHttpHandler.DefaultPath,
                    IsSecureConnection = isSecured,
                    SupportsCompression = canCompress
                }, new WebAssetCollection("~/Content") { StyleSheets });

                objectWriter.AppendCollection("stylesheets", mergedGroup);
            }

            Localization.SerializeTo("localization", objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }