| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
ve.ui.CollabProcessDialog = function VeUiCollabProcessDialog( config ) { |
| 7 |
ve.ui.CollabProcessDialog.super.call( this, config ); |
| 8 |
}; |
| 9 |
|
| 10 |
OO.inheritClass( ve.ui.CollabProcessDialog, OO.ui.ProcessDialog ); |
| 11 |
|
| 12 |
ve.ui.CollabProcessDialog.static.name = null; |
| 13 |
|
| 14 |
ve.ui.CollabProcessDialog.static.title = OO.ui.deferMsg( 'visualeditor-collab-dialog-title' ); |
| 15 |
|
| 16 |
ve.ui.CollabProcessDialog.static.imageUri = 'data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTAiIGhlaWdodD0iMTUwIiBzdHlsZT0ic3Ryb2tlOiNjY2NjY2M7c3Ryb2tlLXdpZHRoOjY7c3Ryb2tlLWxpbmVjYXA6cm91bmQiPg0KIDxyZWN0IHN0eWxlPSJmaWxsOndoaXRlO3N0cm9rZTp3aGl0ZSIgd2lkdGg9IjI1MCIgaGVpZ2h0PSIxNTAiIC8+DQogPHBhdGggZD0iTSAzMCwzMEggNzciIC8+DQogPHBhdGggZD0iTSA5MCwzMEggMTM0IiAvPg0KIDxwYXRoIGQ9Ik0gMTQ3LDMwSCAyMjAiIC8+DQogPHBhdGggZD0iTSAzMCw1MEggMTY4IiBzdHlsZT0ic3Ryb2tlOiNmZmNiMzMiIC8+DQogPHBhdGggZD0iTSAxODAsNTBIIDIyMCIgLz4NCiA8cGF0aCBkPSJNIDMwLDcwSCAxMTUiIHN0eWxlPSJzdHJva2U6I2U4NTdjOCIgLz4NCiA8cGF0aCBkPSJNIDEyOCw3MEggMjIwIiAvPg0KIDxwYXRoIGQ9Ik0gMzAsOTBIIDQ3IiAvPg0KIDxwYXRoIGQ9Ik0gNjAsOTBIIDEzOCIgLz4NCiA8cGF0aCBkPSJNIDE1MSw5MEggMjIwIiBzdHlsZT0ic3Ryb2tlOiMwMGFmODkiIC8+DQogPHBhdGggZD0iTSAzMCwxMTBIIDIyMCIgLz4NCiA8cGF0aCBkPSJNIDMwLDEzMEggOTgiIC8+DQogPHBhdGggZD0iTSAxMTEsMTMwSCAyMjAiIC8+DQo8L3N2Zz4='; |
| 17 |
|
| 18 |
ve.ui.CollabProcessDialog.static.actions = [ |
| 19 |
{ |
| 20 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-done' ), |
| 21 |
flags: [ 'safe', 'close' ] |
| 22 |
} |
| 23 |
]; |
| 24 |
ve.ui.CollabProcessDialog.prototype.initialize = function () { |
| 25 |
ve.ui.CollabProcessDialog.super.prototype.initialize.apply( this, arguments ); |
| 26 |
|
| 27 |
this.stack = new OO.ui.StackLayout( { |
| 28 |
expanded: false |
| 29 |
} ); |
| 30 |
|
| 31 |
this.initPanel = new OO.ui.PanelLayout( { |
| 32 |
padded: true, |
| 33 |
expanded: false |
| 34 |
} ); |
| 35 |
|
| 36 |
this.userNameInput = new OO.ui.TextInputWidget( { |
| 37 |
value: mw.user.getName() |
| 38 |
} ); |
| 39 |
const userNameField = new OO.ui.FieldLayout( this.userNameInput, { |
| 40 |
label: ve.msg( 'visualeditor-rebase-client-author-name' ), |
| 41 |
align: 'left' |
| 42 |
} ); |
| 43 |
|
| 44 |
this.initButton = new OO.ui.ButtonWidget( { |
| 45 |
flags: [ 'primary', 'progressive' ] |
| 46 |
} ); |
| 47 |
this.initButton.$element[ 0 ].style.display = 'block'; |
| 48 |
this.initButton.$element[ 0 ].firstElementChild.style.minWidth = '100%'; |
| 49 |
const initButtonField = new OO.ui.FieldLayout( this.initButton ); |
| 50 |
|
| 51 |
this.$summary = $( '<p>' ); |
| 52 |
|
| 53 |
this.initPanel.$element.append( |
| 54 |
$( '<img>' ).prop( 'src', ve.ui.CollabProcessDialog.static.imageUri ) |
| 55 |
.attr( { width: 250, height: 150 } ) |
| 56 |
.css( { display: 'block', margin: '2em auto' } ), |
| 57 |
this.$summary.css( { 'font-weight': 'bold' } ), |
| 58 |
$( '<p>' ).text( ve.msg( 'visualeditor-collab-dialog-sharing' ) ), |
| 59 |
$( '<p>' ).text( ve.msg( 'visualeditor-collab-dialog-sessionend' ) ), |
| 60 |
$( '<p>' ).text( ve.msg( 'visualeditor-collab-dialog-privacy' ) ), |
| 61 |
userNameField.$element, |
| 62 |
initButtonField.$element |
| 63 |
); |
| 64 |
|
| 65 |
this.stack.addItems( [ |
| 66 |
this.initPanel |
| 67 |
] ); |
| 68 |
|
| 69 |
this.$body.append( this.stack.$element ); |
| 70 |
this.initButton.connect( this, { click: 'onButtonClick' } ); |
| 71 |
}; |
| 72 |
|
| 73 |
ve.ui.CollabProcessDialog.prototype.getBodyHeight = function () { |
| 74 |
return this.stack.$element.outerHeight( true ); |
| 75 |
}; |
| 76 |
|
| 77 |
ve.ui.CollabProcessDialog.prototype.onButtonClick = function () { |
| 78 |
this.close( { action: 'accept', userName: this.userNameInput.getValue() } ); |
| 79 |
}; |
| 80 |
|
| 81 |
ve.ui.CollabProcessDialog.prototype.getReadyProcess = function ( data ) { |
| 82 |
return ve.ui.CollabProcessDialog.super.prototype.getReadyProcess.call( this, data ) |
| 83 |
.next( function () { |
| 84 |
switch ( this.stack.getCurrentItem() ) { |
| 85 |
case this.initPanel: |
| 86 |
this.initButton.focus(); |
| 87 |
break; |
| 88 |
case this.copyPanel: |
| 89 |
this.copyTextLayout.button.focus(); |
| 90 |
break; |
| 91 |
} |
| 92 |
}, this ); |
| 93 |
}; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
ve.ui.HostCollabProcessDialog = function VeUiHostCollabProcessDialog( config ) { |
| 101 |
ve.ui.HostCollabProcessDialog.super.call( this, config ); |
| 102 |
}; |
| 103 |
|
| 104 |
OO.inheritClass( ve.ui.HostCollabProcessDialog, ve.ui.CollabProcessDialog ); |
| 105 |
|
| 106 |
ve.ui.HostCollabProcessDialog.static.name = 'hostCollabDialog'; |
| 107 |
|
| 108 |
ve.ui.HostCollabProcessDialog.prototype.initialize = function () { |
| 109 |
ve.ui.HostCollabProcessDialog.super.prototype.initialize.apply( this, arguments ); |
| 110 |
|
| 111 |
this.initButton.setLabel( ve.msg( 'visualeditor-collab-hostbutton-label' ) ); |
| 112 |
this.initButton.setIcon( 'userAdd' ); |
| 113 |
this.$summary.text( ve.msg( 'visualeditor-collab-dialog-summary-host' ) ); |
| 114 |
|
| 115 |
this.copyPanel = new OO.ui.PanelLayout( { |
| 116 |
padded: true, |
| 117 |
expanded: false |
| 118 |
} ); |
| 119 |
this.afterCopyButton = new OO.ui.ButtonWidget( { |
| 120 |
flags: [ 'primary', 'progressive' ], |
| 121 |
label: ve.msg( 'visualeditor-dialog-action-done' ) |
| 122 |
} ); |
| 123 |
this.copyTextLayout = new OO.ui.CopyTextLayout(); |
| 124 |
this.copyPanel.$element.append( |
| 125 |
new OO.ui.FieldsetLayout( { |
| 126 |
label: ve.msg( 'visualeditor-collab-copy-title' ), |
| 127 |
items: [ |
| 128 |
this.copyTextLayout, |
| 129 |
new OO.ui.FieldLayout( this.afterCopyButton ) |
| 130 |
] |
| 131 |
} ).$element |
| 132 |
); |
| 133 |
this.stack.addItems( [ this.copyPanel ] ); |
| 134 |
|
| 135 |
this.afterCopyButton.on( 'click', this.close.bind( this ) ); |
| 136 |
}; |
| 137 |
|
| 138 |
ve.ui.HostCollabProcessDialog.prototype.onButtonClick = function () { |
| 139 |
this.initButton.setDisabled( true ); |
| 140 |
this.pushPending(); |
| 141 |
|
| 142 |
ve.collab.initPeerServer( this.userNameInput.getValue() ); |
| 143 |
const collabUrl = new URL( location.href ); |
| 144 |
ve.collab.peerServer.peer.on( 'open', ( newId ) => { |
| 145 |
collabUrl.searchParams.set( 'collabSession', newId ); |
| 146 |
this.copyTextLayout.textInput.setValue( collabUrl ); |
| 147 |
this.stack.setItem( this.copyPanel ); |
| 148 |
this.updateSize(); |
| 149 |
this.copyTextLayout.button.focus(); |
| 150 |
this.popPending(); |
| 151 |
} ); |
| 152 |
}; |
| 153 |
|
| 154 |
ve.ui.windowFactory.register( ve.ui.HostCollabProcessDialog ); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
ve.ui.JoinCollabProcessDialog = function VeUiJoinCollabProcessDialog( config ) { |
| 162 |
ve.ui.JoinCollabProcessDialog.super.call( this, config ); |
| 163 |
}; |
| 164 |
|
| 165 |
OO.inheritClass( ve.ui.JoinCollabProcessDialog, ve.ui.CollabProcessDialog ); |
| 166 |
|
| 167 |
ve.ui.JoinCollabProcessDialog.static.name = 'joinCollabDialog'; |
| 168 |
|
| 169 |
ve.ui.JoinCollabProcessDialog.prototype.initialize = function () { |
| 170 |
ve.ui.JoinCollabProcessDialog.super.prototype.initialize.apply( this, arguments ); |
| 171 |
|
| 172 |
this.initButton.setLabel( ve.msg( 'visualeditor-collab-joinbutton-label' ) ); |
| 173 |
this.initButton.setIcon( 'userGroup' ); |
| 174 |
this.$summary.text( ve.msg( 'visualeditor-collab-dialog-summary-join' ) ); |
| 175 |
}; |
| 176 |
|
| 177 |
ve.ui.windowFactory.register( ve.ui.JoinCollabProcessDialog ); |