diff options
Diffstat (limited to 'src/content')
| -rw-r--r-- | src/content/footer-line.js | 3 | ||||
| -rw-r--r-- | src/content/index.js | 44 | 
2 files changed, 30 insertions, 17 deletions
| diff --git a/src/content/footer-line.js b/src/content/footer-line.js index 39d8eaf..fc1dc7b 100644 --- a/src/content/footer-line.js +++ b/src/content/footer-line.js @@ -1,7 +1,7 @@  import './footer-line.css';  export default class FooterLine { -  constructor(doc) { +  constructor(doc, initial = '') {      this.initUi(doc);      this.enteredCallback = () => {} @@ -10,6 +10,7 @@ export default class FooterLine {      this.input.addEventListener('blur', this.handleBlur.bind(this));      this.input.addEventListener('keydown', this.handleKeydown.bind(this));      this.input.addEventListener('keyup', this.handleKeyup.bind(this)); +    this.input.value = initial;    }    initUi(doc) { diff --git a/src/content/index.js b/src/content/index.js index ed33961..17ab308 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -4,6 +4,25 @@ import * as actions from '../shared/actions';  var footer = null; +const createFooterLine = (initial = '') => { +  footer = new FooterLine(document, initial); +  footer.onPromptChange((e) => { +    let request = { +      type: 'event.cmd.suggest', +      text: e.target.value +    }; +    browser.runtime.sendMessage(request); +  }); +  footer.onEntered((e) => { +    let request = { +      type: 'event.cmd.enter', +      text: e.target.value +    }; +    browser.runtime.sendMessage(request); +  }); +  footer.focus(); +} +  const invokeEvent = (action) => {    if (typeof action === 'undefined' || action === null) {      return; @@ -11,22 +30,15 @@ const invokeEvent = (action) => {    switch (action[0]) {    case actions.CMD_OPEN: -    footer = new FooterLine(document); -    footer.onPromptChange((e) => { -      let request = { -        type: 'event.cmd.suggest', -        text: e.target.value -      }; -      browser.runtime.sendMessage(request); -    }); -    footer.onEntered((e) => { -      let request = { -        type: 'event.cmd.enter', -        text: e.target.value -      }; -      browser.runtime.sendMessage(request); -    }); -    footer.focus(); +    createFooterLine(); +    break; +  case actions.CMD_TABS_OPEN: +    if (action[1] || false) { +      // alter url +      createFooterLine('open ' + window.location.href); +    } else { +      createFooterLine('open '); +    }      break;    case actions.SCROLL_UP:      scrolls.scrollUp(window, action[1] || 1); | 
