Changeset 2741703
- Timestamp:
- 06/13/2022 02:12:07 PM (4 years ago)
- Location:
- thron/trunk
- Files:
-
- 20 edited
-
README.txt (modified) (4 diffs)
-
admin/class-thron-admin.php (modified) (23 diffs)
-
admin/class-thron-setting.php (modified) (2 diffs)
-
admin/css/thron-admin.css (modified) (4 diffs)
-
admin/css/thron-block.css (modified) (4 diffs)
-
admin/js/collection-filter.js (modified) (2 diffs)
-
admin/js/thron-admin.js (modified) (2 diffs)
-
admin/js/thron-block.js (modified) (38 diffs)
-
admin/js/wp.media.library.js (modified) (11 diffs)
-
admin/js/wp.media.thron-view.js (modified) (12 diffs)
-
includes/class-thron-api.php (modified) (6 diffs)
-
includes/class-thron.php (modified) (9 diffs)
-
includes/cmb2-field-ajax-search/cmb2-field-ajax-search.php (modified) (1 diff)
-
languages/thron-it_IT-thron-block.json (modified) (5 diffs)
-
languages/thron-it_IT.mo (modified) (previous)
-
languages/thron-it_IT.po (modified) (3 diffs)
-
languages/thron.pot (modified) (2 diffs)
-
public/class-thron-public.php (modified) (2 diffs)
-
public/partials/player.php (modified) (2 diffs)
-
thron.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
thron/trunk/README.txt
r2343564 r2741703 2 2 Contributors: thronspa, websolutedev 3 3 Tags: DAM 4 Stable tag: 1. 0.15 Requires at least: 5. 26 Tested up to: 5. 44 Stable tag: 1.2.1 5 Requires at least: 5.9 6 Tested up to: 5.9.2 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 11 11 THRON is a cloud solution used by leading companies to maximize efficiency and reduce costs related to digital content management. 12 12 13 14 13 == Description == 15 14 16 This plugin allows publishers to select directly from the Wordpress media library all media content such as images, videos, documents, audio and galleries that have been previously uploaded into the DAM. Media files can be included both using standard Gutenberg's blocks and using the THRON Universal Player. 15 THRON Connector for WordPress allows you to publish and update the contents of your 16 website quickly, intuitively and automatically. Editors have access to a library 17 of up-to-date and approved content, directly within the CMS, without the need to 18 create copies. 19 20 Content can be embedded using THRON Universal Player or the Gutenberg editor. 21 22 The connector supports THRON DELIVERY and all its features: from Universal Player 23 to our Real-Time Image Editor, you can publish your content in a centralized and 24 direct way, without duplications and always at maximum performance. 17 25 18 26 = Features = 19 27 20 * full integrated with THRON DAM 21 * allows you to embed images, video, audio and any other type of content 22 * fully responsive for any device 23 * 100% compliant with gutenberg editor 28 - Supports images, videos, audio files and any other type of content 29 - Automatic update: every time you edit a content in THRON, your site is automatically updated, with no need of manual updating activities 30 - Optimize images for the web: with the Real-Time Image Editor, you can optimize images during publication without creating new copies. 31 - Manage the automatic cropping of images directly from the connector, choosing between different cropping modes: Automatic, Centered, Product and Manual 32 - Independently adjust image parameters such as quality, brightness, contrast, sharpness and color saturation, directly from the plug-in and with no need of post-production. 33 - Maximum performance: guarantee the best performance for your users wherever they are thanks to our Universal Player and its features. The player dynamically adapts the quality of the content according to the user's conditions, supports lazy loading and automatically optimizes the reproduced content for SEO purposes. 34 - 100% compliant with the Gutenberg editor. 35 36 = Benefits = 37 38 - Eliminate content duplication 39 - Eliminate integration costs 40 - Improve page loading performance and peak load management with THRON's infrastructure 41 - Automatically gather insights into the usage of your published content with our Content Analytics tools. 24 42 25 43 = Requirements = 26 44 27 * All you need to get started is to register for a free [THRON account](https://www.thron.com/en/trial) to use the plugin and start uploading your media to the cloud. 45 THRON Connector for WordPress is free of charge. If you already use THRON DAM Platform, 46 please contact your Success Manager or email us at [email protected] to learn 47 how to install the connector. 28 48 29 = Highlights = 30 31 * Automatic responsive images for delivery on various devices in different resolutions. 32 * Enpower the performance of your website, 33 * Full support for all types of content: images, videos, audio, gallery and 360 product views 34 * Integrated CDN to improve the performance in the delivery of the contents of your site uploaded in THRON 35 * THRON Player integration with the gutenberg editor: maximize the usability and the exzperience for multimedia contents 36 37 = Simple Integration = 38 39 * Upload your assets in a THRON folder 40 * Embed an image and video from THRON using the simple Gutenberg Thron embed block 49 Would you like to request a demo of THRON DAM Platform? [Click here](https://www.thron.com/en/book-a-demo). 41 50 42 51 = About THRON = 43 52 44 * [Our website](http://thron.com) 45 * [DAM solution](https://www.thron.com/en/digital-asset-management) 46 * [Elastic Media delivery](https://www.thron.com/en/elastic-media-delivery) 47 * [Help page](https://help.thron.com/hc/en-us) 53 - [Our Site](https://www.thron.com/en) 54 - [THRON DAM Platform](https://www.thron.com/en/dam-platform) 55 - [THRON Connectors](https://www.thron.com/en/connettori-thron) 56 - [THRON Blog](https://blog.thron.com/en) 57 - [Help Portal](https://help.thron.com/hc/en-us) 48 58 49 59 = Contributors & Developers = 60 50 61 [THRON spa](https://profiles.wordpress.org/thronspa/) 51 62 [Websolute spa](https://profiles.wordpress.org/websolutedev/) … … 68 79 = Setting up = 69 80 * Once the plugin is activated, go to the `THRON` settings. 70 * You ll be prompted to your THRON clientId, AppId and AppKey that you can find on the Wordpress Connector page in THRON.81 * You'll be prompted to your THRON clientId, AppId and AppKey that you can find on the Wordpress Connector page in THRON. 71 82 * After saving, the plugin is active and connected to the THRON platform. 72 83 … … 80 91 == Changelog == 81 92 93 = 1.2.1 = 94 - THRON Player 95 - Enhance parameters 96 - Crop feature (Manual & THRON-powered) 97 - Various improvements 98 - Manual crop on native Gutenberg Image block 99 - Buttons for “Edit on Thron” and “Update on Thron” 100 - Translations improvements 101 - Various fix 102 103 = 1.0.1 = 104 - Bugfixes 105 82 106 = 1.0.0 = 83 *Initial version107 - Initial version -
thron/trunk/admin/class-thron-admin.php
r2343564 r2741703 57 57 $this->wp_language = strtoupper( substr( get_locale(), 0, 2 ) ); 58 58 59 $this->thron_options = get_option( 'thron_option_api_page' ); 60 61 $this->thron_list_folder = get_option( 'thron_list_folder' ); 62 59 63 /** 60 64 * The parameters to connect to the Thron API are loaded … … 191 195 } while ( $i < $getTemplate->totalResults ); 192 196 197 $this->templateList[] = array( 198 'createdBy' => 'thronPlugin', 199 'createdDate'=> date(DATE_ISO8601), 200 'name' => 'THRON Customer Experience 1.x', 201 'values' => [], 202 'id' => '' 203 ); 193 204 194 205 } … … 221 232 */ 222 233 $thron_options = get_option( 'thron_option_api_page' ); 223 $tlf = get_option('thron_list_folder'); 234 224 235 if ( ! is_array( $thron_options ) ) { 225 236 return; … … 237 248 'media-views' 238 249 ), null, false ); 250 251 252 253 wp_enqueue_script( 254 'thron-image-override', 255 plugin_dir_url( __FILE__ ) . 'js/image-override.js', 256 array(), 257 true 258 ); 259 239 260 240 261 … … 254 275 'thron_appKey' => $appKey, 255 276 'thron_pkey' => get_option( 'thron_pkey' ), 256 'thron_list_folder' => $tlf,257 277 'thron_rootCategoryId' => get_option( 'thron_rootCategoryId' ) 258 278 ) ); … … 273 293 wp_localize_script( 'media-library-taxonomy-filter', 'ThronTagsList', array( 274 294 'tags' => $tagsFilter, 275 'thron_list_folder' => $tlf,276 295 'folders' => $this->folderList, 277 296 'lang' => array( 278 297 'all' => __( 'All', 'thron' ), 279 'allFolders' => $tlf == '' ? __( 'All folders', 'thron' ) : $this->folderNameByID($tlf)298 'allFolders' => __( 'All folders', 'thron' ) 280 299 ) 281 300 ) ); … … 293 312 array( 294 313 'ajaxurl' => admin_url( 'admin-ajax.php' ), 295 'thron_list_folder' => $tlf,296 314 'thron_clientId' => $thron_options['thron_clientId'], 297 315 'thron_appId' => $thron_options['thron_appId'], … … 304 322 'tags' => $tagsFilter, 305 323 'folders' => $this->folderList, 306 'allfolders' => $tlf == '' ? __( 'All folders', 'thron' ) : $this->folderNameByID($tlf),324 'allfolders' => __( 'All folders', 'thron' ), 307 325 'allcontent' => __( 'All content', 'thron' ), 308 326 'contentdetails' => __( 'Content details', 'thron' ), … … 313 331 'widthpx' => __( 'Width (px)', 'thron' ), 314 332 'heightpx' => __( 'Height (px)', 'thron' ), 333 'videos' => __( 'Videos', 'thron' ), 334 'audio' => __( 'Audio', 'thron' ), 335 'images' => __( 'Images', 'thron' ), 336 'documents' => __( 'Document (Other)', 'thron' ), 337 'playlist' => __( 'Playlist', 'thron' ), 338 'url' => __( 'URL', 'thron' ), 339 'pagelet' => __( 'Pagelet', 'thron' ), 315 340 ) ); 316 341 wp_enqueue_script( 'wp-media-thron' ); 317 342 } 318 319 private function folderNameByID( $folderID ) {320 /**321 * Carico i TAG da Thron322 */323 324 $thron_options = get_option( 'thron_option_api_page' );325 326 if (!is_array($thron_options ))327 return;328 329 $clientId = $thron_options['thron_clientId'];330 $appId = $thron_options['thron_appId'];331 $appKey = $thron_options['thron_appKey'];332 333 $thron_api = new ThronAPI( $appId, $clientId, $appKey );334 335 $results = $thron_api->folderNameByID( $folderID );336 337 /**338 * Se la trova seleziona la lingua di default dell'utente339 */340 $language = $results->locales[0];341 foreach ($results->locales as $locale ) {342 if ('EN' == $locale->locale)343 $language = $locale;344 }345 foreach ($results->locales as $locale ) {346 if ($this->wp_language == $locale->locale)347 $language = $locale;348 }349 350 return $language->name;351 }352 353 343 354 344 private function createTree( &$list, $parent, $sep = '' ) { … … 421 411 } 422 412 423 /* 424 * alambertini 202024061511 ::: array index wrap ::: Undefined index: post__in 425 */ 426 if (array_key_exists('post__in',$_REQUEST['query'])) 427 { 428 /** 429 * Esco se il post__in fa riferimento ad un post in particolare 430 */ 431 if ( count( $_REQUEST['query']['post__in'] ) > 0 ) { 432 return; 433 } 413 /** 414 * Esco se il post__in fa riferimento ad un post in particolare 415 */ 416 if ( count( (array)$_REQUEST['query']['post__in'] ) > 0 ) { 417 return; 434 418 } 435 419 … … 519 503 */ 520 504 $term = sanitize_text_field( $query['s'] ); 521 $categories = sanitize_text_field( (isset($query['thron_categories']) ? $query['thron_categories'] : get_option('thron_list_folder')) ); 522 523 /* 524 * alambertini 202026060917 ::: sanitize only on string 525 */ 526 $mime_type = (is_array($query['post_mime_type']) ? $query['post_mime_type'] : sanitize_text_field($query['post_mime_type'])); 527 505 $categories = sanitize_text_field( $query['thron_categories'] ); 506 $mime_type = sanitize_text_field( $query['post_mime_type'] ); 528 507 $tags = null; 529 508 $per_page = sanitize_text_field( $query['posts_per_page'] ); … … 547 526 wp_send_json_success( $posts ); 548 527 die; 528 } 529 530 function infinite_scroll_true( $infinite ){ 531 532 $infinite = true; 533 //print_r($infinite); 534 return $infinite; 549 535 } 550 536 … … 600 586 'helps' => __( '' ) 601 587 ); 588 589 $screen = get_current_screen(); 590 591 if ( $screen->parent_base == 'upload' ) { 592 $t_id = get_post_meta(get_the_ID(),'thron_id', true); 593 if($t_id) { 594 ?> 595 <script> 596 jQuery(function(){ 597 598 var th_img = jQuery('.misc-pub-filename > strong').html().split('?') 599 600 var th_info = th_img[0].split('.') 601 jQuery('.misc-pub-filename > strong').html(th_img[0]) 602 jQuery('.misc-pub-filetype > strong').html(th_info[1].toUpperCase()) 603 604 605 jQuery('#imgedit-open-btn-<?=$post->ID?>').remove() 606 jQuery('p span.spinner').remove() 607 jQuery('#media-head-<?=$post->ID?>').append('<p><a type="button" href="https://<?=$this->thron_options['thron_clientId']?>.thron.com/#/contents/content/<?=$t_id?>" target="_blank" class="button button-hero thron-upload-button"><?=__( 'Edit image on THRON', 'thron' )?></a></p><p> <span class="spinner"></span></p>') 608 }) 609 </script> 610 <?php 611 612 } 613 } 602 614 603 615 return $form_fields; … … 649 661 650 662 $list_files = $thron_api->search( $term, $categories, $tag, $mime_type, $per_page, $pageToken ); 651 663 //print_r($list_files); 652 664 $_SESSION['pageToken'] = $list_files->nextPageToken; 653 665 … … 703 715 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 704 716 705 $file_url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/' . strval( $width_default ) . 'x0/' . $file->details->source->fileName;717 $file_url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/' . strval( $width_default ) . 'x0/' . $file->details->source->fileName; 706 718 707 719 $attachment_metadata = array(); … … 731 743 $height = null; 732 744 } 733 745 //print_r( $file->detail->locales[0]); 746 747 //print_r( $file->detail->locales[0]->name); 734 748 $url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/' . $width . 'x' . $height . '/' . $file->details->source->fileName; 749 //$url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/' . $width . 'x' . $height . '/' . $file->details->locales[0]->name; 750 751 //$url = 'https://' . $clientId . '-cdn.thron.com/api/xcontents/resources/delivery/getThumbnail/' . $clientId . '/' . $width . 'x' . $height . '/' . $file->id; 735 752 736 753 $attachment_metadata[ $image_size ] = array( … … 874 891 'post_type' => 'attachment', 875 892 'post_status' => 'inherit', 893 'post_parent' => 0, 876 894 'meta_query' => array( 877 895 array( … … 879 897 'value' => $thron_id, 880 898 'compare' => '=', 881 ) 899 ) 882 900 ) 883 901 ); 902 884 903 $query = new WP_Query( $args ); 885 886 904 $posts = $query->posts; 905 887 906 888 907 if ( count( $query->posts ) > 0 ) { … … 1165 1184 wp_enqueue_script( 1166 1185 'thron-block', 1167 plugin_dir_url( __FILE__ ) . 'js/thron-block -def.js',1186 plugin_dir_url( __FILE__ ) . 'js/thron-block.js', 1168 1187 array( 'wp-blocks', 'wp-editor' ), 1169 1188 true 1170 1189 ); 1171 1190 1172 1191 wp_set_script_translations( 'thron-block', 'thron', THRON_PLUGIN_PATH . '/languages' ); 1173 1192 … … 1180 1199 'thron_playerTemplates' => get_option( 'thron_playerTemplates' ) ? get_option( 'thron_playerTemplates' ) : $template_default, 1181 1200 'pkey' => get_option( 'thron_pkey' ), 1182 'thron_list_folder' => get_option('thron_list_folder'),1183 1201 'templateList' => $templateList, 1184 1202 'folders' => $this->folderList, … … 1190 1208 } 1191 1209 1192 function thron_add_tci_tracking_image_block( $attributes, $content ) {1193 1194 $content = str_replace('wp-image-', 'tci wp-image-', $content);1195 1196 return $content;1197 }1198 1199 function thron_add_tci_tracking_video_block( $attributes, $content ) {1200 1201 $content = preg_replace_callback( '/(<video) (.*video>)/i', array(1202 $this,1203 'process_video_audio_class'1204 ), $content );1205 1206 return $content;1207 }1208 1209 function thron_add_tci_tracking_audio_block( $attributes, $content ) {1210 1211 $content = preg_replace_callback( '/(<audio) (.*audio>)/i', array(1212 $this,1213 'process_video_audio_class'1214 ), $content );1215 1216 return $content;1217 }1218 1219 1210 1220 1211 function register_block_embed() { 1221 1222 register_block_type( 'core/gallery', array(1223 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ),1224 ) );1225 1226 register_block_type( 'core/media-text', array(1227 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ),1228 ) );1229 1230 register_block_type( 'core/audio', array(1231 'render_callback' => array( $this, 'thron_add_tci_tracking_audio_block' ),1232 ) );1233 1234 register_block_type( 'core/image', array(1235 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ),1236 ) );1237 1238 register_block_type( 'core/video', array(1239 'render_callback' => array( $this, 'thron_add_tci_tracking_video_block' ),1240 ) );1241 1242 1212 1243 1213 register_block_type( … … 1257 1227 ) 1258 1228 ); 1259 1260 1261 register_block_type( 1262 'thron/embed', 1263 array( 1264 'attributes' => array( 1265 'contentID' => array( 1266 'type' => 'string', 1267 'default' => false, 1268 ), 1269 'embedCode' => array( 1270 'type' => 'string', 1271 'default' => false, 1272 ), 1273 ), 1274 'render_callback' => array( $this, 'render_block_embed_alt' ), 1275 ) 1276 ); 1277 1278 } 1229 } 1230 1231 1232 1233 function thron_add_tracking_class( $class ){ 1234 1235 $class .= ' tci'; 1236 return $class; 1237 1238 } 1239 1240 1241 1279 1242 1280 1243 function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ) { … … 1326 1289 } 1327 1290 1328 private function process_video_audio_class( $matches ) {1329 1330 return $matches[1] . ' class="tci" ' . $matches[2] ;1331 }1332 1291 1333 1292 function render_block_embed( $attr ) { 1334 return do_shortcode( '[thron contentID="' . $attr['contentID'] . '" embedCodeId= "' . $attr['embedCode'] . '"]' ); 1335 } 1336 1337 function render_block_embed_alt( $attr ) { 1338 return do_shortcode( '[thron contentID="' . $attr['contentID'] . '" embedCodeId= "' . $attr['embedCode'] . '"]' ); 1339 } 1293 return do_shortcode( '[thron contentID="' . $attr['contentID'] . 1294 '" scalemode= "' . $attr['scalemode'] . '"'. 1295 ($attr['scalemode'] == 'manual' ? '" cropx= "' . $attr['cropx'] . '" cropy= "' . $attr['cropy'] . '" cropw= "' . $attr['cropw'] . '" croph= "' . $attr['croph'] . '"' : ''). 1296 '" quality= "' . $attr['quality'] . '"'. 1297 '" brightness= "' . $attr['brightness'] . '"'. 1298 '" contrast= "' . $attr['contrast'] . '"'. 1299 '" sharpness= "' . $attr['sharpness'] . '"'. 1300 '" color= "' . $attr['color'] . '"'. 1301 '" embedCodeId= "' . $attr['embedCode'] . '"]' ); 1302 } 1303 1304 1305 /** 1306 * OVERRIDING TEMPLATE MEDIA MODAL 1307 */ 1308 public function ws_add_media_overrides($args) { 1309 ?> 1310 <script type="text/html" id="tmpl-uploader-inline-custom"> 1311 1312 <# var messageClass = data.message ? 'has-upload-message' : 'no-upload-message'; #> 1313 <# if ( data.canClose ) { #> 1314 <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close uploader' ); ?></span></button> 1315 <# } #> 1316 <div class="uploader-inline-content {{ messageClass }}"> 1317 <# if ( data.message ) { #> 1318 <h2 class="upload-message">{{ data.message }}</h2> 1319 <# } #> 1320 <?php if ( ! _device_can_upload() ) : ?> 1321 <div class="upload-ui"> 1322 <h2 class="upload-instructions"><?php _e( 'Your browser cannot upload files' ); ?></h2> 1323 <p> 1324 <?php 1325 printf( 1326 /* translators: %s: https://apps.wordpress.org/ */ 1327 __( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ), 1328 'https://apps.wordpress.org/' 1329 ); 1330 ?> 1331 </p> 1332 </div> 1333 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?> 1334 <div class="upload-ui"> 1335 <h2 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h2> 1336 <?php 1337 /** This action is documented in wp-admin/includes/media.php */ 1338 do_action( 'upload_ui_over_quota' ); 1339 ?> 1340 </div> 1341 <?php else : ?> 1342 <div class="upload-ui"> 1343 <h2 class="upload-instructions drop-instructions"><?php _e( 'Drop files to upload' ); ?></h2> 1344 <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> 1345 <button type="button" class="browser button button-hero"><?php _e( 'Select Files' ); ?></button> 1346 </div> 1347 1348 <div class="upload-inline-status"></div> 1349 1350 <div class="post-upload-ui"> 1351 <?php 1352 /** This action is documented in wp-admin/includes/media.php */ 1353 do_action( 'pre-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 1354 /** This action is documented in wp-admin/includes/media.php */ 1355 do_action( 'pre-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 1356 1357 if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) { 1358 /** This action is documented in wp-admin/includes/media.php */ 1359 do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 1360 add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); 1361 } else { 1362 /** This action is documented in wp-admin/includes/media.php */ 1363 do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 1364 } 1365 1366 $max_upload_size = wp_max_upload_size(); 1367 if ( ! $max_upload_size ) { 1368 $max_upload_size = 0; 1369 } 1370 ?> 1371 1372 <p class="max-upload-size"> 1373 <?php 1374 printf( 1375 /* translators: %s: Maximum allowed file size. */ 1376 __( 'Maximum upload file size: %s.' ), 1377 esc_html( size_format( $max_upload_size ) ) 1378 ); 1379 ?> 1380 </p> 1381 1382 <br/> 1383 <p class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p> 1384 <a type="button" href="https://<?=$this->thron_options['thron_clientId']?>.thron.com/#/contents/category/<?= $this->thron_options['thron_list_folder']; ?>" target="_blank" class="button button-hero thron-upload-button"><?=__( 'Upload the content in THRON' )?></a> 1385 1386 <# if ( data.suggestedWidth && data.suggestedHeight ) { #> 1387 <p class="suggested-dimensions"> 1388 <?php 1389 /* translators: 1: Suggested width number, 2: Suggested height number. */ 1390 printf( __( 'Suggested image dimensions: %1$s by %2$s pixels.' ), '{{data.suggestedWidth}}', '{{data.suggestedHeight}}' ); 1391 ?> 1392 </p> 1393 <# } #> 1394 1395 <?php 1396 /** This action is documented in wp-admin/includes/media.php */ 1397 do_action( 'post-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 1398 ?> 1399 </div> 1400 <?php endif; ?> 1401 </div> 1402 </script> 1403 1404 1405 1406 1407 1408 <script type="text/html" id="tmpl-attachment-details-two-column-custom"> 1409 <div class="attachment-media-view {{ data.orientation }}"> 1410 <h2 class="screen-reader-text"><?php _e( 'Attachment Preview' ); ?></h2> 1411 <div class="thumbnail thumbnail-{{ data.type }}"> 1412 1413 <?php //print_r($this->thron_options) 1414 1415 /*print_r($args); $thron_id = get_post_meta($args['id'],'thron_id',true);*/ ?> 1416 1417 <# var u = data.url.split('/') 1418 //console.log(u) 1419 if ( data.uploading ) { #> 1420 <div class="media-progress-bar"><div></div></div> 1421 <# } else if ( data.sizes && data.sizes.large ) { #> 1422 <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" alt="" /> 1423 <# } else if ( data.sizes && data.sizes.full ) { #> 1424 <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" alt="" /> 1425 <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #> 1426 <img class="details-image icon" src="{{ data.icon }}" draggable="false" alt="" /> 1427 <# } #> 1428 1429 <# if ( 'audio' === data.type ) { #> 1430 <div class="wp-media-wrapper wp-audio"> 1431 <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none"> 1432 <source type="{{ data.mime }}" src="{{ data.url }}"/> 1433 </audio> 1434 </div> 1435 <# } else if ( 'video' === data.type ) { 1436 var w_rule = ''; 1437 if ( data.width ) { 1438 w_rule = 'width: ' + data.width + 'px;'; 1439 } else if ( wp.media.view.settings.contentWidth ) { 1440 w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;'; 1441 } 1442 #> 1443 <div style="{{ w_rule }}" class="wp-media-wrapper wp-video"> 1444 <video controls="controls" class="wp-video-shortcode" preload="metadata" 1445 <# if ( data.width ) { #>width="{{ data.width }}"<# } #> 1446 <# if ( data.height ) { #>height="{{ data.height }}"<# } #> 1447 <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>> 1448 <source type="{{ data.mime }}" src="{{ data.url }}"/> 1449 </video> 1450 </div> 1451 <# } #> 1452 1453 <div class="attachment-actions"> 1454 <# if ( 'image' === data.type && ! data.uploading && data.sizes && data.can.save ) { #> 1455 <# var client_info = u[2].split('-'); 1456 if(client_info[0] != '<?=$this->thron_options['thron_clientId']?>') { #> 1457 <button type="button" class="button edit-attachment"><?php _e( 'Edit Image' ); ?></button> 1458 <# }else{ #> 1459 <a type="button" href="https://<?=$this->thron_options['thron_clientId']?>.thron.com/#/contents/content/{{u[7]}}" target="_blank" class="button button-hero thron-upload-button"><?=__( 'Edit image on THRON', 'thron' )?></a> 1460 <# } #> 1461 <div> 1462 <?php 1463 // print_r($this->thron_options); 1464 ?> 1465 </div> 1466 <# } else if ( 'pdf' === data.subtype && data.sizes ) { #> 1467 <p><?php _e( 'Document Preview' ); ?></p> 1468 <# } #> 1469 </div> 1470 </div> 1471 </div> 1472 <div class="attachment-info"> 1473 <span class="settings-save-status" role="status"> 1474 <span class="spinner"></span> 1475 <span class="saved"><?php esc_html_e( 'Saved.' ); ?></span> 1476 </span> 1477 <div class="details"> 1478 <h2 class="screen-reader-text"><?php _e( 'Details' ); ?></h2> 1479 <div class="uploaded"><strong><?php _e( 'Uploaded on:' ); ?></strong> {{ data.dateFormatted }}</div> 1480 <div class="uploaded-by"> 1481 <strong><?php _e( 'Uploaded by:' ); ?></strong> 1482 <# if ( data.authorLink ) { #> 1483 <a href="{{ data.authorLink }}">{{ data.authorName }}</a> 1484 <# } else { #> 1485 {{ data.authorName }} 1486 <# } #> 1487 </div> 1488 <# if ( data.uploadedToTitle ) { #> 1489 <div class="uploaded-to"> 1490 <strong><?php _e( 'Uploaded to:' ); ?></strong> 1491 <# if ( data.uploadedToLink ) { #> 1492 <a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a> 1493 <# } else { #> 1494 {{ data.uploadedToTitle }} 1495 <# } #> 1496 </div> 1497 <# } #> 1498 <div class="filename"><strong><?php _e( 'File name:' ); ?></strong> {{ data.filename }}</div> 1499 <div class="file-type"><strong><?php _e( 'File type:' ); ?></strong> {{ data.mime }}</div> 1500 <div class="file-size"><strong><?php _e( 'File size:' ); ?></strong> {{ data.filesizeHumanReadable }}</div> 1501 <# if ( 'image' === data.type && ! data.uploading ) { #> 1502 <# if ( data.width && data.height ) { #> 1503 <div class="dimensions"><strong><?php _e( 'Dimensions:' ); ?></strong> 1504 <?php 1505 /* translators: 1: A number of pixels wide, 2: A number of pixels tall. */ 1506 printf( __( '%1$s by %2$s pixels' ), '{{ data.width }}', '{{ data.height }}' ); 1507 ?> 1508 </div> 1509 <# } #> 1510 1511 <# if ( data.originalImageURL && data.originalImageName ) { #> 1512 <?php _e( 'Original image:' ); ?> 1513 <a href="{{ data.originalImageURL }}">{{data.originalImageName}}</a> 1514 <# } #> 1515 <# } #> 1516 1517 <# if ( data.fileLength && data.fileLengthHumanReadable ) { #> 1518 <div class="file-length"><strong><?php _e( 'Length:' ); ?></strong> 1519 <span aria-hidden="true">{{ data.fileLength }}</span> 1520 <span class="screen-reader-text">{{ data.fileLengthHumanReadable }}</span> 1521 </div> 1522 <# } #> 1523 1524 <# if ( 'audio' === data.type && data.meta.bitrate ) { #> 1525 <div class="bitrate"> 1526 <strong><?php _e( 'Bitrate:' ); ?></strong> {{ Math.round( data.meta.bitrate / 1000 ) }}kb/s 1527 <# if ( data.meta.bitrate_mode ) { #> 1528 {{ ' ' + data.meta.bitrate_mode.toUpperCase() }} 1529 <# } #> 1530 </div> 1531 <# } #> 1532 1533 <# if ( data.mediaStates ) { #> 1534 <div class="media-states"><strong><?php _e( 'Used as:' ); ?></strong> {{ data.mediaStates }}</div> 1535 <# } #> 1536 1537 <div class="compat-meta"> 1538 <# if ( data.compat && data.compat.meta ) { #> 1539 {{{ data.compat.meta }}} 1540 <# } #> 1541 </div> 1542 </div> 1543 1544 <div class="settings"> 1545 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> 1546 <# if ( 'image' === data.type ) { #> 1547 <span class="setting has-description" data-setting="alt"> 1548 <label for="attachment-details-two-column-alt-text" class="name"><?php _e( 'Alternative Text' ); ?></label> 1549 <input type="text" id="attachment-details-two-column-alt-text" value="{{ data.alt }}" aria-describedby="alt-text-description" {{ maybeReadOnly }} /> 1550 </span> 1551 <p class="description" id="alt-text-description"><?php echo $alt_text_description; ?></p> 1552 <# } #> 1553 <?php if ( post_type_supports( 'attachment', 'title' ) ) : ?> 1554 <span class="setting" data-setting="title"> 1555 <label for="attachment-details-two-column-title" class="name"><?php _e( 'Title' ); ?></label> 1556 <input type="text" id="attachment-details-two-column-title" value="{{ data.title }}" {{ maybeReadOnly }} /> 1557 </span> 1558 <?php endif; ?> 1559 <# if ( 'audio' === data.type ) { #> 1560 <?php 1561 foreach ( array( 1562 'artist' => __( 'Artist' ), 1563 'album' => __( 'Album' ), 1564 ) as $key => $label ) : 1565 ?> 1566 <span class="setting" data-setting="<?php echo esc_attr( $key ); ?>"> 1567 <label for="attachment-details-two-column-<?php echo esc_attr( $key ); ?>" class="name"><?php echo $label; ?></label> 1568 <input type="text" id="attachment-details-two-column-<?php echo esc_attr( $key ); ?>" value="{{ data.<?php echo $key; ?> || data.meta.<?php echo $key; ?> || '' }}" /> 1569 </span> 1570 <?php endforeach; ?> 1571 <# } #> 1572 <span class="setting" data-setting="caption"> 1573 <label for="attachment-details-two-column-caption" class="name"><?php _e( 'Caption' ); ?></label> 1574 <textarea id="attachment-details-two-column-caption" {{ maybeReadOnly }}>{{ data.caption }}</textarea> 1575 </span> 1576 <span class="setting" data-setting="description"> 1577 <label for="attachment-details-two-column-description" class="name"><?php _e( 'Description' ); ?></label> 1578 <textarea id="attachment-details-two-column-description" {{ maybeReadOnly }}>{{ data.description }}</textarea> 1579 </span> 1580 <span class="setting" data-setting="url"> 1581 <label for="attachment-details-two-column-copy-link" class="name"><?php _e( 'File URL:' ); ?></label> 1582 <input type="text" class="attachment-details-copy-link" id="attachment-details-two-column-copy-link" value="{{ data.url }}" readonly /> 1583 <span class="copy-to-clipboard-container"> 1584 <button type="button" class="button button-small copy-attachment-url" data-clipboard-target="#attachment-details-two-column-copy-link"><?php _e( 'Copy URL to clipboard' ); ?></button> 1585 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> 1586 </span> 1587 </span> 1588 <div class="attachment-compat"></div> 1589 </div> 1590 1591 <div class="actions"> 1592 <# if ( data.link ) { #> 1593 <a class="view-attachment" href="{{ data.link }}"><?php _e( 'View attachment page' ); ?></a> 1594 <# } #> 1595 <# if ( data.can.save ) { #> 1596 <# if ( data.link ) { #> 1597 <span class="links-separator">|</span> 1598 <# } #> 1599 <a href="{{ data.editLink }}"><?php _e( 'Edit more details' ); ?></a> 1600 <# } #> 1601 <# if ( ! data.uploading && data.can.remove ) { #> 1602 <# if ( data.link || data.can.save ) { #> 1603 <span class="links-separator">|</span> 1604 <# } #> 1605 <?php if ( MEDIA_TRASH ) : ?> 1606 <# if ( 'trash' === data.status ) { #> 1607 <button type="button" class="button-link untrash-attachment"><?php _e( 'Restore from Trash' ); ?></button> 1608 <# } else { #> 1609 <button type="button" class="button-link trash-attachment"><?php _e( 'Move to Trash' ); ?></button> 1610 <# } #> 1611 <?php else : ?> 1612 <button type="button" class="button-link delete-attachment"><?php _e( 'Delete permanently' ); ?></button> 1613 <?php endif; ?> 1614 <# } #> 1615 </div> 1616 </div> 1617 </script> 1618 1619 <script> 1620 jQuery(document).ready( function($) { 1621 1622 /* 1623 * c.brualdi - 15.02 1624 */ 1625 1626 var uploadUrl = "https://<?=$this->thron_options['thron_clientId']?>.thron.com/#/contents/category/<?= $this->thron_list_folder; ?>"; 1627 1628 // uploader in visualizzazione a griglia 1629 var inlineForm = jQuery('.uploader-inline-content.no-upload-message'); 1630 if (inlineForm.length && !jQuery('#thron-upload').length) { 1631 inlineForm.after('<p id="thron-upload" class="upload-instructions drop-instructions"><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></p><a type="button" href="' + uploadUrl + '" target="_blank" class="button button-hero thron-upload-button"><?=__( 'Upload the content in THRON', 'thron' )?></a><br/><br/><br/>'); 1632 } 1633 1634 // media-new.php 1635 var uploadForm = jQuery('#file-form'); 1636 if (uploadForm.length) { 1637 uploadForm.after('<h2><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?> <a href="' + uploadUrl + '" target="_blank" class="thron-upload-button"><?=__( 'upload the content in THRON', 'thron' )?></a></h2>'); 1638 } 1639 1640 // Modale upload 1641 if( typeof wp.media.view.UploaderInline != 'undefined' ){ 1642 wp.media.view.UploaderInline.prototype.template = wp.media.template( 'uploader-inline-custom' ); 1643 } 1644 1645 // Modale edit image 1646 if( typeof wp.media.view.Attachment.Details.TwoColumn != 'undefined' ){ 1647 wp.media.view.Attachment.Details.TwoColumn.prototype.template = wp.media.template( 'attachment-details-two-column-custom' ); 1648 } 1649 1650 }); 1651 </script> 1652 1653 <?php 1654 } 1655 1656 function ws_add_overrides() { 1657 $args = array ( 1658 'id' => $_GET['item'], // id 1659 ); 1660 1661 add_action( 'admin_footer-post.php', [$this,'ws_add_media_overrides'] ); 1662 add_action( 'admin_footer-media-new.php', [$this,'ws_add_media_overrides'] ); 1663 add_action( 'admin_footer-edit.php', [$this,'ws_add_media_overrides'] ); 1664 add_action( 'admin_footer-upload.php', function() use ( $args ) { 1665 $this->ws_add_media_overrides( $args ); } ); 1666 1667 } 1668 1340 1669 } -
thron/trunk/admin/class-thron-setting.php
r2343564 r2741703 180 180 $thron_options = get_option( 'thron_option_api_page' ); 181 181 182 /*183 * alambertini 202024061455 ::: spostato sopra per evitare ::: array_key_exists() expects parameter 2 to be array, boolean given184 */185 if ( ! is_array( $thron_options ) ) {186 ?>187 <div class="error notice">188 <p><?php _e( 'The connector has not been successfully configured!!', 'thron' ); ?></p>189 </div>190 <?php191 192 return;193 }194 195 182 if (! array_key_exists('thron_maxImageWidth', $thron_options ) or $thron_options['thron_maxImageWidth'] == '' ) { 196 183 $thron_options['thron_maxImageWidth'] = 1920; … … 200 187 201 188 $thron_options = get_option( 'thron_option_api_page' ); 189 190 if ( ! is_array( $thron_options ) ) { 191 ?> 192 <div class="error notice"> 193 <p><?php _e( 'The connector has not been successfully configured!!', 'thron' ); ?></p> 194 </div> 195 <?php 196 197 return; 198 } 199 202 200 203 201 $clientId = $thron_options['thron_clientId']; -
thron/trunk/admin/css/thron-admin.css
r2343564 r2741703 1 1 #wp-media-grid #media-attachment-thron-tags-filter, 2 2 #wp-media-grid #media-attachment-thron-folders-filter { 3 display: none !important;3 display: none; 4 4 } 5 5 6 6 /* Add Media fix style - style duplicato se si vuole personalizzare una sola area*/ 7 7 8 .media-modal #media-attachment-date-filters { 8 9 display: none; 9 10 } 10 11 12 /* 11 13 .media-modal .attachments-browser .media-toolbar { 12 position: absolute;14 position: absolute; 13 15 right: 300px; 14 16 top: 0; 15 17 display: flex; 16 18 justify-content: space-between; 17 height: 110px;18 19 max-height: 250px; 19 overflow: auto; 20 } 21 22 .media-modal .attachments-browser .attachments { 23 position: absolute; 24 top: 125px; 25 left: 0; 26 right: 300px; 27 bottom: 0; 28 overflow: auto; 29 outline: 0; 20 overflow: auto; 21 height: 120px; 22 } 23 24 .wsthron .attachments-browser .media-toolbar { 25 padding-top: 30px; 30 26 } 31 27 32 28 .media-modal .media-toolbar-secondary { 33 display: flex;34 justify-content: flex-start;35 width: 80%;36 flex-wrap: wrap;37 }38 39 .media-modal .media-modal-content .media-frame select.attachment-filters {40 margin-top: 10px !important;41 width: 30%;42 max-width: none;43 }44 45 .media-modal .media-attachments-filter-heading {46 display: none;47 }48 49 .media-modal .media-frame select,50 .media-modal .wp-admin .media-frame select,51 .media-modal .media-frame input[type=search],52 .media-modal .media-frame input[type=number] {53 min-height: 20px;54 font-size: 12px;55 max-height: 26px;56 }57 58 /* fine style Add media wordpress */59 60 .wsthron #media-attachment-date-filters {61 display: none;62 }63 64 .wsthron .media-modal-content .media-frame select.attachment-filters {65 /* max-width: -webkit-calc(33% - 12px);66 max-width: calc(33% - 12px); */67 }68 69 .wsthron .attachments-browser .media-toolbar {70 height: 120px !important;71 }72 .wsthron .attachments-browser .attachments {73 top: 120px !important;74 }75 76 .wsthron .media-modal-content .media-frame select.attachment-filters {77 margin-top: 10px !important;78 width: 30%;79 max-width: none;80 }81 82 .wsthron .attachments-browser .media-toolbar,83 .wsthron .attachments-browser .uploader-inline {84 padding-top: 30px;85 }86 87 88 .wsthron #thron_bar .media-uploader-status div {89 margin-bottom: 15px;90 }91 92 .wsthron #thron_bar .media-uploader-status label {93 margin-bottom: 10px;94 font-weight: bold;95 display: block;96 }97 98 .wsthron .thron_attachments_preview {99 padding-top: 10px;100 }101 102 103 104 /* app takes the whole page */105 .wsthron #thron_list {106 29 display: flex; 107 flex-wrap: wrap; 108 justify-content: flex-start; 109 } 110 111 112 .wsthron #thron_app .td-content-grid { 30 justify-content: flex-start; 31 width: 80%; 32 flex-wrap: wrap; 33 }*/ 34 35 36 /*.media-modal .attachments-browser .attachments { 113 37 position: absolute; 114 top: 1 60px;38 top: 125px; 115 39 left: 0; 116 40 right: 300px; … … 118 42 overflow: auto; 119 43 outline: 0; 120 } 121 122 .wsthron #thron_app .td-content-grid { 123 width: auto; 124 } 125 126 127 /* margins and height */ 128 .wsthron #thron_app #thron_list .content { 129 margin: 6px; 130 height: 150px; 131 width: 150px; 132 overflow: hidden; 133 position: relative; 134 flex-wrap: wrap; 135 /* flex-grow: 1; */ 136 flex: calc((100%/6) - 12px); 137 max-width: calc((100%/6) - 12px); 138 } 139 140 @media (max-width: 1600px) { 141 .wsthron #thron_app #thron_list .content { 142 flex: calc((100%/5) - 12px); 143 max-width: calc((100%/5) - 12px); 144 } 145 } 146 147 @media (max-width: 1024px) { 148 .wsthron #thron_app #thron_list .content { 149 flex: calc((100%/3) - 12px); 150 max-width: calc((100%/3) - 12px); 151 } 152 } 153 154 /* cursor */ 155 .wsthron #thron_list .content, 156 .wsthron .content * { 157 cursor: pointer; 158 } 44 }*/ 45 46 .media-modal .media-modal-content .media-frame select.attachment-filters { 47 margin-top: 10px !important; 48 width: 30%; 49 max-width: none; 50 } 51 52 .media-modal .media-attachments-filter-heading { 53 display: none; 54 } 55 56 .media-modal .media-frame select, 57 .media-modal .wp-admin .media-frame select, 58 .media-modal .media-frame input[type=search], 59 .media-modal .media-frame input[type=number] { 60 min-height: 20px; 61 font-size: 12px; 62 max-height: 26px; 63 } 64 65 .wsthron #media-attachment-date-filters { 66 display: none; 67 } 68 69 .wsthron .attachments-browser .attachments { 70 top: 120px !important; 71 } 72 73 .wsthron .media-modal-content .media-frame select.attachment-filters { 74 margin-top: 10px !important; 75 width: 30%; 76 max-width: none; 77 } 78 79 .wsthron .attachments-browser .uploader-inline { 80 padding-top: 30px; 81 } 82 83 .wsthron #thron_bar .media-uploader-status div { 84 margin-bottom: 15px; 85 } 86 87 .wsthron #thron_bar .media-uploader-status label { 88 margin-bottom: 10px; 89 font-weight: bold; 90 display: block; 91 } 92 93 .wsthron .thron_attachments_preview { 94 padding-top: 10px; 95 } 96 159 97 160 98 /* selection border and overlay */ 99 161 100 .wsthron .content.item-selected { 162 101 box-shadow: 0 0 0 2px #f39900; 163 background-color: black;102 background-color: black; 164 103 } 165 104 166 105 /* selection overlay opacity */ 106 167 107 .wsthron .content.item-selected img { 168 108 opacity: 0.8; … … 170 110 171 111 /* show label when selected */ 112 172 113 .wsthron .content.item-selected .label { 173 114 display: flex; 174 115 } 175 116 176 /* image: fill wrapper (absolute is needed for padding "trick") */177 .wsthron #thron_list .content {178 179 }180 181 117 /* image wrapper: use padding to force aspect ratio */ 118 182 119 .wsthron .content .img-wrapper { 183 120 position: relative; … … 186 123 } 187 124 188 .wsthron .content.selected { 189 border: 7px solid #0073aa; 125 /* checkbox margin */ 126 127 .wsthron input[type="checkbox"] { 128 margin-right: 5px; 129 } 130 131 .wsthron .media-uploader-status { 132 padding: 16px 0px; 133 } 134 135 .wsthron .sidebar_img-dimension { 136 display: flex; 137 flex-wrap: wrap; 138 justify-content: flex-start; 139 } 140 141 .wsthron .dimension_separator { 142 font-weight: bold; 143 line-height: 30px; 144 margin: 0 10px; 145 } 146 147 .wsthron #thron-player-width, 148 .wsthron #thron-player-height { 149 flex: 0 0 30%; 150 max-width: 40%; 151 } 152 153 .wsthron .spinner { 154 position: absolute; 155 right: 0; 156 z-index: 999999; 157 } 158 159 .thronButton { 160 /*tobe changed asap */ 161 height: 48px; 162 } 163 164 .thronText { 165 box-shadow: 0 0 0 transparent !important; 166 border-radius: 0px !important; 167 border-left: 0px solid #7e8993 !important; 168 border-right: 0px solid #7e8993 !important; 169 border-top: 1px solid #000 !important; 170 border-bottom: 1px solid #000 !important; 171 background-color: #fff !important; 172 color: #000 !important; 173 height: 48px; 174 width: 120px; 175 } 176 177 /* Griglia elelemento*/ 178 179 .th-player.th-image:hover .th-wrapper-grid, 180 .th-player.th-image.th-user-active .th-wrapper-grid { 181 display: grid; 182 } 183 184 /*generazione griglia*/ 185 186 .th-player.th-image .th-wrapper-grid { 187 /*display: grid;*/ 188 display: none; 189 grid-template-columns: 33% 33% auto; 190 grid-gap: 1px; 191 background-color: trasparent; 192 color: #444; 193 position: absolute !important; 194 width: 100%; 195 height: 100%; 196 top: 0; 197 pointer-events: none; 198 } 199 200 /*singoli blocchi*/ 201 202 .th-player.th-image .th-wrapper-grid .th-wrapper-grid-box { 203 display: inline-block; 204 height: 100%; 205 width: 100%; 206 border: 2px solid #fff !important; 207 border-left-width: 0 !important; 208 border-top-width: 0 !important; 209 } 210 211 /*rimozione tasto FS*/ 212 213 .th-player.th-image .th-fullscreen-button, 214 .th-player.th-image .th-text-zoom { 215 display: none !important; 216 } 217 218 /*Link verso thron.com*/ 219 220 a.thron-upload-button:hover { 221 opacity: 0.8; 222 } 223 224 a.thron-upload-button { 225 color: #F39900; 226 } 227 228 a.button.button-hero.thron-upload-button { 229 color: #fff; 230 background-color: #f39900; 231 cursor: pointer; 232 text-decoration: none; 233 font-weight: 600; 234 -webkit-border-radius: 30px; 235 -moz-border-radius: 30px; 236 border-radius: 30px; 237 -webkit-box-shadow: 0px 1px 5px 0px rgb(0 0 0 / 20%); 238 -moz-box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.2); 239 box-shadow: 0px 1px 5px 0px rgb(0 0 0 / 20%); 240 border: 0px; 241 font-size: 15px; 242 height: 40px; 243 width: auto; 244 opacity: 1; 245 } 246 247 a.button.button-hero.thron-upload-button:hover { 248 opacity: 0.8; 249 } 250 251 .th_overlay { 252 display: none; 253 } 254 255 .test { 256 display: block 257 } 258 259 /* 260 NEW 261 */ 262 263 /* 264 MEDIA THRON 265 */ 266 .media-thron { 267 display: flex; 268 align-items: stretch; 269 height: 100%; 270 overflow: hidden; 271 } 272 273 /* 274 THRON CONTENT 275 */ 276 #thron_content { 277 display: flex; 278 flex-direction: column; 279 max-height: 100%; 280 } 281 282 #thron_content.thron-block { 283 max-height: calc(100% - 110px); 284 } 285 286 .media-thron #thron_content { 287 flex: 1 0 calc(100% - 267px); 288 min-height: 100%; 289 } 290 291 /* 292 THRON TOOLBAR 293 */ 294 #thron_toolbar { 295 /* 296 position: absolute; 297 right: 300px; 298 top: 0; 299 */ 300 flex: 0 0 auto; 301 height: auto; 190 302 box-sizing: border-box; 191 } 192 193 .wsthron .content.selected .label .thron-type { 194 top: 25%; 195 left: 25%; 196 } 197 198 /* label styling: ellipsis, positioning, width, etc... */ 199 .wsthron .content .label { 200 display: none; 201 202 } 203 204 /* show label when hovered */ 205 .wsthron .content:hover .label { 206 display: flex; 207 } 208 209 /* more label styling */ 210 .wsthron .content .label span { 211 text-overflow: ellipsis; 212 overflow: hidden; 213 white-space: nowrap; 214 width: calc(100% - 20px); 215 } 216 217 .wsthron .content .label .thron-type { 218 width: 60px; 219 height: 60px; 303 position: relative; 304 width: 100%; 305 border: 0 solid #ddd; 306 overflow: hidden; 307 background: white; 308 z-index: 10000; 309 padding: 0 10px; 310 } 311 312 @media (min-width: 768px) { 313 #thron_toolbar { 314 display: flex; 315 justify-content: space-between; 316 } 317 } 318 319 #thron_toolbar .media-toolbar-secondary { 320 display: flex; 321 justify-content: flex-start; 322 flex-wrap: wrap; 323 flex: 1 1 75%; 324 padding-top: 32px; 325 height: auto; 326 } 327 328 #thron_toolbar .media-toolbar-secondary__label { 220 329 position: absolute; 221 top: 25%; 222 left: 30%; 223 } 224 225 .thron-type[data-value="URL"] { 226 background: url('./../img/thumbnails-icons.png'); 227 background-position: -140px 283px; 228 } 229 230 .thron-type[data-value="PAGELET"] { 231 background: url('./../img/thumbnails-icons.png'); 232 background-position: -5px 215px; 233 } 234 235 .thron-type[data-value="IMAGE"] { 236 background: url('./../img/thumbnails-icons.png'); 237 background-position: 308px 214px; 238 } 239 240 .thron-type[data-value="VIDEO"] { 241 background: url('./../img/thumbnails-icons.png'); 242 background-position: -5px 283px; 243 } 244 245 .thron-type[data-value="AUDIO"] { 246 background: url('./../img/thumbnails-icons.png'); 247 background-position: -5px -3px; 248 } 249 250 .thron-type[data-value="PLAYLIST"] { 251 background: url('./../img/thumbnails-icons.png'); 252 background-position: 240px 214px; 253 } 254 255 .thron-type[data-value="OTHER"] { 256 background: url('./../img/thumbnails-icons.png'); 257 background-position: 3px 83px; 258 } 259 260 .wsthron .content .label .thron-extension { 330 top: 0; 331 } 332 333 #thron_toolbar .media-toolbar-primary { 334 position: relative; 335 flex: 1 1 25%; 336 float: none; 337 } 338 339 #thron_toolbar .media-toolbar-primary .search { 340 min-height: 30px!important; 341 margin: 0 0 10px 0!important; 342 } 343 344 #thron_toolbar .media-toolbar-primary .media-search-input-label { 345 display: block; 346 margin: 0 0 5px 0; 347 } 348 349 @media (min-width: 768px) { 350 #thron_toolbar .media-toolbar-primary { 351 display: flex; 352 justify-content: flex-end; 353 align-items: center; 354 } 355 356 #thron_toolbar .media-toolbar-primary .search { 357 margin: 0 0 10px 5px!important; 358 } 359 360 #thron_toolbar .media-toolbar-primary .media-search-input-label { 361 margin: 0 0 10px; 362 } 363 364 .media-frame #thron_toolbar .media-toolbar-primary { 365 display: block; 366 padding-top: 32px; 367 } 368 369 .media-frame #thron_toolbar .media-toolbar-primary .search { 370 margin: 0 0 10px 5px!important; 371 } 372 } 373 374 #thron_toolbar select.attachment-filters { 375 margin-top: 0; 376 max-width: none; 377 margin: 0 10px 10px 0!important; 378 line-height: 2; 379 max-height: 30px; 380 font-size: 14px; 381 min-height: 30px!important; 382 padding: 0 24px 0 8px!important; 383 /* width: calc(25% - 10px); */ 384 } 385 386 .thron-block #thron_toolbar .media-toolbar-secondary, 387 .thron-block #thron_toolbar .media-toolbar-primary { 388 padding-top: 10px; 389 } 390 391 .thron-block #thron_toolbar #media-search-input { 392 font-size: 14px; 393 line-height: 2; 394 color: #32373c; 395 border: 1px solid #7e8993; 396 box-shadow: none; 397 border-radius: 3px; 398 padding: 0 8px; 399 min-height: 30px; 400 max-width: 25rem; 401 appearance: none; 402 } 403 404 /* 405 MEDIA SIDEBAR 406 */ 407 #thron_bar { 408 box-sizing: border-box; 409 position: relative; 410 flex: 0 0 267px; 411 width: 267px; 412 padding: 0 16px; 413 overflow: auto; 414 } 415 416 #thron_bar .media-uploader-status div { 417 margin-bottom: 15px; 418 } 419 420 #thron_bar .media-uploader-status label { 421 margin-bottom: 10px; 422 font-weight: bold; 423 display: block; 424 } 425 426 /* 427 THRON LIST 428 */ 429 #thron_list { 430 box-sizing: border-box; 431 flex: 0 1 auto; 432 position: relative; 433 display: flex; 434 flex-wrap: wrap; 435 justify-content: flex-start; 436 width: 100%; 437 overflow-x: hidden; 438 overflow-y: auto; 439 outline: 0; 440 } 441 442 #thron_list .empty-results { 443 text-align: center; 444 width: 100%; 445 border-top: 1px solid #ccc; 446 padding: 20px 0; 447 } 448 449 #thron_list .content { 450 flex: 1 1 100%; 451 max-width: 100%; 452 } 453 454 @media (min-width: 600px) { 455 #thron_list .content { 456 flex: 1 1 calc((100%/2) - 12px); 457 max-width: calc((100%/2) - 12px); 458 } 459 } 460 461 @media (min-width: 800px) { 462 #thron_list .content { 463 flex: 1 1 calc((100%/3) - 12px); 464 max-width: calc((100%/3) - 12px); 465 } 466 } 467 468 @media (min-width: 901px) { 469 #thron_list .content { 470 flex: 1 1 calc((100%/2) - 12px); 471 max-width: calc((100%/2) - 12px); 472 } 473 } 474 475 @media (min-width: 1024px) { 476 #thron_list .content { 477 flex: 1 1 calc((100%/3) - 12px); 478 max-width: calc((100%/3) - 12px); 479 } 480 } 481 482 @media (min-width: 1200px) { 483 #thron_list .content { 484 flex: 1 1 calc((100%/4) - 12px); 485 max-width: calc((100%/4) - 12px); 486 } 487 } 488 489 @media (min-width: 1300px) { 490 #thron_list .content { 491 flex: 1 1 calc((100%/5) - 12px); 492 max-width: calc((100%/5) - 12px); 493 } 494 } 495 496 @media (min-width: 1400px) { 497 #thron_list .content { 498 flex: 1 1 calc((100%/6) - 12px); 499 max-width: calc((100%/6) - 12px); 500 } 501 } 502 503 @media (min-width: 1600px) { 504 #thron_list .content { 505 flex: 1 1 calc((100%/7) - 12px); 506 max-width: calc((100%/7) - 12px); 507 } 508 } 509 510 @media (min-width: 1920px) { 511 #thron_list .content { 512 flex: 1 1 calc((100%/9) - 12px); 513 max-width: calc((100%/9) - 12px); 514 } 515 } 516 517 /* 518 THRON BLOCK 519 */ 520 @media (min-width: 600px) { 521 .thron-block #thron_list .content { 522 flex: 1 1 calc((100%/2) - 12px); 523 max-width: calc((100%/2) - 12px); 524 } 525 } 526 527 @media (min-width: 800px) { 528 .thron-block #thron_list .content { 529 flex: 1 1 calc((100%/3) - 12px); 530 max-width: calc((100%/3) - 12px); 531 } 532 } 533 534 @media (min-width: 1024px) { 535 .thron-block #thron_list .content { 536 flex: 1 1 calc((100%/5) - 12px); 537 max-width: calc((100%/5) - 12px); 538 } 539 } 540 541 @media (min-width: 1200px) { 542 .thron-block #thron_list .content { 543 flex: 1 1 calc((100%/6) - 12px); 544 max-width: calc((100%/6) - 12px); 545 } 546 } 547 548 @media (min-width: 1300px) { 549 .thron-block #thron_list .content { 550 flex: 1 1 calc((100%/7) - 12px); 551 max-width: calc((100%/7) - 12px); 552 } 553 } 554 555 @media (min-width: 1400px) { 556 .thron-block #thron_list .content { 557 flex: 1 1 calc((100%/8) - 12px); 558 max-width: calc((100%/8) - 12px); 559 } 560 } 561 562 @media (min-width: 1600px) { 563 .thron-block #thron_list .content { 564 flex: 1 1 calc((100%/9) - 12px); 565 max-width: calc((100%/9) - 12px); 566 } 567 } 568 569 @media (min-width: 1920px) { 570 .thron-block #thron_list .content { 571 flex: 1 1 calc((100%/11) - 12px); 572 max-width: calc((100%/11) - 12px); 573 } 574 } 575 576 /* 577 THRON LIST EXPANDED 578 // 579 580 .media-modal.acf-expanded #thron_list { 581 right: 740px; 582 } 583 584 @media (max-width: 1599px) { 585 .media-modal.acf-expanded #thron_list .content { 586 flex: 1 1 100%; 587 max-width: 100%; 588 } 589 } 590 591 @media (min-width: 1600px) { 592 .media-modal.acf-expanded #thron_list .content { 593 flex: 1 1 calc((100%/2) - 12px); 594 max-width: calc((100%/2) - 12px); 595 } 596 } 597 598 @media (min-width: 1920px) { 599 .media-modal.acf-expanded #thron_list .content { 600 flex: 1 1 calc((100%/4) - 12px); 601 max-width: calc((100%/4) - 12px); 602 } 603 } 604 */ 605 606 /* 607 THRON CONTENT 608 */ 609 #thron_list .content { 610 position: relative; 611 margin: 6px; 612 overflow: hidden; 613 cursor: pointer; 614 } 615 616 #thron_list .content picture { 617 position: relative; 618 display: flex; 619 justify-content: center; 620 align-items: center; 621 padding-bottom: 100%; 622 } 623 624 #thron_list .content picture img { 625 box-sizing: border-box; 261 626 position: absolute; 262 top: 2px; 263 left: 2px; 264 background-color: rgba(0, 0, 0, 0.6); 265 padding: 0px 5px 2px 5px; 266 border-radius: 3px; 267 color: white; 268 margin: 0 10px; 627 width: 100%; 628 height: 100%; 629 top: 0; 630 bottom: 0; 631 left: 0; 632 right: 0; 633 object-fit: cover; 634 } 635 636 #thron_list .content.selected picture img { 637 border: 5px solid #0073aa; 638 } 639 640 #thron_list .content .label { 641 display: none; 642 } 643 644 #thron_list .content:hover .label, 645 #thron_list .content.selected .label { 646 display: block; 647 } 648 649 #thron_list .content .label .thron-extension { 650 box-sizing: border-box; 651 position: absolute; 652 top: 5px; 653 left: 5px; 654 margin: 0; 655 padding: 3px 6px; 656 border-radius: 0; 657 width: auto; 658 max-width: 60px; 269 659 white-space: nowrap; 270 660 text-overflow: ellipsis; 271 661 overflow: hidden; 272 662 user-select: none; 273 align-items: center; 663 font-size: 11px; 664 font-weight: 600; 665 line-height: 1; 666 text-transform: uppercase; 667 background-color: rgba(0, 0, 0, 0.6); 668 color: white; 669 } 670 671 #thron_list .content .label .thron-label { 672 position: absolute; 673 bottom: 5px; 674 left: 5px; 274 675 width: auto; 275 font-size: 12px; 276 } 277 278 .wsthron .content .label .thron-label { 279 position: absolute; 280 bottom: 10px; 281 background-color: rgba(0, 0, 0, 0.6); 282 padding: 5px 10px; 283 border-radius: 3px; 284 color: white; 285 width: calc(100% - 20px); 286 margin: 0 10px; 676 max-width: calc(100% - 20px); 677 margin: 0; 678 padding: 3px 6px; 679 border-radius: 0; 680 box-sizing: border-box; 287 681 white-space: nowrap; 288 682 text-overflow: ellipsis; 289 683 overflow: hidden; 290 684 user-select: none; 291 align-items: center; 292 width: 65%; 293 } 294 295 /* font */ 296 .wsthron .content .label * { 297 font-size: 15px; 298 font-weight: 600; 299 } 300 301 /* checkbox margin */ 302 .wsthron input[type="checkbox"] { 303 margin-right: 5px; 304 } 305 306 307 .wsthron .media-toolbar-secondary { 308 display: flex; 309 justify-content: flex-start; 310 width: 80%; 311 flex-wrap: wrap; 312 } 313 314 .wsthron .media-uploader-status { 315 padding: 16px 0px; 316 } 317 318 .wsthron .sidebar_img-dimension { 319 display: flex; 320 flex-wrap: wrap; 321 justify-content: flex-start; 322 } 323 324 .wsthron .dimension_separator { 325 font-weight: bold; 326 line-height: 30px; 327 margin: 0 10px; 328 } 329 330 .wsthron #thron-player-width, 331 .wsthron #thron-player-height { 332 flex: 0 0 30%; 333 max-width: 40%; 334 } 335 336 .wsthron .spinner { 685 font-size: 14px; 686 font-weight: 600; 687 line-height: 1; 688 text-transform: lowercase; 689 background-color: rgba(0, 0, 0, 0.6); 690 color: white; 691 } 692 693 #thron_list .content .label .thron-type { 337 694 position: absolute; 338 right: 0; 339 z-index: 999999; 340 } 695 width: 60px; 696 height: 60px; 697 top: 50%; 698 left: 50%; 699 margin: -30px 0 0 -30px; 700 } 701 702 .thron-type[data-value="IMAGE"] { 703 background: url('./../img/thumbnails-icons.png'); 704 background-position: 308px 214px; 705 } 706 707 .thron-type[data-value="VIDEO"] { 708 background: url('./../img/thumbnails-icons.png'); 709 background-position: -5px 283px; 710 } 711 712 .thron-type[data-value="AUDIO"] { 713 background: url('./../img/thumbnails-icons.png'); 714 background-position: -5px -3px; 715 } 716 717 .thron-type[data-value="PLAYLIST"] { 718 background: url('./../img/thumbnails-icons.png'); 719 background-position: 240px 214px; 720 } 721 722 .thron-type[data-value="URL"] { 723 background: url('./../img/thumbnails-icons.png'); 724 background-position: 240px 283px; 725 } 726 727 .thron-type[data-value="PAGELET"] { 728 background: url('./../img/thumbnails-icons.png'); 729 background-position: -5px 214px; 730 } 731 732 .thron-type[data-value="OTHER"] { 733 background: url('./../img/thumbnails-icons.png'); 734 background-position: 3px 83px; 735 } 736 737 /* cursor */ 738 #thron_list .content { 739 cursor: pointer; 740 } 741 742 .hasThronImage + [aria-label="Rotate"] { 743 display: none; 744 } 745 746 .hasThronImage + .components-toolbar-group button[aria-label="Rotate"] { 747 display: none; 748 } 749 750 span.components-menu-item__item { 751 min-width: 0px; 752 } -
thron/trunk/admin/css/thron-block.css
r2343564 r2741703 10 10 } 11 11 12 .thron-block-overlay { 13 width: 100%; 14 background: transparent; 15 height: 100%; 16 z-index: 9; 17 position: absolute; 18 left: 0; 19 } 20 12 21 .thron-block-modal .components-modal__content { 13 22 position: relative; … … 18 27 position: relative; 19 28 } 29 20 30 21 31 .thron-block-modal .wsthron-header .media-toolbar { … … 52 62 } 53 63 64 54 65 .thron-block-modal .modal-footer { 55 66 position: absolute; … … 76 87 cursor: default; 77 88 } 78 79 .thron-block-modal .wsthron {80 /* overflow-y: scroll;81 height: 72%; */82 }83 84 .thron-block-modal .wsthron #thron_list {85 display: flex;86 flex-wrap: wrap;87 justify-content: flex-start;88 overflow: auto;89 }90 91 .wsthron .td-content-grid {92 93 width: 100%;94 }95 96 .wsthron .content.selected {97 box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #0073aa;98 }99 100 .wsthron #thron_list .content {101 margin: 6px;102 height: 150px;103 overflow: hidden;104 position: relative;105 flex: calc((100%/10) - 12px);106 max-width: calc((100%/10) - 12px);107 }108 109 110 111 @media (max-width: 1600px) {112 .wsthron #thron_list .content {113 flex: calc((100%/8) - 12px);114 max-width: calc((100%/8) - 12px);115 }116 }117 118 @media (max-width: 1024px) {119 .wsthron #thron_list .content {120 flex: calc((100%/6) - 12px);121 max-width: calc((100%/6) - 12px);122 }123 }124 125 .center{ text-align: center}126 .left{ text-align: left}127 .right{ text-align: right} -
thron/trunk/admin/js/collection-filter.js
r2343564 r2741703 76 76 */ 77 77 var MediaLibraryFoldersFilter = wp.media.view.AttachmentFilters.extend({ 78 79 className:'attachment-filters media-attachment-thron-folders-filter',80 78 id: 'media-attachment-thron-folders-filter', 81 79 … … 85 83 86 84 var props = {}; 87 props['thron_categories'] = ThronTagsList.thron_list_folder;85 props['thron_categories'] = ''; 88 86 89 87 filters.all = { -
thron/trunk/admin/js/thron-admin.js
r2343564 r2741703 1 jQuery(document).ready(function ($) {1 jQuery(document).ready(function($) { 2 2 3 3 $(document).on("change", '#media-attachment-thron-source-filter', function(event) { 4 4 if (this.value == 'local') { 5 $(' .media-attachment-thron-folders-filter').prop('disabled', 'disabled');5 $('#media-attachment-thron-folders-filter').prop('disabled', 'disabled'); 6 6 $('.attachment-filters-tag').prop('disabled', 'disabled'); 7 7 8 8 } else { 9 $(' .media-attachment-thron-folders-filter').prop('disabled', false);9 $('#media-attachment-thron-folders-filter').prop('disabled', false); 10 10 $('.attachment-filters-tag').prop('disabled', false); 11 11 … … 14 14 15 15 }); 16 17 18 const setExtraPropsToBlockType = (props, blockType, attributes) => {19 const notDefined = (typeof props.className === 'undefined' || !props.className) ? true : false20 21 if (blockType.name === 'core/cover') {22 return Object.assign(props, {23 className: notDefined ? ' tci' : 'tci ' + props.className,24 });25 }26 27 return props;28 };29 30 31 if(wp.hooks){32 wp.hooks.addFilter(33 'blocks.getSaveContent.extraProps',34 'your-namespace/block-filters',35 setExtraPropsToBlockType36 );37 } -
thron/trunk/admin/js/thron-block.js
r2304750 r2741703 1 (function (blocks, editor, i18n, element, components, _) {1 (function(blocks, blockEditor, i18n, element, components, _) { 2 2 var el = element.createElement; 3 var InspectorControls = editor.InspectorControls; 3 var InspectorControls = blockEditor.InspectorControls; 4 var DropDownMenu = components.DropdownMenu; 5 var MenuItem = components.MenuItem; 4 6 var PanelBody = components.PanelBody; 5 6 const {select} = wp.data;7 8 function ThronListHeight() { 9 var thron_list = document.getElementById("thron_list");10 var wsthron_header = document.getElementsByClassName("wsthron-header")[0].offsetHeight; 11 var modal_h = document.getElementsByClassName("components-modal__frame")[0].offsetHeight; 12 var modal_header_h = document.getElementsByClassName("components-modal__header")[0].offsetHeight + 24;13 var modal_footer_h = document.getElementsByClassName("modal-footer")[0].offsetHeight;14 thron_list.setAttribute("style", "height:" + parseInt(modal_h - modal_header_h - wsthron_header - modal_footer_h - 10) + "px");15 }16 17 const THRONLogo = el('svg', {width: 20, height: 20, viewBox: '80 80 140 140'},7 var thePlayer = []; 8 var destroy = false; 9 var BlockControls = blockEditor.BlockControls; 10 11 const { select } = wp.data; 12 13 14 const ManualPos = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 15 el('defs', 16 el('style', {}, 17 '.cls-1 {fill-rule: evenodd;}' 18 ) 19 ), 18 20 el('path', { 19 fill: "#F39900", 20 d: "M116.52,117.58c-8.5,8.89-12.84,19.69-12.84,32.38c0,13.03,4.35,23.95,13.06,32.76\n" + 21 "\t\tc8.65,8.86,19.36,13.29,32.12,13.29c12.71,0,23.45-4.43,32.2-13.29c8.76-8.76,13.13-19.57,13.13-32.44\n" + 22 "\t\tc0-13.51-4.53-24.61-13.61-33.31c-8.98-8.66-19.33-13.01-31.08-13.06V86.66c15.83,0,30,5.46,42.55,16.38\n" + 23 "\t\tc13.82,12.08,20.73,27.9,20.73,47.47c0,17.19-6.3,31.96-18.91,44.31c-12.55,12.34-27.64,18.51-45.26,18.51\n" + 24 "\t\tc-17.41,0-32.33-6.23-44.78-18.67c-12.5-12.45-18.75-27.4-18.75-44.86c0-17.57,6.34-32.53,18.89-44.76L116.52,117.58z" 21 id: 'manual_pos', 22 'data-name': 'manual pos', 23 className: 'cls-1', 24 d: 'M263.5,32V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm4.291-11.4v6.4h0.8V39.008L254.02,36.53l1.666,4.97H256.3l1.674-4.988-0.074,2.5V41.5h0.8V35.1h-1.037L256,40.322l-1.67-5.221h-1.037Z', 25 transform: 'translate(-244 -27)' 26 }) 27 ); 28 29 const ManualNeg = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 30 el('defs', 31 el('style', {}, 32 '.cls-1 {fill-rule: evenodd;}' 33 ) 34 ), 35 el('path', { 36 id: 'manual_neg', 37 'data-name': 'manual neg', 38 className: 'cls-1', 39 d: 'M246,27h20a2,2,0,0,1,2,2V49a2,2,0,0,1-2,2H246a2,2,0,0,1-2-2V29A2,2,0,0,1,246,27Zm17.5,5V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm4.291-11.4v6.4h0.8V39.008L254.02,36.53l1.666,4.97H256.3l1.674-4.988-0.074,2.5V41.5h0.8V35.1h-1.037L256,40.322l-1.67-5.221h-1.037Z', 40 transform: 'translate(-244 -27)' 41 }) 42 ); 43 44 45 const AutoPos = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 46 el('defs', 47 el('style', {}, 48 '.cls-1 {fill-rule: evenodd; fill: #1e1e1e; }' 49 ) 50 ), 51 el('path', { 52 id: 'auto_pos', 53 'data-name': 'auto pos', 54 className: 'cls-1', 55 d: 'M263.5,32V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm8.586-5h0.827l-2.066-6.4h-0.69L253.6,41.5h0.826l0.5-1.674h2.162ZM256,36.227l0.875,2.909H255.13Z', 56 transform: 'translate(-244 -27)' 57 }) 58 ); 59 60 const AutoNeg = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 61 el('defs', 62 el('style', {}, 63 '.cls-1 {fill-rule: evenodd;}' 64 ) 65 ), 66 el('path', { 67 id: 'auto_neg', 68 'data-name': 'auto neg', 69 className: 'cls-1', 70 d: 'M246,27h20a2,2,0,0,1,2,2V49a2,2,0,0,1-2,2H246a2,2,0,0,1-2-2V29A2,2,0,0,1,246,27Zm17.5,5V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm8.586-5h0.827l-2.066-6.4h-0.69L253.6,41.5h0.826l0.5-1.674h2.162ZM256,36.227l0.875,2.909H255.13Z', 71 transform: 'translate(-244 -27)' 72 }) 73 ); 74 75 const CenteredPos = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 76 el('defs', 77 el('style', {}, 78 '.cls-1 {fill-rule: evenodd;}' 79 ) 80 ), 81 el('path', { 82 id: 'centered_pos', 83 'data-name': 'centered pos', 84 className: 'cls-1', 85 d: 'M263.5,32V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm8.338-7.035A1.96,1.96,0,0,1,257,40.586a1.154,1.154,0,0,1-.905.312,1.061,1.061,0,0,1-.956-0.519,2.8,2.8,0,0,1-.327-1.49V37.716a2.654,2.654,0,0,1,.351-1.5,1.149,1.149,0,0,1,1.007-.512,1.034,1.034,0,0,1,.844.334,1.981,1.981,0,0,1,.329,1.116h0.813a2.427,2.427,0,0,0-.551-1.586,1.85,1.85,0,0,0-1.435-.554,1.928,1.928,0,0,0-1.589.725,3.066,3.066,0,0,0-.582,1.973v1.16a3.159,3.159,0,0,0,.567,1.984,1.833,1.833,0,0,0,1.529.732,1.958,1.958,0,0,0,1.483-.547,2.371,2.371,0,0,0,.578-1.575h-0.813Z', 86 transform: 'translate(-244 -27)' 87 }) 88 ); 89 90 const CenteredNeg = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 91 el('defs', 92 el('style', {}, 93 '.cls-1 {fill-rule: evenodd;}' 94 ) 95 ), 96 el('path', { 97 id: 'centered_neg', 98 'data-name': 'centered neg', 99 className: 'cls-1', 100 d: 'M246,27h20a2,2,0,0,1,2,2V49a2,2,0,0,1-2,2H246a2,2,0,0,1-2-2V29A2,2,0,0,1,246,27Zm17.5,5V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm8.338-7.035A1.96,1.96,0,0,1,257,40.586a1.154,1.154,0,0,1-.905.312,1.061,1.061,0,0,1-.956-0.519,2.8,2.8,0,0,1-.327-1.49V37.716a2.654,2.654,0,0,1,.351-1.5,1.149,1.149,0,0,1,1.007-.512,1.034,1.034,0,0,1,.844.334,1.981,1.981,0,0,1,.329,1.116h0.813a2.427,2.427,0,0,0-.551-1.586,1.85,1.85,0,0,0-1.435-.554,1.928,1.928,0,0,0-1.589.725,3.066,3.066,0,0,0-.582,1.973v1.16a3.159,3.159,0,0,0,.567,1.984,1.833,1.833,0,0,0,1.529.732,1.958,1.958,0,0,0,1.483-.547,2.371,2.371,0,0,0,.578-1.575h-0.813Z', 101 transform: 'translate(-244 -27)' 102 }) 103 ); 104 105 const ProductPos = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 106 el('defs', 107 el('style', {}, 108 '.cls-1 {fill-rule: evenodd;}' 109 ) 110 ), 111 el('path', { 112 id: 'product_pos', 113 'data-name': 'product pos', 114 className: 'cls-1', 115 d: 'M263.5,32V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm7.292-7.5a1.878,1.878,0,0,0,1.369-.516,2.278,2.278,0,0,0-.024-2.843,1.846,1.846,0,0,0-1.4-.534H254.2v6.4H255V39h1.292ZM255,35.792h1.24a1,1,0,0,1,.808.348,1.385,1.385,0,0,1,.3.924,1.343,1.343,0,0,1-.286.92,1.042,1.042,0,0,1-.822.321H255V35.792Z', 116 transform: 'translate(-244 -27)' 117 }) 118 ); 119 120 const ProductNeg = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24' }, 121 el('defs', 122 el('style', {}, 123 '.cls-1 {fill-rule: evenodd;}' 124 ) 125 ), 126 el('path', { 127 id: 'product_neg', 128 'data-name': 'product neg', 129 className: 'cls-1', 130 d: 'M246,27h20a2,2,0,0,1,2,2V49a2,2,0,0,1-2,2H246a2,2,0,0,1-2-2V29A2,2,0,0,1,246,27Zm17.5,5V43H265V32a2.006,2.006,0,0,0-2-2H252v1.5h11A0.472,0.472,0,0,1,263.5,32ZM249,46.5a0.472,0.472,0,0,1-.5-0.5V27H247v3h-3v1.5h3V46a2.006,2.006,0,0,0,2,2h14.5v3H265V48h3V46.5H249Zm7.292-7.5a1.878,1.878,0,0,0,1.369-.516,2.278,2.278,0,0,0-.024-2.843,1.846,1.846,0,0,0-1.4-.534H254.2v6.4H255V39h1.292ZM255,35.792h1.24a1,1,0,0,1,.808.348,1.385,1.385,0,0,1,.3.924,1.343,1.343,0,0,1-.286.92,1.042,1.042,0,0,1-.822.321H255V35.792Z', 131 transform: 'translate(-244 -27)' 132 }) 133 ); 134 135 136 const THRONLogo = el('svg', { width: 20, height: 20, viewBox: '80 80 140 140' }, 137 el('path', { 138 fill: '#F39900', 139 d: 'M116.52,117.58c-8.5,8.89-12.84,19.69-12.84,32.38c0,13.03,4.35,23.95,13.06,32.76\n' + 140 '\t\tc8.65,8.86,19.36,13.29,32.12,13.29c12.71,0,23.45-4.43,32.2-13.29c8.76-8.76,13.13-19.57,13.13-32.44\n' + 141 '\t\tc0-13.51-4.53-24.61-13.61-33.31c-8.98-8.66-19.33-13.01-31.08-13.06V86.66c15.83,0,30,5.46,42.55,16.38\n' + 142 '\t\tc13.82,12.08,20.73,27.9,20.73,47.47c0,17.19-6.3,31.96-18.91,44.31c-12.55,12.34-27.64,18.51-45.26,18.51\n' + 143 '\t\tc-17.41,0-32.33-6.23-44.78-18.67c-12.5-12.45-18.75-27.4-18.75-44.86c0-17.57,6.34-32.53,18.89-44.76L116.52,117.58z' 25 144 }), 26 145 el('path', { 27 fill: "#848587",28 d: "M103.97,105.04c12.64-12.24,27.76-18.36,45.54-18.38v17.25c-13,0-23.81,4.43-32.62,13.29c-0.12,0.13-0.17,0.25-0.37,0.38L103.97,105.04z"146 fill: '#848587', 147 d: 'M103.97,105.04c12.64-12.24,27.76-18.36,45.54-18.38v17.25c-13,0-23.81,4.43-32.62,13.29c-0.12,0.13-0.17,0.25-0.37,0.38L103.97,105.04z' 29 148 }) 30 149 ); 150 151 const CropIcon = el('svg', { width: 24, height: 24, viewBox: '0 0 24 24', role: 'img', focusable: 'false' }, 152 el('path', { 153 d: 'M17.5 7v8H19V7c0-1.1-.9-2-2-2H9v1.5h8c.3 0 .5.2.5.5zM7 17.5c-.3 0-.5-.2-.5-.5V1H5v4H1v1.5h4V17c0 1.1.9 2 2 2h10.5v4H19v-4h4v-1.5H7z' 154 }) 155 ); 156 157 const initialCropIcon = function(props) { 158 switch (props.attributes.scalemode) { 159 case 'auto': 160 return AutoPos; 161 case 'centered': 162 return CenteredPos; 163 case 'product': 164 return ProductPos; 165 case 'manual': 166 return ManualPos; 167 default: 168 return CropIcon; 169 } 170 } 171 172 function cropOps(args, props) { 173 var transform = document.querySelector('#thron-preview-id-' + props.clientId + ' .th-main-container .th-media-container .th-image-player').style.transform; 174 175 var numbers = transform.split('matrix(')[1].split(')')[0].split(',').map(function(item) { 176 return parseInt(item); 177 }); 178 var translateX = numbers[4]; 179 var translateY = numbers[5]; 180 var scale = numbers[0]; 181 182 // get size of some elements (this is needed to calculate crop params for RTIE from matrix information) 183 var imageSize = document.querySelector('#thron-preview-id-' + props.clientId + ' .th-main-container .th-media-container .th-image-player img').getBoundingClientRect(); 184 var playerSize = document.querySelector('#thron-preview-id-' + props.clientId).getBoundingClientRect(); 185 186 // we also need the size of original image, do getcontentdetails again (player does not expose this info) 187 var url = 'https://{clientId}-view.thron.com/api/xcontents/resources/delivery/getContentDetail?clientId={clientId}&xcontentId={xcontentId}&templateId=CE1&pkey={sessId}'; 188 url = url.replace(/{clientId}/g, args.clientId); 189 url = url.replace('{xcontentId}', props.attributes.contentID); 190 url = url.replace('{sessId}', args.pkey); 191 192 193 return fetch(url, { 194 method: 'GET' 195 }) 196 .then(data => data.json()) 197 .then(contentdetails => { 198 var originalHeight = contentdetails.content.deliverySize.maxHeight; 199 var originalWidth = contentdetails.content.deliverySize.maxWidth; 200 var cropx = (imageSize.width / 2) - Math.min(playerSize.width / 2, imageSize.width / 2) - translateX; 201 var cropy = (imageSize.height / 2) - Math.min(playerSize.height / 2, imageSize.height / 2) - translateY; 202 var cropw = Math.min(imageSize.right, playerSize.right) - Math.max(imageSize.left, playerSize.left); 203 var croph = Math.min(imageSize.bottom, playerSize.bottom) - Math.max(imageSize.top, playerSize.top); 204 var originalCropW = cropw; 205 var originalCropH = croph; 206 cropx = Math.min(imageSize.width, Math.max(0, cropx)); 207 cropy = Math.min(imageSize.height, Math.max(0, cropy)); 208 cropw = Math.min(imageSize.width, Math.max(0, cropw)); 209 croph = Math.min(imageSize.height, Math.max(0, croph)); 210 cropx = cropx * originalWidth / imageSize.width; 211 cropy = cropy * originalHeight / imageSize.height; 212 cropw = cropw * originalWidth / imageSize.width; 213 croph = croph * originalHeight / imageSize.height; 214 return { 215 'cropx': cropx, 216 'cropy': cropy, 217 'cropw': cropw, 218 'croph': croph 219 } 220 }) 221 } 222 223 function wsRenderPlayer(args, props, contentID, embedCode) { 224 var rtie = null 225 226 var template = args.templateList.filter(function(value) { 227 if (value.id == props.attributes.templateID) { 228 return value 229 } 230 }) 231 var tplValues = template[0].values.filter(function(v) { 232 if (v.name === 'TH-CSS-SKIN_CUSTOM') return v.value 233 }) 234 235 tplValue = tplValues.length ? tplValues[0].value : 'NOVALUE' 236 237 var tplPlugins = {} 238 var tplSkins = {} 239 240 if (props.attributes.manualCropSaving) { //default template for manual 241 tplPlugins['NOVALUE'] = null 242 tplSkins['NOVALUE'] = null 243 } else { 244 tplPlugins[tplValue] = typeof template[0].jsUrl !== 'undefined' ? { 'src': template[0].jsUrl } : null 245 tplSkins[tplValue] = typeof template[0].cssUrl !== 'undefined' ? { 'src': template[0].cssUrl } : null 246 } 247 248 if (props.attributes.scalemode == 'manual' && 249 typeof props.attributes.rtieCrop != 'undefined' && 250 props.attributes.rtieCrop != null) { 251 252 rtie = { 253 'cropmode': 'pixel', 254 'quality': props.attributes.quality, 255 'scalemode': props.attributes.scalemode, 256 'cropx': props.attributes.rtieCrop.cropx, 257 'cropy': props.attributes.rtieCrop.cropy, 258 'cropw': props.attributes.rtieCrop.cropw, 259 'croph': props.attributes.rtieCrop.croph, 260 'enhance': 'brightness:' + (props.attributes.brightness + 100) + ',contrast:' + (props.attributes.contrast + 100) + ',sharpness:' + (props.attributes.sharpness + 100) + ',color:' + (props.attributes.color + 100) 261 } 262 /*props.setAttributes({ 263 manualCropSaving: false, 264 });*/ 265 } else { 266 rtie = { 267 'cropmode': 'pixel', 268 'quality': props.attributes.quality, 269 'scalemode': props.attributes.scalemode, 270 'enhance': 'brightness:' + (props.attributes.brightness + 100) + ',contrast:' + (props.attributes.contrast + 100) + ',sharpness:' + (props.attributes.sharpness + 100) + ',color:' + (props.attributes.color + 100) 271 } 272 } 273 274 275 276 var options = { 277 'plugins': tplPlugins, 278 'skins': tplSkins, 279 'clientId': args.clientId, 280 'xcontentId': contentID, 281 'sessId': args.pkey, 282 /*'embedCodeId': embedCode,*/ 283 'ignoreUserBehavior': true, 284 'rtie': rtie, 285 'useCache': false 286 }; 287 288 var isContainerEmpty = document.getElementById('thron-preview-id-' + props.clientId)?.innerHTML === ""; 289 if ((typeof thePlayer[props.clientId] !== 'undefined' && destroy) || isContainerEmpty) { 290 thePlayer[props.clientId]?.destroy() 291 destroy = false; 292 } 293 thePlayer[props.clientId] = THRONContentExperience('thron-preview-id-' + props.clientId, options); 294 295 if (props.attributes.scalemode == 'manual' && props.attributes.manualCropSaving) { 296 297 298 299 // prima di generare il player gestisco la rimozione dei tasti non necessari 300 thePlayer[props.clientId].on('beforeInit', 301 function(playerInstance) { 302 303 var schema = window.THRONSchemaHelper.getSchema(); 304 //configure the position of the button 305 var elements = window.THRONSchemaHelper.removeElementsById(schema, 'IMAGE', 'captionText', 'shareButton', 'downloadableButton', 'zoomText', 'fullscreenButton'); 306 var params = playerInstance.params() 307 params['bars'] = schema 308 //add params 309 playerInstance.params(params); 310 } 311 ); 312 // quando il player e pronto inserisco la griglia a video 313 thePlayer[props.clientId].on('ready', function(playerInstance) { 314 //create div grid 315 var mediaContainer = thePlayer[props.clientId].mediaContainer(); 316 var newNode = document.createElement('div'); 317 newNode.className = 'th-wrapper-grid'; 318 //generate box 319 for (i = 0; i < 9; i++) { 320 var newNodeGrid = document.createElement('div'); 321 newNodeGrid.className = 'th-wrapper-grid-box'; 322 newNode.appendChild(newNodeGrid) 323 } 324 //add div grid 325 mediaContainer.appendChild(newNode) 326 }) 327 } 328 } 329 330 331 var debouncedRenderPlayer = _.debounce(function(args, props, contentID, embedCode) { 332 wsRenderPlayer(args, props, contentID, embedCode) 333 }, 300) 334 31 335 32 336 blocks.registerBlockType('thron/embed-player-block', { … … 40 344 }, 41 345 attributes: { 346 initPlayer: { 347 type: 'boolean', 348 default: true 349 }, 350 dropDownCropIcon: { 351 type: 'string', 352 default: null 353 }, 354 manualCropSaving: { 355 type: 'boolean', 356 default: false 357 }, 42 358 isOpen: { 43 359 type: 'boolean', … … 68 384 default: null 69 385 }, 70 386 scalemode: { 387 type: 'string', 388 default: null 389 }, 390 currentScaleMode: { 391 type: 'string', 392 default: null 393 }, 394 rtieCrop: { 395 cropx: { 396 type: 'number', 397 default: 0 398 }, 399 cropy: { 400 type: 'number', 401 default: 0 402 }, 403 cropw: { 404 type: 'number', 405 default: 0 406 }, 407 croph: { 408 type: 'number', 409 default: 0 410 } 411 }, 412 quality: { 413 type: 'number', 414 default: 90 415 }, 416 brightness: { 417 type: 'number', 418 default: 0 419 }, 420 contrast: { 421 type: 'number', 422 default: 0 423 }, 424 sharpness: { 425 type: 'number', 426 default: 0 427 }, 428 color: { 429 type: 'number', 430 default: 0 431 }, 71 432 72 433 /** … … 109 470 default: null 110 471 }, 472 initMediaType: { 473 type: 'string', 474 default: null 475 }, 111 476 folders: { 112 477 type: 'string', … … 118 483 }, 119 484 120 edit: function (props) { 485 edit: function(props) { 486 121 487 var attributes = props.attributes; 122 488 var listTemplate = []; … … 128 494 var listFolders = [ 129 495 el( 130 'option', 131 { 496 'option', { 132 497 value: '' 133 498 }, … … 136 501 ]; 137 502 138 _.each(args.templateList, function (value) { 503 function setMediaType(props) { 504 THRON.init({ 505 clientId: myAjax.thron_clientId, 506 appId: myAjax.thron_appId, 507 appKey: myAjax.thron_appKey 508 }).then(function() { 509 THRON.callApi( 510 'GET', 511 '/xcontents/resources/delivery/getContentDetail?clientId=' + myAjax.thron_clientId + '&xcontentId=' + props.attributes.contentID 512 ) 513 .then(function(response) { 514 props.setAttributes({ 515 mediaType: response.content.contentType 516 }); 517 }); 518 }); 519 } 520 521 _.each(args.templateList, function(value) { 139 522 listTemplate.push({ 140 value: value.id, 141 label: value.name 142 } 143 ) 523 value: value.id, 524 label: value.name 525 }) 144 526 }); 527 528 props.isSelected && props.attributes.mediaType == null && props.attributes.contentID != null && 529 setMediaType(props); 145 530 146 531 filters.push( … … 148 533 className: 'attachment-filters', 149 534 id: 'media-type', 150 onChange: function (event) {535 onChange: function(event) { 151 536 search(event) 152 537 } 153 538 }, 154 539 el( 155 'option', 156 { 540 'option', { 157 541 value: '' 158 542 }, … … 160 544 ), 161 545 el( 162 'option', 163 { 164 value: 'IMAGE' 165 }, 166 i18n.__('Image', 'thron') 546 'option', { 547 value: 'VIDEO' 548 }, 549 i18n.__('Videos', 'thron') 167 550 ), 168 551 el( 169 'option', 170 { 171 value: 'VIDEO' 172 }, 173 i18n.__('Video', 'thron') 174 ), 175 el( 176 'option', 177 { 552 'option', { 178 553 value: 'AUDIO' 179 554 }, … … 181 556 ), 182 557 el( 183 'option', 184 { 558 'option', { 559 value: 'IMAGE' 560 }, 561 i18n.__('Images', 'thron') 562 ), 563 el( 564 'option', { 565 value: 'OTHER' 566 }, 567 i18n.__('Document (Other)', 'thron') 568 ), 569 el( 570 'option', { 185 571 value: 'PLAYLIST' 186 572 }, … … 188 574 ), 189 575 el( 190 'option', 191 { 192 value: 'OTHER' 193 }, 194 i18n.__('Other', 'thron') 576 'option', { 577 value: 'URL' 578 }, 579 i18n.__('URL', 'thron') 580 ), 581 el( 582 'option', { 583 value: 'PAGELET' 584 }, 585 i18n.__('Pagelet', 'thron') 195 586 ) 196 587 ) 197 588 ); 198 589 199 _.each(args.folders, function (value) {590 _.each(args.folders, function(value) { 200 591 201 592 listFolders.push( 202 593 el( 203 'option', 204 { 594 'option', { 205 595 value: value.id 206 596 }, … … 214 604 className: 'attachment-filters', 215 605 id: 'folders', 216 onChange: function (event) {606 onChange: function(event) { 217 607 search(event) 218 608 } … … 223 613 ); 224 614 225 _.each(args.tagsFilter, function (tagList) {615 _.each(args.tagsFilter, function(tagList) { 226 616 227 617 var options = [ 228 618 el( 229 'option', 230 { 619 'option', { 231 620 value: '' 232 621 }, … … 235 624 ]; 236 625 237 _.each(tagList.list, function (value) {626 _.each(tagList.list, function(value) { 238 627 options.push( 239 628 el( 240 'option', 241 { 629 'option', { 242 630 value: value.id 243 631 }, … … 251 639 className: 'attachment-filters', 252 640 id: 'tag-' + tagList.id, 253 onChange: function (event) {641 onChange: function(event) { 254 642 search(event); 255 643 } … … 260 648 }); 261 649 262 var getEmbedCode = function () { 650 var getEmbedCode = function() { 651 652 263 653 264 654 if ((templateID != null) && (contentID != null)) { 265 655 266 const title = select( "core/editor").getEditedPostAttribute('title') != '' ? select("core/editor").getEditedPostAttribute('title') : 'post-id-' + select("core/editor").getEditedPostAttribute('id');656 const title = select('core/editor').getEditedPostAttribute('title') != '' ? select('core/editor').getEditedPostAttribute('title') : 'post-id-' + select('core/editor').getEditedPostAttribute('id'); 267 657 268 658 /** … … 271 661 */ 272 662 this.api = THRON.init({ 273 clientId: myAjax.thron_clientId,274 appId: myAjax.thron_appId,275 appKey: myAjax.thron_appKey276 })277 .then(function () {663 clientId: myAjax.thron_clientId, 664 appId: myAjax.thron_appId, 665 appKey: myAjax.thron_appKey 666 }) 667 .then(function() { 278 668 if (embedCode) { 669 if (templateID !== '') { 670 var tplObj = { 671 'templateId': templateID, 672 'templateType': 'CUSTOM' 673 } 674 } else { 675 var tplObj = { 676 'templateId': 'CE1', 677 'templateType': 'PLATFORM', 678 'templateVersion': null 679 } 680 } 279 681 THRON.callApi( 280 "POST", 281 "/xcontents/resources/playerembedcode/update/" + myAjax.thron_clientId, 282 { 283 body: { 284 "embedCodeId": embedCode, 285 "source": { 286 "id": contentID, 287 "entityType": "CONTENT" 288 }, 289 "update": { 290 "name": title, 291 "template": { 292 "templateId": templateID, 293 "templateType": "CUSTOM" 682 'POST', 683 '/xcontents/resources/playerembedcode/update/' + myAjax.thron_clientId, { 684 body: { 685 'embedCodeId': embedCode, 686 'source': { 687 'id': contentID, 688 'entityType': 'CONTENT' 294 689 }, 295 "enabled": true 690 'update': { 691 'name': title, 692 'template': tplObj, 693 'enabled': true 694 } 296 695 } 297 } 298 }) 299 .then(function (response) { 696 }) 697 .then(function(response) { 300 698 301 699 embedCode = response.item.id; … … 307 705 } else { 308 706 THRON.callApi( 309 "POST", 310 "/xcontents/resources/playerembedcode/insert/" + myAjax.thron_clientId, 311 { 312 body: { 313 "skipPkeyCreation": true, 314 "source": { 315 "id": contentID, 316 "entityType": "CONTENT" 317 }, 318 "value": { 319 "name": title, 320 "template": { 321 "templateId": templateID, 322 "templateType": "CUSTOM" 707 'POST', 708 '/xcontents/resources/playerembedcode/insert/' + myAjax.thron_clientId, { 709 body: { 710 'skipPkeyCreation': true, 711 'source': { 712 'id': contentID, 713 'entityType': 'CONTENT' 323 714 }, 324 "enabled": true 715 'value': { 716 'name': title, 717 'template': { 718 'templateId': templateID, 719 'templateType': 'CUSTOM' 720 }, 721 'enabled': true 722 } 325 723 } 326 } 327 }) 328 .then(function (response) { 724 }) 725 .then(function(response) { 329 726 330 727 embedCode = response.item.id; … … 339 736 }; 340 737 341 var search = function (event) { 738 var requestId = -1; 739 740 var search = function(event, append) { 342 741 var search = attributes.searchString; 343 742 var folders = attributes.folders; … … 355 754 356 755 props.setAttributes({ 357 mediaType: mediaType,756 //mediaType: mediaType, 358 757 searchResult: searchResult 359 758 }); … … 383 782 var id = event.target.id.substring(4).split(';'); 384 783 385 _.each(tags, function (tag) {784 _.each(tags, function(tag) { 386 785 if (id[1] !== tag.parent) { 387 786 new_tags.push(tag); … … 422 821 appId: myAjax.thron_appId, 423 822 appKey: myAjax.thron_appKey 424 }).then(function () {823 }).then(function() { 425 824 426 825 var body = {}; … … 430 829 body.criteria.lemma = {}; 431 830 body.criteria.lemma.text = search; 432 body.criteria.lemma.textMatch = "any_word_match";831 body.criteria.lemma.textMatch = 'any_word_match'; 433 832 } 434 833 … … 449 848 body.criteria.itag.haveAll = []; 450 849 451 _.each(tags, function (tag) {850 _.each(tags, function(tag) { 452 851 if (tag.id != '') { 453 852 body.criteria.itag.haveAll.push({ … … 467 866 body.responseOptions = new Object(); 468 867 body.responseOptions.resultsPageSize = 50; 469 body.responseOptions.returnDetailsFields = new Array("locales", "source"); 470 868 body.responseOptions.returnDetailsFields = new Array('locales', 'source'); 869 870 var currentRequestId = ++requestId; 471 871 THRON.callApi( 472 "POST", 473 "/xcontents/resources/content/search/" + myAjax.thron_clientId, 474 {body: body} 475 ).then(function (response) { 872 'POST', 873 '/xcontents/resources/content/search/' + myAjax.thron_clientId, { body: body } 874 ).then(function(response) { 875 if (currentRequestId !== requestId) { 876 return; 877 } 476 878 477 879 nextPageToken = response.nextPageToken; 478 880 479 var output = searchResult.concat(new Array()); 480 481 _.each(response.items, function (value) { 881 var output = append ? searchResult.concat(new Array()) : []; 882 883 if (response.items.length === 0 && !append) { 884 output.push( 885 el('div', { 886 className: 'empty-results', 887 }, 888 i18n.__('No result for this search', 'thron'), 889 ) 890 ); 891 } 892 893 _.each(response.items, function(value) { 482 894 483 895 484 896 var local_language = value.details.locales[0]; 485 897 486 _.each(value.details.locales, function (lang) {898 _.each(value.details.locales, function(lang) { 487 899 if (lang.locale == 'EN') 488 900 local_language = lang; 489 901 }); 490 _.each(value.details.locales, function (lang) {902 _.each(value.details.locales, function(lang) { 491 903 if (lang.locale == args.wp_language) 492 904 local_language = lang; … … 494 906 495 907 output.push( 496 el('div', 497 { 908 el('div', { 498 909 className: 'content', 499 910 'data-id': value.id, 500 onClick: function (event) {911 onClick: function(event) { 501 912 var id = null; 502 913 var content = null; 503 504 _.each(document.getElementsByClassName('content'), function (item) { 914 _.each(document.getElementsByClassName('content'), function(item) { 505 915 if (item.classList.contains('selected')) 506 916 item.classList.remove('selected'); 507 917 }); 508 509 if (event.target.tagName == 'IMG') { 510 id = event.target.parentElement.getAttribute('data-id'); 511 512 content = event.target.parentElement; 918 content = event.currentTarget; 919 id = content.getAttribute('data-id'); 920 if (content.classList.contains('selected')) { 921 content.classList.remove('selected'); 513 922 } else { 514 id = event.target.parentElement.parentElement.getAttribute('data-id'); 515 516 content = event.target.parentElement.parentElement; 923 content.classList.add('selected'); 517 924 } 518 519 if (content.classList.contains('selected')) 520 content.classList.remove('selected'); 521 else 522 content.classList.add('selected'); 523 524 if (id == null) 925 if (id == null) { 525 926 return; 526 927 } 527 928 props.setAttributes({ 528 929 tmpContentID: id, 930 initMediaType: value.contentType 529 931 }); 530 932 } 531 933 }, 532 el(' img',533 {934 el('picture', {}, 935 el('img', { 534 936 className: 'thumb_img', 535 937 src: 'https://' + myAjax.thron_clientId + '-view.thron.com/api/xcontents/resources/delivery/getThumbnail/' + myAjax.thron_clientId + '/200x150/' + value.id + '?scalemode=auto' 536 } 938 }), 537 939 ), 538 el('div', 539 { 940 el('div', { 540 941 className: 'label' 541 942 }, 542 el('span', 543 { 544 className: 'thron-type', 545 'data-value': value.contentType 546 } 547 ), 548 el('span', 549 { 943 el('span', { 944 className: 'thron-type', 945 'data-value': value.contentType 946 }), 947 el('span', { 550 948 className: 'thron-extension' 551 949 }, 552 typeof value.details.source != "undefined" ? value.details.source.extension : null950 typeof value.details.source !== 'undefined' ? value.details.source.extension : value.contentType 553 951 ), 554 el('span', 555 { 952 el('span', { 556 953 className: 'thron-label' 557 954 }, 558 955 local_language.name 559 956 ), 560 local_language.name561 957 ) 562 958 ) … … 564 960 }); 565 961 566 ThronListHeight();567 962 props.setAttributes({ 568 963 searchResult: output, … … 575 970 }; 576 971 577 if (embedCode != null) { 578 var options = { 579 "clientId": args.clientId, 580 "xcontentId": contentID, 581 "sessId": args.pkey, 582 "embedCodeId": embedCode, 583 "ignoreUserBehavior": true 584 }; 585 586 console.log(options); 587 588 THRONContentExperience("thron-preview-id-" + props.clientId, options); 972 973 if (typeof thePlayer[props.clientId] !== 'undefined') { 974 debouncedRenderPlayer(args, props, contentID, embedCode) 975 } else { 976 if (contentID) wsRenderPlayer(args, props, contentID, embedCode) 589 977 } 590 978 591 979 var searchResult = attributes.searchResult; 980 592 981 var more = []; 593 982 594 983 if (nextPageToken != null) { 595 984 more = [ 596 el(components.Button, 597 { 985 el(components.Button, { 598 986 id: 'thron-more', 599 onClick: function (event) {600 search(event )987 onClick: function(event) { 988 search(event, true) 601 989 } 602 990 }, … … 606 994 } 607 995 608 var closeModal = function () {996 var closeModal = function() { 609 997 searchResult = new Array(); 610 998 folders = null; 611 999 tags = null; 1000 searchString = null; 612 1001 nextPageToken = null; 613 mediaType = null;614 1002 615 1003 props.setAttributes({ … … 618 1006 folders: null, 619 1007 tags: null, 1008 searchString: null, 620 1009 nextPageToken: null, 621 mediaType: null622 1010 }); 623 1011 } … … 625 1013 var dimension = new Array(); 626 1014 if (props.attributes.embedType != 'responsive') { 627 dimension.push(el(components.TextControl, 628 { 1015 dimension.push(el(components.TextControl, { 629 1016 label: i18n.__('Width (px)', 'thron'), 630 1017 type: 'number', 631 1018 help: '', 632 onChange: function (width) {1019 onChange: function(width) { 633 1020 634 1021 var aspectRatio; … … 639 1026 aspectRatio = (maxWidth && maxHeight) ? maxHeight / maxWidth : null; 640 1027 641 props.setAttributes({ width: parseInt(width, 10)});1028 props.setAttributes({ width: parseInt(width, 10) }); 642 1029 643 1030 if (aspectRatio && props.attributes.keepProportions) { 644 1031 height = Math.round(width * aspectRatio); 645 props.setAttributes({ height: parseInt(height, 10)});1032 props.setAttributes({ height: parseInt(height, 10) }); 646 1033 } 1034 destroy = true; 647 1035 }, 648 1036 value: props.attributes.width 649 } 650 ), 651 el(components.TextControl, 652 { 653 label: i18n.__('Height (px)', 'thron'), 654 type: 'number', 655 help: '', 656 onChange: function (height) { 657 658 var aspectRatio; 659 660 var maxWidth = props.attributes.maxWidth; 661 var maxHeight = props.attributes.maxHeight; 662 663 aspectRatio = (maxWidth && maxHeight) ? maxHeight / maxWidth * 100 : null; 664 665 props.setAttributes({height: parseInt(height, 10)}); 666 667 if (aspectRatio && props.attributes.keepProportions) { 668 width = Math.round(height / aspectRatio * 100); 669 props.setAttributes({width: parseInt(width, 10)}); 670 } 671 672 673 }, 674 value: props.attributes.height 675 } 676 ), 677 el(components.CheckboxControl, 678 { 679 label: i18n.__('Maintain aspect ratio', 'thron'), 680 onChange: (value) => { 681 props.setAttributes({keepProportions: value}); 682 }, 683 checked: props.attributes.keepProportions, 684 } 685 ), 1037 }), 1038 el(components.TextControl, { 1039 label: i18n.__('Height (px)', 'thron'), 1040 type: 'number', 1041 help: '', 1042 onChange: function(height) { 1043 1044 var aspectRatio; 1045 1046 var maxWidth = props.attributes.maxWidth; 1047 var maxHeight = props.attributes.maxHeight; 1048 1049 aspectRatio = (maxWidth && maxHeight) ? maxHeight / maxWidth * 100 : null; 1050 1051 props.setAttributes({ height: parseInt(height, 10) }); 1052 1053 if (aspectRatio && props.attributes.keepProportions) { 1054 width = Math.round(height / aspectRatio * 100); 1055 props.setAttributes({ width: parseInt(width, 10) }); 1056 } 1057 destroy = true; 1058 1059 }, 1060 value: props.attributes.height 1061 }), 1062 el(components.CheckboxControl, { 1063 label: i18n.__('Maintain aspect ratio', 'thron'), 1064 onChange: (value) => { 1065 props.setAttributes({ keepProportions: value }); 1066 }, 1067 checked: props.attributes.keepProportions, 1068 }), 686 1069 ) 687 1070 } 688 1071 1072 /*thron toolbar / dropdown crop opt*/ 1073 const thronCustomToolbar = el(BlockControls, { key: 'controls', className: 'components-accessible-toolbar block-editor-block-contextual-toolbar' }, 1074 (props.attributes.scalemode != 'manual' || !props.attributes.manualCropSaving) && 1075 // Non appare finche non c'e il contenuto 1076 props.attributes.contentID != null && 1077 el('div', { className: 'components-toolbar' }, 1078 el(MenuItem, { 1079 icon: 'edit', 1080 onClick: function(event) { 1081 props.setAttributes({ 1082 isOpen: true, 1083 }); 1084 1085 search(event) 1086 } 1087 }) 1088 ), 1089 props.attributes.mediaType == 'IMAGE' && props.attributes.contentID != null && 1090 // Quando siamo in 'modalità crop' faccio sparire anche la dropdown (come nel blocco immagine standard) 1091 (props.attributes.scalemode != 'manual' || !props.attributes.manualCropSaving) && 1092 el(DropDownMenu, { 1093 className: 'components-toolbar components-button components-dropdown-menu__toggle has-icon', 1094 icon: initialCropIcon(props), 1095 title: 'Crop', 1096 'aria-label': 'Crop', 1097 label: 'Crop', 1098 controls: [{ 1099 title: 'Auto', 1100 icon: props.attributes.scalemode === 'auto' ? AutoNeg : AutoPos, 1101 //isDisabled: props.attributes.scalemode === 'auto', 1102 onClick: function() { 1103 props.setAttributes({ 1104 dropDownCropIcon: props.attributes.scalemode !== 'auto' ? AutoPos : CropIcon, 1105 scalemode: props.attributes.scalemode !== 'auto' ? 'auto' : null, 1106 rtieCrop: null, 1107 currentScaleMode: props.attributes.scalemode !== 'auto' ? 'auto' : null 1108 }); 1109 destroy = true; 1110 }, 1111 }, 1112 { 1113 title: 'Centered', 1114 icon: props.attributes.scalemode === 'centered' ? CenteredNeg : CenteredPos, 1115 //isDisabled: props.attributes.scalemode === 'centered', 1116 onClick: function() { 1117 props.setAttributes({ 1118 dropDownCropIcon: props.attributes.scalemode !== 'centered' ? CenteredPos : CropIcon, 1119 scalemode: props.attributes.scalemode !== 'centered' ? 'centered' : null, 1120 rtieCrop: null, 1121 currentScaleMode: props.attributes.scalemode !== 'centered' ? 'centered' : null 1122 }); 1123 1124 destroy = true; 1125 }, 1126 }, 1127 { 1128 title: 'Product', 1129 icon: props.attributes.scalemode === 'product' ? ProductNeg : ProductPos, 1130 //isDisabled: props.attributes.scalemode === 'product', 1131 onClick: function() { 1132 props.setAttributes({ 1133 dropDownCropIcon: props.attributes.scalemode !== 'product' ? ProductPos : CropIcon, 1134 scalemode: props.attributes.scalemode !== 'product' ? 'product' : null, 1135 rtieCrop: null, 1136 currentScaleMode: props.attributes.scalemode !== 'product' ? 'product' : null 1137 }); 1138 destroy = true; 1139 }, 1140 }, 1141 { 1142 title: 'Manual', 1143 icon: props.attributes.scalemode === 'manual' ? ManualNeg : ManualPos, 1144 onClick: function() { 1145 props.setAttributes({ 1146 manualCropSaving: props.attributes.scalemode !== 'manual' ? true : false, 1147 scalemode: props.attributes.scalemode !== 'manual' ? 'manual' : null, 1148 rtieCrop: null 1149 }); 1150 destroy = true; 1151 }, 1152 } 1153 ] 1154 }), 1155 props.attributes.mediaType == 'IMAGE' && 1156 props.attributes.manualCropSaving && props.attributes.scalemode == 'manual' && 1157 el('div', { className: 'components-toolbar-group' }, 1158 el('input', { 1159 type: 'button', 1160 value: i18n.__('Apply', 'thron'), 1161 className: 'components-button components-toolbar-button thronButton', 1162 onClick: function(event) { 1163 cropOps(args, props) 1164 .then(props) 1165 .then(data => { 1166 props.setAttributes({ 1167 dropDownCropIcon: ManualPos, 1168 manualCropSaving: false, 1169 rtieCrop: data, 1170 currentScaleMode: 'product' 1171 }) 1172 }) 1173 destroy = true; 1174 } 1175 }), 1176 el('input', { 1177 type: 'button', 1178 value: i18n.__('Cancel', 'thron'), 1179 className: 'components-button components-toolbar-button thronButton', 1180 onClick: function(event) { 1181 props.setAttributes({ 1182 manualCropSaving: false, 1183 scalemode: props.attributes.currentScaleMode 1184 }); 1185 destroy = true; 1186 } 1187 }), 1188 ) 1189 ); 1190 689 1191 return [ 690 el('div', 691 { 1192 el('div', { 692 1193 className: props.className 693 1194 }, 694 el('div', 695 { 696 className: '' 697 }, 698 !attributes.mediaID && 1195 1196 /*thron custom toolbar*/ 1197 thronCustomToolbar, 1198 1199 el('div', { 1200 className: contentID ? 'block-editor-media-placeholder is-large thron-block' : 'components-placeholder block-editor-media-placeholder is-large thron-block' 1201 }, !contentID && 1202 el('div', { 1203 className: 'components-placeholder__label' 1204 }, 1205 el('span', { 1206 className: 'block-editor-block-icon block-editor-block-switcher__toggle has-colors' 1207 }, 1208 THRONLogo 1209 ), 1210 i18n.__('Select a content from THRON', 'thron') 1211 ), !contentID && 1212 el('div', { 1213 className: 'components-placeholder__instructions' 1214 }, 1215 i18n.__('Choose a content from your THRON Library.', 'thron') 1216 ), !contentID && 699 1217 el(components.Button, { 700 className: ' button button-large aligncenter',1218 className: 'components-button block-editor-media-placeholder__button block-editor-media-placeholder__upload-button is-primary', 701 1219 id: 'thron-open-modal-button', 702 onClick: function (event) {1220 onClick: function(event) { 703 1221 props.setAttributes({ 704 1222 isOpen: true, … … 708 1226 } 709 1227 }, 710 i18n.__('Select content', 'thron')711 ), 1228 i18n.__('Select a content', 'thron') 1229 ), !props.isSelected && contentID && 712 1230 el('div', { 713 id: "thron-preview-id-" + props.clientId + '-wrapper', 1231 className: 'thron-block-overlay' 1232 }, ), 1233 el('div', { 1234 id: 'thron-preview-id-' + props.clientId + '-wrapper', 714 1235 }, 715 1236 el('div', { 716 id: "thron-preview-id-"+ props.clientId,1237 id: 'thron-preview-id-' + props.clientId, 717 1238 className: 'thron-block-preview' 718 1239 }) … … 720 1241 el('style', {}, 721 1242 (props.attributes.embedType == 'responsive') ? 722 "#thron-preview-id-"+ props.clientId + '{ width: 100%; height:100%; position: absolute; top: 0} ' +723 "#thron-preview-id-" + props.clientId + '-wrapper {padding-top:' + (attributes.maxHeight / attributes.maxWidth * 100 ) + '%; width: 100%; position: relative}'724 : "#thron-preview-id-"+ props.clientId + '{ width: ' + attributes.width + 'px; height: ' + attributes.height + 'px; } '1243 '#thron-preview-id-' + props.clientId + '{ width: 100%; height:100%; position: absolute; top: 0} ' + 1244 '#thron-preview-id-' + props.clientId + '-wrapper {padding-top:' + (attributes.maxHeight / attributes.maxWidth * 100) + '%; width: 100%; position: relative}' : 1245 '#thron-preview-id-' + props.clientId + '{ width: ' + attributes.width + 'px; height: ' + attributes.height + 'px; } ' 725 1246 ), 726 1247 1248 //!props.isSelected && props.attributes.scalemode == 'manual' && 1249 props.isSelected && props.attributes.scalemode == 'manual' && 1250 el('div', { 1251 className: 'components-placeholder__label' 1252 }, ), 727 1253 // Modal 728 1254 attributes.isOpen && 729 1255 el(components.Modal, { 730 title: i18n.__('Select content from THRON', 'thron'),1256 title: i18n.__('Select a content from THRON', 'thron'), 731 1257 className: 'thron-block-modal', 732 1258 onRequestClose: closeModal 733 1259 }, 734 // Header modal735 el('div', 736 {737 className: 'wsthron-header'1260 //Media Content 1261 el('div', { 1262 className: 'thron-block', 1263 id: 'thron_content', 738 1264 }, 1265 //Header modal 739 1266 el('div', { 740 className: 'media-toolbar-primary search-form', 741 }, 742 el('label', { 743 className: 'media-search-input-label', 744 htmlFor: 'media-search-input' 745 }, 746 i18n.__('Search', 'thron') 747 ), 748 el('input', { 749 className: 'search', 750 id: 'media-search-input', 751 onChange: search 752 } 753 ), 754 ), 755 el('div', { 756 className: 'media-toolbar' 1267 className: 'media-toolbar wsthron-header', 1268 id: 'thron_toolbar', 757 1269 }, 758 1270 el('div', { … … 761 1273 filters, 762 1274 ), 1275 el('div', { 1276 className: 'media-toolbar-primary search-form', 1277 }, 1278 el('label', { 1279 className: 'media-search-input-label', 1280 htmlFor: 'media-search-input' 1281 }, 1282 i18n.__('Search', 'thron') 1283 ), 1284 el('input', { 1285 className: 'search', 1286 id: 'media-search-input', 1287 onChange: search 1288 }), 1289 ), 1290 ), 1291 //End Header modal 1292 // Search result 1293 el('div', { 1294 id: 'thron_list', 1295 class: 'td-content-grid', 1296 onScroll: function(event) { 1297 var scrollTop = document.getElementById('thron_list').scrollTop 1298 var scrollHeight = document.getElementById('thron_list').scrollHeight 1299 var clientHeight = document.getElementById('thron_list').clientHeight 1300 if (scrollTop + clientHeight === scrollHeight) { 1301 if (typeof attributes.nextPageToken !== null && typeof attributes.nextPageToken !== 'undefined') { 1302 search(event, true); 1303 } 1304 } 1305 } 1306 }, 1307 searchResult 1308 ), 1309 el('div', { 1310 class: 'modal-footer media-toolbar-primary search-form' 1311 }, 1312 el(components.Button, { 1313 className: 'button button-large media-button media-button-insert', 1314 onClick: function() { 1315 1316 /** 1317 * if the content is changed it starts the sequence to change 1318 * the embed code 1319 */ 1320 if (attributes.tmpContentID != contentID) { 1321 1322 embedCode = null; 1323 1324 props.setAttributes({ embedCode: embedCode }); 1325 1326 contentID = attributes.tmpContentID; 1327 1328 /** 1329 * Request content detils 1330 */ 1331 THRON.callApi( 1332 'GET', 1333 '/xcontents/resources/delivery/getContentDetail?clientId=' + myAjax.thron_clientId + '&xcontentId=' + contentID 1334 ) 1335 .then(function(response) { 1336 1337 deliverySize = response.content.deliverySize.aspectRatio.split(':'); 1338 1339 props.setAttributes({ 1340 maxWidth: parseInt(deliverySize[0], 10), 1341 maxHeight: parseInt(deliverySize[1], 10), 1342 }); 1343 }); 1344 1345 props.setAttributes({ 1346 contentID: contentID, 1347 }); 1348 1349 getEmbedCode(); 1350 } 1351 1352 // Close Modal Frame 1353 closeModal(); 1354 1355 props.setAttributes({ 1356 mediaType: props.attributes.initMediaType, 1357 //searchResult: searchResult 1358 }); 1359 1360 } 1361 }, 1362 i18n.__('Insert content', 'thron') 1363 ), 763 1364 ), 764 1365 ), 765 766 //End Header modal767 768 // Search result769 el('div',770 {771 class: 'wsthron'772 },773 el('div', {774 id: 'thron_list',775 class: 'td-content-grid'776 },777 searchResult,778 more779 ),780 ),781 el('div',782 {783 class: 'modal-footer media-toolbar-primary search-form'784 },785 el(components.Button, {786 className: 'button button-large media-button media-button-insert',787 onClick: function () {788 789 /**790 * if the content is changed it starts the sequence to change791 * the embed code792 */793 if (attributes.tmpContentID != contentID) {794 795 embedCode = null;796 797 props.setAttributes({embedCode: embedCode});798 799 contentID = attributes.tmpContentID;800 801 /**802 * Request content detils803 */804 THRON.callApi(805 "GET",806 "/xcontents/resources/delivery/getContentDetail?clientId=" + myAjax.thron_clientId + "&xcontentId=" + contentID807 )808 .then(function (response) {809 810 deliverySize = response.content.deliverySize.aspectRatio.split(':');811 812 props.setAttributes({813 maxWidth: parseInt(deliverySize[0], 10),814 maxHeight: parseInt(deliverySize[1], 10),815 });816 });817 818 props.setAttributes({819 contentID: contentID,820 });821 822 getEmbedCode();823 }824 825 // Close Modal Frame826 closeModal();827 }828 },829 i18n.__('Insert content', 'thron')830 ),831 )832 1366 ), 833 1367 // End Modal 834 1368 1369 1370 835 1371 // SideBar 836 el(InspectorControls, { key: 'inspector'}, // Display the block options in the inspector panel.1372 el(InspectorControls, { key: 'inspector' }, // Display the block options in the inspector panel. 837 1373 el(PanelBody, { 838 1374 title: i18n.__('THRON OPTION', 'thron'), … … 840 1376 initialOpen: true 841 1377 }, 842 el(components.SelectControl, 843 { 844 label: i18n.__('Select template', 'thron'), 845 options: listTemplate, 846 onChange: (value) => { 847 templateID = value; 848 849 props.setAttributes({templateID: templateID}); 850 851 getEmbedCode(); 1378 el(components.SelectControl, { 1379 label: i18n.__('Select template', 'thron'), 1380 options: listTemplate, 1381 onChange: (value) => { 1382 templateID = value; 1383 1384 props.setAttributes({ templateID: templateID }); 1385 1386 getEmbedCode(); 1387 1388 destroy = true; 1389 }, 1390 value: props.attributes.templateID 1391 }), 1392 el(components.SelectControl, { 1393 label: i18n.__('Select embed type', 'thron'), 1394 options: [{ 1395 label: i18n.__('Responsive', 'thron'), 1396 value: 'responsive', 852 1397 }, 853 value: props.attributes.templateID 854 } 855 ), 856 el(components.SelectControl, 857 { 858 label: i18n.__('Select embed type', 'thron'), 859 options: [ 860 { 861 label: i18n.__('Responsive', 'thron'), 862 value: 'responsive', 863 }, 864 { 865 label: i18n.__('Fixed', 'thron'), 866 value: 'fixed' 867 }, 868 ], 869 onChange: (value) => { 870 props.setAttributes({embedType: value}); 1398 { 1399 label: i18n.__('Fixed', 'thron'), 1400 value: 'fixed' 871 1401 }, 872 value: props.attributes.embedType 873 } 874 ), 1402 ], 1403 onChange: (value) => { 1404 props.setAttributes({ embedType: value }); 1405 }, 1406 value: props.attributes.embedType 1407 }), 875 1408 dimension 876 1409 ), 1410 /* props.attributes.mediaType == 'IMAGE' && 1411 el(PanelBody, { 1412 title: i18n.__('RTIE Params', 'thron'), 1413 className: '', 1414 initialOpen: true 1415 }, 1416 ), */ 1417 props.attributes.mediaType == 'IMAGE' && 1418 el(PanelBody, { 1419 title: i18n.__('Image adjustments', 'thron'), 1420 className: '', 1421 initialOpen: true 1422 }, 1423 el(components.RangeControl, { 1424 label: i18n.__('Quality', 'thron'), 1425 min: 0, 1426 default: 90, 1427 max: 100, 1428 step: 5, 1429 type: 'number', 1430 onChange: function(quality) { 1431 props.setAttributes({ 'quality': quality }) 1432 destroy = true; 1433 }, 1434 value: props.attributes.quality 1435 }), 1436 el(components.RangeControl, { 1437 label: i18n.__('Brightness', 'thron'), 1438 min: -100, 1439 max: 100, 1440 default: 0, 1441 step: 5, 1442 help: '', 1443 onChange: function(brightness) { 1444 props.setAttributes({ 'brightness': brightness }) 1445 destroy = true; 1446 }, 1447 value: props.attributes.brightness 1448 }), 1449 el(components.RangeControl, { 1450 label: i18n.__('Contrast', 'thron'), 1451 min: -100, 1452 max: 100, 1453 default: 0, 1454 step: 5, 1455 help: '', 1456 onChange: function(contrast) { 1457 props.setAttributes({ 'contrast': contrast }) 1458 destroy = true; 1459 }, 1460 value: props.attributes.contrast 1461 }), 1462 el(components.RangeControl, { 1463 label: i18n.__('Sharpness', 'thron'), 1464 min: -100, 1465 max: 100, 1466 default: 0, 1467 step: 5, 1468 help: '', 1469 onChange: function(sharpness) { 1470 props.setAttributes({ 'sharpness': sharpness }) 1471 destroy = true; 1472 }, 1473 value: props.attributes.sharpness 1474 }), 1475 el(components.RangeControl, { 1476 label: i18n.__('Color', 'thron'), 1477 min: -100, 1478 max: 100, 1479 default: 0, 1480 step: 5, 1481 help: '', 1482 onChange: function(color) { 1483 props.setAttributes({ 'color': color }) 1484 destroy = true; 1485 }, 1486 value: props.attributes.color 1487 }), 1488 ), 877 1489 ), 878 879 1490 // End SideBar 880 1491 ), … … 883 1494 }, 884 1495 885 save: function (props) {1496 save: function(props) { 886 1497 887 1498 var aspectRatio = 75; … … 895 1506 className: props.className, 896 1507 }, 897 '[thron contentID="' + props.attributes.contentID + '" embedCodeId="' + props.attributes.embedCode + '" embedType="' + props.attributes.embedType + '" width="' + props.attributes.width + '" height="' + props.attributes.height + '" aspectRatio="' + aspectRatio + '"]', 1508 '[thron contentID="' + props.attributes.contentID + '" embedCodeId="' + props.attributes.embedCode + 1509 '" embedType="' + props.attributes.embedType + '" width="' + props.attributes.width + 1510 '" quality="' + props.attributes.quality + 1511 '" scalemode="' + props.attributes.scalemode + 1512 (props.attributes.scalemode == 'manual' && 1513 typeof props.attributes.rtieCrop != 'undefined' && 1514 props.attributes.rtieCrop != null ? '" cropx="' + props.attributes.rtieCrop.cropx + 1515 '" cropy="' + props.attributes.rtieCrop.cropy + 1516 '" croph="' + props.attributes.rtieCrop.croph + 1517 '" cropw="' + props.attributes.rtieCrop.cropw : '') + 1518 '" brightness="' + (props.attributes.brightness + 100) + '" contrast="' + (props.attributes.contrast + 100) + 1519 '" sharpness="' + (props.attributes.sharpness + 100) + '" color="' + (props.attributes.color + 100) + 1520 '" height="' + props.attributes.height + '" aspectRatio="' + aspectRatio + '" ]', 898 1521 ); 899 1522 900 } 1523 1524 }, 1525 1526 1527 deprecated: [{ 1528 attributes: { 1529 manualCropSaving: { 1530 type: 'boolean', 1531 default: false 1532 }, 1533 isOpen: { 1534 type: 'boolean', 1535 default: false 1536 }, 1537 searchString: { 1538 type: 'string', 1539 default: '' 1540 }, 1541 searchResult: { 1542 type: 'array', 1543 default: [] 1544 }, 1545 tmpContentID: { 1546 type: 'string', 1547 default: null 1548 }, 1549 contentID: { 1550 type: 'string', 1551 default: null 1552 }, 1553 templateID: { 1554 type: 'string', 1555 default: args.thron_playerTemplates 1556 }, 1557 embedCode: { 1558 type: 'string', 1559 default: null 1560 }, 1561 scalemode: { 1562 type: 'string', 1563 default: 'auto' 1564 }, 1565 currentScaleMode: { 1566 type: 'string', 1567 default: null 1568 }, 1569 rtieCrop: { 1570 cropx: { 1571 type: 'number', 1572 default: 0 1573 }, 1574 cropy: { 1575 type: 'number', 1576 default: 0 1577 }, 1578 cropw: { 1579 type: 'number', 1580 default: 0 1581 }, 1582 croph: { 1583 type: 'number', 1584 default: 0 1585 } 1586 }, 1587 quality: { 1588 type: 'number', 1589 default: 90 1590 }, 1591 brightness: { 1592 type: 'number', 1593 default: 0 1594 }, 1595 contrast: { 1596 type: 'number', 1597 default: 0 1598 }, 1599 sharpness: { 1600 type: 'number', 1601 default: 0 1602 }, 1603 color: { 1604 type: 'number', 1605 default: 0 1606 }, 1607 1608 /** 1609 * Dimension 1610 */ 1611 embedType: { 1612 type: 'string', 1613 default: 'responsive' 1614 }, 1615 width: { 1616 type: 'number', 1617 default: 100 1618 }, 1619 height: { 1620 type: 'number', 1621 default: null 1622 }, 1623 maxWidth: { 1624 type: 'number', 1625 default: null 1626 }, 1627 maxHeight: { 1628 type: 'number', 1629 default: null 1630 }, 1631 keepProportions: { 1632 type: 'boolean', 1633 default: true 1634 }, 1635 1636 /** 1637 * Filter 1638 */ 1639 nextPageToken: { 1640 type: 'string', 1641 default: null 1642 }, 1643 mediaType: { 1644 type: 'string', 1645 default: null 1646 }, 1647 folders: { 1648 type: 'string', 1649 default: null 1650 }, 1651 tags: { 1652 type: 'array' 1653 }, 1654 }, 1655 1656 save(props) { 1657 1658 var aspectRatio = 75; 1659 1660 var maxWidth = props.attributes.maxWidth; 1661 var maxHeight = props.attributes.maxHeight; 1662 1663 aspectRatio = (maxWidth && maxHeight) ? maxHeight / maxWidth * 100 : 75; 1664 1665 return el('div', { 1666 className: props.className, 1667 }, 1668 '[thron contentID="' + props.attributes.contentID + '" embedCodeId="' + props.attributes.embedCode + '" embedType="' + props.attributes.embedType + '" width="' + props.attributes.width + '" height="' + props.attributes.height + '" aspectRatio="' + aspectRatio + '"]', 1669 ); 1670 }, 1671 }] 1672 1673 1674 901 1675 }) 902 1676 }) 903 1677 ( 904 1678 window.wp.blocks, 905 window.wp. editor,1679 window.wp.blockEditor, 906 1680 window.wp.i18n, 907 1681 window.wp.element, -
thron/trunk/admin/js/wp.media.library.js
r2343564 r2741703 1 function THRONcustomFilter(e){ 2 3 //pulizia elementi filtri mediatype "inutili" 4 if(jQuery(e).length){ 5 jQuery(e + " option[value='uploaded']").remove(); 6 jQuery(e + " option[value='unattached']").remove(); 7 jQuery(e + " option[value='mine']").remove(); 8 jQuery(e + " option[value='detached']").remove(); 9 } 10 11 if(jQuery('.mode-edit').length){ //variazione label in classic media (no modal) 12 jQuery('#media-attachment-thron-source-filter option[value="all"]').text(wp.i18n.__('Attached from THRON', 'thron')) 13 } 14 15 if(Array.isArray(myAjax.folders)){ 16 17 } 18 19 } 20 21 jQuery(document).ready(function ($) { 1 jQuery(document).ready(function($) { 22 2 23 3 /** … … 27 7 if (wp.media) { 28 8 29 // mi assicuro di essere in area media (modale e non)30 wp.media.view.Search.prototype.on("all", function () {31 9 32 //console.log(myAjax) 10 //wp.media.view.Attachment.prototype.template = wp.media.template('tmpl-attachment-details-two-column-custom'); 11 //wp.media.view.Attachment.Details.TwoColumn.prototype.template = wp.media.template('tmpl-attachment-details-two-column-custom'); 33 12 34 THRONcustomFilter('#media-attachment-filters') 35 $('.media-menu-item').on('click', function(){ 36 THRONcustomFilter('#media-attachment-filters') 37 }) 38 39 }); 13 //console.log(wp.media.view.Attachment.Details.TwoColumn.prototype.template) 40 14 41 if(jQuery('.view-list').length){ 42 THRONcustomFilter('#attachment-filter') 43 } 15 //jQuery(document).ready( function($) { 16 //console.log(wp.media.template('attachment-details-two-column-custom')) 17 /*if (typeof wp.media.view.Attachment != 'undefined') { 18 wp.media.view.Attachment.Details.TwoColumn.prototype.template = wp.media.template('attachment-details-two-column-custom'); 19 }*/ 20 //}); 21 22 // Ensure that the Modal is ready. 23 wp.media.view.Modal.prototype.on("all", function(e) { 24 //console.log(e); 25 }); 44 26 45 27 46 wp.media.view.Modal.prototype.on("close", function () {28 wp.media.view.Modal.prototype.on("close", function() { 47 29 48 var state = wp.media.frame.state(); 30 console.log('Inizio salvataggio...'); 31 32 var state = wp.media.frame.state(); 33 34 console.log('Stato: ' + state); 35 36 49 37 var selection = wp.media.frame.state().get('selection'); 38 50 39 var collection = wp.media.frame.content.get().collection; 40 41 console.log('Stato: ' + state.id); 42 51 43 switch (state.id) { 52 44 case "library": … … 54 46 * image 55 47 */ 56 selection.each(function (attachment) {48 selection.each(function(attachment) { 57 49 58 50 var element = collection.get(attachment.id); 51 52 console.log(attachment) 59 53 60 54 $.ajax({ … … 62 56 dataType: "json", 63 57 url: myAjax.ajaxurl, 64 data: { action: "thron_file_upload", 'thron_id': attachment.id},58 data: { action: "thron_file_upload", 'thron_id': attachment.id }, 65 59 async: false, 66 success: function (response) {60 success: function(response) { 67 61 if (response.success == true) { 68 62 69 element.set({ id: response.data.ID});70 element.set({ url: response.data.url});63 element.set({ id: response.data.ID }); 64 element.set({ url: response.data.url }); 71 65 72 collection.set({element}, {remove: false}) 73 } else { 74 } 66 collection.set({ element }, { remove: false }) 67 } else {} 75 68 } 76 69 }); … … 81 74 * image 82 75 */ 83 selection.each(function (attachment) {76 selection.each(function(attachment) { 84 77 85 78 var element = collection.get(attachment.id); … … 89 82 dataType: "json", 90 83 url: myAjax.ajaxurl, 91 data: { action: "thron_file_upload", 'thron_id': attachment.id},84 data: { action: "thron_file_upload", 'thron_id': attachment.id }, 92 85 async: false, 93 success: function (response) {86 success: function(response) { 94 87 if (response.success == true) { 95 88 96 element.set({ id: response.data.ID});97 element.set({ url: response.data.url});89 element.set({ id: response.data.ID }); 90 element.set({ url: response.data.url }); 98 91 99 collection.set({element}, {remove: false}) 100 } else { 101 } 92 collection.set({ element }, { remove: false }) 93 } else {} 102 94 } 103 95 }); … … 109 101 */ 110 102 111 selection.each(function (attachment) {103 selection.each(function(attachment) { 112 104 113 105 var element = collection.get(attachment.id); … … 123 115 }, 124 116 async: false, 125 success: function (response) {117 success: function(response) { 126 118 if (response.success == true) { 127 119 128 element.set({ id: response.data.ID});129 element.set({ url: response.data.url});120 element.set({ id: response.data.ID }); 121 element.set({ url: response.data.url }); 130 122 131 collection.set({element}, {remove: false}); 132 } else { 133 } 123 collection.set({ element }, { remove: false }); 124 } else {} 134 125 } 135 126 }); … … 141 132 */ 142 133 143 collection.each(function (attachment) { 134 collection.each(function(attachment) { 135 136 console.log(attachment); 144 137 145 138 var element = collection.get(attachment.id); … … 149 142 dataType: "json", 150 143 url: myAjax.ajaxurl, 151 data: { action: "thron_file_upload", 'thron_id': attachment.id},144 data: { action: "thron_file_upload", 'thron_id': attachment.id }, 152 145 async: false, 153 success: function (response) {146 success: function(response) { 154 147 if (response.success == true) { 155 148 156 element.set({ id: response.data.ID});157 element.set({ url: response.data.url});149 element.set({ id: response.data.ID }); 150 element.set({ url: response.data.url }); 158 151 159 collection.set({element}, {remove: false}) 160 } else { 161 } 152 collection.set({ element }, { remove: false }) 153 } else {} 162 154 } 163 155 }); … … 166 158 break; 167 159 } 160 161 console.log('Fine del salvataggio...'); 162 168 163 }); 164 169 165 } 166 170 167 }); -
thron/trunk/admin/js/wp.media.thron-view.js
r2343564 r2741703 2 2 wp.media.controller.Thron = wp.media.controller.State.extend({ 3 3 4 initialize: function () {4 initialize: function() { 5 5 // this model contains all the relevant data needed for the application 6 6 this.props = new Backbone.Model({ … … 24 24 25 25 // called each time the model changes 26 refresh: function () {26 refresh: function() { 27 27 // update the toolbar 28 28 this.frame.toolbar.get().refresh(); … … 30 30 31 31 // called when the toolbar button is clicked 32 insertCodeEmbed: function () {32 insertCodeEmbed: function() { 33 33 var playerembedtemplate = this.props.get('playerembedtemplate'); 34 34 var thron_id = this.props.get('thron_id'); … … 45 45 appId: myAjax.thron_appId, 46 46 appKey: myAjax.thron_appKey 47 }).then(function () {47 }).then(function() { 48 48 THRON.callApi( 49 "POST", 50 "/xcontents/resources/playerembedcode/insert/" + myAjax.thron_clientId, 51 { 49 'POST', 50 '/xcontents/resources/playerembedcode/insert/' + myAjax.thron_clientId, { 52 51 body: { 53 "skipPkeyCreation": true,54 "source": {55 "id": thron_id,56 "entityType": "CONTENT"52 'skipPkeyCreation': true, 53 'source': { 54 'id': thron_id, 55 'entityType': 'CONTENT' 57 56 }, 58 "value": {59 "name": "Name",60 "template": {61 "templateId": playerembedtemplate,62 "templateType": "CUSTOM"57 'value': { 58 'name': 'Name', 59 'template': { 60 'templateId': playerembedtemplate, 61 'templateType': 'CUSTOM' 63 62 }, 64 "enabled": true63 'enabled': true 65 64 } 66 65 } 67 }).then(function (response) { 66 }).then(function(response) { 67 // console.log('test'); 68 68 jQuery('#select_template').html(''); 69 69 … … 86 86 // THRON toolbar : contains the buttons at the bottom 87 87 wp.media.view.Toolbar.Thron = wp.media.view.Toolbar.extend({ 88 initialize: function () {88 initialize: function() { 89 89 _.defaults(this.options, { 90 90 event: 'thron_event', … … 105 105 106 106 // called each time the model changes 107 refresh: function () {107 refresh: function() { 108 108 // you can modify the toolbar behaviour in response to user actions here 109 109 // disable the button if there is no custom data … … 116 116 117 117 // triggered when the button is clicked 118 insertAction: function () {118 insertAction: function() { 119 119 this.controller.state().insertCodeEmbed(); 120 120 } … … 123 123 // THRON content : this view contains the main panel UI 124 124 wp.media.view.Thron = wp.media.View.extend({ 125 className: 'media-thron', 126 127 // bind view events 128 events: { 129 'input': 'thron_update', 130 'keyup': 'thron_update', 131 'change': 'thron_update', 132 'click': 'thron_update' 133 }, 134 135 api: null, 136 137 initialize: function () { 138 // create an input 139 this.input = this.make(); 140 141 this.model.set('thronCollection', new Backbone.Collection()); 142 this.model.set('embedType', 'responsive'); 143 144 145 // insert it in the view 146 this.$el.append(this.input); 147 148 // re-render the view when the model changes 149 this.model.on('change:thron_id', this.render, this); 150 151 var t = this; 125 className: 'media-thron', 126 127 // bind view events 128 events: { 129 'input': 'thron_update', 130 'keyup': 'thron_update', 131 'change': 'thron_update', 132 'click': 'thron_update' 133 }, 134 135 api: null, 136 137 initialize: function() { 138 // create an input 139 this.input = this.make(); 140 141 this.model.set('thronCollection', new Backbone.Collection()); 142 this.model.set('embedType', 'responsive'); 143 144 145 // insert it in the view 146 this.$el.append(this.input); 147 148 // re-render the view when the model changes 149 this.model.on('change:thron_id', this.render, this); 150 151 var t = this; 152 153 /** 154 * Download the list of templates 155 */ 156 this.api = THRON.init({ 157 clientId: myAjax.thron_clientId, 158 appId: myAjax.thron_appId, 159 appKey: myAjax.thron_appKey 160 }).then(function() { 161 162 THRON.callApi( 163 'POST', 164 '/xcontents/resources/playerembedtemplate/list/' + myAjax.thron_clientId, { 165 body: { 166 'criteria': { 167 'text': '' 168 }, 169 'offset': 0, 170 'options': { 171 'returnRoles': false, 172 'returnValues': false 173 } 174 } 175 }).then(function(response) { 176 jQuery('#select_template').html('').append(' <option value="">' + myAjax.selecttemplate + '</option>'); 177 178 _.each(response.items, function(template) { 179 selected = ''; 180 181 if (myAjax.thron_playerTemplates == template.id) { 182 selected = 'selected'; 183 t.model.set('playerembedtemplate', template.id); 184 } 185 186 jQuery('#select_template').append('<option value="' + template.id + '" selected >' + template.name + '</option>'); 187 }) 188 }); 189 }); 190 191 jQuery('body').addClass('wsthron'); 192 jQuery('.media-menu-item').not('.media-menu-item.active').click(function() { 193 jQuery('body').removeClass('wsthron'); 194 }); 195 196 setTimeout(function() { 197 jQuery('#thron_list').on('scroll', function() { 198 if (jQuery(this).scrollTop() + jQuery(this).innerHeight() >= jQuery(this)[0].scrollHeight) { 199 t.thron_search(true); 200 } 201 }); 202 }, 3000); 203 204 // mostra i primi risultati 205 this.thron_search(); 206 }, 207 208 render: function() { 209 this.input.value = this.model.get('thron_id'); 210 return this; 211 }, 212 213 make: function() { 214 215 var folder = ''; 216 var tags = ''; 217 218 if ('on' == myAjax.thron_enable_features_search) { 219 if (myAjax.tags.length > 0) { 220 _.each(myAjax.tags, function(value) { 221 if (myAjax.tags.length > 0) { 222 223 tags += '<select id="tag-' + value.id + '" class="attachment-filters">'; 224 tags += '<option value="">All ' + value.name + '</option>'; 225 226 _.each(value.list, function(value2) { 227 tags += '<option value="' + value2.id + ' ">'; 228 tags += value2.name; 229 tags += '</option>'; 230 }); 231 tags += '</select>'; 232 } 233 }) 234 } 235 } 236 237 if ((typeof myAjax.folders != 'undefined') & (myAjax.folders != null)) { 238 if (myAjax.folders.length > 0) { 239 folder += '<select id="folders" class="attachment-filters">'; 240 folder += '<option value="">' + myAjax.allfolders + '</option>'; 241 242 _.each(myAjax.folders, function(value) { 243 folder += '<option id="' + value.id + ' ">'; 244 folder += value.name 245 folder += '</option>'; 246 }) 247 folder += '</select>'; 248 } 249 } 250 251 return '<div id="thron_content">' + 252 ' <div class="media-toolbar" id="thron_toolbar">' + 253 ' <div class="media-toolbar-secondary">' + 254 ' <div class="media-toolbar-secondary__label"><label class="media-search-input-label">Filters</label></div>' + 255 ' <select id="mediaType" class="attachment-filters">' + 256 ' <option value="">' + myAjax.allcontent + '</option>' + 257 ' <option value="VIDEO">' + myAjax.videos +'</option>' + 258 ' <option value="AUDIO">' + myAjax.audio +'</option>' + 259 ' <option value="IMAGE">' + myAjax.images + '</option>' + 260 ' <option value="OTHER">' + myAjax.documents +'</option>' + 261 ' <option value="PLAYLIST">' + myAjax.playlist +'</option>' + 262 ' <option value="URL">' + myAjax.url +'</option>' + 263 ' <option value="PAGELET">' + myAjax.pagelet +'</option>' + 264 ' </select>' + 265 folder + 266 tags + 267 ' </div>' + 268 ' <div class="media-toolbar-primary search-form">' + 269 ' <label for="media-search-input" class="media-search-input-label">Cerca</label>' + 270 ' <input type="search" placeholder="Cerca" class="search" val="{data.value}" />' + 271 ' </div>' + 272 ' </div>' + 273 ' <div class="td-content-grid" id="thron_list"></div>' + 274 '</div>' + 275 '<div class="media-sidebar visible" id="thron_bar">' + 276 ' <div id="thron_attachments_preview"></div>' + 277 ' <div id="thron_playerembedtemplate_preview"></div>' + 278 ' <div class="media-uploader-status">' + 279 ' <div>' + 280 ' <label for="select_template">' + myAjax.playertemplate + '</label>' + 281 ' <select id="select_template" name="select_template"></select>' + 282 ' </div>' + 283 ' <div>' + 284 ' <label for="embedType">' + myAjax.embedtype + '</label>' + 285 ' <div class=\"input_container\"><input type="radio" val="responsive" id="responsive" name="embedType" checked /> Responsive<br \></div>' + 286 ' <div class=\"input_container\"><input type="radio" val="fixed" id="fixed" name="embedType" /> ' + myAjax.fixedsize + '</div>' + 287 ' </div>' + 288 ' <div class=\"sidebar_img-dimension\">' + 289 ' <input type="number" id="thron-player-width" val="" placeholder="' + myAjax.widthpx + '"/>' + 290 ' <div class=\"dimension_separator\"> X </div>' + 291 ' <input type="number" id="thron-player-height" val="" placeholder="' + myAjax.heightpx + '"/>' + 292 ' </div>' + 293 '</div>'; 294 }, 295 296 thron_update: function(event) { 297 var t = this; 298 299 var thron_id = event.target.getAttribute('data-id'); 300 301 if (thron_id) { 302 this.model.set('thron_id', thron_id); 152 303 153 304 /** 154 * Download the list of templates305 * Request content detils 155 306 */ 156 this.api = THRON.init({ 157 clientId: myAjax.thron_clientId, 158 appId: myAjax.thron_appId, 159 appKey: myAjax.thron_appKey 160 }).then(function () { 161 162 THRON.callApi( 163 "POST", 164 "/xcontents/resources/playerembedtemplate/list/" + myAjax.thron_clientId, 165 { 166 body: { 167 "criteria": { 168 "text": "" 169 }, 170 "offset": 0, 171 "options": { 172 "returnRoles": false, 173 "returnValues": false 174 } 175 } 176 }).then(function (response) { 177 jQuery('#select_template').html('').append(" <option value=\"\">" + myAjax.selecttemplate + "</option>"); 178 179 _.each(response.items, function (template) { 180 selected = ''; 181 182 if (myAjax.thron_playerTemplates == template.id) { 183 selected = 'selected'; 184 t.model.set('playerembedtemplate', template.id); 185 } 186 187 jQuery('#select_template').append("<option value=\"" + template.id + "\" selected >" + template.name + "</option>"); 188 }) 189 }); 190 }); 191 192 jQuery('body').addClass('wsthron'); 193 jQuery('.media-menu-item').not('.media-menu-item.active').click(function () { 194 jQuery('body').removeClass('wsthron'); 195 }); 196 197 setTimeout(function () { 198 jQuery('#thron_list').on('scroll', function () { 199 if (jQuery(this).scrollTop() + jQuery(this).innerHeight() >= jQuery(this)[0].scrollHeight) { 200 t.thron_search(); 201 } 202 }); 203 }, 3000); 204 205 // mostra i primi risultati 206 this.thron_search(''); 207 }, 208 209 render: function () { 210 this.input.value = this.model.get('thron_id'); 211 return this; 212 }, 213 214 make: function () { 215 216 var folder = ''; 217 var tags = ''; 218 219 if ('on' == myAjax.thron_enable_features_search) { 220 if (myAjax.tags.length > 0) { 221 _.each(myAjax.tags, function (value) { 222 if (myAjax.tags.length > 0) { 223 224 tags += '<select id="tag-' + value.id + '" class="attachment-filters">'; 225 tags += '<option value="">All ' + value.name + '</option>'; 226 227 _.each(value.list, function (value2) { 228 tags += '<option value="' + value2.id + ' ">'; 229 tags += value2.name; 230 tags += '</option>'; 231 }); 232 tags += '</select>'; 233 } 234 }) 307 THRON.callApi( 308 'GET', 309 '/xcontents/resources/delivery/getContentDetail?clientId=' + myAjax.thron_clientId + '&xcontentId=' + thron_id 310 ) 311 .then(function(response) { 312 313 deliverySize = response.content.deliverySize.aspectRatio.split(':'); 314 315 t.model.set('aspectRatio', deliverySize[1] / deliverySize[0]); 316 317 }); 318 319 jQuery('#thron_attachments_preview').html('<h2>' + myAjax.contentdetails + '</h2><div class="attachment-info"><div class="thumbnail thumbnail-image"><img src="https://' + myAjax.thron_clientId + '-view.thron.com/api/xcontents/resources/delivery/getThumbnail/' + myAjax.thron_clientId + '/150x150/' + thron_id + '" ></div></div>'); 320 } 321 322 if ('input' == event.type) { 323 /** 324 * Gestisce il tipo di embed: 325 * * responsive 326 * * fixed 327 */ 328 if ('embedType' == event.target.name) { 329 330 this.model.set('embedType', event.target.id); 331 } 332 333 /** 334 * Gestisce l'altezza e la larghezza dell'embed 335 */ 336 if ('thron-player-width' == event.target.id) { 337 this.model.set('width', event.target.value); 338 339 var aspectRatio = this.model.get('aspectRatio'); 340 if (aspectRatio) { 341 this.model.set('height', event.target.value * aspectRatio); 342 343 jQuery('#thron-player-height').val(event.target.value * aspectRatio) 235 344 } 236 345 } 237 346 238 if ((typeof myAjax.folders != "undefined") & (myAjax.folders != null)) { 239 if (myAjax.folders.length > 0) { 240 folder += '<select id="folders" class="attachment-filters">'; 241 folder += '<option value="">' + myAjax.allfolders + '</option>'; 242 243 _.each(myAjax.folders, function (value) { 244 folder += '<option id="' + value.id + ' ">'; 245 folder += value.name 246 folder += '</option>'; 247 }) 248 folder += '</select>'; 347 if ('thron-player-height' == event.target.id) { 348 this.model.set('height', event.target.value); 349 350 var aspectRatio = this.model.get('aspectRatio'); 351 if (aspectRatio) { 352 this.model.set('width', event.target.value * aspectRatio); 353 354 jQuery('#thron-player-width').val(event.target.value / aspectRatio) 249 355 } 250 356 } 251 357 252 return "<div class=\"media-toolbar\" style='position: absolute;right: 300px;top: 0;height: 72px; display: flex; justify-content: space-between; height: 110px; max-height: 250px; overflow: auto;'>" + 253 "<div class=\"media-toolbar-secondary\">" + 254 "<select id=\"mediaType\" class=\"attachment-filters\">" + 255 "<option value=\"\">" + myAjax.allcontent + "</option>" + 256 "<option value=\"VIDEO\">" + wp.i18n.__('Video', 'thron') + "</option>" + 257 "<option value=\"AUDIO\">" + wp.i18n.__('Audio', 'thron') + "</option>" + 258 "<option value=\"IMAGE\">" + wp.i18n.__('Image', 'thron') + "</option>" + 259 "<option value=\"OTHER\">" + wp.i18n.__('Document', 'thron') + "</option>" + 260 "<option value=\"PLAYLIST\">" + wp.i18n.__('Playlist', 'thron') + "</option>" + 261 "<option value=\"URL\">" + wp.i18n.__('Url', 'thron') + "</option>" + 262 "<option value=\"PAGELET\">" + wp.i18n.__('Pages', 'thron') + "</option>" + 263 "</select>" + 264 folder + 265 tags + 266 '</div>' + 267 '<div class="media-toolbar-primary search-form">' + 268 '<label for="media-search-input" class="media-search-input-label">Cerca</label>' + 269 "<input type=\"search\" placeholder=\"Cerca\" class=\"search\" val=\"{data.value}\" />" + 270 '</div>' + 271 '</div>' + 272 '<div id="thron_app" class="app">\n' + 273 '<div class="td-content-grid " id="thron_list">' + 274 '</div>' + 275 '<div class="media-sidebar visible" id="thron_bar">' + 276 '<div class="" id="thron_attachments_preview">' + 277 '</div>' + 278 '<div class="" id="thron_playerembedtemplate_preview">' + 279 '</div>' + 280 '<div class="media-uploader-status">' + 281 '<div>' + 282 '<label for="select_template">' + myAjax.playertemplate + '</label>' + 283 '<select id="select_template" name="select_template"></select></div>' + 284 '<div>' + 285 '<label for="embedType">'+myAjax.embedtype+'</label>' + 286 '<div class=\"input_container \"><input type="radio" val="responsive" id="responsive" name="embedType" checked /> Responsive<br \></div>' + 287 '<div class=\"input_container\"><input type="radio" val="fixed" id="fixed" name="embedType" /> ' + myAjax.fixedsize + 288 '</div></div>' + 289 '<div class=\"sidebar_img-dimension\">' + 290 '<input type="number" id="thron-player-width" val="" placeholder="'+myAjax.widthpx+'"/>' + 291 '<div class=\"dimension_separator\"> X </div>' + 292 '<input type="number" id="thron-player-height" val="" placeholder="'+myAjax.heightpx+'"/>' + 293 '</div>' + 294 '</div>' + 295 '</div>' + 296 '</div>' + 297 '</div>'; 298 }, 299 300 thron_update: function (event) { 301 var t = this; 302 303 var thron_id = event.target.getAttribute('data-id'); 304 305 if (thron_id) { 306 this.model.set('thron_id', thron_id); 307 308 /** 309 * Request content detils 310 */ 311 THRON.callApi( 312 "GET", 313 "/xcontents/resources/delivery/getContentDetail?clientId=" + myAjax.thron_clientId + "&xcontentId=" + thron_id 314 ) 315 .then(function (response) { 316 317 deliverySize = response.content.deliverySize.aspectRatio.split(':'); 318 319 t.model.set('aspectRatio', deliverySize[1] / deliverySize[0]); 320 321 }); 322 323 jQuery('#thron_attachments_preview').html('<h2>' + myAjax.contentdetails + '</h2><div class="attachment-info"><div class="thumbnail thumbnail-image"><img src="https://' + myAjax.thron_clientId + '-view.thron.com/api/xcontents/resources/delivery/getThumbnail/' + myAjax.thron_clientId + '/150x150/' + thron_id + '" ></div></div>'); 324 } 325 326 if ('input' == event.type) { 327 /** 328 * Gestisce il tipo di embed: 329 * * responsive 330 * * fixed 331 */ 332 if ('embedType' == event.target.name) { 333 334 this.model.set('embedType', event.target.id); 335 } 336 337 /** 338 * Gestisce l'altezza e la larghezza dell'embed 339 */ 340 if ('thron-player-width' == event.target.id) { 341 this.model.set('width', event.target.value); 342 343 var aspectRatio = this.model.get('aspectRatio'); 344 if (aspectRatio) { 345 this.model.set('height', event.target.value * aspectRatio); 346 347 jQuery('#thron-player-height').val(event.target.value * aspectRatio) 348 } 349 } 350 351 if ('thron-player-height' == event.target.id) { 352 this.model.set('height', event.target.value); 353 354 var aspectRatio = this.model.get('aspectRatio'); 355 if (aspectRatio) { 356 this.model.set('width', event.target.value * aspectRatio); 357 358 jQuery('#thron-player-width').val(event.target.value / aspectRatio) 359 } 360 } 361 362 /** 363 * Gestisce la folders 364 */ 365 if ('folders' == event.target.id) { 366 this.model.set('folders', event.srcElement.options[event.target.selectedIndex].id.trim()); 367 this.model.set('pageToken', null); 368 369 jQuery('#thron_list').html(''); 370 this.thron_search() 371 } 372 373 /** 374 * Gestisce i tags 375 */ 376 if ('tag-' == event.target.id.substring(0, 4)) { 377 var tags = this.model.get('tags') || new Array(); 378 var new_tags = new Array(); 379 380 var id = event.target.id.substring(4).split(';'); 381 382 _.each(tags, function (tag) { 383 if (id[1] != tag.parent) { 384 new_tags.push(tag); 385 } 386 }) 387 388 new_tags.push({ 389 id: event.srcElement.options[event.target.selectedIndex].value.trim(), 390 classificationID: id[0], 391 parent: id[1] 392 }); 393 394 this.model.set('tags', new_tags); 395 this.model.set('pageToken', null); 396 397 jQuery('#thron_list').html(''); 398 this.thron_search(); 399 } 400 401 /** 402 * Gestisce tipi di file 403 */ 404 if ('mediaType' == event.target.id) { 405 406 this.model.set('mediaType', event.target.value); 407 this.model.set('pageToken', null); 408 409 jQuery('#thron_list').html(''); 410 this.thron_search(); 411 } 412 } 413 414 if ('search' == event.target.type) { 415 this.model.set('search', event.target.value); 358 /** 359 * Gestisce la folders 360 */ 361 if ('folders' == event.target.id) { 362 this.model.set('folders', event.target.options[event.target.selectedIndex].id.trim()); 363 this.model.set('pageToken', null); 364 365 jQuery('#thron_list').html(''); 366 this.thron_search() 367 } 368 369 /** 370 * Gestisce i tags 371 */ 372 if ('tag-' == event.target.id.substring(0, 4)) { 373 var tags = this.model.get('tags') || new Array(); 374 var new_tags = new Array(); 375 376 var id = event.target.id.substring(4).split(';'); 377 378 _.each(tags, function(tag) { 379 if (id[1] != tag.parent) { 380 new_tags.push(tag); 381 } 382 }) 383 384 new_tags.push({ 385 id: event.target.options[event.target.selectedIndex].value.trim(), 386 classificationID: id[0], 387 parent: id[1] 388 }); 389 390 this.model.set('tags', new_tags); 416 391 this.model.set('pageToken', null); 417 392 … … 420 395 } 421 396 422 if ('select-one' == event.target.type) { 423 this.model.set('playerembedtemplate', event.target.value); 424 } 425 }, 426 427 thron_search: function () { 428 429 var t = this; 430 var pageToken = this.model.get('pageToken'); 431 432 433 var thronCollection = this.model.get('thronCollection'); 434 var search = this.model.get('search'); 435 var folders = this.model.get('folders'); 436 var tags = this.model.get('tags'); 437 var mediaType = this.model.get('mediaType'); 438 439 this.api = THRON.init({ 440 clientId: myAjax.thron_clientId, 441 appId: myAjax.thron_appId, 442 appKey: myAjax.thron_appKey 443 }).then(function () { 444 445 var body = {}; 446 body.criteria = {}; 447 448 if (search) { 449 body.criteria.lemma = {}; 450 body.criteria.lemma.text = search; 451 body.criteria.lemma.textMatch = "any_word_match"; 397 /** 398 * Gestisce tipi di file 399 */ 400 if ('mediaType' == event.target.id) { 401 402 this.model.set('mediaType', event.target.value); 403 this.model.set('pageToken', null); 404 405 jQuery('#thron_list').html(''); 406 this.thron_search(); 407 } 408 } 409 410 if ('search' == event.target.type) { 411 this.model.set('search', event.target.value); 412 this.model.set('pageToken', null); 413 414 jQuery('#thron_list').html(''); 415 this.thron_search(); 416 } 417 418 if ('select-one' == event.target.type) { 419 this.model.set('playerembedtemplate', event.target.value); 420 } 421 }, 422 423 requestId: -1, 424 425 thron_search: function(append) { 426 427 var t = this; 428 var pageToken = this.model.get('pageToken'); 429 430 var thronCollection = this.model.get('thronCollection'); 431 var search = this.model.get('search'); 432 var folders = this.model.get('folders'); 433 var tags = this.model.get('tags'); 434 var mediaType = this.model.get('mediaType'); 435 436 this.api = THRON.init({ 437 clientId: myAjax.thron_clientId, 438 appId: myAjax.thron_appId, 439 appKey: myAjax.thron_appKey 440 }).then(function() { 441 442 var body = {}; 443 body.criteria = {}; 444 445 if (search) { 446 body.criteria.lemma = {}; 447 body.criteria.lemma.text = search; 448 body.criteria.lemma.textMatch = 'any_word_match'; 449 } 450 451 if (folders) { 452 body.criteria.linkedCategories = {}; 453 body.criteria.linkedCategories.haveAtLeastOne = new Array({ 454 id: folders, 455 cascade: false 456 }); 457 } 458 459 if (tags) { 460 body.criteria.itag = {}; 461 body.criteria.itag.haveAll = []; 462 463 _.each(tags, function(tag) { 464 if (tag.id != '') { 465 body.criteria.itag.haveAll.push({ 466 id: tag.id, 467 classificationId: tag.classificationID, 468 cascade: false 469 }); 470 } 471 472 }); 473 } 474 475 if (mediaType) { 476 body.criteria.contentType = new Array(mediaType); 477 } 478 479 if (pageToken) { 480 body.pageToken = pageToken; 481 } 482 483 body.responseOptions = new Object(); 484 body.responseOptions.resultsPageSize = 50; 485 body.responseOptions.returnDetailsFields = new Array('locales', 'source'); 486 487 var currentRequestId = ++this.requestId; 488 489 THRON.callApi( 490 'POST', 491 '/xcontents/resources/content/search/' + myAjax.thron_clientId, { body: body } 492 ).then(function(response) { 493 // console.log(currentRequestId, this.requestId); 494 if (currentRequestId !== this.requestId) { 495 return; 452 496 } 453 497 454 /*if (folders) { 455 body.criteria.linkedCategories = {}; 456 body.criteria.linkedCategories.haveAtLeastOne = new Array({ 457 id: folders, 458 cascade: false 498 t.model.set('pageToken', response.nextPageToken); 499 500 var template = _.template( 501 '<div class="content">' + 502 ' <picture>'+ 503 ' <img class="thumb_img" data-id="<%- id %>" src="https://<%- clientId %>-view.thron.com/api/xcontents/resources/delivery/getThumbnail/<%- clientId %>/200x150/<%- id %>?scalemode=auto" \>' + 504 ' </picture>' + 505 ' <div class="label">' + 506 ' <span class="thron-type" data-value="<%- thronType %>"></span>' + 507 ' <span class="thron-extension"><%- extension %></span>' + 508 ' <span class="thron-label"><%- value %></span>' + 509 ' </div>' + 510 '</div>' 511 ); 512 513 var output = ''; 514 515 if (response.items.length === 0 && !append) { 516 output += '<div class="empty-results">' + i18n.__('No result for this search', 'thron') + '</div>'; 517 } 518 519 _.each(response.items, function(value) { 520 521 /** 522 * Aggiunge il content nella collection 523 */ 524 thronCollection.add(value); 525 526 output += template({ 527 id: value.id, 528 value: value.details.locales[0].name, 529 clientId: myAjax.thron_clientId, 530 thronType: value.contentType, 531 extension: typeof value.details.source !== 'undefined' ? value.details.source.extension : value.contentType 459 532 }); 460 }*/ 461 462 463 464 if (folders != null) { 465 body.criteria.linkedCategories = {}; 466 body.criteria.linkedCategories.haveAtLeastOne = new Array({ 467 id: folders, 468 cascade: (folders == myAjax.thron_list_folder ? true : false) 533 }); 534 535 if (append) { 536 jQuery('#thron_list').append(output); 537 } else { 538 jQuery('#thron_list').html(output); 539 } 540 541 jQuery('.content').click(function() { 542 jQuery.each(jQuery('.content'), function() { 543 jQuery(this).removeClass('selected'); 469 544 }); 470 } else { 471 body.criteria.linkedCategories = {}; 472 body.criteria.linkedCategories.haveAtLeastOne = new Array({ 473 id: myAjax.thron_list_folder, 474 cascade: true 475 }); 476 } 477 478 479 480 481 482 483 if (tags) { 484 body.criteria.itag = {}; 485 body.criteria.itag.haveAll = []; 486 487 _.each(tags, function (tag) { 488 if (tag.id != '') { 489 body.criteria.itag.haveAll.push({ 490 id: tag.id, 491 classificationId: tag.classificationID, 492 cascade: false 493 }); 494 } 495 496 }); 497 } 498 499 if (mediaType) { 500 body.criteria.contentType = new Array(mediaType); 501 } 502 503 if (pageToken) { 504 body.pageToken = pageToken; 505 } 506 507 body.responseOptions = new Object(); 508 body.responseOptions.resultsPageSize = 50; 509 body.responseOptions.returnDetailsFields = new Array("locales", "source"); 510 511 THRON.callApi( 512 "POST", 513 "/xcontents/resources/content/search/" + myAjax.thron_clientId, 514 {body: body} 515 ).then(function (response) { 516 517 t.model.set('pageToken', response.nextPageToken); 518 519 var template = _.template( 520 "<div class='content'><img class=\"thumb_img\" data-id = \"<%- id %>\" src='https://<%- clientId %>-view.thron.com/api/xcontents/resources/delivery/getThumbnail/<%- clientId %>/200x150/<%- id %>?scalemode=auto' \>" + 521 "<div class='label'>" + 522 "<span class='thron-type' data-value='<%- thronType %>'></span>'" + 523 "<span class='thron-extension'><%- extension %></span>'" + 524 "<span class='thron-label'><%- value %></span>'" + 525 "<%- value %>" + 526 "</div>" + 527 "</div>" 528 ); 529 530 var output = ''; 531 532 _.each(response.items, function (value) { 533 534 /** 535 * Aggiunge il content nella collection 536 */ 537 thronCollection.add(value); 538 539 output += template({ 540 id: value.id, 541 value: value.details.locales[0].name, 542 clientId: myAjax.thron_clientId, 543 thronType: value.contentType, 544 extension: typeof value.details.source != "undefined" ? value.details.source.extension : value.contentType.toLowerCase() 545 }); 546 547 }); 548 549 550 jQuery('#thron_list').append(output); 551 552 jQuery(".thumb_img").click(function () { 553 jQuery.each(jQuery(".content"), function () { 554 jQuery(this).removeClass('selected'); 555 }); 556 jQuery(this).parent().toggleClass("selected"); 557 if (jQuery("#select_template").val() == "") { 558 setTimeout(function () { 559 jQuery(".media-button-thron_event").prop("disabled", true); 560 }, 300) 561 } else { 562 setTimeout(function () { 563 jQuery(".media-button-thron_event").prop("disabled", false); 564 }, 300) 565 } 566 }); 567 568 jQuery("#select_template").change(function () { 569 if (jQuery("#select_template").val() == "") { 570 setTimeout(function () { 571 jQuery(".media-button-thron_event").prop("disabled", true); 572 }, 300) 573 } else { 574 setTimeout(function () { 575 jQuery(".media-button-thron_event").prop("disabled", false); 576 }, 300) 577 } 578 }); 579 580 jQuery(".thron-type, .thron-extension, .thron-label").click(function () { 581 jQuery(this).closest('.content').find('img').click(); 582 }); 583 584 jQuery(".media-toolbar-secondary select").change(function () { 585 setTimeout(function () { 586 if (jQuery("#thron_list .content").length < 8) jQuery(".wsthron #thron_list .content").css("flex-grow", "initial"); 587 }, 300); 588 }); 589 }); 590 591 }) 592 } 545 jQuery(this).toggleClass('selected'); 546 if (jQuery('#select_template').val() == '') { 547 setTimeout(function() { 548 jQuery('.media-button-thron_event').prop('disabled', true); 549 }, 300) 550 } else { 551 setTimeout(function() { 552 jQuery('.media-button-thron_event').prop('disabled', false); 553 }, 300) 554 } 555 }); 556 557 jQuery('#select_template').change(function() { 558 if (jQuery('#select_template').val() == '') { 559 setTimeout(function() { 560 jQuery('.media-button-thron_event').prop('disabled', true); 561 }, 300) 562 } else { 563 setTimeout(function() { 564 jQuery('.media-button-thron_event').prop('disabled', false); 565 }, 300) 566 } 567 }); 568 569 jQuery('.thron-type, .thron-extension, .thron-label').click(function() { 570 jQuery(this).closest('.content').find('img').click(); 571 }); 572 573 jQuery('.media-toolbar-secondary select').change(function() { 574 setTimeout(function() { 575 if (jQuery('#thron_list .content').length < 8) jQuery('.wsthron #thron_list .content').css('flex-grow', 'initial'); 576 }, 300); 577 }); 578 }.bind(this)); 579 580 }.bind(this)); 593 581 } 594 ) 595 ; 582 }); 596 583 597 584 // supersede the default MediaFrame.Post view … … 599 586 wp.media.view.MediaFrame.Post = oldMediaFrame.extend({ 600 587 601 initialize: function () {588 initialize: function() { 602 589 oldMediaFrame.prototype.initialize.apply(this, arguments); 603 590 … … 622 609 }, 623 610 624 createTHRONToolbar: function (toolbar) {611 createTHRONToolbar: function(toolbar) { 625 612 toolbar.view = new wp.media.view.Toolbar.Thron({ 626 613 controller: this … … 628 615 }, 629 616 630 thronAPP: function () {617 thronAPP: function() { 631 618 632 619 // this view has no router -
thron/trunk/includes/class-thron-api.php
r2343564 r2741703 78 78 foreach ( $categories as $category ) { 79 79 $criteria_categories .= '{ 80 "cascade": '.($category == get_option('thron_list_folder') ? 'true' : 'false').',80 "cascade": false, 81 81 "id": "' . $category . '" 82 82 },'; … … 85 85 $criteria_categories .= ']}'; 86 86 } 87 88 89 87 90 88 $criteria_tag .= '"itag": {"haveAll": ['; … … 150 148 } 151 149 } 152 153 154 150 155 151 $pageTokenBody = $pageToken ? '"pageToken": "' . $pageToken . '",' : ''; … … 183 179 ); 184 180 181 182 185 183 if ( is_wp_error( $response ) ) { 186 184 thron_write_log($response->get_error_message); … … 389 387 "options": { 390 388 "returnRoles": false, 391 "returnValues": false389 "returnValues": true 392 390 } 393 391 } … … 402 400 } else { 403 401 $result = json_decode( $response['body'] ); 404 405 402 return $result; 406 403 } -
thron/trunk/includes/class-thron.php
r2328652 r2741703 71 71 $this->version = THRON_VERSION; 72 72 } else { 73 $this->version = '1. 0.1';73 $this->version = '1.2.1'; 74 74 } 75 75 $this->plugin_name = 'thron'; … … 79 79 $this->define_admin_hooks(); 80 80 $this->define_public_hooks(); 81 82 81 } 83 82 … … 127 126 */ 128 127 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-thron-admin.php'; 128 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-thron-wp-rest-attachments-controller.php'; 129 129 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-thron-setting.php'; 130 130 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-thron-cron.php'; 131 131 132 133 132 134 /** 133 135 * The class responsible for defining all actions that occur in the public-facing … … 172 174 173 175 $plugin_admin = new Thron_Admin( $this->get_plugin_name(), $this->get_version() ); 176 $plugin_wp_rest_attachments_controller = new THRON_WP_REST_Attachments_Controller('attachments'); 174 177 $plugin_setting = new Thron_Setting( ); 175 178 $plugin_cron = new Thron_Cron( ); … … 203 206 204 207 208 //$this->loader->add_filter( 'media_send_to_editor', $plugin_admin, 'thron_add_tracking_class', 20, 3 ); 209 $this->loader->add_filter( 'wp_audio_shortcode_class', $plugin_admin, 'thron_add_tracking_class', 1, 1 ); 210 $this->loader->add_filter( 'wp_video_shortcode_class', $plugin_admin, 'thron_add_tracking_class', 1, 1 ); 205 211 /** 206 212 * Perform AJAX search in the media library … … 225 231 $this->loader->add_filter( 'attachment_fields_to_edit', $plugin_admin, 'thron_add_attachment_field', 10, 2 ); 226 232 $this->loader->add_action( 'edit_attachment', $plugin_admin, 'thron_save_attachment', 10, 3 ); 233 234 /** 235 * Insert overriding media template and attachments operation 236 */ 237 $this->loader->add_action( 'wp_enqueue_media', $plugin_admin, 'ws_add_overrides', 10, 2 ); 238 $this->loader->add_action( 'rest_api_init', $plugin_wp_rest_attachments_controller, 'add_custom_media_edit_api', 10, 2); 227 239 228 240 /** … … 256 268 $this->loader->add_action( 'enqueue_block_editor_assets', $plugin_admin, 'THRONBlock' ); 257 269 $this->loader->add_action( 'init', $plugin_admin, 'register_block_embed' ); 270 271 272 $this->loader->add_filter( 'media_library_infinite_scrolling', $plugin_admin, 'infinite_scroll_true'); 273 258 274 } 259 275 … … 282 298 $this->loader->add_filter( 'wp_get_attachment_image_attributes', $plugin_public, 'filter_wp_get_attachment_image_attributes', 10, 3 ); 283 299 300 284 301 /** 285 302 * Add class tci to image … … 287 304 $this->loader->add_filter( 'get_image_tag_class', $plugin_public, 'get_image_tag_class', 10, 3 ); 288 305 $this->loader->add_filter( 'wp_get_attachment_image_attributes', $plugin_public, 'wp_get_attachment_image_attributes', 10, 3 ); 306 $this->loader->add_filter( 'render_block', $plugin_public, 'add_tci_class', 10, 2 ); 289 307 290 308 } -
thron/trunk/includes/cmb2-field-ajax-search/cmb2-field-ajax-search.php
r2343564 r2741703 85 85 $value = $value[0]; 86 86 } 87 87 88 /** 88 89 * Se non è salvata nessuna folder utilizza la root folder 89 90 */ 90 if (! $value) {91 if (! $value) { 91 92 update_option( 'thron_list_folder', get_option( 'thron_rootCategoryId' ) ); 92 }else{ 93 update_option( 'thron_list_folder', $value ); 94 } 95 96 $value = get_option('thron_list_folder'); 93 $value = get_option('thron_list_folder'); 94 } 97 95 98 96 $input_value = $this->folderNameByID( $value ); -
thron/trunk/languages/thron-it_IT-thron-block.json
r2343564 r2741703 8 8 "lang": "it_IT" 9 9 }, 10 "Select template": [ 11 "Seleziona il template" 12 ], 10 13 "THRON Universal Player": [ 11 14 "THRON Universal Player" 12 15 ], 13 "Insert THRON player": [14 "Inserisci THRON player"15 ],16 16 "All content": [ 17 17 "Tutti i contenuti" 18 18 ], 19 "Image ": [19 "Images": [ 20 20 "Immagini" 21 21 ], 22 "Video ": [22 "Videos": [ 23 23 "Video" 24 24 ], … … 29 29 "Playlist" 30 30 ], 31 " Other": [32 " Altro"31 "Pagelet": [ 32 "Pagelet" 33 33 ], 34 " Url": [35 " Url"34 "Document (Other)": [ 35 "Documenti (altro)" 36 36 ], 37 "Pages": [ 38 "Pagine" 39 ], 40 "Document": [ 41 "Documento" 42 ], 43 "More": [ 44 "Continua" 37 "Apply": [ 38 "Applica" 39 ], 40 "Cancel": [ 41 "Annulla" 45 42 ], 46 43 "Width (px)": [ … … 53 50 "Mantieni aspect ratio" 54 51 ], 55 "Select content": [52 "Select a content": [ 56 53 "Seleziona un contenuto" 57 54 ], 58 "Select content from THRON": [55 "Select a content from THRON": [ 59 56 "Seleziona un contenuto da THRON" 57 ], 58 "Choose a content from your THRON Library.": [ 59 "Scegli un contenuto dalla tua libreria THRON." 60 ], 61 "Quality": [ 62 "Qualità" 63 ], 64 "Brightness": [ 65 "Luminosità" 66 ], 67 "Contrast": [ 68 "Contrasto" 69 ], 70 "Sharpness": [ 71 "Nitidezza" 72 ], 73 "Color": [ 74 "Colore" 60 75 ], 61 76 "Search": [ … … 68 83 "THRON OPTION" 69 84 ], 70 " Select template": [71 " Seleziona il template"85 "default template": [ 86 "THRON Customer Experience 1.x" 72 87 ], 73 "Attached from THRON": [ 74 "Allegato da THRON" 75 ], 88 "Image adjustments": [ 89 "Regolazioni immagine" 90 ], 91 "RTIE Params": [ 92 "RTIE Params" 93 ], 76 94 "Select embed type": [ 77 95 "Tipo di embed" … … 85 103 "All folders": [ 86 104 "Tutte le cartelle" 105 ], 106 "No result for this search": [ 107 "Nessun risultato per questa ricerca" 87 108 ] 88 109 } -
thron/trunk/languages/thron-it_IT.po
r2328652 r2741703 1 1 msgid "" 2 2 msgstr "" 3 "Language: it_IT\n"4 "POT-Creation-Date: 2020-05-26 16:27+0000\n"5 "Plural-Forms: nplurals=2; plural=n != 1;\n"6 "PO-Revision-Date: 2020-05-26 16:29+0000\n"7 "X-Generator: Loco https://localise.biz/\n"8 3 "Project-Id-Version: THRON\n" 9 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2020-05-26 16:27+0000\n" 6 "PO-Revision-Date: 2021-06-22 10:45+0200\n" 10 7 "Last-Translator: \n" 11 8 "Language-Team: Italiano\n" 9 "Language: it_IT\n" 12 10 "MIME-Version: 1.0\n" 13 11 "Content-Type: text/plain; charset=UTF-8\n" 14 12 "Content-Transfer-Encoding: 8bit\n" 15 "X-Loco-Version: 2.3.4; wp-5.4.1" 13 "Plural-Forms: nplurals=2; plural=n != 1;\n" 14 "X-Generator: Poedit 2.4.3\n" 15 "X-Loco-Version: 2.3.4; wp-5.4.1\n" 16 17 #: admin/class-thron-admin.php:567 admin/class-thron-admin.php:1456 18 msgid "Edit image on THRON" 19 msgstr "Modifica l'immagine in THRON" 20 21 #: admin/class-thron-admin.php:2628 22 msgid "Upload the content in THRON" 23 msgstr "Carica il contenuto su THRON" 24 25 #: admin/class-thron-admin.php:2634 26 msgid "upload the content in THRON" 27 msgstr "carica il contenuto su THRON" 16 28 17 29 #: admin/class-thron-admin.php:276 … … 167 179 "L'applicazione non è configurata correttamente. Contatta il supporto tecnico." 168 180 181 #: Content type: Videos 182 msgid "Videos" 183 msgstr "Video" 184 185 #: Content type: Images 186 msgid "Images" 187 msgstr "Immagini" 188 189 #: Content type: Documents 190 msgid "Document (Other)" 191 msgstr "Documenti (altro)" 192 169 193 #. Description of the plugin 170 194 msgid "" … … 178 202 msgid "https://www.thron.com" 179 203 msgstr "https://www.thron.com" 204 205 #~ msgid "Unable to get meta information for file." 206 #~ msgstr "Impossibile ottenere le informazioni meta per questo file." -
thron/trunk/languages/thron.pot
r2328652 r2741703 7 7 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 8 "X-Generator: Loco https://localise.biz/" 9 10 #: admin/class-thron-admin.php:567 admin/class-thron-admin.php:1456 11 msgid "Edit image on THRON" 12 msgstr "" 13 14 #: admin/class-thron-admin.php:2628 15 msgid "Upload the content in THRON" 16 msgstr "" 17 18 #: admin/class-thron-admin.php:2634 19 msgid "upload the content in THRON" 20 msgstr "" 9 21 10 22 #: admin/class-thron-admin.php:276 … … 155 167 msgstr "" 156 168 169 #: Content type: Videos 170 msgid "Videos" 171 msgstr "" 172 173 #: Content type: Images 174 msgid "Images" 175 msgstr "" 176 177 #: Content type: Documents 178 msgid "Document (Other)" 179 msgstr "" 180 157 181 #. Description of the plugin 158 182 msgid "" -
thron/trunk/public/class-thron-public.php
r2328652 r2741703 90 90 $contentID = $atts['contentid']; 91 91 $embedCodeId = $atts['embedcodeid']; 92 $scalemode = $atts['scalemode']; 93 $quality = $atts['quality']; 94 $brightness = $atts['brightness']; 95 $contrast = $atts['contrast']; 96 $sharpness = $atts['sharpness']; 97 $color = $atts['color']; 98 99 if($scalemode == 'manual'){ 100 $cropx = $atts['cropx']; 101 $cropy = $atts['cropy']; 102 $cropw = $atts['cropw']; 103 $croph = $atts['croph']; 104 } 92 105 93 106 $aspectRatio = $atts['aspectratio'] ? $atts['aspectratio'] : 75; … … 188 201 } 189 202 203 public function add_tci_class( $block_content, $block ) { 204 205 if ( 'core/image' === $block['blockName'] 206 || 'core/gallery' === $block['blockName'] 207 || 'core/media-text' === $block['blockName'] 208 || 'core/cover' === $block['blockName']) { 209 $block_content = str_replace('wp-image-', 'tci wp-image-', $block_content); 210 return $block_content; 211 } 212 213 if ( 'core/video' === $block['blockName'] ) { 214 $block_content = preg_replace_callback( '/(<video) (.*video>)/i', 215 function ( $matches ) { 216 return $matches[1] . ' class="tci" ' . $matches[2] ; 217 }, 218 $block_content ); 219 220 return $block_content; 221 } 222 223 if ( 'core/audio' === $block['blockName'] ) { 224 $block_content = preg_replace_callback( '/(<audio) (.*audio>)/i', 225 function ( $matches ) { 226 return $matches[1] . ' class="tci" ' . $matches[2] ; 227 }, 228 $block_content ); 229 230 return $block_content; 231 } 232 233 return $block_content; 234 } 235 190 236 public function filter_wp_get_attachment_image_attributes( $attr, $attachment, $size ) { 191 237 -
thron/trunk/public/partials/player.php
r2343564 r2741703 11 11 <script> 12 12 13 <?php if($scalemode == 'manual') { ?> 14 13 15 var options = { 14 16 <?= $tracking_context ? '"contextId": "' . $tracking_context . '",' : ''; ?> … … 16 18 "xcontentId": "<?= $contentID; ?>", 17 19 "sessId": "<?= $sessId; ?>", 18 "embedCodeId": "<?= $embedCodeId; ?>" 20 "embedCodeId": "<?= $embedCodeId; ?>", 21 "rtie": { 22 "cropmode": "pixel", 23 "quality":"<?=$quality?>", 24 "scalemode":"<?=$scalemode?>", 25 <?php if($cropx != ''){?> 26 "cropx" : <?=$cropx?>, 27 "cropy" : <?=$cropy?>, 28 "croph" : <?=$croph?>, 29 "cropw" : <?=$cropw?>, 30 <?php } ?> 31 "enhance":"brightness:<?=($brightness != '' ? $brightness : 100); ?>,contrast:<?=($contrast != '' ? $contrast : 100); ?>,sharpness:<?=($sharpness != '' ? $sharpness : 100); ?>,color:<?=($color != '' ? $color : 100); ?>" 32 } 19 33 }; 20 var player = THRONContentExperience("elementId_<?= $uniqID; ?>", options);34 <?php } else { ?> 21 35 22 console.log('from frontend'); 36 var options = { 37 <?= $tracking_context ? '"contextId": "' . $tracking_context . '",' : ''; ?> 38 "clientId": "<?= $clientId; ?>", 39 "xcontentId": "<?= $contentID; ?>", 40 "sessId": "<?= $sessId; ?>", 41 "embedCodeId": "<?= $embedCodeId; ?>", 42 "rtie": { 43 "cropmode": "pixel", 44 "quality":"<?=$quality?>", 45 "scalemode":"<?=$scalemode?>", 46 "enhance":"brightness:<?= $brightness; ?>,contrast:<?= $contrast; ?>,sharpness:<?= $sharpness; ?>,color:<?= $color; ?>" 47 } 48 }; 49 <?php }?> 50 console.log(options) 51 /*if(player) { 52 player.destroy(); 53 }*/ 23 54 55 //var player = 56 THRONContentExperience("elementId_<?= $uniqID; ?>", options); 24 57 </script> -
thron/trunk/thron.php
r2328652 r2741703 17 17 * Plugin URI: 18 18 * Description: Select the assets to insert within your pages directly from the DAM library 19 * Version: 1. 0.119 * Version: 1.2.1 20 20 * Author: THRON 21 21 * Author URI: https://www.thron.com … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'THRON_VERSION', '1. 0.7' );38 define( 'THRON_VERSION', '1.2.1' ); 39 39 define( 'THRON_PLUGIN_URL', plugin_dir_url(__FILE__) ); 40 40 define( 'THRON_PLUGIN_PATH', plugin_dir_path(__FILE__) );
Note: See TracChangeset
for help on using the changeset viewer.