1+ /*eslint-disable */
2+ /* jscs:disable */
3+ function _inheritsLoose ( subClass , superClass ) { subClass . prototype = Object . create ( superClass . prototype ) ; subClass . prototype . constructor = subClass ; _setPrototypeOf ( subClass , superClass ) ; }
4+ function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf ? Object . setPrototypeOf . bind ( ) : function _setPrototypeOf ( o , p ) { o . __proto__ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
5+ define ( [ "Magento_PageBuilder/js/events" , "Magento_PageBuilder/js/content-type-menu/hide-show-option" , "Magento_PageBuilder/js/uploader" , "Magento_PageBuilder/js/content-type/preview" ] , function ( _events , _hideShowOption , _uploader , _preview ) {
6+ /**
7+ * Copyright © Magento, Inc. All rights reserved.
8+ * See COPYING.txt for license details.
9+ */
10+ /**
11+ * @api
12+ */
13+ var Preview = /*#__PURE__*/ function ( _preview2 ) {
14+ "use strict" ;
15+
16+ function Preview ( ) {
17+ return _preview2 . apply ( this , arguments ) || this ;
18+ }
19+ _inheritsLoose ( Preview , _preview2 ) ;
20+ var _proto = Preview . prototype ;
21+ /**
22+ * Return an array of options
23+ *
24+ * @returns {OptionsInterface }
25+ */
26+ _proto . retrieveOptions = function retrieveOptions ( ) {
27+ var options = _preview2 . prototype . retrieveOptions . call ( this ) ;
28+ options . hideShow = new _hideShowOption ( {
29+ preview : this ,
30+ icon : _hideShowOption . showIcon ,
31+ title : _hideShowOption . showText ,
32+ action : this . onOptionVisibilityToggle ,
33+ classes : [ "hide-show-content-type" ] ,
34+ sort : 40
35+ } ) ;
36+ return options ;
37+ }
38+
39+ /**
40+ * Get registry callback reference to uploader UI component
41+ *
42+ * @returns {Uploader }
43+ */ ;
44+ _proto . getUploader = function getUploader ( ) {
45+ var initialImageValue = this . contentType . dataStore . get ( this . config . additional_data . uploaderConfig . dataScope , "" ) ;
46+ return new _uploader ( "imageuploader_" + this . contentType . id , this . config . additional_data . uploaderConfig , this . contentType . id , this . contentType . dataStore , initialImageValue ) ;
47+ }
48+
49+ /**
50+ * Get viewport image data
51+ * CLOUDINARY MODIFICATION: Removed rand parameter to prevent URL encoding issues
52+ */ ;
53+ _proto . getViewportImageData = function getViewportImageData ( ) {
54+ var desktopImageData = this . data . desktop_image ;
55+ var mobileImageData = this . data . mobile_image ;
56+ var result = this . viewport ( ) === "mobile" && typeof mobileImageData !== "undefined" ? mobileImageData : desktopImageData ;
57+ // CLOUDINARY: Commented out rand parameter addition to prevent double-encoding issues
58+ // if (result && result.attributes() && result.attributes().src.length > 0 && result.attributes().src.indexOf("?rand") === -1) {
59+ // result.attributes().src += "?rand=" + Date.now();
60+ // }
61+ return result ;
62+ }
63+
64+ /**
65+ * @inheritDoc
66+ */ ;
67+ _proto . bindEvents = function bindEvents ( ) {
68+ var _this = this ;
69+ _preview2 . prototype . bindEvents . call ( this ) ;
70+ _events . on ( "image:mountAfter" , function ( args ) {
71+ if ( args . id === _this . contentType . id ) {
72+ _this . isSnapshot . subscribe ( function ( value ) {
73+ _this . changeUploaderControlsVisibility ( ) ;
74+ } ) ;
75+ _this . changeUploaderControlsVisibility ( ) ;
76+ }
77+ } ) ;
78+ _events . on ( this . config . name + ":" + this . contentType . id + ":updateAfter" , function ( ) {
79+ var files = _this . contentType . dataStore . get ( _this . config . additional_data . uploaderConfig . dataScope ) ;
80+ var imageObject = files ? files [ 0 ] : { } ;
81+ _events . trigger ( "image:" + _this . contentType . id + ":assignAfter" , imageObject ) ;
82+ } ) ;
83+ }
84+
85+ /**
86+ * Change uploader controls visibility
87+ */ ;
88+ _proto . changeUploaderControlsVisibility = function changeUploaderControlsVisibility ( ) {
89+ var _this2 = this ;
90+ this . getUploader ( ) . getUiComponent ( ) ( function ( uploader ) {
91+ uploader . visibleControls = ! _this2 . isSnapshot ( ) ;
92+ } ) ;
93+ } ;
94+ return Preview ;
95+ } ( _preview ) ;
96+ return Preview ;
97+ } ) ;
0 commit comments