Esempio n. 1
0
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            if (ListId == 0)
            {
                return;
            }

            var workContext = workContextAccessor.GetContext(viewContext.HttpContext);
            var listService = workContext.Resolve <IListService>();
            var list        = listService.GetById(ListId);

            if (list == null)
            {
                return;
            }

            var urlHelper = workContext.Resolve <UrlHelper>();

            var id = "calendar_" + Guid.NewGuid().ToString("N").ToLowerInvariant();

            if (ShowTitleOnPage)
            {
                writer.Write("<header><h3>{0}</h3></header>", Title);
            }

            writer.Write("<div id=\"{0}\"></div>", id);

            var scriptRegister = new ScriptRegister(workContext);

            scriptRegister.IncludeInline(string.Format("$(document).ready(function(){{ $('#{0}').fullCalendar({{ events: '{1}' }}); }});", id, urlHelper.Action("GetEvents", "Home", new { area = Constants.Areas.Lists, listSlug = list.Url })));
        }
Esempio n. 2
0
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            var workContext = workContextAccessor.GetContext();
            var localizer   = LocalizationUtilities.Resolve(workContext, typeof(DataAnnotations4ModelMetadataProvider).FullName);

            string html = string.Format(
                @"<form id=""newsletter-subscribe-form"" class=""form-horizontal"">
<label for=""email"">{0}</label>
<input type=""text"" id=""newsletter-widget-email"" class=""form-control"" placeholder=""{1}"" />
<input type=""button"" class=""btn btn-primary"" value=""{2}"" onclick=""javascript:newsletterSignUp()"" />
</form>",
                localizer("Sign up for newsletters"),
                localizer("Input e-mail address"),
                localizer("Submit"));

            writer.Write(html);

            var scriptRegister = new ScriptRegister(workContext);

            scriptRegister.IncludeInline(string.Format(
                                             @"function newsletterSignUp() {{
    $.ajax({{
        url: '{0}',
        data: {{ email: $('#newsletter-widget-email').val() }},
        type: 'POST',
        dataType: 'json',
        success: function(result){{
            alert(result.Message);
        }}
    }});
}}",
                                             new UrlHelper(viewContext.RequestContext).Action("Subscribe", "Subscription", new { area = Constants.Areas.Newsletters })));
        }
 public static void IncludeKnockout(this ScriptRegister register)
 {
     register.Include("knockout/knockout-3.0.0.js");
     register.Include("knockout/knockout.mapping.min.js");
     register.Include("knockout/knockout.validation.js");
     register.Include("knockout/knockout.validation.en-US.js");
     register.Include("knockout/knockout-extensions.js");
 }
Esempio n. 4
0
 public override void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
 {
     if (Type != RoboTextType.RichText)
     {
         return;
     }
     scriptRegister.IncludeBundle("richtext");
 }
 public static void IncludePlugin(this ScriptRegister register)
 {
     register.Include("plugin/sparkline/jquery.sparkline.min.js");
     register.Include("plugin/masked-input/jquery.maskedinput.min.js");
     register.Include("plugin/select2/select2.min.js");
     register.Include("plugin/bootstrap-slider/bootstrap-slider.min.js");
     register.Include("plugin/msie-fix/jquery.mb.browser.min.js");
     register.Include("plugin/smartclick/smartclick.js");
 }
Esempio n. 6
0
 public override void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
 {
     if (!EnableChosen)
     {
         return;
     }
     scriptRegister.IncludeBundle("jquery-chosen");
     styleRegister.IncludeBundle("jquery-chosen");
 }
Esempio n. 7
0
        /// <summary>
        /// 设置查看模式
        /// </summary>
        public override void SetViewMode()
        {
            Tag = HtmlTag.Div;
            AddClass("control-value");
            AddClass("markdown");
            Append(new HtmlRaw(Value.HtmlEncode().Replace("\r\n", "<br/>").Replace("\n", "<br/>")));

            ScriptRegister.Register("MarkdownView", "view.node.find('div.markdown').html(markdown.toHTML(view.node.find('div.markdown').text()));");
        }
