OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
5 * Copyright (C) 2009 Joseph Pecoraro | 5 * Copyright (C) 2009 Joseph Pecoraro |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * | 10 * |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 /** | 32 /** |
33 * @param {!Element} element | 33 * @param {!Element} element |
34 * @param {?function(!MouseEvent): boolean} elementDragStart | 34 * @param {?function(!MouseEvent): boolean} elementDragStart |
35 * @param {function(!MouseEvent)} elementDrag | 35 * @param {function(!MouseEvent)} elementDrag |
36 * @param {?function(!MouseEvent)} elementDragEnd | 36 * @param {?function(!MouseEvent)} elementDragEnd |
37 * @param {!string} cursor | 37 * @param {string} cursor |
38 * @param {?string=} hoverCursor | 38 * @param {?string=} hoverCursor |
39 */ | 39 */ |
40 WebInspector.installDragHandle = function(element, elementDragStart, elementDrag , elementDragEnd, cursor, hoverCursor) | 40 WebInspector.installDragHandle = function(element, elementDragStart, elementDrag , elementDragEnd, cursor, hoverCursor) |
41 { | 41 { |
42 element.addEventListener("mousedown", WebInspector.elementDragStart.bind(Web Inspector, elementDragStart, elementDrag, elementDragEnd, cursor), false); | 42 element.addEventListener("mousedown", WebInspector.elementDragStart.bind(Web Inspector, elementDragStart, elementDrag, elementDragEnd, cursor), false); |
43 if (hoverCursor !== null) | 43 if (hoverCursor !== null) |
44 element.style.cursor = hoverCursor || cursor; | 44 element.style.cursor = hoverCursor || cursor; |
45 } | 45 } |
46 | 46 |
47 /** | 47 /** |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 WebInspector.GlassPane.DefaultFocusedViewStack[0].focus(); | 160 WebInspector.GlassPane.DefaultFocusedViewStack[0].focus(); |
161 this.element.remove(); | 161 this.element.remove(); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 /** | 165 /** |
166 * @type {!Array.<!WebInspector.View>} | 166 * @type {!Array.<!WebInspector.View>} |
167 */ | 167 */ |
168 WebInspector.GlassPane.DefaultFocusedViewStack = []; | 168 WebInspector.GlassPane.DefaultFocusedViewStack = []; |
169 | 169 |
170 WebInspector.isBeingEdited = function(node) | 170 /** |
171 * @param {?EventTarget=} target | |
aandrey
2014/06/17 20:58:37
why EventTarget?
apavlov
2014/06/18 07:55:13
Same thing, added a cast in ShortcutRegistry.js
| |
172 * @return {boolean} | |
173 */ | |
174 WebInspector.isBeingEdited = function(target) | |
171 { | 175 { |
176 if (!target) | |
177 return false; | |
178 var node = /** @type {!Node} */ (target); | |
172 if (node.nodeType !== Node.ELEMENT_NODE) | 179 if (node.nodeType !== Node.ELEMENT_NODE) |
173 return false; | 180 return false; |
174 var element = /** {!Element} */ (node); | 181 var element = /** {!Element} */ (node); |
175 if (element.classList.contains("text-prompt") || element.nodeName === "INPUT " || element.nodeName === "TEXTAREA") | 182 if (element.classList.contains("text-prompt") || element.nodeName === "INPUT " || element.nodeName === "TEXTAREA") |
176 return true; | 183 return true; |
177 | 184 |
178 if (!WebInspector.__editingCount) | 185 if (!WebInspector.__editingCount) |
179 return false; | 186 return false; |
180 | 187 |
181 while (element) { | 188 while (element) { |
182 if (element.__editing) | 189 if (element.__editing) |
183 return true; | 190 return true; |
184 element = element.parentElement; | 191 element = element.parentElement; |
185 } | 192 } |
186 return false; | 193 return false; |
187 } | 194 } |
188 | 195 |
196 /** | |
197 * @param {!Element} element | |
198 * @param {boolean} value | |
199 * @return {boolean} | |
200 */ | |
189 WebInspector.markBeingEdited = function(element, value) | 201 WebInspector.markBeingEdited = function(element, value) |
190 { | 202 { |
191 if (value) { | 203 if (value) { |
192 if (element.__editing) | 204 if (element.__editing) |
193 return false; | 205 return false; |
194 element.classList.add("being-edited"); | 206 element.classList.add("being-edited"); |
195 element.__editing = true; | 207 element.__editing = true; |
196 WebInspector.__editingCount = (WebInspector.__editingCount || 0) + 1; | 208 WebInspector.__editingCount = (WebInspector.__editingCount || 0) + 1; |
197 } else { | 209 } else { |
198 if (!element.__editing) | 210 if (!element.__editing) |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 if (kilobytes < 1024) | 474 if (kilobytes < 1024) |
463 return WebInspector.UIString("%.0f\u2009KB", kilobytes); | 475 return WebInspector.UIString("%.0f\u2009KB", kilobytes); |
464 | 476 |
465 var megabytes = kilobytes / 1024; | 477 var megabytes = kilobytes / 1024; |
466 if (megabytes < 100) | 478 if (megabytes < 100) |
467 return WebInspector.UIString("%.1f\u2009MB", megabytes); | 479 return WebInspector.UIString("%.1f\u2009MB", megabytes); |
468 else | 480 else |
469 return WebInspector.UIString("%.0f\u2009MB", megabytes); | 481 return WebInspector.UIString("%.0f\u2009MB", megabytes); |
470 } | 482 } |
471 | 483 |
484 /** | |
485 * @param {number} num | |
486 * @return {string} | |
487 */ | |
472 Number.withThousandsSeparator = function(num) | 488 Number.withThousandsSeparator = function(num) |
473 { | 489 { |
474 var str = num + ""; | 490 var str = num + ""; |
475 var re = /(\d+)(\d{3})/; | 491 var re = /(\d+)(\d{3})/; |
476 while (str.match(re)) | 492 while (str.match(re)) |
477 str = str.replace(re, "$1\u2009$2"); // \u2009 is a thin space. | 493 str = str.replace(re, "$1\u2009$2"); // \u2009 is a thin space. |
478 return str; | 494 return str; |
479 } | 495 } |
480 | 496 |
497 /** | |
498 * @return {boolean} | |
499 */ | |
481 WebInspector.useLowerCaseMenuTitles = function() | 500 WebInspector.useLowerCaseMenuTitles = function() |
482 { | 501 { |
483 return WebInspector.platform() === "windows"; | 502 return WebInspector.platform() === "windows"; |
484 } | 503 } |
485 | 504 |
505 /** | |
506 * @param {string} format | |
507 * @param {?Array.<string>} substitutions | |
508 * @param {!Object.<string, function(string, ...):*>} formatters | |
509 * @param {string} initialValue | |
510 * @param {function(string, string): ?} append | |
511 * @return {!{formattedResult: string, unusedSubstitutions: ?Array.<string>}}; | |
512 */ | |
486 WebInspector.formatLocalized = function(format, substitutions, formatters, initi alValue, append) | 513 WebInspector.formatLocalized = function(format, substitutions, formatters, initi alValue, append) |
487 { | 514 { |
488 return String.format(WebInspector.UIString(format), substitutions, formatter s, initialValue, append); | 515 return String.format(WebInspector.UIString(format), substitutions, formatter s, initialValue, append); |
489 } | 516 } |
490 | 517 |
518 /** | |
519 * @return {string} | |
520 */ | |
491 WebInspector.openLinkExternallyLabel = function() | 521 WebInspector.openLinkExternallyLabel = function() |
492 { | 522 { |
493 return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open l ink in new tab" : "Open Link in New Tab"); | 523 return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Open l ink in new tab" : "Open Link in New Tab"); |
494 } | 524 } |
495 | 525 |
526 /** | |
527 * @return {string} | |
528 */ | |
496 WebInspector.copyLinkAddressLabel = function() | 529 WebInspector.copyLinkAddressLabel = function() |
497 { | 530 { |
498 return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy l ink address" : "Copy Link Address"); | 531 return WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Copy l ink address" : "Copy Link Address"); |
499 } | 532 } |
500 | 533 |
501 WebInspector.installPortStyles = function() | 534 WebInspector.installPortStyles = function() |
502 { | 535 { |
503 var platform = WebInspector.platform(); | 536 var platform = WebInspector.platform(); |
504 document.body.classList.add("platform-" + platform); | 537 document.body.classList.add("platform-" + platform); |
505 var flavor = WebInspector.platformFlavor(); | 538 var flavor = WebInspector.platformFlavor(); |
506 if (flavor) | 539 if (flavor) |
507 document.body.classList.add("platform-" + flavor); | 540 document.body.classList.add("platform-" + flavor); |
508 var port = WebInspector.port(); | 541 var port = WebInspector.port(); |
509 document.body.classList.add("port-" + port); | 542 document.body.classList.add("port-" + port); |
510 } | 543 } |
511 | 544 |
512 WebInspector._windowFocused = function(event) | 545 WebInspector._windowFocused = function(event) |
513 { | 546 { |
514 if (event.target.document.nodeType === Node.DOCUMENT_NODE) | 547 if (event.target.document.nodeType === Node.DOCUMENT_NODE) |
515 document.body.classList.remove("inactive"); | 548 document.body.classList.remove("inactive"); |
516 } | 549 } |
517 | 550 |
518 WebInspector._windowBlurred = function(event) | 551 WebInspector._windowBlurred = function(event) |
519 { | 552 { |
520 if (event.target.document.nodeType === Node.DOCUMENT_NODE) | 553 if (event.target.document.nodeType === Node.DOCUMENT_NODE) |
521 document.body.classList.add("inactive"); | 554 document.body.classList.add("inactive"); |
522 } | 555 } |
523 | 556 |
557 /** | |
558 * @return {!Element} | |
559 */ | |
524 WebInspector.previousFocusElement = function() | 560 WebInspector.previousFocusElement = function() |
525 { | 561 { |
526 return WebInspector._previousFocusElement; | 562 return WebInspector._previousFocusElement; |
527 } | 563 } |
528 | 564 |
565 /** | |
566 * @return {!Element} | |
567 */ | |
529 WebInspector.currentFocusElement = function() | 568 WebInspector.currentFocusElement = function() |
530 { | 569 { |
531 return WebInspector._currentFocusElement; | 570 return WebInspector._currentFocusElement; |
532 } | 571 } |
533 | 572 |
534 WebInspector._focusChanged = function(event) | 573 WebInspector._focusChanged = function(event) |
535 { | 574 { |
536 WebInspector.setCurrentFocusElement(event.target); | 575 WebInspector.setCurrentFocusElement(event.target); |
537 } | 576 } |
538 | 577 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 { | 659 { |
621 if (WebInspector._themeStyleElement) | 660 if (WebInspector._themeStyleElement) |
622 WebInspector._themeStyleElement.textContent = ""; | 661 WebInspector._themeStyleElement.textContent = ""; |
623 } | 662 } |
624 | 663 |
625 /** | 664 /** |
626 * @param {!Element} element | 665 * @param {!Element} element |
627 * @param {number} offset | 666 * @param {number} offset |
628 * @param {number} length | 667 * @param {number} length |
629 * @param {!Array.<!Object>=} domChanges | 668 * @param {!Array.<!Object>=} domChanges |
669 * @return {?Element} | |
630 */ | 670 */ |
631 WebInspector.highlightSearchResult = function(element, offset, length, domChange s) | 671 WebInspector.highlightSearchResult = function(element, offset, length, domChange s) |
632 { | 672 { |
633 var result = WebInspector.highlightSearchResults(element, [new WebInspector. SourceRange(offset, length)], domChanges); | 673 var result = WebInspector.highlightSearchResults(element, [new WebInspector. SourceRange(offset, length)], domChanges); |
634 return result.length ? result[0] : null; | 674 return result.length ? result[0] : null; |
635 } | 675 } |
636 | 676 |
637 /** | 677 /** |
638 * @param {!Element} element | 678 * @param {!Element} element |
639 * @param {!Array.<!WebInspector.SourceRange>} resultRanges | 679 * @param {!Array.<!WebInspector.SourceRange>} resultRanges |
640 * @param {!Array.<!Object>=} changes | 680 * @param {!Array.<!Object>=} changes |
681 * @return {!Array.<!Element>} | |
641 */ | 682 */ |
642 WebInspector.highlightSearchResults = function(element, resultRanges, changes) | 683 WebInspector.highlightSearchResults = function(element, resultRanges, changes) |
643 { | 684 { |
644 return WebInspector.highlightRangesWithStyleClass(element, resultRanges, "hi ghlighted-search-result", changes); | 685 return WebInspector.highlightRangesWithStyleClass(element, resultRanges, "hi ghlighted-search-result", changes); |
645 } | 686 } |
646 | 687 |
647 /** | 688 /** |
648 * @param {!Element} element | 689 * @param {!Element} element |
649 * @param {string} className | 690 * @param {string} className |
650 */ | 691 */ |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 window.addEventListener("focus", WebInspector._windowFocused, false); | 905 window.addEventListener("focus", WebInspector._windowFocused, false); |
865 window.addEventListener("blur", WebInspector._windowBlurred, false); | 906 window.addEventListener("blur", WebInspector._windowBlurred, false); |
866 document.addEventListener("focus", WebInspector._focusChanged, true); | 907 document.addEventListener("focus", WebInspector._focusChanged, true); |
867 document.addEventListener("blur", WebInspector._documentBlurred, true); | 908 document.addEventListener("blur", WebInspector._documentBlurred, true); |
868 window.removeEventListener("DOMContentLoaded", windowLoaded, false); | 909 window.removeEventListener("DOMContentLoaded", windowLoaded, false); |
869 } | 910 } |
870 | 911 |
871 window.addEventListener("DOMContentLoaded", windowLoaded, false); | 912 window.addEventListener("DOMContentLoaded", windowLoaded, false); |
872 | 913 |
873 })(); | 914 })(); |
OLD | NEW |