_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q15100
|
train
|
function(val) {
return new Color(
val ? val : null,
this.options.colorSelectors,
this.options.fallbackColor ? this.options.fallbackColor : this.color,
this.options.fallbackFormat,
this.options.hexNumberSignPrefix
);
}
|
javascript
|
{
"resource": ""
}
|
|
q15101
|
train
|
function (el, x, y) {
var currentRegion = this.currentRegion,
highlightEnabled = !this.options.get('disableHighlight'),
newRegion;
if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) {
return null;
}
newRegion = this.getRegion(el, x, y);
if (currentRegion !== newRegion) {
if (currentRegion !== undefined && highlightEnabled) {
this.removeHighlight();
}
this.currentRegion = newRegion;
if (newRegion !== undefined && highlightEnabled) {
this.renderHighlight();
}
return true;
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15102
|
train
|
function(){
this.width = this.container.width();
this.height = this.container.height();
this.resize();
this.canvas.setSize(this.width, this.height);
this.applyTransform();
}
|
javascript
|
{
"resource": ""
}
|
|
q15103
|
train
|
function() {
var key,
i;
for (key in this.series) {
for (i = 0; i < this.series[key].length; i++) {
this.series[key][i].clear();
}
}
this.scale = this.baseScale;
this.transX = this.baseTransX;
this.transY = this.baseTransY;
this.applyTransform();
}
|
javascript
|
{
"resource": ""
}
|
|
q15104
|
train
|
function(key, marker, seriesData){
var markers = {},
data = [],
values,
i,
seriesData = seriesData || [];
markers[key] = marker;
for (i = 0; i < seriesData.length; i++) {
values = {};
values[key] = seriesData[i];
data.push(values);
}
this.addMarkers(markers, data);
}
|
javascript
|
{
"resource": ""
}
|
|
q15105
|
train
|
function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
}
|
javascript
|
{
"resource": ""
}
|
|
q15106
|
train
|
function(markers){
var i;
for (i = 0; i < markers.length; i++) {
this.markers[ markers[i] ].element.remove();
delete this.markers[ markers[i] ];
};
}
|
javascript
|
{
"resource": ""
}
|
|
q15107
|
train
|
function(lat, lng) {
var point,
proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
width = this.width - this.baseTransX * 2 * this.baseScale,
height = this.height - this.baseTransY * 2 * this.baseScale,
inset,
bbox,
scaleFactor = this.scale / this.baseScale;
if (lng < (-180 + centralMeridian)) {
lng += 360;
}
point = jvm.Proj[proj.type](lat, lng, centralMeridian);
inset = this.getInsetForPoint(point.x, point.y);
if (inset) {
bbox = inset.bbox;
point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
return {
x: point.x + this.transX*this.scale + inset.left*this.scale,
y: point.y + this.transY*this.scale + inset.top*this.scale
};
} else {
return false;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15108
|
train
|
function(x, y) {
var proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
insets = jvm.WorldMap.maps[this.params.map].insets,
i,
inset,
bbox,
nx,
ny;
for (i = 0; i < insets.length; i++) {
inset = insets[i];
bbox = inset.bbox;
nx = x - (this.transX*this.scale + inset.left*this.scale);
ny = y - (this.transY*this.scale + inset.top*this.scale);
nx = (nx / (inset.width * this.scale)) * (bbox[1].x - bbox[0].x) + bbox[0].x;
ny = (ny / (inset.height * this.scale)) * (bbox[1].y - bbox[0].y) + bbox[0].y;
if (nx > bbox[0].x && nx < bbox[1].x && ny > bbox[0].y && ny < bbox[1].y) {
return jvm.Proj[proj.type + '_inv'](nx, -ny, centralMeridian);
}
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15109
|
train
|
function (chrs, buffer, pos, strict, opts) {
var isValid = opts.regex.val1.test(chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val1.test("0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
}
|
javascript
|
{
"resource": ""
}
|
|
q15110
|
train
|
function (is_update) {
this.no_diapason = false;
this.coords.p_step = this.convertToPercent(this.options.step, true);
this.target = "base";
this.toggleInput();
this.append();
this.setMinMax();
if (is_update) {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnUpdate();
} else {
this.force_redraw = true;
this.calc(true);
// callbacks called
this.callOnStart();
}
this.updateScene();
}
|
javascript
|
{
"resource": ""
}
|
|
q15111
|
train
|
function () {
var min = this.options.min,
max = this.options.max,
from = this.options.from,
to = this.options.to;
if (from > min && to === max) {
this.$cache.s_from.addClass("type_last");
} else if (to < max) {
this.$cache.s_to.addClass("type_last");
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15112
|
train
|
function (e) {
if (!this.target) {
var x;
var $handle;
if (this.options.type === "single") {
$handle = this.$cache.single;
} else {
$handle = this.$cache.from;
}
x = $handle.offset().left;
x += ($handle.width() / 2) - 1;
this.pointerClick("single", {preventDefault: function () {}, pageX: x});
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15113
|
train
|
function (e) {
if (!this.dragging) {
return;
}
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
this.coords.x_pointer = x - this.coords.x_gap;
this.calc();
}
|
javascript
|
{
"resource": ""
}
|
|
q15114
|
train
|
function (e) {
if (this.current_plugin !== this.plugin_count) {
return;
}
if (this.is_active) {
this.is_active = false;
} else {
return;
}
this.$cache.cont.find(".state_hover").removeClass("state_hover");
this.force_redraw = true;
if (is_old_ie) {
$("*").prop("unselectable", false);
}
this.updateScene();
this.restoreOriginalMinInterval();
// callbacks call
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
this.callOnFinish();
}
this.dragging = false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15115
|
train
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
if (target === "both") {
this.setTempMinInterval();
}
if (!target) {
target = this.target || "from";
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_active = true;
this.dragging = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = x - this.coords.x_gap;
this.calcPointerPercent();
this.changeLevel(target);
if (is_old_ie) {
$("*").prop("unselectable", true);
}
this.$cache.line.trigger("focus");
this.updateScene();
}
|
javascript
|
{
"resource": ""
}
|
|
q15116
|
train
|
function (target, e) {
e.preventDefault();
var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX;
if (e.button === 2) {
return;
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_click = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
this.force_redraw = true;
this.calc();
this.$cache.line.trigger("focus");
}
|
javascript
|
{
"resource": ""
}
|
|
q15117
|
train
|
function (target, e) {
if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
return;
}
switch (e.which) {
case 83: // W
case 65: // A
case 40: // DOWN
case 37: // LEFT
e.preventDefault();
this.moveByKey(false);
break;
case 87: // S
case 68: // D
case 38: // UP
case 39: // RIGHT
e.preventDefault();
this.moveByKey(true);
break;
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q15118
|
train
|
function (right) {
var p = this.coords.p_pointer;
var p_step = (this.options.max - this.options.min) / 100;
p_step = this.options.step / p_step;
if (right) {
p += p_step;
} else {
p -= p_step;
}
this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p);
this.is_key = true;
this.calc();
}
|
javascript
|
{
"resource": ""
}
|
|
q15119
|
train
|
function () {
var interval = this.result.to - this.result.from;
if (this.old_min_interval === null) {
this.old_min_interval = this.options.min_interval;
}
this.options.min_interval = interval;
}
|
javascript
|
{
"resource": ""
}
|
|
q15120
|
train
|
function () {
if (!this.coords.w_rs) {
this.coords.p_pointer = 0;
return;
}
if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) {
this.coords.x_pointer = 0;
} else if (this.coords.x_pointer > this.coords.w_rs) {
this.coords.x_pointer = this.coords.w_rs;
}
this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100);
}
|
javascript
|
{
"resource": ""
}
|
|
q15121
|
train
|
function (real_x) {
if (this.options.type === "single") {
return "single";
} else {
var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2);
if (real_x >= m_point) {
return this.options.to_fixed ? "from" : "to";
} else {
return this.options.from_fixed ? "to" : "from";
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15122
|
train
|
function () {
if (!this.coords.w_rs) {
return;
}
this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;
this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;
}
|
javascript
|
{
"resource": ""
}
|
|
q15123
|
train
|
function () {
if (!this.coords.w_rs || this.options.hide_from_to) {
return;
}
if (this.options.type === "single") {
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
} else {
this.labels.w_from = this.$cache.from.outerWidth(false);
this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100;
this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2);
this.labels.p_from_left = this.toFixed(this.labels.p_from_left);
this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake);
this.labels.w_to = this.$cache.to.outerWidth(false);
this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100;
this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2);
this.labels.p_to_left = this.toFixed(this.labels.p_to_left);
this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake);
this.labels.w_single = this.$cache.single.outerWidth(false);
this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100;
this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2);
this.labels.p_single_left = this.toFixed(this.labels.p_single_left);
this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15124
|
train
|
function () {
if (this.options.type === "single") {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value);
} else {
this.$cache.input.prop("value", this.result.from);
}
this.$cache.input.data("from", this.result.from);
} else {
if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value);
} else {
this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to);
}
this.$cache.input.data("from", this.result.from);
this.$cache.input.data("to", this.result.to);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15125
|
train
|
function (value, no_min) {
var diapason = this.options.max - this.options.min,
one_percent = diapason / 100,
val, percent;
if (!diapason) {
this.no_diapason = true;
return 0;
}
if (no_min) {
val = value;
} else {
val = value - this.options.min;
}
percent = val / one_percent;
return this.toFixed(percent);
}
|
javascript
|
{
"resource": ""
}
|
|
q15126
|
train
|
function (percent) {
var min = this.options.min,
max = this.options.max,
min_decimals = min.toString().split(".")[1],
max_decimals = max.toString().split(".")[1],
min_length, max_length,
avg_decimals = 0,
abs = 0;
if (percent === 0) {
return this.options.min;
}
if (percent === 100) {
return this.options.max;
}
if (min_decimals) {
min_length = min_decimals.length;
avg_decimals = min_length;
}
if (max_decimals) {
max_length = max_decimals.length;
avg_decimals = max_length;
}
if (min_length && max_length) {
avg_decimals = (min_length >= max_length) ? min_length : max_length;
}
if (min < 0) {
abs = Math.abs(min);
min = +(min + abs).toFixed(avg_decimals);
max = +(max + abs).toFixed(avg_decimals);
}
var number = ((max - min) / 100 * percent) + min,
string = this.options.step.toString().split(".")[1],
result;
if (string) {
number = +number.toFixed(string.length);
} else {
number = number / this.options.step;
number = number * this.options.step;
number = +number.toFixed(0);
}
if (abs) {
number -= abs;
}
if (string) {
result = +number.toFixed(string.length);
} else {
result = this.toFixed(number);
}
if (result < this.options.min) {
result = this.options.min;
} else if (result > this.options.max) {
result = this.options.max;
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
|
q15127
|
train
|
function (percent) {
var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step;
if (rounded > 100) {
rounded = 100;
}
if (percent === 100) {
rounded = 100;
}
return this.toFixed(rounded);
}
|
javascript
|
{
"resource": ""
}
|
|
q15128
|
train
|
function (segment, step) {
if (segment % step === 0) {
return segment;
}
if (Math.round((segment % step) / step)) {
return (segment + (step - segment % step)) % 60;
} else {
return segment - segment % step;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15129
|
train
|
function() {
if (this.isInline) {
return;
}
var widgetWidth = this.$widget.outerWidth(), widgetHeight = this.$widget.outerHeight(), visualPadding = 10, windowWidth =
$(window).width(), windowHeight = $(window).height(), scrollTop = $(window).scrollTop();
var zIndex = parseInt(this.$element.parents().filter(function() { return $(this).css('z-index') !== 'auto'; }).first().css('z-index'), 10) + 10;
var offset = this.component ? this.component.parent().offset() : this.$element.offset();
var height = this.component ? this.component.outerHeight(true) : this.$element.outerHeight(false);
var width = this.component ? this.component.outerWidth(true) : this.$element.outerWidth(false);
var left = offset.left, top = offset.top;
this.$widget.removeClass('timepicker-orient-top timepicker-orient-bottom timepicker-orient-right timepicker-orient-left');
if (this.orientation.x !== 'auto') {
this.$widget.addClass('timepicker-orient-' + this.orientation.x);
if (this.orientation.x === 'right') {
left -= widgetWidth - width;
}
} else{
// auto x orientation is best-placement: if it crosses a window edge, fudge it sideways
// Default to left
this.$widget.addClass('timepicker-orient-left');
if (offset.left < 0) {
left -= offset.left - visualPadding;
} else if (offset.left + widgetWidth > windowWidth) {
left = windowWidth - widgetWidth - visualPadding;
}
}
// auto y orientation is best-situation: top or bottom, no fudging, decision based on which shows more of the widget
var yorient = this.orientation.y, topOverflow, bottomOverflow;
if (yorient === 'auto') {
topOverflow = -scrollTop + offset.top - widgetHeight;
bottomOverflow = scrollTop + windowHeight - (offset.top + height + widgetHeight);
if (Math.max(topOverflow, bottomOverflow) === bottomOverflow) {
yorient = 'top';
} else {
yorient = 'bottom';
}
}
this.$widget.addClass('timepicker-orient-' + yorient);
if (yorient === 'top'){
top += height;
} else{
top -= widgetHeight + parseInt(this.$widget.css('padding-top'), 10);
}
this.$widget.css({
top : top,
left : left,
zIndex : zIndex
});
}
|
javascript
|
{
"resource": ""
}
|
|
q15130
|
train
|
function(element,dimension)
{
if (element['offset'+dimension])
{
return element['offset'+dimension];
}
else
{
return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15131
|
train
|
function(){
// First we need the width of the yLabels, assuming the xLabels aren't rotated
// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
this.startPoint = (this.display) ? this.fontSize : 0;
this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
// Apply padding settings to the start and end point.
this.startPoint += this.padding;
this.endPoint -= this.padding;
// Cache the starting height, so can determine if we need to recalculate the scale yAxis
var cachedHeight = this.endPoint - this.startPoint,
cachedYLabelWidth;
// Build the current yLabels so we have an idea of what size they'll be to start
/*
* This sets what is returned from calculateScaleRange as static properties of this class:
*
this.steps;
this.stepValue;
this.min;
this.max;
*
*/
this.calculateYRange(cachedHeight);
// With these properties set we can now build the array of yLabels
// and also the width of the largest yLabel
this.buildYLabels();
this.calculateXLabelRotation();
while((cachedHeight > this.endPoint - this.startPoint)){
cachedHeight = this.endPoint - this.startPoint;
cachedYLabelWidth = this.yLabelWidth;
this.calculateYRange(cachedHeight);
this.buildYLabels();
// Only go through the xLabel loop again if the yLabel width has changed
if (cachedYLabelWidth < this.yLabelWidth){
this.calculateXLabelRotation();
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15132
|
train
|
function (width, height, canvas) {
// XXX This should probably be a configurable option
var match;
match = this._pxregex.exec(height);
if (match) {
this.pixelHeight = match[1];
} else {
this.pixelHeight = $(canvas).height();
}
match = this._pxregex.exec(width);
if (match) {
this.pixelWidth = match[1];
} else {
this.pixelWidth = $(canvas).width();
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15133
|
train
|
function (shapetype, shapeargs) {
var id = shapeCount++;
shapeargs.unshift(id);
return new VShape(this, id, shapetype, shapeargs);
}
|
javascript
|
{
"resource": ""
}
|
|
q15134
|
substituteTimeAgo
|
train
|
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
|
javascript
|
{
"resource": ""
}
|
q15135
|
finalPropName
|
train
|
function finalPropName( name ) {
var ret = jQuery.cssProps[ name ];
if ( !ret ) {
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
q15136
|
init
|
train
|
function init (doc) {
if (status === 'ready') return
const taroStyle = doc.createElement('style')
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}'
doc.querySelector('head').appendChild(taroStyle)
status = 'ready'
}
|
javascript
|
{
"resource": ""
}
|
q15137
|
listCacheDelete
|
train
|
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
}
|
javascript
|
{
"resource": ""
}
|
q15138
|
getWebpackSizes
|
train
|
async function getWebpackSizes() {
await fse.mkdirp(path.join(__dirname, 'build'));
const configPath = path.join(__dirname, 'webpack.config.js');
const statsPath = path.join(__dirname, 'build', 'stats.json');
await exec(`webpack --config ${configPath} --json > ${statsPath}`);
const stats = await fse.readJSON(statsPath);
const assets = new Map(stats.assets.map(asset => [asset.name, asset]));
return Object.entries(stats.assetsByChunkName).map(([chunkName, assetName]) => {
const parsedSize = assets.get(assetName).size;
const gzipSize = assets.get(`${assetName}.gz`).size;
return [chunkName, { parsed: parsedSize, gzip: gzipSize }];
});
}
|
javascript
|
{
"resource": ""
}
|
q15139
|
Hidden
|
train
|
function Hidden(props) {
const { implementation, ...other } = props;
if (implementation === 'js') {
return <HiddenJs {...other} />;
}
return <HiddenCss {...other} />;
}
|
javascript
|
{
"resource": ""
}
|
q15140
|
transformSVGIconImports
|
train
|
function transformSVGIconImports(j, root) {
const pathMatchRegex = /^material-ui\/svg-icons\/.+\/(.+)$/;
root
.find(j.Literal)
.filter(path => pathMatchRegex.test(path.node.value))
.forEach(path => {
const [, iconName] = path.node.value.match(pathMatchRegex);
// update to new path
path.node.value = `@material-ui/icons/${pascalize(iconName)}`;
});
}
|
javascript
|
{
"resource": ""
}
|
q15141
|
run
|
train
|
async function run() {
console.log(`\u{1f52c} Searching for modules inside "${chalk.dim(SRC_DIR)}".`);
const files = glob.sync('!(index)*.js', { cwd: SRC_DIR });
const typings = files.map(file => createIconTyping(file));
await Promise.all([...typings, createIndexTyping(files)]);
console.log(`\u{1F5C4} Written typings to ${chalk.dim(TARGET_DIR)}.`);
}
|
javascript
|
{
"resource": ""
}
|
q15142
|
createData
|
train
|
function createData(id, date, name, shipTo, paymentMethod, amount) {
return { id, date, name, shipTo, paymentMethod, amount };
}
|
javascript
|
{
"resource": ""
}
|
q15143
|
git
|
train
|
function git(args) {
return new Promise((resolve, reject) => {
exec(`git ${args}`, (err, stdout) => {
if (err) {
reject(err);
} else {
resolve(stdout.trim());
}
});
});
}
|
javascript
|
{
"resource": ""
}
|
q15144
|
addPercent
|
train
|
function addPercent(change, goodEmoji = '', badEmooji = ':small_red_triangle:') {
const formatted = (change * 100).toFixed(2);
if (/^-|^0(?:\.0+)$/.test(formatted)) {
return `${formatted}% ${goodEmoji}`;
}
return `+${formatted}% ${badEmooji}`;
}
|
javascript
|
{
"resource": ""
}
|
q15145
|
generateMDTable
|
train
|
function generateMDTable(headers, body) {
const headerRow = headers.map(header => header.label);
const alignmentRow = headers.map(header => {
if (header.align === 'right') {
return ' ---:';
}
if (header.align === 'center') {
return ':---:';
}
return ' --- ';
});
return [headerRow, alignmentRow, ...body].map(row => row.join(' | ')).join('\n');
}
|
javascript
|
{
"resource": ""
}
|
q15146
|
findComponents
|
train
|
function findComponents(directory, components = []) {
const items = fs.readdirSync(directory);
items.forEach(item => {
const itemPath = path.resolve(directory, item);
if (fs.statSync(itemPath).isDirectory()) {
findComponents(itemPath, components);
return;
}
if (!componentRegex.test(item)) {
return;
}
components.push({
filename: itemPath,
});
});
return components;
}
|
javascript
|
{
"resource": ""
}
|
q15147
|
findPages
|
train
|
function findPages(
options = {},
directory = path.resolve(__dirname, '../../../../pages'),
pages = [],
) {
fs.readdirSync(directory).forEach(item => {
const itemPath = path.resolve(directory, item);
const pathname = itemPath
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
.replace(/^.*\/pages/, '')
.replace('.js', '')
.replace(/^\/index$/, '/') // Replace `index` by `/`.
.replace(/\/index$/, '');
if (pathname.indexOf('.eslintrc') !== -1) {
return;
}
if (
options.front &&
pathname.indexOf('/components') === -1 &&
pathname.indexOf('/api') === -1
) {
return;
}
if (fs.statSync(itemPath).isDirectory()) {
const children = [];
pages.push({
pathname,
children,
});
findPages(options, itemPath, children);
return;
}
if (!jsRegex.test(item) || blackList.includes(pathname)) {
return;
}
pages.push({
pathname,
});
});
// sort by pathnames without '-' so that e.g. card comes before card-action
pages.sort((a, b) => {
const pathnameA = a.pathname.replace(/-/g, '');
const pathnameB = b.pathname.replace(/-/g, '');
if (pathnameA < pathnameB) return -1;
if (pathnameA > pathnameB) return 1;
return 0;
});
return pages;
}
|
javascript
|
{
"resource": ""
}
|
q15148
|
valueReducer
|
train
|
function valueReducer(rawValue, props, event) {
const { disabled, max, min, step } = props;
function roundToStep(number) {
return Math.round(number / step) * step;
}
if (!disabled && step) {
if (rawValue > min && rawValue < max) {
if (rawValue === max - step) {
// If moving the Slider using arrow keys and value is formerly an maximum edge value
return roundToStep(rawValue + step / 2);
}
if (rawValue === min + step) {
// Same for minimum edge value
return roundToStep(rawValue - step / 2);
}
return roundToStep(rawValue);
}
return rawValue;
}
return defaultValueReducer(rawValue, props, event);
}
|
javascript
|
{
"resource": ""
}
|
q15149
|
jssPreset
|
train
|
function jssPreset() {
return {
plugins: [
functions(),
global(),
nested(),
camelCase(),
defaultUnit(),
// Disable the vendor prefixer server-side, it does nothing.
// This way, we can get a performance boost.
// In the documentation, we are using `autoprefixer` to solve this problem.
typeof window === 'undefined' ? null : vendorPrefixer(),
propsSort(),
],
};
}
|
javascript
|
{
"resource": ""
}
|
q15150
|
ClickAwayListener
|
train
|
function ClickAwayListener(props) {
const { children, mouseEvent = 'onMouseUp', touchEvent = 'onTouchEnd', onClickAway } = props;
const mountedRef = useMountedRef();
const movedRef = React.useRef(false);
const nodeRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
const handleOwnRef = React.useCallback(instance => {
// #StrictMode ready
nodeRef.current = ReactDOM.findDOMNode(instance);
}, []);
const handleRef = useForkRef(children.ref, handleOwnRef);
const handleClickAway = React.useCallback(
event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE 11 support, which trigger the handleClickAway even after the unbind
if (!mountedRef.current) {
return;
}
// Do not act if user performed touchmove
if (movedRef.current) {
movedRef.current = false;
return;
}
const { current: node } = nodeRef;
// The child might render null.
if (!node) {
return;
}
const doc = ownerDocument(node);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!node.contains(event.target)
) {
onClickAway(event);
}
},
[mountedRef, onClickAway],
);
const handleTouchMove = React.useCallback(() => {
movedRef.current = true;
}, []);
const listenerProps = {};
if (mouseEvent !== false) {
listenerProps[mouseEvent] = handleClickAway;
}
if (touchEvent !== false) {
listenerProps[touchEvent] = handleClickAway;
listenerProps.onTouchMove = handleTouchMove;
}
return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef })}
<EventListener target="document" {...listenerProps} />
</React.Fragment>
);
}
|
javascript
|
{
"resource": ""
}
|
q15151
|
sortFactory
|
train
|
function sortFactory(key) {
return function sortNumeric(a, b) {
if (b[key] < a[key]) {
return -1;
}
if (b[key] > a[key]) {
return 1;
}
return 0;
};
}
|
javascript
|
{
"resource": ""
}
|
q15152
|
EmotionCSS
|
train
|
function EmotionCSS() {
return (
<div>
<Button>Material-UI</Button>
<Button
css={css`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
`}
>
Emotion
</Button>
</div>
);
}
|
javascript
|
{
"resource": ""
}
|
q15153
|
getComponentName
|
train
|
function getComponentName(destPath) {
const splitregex = new RegExp(`[\\${path.sep}-]+`);
const parts = destPath
.replace('.js', '')
.split(splitregex)
.map(part => part.charAt(0).toUpperCase() + part.substring(1));
return parts.join('');
}
|
javascript
|
{
"resource": ""
}
|
q15154
|
CssBaseline
|
train
|
function CssBaseline(props) {
const { children = null } = props;
useStyles();
return <React.Fragment>{children}</React.Fragment>;
}
|
javascript
|
{
"resource": ""
}
|
q15155
|
mergeOuterLocalTheme
|
train
|
function mergeOuterLocalTheme(outerTheme, localTheme) {
if (typeof localTheme === 'function') {
const mergedTheme = localTheme(outerTheme);
warning(
mergedTheme,
[
'Material-UI: you should return an object from your theme function, i.e.',
'<ThemeProvider theme={() => ({})} />',
].join('\n'),
);
return mergedTheme;
}
return { ...outerTheme, ...localTheme };
}
|
javascript
|
{
"resource": ""
}
|
q15156
|
getScrollParent
|
train
|
function getScrollParent(parent, child) {
let element = child;
let scrollTop = 0;
while (element && element !== parent) {
element = element.parentNode;
scrollTop += element.scrollTop;
}
return scrollTop;
}
|
javascript
|
{
"resource": ""
}
|
q15157
|
emptyDir
|
train
|
function emptyDir(dir) {
return new Promise((resolve, reject) => {
FS.emptyDir(dir, err => {
err ? reject(err) : resolve(dir);
})
});
}
|
javascript
|
{
"resource": ""
}
|
q15158
|
train
|
function (approxTickNum) {
approxTickNum = approxTickNum || 10;
var extent = this._extent;
var span = extent[1] - extent[0];
if (span === Infinity || span <= 0) {
return;
}
var interval = numberUtil.quantity(span);
var err = approxTickNum / span * interval;
// Filter ticks to get closer to the desired count.
if (err <= 0.5) {
interval *= 10;
}
// Interval should be integer
while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
interval *= 10;
}
var niceExtent = [
numberUtil.round(mathCeil(extent[0] / interval) * interval),
numberUtil.round(mathFloor(extent[1] / interval) * interval)
];
this._interval = interval;
this._niceExtent = niceExtent;
}
|
javascript
|
{
"resource": ""
}
|
|
q15159
|
train
|
function (opt) {
intervalScaleProto.niceExtent.call(this, opt);
var originalScale = this._originalScale;
originalScale.__fixMin = opt.fixMin;
originalScale.__fixMax = opt.fixMax;
}
|
javascript
|
{
"resource": ""
}
|
|
q15160
|
train
|
function (depth) {
var height = 0;
this.depth = depth;
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
child.updateDepthAndHeight(depth + 1);
if (child.height > height) {
height = child.height;
}
}
this.height = height + 1;
}
|
javascript
|
{
"resource": ""
}
|
|
q15161
|
train
|
function (node) {
var parent = node.parentNode;
while (parent) {
if (parent === this) {
return true;
}
parent = parent.parentNode;
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15162
|
train
|
function () {
var data = this.data;
var nodes = this._nodes;
for (var i = 0, len = nodes.length; i < len; i++) {
nodes[i].dataIndex = -1;
}
for (var i = 0, len = data.count(); i < len; i++) {
nodes[data.getRawIndex(i)].dataIndex = i;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15163
|
addChild
|
train
|
function addChild(child, node) {
var children = node.children;
if (child.parentNode === node) {
return;
}
children.push(child);
child.parentNode = node;
}
|
javascript
|
{
"resource": ""
}
|
q15164
|
ExtensionAPI
|
train
|
function ExtensionAPI(chartInstance) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(chartInstance[name], chartInstance);
}, this);
}
|
javascript
|
{
"resource": ""
}
|
q15165
|
groupSeriesByAxis
|
train
|
function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
});
return result;
}
|
javascript
|
{
"resource": ""
}
|
q15166
|
calculateBase
|
train
|
function calculateBase(groupItem) {
var extent;
var baseAxis = groupItem.axis;
var seriesModels = groupItem.seriesModels;
var seriesCount = seriesModels.length;
var boxWidthList = groupItem.boxWidthList = [];
var boxOffsetList = groupItem.boxOffsetList = [];
var boundList = [];
var bandWidth;
if (baseAxis.type === 'category') {
bandWidth = baseAxis.getBandWidth();
}
else {
var maxDataCount = 0;
each(seriesModels, function (seriesModel) {
maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
});
extent = baseAxis.getExtent(),
Math.abs(extent[1] - extent[0]) / maxDataCount;
}
each(seriesModels, function (seriesModel) {
var boxWidthBound = seriesModel.get('boxWidth');
if (!zrUtil.isArray(boxWidthBound)) {
boxWidthBound = [boxWidthBound, boxWidthBound];
}
boundList.push([
parsePercent(boxWidthBound[0], bandWidth) || 0,
parsePercent(boxWidthBound[1], bandWidth) || 0
]);
});
var availableWidth = bandWidth * 0.8 - 2;
var boxGap = availableWidth / seriesCount * 0.3;
var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
var base = boxWidth / 2 - availableWidth / 2;
each(seriesModels, function (seriesModel, idx) {
boxOffsetList.push(base);
base += boxGap + boxWidth;
boxWidthList.push(
Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
);
});
}
|
javascript
|
{
"resource": ""
}
|
q15167
|
layoutSingleSeries
|
train
|
function layoutSingleSeries(seriesModel, offset, boxWidth) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var halfWidth = boxWidth / 2;
var cDimIdx = seriesModel.get('layout') === 'horizontal' ? 0 : 1;
var vDimIdx = 1 - cDimIdx;
var coordDims = ['x', 'y'];
var cDim = data.mapDimension(coordDims[cDimIdx]);
var vDims = data.mapDimension(coordDims[vDimIdx], true);
if (cDim == null || vDims.length < 5) {
return;
}
for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
var axisDimVal = data.get(cDim, dataIndex);
var median = getPoint(axisDimVal, vDims[2], dataIndex);
var end1 = getPoint(axisDimVal, vDims[0], dataIndex);
var end2 = getPoint(axisDimVal, vDims[1], dataIndex);
var end4 = getPoint(axisDimVal, vDims[3], dataIndex);
var end5 = getPoint(axisDimVal, vDims[4], dataIndex);
var ends = [];
addBodyEnd(ends, end2, 0);
addBodyEnd(ends, end4, 1);
ends.push(end1, end2, end5, end4);
layEndLine(ends, end1);
layEndLine(ends, end5);
layEndLine(ends, median);
data.setItemLayout(dataIndex, {
initBaseline: median[vDimIdx],
ends: ends
});
}
function getPoint(axisDimVal, dimIdx, dataIndex) {
var val = data.get(dimIdx, dataIndex);
var p = [];
p[cDimIdx] = axisDimVal;
p[vDimIdx] = val;
var point;
if (isNaN(axisDimVal) || isNaN(val)) {
point = [NaN, NaN];
}
else {
point = coordSys.dataToPoint(p);
point[cDimIdx] += offset;
}
return point;
}
function addBodyEnd(ends, point, start) {
var point1 = point.slice();
var point2 = point.slice();
point1[cDimIdx] += halfWidth;
point2[cDimIdx] -= halfWidth;
start
? ends.push(point1, point2)
: ends.push(point2, point1);
}
function layEndLine(ends, endCenter) {
var from = endCenter.slice();
var to = endCenter.slice();
from[cDimIdx] -= halfWidth;
to[cDimIdx] += halfWidth;
ends.push(from, to);
}
}
|
javascript
|
{
"resource": ""
}
|
q15168
|
confineInContainer
|
train
|
function confineInContainer(position, width, height, api) {
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
position[0] = Math.min(position[0] + width, viewWidth) - width;
position[1] = Math.min(position[1] + height, viewHeight) - height;
position[0] = Math.max(position[0], 0);
position[1] = Math.max(position[1], 0);
}
|
javascript
|
{
"resource": ""
}
|
q15169
|
markerTypeCalculatorWithExtent
|
train
|
function markerTypeCalculatorWithExtent(
mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim /*, otherDataDim*/);
var calcDataDim = stacked
? data.getCalculationInfo('stackResultDimension')
: targetDataDim;
var value = numCalculate(data, calcDataDim, mlType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
// Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return coordArr;
}
|
javascript
|
{
"resource": ""
}
|
q15170
|
train
|
function (option, ecModel) {
var layoutMode = this.layoutMode;
var inputPositionParams = layoutMode
? getLayoutParams(option) : {};
// Backward compat: using subType on theme.
// But if name duplicate between series subType
// (for example: parallel) add component mainType,
// add suffix 'Series'.
var themeSubType = this.subType;
if (ComponentModel.hasClass(themeSubType)) {
themeSubType += 'Series';
}
zrUtil.merge(
option,
ecModel.getTheme().get(this.subType)
);
zrUtil.merge(option, this.getDefaultOption());
// Default label emphasis `show`
modelUtil.defaultEmphasis(option, 'label', ['show']);
this.fillDataTextStyle(option.data);
if (layoutMode) {
mergeLayoutParam(option, inputPositionParams, layoutMode);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15171
|
autoSeriesName
|
train
|
function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var name = seriesModel.name;
if (!modelUtil.isNameSpecified(seriesModel)) {
seriesModel.name = getSeriesAutoName(seriesModel) || name;
}
}
|
javascript
|
{
"resource": ""
}
|
q15172
|
getLineWidth
|
train
|
function getLineWidth(itemModel, rawLayout) {
var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
|
javascript
|
{
"resource": ""
}
|
q15173
|
resizeGeo
|
train
|
function resizeGeo(geoModel, api) {
var boundingCoords = geoModel.get('boundingCoords');
if (boundingCoords != null) {
var leftTop = boundingCoords[0];
var rightBottom = boundingCoords[1];
if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
if (__DEV__) {
console.error('Invalid boundingCoords');
}
}
else {
this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
}
}
var rect = this.getBoundingRect();
var boxLayoutOption;
var center = geoModel.get('layoutCenter');
var size = geoModel.get('layoutSize');
var viewWidth = api.getWidth();
var viewHeight = api.getHeight();
var aspect = rect.width / rect.height * this.aspectScale;
var useCenterAndSize = false;
if (center && size) {
center = [
numberUtil.parsePercent(center[0], viewWidth),
numberUtil.parsePercent(center[1], viewHeight)
];
size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
useCenterAndSize = true;
}
else {
if (__DEV__) {
console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
}
}
}
var viewRect;
if (useCenterAndSize) {
var viewRect = {};
if (aspect > 1) {
// Width is same with size
viewRect.width = size;
viewRect.height = size / aspect;
}
else {
viewRect.height = size;
viewRect.width = size * aspect;
}
viewRect.y = center[1] - viewRect.height / 2;
viewRect.x = center[0] - viewRect.width / 2;
}
else {
// Use left/top/width/height
boxLayoutOption = geoModel.getBoxLayoutParams();
// 0.75 rate
boxLayoutOption.aspect = aspect;
viewRect = layout.getLayoutRect(boxLayoutOption, {
width: viewWidth,
height: viewHeight
});
}
this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
this.setCenter(geoModel.get('center'));
this.setZoom(geoModel.get('zoom'));
}
|
javascript
|
{
"resource": ""
}
|
q15174
|
train
|
function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({name: name});
});
return regionsArr;
}
|
javascript
|
{
"resource": ""
}
|
|
q15175
|
createGridClipShape
|
train
|
function createGridClipShape(rect, seriesModel, cb) {
var rectEl = new graphic.Rect({
shape: {
x: rect.x - 10,
y: rect.y - 10,
width: 0,
height: rect.height + 20
}
});
graphic.initProps(rectEl, {
shape: {
width: rect.width + 20,
height: rect.height + 20
}
}, seriesModel, cb);
return rectEl;
}
|
javascript
|
{
"resource": ""
}
|
q15176
|
ifMarkLineHasOnlyDim
|
train
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
}
|
javascript
|
{
"resource": ""
}
|
q15177
|
train
|
function (dataIndex) {
var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
var node = this.getData().tree.getNodeByDataIndex(dataIndex);
params.treePathInfo = wrapTreePathInfo(node, this);
return params;
}
|
javascript
|
{
"resource": ""
}
|
|
q15178
|
setDefault
|
train
|
function setDefault(levels, ecModel) {
var globalColorList = ecModel.get('color');
if (!globalColorList) {
return;
}
levels = levels || [];
var hasColorDefine;
zrUtil.each(levels, function (levelDefine) {
var model = new Model(levelDefine);
var modelColor = model.get('color');
if (model.get('itemStyle.color')
|| (modelColor && modelColor !== 'none')
) {
hasColorDefine = true;
}
});
if (!hasColorDefine) {
var level0 = levels[0] || (levels[0] = {});
level0.color = globalColorList.slice();
}
return levels;
}
|
javascript
|
{
"resource": ""
}
|
q15179
|
ifMarkLineHasOnlyDim
|
train
|
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
var dimName = coordSys.dimensions[dimIndex];
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
&& fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
}
|
javascript
|
{
"resource": ""
}
|
q15180
|
train
|
function (markLineModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var mlModel = seriesModel.markLineModel;
if (mlModel) {
var mlData = mlModel.getData();
var fromData = mlModel.__from;
var toData = mlModel.__to;
// Update visual and layout of from symbol and to symbol
fromData.each(function (idx) {
updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
});
// Update layout of line
mlData.each(function (idx) {
mlData.setItemLayout(idx, [
fromData.getItemLayout(idx),
toData.getItemLayout(idx)
]);
});
this.markerGroupMap.get(seriesModel.id).updateLayout();
}
}, this);
}
|
javascript
|
{
"resource": ""
}
|
|
q15181
|
symbolPathSetColor
|
train
|
function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
}
|
javascript
|
{
"resource": ""
}
|
q15182
|
parse
|
train
|
function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
}
|
javascript
|
{
"resource": ""
}
|
q15183
|
train
|
function () {
var thisOption = this.option;
return zrUtil.bind(
thisOption.mappingMethod === 'category'
? function (value, isNormalized) {
!isNormalized && (value = this._normalizeData(value));
return doMapCategory.call(this, value);
}
: function (value, isNormalized, out) {
// If output rgb array
// which will be much faster and useful in pixel manipulation
var returnRGBArray = !!out;
!isNormalized && (value = this._normalizeData(value));
out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
},
this
);
}
|
javascript
|
{
"resource": ""
}
|
|
q15184
|
train
|
function (brushOptionList) {
if (__DEV__) {
zrUtil.assert(this._mounted);
}
brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
});
var tmpIdPrefix = '\0-brush-index-';
var oldCovers = this._covers;
var newCovers = this._covers = [];
var controller = this;
var creatingCover = this._creatingCover;
(new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
.add(addOrUpdate)
.update(addOrUpdate)
.remove(remove)
.execute();
return this;
function getKey(brushOption, index) {
return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
+ '-' + brushOption.brushType;
}
function oldGetKey(cover, index) {
return getKey(cover.__brushOption, index);
}
function addOrUpdate(newIndex, oldIndex) {
var newBrushOption = brushOptionList[newIndex];
// Consider setOption in event listener of brushSelect,
// where updating cover when creating should be forbiden.
if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
newCovers[newIndex] = oldCovers[oldIndex];
}
else {
var cover = newCovers[newIndex] = oldIndex != null
? (
oldCovers[oldIndex].__brushOption = newBrushOption,
oldCovers[oldIndex]
)
: endCreating(controller, createCover(controller, newBrushOption));
updateCoverAfterCreation(controller, cover);
}
}
function remove(oldIndex) {
if (oldCovers[oldIndex] !== creatingCover) {
controller.group.remove(oldCovers[oldIndex]);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q15185
|
getPanelByCover
|
train
|
function getPanelByCover(controller, cover) {
var panels = controller._panels;
if (!panels) {
return true; // Global panel
}
var panelId = cover.__brushOption.panelId;
// User may give cover without coord sys info,
// which is then treated as global panel.
return panelId != null ? panels[panelId] : true;
}
|
javascript
|
{
"resource": ""
}
|
q15186
|
train
|
function (coord) {
var regions = this.regions;
for (var i = 0; i < regions.length; i++) {
if (regions[i].contain(coord)) {
return true;
}
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15187
|
prepareAnimationWhenNoOld
|
train
|
function prepareAnimationWhenNoOld(lasts, element, storageName) {
var lastCfg = lasts[thisRawIndex] = {};
var parentNode = thisNode.parentNode;
if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
var parentOldX = 0;
var parentOldY = 0;
// New nodes appear from right-bottom corner in 'zoomToNode' animation.
// For convenience, get old bounding rect from background.
var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
if (!reRoot && parentOldBg && parentOldBg.old) {
parentOldX = parentOldBg.old.width;
parentOldY = parentOldBg.old.height;
}
// When no parent old shape found, its parent is new too,
// so we can just use {x:0, y:0}.
lastCfg.old = storageName === 'nodeGroup'
? [0, parentOldY]
: {x: parentOldX, y: parentOldY, width: 0, height: 0};
}
// Fade in, user can be aware that these nodes are new.
lastCfg.fadein = storageName !== 'nodeGroup';
}
|
javascript
|
{
"resource": ""
}
|
q15188
|
train
|
function (dim, scale, extent) {
/**
* Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'.
* @type {string}
*/
this.dim = dim;
/**
* Axis scale
* @type {module:echarts/coord/scale/*}
*/
this.scale = scale;
/**
* @type {Array.<number>}
* @private
*/
this._extent = extent || [0, 0];
/**
* @type {boolean}
*/
this.inverse = false;
/**
* Usually true when axis has a ordinal scale
* @type {boolean}
*/
this.onBand = false;
}
|
javascript
|
{
"resource": ""
}
|
|
q15189
|
train
|
function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
}
|
javascript
|
{
"resource": ""
}
|
|
q15190
|
train
|
function (data, clamp) {
var extent = this._extent;
var scale = this.scale;
data = scale.normalize(data);
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
}
|
javascript
|
{
"resource": ""
}
|
|
q15191
|
train
|
function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
}
|
javascript
|
{
"resource": ""
}
|
|
q15192
|
train
|
function () {
var axisExtent = this._extent;
var dataExtent = this.scale.getExtent();
var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
// Fix #2728, avoid NaN when only one data.
len === 0 && (len = 1);
var size = Math.abs(axisExtent[1] - axisExtent[0]);
return Math.abs(size) / len;
}
|
javascript
|
{
"resource": ""
}
|
|
q15193
|
mergeControllerParams
|
train
|
function mergeControllerParams(dataZoomInfos) {
var controlType;
// DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
// as string, it is probably revert to reserved word by compress tool. See #7411.
var prefix = 'type_';
var typePriority = {
'type_true': 2,
'type_move': 1,
'type_false': 0,
'type_undefined': -1
};
var preventDefaultMouseMove = true;
zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
var dataZoomModel = dataZoomInfo.dataZoomModel;
var oneType = dataZoomModel.get('disabled', true)
? false
: dataZoomModel.get('zoomLock', true)
? 'move'
: true;
if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
controlType = oneType;
}
// Prevent default move event by default. If one false, do not prevent. Otherwise
// users may be confused why it does not work when multiple insideZooms exist.
preventDefaultMouseMove &= dataZoomModel.get('preventDefaultMouseMove', true);
});
return {
controlType: controlType,
opt: {
// RoamController will enable all of these functionalities,
// and the final behavior is determined by its event listener
// provided by each inside zoom.
zoomOnMouseWheel: true,
moveOnMouseMove: true,
moveOnMouseWheel: true,
preventDefaultMouseMove: !!preventDefaultMouseMove
}
};
}
|
javascript
|
{
"resource": ""
}
|
q15194
|
train
|
function () {
var axis = this;
var labelModel = axis.getLabelModel();
var ordinalScale = axis.scale;
var ordinalExtent = ordinalScale.getExtent();
// Providing this method is for optimization:
// avoid generating a long array by `getTicks`
// in large category data case.
var tickCount = ordinalScale.count();
if (ordinalExtent[1] - ordinalExtent[0] < 1) {
return 0;
}
var tickValue = ordinalExtent[0];
var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
var unitH = Math.abs(unitSpan);
// Not precise, just use height as text width
// and each distance from axis line yet.
var rect = textContain.getBoundingRect(
tickValue, labelModel.getFont(), 'center', 'top'
);
var maxH = Math.max(rect.height, 7);
var dh = maxH / unitH;
// 0/0 is NaN, 1/0 is Infinity.
isNaN(dh) && (dh = Infinity);
var interval = Math.max(0, Math.floor(dh));
var cache = inner(axis.model);
var lastAutoInterval = cache.lastAutoInterval;
var lastTickCount = cache.lastTickCount;
// Use cache to keep interval stable while moving zoom window,
// otherwise the calculated interval might jitter when the zoom
// window size is close to the interval-changing size.
if (lastAutoInterval != null
&& lastTickCount != null
&& Math.abs(lastAutoInterval - interval) <= 1
&& Math.abs(lastTickCount - tickCount) <= 1
// Always choose the bigger one, otherwise the critical
// point is not the same when zooming in or zooming out.
&& lastAutoInterval > interval
) {
interval = lastAutoInterval;
}
// Only update cache if cache not used, otherwise the
// changing of interval is too insensitive.
else {
cache.lastTickCount = tickCount;
cache.lastAutoInterval = interval;
}
return interval;
}
|
javascript
|
{
"resource": ""
}
|
|
q15195
|
create
|
train
|
function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = ecModel.queryComponents({
mainType: 'singleAxis',
index: seriesModel.get('singleAxisIndex'),
id: seriesModel.get('singleAxisId')
})[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
}
|
javascript
|
{
"resource": ""
}
|
q15196
|
Single
|
train
|
function Single(axisModel, ecModel, api) {
/**
* @type {string}
* @readOnly
*/
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*
* @type {Array.<string>}
* @readOnly
*/
this.dimensions = ['single'];
/**
* @private
* @type {module:echarts/coord/single/SingleAxis}.
*/
this._axis = null;
/**
* @private
* @type {module:zrender/core/BoundingRect}
*/
this._rect;
this._init(axisModel, ecModel, api);
/**
* @type {module:echarts/coord/single/AxisModel}
*/
this.model = axisModel;
}
|
javascript
|
{
"resource": ""
}
|
q15197
|
train
|
function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(
dim,
axisHelper.createScaleByModel(axisModel),
[0, 0],
axisModel.get('type'),
axisModel.get('position')
);
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
}
|
javascript
|
{
"resource": ""
}
|
|
q15198
|
train
|
function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
}
|
javascript
|
{
"resource": ""
}
|
|
q15199
|
train
|
function (axisModel, api) {
this._rect = getLayoutRect(
{
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
},
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._adjustAxis();
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.