<commit_before>/**
 * ownCloud
 *
 * @author Bartek Przybylski, Christopher Schäpers, Thomas Tanghus
 * @copyright 2012 Bartek Przybylski bartek@alefzero.eu
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/**
 * this class to ease the usage of jquery dialogs
 */
var OCdialogs = {
	// dialog button types
	YES_NO_BUTTONS:		70,
	OK_BUTTONS:		71,
	// used to name each dialog
	dialogs_counter: 0,
	/**
	* displays alert dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses OK
	* @param modal make the dialog modal
	*/
	alert:function(text, title, callback, modal) {
		this.message(text, title, 'alert', OCdialogs.OK_BUTTON, callback, modal);
	},
	/**
	* displays info dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses OK
	* @param modal make the dialog modal
	*/
	info:function(text, title, callback, modal) {
		this.message(text, title, 'info', OCdialogs.OK_BUTTON, callback, modal);
	},
	/**
	* displays confirmation dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses YES or NO (true or false would be passed to callback respectively)
	* @param modal make the dialog modal
	*/
	confirm:function(text, title, callback, modal) {
		this.message(text, title, 'notice', OCdialogs.YES_NO_BUTTONS, callback, modal);
	},
	/**
	 * show a file picker to pick a file from
	 * @param title dialog title
	 * @param callback which will be triggered when user presses Choose
	 * @param multiselect whether it should be possible to select multiple files
	 * @param mimetype_filter mimetype to filter by
	 * @param modal make the dialog modal
	*/
	filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
		var self = this;
		$.when(this._getFilePickerTemplate()).then(function($tmpl) {
			var dialog_name = 'oc-dialog-filepicker-content';
			var dialog_id = '#' + dialog_name;
			if(self.$filePicker) {
				self.$filePicker.ocdialog('close');
			}
			self.$filePicker = $tmpl.octemplate({
				dialog_name: dialog_name,
				title: title
			}).data('path', '').data('multiselect', multiselect).data('mimetype', mimetype_filter);

			if (modal === undefined) {
				modal = false;
			}
			if (multiselect === undefined) {
				multiselect = false;
			}
			if (mimetype_filter === undefined) {
				mimetype_filter = '';
			}

			$('body').append(self.$filePicker);

			self.$filePicker.ready(function() {
				self.$filelist = self.$filePicker.find('.filelist');
				self.$dirTree = self.$filePicker.find('.dirtree');
				self.$dirTree.on('click', 'span:not(:last-child)', self, self._handleTreeListSelect);
				self.$filelist.on('click', 'li', function(event) {
					self._handlePickerClick(event, $(this));
				});
				self._fillFilePicker('');
			});

			// build buttons
			var functionToCall = function() {
				if (callback !== undefined) {
					var datapath;
					if (multiselect === true) {
						datapath = [];
						self.$filelist.find('.filepicker_element_selected .filename').each(function(index, element) {
							datapath.push(self.$filePicker.data('path') + '/' + $(element).text());
						});
					} else {
						datapath = self.$filePicker.data('path');
						datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text();
					}
					callback(datapath);
					self.$filePicker.ocdialog('close');
				}
			};
			var buttonlist = [{
				text: t('core', 'Choose'),
				click: functionToCall,
				defaultButton: true
			}];

			self.$filePicker.ocdialog({
				closeOnEscape: true,
				width: (4/9)*$(document).width(),
				height: 420,
				modal: modal,
				buttons: buttonlist,
				close: function(event, ui) {
					try {
						$(this).ocdialog('destroy').remove();
					} catch(e) {}
					self.$filePicker = null;
				}
			});
		})
		.fail(function() {
			alert(t('core', 'Error loading file picker template'));
		});
	},
	/**
	 * Displays raw dialog
	 * You better use a wrapper instead ...
	*/
	message:function(content, title, dialog_type, buttons, callback, modal) {
		$.when(this._getMessageTemplate()).then(function($tmpl) {
			var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
			var dialog_id = '#' + dialog_name;
			var $dlg = $tmpl.octemplate({
				dialog_name: dialog_name,
				title: title,
				message: content,
				type: dialog_type
			});
			if (modal === undefined) {
				modal = false;
			}
			$('body').append($dlg);
			var buttonlist = [];
			switch (buttons) {
				case OCdialogs.YES_NO_BUTTONS:
					buttonlist = [{
						text: t('core', 'Yes'),
						click: function(){
							if (callback !== undefined) {
								callback(true);
							}
							$(dialog_id).ocdialog('close');
						},
						defaultButton: true
					},
					{
						text: t('core', 'No'),
						click: function(){
							if (callback !== undefined) {
								callback(false);
							}
							$(dialog_id).ocdialog('close');
						}
					}];
				break;
				case OCdialogs.OK_BUTTON:
					var functionToCall = function() {
						$(dialog_id).ocdialog('close');
						if(callback !== undefined) {
							callback();
						}
					};
					buttonlist[0] = {
						text: t('core', 'Ok'),
						click: functionToCall,
						defaultButton: true
					};
				break;
			}

			$(dialog_id).ocdialog({
				closeOnEscape: true,
				modal: modal,
				buttons: buttonlist
			});
			OCdialogs.dialogs_counter++;
		})
		.fail(function() {
			alert(t('core', 'Error loading file picker template'));
		});
	},
	_getFilePickerTemplate: function() {
		var defer = $.Deferred();
		if(!this.$filePickerTemplate) {
			var self = this;
			$.get(OC.filePath('core', 'templates', 'filepicker.html'), function(tmpl) {
				self.$filePickerTemplate = $(tmpl);
				self.$listTmpl = self.$filePickerTemplate.find('.filelist li:first-child').detach();
				defer.resolve(self.$filePickerTemplate);
			})
			.fail(function() {
				defer.reject();
			});
		} else {
			defer.resolve(this.$filePickerTemplate);
		}
		return defer.promise();
	},
	_getMessageTemplate: function() {
		var defer = $.Deferred();
		if(!this.$messageTemplate) {
			var self = this;
			$.get(OC.filePath('core', 'templates', 'message.html'), function(tmpl) {
				self.$messageTemplate = $(tmpl);
				defer.resolve(self.$messageTemplate);
			})
			.fail(function() {
				defer.reject();
			});
		} else {
			defer.resolve(this.$messageTemplate);
		}
		return defer.promise();
	},
	_getFileList: function(dir, mimeType) {
		return $.getJSON(
			OC.filePath('files', 'ajax', 'rawlist.php'),
			{dir: dir, mimetype: mimeType}
		);
	},
	_determineValue: function(element) {
		if ( $(element).attr('type') === 'checkbox' ) {
			return element.checked;
		} else {
			return $(element).val();
		}
	},

	/**
	 * fills the filepicker with files
	*/
	_fillFilePicker:function(dir) {
		var dirs = [];
		var others = [];
		var self = this;
		this.$filelist.empty().addClass('loading');
		this.$filePicker.data('path', dir);
		$.when(this._getFileList(dir, this.$filePicker.data('mimetype'))).then(function(response) {
			$.each(response.data, function(index, file) {
				if (file.type === 'dir') {
					dirs.push(file);
				} else {
					others.push(file);
				}
			});

			self._fillSlug();
			var sorted = dirs.concat(others);

			$.each(sorted, function(idx, entry) {
				var $li = self.$listTmpl.octemplate({
					type: entry.type,
					dir: dir,
					filename: entry.name,
					date: OC.mtime2date(entry.mtime)
				});
				if (entry.mimetype === "httpd/unix-directory") {
					$li.find('img').attr('src', OC.imagePath('core', 'filetypes/folder.png'));
				} else {
					$li.find('img').attr('src', OC.Router.generate('core_ajax_preview', {x:32, y:32, file:escapeHTML(dir+'/'+entry.name)}) );
				}
				self.$filelist.append($li);
			});

			self.$filelist.removeClass('loading');
		});
	},
	/**
	 * fills the tree list with directories
	*/
	_fillSlug: function() {
		this.$dirTree.empty();
		var self = this;
		var path = this.$filePicker.data('path');
		var $template = $('{name}');
		if(path) {
			var paths = path.split('/');
			$.each(paths, function(index, dir) {
				dir = paths.pop();
				if(dir === '') {
					return false;
				}
				self.$dirTree.prepend($template.octemplate({
					dir: paths.join('/') + '/' + dir,
					name: dir
				}));
			});
		}
		$template.octemplate({
			dir: '',
			name: '    ' // Ugly but works ;)
		}, {escapeFunction: null}).addClass('home svg').prependTo(this.$dirTree);
	},
	/**
	 * handle selection made in the tree list
	*/
	_handleTreeListSelect:function(event) {
		var self = event.data;
		var dir = $(event.target).data('dir');
		self._fillFilePicker(dir);
	},
	/**
	 * handle clicks made in the filepicker
	*/
	_handlePickerClick:function(event, $element) {
		if ($element.data('type') === 'file') {
			if (this.$filePicker.data('multiselect') !== true || !event.ctrlKey) {
				this.$filelist.find('.filepicker_element_selected').removeClass('filepicker_element_selected');
			}
			$element.toggleClass('filepicker_element_selected');
			return;
		} else if ( $element.data('type') === 'dir' ) {
			this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
		}
	}
};
<commit_msg>Don't popup meaningless alerts when dialog called on page leave<commit_after>/**
 * ownCloud
 *
 * @author Bartek Przybylski, Christopher Schäpers, Thomas Tanghus
 * @copyright 2012 Bartek Przybylski bartek@alefzero.eu
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/**
 * this class to ease the usage of jquery dialogs
 */
