src_js/iconolab-bundle/src/components/editor/Canvas.vue
author Alexandre Segura <mex.zktk@gmail.com>
Mon, 15 May 2017 12:38:40 +0200
changeset 502 89dc19ad8073
parent 493 5e8ef87576ec
child 503 a6290b2fae6b
permissions -rw-r--r--
Fix zoom positioning / center.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
<template>
407
74e0a5ea614a Display item metadata below image.
Alexandre Segura <mex.zktk@gmail.com>
parents: 404
diff changeset
     2
    <div class="wrapper">
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     3
        <div>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     4
            <svg ref="svg"
350
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
     5
                class="cut-canvas"
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
     6
                v-bind:class="canvasClass"
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     7
                xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
345
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
     8
                <image xmlns:xlink="http://www.w3.org/1999/xlink"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
     9
                    ref="image"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
    10
                    v-if="loaded"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
    11
                    v-bind:xlink:href="image"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
    12
                    x="0" y="0"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
    13
                    v-bind:width="imageWidth"
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
    14
                    v-bind:height="imageHeight" />
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    15
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    16
                <!-- These are the existing fragments -->
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    17
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    18
                <!-- FIXME using <component :is="..."> does not work -->
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    19
                <shape-rect
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    20
                    v-for="annotation in normalizedAnnotations"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    21
                    :key="annotation.annotation_guid"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    22
                    v-if="loaded &amp;&amp; readonly &amp;&amp; annotation.mode == 'rect'"
342
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
    23
                    v-bind:paper="paper"
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
    24
                    v-bind:original-annotation="annotation"
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    25
                    v-bind:original-path="annotation.path"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    26
                    v-bind:readonly="readonly"
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
    27
                    v-on:click="onAnnotationClick(annotation)"
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
    28
                    v-bind:stroke-width="strokeWidth"></shape-rect>
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    29
                <shape-free
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    30
                    v-for="annotation in normalizedAnnotations"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    31
                    :key="annotation.annotation_guid"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    32
                    v-if="loaded &amp;&amp; readonly &amp;&amp; annotation.mode == 'free'"
342
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
    33
                    v-bind:paper="paper"
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
    34
                    v-bind:original-annotation="annotation"
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    35
                    v-bind:original-path="annotation.path"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    36
                    v-bind:readonly="readonly"
437
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
    37
                    v-bind:stroke-width="strokeWidth"
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    38
                    v-on:click="onAnnotationClick(annotation)"></shape-free>
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    39
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    40
                <!-- These are the new fragments -->
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    41
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    42
                <shape-rect ref="rect"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    43
                    v-show="loaded &amp;&amp; !readonly &amp;&amp; mode == 'rect'"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    44
                    v-bind:paper="paper"
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
    45
                    v-bind:stroke-width="strokeWidth"
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    46
                    :readonly="false"></shape-rect>
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    47
                <shape-free ref="free"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    48
                    v-show="loaded &amp;&amp; !readonly &amp;&amp; mode == 'free'"
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    49
                    v-bind:paper="paper"
437
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
    50
                    v-bind:stroke-width="strokeWidth"
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    51
                    :readonly="false"></shape-free>
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    52
408
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    53
                <defs>
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    54
                    <filter id="shadow" width="200%" height="200%">
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    55
                        <feOffset result="offOut" in="SourceAlpha" dx="0" dy="0"/>
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    56
                        <feGaussianBlur result="blurOut" in="offOut" stdDeviation="10"/>
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    57
                        <feBlend in="SourceGraphic" in2="blurOut" mode="normal"/>
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    58
                    </filter>
159042869b47 Introduce shadow effect on shapes.
Alexandre Segura <mex.zktk@gmail.com>
parents: 407
diff changeset
    59
                </defs>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    60
            </svg>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    61
        </div>
421
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
    62
        <div class="controls" v-show="loaded">
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
    63
            <div class="controls-left">
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    64
                <button
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    65
                    data-intro="Visualisez toutes les annotations"
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    66
                    data-position="top"
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    67
                    @click="toggleReadonly" type="button" class="btn"
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    68
                    v-bind:class="{ 'active': readonly }"
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    69
                    v-show="isAuthenticated">