Esempio n. 8
0
        public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper)
        {
            var scriptRegister = new ScriptRegister(workContext);
            var clientId       = controlForm.ViewData.TemplateInfo.GetFullHtmlFieldId(Name);

            scriptRegister.IncludeInline(string.Format("$('#{0}').simplecolorpicker({{ picker: {1}, theme: '{2}' }});", clientId, Picker.ToString().ToLowerInvariant(), Theme));

            return(base.SelfGenerateControlUI(controlForm, workContext, htmlHelper));
        }
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            var workContext  = workContextAccessor.GetContext(viewContext.HttpContext);
            var mediaService = workContext.Resolve <IMediaService>();
            var files        = mediaService.GetMediaFiles(PhotosFolder).Where(IsPhotoFile).OrderBy(x => x.Name).ToList();

            if (files.Count == 0)
            {
                return;
            }

            var captions = Captions ?? new List <FileCaption>();

            var clientId = "gallery-" + Guid.NewGuid().ToString("N");

            if (!string.IsNullOrEmpty(CssClass))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "row");
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, clientId);
            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            foreach (var file in files)
            {
                var caption = captions.FirstOrDefault(x => x.FileName == file.Name) ?? new FileCaption();

                if (!string.IsNullOrEmpty(ItemCssClass))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, ItemCssClass);
                }
                else
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-sm-6 col-md-4");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.Write("<a class=\"fancybox\" rel=\"{2}\" href=\"{0}\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" /></a>", file.MediaPath, caption.Caption, clientId);
                writer.RenderEndTag(); // li
            }

            writer.RenderEndTag(); // ul

            if (files.Count > 0)
            {
                var scriptRegister = new ScriptRegister(workContext);
                scriptRegister.IncludeInline(string.Format("$(document).ready(function(){{ $('#{0} .fancybox').fancybox({{ autoPlay: {1} }}); }});", clientId, AutoPlay ? "true" : "false"));
                if (AutoShow)
                {
                    scriptRegister.IncludeInline(string.Format("$(document).ready(function(){{ $('#{0} .fancybox:first').trigger('click'); }});", clientId));
                }
            }
        }
Esempio n. 10
0
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            if (UploadPhotos == null || UploadPhotos.Count == 0)
            {
                return;
            }

            var clientId = "nivoSlider_" + Guid.NewGuid().ToString("N").ToLowerInvariant();

            if (ShowTitleOnPage)
            {
                writer.RenderBeginTag("header");
                writer.RenderBeginTag(HtmlTextWriterTag.H3);
                writer.Write(Title);
                writer.RenderEndTag(); // h3
                writer.RenderEndTag(); // header
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "slider-wrapper " + Theme);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Id, clientId);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "nivoSlider");
            writer.AddStyleAttributeIfHave("max-width", Width);
            writer.AddStyleAttributeIfHave("max-height", Height);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            foreach (var slide in UploadPhotos)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Href, string.IsNullOrEmpty(slide.TargetUrl) ? "javascript:void(0)" : slide.TargetUrl);
                writer.RenderBeginTag(HtmlTextWriterTag.A);

                writer.AddAttribute(HtmlTextWriterAttribute.Src, slide.Url);
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, slide.Caption);
                writer.AddAttribute(HtmlTextWriterAttribute.Title, slide.Caption);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag(); // img

                writer.RenderEndTag(); // a
            }

            writer.RenderEndTag(); // div

            writer.RenderEndTag(); // div

            var workContext   = workContextAccessor.GetContext();
            var scripRegister = new ScriptRegister(workContext);

            scripRegister.IncludeInline(string.Format("$(document).ready(function(){{ $('#{0}').nivoSlider({{ controlNavThumbs: {2}, controlNav: {1}, effect: '{3}', pauseTime: {4} }}); }});",
                                                      clientId,
                                                      ControlNavigation ? "true" : "false",
                                                      ShowThumbnails ? "true" : "false",
                                                      Effect, PauseTime));
        }
Esempio n. 11
0
        protected override ViewEngineResult FindView(ControllerContext controllerContext)
        {
            var result = ViewEngineCollection.FindView(controllerContext, "RoboFormResult_", null);

            var workContext    = EngineContext.Current.Resolve <IWebWorkContext>();
            var scriptRegister = new ScriptRegister(workContext);
            var styleRegister  = new StyleRegister(workContext);

            GetAdditionalResources(scriptRegister, styleRegister);

            return(result);
        }
Esempio n. 12
0
        public override void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
        {
            scriptRegister.IncludeBundle("jquery-ui");
            styleRegister.IncludeBundle("jquery-ui");

            scriptRegister.IncludeBundle("jqueryval");

            //scriptRegister.IncludeBundle("fancybox");
            //styleRegister.IncludeBundle("fancybox");

            scriptRegister.IncludeBundle("jqgrid");
            styleRegister.IncludeBundle("jqgrid");
        }
