ember-arcgis-page-layout
Version:
Page Layout infrastructure components
59 lines (53 loc) • 2.06 kB
JavaScript
/**
* empty-section-drop-target/component.js
*/
import Ember from 'ember';
import layout from './template';
export default Ember.Component.extend({
layout:layout,
classNames:['empty-section-drop-target'],
attributeBindings:['style'],
layoutCoordinator: Ember.inject.service('layout-coordinator'),
sectionComponent:null,
targetContainerStyle: Ember.String.htmlSafe('display:none;'),
hasDockingTarget: Ember.computed.notEmpty('dockingTarget'),
dockingTarget: Ember.computed.alias('layoutCoordinator.draggingProperties.dockingTarget'),
init(){
this._super(...arguments);
//add handlers for layoutCoordinator events
this.get('layoutCoordinator').on('showEmptySectionDropTarget', Ember.run.bind(this, this.showEmptySectionDropTarget));
},
willDestroyElement(){
//console.log('empty-section-drop-target:: '+ this.get('elementId') + ' is is destroying...');
this.set('sectionComponent',null);
this.get('layoutCoordinator').off('showEmptySectionDropTarget');
},
showEmptySectionDropTarget(sectionComponent){
if(sectionComponent){
this.set('sectionComponent', sectionComponent);
this.updateTargetStyle(sectionComponent.get('componentPosition'));
}else{
this.set('sectionComponent',null);
this.updateTargetStyle( null );
}
},
updateTargetStyle(componentPosition){
let styleString = Ember.String.htmlSafe('display:none;');
let pos = componentPosition;
if(pos){
styleString = Ember.String.htmlSafe('top:' + pos.top + 'px; left:' + pos.left + 'px;height:' + pos.height+ 'px;width:' + pos.width + 'px;');
}
this.set('targetContainerStyle', styleString);
},
actions: {
/**
* fires on mouseEnter & mouseLeave for the targets
*/
updateDockingTarget(dockTargetName){
if(this.get('layoutCoordinator.draggingProperties')){
console.log('empty-section-drop-target setting dropTargetName to ' + dockTargetName);
this.set('layoutCoordinator.draggingProperties.dockingTarget', dockTargetName);
}
}
}
});