Your IP : 3.147.47.202


Current Path : /usr/local/mgr5/skins/orion/src/
Upload File :
Current File : //usr/local/mgr5/skins/orion/src/App.Captcha.js

/**
 * Wrapper for google charts
 *  @param {object} window  global object
 *  @param {function} $ jQuery library
 *  @param {object} EventMgr EventMgr library
 *  @param {object} App Application
 *  @param {object} pageInfo
 */
/*global App: true*/
App.Captcha = function(window, $, EventMgr, App, pageInfo) {
  'use strict';
  var init = function() {
    EventMgr.bind('appendCaptcha', appendCaptcha);
  };

  function appendCaptcha(e, d) {
    var id = d.id,
        node = App.Dom.byId(id);
    if (window.grecaptcha && typeof window.grecaptcha.render === 'function' && node) {
      if (node.innerHTML === '') {
        renderCaptcha(node);
      } else {
        //if doesnt rerender tab after refresh
        setTimeout(function() {
          appendCaptcha(e, d);
        }, 100);
      }
    } else {
      appendScript(node);
    }
  }

  function appendScript(node) {
    var file = 'https://www.google.com/recaptcha/api.js';
    App.Common.required(file, renderCaptcha, node);
  }

  function renderCaptcha(node) {
    if (node) {
      window.grecaptcha.render(node, { sitekey: node.getAttribute('data-sitekey')});
    }
  }


  return {
    init: init
  };
}(window, $, EventMgr, App, pageInfo);