Esempio n. 13
0
        public ActionResult Edit(Guid key)
        {
            var topic = _topicDriver.Get(key, new string[] { "Tags", "Tags.Category", "Thread", "Thread.TagCategoryMaps" });

            if (topic != null && !topic.IsNew())
            {
                TopicClient topicClient = _topicDriver.ToClient(topic);
                ProcessTagOption(topicClient);
                ScriptRegister.AddJson("topic", topicClient);
                return(View("Record", topicClient));
            }
            return(HttpNotFound());
        }
Esempio n. 14
0
        public string ToHtmlString()
        {
            if (setupAction != null)
            {
                setupAction(this);
            }
            var workContext    = EngineContext.Current.Resolve <IWebWorkContext>();
            var scriptRegister = new ScriptRegister(workContext);
            var styleRegister  = new StyleRegister(workContext);

            GetAdditionalResources(scriptRegister, styleRegister);
            return(GenerateView());
        }
Esempio n. 15
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
            {
                return;
            }

            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                return;
            }

            var workContext = workContextAccessor.GetContext(filterContext);

            if (workContext == null || workContext.Layout == null)
            {
                return;
            }

            var widgets = providers.SelectMany(x => x.GetWidgets(workContext)).ToList();
            var zones   = workContext.Layout.Zones;

            var resourceTypes = new List <ResourceType>();

            foreach (var widget in widgets)
            {
                resourceTypes.AddRange(widget.GetAdditionalResources());

                var widgetShape = shapeFactory.Widget();
                widgetShape.Widget = widget;

                var zoneRecord = zoneService.GetById(widget.ZoneId);
                if (zoneRecord != null)
                {
                    var zone = zones[zoneRecord.Name];
                    zone.Add(widgetShape, widget.Order.ToString(CultureInfo.InvariantCulture));
                }
            }

            if (resourceTypes.Count > 0)
            {
                var scriptRegister = new ScriptRegister(workContext);
                var styleRegister  = new StyleRegister(workContext);

                foreach (var resourceType in resourceTypes)
                {
                    ResourcesManager.LookupResources(resourceType, scriptRegister, styleRegister);
                }
            }
        }
Esempio n. 16
0
        public override void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
        {
            if (EnableFineUploader)
            {
                scriptRegister.IncludeBundle("fine-uploader");
                styleRegister.IncludeBundle("fine-uploader");
            }

            if (EnableBrowse)
            {
                scriptRegister.IncludeBundle("fancybox");
                styleRegister.IncludeBundle("fancybox");
            }
        }
Esempio n. 17
0
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            if (Backgrounds == null || Backgrounds.Count == 0)
            {
                return;
            }

            var workContext    = workContextAccessor.GetContext(viewContext.HttpContext);
            var scriptRegister = new ScriptRegister(workContext);

            var options = new JObject
            {
                { "delay", Delay },
                { "backgrounds", new JArray(Backgrounds.Select(x => new JObject(new JProperty("src", x.Url), new JProperty("fade", x.Fade)))) }
            };

            scriptRegister.IncludeInline(string.Format("$(document).ready(function(){{ $.vegas('slideshow', {0})('overlay'); }});", options));
        }
Esempio n. 18
0
        /// <summary>
        /// 设置输入模式
        /// </summary>
        public override void SetInputMode()
        {
            Tag = HtmlTag.Textarea;
            Attribute(HtmlAttribute.Name, Name);
            Attribute(HtmlAttribute.Rows, "5");
            Data("provide", "markdown");
            if (PropertyContent.Disabled || PropertyContent.ReadOnly)
            {
                Attribute(HtmlAttribute.Disabled, "disabled");
            }
            if (!string.IsNullOrEmpty(PropertyContent.Description))
            {
                Attribute(HtmlAttribute.PlaceHolder, PropertyContent.Description);
            }
            Text(Value);
            AddClass("form-control");
            AddClass("markdown");

            ScriptRegister.Register("MarkdownEdit", "view.node.find('textarea.markdown').markdown({resize : 'vertical'});");
        }