430
34760e26cc78 Change controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 421
diff changeset
    70
                    <i class="fa fa-eye"></i>
34760e26cc78 Change controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 421
diff changeset
    71
                </button>
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    72
                <button
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    73
                    data-intro="Changez de mode"
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    74
                    data-position="top"
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
    75
                    @click="toggleReadonly" type="button" class="btn"
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    76
                    v-show="isAuthenticated">
430
34760e26cc78 Change controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 421
diff changeset
    77
                    <i v-show="readonly" class="fa fa-toggle-on" style="transform: rotate(180deg)"></i>
34760e26cc78 Change controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 421
diff changeset
    78
                    <i v-show="!readonly" class="fa fa-toggle-on"></i>
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
    79
                </button>
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
    80
                <button data-intro="Sélectionnez un rectangle" data-position="top" @click="setMode('rect')" type="button" class="btn"
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    81
                    v-bind:class="{ 'active': !readonly &amp;&amp; mode === 'rect', 'disabled': readonly }"
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    82
                    v-show="isAuthenticated">
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
    83
                    <svg width="14" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve"><g><rect x="352" y="432" width="64" height="48"/><polygon points="416,352 416,96 176,96 176,160 352,160 352,352 160,352 160,32 96,32 96,96 32,96 32,160 96,160 96,416 480,416 480,352"/></g><text x="0" y="527" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Bluetip Design</text><text x="0" y="532" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>
352
4f0ede751fcf Handle max zoom level.
Alexandre Segura <mex.zktk@gmail.com>
parents: 350
diff changeset
    84
                </button>
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
    85
                <button data-intro="Sélectionnez un polygone" data-position="top" @click="setMode('free')" type="button" class="btn"
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    86
                    v-bind:class="{ 'active': !readonly &amp;&amp; mode === 'free', 'disabled': readonly }"
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    87
                    v-show="isAuthenticated">
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
    88
                    <svg width="14" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 30 30" xml:space="preserve"><g transform="translate(-450 -380)"><g xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M453,395c0,2.209,1.79,4,4,4c1.307,0,2.455-0.635,3.186-1.604l7.121,4.069C467.11,401.938,467,402.456,467,403    c0,2.209,1.79,4,4,4c2.209,0,4-1.791,4-4s-1.791-4-4-4c-1.307,0-2.455,0.635-3.186,1.604l-7.121-4.069    c0.196-0.473,0.307-0.99,0.307-1.534s-0.11-1.062-0.307-1.534l7.121-4.069c0.73,0.969,1.879,1.604,3.186,1.604    c2.209,0,4-1.791,4-4s-1.791-4-4-4c-2.21,0-4,1.791-4,4c0,0.544,0.11,1.062,0.307,1.534l-7.121,4.069    c-0.73-0.969-1.879-1.604-3.186-1.604C454.79,391,453,392.791,453,395z M471,400c1.654,0,3,1.346,3,3s-1.346,3-3,3s-3-1.346-3-3    S469.346,400,471,400z M471,384c1.654,0,3,1.346,3,3s-1.346,3-3,3s-3-1.346-3-3S469.346,384,471,384z M460,395    c0,1.654-1.346,3-3,3s-3-1.346-3-3s1.346-3,3-3S460,393.346,460,395z"/></g></g><text x="0" y="45" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Hea Poh Lin</text><text x="0" y="50" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>
352
4f0ede751fcf Handle max zoom level.
Alexandre Segura <mex.zktk@gmail.com>
parents: 350
diff changeset
    89
                </button>
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    90
                <a class="btn" v-bind:href="loginUrl" v-show="!isAuthenticated">
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    91
                    <i class="fa fa-sign-in"></i> <small>Connexion</small>
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
    92
                </a>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    93
            </div>
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    94
            <div class="controls-center">
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    95
                <zoom-thumbnail
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    96
                    data-intro="Déplacez vous dans l'image zoomée"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    97
                    data-position="top"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    98
                    ref="thumbnail"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
    99
                    @move="changeViewBox($event)"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   100
                    @moveend="syncViewBox()"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   101
                    @dragstart="hideTooltip"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   102
                    @dragend="showTooltip"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   103
                    v-if="loaded"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   104
                    v-bind:image="thumbnail"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   105
                    v-bind:viewport="viewport"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   106
                    v-bind:parentViewBox="viewBox"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   107
                    v-bind:imageWidth="imageWidth"
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   108
                    v-bind:imageHeight="imageHeight"></zoom-thumbnail>
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   109
            </div>
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   110
            <div class="controls-right" data-intro="Zoomez dans l'image" data-position="top">
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   111
                <button @click="zoomOut" type="button" class="btn"
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   112
                    v-bind:class="{ disabled: scale === 1 }">
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   113
                    <i class="fa fa-minus" aria-hidden="true"></i>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   114
                </button>
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   115
                <button @click="zoomIn" type="button" class="btn"
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   116
                    v-bind:class="{ disabled: scale >= 1.9 }">
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   117
                    <i class="fa fa-plus" aria-hidden="true"></i>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   118
                </button>
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   119
            </div>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   120
        </div>
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   121
        <div class="help">
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   122
            <a href="#" class="btn btn-default" v-on:click.stop.prevent="showOnboarding"><i class="fa fa-question-circle"></i></a>
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   123
        </div>
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   124
    </div>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   125
</template>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   126
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   127
<script>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   128
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   129
    import Snap from 'snapsvg'
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   130
    import ShapeRect from './ShapeRect.vue'
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   131
    import ShapeFree from './ShapeFree.vue'
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   132
    import ZoomThumbnail from './ZoomThumbnail.vue'
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   133
    import introJs from 'intro.js'
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   134
    import _ from 'lodash'
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   135
    import Cookies from 'js-cookie'
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   136
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   137
    export default {
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   138
        props: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   139
            image: String,
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   140
            thumbnail: String,
325
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
   141
            annotation: {
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
   142
                type: Object,
342
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   143
                default: null
325
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
   144
            },
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   145
            tooltip: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   146
                type: Boolean,
342
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   147
                default: false
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   148
            },
385
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 374
diff changeset
   149
            isAuthenticated: {
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 374
diff changeset
   150
                type: Boolean,
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 374
diff changeset
   151
                default: false
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   152
            },
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   153
            annotations: {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   154
                type: Array,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   155
                default: []
444
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
   156
            },
d57f95ee9115 Add link to connect when user is not authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 437
diff changeset
   157
            loginUrl: String
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   158
        },
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   159
        components: {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   160
            shapeRect: ShapeRect,
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   161
            shapeFree: ShapeFree,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   162
            zoomThumbnail: ZoomThumbnail,
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   163
        },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   164
        data() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   165
            return {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   166
                paper: null,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   167
                loaded: false,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   168
                mode: 'rect',
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   169
                viewport: { width: 0, height: 0 },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   170
                viewBox: [0 , 0, 0, 0],
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   171
                zoomFactor: 0.1,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   172
                scale: 1,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   173
                imgMinSize: 0,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   174
                imageWidth: 0,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   175
                imageHeight: 0,
437
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
   176
                readonly: false,
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
   177
                strokeWidth: 15,
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   178
                imageRatio: 1
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   179
            }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   180
        },
350
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   181
        computed: {
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   182
            canvasClass: function() {
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   183
                return {
389
583a366e298c Fix usage of isAuthenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 385
diff changeset
   184
                    'canvas--rect': !this.readonly && this.isAuthenticated && this.mode === 'rect',
583a366e298c Fix usage of isAuthenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 385
diff changeset
   185
                    'canvas--free': !this.readonly && this.isAuthenticated && this.mode === 'free'
350
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   186
                }
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   187
            },
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   188
            normalizedAnnotations: function() {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   189
                var normalizedAnnotations = _.map(this.annotations, (annotation) => {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   190
                    if (annotation.fragment.length > 0) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   191
                        var pieces = annotation.fragment.split(';');
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   192
                        var path = this.denormalizePath(pieces[0]);
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   193
                        var mode = pieces[1].toLowerCase();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   194
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   195
                        Object.assign(annotation, {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   196
                            mode: mode,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   197
                            path: path,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   198
                        });
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   199
                    }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   200
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   201
                    return annotation;
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   202
                });
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   203
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   204
                if (this.annotation) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   205
                    return _.filter(normalizedAnnotations, (annotation) => {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   206
                        return annotation === this.annotation;
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   207
                    });
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   208
                }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   209
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   210
                return normalizedAnnotations;
