public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            //class="nsyte" id="6Fg3Aj9GzNw" data-width="480" data-height="360">
            output.TagName = "";

            _scriptManager.AddScript(new ScriptReference("/js/jquery.nonSuckyYouTubeEmbed.js", 1000));

            var uniqueVal = Guid.NewGuid().ToString("D");

            // add guid to .nyste (same for all, global guid)
            var sb = new StringBuilder();

            sb.AppendFormat
                ("<div  id=\"nsyte-{0}\" youtubeid=\"{1}\" \"></div>",
                uniqueVal, YouTubeId);


            var scriptTextExecute = string.Format(@"
                 $(document).ready(function () {{
                        $('#nsyte-{0}').nonSuckyYouTubeEmbed();
                }});
            ", uniqueVal);

            _scriptManager.AddScriptText(scriptTextExecute);

            output.Content = output.Content.SetHtmlContent(sb.ToString());
        }
Beispiel #2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            _scriptManager.AddScript(
                new ScriptReference("https://code.jquery.com/jquery-1.10.2.min.js", 1000));
            _scriptManager.AddScript(
                new ScriptReference("/js/jquery.nonSuckyYouTubeEmbed.js", 1000));
            output.Attributes.Add(new TagHelperAttribute("youtubeid", YouTubeId));
            output.Attributes.Add(new TagHelperAttribute("class", "nsyte"));

            var scriptTextExecute = string.Format(@"
                 $(document).ready(function () {{
                        $('.nsyte').nonSuckyYouTubeEmbed();
                }});
            ");

            _scriptManager.AddScriptText(scriptTextExecute);
        }
        public override async Task ProcessAsync(TagHelperContext context,
                                                TagHelperOutput output)
        {
            var src = output.Attributes["src"].Value.ToString();

            _scriptManager.AddScript(new ScriptReference
                                         (src, Convert.ToInt32(IncludeOrderPriority)));
            await output.GetChildContentAsync();

            output.SuppressOutput();
        }
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            // needed because of builtin tag helper that looks at src
            var src = GetEncodedStringValue(output.Attributes["src"].Value);

            _scriptManager.AddScript(new ScriptReference(src, Convert.ToInt32(IncludeOrderPriority)));

            await output.GetChildContentAsync();

            output.SuppressOutput();
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            //var script = "PrivateValue: " + _scriptManager.PrivateValue + " script-" + Guid.NewGuid() + " Count: " +
            //             _scriptManager.Scripts.Count;

            var scriptGuid = Guid.NewGuid().ToString("N");

            var script = "<script src='" + scriptGuid + ".js'></script>";

            _scriptManager.AddScript(script);


            output.Content.SetContent("<b>Suppress This Normally " + scriptGuid + "</b>");
            //output.SuppressOutput();
        }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var src = output.Attributes["src"].Value.ToString(); // get here and not property because other tag helpers might have run

            // src is going to look /foo/abc.js

            // find file passe in to source


            // add file to script manager (de-duplicate in script manager)

            //var xx = output.Attributes["IncludeOrderPriority"].ToString();

            _scriptManager.AddScript(src);

            // suppress output
            output.SuppressOutput();
        }