Esempio n. 19
0
        public override void InitHelpers()
        {
            base.InitHelpers();

            if (initializationCompleted)
            {
                return;
            }

            if (!DataSettingsHelper.IsDatabaseInstalled)
            {
                return;
            }

            WorkContext             = EngineContext.Current.Resolve <IWebWorkContext>();
            resourcesManager        = EngineContext.Current.Resolve <IResourcesManager>();
            Script                  = new ScriptRegister(WorkContext, this);
            Style                   = new StyleRegister(WorkContext);
            initializationCompleted = true;
        }
Esempio n. 20
0
        public ActionResult New(string key)
        {
            var currentThread = string.IsNullOrEmpty(key) ? _threadDriver.RootThread : _threadDriver.GetThreadByKey(key);

            if (currentThread == null)
            {
                return(HttpNotFound());
            }

            var topic = _topicDriver.Create();

            topic.Thread   = currentThread;
            topic.ThreadId = currentThread.Id;

            var topicClient = _topicDriver.ToClient(topic);

            ProcessTagOption(topicClient);
            ScriptRegister.AddJson("topic", topicClient);

            return(View("Record", topicClient));
        }
Esempio n. 21
0
        public ActionResult Show(Guid key)
        {
            var commentsPerTopic = _topicDriver.GetTopicWithComments(key, PageConstants.FirstPageNumber, DefaultSetting.CommentsPerPage);

            if (commentsPerTopic == null)
            {
                return(HttpNotFound());
            }

            ScriptRegister.AddJson("commentsPerTopic", _topicDriver.ToTopicWithCommentsClient(commentsPerTopic));

            var newComment = _commentDriver.Create();

            newComment.TopicId = commentsPerTopic.Topic.Id;
            newComment.Topic   = commentsPerTopic.Topic;
            ScriptRegister.AddJson("newComment", _commentDriver.ToClient(newComment));

            ViewBag.CurrentThread = _threadDriver.Get(commentsPerTopic.Topic.ThreadId);

            return(View());
        }
