Ticket #31468: 31468.2.diff
File 31468.2.diff, 3.2 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/bookmarklet.js
1 1 ( function( window, document, href, pt_url ) { 2 var enc odeURI = window.encodeURIComponent,2 var encURI = window.encodeURIComponent, 3 3 form = document.createElement( 'form' ), 4 4 head = document.getElementsByTagName( 'head' )[0], 5 5 img = new Image(), 6 6 target = '_press_this_app', 7 canPost = true, 7 8 windowWidth, windowHeight, 8 9 metas, links, content, imgs, ifrs, 9 vid, selection ;10 vid, selection, newWin; 10 11 11 12 if ( ! pt_url ) { 12 13 return; 13 14 } 14 15 16 if ( href.match( /^https?:/ ) ) { 17 pt_url += '&u=' + encURI( href ); 18 if ( window.navigator.userAgent.indexOf( 'Firefox/' ) !== -1 && href.match( /^https:/ ) && pt_url.match( /^http:/ ) ) { 19 canPost = false; 20 } 21 } else { 22 top.location.href = pt_url; 23 return; 24 } 25 15 26 if ( window.getSelection ) { 16 27 selection = window.getSelection() + ''; 17 28 } else if ( document.getSelection ) { … … 22 33 23 34 pt_url += ( pt_url.indexOf( '?' ) > -1 ? '&' : '?' ) + 'buster=' + ( new Date().getTime() ); 24 35 25 if ( document.title.length && document.title.length <= 512) {26 pt_url += '&t=' + enc odeURI( document.title);36 if ( document.title.length && ( document.title.length <= 256 || ! canPost ) ) { 37 pt_url += '&t=' + encURI( document.title.substr( 0, 256 ) ); 27 38 } 28 39 29 if ( selection && selection.length <= 512) {30 pt_url += '&s=' + enc odeURI( selection);40 if ( selection && ( selection.length <= 512 || ! canPost ) ) { 41 pt_url += '&s=' + encURI( selection.substr( 0, 512 ) ); 31 42 } 32 43 33 if ( href.match( /^https?:/ ) ) { 34 pt_url += '&u=' + encodeURI( href ); 35 } else { 36 top.location.href = pt_url; 44 windowWidth = window.outerWidth || document.documentElement.clientWidth || 600; 45 windowHeight = window.outerHeight || document.documentElement.clientHeight || 700; 46 47 windowWidth = ( windowWidth < 800 || windowWidth > 5000 ) ? 600 : ( windowWidth * 0.7 ); 48 windowHeight = ( windowHeight < 800 || windowHeight > 3000 ) ? 700 : ( windowHeight * 0.9 ); 49 50 if ( ! canPost ) { 51 newWin = window.open( pt_url, target, 'location,resizable,scrollbars,width=' + windowWidth + ',height=' + windowHeight ); 52 newWin.focus(); 37 53 return; 38 54 } 39 55 … … 173 189 form.setAttribute( 'target', target ); 174 190 form.setAttribute( 'style', 'display: none;' ); 175 191 176 windowWidth = window.outerWidth || document.documentElement.clientWidth || 600; 177 windowHeight = window.outerHeight || document.documentElement.clientHeight || 700; 192 newWin = window.open( 'about:blank', target, 'location,resizable,scrollbars,width=' + windowWidth + ',height=' + windowHeight ); 178 193 179 windowWidth = ( windowWidth < 800 || windowWidth > 5000 ) ? 600 : ( windowWidth * 0.7 );180 windowHeight = ( windowHeight < 800 || windowHeight > 3000 ) ? 700 : ( windowHeight * 0.9 );181 182 window.open( 'about:blank', target, 'location,resizable,scrollbars,width=' + windowWidth + ',height=' + windowHeight );183 184 194 document.body.appendChild( form ); 195 form.submit(); 185 196 186 form.submit();197 newWin.focus(); 187 198 } )( window, document, top.location.href, window.pt_url );