From 8f9c58ad240a7000f798c7005193f61536f2de75 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Tue, 14 Apr 2020 14:12:58 -0400 Subject: [PATCH] Add check to see whether transformation is already applied --- .../css/cloudinary.css | 318 +++++++++++++++- .../js/block-editor.js | 353 +++++++++++++++++- .../js/cloudinary.js | 183 ++++++++- .../php/media/class-video.php | 10 +- 4 files changed, 857 insertions(+), 7 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css index 7df57b89b..263568e5f 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css @@ -1 +1,317 @@ -@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.eot);src:url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.ttf) format("truetype"),url(../css/fonts/cloudinary.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.warning:before{content:"\e902"}.dashicons-cloudinary.warning{color:#fd9d2c}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file +@font-face { + font-family: 'cloudinary'; + src: url(../css/fonts/cloudinary.eot); + src: url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"), url(../css/fonts/cloudinary.ttf) format("truetype"), url(../css/fonts/cloudinary.woff) format("woff"), url(../css/cloudinary.svg#cloudinary) format("svg"); + font-weight: normal; + font-style: normal; } + +.dashicons-cloudinary { + /* use !important to prevent issues with browser extensions that change fonts */ + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } + .dashicons-cloudinary:before { + font-family: 'cloudinary' !important; + content: '\e900'; } + .dashicons-cloudinary.success { + color: #558b2f; } + .dashicons-cloudinary.error { + color: #dd2c00; } + .dashicons-cloudinary.error:before { + content: '\e901'; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + .dashicons-cloudinary.warning:before { + content: '\e902'; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + +.column-cld_status { + width: 5.5em; } + .column-cld_status .dashicons-cloudinary { + display: inline-block; } + .column-cld_status .dashicons-cloudinary:before { + font-size: 1.8rem; } + +.form-field .error-notice, .form-table .error-notice { + display: none; + color: #dd2c00; } + +.form-field input.cld-field:invalid, .form-table input.cld-field:invalid { + border-color: #dd2c00; } + .form-field input.cld-field:invalid + .error-notice, .form-table input.cld-field:invalid + .error-notice { + display: inline-block; } + +.cloudinary-welcome { + background-image: url(../css/logo.svg); + background-repeat: no-repeat; + background-size: 153px; + background-position: top 12px right 20px; } + +.settings-image { + max-width: 100%; + padding-top: 5px; } + +.settings-tabs > li { + display: inline-block; } + .settings-tabs > li a { + padding: .6em; } + .settings-tabs > li a.active { + background-color: #ffffff; } + +.settings-tab-section { + padding: 20px 0 0 0; + max-width: 1030px; + position: relative; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard { + display: flex; + align-items: flex-start; + align-content: flex-start; + margin-top: 40px; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description { + width: 55%; + margin: 0 auto 0 0; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content { + width: 35%; + margin: 0 auto; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons { + color: #9EA3A8; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-card { + margin-top: 0; } + .settings-tab-section-fields .field-heading th { + display: block; + width: auto; + color: #23282d; + font-size: 1.1em; + margin: 1em 0; } + .settings-tab-section-fields .field-heading td { + display: none; + visibility: hidden; } + .settings-tab-section-fields .regular-textarea { + width: 100%; + height: 60px; } + .settings-tab-section-fields .dashicons { + text-decoration: none; + vertical-align: middle; } + .settings-tab-section-fields a .dashicons { + color: #5F5F5F; } + .settings-tab-section-fields-dashboard-error { + font-size: 1.2em; + color: #5F5F5F; } + .settings-tab-section-fields-dashboard-error .dashicons { + color: #AC0000; } + .settings-tab-section-fields-dashboard-error .button { + font-size: 1.1em; + height: 40px; + line-height: 40px; + padding-right: 40px; + padding-left: 40px; } + .settings-tab-section-fields-dashboard-success { + font-size: 1.2em; + color: #23282d; } + .settings-tab-section-fields-dashboard-success.expanded { + padding-top: 40px; } + .settings-tab-section-fields-dashboard-success .dashicons { + color: #4FB651; } + .settings-tab-section-fields-dashboard-success .button { + font-size: 1.1em; + height: 40px; + line-height: 40px; + padding-right: 40px; + padding-left: 40px; } + .settings-tab-section-fields-dashboard-success .description { + color: #5F5F5F; + font-weight: normal; + margin-top: 12px; } + .settings-tab-section-card { + box-sizing: border-box; + border: 1px solid #E5E5E5; + background-color: #FFFFFF; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.07); + padding: 20px 23px; + margin-top: 12px; } + .settings-tab-section-card .dashicons { + font-size: 1.4em; } + .settings-tab-section-card h2 { + font-size: 1.8em; + font-weight: normal; + margin-top: 0; } + .settings-tab-section-card.pull-right { + width: 450px; + padding: 12px; + float: right; + position: relative; + z-index: 10; } + .settings-tab-section-card.pull-right img.settings-image { + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5); + border: 1px solid #979797; + margin-top: 12px; } + .settings-tab-section-card.pull-right h4, .settings-tab-section-card.pull-right h3 { + margin-top: 0; } + .settings-tab-section .field-row-cloudinary_url, .settings-tab-section .field-row-signup { + display: block; } + .settings-tab-section .field-row-cloudinary_url td, .settings-tab-section .field-row-cloudinary_url th, .settings-tab-section .field-row-signup td, .settings-tab-section .field-row-signup th { + display: block; + width: auto; + padding: 10px 0 0; } + .settings-tab-section .field-row-cloudinary_url td .sign-up, .settings-tab-section .field-row-cloudinary_url th .sign-up, .settings-tab-section .field-row-signup td .sign-up, .settings-tab-section .field-row-signup th .sign-up { + vertical-align: baseline; } + .settings-tab-section.connect .form-table { + display: inline-block; + width: auto; + max-width: 580px; } + +.settings-valid { + color: #558b2f; + font-size: 30px; } + .settings-valid-field { + border-color: #558b2f !important; } + +.settings-invalid-field { + border-color: #dd2c00 !important; } + +.sync .spinner { + display: inline-block; + visibility: visible; + float: none; + margin: 0 5px 0 0; } + +.sync-media { + display: none; } + .sync-media-progress { + display: none; } + .sync-media-progress-outer { + height: 20px; + margin: 20px 0 10px; + width: 500px; + background-color: #e5e5e5; + position: relative; } + .sync-media-progress-outer .progress-bar { + width: 0; + height: 20px; + background-color: #558b2f; + transition: width 250ms; } + .sync-media-progress-notice { + color: #dd2c00; } + .sync-media-resource { + width: 100px; + display: inline-block; } + .sync-media-error { + color: #dd2c00; } + +.sync-count { + font-weight: bold; } + +.sync-details { + margin-top: 10px; } + +.sync .button.stop-sync, .sync .button.start-sync { + display: none; + padding: 0 16px; } + .sync .button.stop-sync .dashicons, .sync .button.start-sync .dashicons { + line-height: 2.2em; } + +.sync .progress-text { + padding: 12px 4px 12px 12px; + display: inline-block; + font-weight: bold; } + +.sync .completed { + max-width: 300px; + display: none; } + +.cloudinary-widget { + height: 100%; } + .cloudinary-widget-wrapper { + height: 100%; + overflow: hidden; + background-image: url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbCiAgICAgIEBrZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhGRjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OEZGOyB9CiAgICAgIH0KCiAgICAgIEBrZXlmcmFtZXMgZGFzaCB7CiAgICAgICAwJSB7IHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgIDUwJSB7CiAgICAgICAgICBzdHJva2UtZGFzaG9mZnNldDogMDsKICAgICAgIH0KICAgICAgIDEwMCUgeyAgIHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgfQogICAgICBALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhmZjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OGZmOyB9CiAgICAgIH0KCiAgICAgIEAtd2Via2l0LWtleWZyYW1lcyBkYXNoIHsKICAgICAgIDAlIHsgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsgfQogICAgICAgNTAlIHsKICAgICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgfQogICAgICAgMTAwJSB7ICAgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsKICAgICAgIH0KICAgICAgfQogICAgICAucGF0aCB7CiAgICAgICAgc3Ryb2tlLWRhc2hhcnJheTogMjgwOwogICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgIHRyYW5zZm9ybS1vcmlnaW46IGNlbnRlcjsKICAgICAgICAtd2Via2l0LWFuaW1hdGlvbjoKICAgICAgICAgIGRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsIGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZTsKICAgICAgICBhbmltYXRpb246CiAgICAgICAgICBkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLCBjb2xvcnMgOHMgZWFzZS1pbi1vdXQgaW5maW5pdGU7CiAgICAgIH0KICAgIF1dPjwvc3R5bGU+CiAgPHBhdGggY2xhc3M9InBhdGgiIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K"); + background-repeat: no-repeat; + background-position: center; + background-size: 150px; } + +.attachment-info .edit-attachment { + display: none; } + +.attachment-actions .button.edit-attachment { + display: none; } + +.global-transformations-preview { + position: relative; + max-width: 600px; } + +.global-transformations-spinner { + display: none; } + +.global-transformations-button.button-primary { + display: none; + position: absolute; + z-index: 100; } + +.global-transformations-url { + margin-bottom: 5px; + margin-top: 5px; } + .global-transformations-url-transformation { + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + color: #51A3FF; } + .global-transformations-url-file { + color: #f2d864; } + .global-transformations-url-link { + display: block; + padding: 16px; + background-color: #262c35; + text-decoration: none; + color: #fff; + border-radius: 6px; + overflow: hidden; + text-overflow: ellipsis; } + .global-transformations-url-link:hover { + color: #888888; + text-decoration: underline; } + +.cld-tax-order-list-item { + border: 1px solid #efefef; + padding: 4px; + margin: 0 0 -1px; + background-color: #ffffff; } + .cld-tax-order-list-item.no-items { + color: #888; + text-align: center; + display: none; } + .cld-tax-order-list-item.no-items:last-child { + display: block; } + .cld-tax-order-list-item.ui-sortable-helper { + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); } + .cld-tax-order-list-item-placeholder { + background-color: #efefef; + height: 45px; + margin: 0; } + .cld-tax-order-list-item-handle { + cursor: grab; + margin-right: 4px; + color: #999; } + +.cld-tax-order-list-type { + width: 45%; + display: inline-block; + margin-right: 8px; } + .cld-tax-order-list-type input { + margin-right: 4px !important; } + +.cloudinary-media-library { + position: relative; + margin-left: -20px; } + @media screen and (max-width: 782px) { + .cloudinary-media-library { + margin-left: -10px; } } + diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js index 38488de8c..f3bce37b8 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js @@ -1 +1,352 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e,r){var n=r(5);t.exports=function(t){for(var e=1;e=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,r=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,e.percent<100?(this.barSyncCount.innerText=e.total,this.progressCount.innerText=e.done,this.progress.style.display=this.show):(this.completed.style.display=this.show,this.progress.style.display=this.hide)},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var r=a;a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var o=i(1),l=i.n(o);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),r=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${r})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var p=u;const m={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=m;m._init();i(2);i.d(t,"cloudinary",(function(){return f}));window.$=window.jQuery;const f={settings:s.a,sync:r,widget:l.a,Global_Transformations:c,Terms_Order:p,Media_Library:h}}]); \ No newline at end of file +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./js/src/main.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./css/src/main.scss": +/*!***************************!*\ + !*** ./css/src/main.scss ***! + \***************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./css/src/main.scss?"); + +/***/ }), + +/***/ "./js/src/components/global-transformations.js": +/*!*****************************************************!*\ + !*** ./js/src/components/global-transformations.js ***! + \*****************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\nconst Global_Transformations = {\n\tsample: {\n\t\timage: document.getElementById( 'transformation-sample-image' ),\n\t\tvideo: document.getElementById( 'transformation-sample-video' ),\n\t},\n\tpreview: {\n\t\timage: document.getElementById( 'sample-image' ),\n\t\tvideo: document.getElementById( 'sample-video' ),\n\t},\n\tfields: document.getElementsByClassName( 'cld-field' ),\n\tbutton: {\n\t\timage: document.getElementById( 'refresh-image-preview' ),\n\t\tvideo: document.getElementById( 'refresh-video-preview' ),\n\t},\n\tspinner: {\n\t\timage : document.getElementById( 'image-loader' ),\n\t\tvideo : document.getElementById( 'video-loader' ),\n\t},\n\tactiveItem: null,\n\telements: {\n\t\timage: [],\n\t\tvideo: [],\n\t},\n\t_placeItem: function( item ) {\n\t\tif ( null !== item ) {\n\t\t\titem.style.display = 'block';\n\t\t\titem.style.visibility = 'visible';\n\t\t\titem.style.position = 'absolute';\n\t\t\titem.style.top = (item.parentElement.clientHeight / 2) - (item.clientHeight / 2) + 'px';\n\t\t\titem.style.left = (item.parentElement.clientWidth / 2) - (item.clientWidth / 2) + 'px';\n\t\t}\n\t},\n\t_setLoading: function( type ) {\n\t\tthis.button[ type ].style.display = 'block';\n\t\tthis._placeItem( this.button[ type ] );\n\t\tthis.preview[ type ].style.opacity = '0.1';\n\n\t\t},\n\t_build: function( type ) {\n\t\tthis.sample[ type ].innerHTML = '';\n\t\tthis.elements[ type ] = [];\n\t\tfor (let item of this.fields) {\n\t\t\tif( type !== item.dataset.context ){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet value = item.value.trim();\n\t\t\tif ( value.length ) {\n\n\t\t\t\tif ( 'select-one' === item.type ) {\n\t\t\t\t\tif ( 'none' === value ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvalue = item.dataset.meta + '_' + value;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet type = item.dataset.context;\n\t\t\t\t\tvalue = this._transformations( value, type, true );\n\t\t\t\t}\n\t\t\t\t// Apply value if valid.\n\t\t\t\tif( value ) {\n\t\t\t\t\tthis.elements[ type ].push( value );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlet transformations = '';\n\t\tif ( this.elements[ type ].length ) {\n\t\t\ttransformations = '/' + this.elements[ type ].join( ',' ).replace( / /g, '%20' );\n\t\t}\n\t\tthis.sample[ type ].textContent = transformations;\n\t\tthis.sample[ type ].parentElement.href = 'https://res.cloudinary.com/demo/' + this.sample[ type ].parentElement.innerText.trim().replace('../', '').replace( / /g, '%20' );\n\t},\n\t_clearLoading: function( type ) {\n\t\tthis.spinner[ type ].style.visibility = 'hidden';\n\t\tthis.activeItem = null;\n\t\tthis.preview[ type ].style.opacity = 1;\n\t},\n\t_refresh: function( e, type ) {\n\t\tif( e ) {\n\t\t\te.preventDefault();\n\t\t}\n\t\tlet self = this;\n\t\tlet new_src = CLD_GLOBAL_TRANSFORMATIONS[ type ].preview_url + self.elements[ type ].join( ',' ) + CLD_GLOBAL_TRANSFORMATIONS[ type ].file;\n\t\tthis.button[ type ].style.display = 'none';\n\t\tthis._placeItem( this.spinner[ type ] );\n\t\tif ( type === 'image' ) {\n\t\t\tlet newImg = new Image;\n\t\t\tnewImg.onload = function() {\n\t\t\t\tself.preview[ type ].src = this.src;\n\t\t\t\tself._clearLoading( type );\n\t\t\t\tnewImg.remove();\n\t\t\t};\n\t\t\tnewImg.onerror = function() {\n\t\t\t\talert( CLD_GLOBAL_TRANSFORMATIONS[type].error );\n\t\t\t\tself._clearLoading( type );\n\t\t\t};\n\t\t\tnewImg.src = new_src;\n\t\t}else{\n\t\t\tlet transformations = self._transformations( self.elements[ type ].join( ',' ), type );\n\t\t\tsamplePlayer.source( { publicId: 'dog', transformation: transformations } );\n\t\t\tself._clearLoading( type );\n\t\t}\n\t},\n\t_transformations : function( input, type, string = false ){\n\t\tlet set = CLD_GLOBAL_TRANSFORMATIONS[ type ].valid_types;\n\t\tlet value = null;\n\t\tlet elements = input.split( '/' );\n\t\tlet valid_elements = [];\n\t\tfor (let i = 0; i < elements.length; i++) {\n\t\t\tlet parts = elements[ i ].split(',');\n\t\t\tlet valid_parts;\n\t\t\tif( true === string ) {\n\t\t\t\tvalid_parts = [];\n\t\t\t}else{\n\t\t\t\tvalid_parts = {};\n\t\t\t}\n\t\t\tfor (let p = 0; p < parts.length; p++) {\n\t\t\t\tlet key_val = parts[ p ].trim().split('_');\n\t\t\t\tif( key_val.length <= 1 || typeof set[ key_val[0] ] === 'undefined' ){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet option = key_val.shift();\n\t\t\t\tlet instruct = key_val.join( '_' );\n\t\t\t\tif( true === string ) {\n\t\t\t\t\tif( 'f' === option || 'q' === option ){\n\t\t\t\t\t\tfor( let t in this.elements[ type ] ){\n\t\t\t\t\t\t\tif( option + '_' === this.elements[ type ][ t ].substr(0,2 ) ){\n\t\t\t\t\t\t\t\tthis.elements[ type ].splice(t,1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvalid_parts.push( parts[ p ] );\n\t\t\t\t}else{\n\t\t\t\t\tvalid_parts[ set[ option ] ] = instruct.trim();\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet length = 0;\n\t\t\tif( true === string ) {\n\t\t\t\tlength = valid_parts.length;\n\t\t\t}else{\n\t\t\t\tlength = Object.keys( valid_parts ).length;\n\t\t\t}\n\t\t\tif ( length ) {\n\t\t\t\tif( true === string ) {\n\t\t\t\t\tvalid_parts = valid_parts.join( ',' );\n\t\t\t\t}\n\t\t\t\tvalid_elements.push( valid_parts );\n\t\t\t}\n\t\t}\n\n\t\tif ( valid_elements.length ) {\n\t\t\tif( true === string ) {\n\t\t\t\tvalue = valid_elements.join( '/' ).trim();\n\t\t\t}else{\n\t\t\t\tvalue = valid_elements;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t},\n\t_reset: function() {\n\t\tfor (let item of this.fields) {\n\t\t\titem.value = null;\n\t\t}\n\t\tfor( let type in this.button ) {\n\t\t\tthis._build( type );\n\t\t\tthis._refresh( null, type );\n\t\t}\n\t},\n\t_input: function( input ){\n\t\tif( typeof input.dataset.context !== 'undefined' && input.dataset.context.length ) {\n\t\t\tlet type = input.dataset.context;\n\t\t\tthis._setLoading( type );\n\t\t\tthis._build( type );\n\t\t}\n\t},\n\t_init: function() {\n\n\t\tif ( typeof CLD_GLOBAL_TRANSFORMATIONS !== 'undefined' ) {\n\t\t\tlet self = this;\n\n\t\t\tdocument.addEventListener( 'DOMContentLoaded', function( ev ) {\n\t\t\t\tfor( let type in self.button ) {\n\t\t\t\t\tif( self.button[ type ] ) {\n\t\t\t\t\t\tself.button[ type ].addEventListener( 'click', function( e ) {\n\t\t\t\t\t\t\tself._refresh( e, type );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (let item of self.fields) {\n\t\t\t\t\titem.addEventListener( 'input', function(){\n\t\t\t\t\t\tself._input( this );\n\t\t\t\t\t} );\n\t\t\t\t\titem.addEventListener( 'change', function() {\n\t\t\t\t\t\tself._input( this );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\t// Init.\n\t\t\t\tfor( let type in CLD_GLOBAL_TRANSFORMATIONS ) {\n\t\t\t\t\tself._build( type );\n\t\t\t\t\tself._refresh( null, type );\n\t\t\t\t}\n\t\t\t} );\n\t\t\t// listen to AJAX add-tag complete\n\t\t\tjQuery(document).ajaxComplete(function(event, xhr, settings) {\n\n\t\t\t\t// bail early if is other ajax call\n\t\t\t\tif( settings.data.indexOf('action=add-tag') === -1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// bail early if response contains error\n\t\t\t\tif( xhr.responseText.indexOf('wp_error') !== -1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tself._reset();\n\t\t\t});\n\t\t}\n\t},\n};\n\n// Init.\nGlobal_Transformations._init();\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Global_Transformations);\n\n\n//# sourceURL=webpack:///./js/src/components/global-transformations.js?"); + +/***/ }), + +/***/ "./js/src/components/media-library.js": +/*!********************************************!*\ + !*** ./js/src/components/media-library.js ***! + \********************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\nconst Media_Library = {\n\twpWrap: document.getElementById( 'wpwrap' ),\n\twpContent: document.getElementById( 'wpbody-content' ),\n\tlibraryWrap: document.getElementById( 'cloudinary-embed' ),\n\t_init: function() {\n\t\tlet self = this;\n\t\tif ( typeof CLD_ML !== 'undefined' ) {\n\n\t\t\tcloudinary.openMediaLibrary( CLD_ML.mloptions, {\n\t\t\t\t\tinsertHandler: function( data ) {\n\t\t\t\t\t\t// @todo: Determin what to do here.\n\t\t\t\t\t\talert( 'Import is not yet implemented.' );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\twindow.addEventListener( 'resize', function( ev ) {\n\t\t\t\tself._resize();\n\t\t\t} );\n\n\t\t\tself._resize();\n\t\t}\n\t},\n\t_resize: function() {\n\t\tlet style = getComputedStyle( this.wpContent );\n\t\tthis.libraryWrap.style.height = (this.wpWrap.offsetHeight - parseInt( style.getPropertyValue( 'padding-bottom' ) )) + 'px';\n\t},\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Media_Library);\n\n// Init.\nMedia_Library._init();\n\n\n//# sourceURL=webpack:///./js/src/components/media-library.js?"); + +/***/ }), + +/***/ "./js/src/components/settings-page.js": +/*!********************************************!*\ + !*** ./js/src/components/settings-page.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("(function() {\n\n\tjQuery( document ).ready( function( $ ) {\n\n\t\t// Initilize instance events\n\t\t$( document ).on( 'tabs.init', function() {\n\n\t\t\tvar tabs = $( '.settings-tab-trigger' ),\n\t\t\t sections = $( '.settings-tab-section' );\n\n\t\t\t// Create instance bindings\n\t\t\t$( this ).on( 'click', '.settings-tab-trigger', function( e ) {\n\t\t\t\tvar clicked = $( this ),\n\t\t\t\t target = $( clicked.attr( 'href' ) );\n\n\t\t\t\t// Trigger an instance action.\n\t\t\t\te.preventDefault();\n\n\t\t\t\ttabs.removeClass( 'active' );\n\t\t\t\tsections.removeClass( 'active' );\n\n\t\t\t\tclicked.addClass( 'active' );\n\t\t\t\ttarget.addClass( 'active' );\n\n\t\t\t\t// Trigger the tabbed event.\n\t\t\t\t$( document ).trigger( 'settings.tabbed', clicked );\n\n\t\t\t} );\n\n\t\t\t// Bind conditions.\n\t\t\t$( '.cld-field' ).not( '[data-condition=\"false\"]' ).each( function() {\n\t\t\t\tconst field = $(this);\n\t\t\t\tconst condition = field.data('condition');\n\t\t\t\tfor (let f in condition) {\n\t\t\t\t\tconst value = condition[ f ];\n\t\t\t\t\tconst target = $( '#field-' + f );\n\t\t\t\t\tconst wrapper = field.closest('tr');\n\t\t\t\t\ttarget.on('change init', function(){\n\t\t\t\t\t\tif( this.value === value || this.checked ){\n\t\t\t\t\t\t\twrapper.show();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\twrapper.hide();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\ttarget.trigger('init');\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t$('#field-cloudinary_url').on('input change', function(){\n\t\t\t\tlet field = $(this),\n\t\t\t\t\tvalue = field.val();\n\n\t\t\t\tlet reg = new RegExp(/^(cloudinary:\\/\\/){1}(\\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g );\n\t\t\t\tif( reg.test( value ) ){\n\t\t\t\t\tfield.addClass( 'settings-valid-field' );\n\t\t\t\t\tfield.removeClass( 'settings-invalid-field' );\n\t\t\t\t}else{\n\t\t\t\t\tfield.removeClass( 'settings-valid-field' );\n\t\t\t\t\tfield.addClass( 'settings-invalid-field' );\n\t\t\t\t}\n\t\t\t}).trigger('change' );\n\n\n\t\t} );\n\n\t\t// On Ready, find all render trigger elements and fire their events.\n\t\t$( '.render-trigger[data-event]' ).each( function() {\n\t\t\tvar trigger = $( this ),\n\t\t\t event = trigger.data( 'event' );\n\t\t\ttrigger.trigger( event, this );\n\t\t} );\n\t} );\n\n})( window, jQuery );\n\n\n//# sourceURL=webpack:///./js/src/components/settings-page.js?"); + +/***/ }), + +/***/ "./js/src/components/sync.js": +/*!***********************************!*\ + !*** ./js/src/components/sync.js ***! + \***********************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\n\nconst Sync = {\n\tprogress: document.getElementById( 'progress-wrapper' ),\n\tsubmitButton: document.getElementById( 'submit' ),\n\tstopButton: document.getElementById( 'stop-sync' ),\n\tprogressCount: document.getElementById( 'sync-progress' ),\n\tbarSyncCount: document.getElementById( 'sync-total' ),\n\tcompleted: document.getElementById( 'completed-notice' ),\n\tshow: 'inline-block',\n\thide: 'none',\n\tgetStatus: function getStatus() {\n\t\tvar self = this,\n\t\t\tresourceType = [],\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/attachments',\n\t\t\tparams;\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\ttype: 'GET',\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} ).done( function( data ) {\n\t\t\tif ( data.done < data.total ) {\n\t\t\t\tsetTimeout( Sync.getStatus, 2000 );\n\t\t\t}\n\t\t\tSync._updateUI( data );\n\t\t} );\n\t},\n\tstopSync: function stopSync() {\n\t\tvar self = this,\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/sync';\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\tdata: {\n\t\t\t\tstop: true,\n\t\t\t},\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} ).done( function( data ) {\n\t\t\tSync._updateUI( data );\n\t\t} );\n\t},\n\tpushAttachments: function pushAttachments() {\n\t\tvar self = this,\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/sync';\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} );\n\t},\n\t_updateUI: function _updateUI( data ) {\n\t\tif ( data.percent < 100 && typeof data.started !== 'undefined' ) {\n\t\t\tthis.submitButton.style.display = this.hide;\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse if ( data.percent >= 100 && typeof data.started !== 'undefined' ) {\n\t\t\tthis.submitButton.style.display = this.hide;\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse if ( data.pending > 0 ) {\n\t\t\tthis.submitButton.style.display = this.show;\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\t\telse if ( data.processing > 0 ) {\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\n\t\tif ( data.percent < 100 ) {\n\t\t\tthis.barSyncCount.innerText = data.total;\n\t\t\tthis.progressCount.innerText = data.done;\n\t\t\tthis.progress.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.completed.style.display = this.show;\n\t\t\tthis.progress.style.display = this.hide;\n\t\t}\n\t},\n\t_start: function _start( e ) {\n\t\te.preventDefault();\n\t\tSync.stopButton.style.display = Sync.show;\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.pushAttachments();\n\t},\n\t_reset: function _reset( e ) {\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.getStatus();\n\t},\n\t_init: function( fn ) {\n\n\t\tif ( typeof cloudinaryApi !== 'undefined' ) {\n\t\t\tif ( document.attachEvent ? document.readyState === 'complete' : document.readyState !== 'loading' ) {\n\t\t\t\tfn();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdocument.addEventListener( 'DOMContentLoaded', fn );\n\t\t\t}\n\t\t}\n\t},\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Sync);\n\n// Init.\nSync._init( function() {\n\tSync._reset();\n\tSync.submitButton.addEventListener( 'click', Sync._start );\n\tSync.stopButton.addEventListener( 'click', Sync.stopSync );\n} );\n\n\n//# sourceURL=webpack:///./js/src/components/sync.js?"); + +/***/ }), + +/***/ "./js/src/components/terms_order.js": +/*!******************************************!*\ + !*** ./js/src/components/terms_order.js ***! + \******************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp wpAjax */\n\nconst Terms_Order = {\n template: '',\n tags: jQuery( '#cld-tax-items' ),\n tagDelimiter: ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ',',\n startId: null,\n _init: function() {\n // Check that we found the tax-items.\n if ( !this.tags.length ) {\n return;\n }\n\n const self = this;\n this._sortable();\n\n // Setup ajax overrides.\n if ( typeof wpAjax !== 'undefined' ) {\n wpAjax.procesParseAjaxResponse = wpAjax.parseAjaxResponse;\n wpAjax.parseAjaxResponse = function( response, settingsResponse, element ) {\n let newResponse = wpAjax.procesParseAjaxResponse( response, settingsResponse, element );\n if ( !newResponse.errors && newResponse.responses[ 0 ] ) {\n if ( jQuery( '[data-taxonomy=\"' + newResponse.responses[ 0 ].what + '\"]' ).length ) {\n const data = jQuery( newResponse.responses[ 0 ].data );\n const text = data.find( 'label' ).last().text().trim();\n self._pushItem( newResponse.responses[ 0 ].what, text );\n }\n }\n\n return newResponse;\n };\n }\n\n if ( typeof window.tagBox !== 'undefined' ) {\n window.tagBox.processflushTags = window.tagBox.flushTags;\n window.tagBox.flushTags = function( el, a, f ) {\n if ( typeof f === 'undefined' ) {\n let text, list;\n const taxonomy = el.prop( 'id' );\n const newTag = jQuery( 'input.newtag', el );\n\n a = a || false;\n\n text = a ? jQuery( a ).text() : newTag.val();\n list = window.tagBox.clean( text ).split( self.tagDelimiter );\n for ( var i in list ) {\n var tag = taxonomy + ':' + list[ i ];\n if ( !jQuery( '[data-item=\"' + tag + '\"]' ).length ) {\n self._pushItem( tag, list[ i ] );\n }\n }\n }\n\n return this.processflushTags( el, a, f );\n };\n\n window.tagBox.processTags = window.tagBox.parseTags;\n\n window.tagBox.parseTags = function( el ) {\n const id = el.id;\n const num = id.split( '-check-num-' )[ 1 ];\n const taxonomy = id.split( '-check-num-' )[ 0 ];\n const taxBox = jQuery( el ).closest( '.tagsdiv' );\n const tagsTextarea = taxBox.find( '.the-tags' );\n const tagToRemove = window.tagBox.clean( tagsTextarea.val() ).split( self.tagDelimiter )[ num ];\n\n new wp.api.collections.Tags()\n .fetch( { data: { slug: tagToRemove } } )\n .done( ( tag ) => {\n const tagFromDatabase = tag.length ? jQuery( '[data-item=\"' + taxonomy + ':' + tag[ 0 ].id + '\"]' ) : false;\n\n if ( tagFromDatabase.length ) {\n tagFromDatabase.remove();\n }\n else {\n jQuery( `.cld-tax-order-list-item:contains(${ tagToRemove })` ).remove();\n --self.startId;\n }\n this.processTags( el );\n } );\n };\n }\n\n jQuery( 'body' ).on( 'change', '.selectit input', function() {\n const clickedItem = jQuery( this );\n const id = clickedItem.val();\n const checked = clickedItem.is( ':checked' );\n const text = clickedItem.parent().text().trim();\n\n if ( true === checked ) {\n if( ! self.tags.find(`[data-item=\"category:${ id }\"]`).length ) {\n self._pushItem( `category:${ id }`, text );\n }\n }\n else {\n self.tags.find( `[data-item=\"category:${ id }\"]` ).remove();\n }\n } );\n },\n _createItem: function( id, name ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li.addClass( 'cld-tax-order-list-item' ).attr( 'data-item', id );\n input.addClass( 'cld-tax-order-list-item-input' ).attr( 'type', 'hidden' ).attr( 'name', 'cld_tax_order[]' ).val( id );\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n },\n _pushItem: function( id, text ) {\n let item = this._createItem( id, text );\n this.tags.append( item ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n },\n _sortable: function() {\n const items = jQuery( '.cld-tax-order-list' );\n\n items.sortable( {\n connectWith: '.cld-tax-order',\n axis: 'y',\n handle: '.cld-tax-order-list-item-handle',\n placeholder: 'cld-tax-order-list-item-placeholder',\n forcePlaceholderSize: true,\n helper: 'clone',\n } );\n }\n};\n\nif ( typeof window.CLDN !== 'undefined' ) {\n Terms_Order._init();\n // Init checked categories.\n jQuery( '[data-wp-lists] .selectit input[checked]' ).map( ( ord, check ) => {\n jQuery( check ).trigger( 'change' );\n } );\n}\n\n// Gutenberg.\nif ( wp.data && wp.data.select( 'core/editor' ) ) {\n const orderSet = {};\n wp.data.subscribe( function() {\n let taxonomies = wp.data.select( 'core' ).getTaxonomies();\n\n if ( taxonomies ) {\n for ( let t in taxonomies ) {\n const set = wp.data.select( 'core/editor' ).getEditedPostAttribute( taxonomies[ t ].rest_base );\n orderSet[ taxonomies[ t ].slug ] = set;\n }\n }\n } );\n\n const el = wp.element.createElement;\n const CustomizeTaxonomySelector = ( OriginalComponent ) => {\n class CustomHandler extends OriginalComponent {\n constructor( props ) {\n super( props );\n\n this.currentItems = jQuery( '.cld-tax-order-list-item' )\n .map( ( _, taxonomy ) => jQuery( taxonomy ).data( 'item' ) ).get();\n }\n\n makeItem( item ) {\n // Prevent duplicates in the tax order box\n if ( this.currentItems.includes( this.getId( item ) ) ) {\n return;\n }\n\n const row = this.makeElement( item );\n const box = jQuery( '#cld-tax-items' );\n box.append( row ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n }\n\n removeItem( item ) {\n const elementWithId = jQuery( `[data-item=\"${ this.getId( item ) }\"]` );\n\n if ( elementWithId.length ) {\n elementWithId.remove();\n\n this.currentItems = this.currentItems.filter( ( taxIdentifier ) => {\n return taxIdentifier !== this.getId( item );\n } );\n }\n }\n\n findOrCreateTerm( termName ) {\n termName = super.findOrCreateTerm( termName );\n termName.then( ( item ) => this.makeItem( item ) );\n\n return termName;\n }\n\n onChange( event ) {\n super.onChange( event );\n const item = this.pickItem( event );\n\n if ( item ) {\n if ( orderSet[ this.props.slug ].includes( item.id ) ) {\n this.makeItem( item );\n }\n else {\n this.removeItem( item );\n }\n }\n }\n\n pickItem( event ) {\n if ( typeof event === 'object' ) {\n if ( event.target ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === parseInt( event.target.value ) ) {\n return this.state.availableTerms[ p ];\n }\n }\n // Tags that are already registered need to be selected\n // separately as its expected that they return back\n // with an \"id\" property.\n }\n else if ( Array.isArray( event ) ) {\n // Figure out the diff between the current state and\n // the event and determine which tag is getting removed\n let enteredTag = this.state.selectedTerms.filter( flatItem => !event.includes( flatItem ) )[ 0 ];\n\n if ( typeof enteredTag === 'undefined' ) {\n // If the above returns undefined, then we presume\n // the user is adding, so reverse the logic to\n // figure out the new item\n enteredTag = event.filter( flatItem => !this.state.selectedTerms.includes( flatItem ) )[ 0 ];\n }\n\n return this.state.availableTerms.find( ( item ) => item.name === enteredTag );\n }\n }\n else if ( typeof event === 'number' ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === event ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n else {\n let text;\n\n // add or remove.\n if ( event.length > this.state.selectedTerms.length ) {\n // Added.\n for ( let o in event ) {\n if ( this.state.selectedTerms.indexOf( event[ o ] ) === -1 ) {\n text = event[ o ];\n }\n }\n }\n else {\n // removed.\n for ( let o in this.state.selectedTerms ) {\n if ( event.indexOf( this.state.selectedTerms[ o ] ) === -1 ) {\n text = this.state.selectedTerms[ o ];\n }\n }\n }\n\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].name === text ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n }\n\n getId( item ) {\n return `${ this.props.slug }:${ item.id }`;\n }\n\n makeElement( item ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li\n .addClass( 'cld-tax-order-list-item' )\n .attr( 'data-item', this.getId( item ) );\n\n input\n .addClass( 'cld-tax-order-list-item-input' )\n .attr( 'type', 'hidden' )\n .attr( 'name', 'cld_tax_order[]' ).val( this.getId( item ) );\n\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( item.name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n }\n }\n\n return ( props ) => el( CustomHandler, props );\n };\n\n wp.hooks.addFilter(\n 'editor.PostTaxonomyType',\n 'cld',\n CustomizeTaxonomySelector\n );\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Terms_Order);\n\n\n//# sourceURL=webpack:///./js/src/components/terms_order.js?"); + +/***/ }), + +/***/ "./js/src/components/widget.js": +/*!*************************************!*\ + !*** ./js/src/components/widget.js ***! + \*************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("/* global window wp Backbone */\nif ( wp.media && window.CLDN ) {\n\n\twp.media.events.on( 'editor:image-edit', function( props ){\n\t\tprops.metadata.cldoverwrite = null;\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( classes.indexOf('cld-overwrite' ) >= 0 ){\n\t\t\tprops.metadata.cldoverwrite = 'true';\n\t\t}\n\t} );\n\twp.media.events.on( 'editor:image-update', function( props ){\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) === -1 ) {\n\t\t\tclasses.push( 'cld-overwrite' );\n\t\t} else if( ! props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) >= 0 ) {\n\t\t\tdelete classes[ classes.indexOf('cld-overwrite' ) ];\n\t\t}\n\n\t\tprops.image.className = classes.join( ' ' );\n\t} );\n\n\t// Intercept props and inject cld-overwrite class.\n\tlet currentOverwrite = null;\n\tlet imageProps = wp.media.string.props;\n\twp.media.string.props = function( props, asset ){\n\t\tif( props.cldoverwrite ){\n\t\t\tprops.classes = [ 'cld-overwrite' ];\n\t\t\tcurrentOverwrite = true;\n\t\t}\n\t\tlet newProps = imageProps( props, asset );\n\t\treturn newProps;\n\t}\n\t// Intercept ajax post, and send the cld-overwrite flag, and transformations.\n\twp.media.post = function( action, data ) {\n\n\t\tif ( 'send-attachment-to-editor' === action ) {\n\t\t\tlet state = wp.media.editor.get().state();\n\t\t\tlet attach = state.get( 'selection' ).get( data.attachment );\n\t\t\tif ( attach.attributes.transformations ) {\n\t\t\t\tdata.attachment.transformations = attach.attributes.transformations;\n\t\t\t}\n\t\t\tif( data.html.indexOf('cld-overwrite') > -1 || true === currentOverwrite ){\n\t\t\t\tdata.attachment.cldoverwrite = true;\n\t\t\t\tcurrentOverwrite = null;\n\t\t\t}\n\n\t\t}\n\t\t// Return the original.\n\t\treturn wp.ajax.post( action, data );\n\t};\n\n\tlet Library = wp.media.controller.Library;\n\tlet MediaFrame = wp.media.view.MediaFrame.Select;\n\tlet MediaFramePost = wp.media.view.MediaFrame.Post;\n\tlet MediaFrameImageDetails = wp.media.view.MediaFrame.ImageDetails;\n\tlet MediaFrameVideoDetails = wp.media.view.MediaFrame.VideoDetails;\n\tlet Cloudinary = wp.media.View.extend( {\n\t\ttagName: 'div',\n\t\tclassName: 'cloudinary-widget',\n\t\ttemplate: wp.template( 'cloudinary-dam' ),\n\t\tactive: false,\n\t\ttoolbar: null,\n\t\tframe: null,\n\t\tready: function() {\n\t\t\tlet controller = this.controller;\n\t\t\tlet selection = this.model.get( 'selection' );\n\t\t\tlet library = this.model.get( 'library' );\n\t\t\tlet attachment = wp.media.model.Attachment;\n\t\t\t// Set widget to same as model.\n\t\t\tCLDN.mloptions.multiple = controller.options.multiple;\n\t\t\tif ( this.cid !== this.active ) {\n\t\t\t\tCLDN.mloptions.inline_container = '#cloudinary-dam-' + controller.cid;\n\t\t\t\tif ( 1 === selection.length ) {\n\t\t\t\t\tvar att = attachment.get( selection.models[ 0 ].id );\n\t\t\t\t\tif ( typeof att.attributes.public_id !== 'undefined' ) {\n\t\t\t\t\t\tCLDN.mloptions.asset = {resource_id: att.attributes.public_id };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tCLDN.mloptions.asset = null;\n\t\t\t\t}\n\t\t\t\twindow.ml = cloudinary.openMediaLibrary( CLDN.mloptions, {\n\t\t\t\t\t\tinsertHandler: function( data ) {\n\t\t\t\t\t\t\tfor (let i = 0; i < data.assets.length; i++) {\n\t\t\t\t\t\t\t\tlet temp = data.assets[ i ];\n\t\t\t\t\t\t\t\twp.media.post( 'cloudinary-down-sync', {\n\t\t\t\t\t\t\t\t\tnonce: CLDN.nonce,\n\t\t\t\t\t\t\t\t\tasset: temp,\n\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\tlet update_asset = function( asset, attach ){\n\t\t\t\t\t\t\t\t\t\tasset.uploading = false;\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.remove( attach );\n\t\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( typeof asset.fetch !== 'undefined' ) {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.attachment_id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tlibrary.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.ajax.send( {\n\t\t\t\t\t\t\t\t\t\t\turl: asset.fetch,\n\t\t\t\t\t\t\t\t\t\t\tbeforeSend: function( request ) {\n\t\t\t\t\t\t\t\t\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', CLDN.nonce );\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\t\tsrc: asset.url,\n\t\t\t\t\t\t\t\t\t\t\t\tfilename: asset.filename,\n\t\t\t\t\t\t\t\t\t\t\t\tattachment_id: asset.attachment_id,\n\t\t\t\t\t\t\t\t\t\t\t\ttransformations: asset.transformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t} ).fail( function( data ) {\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t\tlibrary.remove( attach );\n\t\t\t\t\t\t\t\t\t\t\tselection.remove( attach );\n\n\t\t\t\t\t\t\t\t\t\t\tif( typeof data === 'string' ) {\n\t\t\t\t\t\t\t\t\t\t\t\talert( data );\n\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t\tif( data.status === 500 ){\n\t\t\t\t\t\t\t\t\t\t\t\t\talert('HTTP error.');\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tselection.add( attach );\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontroller.content.mode( 'browse' );\n\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tdocument.querySelectorAll( '.dam-cloudinary' )[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.active = this.cid;\n\t\t\treturn this;\n\t\t},\n\t} );\n\tlet extend_type = function( type ) {\n\t\tlet obj = {\n\n\t\t\t/**\n\t\t\t * Bind region mode event callbacks.\n\t\t\t *\n\t\t\t * @see media.controller.Region.render\n\t\t\t */\n\t\t\tbindHandlers: function() {\n\t\t\t\ttype.prototype.bindHandlers.apply( this, arguments );\n\t\t\t\tthis.on( 'content:render:cloudinary', this.cloudinaryContent, this );\n\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Render callback for the router region in the `browse` mode.\n\t\t\t *\n\t\t\t * @param {wp.media.view.Router} routerView\n\t\t\t */\n\t\t\tbrowseRouter: function( routerView ) {\n\n\t\t\t\ttype.prototype.browseRouter.apply( this, arguments );\n\t\t\t\tlet state_id = this.state().get( 'id' );\n\t\t\t\trouterView.set( {\n\t\t\t\t\tcloudinary: {\n\t\t\t\t\t\ttext: 'Cloudinary',\n\t\t\t\t\t\tpriority: 60\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t/**\n\t\t\t * Render callback for the content region in the `upload` mode.\n\t\t\t */\n\t\t\tcloudinaryContent: function( contentRegion ) {\n\t\t\t\tlet state = this.state();\n\t\t\t\tlet view = new Cloudinary( {\n\t\t\t\t\tcontroller: this,\n\t\t\t\t\tmodel: state,\n\t\t\t\t} ).render();\n\t\t\t\tthis.content.set( view );\n\t\t\t},\n\t\t};\n\n\t\treturn obj;\n\t};\n\t// Extending the current media library frames to add a new tab to each area.\n\twp.media.view.MediaFrame.Select = MediaFrame.extend( extend_type( MediaFrame ) );\n\twp.media.view.MediaFrame.Post = MediaFramePost.extend( extend_type( MediaFramePost ) );\n\twp.media.view.MediaFrame.ImageDetails = MediaFrameImageDetails.extend( extend_type( MediaFrameImageDetails ) );\n\twp.media.view.MediaFrame.VideoDetails = MediaFrameVideoDetails.extend( extend_type( MediaFrameVideoDetails ) );\n\n}\n\n\n//# sourceURL=webpack:///./js/src/components/widget.js?"); + +/***/ }), + +/***/ "./js/src/main.js": +/*!************************!*\ + !*** ./js/src/main.js ***! + \************************/ +/*! exports provided: cloudinary */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"cloudinary\", function() { return cloudinary; });\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/settings-page */ \"./js/src/components/settings-page.js\");\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_components_settings_page__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _components_sync__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/sync */ \"./js/src/components/sync.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/widget */ \"./js/src/components/widget.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_components_widget__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/global-transformations */ \"./js/src/components/global-transformations.js\");\n/* harmony import */ var _components_terms_order__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/terms_order */ \"./js/src/components/terms_order.js\");\n/* harmony import */ var _components_media_library__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/media-library */ \"./js/src/components/media-library.js\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../css/src/main.scss */ \"./css/src/main.scss\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__);\n/* global window */\n/**\n * Main JS.\n */\n\n// Components\n\n\n\n\n\n\n\n\n\n// jQuery, because reasons.\nconst $ = window.$ = window.jQuery;\n\n// Global Constants\nconst cloudinary = {\n\tsettings: (_components_settings_page__WEBPACK_IMPORTED_MODULE_0___default()),\n\tsync: _components_sync__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n\twidget: (_components_widget__WEBPACK_IMPORTED_MODULE_2___default()),\n\tGlobal_Transformations: _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n\tTerms_Order: _components_terms_order__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n\tMedia_Library: _components_media_library__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n};\n\n\n\n//# sourceURL=webpack:///./js/src/main.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php index 3091d085a..6d9f94add 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php @@ -385,10 +385,12 @@ public function print_video_scripts() { videoElement.style.width = '100%'; config['video_freeform'] ): ?> - videoElement.src = videoElement.src.replace( - 'upload/', - 'upload/config['video_freeform'] ) ?>/' - ); + if ( videoElement.src.indexOf( 'config['video_freeform'] ) ?>' ) === -1 ) { + videoElement.src = videoElement.src.replace( + 'upload/', + 'upload/config['video_freeform'] ) ?>/' + ); + } } }