Beispiel #1
0
        public ActionResult Settings(ImageSliderSettings imageSliderSettings)
        {
            context.Entry(imageSliderSettings).State = EntityState.Modified;
            context.SaveChanges();

            TempData["StatusMessage"] = "Changes saved successfully!";

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public static string ImageSlider(string input, IList <ImageSliderImage> imageSliderImages, ImageSliderSettings imageSliderSettings)
        {
            string insertCode = "";

            // only show the slider if there is any images
            if (imageSliderImages.Count > 0)
            {
                insertCode += "<ul class='bxslider'>";

                // loop through the images
                foreach (var image in imageSliderImages)
                {
                    // add the images
                    insertCode += String.Format(@"<li><a href='{0}' title='{1}'>
                        <img src='/Images/ImageSlider/{2}' alt='{2}' /></a></li>", image.LinkUrl, image.Title, image.ImageUrl);
                }

                // insert .js and css files and initialize the script
                insertCode += String.Format(
                    @"</ul><script>
                    $(document).ready(function(){{
                        $('.bxslider').bxSlider({{
                            auto: true,
                            pause: {0},
                            speed: 1000,
                            controls: false,
                            autoHover: true
                        }});
                    }});
                </script>", imageSliderSettings.TransitionSpeed * 1000);
            }

            // insert the code
            input = input.Replace("[widget=imageslider]", insertCode);

            return(input);
        }