<commit_before>/* global ProjectKindsModel, ComponentsRegistry */
/* jshint indent: false */ // TODO: ENYO-3311

enyo.kind({
	name: "Deimos",
	classes: "enyo-unselectable onyx",
	debug: false,
	published: {
		projectData: null		// All the project data shared mainly between phobos and deimos
	},
	components: [
		{name: "actionPopup", kind:"PaletteComponentActionPopup", centered: true, floating: true, autoDismiss: false, modal: true},
		{kind: "FittableRows", classes: "enyo-fit", components: [
			{name: "body", fit: true, classes: "deimos_panel_body", kind: "FittableColumns", components: [
				{name: "palette", classes:"ares_deimos_left", kind: "Palette", ondragstart: "paletteDragStart"},
				{name: "middle", fit: true, kind: "FittableRows", components: [
					{kind: "onyx.MoreToolbar", classes: "deimos-toolbar", components: [
						{kind: "onyx.Button", name: "reloadDesignerButton", classes: "deimos-designer-toolbar-spacing", content: "Reload", ontap: "reloadDesigner"},
						{content: "Size:"},
						{kind: "onyx.PickerDecorator", classes: "deimos-device-picker deimos-designer-toolbar-spacing", components: [
							{style: "width:100%;"},
							{kind: "onyx.Picker", name: "devicePicker", ontap: "deviceChosen", components: [
								{content: "(600 x 800) Default",		value: { height: 800,  width: 600 }},
								{content: "(1920 x 1080) HDTV",			value: { height: 1080, width: 1920 }},
								{content: "(320 x 480) iPhone\u2122",	value: { height: 480,  width: 320 }},
								{content: "(320 x 573) iPhone\u2122 5",	value: { height: 573,  width: 320 }},
								{content: "(1024 x 768) iPad\u2122",	value: { height: 768,  width: 1024 }},
								{content: "Custom"}
							]}
						]},
						{content: "Width:"},
						{kind: "onyx.InputDecorator", components: [
							{kind: "onyx.Input", name: "designerWidthInput", classes: "deimos-designer-input", placeholder: "Auto", onchange: "updateWidth"}
						]},
						{kind: "onyx.Button", name: "swapDesignerDimensionsButton", classes: "deimos-swap-dimensions-button", allowHtml: true, content: "&larr;<br/>&rarr;", ontap: "swapDesignerDimensions"},
						{content: "Height:"},
						{kind: "onyx.InputDecorator", components: [
							{kind: "onyx.Input", name: "designerHeightInput", classes: "deimos-designer-input", placeholder: "Auto", onchange: "updateHeight"}
						]},
						{content: "Zoom:"},
						{kind: "onyx.Slider", classes: "deimos-zoom-slider", value: 100, onChange: 'zoomDesigner', onChanging: 'zoomDesigner' }
					]},
					{kind: "Scroller", classes: "deimos-designer-wrapper", fit: true, components: [
						{kind: "Designer", name: "designer",
							onSelect: "designerSelect",
							onSelected: "designerSelected",
							onDesignRendered: "designRendered",
							onMoveItem: "moveItem",
							onCreateItem: "createItem",
							onSyncDropTargetHighlighting: "syncComponentViewDropTargetHighlighting",
							onReloadComplete: "reloadComplete",
							onResizeItem: "resizeItem",
							onReturnPositionValue: "designerReturnPositionValue",
							onForceCloseDesigner: "closeDesignerAction"
						}
					]}
				]},				
				{name: "right", classes:"ares_deimos_right", kind: "FittableRows", components: [
					{kind: "onyx.MoreToolbar", classes: "deimos-toolbar deimos-toolbar-margined-buttons", components: [
						{name:"deleteButton", kind: "onyx.Button", content: "Delete", classes: "btn-danger",  ontap: "deleteAction"},
						{name:"undoButton", kind: "onyx.Button", content: "Undo", classes: "btn-danger",  ontap: "undoAction"},
						{name:"redoButton", kind: "onyx.Button", content: "Redo", classes: "btn-danger",  ontap: "redoAction"}
					]},
					
					{kind: "ComponentView", classes: "deimos_panel ares_deimos_componentView",
						onSelect: "componentViewSelect",
						onHighlightDropTarget: "highlightDesignerDropTarget",
						onUnHighlightDropTargets: "unhighlightDesignerDropTargets",
						onMoveItem: "moveItem",
						onCreateItem: "createItem",
						onHoldOver: "holdOver"
					},
					
					{kind: "Inspector", fit: true, classes: "deimos_panel",
						onModify: "inspectorModify",
						onRequestPositionValue: "inspectorRequestPositionValue",
						onPositionDataUpdated: "inspectorPositionDataUpdated"
					}
				]}
			]}
		]}
	],
	/**
		Select the first item in _this.$.picker_ to iniitalize (do this after
		rendering to avoid error with setting values of width/height fields)
	*/
	events: {
		onCloseDesigner: "",
		onDesignerUpdate: "",
		onUndo: "",
		onRedo: "",
		onRegisterMe: "",
		onError:""
	},
	handlers:{
		onPaletteComponentAction: "runPaletteComponentAction"
	},
	kinds: [],
	index: null,
	previousContent: "",
	fileName: "",
	selectFromComponentView: false,
	
	create: function() {
		ares.setupTraceLogger(this);
		this.trace("Creating Deimos");
		this.inherited(arguments);
		this.addHandlers();
		this.doRegisterMe({name:"deimos", reference:this});
	},
	rendered: function() {
		this.inherited(arguments);
		this.initializeDesignerToolbar();
	},
	//* Initialize _devicePicker_ in the toolbar at render time
	initializeDesignerToolbar: function() {
		this.trace("called");
		var initItem = this.$.devicePicker.getClientControls()[0];
		this.$.devicePicker.setSelected(initItem);
		this.deviceChosen(null, {selected: initItem});
	},
	/**
	 * Loads the first kind passed thru the data parameter
	 * @param data contains kinds declaration (enyo.kind format)
	 *   and project information such as the analyzer output
	 *   for all the .js files of the project and for enyo/onyx.
	 * @public
	 */
	// load acts on pallete, inspector, kindPicker and (may be) sends
	// to designerFrame serialisation options extracted from .design
	// files. No ack message is expected from designerFrame
	load: function(data) {
		this.trace("called with",data);
		this.enableDesignerActionButtons(false);

		var what = data.kinds;
		var maxLen = 0;
		
		this.index = null;
		this.kinds = what;
		this.fileName = data.fileIndexer.name;
		
		this.owner.$.kindPicker.destroyClientControls();

		// Pass the project information (analyzer output, ...) to the inspector and palette
		this.setProjectData(data.projectData);

		// kindPicker let user select the top kind to be designed
		for (var i = 0; i < what.length; i++) {
			var k = what[i];<commit_msg>ENYO-3082: added FIXME 3082 comment<commit_after>/* global ProjectKindsModel, ComponentsRegistry */
/* jshint indent: false */ // TODO: ENYO-3311

enyo.kind({
	name: "Deimos",
	classes: "enyo-unselectable onyx",
	debug: false,
	published: {
		projectData: null		// All the project data shared mainly between phobos and deimos
	},
	components: [
		{name: "actionPopup", kind:"PaletteComponentActionPopup", centered: true, floating: true, autoDismiss: false, modal: true},
		{kind: "FittableRows", classes: "enyo-fit", components: [
			{name: "body", fit: true, classes: "deimos_panel_body", kind: "FittableColumns", components: [
				{name: "palette", classes:"ares_deimos_left", kind: "Palette", ondragstart: "paletteDragStart"},
				{name: "middle", fit: true, kind: "FittableRows", components: [
					{kind: "onyx.MoreToolbar", classes: "deimos-toolbar", components: [
						{kind: "onyx.Button", name: "reloadDesignerButton", classes: "deimos-designer-toolbar-spacing", content: "Reload", ontap: "reloadDesigner"},
						{content: "Size:"},
						{kind: "onyx.PickerDecorator", classes: "deimos-device-picker deimos-designer-toolbar-spacing", components: [
							{style: "width:100%;"},
							{kind: "onyx.Picker", name: "devicePicker", ontap: "deviceChosen", components: [
								{content: "(600 x 800) Default",		value: { height: 800,  width: 600 }},
								{content: "(1920 x 1080) HDTV",			value: { height: 1080, width: 1920 }},
								{content: "(320 x 480) iPhone\u2122",	value: { height: 480,  width: 320 }},
								{content: "(320 x 573) iPhone\u2122 5",	value: { height: 573,  width: 320 }},
								{content: "(1024 x 768) iPad\u2122",	value: { height: 768,  width: 1024 }},
								{content: "Custom"}
							]}
						]},
						{content: "Width:"},
						{kind: "onyx.InputDecorator", components: [
							{kind: "onyx.Input", name: "designerWidthInput", classes: "deimos-designer-input", placeholder: "Auto", onchange: "updateWidth"}
						]},
						{kind: "onyx.Button", name: "swapDesignerDimensionsButton", classes: "deimos-swap-dimensions-button", allowHtml: true, content: "&larr;<br/>&rarr;", ontap: "swapDesignerDimensions"},
						{content: "Height:"},
						{kind: "onyx.InputDecorator", components: [
							{kind: "onyx.Input", name: "designerHeightInput", classes: "deimos-designer-input", placeholder: "Auto", onchange: "updateHeight"}
						]},
						{content: "Zoom:"},
						{kind: "onyx.Slider", classes: "deimos-zoom-slider", value: 100, onChange: 'zoomDesigner', onChanging: 'zoomDesigner' }
					]},
					{kind: "Scroller", classes: "deimos-designer-wrapper", fit: true, components: [
						{kind: "Designer", name: "designer",
							onSelect: "designerSelect",
							onSelected: "designerSelected",
							onDesignRendered: "designRendered",
							onMoveItem: "moveItem",
							onCreateItem: "createItem",
							onSyncDropTargetHighlighting: "syncComponentViewDropTargetHighlighting",
							onReloadComplete: "reloadComplete",
							onResizeItem: "resizeItem",
							onReturnPositionValue: "designerReturnPositionValue",
							onForceCloseDesigner: "closeDesignerAction"
						}
					]}
				]},				
				{name: "right", classes:"ares_deimos_right", kind: "FittableRows", components: [
					{kind: "onyx.MoreToolbar", classes: "deimos-toolbar deimos-toolbar-margined-buttons", components: [
						{name:"deleteButton", kind: "onyx.Button", content: "Delete", classes: "btn-danger",  ontap: "deleteAction"},
						{name:"undoButton", kind: "onyx.Button", content: "Undo", classes: "btn-danger",  ontap: "undoAction"},
						{name:"redoButton", kind: "onyx.Button", content: "Redo", classes: "btn-danger",  ontap: "redoAction"}
					]},
					
					{kind: "ComponentView", classes: "deimos_panel ares_deimos_componentView",
						onSelect: "componentViewSelect",
						onHighlightDropTarget: "highlightDesignerDropTarget",
						onUnHighlightDropTargets: "unhighlightDesignerDropTargets",
						onMoveItem: "moveItem",
						onCreateItem: "createItem",
						onHoldOver: "holdOver"
					},
					
					{kind: "Inspector", fit: true, classes: "deimos_panel",
						onModify: "inspectorModify",
						onRequestPositionValue: "inspectorRequestPositionValue",
						onPositionDataUpdated: "inspectorPositionDataUpdated"
					}
				]}
			]}
		]}
	],
	/**
		Select the first item in _this.$.picker_ to iniitalize (do this after
		rendering to avoid error with setting values of width/height fields)
	*/
	events: {
		onCloseDesigner: "",
		onDesignerUpdate: "",
		onUndo: "",
		onRedo: "",
		onRegisterMe: "",
		onError:""
	},
	handlers:{
		onPaletteComponentAction: "runPaletteComponentAction"
	},
	kinds: [],
	index: null,
	previousContent: "",
	fileName: "",
	selectFromComponentView: false,
	
	create: function() {
		ares.setupTraceLogger(this);
		this.trace("Creating Deimos");
		this.inherited(arguments);
		this.addHandlers();
		this.doRegisterMe({name:"deimos", reference:this});
	},
	rendered: function() {
		this.inherited(arguments);
		this.initializeDesignerToolbar();
	},
	//* Initialize _devicePicker_ in the toolbar at render time
	initializeDesignerToolbar: function() {
		this.trace("called");
		var initItem = this.$.devicePicker.getClientControls()[0];
		this.$.devicePicker.setSelected(initItem);
		this.deviceChosen(null, {selected: initItem});
	},
	/**
	 * Loads the first kind passed thru the data parameter
	 * @param data contains kinds declaration (enyo.kind format)
	 *   and project information such as the analyzer output
	 *   for all the .js files of the project and for enyo/onyx.
	 * @public
	 */
	// load acts on pallete, inspector, kindPicker and (may be) sends
	// to designerFrame serialisation options extracted from .design
	// files. No ack message is expected from designerFrame
	// FIXME-3082: rename to loadDesignerUI ?
	// FIXME 3082: add a callback to delay file load due to kind picker selection
	load: function(data) {
		this.trace("called with",data);
		this.enableDesignerActionButtons(false);

		var what = data.kinds;
		var maxLen = 0;
		
		this.index = null;
		this.kinds = what;
		this.fileName = data.fileIndexer.name;
		
		this.owner.$.kindPicker.destroyClientControls();

		// Pass the project information (analyzer output, ...) to the inspector and palette
		this.setProjectData(data.projectData);

		// kindPicker let user select the top kind to be designed
		for (var i = 0; i < what.length; i++) {
			var k = what[i];
{'fraction_non_alphanumeric': 0.14772189815544695, 'fraction_numerical': 0.015765410688948447, 'mean_word_length': 4.038522637013503, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5735318', 'n_tokens_mistral': 4978, 'n_tokens_neox': 3995, 'n_words': 997}