1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-02 22:12:23 +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> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>tablefilter v0.2.42 - Starter</title> <title>tablefilter v0.2.43 - Starter</title>
</head> </head>
<body> <body>
<h1>tablefilter v0.2.42</h1> <h1>tablefilter v0.2.43</h1>

View file

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

View file

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

View file

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

View file

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