<commit_before>dojo.provide("dojox.editor.plugins.Breadcrumb");

dojo.require("dijit._editor._Plugin");
dojo.require("dijit._editor.range");
dojo.require("dojo.i18n");
dojo.require("dojo.string");
dojo.require("dijit.Toolbar");
dojo.require("dijit.form.Button");
dojo.require("dijit._editor.selection");
dojo.require("dijit.Menu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.MenuSeparator");

dojo.experimental("dojox.editor.plugins.Breadcrumb");

dojo.requireLocalization("dojox.editor.plugins", "Breadcrumb");

dojo.declare("dojox.editor.plugins._BreadcrumbMenuTitle",[dijit._Widget, dijit._Templated, dijit._Contained],{
	// summary:
	//		SImple internal, non-clickable, menu entry to act as a menu title bar.
	templateString: "

",

	menuTitle: "",

	postCreate: function(){
		dojo.setSelectable(this.domNode, false);
		var label = this.id+"_text";
		dijit.setWaiState(this.domNode, "labelledby", label);
	},

	_setMenuTitleAttr: function(str){
		this.title.innerHTML = str;
	},
	_getMenuTitleAttr: function(str){
		return this.title.innerHTML;
	}
});

dojo.declare("dojox.editor.plugins.Breadcrumb",dijit._editor._Plugin,{
	// summary:
	//		This plugin provides Breadcrumb cabability to the editor.  When
	//		As you move around the editor, it updates with your current indention
	//		depth.

	//	_menu: [private]
	//		The popup menu that is displayed.
	_menu: null,

	//	breadcrumbBar: [protected]
	//		The toolbar containing the breadcrumb.
	breadcrumbBar: null,

	setEditor: function(editor){
		// summary:
		//		Over-ride for the setting of the editor.
		// editor: Object
		//		The editor to configure for this plugin to use.
		this.editor = editor;
		this._buttons = [];
		this.breadcrumbBar = new dijit.Toolbar();
		dojo.style(this.breadcrumbBar.domNode, "height", "1.5em");

		var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "Breadcrumb");
		this._titleTemplate = strings.nodeActions;

		editor.footer.appendChild(this.breadcrumbBar.domNode);
		this.editor.onLoadDeferred.addCallback(dojo.hitch(this, function(){
			this._menu = new dijit.Menu({});
			dojo.addClass(this.breadcrumbBar.domNode, "dojoxEditorBreadcrumbArrow");
			var self = this;
			var body = new dijit.form.ComboButton({
				showLabel: true,
				label: "body",
				_selNode: editor.editNode,
				dropDown: this._menu,
				onClick: dojo.hitch(this, function(){
					this._menuTarget = editor.editNode;
					this._selectContents();
				})
			});

			// Build the menu
			this._menuTitle = new dojox.editor.plugins._BreadcrumbMenuTitle({menuTitle: strings.nodeActions});
			this._selCMenu = new dijit.MenuItem({label: strings.selectContents, onClick: dojo.hitch(this, this._selectContents)});
			this._delCMenu = new dijit.MenuItem({label: strings.deleteContents, onClick: dojo.hitch(this, this._deleteContents)});
			this._selEMenu = new dijit.MenuItem({label: strings.selectElement, onClick: dojo.hitch(this, this._selectElement)});
			this._delEMenu = new dijit.MenuItem({label: strings.deleteElement, onClick: dojo.hitch(this, this._deleteElement)});
			this._moveSMenu = new dijit.MenuItem({label: strings.moveStart, onClick: dojo.hitch(this, this._moveCToStart)});
			this._moveEMenu = new dijit.MenuItem({label: strings.moveEnd, onClick: dojo.hitch(this, this._moveCToEnd)});

			this._menu.addChild(this._menuTitle);
			this._menu.addChild(this._selCMenu);
			this._menu.addChild(this._delCMenu);
			this._menu.addChild(new dijit.MenuSeparator({}));
			this._menu.addChild(this._selEMenu);
			this._menu.addChild(this._delEMenu);
			this._menu.addChild(new dijit.MenuSeparator({}));
			this._menu.addChild(this._moveSMenu);
			this._menu.addChild(this._moveEMenu);

			body._ddConnect = dojo.connect(body, "openDropDown", dojo.hitch(this, function(){
				this._menuTarget = body._selNode;
				this._menuTitle.attr("menuTitle", dojo.string.substitute(this._titleTemplate,{
						"nodeName": "<body>"
				}));
				this._selEMenu.attr("disabled", true);
				this._delEMenu.attr("disabled", true);
				this._selCMenu.attr("disabled", false);
				this._delCMenu.attr("disabled", false);
				this._moveSMenu.attr("disabled", false);
				this._moveEMenu.attr("disabled", false);
			}));
			this.breadcrumbBar.addChild(body);
			this.connect(this.editor, "onNormalizedDisplayChanged", "updateState");
		}));
		this.breadcrumbBar.startup();
	},

	_selectContents: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			var nodeName = this._menuTarget.tagName.toLowerCase();
			switch(nodeName){
				case 'br':
				case 'hr':
				case 'img':
				case 'input':
				case 'base':
				case 'meta':
				case 'area':
				case 'basefont':
						break;
				default:
					try{
						dojo.withGlobal(this.editor.window,
							"collapse", dijit._editor.selection, [null]);
						dojo.withGlobal(this.editor.window,
							"selectElementChildren", dijit._editor.selection, [this._menuTarget]);
						this.editor.onDisplayChanged();
					}catch(e){/*squelch*/}
			}
		}
	},

	_deleteContents: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		if(this._menuTarget){
			this.editor.beginEditing();
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"remove", dijit._editor.selection, [this._menuTarget]);
			this.editor.endEditing();
			this._updateBreadcrumb();
			this.editor.onDisplayChanged();
		}
	},

	_selectElement: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [null]);
			dojo.withGlobal(this.editor.window,
				"selectElement", dijit._editor.selection, [this._menuTarget]);
			this.editor.onDisplayChanged();

		}
	},

	_deleteElement: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		if(this._menuTarget){
			this.editor.beginEditing();
			this._selectElement();
			dojo.withGlobal(this.editor.window,
				"remove", dijit._editor.selection, [this._menuTarget]);
			this.editor.endEditing();
			this._updateBreadcrumb();
			this.editor.onDisplayChanged();
		}
	},

	_moveCToStart: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [true]);
		}
	},

	_moveCToEnd: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [false]);
		}
	},

	_updateBreadcrumb: function(){
		// summary:
		//		Function to trigger updating of the breadcrumb
		// tags:
		//		private
		var ed = this.editor;
		if(ed.window){
			var sel = dijit.range.getSelection(ed.window);
			if(sel && sel.rangeCount > 0){
				var range = sel.getRangeAt(0);

				// Check the getSelectedElement call.  Needed when dealing with img tags.
				var node = dojo.withGlobal(ed.window,
					"getSelectedElement", dijit._editor.selection) || range.startContainer;
				//var node = range.startContainer;
				var bcList = [];

				// Make sure we get a selection within the editor document,
				// have seen cases on IE where this wasn't true.
				if(node && node.ownerDocument === ed.document){
					while(node && node !== ed.editNode){
						if(node.nodeType === 1){
							bcList.push({type: node.tagName.toLowerCase(), node: node});
						}
						node = node.parentNode;
					}
					bcList = bcList.reverse();

					while(this._buttons.length){
						var db = this._buttons.pop();
						dojo.disconnect(db._ddConnect);
						this.breadcrumbBar.removeChild(db);
					}
					this._buttons = [];

					var i;
					var self = this;
					for(i = 0; i < bcList.length; i++){
						var bc = bcList[i];
						var b = new dijit.form.ComboButton({
							showLabel: true,
							label: bc.type,
							_selNode: bc.node,
							dropDown: this._menu,
							onClick: function(){
								self._menuTarget = this._selNode;
								self._selectContents();
							}
						});
						b._ddConnect = dojo.connect(b, "openDropDown", dojo.hitch(b, function(){
							self._menuTarget = this._selNode;
							var nodeName = self._menuTarget.tagName.toLowerCase();
							var title = dojo.string.substitute(self._titleTemplate,{
								"nodeName": "<" + nodeName + ">"
							});
							self._menuTitle.attr("menuTitle", title);
							switch(nodeName){
								case 'br':
								case 'hr':
								case 'img':
								case 'input':
								case 'base':
								case 'meta':
								case 'area':
								case 'basefont':
									self._selCMenu.attr("disabled", true);
									self._delCMenu.attr("disabled", true);
									self._moveSMenu.attr("disabled", true);
									self._moveEMenu.attr("disabled", true);
									self._selEMenu.attr("disabled", false);
									self._delEMenu.attr("disabled", false);
									break;
								default:
									self._selCMenu.attr("disabled", false);
									self._delCMenu.attr("disabled", false);
									self._selEMenu.attr("disabled", false);
									self._delEMenu.attr("disabled", false);
									self._moveSMenu.attr("disabled", false);
									self._moveEMenu.attr("disabled", false);
							}
						}));
						this._buttons.push(b);
						this.breadcrumbBar.addChild(b);
					}
					if(dojo.isIE){
						// Prod it to fix layout.
						this.breadcrumbBar.domNode.className = this.breadcrumbBar.domNode.className;
					}

				}
			}
		}
	},

	updateState: function(){
		// summary:
		//		Over-ride of updateState to hide the toolbar when the iframe is not visible.
		//		Also triggers the breadcrumb update.
		if(dojo.style(this.editor.iframe, "display") === "none"){
			dojo.style(this.breadcrumbBar.domNode, "display", "none");
		}else{
			if(dojo.style(this.breadcrumbBar.domNode, "display") === "none"){
				dojo.style(this.breadcrumbBar.domNode, "display", "block");
			}
			this._updateBreadcrumb();
		}
	},

	destroy: function(){
		// summary:
		//		Over-ride to clean up the breadcrumb toolbar.
		if(this.breadcrumbBar){
			this.breadcrumbBar.destroy();
			this.breadcrumbBar = null;
		}
		this._buttons = null;
		delete this.editor.breadcrumbBar;
		this.inherited(arguments);
	}
});

// Register this plugin.
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
	if(o.plugin){ return; }
	var name = o.args.name.toLowerCase();
	if(name === "breadcrumb"){
		o.plugin = new dojox.editor.plugins.Breadcrumb({});
	}
});
<commit_msg>Switched to dojo.place.  refs #10311<commit_after>dojo.provide("dojox.editor.plugins.Breadcrumb");

