Skip to content

Commit

Permalink
Version 0.12: Initial search for selected text
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed Sep 27, 2014
1 parent 1bf066c commit 02fb173
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
14 changes: 7 additions & 7 deletions chrome/content/quickmove-overlay.xul
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
</menu>
Expand All @@ -39,7 +39,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeCopy)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
</menu>
Expand All @@ -54,7 +54,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-filebutton-separator" class="quickmove-separator"/>
</menupopup>
</toolbarbutton>
Expand All @@ -70,7 +70,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
<menupopup id="quickmove-goto-menupopup"
Expand All @@ -82,7 +82,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-goto-separator" class="quickmove-separator"/>
</menupopup>
</popupset>
Expand All @@ -97,7 +97,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
</window>
Expand All @@ -114,7 +114,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-location-separator" class="quickmove-separator"/>
</menupopup>
</menulist>
Expand Down
8 changes: 4 additions & 4 deletions chrome/content/quickmove-postbox.xul
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
<menupopup id="quickmove-goto-menupopup"
Expand All @@ -56,7 +56,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeGoto)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-goto-separator" class="quickmove-separator"/>
</menupopup>
</window>
Expand All @@ -75,7 +75,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeMove)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
</menu>
Expand All @@ -89,7 +89,7 @@
type="search"
timeout="500"
onkeypress="quickmove.keypress(event, quickmove.executeCopy)"
oncommand="quickmove.search(event)"/>
oncommand="quickmove.search(event.target); event.stopPropagation();"/>
<menuseparator id="quickmove-separator" class="quickmove-separator"/>
</menupopup>
</menu>
Expand Down
28 changes: 17 additions & 11 deletions chrome/content/quickmove.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ var quickmove = {
quickmove.clearItems(event.target);
quickmove.prepareFolders();

event.target.firstChild.value = "";
let initialText = "";
if (typeof GetMessagePaneFrame != "undefined") {
initialText = GetMessagePaneFrame().getSelection().toString() || "";
}

event.target.firstChild.value = initialText;
quickmove.dirty = false;
quickmove.addFolders(quickmove.recentFolders, event.target, event.target.firstChild.value);
if (initialText) {
quickmove.search(event.target.firstChild);
} else {
quickmove.addFolders(quickmove.recentFolders, event.target, event.target.firstChild.value);
}
event.stopPropagation();
},

Expand Down Expand Up @@ -224,17 +233,17 @@ var quickmove = {
* Perform a search. If no search term is entered, the recent folders are
* shown, otherwise folders which match the search term are shown.
*/
search: function Search(event) {
let popup = event.target.parentNode;
search: function Search(textboxNode) {
let popup = textboxNode.parentNode;
quickmove.clearItems(popup);
if (event.target.value.length == 0) {
quickmove.addFolders(quickmove.recentFolders, popup, event.target.value);
if (textboxNode.value.length == 0) {
quickmove.addFolders(quickmove.recentFolders, popup, textboxNode.value);
} else {
let folders = quickmove.suffixTree
.findMatches(event.target.value.toLowerCase())
.findMatches(textboxNode.value.toLowerCase())
.filter(function(x) x.canFileMessages);
if (folders.length) {
quickmove.addFolders(folders, popup, event.target.value);
quickmove.addFolders(folders, popup, textboxNode.value);
} else {
let node = document.createElement("menuitem");
node.setAttribute("disabled", "true");
Expand All @@ -251,9 +260,6 @@ var quickmove = {
quickmove.searchCompleteFunc();
quickmove.searchCompleteFunc = null;
}

// No further processing needed.
event.stopPropagation();
},

executeCopy: function executeCopy(folder) {
Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:type>2</em:type>
<em:version>0.11</em:version>
<em:version>0.12</em:version>

<em:name>Quick Folder Move</em:name>
<em:description>Quickly move messages into other folders using the keyboard</em:description>
Expand Down Expand Up @@ -49,7 +49,7 @@
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> <!-- thunderbird -->
<em:minVersion>3.0a2pre</em:minVersion>
<em:maxVersion>27.0a1</em:maxVersion>
<em:maxVersion>34.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
Expand Down

0 comments on commit 02fb173

Please sign in to comment.