var OCdialogs = {
	// dialog button types
	YES_NO_BUTTONS:		70,
	OK_BUTTONS:		71,
	// used to name each dialog
	dialogs_counter: 0,
	/**
	* displays alert dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses OK
	* @param modal make the dialog modal
	*/
	alert:function(text, title, callback, modal) {
		this.message(text, title, 'alert', OCdialogs.OK_BUTTON, callback, modal);
	},
	/**
	* displays info dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses OK
	* @param modal make the dialog modal
	*/
	info:function(text, title, callback, modal) {
		this.message(text, title, 'info', OCdialogs.OK_BUTTON, callback, modal);
	},
	/**
	* displays confirmation dialog
	* @param text content of dialog
	* @param title dialog title
	* @param callback which will be triggered when user presses YES or NO (true or false would be passed to callback respectively)
	* @param modal make the dialog modal
	*/
	confirm:function(text, title, callback, modal) {
		this.message(text, title, 'notice', OCdialogs.YES_NO_BUTTONS, callback, modal);
	},
	/**
	 * show a file picker to pick a file from
	 * @param title dialog title
	 * @param callback which will be triggered when user presses Choose
	 * @param multiselect whether it should be possible to select multiple files
	 * @param mimetype_filter mimetype to filter by
	 * @param modal make the dialog modal
	*/
	filepicker:function(title, callback, multiselect, mimetype_filter, modal) {
		var self = this;
		$.when(this._getFilePickerTemplate()).then(function($tmpl) {
			var dialog_name = 'oc-dialog-filepicker-content';
			var dialog_id = '#' + dialog_name;
			if(self.$filePicker) {
				self.$filePicker.ocdialog('close');
			}
			self.$filePicker = $tmpl.octemplate({
				dialog_name: dialog_name,
				title: title
			}).data('path', '').data('multiselect', multiselect).data('mimetype', mimetype_filter);

			if (modal === undefined) {
				modal = false;
			}
			if (multiselect === undefined) {
				multiselect = false;
			}
			if (mimetype_filter === undefined) {
				mimetype_filter = '';
			}

			$('body').append(self.$filePicker);

			self.$filePicker.ready(function() {
				self.$filelist = self.$filePicker.find('.filelist');
				self.$dirTree = self.$filePicker.find('.dirtree');
				self.$dirTree.on('click', 'span:not(:last-child)', self, self._handleTreeListSelect);
				self.$filelist.on('click', 'li', function(event) {
					self._handlePickerClick(event, $(this));
				});
				self._fillFilePicker('');
			});

			// build buttons
			var functionToCall = function() {
				if (callback !== undefined) {
					var datapath;
					if (multiselect === true) {
						datapath = [];
						self.$filelist.find('.filepicker_element_selected .filename').each(function(index, element) {
							datapath.push(self.$filePicker.data('path') + '/' + $(element).text());
						});
					} else {
						datapath = self.$filePicker.data('path');
						datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text();
					}
					callback(datapath);
					self.$filePicker.ocdialog('close');
				}
			};
			var buttonlist = [{
				text: t('core', 'Choose'),
				click: functionToCall,
				defaultButton: true
			}];

			self.$filePicker.ocdialog({
				closeOnEscape: true,
				width: (4/9)*$(document).width(),
				height: 420,
				modal: modal,
				buttons: buttonlist,
				close: function(event, ui) {
					try {
						$(this).ocdialog('destroy').remove();
					} catch(e) {}
					self.$filePicker = null;
				}
			});
		})
		.fail(function(status, error) {
			// If the method is called while navigating away
			// from the page, it is probably not needed ;)
			if(status === 0) {
				return;
			} else {
				alert(t('core', 'Error loading file picker template: {error}', {error: error}));
			}
		});
	},
	/**
	 * Displays raw dialog
	 * You better use a wrapper instead ...
	*/
	message:function(content, title, dialog_type, buttons, callback, modal) {
		$.when(this._getMessageTemplate()).then(function($tmpl) {
			var dialog_name = 'oc-dialog-' + OCdialogs.dialogs_counter + '-content';
			var dialog_id = '#' + dialog_name;
			var $dlg = $tmpl.octemplate({
				dialog_name: dialog_name,
				title: title,
				message: content,
				type: dialog_type
			});
			if (modal === undefined) {
				modal = false;
			}
			$('body').append($dlg);
			var buttonlist = [];
			switch (buttons) {
				case OCdialogs.YES_NO_BUTTONS:
					buttonlist = [{
						text: t('core', 'Yes'),
						click: function(){
							if (callback !== undefined) {
								callback(true);
							}
							$(dialog_id).ocdialog('close');
						},
						defaultButton: true
					},
					{
						text: t('core', 'No'),
						click: function(){
							if (callback !== undefined) {
								callback(false);
							}
							$(dialog_id).ocdialog('close');
						}
					}];
				break;
				case OCdialogs.OK_BUTTON:
					var functionToCall = function() {
						$(dialog_id).ocdialog('close');
						if(callback !== undefined) {
							callback();
						}
					};
					buttonlist[0] = {
						text: t('core', 'Ok'),
						click: functionToCall,
						defaultButton: true
					};
				break;
			}

			$(dialog_id).ocdialog({
				closeOnEscape: true,
				modal: modal,
				buttons: buttonlist
			});
			OCdialogs.dialogs_counter++;
		})
		.fail(function(status, error) {
			// If the method is called while navigating away from
			// the page, we still want to deliver the message.
			if(status === 0) {
				alert(title + ': ' + content);
			} else {
				alert(t('core', 'Error loading message template: {error}', {error: error}));
			}
		});
	},
	_getFilePickerTemplate: function() {
		var defer = $.Deferred();
		if(!this.$filePickerTemplate) {
			var self = this;
			$.get(OC.filePath('core', 'templates', 'filepicker.html'), function(tmpl) {
				self.$filePickerTemplate = $(tmpl);
				self.$listTmpl = self.$filePickerTemplate.find('.filelist li:first-child').detach();
				defer.resolve(self.$filePickerTemplate);
			})
			.fail(function(jqXHR, textStatus, errorThrown) {
				defer.reject(jqXHR.status, errorThrown);
			});
		} else {
			defer.resolve(this.$filePickerTemplate);
		}
		return defer.promise();
	},
	_getMessageTemplate: function() {
		var defer = $.Deferred();
		if(!this.$messageTemplate) {
			var self = this;
			$.get(OC.filePath('core', 'templates', 'message.htm'), function(tmpl) {
				self.$messageTemplate = $(tmpl);
				defer.resolve(self.$messageTemplate);
			})
			.fail(function(jqXHR, textStatus, errorThrown) {
				defer.reject(jqXHR.status, errorThrown);
			});
		} else {
			defer.resolve(this.$messageTemplate);
		}
		return defer.promise();
	},
	_getFileList: function(dir, mimeType) {
		return $.getJSON(
			OC.filePath('files', 'ajax', 'rawlist.php'),
			{dir: dir, mimetype: mimeType}
		);
	},
	_determineValue: function(element) {
		if ( $(element).attr('type') === 'checkbox' ) {
			return element.checked;
		} else {
			return $(element).val();
		}
	},

	/**
	 * fills the filepicker with files
	*/
	_fillFilePicker:function(dir) {
		var dirs = [];
		var others = [];
		var self = this;
		this.$filelist.empty().addClass('loading');
		this.$filePicker.data('path', dir);
		$.when(this._getFileList(dir, this.$filePicker.data('mimetype'))).then(function(response) {
			$.each(response.data, function(index, file) {
				if (file.type === 'dir') {
					dirs.push(file);
				} else {
					others.push(file);
				}
			});

			self._fillSlug();
			var sorted = dirs.concat(others);

			$.each(sorted, function(idx, entry) {
				var $li = self.$listTmpl.octemplate({
					type: entry.type,
					dir: dir,
					filename: entry.name,
					date: OC.mtime2date(entry.mtime)
				});
				if (entry.mimetype === "httpd/unix-directory") {
					$li.find('img').attr('src', OC.imagePath('core', 'filetypes/folder.png'));
				} else {
					$li.find('img').attr('src', OC.Router.generate('core_ajax_preview', {x:32, y:32, file:escapeHTML(dir+'/'+entry.name)}) );
				}
				self.$filelist.append($li);
			});

			self.$filelist.removeClass('loading');
		});
	},
	/**
	 * fills the tree list with directories
	*/
	_fillSlug: function() {
		this.$dirTree.empty();
		var self = this;
		var path = this.$filePicker.data('path');
		var $template = $('{name}');
		if(path) {
			var paths = path.split('/');
			$.each(paths, function(index, dir) {
				dir = paths.pop();
				if(dir === '') {
					return false;
				}
				self.$dirTree.prepend($template.octemplate({
					dir: paths.join('/') + '/' + dir,
					name: dir
				}));
			});
		}
		$template.octemplate({
			dir: '',
			name: '    ' // Ugly but works ;)
		}, {escapeFunction: null}).addClass('home svg').prependTo(this.$dirTree);
	},
	/**
	 * handle selection made in the tree list
	*/
	_handleTreeListSelect:function(event) {
		var self = event.data;
		var dir = $(event.target).data('dir');
		self._fillFilePicker(dir);
	},
	/**
	 * handle clicks made in the filepicker
	*/
	_handlePickerClick:function(event, $element) {
		if ($element.data('type') === 'file') {
			if (this.$filePicker.data('multiselect') !== true || !event.ctrlKey) {
				this.$filelist.find('.filepicker_element_selected').removeClass('filepicker_element_selected');
			}
			$element.toggleClass('filepicker_element_selected');
			return;
		} else if ( $element.data('type') === 'dir' ) {
			this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
		}
	}
};
<|endoftext|>


<commit_before>// @flow
import React, { Component } from 'react';
import classnames from 'classnames';

import ParameterList from '../ParameterList';
import * as utils from '../../../utils';

import styles from './json-doc.css';
import type { Service } from '../../../generated/version/ServiceType';

const defaultView =
  (

    <-- Hover over JSON example for documentation

);

type Props = {
  documentationFullType: string,
  service: Service,
  importedServices: Service[],
};

class Documentation extends Component {
  props: Props;
  state: {
    height: number,
  };

  constructor(props: Props) {
    super(props);
    this.state = { height: 0 };
    this.updateContainerHeight = this.updateContainerHeight.bind(this);
  }

  componentDidUpdate() {
    this.updateContainerHeight();
  }

  container: HTMLDivElement;
  updateContainerHeight: () => void;

  updateContainerHeight() {
    const container = this.container;
    if (container) {
      const height = container.clientHeight;
      if (height > this.state.height) {
        this.setState({ height });
      }
    }
  }

  render() {
    const { documentationFullType, service, importedServices } = this.props;
    const { height } = this.state;
    if (!documentationFullType) return defaultView;

    const modelName = documentationFullType.substring(0, documentationFullType.lastIndexOf('.'));
    const fieldName = documentationFullType.substring(documentationFullType.lastIndexOf('.') + 1);
    const model = utils.getModel(modelName, service, importedServices);
    const field = model ? model.fields.find(f => f.name === fieldName) : null;

    return (

 { this.container = el; }}
        className={classnames(styles.documentation)}
        style={{ minHeight: `${height}px` }}
      >
        <ParameterList {...field} service={service} importedServices={importedServices} parentModel={modelName} />

    );
  }
}

export default Documentation;
<commit_msg>use arrow func instead of bind<commit_after>// @flow
import React, { Component } from 'react';
import classnames from 'classnames';

import ParameterList from '../ParameterList';
import * as utils from '../../../utils';

import styles from './json-doc.css';
import type { Service } from '../../../generated/version/ServiceType';

const defaultView =
  (

    <-- Hover over JSON example for documentation

);

type Props = {
  documentationFullType: string,
  service: Service,
  importedServices: Service[],
};

class Documentation extends Component {
  props: Props;
  state: {
    height: number,
  };

  constructor(props: Props) {
    super(props);
    this.state = { height: 0 };
  }

  componentDidUpdate() {
    this.updateContainerHeight();
  }

  container: HTMLDivElement;

  updateContainerHeight = (): void => {
    const container = this.container;
    if (container) {
      const height = container.clientHeight;
      if (height > this.state.height) {
        this.setState({ height });
      }
    }
  };

