<commit_before>/*global _, Kinetic, MAPJS, Image, setTimeout */
Kinetic.IdeaProxy = function (idea, container, stage, layer) {
	'use strict';
	var cached,
		cacheImage = function () {
			var x = -1, y = -1,
				width = idea.getWidth() + 20,
				height = idea.getHeight() + 20;
			idea.remove();
			idea.toImage({
				x: x,
				y: y,
				width: width,
				height: height,
				callback: function (img) {
					var image = new Kinetic.Image({
						x: x,
						y: y,
						width: width,
						height: height,
						image: img
					});
					container.add(image);
					cached = image;
					container.getLayer().draw();
				}
			});
		};

	container.attrs.x = idea.attrs.x;
	container.attrs.y = idea.attrs.y;
	idea.attrs.x = 0;
	idea.attrs.y = 0;
	container.add(idea);

	container.cacheImage = cacheImage;

	container.isVisible = function (offset) {
		return stage && stage.isRectVisible(new MAPJS.Rectangle(container.attrs.x, container.attrs.y, container.getWidth(), container.getHeight()), offset);
	};
	idea.isVisible = function (offset) {
		return stage && stage.isRectVisible(new MAPJS.Rectangle(container.attrs.x, container.attrs.y, container.getWidth(), container.getHeight()), offset);
	};
	container.transitionToAndDontStopCurrentTransitions = function (config) {
		var transition = new Kinetic.Transition(container, config),
			animation = new Kinetic.Animation();
		animation.func = transition._onEnterFrame.bind(transition);
		animation.node = container.getLayer();
		transition.onFinished = animation.stop.bind(animation);
		transition.start();
		animation.start();
	};
	_.each(['getHeight', 'getWidth'], function (fname) {
		container[fname] = function () {
			if (cacheImage && cacheImage[fname]) {
				return cacheImage[fname].apply(cacheImage, arguments);
			}
			return idea && idea[fname] && idea[fname].apply(idea, arguments);
		};
	});
	_.each(['setMMStyle', 'setIsSelected', 'setText', 'setIsDroppable'], function (fname) {
		container[fname] = function () {
			var result = idea && idea[fname] && idea[fname].apply(idea, arguments);
			return result;
		};
	});

	layer.add(container);
	container.transitionToAndDontStopCurrentTransitions({
		opacity: 1,
		duration: 0.4
	});
	setTimeout(container.cacheImage, 10000);
	return container;
};
<commit_msg>using images from the start<commit_after>/*global _, Kinetic, MAPJS, Image, setTimeout */
Kinetic.IdeaProxy = function (idea, container, stage, layer) {
	'use strict';
	var cached,
		cacheImage = function () {
			var x = -1, y = -1,
				width = idea.getWidth() + 20,
				height = idea.getHeight() + 20;
			idea.toImage({
				x: x,
				y: y,
				width: width,
				height: height,
				callback: function (img) {
					if (cached) {
						cached.setImage(img);
					} else {
						var image = new Kinetic.Image({
							x: x,
							y: y,
							width: width,
							height: height,
							image: img
						});
						container.add(image);
						cached = image;
						container.getLayer().draw();
					}
				}
			});
		};

	container.attrs.x = idea.attrs.x;
	container.attrs.y = idea.attrs.y;
	idea.attrs.x = 0;
	idea.attrs.y = 0;
	//container.add(idea);

	container.cacheImage = cacheImage;

	container.isVisible = function (offset) {
		return stage && stage.isRectVisible(new MAPJS.Rectangle(container.attrs.x, container.attrs.y, container.getWidth(), container.getHeight()), offset);
	};
	idea.isVisible = function (offset) {
		return stage && stage.isRectVisible(new MAPJS.Rectangle(container.attrs.x, container.attrs.y, container.getWidth(), container.getHeight()), offset);
	};
	idea.getLayer = function () {
		return layer;
	};
	container.transitionToAndDontStopCurrentTransitions = function (config) {
		var transition = new Kinetic.Transition(container, config),
			animation = new Kinetic.Animation();
		animation.func = transition._onEnterFrame.bind(transition);
		animation.node = container.getLayer();
		transition.onFinished = animation.stop.bind(animation);
		transition.start();
		animation.start();
	};
	_.each(['getHeight', 'getWidth'], function (fname) {
		container[fname] = function () {
			return idea && idea[fname] && idea[fname].apply(idea, arguments);
		};
	});
	_.each(['setMMStyle', 'setIsSelected', 'setText', 'setIsDroppable'], function (fname) {
		container[fname] = function () {
			var result = idea && idea[fname] && idea[fname].apply(idea, arguments);
			cacheImage();
			return result;
		};
	});

	layer.add(container);
	container.transitionToAndDontStopCurrentTransitions({
		opacity: 1,
		duration: 0.4
	});
	container.cacheImage();
	return container;
};

{'fraction_non_alphanumeric': 0.15477497255762898, 'fraction_numerical': 0.005927552140504939, 'mean_word_length': 3.7163561076604554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5970625', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1460, 'n_words': 313}