Esempio n. 22
0
        public override void InitHelpers()
        {
            base.InitHelpers();

            if (initHelpers)
            {
                return;
            }

            WorkContext = ViewContext.GetWorkContext();

            resourcesManager = WorkContext.Resolve <IResourcesManager>();

            Script = new ScriptRegister(WorkContext, this);

            Style = new StyleRegister(WorkContext);

            Display = DisplayHelperFactory.CreateHelper(ViewContext, this);

            Layout = WorkContext.Layout;

            initHelpers = true;
        }
        protected override ViewEngineResult FindView(ControllerContext context)
        {
            var result = ViewEngineCollection.FindView(context, "ControlFormResult_", null);

            var controller = context.Controller as BaseController;

            if (controller != null)
            {
                var additionalResources = GetAdditionalResources(context).ToList();
                if (additionalResources.Any())
                {
                    var workContext    = controller.WorkContext;
                    var scriptRegister = new ScriptRegister(workContext);
                    var styleRegister  = new StyleRegister(workContext);

                    foreach (var resource in additionalResources)
                    {
                        ResourcesManager.LookupResources(resource, scriptRegister, styleRegister);
                    }
                }
            }

            return(result);
        }
        public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper)
        {
            var id = htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldId(Name);

            if (!EnableFineUploader)
            {
                return(string.Format(Required
                    ? "<input type=\"file\" name=\"{0}\" class=\"{1}\" id=\"{2}\" data-val=\"true\" data-val-required=\"{3}\" /><span data-valmsg-for=\"{0}\" data-valmsg-replace=\"true\"></span>"
                    : "<input type=\"file\" name=\"{0}\" class=\"{1}\" id=\"{2}\" />", Name, CssClass, id, Constants.Messages.Validation.Required));
            }

            var options      = controlForm.GetFileUploadOptions(Name);
            var urlHelper    = new UrlHelper(htmlHelper.ViewContext.RequestContext);
            var uploadUrl    = options.UploadUrl ?? urlHelper.Action("UploadFiles", "UploadFiles", new { area = Constants.Areas.Media });
            var uploadFolder = options.UploadFolder;

            if (string.IsNullOrEmpty(uploadFolder))
            {
                uploadFolder = UploadFolder;
            }

            string browseButton = null;

            if (AllowBrowseOnServer)
            {
                browseButton = string.Format("<button class=\"btn btn-default qq-browse-button\" onclick=\"$.fancybox.open({{ href: '{0}', type: 'iframe', modal: true, padding: 0, width: 500, height: 200, autoSize: false, minHeight: 250, afterClose: function(){{ if(window.fancyboxResult){{ $('#{1}, #{1}_Validator').val(window.fancyboxResult); $('#{1}_UploadList').html(window.fancyboxResult); }} }} }}); return false;\"><i class=\"cx-icon cx-icon-folder-open\"></i></button>", urlHelper.Action("Browse", "Media", new { area = Constants.Areas.Media }), id);
            }

            var clientOptions = new JObject
            {
                new JProperty("multiple", false),
                new JProperty("paramsInBody", true),
                new JProperty("validation", new JObject(
                                  new JProperty("allowedExtensions", GetAllowedExtensions(options.AllowedExtensions ?? AllowedExtensions)),
                                  new JProperty("sizeLimit", options.SizeLimit))),
                new JProperty("request", new JObject(new JProperty("endpoint", uploadUrl), new JProperty("params", new JObject(new JProperty("folder", uploadFolder ?? ""))))),
                new JProperty("text", new JObject(new JProperty("uploadButton", "<i class=\"fa fa-lg fa-upload\"></i>"))),
                new JProperty("template", string.Format("<div class=\"input-group\"><input type=\"text\" class=\"form-control\" name=\"{0}\" id=\"{1}\" value=\"{2}\" autocomplete=\"off\" data-val=\"{4}\" data-val-required=\"{5}\" /><div class=\"input-group-btn\"><div class=\"qq-upload-drop-area\"><span>{{dragZoneText}}</span></div><div class=\"btn btn-default qq-upload-button\">{{uploadButtonText}}</div>{3}</div></div><div class=\"qq-drop-processing\"><span>{{dropProcessingText}}</span><span class=\"qq-drop-processing-spinner\"></span></div><div class=\"qq-upload-list\"></div>", Name, id, Value, browseButton, Required.ToString().ToLowerInvariant(), Constants.Messages.Validation.Required)),
                new JProperty("fileTemplate", "<div><div class=\"qq-progress-bar hide\"></div><span class=\"qq-upload-spinner\"></span><span class=\"qq-upload-file hide\"></span><span class=\"qq-upload-size\"></span><a class=\"qq-upload-cancel\" href=\"#\">{cancelButtonText}</a><span class=\"qq-upload-status-text\">{statusText}</span></div>"),
            };

            var sb = new StringBuilder();

            sb.AppendFormat("<div class=\"{1}\" id=\"{0}_Container\"></div>", id, CssClass);

            if (Required)
            {
                sb.AppendFormat("<span data-valmsg-for=\"{0}\" data-valmsg-replace=\"true\"></span>", Name);
            }

            if (ShowThumbnail)
            {
                if (Value != null)
                {
                    sb.AppendFormat("<a href=\"{0}\" target=\"_blank\" title=\"Click to view larger image\"><img src=\"{0}\" data-src=\"holder.js/128x128\" style=\"max-width: 128px; max-height: 128px; margin-top: 5px;\" /></a>", Value);
                }
            }

            var scriptRegister = new ScriptRegister(workContext);

            scriptRegister.IncludeInline(string.Format("$('#{0}_Container').fineUploader({1}).on('upload', function(){{ var f = document.getElementById('{0}').form; var o ={{}};var a = $(f).serializeArray(); $.each(a, function(){{ if(o[this.name] !== undefined){{ if(!o[this.name].push){{ o[this.name]=[o[this.name]]; }} o[this.name].push(this.value || ''); }}else{{ o[this.name] = this.value || '';}} }}); $(this).fineUploader('setParams', o); }}).on('complete', function(event, id, name, responseJSON){{ if(responseJSON.success){{ $('#{0}').val(responseJSON.mediaUrl); }} else {{ $('#{0}').val(''); }} }}).on('complete', function(){{ $('#{0}_Container .qq-upload-list').hide(); }});",
                                                       id, clientOptions.ToString(Formatting.None)));

            return(sb.ToString());
        }
Esempio n. 25
0
 public virtual void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
 {
 }
Esempio n. 26
0
 public abstract void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister);
