1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-10 02:16:40 +02:00

Added comments for autogenerated documentation (hash, help)

This commit is contained in:
Max Guglielmi 2016-07-23 18:34:19 +10:00
parent d52e58ec74
commit fb56fab0c7
5 changed files with 103 additions and 22 deletions

4
dist/starter.html vendored
View file

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tablefilter v0.2.42 - Starter</title>
<title>tablefilter v0.2.43 - Starter</title>
</head>
<body>
<h1>tablefilter v0.2.42</h1>
<h1>tablefilter v0.2.43</h1>

View file

@ -28,7 +28,7 @@
"tag": "next"
},
"devDependencies": {
"babel-core": "^6.10.4",
"babel-core": "^6.11.4",
"babel-eslint": "6.1.2",
"babel-loader": "^6.0.1",
"babel-preset-es2015": "^6.9.0",

View file

@ -5,13 +5,16 @@ const JSON = root.JSON;
const location = root.location;
const decodeURIComponent = root.decodeURIComponent;
/**
* Checks if browser has onhashchange event
*/
export const hasHashChange = () => {
let docMode = root.documentMode;
return ('onhashchange' in root) && (docMode === undefined || docMode > 7);
};
/**
* Manages the URL hash reflecting the features state to be persisted
* Manages state via URL hash changes
*
* @export
* @class Hash
@ -24,9 +27,30 @@ export class Hash {
* @param {State} state Instance of State
*/
constructor(state) {
/**
* State object
* @type {State} State
*/
this.state = state;
/**
* Cached URL hash
* @type {String} Hash string
* @private
*/
this.lastHash = null;
/**
* Application event emitter instance
* @type {Emitter}
*/
this.emitter = state.emitter;
/**
* Bound sync wrapper for future use
* @private
*/
this.boundSync = null;
}
/**
@ -38,7 +62,7 @@ export class Hash {
}
this.lastHash = location.hash;
//Store a bound sync wrapper for future use.
//Store a bound sync wrapper
this.boundSync = this.sync.bind(this);
this.emitter.on(['state-changed'], (tf, state) => this.update(state));
this.emitter.on(['initialized'], this.boundSync);

View file

@ -7,23 +7,37 @@ const WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' +
'4.-Filter-operators';
const WEBSITE_URL = 'http://koalyptus.github.io/TableFilter/';
/**
* Help UI component
*/
export class Help extends Feature {
/**
* Help UI component
* @param {Object} tf TableFilter instance
* Creates an instance of Help.
* @param {TableFilter} tf TableFilter instance
*/
constructor(tf) {
super(tf, 'help');
var f = this.config;
//id of custom container element for instructions
/**
* ID of main custom container element
* @type {String}
*/
this.tgtId = f.help_instructions_target_id || null;
//id of custom container element for instructions
/**
* ID of custom container element for instructions
* @type {String}
*/
this.contTgtId = f.help_instructions_container_target_id ||
null;
//defines help text
/**
* Instructions text (accepts HTML)
* @type {String}
*/
this.instrText = f.help_instructions_text ?
f.help_instructions_text :
'Use the filters above each column to filter and limit table ' +
@ -33,21 +47,54 @@ export class Help extends Feature {
'<b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, ' +
'<b>rgx:</b><br/><a href="' + WIKI_URL + '" target="_blank">' +
'Learn more</a><hr/>';
//defines help innerHtml
/**
* Instructions HTML
* @type {String}
*/
this.instrHtml = f.help_instructions_html || null;
//defines reset button text
/**
* Help button text ('?')
* @type {String}
*/
this.btnText = f.help_instructions_btn_text || '?';
//defines reset button innerHtml
/**
* Custom help button HTML
* @type {String}
*/
this.btnHtml = f.help_instructions_btn_html || null;
//defines css class for help button
/**
* Css class for help button
* @type {String}
*/
this.btnCssClass = f.help_instructions_btn_css_class || 'helpBtn';
//defines css class for help container
/**
* Css class for help container element
* @type {String}
*/
this.contCssClass = f.help_instructions_container_css_class ||
'helpCont';
//help button element
/**
* Stores button DOM element
* @type {DOMElement}
*/
this.btn = null;
//help content div
/**
* Stores help container DOM element
* @type {DOMElement}
*/
this.cont = null;
/**
* Default HTML appended to instructions text
* @type {String}
*/
this.defaultHtml = '<div class="helpFooter"><h4>TableFilter ' +
'v' + tf.version + '</h4>' + '<a href="' + WEBSITE_URL +
'" target="_blank">' + WEBSITE_URL + '</a>' +
@ -55,9 +102,18 @@ export class Help extends Feature {
'<div align="center" style="margin-top:8px;">' +
'<a href="javascript:void(0);" class="close">Close</a></div></div>';
//id prefix for help elements
/**
* Prefix for help main container ID
* @type {String}
* @private
*/
this.prfxHelpSpan = 'helpSpan_';
//id prefix for help elements
/**
* Prefix for help instructions container ID
* @type {String}
* @private
*/
this.prfxHelpDiv = 'helpDiv_';
this.emitter.on(['init-help'], () => this.init());
@ -65,7 +121,6 @@ export class Help extends Feature {
/**
* Initialise Help instance
*
* @returns (description)
*/
init() {
@ -120,6 +175,9 @@ export class Help extends Feature {
this.cont = helpdiv;
this.btn = helpspan;
/**
* @inherited
*/
this.initialized = true;
}

View file

@ -5,8 +5,7 @@ import {isEmpty} from '../string';
import {isArray, isNull, isString, isUndef} from '../types';
/**
* Reflects the state of features to be persisted via hash, localStorage or
* cookie
* State persistence via hash, localStorage or cookie
*
* @export
* @class State