dojo.require("dijit._editor._Plugin");
dojo.require("dijit._editor.range");
dojo.require("dojo.i18n");
dojo.require("dojo.string");
dojo.require("dijit.Toolbar");
dojo.require("dijit.form.Button");
dojo.require("dijit._editor.selection");
dojo.require("dijit.Menu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.MenuSeparator");

dojo.experimental("dojox.editor.plugins.Breadcrumb");

dojo.requireLocalization("dojox.editor.plugins", "Breadcrumb");

dojo.declare("dojox.editor.plugins._BreadcrumbMenuTitle",[dijit._Widget, dijit._Templated, dijit._Contained],{
	// summary:
	//		SImple internal, non-clickable, menu entry to act as a menu title bar.
	templateString: "

",

	menuTitle: "",

	postCreate: function(){
		dojo.setSelectable(this.domNode, false);
		var label = this.id+"_text";
		dijit.setWaiState(this.domNode, "labelledby", label);
	},

	_setMenuTitleAttr: function(str){
		this.title.innerHTML = str;
	},
	_getMenuTitleAttr: function(str){
		return this.title.innerHTML;
	}
});

dojo.declare("dojox.editor.plugins.Breadcrumb",dijit._editor._Plugin,{
	// summary:
	//		This plugin provides Breadcrumb cabability to the editor.  When
	//		As you move around the editor, it updates with your current indention
	//		depth.

	//	_menu: [private]
	//		The popup menu that is displayed.
	_menu: null,

	//	breadcrumbBar: [protected]
	//		The toolbar containing the breadcrumb.
	breadcrumbBar: null,

	setEditor: function(editor){
		// summary:
		//		Over-ride for the setting of the editor.
		// editor: Object
		//		The editor to configure for this plugin to use.
		this.editor = editor;
		this._buttons = [];
		this.breadcrumbBar = new dijit.Toolbar();
		dojo.style(this.breadcrumbBar.domNode, "height", "1.5em");

		var strings = dojo.i18n.getLocalization("dojox.editor.plugins", "Breadcrumb");
		this._titleTemplate = strings.nodeActions;

		dojo.place(this.breadcrumbBar.domNode, editor.footer);
		this.editor.onLoadDeferred.addCallback(dojo.hitch(this, function(){
			this._menu = new dijit.Menu({});
			dojo.addClass(this.breadcrumbBar.domNode, "dojoxEditorBreadcrumbArrow");
			var self = this;
			var body = new dijit.form.ComboButton({
				showLabel: true,
				label: "body",
				_selNode: editor.editNode,
				dropDown: this._menu,
				onClick: dojo.hitch(this, function(){
					this._menuTarget = editor.editNode;
					this._selectContents();
				})
			});

			// Build the menu
			this._menuTitle = new dojox.editor.plugins._BreadcrumbMenuTitle({menuTitle: strings.nodeActions});
			this._selCMenu = new dijit.MenuItem({label: strings.selectContents, onClick: dojo.hitch(this, this._selectContents)});
			this._delCMenu = new dijit.MenuItem({label: strings.deleteContents, onClick: dojo.hitch(this, this._deleteContents)});
			this._selEMenu = new dijit.MenuItem({label: strings.selectElement, onClick: dojo.hitch(this, this._selectElement)});
			this._delEMenu = new dijit.MenuItem({label: strings.deleteElement, onClick: dojo.hitch(this, this._deleteElement)});
			this._moveSMenu = new dijit.MenuItem({label: strings.moveStart, onClick: dojo.hitch(this, this._moveCToStart)});
			this._moveEMenu = new dijit.MenuItem({label: strings.moveEnd, onClick: dojo.hitch(this, this._moveCToEnd)});

			this._menu.addChild(this._menuTitle);
			this._menu.addChild(this._selCMenu);
			this._menu.addChild(this._delCMenu);
			this._menu.addChild(new dijit.MenuSeparator({}));
			this._menu.addChild(this._selEMenu);
			this._menu.addChild(this._delEMenu);
			this._menu.addChild(new dijit.MenuSeparator({}));
			this._menu.addChild(this._moveSMenu);
			this._menu.addChild(this._moveEMenu);

			body._ddConnect = dojo.connect(body, "openDropDown", dojo.hitch(this, function(){
				this._menuTarget = body._selNode;
				this._menuTitle.attr("menuTitle", dojo.string.substitute(this._titleTemplate,{
						"nodeName": "<body>"
				}));
				this._selEMenu.attr("disabled", true);
				this._delEMenu.attr("disabled", true);
				this._selCMenu.attr("disabled", false);
				this._delCMenu.attr("disabled", false);
				this._moveSMenu.attr("disabled", false);
				this._moveEMenu.attr("disabled", false);
			}));
			this.breadcrumbBar.addChild(body);
			this.connect(this.editor, "onNormalizedDisplayChanged", "updateState");
		}));
		this.breadcrumbBar.startup();
	},

	_selectContents: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			var nodeName = this._menuTarget.tagName.toLowerCase();
			switch(nodeName){
				case 'br':
				case 'hr':
				case 'img':
				case 'input':
				case 'base':
				case 'meta':
				case 'area':
				case 'basefont':
						break;
				default:
					try{
						dojo.withGlobal(this.editor.window,
							"collapse", dijit._editor.selection, [null]);
						dojo.withGlobal(this.editor.window,
							"selectElementChildren", dijit._editor.selection, [this._menuTarget]);
						this.editor.onDisplayChanged();
					}catch(e){/*squelch*/}
			}
		}
	},

	_deleteContents: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		if(this._menuTarget){
			this.editor.beginEditing();
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"remove", dijit._editor.selection, [this._menuTarget]);
			this.editor.endEditing();
			this._updateBreadcrumb();
			this.editor.onDisplayChanged();
		}
	},

	_selectElement: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [null]);
			dojo.withGlobal(this.editor.window,
				"selectElement", dijit._editor.selection, [this._menuTarget]);
			this.editor.onDisplayChanged();

		}
	},

	_deleteElement: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		if(this._menuTarget){
			this.editor.beginEditing();
			this._selectElement();
			dojo.withGlobal(this.editor.window,
				"remove", dijit._editor.selection, [this._menuTarget]);
			this.editor.endEditing();
			this._updateBreadcrumb();
			this.editor.onDisplayChanged();
		}
	},

	_moveCToStart: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [true]);
		}
	},

	_moveCToEnd: function(){
		// summary:
		//		Internal function for selecting the contents of a node.
		this.editor.focus();
		if(this._menuTarget){
			this._selectContents();
			dojo.withGlobal(this.editor.window,
				"collapse", dijit._editor.selection, [false]);
		}
	},

	_updateBreadcrumb: function(){
		// summary:
		//		Function to trigger updating of the breadcrumb
		// tags:
		//		private
		var ed = this.editor;
		if(ed.window){
			var sel = dijit.range.getSelection(ed.window);
			if(sel && sel.rangeCount > 0){
				var range = sel.getRangeAt(0);

				// Check the getSelectedElement call.  Needed when dealing with img tags.
				var node = dojo.withGlobal(ed.window,
					"getSelectedElement", dijit._editor.selection) || range.startContainer;
				//var node = range.startContainer;
				var bcList = [];

				// Make sure we get a selection within the editor document,
				// have seen cases on IE where this wasn't true.
				if(node && node.ownerDocument === ed.document){
					while(node && node !== ed.editNode){
						if(node.nodeType === 1){
							bcList.push({type: node.tagName.toLowerCase(), node: node});
						}
						node = node.parentNode;
					}
					bcList = bcList.reverse();

					while(this._buttons.length){
						var db = this._buttons.pop();
						dojo.disconnect(db._ddConnect);
						this.breadcrumbBar.removeChild(db);
					}
					this._buttons = [];

					var i;
					var self = this;
					for(i = 0; i < bcList.length; i++){
						var bc = bcList[i];
						var b = new dijit.form.ComboButton({
							showLabel: true,
							label: bc.type,
							_selNode: bc.node,
							dropDown: this._menu,
							onClick: function(){
								self._menuTarget = this._selNode;
								self._selectContents();
							}
						});
						b._ddConnect = dojo.connect(b, "openDropDown", dojo.hitch(b, function(){
							self._menuTarget = this._selNode;
							var nodeName = self._menuTarget.tagName.toLowerCase();
							var title = dojo.string.substitute(self._titleTemplate,{
								"nodeName": "<" + nodeName + ">"
							});
							self._menuTitle.attr("menuTitle", title);
							switch(nodeName){
								case 'br':
								case 'hr':
								case 'img':
								case 'input':
								case 'base':
								case 'meta':
								case 'area':
								case 'basefont':
									self._selCMenu.attr("disabled", true);
									self._delCMenu.attr("disabled", true);
									self._moveSMenu.attr("disabled", true);
									self._moveEMenu.attr("disabled", true);
									self._selEMenu.attr("disabled", false);
									self._delEMenu.attr("disabled", false);
									break;
								default:
									self._selCMenu.attr("disabled", false);
									self._delCMenu.attr("disabled", false);
									self._selEMenu.attr("disabled", false);
									self._delEMenu.attr("disabled", false);
									self._moveSMenu.attr("disabled", false);
									self._moveEMenu.attr("disabled", false);
							}
						}));
						this._buttons.push(b);
						this.breadcrumbBar.addChild(b);
					}
					if(dojo.isIE){
						// Prod it to fix layout.
						this.breadcrumbBar.domNode.className = this.breadcrumbBar.domNode.className;
					}

				}
			}
		}
	},

	updateState: function(){
		// summary:
		//		Over-ride of updateState to hide the toolbar when the iframe is not visible.
		//		Also triggers the breadcrumb update.
		if(dojo.style(this.editor.iframe, "display") === "none"){
			dojo.style(this.breadcrumbBar.domNode, "display", "none");
		}else{
			if(dojo.style(this.breadcrumbBar.domNode, "display") === "none"){
				dojo.style(this.breadcrumbBar.domNode, "display", "block");
			}
			this._updateBreadcrumb();
		}
	},

	destroy: function(){
		// summary:
		//		Over-ride to clean up the breadcrumb toolbar.
		if(this.breadcrumbBar){
			this.breadcrumbBar.destroy();
			this.breadcrumbBar = null;
		}
		this._buttons = null;
		delete this.editor.breadcrumbBar;
		this.inherited(arguments);
	}
});

