diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-23 12:36:28 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-23 11:27:57 +0000 |
commit | 1c9da7439d1d4664a91c0dd43162b47a2203b02c (patch) | |
tree | db7d264165697db4f58481a39b4fa82d5b5ebcc1 /examples/demos/photoviewer/PhotoViewerCore | |
parent | 25b032a522a993808f9fc17bc767eb54ae3813a2 (diff) |
Port photoviewer example to use a ES module for the script code
... instead of the proprietary .pragma library syntax.
Change-Id: Ic5add04d6446a3c221eb3be6ec5a2240f0f80691
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/demos/photoviewer/PhotoViewerCore')
-rw-r--r-- | examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml | 2 | ||||
-rw-r--r-- | examples/demos/photoviewer/PhotoViewerCore/script/script.mjs (renamed from examples/demos/photoviewer/PhotoViewerCore/script/script.js) | 10 |
2 files changed, 5 insertions, 7 deletions
diff --git a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml index a4196dbdc..b3652701e 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml +++ b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -49,7 +49,7 @@ ****************************************************************************/ import QtQuick 2.0 -import "script/script.js" as Script +import "script/script.mjs" as Script Package { Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } diff --git a/examples/demos/photoviewer/PhotoViewerCore/script/script.js b/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs index 0b3cae5ff..1eb7cac7e 100644 --- a/examples/demos/photoviewer/PhotoViewerCore/script/script.js +++ b/examples/demos/photoviewer/PhotoViewerCore/script/script.mjs @@ -48,22 +48,20 @@ ** ****************************************************************************/ -.pragma library - -function getWidth(string) { +export function getWidth(string) { return (string.match(/width=\"([0-9]+)\"/))[1] } -function getHeight(string) { +export function getHeight(string) { return (string.match(/height=\"([0-9]+)\"/))[1] } -function getImagePath(string) { +export function getImagePath(string) { var pattern = /src=\"http:\/\/(\S+)\"/ return (string.match(pattern))[1] } -function calculateScale(width, height, cellSize) { +export function calculateScale(width, height, cellSize) { var widthScale = (cellSize * 1.0) / width var heightScale = (cellSize * 1.0) / height var scale = 0 |