  render() {
    const { documentationFullType, service, importedServices } = this.props;
    const { height } = this.state;
    if (!documentationFullType) return defaultView;

    const modelName = documentationFullType.substring(0, documentationFullType.lastIndexOf('.'));
    const fieldName = documentationFullType.substring(documentationFullType.lastIndexOf('.') + 1);
    const model = utils.getModel(modelName, service, importedServices);
    const field = model ? model.fields.find(f => f.name === fieldName) : null;

    return (

 { this.container = el; }}
        className={classnames(styles.documentation)}
        style={{ minHeight: `${height}px` }}
      >
        <ParameterList {...field} service={service} importedServices={importedServices} parentModel={modelName} />

    );
  }
}

export default Documentation;
<|endoftext|>


<commit_before>/* global prettyPrint */
(function($) {
	"use strict";

	var $window = $(window),
		$body = $('body'),
		urlHash = window.location.hash,
		scrollBuffer = false,

		// Nav vars
		$kssMenuToggle = $('.kss___header__toggleNav'),
		$kssMenuWrapper = $(".kss___navWrapper"),
		$kssMenu = $(".kss___nav"),
		$kssMenuItems = $kssMenu.find(".kss___nav__item"),
		$kssMenuActiveItem = $kssMenuItems.eq($kssMenu.data("kss-activemenuindex")),
		$kssMenuSub = $(".kss___navSub"),
		$kssMenuSubItems = $kssMenuSub.find(".kss___navSub__item"),
		kssMenuToggleActiveClass = 'kss___header__toggleNav--active',
		kssMenuIsOpenClass = 'kss___navIsOpen',
		kssMenuWrapperWidth = $kssMenuWrapper.outerWidth(),
		kssMenuStickyClass = "kss___nav--sticky",
		kssMenuSubActiveClass = "kss___navSub__item--active",
		kssMenuOffset = $kssMenu.offset().top,

		// Content related vars
		$kssSiteWrapper = $('.kss___siteWrapper'),
		$kssContentWrapper = $('.kss___contentWrapper'),

		// Initial setup of the application.
		init = function() {
			$kssMenuToggle.on("click", function(event){
				event.preventDefault();
				event.stopImmediatePropagation();

				toggleMenu();
			});
			$kssSiteWrapper.on('click', function() {
				closeMenu();
			});

			// Add the active class for the current item in the sideMenu.
			$kssMenuActiveItem.addClass("kss___nav__item--active");

			// Format the template.
			formatTemplate();

			if ($kssMenuSub.length) {
				// Render the submenu
				renderSubMenu();

				// Set the active class on the current item.
				scrollSpy();
				$window.on("scroll", function() {
					if (!scrollBuffer) {
						scrollBuffer = setTimeout(function () {
							scrollSpy();
							scrollBuffer = false;
						}, 60);
					}
				});
			}

			// Set the height of the sideNav as a min-height on the contentWrapper.
			$kssContentWrapper.css("min-height", $kssMenu.height());

			// Ensure code blocks are highlighted properly...
			prettyPrint();
		},

		renderSubMenu = function() {
			// Add the menu depth classes for each item.
			$kssMenuSubItems.each(function(index, elem) {
				var $this = $(elem),
					$referenceNum = $this.find('.kss___navSub__item__ref'),
					depth = $referenceNum.html().split('.').length;
				$this.addClass('kss___navSub__item--' + depth);
			});

			// Append the subMenu of the current item into the sideMenu.
			$kssMenuSub.appendTo(".kss___nav__item--active");
		},

		scrollSpy = function () {
			var scrollTop = $window.scrollTop(),
				$kssMenuSubAnchors = $kssMenuSub.find("a"),
				currentTargetHash,
				activeIndex;

			// Get the new index for the new active subMenuItem.
			$kssMenuSubAnchors.each(function (index) {
				var anchorHash = $(this).attr("href"),
					$anchorTarget = $(anchorHash.replace(/\./g, "\\.")),
					offsetTop = $anchorTarget.offset().top,
					offsetBottom = offsetTop + $anchorTarget.outerHeight(true);

				if (offsetTop <= scrollTop && scrollTop < offsetBottom) {
					activeIndex = index;
					currentTargetHash = anchorHash;
				}
			});

			// Set the active class on the subMenuItem.
			$kssMenuSubItems.removeClass(kssMenuSubActiveClass);
			if (typeof activeIndex !== "undefined") {
				$kssMenuSubItems.eq(activeIndex).addClass(kssMenuSubActiveClass);
				if(urlHash !== currentTargetHash) {
					history.replaceState(null, null, currentTargetHash);
					urlHash = currentTargetHash;
				}
			} else if(scrollTop < $($kssMenuSubAnchors.eq(0).attr("href").replace(/\./g, "\\.")).offset().top) {
				$kssMenuSubItems.eq(0).addClass(kssMenuSubActiveClass);
			}
		},
		formatTemplate = function() {
			$('.kss-box > p').each(function(index, elem) {
				var $this = $(elem),
					text = $this.html(),
					regExp = /(^<!= |, !&gt)/;

				if(regExp.test(text)) {
					text = text.replace('<!= ', '').replace(' !>', '');
					var $wrapper = $this.parent().parent(),
						array = text.split(' || ');

					// Check for code only sections.
					if(array.indexOf('isPureCode') !== -1) {
						$wrapper.addClass('kss___hideExamples');
					}

					// Set the optional 'css' code type on the prettyPrint element.
					if(array.indexOf('type: css') !== -1) {
						$wrapper.find('.kss-markup > pre').removeClass('lang-html').addClass('lang-css');
					}

					// Remove the marker element.
					$this.remove();
				}
			});
		},
		toggleMenu = function() {
			if($body.hasClass(kssMenuIsOpenClass)) {
				closeMenu();
			} else {
				openMenu();
			}
		},
		openMenu = function() {
			$kssMenuToggle.addClass(kssMenuToggleActiveClass);
			$body.addClass(kssMenuIsOpenClass);

			// Fallback for older browsers.
			if(!Modernizr.csstransforms) {
				$kssMenuWrapper.show().animate({
					left: '0'
				}, 400 );
				$kssSiteWrapper.animate({
					marginLeft: kssMenuWrapperWidth
				}, 400 );
			}
		},
		closeMenu = function() {
			$kssMenuToggle.removeClass(kssMenuToggleActiveClass);
			$body.removeClass(kssMenuIsOpenClass);

			// Fallback for older browsers.
			if(!Modernizr.csstransforms) {
				$kssMenuWrapper.animate({
					left: '-' + kssMenuWrapperWidth
				}, 400, function(){
					$kssMenuWrapper.hide();
				} );
				$kssSiteWrapper.animate({
					marginLeft: '0'
				}, 400 );
			}
		};

	init();
})(jQuery);
<commit_msg>[MISC] Code consistency<commit_after>/* global prettyPrint */
(function($) {
	"use strict";

	var $window = $(window),
		$body = $('body'),
		urlHash = window.location.hash,
		scrollBuffer = false,

		// Nav vars
		$kssMenuToggle = $('.kss___header__toggleNav'),
		$kssMenuWrapper = $(".kss___navWrapper"),
		$kssMenu = $(".kss___nav"),
		$kssMenuItems = $kssMenu.find(".kss___nav__item"),
		$kssMenuActiveItem = $kssMenuItems.eq($kssMenu.data("kss-activemenuindex")),
		$kssMenuSub = $(".kss___navSub"),
		$kssMenuSubItems = $kssMenuSub.find(".kss___navSub__item"),
		kssMenuToggleActiveClass = 'kss___header__toggleNav--active',
		kssMenuIsOpenClass = 'kss___navIsOpen',
		kssMenuWrapperWidth = $kssMenuWrapper.outerWidth(),
		kssMenuStickyClass = "kss___nav--sticky",
		kssMenuSubActiveClass = "kss___navSub__item--active",
		kssMenuOffset = $kssMenu.offset().top,

		// Content related vars
		$kssSiteWrapper = $('.kss___siteWrapper'),
		$kssContentWrapper = $('.kss___contentWrapper'),

		// Initial setup of the application.
		init = function() {
			$kssMenuToggle.on("click", function(event){
				event.preventDefault();
				event.stopImmediatePropagation();

				toggleMenu();
			});
			$kssSiteWrapper.on('click', function() {
				closeMenu();
			});

			// Add the active class for the current item in the sideMenu.
			$kssMenuActiveItem.addClass("kss___nav__item--active");

			// Format the template.
			formatTemplate();

			if ($kssMenuSub.length) {
				// Render the submenu.
				renderSubMenu();

				// Set the active class on the current item.
				scrollSpy();
				$window.on("scroll", function() {
					if (!scrollBuffer) {
						scrollBuffer = setTimeout(function () {
							scrollSpy();
							scrollBuffer = false;
						}, 60);
					}
				});
			}

			// Set the height of the sideNav as a min-height on the contentWrapper.
			$kssContentWrapper.css("min-height", $kssMenu.height());

			// Ensure code blocks are highlighted properly.
			prettyPrint();
		},

		renderSubMenu = function() {
			// Add the menu depth classes for each item.
			$kssMenuSubItems.each(function(index, elem) {
				var $this = $(elem),
					$referenceNum = $this.find('.kss___navSub__item__ref'),
					depth = $referenceNum.html().split('.').length;
				$this.addClass('kss___navSub__item--' + depth);
			});

			// Append the subMenu of the current item into the sideMenu.
			$kssMenuSub.appendTo(".kss___nav__item--active");
		},

		scrollSpy = function () {
			var scrollTop = $window.scrollTop(),
				$kssMenuSubAnchors = $kssMenuSub.find("a"),
				currentTargetHash,
				activeIndex;

			// Get the new index for the new active subMenuItem.
			$kssMenuSubAnchors.each(function (index) {
				var anchorHash = $(this).attr("href"),
					$anchorTarget = $(anchorHash.replace(/\./g, "\\.")),
					offsetTop = $anchorTarget.offset().top,
					offsetBottom = offsetTop + $anchorTarget.outerHeight(true);

				if (offsetTop <= scrollTop && scrollTop < offsetBottom) {
					activeIndex = index;
					currentTargetHash = anchorHash;
				}
			});

			// Set the active class on the subMenuItem.
			$kssMenuSubItems.removeClass(kssMenuSubActiveClass);
			if (typeof activeIndex !== "undefined") {
				$kssMenuSubItems.eq(activeIndex).addClass(kssMenuSubActiveClass);
				if(urlHash !== currentTargetHash) {
					history.replaceState(null, null, currentTargetHash);
					urlHash = currentTargetHash;
				}
			} else if(scrollTop < $($kssMenuSubAnchors.eq(0).attr("href").replace(/\./g, "\\.")).offset().top) {
				$kssMenuSubItems.eq(0).addClass(kssMenuSubActiveClass);
			}
		},
		formatTemplate = function() {
			$('.kss-box > p').each(function(index, elem) {
				var $this = $(elem),
					text = $this.html(),
					regExp = /(^<!= |, !&gt)/;

				if(regExp.test(text)) {
					text = text.replace('<!= ', '').replace(' !>', '');
					var $wrapper = $this.parent().parent(),
						array = text.split(' || ');

					// Check for code only sections.
					if(array.indexOf('isPureCode') !== -1) {
						$wrapper.addClass('kss___hideExamples');
					}

					// Set the optional 'css' code type on the prettyPrint element.
					if(array.indexOf('type: css') !== -1) {
						$wrapper.find('.kss-markup > pre').removeClass('lang-html').addClass('lang-css');
					}

					// Remove the marker element.
					$this.remove();
				}
			});
		},
		toggleMenu = function() {
			if($body.hasClass(kssMenuIsOpenClass)) {
				closeMenu();
			} else {
				openMenu();
			}
		},
		openMenu = function() {
			$kssMenuToggle.addClass(kssMenuToggleActiveClass);
			$body.addClass(kssMenuIsOpenClass);

			// Fallback for older browsers.
			if(!Modernizr.csstransforms) {
				$kssMenuWrapper.show().animate({
					left: '0'
				}, 400 );
				$kssSiteWrapper.animate({
					marginLeft: kssMenuWrapperWidth
				}, 400 );
			}
		},
		closeMenu = function() {
			$kssMenuToggle.removeClass(kssMenuToggleActiveClass);
			$body.removeClass(kssMenuIsOpenClass);

			// Fallback for older browsers.
			if(!Modernizr.csstransforms) {
				$kssMenuWrapper.animate({
					left: '-' + kssMenuWrapperWidth
				}, 400, function(){
					$kssMenuWrapper.hide();
				} );
				$kssSiteWrapper.animate({
					marginLeft: '0'
				}, 400 );
			}
		};

	init();
})(jQuery);
<|endoftext|>


