@@ -646,30 +646,36 @@ ngApp
646646 constructor ( ) {
647647 let self = this ;
648648 self . rotateFunctions = {
649+ rotate0 : self . rotate0 . bind ( self ) ,
649650 rotate90 : self . rotate90 . bind ( self ) ,
650651 rotate180 : self . rotate180 . bind ( self ) ,
651652 rotate270 : self . rotate270 . bind ( self )
652653 }
653654
654655 $window . chrome . contextMenus . removeAll ( ( ) => {
656+ $window . chrome . contextMenus . create ( { title : 'Image Rotate (0deg)' , id : 'rotate-0' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate0 } , ( ) => { } ) ;
655657 $window . chrome . contextMenus . create ( { title : 'Image Rotate (90deg)' , id : 'rotate-90' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate90 } , ( ) => { } ) ;
656658 $window . chrome . contextMenus . create ( { title : 'Image Rotate (180deg)' , id : 'rotate-180' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate180 } , ( ) => { } ) ;
657659 $window . chrome . contextMenus . create ( { title : 'Image Rotate (270deg)' , id : 'rotate-270' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate270 } , ( ) => { } ) ;
658660
659661 $window . chrome . contextMenus . create ( { title : 'Utilities' , id : 'utilities' , contexts : [ 'image' ] } ) ;
660- $window . chrome . contextMenus . create ( { title : 'Image Rotate (90deg)' , id : 'utilities-rotate-90' , parentId : 'utilities' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate90 } , ( ) => { } ) ;
661- $window . chrome . contextMenus . create ( { title : 'Image Rotate (180deg)' , id : 'utilities-rotate-180' , parentId : 'utilities' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate180 } , ( ) => { } ) ;
662- $window . chrome . contextMenus . create ( { title : 'Image Rotate (270deg)' , id : 'utilities-rotate-270' , parentId : 'utilities' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate270 } , ( ) => { } ) ;
662+ $window . chrome . contextMenus . create ( { title : 'Image Rotate' , id : 'image-rotate' , parentId : 'utilities' , contexts : [ 'image' ] } ) ;
663+ $window . chrome . contextMenus . create ( { title : 'Image Rotate (0deg)' , id : 'utilities-rotate-0' , parentId : 'image-rotate' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate0 } , ( ) => { } ) ;
664+ $window . chrome . contextMenus . create ( { title : 'Image Rotate (90deg)' , id : 'utilities-rotate-90' , parentId : 'image-rotate' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate90 } , ( ) => { } ) ;
665+ $window . chrome . contextMenus . create ( { title : 'Image Rotate (180deg)' , id : 'utilities-rotate-180' , parentId : 'image-rotate' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate180 } , ( ) => { } ) ;
666+ $window . chrome . contextMenus . create ( { title : 'Image Rotate (270deg)' , id : 'utilities-rotate-270' , parentId : 'image-rotate' , contexts : [ 'image' ] , onclick : self . rotateFunctions . rotate270 } , ( ) => { } ) ;
663667 } ) ;
664668 }
669+ rotate0 ( info , tab ) { return this . rotate ( 0 , info , tab ) }
665670 rotate90 ( info , tab ) { return this . rotate ( 90 , info , tab ) }
666671 rotate180 ( info , tab ) { return this . rotate ( 180 , info , tab ) }
667672 rotate270 ( info , tab ) { return this . rotate ( 270 , info , tab ) }
668673 rotate ( angle , info , tab ) {
669674 if ( info . mediaType && info . mediaType === 'image' ) {
675+ let pathname = new URL ( info . srcUrl ) . pathname ;
670676 chrome . tabs . executeScript ( tab . id , { allFrames : true , code : `
671- document.querySelector("img[src='${ info . srcUrl } ']").style.transform = 'rotate(${ angle } deg)';
672- document.querySelector("img[src='${ info . srcUrl } ']").style.overflow = 'visible';
677+ document.querySelector("img[src* ='${ pathname } ']").style.transform = 'rotate(${ angle } deg)';
678+ document.querySelector("img[src* ='${ pathname } ']").style.overflow = 'visible';
673679 ` } , ( ) => {
674680 $window . _gaq . push ( [ '_trackEvent' , 'Utilities Event' , 'rotate' , `${ angle } ` , undefined , true ] ) ;
675681 } ) ;
0 commit comments