| 34 | 34 | title : [ { type : ATTRTYPE_OBJECT, name : 'title' }, { type : ATTRTYPE_EMBED, name : 'title' } ], |
| 35 | 35 | 'class' : [ { type : ATTRTYPE_OBJECT, name : 'class' }, { type : ATTRTYPE_EMBED, name : 'class'} ], |
| 36 | 36 | width : [ { type : ATTRTYPE_OBJECT, name : 'width' }, { type : ATTRTYPE_EMBED, name : 'width' } ], |
| | 171 | // There's only one committing process allowed each time to avoid cycling. |
| | 172 | var internalCommit; |
| | 173 | |
| | 174 | // Synchronous field values to other impacted fields when necessary, |
| | 175 | // e.g. alignment change should alter inline-style text as well. |
| | 176 | function commitInternally( targetFields ) |
| | 177 | { |
| | 178 | if( internalCommit ) |
| | 179 | return; |
| | 180 | |
| | 181 | var dialog = this.getDialog(), |
| | 182 | object = dialog.objectNode, |
| | 183 | embeded = dialog.embedNode; |
| | 184 | |
| | 185 | if( object || embeded ) |
| | 186 | { |
| | 187 | internalCommit = 1; |
| | 188 | // Commit this field and broadcast to target fields. |
| | 189 | this.commit( object, embeded ); |
| | 190 | |
| | 191 | targetFields = [].concat( targetFields ); |
| | 192 | var length = targetFields.length, |
| | 193 | field; |
| | 194 | for ( var i = 0; i < length; i++ ) |
| | 195 | { |
| | 196 | field = dialog.getContentElement.apply( dialog, targetFields[ i ].split( ':' ) ); |
| | 197 | field && field.setup( object, embeded ); |
| | 198 | } |
| | 199 | internalCommit = 0; |
| | 200 | } |
| | 201 | } |
| | 202 | |
| | 203 | |
| | 218 | onLoad : function() |
| | 219 | { |
| | 220 | // Custom commit dialog logic, where we're intended to give inline style |
| | 221 | // field (txtdlgGenStyle) higher priority to avoid overwriting styles contribute |
| | 222 | // by other fields. |
| | 223 | this.commitContent = function() |
| | 224 | { |
| | 225 | var args = arguments; |
| | 226 | var inlineStyleField = this.getContentElement( 'advanced', 'style' ); |
| | 227 | inlineStyleField && inlineStyleField.commit.apply( inlineStyleField, args ); |
| | 228 | |
| | 229 | this.foreach( function( widget ) |
| | 230 | { |
| | 231 | if ( widget.commit && widget.id != 'style' ) |
| | 232 | widget.commit.apply( widget, args ); |
| | 233 | }); |
| | 234 | } |
| | 235 | }, |
| 253 | | else |
| 254 | | { |
| 255 | | objectNode = this.objectNode; |
| 256 | | embedNode = this.embedNode; |
| 257 | | } |
| | 294 | |
| | 295 | this.objectNode = objectNode; |
| | 296 | this.embedNode = embedNode; |
| | 297 | |
| | 298 | this.setupContent( this.objectNode, this.embedNode, paramMap, fakeImage ); |
| | 299 | }, |
| | 300 | onOk : function() |
| | 301 | { |
| | 302 | var objectNode = this.objectNode, |
| | 303 | embedNode = this.embedNode, |
| | 304 | paramMap = null; |
| 564 | | [ editor.lang.common.notSet , ''], |
| 565 | | [ editor.lang.image.alignLeft , 'left'], |
| 566 | | [ editor.lang.image.alignAbsBottom , 'absBottom'], |
| 567 | | [ editor.lang.image.alignAbsMiddle , 'absMiddle'], |
| 568 | | [ editor.lang.image.alignBaseline , 'baseline'], |
| 569 | | [ editor.lang.image.alignBottom , 'bottom'], |
| 570 | | [ editor.lang.image.alignMiddle , 'middle'], |
| 571 | | [ editor.lang.image.alignRight , 'right'], |
| 572 | | [ editor.lang.image.alignTextTop , 'textTop'], |
| 573 | | [ editor.lang.image.alignTop , 'top'] |
| | 613 | [ editor.lang.common.notSet , '' ], |
| | 614 | [ editor.lang.flash.alignLeft , 'left' ], |
| | 615 | [ editor.lang.flash.alignRight , 'right' ] |
| 575 | | setup : loadValue, |
| 576 | | commit : commitValue |
| 577 | | }, |
| 578 | | { |
| | 617 | onChange : function() |
| | 618 | { |
| | 619 | commitInternally.call( this, 'advanced:style' ); |
| | 620 | }, |
| | 621 | setup : function( objectElement, embedElement ) |
| | 622 | { |
| | 623 | var element = objectElement || embedElement; |
| | 624 | |
| | 625 | if ( element ) |
| | 626 | { |
| | 627 | var value = element.getStyle( 'float' ); |
| | 628 | switch ( value ) |
| | 629 | { |
| | 630 | // Ignore those unrelated values. |
| | 631 | case 'inherit': |
| | 632 | case 'none': |
| | 633 | value = ''; |
| | 634 | } |
| | 635 | !value && ( value = ( element.getAttribute( 'align' ) || '' ).toLowerCase() ); |
| | 636 | this.setValue( value ); |
| | 637 | } |
| | 638 | }, |
| | 639 | commit : function( objectElement, embedElement ) |
| | 640 | { |
| | 641 | var element = objectElement || embedElement; |
| | 642 | if ( element ) |
| | 643 | { |
| | 644 | var value = this.getValue(); |
| | 645 | value ? element.setStyle( 'float', value ) |
| | 646 | : element.removeStyle( 'float' ); |
| | 647 | |
| | 648 | if ( !internalCommit ) |
| | 649 | { |
| | 650 | value = ( element.getAttribute( 'align' ) || '' ).toLowerCase(); |
| | 651 | switch ( value ) |
| | 652 | { |
| | 653 | // we should remove it only if it matches "left" or "right", |
| | 654 | // otherwise leave it intact. |
| | 655 | case 'left': |
| | 656 | case 'right': |
| | 657 | element.removeAttribute( 'align' ); |
| | 658 | } |
| | 659 | } |
| | 660 | } |
| | 661 | } |
| | 662 | }, |
| | 663 | { |
| 680 | | setup : loadValue, |
| 681 | | commit : commitValue |
| 682 | | } |
| | 765 | onChange : function () |
| | 766 | { |
| | 767 | commitInternally.call( this, |
| | 768 | [ 'properties:align' ] ); |
| | 769 | }, |
| | 770 | setup : function( objectElement, embedElement ) |
| | 771 | { |
| | 772 | var element = objectElement || embedElement; |
| | 773 | if ( element ) |
| | 774 | { |
| | 775 | var genStyle = element.getAttribute( 'style' ) |
| | 776 | || element.$.style.cssText; |
| | 777 | |
| | 778 | this.setValue( genStyle ); |
| | 779 | } |
| | 780 | }, |
| | 781 | commit : function( objectElement, embedElement ) |
| | 782 | { |
| | 783 | var element = objectElement || embedElement; |
| | 784 | element && element.setAttribute( 'style', this.getValue() ); |
| | 785 | } |
| | 786 | } |