<commit_before>module.exports = function () {
    var parseXMLString = require('xml2js').parseString,
        apiConstants = require('../../common/api-constants.js')(),
        httpService = require('../../common/http-service.js')();

    return {
        get: function () {
            var options = httpService.clone(apiConstants.cnn);
            return httpService.performGetRequest(options, dataTransformer);

            function dataTransformer(data) {
                var articlesArray = [];
                parseXMLString(data, function (err, result) {
                    result.rss.channel[0].item.forEach(function (newsItemData) {
                        articlesArray.push({
                            title: newsItemData.title[0],
                            shortInfo: newsItemData.description ? newsItemData.description[0] : '',
                            url: newsItemData.link[0],
                            image: newsItemData['media:group'] ? newsItemData['media:group'][0]['media:content'][0]['$'].url : null,
                            dateTime: newsItemData.pubDate ? newsItemData.pubDate[0] : ''
                        });
                    });
                });
                return articlesArray;
            }
        }
    };
};
<commit_msg>Minor model changes<commit_after>module.exports = function () {
    var parseXMLString = require('xml2js').parseString,
        apiConstants = require('../../common/api-constants.js')(),
        httpService = require('../../common/http-service.js')();

    return {
        get: function () {
            var options = httpService.clone(apiConstants.cnn);
            return httpService.performGetRequest(options, dataTransformer);

            function dataTransformer(data) {
                var articlesArray = [];
                parseXMLString(data, function (err, result) {
                    result.rss.channel[0].item.forEach(function (newsItemData) {
                        var currentNewsModel = {
                            title: newsItemData.title[0],
                            shortInfo: newsItemData.description ? newsItemData.description[0] : '',
                            url: newsItemData.link[0],
                            image: null,//newsItemData['media:group'] ? newsItemData['media:group'][0]['media:content'][0]['$'].url : null
                            dateTime: newsItemData.pubDate ? newsItemData.pubDate[0] : ''
                        };

                        if (currentNewsModel.shortInfo) {
                            articlesArray.push(currentNewsModel);
                        }
                    });
                });
                return articlesArray;
            }
        }
    };
};
<|endoftext|>


<commit_before>'use strict';

var mongoose = require('mongoose'),
    restify = require('restify'),
    Promise = require('bluebird'),
    rHandler = require('../lib/util/response-handlers'),
    CommonController = require('./common');

class LocationsController extends CommonController {
    constructor() {
        super();

        this.coroutines.findResource.main = Promise.coroutine(function* (req, res, next, config) {
            var maxdist = parseFloat(req.query.radius || 2000) / 6371,
                page = parseInt(req.query.page || 0),
                pagesize = parseInt(req.query.pagesize || 1000),
                geoquery, query, q;

            let uuid = req.params.region_uuid || req.params.uuid,
                region = yield mongoose.model('Region').findOne({$or: [{uuid: uuid}, {slug: uuid}]});

            if (!region) {
                return rHandler.handleErrorResponse(new restify.NotFoundError(), res, next);
            }

            // TODO: put this in lib
            var isAdmin = req.api_key && (
                    req.api_key.scopes.indexOf('admin') ||
                    req.api_key.scopes.indexOf('region-' + region.uuid)
                );

            geoquery = {
                region_uuid: region.uuid
            };

            if (req.query.longitude && req.query.latitude) {
                geoquery.lonlat = {
                    $near: [parseFloat(req.query.longitude || 10.0014), parseFloat(req.query.latitude || 53.5653)],
                    $maxDistance: maxdist
                };
            }

            if (!isAdmin) {
                geoquery.hidden = false;
            }

            query = require('../lib/util/query-mapping')(geoquery, req, config);
            q = mongoose.model(config.resource).find(query);
            if (req.query.sort) {
                q = q.sort(req.params.sort);
            }

            q = config.select ? q.select(config.select) : q;
            if (page < 0) page = 0;
            if (pagesize < 0) pagesize = 25;
            q = q.skip(page * pagesize).limit(pagesize);

            var data = yield q.exec(),
                result = {
                    page: page,
                    pagesize: pagesize,
                    total: yield mongoose.model(config.resource).count(q._conditions),
                    results: data
                };

            var output = [];
            return Promise.map(data, function (result) {
                return mongoose.model('User')
                    .findOne({uuid: result.user_uuid})
                    .select('uuid nickname').exec()
                    .then(function (user) {
                        result = result.toObject();
                        result.user = user;
                        return mongoose.model('Photo')
                            .findOne({location_uuid: result.uuid})
                            .select('thumb_url uuid extension')
                            .exec();
                    })
                    .then(function (photo) {
                        if (photo) {
                            result.thumb_url = photo.thumb_url;
                        }
                        return mongoose.model('Region')
                            .findOne({uuid: result.region_uuid})
                            .select('uuid title slug')
                            .exec();
                    })
                    .then(function (region) {
                        result.region = region;
                        output.push(result);
                    });
            })
            .then(function () {
                result.results = output;
                rHandler.handleDataResponse(result, 200, res, next);
            });

        });

        this.coroutines.searchResource = {
            pre: Promise.resolve,
            main: Promise.coroutine(function* (req, res, next, config) {
                var parts = req.params.q.split(' '),
                    query = {
                        $and: parts.map(function (part) {
                            var reg = new RegExp(part, 'i');
                            return {
                                $and: [
                                    { hidden: false },
                                    {
                                        $or: [
                                            {title: {$regex: reg}},
                                            {description: {$regex: reg}},
                                            {owner: {$regex: reg}},
                                            {street: {$regex: reg}},
                                            {city: {$regex: reg}},
                                            {postcode: {$regex: reg}},
                                            {street: {$regex: reg}}
                                        ]
                                    }
                                ]
                            };
                        })
                    };
                if (req.params.uuid) {
                    query.region_uuid = req.params.uuid;
                }
                var q = mongoose.model('Location').find(query);
                q = config.select ? q.select(config.select) : q;
                rHandler.handleDataResponse(yield q.exec(), 200, res, next);
            })
        };
    }
}

module.exports = LocationsController;<commit_msg>fix user location list<commit_after>'use strict';

var mongoose = require('mongoose'),
    restify = require('restify'),
    Promise = require('bluebird'),
    rHandler = require('../lib/util/response-handlers'),
    CommonController = require('./common');

class LocationsController extends CommonController {
    constructor() {
        super();

        this.coroutines.findResource.main = Promise.coroutine(function* (req, res, next, config) {
            var maxdist = parseFloat(req.query.radius || 2000) / 6371,
                page = parseInt(req.query.page || 0),
                pagesize = parseInt(req.query.pagesize || 1000),
                geoquery, query, q;

            let uuid = req.params.region_uuid || req.params.uuid,
                region = yield mongoose.model('Region').findOne({$or: [{uuid: uuid}, {slug: uuid}]});

            if (!region && !config.query.user_mapping) {
                return rHandler.handleErrorResponse(new restify.NotFoundError(), res, next);
            }

            geoquery = {};

            if (region) {
                // TODO: put this in lib
                var isAdmin = req.api_key && (
                        req.api_key.scopes.indexOf('admin') ||
                        req.api_key.scopes.indexOf('region-' + region.uuid)
                    );
                geoquery.region_uuid = region.uuid;
            }

            if (req.query.longitude && req.query.latitude) {
                geoquery.lonlat = {
                    $near: [parseFloat(req.query.longitude || 10.0014), parseFloat(req.query.latitude || 53.5653)],
                    $maxDistance: maxdist
                };
            }

            if (!isAdmin) {
                geoquery.hidden = false;
            }

            query = require('../lib/util/query-mapping')(geoquery, req, config);
            q = mongoose.model(config.resource).find(query);
            if (req.query.sort) {
                q = q.sort(req.params.sort);
            }

            q = config.select ? q.select(config.select) : q;
            if (page < 0) page = 0;
            if (pagesize < 0) pagesize = 25;
            q = q.skip(page * pagesize).limit(pagesize);

            var data = yield q.exec(),
                result = {
                    page: page,
                    pagesize: pagesize,
                    total: yield mongoose.model(config.resource).count(q._conditions),
                    results: data
                };

            var output = [];
            return Promise.map(data, function (result) {
                return mongoose.model('User')
                    .findOne({uuid: result.user_uuid})
                    .select('uuid nickname').exec()
                    .then(function (user) {
                        result = result.toObject();
                        result.user = user;
                        return mongoose.model('Photo')
                            .findOne({location_uuid: result.uuid})
                            .select('thumb_url uuid extension')
                            .exec();
                    })
                    .then(function (photo) {
                        if (photo) {
                            result.thumb_url = photo.thumb_url;
                        }
                        return mongoose.model('Region')
                            .findOne({uuid: result.region_uuid})
                            .select('uuid title slug')
                            .exec();
                    })
                    .then(function (region) {
                        result.region = region;
                        output.push(result);
                    });
            })
            .then(function () {
                result.results = output;
                rHandler.handleDataResponse(result, 200, res, next);
            });

        });

        this.coroutines.searchResource = {
            pre: Promise.resolve,
            main: Promise.coroutine(function* (req, res, next, config) {
                var parts = req.params.q.split(' '),
                    query = {
                        $and: parts.map(function (part) {
                            var reg = new RegExp(part, 'i');
                            return {
                                $and: [
                                    { hidden: false },
                                    {
                                        $or: [
                                            {title: {$regex: reg}},
                                            {description: {$regex: reg}},
                                            {owner: {$regex: reg}},
                                            {street: {$regex: reg}},
                                            {city: {$regex: reg}},
                                            {postcode: {$regex: reg}},
                                            {street: {$regex: reg}}
                                        ]
                                    }
                                ]
                            };
                        })
                    };
                if (req.params.uuid) {
                    query.region_uuid = req.params.uuid;
                }
                var q = mongoose.model('Location').find(query);
                q = config.select ? q.select(config.select) : q;
                rHandler.handleDataResponse(yield q.exec(), 200, res, next);
            })
        };
    }
}

