Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(477)

Side by Side Diff: app/views/charm-panel.js

Issue 6947057: Make the prod tests pass.
Patch Set: Created 5 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 'use strict'; 1 'use strict';
2 /** 2 /**
3 * The charm panel view(s). 3 * The charm panel view(s).
4 * 4 *
5 * @module views 5 * @module views
6 */ 6 */
7 7
8 YUI.add('juju-charm-panel', function(Y) { 8 YUI.add('juju-charm-panel', function(Y) {
9 9
10 var views = Y.namespace('juju.views'), 10 var views = Y.namespace('juju.views'),
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 '.btn.cancel': {click: 'goBack'}, 690 '.btn.cancel': {click: 'goBack'},
691 '.btn.deploy': {click: 'onCharmDeployClicked'}, 691 '.btn.deploy': {click: 'onCharmDeployClicked'},
692 '.charm-section h4': {click: toggleSectionVisibility}, 692 '.charm-section h4': {click: toggleSectionVisibility},
693 '.config-file-upload-widget': {change: 'onFileChange'}, 693 '.config-file-upload-widget': {change: 'onFileChange'},
694 '.config-file-upload-overlay': {click: 'onOverlayClick'}, 694 '.config-file-upload-overlay': {click: 'onOverlayClick'},
695 '.config-field': {focus: 'showDescription', 695 '.config-field': {focus: 'showDescription',
696 blur: 'hideDescription'}, 696 blur: 'hideDescription'},
697 'input.config-field[type=checkbox]': 697 'input.config-field[type=checkbox]':
698 {click: function(evt) {evt.target.focus();}} 698 {click: function(evt) {evt.target.focus();}}
699 }, 699 },
700 /**
701 * Determines the Y coordinate that would center a tooltip on a field.
702 *
703 * @static
704 * @param {Number} fieldY The current Y position of the tooltip.
705 * @param {Number} fieldHeight The hight of the field.
706 * @param {Number} tooltipHeight The height of the tooltip.
707 * @return {Number} New Y coordinate for the tooltip.
708 */
709 _calculateTooltipY: function(fieldY, fieldHeight, tooltipHeight) {
710 var y_offset = (tooltipHeight - fieldHeight) / 2;
711 return fieldY - y_offset;
712 },
713 /**
714 * Determines the X coordinate that would place a tooltip next to a
715 * field.
716 *
717 * @static
718 * @param {Number} fieldX The current X position of the tooltip.
719 * @param {Number} tooltipWidth The width of the tooltip.
720 * @return {Number} New X coordinate for the tooltip.
721 */
722 _calculateTooltipX: function(fieldX, tooltipWidth) {
723 return fieldX - tooltipWidth - 15;
724 },
700 _moveTooltip: function() { 725 _moveTooltip: function() {
701 if (this.tooltip.field && 726 if (this.tooltip.field &&
702 Y.DOM.inRegion( 727 Y.DOM.inRegion(
703 this.tooltip.field.getDOMNode(), 728 this.tooltip.field.getDOMNode(),
704 this.tooltip.panelRegion, 729 this.tooltip.panelRegion,
705 true)) { 730 true)) {
706 var fieldHeight = this.tooltip.field.get('clientHeight'); 731 var fieldHeight = this.tooltip.field.get('clientHeight');
707 if (fieldHeight) { 732 if (fieldHeight) {
708 var widget = this.tooltip.get('boundingBox'), 733 var widget = this.tooltip.get('boundingBox'),
709 tooltipWidth = widget.get('clientWidth'), 734 tooltipWidth = widget.get('clientWidth'),
710 tooltipHeight = widget.get('clientHeight'), 735 tooltipHeight = widget.get('clientHeight'),
711 y_offset = (tooltipHeight - fieldHeight) / 2; 736 fieldX = this.tooltip.panel.getX(),
712 this.tooltip.move( // These are the x, y coordinates. 737 fieldY = this.tooltip.field.getY(),
713 [this.tooltip.panel.getX() - tooltipWidth - 15, 738 tooltipX = this._calculateTooltipX(
714 this.tooltip.field.getY() - y_offset]); 739 fieldX, tooltipWidth),
740 tooltipY = this._calculateTooltipY(
741 fieldY, fieldHeight, tooltipHeight);
742 this.tooltip.move([tooltipX, tooltipY]);
715 if (!this.tooltip.get('visible')) { 743 if (!this.tooltip.get('visible')) {
716 this.tooltip.show(); 744 this.tooltip.show();
717 } 745 }
718 } 746 }
719 } else if (this.tooltip.get('visible')) { 747 } else if (this.tooltip.get('visible')) {
720 this.tooltip.hide(); 748 this.tooltip.hide();
721 } 749 }
722 }, 750 },
723 showDescription: function(evt) { 751 showDescription: function(evt) {
724 var controlGroup = evt.target.ancestor('.control-group'), 752 var controlGroup = evt.target.ancestor('.control-group'),
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 'event-key', 1236 'event-key',
1209 'event-outside', 1237 'event-outside',
1210 'widget-anim', 1238 'widget-anim',
1211 'overlay', 1239 'overlay',
1212 'dom-core', 1240 'dom-core',
1213 'juju-models', 1241 'juju-models',
1214 'event-resize', 1242 'event-resize',
1215 'gallery-ellipsis' 1243 'gallery-ellipsis'
1216 ] 1244 ]
1217 }); 1245 });
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 204d58d