mirror of
https://github.com/documize/community.git
synced 2025-07-30 10:39:44 +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');
|
let folder = this.get('folder');
|
||||||
this.set('pinState.pinId', this.get('pinned').isSpacePinned(folder.get('id')));
|
this.set('pinState.pinId', this.get('pinned').isSpacePinned(folder.get('id')));
|
||||||
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
|
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);
|
this.set('movedFolderOptions', targets);
|
||||||
},
|
},
|
||||||
|
|
||||||
didRender() {
|
didRender() {
|
||||||
|
this.renderTooltips();
|
||||||
|
},
|
||||||
|
|
||||||
|
renderTooltips() {
|
||||||
|
this.destroyTooltips();
|
||||||
|
|
||||||
if (this.get('hasSelectedDocuments')) {
|
if (this.get('hasSelectedDocuments')) {
|
||||||
if (this.get('permissions.documentMove')) {
|
if (this.get('permissions.documentMove')) {
|
||||||
this.addTooltip(document.getElementById("move-documents-button"));
|
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"));
|
this.addTooltip(document.getElementById("space-settings-button"));
|
||||||
}
|
}
|
||||||
if (this.get('session.authenticated')) {
|
if (this.get('session.authenticated')) {
|
||||||
let t = this.get('pinState.tip');
|
this.addTooltip(document.getElementById("space-unpin-button"));
|
||||||
if (is.not.null(t)) {
|
} else {
|
||||||
t.destroy();
|
this.addTooltip(document.getElementById("space-pin-button"));
|
||||||
}
|
|
||||||
|
|
||||||
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")))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
|
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (is.not.null(this.get('drop'))) {
|
if (is.not.null(this.get('drop'))) {
|
||||||
this.get('drop').destroy();
|
this.get('drop').destroy();
|
||||||
this.set('drop', null);
|
this.set('drop', null);
|
||||||
|
@ -94,6 +97,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
||||||
this.set('pinState.isPinned', false);
|
this.set('pinState.isPinned', false);
|
||||||
this.set('pinState.pinId', '');
|
this.set('pinState.pinId', '');
|
||||||
this.eventBus.publish('pinChange');
|
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.isPinned', true);
|
||||||
this.set('pinState.pinId', pin.get('id'));
|
this.set('pinState.pinId', pin.get('id'));
|
||||||
this.eventBus.publish('pinChange');
|
this.eventBus.publish('pinChange');
|
||||||
|
this.renderTooltips();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -35,10 +35,14 @@ export default Ember.Mixin.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyTooltips() {
|
destroyTooltips() {
|
||||||
let tt = this.get('tooltips');
|
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tt = this.get('tooltips');
|
||||||
|
|
||||||
tt.forEach(t => {
|
tt.forEach(t => {
|
||||||
t.destroy();
|
t.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
tt.length = 0;
|
tt.length = 0;
|
||||||
|
|
|
@ -42,11 +42,11 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
{{#if pinState.isPinned}}
|
{{#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>
|
<i class="material-icons">favorite</i>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{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>
|
<i class="material-icons">favorite_border</i>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -68,10 +68,10 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#unless pinState.isPinned}}
|
{{#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">
|
<div class="input-control">
|
||||||
<label>Pin Space</label>
|
<label>Favorite Space</label>
|
||||||
<div class="tip">A 3 or 4 character name</div>
|
<div class="tip">Provide short name</div>
|
||||||
{{input type='text' id="pin-space-name" value=pinState.newName}}
|
{{input type='text' id="pin-space-name" value=pinState.newName}}
|
||||||
</div>
|
</div>
|
||||||
{{/dropdown-dialog}}
|
{{/dropdown-dialog}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue