function () {
function wrapped() {
(function (window) {
/**
* This is the SMCX singleton for the publisher DOM
*/
var SMCX = window.SMCX = new (function PublisherSMCX() {
var that = this;
/**
* Before SMCX is initialized, it is an array that holds any user-defined
* settings created via `SMCX.push`. When SMCX is initialized, it consumes
* the original array, passing it along to the App's Configuration object,
* but continues to act like an array with push semantics (i.e. users can
* still call `SMCX.push`)
*/
that.__settings__ = window.SMCX || [];
that.push = function () {
that.__settings__.push.apply(that.__settings__, arguments);
};
that.onerror = window.onerror;
/**
* Pass this as a query parameter in the publisher page's URL to enable
* debug mode within the application
*
* Usage:
*
* http://www.example.com/pages/test?smcx_debug=true
*
*/
that.DEBUG_QUERY_PARAM = 'smcx_debug';
that.initialize = function (options) {
log("Initializing SMCX");
withDocumentBody(function () {
if (shouldAbortInit()) {
log("Aborted");
return;
}
// A dictionary of performance data, see `SMCX.Sandbox.T` for usage
that.PERF = {0: +new Date};
options.perf = that.PERF;
options.settings = that.__settings__;
that.env = new SMCX.Publisher.Env;
that.env.initialize(options);
});
};
that.boot = function () {
if (that.env) {
that.env.boot();
}
};
that.destroy = function () {
that.__settings__ = [];
if (that.env) {
that.env.destroy();
that.env = null;
}
};
that.debug = function () {
if (that.env && that.env.DEBUG) {
return true;
}
var queryParams = SMCX.Utils.queryParams(window);
return queryParams.indexOf(that.DEBUG_QUERY_PARAM) !== -1;
};
function withDocumentBody(callback) {
if (document.body) {
return callback();
}
// Poll for up to 10 seconds to see if `document.body`
// shows up for the party
var id, count = 0;
id = setInterval(function () {
if (document.body || count > 100) {
clearInterval(id);
if (document.body) {
callback();
}
}
log("Called withDocumentBody");
count++;
}, 100);
}
function shouldAbortInit() {
// Abort if the browser doesn't support cross-domain messaging
if (!SMCX.Utils.xdmSupported(window)) {
return true;
}
// Abort if on IE8 and we would be adding more stylesheets than it can
// handle (we add 2 and it can support up to 30)
if (SMCX.Utils.browserHasLowStylesLimit(window) &&
SMCX.Utils.numStyles(window) > 28) {
return true;
}
return false;
}
// Logging
function log(message) {
SMCX.log(message);
}
})();
window.SMCX.Publisher = {};
}(window));
(function (window) {
/**
* This is the SMCX JS SDK log function
*
* If you're looking for the main application's log function, it lives
* at `/app/assets/javascripts/lib/log.js`
*
*/
window.SMCX.log = function (message, options) {
options = options || {};
if (SMCX.debug() || options.force) {
if (window.console) {
// Only add namespaces to messages that are strings so as not to mess up
// the nice object inspection functionality in modern browsers
if (typeof message === 'string') {
if (options.namespace) {
message = '[smcx.' + options.namespace + '] ' + message;
} else {
message = '[smcx] ' + message;
}
}
console.log(message);
}
}
};
}(window));
(function (window) {
window.SMCX.Utils = {
/**
* Get the query parameters from the target window's URL
*
* @param targetWindow Window
* @returns String
*/
queryParams: function (targetWindow) {
return targetWindow.document.location.search;
},
/**
* Determine if the current viewport is a mobile device
*
* @returns Boolean
*/
onMobile: function (targetWindow) {
var innerWidth, clientWidth, width;
clientWidth = targetWindow.document.documentElement.clientWidth;
innerWidth = targetWindow.innerWidth;
width = Math.max(innerWidth, clientWidth || 0);
return width <= 760;
},
/**
* Check if the browser supports cross-domain messaging (XDM)
*
* To support XDM, browsers need to implement the `postMessage` method,
* which is true for IE8+ and all modern browsers
*
* @param targetWindow
* @returns Boolean
*/
xdmSupported: function (targetWindow) {
return !!targetWindow['postMessage'];
},
/**
* Detect whether the current browser has a low stylesheet limit
*
* This is used when determining whether to initialize a widget (which would
* inject another stylesheet) because IE8 has a hard limit of 31 stylesheets
* and/or style tags on a given page
*
* FYI: modern browsers have a limit in the thousands, so for all intents
* and purposes, we don't need to care about stylesheet limits on any
* browser other than IE8
*
* @returns Boolean
*/
browserHasLowStylesLimit: function (targetWindow) {
return !('getComputedStyle' in targetWindow);
},
/**
* Get the # of stylesheets and style tags on the page
*
* @param targetWindow Window
* @returns Integer
*/
numStyles: function (targetWindow) {
var doc, numLinks, numStyles;
doc = targetWindow.document;
numLinks = doc.getElementsByTagName('link').length;
numStyles = doc.getElementsByTagName('style').length;
return numLinks + numStyles;
}
}
}(window));
/**
* This is the SMCX singleton for the publisher DOM
*/
(function (window, document, undefined) {
var Env = SMCX.Publisher.Env = function () {
var that = this;
/**
*
* @param options
* @param options.sandbox
* @param options.sandbox.init (optional)
* @param options.sandbox.boot (optional)
* @param options.sandbox.js
* @param options.sandbox.data
*/
this.initialize = function (options) {
/**
* Set which type of singleton this is so it's possible to differentiate
* among the three different types
*
* @type String
* @private
*/
that.__TYPE__ = 'publisher';
/**
* The current environment
*
* This is originally set by the parameter passed to `InitV{n}View` on
* the server
*
* @type String
*/
that.NAME = options.env;
that.DEBUG = options.debug;
log("Initializing environment (type=publisher, mode=" + that.NAME + ")");
that.options = extractOptions(options);
that.settings = that.options.settings;
// reference to the sandboxed SMCX singleton
that.__SMCX__ = null;
that.events = {
'smcx.container:sdkjs:loaded': [onSandboxedJSLoaded],
'smcx.sandbox:init': [],
'smcx.sandbox:boot': []
};
that.container = new SMCX.Publisher.Container();
that.container.initialize(optionsForContainer());
};
function extractOptions(options) {
if (options.sandbox === undefined) {
throw("`options.sandbox` must be defined");
}
if (options.sandbox.data === undefined) {
throw("`options.sandbox.data` must be defined");
}
if (options.sandbox.js === undefined) {
throw("`options.sandbox.js` must be defined");
}
if (typeof(options.sandbox.js) !== 'string') {
throw("`options.sandbox.js` must be a string");
}
if (that.DEBUG) {
options.sandbox.js = JSON.parse(options.sandbox.js);
}
if (typeof(options.sandbox.data) !== 'object') {
throw("`options.sandbox.data` must be an object");
}
if (options.data['cookie_url'] === undefined) {
throw("`options.data.cookie_url` must be defined");
}
if (options.sandbox.init === undefined) {
options.sandbox.init = true;
}
if (options.sandbox.boot === undefined) {
options.sandbox.boot = true;
}
return options;
}
this.boot = function () {
configureContainer(that.container);
that.container.render();
};
this.addCallback = function (eventName, callback) {
if (that.events[eventName] === undefined) {
throw(eventName + ' is not a valid event name');
}
that.events[eventName].push(callback);
};
this.trigger = function () {
var eventName = Array.prototype.shift.apply(arguments); // pop first arg
logEvent(eventName);
runCallbacksFor(eventName, arguments);
}
this.destroy = function () {
log("Destroying SMCX (type=publisher)");
that.settings = [];
if (that.__SMCX__) {
that.__SMCX__.destroy();
that.__SMCX__ = null;
}
// NB: destroying the container (and its frame) must come after its child
// objects are destroyed and events unbound, otherwise it creates a race
// condition that can cause script errors
if (that.container) {
that.container.destroy();
that.container = null;
}
};
this.debug = function () {
return that.DEBUG;
};
// Container
function optionsForContainer() {
return {
debug: that.DEBUG,
div: {
id: '__smcx__'
},
frame: {
id: 'smcx_frame'
}
}
}
/**
* Build up the HTML we want to `document.write` into the container's frame
*
* @param container
*/
function configureContainer(container) {
container.addRemoteScript({src: that.constructor.JQUERY_URL});
container.addRemoteScript({src: buildCookieUrl()});
/**
* Inject the script element(s) for the JS SDK
*
* In debug mode, `js` will be a set of "
*
* See `addString` for more details about available options
*
* @param options Object
* @param options.src String (the path or url to the script)
*/
this.addRemoteScript = function (options) {
var script = '<' + 'script src="' + options.src + '">';
this.addString({text: script, el: options.el});
};
/**
* Add an inline script to the list of strings to be written into the
* frame's document
*
* Example:
*
* addInlineScript({text: 'alert("foo");'})
*
* This will add the following string to `options.frame.head`:
*
* ""
*
* See `addString` for more details about available options
*
* @param options Object
* @param options.text String (escaped Javascript)
*/
this.addInlineScript = function (options) {
var script, text;
if (options['on'] === 'load') {
text = wrapInOnLoadCallback(options.text);
} else {
text = options.text;
}
script = '<' + 'script>' + text + '';
this.addString({text: script, el: options.el});
};
/**
* Build a JS snippet to set a frame's `document.domain` via its `src`
* attribute
*
* @param domain
* @returns {string}
*/
function domainSrcFor(domain) {
var src = "javascript:";
src += "var d=document.open(); d.domain='" + document.domain + "';";
src += 'void(0);'
return src;
}
/**
* Build the HTML markup for the document
*
* NB: we include a DOCTYPE here to ensure that iframes getting rendered
* in IE don't fall in to Quirks Mode (in which certain standard libraries,
* such as JSON, aren't available)
*
* @returns {string}
*/
function buildFrameHTML() {
var s = String();
s += '';
s += '<' + 'html>';
s += '<' + 'head>';
s += that.options.frame.head.join('\n');
s += '<' + '/head>';
s += '<' + 'body>';
s += that.options.frame.body.join('\n');
s += '
Validate your login
Ingresá a tu cuenta