350
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   211
            }
7c0b98b10e00 Do not show custom cursors when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 345
diff changeset
   212
        },
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   213
        watch: {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   214
            mode: function(mode) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   215
                this.reset();
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   216
                if (this.readonly) { return; }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   217
                this.handleDraw();
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   218
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   219
            loaded: function(loaded) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   220
                if (!loaded) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   221
374
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   222
                var bcr = this.paper.node.getBoundingClientRect();
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   223
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   224
                console.log('Viewport: %s x %s', bcr.width, bcr.height);
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   225
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   226
                var viewBox = [0 , 0, this.imageWidth, this.imageHeight];
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   227
                var viewport = {
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   228
                    width: bcr.width,
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   229
                    height: bcr.height
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   230
                };
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   231
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   232
                var imageRatio = 1;
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   233
                if (this.imageWidth > this.imageHeight) {
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   234
                    imageRatio = viewport.width / this.imageWidth;
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   235
                }
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   236
                if (this.imageHeight > this.imageWidth) {
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   237
                    imageRatio = viewport.height / this.imageHeight;
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   238
                }
437
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
   239
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   240
                var strokeWidth = imageRatio > 1 ? (2 * imageRatio) : (2 / imageRatio);
437
0aa597a588c1 Pass strokeWidth as prop.
Alexandre Segura <mex.zktk@gmail.com>
parents: 434
diff changeset
   241
374
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   242
                Object.assign(this, {
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   243
                    viewBox: viewBox,
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   244
                    viewport: viewport,
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   245
                    imageRatio: imageRatio,
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   246
                    strokeWidth: strokeWidth
374
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   247
                });
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   248
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   249
                this.paper.attr({"viewBox": this.viewBox});
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   250
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   251
                if (_.size(this.annotations) > 0) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   252
                    this.readonly = true;
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   253
                }
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   254
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   255
                const onboarding = Cookies.get('__iconolab_onboarding');
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   256
493
5e8ef87576ec Show onboarding only when user is authenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 487
diff changeset
   257
                if (!onboarding && this.isAuthenticated) {
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   258
                    setTimeout(() => {
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   259
                        this.startOnboarding();
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   260
                    }, 1000);
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 449
diff changeset
   261
                }
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   262
            },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   263
            annotation: function(annotation) {
421
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   264
                if (this.isAuthenticated) {
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   265
                    this.readonly = !!annotation;
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   266
                }
334
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   267
            },
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   268
            scale: function(scale) {
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   269
                var factor = 0;
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   270
                if (scale > 1) {
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   271
                    factor = scale - 1;
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   272
                }
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   273
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   274
                if (scale === 1) {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   275
                    this.resetViewBox();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   276
                } else {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   277
                    var center = this.getCenter();
334
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   278
434
924d95c07149 Preserve ratio on zoom.
Alexandre Segura <mex.zktk@gmail.com>
parents: 430
diff changeset
   279
                    var viewBoxW = this.imageWidth - (this.imageWidth * factor);
924d95c07149 Preserve ratio on zoom.
Alexandre Segura <mex.zktk@gmail.com>
parents: 430
diff changeset
   280
                    var viewBoxH = this.imageHeight - (this.imageHeight * factor);
334
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   281
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   282
                    var viewBox = [
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   283
                        center.x - viewBoxW / 2,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   284
                        center.y - viewBoxH / 2,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   285
                        viewBoxW,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   286
                        viewBoxH
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   287
                    ];
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   288
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   289
                    this.hideTooltip();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   290
                    this.animateViewBox(viewBox, () => this.showTooltip());
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   291
                }
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   292
            },
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   293
            readonly: function(readonly, previous) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   294
                this.reset();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   295
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   296
                if (!readonly) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   297
                    this.handleDraw();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   298
                    if (this.annotation) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   299
                        this.$emit('close:annotation');
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   300
                    }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   301
                }
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   302
            }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   303
        },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   304
        mounted() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   305
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   306
            var img = new Image();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   307
            img.onload = (e) => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   308
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   309
                this.paper = new Snap(this.$refs.svg);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   310
