mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
improved favorite JS code
This commit is contained in:
parent
775990f040
commit
0c152c219f
3 changed files with 27 additions and 18 deletions
|
@ -44,12 +44,18 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
let folder = this.get('folder');
|
||||
this.set('pinState.pinId', this.get('pinned').isSpacePinned(folder.get('id')));
|
||||
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
|
||||
this.set('pinState.newName', folder.get('name').substring(0,3).toUpperCase());
|
||||
this.set('pinState.newName', folder.get('name'));
|
||||
|
||||
this.set('movedFolderOptions', targets);
|
||||
},
|
||||
|
||||
didRender() {
|
||||
this.renderTooltips();
|
||||
},
|
||||
|
||||
renderTooltips() {
|
||||
this.destroyTooltips();
|
||||
|
||||
if (this.get('hasSelectedDocuments')) {
|
||||
if (this.get('permissions.documentMove')) {
|
||||
this.addTooltip(document.getElementById("move-documents-button"));
|
||||
|
@ -65,21 +71,18 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
this.addTooltip(document.getElementById("space-settings-button"));
|
||||
}
|
||||
if (this.get('session.authenticated')) {
|
||||
let t = this.get('pinState.tip');
|
||||
if (is.not.null(t)) {
|
||||
t.destroy();
|
||||
}
|
||||
|
||||
if (this.get('pinState.isPinned')) {
|
||||
this.set('pinState.tip', this.addTooltip(document.getElementById("space-unpin-button")))
|
||||
} else {
|
||||
this.set('pinState.tip', this.addTooltip(document.getElementById("space-pin-button")))
|
||||
}
|
||||
this.addTooltip(document.getElementById("space-unpin-button"));
|
||||
} else {
|
||||
this.addTooltip(document.getElementById("space-pin-button"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is.not.null(this.get('drop'))) {
|
||||
this.get('drop').destroy();
|
||||
this.set('drop', null);
|
||||
|
@ -94,6 +97,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
this.set('pinState.isPinned', false);
|
||||
this.set('pinState.pinId', '');
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -113,6 +117,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
this.set('pinState.isPinned', true);
|
||||
this.set('pinState.pinId', pin.get('id'));
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
@ -35,10 +35,14 @@ export default Ember.Mixin.create({
|
|||
},
|
||||
|
||||
destroyTooltips() {
|
||||
let tt = this.get('tooltips');
|
||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tt = this.get('tooltips');
|
||||
|
||||
tt.forEach(t => {
|
||||
t.destroy();
|
||||
t.destroy();
|
||||
});
|
||||
|
||||
tt.length = 0;
|
||||
|
|
|
@ -42,11 +42,11 @@
|
|||
{{else}}
|
||||
|
||||
{{#if pinState.isPinned}}
|
||||
<div class="round-button button-gray" id="space-unpin-button" data-tooltip="Unpin space" data-tooltip-position="top center" {{action 'onUnpin'}}>
|
||||
<div class="round-button button-gray" id="space-unpin-button" data-tooltip="Remove favorite" data-tooltip-position="top center" {{action 'onUnpin'}}>
|
||||
<i class="material-icons">favorite</i>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="round-button button-gray" id="space-pin-button" data-tooltip="Pin space" data-tooltip-position="top center">
|
||||
<div class="round-button button-gray" id="space-pin-button" data-tooltip="Mark favorite" data-tooltip-position="top center">
|
||||
<i class="material-icons">favorite_border</i>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
@ -68,10 +68,10 @@
|
|||
{{/if}}
|
||||
|
||||
{{#unless pinState.isPinned}}
|
||||
{{#dropdown-dialog target="space-pin-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-space-name" }}
|
||||
{{#dropdown-dialog target="space-pin-button" position="bottom right" button="Pin" color="flat-green" onAction=(action 'onPin') focusOn="pin-space-name"}}
|
||||
<div class="input-control">
|
||||
<label>Pin Space</label>
|
||||
<div class="tip">A 3 or 4 character name</div>
|
||||
<label>Favorite Space</label>
|
||||
<div class="tip">Provide short name</div>
|
||||
{{input type='text' id="pin-space-name" value=pinState.newName}}
|
||||
</div>
|
||||
{{/dropdown-dialog}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue