Changeset 474
- Timestamp:
- 2007-07-05 20:49:31 (2 years ago)
- Files:
-
- trunk/chrome.manifest (modified) (2 diffs)
- trunk/chrome/content/common/internalFunctions.js (modified) (2 diffs)
- trunk/chrome/content/common/overlayFunctions.js (modified) (7 diffs)
- trunk/chrome/content/integration/elements.js (modified) (15 diffs)
- trunk/chrome/content/integration/firefox.xul (modified) (1 diff)
- trunk/chrome/content/integration/thunderbird.xul (added)
- trunk/install.rdf (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome.manifest
r463 r474 26 26 overlay chrome://browser/content/sanitize.xul chrome://dta/content/privacy/overlaySanitizeUI.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} 27 27 overlay chrome://browser/content/sanitize.xul chrome://dta/content/privacy/overlaySanitizeCode.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} 28 overlay chrome:///content/downloads/unknownContentType.xul chrome://dta/content/integration/saveas.xul 28 29 29 30 ## Seamonkey ## … … 33 34 style chrome://navigator/content/navigator.xul chrome://dta/skin/integration/style.css application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 34 35 36 ## Thunderbird ## 37 overlay chrome://messenger/content/messenger.xul chrome://dta/content/integration/thunderbird.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 38 overlay chrome://messenger/content/messageWindow.xul chrome://dta/content/integration/thunderbird.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 39 overlay chrome://dta/content/integration/thunderbird.xul chrome://dta/content/integration/elements.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} 40 style chrome://messenger/content/messenger.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 41 style chrome://messenger/content/messageWindow.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 42 style chrome://global/content/customizeToolbar.xul chrome://dta/skin/integration/style.css application={3550f703-e582-4d05-9a08-453d09bdfdc6} 43 35 44 ## toolkit ## 36 45 overlay chrome://mozapps/content/downloads/unknownContentType.xul chrome://dta/content/integration/saveas.xul trunk/chrome/content/common/internalFunctions.js
r461 r474 310 310 } 311 311 312 var units = [ 'TB','GB','MB','KB'];312 var units = [['TB', 3], ['GB', 2], ['MB', 2], ['KB', 1]]; 313 313 var unit; 314 314 … … 318 318 } 319 319 320 return aNumber.toFixed( 2) + " " + unit;320 return aNumber.toFixed(unit[1]) + " " + unit[0]; 321 321 }, 322 322 trunk/chrome/content/common/overlayFunctions.js
r461 r474 329 329 DTA_DropProcessor.prototype = { 330 330 getSupportedFlavours: function() { 331 var flavours = new FlavourSet ();331 var flavours = new FlavourSet(); 332 332 flavours.appendFlavour("text/x-moz-url"); 333 333 return flavours; 334 334 }, 335 onDragOver: function(evt,flavour,session) { 336 }, 335 onDragOver: function(evt,flavour,session) {}, 337 336 onDrop: function (evt,dropdata,session) { 338 337 if (!dropdata) { 339 338 return; 340 339 } 341 var url = transferUtils.retrieveURLFromData(dropdata.data, dropdata.flavour.contentType); 340 try { 341 var url = transferUtils.retrieveURLFromData(dropdata.data, dropdata.flavour.contentType); 342 } 343 catch (ex) { 344 return; 345 } 342 346 var doc = document.commandDispatcher.focusedWindow.document; 343 347 url = new DTA_URL(url, doc.characterSet); 344 var ref = doc.URL; 345 if (!ref) { 346 ref = DTA_Mediator.getMostRecentURL(); 347 } 348 var ref = DTA_AddingFunctions.getRef(doc); 348 349 this.func(url, ref); 349 350 } … … 421 422 return this.ios.newURI(rel, doc.characterSet, this.ios.newURI(base, doc.characterSet, null)).spec; 422 423 }, 424 425 getRef: function(doc) { 426 var ref = doc.URL; 427 if (!this.isLinkOpenable(ref)) { 428 var b = doc.getElementsByTagName('base'); 429 for (var i = 0; i < b.length; ++i) { 430 if (!b[i].hasAttribute('href')) { 431 continue; 432 } 433 try { 434 ref = this.composeURL(doc, b[i].getAttribute('href')); 435 } 436 catch (ex) { 437 continue; 438 } 439 break; 440 } 441 } 442 return this.isLinkOpenable(ref) ? ref: ''; 443 }, 423 444 424 445 saveSingleLink : function(turbo, url, referrer, description) { … … 540 561 openManager : function (quite) { 541 562 try { 542 var win = DTA_Mediator.get ("chrome://dta/content/dta/manager.xul");563 var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 543 564 if (win) { 544 565 if (!quite) { … … 552 573 "chrome, centerscreen, resizable=yes, dialog=no, all, modal=no, dependent=no" 553 574 ); 554 return DTA_Mediator.get ("chrome://dta/content/dta/manager.xul");575 return DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 555 576 } catch(ex) { 556 577 DTA_debug.dump("openManager():", ex); … … 560 581 561 582 sendToDown : function(notQueue, links) { 562 var win = DTA_Mediator.get ("chrome://dta/content/dta/manager.xul");583 var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 563 584 if (win) { 564 585 win.self.startnewDownloads(notQueue, links); … … 577 598 578 599 getMostRecent: function(name) { 579 var rv = this._m.getMostRecentWindow(name ? name : "navigator:browser"); 580 return rv ? rv : null; 581 }, 582 getMostRecentURL: function() { 583 var rv = this.getMostRecent(); 584 return rv ? rv.content.document.location : ""; 585 }, 586 'get': function(url) { 600 var names = ['navigator:browser', 'mail:messageWindow', 'mail:3pane']; 601 if (name) { 602 names.unshift(name); 603 } 604 var rv = null; 605 names.some( 606 function(name) { 607 rv = this._m.getMostRecentWindow(name); 608 return rv; 609 }, 610 this 611 ); 612 return rv; 613 }, 614 getByUrl: function(url) { 587 615 if (!url) { 588 616 return null; … … 602 630 } 603 631 return null; 632 }, 633 getAllByType: function(type) { 634 var rv = []; 635 var enumerator = this._m.getEnumerator(type); 636 while (enumerator.hasMoreElements()) { 637 rv.push(enumerator.getNext()); 638 } 639 return rv; 604 640 }, 605 641 openTab: function WM_openTab(url, ref) { trunk/chrome/content/integration/elements.js
r463 r474 58 58 59 59 addLinksToArray: function(lnks, urls, doc) { 60 var ref = doc.URL; 61 if (!('length' in lnks)) { 60 if (!lnks || !lnks.length) { 62 61 return; 63 62 } 64 var known = {}; 63 64 var ref = DTA_AddingFunctions.getRef(doc); 65 65 66 for (var i = 0; i < lnks.length; ++i) { 66 67 // remove anchor from url … … 68 69 var plink = link.href.replace(/#.*$/gi, ""); 69 70 // if it's valid and it's new 70 if (!DTA_AddingFunctions.isLinkOpenable(plink) || plink in known) {71 if (!DTA_AddingFunctions.isLinkOpenable(plink)) { 71 72 continue; 72 73 } … … 85 86 'hash': DTA_getLinkPrintHash(link.hash) 86 87 }); 87 known[plink] = null;88 88 89 89 var ml = DTA_getLinkPrintMetalink(link.hash); … … 96 96 'metalink': true 97 97 }); 98 known[ml] = null;99 98 } 100 99 } … … 102 101 103 102 addImagesToArray: function(lnks, images, doc) { 104 var ref = doc.URL;105 106 103 if (!lnks || !lnks.length) { 107 104 return; 108 105 } 109 var known = {}; 110 106 107 var ref = DTA_AddingFunctions.getRef(doc); 108 111 109 for (var i = 0; i < lnks.length; ++i) { 112 110 var src = lnks[i].src; … … 122 120 // if it's valid and it's new 123 121 // better double check :p 124 if (!DTA_AddingFunctions.isLinkOpenable(src) || src in known) {122 if (!DTA_AddingFunctions.isLinkOpenable(src)) { 125 123 continue; 126 124 } … … 137 135 'description': desc 138 136 }); 139 known[src] = null;140 137 } 141 138 }, … … 171 168 var sel = aWin.getSelection(); 172 169 if (honorSelection && sel && !sel.isCollapsed) { 173 [links, images, embeds, inputs].forEach( 170 DTA_debug.dump("selection only"); 171 [links, images, embeds, inputs] = [links, images, embeds, inputs].map( 174 172 function(e) { 175 e =filterElements(e, sel);173 return filterElements(e, sel); 176 174 } 177 175 ); … … 203 201 }, 204 202 203 findWindowsNavigator: function(all) { 204 var windows = []; 205 if (!all) { 206 var sel = document.commandDispatcher.focusedWindow.getSelection(); 207 if (sel.isCollapsed) { 208 windows.push(DTA_Mediator.getMostRecent().getBrowser().selectedBrowser.contentWindow.top); 209 } 210 else { 211 windows.push(document.commandDispatcher.focusedWindow); 212 } 213 } 214 else { 215 var win = DTA_Mediator.getMostRecent().getBrowser(); 216 win.browsers.forEach( 217 function(e) { 218 windows.push(e.contentWindow.top); 219 } 220 ); 221 } 222 return windows; 223 }, 224 findWindowsMail: function(all) { 225 var windows = []; 226 if (document.documentElement.getAttribute('windowtype') == 'mail:3pane') { 227 windows.push(document.getElementById('messagepane').contentWindow); 228 } 229 else if (!all) { 230 windows.push(document.commandDispatcher.focusedWindow); 231 } 232 else { 233 windows = DTA_Mediator 234 .getAllByType('mail:messageWindow') 235 .map(function(w) { 236 return w.content; 237 }); 238 } 239 return windows; 240 }, 241 205 242 findLinks: function(turbo, all) { 206 243 try { 244 245 function makeUnique(i) { 246 var known = {}; 247 return i.filter( 248 function(e) { 249 var url = e.url.url; 250 if (url in known) { 251 return false; 252 } 253 known[url] = null; 254 return true; 255 } 256 ); 257 } 258 207 259 if (turbo) { 208 260 DTA_debug.dump("findLinks(): DtaOneClick request from the user"); … … 211 263 } 212 264 213 var windows = []; 214 if (!all) { 215 var sel = document.commandDispatcher.focusedWindow.getSelection(); 216 if (sel.isCollapsed) { 217 windows.push(DTA_Mediator.getMostRecent().getBrowser().selectedBrowser.contentWindow.top); 218 } 219 else { 220 windows.push(document.commandDispatcher.focusedWindow); 221 } 222 } 223 else { 224 var win = DTA_Mediator.getMostRecent().getBrowser(); 225 win.browsers.forEach( 226 function(e) { 227 windows.push(e.contentWindow.top); 228 } 229 ); 230 } 231 232 265 var wt = document.documentElement.getAttribute('windowtype'); 266 var windows = ( 267 wt.match(/^mail:/) 268 ? this.findWindowsMail 269 : this.findWindowsNavigator 270 )(all); 271 233 272 var urls = []; 234 273 var images = []; … … 239 278 this 240 279 ); 280 urls = makeUnique(urls); 281 images = makeUnique(images); 282 241 283 if (!urls.length && !images.length) { 242 284 DTA_alert(this.getString('error'), this.getString('errornolinks')); … … 265 307 var cur = gContextMenu.target; 266 308 267 if (gContextMenu.onLink) 268 var tofind = /^a$/i; 269 else 270 var tofind = /^img$/i; 271 309 var tofind = gContextMenu.onLink ? /^a$/i : /^img$/i; 310 272 311 while (!("tagName" in cur) || !tofind.test(cur.tagName)) { 273 312 cur = cur.parentNode; 274 313 } 275 276 314 var url = gContextMenu.onLink ? cur.href : cur.src; 277 315 … … 282 320 283 321 url = new DTA_URL(url, win.document.characterSet); 284 var ref = document.commandDispatcher.focusedWindow.document.URL;322 var ref = DTA_AddingFunctions.getRef(document.commandDispatcher.focusedWindow.document); 285 323 var desc = this.extractDescription(cur); 286 324 if (turbo) { … … 394 432 395 433 // general setup 396 var base = document.getElementById( 'context-sep-selectall');434 var base = document.getElementById(this.ctxBase.getAttribute('insertafter')); 397 435 if (compact) { 398 436 this.ctxBase.hidden = false; … … 411 449 if (compact) { 412 450 this.ctxMenu.insertBefore(cur, this.ctxMenu.firstChild); 413 } else { 451 } 452 else { 414 453 base.parentNode.insertBefore(cur, base); 415 454 base = cur; trunk/chrome/content/integration/firefox.xul
r463 r474 13 13 14 14 <popup id="contentAreaContextMenu"> 15 <menu id="dtaCtxCompact" insertafter="context-sep-selectall"/>15 <menu id="dtaCtxCompact" insertafter="context-sep-selectall"/> 16 16 </popup> 17 17 trunk/install.rdf
r463 r474 25 25 <rdf:Description> 26 26 <id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id> 27 <minVersion>2.0 .</minVersion>27 <minVersion>2.0</minVersion> 28 28 <maxVersion>3.0.*</maxVersion> 29 29 </rdf:Description> … … 37 37 <maxVersion>3.0</maxVersion> 38 38 </rdf:Description> 39 </targetApplication> 39 </targetApplication> 40 41 <!-- Thunderbird --> 42 <targetApplication> 43 <rdf:Description> 44 <id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</id> 45 <minVersion>2.0</minVersion> 46 <maxVersion>3.0.*</maxVersion> 47 </rdf:Description> 48 </targetApplication> 40 49 41 50 </rdf:Description>
