@dynatrace/groundhog
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -10,3 +10,3 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var toggleClass = 'is-expanded'; | ||
var toggleClass = 'is-active'; | ||
@@ -35,3 +35,3 @@ var init = function init() { | ||
var toggleClass = 'is-expanded'; | ||
var toggleClass = 'is-active'; | ||
@@ -107,5 +107,7 @@ var handleClick = function handleClick(ev) { | ||
el.addEventListener('click', function (ev) { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
(0, _dollar2.default)(el.dataset.target)[0].classList.toggle(toggleClass); | ||
if ((0, _dollar2.default)(el.dataset.target)[0]) { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
(0, _dollar2.default)(el.dataset.target)[0].classList.toggle(toggleClass); | ||
} | ||
}); | ||
@@ -115,3 +117,30 @@ }); | ||
},{"./dollar":4}],6:[function(require,module,exports){ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function debounce(callback, wait) { | ||
var context = arguments.length <= 2 || arguments[2] === undefined ? this : arguments[2]; | ||
var timeout = null; | ||
var callbackArgs = null; | ||
var later = function later() { | ||
return callback.apply(context, callbackArgs); | ||
}; | ||
return function db() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
callbackArgs = args; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
}; | ||
} | ||
exports.debounce = debounce; | ||
},{}],7:[function(require,module,exports){ | ||
require('./js-common-components/toggler'); | ||
@@ -123,4 +152,5 @@ require('./js-common-components/closest'); | ||
require('./table/table'); | ||
require('./navbar/navbar'); | ||
},{"./expandable/expandable":1,"./js-common-components/closest":3,"./js-common-components/toggler":5,"./slider/slider":7,"./table/table":8,"./tabs/tabs":9}],7:[function(require,module,exports){ | ||
},{"./expandable/expandable":1,"./js-common-components/closest":3,"./js-common-components/toggler":5,"./navbar/navbar":8,"./slider/slider":9,"./table/table":10,"./tabs/tabs":11}],8:[function(require,module,exports){ | ||
var _dollar = require('../js-common-components/dollar'); | ||
@@ -130,4 +160,80 @@ | ||
var _utils = require('../js-common-components/utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function clearResults(select) { | ||
var emptySearchResults = select; | ||
emptySearchResults.classList.remove('is-active'); | ||
while (select.firstChild) { | ||
select.removeChild(select.firstChild); | ||
} | ||
} | ||
function createListElement(result, opts) { | ||
var opt = document.createElement('li'); | ||
var link = document.createElement('a'); | ||
link.setAttribute('href', result[opts.url]); | ||
link.textContent = result[opts.title]; | ||
opt.appendChild(link); | ||
return opt; | ||
} | ||
function fetchResults(select, searchData, params, opts) { | ||
fetch(searchData + '?' + params).catch(function () { | ||
return '{ results: [] }'; | ||
}).then(function (res) { | ||
return res.json(); | ||
}).then(function (searchResults) { | ||
var results = searchResults[opts.resultskey]; | ||
if (!results) { | ||
return; | ||
} | ||
var trimmedresults = results.slice(0, opts.maxresults); | ||
var elements = trimmedresults.map(function (el) { | ||
return createListElement(el, opts); | ||
}); | ||
window.requestAnimationFrame(function () { | ||
clearResults(select); | ||
select.classList.add('expandable', 'is-active'); | ||
elements.forEach(function (el) { | ||
return select.appendChild(el); | ||
}); | ||
}); | ||
}); | ||
} | ||
var initData = function initData() { | ||
(0, _dollar2.default)('.js-search:not([action=""]').forEach(function (el) { | ||
var form = el.parentNode; | ||
var ul = form.appendChild(document.createElement('ul')); | ||
var searchData = form.action; | ||
ul.classList.add('search__results', 'expandable'); | ||
var opts = { | ||
title: form.dataset.titleprop || 'title', | ||
url: form.dataset.urlprop || 'url', | ||
maxresults: parseInt(form.dataset.maxresults, 10) || 10, | ||
resultskey: form.dataset.resultskey || 'results' | ||
}; | ||
el.addEventListener('keyup', (0, _utils.debounce)(function () { | ||
var params = (0, _dollar2.default)('input', form).map(function (input) { | ||
return input.name + '=' + input.value; | ||
}).join('&'); | ||
fetchResults(ul, searchData, params, opts); | ||
}, 150)); | ||
el.addEventListener('blur', function () { | ||
clearResults(ul); | ||
}); | ||
}); | ||
}; | ||
initData(); | ||
},{"../js-common-components/dollar":4,"../js-common-components/utils":6}],9:[function(require,module,exports){ | ||
var _dollar = require('../js-common-components/dollar'); | ||
var _dollar2 = _interopRequireDefault(_dollar); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function colorRangeInput() { | ||
@@ -153,3 +259,3 @@ this.min = this.min || 0; | ||
},{"../js-common-components/dollar":4}],8:[function(require,module,exports){ | ||
},{"../js-common-components/dollar":4}],10:[function(require,module,exports){ | ||
var _dollar = require('../js-common-components/dollar'); | ||
@@ -189,3 +295,3 @@ | ||
},{"../js-common-components/dollar":4}],9:[function(require,module,exports){ | ||
},{"../js-common-components/dollar":4}],11:[function(require,module,exports){ | ||
var _dollar = require('../js-common-components/dollar'); | ||
@@ -224,2 +330,2 @@ | ||
},{"../js-common-components/closest":3,"../js-common-components/dollar":4}]},{},[6]); | ||
},{"../js-common-components/closest":3,"../js-common-components/dollar":4}]},{},[7]); |
{ | ||
"name": "@dynatrace/groundhog", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "CSS components for Dynatrace", | ||
@@ -5,0 +5,0 @@ "main": "dist/js/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318697
241
5403
2