345
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   311
                console.log('Image: %s x %s', img.width, img.height);
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   312
374
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   313
                Object.assign(this, {
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   314
                    imageWidth: img.width,
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   315
                    imageHeight: img.height,
449
04ac84f80eb3 Improve calculation of stroke width depending on image ratio.
Alexandre Segura <mex.zktk@gmail.com>
parents: 444
diff changeset
   316
                    imgMinSize: Math.min(img.width, img.height),
374
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   317
                    loaded: true
01a7e6b61314 Improve image loading, do not use setTimeout.
Alexandre Segura <mex.zktk@gmail.com>
parents: 355
diff changeset
   318
                });
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   319
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   320
            }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   321
            img.src = this.image;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   322
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   323
        },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   324
        methods: {
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   325
            onAnnotationClick: function(annotation) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   326
                this.$emit('click:annotation', annotation);
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   327
            },
421
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   328
            toggleReadonly: function() {
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   329
                if (!this.isAuthenticated) { return; }
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   330
                this.readonly = !this.readonly;
6949fe7a69b6 Improve readonly switch.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   331
            },
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   332
            hideTooltip: function() {
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   333
                this.$refs.free.hideTooltip();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   334
                this.$refs.rect.hideTooltip();
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   335
            },
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   336
            showTooltip: function() {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   337
                if (this.mode === 'free') {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   338
                    this.$refs.free.showTooltip();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   339
                }
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   340
                if (this.mode === 'rect') {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   341
                    this.$refs.rect.showTooltip();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   342
                }
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   343
            },
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   344
            reset: function() {
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   345
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   346
                this.$refs.rect.clear();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   347
                this.$refs.free.clear();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   348
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   349
                this.removeEventHandlers();
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   350
                this.resetZoom();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   351
                this.resetViewBox();
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   352
            },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   353
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   354
            removeEventHandlers: function() {
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   355
                this.paper.unmousedown();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   356
                this.paper.unmousemove();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   357
                this.paper.unmouseup();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   358
                this.paper.unclick();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   359
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   360
342
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   361
            setMode: function(mode) {
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   362
                if (this.readonly) { return; }
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   363
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   364
                this.mode = mode;
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   365
            },
ebec1d59dc74 Disable resize & change drawing mode when readonly.
Alexandre Segura <mex.zktk@gmail.com>
parents: 335
diff changeset
   366
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   367
            getCenter: function() {
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   368
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   369
                if (!this.$refs.thumbnail) {
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   370
                    return {
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   371
                        x: this.viewBox[0] + (this.viewBox[2] / 2),
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   372
                        y: this.viewBox[1] + (this.viewBox[3] / 2)
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   373
                    }
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   374
                }
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   375
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   376
                return this.$refs.thumbnail.getCenter()
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   377
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   378
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   379
            changeViewBox: function(e) {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   380
                const viewBox = this.viewBox.slice();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   381
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   382
                viewBox[0] = e.x;
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   383
                viewBox[1] = e.y;
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   384
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   385
                this.paper.attr({ "viewBox": viewBox });
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   386
            },
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   387
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   388
            syncViewBox: function() {
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   389
                const viewBox = this.paper.attr('viewBox');
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   390
                this.viewBox = [
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   391
                    viewBox.x, viewBox.y,
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   392
                    viewBox.width, viewBox.height
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   393
                ]
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   394
            },
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   395
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   396
            resetZoom: function() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   397
                this.scale = 1;
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   398
                if (this.$refs.thumbnail) {
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   399
                    this.$refs.thumbnail.reset();
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   400
                }
335
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   401
            },
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   402
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   403
            animateViewBox: function(viewBox, cb) {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   404
                const viewBoxPrev = this.viewBox.slice();
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   405
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   406
                Snap.animate(
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   407
                    viewBoxPrev, viewBox,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   408
                    (viewBox) => this.paper.attr({ "viewBox": viewBox }),
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   409
                    350, mina.easeinout,
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   410
                    () => {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   411
                        this.viewBox = viewBox;
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   412
                        if (cb) { cb(); }
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   413
                    }
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   414
                );
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   415
            },
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   416
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   417
            resetViewBox: function() {
86dbf2cdeeeb Introduce ZoomThumbnail, improve zoom behavior.
Alexandre Segura <mex.zktk@gmail.com>
parents: 334
diff changeset
   418
                this.animateViewBox([0, 0, this.imageWidth, this.imageHeight]);
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   419
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   420
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   421
            zoomIn: function() {
352
4f0ede751fcf Handle max zoom level.
Alexandre Segura <mex.zktk@gmail.com>
parents: 350
diff changeset
   422
                if (this.scale >= 1.9) { return; }
334
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   423
                this.scale = this.scale + (1 * this.zoomFactor);
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   424
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   425
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   426
            zoomOut: function() {
334
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   427
                if (this.scale === 1) { return; }
a0caf91c8374 Improve zoom, simplify code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 331
diff changeset
   428
                this.scale = this.scale - (1 * this.zoomFactor);
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   429
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   430
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   431
            zoomOffset: function() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   432
                return {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   433
                    x: this.viewport.width / this.viewBox[2],
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   434
                    y: this.viewport.height / this.viewBox[3]
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   435
                };
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   436
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   437
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   438
            computeOffset: function(e) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   439
                var rect = this.$refs.image.getBoundingClientRect();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   440
                var zoomOffset = this.zoomOffset();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   441
                var offsetX = (e.clientX - rect.left) / Math.min(zoomOffset.x, zoomOffset.y);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   442
                var offsetY  = (e.clientY - rect.top) / Math.min(zoomOffset.x, zoomOffset.y);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   443
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   444
                return { x: offsetX, y: offsetY };
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   445
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   446
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   447
            normalizePath: function(path) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   448
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   449
                var xRatio = 100 / this.imageWidth;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   450
                var yRatio = 100 / this.imageHeight;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   451
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   452
                if (isNaN(xRatio) || isNaN(yRatio)) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   453
                    throw new Error('Ratio should be a number.');
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   454
                }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   455
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   456
                var normalizeMatrix = Snap.matrix(xRatio, 0, 0, yRatio, 0, 0);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   457
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   458
                path = Snap.path.map(path, normalizeMatrix).toString();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   459
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   460
                if (path.search(/[z|Z]/gi) === -1) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   461
                    path += " Z";
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   462
                }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   463
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   464
                return path;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   465
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   466
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   467
            denormalizePath: function(path) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   468
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   469
                var xRatio = this.imageWidth / 100;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   470
                var yRatio = this.imageHeight / 100;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   471
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   472
                if (isNaN(xRatio) || isNaN(yRatio)) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   473
                    throw new Error('Ratio should be a number.');
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   474
                }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   475
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   476
                var transformMatrix = Snap.matrix(xRatio, 0, 0, yRatio, 0, 0);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   477
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   478
                path = Snap.path.map(path, transformMatrix).toString();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   479
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   480
                if (path.search(/[z|Z]/gi) === -1) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   481
                    path += " Z";
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   482
                }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   483
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   484
                return path;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   485
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   486
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   487
            toSVGPath: function() {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   488
                if (this.mode === 'free') {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   489
                    this.$refs.free.toSVGPath();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   490
                }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   491
                if (this.mode === 'rect') {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   492
                    this.$refs.rect.toSVGPath();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   493
                }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   494
            },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   495
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   496
            handleDraw: function() {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   497
                if (this.mode === 'free') {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   498
                    this.handleDrawFree();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   499
                }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   500
                if (this.mode === 'rect') {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   501
                    this.handleDrawRect();
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   502
                }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   503
            },
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 414
diff changeset
   504
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   505
            handleDrawFree: function() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   506