// Register this plugin.
dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
	if(o.plugin){ return; }
	var name = o.args.name.toLowerCase();
	if(name === "breadcrumb"){
		o.plugin = new dojox.editor.plugins.Breadcrumb({});
	}
});
<|endoftext|>


<commit_before>'use strict';

var _                  = require('mano').i18n.bind('View: Supervisor')
  , toArray            = require('es5-ext/object/to-array')
  , byOrder            = function (a, b) { return this[a].order - this[b].order; }
  , once               = require('timers-ext/once')
  , dispatch           = require('dom-ext/html-element/#/dispatch-event-2')
  , location           = require('mano/lib/client/location')
  , timeRanges         = require('../utils/supervisor-time-ranges')
  , assign             = require('es5-ext/object/assign')
  , stepsMap           = assign(require('../utils/processing-steps-map'))
  , getSupervisorTable = require('eregistrations/view/components/supervisor-table')
  , from               = require('es5-ext/array/from')
  , tableColumns       = require('eregistrations/view/_supervisor-table-columns.js')
  , columns            = from(tableColumns.columns)
  , env                = require('mano').env;

exports._parent = require('./user-base');

exports['sub-main'] = {
	class: { content: true },
	content: function () {
		var searchForm, searchInput, supervisorTable;

		section({ class: 'section-primary users-table-filter-bar' },
			searchForm = form({ action: '/', autoSubmit: true },
				div({ class: 'users-table-filter-bar-status' },
					label({ for: 'state-select' }, _("Role"), ":"),
					select({ id: 'state-select', name: 'step' },
						option({ value: '', selected:
								location.query.get('step').map(function (value) {
								return value ? null : 'selected';
							}) },
							_("All")),
						toArray(stepsMap, function (data, name) {
							return option({ value: name, selected:
									location.query.get('step').map(function (value) {
									return value === name ? 'selected' : null;
								}) },
								data.label);
						}, null, byOrder))),
				div(
					label({ for: 'time-select' }, _("Time"), ":"),
					select({ id: 'time-select', name: 'time' },
						list(timeRanges, function (data) {
							return option({ value: data.name || '', selected:
									location.query.get('time').map(function (name) {
									var selected = (data.name ? (data.name === name) : (name == null));
									return selected ? 'selected' : null;
								}) },
									data.label);
						}))
				),
				div(
					label({ for: 'search-input' }, _("Search")),
					span({ class: 'input-append' },
						searchInput = input({ id: 'search-input', name: 'search', type: 'search',
							value: location.query.get('search') }),
						span({ class: 'add-on' }, span({ class: 'fa fa-search' })))
				),
				div(
					input({ type: 'submit', value: _("Search") })
				)),
			div(
				a({ href: mmap(location.query.get('step'), function (step) {
					return mmap(location.query.get('time'), function (time) {
						return mmap(location.query.get('page'), function (page) {
							var search = [];
								if (step) search.push('step=' + step);
								if (time) search.push('time=' + time);
								if (page) search.push('page=' + page);
								if (search.length) search = '?' + search.join('&');
								else search = null;
							return url('print-supervisor-list', search);
						});
					});
				}), class: 'users-table-filter-bar-print', target: '_blank' },
					span({ class: 'fa fa-print' },
						_("Print list of requests")), _("Print the list"))
			));

		searchInput.oninput = once(function () { dispatch.call(searchForm, 'submit'); }, 300);

		supervisorTable = getSupervisorTable({
			user: this.user,
			stepsMap: stepsMap,
			itemsPerPage: env.objectsListItemsPerPage,
			columns: columns,
			class: 'submitted-user-data-table'
		});

		insert(supervisorTable.pagination,
			section({ class: 'table-responsive-container' }, supervisorTable),
			supervisorTable.pagination);
	}
};
<commit_msg>Issue #1414. Add status select to supervisor view<commit_after>'use strict';

var _                  = require('mano').i18n.bind('View: Supervisor')
  , toArray            = require('es5-ext/object/to-array')
  , byOrder            = function (a, b) { return this[a].order - this[b].order; }
  , once               = require('timers-ext/once')
  , dispatch           = require('dom-ext/html-element/#/dispatch-event-2')
  , location           = require('mano/lib/client/location')
  , timeRanges         = require('../utils/supervisor-time-ranges')
  , statuses           = require('../utils/supervisor-statuses-list')
  , statusMeta         = require('mano').db.ProcessingStepStatus.meta
  , assign             = require('es5-ext/object/assign')
  , stepsMap           = assign(require('../utils/processing-steps-map'))
  , getSupervisorTable = require('eregistrations/view/components/supervisor-table')
  , from               = require('es5-ext/array/from')
  , tableColumns       = require('eregistrations/view/_supervisor-table-columns.js')
  , columns            = from(tableColumns.columns)
  , env                = require('mano').env;

exports._parent = require('./user-base');

exports['sub-main'] = {
	class: { content: true },
	content: function () {
		var searchForm, searchInput, supervisorTable;

		section({ class: 'section-primary users-table-filter-bar' },
			searchForm = form({ action: '/', autoSubmit: true },
				div({ class: 'users-table-filter-bar-status' },
					label({ for: 'state-select' }, _("Role"), ":"),
					select({ id: 'state-select', name: 'step' },
						option({ value: '', selected:
								location.query.get('step').map(function (value) {
								return value ? null : 'selected';
							}) },
							_("All")),
						toArray(stepsMap, function (data, name) {
							return option({ value: name, selected:
									location.query.get('step').map(function (value) {
									return value === name ? 'selected' : null;
								}) },
								data.label);
						}, null, byOrder))),
				div(
					label({ for: 'status-select' }, _("Status"), ":"),
					select({ id: 'status-select', name: 'status' },
						list(statuses, function (status) {
							return option({ value: status }, statusMeta[status].label);
						}))
				),
				div(
					label({ for: 'time-select' }, _("Time"), ":"),
					select({ id: 'time-select', name: 'time' },
						list(timeRanges, function (data) {
							return option({ value: data.name || '', selected:
									location.query.get('time').map(function (name) {
									var selected = (data.name ? (data.name === name) : (name == null));
									return selected ? 'selected' : null;
								}) },
									data.label);
						}))
				),
				div(
					label({ for: 'search-input' }, _("Search")),
					span({ class: 'input-append' },
						searchInput = input({ id: 'search-input', name: 'search', type: 'search',
							value: location.query.get('search') }),
						span({ class: 'add-on' }, span({ class: 'fa fa-search' })))
				),
				div(
					input({ type: 'submit', value: _("Search") })
				)),
			div(
				a({ href: mmap(location.query.get('step'), function (step) {
					return mmap(location.query.get('time'), function (time) {
						return mmap(location.query.get('page'), function (page) {
							var search = [];
								if (step) search.push('step=' + step);
								if (time) search.push('time=' + time);
								if (page) search.push('page=' + page);
								if (search.length) search = '?' + search.join('&');
								else search = null;
							return url('print-supervisor-list', search);
						});
					});
				}), class: 'users-table-filter-bar-print', target: '_blank' },
					span({ class: 'fa fa-print' },
						_("Print list of requests")), _("Print the list"))
			));

		searchInput.oninput = once(function () { dispatch.call(searchForm, 'submit'); }, 300);

		supervisorTable = getSupervisorTable({
			user: this.user,
			stepsMap: stepsMap,
			itemsPerPage: env.objectsListItemsPerPage,
			columns: columns,
			class: 'submitted-user-data-table'
		});

		insert(supervisorTable.pagination,
			section({ class: 'table-responsive-container' }, supervisorTable),
			supervisorTable.pagination);
	}
};
<|endoftext|>


<commit_before>//----------------------------------------------------------------------------
//  Copyright (C) 2008-2012  The IPython Development Team
//
//  Distributed under the terms of the BSD License.  The full license is in
//  the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------

//============================================================================
// TextCell
//============================================================================

/**
    A module that allow to create different type of Text Cell
    @module IPython
    @namespace IPython
 */