module.exports = LocationsController;<|endoftext|>


<commit_before>import React, { Component } from 'react';

class Author extends Component {
  render() {
    const { firstname, lastname, company, presenter, ...rest } = this.props;
    let className = 'co-author';
    if (presenter) {
      className = 'presenter';
    }
    const fullName = `${firstname} ${lastname}`;

    return (

        {fullName}, {company}

    );
  }
}

export default Author;
<commit_msg>I like to have text as variables<commit_after>import React, { Component } from 'react';

class Author extends Component {
  render() {
    const { firstname, lastname, company, presenter, ...rest } = this.props;
    let className = 'co-author';
    if (presenter) {
      className = 'presenter';
    }
    const fullName = `${firstname} ${lastname}`;
    const seperator = ', ';
    return (

        {fullName}
        {seperator}
        {company}

    );
  }
}

export default Author;
<|endoftext|>


<commit_before>// This module defines the Angular controller that renders the Chord Diagram.
define(function(require) {

  // Load D3 v4 via our custom bundle build output.
  var d3 = require("../d3/d3.min");

  // Load the module that defines the Chord Diagram using D3.
  var ChordDiagram = require("./chordDiagram");

  // Load the module that defines the HTML Table using D3.
  var Table = require("./table");

  // Access the Kibana plugin Angular module.
  var module = require("ui/modules").get("kibana-chord");

  // Create a time formatter for the timestamp in the table.
  var formatTime = d3.timeFormat("%b %d, %y %X");

  // Register the controller with the Kibana plugin Angular module.
  module.controller("ChordController", function($scope, $rootScope, Private, $element, $http) {

    // Inject the tabify utility from Kibana internals.
    var tabifyAggResponse = Private(require("ui/agg_response/tabify/tabify"));

    // Access the DOM element provided by Angular's dependency injection.
    var div = $element[0];

    // Construct a Bootstrap Grid to position the Chord Diagram and Table.
    var container = d3.select(div).style("width", "100%")
          .append("div").attr("class", "container-fluid")
          .append("div").attr("class", "row"),
        chordContainer = container.append("div")
          .attr("class", "col-md-6").node(),
        tableContainer = container.append("div")
          .attr("class", "col-md-6");

    // These two divs will go in the column to the right.
    var tableHeaderContainer = tableContainer.append("div")
          .style("font-size", "2em")
          .style("margin-top", "0.5em"),
        tableBodyContainer = tableContainer.append("div").node();

    // Construct an instance of the Chord Diagram.
    var chordDiagram = ChordDiagram(chordContainer);

    // Construct an instance of the HTML Table.
    var table = Table(tableBodyContainer);

    // Converts hierarchical result set from ElasticSearch into a tabular form.
    // Returns an array of row objects, similar to the format returned by d3.csv.
    function tabify(response){

      var tabified = tabifyAggResponse($scope.vis, response, {
        asAggConfigResults: true
      });

      // Handle the case of a filter being applied in "Split Chart",
      // which yields a nested data structure with the table one level deeper.
      if("tables" in tabified.tables[0]){
        tabified = tabified.tables[0];
      }

      return tabified.tables[0].rows.map(function (array){
        var row = {};
        array.forEach(function (entry){
          row[entry.aggConfig.id] = entry.value;
        });
        return row;
      });
    }

    // Update the visualization with new data as the query response changes.
    $scope.$watch("esResponse", function(response) {

      // Guard against undefined value, which always occurs
      // after the plugin is loaded and before the data gets loaded.
      if(response){

        // Tabify the response.
        var data = tabify(response);

        // Pass the fresh data into the Chord Diagram.
        chordDiagram.data(data);

        // Render the Chord Diagram.
        chordDiagram();

        // Update the table (if a ribbon is currently selected).
        // This is invoked here to handle the case of auto-refresh.
        if(chordDiagram.selectedRibbon()){
          updateTable();
        }
      }
    });

    // Updates the details table based on the selected chord.
    function updateTable(){

      // Get the currently selected ribbon.
      var selectedRibbon = chordDiagram.selectedRibbon();

      if(selectedRibbon){

        // Update the table header.
        tableHeaderContainer.text(
          "Flows between " + selectedRibbon.source +
          " and " + selectedRibbon.destination
        );

        // Extract the time interval from the global timeFilter.
        var timeBounds = $rootScope.timefilter.getBounds();

        // Construct the HTTP POST payload for the query middleware.
        var options = {
          source: selectedRibbon.source,
          destination: selectedRibbon.destination,
          index: $scope.vis.indexPattern.id,
          time: {
            gte: timeBounds.min.toDate().getTime(),
            lte: timeBounds.max.toDate().getTime(),
            format: "epoch_millis"
          }
        };

        // Invoke the query middleware, then render it into the table.
        $http
          .post("/api/kibana-chord", options)
          .then(function successCallback(response){

            // Transform the response data into a form the table can use.
            var data = response.data.hits.hits.map(function (d){
              d = d._source;

              // Format timestamp as human-readable date.
              d.timestamp = formatTime(new Date(d.timestamp));

              // Add source and dest attribute to be used in table
              d.source = d.nuage_metadata.sourcepolicygroups;
              d.dest = d.nuage_metadata.destinationpolicygroups;

              return d;
            });

            // Render the HTML Table.
            table(data, [
              { title: "Source IP", property: "sourceip" },
              { title: "Dest IP", property: "destinationip" },
              { title: "Source PG", property: "source" },
              { title: "Dest PG", property: "dest" },
              { title: "Type", property: "type" },
              { title: "Timestamp", property: "timestamp" },
              { title: "Packets", property: "packets" }
            ]);

          }, function errorCallback(response){
            throw response;
          });

      // If there is no selected ribbon, then
      } else {

        // clear the table header,
        tableHeaderContainer.text("");

        // clear the existing table.
        table([], []);

      }
    }

    // Invoke our custom middleware for querying ElasticSearch
    // when the user clicks on the ribbon.
    chordDiagram.onSelectedRibbonChange(updateTable);
  });
});
<commit_msg>Access scroll id in client<commit_after>// This module defines the Angular controller that renders the Chord Diagram.
define(function(require) {

  // Load D3 v4 via our custom bundle build output.
  var d3 = require("../d3/d3.min");

  // Load the module that defines the Chord Diagram using D3.
  var ChordDiagram = require("./chordDiagram");

  // Load the module that defines the HTML Table using D3.
  var Table = require("./table");

  // Access the Kibana plugin Angular module.
  var module = require("ui/modules").get("kibana-chord");

  // Create a time formatter for the timestamp in the table.
  var formatTime = d3.timeFormat("%b %d, %y %X");

  // Register the controller with the Kibana plugin Angular module.
  module.controller("ChordController", function($scope, $rootScope, Private, $element, $http) {

    // Inject the tabify utility from Kibana internals.
    var tabifyAggResponse = Private(require("ui/agg_response/tabify/tabify"));

    // Access the DOM element provided by Angular's dependency injection.
    var div = $element[0];

    // Construct a Bootstrap Grid to position the Chord Diagram and Table.
    var container = d3.select(div).style("width", "100%")
          .append("div").attr("class", "container-fluid")
          .append("div").attr("class", "row"),
        chordContainer = container.append("div")
          .attr("class", "col-md-6").node(),
        tableContainer = container.append("div")
          .attr("class", "col-md-6");

    // These two divs will go in the column to the right.
    var tableHeaderContainer = tableContainer.append("div")
          .style("font-size", "2em")
          .style("margin-top", "0.5em"),
        tableBodyContainer = tableContainer.append("div").node();

    // Construct an instance of the Chord Diagram.
    var chordDiagram = ChordDiagram(chordContainer);

    // Construct an instance of the HTML Table.
    var table = Table(tableBodyContainer);

    // Converts hierarchical result set from ElasticSearch into a tabular form.
    // Returns an array of row objects, similar to the format returned by d3.csv.
    function tabify(response){

      var tabified = tabifyAggResponse($scope.vis, response, {
        asAggConfigResults: true
      });

      // Handle the case of a filter being applied in "Split Chart",
      // which yields a nested data structure with the table one level deeper.
      if("tables" in tabified.tables[0]){
        tabified = tabified.tables[0];
      }

      return tabified.tables[0].rows.map(function (array){
        var row = {};
        array.forEach(function (entry){
          row[entry.aggConfig.id] = entry.value;
        });
        return row;
      });
    }

    // Update the visualization with new data as the query response changes.
    $scope.$watch("esResponse", function(response) {

      // Guard against undefined value, which always occurs
      // after the plugin is loaded and before the data gets loaded.
      if(response){

        // Tabify the response.
        var data = tabify(response);

        // Pass the fresh data into the Chord Diagram.
        chordDiagram.data(data);

        // Render the Chord Diagram.
        chordDiagram();

        // Update the table (if a ribbon is currently selected).
        // This is invoked here to handle the case of auto-refresh.
        if(chordDiagram.selectedRibbon()){
          updateTable();
        }
      }
    });

    // Updates the details table based on the selected chord.
    function updateTable(){

      // Get the currently selected ribbon.
      var selectedRibbon = chordDiagram.selectedRibbon();

      if(selectedRibbon){

        // Update the table header.
        tableHeaderContainer.text(
          "Flows between " + selectedRibbon.source +
          " and " + selectedRibbon.destination
        );

        // Extract the time interval from the global timeFilter.
        var timeBounds = $rootScope.timefilter.getBounds();

        // Construct the HTTP POST payload for the query middleware.
        var options = {
          source: selectedRibbon.source,
          destination: selectedRibbon.destination,
          index: $scope.vis.indexPattern.id,
          time: {
            gte: timeBounds.min.toDate().getTime(),
            lte: timeBounds.max.toDate().getTime(),
            format: "epoch_millis"
          }
        };

        // Invoke the query middleware, then render it into the table.
        $http
          .post("/api/kibana-chord", options)
          .then(function successCallback(response){

            console.log(response._scroll_id);

            // Transform the response data into a form the table can use.
            var data = response.data.hits.hits.map(function (d){
              d = d._source;

              // Format timestamp as human-readable date.
              d.timestamp = formatTime(new Date(d.timestamp));

              // Add source and dest attribute to be used in table
              d.source = d.nuage_metadata.sourcepolicygroups;
              d.dest = d.nuage_metadata.destinationpolicygroups;

              return d;
            });

            // Render the HTML Table.
            table(data, [
              { title: "Source IP", property: "sourceip" },
              { title: "Dest IP", property: "destinationip" },
              { title: "Source PG", property: "source" },
              { title: "Dest PG", property: "dest" },
              { title: "Type", property: "type" },
              { title: "Timestamp", property: "timestamp" },
              { title: "Packets", property: "packets" }
            ]);

          }, function errorCallback(response){
            throw response;
          });

      // If there is no selected ribbon, then
      } else {

        // clear the table header,
        tableHeaderContainer.text("");

        // clear the existing table.
        table([], []);

      }
    }

    // Invoke our custom middleware for querying ElasticSearch
    // when the user clicks on the ribbon.
    chordDiagram.onSelectedRibbonChange(updateTable);
  });
});
<|endoftext|>


