JavaScript API

Public JavaScript methods

The public JavaScript events are placed on the RefinedWiki API namespace: RWA. This is divided into sub-namespaces based on functionality.

RWA.Category 

/**

  • Hides the user category link located in the category menu.

  • Also removes all User category dropdowns

  • @return void - no return value

 */

RWA.Category.hideUserCategory = function();

/**

  • Hides all inline user category inline dialogs. Note that this won't hide users associated with a top level

  • category, only open dialogs refering to subcategories.

 */

RWA.Category.hideInlineUserCategoryDialogs = function();

/**

  • Hides any open category by closing the category dropdown and any open

  • user category dialogs. This function will trigger a 

  • 'rw-categories:category-dropdown-closed' event.

*

  • @return the ID selector for the DOM element representing the closed 

  • category. On the form rw_category_key_{categoryKey}

 */

RWA.Category.hideCategory = function();

/**

  • Shows the requested top level category by opening its category 

  • dropdown. Will trigger 'rw-categories:category-dropdown-open' event.

  • @param key - nameKey of the category to open.

  • @param expandAll - True or false depending on if the containing 

  • subcategories in the dropdown should be expanded or collapsed. Usable 

  • if collapsed mode is used.

  • @param callback - Callback function for when the dropdown content has

  • been rendered. If supplied this will be called with two parameters:

 *

  • $el - the category dropdown wrapper as jQuery object.

  • category - JSON object representing the category just opened - with 

  • any fetched data populated as well.

 *

  • @return boolean - True if the category with the specified key was 

  • found - false otherwise. Use the callback function to get relevant values.

 */

RWA.Category.showCategory = function(key, expandAll, callback);

/**

  • Toggles the requested subcategory by collapsing/expanding it.

  • @param subCategory - Either the key of the subcategory e.g. 'subKey' 

  • or the entire jQuery selector string e.g. 'rw_sub_category_key_subKey', 

  • or the jQuery object itself e.g. $('#rw_sub_category_key_subKey')

 *

  • Will trigger a 'rw-categories:category-opened' or a 

  • 'rw-categories:category-closed' event depending on the result of the 

  • toggle.

  • @returns void - no return value

 */

RWA.Category.toggleSubCategory(subCategory);

RWA.Page

Events

Refined for Confluence provides various js events you can listen to, which are triggered on the AJS namespace. You can bind on them in the following way:

AJS.bind('rw-categories:category-opened', function(e, $el, category){

  // A collapsed category was just opened. Check if we should append our cool feature ...

});

Available rw-categories events

Available rw-page events