From 0a905986d9539441fe42f895c57edb9e53d3a423 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 2 Oct 2008 06:40:24 +0000 Subject: [PATCH] add DOMLoad autocmd event --- NEWS | 1 + content/events.js | 9 +++++++++ content/vimperator.js | 1 + locale/en-US/autocommands.txt | 1 + vimperator.vim | 4 ++-- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 07e0beb3..35fe2002 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ special versions for the old behavior * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add DOMLoad autocmd event * add :messages and 'messages' * add :runtime * add 'runtimepath' diff --git a/content/events.js b/content/events.js index eed1eef4..a6513ec2 100644 --- a/content/events.js +++ b/content/events.js @@ -300,6 +300,8 @@ liberator.Events = function () //{{{ }, false); } + getBrowser().addEventListener("DOMContentLoaded", onDOMContentLoaded, true); + // this adds an event which is is called on each page load, even if the // page is loaded in a background tab getBrowser().addEventListener("load", onPageLoad, true); @@ -447,6 +449,13 @@ liberator.Events = function () //{{{ return false; } + function onDOMContentLoaded(event) + { + if (event.originalTarget instanceof HTMLDocument) + liberator.autocommands.trigger("DOMLoad", event.originalTarget.location.href); + } + + // TODO: see what can be moved to onDOMContentLoaded() function onPageLoad(event) { if (event.originalTarget instanceof HTMLDocument) diff --git a/content/vimperator.js b/content/vimperator.js index e84da7db..969cad0a 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -39,6 +39,7 @@ liberator.config = { //{{{ get visualbellWindow() getBrowser().mPanelContainer, autocommands: [["BookmarkAdd", "Triggered after a page is bookmarked"], + ["DOMLoad", "Triggered when a page's DOM content has fully loaded"], ["LocationChange", "Triggered when changing tabs or when naviagtion to a new location"], ["PageLoadPre", "Triggered after a page load is initiated"], ["PageLoad", "Triggered when a page gets (re)loaded/opened"], diff --git a/locale/en-US/autocommands.txt b/locale/en-US/autocommands.txt index 1f6e4994..4b5b10cc 100644 --- a/locale/en-US/autocommands.txt +++ b/locale/en-US/autocommands.txt @@ -21,6 +21,7 @@ Available {events}: `--------------------`---------------------------------------- *BookmarkAdd* Triggered after a page is bookmarked +*DOMLoad* Triggered when a page's DOM content has fully loaded *LocationChange* Triggered when changing tabs or when navigating to a new location *PageLoadPre* Triggered after a page load is initiated. *PageLoad* Triggered when a page gets (re)loaded/opened diff --git a/vimperator.vim b/vimperator.vim index 5ce85268..02978881 100644 --- a/vimperator.vim +++ b/vimperator.vim @@ -32,8 +32,8 @@ syn match vimperatorCommand "!" contained syn keyword vimperatorAutoCmd au[tocmd] contained nextgroup=vimperatorAutoEventList skipwhite -syn keyword vimperatorAutoEvent BookmarkAdd LocationChange PageLoadPre PageLoad ShellCmdPost VimperatorEnter VimperatorLeavePre - \ VimperatorLeave +syn keyword vimperatorAutoEvent BookmarkAdd DOMLoad LocationChange PageLoadPre PageLoad ShellCmdPost VimperatorEnter + \ VimperatorLeavePre VimperatorLeave \ contained syn match vimperatorAutoEventList "\(\a\+,\)*\a\+" contained contains=vimperatorAutoEvent