From f2630fb7e296d8b4d6ade63c4df4885c22a3919b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20P=C5=82=C3=B3cieniak?= Date: Sun, 9 Apr 2017 21:43:16 +0200 Subject: [PATCH] #93 | Unify MouseEvent type Unified MouseEvent type Switched off mangling names in gulp-uglify --- app/chrome/popup/scripts/popup.ts | 3 ++- app/sc_ext/Extensions.ts | 9 +++++++++ app/sc_ext/_all.ts | 2 ++ .../modules/fieldInspector/FieldInspectorModule.ts | 6 +++--- app/sc_ext/modules/launcher/LauncherModule.ts | 4 ++-- .../modules/treeAutoExpand/TreeAutoExpandModule.ts | 2 +- gulpfile.js | 2 +- 7 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 app/sc_ext/Extensions.ts diff --git a/app/chrome/popup/scripts/popup.ts b/app/chrome/popup/scripts/popup.ts index ca2a23c..3e0bad3 100644 --- a/app/chrome/popup/scripts/popup.ts +++ b/app/chrome/popup/scripts/popup.ts @@ -38,7 +38,8 @@ class LinkItemViewModel extends LinkItem { let href = connector + this.url; let mode = this.mode; elLi.onclick = () => { - chrome.tabs.getSelected(null, function (tab) { + chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) { + let tab = tabs[0]; var tablink = tab.url; var origin = tablink.match(/^[\w-]+:\/*\[?([\w\.:-]+)\]?(?::\d+)?/)[0]; if (mode == 'newtab') { diff --git a/app/sc_ext/Extensions.ts b/app/sc_ext/Extensions.ts new file mode 100644 index 0000000..ff4a98a --- /dev/null +++ b/app/sc_ext/Extensions.ts @@ -0,0 +1,9 @@ +declare interface MouseEvent { + getSrcElement(): Element; +} + +namespace SitecoreExtensions { + MouseEvent.prototype['getSrcElement'] = function (): Element { + return this.target; + }; +} \ No newline at end of file diff --git a/app/sc_ext/_all.ts b/app/sc_ext/_all.ts index fac8e82..622703e 100644 --- a/app/sc_ext/_all.ts +++ b/app/sc_ext/_all.ts @@ -1,5 +1,7 @@ // Typings /// +/// + // Options Page /// diff --git a/app/sc_ext/modules/fieldInspector/FieldInspectorModule.ts b/app/sc_ext/modules/fieldInspector/FieldInspectorModule.ts index 38a5759..4a07a1c 100644 --- a/app/sc_ext/modules/fieldInspector/FieldInspectorModule.ts +++ b/app/sc_ext/modules/fieldInspector/FieldInspectorModule.ts @@ -151,7 +151,7 @@ namespace SitecoreExtensions.Modules.FieldInspector { let spanGetFieldName = HTMLHelpers.createElement("span", { class: this.classFieldNameSpan }, { default: label.innerHTML }) as HTMLSpanElement; spanGetFieldName.innerHTML = label.innerHTML; spanGetFieldName.onclick = (e) => { - let currentElement = this.getFirstElementWithClass(e.srcElement, this.classFieldNameSpan); + let currentElement = this.getFirstElementWithClass(e.getSrcElement(), this.classFieldNameSpan); let fieldNameElement = new FieldNameElement(currentElement as HTMLSpanElement); if (!fieldNameElement.IsInitialized()) { @@ -196,11 +196,11 @@ namespace SitecoreExtensions.Modules.FieldInspector { } private writeDownFieldName(e, sectionElement, j) { - let elemenet = HTMLHelpers.getElement(e.srcElement, (e) => { return e.dataset['fieldid'] != null; }) as HTMLDivElement; + let elemenet = HTMLHelpers.getElement(e.getSrcElement(), (e) => { return e.dataset['fieldid'] != null; }) as HTMLDivElement; let fieldID = elemenet.dataset['fieldid']; let sectionName = this.getSectionName(sectionElement); this.getFieldName(fieldID, sectionName, j, (fieldName) => { - let node = this.getFirstElementWithClass(e.srcElement, this.classFieldNameSpan) as HTMLDivElement; + let node = this.getFirstElementWithClass(e.getSrcElement(), this.classFieldNameSpan) as HTMLDivElement; let currentElement = new FieldNameElement(node); currentElement.Initialize(fieldName); currentElement.setFieldName(); diff --git a/app/sc_ext/modules/launcher/LauncherModule.ts b/app/sc_ext/modules/launcher/LauncherModule.ts index 8d081d1..ade4630 100644 --- a/app/sc_ext/modules/launcher/LauncherModule.ts +++ b/app/sc_ext/modules/launcher/LauncherModule.ts @@ -375,7 +375,7 @@ namespace SitecoreExtensions.Modules.Launcher { li.appendChild(spanDescription); li.onclick = (e) => { - var element = e.srcElement; + var element = e.getSrcElement(); while (element.tagName != 'LI') { element = element.parentNode; } @@ -401,7 +401,7 @@ namespace SitecoreExtensions.Modules.Launcher { li.appendChild(spanDescription); li.onclick = (e) => { - var element = e.srcElement; + var element = e.getSrcElement(); while (element.tagName != 'LI') { element = element.parentNode; } diff --git a/app/sc_ext/modules/treeAutoExpand/TreeAutoExpandModule.ts b/app/sc_ext/modules/treeAutoExpand/TreeAutoExpandModule.ts index a3b4775..ce955e9 100644 --- a/app/sc_ext/modules/treeAutoExpand/TreeAutoExpandModule.ts +++ b/app/sc_ext/modules/treeAutoExpand/TreeAutoExpandModule.ts @@ -27,7 +27,7 @@ namespace SitecoreExtensions.Modules.TreeAutoExpand { } expandSubTree(evt: MouseEvent): void { - let glyphId = evt.srcElement.id; + let glyphId = evt.getSrcElement().id; let icon = new TreeNodeGlyph(glyphId); if (icon.isExpandable()) { diff --git a/gulpfile.js b/gulpfile.js index 896f3c6..7f61963 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -180,7 +180,7 @@ function publish(src, dest) { .pipe(_if('*.css', cleanCss({ compatibility: '*' }))) - .pipe(_if('*.js', uglify())) + .pipe(_if('*.js', uglify({ mangle:false}))) .pipe(_if('*.html', htmlmin({ removeComments: true, collapseWhitespace: true