Javascript API for accessing the form components of Forum post editor

rated by 0 users
This post has 5 Replies | 3 Followers

primedia_jdavis
Top 500 Contributor
Posts 89
Points 1,225
By: primedia_jdavis
Posted: Wed, Aug 15 2007 3:09 PM

Is there a Javascript API for accessing the form components of Forum post editor? For example, I would like, at runtime and after events like after all other loading has completed and before form posting begins, to evaluate the HTML of the HTML editor and replace it with some custom stuff.

For example, [here] I posted my solution to make it easier to post a calendar event without telling the user to use a 'cal' tag, by hijacking the post on the server side, but I would have liked to do this on the client-side, so that I can hide the 'cal' tag in the view when going back to edit the post, but show the date again in the custom Date field I had added.

As another example and what I need to do now is to expand on the hidden but built-in video functionality, but manually hide the Video tab in normal forum posts, then copy the forum post editor ASPX file, add the ability for a user to paste a YouTube embed tag, then in JS I'd extract the actual video URL from the tag, auto-inject the [video] tag in the forum post, and use my own embed tag where [video] tag exists, and try to populate the values that would be in the Video tab, and all of these would go under a predefined section (user's photo gallery or common Videos forum or something).

I'm just thinking out loud, these aren't actual requirement specs but if there was API exposed to do this level of customization in as few lines of readable Javascript code as possible, that'd be nice.

Maybe someone might surprise me and tell me that most of what I'm looking for is there? [crossing fingers]

 
Ben Tiedt
Top 10 Contributor
Posts 3,338
Points 63,065
CS Developers
By: Ben Tiedt
Posted: Thu, Aug 16 2007 9:39 AM In reply to

The form components (text boxes, checkboxes, etc) are accessable on the client-side using standard ASP.Net techniques -- the theme defines the IDs of each of these controls and can interact with them directly.

Editors are a little different because they are loaded dynamically, but all editors must implement the CommunityServer.Controls.ITextEditor interface which provides methods to retrieve the client-side script for getting, appending, inserting, and updating the content of the specific editor rendered.

The tabs on the post editor page use the Telligent.Glow.TabbedPanes control which exposes a client-side API (the tab's client-side object is named the same as the control's ClientID) -- for example,

  • tabbedPanesControl.GetTabByIndex(index)
  • tabbedPanesControl.GetTabsByText(text)
  • tabbedPanesControl.GetTabById(id)
  • tabbedPanesControl.GetSelectedTab()

Additionally, when you retrieve a tab via client-script (using one of these functions of the TabbedPanes control), you can select it using

  • tabbedPanesControl.SelectTab(tab)

or enable/disable it (hide/show it) using the following script:

var tab = tabbedPanesControl.GetTabByIndex(0);
tab.Disabled = true; // or false
tabbedPanesControl.Refresh();

There are also functions for adding, removing, and reordering tabs and editing the content of an individual tab's pane.

Ben Tiedt's Blog

 
  • Post Points: 20 |
primedia_jdavis
Top 500 Contributor
Posts 89
Points 1,225
By: primedia_jdavis
Posted: Thu, Aug 16 2007 12:45 PM In reply to

Thanks for your response, Ben. If I run into any issues on this I'll post here.

 
  • Post Points: 20 |
jsawruk
Top 500 Contributor
Posts 68
Points 1,005
By: jsawruk
Posted: Mon, Feb 25 2008 4:13 PM In reply to

I am trying to make a button that will call a Javascript function to advance to the next tab on the EditProfilePreferences.aspx page.

I have tried this approach but I cannot get it to work. Is it because:

1) I am running CS 2008 and something has changed

and/or

2) The TWC:TabbedPanes control is inside the FormTemplate of CSControl:EditUserForm

?

 
  • Post Points: 20 |
Ben Tiedt
Top 10 Contributor
Posts 3,338
Points 63,065
CS Developers
By: Ben Tiedt
Posted: Tue, Feb 26 2008 12:10 AM In reply to

jsawruk:

I have tried this approach but I cannot get it to work. Is it because:

1) I am running CS 2008 and something has changed

and/or

2) The TWC:TabbedPanes control is inside the FormTemplate of CSControl:EditUserForm

?

Most likely #2.  When referencing the control in script, you need to use it's ClientID.  For example,

<%= CSControlUtility.Instance().FindControl(this, "ID_OF_TABBEDPANES_CONTROL" ).ClientID %>.GetSelectedTab();

or, when beta-2 is available,

<CSControl:ControlData runat="server" ControlId="ID_OF_TABBEDPANES_CONTROL" Property="ClientID" />.GetSelectedTab();

 

 

Ben Tiedt's Blog

 
  • Post Points: 20 |
jsawruk
Top 500 Contributor
Posts 68
Points 1,005
By: jsawruk
Posted: Tue, Feb 26 2008 9:45 AM In reply to

Thanks, that worked. It turned out that before I wasn't getting the reference to the correct object. I was getting the individual tabs, not the TabbedPanes.

 

 
  • Post Points: 5 |
Page 1 of 1 (6 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com