var IPython = (function (IPython) {

    // TextCell base class
    var key = IPython.utils.keycodes;

    /**
     * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text'
     * cell start as not redered.
     *
     * @class TextCell
     * @constructor TextCell
     * @extend Ipython.Cell
     * @param {object|undefined} [options]
     *      @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config
     */
    var TextCell = function (options) {
        this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
        var options = options || {};

        var cm_overwrite_options  = {
            extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"},
            onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
        };

        var arg_cm_options = options.cm_options || {};
        var cm_config = $.extend({},TextCell.cm_default, arg_cm_options, cm_overwrite_options);

        var options = {};
        options.cm_config = cm_config;

        IPython.Cell.apply(this, [options]);
        this.rendered = false;
        this.cell_type = this.cell_type || 'text';
    };

    TextCell.cm_default = {
            mode: this.code_mirror_mode,
            theme: 'default',
            value: this.placeholder,
            lineWrapping : true,
        }

    TextCell.prototype = new IPython.Cell();

    /**
     * Create the DOM element of the TextCell
     * @method create_element
     * @private
     */
    TextCell.prototype.create_element = function () {
        IPython.Cell.prototype.create_element.apply(this, arguments);
        var cell = $("
").addClass('cell text_cell border-box-sizing vbox');
        cell.attr('tabindex','2');

        this.celltoolbar = new IPython.CellToolbar(this);
        cell.append(this.celltoolbar.element);

        var input_area = $('
').addClass('text_cell_input border-box-sizing');
        this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
        // The tabindex=-1 makes this div focusable.
        var render_area = $('
').addClass('text_cell_render border-box-sizing').
            addClass('rendered_html').attr('tabindex','-1');
        cell.append(input_area).append(render_area);
        this.element = cell;
    };

    /**
     * Bind the DOM evet to cell actions
     * Need to be called after TextCell.create_element
     * @private
     * @method bind_event
     */
    TextCell.prototype.bind_events = function () {
        IPython.Cell.prototype.bind_events.apply(this);
        var that = this;
        this.element.keydown(function (event) {
            if (event.which === 13 && !event.shiftKey) {
                if (that.rendered) {
                    that.edit();
                    return false;
                };
            };
        });
        this.element.dblclick(function () {
            that.edit();
        });
    };

    /**
     * This method gets called in CodeMirror's onKeyDown/onKeyPress
     * handlers and is used to provide custom key handling.
     *
     * Subclass should override this method to have custom handeling
     *
     * @method handle_codemirror_keyevent
     * @param {CodeMirror} editor - The codemirror instance bound to the cell
     * @param {event} event -
     * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise
     */
    TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {

        if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
            // Always ignore shift-enter in CodeMirror as we handle it.
            return true;
        }
        return false;
    };

    /**
     * Select the current cell and trigger 'focus'
     * @method select
     */
    TextCell.prototype.select = function () {
        IPython.Cell.prototype.select.apply(this);
        var output = this.element.find("div.text_cell_render");
        output.trigger('focus');
    };

    /**
     * unselect the current cell and `render` it
     * @method unselect
     */
    TextCell.prototype.unselect = function() {
        // render on selection of another cell
        this.render();
        IPython.Cell.prototype.unselect.apply(this);
    };

    /**
     *
     * put the current cell in edition mode
     * @method edit
     */
    TextCell.prototype.edit = function () {
        if ( this.read_only ) return;
        if (this.rendered === true) {
            var text_cell = this.element;
            var output = text_cell.find("div.text_cell_render");
            output.hide();
            text_cell.find('div.text_cell_input').show();
            this.code_mirror.refresh();
            this.code_mirror.focus();
            // We used to need an additional refresh() after the focus, but
            // it appears that this has been fixed in CM. This bug would show
            // up on FF when a newly loaded markdown cell was edited.
            this.rendered = false;
            if (this.get_text() === this.placeholder) {
                this.set_text('');
                this.refresh();
            }
        }
    };

    /**
     * Empty, Subclasses must define render.
     * @method render
     */
    TextCell.prototype.render = function () {};

    /**
     * setter: {{#crossLink "TextCell/set_text"}}{{/crossLink}}
     * @method get_text
     * @retrun {string} CodeMirror current text value
     */
    TextCell.prototype.get_text = function() {
        return this.code_mirror.getValue();
    };

    /**
     * @param {string} text - Codemiror text value
     * @see TextCell#get_text
     * @method set_text
     * */
    TextCell.prototype.set_text = function(text) {
        this.code_mirror.setValue(text);
        this.code_mirror.refresh();
    };

    /**
     * setter :{{#crossLink "TextCell/set_rendered"}}{{/crossLink}}
     * @method get_rendered
     * @return {html} html of rendered element
     * */
    TextCell.prototype.get_rendered = function() {
        return this.element.find('div.text_cell_render').html();
    };

    /**
     * @method set_rendered
     */
    TextCell.prototype.set_rendered = function(text) {
        this.element.find('div.text_cell_render').html(text);
    };

    /**
     * not deprecated, but implementation wrong
     * @method at_top
     * @deprecated
     * @return {Boolean} true is cell rendered, false otherwise
     * I doubt this is what it is supposed to do
     * this implementation is completly false
     */
    TextCell.prototype.at_top = function () {
        if (this.rendered) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * not deprecated, but implementation wrong
     * @method at_bottom
     * @deprecated
     * @return {Boolean} true is cell rendered, false otherwise
     * I doubt this is what it is supposed to do
     * this implementation is completly false
     * */
    TextCell.prototype.at_bottom = function () {
        if (this.rendered) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * Create Text cell from JSON
     * @param {json} data - JSON serialized text-cell
     * @method fromJSON
     */
    TextCell.prototype.fromJSON = function (data) {
        IPython.Cell.prototype.fromJSON.apply(this, arguments);
        if (data.cell_type === this.cell_type) {
            if (data.source !== undefined) {
                this.set_text(data.source);
                // make this value the starting point, so that we can only undo
                // to this state, instead of a blank cell
                this.code_mirror.clearHistory();
                this.set_rendered(data.rendered || '');
                this.rendered = false;
                this.render();
            }
        }
    };

    /** Generate JSON from cell
     * @return {object} cell data serialised to json
     */
    TextCell.prototype.toJSON = function () {
        var data = IPython.Cell.prototype.toJSON.apply(this);
        data.cell_type = this.cell_type;
        data.source = this.get_text();
        return data;
    };

    /**
     * @constructor HtmlCell
     * @class HtmlCell
     * @extends Ipython.TextCell
     */
    var HTMLCell = function () {
        this.placeholder = "Type HTML and LaTeX: $\\alpha^2$";
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'html';
    };

    HTMLCell.prototype = new TextCell();

    /**
     * @method render
     */
    HTMLCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            this.set_rendered(text);
            this.typeset();
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            this.rendered = true;
        }
    };

    /**
     * @class MarkdownCell
     * @constructor MarkdownCell
     * @extends Ipython.HtmlCell
     */
    var MarkdownCell = function () {
        this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'markdown';
    };

    MarkdownCell.prototype = new TextCell();

    /**
     * @method render
     */
    MarkdownCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            text = IPython.mathjaxutils.remove_math(text)
            var html = IPython.markdown_converter.makeHtml(text);
            html = IPython.mathjaxutils.replace_math(html)
            try {
                this.set_rendered(html);
            } catch (e) {
                console.log("Error running Javascript in Markdown:");
                console.log(e);
                this.set_rendered($("
").addClass("js-error").html(
                    "Error rendering Markdown!
" + e.toString())
                );
            }
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            var code_snippets = this.element.find("pre > code");
            code_snippets.replaceWith(function () {
                var code = $(this).html();
                /* Substitute br for newlines and   for spaces
                   before highlighting, since prettify doesn't
                   preserve those on all browsers */
                code = code.replace(/(\r\n|\n|\r)/gm, "
");
                code = code.replace(/ /gm, ' ');
                code = prettyPrintOne(code);

                return '' + code + '';
            });
            this.typeset()
            this.rendered = true;
        }
    };

    // RawCell

    /**
     * @class RawCell
     * @constructor RawCell
     * @extends Ipython.TextCell
     */
    var RawCell = function () {
        this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
        this.code_mirror_mode = 'rst';
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'raw';
        var that = this

        this.element.focusout(
                function() { that.auto_highlight(); }
            );
    };

    RawCell.prototype = new TextCell();

    /**
     * Trigger autodetection of highlight scheme for current cell
     * @method auto_highlight
     */
    RawCell.prototype.auto_highlight = function () {
        this._auto_highlight(IPython.config.raw_cell_highlight);
    };

    /** @method render **/
    RawCell.prototype.render = function () {
        this.rendered = true;
        this.edit();
    };

    /** @method handle_codemirror_keyevent **/
    RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {

        var that = this;
        if (event.which === key.UPARROW && event.type === 'keydown') {
            // If we are not at the top, let CM handle the up arrow and
            // prevent the global keydown handler from handling it.
            if (!that.at_top()) {
                event.stop();
                return false;
            } else {
                return true;
            };
        } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
            // If we are not at the bottom, let CM handle the down arrow and
            // prevent the global keydown handler from handling it.
            if (!that.at_bottom()) {
                event.stop();
                return false;
            } else {
                return true;
            };
        };
        return false;
    };

    /** @method select **/
    RawCell.prototype.select = function () {
        IPython.Cell.prototype.select.apply(this);
        this.code_mirror.refresh();
        this.code_mirror.focus();
    };

    /** @method at_top **/
    RawCell.prototype.at_top = function () {
        var cursor = this.code_mirror.getCursor();
        if (cursor.line === 0 && cursor.ch === 0) {
            return true;
        } else {
            return false;
        }
    };

    /** @method at_bottom **/
    RawCell.prototype.at_bottom = function () {
        var cursor = this.code_mirror.getCursor();
        if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * @class HeadingCell
     * @extends Ipython.TextCell
     */

    /**
     * @constructor HeadingCell
     * @extends Ipython.TextCell
     */
    var HeadingCell = function () {
        this.placeholder = "Type Heading Here";
        IPython.TextCell.apply(this, arguments);
        /**
         * heading level of the cell, use getter and setter to access
         * @property level
         */
        this.level = 1;
        this.cell_type = 'heading';
    };

    HeadingCell.prototype = new TextCell();

    /** @method fromJSON */
    HeadingCell.prototype.fromJSON = function (data) {
        if (data.level != undefined){
            this.level = data.level;
        }
        IPython.TextCell.prototype.fromJSON.apply(this, arguments);
    };

    /** @method toJSON */
    HeadingCell.prototype.toJSON = function () {
        var data = IPython.TextCell.prototype.toJSON.apply(this);
        data.level = this.get_level();
        return data;
    };

    /**
     * Change heading level of cell, and re-render
     * @method set_level
     */
    HeadingCell.prototype.set_level = function (level) {
        this.level = level;
        if (this.rendered) {
            this.rendered = false;
            this.render();
        };
    };

    /** The depth of header cell, based on html (h1 to h6)
     * @method get_level
     * @return {integer} level - for 1 to 6
     */
    HeadingCell.prototype.get_level = function () {
        return this.level;
    };

    HeadingCell.prototype.set_rendered = function (text) {
        var r = this.element.find("div.text_cell_render");
        r.empty();
        r.append(
            $('')
            .addClass('heading-link')
            .attr('href', '#' + text)
            .attr('name', text)
            .append(
                $('<h'+this.level+'/>')
                .html(text)
            )
        );
    };

    HeadingCell.prototype.get_rendered = function () {
        var r = this.element.find("div.text_cell_render");
        return r.children().first().html();
    };

    HeadingCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            this.set_rendered(text);
            this.typeset();
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            this.rendered = true;
        };
    };

    IPython.TextCell = TextCell;
    IPython.HTMLCell = HTMLCell;
    IPython.MarkdownCell = MarkdownCell;
    IPython.RawCell = RawCell;
    IPython.HeadingCell = HeadingCell;

    return IPython;

}(IPython));

<commit_msg>put the anchor inside the header tag<commit_after>//----------------------------------------------------------------------------
//  Copyright (C) 2008-2012  The IPython Development Team
//
//  Distributed under the terms of the BSD License.  The full license is in
//  the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------

//============================================================================
// TextCell
//============================================================================

/**
    A module that allow to create different type of Text Cell
    @module IPython
    @namespace IPython
 */
