@oat-sa/tao-core-ui 1.5.4 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/ckeditor/ckConfigurator.js +9 -1
  2. package/dist/mediaEditor/mediaEditorComponent.js +5 -3
  3. package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +46 -25
  4. package/dist/mediaplayer/css/player.css +104 -14
  5. package/dist/mediaplayer/css/player.css.map +1 -1
  6. package/dist/mediaplayer/players/html5.js +767 -0
  7. package/dist/mediaplayer/players/youtube.js +470 -0
  8. package/dist/mediaplayer/players.js +35 -0
  9. package/dist/mediaplayer/support.js +134 -0
  10. package/dist/mediaplayer/utils/reminder.js +198 -0
  11. package/dist/mediaplayer/utils/timeObserver.js +149 -0
  12. package/dist/mediaplayer/youtubeManager.js +177 -0
  13. package/dist/mediaplayer.js +1251 -1912
  14. package/dist/previewer.js +25 -19
  15. package/package.json +1 -1
  16. package/scss/basic.scss +1 -0
  17. package/scss/inc/_jquery.nouislider.scss +254 -0
  18. package/src/ckeditor/ckConfigurator.js +10 -1
  19. package/src/itemButtonList/css/item-button-list.css +225 -0
  20. package/src/itemButtonList/css/item-button-list.css.map +1 -0
  21. package/src/mediaEditor/mediaEditorComponent.js +25 -26
  22. package/src/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +83 -63
  23. package/src/mediaplayer/css/player.css +104 -14
  24. package/src/mediaplayer/css/player.css.map +1 -1
  25. package/src/mediaplayer/players/html5.js +564 -0
  26. package/src/mediaplayer/players/youtube.js +323 -0
  27. package/src/mediaplayer/players.js +29 -0
  28. package/src/mediaplayer/scss/player.scss +125 -16
  29. package/src/mediaplayer/support.js +126 -0
  30. package/src/mediaplayer/tpl/audio.tpl +6 -0
  31. package/src/mediaplayer/tpl/player.tpl +11 -32
  32. package/src/mediaplayer/tpl/source.tpl +1 -0
  33. package/src/mediaplayer/tpl/video.tpl +6 -0
  34. package/src/mediaplayer/tpl/youtube.tpl +1 -0
  35. package/src/mediaplayer/utils/reminder.js +184 -0
  36. package/src/mediaplayer/utils/timeObserver.js +143 -0
  37. package/src/mediaplayer/youtubeManager.js +161 -0
  38. package/src/mediaplayer.js +1217 -1901
  39. package/src/previewer.js +40 -33
  40. package/src/searchModal/css/advancedSearch.css +190 -0
  41. package/src/searchModal/css/advancedSearch.css.map +1 -0
  42. package/src/searchModal/css/searchModal.css +506 -0
  43. package/src/searchModal/css/searchModal.css.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../scss/item-button-list.scss","../../../scss/inc/_functions.scss","../../../scss/inc/fonts/_tao-icon-vars.scss","../../../scss/inc/_colors.scss"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;ACHF;;;;;;CDUC;AEvBD,gBAAA;AF6BA;IACI,aAAa;IACb,eAAe;IACf,sBAAsB;IACtB,UAAU;IAEV,2BAAA;IAsFA,iCAAA;IAkDA,uDAAA;IAsBA,qCAAA;AA/JJ;;AALA;IAQQ,eAZY;IAaZ,cAbY;IAcZ,aAAa;IACb,uBAAuB;IAAE,gEAAA;IACzB,mBAAmB;IACnB,wBAAA;IACA,UAAU;IACV,YAAY;AAEpB;;AAjBA;IAmBQ,kBAAkB;IAClB,aAAa;IACb,uBAAuB;IACvB,mBAAmB;IACnB,YA5BU;IA6BV,WA7BU;IA8BV,mBAAmB;IACnB,kBAhCY;IAiCZ,sBA9Ba;IA+Bb,qBGdmC;IHenC,mCAAmC;IACnC,UAAU;IAAE,6BAAA;IACZ,iBAAiB;IACjB,iBAAiB;IACjB,uBCiJiC;IDhJjC,cGpBmC;IHqBnC,iBAAiB;IACjB,eAAe;AAGvB;;AAvCA;IAwCQ,gEAAgE;IAChE,kBAAkB;IAClB,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;AAG5B;;AA/CA;IAgDQ,UAAU;IACV,MAAM;IACN,OAAO;AAGf;;AArDA;IAsDQ,aAAa;AAGrB;;AAzDA;IA0DQ,kBAAkB;IAClB,YAAY;IACZ,cAAc;IACd,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,YCkHiC;IDjHjC,0BCiHiC;IDhHjC,aAAa;IACb,uBAAuB;IACvB,mBAAmB;AAG3B;;AAvEA;IAwEQ,iBAAiB;IACjB,UAAU;IACV,MAAM;IACN,OAAO;AAGf;;AA9EA;IEdwB,gBAAgB;AFgGxC;;AAlFA;IEZuB,gBAAgB;AFkGvC;;AAtFA;IEiLwB,gBAAgB;AFvFxC;;AA1FA;IEgLyB,gBAAgB;AFlFzC;;AA9FA;IC4BY,yBAAwB;IAAxB,qBAAwB;IAAxB,oBAAwB;IAAxB,iBAAwB;AD0EpC;;AAtGA;IAkGgB,qBApGM;IAqGN,cGpF0B;IHqF1B,qBGrF0B;AH6F1C;;AA5GA;IAyGgB,qBA3GM;IA4GN,yBG3F0B;IH4F1B,YCuEyB;IDtEzB,qBG7F0B;AHoG1C;;AAnHA;IAiHgB,kBAAkB;IAClB,cAAc;IACd,UAAU;IACV,cGrG0B;IHsG1B,cAAc;IACd,iBAAiB;IACjB,UAAU;IACV,eAAe;IACf,UAAU;IACV,2BAAA;IACA,SAAS;IACT,2BAA2B;AAM3C;;AAlIA;IAkIgB,yBG9JU;AHkK1B;;AAtIA;IAwIgB,yBGhKQ;AHkKxB;;AA1IA;IAiJY,yBAzJsB;IA0JtB,cGjIuC;IHkIvC,qBGlIuC;AH+HnD;;AAhJA;IAuJS,wBAAA;IACD,kCAAkC;IAClC,qBAAqB;IACrB,4BAA4B;AAHpC;;AAvJA;IA6JY,mBAAmB;IACnB,wBAAA;IACA,YAAY;IACZ,iBAAiB;AAF7B;;AA9JA;;IAwKY,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,SAAS;IACT,QAAQ;IACR,gCAAgC;IAChC,qBAlLU;IAmLV,qBGhKuC;IHiKvC,oBAAoB;IACpB,kBAzLQ;AAoLpB;;AA9KA;;;IAyLY,cGxKuC;AHmKnD;;AApLA;;IA8LY,uBCZ6B;IDa7B,cG9KuC;IH+KvC,qBG/KuC;AH0KnD;;AA3LA;;IAqMY,yBGpLuC;IHqLvC,YCpB6B;IDqB7B,qBGtLuC;AHiLnD","file":"item-button-list.css","sourcesContent":["/**\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public License\n * as published by the Free Software Foundation; under version 2\n * of the License (non-upgradable).\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n *\n * Copyright (c) 2022 Open Assessment Technologies SA ;\n */\n@import \"inc/bootstrap\";\n\n$correctColor: $success;\n$incorrectColor: $error;\n$hoverBgColor: hsl(208, 100%, 95%);\n\n$radiusCircular: 50%;\n$sizeDefault: 4rem;\n$hitboxSize: 6.25rem;\n$borderThin: 0.125rem;\n$borderMedium: 0.25rem;\n\n.buttonlist-items {\n display: flex;\n flex-wrap: wrap;\n justify-content: start;\n padding: 0;\n\n /****** base styles *******/\n .buttonlist-item {\n height: $hitboxSize;\n width: $hitboxSize;\n display: flex;\n justify-content: center; /* aligning left - cut focusing board for keyboard interacting */\n align-items: center;\n /* reset parent styles */\n padding: 0;\n border: none;\n }\n\n .buttonlist-btn {\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n height: $sizeDefault;\n width: $sizeDefault;\n border-style: solid;\n border-radius: $radiusCircular;\n border-width: $borderThin;\n border-color: $uiReviewPanelTextDisabled;\n margin: 1.3rem 0.75rem 1rem 0.75rem;\n padding: 0; /*Fixes firefox button jumps*/\n font-weight: bold;\n font-size: 1.6rem;\n background-color: $uiReviewPanelBgDefault;\n color: $uiReviewPanelTextDisabled;\n text-shadow: none;\n cursor: pointer;\n }\n\n .buttonlist-label {\n font-family: 'Nunito Sans', 'Source Sans Pro', Arial, sans-serif;\n max-width: 3.75rem;\n overflow: hidden;\n white-space: nowrap;\n line-height: initial;\n }\n\n .buttonlist-icon {\n padding: 0;\n top: 0;\n left: 0;\n }\n\n .indicator {\n display: none;\n }\n\n .buttonlist-score-badge {\n position: absolute;\n top: -0.9rem;\n right: -0.9rem;\n width: 2rem;\n height: 2rem;\n border-radius: 100%;\n color: $uiReviewPanelTextInverted;\n border: 0.1rem solid $uiReviewPanelTextInverted;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .buttonlist-score-icon {\n font-size: 1.2rem;\n padding: 0;\n top: 0;\n left: 0;\n }\n\n .icon-info::before {\n @include icon-info-bare;\n }\n .icon-flagged::before {\n @include icon-bookmark;\n }\n .icon-correct::before {\n @include icon-result-ok;\n }\n .icon-incorrect::before {\n @include icon-result-nok;\n }\n\n\n /****** step state styles *******/\n .buttonlist-item {\n @include disableSelect();\n\n &.viewed {\n .buttonlist-btn {\n border-width: $borderMedium;\n color: $uiReviewPanelTextDefault;\n border-color: $uiReviewPanelTextDefault;\n }\n }\n &.answered {\n .buttonlist-btn {\n border-width: $borderMedium;\n background-color: $uiReviewPanelBgInverted;\n color: $uiReviewPanelTextInverted;\n border-color: $uiReviewPanelBgInverted;\n }\n }\n &.buttonlist-item-active {\n .indicator {\n position: absolute;\n display: block;\n z-index: 1;\n color: $uiReviewPanelTextDefault;\n height: 1.4rem;\n min-width: 1.6rem;\n top: unset;\n bottom: -1.7rem;\n padding: 0;\n /* centering horizontally */\n left: 50%;\n transform: translateX(-50%);\n }\n }\n\n &.correct {\n .buttonlist-score-badge {\n background-color: $correctColor;\n }\n }\n\n &.incorrect {\n .buttonlist-score-badge {\n background-color: $incorrectColor;\n }\n }\n\n }\n\n /* disabling is applied at the buttonlist-items level */\n &:not(.disabled) {\n .buttonlist-btn:hover {\n background-color: $hoverBgColor;\n color: $uiReviewPanelPrimaryHighlight;\n border-color: $uiReviewPanelPrimaryHighlight;\n }\n }\n &.disabled {\n /* reset global styles */\n background-color: unset !important;\n opacity: 1 !important;\n text-shadow: none !important;\n\n .buttonlist-btn {\n cursor: not-allowed;\n /* reset global styles */\n opacity: 0.5;\n text-shadow: none;\n }\n }\n\n /****** keyboard focus styles *******/\n .buttonlist-item {\n &.key-navigation-highlight .buttonlist-btn::before,\n .buttonlist-btn.buttonlist-btn-focus:focus::before {\n content: '';\n display: block;\n position: absolute;\n width: 5.2rem;\n height: 5.2rem;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border-width: $borderMedium;\n border-color: $uiReviewPanelPrimaryHighlight;\n border-style: dotted;\n border-radius: $radiusCircular;\n }\n\n &.key-navigation-highlight.buttonlist-item-active .buttonlist-btn .indicator,\n &.buttonlist-item-active .buttonlist-btn.buttonlist-btn-focus:focus .indicator,\n &.buttonlist-item-active .buttonlist-btn:focus-visible .indicator {\n color: $uiReviewPanelPrimaryHighlight;\n }\n\n &.key-navigation-highlight.viewed .buttonlist-btn,\n &.viewed .buttonlist-btn.buttonlist-btn-focus:focus {\n background-color: $uiReviewPanelBgDefault;\n color: $uiReviewPanelPrimaryHighlight;\n border-color: $uiReviewPanelPrimaryHighlight;\n }\n\n &.key-navigation-highlight.answered .buttonlist-btn,\n &.answered .buttonlist-btn.buttonlist-btn-focus:focus {\n background-color: $uiReviewPanelPrimaryHighlight;\n color: $uiReviewPanelTextInverted;\n border-color: $uiReviewPanelPrimaryHighlight;\n }\n }\n}\n\n/*# sourceMappingURL=item-button-list.css.map */","@mixin iterate-sprite($iconList, $x, $y, $direction, $prefix:'') {\n @each $icon in $iconList {\n #{$prefix}#{$icon} {\n background-position: $x * 1px $y * 1px;\n }\n @if $direction == 'x' {\n $x: $x - 16;\n } @else {\n $y: $y - 16;\n }\n }\n}\n\n/*\nUsage:\n- linear-gradient((color1, color2, color3)) - returns linear-gradient with evenly distributed colors,\n if 3 colors used then the position of each will be 33,33%\n- linear-gradient((color1 0%, color2 30%, color3 80%)) - returns linear-gradient with manually distributed colors,\n first param - color, second - position. Also you can use px or other valid units for set position.\n*/\n@mixin linear-gradient($colorList, $direction: 'to right') {\n $percentage: 0;\n $units: '%';\n $count: length($colorList);\n $increment: 100 / ($count - 1);\n $css: #{$direction + ', '};\n $sep: ', ';\n @each $colorItem in $colorList {\n $color: $colorItem;\n @if (length($colorItem) > 1) {\n $color: nth($colorItem, 1);\n $percentage: nth($colorItem, 2);\n $units: '';\n }\n @if ($percentage >= 100 or index($colorList, $colorItem) == $count) {\n $sep: '';\n }\n $css: #{$css + $color + ' ' + $percentage + $units + $sep};\n $percentage: $percentage + $increment;\n }\n background: linear-gradient( #{$css} );\n}\n\n@mixin grid-unit($span, $numCols: 12, $gutter: 0) {\n $gridPx: 840;\n $rawSpanPx: (($gridPx - ($numCols * $gutter)) / $numCols);\n $spanPx: $rawSpanPx * $span + (($span - 1) * $gutter);\n $spanPercent: widthPerc($spanPx, $gridPx);\n $marginPercent: widthPerc($gutter, $gridPx);\n margin-left: $marginPercent;\n width: $spanPercent;\n}\n\n\n@mixin vendor-prefix($property, $value, $whatToPrefix: property, $prefixes: (-webkit-, -moz-, -ms-, -o-, '')) {\n @if $whatToPrefix == 'property' {\n @each $prefix in $prefixes {\n #{$prefix + $property}: #{$value};\n }\n }\n @else if $whatToPrefix == 'value' {\n @each $prefix in $prefixes {\n #{$property}: #{$prefix + $value};\n }\n }\n}\n@mixin flex-container($wrapBehavior: nowrap, $direction : row) {\n @include vendor-prefix(display, flex, value, (-ms-, -webkit-, ''));\n\n @include vendor-prefix(flex-direction, $direction, property, (-ms-, -webkit-, ''));\n @include vendor-prefix(flex-wrap, $wrapBehavior, property, (-ms-, -webkit-, ''));\n\n @include vendor-prefix(justify-content, flex-start, property, (-webkit-, ''));\n\n @include vendor-prefix(align-content, flex-start, property, (-webkit-, ''));\n\n @include vendor-prefix(align-items, stretch, property, (-webkit-, ''));\n}\n\n@mixin simple-flex-box($width: auto, $minWidth: 1) {\n\n @include vendor-prefix(order, 0, property, (-ms-, -webkit-, ''));\n flex-item-align: stretch;\n -ms-flex-item-align: stretch;\n @include vendor-prefix(align-self, stretch, property, (-webkit-, ''));\n\n // if both, min width and width are set, width will win this conflict\n @if ($width == auto) {\n @if ($minWidth != 1) {\n @include vendor-prefix(flex, 1 1 $minWidth, property, (-ms-, -webkit-, ''));\n }\n @else {\n @include vendor-prefix(flex, 1 1 auto, property, (-ms-, -webkit-, ''));\n // @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis#Values\n // for a discussion auto vs. main-size\n @include vendor-prefix(flex, 1 1, property, (-ms-, -webkit-, ''));\n }\n }\n @else {\n @include vendor-prefix(flex, 0 0 $width, property, (-ms-, -webkit-, ''));\n }\n}\n\n\n@mixin box-shadow($horiz: 1px, $vert: 1px, $blur: 2px, $spread: 0, $color: rgba(0, 0, 0, .2)) {\n @include vendor-prefix(box-shadow, $horiz $vert $blur $spread $color, property);\n}\n\n@mixin simple-border($color: #ddd) {\n border: 1px solid $color;\n border-radius: 2px;\n -webkit-border-radius: 2px;\n}\n\n@mixin border-radius($radius: 2) {\n -moz-border-radius: $radius * 1px;\n -webkit-border-radius: $radius * 1px;\n border-radius: $radius * 1px;\n}\n\n@mixin border-radius-top($radius: 2) {\n -webkit-border-top-left-radius: $radius * 1px;\n -webkit-border-top-right-radius: $radius * 1px;\n -moz-border-radius-topleft: $radius * 1px;\n -moz-border-radius-topright: $radius * 1px;\n border-top-left-radius: $radius * 1px;\n border-top-right-radius: $radius * 1px;\n}\n\n@mixin border-radius-bottom($radius: 2) {\n -webkit-border-bottom-right-radius: $radius * 1px;\n -webkit-border-bottom-left-radius: $radius * 1px;\n -moz-border-radius-bottomright: $radius * 1px;\n -moz-border-radius-bottomleft: $radius * 1px;\n border-bottom-right-radius: $radius * 1px;\n border-bottom-left-radius: $radius * 1px;\n}\n\n@mixin border-radius-left($radius: 2) {\n -webkit-border-top-left-radius: $radius * 1px;\n -webkit-border-bottom-left-radius: $radius * 1px;\n -moz-border-radius-topleft: $radius * 1px;\n -moz-border-radius-bottomleft: $radius * 1px;\n border-top-left-radius: $radius * 1px;\n border-bottom-left-radius: $radius * 1px;\n}\n\n@mixin border-radius-right($radius: 2) {\n -webkit-border-top-right-radius: $radius * 1px;\n -webkit-border-bottom-right-radius: $radius * 1px;\n -moz-border-radius-topright: $radius * 1px;\n -moz-border-radius-bottomright: $radius * 1px;\n border-top-right-radius: $radius * 1px;\n border-bottom-right-radius: $radius * 1px;\n}\n\n@mixin border-radius-top-left($radius: 2) {\n -webkit-border-top-left-radius: $radius * 1px;\n -moz-border-radius-topleft: $radius * 1px;\n border-top-left-radius: $radius * 1px;\n}\n\n@mixin border-radius-top-right($radius: 2) {\n -webkit-border-top-right-radius: $radius * 1px;\n -moz-border-radius-topright: $radius * 1px;\n border-top-right-radius: $radius * 1px;\n}\n\n@mixin border-radius-bottom-right($radius: 2) {\n -webkit-border-bottom-right-radius: $radius * 1px;\n -moz-border-radius-bottomright: $radius * 1px;\n border-bottom-right-radius: $radius * 1px;\n}\n\n@mixin border-radius-bottom-left($radius: 2) {\n -webkit-border-bottom-left-radius: $radius * 1px;\n -moz-border-radius-bottomleft: $radius * 1px;\n border-bottom-left-radius: $radius * 1px;\n}\n\n@mixin border-box() {\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n@function whiten($color, $white: 0.3) {\n @return mix(#fff, $color, ($white * 100) * 1%);\n}\n\n@function blacken($color, $black: 0.3) {\n @return mix(#000, $color, ($black * 100) * 1%);\n}\n\n@function widthPerc($colWidth, $context) {\n @return ($colWidth * 100 / $context) * 1%\n}\n\n@function remDist($fontSizePx) {\n @return ($fontSizePx / 10) * 1rem\n}\n\n@function black($alpha: 1) {\n @return (rgba(0, 0, 0, $alpha))\n}\n\n@function white($alpha: 1) {\n @return (rgba(255, 255, 255, $alpha))\n}\n\n@mixin font-size($remPx, $important: false) {\n @if $important == true {\n font-size: ($remPx) * 1px !important;\n font-size: ($remPx / 10) * 1rem !important;\n }\n @else {\n font-size: ($remPx) * 1px;\n font-size: ($remPx / 10) * 1rem;\n }\n}\n\n\n@mixin keyframes($name) {\n @-o-keyframes #{$name} { @content };\n @-moz-keyframes #{$name} { @content };\n @-webkit-keyframes #{$name} { @content };\n @keyframes #{$name} { @content };\n}\n\n\n@mixin animation($value, $type:'') {\n $animation: animation;\n @if $type != '' {\n $animation: $animation + '-' + $type;\n }\n @include vendor-prefix($animation, $value, property);\n}\n\n/// CSS transition mixin to the current selection (apply also vendor prefixes).\n/// See <https://developer.mozilla.org/en-US/docs/Web/CSS/transition> for the values\n///\n/// @param {property} [$type = all] the CSS property to apply the transition to\n/// @param {time} [$duration = .5s] the transition property\n/// @param {timing-function} [$effect = ease-out] the transition property\n@mixin transition($type : all, $duration : 0.5s, $effect : ease-out, $delay : 0s){\n @include vendor-prefix(transition, $type + ', ' + $duration + ', ' + $effect + ', ' + $delay, property);\n}\n\n@mixin fade($duration: 1s){\n\n @include keyframes(fade) {\n 0% {opacity:0;}\n 50% {opacity:1;}\n 100% {opacity:0;}\n }\n\n @include vendor-prefix(animation, fade 1s forwards, property);\n}\n\n@mixin repeat(){\n @include animation(infinite, iteration-count);\n}\n\n@mixin largeHeading() {\n @include font-size(20);\n font-family: $headingFont;\n font-style: normal;\n}\n\n@mixin disableSelect() {\n @include vendor-prefix(user-select, none, property);\n}\n","/* Do not edit */@mixin tao-icon-setup {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'tao' !important;\n speak: never;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n line-height: 1;\n\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n@mixin icon-info-bare { content: \"\\e923\"; }\n@mixin icon-bookmark-outline { content: \"\\e922\"; }\n@mixin icon-bookmark { content: \"\\e921\"; }\n@mixin icon-indicator { content: \"\\e920\"; }\n@mixin icon-add-subsection { content: \"\\e918\"; }\n@mixin icon-wrap-inline { content: \"\\e915\"; }\n@mixin icon-wrap-left { content: \"\\e916\"; }\n@mixin icon-wrap-right { content: \"\\e917\"; }\n@mixin icon-offline { content: \"\\e913\"; }\n@mixin icon-online { content: \"\\e914\"; }\n@mixin icon-tab { content: \"\\e90d\"; }\n@mixin icon-untab { content: \"\\e90e\"; }\n@mixin icon-multi-select { content: \"\\e90b\"; }\n@mixin icon-clipboard { content: \"\\e90a\"; }\n@mixin icon-filebox { content: \"\\e909\"; }\n@mixin icon-click-to-speak { content: \"\\e907\"; }\n@mixin icon-speech-bubble { content: \"\\f0e5\"; }\n@mixin icon-microphone { content: \"\\f130\"; }\n@mixin icon-microphone-off { content: \"\\f131\"; }\n@mixin icon-disconnect { content: \"\\e905\"; }\n@mixin icon-connect { content: \"\\e906\"; }\n@mixin icon-eliminate { content: \"\\e904\"; }\n@mixin icon-wheelchair { content: \"\\e903\"; }\n@mixin icon-text-marker { content: \"\\e902\"; }\n@mixin icon-unshield { content: \"\\e32a\"; }\n@mixin icon-shield { content: \"\\e8e8\"; }\n@mixin icon-tree { content: \"\\e6b4\"; }\n@mixin icon-home { content: \"\\e6b3\"; }\n@mixin icon-shared-file { content: \"\\e6b2\"; }\n@mixin icon-end-attempt { content: \"\\e603\"; }\n@mixin icon-icon { content: \"\\f1c5\"; }\n@mixin icon-radio-bg { content: \"\\e600\"; }\n@mixin icon-checkbox-bg { content: \"\\e601\"; }\n@mixin icon-tag { content: \"\\e602\"; }\n@mixin icon-style { content: \"\\e604\"; }\n@mixin icon-ownership-transfer { content: \"\\e605\"; }\n@mixin icon-property-advanced { content: \"\\e606\"; }\n@mixin icon-property-add { content: \"\\e607\"; }\n@mixin icon-repository-add { content: \"\\e608\"; }\n@mixin icon-repository-remove { content: \"\\e609\"; }\n@mixin icon-repository { content: \"\\e60a\"; }\n@mixin icon-result-server { content: \"\\e60b\"; }\n@mixin icon-folder { content: \"\\e60c\"; }\n@mixin icon-folder-open { content: \"\\e60d\"; }\n@mixin icon-left { content: \"\\e60e\"; }\n@mixin icon-right { content: \"\\e60f\"; }\n@mixin icon-up { content: \"\\e610\"; }\n@mixin icon-down { content: \"\\e611\"; }\n@mixin icon-undo { content: \"\\e612\"; }\n@mixin icon-redo { content: \"\\e613\"; }\n@mixin icon-screen { content: \"\\e614\"; }\n@mixin icon-laptop { content: \"\\e615\"; }\n@mixin icon-tablet { content: \"\\e616\"; }\n@mixin icon-phone { content: \"\\e617\"; }\n@mixin icon-move { content: \"\\e618\"; }\n@mixin icon-bin { content: \"\\e619\"; }\n@mixin icon-shuffle { content: \"\\e61a\"; }\n@mixin icon-print { content: \"\\e61b\"; }\n@mixin icon-tools { content: \"\\e61c\"; }\n@mixin icon-settings { content: \"\\e61d\"; }\n@mixin icon-video { content: \"\\e61e\"; }\n@mixin icon-find { content: \"\\e61f\"; }\n@mixin icon-image { content: \"\\e620\"; }\n@mixin icon-edit { content: \"\\e621\"; }\n@mixin icon-document { content: \"\\e622\"; }\n@mixin icon-resize-grid { content: \"\\e623\"; }\n@mixin icon-resize { content: \"\\e624\"; }\n@mixin icon-help { content: \"\\e625\"; }\n@mixin icon-mobile-menu { content: \"\\e626\"; }\n@mixin icon-fix { content: \"\\e627\"; }\n@mixin icon-unlock { content: \"\\e628\"; }\n@mixin icon-lock { content: \"\\e629\"; }\n@mixin icon-ul { content: \"\\e62a\"; }\n@mixin icon-ol { content: \"\\e62b\"; }\n@mixin icon-email { content: \"\\e62c\"; }\n@mixin icon-download { content: \"\\e62d\"; }\n@mixin icon-logout { content: \"\\e62e\"; }\n@mixin icon-login { content: \"\\e62f\"; }\n@mixin icon-spinner { content: \"\\e630\"; }\n@mixin icon-preview { content: \"\\e631\"; }\n@mixin icon-external { content: \"\\e632\"; }\n@mixin icon-time { content: \"\\e633\"; }\n@mixin icon-save { content: \"\\e634\"; }\n@mixin icon-warning { content: \"\\e635\"; }\n@mixin icon-add { content: \"\\e636\"; }\n@mixin icon-error { content: \"\\e900\"; }\n@mixin icon-close { content: \"\\e637\"; }\n@mixin icon-success { content: \"\\e638\"; }\n@mixin icon-remove { content: \"\\e639\"; }\n@mixin icon-info { content: \"\\e63a\"; }\n@mixin icon-danger { content: \"\\e63b\"; }\n@mixin icon-users { content: \"\\e63c\"; }\n@mixin icon-user { content: \"\\e63d\"; }\n@mixin icon-test-taker { content: \"\\e63e\"; }\n@mixin icon-test-takers { content: \"\\e63f\"; }\n@mixin icon-item { content: \"\\e640\"; }\n@mixin icon-test { content: \"\\e641\"; }\n@mixin icon-delivery { content: \"\\e642\"; }\n@mixin icon-eye-slash { content: \"\\e643\"; }\n@mixin icon-result { content: \"\\e644\"; }\n@mixin icon-delivery-small { content: \"\\e645\"; }\n@mixin icon-upload { content: \"\\e646\"; }\n@mixin icon-result-small { content: \"\\e647\"; }\n@mixin icon-mobile-preview { content: \"\\e648\"; }\n@mixin icon-extension { content: \"\\e649\"; }\n@mixin icon-desktop-preview { content: \"\\e64a\"; }\n@mixin icon-tablet-preview { content: \"\\e64b\"; }\n@mixin icon-insert-horizontal-line { content: \"\\e64c\"; }\n@mixin icon-table { content: \"\\e64d\"; }\n@mixin icon-anchor { content: \"\\e64e\"; }\n@mixin icon-unlink { content: \"\\e64f\"; }\n@mixin icon-link { content: \"\\e650\"; }\n@mixin icon-right-left { content: \"\\e651\"; }\n@mixin icon-left-right { content: \"\\e652\"; }\n@mixin icon-special-character { content: \"\\e653\"; }\n@mixin icon-source { content: \"\\e654\"; }\n@mixin icon-new-page { content: \"\\e655\"; }\n@mixin icon-templates { content: \"\\e656\"; }\n@mixin icon-cut { content: \"\\e657\"; }\n@mixin icon-replace { content: \"\\e658\"; }\n@mixin icon-copy { content: \"\\e659\"; }\n@mixin icon-paste { content: \"\\e65a\"; }\n@mixin icon-select-all { content: \"\\e65b\"; }\n@mixin icon-paste-text { content: \"\\e65c\"; }\n@mixin icon-paste-word { content: \"\\e65d\"; }\n@mixin icon-bold { content: \"\\e65e\"; }\n@mixin icon-italic { content: \"\\e65f\"; }\n@mixin icon-underline { content: \"\\e660\"; }\n@mixin icon-subscript { content: \"\\e661\"; }\n@mixin icon-superscript { content: \"\\e662\"; }\n@mixin icon-strike-through { content: \"\\e663\"; }\n@mixin icon-decrease-indent { content: \"\\e664\"; }\n@mixin icon-increase-indent { content: \"\\e665\"; }\n@mixin icon-block-quote { content: \"\\e666\"; }\n@mixin icon-div-container { content: \"\\e667\"; }\n@mixin icon-align-left { content: \"\\e668\"; }\n@mixin icon-center { content: \"\\e669\"; }\n@mixin icon-align-right { content: \"\\e66a\"; }\n@mixin icon-justify { content: \"\\e66b\"; }\n@mixin icon-choice { content: \"\\e66c\"; }\n@mixin icon-inline-choice { content: \"\\e66d\"; }\n@mixin icon-match { content: \"\\e66e\"; }\n@mixin icon-associate { content: \"\\e66f\"; }\n@mixin icon-media { content: \"\\e670\"; }\n@mixin icon-graphic-order { content: \"\\e671\"; }\n@mixin icon-hotspot { content: \"\\e672\"; }\n@mixin icon-graphic-gap { content: \"\\e673\"; }\n@mixin icon-graphic-associate { content: \"\\e674\"; }\n@mixin icon-select-point { content: \"\\e675\"; }\n@mixin icon-pin { content: \"\\e676\"; }\n@mixin icon-import { content: \"\\e677\"; }\n@mixin icon-export { content: \"\\e678\"; }\n@mixin icon-move-item { content: \"\\e679\"; }\n@mixin icon-meta-data { content: \"\\e67a\"; }\n@mixin icon-slider { content: \"\\e67b\"; }\n@mixin icon-summary-report { content: \"\\e67c\"; }\n@mixin icon-text-entry { content: \"\\e67d\"; }\n@mixin icon-extended-text { content: \"\\e67e\"; }\n@mixin icon-eraser { content: \"\\e67f\"; }\n@mixin icon-row { content: \"\\e680\"; }\n@mixin icon-column { content: \"\\e681\"; }\n@mixin icon-text-color { content: \"\\e682\"; }\n@mixin icon-background-color { content: \"\\e683\"; }\n@mixin icon-spell-check { content: \"\\e684\"; }\n@mixin icon-polygon { content: \"\\e685\"; }\n@mixin icon-rectangle { content: \"\\e686\"; }\n@mixin icon-gap-match { content: \"\\e687\"; }\n@mixin icon-order { content: \"\\e688\"; }\n@mixin icon-hottext { content: \"\\e689\"; }\n@mixin icon-free-form { content: \"\\e68a\"; }\n@mixin icon-step-backward { content: \"\\e68b\"; }\n@mixin icon-fast-backward { content: \"\\e68c\"; }\n@mixin icon-backward { content: \"\\e68d\"; }\n@mixin icon-play { content: \"\\e68e\"; }\n@mixin icon-pause { content: \"\\e68f\"; }\n@mixin icon-stop { content: \"\\e690\"; }\n@mixin icon-forward { content: \"\\e691\"; }\n@mixin icon-fast-forward { content: \"\\e692\"; }\n@mixin icon-step-forward { content: \"\\e693\"; }\n@mixin icon-ellipsis { content: \"\\e694\"; }\n@mixin icon-circle { content: \"\\e695\"; }\n@mixin icon-target { content: \"\\e696\"; }\n@mixin icon-guide-arrow { content: \"\\e697\"; }\n@mixin icon-range-slider-right { content: \"\\e698\"; }\n@mixin icon-range-slider-left { content: \"\\e699\"; }\n@mixin icon-radio-checked { content: \"\\e69a\"; }\n@mixin icon-checkbox-indeterminate { content: \"\\e901\"; }\n@mixin icon-checkbox { content: \"\\e69b\"; }\n@mixin icon-checkbox-crossed { content: \"\\e69c\"; }\n@mixin icon-checkbox-checked { content: \"\\e69d\"; }\n@mixin icon-result-nok { content: \"\\e69e\"; }\n@mixin icon-result-ok { content: \"\\e69f\"; }\n@mixin icon-not-evaluated { content: \"\\e6a0\"; }\n@mixin icon-filter { content: \"\\e6a1\"; }\n@mixin icon-translate { content: \"\\e6a2\"; }\n@mixin icon-eject { content: \"\\e6a3\"; }\n@mixin icon-continue { content: \"\\e6a4\"; }\n@mixin icon-radio { content: \"\\e6a5\"; }\n@mixin icon-sphere { content: \"\\e6a6\"; }\n@mixin icon-reset { content: \"\\e6a7\"; }\n@mixin icon-smaller { content: \"\\e6a8\"; }\n@mixin icon-larger { content: \"\\e6a9\"; }\n@mixin icon-clock { content: \"\\e6aa\"; }\n@mixin icon-font { content: \"\\e6ab\"; }\n@mixin icon-maths { content: \"\\e6ac\"; }\n@mixin icon-grip { content: \"\\e6ad\"; }\n@mixin icon-rubric { content: \"\\e6ae\"; }\n@mixin icon-audio { content: \"\\e6af\"; }\n@mixin icon-grip-h { content: \"\\e6b0\"; }\n@mixin icon-magicwand { content: \"\\e6b1\"; }\n@mixin icon-loop { content: \"\\ea2e\"; }\n@mixin icon-calendar { content: \"\\e953\"; }\n@mixin icon-reload { content: \"\\e984\"; }\n@mixin icon-speed { content: \"\\e9a6\"; }\n@mixin icon-volume { content: \"\\ea27\"; }\n@mixin icon-contrast { content: \"\\e9d5\"; }\n@mixin icon-headphones { content: \"\\e910\"; }\n@mixin icon-compress { content: \"\\f066\"; }\n@mixin icon-map-o { content: \"\\f278\"; }\n@mixin icon-variable { content: \"\\e908\"; }\n@mixin icon-tooltip { content: \"\\e90c\"; }\n@mixin icon-globe { content: \"\\e9c9\"; }\n@mixin icon-highlighter { content: \"\\e90f\"; }\n@mixin icon-eliminate-crossed { content: \"\\e911\"; }\n@mixin icon-play-from-here { content: \"\\e912\"; }\n","// buttons and alerts\n$success: rgb(14, 145, 75);\n$info: rgb(14, 93, 145);\n$warning: rgb(216, 174, 91);\n$danger: rgb(201, 96, 67);\n$error: rgb(186, 18, 43);\n$activeInteraction: rgb(195, 90, 19);\n\n// corporate identity\n$logoRed: rgb(186, 18, 43);\n$grey: rgb(173, 161, 148);\n$darkBlueGrey: rgb(164, 187, 197);\n$mediumBlueGrey: rgb(193, 212, 220);\n$lightBlueGrey: rgb(228, 236, 239);\n$brownRedGrey: rgb(154, 137, 123);\n$darkBrown: rgb(111, 99, 89);\n$websiteBorder: rgb(141, 148, 158);\n\n// ui elements, these should only variations of the above\n// naming convention: jQueryUi theme roller -> camelCase\n\n$textColor: #222;\n$textHighlight: white;\n\n$uiGeneralContentBg: white();\n$uiGeneralContentBorder: #ddd;\n\n$uiHeaderBg: #d4d5d7;\n\n$uiClickableDefaultBg: #f3f1ef;\n$uiClickableHoverBg: whiten($info, 0.2);\n//$uiClickableActiveBg: $uiHeaderBg;\n$uiClickableActiveBg: whiten($websiteBorder, 0.2);\n//$uiClickableActiveBg: #aaa;\n\n$uiSelectableSelectedBg: whiten($info, 0.2);\n$uiSelectableSelectedHoverBg: whiten($info, 0.1);\n$uiSelectableHoverBg: whiten($info, 0.9);\n\n$uiOverlay: $lightBlueGrey;\n\n// new layout. Implemented now only for review panel\n$uiReviewPanelBg: #f2f2f2;\n$uiReviewPanelTextDisabled: hsl(0, 0%, 45%);\n$uiReviewPanelTextDefault: hsl(0, 0%, 12%);\n$uiReviewPanelBgDefault: $uiGeneralContentBg;\n$uiReviewPanelPrimaryHighlight: hsl(208, 100%, 32%);\n$uiReviewPanelBgInverted: $uiReviewPanelTextDefault;\n$uiReviewPanelTextInverted: $uiGeneralContentBg;\n\n// sidebars etc.\n$canvas: mix(#fff, $grey, 85%);\n\n// colors taken from feedback.scss\n$successBgColor: whiten($success, 0.8);\n$successBorderColor: whiten($success, 0.1);\n\n$infoBgColor: whiten($info, 0.8);\n$infoBorderColor: whiten($info, 0.1);\n\n$warningBgColor: whiten($warning, 0.8);\n$warningBorderColor: whiten($warning, 0.1);\n\n$dangerBgColor: whiten($danger, 0.8);\n$dangerBorderColor: whiten($danger, 0.1);\n\n$errorBgColor: whiten($error, 0.8);\n$errorBorderColor: whiten($error, 0.1);\n\n$darkBar: rgb(51, 51, 51);\n$darkBarTxt: rgb(230, 230, 230);\n$darkBarIcon: rgb(220, 220, 220);\n\n$actionLinkColor: #276d9b;\n$actionLinkHoverColor: #4f83a7;\n\n$colorWheel-01: #c3ba13;\n$colorWheel-02: #84a610;\n$colorWheel-03: #2b8e0e;\n$colorWheel-04: #0f9787;\n$colorWheel-05: #0e5d91;\n$colorWheel-06: #0d2689;\n$colorWheel-07: #400d83;\n$colorWheel-08: #960e7d;\n$colorWheel-09: #ba122b;\n$colorWheel-10: #c34713;\n$colorWheel-11: #c36f13;\n$colorWheel-12: #c39413;\n"]}
@@ -57,7 +57,7 @@ import tpl from 'ui/mediaEditor/tpl/editor';
57
57
  * @type mediaEditorConfig
58
58
  * @private
59
59
  */
60
- var defaultConfig = {
60
+ const defaultConfig = {
61
61
  mediaDimension: {
62
62
  active: false
63
63
  }
@@ -76,15 +76,15 @@ export default function mediaEditorFactory($container, media, config) {
76
76
  * Active Plugins
77
77
  * @type {Array}
78
78
  */
79
- var plugins = [];
79
+ const plugins = [];
80
80
 
81
81
  /**
82
82
  * Current component
83
83
  */
84
- var mediaEditorComponent = component({}, defaultConfig);
84
+ const mediaEditorComponent = component({}, defaultConfig);
85
85
  mediaEditorComponent
86
86
  .setTemplate(tpl)
87
- .on('init', function() {
87
+ .on('init', function () {
88
88
  if (!media || !media.$node || !media.$node.length) {
89
89
  throw new Error('mediaEditorComponent requires media.$node');
90
90
  }
@@ -93,38 +93,37 @@ export default function mediaEditorFactory($container, media, config) {
93
93
  }
94
94
  this.render($container);
95
95
  })
96
- .on('render', function() {
97
- var self = this;
98
- var $dimensionTools = $('.media-dimension', this.getTemplate());
99
- var plugin;
96
+ .on('render', function () {
97
+ const $dimensionTools = $('.media-dimension', this.getTemplate());
98
+ let plugin;
100
99
  if (this.getConfig().mediaDimension.active) {
101
- plugin = mediaDimensionComponent($dimensionTools, media, { responsive: media.responsive }).on(
102
- 'change',
103
- function(conf) {
104
- media.responsive = conf.responsive;
105
- if (conf.responsive) {
106
- // percent
107
- media.width = conf.sizeProps['%'].current.width;
108
- media.height = null;
109
- } else {
110
- media.width = conf.sizeProps.px.current.width;
111
- media.height = conf.sizeProps.px.current.height;
112
- }
113
-
114
- self.trigger('change', media);
100
+ plugin = mediaDimensionComponent($dimensionTools, media, {
101
+ responsive: media.responsive,
102
+ showResponsiveToggle: this.getConfig().mediaDimension.showResponsiveToggle
103
+ }).on('change', conf => {
104
+ media.responsive = conf.responsive;
105
+ if (conf.responsive) {
106
+ // percent
107
+ media.width = conf.sizeProps['%'].current.width;
108
+ media.height = null;
109
+ } else {
110
+ media.width = conf.sizeProps.px.current.width;
111
+ media.height = conf.sizeProps.px.current.height;
115
112
  }
116
- );
113
+
114
+ this.trigger('change', media);
115
+ });
117
116
 
118
117
  plugins.push(plugin);
119
118
  }
120
119
  })
121
- .on('destroy', function() {
122
- _.forEach(plugins, function(plugin) {
120
+ .on('destroy', function () {
121
+ _.forEach(plugins, function (plugin) {
123
122
  plugin.destroy();
124
123
  });
125
124
  });
126
125
 
127
- _.defer(function() {
126
+ _.defer(function () {
128
127
  mediaEditorComponent.init(config);
129
128
  });
130
129
 
@@ -76,7 +76,7 @@ import 'ui/mediaEditor/plugins/mediaDimension/style.css';
76
76
  * }}
77
77
  * @private
78
78
  */
79
- var defaultConfig = {
79
+ const defaultConfig = {
80
80
  showResponsiveToggle: true,
81
81
  showSync: true,
82
82
  showReset: true,
@@ -115,22 +115,22 @@ var defaultConfig = {
115
115
 
116
116
  /**
117
117
  * Creates mediaDimension component
118
- * @param $container
119
- * @param media
120
- * @param config
118
+ * @param {jQueryElement} $container
119
+ * @param {Object} media
120
+ * @param {Object} config
121
121
  * @fires "changed" - on State changed
122
- * return {component|*}
122
+ * @returns {component|*} mediaDimensionComponent
123
123
  */
124
124
  export default function mediaDimensionFactory($container, media, config) {
125
125
  /**
126
126
  * Collections of the jquery elements grouped by type
127
127
  */
128
- var $blocks, $slider, $fields;
128
+ let $blocks, $slider, $fields;
129
129
 
130
130
  /**
131
131
  * Template of the dimension controller
132
132
  */
133
- var $template;
133
+ let $template;
134
134
 
135
135
  /**
136
136
  * Size properties of the media control panel
@@ -149,13 +149,15 @@ export default function mediaDimensionFactory($container, media, config) {
149
149
  * @type {mediaSizeProps}
150
150
  * @private
151
151
  */
152
- var initialConfig;
152
+ let initialConfig;
153
153
 
154
154
  /**
155
155
  * Calculate propSizes to have correct sizes for the shown image
156
+ * @param {Object} conf
157
+ * @returns {Object}
156
158
  */
157
- var calculateCurrentSizes = function calculateCurrentSizes(conf) {
158
- var mediaContainerWidth = helper.getMediaContainerWidth(media);
159
+ const calculateCurrentSizes = function calculateCurrentSizes(conf) {
160
+ const mediaContainerWidth = helper.getMediaContainerWidth(media);
159
161
  return helper.applyDimensions(conf, {
160
162
  width:
161
163
  mediaContainerWidth < conf.sizeProps.px.natural.width
@@ -165,20 +167,34 @@ export default function mediaDimensionFactory($container, media, config) {
165
167
  });
166
168
  };
167
169
 
170
+ /**
171
+ * Return oroginal size
172
+ * @returns {Object}
173
+ */
174
+ function getOriginalSize() {
175
+ // for images naturalWidth, for video videoWidth, for youtube iframe width
176
+ return {
177
+ width: media.$node[0].naturalWidth || media.$node[0].videoWidth || media.$node[0].width,
178
+ height: media.$node[0].naturalHeight || media.$node[0].videoHeight || media.$node[0].height
179
+ };
180
+ }
181
+
168
182
  /**
169
183
  * Current component
170
184
  */
171
- var mediaDimensionComponent = component(
185
+ const mediaDimensionComponent = component(
172
186
  {
173
187
  /**
174
188
  * Reset the component to the initial state
189
+ * @returns {component} this
175
190
  */
176
191
  reset: function reset() {
177
- var syncDim = initialConfig.syncDimensions;
192
+ const syncDim = initialConfig.syncDimensions;
178
193
  if (this.is('rendered')) {
179
- // revert the sizes to the original of the image
180
- initialConfig.sizeProps.px.current.width = media.$node[0].naturalWidth;
181
- initialConfig.sizeProps.px.current.height = media.$node[0].naturalHeight;
194
+ // revert the sizes to the original
195
+ const originalSize = getOriginalSize();
196
+ initialConfig.sizeProps.px.current.width = originalSize.width;
197
+ initialConfig.sizeProps.px.current.height = originalSize.height;
182
198
  initialConfig.sizeProps.ratio.current = initialConfig.sizeProps.ratio.natural;
183
199
 
184
200
  // reset needs to restore everything
@@ -215,12 +231,12 @@ export default function mediaDimensionFactory($container, media, config) {
215
231
 
216
232
  /**
217
233
  * Check that input in progress and we don't need to change anything
218
- * @param val
234
+ * @param {String|number} val
219
235
  * @returns {RegExpMatchArray | null}
220
236
  */
221
- var isInsignificantEnd = function isInsignificantEnd(val) {
237
+ const isInsignificantEnd = function isInsignificantEnd(val) {
222
238
  if (typeof val !== 'string') {
223
- val = val + '';
239
+ val = `${val}`;
224
240
  }
225
241
  return val.match(/\.[0]*$/);
226
242
  };
@@ -228,12 +244,12 @@ export default function mediaDimensionFactory($container, media, config) {
228
244
  /**
229
245
  * Blocks are the two different parts of the form (either width|height or size)
230
246
  *
231
- * @param $elt
247
+ * @param {jQueryElement} $elt
232
248
  * @returns {{}}
233
249
  * @private
234
250
  */
235
- var initBlocks = function initBlocks($elt) {
236
- var _blocks = {},
251
+ const initBlocks = function initBlocks($elt) {
252
+ const _blocks = {},
237
253
  $responsiveToggleField = $elt.find('.media-mode-switch'),
238
254
  checkMode = function checkMode() {
239
255
  if ($responsiveToggleField.is(':checked')) {
@@ -264,13 +280,13 @@ export default function mediaDimensionFactory($container, media, config) {
264
280
  $elt.addClass('media-sizer-responsivetoggle-off');
265
281
  }
266
282
 
267
- _(['px', '%']).forEach(function(unit) {
268
- _blocks[unit] = $elt.find('.media-sizer-' + (unit === 'px' ? 'pixel' : 'percent'));
283
+ _(['px', '%']).forEach(function (unit) {
284
+ _blocks[unit] = $elt.find(`.media-sizer-${unit === 'px' ? 'pixel' : 'percent'}`);
269
285
  _blocks[unit].prop('unit', unit);
270
286
  _blocks[unit].find('input').data('unit', unit);
271
287
  });
272
288
 
273
- $responsiveToggleField.on('click', function() {
289
+ $responsiveToggleField.on('click', function () {
274
290
  checkMode();
275
291
  });
276
292
 
@@ -285,12 +301,12 @@ export default function mediaDimensionFactory($container, media, config) {
285
301
  /**
286
302
  * Toggle width/height synchronization
287
303
  *
288
- * @param $elt
304
+ * @param {jQueryElement} $elt
289
305
  * @returns {*}
290
306
  * @private
291
307
  */
292
- var initSyncBtn = function initSyncBtn($elt) {
293
- var $mediaSizer = $elt.find('.media-sizer'),
308
+ const initSyncBtn = function initSyncBtn($elt) {
309
+ const $mediaSizer = $elt.find('.media-sizer'),
294
310
  $btn = $elt.find('.media-sizer-sync');
295
311
 
296
312
  if (!initialConfig.showSync) {
@@ -299,8 +315,8 @@ export default function mediaDimensionFactory($container, media, config) {
299
315
  }
300
316
  // this stays intact even if hidden in case it will be
301
317
  // displayed from somewhere else
302
- $btn.on('click', function() {
303
- var $sizerEl = $(this).parents('.media-sizer');
318
+ $btn.on('click', function () {
319
+ const $sizerEl = $(this).parents('.media-sizer');
304
320
  $sizerEl.toggleClass('media-sizer-synced');
305
321
  initialConfig.syncDimensions = $sizerEl.hasClass('media-sizer-synced');
306
322
  });
@@ -310,12 +326,12 @@ export default function mediaDimensionFactory($container, media, config) {
310
326
  /**
311
327
  * Button to reset the size to its original values
312
328
  *
313
- * @param $elt
329
+ * @param {jQueryElement} $elt
314
330
  * @returns {*}
315
331
  * @private
316
332
  */
317
- var initResetBtn = function initResetBtn($elt) {
318
- var $btn = $elt.find('.media-sizer-reset');
333
+ const initResetBtn = function initResetBtn($elt) {
334
+ const $btn = $elt.find('.media-sizer-reset');
319
335
 
320
336
  if (!initialConfig.showReset) {
321
337
  $elt.find('.media-sizer').addClass('media-sizer-reset-off');
@@ -323,7 +339,7 @@ export default function mediaDimensionFactory($container, media, config) {
323
339
 
324
340
  // this stays intact even if hidden in case it will be
325
341
  // displayed from somewhere else
326
- $btn.on('click', function(e) {
342
+ $btn.on('click', function (e) {
327
343
  e.preventDefault();
328
344
  mediaDimensionComponent.reset();
329
345
  return false;
@@ -338,17 +354,17 @@ export default function mediaDimensionFactory($container, media, config) {
338
354
  * @returns {{}}
339
355
  * @private
340
356
  */
341
- var initFields = function initFields() {
342
- var dimensions = ['width', 'height'],
343
- field,
344
- _fields = {};
357
+ const initFields = function initFields() {
358
+ const dimensions = ['width', 'height'];
359
+ let field;
360
+ const _fields = {};
345
361
 
346
- _($blocks).forOwn(function($block, unit) {
362
+ _($blocks).forOwn(function ($block, unit) {
347
363
  _fields[unit] = {};
348
364
 
349
- $blocks[unit].find('input').each(function() {
350
- _(dimensions).forEach(function(dim) {
351
- field = $blocks[unit].find('[name="' + dim + '"]');
365
+ $blocks[unit].find('input').each(function () {
366
+ _(dimensions).forEach(function (dim) {
367
+ field = $blocks[unit].find(`[name="${dim}"]`);
352
368
  // there is no 'height' field for % - $('<input>') is a dummy to avoid checking if the field exists all the time
353
369
  _fields[unit][dim] = field.length ? field : $('<input>');
354
370
  _fields[unit][dim].prop({
@@ -357,11 +373,11 @@ export default function mediaDimensionFactory($container, media, config) {
357
373
  });
358
374
  _fields[unit][dim].val(initialConfig.sizeProps[unit].current[dim]);
359
375
 
360
- _fields[unit][dim].on('keydown', function(e) {
361
- var $field = $(this),
376
+ _fields[unit][dim].on('keydown', function (e) {
377
+ const $field = $(this),
362
378
  c = e.keyCode,
363
- specChars = (function() {
364
- var chars = [8, 37, 39, 46];
379
+ specChars = (function () {
380
+ const chars = [8, 37, 39, 46];
365
381
  if ($field.val().indexOf('.') === -1) {
366
382
  chars.push(190);
367
383
  chars.push(110);
@@ -376,10 +392,10 @@ export default function mediaDimensionFactory($container, media, config) {
376
392
  return allowed;
377
393
  });
378
394
 
379
- _fields[unit][dim].on('keyup blur sliderchange', function() {
380
- var $field = $(this),
381
- value = $field.val().replace(/,/g, '.'),
382
- newDimensions;
395
+ _fields[unit][dim].on('keyup blur sliderchange', function () {
396
+ const $field = $(this);
397
+ let value = $field.val().replace(/,/g, '.');
398
+ let newDimensions;
383
399
 
384
400
  $field.val(value);
385
401
  if (isInsignificantEnd(value)) {
@@ -389,10 +405,10 @@ export default function mediaDimensionFactory($container, media, config) {
389
405
 
390
406
  if (value > $field.data('max')) {
391
407
  $field.val($field.data('max'));
392
- value = $field.data('max') + '';
408
+ value = `${$field.data('max')}`;
393
409
  } else if (value < $field.data('min')) {
394
410
  $field.val($field.data('min'));
395
- value = $field.data('min') + '';
411
+ value = `${$field.data('min')}`;
396
412
  }
397
413
 
398
414
  if ($field.prop('unit') === '%') {
@@ -419,11 +435,12 @@ export default function mediaDimensionFactory($container, media, config) {
419
435
  /**
420
436
  * Initialize the two sliders, one based on pixels the other on percentage
421
437
  *
438
+ * @param {jQueryElement} $elt
422
439
  * @returns {{}}
423
440
  * @private
424
441
  */
425
- var initSlider = function initSlider($elt) {
426
- var slider;
442
+ const initSlider = function initSlider($elt) {
443
+ let slider;
427
444
 
428
445
  slider = $elt.find('.media-sizer-slider');
429
446
  slider.prop('unit', '%');
@@ -435,9 +452,9 @@ export default function mediaDimensionFactory($container, media, config) {
435
452
  max: initialConfig.sizeProps.slider.max
436
453
  }
437
454
  })
438
- .on('slide', function() {
455
+ .on('slide', function () {
439
456
  // to avoid .00
440
- var percent = parseFloat($(this).val() + '');
457
+ const percent = parseFloat(`${$(this).val()}`);
441
458
  helper.applyDimensions(initialConfig, {
442
459
  percent: percent,
443
460
  maxWidth: helper.getMediaContainerWidth(media)
@@ -449,16 +466,19 @@ export default function mediaDimensionFactory($container, media, config) {
449
466
  };
450
467
 
451
468
  mediaDimensionComponent
452
- .on('init', function() {
453
- var mediaProps = {
469
+ .on('init', function () {
470
+ const originalSize = getOriginalSize();
471
+ const naturalWidth = originalSize.width;
472
+ const naturalHeight = originalSize.height;
473
+ const mediaProps = {
454
474
  px: {
455
475
  current: {
456
476
  width: media.width,
457
477
  height: media.height
458
478
  },
459
479
  natural: {
460
- width: media.$node[0].naturalWidth ? media.$node[0].naturalWidth : media.width,
461
- height: media.$node[0].naturalHeight ? media.$node[0].naturalHeight : media.height
480
+ width: naturalWidth ? naturalWidth : media.width,
481
+ height: naturalHeight ? naturalHeight : media.height
462
482
  }
463
483
  },
464
484
  '%': {
@@ -480,8 +500,8 @@ export default function mediaDimensionFactory($container, media, config) {
480
500
  initialConfig.sizeProps.currentUtil = initialConfig.responsive ? '%' : 'px';
481
501
  this.render($container);
482
502
  })
483
- .on('render', function() {
484
- var $mediaSizer;
503
+ .on('render', function () {
504
+ let $mediaSizer;
485
505
 
486
506
  initialConfig = this.getConfig();
487
507
  $template = $(
@@ -529,11 +549,11 @@ export default function mediaDimensionFactory($container, media, config) {
529
549
 
530
550
  mediaDimensionComponent.update();
531
551
  })
532
- .on('destroy', function() {
552
+ .on('destroy', function () {
533
553
  $template.remove();
534
554
  });
535
555
 
536
- _.defer(function() {
556
+ _.defer(function () {
537
557
  mediaDimensionComponent.init(config);
538
558
  });
539
559