Esempio n. 1
0
        /* Function: AppendOpeningLinkTag
         *
         * Constructs an <a> tag from the <Context's> <HTMLTopicPage> to the passed topic and appends it to the passed StringBuilder.
         *
         * Requirements:
         *
         *		- The <Context>'s topic page must be set.
         */
        public void AppendOpeningLinkTag(Topics.Topic targetTopic, StringBuilder output, string extraCSSClass = null)
        {
                        #if DEBUG
            if (Context.TopicPage == null)
            {
                throw new Exception("Tried to call AppendOpeningLinkTag without setting the context's topic page.");
            }
                        #endif

            // The URL can't be only the hash path because it would use the iframe's location.  We need a relative path back to index.html
            // to append it to.

            Path currentOutputFolder = Context.TopicPage.OutputFile.ParentFolder;
            Path indexFile           = Context.Builder.OutputFolder + "/index.html";
            Path pathToIndex         = indexFile.MakeRelativeTo(currentOutputFolder);

            Output.Components.HTMLTopicPage targetTopicPage = Context.TopicPage.GetLinkTarget(targetTopic);

            output.Append("<a ");

            if (extraCSSClass != null)
            {
                output.Append("class=\"" + extraCSSClass + "\" ");
            }

            string topicHashPath = Context.Builder.Source_TopicHashPath(targetTopic, targetTopicPage.IncludeClassInTopicHashPaths);

            output.Append("href=\"" + pathToIndex.ToURL() +
                          '#' + targetTopicPage.OutputFileHashPath.EntityEncode() +
                          (topicHashPath != null ? ':' + topicHashPath.EntityEncode() : "") + "\" " +
                          "target=\"_top\" " +
                          "onmouseover=\"NDContentPage.OnLinkMouseOver(event," + targetTopic.TopicID + ");\" " +
                          "onmouseout=\"NDContentPage.OnLinkMouseOut(event);\" " +
                          ">");
        }
Esempio n. 2
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: Context
         * Creates a context with the passed parameters.
         */
        public Context(Builders.HTML builder, Output.Components.HTMLTopicPage topicPage = null, Topic topic = null)
        {
                        #if DEBUG
            if (topicPage != null)
            {
                if ((object)topicPage.HTMLBuilder != (object)builder)
                {
                    throw new Exception("Tried to create a Context with a topic page that doesn't match the builder.");
                }
            }
                        #endif

            this.builder   = builder;
            this.topicPage = topicPage;
            this.topic     = topic;
        }