pagelets/nodejitsu/login/base.js
function render(name, data) {
    var template;

    if (name !== 'login') {
      template = this.template(name, data || {});

      template.where('name').is('username').use('username').as('value');
      template.where('name').is('password').use('password').as('value');

      if (data && data.error) {
        template.className('error').use('error');
      } else {
        template.className('error').remove();
      }

      if (data && data.success) {
        template.className('success').use('success');
      } else {
        template.className('success').remove();
      }
    } else if (data && data.error) {
      // Hide the spinner and show the close button.
      $('.modal .close').removeClass('gone');
      $('.modal .spinner').addClass('gone');

      // Login request, but with data.. so the login failed
      $('.modal input[name="username"], .modal input[name="password"]').set(
        'readOnly',
        false
      );

      $('.modal button[type="submit"]')
        .removeClass('disabled loading')
        .set('innerHTML', 'Log in')
        .set('disabled', '');

      $('.modal .error').removeClass('gone').set('innerHTML', data.error);
    }

    Cortex.app('modal')
      .render(template)
      .once('done', this.close.bind(this, name));

    //
    // Check if we need to create a hidden input field with a redirect directive.
    //
    if (this.redirect) {
      $('.modal form input[name="redirect"]').set('value', this.redirect);
    }

    return this;
  }
function render(name, data) {
    var template;

    if (name !== 'login') {
      template = this.template(name, data || {});

      template.where('name').is('username').use('username').as('value');
      template.where('name').is('password').use('password').as('value');

      if (data && data.error) {
        template.className('error').use('error');
      } else {
        template.className('error').remove();
      }

      if (data && data.success) {
        template.className('success').use('success');
      } else {
        template.className('success').remove();
      }
    } else if (data && data.error) {
      // Hide the spinner and show the close button.
      $('.modal .close').removeClass('gone');
      $('.modal .spinner').addClass('gone');

      // Login request, but with data.. so the login failed
      $('.modal input[name="username"], .modal input[name="password"]').set(
        'readOnly',
        false
      );

      $('.modal button[type="submit"]')
        .removeClass('disabled loading')
        .set('innerHTML', 'Log in')
        .set('disabled', '');

      $('.modal .error').removeClass('gone').set('innerHTML', data.error);
    }

    Cortex.app('modal')
      .render(template)
      .once('done', this.close.bind(this, name));

    //
    // Check if we need to create a hidden input field with a redirect directive.
    //
    if (this.redirect) {
      $('.modal form input[name="redirect"]').set('value', this.redirect);
    }

    return this;
  }
function render ( name , data ) { var template ; if ( name !== 'login' ) { template = this . template ( name , data || { } ) ; template . where ( 'name' ) . is ( 'username' ) . use ( 'username' ) . as ( 'value' ) ; template . where ( 'name' ) . is ( 'password' ) . use ( 'password' ) . as ( 'value' ) ; if ( data && data . error ) { template . className ( 'error' ) . use ( 'error' ) ; } else { template . className ( 'error' ) . remove ( ) ; } if ( data && data . success ) { template . className ( 'success' ) . use ( 'success' ) ; } else { template . className ( 'success' ) . remove ( ) ; } } else if ( data && data . error ) { // Hide the spinner and show the close button. $ ( '.modal .close' ) . removeClass ( 'gone' ) ; $ ( '.modal .spinner' ) . addClass ( 'gone' ) ; // Login request, but with data.. so the login failed $ ( '.modal input[name="username"], .modal input[name="password"]' ) . set ( 'readOnly' , false ) ; $ ( '.modal button[type="submit"]' ) . removeClass ( 'disabled loading' ) . set ( 'innerHTML' , 'Log in' ) . set ( 'disabled' , '' ) ; $ ( '.modal .error' ) . removeClass ( 'gone' ) . set ( 'innerHTML' , data . error ) ; } Cortex . app ( 'modal' ) . render ( template ) . once ( 'done' , this . close . bind ( this , name ) ) ; // // Check if we need to create a hidden input field with a redirect directive. // if ( this . redirect ) { $ ( '.modal form input[name="redirect"]' ) . set ( 'value' , this . redirect ) ; } return this ; }
Render a new Modal window where the user can log his stuff

@param {Object} data
@api public
Render a new Modal window where the user can log his stuff