389
583a366e298c Fix usage of isAuthenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 385
diff changeset
   507
                if (!this.isAuthenticated) { return; }
385
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 374
diff changeset
   508
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   509
                this.removeEventHandlers();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   510
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   511
                var clickTimeout;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   512
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   513
                var clickHandler = function (offsetX, offsetY) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   514
                    clickTimeout = null;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   515
                    this.$refs.free.addPoint(offsetX, offsetY);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   516
                }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   517
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   518
                this.paper.click((e) => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   519
                    if (clickTimeout) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   520
                    if (!$(e.target).is('image')) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   521
                    if (this.$refs.free.closed) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   522
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   523
                    var offset = this.computeOffset(e);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   524
                    var offsetX = offset.x;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   525
                    var offsetY = offset.y;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   526
                    clickTimeout = setTimeout(clickHandler.bind(this, offsetX, offsetY), 190);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   527
                });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   528
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   529
            },
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   530
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   531
            handleDrawRect: function() {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   532
389
583a366e298c Fix usage of isAuthenticated.
Alexandre Segura <mex.zktk@gmail.com>
parents: 385
diff changeset
   533
                if (!this.isAuthenticated) { return; }
385
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 374
diff changeset
   534
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   535
                this.removeEventHandlers();
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents: 320
diff changeset
   536
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   537
                var startPosition = { x: 0, y: 0 };
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   538
                var currentPosition = { x: 0, y: 0 };
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   539
                var canDraw = false;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   540
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   541
                this.paper.mousedown((e) => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   542
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   543
                    if (this.$refs.rect.width > 0 && this.$refs.rect.height > 0) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   544
331
74cdfdfa9f22 Remove duplicate code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 330
diff changeset
   545
                    startPosition = this.computeOffset(e);
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   546
                    canDraw = true;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   547
                });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   548
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   549
                this.paper.mousemove((e) => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   550
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   551
                    if (!canDraw) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   552
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   553
                    var x, y;
331
74cdfdfa9f22 Remove duplicate code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 330
diff changeset
   554
                    currentPosition = this.computeOffset(e);
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   555
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   556
                    /* bas -> droite */
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   557
                    var width = Math.abs(currentPosition.x - startPosition.x);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   558
                    var height = Math.abs(startPosition.y - currentPosition.y);
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   559
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   560
                    if (currentPosition.y > startPosition.y && currentPosition.x > startPosition.x) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   561
                        x = startPosition.x;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   562
                        y = startPosition.y;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   563
                    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   564
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   565
                    /* haut -> droite */
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   566
                    if (currentPosition.y < startPosition.y && currentPosition.x > startPosition.x) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   567
                        x = currentPosition.x - width;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   568
                        y = currentPosition.y;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   569
                    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   570
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   571
                    /* haut -> gauche */
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   572
                    if (currentPosition.y < startPosition.y && currentPosition.x < startPosition.x) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   573
                        x = currentPosition.x;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   574
                        y = currentPosition.y;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   575
                    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   576
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   577
                    /* bas -> gauche */
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   578
                    if (currentPosition.y > startPosition.y && currentPosition.x < startPosition.x) {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   579
                        x = currentPosition.x
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   580
                        y = currentPosition.y - height;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   581
                    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   582
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   583
                    if(!x || !y) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   584
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   585
                    Object.assign(this.$refs.rect, {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   586
                        x: x,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   587
                        y: y,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   588
                        width: width,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   589
                        height: height,
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   590
                    });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   591
                });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   592
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   593
                this.paper.mouseup((e) => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   594
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   595
                    if (!canDraw) { return; }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   596
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   597
                    canDraw = false;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   598
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   599
                    if (this.$refs.rect.width === 0 && this.$refs.rect.height === 0) {
331
74cdfdfa9f22 Remove duplicate code.
Alexandre Segura <mex.zktk@gmail.com>
parents: 330
diff changeset
   600
                        var currentPosition = this.computeOffset(e);
345
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   601
                        var size = this.imgMinSize / 4;
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   602
                        Object.assign(this.$refs.rect, {
345
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   603
                            x: currentPosition.x - (size / 2),
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   604
                            y: currentPosition.y - (size / 2),
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   605
                            width: size,
4bf0f6ff748d Use getBoundingClientRect to calculate viewport (works cross browser).
Alexandre Segura <mex.zktk@gmail.com>
parents: 342
diff changeset
   606
                            height: size,
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   607
                        });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   608
                    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   609
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   610
                    this.$nextTick(() => {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   611
                        this.$refs.rect.addResizeHandlers();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   612
                        this.$refs.rect.addTooltip();
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   613
                    });
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   614
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   615
                });
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   616
            },
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   617
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   618
            showOnboarding: function(e) {
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   619
                this.startOnboarding();
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   620
            },
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   621
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   622
            startOnboarding: function() {
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   623
                const intro = introJs.introJs();
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   624
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   625
                intro.setOptions({
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   626
                    nextLabel: 'Suivant',
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   627
                    prevLabel: 'Précédent',
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   628
                    skipLabel: 'J\'ai compris',
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   629
                    doneLabel: 'Terminé'
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   630
                })
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   631
                intro.onexit(function() {
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   632
                    Cookies.set('__iconolab_onboarding', 'true', { expires: 365 });
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   633
                })
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   634
                intro.start()
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   635
            }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   636
        }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   637
    }
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   638
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   639
</script>
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   640
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   641
<style scoped>
407
74e0a5ea614a Display item metadata below image.
Alexandre Segura <mex.zktk@gmail.com>
parents: 404
diff changeset
   642
.wrapper {
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   643
    position: relative;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   644
}
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   645
.cut-canvas {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   646
    width: 100%;
411
74b01659ee40 coherent colors
duong tam kien <tk@deveha.com>
parents: 408
diff changeset
   647
    height: 700px;
74b01659ee40 coherent colors
duong tam kien <tk@deveha.com>
parents: 408
diff changeset
   648
    border: 1px solid #ddd;
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   649
}
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   650
.canvas--rect:hover {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   651
    cursor: crosshair;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   652
}
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   653
.canvas--free:hover {
404
38dfe91ee69a switches cursor to `crosshair` in free form mode
duong tam kien <tk@deveha.com>
parents: 389
diff changeset
   654
    cursor: crosshair;
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   655
}
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   656
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   657
.mode-controls .btn > svg {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   658
    margin-top: 4px;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   659
}
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   660
.mode-controls .btn-primary > svg {
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   661
    fill: #fff;
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   662
}
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   663
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   664
.controls {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   665
    position: absolute;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   666
    transform: translateX(-50%);
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   667
    left: 50%;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   668
    bottom: 15px;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   669
    display: flex;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   670
    align-items: center;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   671
}
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   672
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   673
    .controls > * {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   674
        background-color: rgba(34, 34, 34, 0.9);
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   675
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   676
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   677
    .controls .btn {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   678
        background-color: transparent;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   679
        color: #ccc;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   680
        fill: #ccc;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   681
        float: left;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   682
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   683
    .controls .btn:active,
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   684
    .controls .btn.active {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   685
        color: #fff;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   686
        fill: #fff;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   687
        background-color: #111;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   688
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   689
    .controls .btn:hover {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   690
        background-color: #222;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   691
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   692
    .controls .controls-left {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   693
        border-top-left-radius: 4px;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   694
        border-bottom-left-radius: 4px;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   695
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   696
    .controls .controls-center {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   697
        border-radius: 4px;
502
89dc19ad8073 Fix zoom positioning / center.
Alexandre Segura <mex.zktk@gmail.com>
parents: 493
diff changeset
   698
        padding: 8px;
355
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   699
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   700
    .controls .controls-right {
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   701
        border-top-right-radius: 4px;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   702
        border-bottom-right-radius: 4px;
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   703
    }
004fdb42f063 Change design of controls.
Alexandre Segura <mex.zktk@gmail.com>
parents: 352
diff changeset
   704
487
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   705
.help {
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   706
    position: absolute;
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   707
    top: 10px;
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   708
    right: 10px;
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   709
}
a881aa78a3b1 Add button to trigger onboarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 485
diff changeset
   710
320
81945eedc63f Introduce refactored components using Vue.js.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   711
</style>