Esempio n. 27
0
        public override void BuildDisplay(HtmlTextWriter writer, ViewContext viewContext, IWorkContextAccessor workContextAccessor)
        {
            if (Images == null || Images.Count == 0)
            {
                return;
            }

            if (!string.IsNullOrEmpty(CssClass))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (ShowTitleOnPage)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.H3);
                writer.Write(Title);
                writer.RenderEndTag(); // h3
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "owl-" + Id);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            foreach (var image in Images)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "item");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                if (!string.IsNullOrEmpty(image.Url))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, image.Url);
                    writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Src, image.ImageUrl);
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, image.Title);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag(); // img

                if (!string.IsNullOrEmpty(image.Url))
                {
                    writer.RenderEndTag(); // a
                }

                if (!string.IsNullOrEmpty(image.Title))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "caption");
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);

                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "title");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write(image.Title);
                    writer.RenderEndTag();

                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "sub-title");
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);

                    if (!string.IsNullOrEmpty(image.Url))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Href, image.Url);
                        writer.AddAttribute(HtmlTextWriterAttribute.Target, "_blank");
                        writer.RenderBeginTag(HtmlTextWriterTag.A);
                    }

                    writer.Write(image.SubTitle);

                    if (!string.IsNullOrEmpty(image.Url))
                    {
                        writer.RenderEndTag(); // a
                    }

                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "description");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write(image.Description);
                    writer.RenderEndTag(); // span

                    writer.RenderEndTag(); // div

                    writer.RenderEndTag(); // div
                }

                writer.RenderEndTag(); // div
            }

            writer.RenderEndTag(); // div

            writer.RenderEndTag(); // div

            var workContext    = workContextAccessor.GetContext(viewContext.HttpContext);
            var scriptRegister = new ScriptRegister(workContext);

            var options = new JObject
            {
                { "items", VisibleItems },
                { "stopOnHover", StopOnHover },
                { "pagination", EnablePagination }
            };

            if (PlaySpeed > 0)
            {
                options.Add("autoPlay", PlaySpeed);
            }
            else
            {
                options.Add("autoPlay", false);
            }

            scriptRegister.IncludeInline(string.Format("$(document).ready(function(){{ $('#owl-{0}').owlCarousel({1}); }});", Id, options.ToString(Formatting.None)));
        }
Esempio n. 28
0
        public static void IncludePluginScript(this ScriptRegister register, string script, int?order = null)
        {
            string path = string.Format("/Plugins/Widgets.OwlCarousel/Scripts/{0}", script);

            register.IncludeExternal(path, order);
        }
Esempio n. 29
0
 public override void GetAdditionalResources(ScriptRegister scriptRegister, StyleRegister styleRegister)
 {
     scriptRegister.IncludeBundle("jquery-color-picker");
     styleRegister.IncludeBundle("jquery-color-picker");
 }
Esempio n. 30
0
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            PageModel model = pageService.GetById(id);

            WorkContext.Breadcrumbs.Add(T("Pages"), Url.Action("Index", new { area = Constants.Areas.Pages }));
            WorkContext.Breadcrumbs.Add(model.Title);
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var menuItem = menuItemService.GetMenuItemByRefId(id);

            if (menuItem != null)
            {
                model.ShowOnMenuId = menuItem.MenuId;
            }

            var result = new ControlFormResult <PageModel>(model)
            {
                Title                = T("Edit Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);

            result.AddAction(addToTop: false)
            .HasText(T("Preview"))
            .HasClientId("btnPreview")
            .HasButtonStyle(ButtonStyle.Info);

            var themes = extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType) && descriptor.Features.Any(f => f.Name == x.Id)).ToDictionary(k => k.Id, v => v.Name);

            result.RegisterExternalDataSource(x => x.Theme, themes);
            result.RegisterExternalDataSource(x => x.ShowOnMenuId, menuService.GetRecords().ToDictionary(k => k.Id, v => v.Name));

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            var scriptRegister = new ScriptRegister(WorkContext);

            scriptRegister.IncludeInline(Constants.Scripts.JQueryFormExtension);
            scriptRegister.IncludeInline(Constants.Scripts.JQueryFormParams);

            var sbScript = new StringBuilder(256);

            sbScript.Append("$(document).ready(function(){");
            sbScript.Append("$('#btnPreview').click(function(e){");
            sbScript.Append("var data = $('form').formParams();");
            sbScript.Append("var bodyContent = $('#idContentoEdit0').contents().find('body').html();");
            sbScript.Append("data.BodyContent = bodyContent;");
            sbScript.AppendFormat("$.form('{0}',", Url.Action("Preview"));
            sbScript.Append("data");
            sbScript.Append(").attr('target', '_blank').submit().remove(); return false;");
            sbScript.Append("});})");

            scriptRegister.IncludeInline(sbScript.ToString());

            return(result);
        }