<commit_before><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../cosmoz-templatize/cosmoz-templatize.html">

<script>

/**
`Cosmoz.DialogBehavior`
*/
(function () {
	'use strict';

	window.Cosmoz = window.Cosmoz || {};
	const _async = window.requestIdleCallback || window.requestAnimationFrame || Polymer.Base.async;

	/**
	 * @polymerBehavior Cosmoz.DialogBehavior
	*/
	Cosmoz.DialogBehaviorImpl = {
		properties: {
			modal: {
				type: Boolean
			},

			withBackdrop: {
				type: Boolean
			},

			/**
			 * Set to true to disable auto-focusing the overlay or child nodes with
			 * the `autofocus` attribute` when the overlay is opened.
			 */
			noAutoFocus: {
				type: Boolean,
				value: false
			},

			/**
			 * True if the dialog should be rendered before first call to `open`.
			 */
			prerender: {
				type: Boolean,
				value: false
			}
		},

		hostAttributes: {
			'role': 'dialog',
			'tabindex': '-1'
		},

		// The generated paper-dialog element
		_paperDialog: null,

		_templateInstance: null,

		_dialogEventsHandler: null,

		_pendingProps: null,

		created() {
			this._dialogEventsHandler = this._handlePaperDialogEvents.bind(this);
			this._pendingProps = {};
			this._spawn = this._spawn.bind(this);
			this._spawnSteps = [this._createDialog, this._createInstance];
		},

		attached() {
			this._observer = Polymer.dom(this).observeNodes(this._onNodesChange);
			this.listen(window, 'cosmoz-dialog-closeall', 'close');
		},

		detached() {
			if (this._observer) {
				Polymer.dom(this).unobserveNodes(this._observer);
				this._observer = null;
			}
			this._detachDialog();
			this.unlisten(window, 'cosmoz-dialog-closeall', 'close');
			this._templateInstance = null;
		},

		_spawn() {
			const step = this._spawnSteps.shift();
			if (!step) {
				return;
			}
			step.call(this);
			_async(this._spawn);
		},
		/**
		 * Get the generated paper-dialog element
		 */
		get paperDialog() {
			return this._paperDialog;
		},

		open() {
			if (!this._userTemplate) {
				return;
			}

			this._spawnSteps.splice(0).forEach(step => step.call(this));

			this._attachDialog();
			this._paperDialog.open();
		},

		_attachDialog() {
			if (!this._paperDialog.parentNode) {
				Polymer.dom(document.body).appendChild(this._paperDialog);
			}
		},

		_detachDialog() {
			const dialog = this._paperDialog;
			if (dialog == null) {
				return;
			}
			dialog.removeEventListener('iron-overlay-opened', this._dialogEventsHandler);
			dialog.removeEventListener('iron-overlay-closed', this._dialogEventsHandler);

			if (!dialog.parentNode) {
				return;
			}
			Polymer.dom(dialog.parentNode).removeChild(dialog);
		},


		close() {
			if (this._paperDialog != null) {
				this._paperDialog.close();
			}
		},

		fit() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.fit();
			}
		},

		refit() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.refit();
			}
		},

		center() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.center();
			}
		},

		_onNodesChange() {
			if (this._userTemplate) {
				return;
			}
			const template = this.queryEffectiveChildren('template');

			if (!template) {
				console.warn('cosmoz-dialog-behavior requires a template');
				this._spawnSteps.splice(0);
			}

			this._userTemplate = template;

			this._instanceCtor = Cosmoz.Templatize.templatize(template, this, {
				instanceProps: {},
				parentModel: true,
				forwardParentProp: this._forwardHostProp,
				forwardParentPath: this._forwardParentPath,
				forwardHostProp: this._forwardHostProp,
			});

			if (!this.prerender) {
				return;
			}

			_async(this._spawn);
		},

		_createDialog() {
			if (!this._userTemplate) {
				return;
			}

			var dialog = document.createElement('paper-dialog');
			dialog.modal = this.modal;

			if (!this.modal) {
				dialog.withBackdrop = this.withBackdrop;
			}

			dialog.noAutoFocus = this.noAutoFocus;

			dialog.addEventListener('iron-overlay-opened', this._dialogEventsHandler);
			dialog.addEventListener('iron-overlay-closed', this._dialogEventsHandler);

			this._paperDialog = dialog;
			return dialog;
		},

		_createInstance() {<commit_msg>Remove modal property, added properties. refs #286<commit_after><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../cosmoz-templatize/cosmoz-templatize.html">

<script>

/**
`Cosmoz.DialogBehavior`
*/
(function () {
	'use strict';

	window.Cosmoz = window.Cosmoz || {};
	const _async = window.requestIdleCallback || window.requestAnimationFrame || Polymer.Base.async;

	/**
	 * @polymerBehavior Cosmoz.DialogBehavior
	*/
	Cosmoz.DialogBehaviorImpl = {
		properties: {
			/**
			 *  Set to true to display a backdrop behind the overlay
			 */
			 withBackdrop: {
				type: Boolean,
				value: true
			},

			/**
			 * Set to true to disable auto-focusing the overlay or child nodes with
			 * the `autofocus` attribute` when the overlay is opened.
			 */
			noAutoFocus: {
				type: Boolean,
				value: false
			},

			/**
			 * True if the dialog should be rendered before first call to `open`.
			 */
			prerender: {
				type: Boolean,
				value: false
			},

			/**
			 * Set to true to disable closing dialog with the ESC key
			 */
			noCancelOnEscKey: {
				type: Boolean,
				value: false
			},

			/**
			 * Set to true to diable closing dialog when clicking outside of dialog
			 */
			noCancelOnOutsideClick: {
				type: Boolean,
				value: true
			}
		},

		hostAttributes: {
			'role': 'dialog',
			'tabindex': '-1'
		},

		// The generated paper-dialog element
		_paperDialog: null,

		_templateInstance: null,

		_dialogEventsHandler: null,

		_pendingProps: null,

		created() {
			this._dialogEventsHandler = this._handlePaperDialogEvents.bind(this);
			this._pendingProps = {};
			this._spawn = this._spawn.bind(this);
			this._spawnSteps = [this._createDialog, this._createInstance];
		},

		attached() {
			this._observer = Polymer.dom(this).observeNodes(this._onNodesChange);
			this.listen(window, 'cosmoz-dialog-closeall', 'close');
		},

		detached() {
			if (this._observer) {
				Polymer.dom(this).unobserveNodes(this._observer);
				this._observer = null;
			}
			this._detachDialog();
			this.unlisten(window, 'cosmoz-dialog-closeall', 'close');
			this._templateInstance = null;
		},

		_spawn() {
			const step = this._spawnSteps.shift();
			if (!step) {
				return;
			}
			step.call(this);
			_async(this._spawn);
		},
		/**
		 * Get the generated paper-dialog element
		 */
		get paperDialog() {
			return this._paperDialog;
		},

		open() {
			if (!this._userTemplate) {
				return;
			}

			this._spawnSteps.splice(0).forEach(step => step.call(this));

			this._attachDialog();
			this._paperDialog.open();
		},

		_attachDialog() {
			if (!this._paperDialog.parentNode) {
				Polymer.dom(document.body).appendChild(this._paperDialog);
			}
		},

		_detachDialog() {
			const dialog = this._paperDialog;
			if (dialog == null) {
				return;
			}
			dialog.removeEventListener('iron-overlay-opened', this._dialogEventsHandler);
			dialog.removeEventListener('iron-overlay-closed', this._dialogEventsHandler);

			if (!dialog.parentNode) {
				return;
			}
			Polymer.dom(dialog.parentNode).removeChild(dialog);
		},


		close() {
			if (this._paperDialog != null) {
				this._paperDialog.close();
			}
		},

		fit() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.fit();
			}
		},

		refit() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.refit();
			}
		},

		center() {
			if (this._paperDialog != null && this._paperDialog.opened) {
				this._paperDialog.center();
			}
		},

		_onNodesChange() {
			if (this._userTemplate) {
				return;
			}
			const template = this.queryEffectiveChildren('template');

			if (!template) {
				console.warn('cosmoz-dialog-behavior requires a template');
				this._spawnSteps.splice(0);
			}

			this._userTemplate = template;

			this._instanceCtor = Cosmoz.Templatize.templatize(template, this, {
				instanceProps: {},
				parentModel: true,
				forwardParentProp: this._forwardHostProp,
				forwardParentPath: this._forwardParentPath,
				forwardHostProp: this._forwardHostProp,
			});

			if (!this.prerender) {
				return;
			}

			_async(this._spawn);
		},

		_createDialog() {
			if (!this._userTemplate) {
				return;
			}

			const dialog = document.createElement('paper-dialog');

			dialog.noAutoFocus = this.noAutoFocus;
			dialog.noCancelOnEscKey = this.noCancelOnEscKey;
			dialog.noCancelOnOutsideClick = this.noCancelOnOutsideClick;
			dialog.withBackdrop = this.withBackdrop;

			dialog.addEventListener('iron-overlay-opened', this._dialogEventsHandler);
			dialog.addEventListener('iron-overlay-closed', this._dialogEventsHandler);

			this._paperDialog = dialog;
			return dialog;
		},

		_createInstance() {
{'fraction_non_alphanumeric': 0.1422907488986784, 'fraction_numerical': 0.0009911894273127754, 'mean_word_length': 3.2355410447761193, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '635371', 'n_tokens_mistral': 3610, 'n_tokens_neox': 2862, 'n_words': 532}