!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 46 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/toolkit/content/finddialog.js"
2
3 var dialog; // Quick access to document/form elements.
4 var gFindInst; // nsIWebBrowserFind that we're going to use
5 var gFindInstData; // use this to update the find inst data
6
initDialogObject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
7 function initDialogObject()
8 {
9 // Create dialog object and initialize.
10 dialog = new Object;
11 dialog.findKey = document.getElementById("dialog.findKey");
12 dialog.caseSensitive = document.getElementById("dialog.caseSensitive");
13 dialog.wrap = document.getElementById("dialog.wrap");
14 dialog.find = document.getElementById("btnFind");
15 dialog.up = document.getElementById("radioUp");
16 dialog.down = document.getElementById("radioDown");
17 dialog.rg = dialog.up.radioGroup;
18 dialog.bundle = null;
19
20 // Move dialog to center, if it not been shown before
21 var windowElement = document.getElementById("findDialog");
22 if (!windowElement.hasAttribute("screenX") || !windowElement.hasAttribute("screenY"))
23 {
24 sizeToContent();
25 moveToAlertPosition();
26 }
27 }
28
fillDialog
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
29 function fillDialog()
30 {
31 // get the find service, which stores global find state
32 var findService = Components.classes["@mozilla.org/find/find_service;1"]
33 .getService(Components.interfaces.nsIFindService);
34
35 // Set initial dialog field contents. Use the gFindInst attributes first,
36 // this is necessary for window.find()
37 dialog.findKey.value = gFindInst.searchString ? gFindInst.searchString : findService.searchString;
38 dialog.caseSensitive.checked = gFindInst.matchCase ? gFindInst.matchCase : findService.matchCase;
39 dialog.wrap.checked = gFindInst.wrapFind ? gFindInst.wrapFind : findService.wrapFind;
40 var findBackwards = gFindInst.findBackwards ? gFindInst.findBackwards : findService.findBackwards;
41 if (findBackwards)
42 dialog.rg.selectedItem = dialog.up;
43 else
44 dialog.rg.selectedItem = dialog.down;
45 }
46
saveFindData
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
47 function saveFindData()
48 {
49 // get the find service, which stores global find state
50 var findService = Components.classes["@mozilla.org/find/find_service;1"]
51 .getService(Components.interfaces.nsIFindService);
52
53 // Set data attributes per user input.
54 findService.searchString = dialog.findKey.value;
55 findService.matchCase = dialog.caseSensitive.checked;
56 findService.wrapFind = dialog.wrap.checked;
57 findService.findBackwards = dialog.up.selected;
58 }
59
onLoad
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
60 function onLoad()
61 {
62 initDialogObject();
63
64 // get the find instance
65 var arg0 = window.arguments[0];
66 // If the dialog was opened from window.find(),
67 // arg0 will be an instance of nsIWebBrowserFind
68 if (arg0 instanceof Components.interfaces.nsIWebBrowserFind) {
69 gFindInst = arg0;
70 } else {
71 gFindInstData = arg0;
72 gFindInst = gFindInstData.webBrowserFind;
73 }
74
75 fillDialog();
76 doEnabling();
77
78 if (dialog.findKey.value)
79 dialog.findKey.select();
80 dialog.findKey.focus();
81 }
82
onUnload
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
83 function onUnload()
84 {
85 window.opener.findDialog = 0;
86 }
87
onAccept
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
88 function onAccept()
89 {
90 if (gFindInstData && gFindInst != gFindInstData.webBrowserFind) {
91 gFindInstData.init();
92 gFindInst = gFindInstData.webBrowserFind;
93 }
94
95 // Transfer dialog contents to the find service.
96 saveFindData();
97
98 // set up the find instance
99 gFindInst.searchString = dialog.findKey.value;
100 gFindInst.matchCase = dialog.caseSensitive.checked;
101 gFindInst.wrapFind = dialog.wrap.checked;
102 gFindInst.findBackwards = dialog.up.selected;
103
104 // Search.
105 var result = gFindInst.findNext();
106
107 if (!result)
108 {
109 if (!dialog.bundle)
110 dialog.bundle = document.getElementById("findBundle");
111 window.alert(dialog.bundle.getString("notFoundWarning"));
112 dialog.findKey.select();
113 dialog.findKey.focus();
114 }
115 return false;
116 }
117
doEnabling
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
118 function doEnabling()
119 {
120 dialog.find.disabled = !dialog.findKey.value;
121 }