Skip to content

Commit

Permalink
flow now runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Nov 22, 2016
1 parent ea06f6c commit 8a31a32
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 14 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[ignore]
<PROJECT_ROOT>/node_modules/.*

[include]

Expand Down
2 changes: 1 addition & 1 deletion js/holmes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 48 additions & 7 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ import {mergeObj, toFactory} from './util.js';
*/
class Holmes {

elements: NodeList<HTMLElement>;
elementsArray: Array<HTMLElement>;
elementsLength: number;
hidden: number;
input: HTMLElement;
options: {
input: string,
find: string,
placeholder: ?string,
mark: ?boolean,
class: {
visible: ?string,
hidden: string
},
dynamic: ?boolean,
instant: ?boolean,
minCharacters: ?number,
hiddenAttr: ?boolean,
onHidden: ?function,
onVisible: ?function,
onEmpty: ?function,
onFound: ?function,
onInput: ?function,
};
running: boolean;
placeholderNode: HTMLElement;
searchString: string;
_regex: RegExp;
_inputHandler: function;

/**
* search for dom elements on your page
*
Expand Down Expand Up @@ -78,7 +108,7 @@ class Holmes {
*/
this.options = {
input: 'input[type=search]',
find: undefined,
find: '',
placeholder: undefined,
mark: false,
class: {
Expand Down Expand Up @@ -115,7 +145,7 @@ class Holmes {
* @memberOf holmes
* @instance
*/
this.input = undefined;
this.input;

/**
* All of the elements that are searched
Expand All @@ -124,7 +154,7 @@ class Holmes {
* @memberOf holmes
* @instance
*/
this.elements = undefined;
this.elements;

/**
* Placeholder element
Expand All @@ -133,7 +163,16 @@ class Holmes {
* @memberOf holmes
* @instance
*/
this.placeholderNode = undefined;
this.placeholderNode;

/**
* Is the current instance running
* @member running
* @memberOf holmes
* @instance
* @type {Boolean}
*/
this.running = false;

if (this.options.instant) {
this.start(options);
Expand Down Expand Up @@ -371,8 +410,9 @@ class Holmes {

// if a visible class is given, give it to everything
if (this.options.class.visible) {
const vis: string = this.options.class.visible;
this.elementsArray.forEach((element => {
element.classList.add(this.options.class.visible);
element.classList.add(vis);
}));
}

Expand Down Expand Up @@ -429,16 +469,17 @@ class Holmes {
this.setInput('');
// if a visible class is given, give it to everything
if (this.options.class.visible) {
const vis: string = this.options.class.visible;
this.elementsArray.forEach(element => {
element.classList.remove(this.options.class.hidden);
element.classList.add(this.options.class.visible);
element.classList.add(vis);
});
} else {
this.elementsArray.forEach(element => {
element.classList.remove(this.options.class.hidden);
});
}
if (this.options.placeholder) {
if (this.options.placeholder && this.options.class.hidden) {
this.placeholderNode.classList.add(this.options.class.hidden);
if (this.options.class.visible) {
this.placeholderNode.classList.remove(this.options.class.visible);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"jsdoc": "^3.4.0",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-flow": "^1.0.1",
"rollup-plugin-uglify": "^1.0.1"
}
}
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import flow from 'rollup-plugin-flow';

export default {
entry: 'js/main.js',
dest: 'js/holmes.js',
format: 'umd',
moduleName: 'holmes',
plugins: [
flow(),
babel({
babelrc: false,
presets: ['es2015-rollup']
Expand Down
Loading

0 comments on commit 8a31a32

Please sign in to comment.