MediaWiki:Common.js/OOUI-ProcessDialog.js

Tủ sách mở Wikibooks

Chú ý: Sau khi lưu trang, có thể bạn sẽ phải xóa bộ nhớ đệm của trình duyệt để xem các thay đổi.

  • Firefox / Safari: Nhấn giữ phím Shift trong khi nhấn Tải lại (Reload), hoặc nhấn tổ hợp Ctrl-F5 hay Ctrl-R (⌘R trên Mac)
  • Google Chrome: Nhấn tổ hợp Ctrl-Shift-R (⇧⌘R trên Mac)
  • Internet Explorer / Edge: Nhấn giữ phím Ctrl trong khi nhấn Làm tươi (Refresh), hoặc nhấn tổ hợp Ctrl-F5
  • Opera: Nhấn tổ hợp Ctrl-F5.
/* Mã JavaScript viết cho [[Bản mẫu:OOUI-ProcessDialog]] */

mw.loader.using(['oojs-ui-core', 'oojs-ui-windows'], function() {
	$(document).ready(function() {
		$('.processDialog-button').click(function() {
			setTimeout(function() {
				var targetHash = window.location.hash.substr(22);
				var content = $('#processDialog-content-' + targetHash);
				var title = $('#processDialog-content-' + targetHash + ' > .processDialog-title');
				var size = $('#processDialog-content-' + targetHash + ' > .processDialog-size');
				
				function MyProcessDialog( config ) {
				    MyProcessDialog.super.call( this, config );
				}
				OO.inheritClass( MyProcessDialog, OO.ui.ProcessDialog );
				
				MyProcessDialog.static.name = 'myProcessDialog';
				MyProcessDialog.static.title = title.text();
				MyProcessDialog.static.size = size.text();
				MyProcessDialog.static.actions = [
				    {label: 'OK', flags: 'primary' },
				];
				
				MyProcessDialog.prototype.initialize = function () {
				    MyProcessDialog.super.prototype.initialize.apply( this, arguments );
				    this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
				    this.content.$element.append( content.html() );
				    this.$body.append( this.content.$element );
				};
				MyProcessDialog.prototype.getActionProcess = function ( action ) {
				    var dialog = this;
				    if ( action ) {
				        return new OO.ui.Process( function () {
				            dialog.close( { action: action } );
				        } );
				    }
				    return MyProcessDialog.super.prototype.getActionProcess.call( this, action );
				};
				
				var windowManager = new OO.ui.WindowManager();
				$( document.body ).append( windowManager.$element );
				
				var dialog = new MyProcessDialog();
				windowManager.addWindows( [ dialog ] );
				windowManager.openWindow( dialog );
			}, 1);
		});
	});
});