@@ -11,14 +11,14 @@ export default class Resizer {
1111 this . linkButton = document . querySelector ( `#${ main . id } .ptro-resize-widget-wrapper button.ptro-link` ) ;
1212 this . linkButtonIcon = document . querySelector ( `#${ main . id } .ptro-resize-widget-wrapper button.ptro-link i` ) ;
1313 this . closeButton = document . querySelector ( `#${ main . id } .ptro-resize-widget-wrapper button.ptro-close` ) ;
14- this . applyButton = document . querySelector ( `#${ main . id } .ptro-resize-widget-wrapper button.ptro-apply ` ) ;
15-
14+ this . scaleButton = document . querySelector ( `#${ main . id } .ptro-resize-widget-wrapper button.ptro-scale ` ) ;
15+ this . resizeButton = document . querySelector ( `# ${ main . id } .ptro-resize-widget-wrapper button.ptro-resize` ) ;
1616 this . linked = true ;
1717 this . closeButton . onclick = ( ) => {
1818 this . startClose ( ) ;
1919 } ;
2020
21- this . applyButton . onclick = ( ) => {
21+ this . scaleButton . onclick = ( ) => {
2222 const origW = this . main . size . w ;
2323 const origH = this . main . size . h ;
2424
@@ -40,6 +40,20 @@ export default class Resizer {
4040 img . src = tmpData ;
4141 } ;
4242
43+ this . resizeButton . onclick = ( ) => {
44+ const tmpData = this . main . canvas . toDataURL ( ) ;
45+ this . main . resize ( this . newW , this . newH ) ;
46+ this . main . clearBackground ( ) ;
47+ const img = new Image ( ) ;
48+ img . onload = ( ) => {
49+ this . main . ctx . drawImage ( img , 0 , 0 ) ;
50+ this . main . adjustSizeFull ( ) ;
51+ this . main . worklog . captureState ( ) ;
52+ this . startClose ( ) ;
53+ } ;
54+ img . src = tmpData ;
55+ } ;
56+
4357 this . linkButton . onclick = ( ) => {
4458 this . linked = ! this . linked ;
4559 if ( this . linked ) {
@@ -107,15 +121,16 @@ export default class Resizer {
107121 '</div>' +
108122 '<div class="ptro-resize-link-wrapper">' +
109123 `<button class="ptro-icon-btn ptro-link ptro-color-control" title="${ tr ( 'keepRatio' ) } ">` +
110- '<i class="ptro-icon ptro-icon-linked"></i>' +
124+ '<i class="ptro-icon ptro-icon-linked" style="font-size: 18px;" ></i>' +
111125 '</button>' +
112126 '</div>' +
113- '<div>' +
114- '<button class="ptro-named-btn ptro-apply ptro-color-control" ' +
115- 'style="margin-top: 8px;position: absolute; top: 95px; right: 75px;">' +
116- `${ tr ( 'apply' ) } </button>` +
117- '<button class="ptro-named-btn ptro-close ptro-color-control" ' +
118- 'style="margin-top: 8px;position: absolute; top: 95px; right: 10px;">' +
127+ '<div></div>' +
128+ '<div style="margin-top: 40px;">' +
129+ '<button class="ptro-named-btn ptro-resize ptro-color-control">' +
130+ `${ tr ( 'resizeResize' ) } </button>` +
131+ '<button class="ptro-named-btn ptro-scale ptro-color-control">' +
132+ `${ tr ( 'resizeScale' ) } </button>` +
133+ '<button class="ptro-named-btn ptro-close ptro-color-control">' +
119134 `${ tr ( 'cancel' ) } </button>` +
120135 '</div>' +
121136 '</div>' +
0 commit comments