var IPython = (function (IPython) {

    // TextCell base class
    var key = IPython.utils.keycodes;

    /**
     * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text'
     * cell start as not redered.
     *
     * @class TextCell
     * @constructor TextCell
     * @extend Ipython.Cell
     * @param {object|undefined} [options]
     *      @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config
     */
    var TextCell = function (options) {
        this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
        var options = options || {};

        var cm_overwrite_options  = {
            extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"},
            onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
        };

        var arg_cm_options = options.cm_options || {};
        var cm_config = $.extend({},TextCell.cm_default, arg_cm_options, cm_overwrite_options);

        var options = {};
        options.cm_config = cm_config;

        IPython.Cell.apply(this, [options]);
        this.rendered = false;
        this.cell_type = this.cell_type || 'text';
    };

    TextCell.cm_default = {
            mode: this.code_mirror_mode,
            theme: 'default',
            value: this.placeholder,
            lineWrapping : true,
        }

    TextCell.prototype = new IPython.Cell();

    /**
     * Create the DOM element of the TextCell
     * @method create_element
     * @private
     */
    TextCell.prototype.create_element = function () {
        IPython.Cell.prototype.create_element.apply(this, arguments);
        var cell = $("
").addClass('cell text_cell border-box-sizing vbox');
        cell.attr('tabindex','2');

        this.celltoolbar = new IPython.CellToolbar(this);
        cell.append(this.celltoolbar.element);

        var input_area = $('
').addClass('text_cell_input border-box-sizing');
        this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
        // The tabindex=-1 makes this div focusable.
        var render_area = $('
').addClass('text_cell_render border-box-sizing').
            addClass('rendered_html').attr('tabindex','-1');
        cell.append(input_area).append(render_area);
        this.element = cell;
    };

    /**
     * Bind the DOM evet to cell actions
     * Need to be called after TextCell.create_element
     * @private
     * @method bind_event
     */
    TextCell.prototype.bind_events = function () {
        IPython.Cell.prototype.bind_events.apply(this);
        var that = this;
        this.element.keydown(function (event) {
            if (event.which === 13 && !event.shiftKey) {
                if (that.rendered) {
                    that.edit();
                    return false;
                };
            };
        });
        this.element.dblclick(function () {
            that.edit();
        });
    };

    /**
     * This method gets called in CodeMirror's onKeyDown/onKeyPress
     * handlers and is used to provide custom key handling.
     *
     * Subclass should override this method to have custom handeling
     *
     * @method handle_codemirror_keyevent
     * @param {CodeMirror} editor - The codemirror instance bound to the cell
     * @param {event} event -
     * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise
     */
    TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {

        if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
            // Always ignore shift-enter in CodeMirror as we handle it.
            return true;
        }
        return false;
    };

    /**
     * Select the current cell and trigger 'focus'
     * @method select
     */
    TextCell.prototype.select = function () {
        IPython.Cell.prototype.select.apply(this);
        var output = this.element.find("div.text_cell_render");
        output.trigger('focus');
    };

    /**
     * unselect the current cell and `render` it
     * @method unselect
     */
    TextCell.prototype.unselect = function() {
        // render on selection of another cell
        this.render();
        IPython.Cell.prototype.unselect.apply(this);
    };

    /**
     *
     * put the current cell in edition mode
     * @method edit
     */
    TextCell.prototype.edit = function () {
        if ( this.read_only ) return;
        if (this.rendered === true) {
            var text_cell = this.element;
            var output = text_cell.find("div.text_cell_render");
            output.hide();
            text_cell.find('div.text_cell_input').show();
            this.code_mirror.refresh();
            this.code_mirror.focus();
            // We used to need an additional refresh() after the focus, but
            // it appears that this has been fixed in CM. This bug would show
            // up on FF when a newly loaded markdown cell was edited.
            this.rendered = false;
            if (this.get_text() === this.placeholder) {
                this.set_text('');
                this.refresh();
            }
        }
    };

    /**
     * Empty, Subclasses must define render.
     * @method render
     */
    TextCell.prototype.render = function () {};

    /**
     * setter: {{#crossLink "TextCell/set_text"}}{{/crossLink}}
     * @method get_text
     * @retrun {string} CodeMirror current text value
     */
    TextCell.prototype.get_text = function() {
        return this.code_mirror.getValue();
    };

    /**
     * @param {string} text - Codemiror text value
     * @see TextCell#get_text
     * @method set_text
     * */
    TextCell.prototype.set_text = function(text) {
        this.code_mirror.setValue(text);
        this.code_mirror.refresh();
    };

    /**
     * setter :{{#crossLink "TextCell/set_rendered"}}{{/crossLink}}
     * @method get_rendered
     * @return {html} html of rendered element
     * */
    TextCell.prototype.get_rendered = function() {
        return this.element.find('div.text_cell_render').html();
    };

    /**
     * @method set_rendered
     */
    TextCell.prototype.set_rendered = function(text) {
        this.element.find('div.text_cell_render').html(text);
    };

    /**
     * not deprecated, but implementation wrong
     * @method at_top
     * @deprecated
     * @return {Boolean} true is cell rendered, false otherwise
     * I doubt this is what it is supposed to do
     * this implementation is completly false
     */
    TextCell.prototype.at_top = function () {
        if (this.rendered) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * not deprecated, but implementation wrong
     * @method at_bottom
     * @deprecated
     * @return {Boolean} true is cell rendered, false otherwise
     * I doubt this is what it is supposed to do
     * this implementation is completly false
     * */
    TextCell.prototype.at_bottom = function () {
        if (this.rendered) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * Create Text cell from JSON
     * @param {json} data - JSON serialized text-cell
     * @method fromJSON
     */
    TextCell.prototype.fromJSON = function (data) {
        IPython.Cell.prototype.fromJSON.apply(this, arguments);
        if (data.cell_type === this.cell_type) {
            if (data.source !== undefined) {
                this.set_text(data.source);
                // make this value the starting point, so that we can only undo
                // to this state, instead of a blank cell
                this.code_mirror.clearHistory();
                this.set_rendered(data.rendered || '');
                this.rendered = false;
                this.render();
            }
        }
    };

    /** Generate JSON from cell
     * @return {object} cell data serialised to json
     */
    TextCell.prototype.toJSON = function () {
        var data = IPython.Cell.prototype.toJSON.apply(this);
        data.cell_type = this.cell_type;
        data.source = this.get_text();
        return data;
    };

    /**
     * @constructor HtmlCell
     * @class HtmlCell
     * @extends Ipython.TextCell
     */
    var HTMLCell = function () {
        this.placeholder = "Type HTML and LaTeX: $\\alpha^2$";
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'html';
    };

    HTMLCell.prototype = new TextCell();

    /**
     * @method render
     */
    HTMLCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            this.set_rendered(text);
            this.typeset();
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            this.rendered = true;
        }
    };

    /**
     * @class MarkdownCell
     * @constructor MarkdownCell
     * @extends Ipython.HtmlCell
     */
    var MarkdownCell = function () {
        this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'markdown';
    };

    MarkdownCell.prototype = new TextCell();

    /**
     * @method render
     */
    MarkdownCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            text = IPython.mathjaxutils.remove_math(text)
            var html = IPython.markdown_converter.makeHtml(text);
            html = IPython.mathjaxutils.replace_math(html)
            try {
                this.set_rendered(html);
            } catch (e) {
                console.log("Error running Javascript in Markdown:");
                console.log(e);
                this.set_rendered($("
").addClass("js-error").html(
                    "Error rendering Markdown!
" + e.toString())
                );
            }
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            var code_snippets = this.element.find("pre > code");
            code_snippets.replaceWith(function () {
                var code = $(this).html();
                /* Substitute br for newlines and   for spaces
                   before highlighting, since prettify doesn't
                   preserve those on all browsers */
                code = code.replace(/(\r\n|\n|\r)/gm, "
");
                code = code.replace(/ /gm, ' ');
                code = prettyPrintOne(code);

                return '' + code + '';
            });
            this.typeset()
            this.rendered = true;
        }
    };

    // RawCell

    /**
     * @class RawCell
     * @constructor RawCell
     * @extends Ipython.TextCell
     */
    var RawCell = function () {
        this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
        this.code_mirror_mode = 'rst';
        IPython.TextCell.apply(this, arguments);
        this.cell_type = 'raw';
        var that = this

        this.element.focusout(
                function() { that.auto_highlight(); }
            );
    };

    RawCell.prototype = new TextCell();

    /**
     * Trigger autodetection of highlight scheme for current cell
     * @method auto_highlight
     */
    RawCell.prototype.auto_highlight = function () {
        this._auto_highlight(IPython.config.raw_cell_highlight);
    };

    /** @method render **/
    RawCell.prototype.render = function () {
        this.rendered = true;
        this.edit();
    };

    /** @method handle_codemirror_keyevent **/
    RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {

        var that = this;
        if (event.which === key.UPARROW && event.type === 'keydown') {
            // If we are not at the top, let CM handle the up arrow and
            // prevent the global keydown handler from handling it.
            if (!that.at_top()) {
                event.stop();
                return false;
            } else {
                return true;
            };
        } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
            // If we are not at the bottom, let CM handle the down arrow and
            // prevent the global keydown handler from handling it.
            if (!that.at_bottom()) {
                event.stop();
                return false;
            } else {
                return true;
            };
        };
        return false;
    };

    /** @method select **/
    RawCell.prototype.select = function () {
        IPython.Cell.prototype.select.apply(this);
        this.code_mirror.refresh();
        this.code_mirror.focus();
    };

    /** @method at_top **/
    RawCell.prototype.at_top = function () {
        var cursor = this.code_mirror.getCursor();
        if (cursor.line === 0 && cursor.ch === 0) {
            return true;
        } else {
            return false;
        }
    };

    /** @method at_bottom **/
    RawCell.prototype.at_bottom = function () {
        var cursor = this.code_mirror.getCursor();
        if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
            return true;
        } else {
            return false;
        }
    };

    /**
     * @class HeadingCell
     * @extends Ipython.TextCell
     */

    /**
     * @constructor HeadingCell
     * @extends Ipython.TextCell
     */
    var HeadingCell = function () {
        this.placeholder = "Type Heading Here";
        IPython.TextCell.apply(this, arguments);
        /**
         * heading level of the cell, use getter and setter to access
         * @property level
         */
        this.level = 1;
        this.cell_type = 'heading';
    };

    HeadingCell.prototype = new TextCell();

    /** @method fromJSON */
    HeadingCell.prototype.fromJSON = function (data) {
        if (data.level != undefined){
            this.level = data.level;
        }
        IPython.TextCell.prototype.fromJSON.apply(this, arguments);
    };

    /** @method toJSON */
    HeadingCell.prototype.toJSON = function () {
        var data = IPython.TextCell.prototype.toJSON.apply(this);
        data.level = this.get_level();
        return data;
    };

    /**
     * Change heading level of cell, and re-render
     * @method set_level
     */
    HeadingCell.prototype.set_level = function (level) {
        this.level = level;
        if (this.rendered) {
            this.rendered = false;
            this.render();
        };
    };

    /** The depth of header cell, based on html (h1 to h6)
     * @method get_level
     * @return {integer} level - for 1 to 6
     */
    HeadingCell.prototype.get_level = function () {
        return this.level;
    };

    HeadingCell.prototype.set_rendered = function (text) {
        var r = this.element.find("div.text_cell_render");
        r.empty();
        r.append(
            $('<h'+this.level+'/>')
            .append(
            $('')
                .addClass('heading-link')
                .attr('href', '#' + text)
                .attr('name', text)
                .html(text)
            )
        );
    };

    HeadingCell.prototype.get_rendered = function () {
        var r = this.element.find("div.text_cell_render");
        return r.children().first().html();
    };

    HeadingCell.prototype.render = function () {
        if (this.rendered === false) {
            var text = this.get_text();
            if (text === "") { text = this.placeholder; }
            this.set_rendered(text);
            this.typeset();
            this.element.find('div.text_cell_input').hide();
            this.element.find("div.text_cell_render").show();
            this.rendered = true;
        };
    };

    IPython.TextCell = TextCell;
    IPython.HTMLCell = HTMLCell;
    IPython.MarkdownCell = MarkdownCell;
    IPython.RawCell = RawCell;
    IPython.HeadingCell = HeadingCell;

    return IPython;

}(IPython));