<commit_before>const Discord = require('discord.js');
const Util = require('../classes/Util.js');

module.exports.name = 'logwarning';
module.exports.alias = ['log', 'silentwarn', 'silent'];

module.exports.isAllowed = (message, server) => {
  return server.hiddenChannels.includes(message.channel.id);
};

module.exports.help = 'Warn a user silently `,log <User> <Warning message>';

module.exports.command = async (message, content, bot, server) => {
  if (content == '') {
    message.channel.send('Please specify a user with an ID or mention them');
    return;
  }

  let member;
  let mentions = message.mentions.members;
  if (mentions.size != 0) {
    member = mentions.first();
    content = content.replace(Util.REGEX_USER, '');
  } else {
    const idMatch = content.match(Util.REGEX_RAW_ID);
    if (idMatch) {
      member = await server.guild.member(idMatch[0]);
      content = content.replace(idMatch[0], '');
    }
  }
  if (!member) {
    message.channel.send('Failed to get a member');
    return;
  }

  content = content.trim();

  if (!content) {
    message.channel.send('There must be a warning message');
    return;
  }
  const warning = {
    issued: message.createdTimestamp,
    issuer: message.author.id,
    link: message.url,
    silent: true,
    warnMessage: content,
  };

  if (server.warnlist[member.id]) {
    server.warnlist[member.id].push(warning);
  } else {
    server.warnlist[member.id] = [warning];
  }
  message.channel.send({
    embed: new Discord.MessageEmbed()
      .setDescription(
        `Logged the warning for ${member} by ${message.author}. (They did not receive the warning from Ciri) `
      )
      .setColor('0x42f46b'),
  });
  server.save();
};
<commit_msg>allow log<commit_after>const Discord = require('discord.js');
const Util = require('../classes/Util.js');

module.exports.name = 'logwarning';
module.exports.alias = ['log', 'silentwarn', 'silent'];

module.exports.isAllowed = (message, server) => {
  return (
    server.hiddenChannels.includes(message.channel.id) ||
    (server.guild.id === '189571157446492161' &&
      (message.member.hasPermission('BAN_MEMBERS') ||
        message.member.roles.cache.has('543721608506900480')))
  );
};

module.exports.help = 'Warn a user silently `,log <User> <Warning message>';

module.exports.command = async (message, content, bot, server) => {
  if (content == '') {
    message.channel.send('Please specify a user with an ID or mention them');
    return;
  }

  let member;
  let mentions = message.mentions.members;
  if (mentions.size != 0) {
    member = mentions.first();
    content = content.replace(Util.REGEX_USER, '');
  } else {
    const idMatch = content.match(Util.REGEX_RAW_ID);
    if (idMatch) {
      member = await server.guild.member(idMatch[0]);
      content = content.replace(idMatch[0], '');
    }
  }
  if (!member) {
    message.channel.send('Failed to get a member');
    return;
  }

  content = content.trim();

  if (!content) {
    message.channel.send('There must be a warning message');
    return;
  }
  const warning = {
    issued: message.createdTimestamp,
    issuer: message.author.id,
    link: message.url,
    silent: true,
    warnMessage: content,
  };

  if (server.warnlist[member.id]) {
    server.warnlist[member.id].push(warning);
  } else {
    server.warnlist[member.id] = [warning];
  }
  message.channel.send({
    embed: new Discord.MessageEmbed()
      .setDescription(
        `Logged the warning for ${member} by ${message.author}. (They did not receive the warning from Ciri) `
      )
      .setColor('0x42f46b'),
  });
  server.save();
};
<|endoftext|>


<commit_before>Ext.form.BasicForm.override({
    resetDirty: function() {
        this.items.each(function(field) {
            field.resetDirty();
        });
    },
    setDefaultValues: function() {
        this.items.each(function(field) {
            field.setDefaultValue();
        }, this);
    },
    clearValues: function() {
        this.items.each(function(field) {
            field.clearValue();
        }, this);
    },

    //override stupid Ext behavior
    //better to ask the individual form fields
    //needed for: Checkbox, ComboBox, SwfUpload, Date...
    getValues: function() {
        var ret = {};
        debugger;
        this.items.each(function(field) {
            var v = field.getValue();
            if (v instanceof Date) {
                v = v.format("Y-m-d");
            }
            ret[field.getName()] = v;
        }, this);
        return ret;
    }
});
<commit_msg>debugger entfernt<commit_after>Ext.form.BasicForm.override({
    resetDirty: function() {
        this.items.each(function(field) {
            field.resetDirty();
        });
    },
    setDefaultValues: function() {
        this.items.each(function(field) {
            field.setDefaultValue();
        }, this);
    },
    clearValues: function() {
        this.items.each(function(field) {
            field.clearValue();
        }, this);
    },

    //override stupid Ext behavior
    //better to ask the individual form fields
    //needed for: Checkbox, ComboBox, SwfUpload, Date...
    getValues: function() {
        var ret = {};
        this.items.each(function(field) {
            var v = field.getValue();
            if (v instanceof Date) {
                v = v.format("Y-m-d");
            }
            ret[field.getName()] = v;
        }, this);
        return ret;
    }
});
<|endoftext|>


<commit_before>[
  {
 		"name": "Indian Mountains",
 		"author": "Hiten Soni",
 		"thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Mountains-India.jpg",
 		"url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Mountains-India.jpg"
 		},
  {
    "name": "Photography",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_1.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_1.jpg"
  },
  {
    "name": "Photography 2",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_2.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_2.jpg"
  },
  {
    "name": "Photography 3",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_3.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_3.jpg"
  },
  {
    "name": "Photography 4",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_4.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_4.jpg"
  },
  {
    "name": "Photography 5",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_5.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_5.jpg"
  },
  {
    "name": "Photography 6",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_6.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_6.jpg"
  },
  {
    "name": "Photography 7",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_7.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_7.jpg"
  },
  {
    "name": "Photography 8",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_8.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_8.jpg"
  },
  {
    "name": "Photography 9",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_9.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_9.jpg"
  },
  {
    "name": "Photography 10",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_10.jpg",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_10.jpg"
  },
  {
    "name": "Deep",
    "author": "Hiten Soni",
    "url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Deep.JPG",
    "thumb_url": "https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Deep.JPG"
  }
]
<commit_msg>Update Photography.js<commit_after>[
   {
      "name":"Indian Mountains",
      "author":"Hiten Soni",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Mountains-India.jpg",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Mountains-India.jpg"
   },
   {
      "name":"Photography",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_1.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_1.jpg"
   },
   {
      "name":"Photography 2",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_2.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_2.jpg"
   },
   {
      "name":"Photography 3",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_3.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_3.jpg"
   },
   {
      "name":"Photography 4",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_4.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_4.jpg"
   },
   {
      "name":"Photography 5",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_5.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_5.jpg"
   },
   {
      "name":"Photography 6",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_6.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_6.jpg"
   },
   {
      "name":"Photography 7",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_7.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_7.jpg"
   },
   {
      "name":"Photography 8",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_8.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_8.jpg"
   },
   {
      "name":"Photography 9",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_9.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_9.jpg"
   },
   {
      "name":"Photography 10",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Photography_10.jpg",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Photography_10.jpg"
   },
   {
      "name":"Deep",
      "author":"Hiten Soni",
      "url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Photography/Deep.JPG",
      "thumb_url":"https://raw.githubusercontent.com/hiten1985/Backgrounds/master/Walls/Thumbs/Deep.JPG"
   }
]
<|endoftext|>


<commit_before>goog.provide('ol.MapBrowserEvent');
goog.provide('ol.MapBrowserEvent.EventType');
goog.provide('ol.MapBrowserEventHandler');
goog.provide('ol.MapBrowserPointerEvent');

goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.BrowserEvent');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
goog.require('goog.object');

goog.require('ol.Coordinate');
goog.require('ol.MapEvent');
goog.require('ol.Pixel');
goog.require('ol.pointer.PointerEvent');
goog.require('ol.pointer.PointerEventHandler');

/**
 * @constructor
 * @extends {ol.MapEvent}
 * @implements {oli.MapBrowserEvent}
 * @param {string} type Event type.
 * @param {ol.Map} map Map.
 * @param {goog.events.BrowserEvent} browserEvent Browser event.
 * @param {?oli.FrameState=} opt_frameState Frame state.
 * @todo stability experimental
 */
ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {

  goog.base(this, type, map, opt_frameState);

  /**
   * @const
   * @type {goog.events.BrowserEvent}
   */
  this.browserEvent = browserEvent;

  /**
   * @const
   * @type {Event}
   */
  this.originalEvent = browserEvent.getBrowserEvent();

  /**
   * @type {ol.Coordinate}
   */
  this.coordinate = map.getEventCoordinate(this.originalEvent);

  /**
   * @type {ol.Pixel}
   */
  this.pixel = map.getEventPixel(this.originalEvent);

};
goog.inherits(ol.MapBrowserEvent, ol.MapEvent);

/**
 * Prevents the default browser action.
 * @see https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault
 * @override
 * @todo stability experimental
 */
ol.MapBrowserEvent.prototype.preventDefault = function() {
  goog.base(this, 'preventDefault');
  this.browserEvent.preventDefault();
};

/**
 * Prevents further propagation of the current event.
 * @see https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation
 * @override
 * @todo stability experimental
 */
ol.MapBrowserEvent.prototype.stopPropagation = function() {
  goog.base(this, 'stopPropagation');
  this.browserEvent.stopPropagation();
};

/**
 * @constructor
 * @extends {ol.MapBrowserEvent}
 * @param {string} type Event type.
 * @param {ol.Map} map Map.
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @param {?ol.FrameState=} opt_frameState Frame state.
 * @todo stability experimental
 */
ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_frameState) {

  goog.base(this, type, map, pointerEvent.browserEvent, opt_frameState);

  /**
   * @const
   * @type {ol.pointer.PointerEvent}
   */
  this.pointerEvent = pointerEvent;

};
goog.inherits(ol.MapBrowserPointerEvent, ol.MapBrowserEvent);

