summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2017-01-21 04:24:00 +0000
committerJacob Schatz <jschatz@gitlab.com>2017-01-21 04:24:00 +0000
commitbb6f931bc39dc504661767b96436985dfb47d84e (patch)
treec3aca86db6b66ac7ceedd08548f9db57623597e6
parent611917eca06b3d7134dddaf3b1c6079b88b7fc5c (diff)
parentf19724de34cb1488e4b6e649a1914cc513657fa9 (diff)
downloadgitlab-ce-bb6f931bc39dc504661767b96436985dfb47d84e.tar.gz
Merge branch 'revert-611917ec' into 'master'
Revert "Merge branch '26785-fix-droplab-in-ie-11-v1' into 'master'" See merge request !8680
-rw-r--r--app/assets/javascripts/droplab/droplab.js49
-rw-r--r--app/assets/javascripts/extensions/custom_event.js.es611
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es65
-rw-r--r--changelogs/unreleased/26785-fix-droplab-in-ie-11-v1.yml4
4 files changed, 21 insertions, 48 deletions
diff --git a/app/assets/javascripts/droplab/droplab.js b/app/assets/javascripts/droplab/droplab.js
index c79f0230951..6c6d650db3a 100644
--- a/app/assets/javascripts/droplab/droplab.js
+++ b/app/assets/javascripts/droplab/droplab.js
@@ -62,7 +62,6 @@ var DropDown = function(list) {
this.list = list;
this.items = [];
this.getItems();
- this.initTemplateString();
this.addEvents();
this.initialState = list.innerHTML;
};
@@ -73,17 +72,6 @@ Object.assign(DropDown.prototype, {
return this.items;
},
- initTemplateString: function() {
- var items = this.items || this.getItems();
-
- var templateString = '';
- if(items.length > 0) {
- templateString = items[items.length - 1].outerHTML;
- }
- this.templateString = templateString;
- return this.templateString;
- },
-
clickEvent: function(e) {
// climb up the tree to find the LI
var selected = utils.closest(e.target, 'LI');
@@ -123,21 +111,30 @@ Object.assign(DropDown.prototype, {
addData: function(data) {
this.data = (this.data || []).concat(data);
- this.render(this.data);
+ this.render(data);
},
// call render manually on data;
render: function(data){
// debugger
// empty the list first
- var templateString = this.templateString;
+ var sampleItem;
var newChildren = [];
var toAppend;
- newChildren = (data ||[]).map(function(dat){
- var html = utils.t(templateString, dat);
+ for(var i = 0; i < this.items.length; i++) {
+ var item = this.items[i];
+ sampleItem = item;
+ if(item.parentNode && item.parentNode.dataset.hasOwnProperty('dynamic')) {
+ item.parentNode.removeChild(item);
+ }
+ }
+
+ newChildren = this.data.map(function(dat){
+ var html = utils.t(sampleItem.outerHTML, dat);
var template = document.createElement('div');
template.innerHTML = html;
+ // console.log(template.content)
// Help set the image src template
var imageTags = template.querySelectorAll('img[data-src]');
@@ -176,7 +173,10 @@ Object.assign(DropDown.prototype, {
},
destroy: function() {
- this.hide();
+ if (!this.hidden) {
+ this.hide();
+ }
+
this.list.removeEventListener('click', this.clickWrapper);
}
});
@@ -462,8 +462,6 @@ Object.assign(HookInput.prototype, {
var self = this;
this.mousedown = function mousedown(e) {
- if(self.hasRemovedEvents) return;
-
var mouseEvent = new CustomEvent('mousedown.dl', {
detail: {
hook: self,
@@ -476,8 +474,6 @@ Object.assign(HookInput.prototype, {
}
this.input = function input(e) {
- if(self.hasRemovedEvents) return;
-
var inputEvent = new CustomEvent('input.dl', {
detail: {
hook: self,
@@ -491,14 +487,10 @@ Object.assign(HookInput.prototype, {
}
this.keyup = function keyup(e) {
- if(self.hasRemovedEvents) return;
-
keyEvent(e, 'keyup.dl');
}
this.keydown = function keydown(e) {
- if(self.hasRemovedEvents) return;
-
keyEvent(e, 'keydown.dl');
}
@@ -528,8 +520,7 @@ Object.assign(HookInput.prototype, {
this.trigger.addEventListener('keydown', this.keydown);
},
- removeEvents: function() {
- this.hasRemovedEvents = true;
+ removeEvents: function(){
this.trigger.removeEventListener('mousedown', this.mousedown);
this.trigger.removeEventListener('input', this.input);
this.trigger.removeEventListener('keyup', this.keyup);
@@ -677,14 +668,14 @@ var camelize = function(str) {
};
var closest = function(thisTag, stopTag) {
- while(thisTag && thisTag.tagName !== stopTag && thisTag.tagName !== 'HTML'){
+ while(thisTag.tagName !== stopTag && thisTag.tagName !== 'HTML'){
thisTag = thisTag.parentNode;
}
return thisTag;
};
var isDropDownParts = function(target) {
- if(!target || target.tagName === 'HTML') { return false; }
+ if(target.tagName === 'HTML') { return false; }
return (
target.hasAttribute(DATA_TRIGGER) ||
target.hasAttribute(DATA_DROPDOWN)
diff --git a/app/assets/javascripts/extensions/custom_event.js.es6 b/app/assets/javascripts/extensions/custom_event.js.es6
deleted file mode 100644
index 7dfbe6c66e2..00000000000
--- a/app/assets/javascripts/extensions/custom_event.js.es6
+++ /dev/null
@@ -1,11 +0,0 @@
-/* global CustomEvent */
-
-// Custom event support for IE
-CustomEvent = function (event, parameters) {
- const params = parameters || { bubbles: false, cancelable: false, detail: undefined };
- const evt = document.createEvent('CustomEvent');
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
- return evt;
-};
-
-CustomEvent.prototype = window.Event.prototype;
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
index 9128ea907b3..886d8113f4a 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
@@ -78,10 +78,7 @@
dispatchInputEvent() {
// Propogate input change to FilteredSearchDropdownManager
// so that it can determine which dropdowns to open
- this.input.dispatchEvent(new CustomEvent('input', {
- bubbles: true,
- cancelable: true,
- }));
+ this.input.dispatchEvent(new Event('input'));
}
hideDropdown() {
diff --git a/changelogs/unreleased/26785-fix-droplab-in-ie-11-v1.yml b/changelogs/unreleased/26785-fix-droplab-in-ie-11-v1.yml
deleted file mode 100644
index 76e9b19b828..00000000000
--- a/changelogs/unreleased/26785-fix-droplab-in-ie-11-v1.yml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: Add some basic fixes for IE11/Edge
-merge_request:
-author: