MediaWiki:Gadget-campaignEventPagesAdd.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
( function () {
  function getDialog() {
 
    function CreateEventDialog( config ) {
      CreateEventDialog.parent.call( this, config );
    }
    OO.inheritClass( CreateEventDialog, OO.ui.ProcessDialog );
    CreateEventDialog.static.name = 'createEventDialog';
    CreateEventDialog.static.title = 'Add Organizer';
    CreateEventDialog.static.actions = [
					{
						action: 'continue',
						modes: 'edit',
						label: 'Save',
						flags: [ 'primary', 'constructive' ]
					},
					{
						action: 'cancel',
						modes: 'edit',
						label: 'Cancel',
						flags: 'safe'
					}
				];

    CreateEventDialog.prototype.initialize = function () {
      var self = this;
      CreateEventDialog.parent.prototype.initialize.call( this );

      this.curStepID = 'add-organizer';

      var userName = new OO.ui.TextInputWidget( {
        align: 'top',
        required: true,
        validate: 'non-empty'
        } ),

      background = new OO.ui.TextInputWidget( {
        align: 'top',
        required: true,
        validate: 'non-empty'
        } ),
        
      icon = new OO.ui.TextInputWidget( {
        align: 'top',
        } ),

      fieldset = new OO.ui.FieldsetLayout( {
        align: 'top',
        label: 'About the Organizer'
      } );

      fieldset.addItems( [
        new OO.ui.FieldLayout( userName, {
          label: 'Username',
          align: 'top',
          help: 'Your wiki username without "User:"',
          helpInline: true
        } ),
        new OO.ui.FieldLayout( background, {
          label: 'Background',
          align: 'top',
          help: 'Brief description about yourself',
          helpInline: true
        } ),
        new OO.ui.FieldLayout( icon, {
          label: 'Icon',
          align: 'top'
        } )
      ] );

      var addOrganizerForm = new OO.ui.FormLayout( {
        items: [ fieldset,
        //new OO.ui.FieldLayout( new OO.ui.Widget( { content: [ getSteplastButtons() ] }),{ align: 'top'} )
        ]
      } )
      $( document.body ).append( addOrganizerForm.$element );


      
      

        
      this.panelLayout = new OO.ui.PanelLayout( { padded: true, expanded: false } );
      this.panelLayout.$element.append(
        $( '<div />', { id: 'add-organizer' } ).append( addOrganizerForm.$element )
      );
      this.$body.append( this.panelLayout.$element );
    };
 
    CreateEventDialog.prototype.getBodyHeight = function () {
      return this.panelLayout.$element.outerHeight( true );
    };

    CreateEventDialog.prototype.getActionProcess = function ( action ) {
					var self = this;
					if ( action === 'continue' ) {//&& dialog.fieldType.getValue() ) {
						return new OO.ui.Process( function () {
							self.saveItem();
						} );
					} else {
						return new OO.ui.Process( function () {
							self.close();
						} );
					}
					return NewItemDialog.parent.prototype.getActionProcess.call( this, action );
				};

        CreateEventDialog.prototype.saveItem = function ( deleteFlag ) {
				//	var dialog = this, content;
	
					//dialog.pushPending();

        }


    return new CreateEventDialog( {
      size: 'medium'
    } );
  }
  
    var dialog, windowManager;
      function openDialog() {
        if ( !dialog ) {
        dialog = getDialog();
        windowManager = new OO.ui.WindowManager();
        $( 'body' ).append( windowManager.$element );
        windowManager.addWindows( [ dialog ] );     
      }
      windowManager.openWindow( dialog );
    }

//function addButton() {
 //   var btn = new OO.ui.ButtonInputWidget( {
 //     label: 'Add Organizer',
 //     flags: [
 //       'primary',
 //       'progressive'
 //     ]
 //   } )
 //     .on( 'click', openDialog );
 //   $( '#firstHeading' ).append( btn.$element );
 // }

  $( '.createEventPageAO' ).on( 'click', openDialog );


 // $( function () {
    mw.loader.using( [ 'mediawiki.util', 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows' ] );
 //     .done( addButton );
 // } );
} )();