/**
 * @param {ol.Map} map The map with the viewport to listen to events on.
 * @constructor
 * @extends {goog.events.EventTarget}
 */
ol.MapBrowserEventHandler = function(map) {

  goog.base(this);

  /**
   * This is the element that we will listen to the real events on.
   * @type {ol.Map}
   * @private
   */
  this.map_ = map;

  /**
   * @type {number}
   * @private
   */
  this.clickTimeoutId_ = 0;

  /**
   * @type {boolean}
   * @private
   */
  this.dragged_ = false;

  /**
   * @type {Array.<number>}
   * @private
   */
  this.dragListenerKeys_ = null;

  /**
   * @type {goog.events.Key}
   * @private
   */
  this.pointerdownListenerKey_ = null;

  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    /**
     * @type {goog.events.Key}
     * @private
     */
    this.ieDblclickListenerKey_ = null;
  }

  /**
   * @type {ol.pointer.PointerEvent}
   * @private
   */
  this.down_ = null;

  var element = this.map_.getViewport();

  /**
   * @type {number}
   * @private
   */
  this.activePointers_ = 0;

  /**
   * @type {Object.<number, boolean>}
   * @private
   */
  this.trackedTouches_ = {};

  /**
   * Event handler which generates pointer events for
   * the viewport element.
   *
   * @type {ol.pointer.PointerEventHandler}
   * @private
   */
  this.pointerEventHandler_ = new ol.pointer.PointerEventHandler(element);

  /**
   * Event handler which generates pointer events for
   * the document (used when dragging).
   *
   * @type {ol.pointer.PointerEventHandler}
   * @private
   */
  this.documentPointerEventHandler_ = null;

  this.pointerdownListenerKey_ = goog.events.listen(this.pointerEventHandler_,
      ol.pointer.EventType.POINTERDOWN,
      this.handlePointerDown_, false, this);

  this.relayedListenerKey_ = goog.events.listen(this.pointerEventHandler_,
      ol.pointer.EventType.POINTERMOVE,
      this.relayEvent_, false, this);

  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    /*
     * On legacy IE, double clicks do not produce two mousedown and
     * mouseup events. That is why a separate DBLCLICK event listener
     * is used.
     */
    this.ieDblclickListenerKey_ = goog.events.listen(element,
        goog.events.EventType.DBLCLICK,
        this.emulateClickLegacyIE_, false, this);
  }

};
goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget);

/**
 * Get the last "down" type event. This will be set on pointerdown.
 * @return {ol.pointer.PointerEvent} The most recent "down" type event (or null
 * if none have occurred).
 */
ol.MapBrowserEventHandler.prototype.getDown = function() {
  return this.down_;
};

/**
 * @param {goog.events.BrowserEvent} browserEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.emulateClickLegacyIE_ =
    function(browserEvent) {
  var pointerEvent = this.pointerEventHandler_.wrapMouseEvent(
      ol.MapBrowserEvent.EventType.POINTERUP,
      browserEvent
      );
  this.emulateClick_(pointerEvent);
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
  if (this.clickTimeoutId_ !== 0) {
    // double-click
    goog.global.clearTimeout(this.clickTimeoutId_);
    this.clickTimeoutId_ = 0;
    var newEvent = new ol.MapBrowserPointerEvent(
        ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, pointerEvent);
    this.dispatchEvent(newEvent);
  } else {
    // click
    this.clickTimeoutId_ = goog.global.setTimeout(goog.bind(function() {
      this.clickTimeoutId_ = 0;
      var newEvent = new ol.MapBrowserPointerEvent(
          ol.MapBrowserEvent.EventType.SINGLECLICK, this.map_, pointerEvent);
      this.dispatchEvent(newEvent);
    }, this), 250);
  }
};

/**
 * Keeps track on how many pointers are currently active.
 *
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.updateActivePointers_ =
    function(pointerEvent) {
  var event = pointerEvent;

  if (event.type == ol.MapBrowserEvent.EventType.POINTERUP ||
      event.type == ol.MapBrowserEvent.EventType.POINTERCANCEL) {
    delete this.trackedTouches_[event.pointerId];
  } else if (event.type == ol.MapBrowserEvent.EventType.POINTERDOWN) {
    this.trackedTouches_[event.pointerId] = true;
  }
  this.activePointers_ = goog.object.getCount(this.trackedTouches_);
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
  this.updateActivePointers_(pointerEvent);
  var newEvent = new ol.MapBrowserPointerEvent(
      ol.MapBrowserEvent.EventType.POINTERUP, this.map_, pointerEvent);
  this.dispatchEvent(newEvent);

  goog.asserts.assert(this.activePointers_ >= 0);
  if (this.activePointers_ === 0) {
    goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
    this.dragListenerKeys_ = null;
    goog.dispose(this.documentPointerEventHandler_);
    this.documentPointerEventHandler_ = null;
  }

  // We emulate click event on left mouse button click, touch contact, and pen
  // contact. isMouseActionButton returns true in these cases (evt.button is set
  // to 0).
  // See http://www.w3.org/TR/pointerevents/#button-states
  if (!this.dragged_ && this.isMouseActionButton_(pointerEvent)) {
    goog.asserts.assert(!goog.isNull(this.down_));
    this.emulateClick_(this.down_);
  }
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @return {boolean} If the left mouse button was pressed.
 * @private
 */
ol.MapBrowserEventHandler.prototype.isMouseActionButton_ =
    function(pointerEvent) {
  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    return pointerEvent.button == 1;
  } else {
    return pointerEvent.button == 0;
  }
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerDown_ =
    function(pointerEvent) {
  this.updateActivePointers_(pointerEvent);
  var newEvent = new ol.MapBrowserPointerEvent(
      ol.MapBrowserEvent.EventType.POINTERDOWN, this.map_, pointerEvent);
  this.dispatchEvent(newEvent);

  this.down_ = pointerEvent;
  this.dragged_ = false;

  if (goog.isNull(this.dragListenerKeys_)) {
    /* Set up a pointer event handler on the `document`,
     * which is required when the pointer is moved outside
     * the viewport when dragging.
     */
    this.documentPointerEventHandler_ =
        new ol.pointer.PointerEventHandler(document);

    this.dragListenerKeys_ = [
      goog.events.listen(this.documentPointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERMOVE,
          this.handlePointerMove_, false, this),
      goog.events.listen(this.documentPointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERUP,
          this.handlePointerUp_, false, this),
      goog.events.listen(this.pointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERCANCEL,
          this.handlePointerUp_, false, this)
    ];
  }

  // FIXME check if/when this is necessary
  // prevent context menu
  pointerEvent.preventDefault();
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
    function(pointerEvent) {
  // Fix IE10 on windows Surface : When you tap the tablet, it triggers
  // multiple pointermove events between pointerdown and pointerup with
  // the exact same coordinates of the pointerdown event. To avoid a
  // 'false' touchmove event to be dispatched , we test if the pointer
  // effectively moved.
  if (pointerEvent.clientX != this.down_.clientX ||
      pointerEvent.clientY != this.down_.clientY) {
    this.dragged_ = true;
    var newEvent = new ol.MapBrowserPointerEvent(
        ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent);
    this.dispatchEvent(newEvent);
  }

  // Some native android browser triggers mousemove events during small period
  // of time. See: https://code.google.com/p/android/issues/detail?id=5491 or
  // https://code.google.com/p/android/issues/detail?id=19827
  // ex: Galaxy Tab P3110 + Android 4.1.1
  pointerEvent.preventDefault();
};

/**
 * Wrap and relay a pointer event.  Note that this requires that the type
 * string for the MapBrowserPointerEvent matches the PointerEvent type.
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
  this.dispatchEvent(new ol.MapBrowserPointerEvent(
      pointerEvent.type, this.map_, pointerEvent));
};

/**
 * @inheritDoc
 */
ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
  if (!goog.isNull(this.relayedListenerKey_)) {
    goog.events.unlistenByKey(this.relayedListenerKey_);
    this.relayedListenerKey_ = null;
  }
  if (!goog.isNull(this.pointerdownListenerKey_)) {
    goog.events.unlistenByKey(this.pointerdownListenerKey_);
    this.pointerdownListenerKey_ = null;
  }
  if (!goog.isNull(this.dragListenerKeys_)) {
    goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
    this.dragListenerKeys_ = null;
  }
  if (!goog.isNull(this.documentPointerEventHandler_)) {
    goog.dispose(this.documentPointerEventHandler_);
    this.documentPointerEventHandler_ = null;
  }
  if (!goog.isNull(this.pointerEventHandler_)) {
    goog.dispose(this.pointerEventHandler_);
    this.pointerEventHandler_ = null;
  }
  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE &&
      !goog.isNull(this.ieDblclickListenerKey_)) {
    goog.events.unlistenByKey(this.ieDblclickListenerKey_);
    this.ieDblclickListenerKey_ = null;
  }
  goog.base(this, 'disposeInternal');
};

/**
 * Constants for event names.
 * @enum {string}
 */
ol.MapBrowserEvent.EventType = {
  SINGLECLICK: 'singleclick',
  DBLCLICK: goog.events.EventType.DBLCLICK,
  POINTERDRAG: 'pointermove',

  POINTERMOVE: 'pointermove',
  POINTERDOWN: 'pointerdown',
  POINTERUP: 'pointerup',
  POINTEROVER: 'pointerover',
  POINTEROUT: 'pointerout',
  POINTERENTER: 'pointerenter',
  POINTERLEAVE: 'pointerleave',
  POINTERCANCEL: 'pointercancel'
};
<commit_msg>Fix type annotation<commit_after>goog.provide('ol.MapBrowserEvent');
goog.provide('ol.MapBrowserEvent.EventType');
goog.provide('ol.MapBrowserEventHandler');
goog.provide('ol.MapBrowserPointerEvent');

goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.BrowserEvent');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
goog.require('goog.object');

goog.require('ol.Coordinate');
goog.require('ol.MapEvent');
goog.require('ol.Pixel');
goog.require('ol.pointer.PointerEvent');
goog.require('ol.pointer.PointerEventHandler');

/**
 * @constructor
 * @extends {ol.MapEvent}
 * @implements {oli.MapBrowserEvent}
 * @param {string} type Event type.
 * @param {ol.Map} map Map.
 * @param {goog.events.BrowserEvent} browserEvent Browser event.
 * @param {?oli.FrameState=} opt_frameState Frame state.
 * @todo stability experimental
 */
ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {

  goog.base(this, type, map, opt_frameState);

  /**
   * @const
   * @type {goog.events.BrowserEvent}
   */
  this.browserEvent = browserEvent;

  /**
   * @const
   * @type {Event}
   */
  this.originalEvent = browserEvent.getBrowserEvent();

  /**
   * @type {ol.Coordinate}
   */
  this.coordinate = map.getEventCoordinate(this.originalEvent);

  /**
   * @type {ol.Pixel}
   */
  this.pixel = map.getEventPixel(this.originalEvent);

};
goog.inherits(ol.MapBrowserEvent, ol.MapEvent);