<|endoftext|>


<commit_before>var shakaGetMessage = function(code) {
	for (var k in shaka.util.Error.Code) {
		if (shaka.util.Error.Code[k] == code)
			return k
	}
}

var shakaSignalError = function(ui, err) {
	if (!err.message)
		err.message = shakaGetMessage(err.code)
	ui.error(err)
}

var Player = function(ui) {
	var player = ui._context.createElement('video')

	this._player = player

	if (!shaka.Player.isBrowserSupported()) {
		throw new Error("browser is not supported, backend should not have been registered")
	}

	var shakaPlayer = new shaka.Player(player.dom);
	this.shakaPlayer = shakaPlayer;

	this.element = player
	this.ui = ui
	this.setEventListeners()

	ui.element.remove()
	ui.element = player
	ui.parent.element.append(ui.element)
}

Player.prototype = Object.create(_globals.video.html5.backend.Player.prototype)

Player.prototype.setupDrm = function(type, options, callback, error) {
	var laServer = {}
	if (type === "widevine")
		laServer["com.widevine.alpha"] = options.laServer
	else if (type === "playready")
		laServer["com.microsoft.playready"] = options.laServer
	else
		error ? error(new Error("Unknown or not supported DRM type " + type)) : log("Unknown or not supported DRM type " + type)

	var config = { drm: { servers: laServer }, manifest: { dash: { defaultPresentationDelay: 30 } } }
	log("SetupDRM", config)
	this.shakaPlayer.configure(config);
	if (callback)
		callback()
}

Player.prototype.stop = function() {
	log("stop player")
	var self = this
	if (this._loaded) {
		this.shakaPlayer.unload()
			.then(function(e) { log("Unloaded"); self.shakaPlayer.destroy(); self.shakaPlayer = new shaka.Player(self._player.dom); })
			.catch(function(e) { log("Unload failed", e); self.shakaPlayer.destroy(); self.shakaPlayer = new shaka.Player(self._player.dom); })
	} else {
		this.pause()
	}
}

Player.prototype.setSource = function(url) {
	var ui = this.ui
	this._language = null
	this._videoTrackHeight = null
	if (url) {
		var urlLower = url.toLowerCase()
		var querryIndex = url.indexOf("?")
		if (querryIndex >= 0)
			urlLower = urlLower.substring(0, querryIndex)
		var extIndex = urlLower.lastIndexOf(".")
		var extension = urlLower.substring(extIndex, urlLower.length)
		var player = this._player
		if (extension === ".mpd") {
			this._loaded = true
			var self = this
			this.shakaPlayer.load(url)
				.then(function() {
					console.log('The video has now been loaded!');
					if (ui.autoPlay)
						self.play()
				})
				.catch(ui._context.wrapNativeCallback(function(err) { log("Failed to load manifest", err); shakaSignalError(ui, err) }));
		} else {
			this._loaded = false
			this._player.dom.src = url
		}
	}
	if (ui.autoPlay)
		this.play()
}

Player.prototype.getVideoTracks = function() {
	var video = []
	var tracks = this.shakaPlayer.getVariantTracks()

	var lang = tracks && tracks.length ? tracks[0].language : ""
	for (var i = 0; i < tracks.length; ++i) {
		var track = tracks[i]
		if (track.language == lang) {
			video.push({
				id: track.id,
				width: track.width,
				framerate: track.frameRate,
				bandwidth: track.videoBandwidth,
				height: track.height
			})
		}
	}
	return video
}

Player.prototype.getAudioTracks = function() {
	var tracks = this.shakaPlayer.getVariantTracks()
	var audioTracks = {}
	for (var i = 0; i < tracks.length; ++i) {
		var track = tracks[i]
		if (audioTracks[track.audioId])
			continue

		audioTracks[track.audioId] = {
			id: track.audioId,
			language: track.language,
			codec: track.audioCodec
		}
	}

	var audio = []
	for (var i in audioTracks) {
		audio.push(audioTracks[i])
	}
	log("Available audio tracks", audio)

	return audio
}

Player.prototype.setAudioTrack = function(trackId) {
	var tracks = this.shakaPlayer.getVariantTracks()

	var found = tracks.filter(function(element) {
		return element.audioId === trackId
	})

	log("Try to set audio track", found)
	if (found && found.length) {
		var video = found[0]
		var height = this._videoTrackHeight
		if (height && height != video.height) {
			var foundHeight = tracks.filter(function(element) {
				return element.language === video.language && element.height === height
			})
			if (foundHeight && foundHeight.length)
				video = foundHeight[0]
		}
		this.shakaPlayer.configure({
			abr: {
				enabled: false,
				switchInterval: 0
			}
		});
		this._language = found[0].language
		this.shakaPlayer.selectVariantTrack(video)
	}
}

Player.prototype.setVideoTrack = function(trackId) {
	var tracks = this.shakaPlayer.getVariantTracks()

	var found = tracks.filter(function(element) {
		return element.id === trackId
	})

	log("Try to set video track", found)
	if (found && found.length) {
		var video = found[0]
		var lang = this._language
		if (lang && lang != video.language) {
			var foundLang = tracks.filter(function(element) {
				return element.height === video.height && element.language === lang
			})
			if (foundLang && foundLang.length)
				video = foundLang[0]
		}
		this.shakaPlayer.configure({
			abr: {
				enabled: false,
				switchInterval: 0
			}
		});
		this._videoTrackHeight = video.height
		this.shakaPlayer.selectVariantTrack(video)
	}
}

exports.createPlayer = function(ui) {
	return new Player(ui)
}

exports.probeUrl = function(url) {
	return 150
}

exports.Player = Player
<commit_msg>do not call play() after scheduling load, use it for source assignment<commit_after>var shakaGetMessage = function(code) {
	for (var k in shaka.util.Error.Code) {
		if (shaka.util.Error.Code[k] == code)
			return k
	}
}

var shakaSignalError = function(ui, err) {
	if (!err.message)
		err.message = shakaGetMessage(err.code)
	ui.error(err)
}

var Player = function(ui) {
	var player = ui._context.createElement('video')

	this._player = player

	if (!shaka.Player.isBrowserSupported()) {
		throw new Error("browser is not supported, backend should not have been registered")
	}

	var shakaPlayer = new shaka.Player(player.dom);
	this.shakaPlayer = shakaPlayer;

	this.element = player
	this.ui = ui
	this.setEventListeners()

	ui.element.remove()
	ui.element = player
	ui.parent.element.append(ui.element)
}

Player.prototype = Object.create(_globals.video.html5.backend.Player.prototype)

Player.prototype.setupDrm = function(type, options, callback, error) {
	var laServer = {}
	if (type === "widevine")
		laServer["com.widevine.alpha"] = options.laServer
	else if (type === "playready")
		laServer["com.microsoft.playready"] = options.laServer
	else
		error ? error(new Error("Unknown or not supported DRM type " + type)) : log("Unknown or not supported DRM type " + type)

	var config = { drm: { servers: laServer }, manifest: { dash: { defaultPresentationDelay: 30 } } }
	log("SetupDRM", config)
	this.shakaPlayer.configure(config);
	if (callback)
		callback()
}

Player.prototype.stop = function() {
	log("stop player")
	var self = this
	if (this._loaded) {
		this.shakaPlayer.unload()
			.then(function(e) { log("Unloaded"); self.shakaPlayer.destroy(); self.shakaPlayer = new shaka.Player(self._player.dom); })
			.catch(function(e) { log("Unload failed", e); self.shakaPlayer.destroy(); self.shakaPlayer = new shaka.Player(self._player.dom); })
	} else {
		this.pause()
	}
}

Player.prototype.setSource = function(url) {
	var ui = this.ui
	this._language = null
	this._videoTrackHeight = null
	if (url) {
		var urlLower = url.toLowerCase()
		var querryIndex = url.indexOf("?")
		if (querryIndex >= 0)
			urlLower = urlLower.substring(0, querryIndex)
		var extIndex = urlLower.lastIndexOf(".")
		var extension = urlLower.substring(extIndex, urlLower.length)
		var player = this._player
		if (extension === ".mpd") {
			this._loaded = true
			var self = this
			this.shakaPlayer.load(url)
				.then(function() {
					console.log('The video has now been loaded!');
					if (ui.autoPlay)
						self.play()
				})
				.catch(ui._context.wrapNativeCallback(function(err) { log("Failed to load manifest", err); shakaSignalError(ui, err) }));
		} else {
			this._loaded = false
			this._player.dom.src = url
			if (ui.autoPlay)
				this.play()
		}
	}
}

