-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zoom) #MAG-234 : add zoom component for board view
- Loading branch information
1 parent
a79828c
commit f5c97f9
Showing
9 changed files
with
202 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/resources/public/sass/global/components/directives/_zoom.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.zoom{ | ||
background-color: $magneto-grey; | ||
opacity: 75%; | ||
display: flex; | ||
color: $magneto-white; | ||
position: fixed; | ||
border-radius: 32px; | ||
padding: 8px; | ||
right: 45%; | ||
bottom: 1em; | ||
z-index: 2; | ||
|
||
&-plus{ | ||
font-size: 32px; | ||
padding-left: 1em; | ||
margin-top: 3px; | ||
&-disabled{ | ||
color: $magneto-light-grey; | ||
} | ||
} | ||
&-minus{ | ||
padding-right: 1em; | ||
font-size: 32px; | ||
margin-top: 3px; | ||
&-disabled{ | ||
color: $magneto-light-grey; | ||
} | ||
} | ||
&-label{ | ||
margin: 0 1em ; | ||
} | ||
|
||
&-line1 { | ||
content: ""; | ||
position: absolute; | ||
top: 50%; | ||
left: 20%; | ||
width: 40px; | ||
height: 1px; | ||
background-color: #ffffff; | ||
} | ||
|
||
&-line2 { | ||
content: ""; | ||
position: absolute; | ||
top: 50%; | ||
left: 62%; | ||
width: 40px; | ||
height: 1px; | ||
background-color: #ffffff; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/resources/public/ts/directives/zoom/zoom.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import {RootsConst} from "../../core/constants/roots.const"; | ||
import {ng, Me} from "entcore"; | ||
|
||
|
||
interface IViewModel extends ng.IController, ICardProfileProps { | ||
zoomIn(): void; | ||
zoomOut(): void; | ||
savePreferences(): Promise<void> | ||
resetZoom():void; | ||
|
||
zoomReset:number; | ||
} | ||
|
||
interface ICardProfileProps { | ||
zoomLevel: number; | ||
zoomMax: number; | ||
zoomMin: number; | ||
zoomIncrement: number; | ||
preferences: string; | ||
|
||
} | ||
|
||
interface IZoomScope extends ICardProfileProps, IViewModel { | ||
vm: IViewModel; | ||
} | ||
|
||
class Controller implements IViewModel { | ||
zoomLevel: number; | ||
zoomMax: number; | ||
zoomMin: number; | ||
zoomIncrement: number | ||
zoomReset:number | ||
preferences: string; | ||
|
||
constructor() { | ||
if (this.zoomMax === undefined) | ||
this.zoomMax = 150 | ||
if (this.zoomMin === undefined) | ||
this.zoomMin = 50 | ||
if (this.zoomIncrement === undefined) { | ||
this.zoomIncrement = 25 | ||
} | ||
} | ||
|
||
async $onInit() : Promise<void>{ | ||
await Me.preference('magneto') | ||
if (!Me.preferences['magneto']) { | ||
await Me.savePreference('magneto'); | ||
await Me.preference('magneto') | ||
} | ||
if (!Me.preferences['magneto'][this.preferences]) { | ||
Me.preferences['magneto'][this.preferences] = this.zoomLevel; | ||
await Me.savePreference('magneto'); | ||
await Me.preference('magneto') | ||
}else{ | ||
this.zoomLevel = Me.preferences['magneto'][this.preferences]; | ||
} | ||
this.zoomReset = this.zoomLevel; | ||
} | ||
|
||
async zoomIn(): Promise<void> { | ||
if (this.zoomLevel < this.zoomMax) | ||
this.zoomLevel += this.zoomIncrement; | ||
await this.savePreferences(); | ||
} | ||
|
||
async savePreferences():Promise<void> { | ||
Me.preferences['magneto'][this.preferences] = this.zoomLevel; | ||
await Me.savePreference('magneto'); | ||
} | ||
|
||
async zoomOut(): Promise<void> { | ||
if (this.zoomLevel > this.zoomMin) | ||
this.zoomLevel -= this.zoomIncrement; | ||
Me.preferences['magneto'][this.preferences] = this.zoomLevel; | ||
await Me.savePreference('magneto'); | ||
} | ||
|
||
resetZoom():void { | ||
this.zoomLevel = this.zoomReset; | ||
} | ||
|
||
} | ||
|
||
function directive() { | ||
return { | ||
restrict: 'E', | ||
templateUrl: `${RootsConst.directive}zoom/zoom.html`, | ||
scope: { | ||
zoomLevel: '=', | ||
zoomMax: '=?', | ||
zoomMin: '=?', | ||
zoomIncrement: '=?', | ||
preferences: '@' | ||
}, | ||
controllerAs: 'vm', | ||
bindToController: true, | ||
controller: ['$scope', '$location', '$window', Controller], | ||
/* interaction DOM/element */ | ||
link: function ($scope: IZoomScope, | ||
element: ng.IAugmentedJQuery, | ||
attrs: ng.IAttributes, | ||
vm: IViewModel) { | ||
} | ||
} | ||
} | ||
|
||
export const zoom = ng.directive('zoom', directive) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="zoom"> | ||
|
||
<div class="zoom-minus" ng-click="vm.zoomOut()" ng-disabled="vm.zoomLevel === vm.zoomMin" | ||
ng-class="{'zoom-minus-disabled' : vm.zoomLevel === vm.zoomMin}"> | ||
<i class="magneto-minus" ></i> | ||
</div> | ||
<div class="zoom-line1"></div> | ||
<div class="zoom-label" ng-click="vm.resetZoom()"> | ||
<i18n>magneto.zoom</i18n> | ||
</div> | ||
<div class="zoom-line2"></div> | ||
<div class="zoom-plus" ng-click="vm.zoomIn()" ng-disabled="vm.zoomLevel === vm.zoomMax" | ||
ng-class="{'zoom-plus-disabled' : vm.zoomLevel === vm.zoomMax}"> | ||
<i class="magneto-plus"></i> | ||
</div> | ||
|
||
</div> |