/**
 * Prevents the default browser action.
 * @see https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault
 * @override
 * @todo stability experimental
 */
ol.MapBrowserEvent.prototype.preventDefault = function() {
  goog.base(this, 'preventDefault');
  this.browserEvent.preventDefault();
};

/**
 * Prevents further propagation of the current event.
 * @see https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation
 * @override
 * @todo stability experimental
 */
ol.MapBrowserEvent.prototype.stopPropagation = function() {
  goog.base(this, 'stopPropagation');
  this.browserEvent.stopPropagation();
};

/**
 * @constructor
 * @extends {ol.MapBrowserEvent}
 * @param {string} type Event type.
 * @param {ol.Map} map Map.
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @param {?oli.FrameState=} opt_frameState Frame state.
 * @todo stability experimental
 */
ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_frameState) {

  goog.base(this, type, map, pointerEvent.browserEvent, opt_frameState);

  /**
   * @const
   * @type {ol.pointer.PointerEvent}
   */
  this.pointerEvent = pointerEvent;

};
goog.inherits(ol.MapBrowserPointerEvent, ol.MapBrowserEvent);

/**
 * @param {ol.Map} map The map with the viewport to listen to events on.
 * @constructor
 * @extends {goog.events.EventTarget}
 */
ol.MapBrowserEventHandler = function(map) {

  goog.base(this);

  /**
   * This is the element that we will listen to the real events on.
   * @type {ol.Map}
   * @private
   */
  this.map_ = map;

  /**
   * @type {number}
   * @private
   */
  this.clickTimeoutId_ = 0;

  /**
   * @type {boolean}
   * @private
   */
  this.dragged_ = false;

  /**
   * @type {Array.<number>}
   * @private
   */
  this.dragListenerKeys_ = null;

  /**
   * @type {goog.events.Key}
   * @private
   */
  this.pointerdownListenerKey_ = null;

  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    /**
     * @type {goog.events.Key}
     * @private
     */
    this.ieDblclickListenerKey_ = null;
  }

  /**
   * @type {ol.pointer.PointerEvent}
   * @private
   */
  this.down_ = null;

  var element = this.map_.getViewport();

  /**
   * @type {number}
   * @private
   */
  this.activePointers_ = 0;

  /**
   * @type {Object.<number, boolean>}
   * @private
   */
  this.trackedTouches_ = {};

  /**
   * Event handler which generates pointer events for
   * the viewport element.
   *
   * @type {ol.pointer.PointerEventHandler}
   * @private
   */
  this.pointerEventHandler_ = new ol.pointer.PointerEventHandler(element);

  /**
   * Event handler which generates pointer events for
   * the document (used when dragging).
   *
   * @type {ol.pointer.PointerEventHandler}
   * @private
   */
  this.documentPointerEventHandler_ = null;

  this.pointerdownListenerKey_ = goog.events.listen(this.pointerEventHandler_,
      ol.pointer.EventType.POINTERDOWN,
      this.handlePointerDown_, false, this);

  this.relayedListenerKey_ = goog.events.listen(this.pointerEventHandler_,
      ol.pointer.EventType.POINTERMOVE,
      this.relayEvent_, false, this);

  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    /*
     * On legacy IE, double clicks do not produce two mousedown and
     * mouseup events. That is why a separate DBLCLICK event listener
     * is used.
     */
    this.ieDblclickListenerKey_ = goog.events.listen(element,
        goog.events.EventType.DBLCLICK,
        this.emulateClickLegacyIE_, false, this);
  }

};
goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget);

/**
 * Get the last "down" type event. This will be set on pointerdown.
 * @return {ol.pointer.PointerEvent} The most recent "down" type event (or null
 * if none have occurred).
 */
ol.MapBrowserEventHandler.prototype.getDown = function() {
  return this.down_;
};

/**
 * @param {goog.events.BrowserEvent} browserEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.emulateClickLegacyIE_ =
    function(browserEvent) {
  var pointerEvent = this.pointerEventHandler_.wrapMouseEvent(
      ol.MapBrowserEvent.EventType.POINTERUP,
      browserEvent
      );
  this.emulateClick_(pointerEvent);
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
  if (this.clickTimeoutId_ !== 0) {
    // double-click
    goog.global.clearTimeout(this.clickTimeoutId_);
    this.clickTimeoutId_ = 0;
    var newEvent = new ol.MapBrowserPointerEvent(
        ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, pointerEvent);
    this.dispatchEvent(newEvent);
  } else {
    // click
    this.clickTimeoutId_ = goog.global.setTimeout(goog.bind(function() {
      this.clickTimeoutId_ = 0;
      var newEvent = new ol.MapBrowserPointerEvent(
          ol.MapBrowserEvent.EventType.SINGLECLICK, this.map_, pointerEvent);
      this.dispatchEvent(newEvent);
    }, this), 250);
  }
};

/**
 * Keeps track on how many pointers are currently active.
 *
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.updateActivePointers_ =
    function(pointerEvent) {
  var event = pointerEvent;

  if (event.type == ol.MapBrowserEvent.EventType.POINTERUP ||
      event.type == ol.MapBrowserEvent.EventType.POINTERCANCEL) {
    delete this.trackedTouches_[event.pointerId];
  } else if (event.type == ol.MapBrowserEvent.EventType.POINTERDOWN) {
    this.trackedTouches_[event.pointerId] = true;
  }
  this.activePointers_ = goog.object.getCount(this.trackedTouches_);
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
  this.updateActivePointers_(pointerEvent);
  var newEvent = new ol.MapBrowserPointerEvent(
      ol.MapBrowserEvent.EventType.POINTERUP, this.map_, pointerEvent);
  this.dispatchEvent(newEvent);

  goog.asserts.assert(this.activePointers_ >= 0);
  if (this.activePointers_ === 0) {
    goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
    this.dragListenerKeys_ = null;
    goog.dispose(this.documentPointerEventHandler_);
    this.documentPointerEventHandler_ = null;
  }

  // We emulate click event on left mouse button click, touch contact, and pen
  // contact. isMouseActionButton returns true in these cases (evt.button is set
  // to 0).
  // See http://www.w3.org/TR/pointerevents/#button-states
  if (!this.dragged_ && this.isMouseActionButton_(pointerEvent)) {
    goog.asserts.assert(!goog.isNull(this.down_));
    this.emulateClick_(this.down_);
  }
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @return {boolean} If the left mouse button was pressed.
 * @private
 */
ol.MapBrowserEventHandler.prototype.isMouseActionButton_ =
    function(pointerEvent) {
  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
    return pointerEvent.button == 1;
  } else {
    return pointerEvent.button == 0;
  }
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerDown_ =
    function(pointerEvent) {
  this.updateActivePointers_(pointerEvent);
  var newEvent = new ol.MapBrowserPointerEvent(
      ol.MapBrowserEvent.EventType.POINTERDOWN, this.map_, pointerEvent);
  this.dispatchEvent(newEvent);

  this.down_ = pointerEvent;
  this.dragged_ = false;

  if (goog.isNull(this.dragListenerKeys_)) {
    /* Set up a pointer event handler on the `document`,
     * which is required when the pointer is moved outside
     * the viewport when dragging.
     */
    this.documentPointerEventHandler_ =
        new ol.pointer.PointerEventHandler(document);

    this.dragListenerKeys_ = [
      goog.events.listen(this.documentPointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERMOVE,
          this.handlePointerMove_, false, this),
      goog.events.listen(this.documentPointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERUP,
          this.handlePointerUp_, false, this),
      goog.events.listen(this.pointerEventHandler_,
          ol.MapBrowserEvent.EventType.POINTERCANCEL,
          this.handlePointerUp_, false, this)
    ];
  }

  // FIXME check if/when this is necessary
  // prevent context menu
  pointerEvent.preventDefault();
};

/**
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
    function(pointerEvent) {
  // Fix IE10 on windows Surface : When you tap the tablet, it triggers
  // multiple pointermove events between pointerdown and pointerup with
  // the exact same coordinates of the pointerdown event. To avoid a
  // 'false' touchmove event to be dispatched , we test if the pointer
  // effectively moved.
  if (pointerEvent.clientX != this.down_.clientX ||
      pointerEvent.clientY != this.down_.clientY) {
    this.dragged_ = true;
    var newEvent = new ol.MapBrowserPointerEvent(
        ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent);
    this.dispatchEvent(newEvent);
  }

  // Some native android browser triggers mousemove events during small period
  // of time. See: https://code.google.com/p/android/issues/detail?id=5491 or
  // https://code.google.com/p/android/issues/detail?id=19827
  // ex: Galaxy Tab P3110 + Android 4.1.1
  pointerEvent.preventDefault();
};

/**
 * Wrap and relay a pointer event.  Note that this requires that the type
 * string for the MapBrowserPointerEvent matches the PointerEvent type.
 * @param {ol.pointer.PointerEvent} pointerEvent Pointer event.
 * @private
 */
ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
  this.dispatchEvent(new ol.MapBrowserPointerEvent(
      pointerEvent.type, this.map_, pointerEvent));
};

/**
 * @inheritDoc
 */
ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
  if (!goog.isNull(this.relayedListenerKey_)) {
    goog.events.unlistenByKey(this.relayedListenerKey_);
    this.relayedListenerKey_ = null;
  }
  if (!goog.isNull(this.pointerdownListenerKey_)) {
    goog.events.unlistenByKey(this.pointerdownListenerKey_);
    this.pointerdownListenerKey_ = null;
  }
  if (!goog.isNull(this.dragListenerKeys_)) {
    goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
    this.dragListenerKeys_ = null;
  }
  if (!goog.isNull(this.documentPointerEventHandler_)) {
    goog.dispose(this.documentPointerEventHandler_);
    this.documentPointerEventHandler_ = null;
  }
  if (!goog.isNull(this.pointerEventHandler_)) {
    goog.dispose(this.pointerEventHandler_);
    this.pointerEventHandler_ = null;
  }
  if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE &&
      !goog.isNull(this.ieDblclickListenerKey_)) {
    goog.events.unlistenByKey(this.ieDblclickListenerKey_);
    this.ieDblclickListenerKey_ = null;
  }
  goog.base(this, 'disposeInternal');
};

/**
 * Constants for event names.
 * @enum {string}
 */
ol.MapBrowserEvent.EventType = {
  SINGLECLICK: 'singleclick',
  DBLCLICK: goog.events.EventType.DBLCLICK,
  POINTERDRAG: 'pointermove',

  POINTERMOVE: 'pointermove',
  POINTERDOWN: 'pointerdown',
  POINTERUP: 'pointerup',
  POINTEROVER: 'pointerover',
  POINTEROUT: 'pointerout',
  POINTERENTER: 'pointerenter',
  POINTERLEAVE: 'pointerleave',
  POINTERCANCEL: 'pointercancel'
};
<|endoftext|>