Player.prototype.getVideoTracks = function() {
	var video = []
	var tracks = this.shakaPlayer.getVariantTracks()

	var lang = tracks && tracks.length ? tracks[0].language : ""
	for (var i = 0; i < tracks.length; ++i) {
		var track = tracks[i]
		if (track.language == lang) {
			video.push({
				id: track.id,
				width: track.width,
				framerate: track.frameRate,
				bandwidth: track.videoBandwidth,
				height: track.height
			})
		}
	}
	return video
}

Player.prototype.getAudioTracks = function() {
	var tracks = this.shakaPlayer.getVariantTracks()
	var audioTracks = {}
	for (var i = 0; i < tracks.length; ++i) {
		var track = tracks[i]
		if (audioTracks[track.audioId])
			continue

		audioTracks[track.audioId] = {
			id: track.audioId,
			language: track.language,
			codec: track.audioCodec
		}
	}

	var audio = []
	for (var i in audioTracks) {
		audio.push(audioTracks[i])
	}
	log("Available audio tracks", audio)

	return audio
}

Player.prototype.setAudioTrack = function(trackId) {
	var tracks = this.shakaPlayer.getVariantTracks()

	var found = tracks.filter(function(element) {
		return element.audioId === trackId
	})

	log("Try to set audio track", found)
	if (found && found.length) {
		var video = found[0]
		var height = this._videoTrackHeight
		if (height && height != video.height) {
			var foundHeight = tracks.filter(function(element) {
				return element.language === video.language && element.height === height
			})
			if (foundHeight && foundHeight.length)
				video = foundHeight[0]
		}
		this.shakaPlayer.configure({
			abr: {
				enabled: false,
				switchInterval: 0
			}
		});
		this._language = found[0].language
		this.shakaPlayer.selectVariantTrack(video)
	}
}

Player.prototype.setVideoTrack = function(trackId) {
	var tracks = this.shakaPlayer.getVariantTracks()

	var found = tracks.filter(function(element) {
		return element.id === trackId
	})

	log("Try to set video track", found)
	if (found && found.length) {
		var video = found[0]
		var lang = this._language
		if (lang && lang != video.language) {
			var foundLang = tracks.filter(function(element) {
				return element.height === video.height && element.language === lang
			})
			if (foundLang && foundLang.length)
				video = foundLang[0]
		}
		this.shakaPlayer.configure({
			abr: {
				enabled: false,
				switchInterval: 0
			}
		});
		this._videoTrackHeight = video.height
		this.shakaPlayer.selectVariantTrack(video)
	}
}

exports.createPlayer = function(ui) {
	return new Player(ui)
}

exports.probeUrl = function(url) {
	return 150
}

exports.Player = Player
<|endoftext|>


<commit_before>const path = require("path");

module.exports = {
  extractCSS: false,
  entry: path.resolve(__dirname, "./dev/index.js"),
  vendor: false,
  filename: {
    js: "vue2-editor.js"
  }
};
<commit_msg>Added back poi config option for Quill modules. Commented out<commit_after>const path = require("path");

module.exports = {
  extractCSS: false,
  entry: path.resolve(__dirname, "./dev/index.js"),
  vendor: false,
  filename: {
    js: "vue2-editor.js"
  }
  // extendWebpack(config) {
  // 	config.plugin('provide') // <-- give it a name
  // 		.use(webpack.ProvidePlugin, [{
  // 			'window.Quill': 'quill/dist/quill.js',
  // 			'Quill': 'quill/dist/quill.js',
  // 		}])
  // }
};
<|endoftext|>


<commit_before><commit_msg>Log received data in slide file generation<commit_after><|endoftext|>


<commit_before>const DrawCard = require('../../drawcard.js');
const _ = require('underscore');

class SeppunIshikawa extends DrawCard {
    setupCardAbilities(ability) {
        this.persistentEffect({
            match: this,
            recalculateWhen: ['onMove', 'onPlayIntoConflict', 'onCardTraitChanged', 'onCardEntersPlay', 'onProvinceRevealed', 'onCardTakenControl', 'onCardLeavesPlay', 'onCardSacrificed', 'onCardAttached', 'onBreakProvince'],
            effect: [
                ability.effects.dynamicMilitarySkill(() => this.getImperialCardsInPlay()),
                ability.effects.dynamicPoliticalSkill(() => this.getImperialCardsInPlay())
            ]
        });
    }

    getImperialCardsInPlay() {
        if(this.controller && this.controller.cardsInPlay) {
            return  _.reduce(_.flatten([this.controller.cardsInPlay._wrapped, this.getProvinces()]), (sum, card) => {
                if(card.hasTrait('imperial')) {
                    return sum + 1;
                }
                return sum;
            }, -1);
        }
        return 0;
    }

    getProvinces() {
        let provinces = _.map(['province 1', 'province 2', 'province 3', 'province 4'], location => {
            return this.controller.getProvinceCardInProvince(location);
        });
        return _.filter(provinces, province => {
            return !province.isBroken && !province.facedown
        })
    }
}

SeppunIshikawa.id = 'seppun-ishikawa';

module.exports = SeppunIshikawa;
<commit_msg>eslint<commit_after>const DrawCard = require('../../drawcard.js');
const _ = require('underscore');

class SeppunIshikawa extends DrawCard {
    setupCardAbilities(ability) {
        this.persistentEffect({
            match: this,
            recalculateWhen: ['onMove', 'onPlayIntoConflict', 'onCardTraitChanged', 'onCardEntersPlay', 'onProvinceRevealed', 'onCardTakenControl', 'onCardLeavesPlay', 'onCardSacrificed', 'onCardAttached', 'onBreakProvince'],
            effect: [
                ability.effects.dynamicMilitarySkill(() => this.getImperialCardsInPlay()),
                ability.effects.dynamicPoliticalSkill(() => this.getImperialCardsInPlay())
            ]
        });
    }

    getImperialCardsInPlay() {
        if(this.controller && this.controller.cardsInPlay) {
            return _.reduce(_.flatten([this.controller.cardsInPlay._wrapped, this.getProvinces()]), (sum, card) => {
                if(card.hasTrait('imperial')) {
                    return sum + 1;
                }
                return sum;
            }, -1);
        }
        return 0;
    }

    getProvinces() {
        let provinces = _.map(['province 1', 'province 2', 'province 3', 'province 4'], location => {
            return this.controller.getProvinceCardInProvince(location);
        });
        return _.filter(provinces, province => {
            return !province.isBroken && !province.facedown;
        });
    }
}

SeppunIshikawa.id = 'seppun-ishikawa';

module.exports = SeppunIshikawa;
<|endoftext|>


<commit_before>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
(function() {
  'use strict';

  CKEDITOR.plugins.add('xwiki-wysiwygarea', {
    requires: 'wysiwygarea',

    init: function(editor) {
      // The plugins load additional CSS by calling editor.addContentsCss() which collects the style sheets in the
      // editor.config.contentsCss configuration property. Unfortunately this property is ignored when fullPage is on.
      // We need full page, because we want to load all the XWiki styles, and we also need the plugins styles so the
      // following code fixes this.
      if (editor.config.fullPage) {
        this.injectPluginStyles(editor);
      }
    },

    // Inject the plugins styles into the editing area.
    injectPluginStyles: function(editor) {
      // See https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-contentsCss
      // See https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-toHtml
      editor.on('toHtml', function(event) {
        if (!CKEDITOR.tools.isArray(editor.config.contentsCss)) {
          // No styles to inject.
          return;
        }
        // CKEDITOR.htmlParser.fragment instance
        var documentFragment = event.data.dataValue;
        var heads = documentFragment.find('head', true);
        if (heads.length === 0) {
          // No place to inject the styles.
          return;
        }
        var head = heads[0];
        editor.config.contentsCss.forEach(function(url) {
          // We want to inject only the styles required by the loaded plugins.
          if (url.indexOf('/plugins/') > 0) {
            head.children.push(new CKEDITOR.htmlParser.element('link', {
              rel: 'stylesheet',
              type: 'text/css',
              href: url
            }));
          }
        });
      }, null, null, 14);
    }
  });
})();
<commit_msg>CKEDITOR-219: Paste Fails in CKEditor<commit_after>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
(function() {
  'use strict';

  CKEDITOR.plugins.add('xwiki-wysiwygarea', {
    requires: 'wysiwygarea',

    init: function(editor) {
      // The plugins load additional CSS by calling editor.addContentsCss() which collects the style sheets in the
      // editor.config.contentsCss configuration property. Unfortunately this property is ignored when fullPage is on.
      // We need full page, because we want to load all the XWiki styles, and we also need the plugins styles so the
      // following code fixes this.
      if (editor.config.fullPage) {
        this.injectPluginStyles(editor);
      }
    },

    // Inject the plugins styles into the editing area.
    injectPluginStyles: function(editor) {
      // See https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-contentsCss
      // See https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-toHtml
      editor.on('toHtml', function(event) {
        if (!CKEDITOR.tools.isArray(editor.config.contentsCss)) {
          // No styles to inject.
          return;
        }
        // CKEDITOR.htmlParser.fragment instance
        var documentFragment = event.data.dataValue;
        if (typeof documentFragment.find !== 'function') {
          // The root node doesn't have support for finding child elements.
          return;
        }
        var heads = documentFragment.find('head', true);
        if (heads.length === 0) {
          // No place to inject the styles.
          return;
        }
        var head = heads[0];
        editor.config.contentsCss.forEach(function(url) {
          // We want to inject only the styles required by the loaded plugins.
          if (url.indexOf('/plugins/') > 0) {
            head.children.push(new CKEDITOR.htmlParser.element('link', {
              rel: 'stylesheet',
              type: 'text/css',
              href: url
            }));
          }
        });
      }, null, null, 14);
    }
  });
})();
<|endoftext|>


<commit_before>var curtemp = new TimeSeries();
var settemp = new TimeSeries();
var settempm = new TimeSeries();
var settempp = new TimeSeries();
var pterm = new TimeSeries();
var iterm = new TimeSeries();
var dterm = new TimeSeries();
var pidval = new TimeSeries();
var avgpid = new TimeSeries();
var lastreqdone = 1;

$(document).ready(function(){
  createTimeline();

  $(".adv").hide();
  $("#toggleadv").click(function(){
    $(".adv").toggle();
  });

  $.getJSON({
    url: "/allstats",
    timeout: 500,
    success: function ( resp ) {
      $("#inputSetTemp").val( resp.settemp );
      $("#inputSnooze").val( resp.snooze );
    }
  });

  $("#btnSetTemp").click(function(){
    $.post(
      "/settemp",
      { settemp: $("#inputSetTemp").val() }
    );
  });

  $("#btnSnooze").click(function(){
    $.post("/snooze",{ snooze: $("#inputSnooze").val() });
    $("#btnSnooze").hide();
    $("#btnSnoozeC").show();
  });

  $("#btnSnoozeC").click(function(){
    $.post("/resetsnooze");
    $("#btnSnooze").show();
    $("#btnSnoozeC").hide();
  });

});

setInterval(function() {
  if (lastreqdone == 1) {
    $.getJSON({
      url: "/allstats",
      timeout: 500,
      success: function ( resp ) {
        if (resp.snoozeon == true) {
          $("#btnSnooze").hide();
          $("#btnSnoozeC").show();
        } else {
          $("#btnSnooze").show();
          $("#btnSnoozeC").hide();
        }
        curtemp.append(new Date().getTime(), resp.tempf);
        settemp.append(new Date().getTime(), resp.settemp);
        settempm.append(new Date().getTime(), resp.settemp-4);
        settempp.append(new Date().getTime(), resp.settemp+4);
        pterm.append(new Date().getTime(), resp.pterm);
        iterm.append(new Date().getTime(), resp.iterm);
        dterm.append(new Date().getTime(), resp.dterm);
        pidval.append(new Date().getTime(), resp.pidval);
        avgpid.append(new Date().getTime(), resp.avgpid);
        $("#curtemp").html(resp.tempf.toFixed(2));
        $("#pterm").html(resp.pterm.toFixed(2));
        $("#iterm").html(resp.iterm.toFixed(2));
        $("#dterm").html(resp.dterm.toFixed(2));
        $("#pidval").html(resp.pidval.toFixed(2));
        $("#avgpid").html(resp.avgpid.toFixed(2));
      },
      complete: function () {
        lastreqdone = 1;
      }
    });
    lastreqdone = 0;
  }
}, 100);

function createTimeline() {
  var chart = new SmoothieChart({grid:{verticalSections:3},minValueScale:1.05,maxValueScale:1.05});
  chart.addTimeSeries(settemp, {lineWidth:1,strokeStyle:'#ffff00'});
  chart.addTimeSeries(settempm, {lineWidth:1,strokeStyle:'#ffffff'});
  chart.addTimeSeries(settempp, {lineWidth:1,strokeStyle:'#ffffff'});
  chart.addTimeSeries(curtemp, {lineWidth:3,strokeStyle:'#ff0000'});
  chart.streamTo(document.getElementById("chart"), 500);

  var pidchart = new SmoothieChart({grid:{verticalSections:3},minValueScale:1.05,maxValueScale:1.05});
  pidchart.addTimeSeries(pterm, {lineWidth:2,strokeStyle:'#ff0000'});
  pidchart.addTimeSeries(iterm, {lineWidth:2,strokeStyle:'#00ff00'});
  pidchart.addTimeSeries(dterm, {lineWidth:2,strokeStyle:'#0000ff'});
  pidchart.addTimeSeries(pidval, {lineWidth:2,strokeStyle:'#ffff00'});
  pidchart.addTimeSeries(avgpid, {lineWidth:2,strokeStyle:'#00ffff'});
  pidchart.streamTo(document.getElementById("pidchart"), 500);
}
<commit_msg>added functionality to reset brew temp and wakeup timer input boxes if idle for more than 30 seconds<commit_after>var curtemp = new TimeSeries();
var settemp = new TimeSeries();
var settempm = new TimeSeries();
var settempp = new TimeSeries();
var pterm = new TimeSeries();
var iterm = new TimeSeries();
var dterm = new TimeSeries();
var pidval = new TimeSeries();
var avgpid = new TimeSeries();
var lastreqdone = 1;
var timeout;

function refreshinputs() {
  $.getJSON({
    url: "/allstats",
    timeout: 500,
    success: function ( resp ) {
      $("#inputSetTemp").val( resp.settemp );
      $("#inputSnooze").val( resp.snooze );
    }
  });
}

function resettimer() {
  clearTimeout(timeout);
  timeout = setTimeout(refreshinputs, 30000);
}

$(document).ready(function(){
  resettimer;
  $(this).mousemove(resettimer);
  $(this).keypress(resettimer);
  createTimeline();

  $(".adv").hide();
  $("#toggleadv").click(function(){
    $(".adv").toggle();
  });

  refreshinputs();

  $("#btnSetTemp").click(function(){
    $.post(
      "/settemp",
      { settemp: $("#inputSetTemp").val() }
    );
  });

  $("#btnSnooze").click(function(){
    $.post("/snooze",{ snooze: $("#inputSnooze").val() });
    $("#btnSnooze").hide();
    $("#btnSnoozeC").show();
  });

  $("#btnSnoozeC").click(function(){
    $.post("/resetsnooze");
    $("#btnSnooze").show();
    $("#btnSnoozeC").hide();
  });

});

setInterval(function() {
  if (lastreqdone == 1) {
    $.getJSON({
      url: "/allstats",
      timeout: 500,
      success: function ( resp ) {
        if (resp.snoozeon == true) {
          $("#btnSnooze").hide();
          $("#btnSnoozeC").show();
        } else {
          $("#btnSnooze").show();
          $("#btnSnoozeC").hide();
        }
        curtemp.append(new Date().getTime(), resp.tempf);
        settemp.append(new Date().getTime(), resp.settemp);
        settempm.append(new Date().getTime(), resp.settemp-4);
        settempp.append(new Date().getTime(), resp.settemp+4);
        pterm.append(new Date().getTime(), resp.pterm);
        iterm.append(new Date().getTime(), resp.iterm);
        dterm.append(new Date().getTime(), resp.dterm);
        pidval.append(new Date().getTime(), resp.pidval);
        avgpid.append(new Date().getTime(), resp.avgpid);
        $("#curtemp").html(resp.tempf.toFixed(2));
        $("#pterm").html(resp.pterm.toFixed(2));
        $("#iterm").html(resp.iterm.toFixed(2));
        $("#dterm").html(resp.dterm.toFixed(2));
        $("#pidval").html(resp.pidval.toFixed(2));
        $("#avgpid").html(resp.avgpid.toFixed(2));
      },
      complete: function () {
        lastreqdone = 1;
      }
    });
    lastreqdone = 0;
  }
}, 100);

function createTimeline() {
  var chart = new SmoothieChart({grid:{verticalSections:3},minValueScale:1.05,maxValueScale:1.05});
  chart.addTimeSeries(settemp, {lineWidth:1,strokeStyle:'#ffff00'});
  chart.addTimeSeries(settempm, {lineWidth:1,strokeStyle:'#ffffff'});
  chart.addTimeSeries(settempp, {lineWidth:1,strokeStyle:'#ffffff'});
  chart.addTimeSeries(curtemp, {lineWidth:3,strokeStyle:'#ff0000'});
  chart.streamTo(document.getElementById("chart"), 500);

  var pidchart = new SmoothieChart({grid:{verticalSections:3},minValueScale:1.05,maxValueScale:1.05});
  pidchart.addTimeSeries(pterm, {lineWidth:2,strokeStyle:'#ff0000'});
  pidchart.addTimeSeries(iterm, {lineWidth:2,strokeStyle:'#00ff00'});
  pidchart.addTimeSeries(dterm, {lineWidth:2,strokeStyle:'#0000ff'});
  pidchart.addTimeSeries(pidval, {lineWidth:2,strokeStyle:'#ffff00'});
  pidchart.addTimeSeries(avgpid, {lineWidth:2,strokeStyle:'#00ffff'});
  pidchart.streamTo(document.getElementById("pidchart"), 500);
}
<|endoftext|>


<commit_before>module.exports = {
  'src-specs': {
    src: [
      'test/fail-tests-if-have-errors-in-src.js',
      'test/spec/api/**/*',
      'test/spec/core/**/*',
      'test/spec/dataviews/**/*',
      'test/spec/util/**/*',
      'test/spec/geo/**/*',
      'test/spec/ui/**/*',
      'test/spec/vis/**/*',
      'test/spec/windshaft/**/*',
      'test/spec/windshaft-integration/**/*',
      'test/spec/analysis/**/*',
      'test/spec/engine.spec.js',

      // not actually used anywhere in cartodb.js, only for editor?
      // TODO can be (re)moved?
      '!test/spec/ui/common/tabpane.spec.js'
    ],
    dest: '<%= config.tmp %>/src-specs.js'
  },

  cartodb: {
    src: 'src/cartodb.js',
    exclude: [
      'src/api/v4/'
    ],
    dest: '<%= config.dist %>/internal/cartodb.uncompressed.js'
  },

  'carto-public': {
    src: 'src/api/v4/index.js',
    dest: '<%= config.dist %>/public/carto.uncompressed.js',
    options: {
      external: [ 'leaflet' ]
    }
  }
};
<commit_msg>Add latest camshaft reference in the bundle<commit_after>module.exports = {
  'src-specs': {
    src: [
      'test/fail-tests-if-have-errors-in-src.js',
      'test/spec/api/**/*',
      'test/spec/core/**/*',
      'test/spec/dataviews/**/*',
      'test/spec/util/**/*',
      'test/spec/geo/**/*',
      'test/spec/ui/**/*',
      'test/spec/vis/**/*',
      'test/spec/windshaft/**/*',
      'test/spec/windshaft-integration/**/*',
      'test/spec/analysis/**/*',
      'test/spec/engine.spec.js',

      // not actually used anywhere in cartodb.js, only for editor?
      // TODO can be (re)moved?
      '!test/spec/ui/common/tabpane.spec.js'
    ],
    dest: '<%= config.tmp %>/src-specs.js'
  },

  cartodb: {
    src: 'src/cartodb.js',
    exclude: [
      'src/api/v4/'
    ],
    dest: '<%= config.dist %>/internal/cartodb.uncompressed.js'
  },

  'carto-public': {
    src: [
      'src/api/v4/index.js',
      'node_modules/camshaft-reference/versions/0.59.4/reference.json'
    ],
    dest: '<%= config.dist %>/public/carto.uncompressed.js',
    options: {
      external: [ 'leaflet' ]
    }
  }
};
<|endoftext|>