Last active
March 5, 2019 16:10
-
-
Save seangwright/8767e2d388eaa58e9a255601cea62960 to your computer and use it in GitHub Desktop.
ken120-mvc-vuejs-media-selection-editor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
let appRoot = undefined; | |
window.kentico.pageBuilder.registerInlineEditor("media-selection-editor", { | |
init: function(options) { | |
const editor = options.editor; | |
appRoot = new Vue({ | |
el: `#${editor.attributes["data-id"].value}`, | |
data: { | |
hostUrl: editor.attributes["data-host-url"].value, | |
selectedMediaUrl: editor.attributes["data-current-media"].value, | |
propertyName: options.propertyName | |
}, | |
methods: { | |
onDispatch: function (media) { | |
const widgetEvent = new CustomEvent("updateProperty", { | |
detail: { | |
name: this.propertyName, | |
value: media.fileGUID, | |
refreshMarkup: false | |
} | |
}); | |
editor.dispatchEvent(widgetEvent); | |
this.selectedMediaUrl = media.permanentUrl; | |
} | |
} | |
}); | |
}, | |
destroy: function() { | |
if (appRoot) { | |
appRoot.$destroy(); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment