')
- .height('100%' /*container.outerHeight()*/)
- .width('100%' /*container.outerWidth()*/)
- .addClass(F2.Constants.Css.MASK);
-
- // set inline styles if useClasses is false
- if (!_containerConfig.UI.Mask.useClasses) {
- mask.css({
- 'background-color':_containerConfig.UI.Mask.backgroundColor,
- 'background-image': !!_containerConfig.UI.Mask.loadingIcon ? ('url(' + _containerConfig.UI.Mask.loadingIcon + ')') : '',
- 'background-position':'50% 50%',
- 'background-repeat':'no-repeat',
- 'display':'block',
- 'left':0,
- 'min-height':30,
- 'padding':0,
- 'position':'absolute',
- 'top':0,
- 'z-index':_containerConfig.UI.Mask.zIndex,
-
- 'filter':'alpha(opacity=' + (_containerConfig.UI.Mask.opacity * 100) + ')',
- 'opacity':_containerConfig.UI.Mask.opacity
- });
- }
-
- // only set the position if the container is currently static
- if (container.css('position') === 'static') {
- container.css({'position':'relative'});
- // setting this data property tells hideMask to set the position
- // back to static
- container.data(F2.Constants.Css.MASK_CONTAINER, true);
- }
-
- // add the mask to the container
- container.append(mask);
- }
- };
-
- return UI_Class;
+F2.extend('UI', (function () {
+
+ var _containerConfig;
+
+ /**
+ * UI helper methods
+ * @class F2.UI
+ * @constructor
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ */
+ var UI_Class = function (appConfig) {
+
+ var _appConfig = appConfig;
+ var $root = jQuery(appConfig.root);
+
+ var _updateHeight = function (height) {
+ height = height || jQuery(_appConfig.root).outerHeight();
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'updateHeight',
+ [
+ height
+ ]
+ );
+ } else {
+ _appConfig.height = height;
+ $root.find('iframe').height(_appConfig.height);
+ }
+ };
+
+ //http://getbootstrap.com/javascript/#modals
+ var _modalHtml = function (type, message, showCancel) {
+ return [
+ '
'
+ ].join('');
+ };
+
+ return {
+ /**
+ * Removes a overlay from an Element on the page
+ * @method hideMask
+ * @param {string|Element} selector The Element or selector to an Element
+ * that currently contains the loader
+ */
+ hideMask: function (selector) {
+ F2.UI.hideMask(_appConfig.instanceId, selector);
+ },
+ /**
+ * Helper methods for creating and using Modals
+ * @class F2.UI.Modals
+ * @for F2.UI
+ */
+ Modals: (function () {
+
+ var _renderAlert = function (message) {
+ return _modalHtml('Alert', message);
+ };
+
+ var _renderConfirm = function (message) {
+ return _modalHtml('Confirm', message, true);
+ };
+
+ return {
+ /**
+ * Display an alert message on the page
+ * @method alert
+ * @param {string} message The message to be displayed
+ * @param {function} [callback] The callback to be fired when the user
+ * closes the dialog
+ * @for F2.UI.Modals
+ */
+ alert: function (message, callback) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.Modals.alert()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Modals.alert',
+ [].slice.call(arguments)
+ );
+ } else {
+ // display the alert
+ jQuery(_renderAlert(message))
+ .on('show.bs.modal', function () {
+ var modal = this;
+ jQuery(modal).find('.btn-primary').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (callback || jQuery.noop)();
+ });
+ })
+ .modal({backdrop: true});
+ }
+ },
+ /**
+ * Display a confirm message on the page
+ * @method confirm
+ * @param {string} message The message to be displayed
+ * @param {function} okCallback The function that will be called when the OK
+ * button is pressed
+ * @param {function} cancelCallback The function that will be called when
+ * the Cancel button is pressed
+ * @for F2.UI.Modals
+ */
+ confirm: function (message, okCallback, cancelCallback) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.Modals.confirm()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Modals.confirm',
+ [].slice.call(arguments)
+ );
+ } else {
+ // display the alert
+ jQuery(_renderConfirm(message))
+ .on('show.bs.modal', function () {
+ var modal = this;
+
+ jQuery(modal).find('.btn-ok').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (okCallback || jQuery.noop)();
+ });
+
+ jQuery(modal).find('.btn-cancel').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (cancelCallback || jQuery.noop)();
+ });
+ })
+ .modal({backdrop: true});
+ }
+ }
+ };
+ })(),
+ /**
+ * Sets the title of the app as shown in the browser. Depending on the
+ * container HTML, this method may do nothing if the container has not been
+ * configured properly or else the container provider does not allow Title's
+ * to be set.
+ * @method setTitle
+ * @params {string} title The title of the app
+ * @for F2.UI
+ */
+ setTitle: function (title) {
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'setTitle',
+ [
+ title
+ ]
+ );
+ } else {
+ jQuery(_appConfig.root).find('.' + F2.Constants.Css.APP_TITLE).text(title);
+ }
+ },
+ /**
+ * Display an ovarlay over an Element on the page
+ * @method showMask
+ * @param {string|Element} selector The Element or selector to an Element
+ * over which to display the loader
+ * @param {bool} showLoading Display a loading icon
+ */
+ showMask: function (selector, showLoader) {
+ F2.UI.showMask(_appConfig.instanceId, selector, showLoader);
+ },
+ /**
+ * For secure apps, this method updates the size of the iframe that
+ * contains the app. **Note: It is recommended that app developers call
+ * this method anytime Elements are added or removed from the DOM**
+ * @method updateHeight
+ * @params {int} height The height of the app
+ */
+ updateHeight: _updateHeight,
+ /**
+ * Helper methods for creating and using Views
+ * @class F2.UI.Views
+ * @for F2.UI
+ */
+ Views: (function () {
+
+ var _events = new EventEmitter2();
+ var _rValidEvents = /change/i;
+
+ // unlimited listeners, set to > 0 for debugging
+ _events.setMaxListeners(0);
+
+ var _isValid = function (eventName) {
+ if (_rValidEvents.test(eventName)) {
+ return true;
+ } else {
+ F2.log('"' + eventName + '" is not a valid F2.UI.Views event name');
+ return false;
+ }
+ };
+
+ return {
+ /**
+ * Change the current view for the app or add an event listener
+ * @method change
+ * @param {string|function} [input] If a string is passed in, the view
+ * will be changed for the app. If a function is passed in, a change
+ * event listener will be added.
+ * @for F2.UI.Views
+ */
+ change: function (input) {
+
+ if (typeof input === 'function') {
+ this.on('change', input);
+ } else if (typeof input === 'string') {
+
+ if (_appConfig.isSecure && !F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Views.change',
+ [].slice.call(arguments)
+ );
+ } else if (F2.inArray(input, _appConfig.views)) {
+ jQuery('.' + F2.Constants.Css.APP_VIEW, $root)
+ .addClass('hide')
+ .filter('[data-f2-view="' + input + '"]', $root)
+ .removeClass('hide');
+
+ _updateHeight();
+ _events.emit('change', input);
+ }
+ }
+ },
+ /**
+ * Removes a view event listener
+ * @method off
+ * @param {string} event The event name
+ * @param {function} listener The function that will be removed
+ * @for F2.UI.Views
+ */
+ off: function (event, listener) {
+ if (_isValid(event)) {
+ _events.off(event, listener);
+ }
+ },
+ /**
+ * Adds a view event listener
+ * @method on
+ * @param {string} event The event name
+ * @param {function} listener The function to be fired when the event is
+ * emitted
+ * @for F2.UI.Views
+ */
+ on: function (event, listener) {
+ if (_isValid(event)) {
+ _events.on(event, listener);
+ }
+ }
+ };
+ })()
+ };
+ };
+
+ /**
+ * Removes a overlay from an Element on the page
+ * @method hideMask
+ * @static
+ * @param {string} instanceId The Instance ID of the app
+ * @param {string|Element} selector The Element or selector to an Element
+ * that currently contains the loader
+ * @for F2.UI
+ */
+ UI_Class.hideMask = function (instanceId, selector) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.hideMask()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(instanceId) && !jQuery(selector).is('.' + F2.Constants.Css.APP)) {
+ F2.Rpc.call(
+ instanceId,
+ F2.Constants.Sockets.RPC,
+ 'F2.UI.hideMask',
+ [
+ instanceId,
+ // must only pass the selector argument. if we pass an Element there
+ // will be F2.stringify() errors
+ jQuery(selector).selector
+ ]
+ );
+ } else {
+
+ var container = jQuery(selector);
+ container.find('> .' + F2.Constants.Css.MASK).remove();
+ container.removeClass(F2.Constants.Css.MASK_CONTAINER);
+
+ // if the element contains this data property, we need to reset static
+ // position
+ if (container.data(F2.Constants.Css.MASK_CONTAINER)) {
+ container.css({'position': 'static'});
+ }
+ }
+ };
+
+ /**
+ *
+ * @method init
+ * @static
+ * @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
+ */
+ UI_Class.init = function (containerConfig) {
+ _containerConfig = containerConfig;
+
+ // set defaults
+ _containerConfig.UI = jQuery.extend(true, {}, F2.ContainerConfig.UI, _containerConfig.UI || {});
+ };
+
+ /**
+ * Display an ovarlay over an Element on the page
+ * @method showMask
+ * @static
+ * @param {string} instanceId The Instance ID of the app
+ * @param {string|Element} selector The Element or selector to an Element
+ * over which to display the loader
+ * @param {bool} showLoading Display a loading icon
+ */
+ UI_Class.showMask = function (instanceId, selector, showLoading) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.showMask()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(instanceId) && jQuery(selector).is('.' + F2.Constants.Css.APP)) {
+ F2.Rpc.call(
+ instanceId,
+ F2.Constants.Sockets.RPC,
+ 'F2.UI.showMask',
+ [
+ instanceId,
+ // must only pass the selector argument. if we pass an Element there
+ // will be F2.stringify() errors
+ jQuery(selector).selector,
+ showLoading
+ ]
+ );
+ } else {
+
+ if (showLoading && !_containerConfig.UI.Mask.loadingIcon) {
+ F2.log('Unable to display loading icon. Please set F2.ContainerConfig.UI.Mask.loadingIcon when calling F2.init();');
+ }
+
+ var container = jQuery(selector).addClass(F2.Constants.Css.MASK_CONTAINER);
+ var mask = jQuery('
"].join("")};return{alert:function(c,d){return F2.isInit()?void(F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Modals.alert",[].slice.call(arguments)):jQuery(a(c)).on("show",function(){var a=this;jQuery(a).find(".btn-primary").on("click",function(){jQuery(a).modal("hide").remove(),(d||jQuery.noop)()})}).modal({backdrop:!0})):void F2.log("F2.init() must be called before F2.UI.Modals.alert()")},confirm:function(a,d,e){return F2.isInit()?void(F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Modals.confirm",[].slice.call(arguments)):jQuery(c(a)).on("show",function(){var a=this;jQuery(a).find(".btn-ok").on("click",function(){jQuery(a).modal("hide").remove(),(d||jQuery.noop)()}),jQuery(a).find(".btn-cancel").on("click",function(){jQuery(a).modal("hide").remove(),(e||jQuery.noop)()})}).modal({backdrop:!0})):void F2.log("F2.init() must be called before F2.UI.Modals.confirm()")}}}(),setTitle:function(a){F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"setTitle",[a]):jQuery(b.root).find("."+F2.Constants.Css.APP_TITLE).text(a)},showMask:function(a,c){F2.UI.showMask(b.instanceId,a,c)},updateHeight:d,Views:function(){var a=new EventEmitter2,e=/change/i;a.setMaxListeners(0);var f=function(a){return e.test(a)?!0:(F2.log('"'+a+'" is not a valid F2.UI.Views event name'),!1)};return{change:function(e){"function"==typeof e?this.on("change",e):"string"==typeof e&&(b.isSecure&&!F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Views.change",[].slice.call(arguments)):F2.inArray(e,b.views)&&(jQuery("."+F2.Constants.Css.APP_VIEW,c).addClass("hide").filter('[data-f2-view="'+e+'"]',c).removeClass("hide"),d(),a.emit("change",e)))},off:function(b,c){f(b)&&a.off(b,c)},on:function(b,c){f(b)&&a.on(b,c)}}}()}};return b.hideMask=function(a,b){if(!F2.isInit())return void F2.log("F2.init() must be called before F2.UI.hideMask()");if(F2.Rpc.isRemote(a)&&!jQuery(b).is("."+F2.Constants.Css.APP))F2.Rpc.call(a,F2.Constants.Sockets.RPC,"F2.UI.hideMask",[a,jQuery(b).selector]);else{var c=jQuery(b);c.find("> ."+F2.Constants.Css.MASK).remove(),c.removeClass(F2.Constants.Css.MASK_CONTAINER),c.data(F2.Constants.Css.MASK_CONTAINER)&&c.css({position:"static"})}},b.init=function(b){a=b,a.UI=jQuery.extend(!0,{},F2.ContainerConfig.UI,a.UI||{})},b.showMask=function(b,c,d){if(!F2.isInit())return void F2.log("F2.init() must be called before F2.UI.showMask()");if(F2.Rpc.isRemote(b)&&jQuery(c).is("."+F2.Constants.Css.APP))F2.Rpc.call(b,F2.Constants.Sockets.RPC,"F2.UI.showMask",[b,jQuery(c).selector,d]);else{d&&!a.UI.Mask.loadingIcon&&F2.log("Unable to display loading icon. Please set F2.ContainerConfig.UI.Mask.loadingIcon when calling F2.init();");var e=jQuery(c).addClass(F2.Constants.Css.MASK_CONTAINER),f=jQuery("
"].join("")};return{hideMask:function(a){F2.UI.hideMask(b.instanceId,a)},Modals:function(){var a=function(a){return e("Alert",a)},c=function(a){return e("Confirm",a,!0)};return{alert:function(c,d){return F2.isInit()?void(F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Modals.alert",[].slice.call(arguments)):jQuery(a(c)).on("show.bs.modal",function(){var a=this;jQuery(a).find(".btn-primary").on("click",function(){jQuery(a).modal("hide").remove(),(d||jQuery.noop)()})}).modal({backdrop:!0})):void F2.log("F2.init() must be called before F2.UI.Modals.alert()")},confirm:function(a,d,e){return F2.isInit()?void(F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Modals.confirm",[].slice.call(arguments)):jQuery(c(a)).on("show.bs.modal",function(){var a=this;jQuery(a).find(".btn-ok").on("click",function(){jQuery(a).modal("hide").remove(),(d||jQuery.noop)()}),jQuery(a).find(".btn-cancel").on("click",function(){jQuery(a).modal("hide").remove(),(e||jQuery.noop)()})}).modal({backdrop:!0})):void F2.log("F2.init() must be called before F2.UI.Modals.confirm()")}}}(),setTitle:function(a){F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"setTitle",[a]):jQuery(b.root).find("."+F2.Constants.Css.APP_TITLE).text(a)},showMask:function(a,c){F2.UI.showMask(b.instanceId,a,c)},updateHeight:d,Views:function(){var a=new EventEmitter2,e=/change/i;a.setMaxListeners(0);var f=function(a){return e.test(a)?!0:(F2.log('"'+a+'" is not a valid F2.UI.Views event name'),!1)};return{change:function(e){"function"==typeof e?this.on("change",e):"string"==typeof e&&(b.isSecure&&!F2.Rpc.isRemote(b.instanceId)?F2.Rpc.call(b.instanceId,F2.Constants.Sockets.UI_RPC,"Views.change",[].slice.call(arguments)):F2.inArray(e,b.views)&&(jQuery("."+F2.Constants.Css.APP_VIEW,c).addClass("hide").filter('[data-f2-view="'+e+'"]',c).removeClass("hide"),d(),a.emit("change",e)))},off:function(b,c){f(b)&&a.off(b,c)},on:function(b,c){f(b)&&a.on(b,c)}}}()}};return b.hideMask=function(a,b){if(!F2.isInit())return void F2.log("F2.init() must be called before F2.UI.hideMask()");if(F2.Rpc.isRemote(a)&&!jQuery(b).is("."+F2.Constants.Css.APP))F2.Rpc.call(a,F2.Constants.Sockets.RPC,"F2.UI.hideMask",[a,jQuery(b).selector]);else{var c=jQuery(b);c.find("> ."+F2.Constants.Css.MASK).remove(),c.removeClass(F2.Constants.Css.MASK_CONTAINER),c.data(F2.Constants.Css.MASK_CONTAINER)&&c.css({position:"static"})}},b.init=function(b){a=b,a.UI=jQuery.extend(!0,{},F2.ContainerConfig.UI,a.UI||{})},b.showMask=function(b,c,d){if(!F2.isInit())return void F2.log("F2.init() must be called before F2.UI.showMask()");if(F2.Rpc.isRemote(b)&&jQuery(c).is("."+F2.Constants.Css.APP))F2.Rpc.call(b,F2.Constants.Sockets.RPC,"F2.UI.showMask",[b,jQuery(c).selector,d]);else{d&&!a.UI.Mask.loadingIcon&&F2.log("Unable to display loading icon. Please set F2.ContainerConfig.UI.Mask.loadingIcon when calling F2.init();");var e=jQuery(c).addClass(F2.Constants.Css.MASK_CONTAINER),f=jQuery("
").height("100%").width("100%").addClass(F2.Constants.Css.MASK);a.UI.Mask.useClasses||f.css({"background-color":a.UI.Mask.backgroundColor,"background-image":a.UI.Mask.loadingIcon?"url("+a.UI.Mask.loadingIcon+")":"","background-position":"50% 50%","background-repeat":"no-repeat",display:"block",left:0,"min-height":30,padding:0,position:"absolute",top:0,"z-index":a.UI.Mask.zIndex,filter:"alpha(opacity="+100*a.UI.Mask.opacity+")",opacity:a.UI.Mask.opacity}),"static"===e.css("position")&&(e.css({position:"relative"}),e.data(F2.Constants.Css.MASK_CONTAINER,!0)),e.append(f)}},b}()),F2.extend("",function(){var _apps={},_config=!1,_bUsesAppHandlers=!1,_sAppHandlerToken=F2.AppHandlers.__f2GetToken(),_afterAppRender=function(a,b){var c=_config.afterAppRender||function(a,b){return jQuery(b).appendTo("body")},d=c(a,b);return _config.afterAppRender&&!d?void F2.log("F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app"):(jQuery(d).addClass(F2.Constants.Css.APP),d.get(0))},_appRender=function(a,b){return b=_outerHtml(jQuery(b).addClass(F2.Constants.Css.APP_CONTAINER+" "+a.appId)),_config.appRender&&(b=_config.appRender(a,b)),_outerHtml(b)},_beforeAppRender=function(a){var b=_config.beforeAppRender||jQuery.noop;return b(a)},_appScriptLoadFailed=function(a,b){var c=_config.appScriptLoadFailed||jQuery.noop;return c(a,b)},_createAppConfig=function(a){return a=jQuery.extend(!0,{},a),a.instanceId=a.instanceId||F2.guid(),a.views=a.views||[],F2.inArray(F2.Constants.Views.HOME,a.views)||a.views.push(F2.Constants.Views.HOME),F2.ContainerConfig.locale&&(a.containerLocale=F2.ContainerConfig.locale),a},_getAppConfigFromElement=function(a){var b;if(a){var c=a.getAttribute("data-f2-appid"),d=a.getAttribute("data-f2-manifesturl");if(c&&d){b={appId:c,enableBatchRequests:a.hasAttribute("data-f2-enablebatchrequests"),isSecure:a.hasAttribute("data-f2-issecure"),manifestUrl:d,root:a};var e=a.getAttribute("data-f2-context");if(e)try{b.context=F2.parse(e)}catch(f){console.warn('F2: "data-f2-context" of node is not valid JSON','"'+f+'"')}}}return b},_hasNonTextChildNodes=function(a){var b=!1;if(a.hasChildNodes())for(var c=0,d=a.childNodes.length;d>c;c++)if(1===a.childNodes[c].nodeType){b=!0;break}return b},_hydrateContainerConfig=function(a){a.scriptErrorTimeout||(a.scriptErrorTimeout=F2.ContainerConfig.scriptErrorTimeout),a.debugMode!==!0&&(a.debugMode=F2.ContainerConfig.debugMode),a.locale&&"string"==typeof a.locale&&(F2.ContainerConfig.locale=a.locale)},_initAppEvents=function(a){jQuery(a.root).on("click","."+F2.Constants.Css.APP_VIEW_TRIGGER+"["+F2.Constants.Views.DATA_ATTRIBUTE+"]",function(b){b.preventDefault();var c=jQuery(this).attr(F2.Constants.Views.DATA_ATTRIBUTE).toLowerCase();c==F2.Constants.Views.REMOVE?F2.removeApp(a.instanceId):a.ui.Views.change(c)})},_initContainerEvents=function(){var a,b=function(){F2.Events.emit(F2.Constants.Events.CONTAINER_WIDTH_CHANGE)};jQuery(window).on("resize",function(){clearTimeout(a),a=setTimeout(b,100)}),F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(a){a.locale&&"string"==typeof a.locale&&(F2.ContainerConfig.locale=a.locale)})},_isPlaceholderElement=function(a){return F2.isNativeDOMNode(a)&&!_hasNonTextChildNodes(a)&&!!a.getAttribute("data-f2-appid")&&!!a.getAttribute("data-f2-manifesturl")},_isInit=function(){return!!_config},_createAppInstance=function(a,b){a.ui=new F2.UI(a),void 0!==F2.Apps[a.appId]&&("function"==typeof F2.Apps[a.appId]?setTimeout(function(){_apps[a.instanceId].app=new F2.Apps[a.appId](a,b,a.root),void 0!==_apps[a.instanceId].app.init&&_apps[a.instanceId].app.init()},0):F2.log("app initialization class is defined but not a function. ("+a.appId+")"))},_loadApps=function(appConfigs,appManifest){if(appConfigs=[].concat(appConfigs),1==appConfigs.length&&appConfigs[0].isSecure&&!_config.isSecureAppPage)return void _loadSecureApp(appConfigs[0],appManifest);if(appConfigs.length!=appManifest.apps.length)return void F2.log("The number of apps defined in the AppManifest do not match the number requested.",appManifest);var _loadStyles=function(a,b){if(_config.loadStyles)_config.loadStyles(a,b);else{var c=null,d=!!document.createStyleSheet;jQuery.each(a,function(a,b){d?document.createStyleSheet(b):(c=c||[],c.push('
'))}),c&&jQuery("head").append(c.join("")),b()}},_loadScripts=function(a,b){if(_config.loadScripts)_config.loadScripts(a,b);else if(a.length){var c=a.length,d=0,e="addEventListener"in window?{}:{loaded:!0,complete:!0},f=function(a){setTimeout(function(){var b={src:a.target.src,appId:appConfigs[0].appId};F2.log("Script defined in '"+b.appId+"' failed to load '"+b.src+"'"),F2.Events.emit("RESOURCE_FAILED_TO_LOAD",b),_bUsesAppHandlers?F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,appConfigs[0],b.src):_appScriptLoadFailed(appConfigs[0],b.src)},_config.scriptErrorTimeout)};jQuery.each(a,function(a,g){var h=document,i=h.createElement("script"),j=g;_config.debugMode&&(j+="?cachebuster="+(new Date).getTime()),i.async=!1,i.src=j,i.type="text/javascript",i.charset="utf-8",i.onerror=f,i.onload=i.onreadystatechange=function(a){a=a||window.event,("load"==a.type||e[i.readyState])&&(i.onload=i.onreadystatechange=i.onerror=null,i=null,++d===c&&b())},h.body.appendChild(i)})}else b()},_loadInlineScripts=function(inlines,cb){if(_config.loadInlineScripts)_config.loadInlineScripts(inlines,cb);else{for(var i=0,len=inlines.length;len>i;i++)try{eval(inlines[i])}catch(exception){F2.log("Error loading inline script: "+exception+"\n\n"+inlines[i]),_bUsesAppHandlers?F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,appConfigs[0],exception):_appScriptLoadFailed(appConfigs[0],exception)}cb()}},elementInDocument=function(a){if(a)for(;a.parentNode;)if(a=a.parentNode,a===document)return!0;return!1},_loadHtml=function(a){jQuery.each(a,function(a,b){if(_isPlaceholderElement(appConfigs[a].root))jQuery(appConfigs[a].root).addClass(F2.Constants.Css.APP).append(jQuery(b.html).addClass(F2.Constants.Css.APP_CONTAINER+" "+appConfigs[a].appId));else if(_bUsesAppHandlers){F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_RENDER,appConfigs[a],_outerHtml(jQuery(b.html).addClass(F2.Constants.Css.APP_CONTAINER+" "+appConfigs[a].appId)));var c=appConfigs[a].appId,d=appConfigs[a].root;if(!d)throw"Root for "+c+" must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.";if(!elementInDocument(d))throw"App root for "+c+" was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.";if(F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_RENDER_AFTER,appConfigs[a]),!F2.isNativeDOMNode(d))throw"App root for "+c+" must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element."}else appConfigs[a].root=_afterAppRender(appConfigs[a],_appRender(appConfigs[a],b.html));_initAppEvents(appConfigs[a])})},scripts=appManifest.scripts||[],styles=appManifest.styles||[],inlines=appManifest.inlineScripts||[],apps=appManifest.apps||[];_loadStyles(styles,function(){_loadHtml(apps),_loadScripts(scripts,function(){_loadInlineScripts(inlines,function(){jQuery.each(appConfigs,function(a,b){_createAppInstance(b,appManifest.apps[a])})})})})},_loadSecureApp=function(a,b){if(_config.secureAppPagePath){if(_isPlaceholderElement(a.root))jQuery(a.root).addClass(F2.Constants.Css.APP).append(jQuery("
").addClass(F2.Constants.Css.APP_CONTAINER+" "+a.appId));else if(_bUsesAppHandlers){var c=jQuery(a.root);if(F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_RENDER,a,_outerHtml(jQuery(b.html).addClass(F2.Constants.Css.APP_CONTAINER+" "+a.appId))),0===c.parents("body:first").length)throw"App was never rendered on the page. Please check your AppHandler callbacks to ensure you have rendered the app root to the DOM.";if(F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_RENDER_AFTER,a),!a.root)throw"App Root must be a native dom node and can not be null or undefined. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node.";if(!F2.isNativeDOMNode(a.root))throw"App Root must be a native dom node. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node."}else a.root=_afterAppRender(a,_appRender(a,"
"));a.ui=new F2.UI(a),_initAppEvents(a),F2.Rpc.register(a,b)}else F2.log('Unable to load secure app: "secureAppPagePath" is not defined in F2.ContainerConfig.')},_outerHtml=function(a){return jQuery("
").append(a).html()},_validateApp=function(a){return a.appId?a.root||a.manifestUrl?!0:(F2.log('"manifestUrl" missing from app object'),!1):(F2.log('"appId" missing from app object'),!1)},_validateContainerConfig=function(){if(_config&&_config.xhr){if("function"!=typeof _config.xhr&&"object"!=typeof _config.xhr)throw"ContainerConfig.xhr should be a function or an object";if(_config.xhr.dataType&&"function"!=typeof _config.xhr.dataType)throw"ContainerConfig.xhr.dataType should be a function";if(_config.xhr.type&&"function"!=typeof _config.xhr.type)throw"ContainerConfig.xhr.type should be a function";if(_config.xhr.url&&"function"!=typeof _config.xhr.url)throw"ContainerConfig.xhr.url should be a function"}return!0};return{getContainerState:function(){return _isInit()?jQuery.map(_apps,function(a){return{appId:a.config.appId}}):void F2.log("F2.init() must be called before F2.getContainerState()")},getContainerLocale:function(){return _isInit()?F2.ContainerConfig.locale:void F2.log("F2.init() must be called before F2.getContainerLocale()")},init:function(a){_config=a||{},_validateContainerConfig(),_hydrateContainerConfig(_config),_bUsesAppHandlers=!(_config.beforeAppRender||_config.appRender||_config.afterAppRender||_config.appScriptLoadFailed),(_config.secureAppPagePath||_config.isSecureAppPage)&&F2.Rpc.init(_config.secureAppPagePath?_config.secureAppPagePath:!1),F2.UI.init(_config),_config.isSecureAppPage||_initContainerEvents()},isInit:_isInit,loadPlaceholders:function(a){var b=[],c=[],d=function(a){a&&b.push(a)},e=function(a){if(a)for(var b=0,c=a.length;c>b;b++)d(a[b])};if(a&&!F2.isNativeDOMNode(a))throw'"parentNode" must be null or a DOM node';a&&a.hasAttribute("data-f2-appid")?d(a):(a=a||document,a.querySelectorAll&&e(a.querySelectorAll("[data-f2-appid]")));for(var f=0,g=b.length;g>f;f++){var h=_getAppConfigFromElement(b[f]);c.push(h)}c.length&&F2.registerApps(c)},registerApps:function(a,b){if(!_isInit())return void F2.log("F2.init() must be called before F2.registerApps()");if(!a)return void F2.log("At least one AppConfig must be passed when calling F2.registerApps()");var c=[],d={},e={},f=!1;return a=[].concat(a),b=[].concat(b||[]),f=!!b.length,a.length?a.length&&f&&a.length!=b.length?void F2.log('The length of "apps" does not equal the length of "appManifests"'):(jQuery.each(a,function(a,e){if(e=_createAppConfig(e),e.root=e.root||null,_validateApp(e)){if(_apps[e.instanceId]={config:e},e.root&&!_isPlaceholderElement(e.root)){if(!e.root&&"string"!=typeof e.root&&!F2.isNativeDOMNode(e.root))throw F2.log("AppConfig invalid for pre-load, not a valid string and not dom node"),F2.log("AppConfig instance:",e),"Preloaded appConfig.root property must be a native dom node or a string representing a sizzle selector. Please check your inputs and try again.";if(1!=jQuery(e.root).length)throw F2.log("AppConfig invalid for pre-load, root not unique"),F2.log("AppConfig instance:",e),F2.log("Number of dom node instances:",jQuery(e.root).length),"Preloaded appConfig.root property must map to a unique dom node. Please check your inputs and try again.";return _createAppInstance(e),void _initAppEvents(e)}_isPlaceholderElement(e.root)||(_bUsesAppHandlers?(F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_CREATE_ROOT,e),F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_RENDER_BEFORE,e)):e.root=_beforeAppRender(e)),f?_loadApps(e,b[a]):e.enableBatchRequests&&!e.isSecure?(d[e.manifestUrl.toLowerCase()]=d[e.manifestUrl.toLowerCase()]||[],d[e.manifestUrl.toLowerCase()].push(e)):c.push({apps:[e],url:e.manifestUrl})}}),void(f||(jQuery.each(d,function(a,b){c.push({url:a,apps:b})}),jQuery.each(c,function(a,b){var c=F2.Constants.JSONP_CALLBACK+b.apps[0].appId;e[c]=e[c]||[],e[c].push(b)}),jQuery.each(e,function(a,b){var c=function(d,e){if(e){var f=e.url,g="GET",h="jsonp",i=function(){c(a,b.pop())},j=function(){jQuery.each(e.apps,function(a,b){b.name=b.name||b.appId,F2.log("Removed failed "+b.name+" app",b),F2.removeApp(b.instanceId)})},k=function(a){_loadApps(e.apps,a)};if(_config.xhr&&_config.xhr.dataType&&(h=_config.xhr.dataType(e.url,e.apps),"string"!=typeof h))throw"ContainerConfig.xhr.dataType should return a string";if(_config.xhr&&_config.xhr.type&&(g=_config.xhr.type(e.url,e.apps),"string"!=typeof g))throw"ContainerConfig.xhr.type should return a string";if(_config.xhr&&_config.xhr.url&&(f=_config.xhr.url(e.url,e.apps),"string"!=typeof f))throw"ContainerConfig.xhr.url should return a string";var l=_config.xhr;"function"!=typeof l&&(l=function(a,b,c,f,i){jQuery.ajax({url:a,type:g,data:{params:F2.stringify(e.apps,F2.appConfigReplacer)},jsonp:!1,jsonpCallback:d,dataType:h,success:c,error:function(a,b,c){F2.log("Failed to load app(s)",c.toString(),e.apps),f()},complete:i})}),l(f,e.apps,k,j,i)}};c(a,b.pop())})))):void F2.log("At least one AppConfig must be passed when calling F2.registerApps()")},removeAllApps:function(){return _isInit()?void jQuery.each(_apps,function(a,b){F2.removeApp(b.config.instanceId)}):void F2.log("F2.init() must be called before F2.removeAllApps()")},removeApp:function(a){return _isInit()?void(_apps[a]&&(F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_DESTROY_BEFORE,_apps[a]),F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_DESTROY,_apps[a]),F2.AppHandlers.__trigger(_sAppHandlerToken,F2.Constants.AppHandlers.APP_DESTROY_AFTER,_apps[a]),delete _apps[a])):void F2.log("F2.init() must be called before F2.removeApp()")}}}()),jQuery(function(){var a=[],b=function(b){b&&a.push(b)},c=function(a){if(a)for(var c=0,d=a.length;d>c;c++)b(a[c])};if(b(document.getElementById("f2-autoload")),document.querySelectorAll&&(c(document.querySelectorAll("[data-f2-autoload]")),c(document.querySelectorAll(".f2-autoload"))),a.length){F2.init();for(var d=0,e=a.length;e>d;d++)F2.loadPlaceholders(a[d])}}),exports.F2=F2,"undefined"!=typeof define&&define.amd&&define(function(){return F2})}}("undefined"!=typeof exports?exports:window);
\ No newline at end of file
diff --git a/sdk/src/F2.js b/sdk/src/F2.js
index 78b71e4a..bae22d4d 100644
--- a/sdk/src/F2.js
+++ b/sdk/src/F2.js
@@ -34,96 +34,96 @@ var F2;
* @main f2
*/
-F2 = (function() {
+F2 = (function () {
- /**
- * Abosolutizes a relative URL
- * @method _absolutizeURI
- * @private
- * @param {e.g., location.href} base
- * @param {URL to absolutize} href
- * @returns {string} URL
- * Source: https://gist.github.com/Yaffle/1088850
- * Tests: http://skew.org/uri/uri_tests.html
- */
- var _absolutizeURI = function(base, href) {// RFC 3986
+ /**
+ * Abosolutizes a relative URL
+ * @method _absolutizeURI
+ * @private
+ * @param {e.g., location.href} base
+ * @param {URL to absolutize} href
+ * @returns {string} URL
+ * Source: https://gist.github.com/Yaffle/1088850
+ * Tests: http://skew.org/uri/uri_tests.html
+ */
+ var _absolutizeURI = function (base, href) {// RFC 3986
- function removeDotSegments(input) {
- var output = [];
- input.replace(/^(\.\.?(\/|$))+/, '')
- .replace(/\/(\.(\/|$))+/g, '/')
- .replace(/\/\.\.$/, '/../')
- .replace(/\/?[^\/]*/g, function (p) {
- if (p === '/..') {
- output.pop();
- } else {
- output.push(p);
- }
- });
- return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
- }
+ function removeDotSegments(input) {
+ var output = [];
+ input.replace(/^(\.\.?(\/|$))+/, '')
+ .replace(/\/(\.(\/|$))+/g, '/')
+ .replace(/\/\.\.$/, '/../')
+ .replace(/\/?[^\/]*/g, function (p) {
+ if (p === '/..') {
+ output.pop();
+ } else {
+ output.push(p);
+ }
+ });
+ return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : '');
+ }
- href = _parseURI(href || '');
- base = _parseURI(base || '');
+ href = _parseURI(href || '');
+ base = _parseURI(base || '');
- return !href || !base ? null : (href.protocol || base.protocol) +
- (href.protocol || href.authority ? href.authority : base.authority) +
- removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) +
- (href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
- href.hash;
- };
+ return !href || !base ? null : (href.protocol || base.protocol) +
+ (href.protocol || href.authority ? href.authority : base.authority) +
+ removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) +
+ (href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) +
+ href.hash;
+ };
- /**
- * Parses URI
- * @method _parseURI
- * @private
- * @param {The URL to parse} url
- * @returns {Parsed URL} string
- * Source: https://gist.github.com/Yaffle/1088850
- * Tests: http://skew.org/uri/uri_tests.html
- */
- var _parseURI = function(url) {
- var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
- // authority = '//' + user + ':' + pass '@' + hostname + ':' port
- return (m ? {
- href : m[0] || '',
- protocol : m[1] || '',
- authority: m[2] || '',
- host : m[3] || '',
- hostname : m[4] || '',
- port : m[5] || '',
- pathname : m[6] || '',
- search : m[7] || '',
- hash : m[8] || ''
- } : null);
- };
+ /**
+ * Parses URI
+ * @method _parseURI
+ * @private
+ * @param {The URL to parse} url
+ * @returns {Parsed URL} string
+ * Source: https://gist.github.com/Yaffle/1088850
+ * Tests: http://skew.org/uri/uri_tests.html
+ */
+ var _parseURI = function (url) {
+ var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ // authority = '//' + user + ':' + pass '@' + hostname + ':' port
+ return (m ? {
+ href: m[0] || '',
+ protocol: m[1] || '',
+ authority: m[2] || '',
+ host: m[3] || '',
+ hostname: m[4] || '',
+ port: m[5] || '',
+ pathname: m[6] || '',
+ search: m[7] || '',
+ hash: m[8] || ''
+ } : null);
+ };
- return {
- /**
- * A function to pass into F2.stringify which will prevent circular
- * reference errors when serializing objects
- * @method appConfigReplacer
- */
- appConfigReplacer: function(key, value) {
- if (key == 'root' || key == 'ui' || key == 'height') {
- return undefined;
- } else {
- return value;
- }
- },
- /**
- * The apps namespace is a place for app developers to put the javascript
- * class that is used to initialize their app. The javascript classes should
- * be namepaced with the {{#crossLink "F2.AppConfig"}}{{/crossLink}}.appId.
- * It is recommended that the code be placed in a closure to help keep the
- * global namespace clean.
- *
- * If the class has an 'init' function, that function will be called
- * automatically by F2.
- * @property Apps
- * @type object
- * @example
- * F2.Apps["com_example_helloworld"] = (function() {
+ return {
+ /**
+ * A function to pass into F2.stringify which will prevent circular
+ * reference errors when serializing objects
+ * @method appConfigReplacer
+ */
+ appConfigReplacer: function (key, value) {
+ if (key == 'root' || key == 'ui' || key == 'height') {
+ return undefined;
+ } else {
+ return value;
+ }
+ },
+ /**
+ * The apps namespace is a place for app developers to put the javascript
+ * class that is used to initialize their app. The javascript classes should
+ * be namepaced with the {{#crossLink "F2.AppConfig"}}{{/crossLink}}.appId.
+ * It is recommended that the code be placed in a closure to help keep the
+ * global namespace clean.
+ *
+ * If the class has an 'init' function, that function will be called
+ * automatically by F2.
+ * @property Apps
+ * @type object
+ * @example
+ * F2.Apps["com_example_helloworld"] = (function() {
* var App_Class = function(appConfig, appContent, root) {
* this._app = appConfig; // the F2.AppConfig object
* this._appContent = appContent // the F2.AppManifest.AppContent object
@@ -136,233 +136,236 @@ F2 = (function() {
*
* return App_Class;
* })();
- * @example
- * F2.Apps["com_example_helloworld"] = function(appConfig, appContent, root) {
+ * @example
+ * F2.Apps["com_example_helloworld"] = function(appConfig, appContent, root) {
* return {
* init:function() {
* // perform init actions
* }
* };
* };
- * @for F2
- */
- Apps: {},
- /**
- * Creates a namespace on F2 and copies the contents of an object into
- * that namespace optionally overwriting existing properties.
- * @method extend
- * @param {string} ns The namespace to create. Pass a falsy value to
- * add properties to the F2 namespace directly.
- * @param {object} obj The object to copy into the namespace.
- * @param {bool} overwrite True if object properties should be overwritten
- * @return {object} The created object
- */
- extend: function (ns, obj, overwrite) {
- var isFunc = typeof obj === 'function';
- var parts = ns ? ns.split('.') : [];
- var parent = this;
- obj = obj || {};
-
- // ignore leading global
- if (parts[0] === 'F2') {
- parts = parts.slice(1);
- }
+ * @for F2
+ */
+ Apps: {},
+ /**
+ * Creates a namespace on F2 and copies the contents of an object into
+ * that namespace optionally overwriting existing properties.
+ * @method extend
+ * @param {string} ns The namespace to create. Pass a falsy value to
+ * add properties to the F2 namespace directly.
+ * @param {object} obj The object to copy into the namespace.
+ * @param {bool} overwrite True if object properties should be overwritten
+ * @return {object} The created object
+ */
+ extend: function (ns, obj, overwrite) {
+ var isFunc = typeof obj === 'function';
+ var parts = ns ? ns.split('.') : [];
+ var parent = this;
+ obj = obj || {};
- // create namespaces
- for (var i = 0, len = parts.length; i < len; i++) {
- if (!parent[parts[i]]) {
- parent[parts[i]] = isFunc && i + 1 == len ? obj : {};
- }
- parent = parent[parts[i]];
- }
+ // ignore leading global
+ if (parts[0] === 'F2') {
+ parts = parts.slice(1);
+ }
- // copy object into namespace
- if (!isFunc) {
- for (var prop in obj) {
- if (typeof parent[prop] === 'undefined' || overwrite) {
- parent[prop] = obj[prop];
- }
- }
- }
+ // create namespaces
+ for (var i = 0, len = parts.length; i < len; i++) {
+ if (!parent[parts[i]]) {
+ parent[parts[i]] = isFunc && i + 1 == len ? obj : {};
+ }
+ parent = parent[parts[i]];
+ }
- return parent;
- },
- /**
- * Generates a somewhat random id
- * @method guid
- * @return {string} A random id
- * @for F2
- */
- guid: function() {
- var S4 = function() {
- return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
- };
- return (S4()+S4()+'-'+S4()+'-'+S4()+'-'+S4()+'-'+S4()+S4()+S4());
- },
- /**
- * Search for a value within an array.
- * @method inArray
- * @param {object} value The value to search for
- * @param {Array} array The array to search
- * @return {bool} True if the item is in the array
- */
- inArray: function(value, array) {
- return jQuery.inArray(value, array) > -1;
- },
- /**
- * Tests a URL to see if it's on the same domain (local) or not
- * @method isLocalRequest
- * @param {URL to test} url
- * @returns {bool} Whether the URL is local or not
- * Derived from: https://github.com/jquery/jquery/blob/master/src/ajax.js
- */
- isLocalRequest: function(url){
- var rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
- urlLower = url.toLowerCase(),
- parts = rurl.exec( urlLower ),
- ajaxLocation,
- ajaxLocParts;
+ // copy object into namespace
+ if (!isFunc) {
+ for (var prop in obj) {
+ if (typeof parent[prop] === 'undefined' || overwrite) {
+ parent[prop] = obj[prop];
+ }
+ }
+ }
- try {
- ajaxLocation = location.href;
- } catch( e ) {
- // Use the href attribute of an A element
- // since IE will modify it given document.location
- ajaxLocation = document.createElement('a');
- ajaxLocation.href = '';
- ajaxLocation = ajaxLocation.href;
- }
+ return parent;
+ },
+ /**
+ * Generates a somewhat random id
+ * @method guid
+ * @return {string} A random id
+ * @for F2
+ */
+ guid: function () {
+ var S4 = function () {
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+ };
+ return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4());
+ },
+ /**
+ * Search for a value within an array.
+ * @method inArray
+ * @param {object} value The value to search for
+ * @param {Array} array The array to search
+ * @return {bool} True if the item is in the array
+ */
+ inArray: function (value, array) {
+ return jQuery.inArray(value, array) > -1;
+ },
+ /**
+ * Tests a URL to see if it's on the same domain (local) or not
+ * @method isLocalRequest
+ * @param {URL to test} url
+ * @returns {bool} Whether the URL is local or not
+ * Derived from: https://github.com/jquery/jquery/blob/master/src/ajax.js
+ */
+ isLocalRequest: function (url) {
+ var rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
+ urlLower = url.toLowerCase(),
+ parts = rurl.exec(urlLower),
+ ajaxLocation,
+ ajaxLocParts;
- ajaxLocation = ajaxLocation.toLowerCase();
+ try {
+ ajaxLocation = location.href;
+ } catch (e) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement('a');
+ ajaxLocation.href = '';
+ ajaxLocation = ajaxLocation.href;
+ }
- // uh oh, the url must be relative
- // make it fully qualified and re-regex url
- if (!parts){
- urlLower = _absolutizeURI(ajaxLocation,urlLower).toLowerCase();
- parts = rurl.exec( urlLower );
- }
+ ajaxLocation = ajaxLocation.toLowerCase();
- // Segment location into parts
- ajaxLocParts = rurl.exec( ajaxLocation ) || [];
+ // uh oh, the url must be relative
+ // make it fully qualified and re-regex url
+ if (!parts) {
+ urlLower = _absolutizeURI(ajaxLocation, urlLower).toLowerCase();
+ parts = rurl.exec(urlLower);
+ }
- // do hostname and protocol and port of manifest URL match location.href? (a "local" request on the same domain)
- var matched = !(parts &&
- (parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
- (parts[ 3 ] || (parts[ 1 ] === 'http:' ? '80' : '443')) !==
- (ajaxLocParts[ 3 ] || (ajaxLocParts[ 1 ] === 'http:' ? '80' : '443'))));
-
- return matched;
- },
- /**
- * Utility method to determine whether or not the argument passed in is or is not a native dom node.
- * @method isNativeDOMNode
- * @param {object} testObject The object you want to check as native dom node.
- * @return {bool} Returns true if the object passed is a native dom node.
- */
- isNativeDOMNode: function(testObject) {
- var bIsNode = (
- typeof Node === 'object' ? testObject instanceof Node :
- testObject && typeof testObject === 'object' && typeof testObject.nodeType === 'number' && typeof testObject.nodeName === 'string'
- );
-
- var bIsElement = (
- typeof HTMLElement === 'object' ? testObject instanceof HTMLElement : //DOM2
- testObject && typeof testObject === 'object' && testObject.nodeType === 1 && typeof testObject.nodeName === 'string'
- );
-
- return (bIsNode || bIsElement);
- },
- /**
- * A utility logging function to write messages or objects to the browser console. This is a proxy for the [`console` API](https://developers.google.com/chrome-developer-tools/docs/console).
- * @method log
- * @param {object|string} Object/Method An object to be logged _or_ a `console` API method name, such as `warn` or `error`. All of the console method names are [detailed in the Chrome docs](https://developers.google.com/chrome-developer-tools/docs/console-api).
- * @param {object} [obj2]* An object to be logged
- * @example
- //Pass any object (string, int, array, object, bool) to .log()
- F2.log('foo');
- F2.log(myArray);
- //Use a console method name as the first argument.
- F2.log('error', err);
- F2.log('info', 'The session ID is ' + sessionId);
- * Some code derived from [HTML5 Boilerplate console plugin](https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js)
- */
- log: function() {
- var _log;
- var _logMethod = 'log';
- var method;
- var noop = function () { };
- var methods = [
- 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
- 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
- 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
- 'timeStamp', 'trace', 'warn'
- ];
- var length = methods.length;
- var console = (window.console = window.console || {});
- var args;
+ // Segment location into parts
+ ajaxLocParts = rurl.exec(ajaxLocation) || [];
- while (length--) {
- method = methods[length];
+ // do hostname and protocol and port of manifest URL match location.href? (a "local" request on the same domain)
+ var matched = !(parts &&
+ (parts[1] !== ajaxLocParts[1] || parts[2] !== ajaxLocParts[2] ||
+ (parts[3] || (parts[1] === 'http:' ? '80' : '443')) !==
+ (ajaxLocParts[3] || (ajaxLocParts[1] === 'http:' ? '80' : '443'))));
- // Only stub undefined methods.
- if (!console[method]) {
- console[method] = noop;
- }
+ return matched;
+ },
+ /**
+ * Utility method to determine whether or not the argument passed in is or is not a native dom node.
+ * @method isNativeDOMNode
+ * @param {object} testObject The object you want to check as native dom node.
+ * @return {bool} Returns true if the object passed is a native dom node.
+ */
+ isNativeDOMNode: function (testObject) {
+ var bIsNode = (
+ typeof Node === 'object' ? testObject instanceof Node :
+ testObject && typeof testObject === 'object' && typeof testObject.nodeType === 'number' && typeof testObject.nodeName === 'string'
+ );
- //if first arg is a console function, use it.
- //defaults to console.log()
- if (arguments && arguments.length > 1 && arguments[0] == method){
- _logMethod = method;
- //remove console func from args
- args = Array.prototype.slice.call(arguments, 1);
- }
- }
+ var bIsElement = (
+ typeof HTMLElement === 'object' ? testObject instanceof HTMLElement : //DOM2
+ testObject && typeof testObject === 'object' && testObject.nodeType === 1 && typeof testObject.nodeName === 'string'
+ );
- if (Function.prototype.bind) {
- _log = Function.prototype.bind.call(console[_logMethod], console);
- } else {
- _log = function() {
- Function.prototype.apply.call(console[_logMethod], console, (args || arguments));
- };
- }
+ return (bIsNode || bIsElement);
+ },
+ /**
+ * A utility logging function to write messages or objects to the browser console. This is a proxy for the [`console` API](https://developers.google.com/chrome-developer-tools/docs/console).
+ * @method log
+ * @param {object|string} Object/Method An object to be logged _or_ a `console` API method name, such as `warn` or `error`. All of the console method names are [detailed in the Chrome docs](https://developers.google.com/chrome-developer-tools/docs/console-api).
+ * @param {object} [obj2]* An object to be logged
+ * @example
+ //Pass any object (string, int, array, object, bool) to .log()
+ F2.log('foo');
+ F2.log(myArray);
+ //Use a console method name as the first argument.
+ F2.log('error', err);
+ F2.log('info', 'The session ID is ' + sessionId);
+ * Some code derived from [HTML5 Boilerplate console plugin](https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js)
+ */
+ log: function () {
+ var _log;
+ var _logMethod = 'log';
+ var method;
+ var noop = function () {
+ };
+ var methods = [
+ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
+ 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
+ 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
+ 'timeStamp', 'trace', 'warn'
+ ];
+ var length = methods.length;
+ var console = (window.console = window.console || {});
+ var args;
- _log.apply(this, (args || arguments));
- },
- /**
- * Wrapper to convert a JSON string to an object
- * @method parse
- * @param {string} str The JSON string to convert
- * @return {object} The parsed object
- */
- parse: function(str) {
- return JSON.parse(str);
- },
- /**
- * Wrapper to convert an object to JSON
- *
- * **Note: When using F2.stringify on an F2.AppConfig object, it is
- * recommended to pass F2.appConfigReplacer as the replacer function in
- * order to prevent circular serialization errors.**
- * @method stringify
- * @param {object} value The object to convert
- * @param {function|Array} replacer An optional parameter that determines
- * how object values are stringified for objects. It can be a function or an
- * array of strings.
- * @param {int|string} space An optional parameter that specifies the
- * indentation of nested structures. If it is omitted, the text will be
- * packed without extra whitespace. If it is a number, it will specify the
- * number of spaces to indent at each level. If it is a string (such as '\t'
- * or ' '), it contains the characters used to indent at each level.
- * @return {string} The JSON string
- */
- stringify: function(value, replacer, space) {
- return JSON.stringify(value, replacer, space);
- },
- /**
- * Function to get the F2 version number
- * @method version
- * @return {string} F2 version number
- */
- version: function() { return '<%= version%>'; }
- };
+ while (length--) {
+ method = methods[length];
+
+ // Only stub undefined methods.
+ if (!console[method]) {
+ console[method] = noop;
+ }
+
+ //if first arg is a console function, use it.
+ //defaults to console.log()
+ if (arguments && arguments.length > 1 && arguments[0] == method) {
+ _logMethod = method;
+ //remove console func from args
+ args = Array.prototype.slice.call(arguments, 1);
+ }
+ }
+
+ if (Function.prototype.bind) {
+ _log = Function.prototype.bind.call(console[_logMethod], console);
+ } else {
+ _log = function () {
+ Function.prototype.apply.call(console[_logMethod], console, (args || arguments));
+ };
+ }
+
+ _log.apply(this, (args || arguments));
+ },
+ /**
+ * Wrapper to convert a JSON string to an object
+ * @method parse
+ * @param {string} str The JSON string to convert
+ * @return {object} The parsed object
+ */
+ parse: function (str) {
+ return JSON.parse(str);
+ },
+ /**
+ * Wrapper to convert an object to JSON
+ *
+ * **Note: When using F2.stringify on an F2.AppConfig object, it is
+ * recommended to pass F2.appConfigReplacer as the replacer function in
+ * order to prevent circular serialization errors.**
+ * @method stringify
+ * @param {object} value The object to convert
+ * @param {function|Array} replacer An optional parameter that determines
+ * how object values are stringified for objects. It can be a function or an
+ * array of strings.
+ * @param {int|string} space An optional parameter that specifies the
+ * indentation of nested structures. If it is omitted, the text will be
+ * packed without extra whitespace. If it is a number, it will specify the
+ * number of spaces to indent at each level. If it is a string (such as '\t'
+ * or ' '), it contains the characters used to indent at each level.
+ * @return {string} The JSON string
+ */
+ stringify: function (value, replacer, space) {
+ return JSON.stringify(value, replacer, space);
+ },
+ /**
+ * Function to get the F2 version number
+ * @method version
+ * @return {string} F2 version number
+ */
+ version: function () {
+ return '<%= version%>';
+ }
+ };
})();
diff --git a/sdk/src/app_handlers.js b/sdk/src/app_handlers.js
index a0ddc1e7..39c4e063 100644
--- a/sdk/src/app_handlers.js
+++ b/sdk/src/app_handlers.js
@@ -10,7 +10,7 @@
*
*
* ### Order of Execution
- *
+ *
* **App Rendering**
*
* 0. {{#crossLink "F2/registerApps"}}F2.registerApps(){{/crossLink}} method is called by the Container Developer and the following methods are run for *each* {{#crossLink "F2.AppConfig"}}{{/crossLink}} passed.
@@ -27,462 +27,419 @@
* 1. **'appDestroyBefore'** (*{{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.APP\_DESTROY\_BEFORE*) handlers are fired in the order they were attached.
* 2. **'appDestroy'** (*{{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.APP\_DESTROY*) handlers are fired in the order they were attached.
* 3. **'appDestroyAfter'** (*{{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.APP\_DESTROY\_AFTER*) handlers are fired in the order they were attached.
- *
+ *
* **Error Handling**
* 0. **'appScriptLoadFailed'** (*{{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.APP\_SCRIPT\_LOAD\_FAILED*) handlers are fired in the order they were attached.
- *
+ *
* @class F2.AppHandlers
*/
-F2.extend('AppHandlers', (function() {
-
- // the hidden token that we will check against every time someone tries to add, remove, fire handler
- var _ct = F2.guid();
- var _f2t = F2.guid();
-
- var _handlerCollection = {
- appCreateRoot: [],
- appRenderBefore: [],
- appDestroyBefore: [],
- appRenderAfter: [],
- appDestroyAfter: [],
- appRender: [],
- appDestroy: [],
- appScriptLoadFailed: []
- };
-
- var _defaultMethods = {
- appRender: function(appConfig, appHtml)
- {
- var $root = null;
-
- // if no app root is defined use the app's outer most node
- if(!F2.isNativeDOMNode(appConfig.root))
- {
- appConfig.root = jQuery(appHtml).get(0);
- // get a handle on the root in jQuery
- $root = jQuery(appConfig.root);
- }
- else
- {
- // get a handle on the root in jQuery
- $root = jQuery(appConfig.root);
-
- // append the app html to the root
- $root.append(appHtml);
- }
-
- // append the root to the body by default.
- jQuery('body').append($root);
- },
- appDestroy: function(appInstance)
- {
- // call the apps destroy method, if it has one
- if(appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == 'function')
- {
- appInstance.app.destroy();
- }
- // warn the Container and App Developer that even though they have a destroy method it hasn't been
- else if(appInstance && appInstance.app && appInstance.app.destroy)
- {
- F2.log(appInstance.config.appId + ' has a destroy property, but destroy is not of type function and as such will not be executed.');
- }
-
- // fade out and remove the root
- jQuery(appInstance.config.root).fadeOut(500, function() {
- jQuery(this).remove();
- });
- }
- };
-
- var _createHandler = function(token, sNamespace, func_or_element, bDomNodeAppropriate)
- {
- // will throw an exception and stop execution if the token is invalid
- _validateToken(token);
-
- // create handler structure. Not all arguments properties will be populated/used.
- var handler = {
- func: (typeof(func_or_element)) ? func_or_element : null,
- namespace: sNamespace,
- domNode: (F2.isNativeDOMNode(func_or_element)) ? func_or_element : null
- };
-
- if(!handler.func && !handler.domNode)
- {
- throw ('Invalid or null argument passed. Handler will not be added to collection. A valid dom element or callback function is required.');
- }
-
- if(handler.domNode && !bDomNodeAppropriate)
- {
- throw ('Invalid argument passed. Handler will not be added to collection. A callback function is required for this event type.');
- }
-
- return handler;
- };
-
- var _validateToken = function(sToken)
- {
- // check token against F2 and container
- if(_ct != sToken && _f2t != sToken) { throw ('Invalid token passed. Please verify that you have correctly received and stored token from F2.AppHandlers.getToken().'); }
- };
-
- var _removeHandler = function(sToken, eventKey, sNamespace)
- {
- // will throw an exception and stop execution if the token is invalid
- _validateToken(sToken);
-
- if(!sNamespace && !eventKey)
- {
- return;
- }
- // remove by event key
- else if(!sNamespace && eventKey)
- {
- _handlerCollection[eventKey] = [];
- }
- // remove by namespace only
- else if(sNamespace && !eventKey)
- {
- sNamespace = sNamespace.toLowerCase();
-
- for(var currentEventKey in _handlerCollection)
- {
- var eventCollection = _handlerCollection[currentEventKey];
- var newEvents = [];
-
- for(var i = 0, ec = eventCollection.length; i < ec; i++)
- {
- var currentEventHandler = eventCollection[i];
- if(currentEventHandler)
- {
- if(!currentEventHandler.namespace || currentEventHandler.namespace.toLowerCase() != sNamespace)
- {
- newEvents.push(currentEventHandler);
- }
- }
- }
-
- eventCollection = newEvents;
- }
- }
- else if(sNamespace && _handlerCollection[eventKey])
- {
- sNamespace = sNamespace.toLowerCase();
-
- var newHandlerCollection = [];
-
- for(var iCounter = 0, hc = _handlerCollection[eventKey].length; iCounter < hc; iCounter++)
- {
- var currentHandler = _handlerCollection[eventKey][iCounter];
- if(currentHandler)
- {
- if(!currentHandler.namespace || currentHandler.namespace.toLowerCase() != sNamespace)
- {
- newHandlerCollection.push(currentHandler);
- }
- }
- }
-
- _handlerCollection[eventKey] = newHandlerCollection;
- }
- };
-
- return {
- /**
- * Allows Container Developer to retrieve a unique token which must be passed to
- * all `on` and `off` methods. This function will self destruct and can only be called
- * one time. Container Developers must store the return value inside of a closure.
- * @method getToken
- **/
- getToken: function()
- {
- // delete this method for security that way only the container has access to the token 1 time.
- // kind of Ethan Hunt-ish, this message will self destruct immediately.
- delete this.getToken;
- // return the token, which we validate against.
- return _ct;
- },
- /**
- * Allows F2 to get a token internally. Token is required to call {{#crossLink "F2.AppHandlers/\_\_trigger:method"}}{{/crossLink}}.
- * This function will self destruct to eliminate other sources from using the {{#crossLink "F2.AppHandlers/\_\_trigger:method"}}{{/crossLink}}
- * and additional internal methods.
- * @method __f2GetToken
- * @private
- **/
- __f2GetToken: function()
- {
- // delete this method for security that way only the F2 internally has access to the token 1 time.
- // kind of Ethan Hunt-ish, this message will self destruct immediately.
- delete this.__f2GetToken;
- // return the token, which we validate against.
- return _f2t;
- },
- /**
- * Allows F2 to trigger specific events internally.
- * @method __trigger
- * @private
- * @chainable
- * @param {String} token The token received from {{#crossLink "F2.AppHandlers/\_\_f2GetToken:method"}}{{/crossLink}}.
- * @param {String} eventKey The event to fire. The complete list of event keys is available in {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
- **/
- __trigger: function(token, eventKey) // additional arguments will likely be passed
- {
- // will throw an exception and stop execution if the token is invalid
- if(token != _f2t)
- {
- throw ('Token passed is invalid. Only F2 is allowed to call F2.AppHandlers.__trigger().');
- }
-
- if(_handlerCollection && _handlerCollection[eventKey])
- {
- // create a collection of arguments that are safe to pass to the callback.
- var passableArgs = [];
-
- // populate that collection with all arguments except token and eventKey
- for(var i = 2, j = arguments.length; i < j; i++)
- {
- passableArgs.push(arguments[i]);
- }
-
- if(_handlerCollection[eventKey].length === 0 && _defaultMethods[eventKey])
- {
- _defaultMethods[eventKey].apply(F2, passableArgs);
- return this;
- }
- else if(_handlerCollection[eventKey].length === 0 && !_handlerCollection[eventKey])
- {
- return this;
- }
-
- // fire all event listeners in the order that they were added.
- for(var iCounter = 0, hcl = _handlerCollection[eventKey].length; iCounter < hcl; iCounter++)
- {
- var handler = _handlerCollection[eventKey][iCounter];
-
- // appRender where root is already defined
- if (handler.domNode && arguments[2] && arguments[2].root && arguments[3])
- {
- var $appRoot = jQuery(arguments[2].root).append(arguments[3]);
- jQuery(handler.domNode).append($appRoot);
- }
- else if (handler.domNode && arguments[2] && !arguments[2].root && arguments[3])
- {
- // set the root to the actual HTML of the app
- arguments[2].root = jQuery(arguments[3]).get(0);
- // appends the root to the dom node specified
- jQuery(handler.domNode).append(arguments[2].root);
- }
- else
- {
- handler.func.apply(F2, passableArgs);
- }
- }
- }
- else
- {
- throw ('Invalid EventKey passed. Check your inputs and try again.');
- }
-
- return this;
- },
- /**
- * Allows Container Developer to easily tell all apps to render in a specific location. Only valid for eventType `appRender`.
- * @method on
- * @chainable
- * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
- * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. The namespace is useful for removal
- * purposes. At this time it does not affect when an event is fired. Complete list of event keys available in
- * {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
- * @params {HTMLElement} element Specific DOM element to which app gets appended.
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * 'appRender',
- * document.getElementById('my_app')
- * );
- *
- * Or:
- * @example
- * F2.AppHandlers.on(
- * _token,
- * 'appRender.myNamespace',
- * document.getElementById('my_app')
- * );
- **/
- /**
- * Allows Container Developer to add listener method that will be triggered when a specific event occurs.
- * @method on
- * @chainable
- * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
- * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. The namespace is useful for removal
- * purposes. At this time it does not affect when an event is fired. Complete list of event keys available in
- * {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
- * @params {Function} listener A function that will be triggered when a specific event occurs. For detailed argument definition refer to {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * 'appRenderBefore'
- * function() { F2.log('before app rendered!'); }
- * );
- *
- * Or:
- * @example
- * F2.AppHandlers.on(
- * _token,
- * 'appRenderBefore.myNamespace',
- * function() { F2.log('before app rendered!'); }
- * );
- **/
- on: function(token, eventKey, func_or_element)
- {
- var sNamespace = null;
-
- if(!eventKey)
- {
- throw ('eventKey must be of type string and not null. For available appHandlers check F2.Constants.AppHandlers.');
- }
-
- // we need to check the key for a namespace
- if(eventKey.indexOf('.') > -1)
- {
- var arData = eventKey.split('.');
- eventKey = arData[0];
- sNamespace = arData[1];
- }
-
- if(_handlerCollection && _handlerCollection[eventKey])
- {
- _handlerCollection[eventKey].push(
- _createHandler(
- token,
- sNamespace,
- func_or_element,
- (eventKey == 'appRender')
- )
- );
- }
- else
- {
- throw ('Invalid EventKey passed. Check your inputs and try again.');
- }
-
- return this;
- },
- /**
- * Allows Container Developer to remove listener methods for specific events
- * @method off
- * @chainable
- * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
- * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. If no namespace is provided all
- * listeners for the specified event type will be removed.
- * Complete list available in {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.off(_token,'appRenderBefore');
- *
- **/
- off: function(token, eventKey)
- {
- var sNamespace = null;
-
- if(!eventKey)
- {
- throw ('eventKey must be of type string and not null. For available appHandlers check F2.Constants.AppHandlers.');
- }
-
- // we need to check the key for a namespace
- if(eventKey.indexOf('.') > -1)
- {
- var arData = eventKey.split('.');
- eventKey = arData[0];
- sNamespace = arData[1];
- }
-
- if(_handlerCollection && _handlerCollection[eventKey])
- {
- _removeHandler(
- token,
- eventKey,
- sNamespace
- );
- }
- else
- {
- throw ('Invalid EventKey passed. Check your inputs and try again.');
- }
-
- return this;
- }
- };
+F2.extend('AppHandlers', (function () {
+
+ // the hidden token that we will check against every time someone tries to add, remove, fire handler
+ var _ct = F2.guid();
+ var _f2t = F2.guid();
+
+ var _handlerCollection = {
+ appCreateRoot: [],
+ appRenderBefore: [],
+ appDestroyBefore: [],
+ appRenderAfter: [],
+ appDestroyAfter: [],
+ appRender: [],
+ appDestroy: [],
+ appScriptLoadFailed: []
+ };
+
+ var _defaultMethods = {
+ appRender: function (appConfig, appHtml) {
+ var $root = null;
+
+ // if no app root is defined use the app's outer most node
+ if (!F2.isNativeDOMNode(appConfig.root)) {
+ appConfig.root = jQuery(appHtml).get(0);
+ // get a handle on the root in jQuery
+ $root = jQuery(appConfig.root);
+ }
+ else {
+ // get a handle on the root in jQuery
+ $root = jQuery(appConfig.root);
+
+ // append the app html to the root
+ $root.append(appHtml);
+ }
+
+ // append the root to the body by default.
+ jQuery('body').append($root);
+ },
+ appDestroy: function (appInstance) {
+ // call the apps destroy method, if it has one
+ if (appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == 'function') {
+ appInstance.app.destroy();
+ }
+ // warn the Container and App Developer that even though they have a destroy method it hasn't been
+ else if (appInstance && appInstance.app && appInstance.app.destroy) {
+ F2.log(appInstance.config.appId + ' has a destroy property, but destroy is not of type function and as such will not be executed.');
+ }
+
+ // fade out and remove the root
+ jQuery(appInstance.config.root).fadeOut(500, function () {
+ jQuery(this).remove();
+ });
+ }
+ };
+
+ var _createHandler = function (token, sNamespace, func_or_element, bDomNodeAppropriate) {
+ // will throw an exception and stop execution if the token is invalid
+ _validateToken(token);
+
+ // create handler structure. Not all arguments properties will be populated/used.
+ var handler = {
+ func: (typeof(func_or_element)) ? func_or_element : null,
+ namespace: sNamespace,
+ domNode: (F2.isNativeDOMNode(func_or_element)) ? func_or_element : null
+ };
+
+ if (!handler.func && !handler.domNode) {
+ throw ('Invalid or null argument passed. Handler will not be added to collection. A valid dom element or callback function is required.');
+ }
+
+ if (handler.domNode && !bDomNodeAppropriate) {
+ throw ('Invalid argument passed. Handler will not be added to collection. A callback function is required for this event type.');
+ }
+
+ return handler;
+ };
+
+ var _validateToken = function (sToken) {
+ // check token against F2 and container
+ if (_ct != sToken && _f2t != sToken) {
+ throw ('Invalid token passed. Please verify that you have correctly received and stored token from F2.AppHandlers.getToken().');
+ }
+ };
+
+ var _removeHandler = function (sToken, eventKey, sNamespace) {
+ // will throw an exception and stop execution if the token is invalid
+ _validateToken(sToken);
+
+ if (!sNamespace && !eventKey) {
+ return;
+ }
+ // remove by event key
+ else if (!sNamespace && eventKey) {
+ _handlerCollection[eventKey] = [];
+ }
+ // remove by namespace only
+ else if (sNamespace && !eventKey) {
+ sNamespace = sNamespace.toLowerCase();
+
+ for (var currentEventKey in _handlerCollection) {
+ var eventCollection = _handlerCollection[currentEventKey];
+ var newEvents = [];
+
+ for (var i = 0, ec = eventCollection.length; i < ec; i++) {
+ var currentEventHandler = eventCollection[i];
+ if (currentEventHandler) {
+ if (!currentEventHandler.namespace || currentEventHandler.namespace.toLowerCase() != sNamespace) {
+ newEvents.push(currentEventHandler);
+ }
+ }
+ }
+
+ eventCollection = newEvents;
+ }
+ }
+ else if (sNamespace && _handlerCollection[eventKey]) {
+ sNamespace = sNamespace.toLowerCase();
+
+ var newHandlerCollection = [];
+
+ for (var iCounter = 0, hc = _handlerCollection[eventKey].length; iCounter < hc; iCounter++) {
+ var currentHandler = _handlerCollection[eventKey][iCounter];
+ if (currentHandler) {
+ if (!currentHandler.namespace || currentHandler.namespace.toLowerCase() != sNamespace) {
+ newHandlerCollection.push(currentHandler);
+ }
+ }
+ }
+
+ _handlerCollection[eventKey] = newHandlerCollection;
+ }
+ };
+
+ return {
+ /**
+ * Allows Container Developer to retrieve a unique token which must be passed to
+ * all `on` and `off` methods. This function will self destruct and can only be called
+ * one time. Container Developers must store the return value inside of a closure.
+ * @method getToken
+ **/
+ getToken: function () {
+ // delete this method for security that way only the container has access to the token 1 time.
+ // kind of Ethan Hunt-ish, this message will self destruct immediately.
+ delete this.getToken;
+ // return the token, which we validate against.
+ return _ct;
+ },
+ /**
+ * Allows F2 to get a token internally. Token is required to call {{#crossLink "F2.AppHandlers/\_\_trigger:method"}}{{/crossLink}}.
+ * This function will self destruct to eliminate other sources from using the {{#crossLink "F2.AppHandlers/\_\_trigger:method"}}{{/crossLink}}
+ * and additional internal methods.
+ * @method __f2GetToken
+ * @private
+ **/
+ __f2GetToken: function () {
+ // delete this method for security that way only the F2 internally has access to the token 1 time.
+ // kind of Ethan Hunt-ish, this message will self destruct immediately.
+ delete this.__f2GetToken;
+ // return the token, which we validate against.
+ return _f2t;
+ },
+ /**
+ * Allows F2 to trigger specific events internally.
+ * @method __trigger
+ * @private
+ * @chainable
+ * @param {String} token The token received from {{#crossLink "F2.AppHandlers/\_\_f2GetToken:method"}}{{/crossLink}}.
+ * @param {String} eventKey The event to fire. The complete list of event keys is available in {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
+ **/
+ __trigger: function (token, eventKey) // additional arguments will likely be passed
+ {
+ // will throw an exception and stop execution if the token is invalid
+ if (token != _f2t) {
+ throw ('Token passed is invalid. Only F2 is allowed to call F2.AppHandlers.__trigger().');
+ }
+
+ if (_handlerCollection && _handlerCollection[eventKey]) {
+ // create a collection of arguments that are safe to pass to the callback.
+ var passableArgs = [];
+
+ // populate that collection with all arguments except token and eventKey
+ for (var i = 2, j = arguments.length; i < j; i++) {
+ passableArgs.push(arguments[i]);
+ }
+
+ if (_handlerCollection[eventKey].length === 0 && _defaultMethods[eventKey]) {
+ _defaultMethods[eventKey].apply(F2, passableArgs);
+ return this;
+ }
+ else if (_handlerCollection[eventKey].length === 0 && !_handlerCollection[eventKey]) {
+ return this;
+ }
+
+ // fire all event listeners in the order that they were added.
+ for (var iCounter = 0, hcl = _handlerCollection[eventKey].length; iCounter < hcl; iCounter++) {
+ var handler = _handlerCollection[eventKey][iCounter];
+
+ // appRender where root is already defined
+ if (handler.domNode && arguments[2] && arguments[2].root && arguments[3]) {
+ var $appRoot = jQuery(arguments[2].root).append(arguments[3]);
+ jQuery(handler.domNode).append($appRoot);
+ }
+ else if (handler.domNode && arguments[2] && !arguments[2].root && arguments[3]) {
+ // set the root to the actual HTML of the app
+ arguments[2].root = jQuery(arguments[3]).get(0);
+ // appends the root to the dom node specified
+ jQuery(handler.domNode).append(arguments[2].root);
+ }
+ else {
+ handler.func.apply(F2, passableArgs);
+ }
+ }
+ }
+ else {
+ throw ('Invalid EventKey passed. Check your inputs and try again.');
+ }
+
+ return this;
+ },
+ /**
+ * Allows Container Developer to easily tell all apps to render in a specific location. Only valid for eventType `appRender`.
+ * @method on
+ * @chainable
+ * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
+ * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. The namespace is useful for removal
+ * purposes. At this time it does not affect when an event is fired. Complete list of event keys available in
+ * {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
+ * @params {HTMLElement} element Specific DOM element to which app gets appended.
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * 'appRender',
+ * document.getElementById('my_app')
+ * );
+ *
+ * Or:
+ * @example
+ * F2.AppHandlers.on(
+ * _token,
+ * 'appRender.myNamespace',
+ * document.getElementById('my_app')
+ * );
+ **/
+ /**
+ * Allows Container Developer to add listener method that will be triggered when a specific event occurs.
+ * @method on
+ * @chainable
+ * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
+ * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. The namespace is useful for removal
+ * purposes. At this time it does not affect when an event is fired. Complete list of event keys available in
+ * {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
+ * @params {Function} listener A function that will be triggered when a specific event occurs. For detailed argument definition refer to {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * 'appRenderBefore'
+ * function() { F2.log('before app rendered!'); }
+ * );
+ *
+ * Or:
+ * @example
+ * F2.AppHandlers.on(
+ * _token,
+ * 'appRenderBefore.myNamespace',
+ * function() { F2.log('before app rendered!'); }
+ * );
+ **/
+ on: function (token, eventKey, func_or_element) {
+ var sNamespace = null;
+
+ if (!eventKey) {
+ throw ('eventKey must be of type string and not null. For available appHandlers check F2.Constants.AppHandlers.');
+ }
+
+ // we need to check the key for a namespace
+ if (eventKey.indexOf('.') > -1) {
+ var arData = eventKey.split('.');
+ eventKey = arData[0];
+ sNamespace = arData[1];
+ }
+
+ if (_handlerCollection && _handlerCollection[eventKey]) {
+ _handlerCollection[eventKey].push(
+ _createHandler(
+ token,
+ sNamespace,
+ func_or_element,
+ (eventKey == 'appRender')
+ )
+ );
+ }
+ else {
+ throw ('Invalid EventKey passed. Check your inputs and try again.');
+ }
+
+ return this;
+ },
+ /**
+ * Allows Container Developer to remove listener methods for specific events
+ * @method off
+ * @chainable
+ * @param {String} token The token received from {{#crossLink "F2.AppHandlers/getToken:method"}}{{/crossLink}}.
+ * @param {String} eventKey{.namespace} The event key used to determine which event to attach the listener to. If no namespace is provided all
+ * listeners for the specified event type will be removed.
+ * Complete list available in {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.off(_token,'appRenderBefore');
+ *
+ **/
+ off: function (token, eventKey) {
+ var sNamespace = null;
+
+ if (!eventKey) {
+ throw ('eventKey must be of type string and not null. For available appHandlers check F2.Constants.AppHandlers.');
+ }
+
+ // we need to check the key for a namespace
+ if (eventKey.indexOf('.') > -1) {
+ var arData = eventKey.split('.');
+ eventKey = arData[0];
+ sNamespace = arData[1];
+ }
+
+ if (_handlerCollection && _handlerCollection[eventKey]) {
+ _removeHandler(
+ token,
+ eventKey,
+ sNamespace
+ );
+ }
+ else {
+ throw ('Invalid EventKey passed. Check your inputs and try again.');
+ }
+
+ return this;
+ }
+ };
})());
F2.extend('Constants', {
- /**
- * A convenient collection of all available appHandler events.
- * @class F2.Constants.AppHandlers
- **/
- AppHandlers: (function()
- {
- return {
- /**
- * Equivalent to `appCreateRoot`. Identifies the create root method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
- * @property APP_CREATE_ROOT
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_CREATE_ROOT,
- * function(appConfig)
- * {
+ /**
+ * A convenient collection of all available appHandler events.
+ * @class F2.Constants.AppHandlers
+ **/
+ AppHandlers: (function () {
+ return {
+ /**
+ * Equivalent to `appCreateRoot`. Identifies the create root method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
+ * @property APP_CREATE_ROOT
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ * function(appConfig)
+ * {
* // If you want to create a custom root. By default F2 uses the app's outermost HTML element.
* // the app's html is not available until after the manifest is retrieved so this logic occurs in F2.Constants.AppHandlers.APP_RENDER
* appConfig.root = jQuery('
').get(0);
* }
- * );
- */
- APP_CREATE_ROOT: 'appCreateRoot',
- /**
- * Equivalent to `appRenderBefore`. Identifies the before app render method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
- * @property APP_RENDER_BEFORE
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- * function(appConfig)
- * {
+ * );
+ */
+ APP_CREATE_ROOT: 'appCreateRoot',
+ /**
+ * Equivalent to `appRenderBefore`. Identifies the before app render method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
+ * @property APP_RENDER_BEFORE
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ * function(appConfig)
+ * {
* F2.log(appConfig);
* }
- * );
- */
- APP_RENDER_BEFORE: 'appRenderBefore',
- /**
- * Equivalent to `appRender`. Identifies the app render method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}}, [appHtml](../../app-development.html#app-design) )
- * @property APP_RENDER
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_RENDER,
- * function(appConfig, appHtml)
- * {
+ * );
+ */
+ APP_RENDER_BEFORE: 'appRenderBefore',
+ /**
+ * Equivalent to `appRender`. Identifies the app render method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}}, [appHtml](../../app-development.html#app-design) )
+ * @property APP_RENDER
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_RENDER,
+ * function(appConfig, appHtml)
+ * {
* var $root = null;
*
* // if no app root is defined use the app's outer most node
@@ -504,64 +461,64 @@ F2.extend('Constants', {
* // append the root to the body by default.
* jQuery('body').append($root);
* }
- * );
- */
- APP_RENDER: 'appRender',
- /**
- * Equivalent to `appRenderAfter`. Identifies the after app render method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
- * @property APP_RENDER_AFTER
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_RENDER_AFTER,
- * function(appConfig)
- * {
+ * );
+ */
+ APP_RENDER: 'appRender',
+ /**
+ * Equivalent to `appRenderAfter`. Identifies the after app render method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}} )
+ * @property APP_RENDER_AFTER
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ * function(appConfig)
+ * {
* F2.log(appConfig);
* }
- * );
- */
- APP_RENDER_AFTER: 'appRenderAfter',
- /**
- * Equivalent to `appDestroyBefore`. Identifies the before app destroy method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( appInstance )
- * @property APP_DESTROY_BEFORE
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
- * function(appInstance)
- * {
+ * );
+ */
+ APP_RENDER_AFTER: 'appRenderAfter',
+ /**
+ * Equivalent to `appDestroyBefore`. Identifies the before app destroy method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( appInstance )
+ * @property APP_DESTROY_BEFORE
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
+ * function(appInstance)
+ * {
* F2.log(appInstance);
* }
- * );
- */
- APP_DESTROY_BEFORE: 'appDestroyBefore',
- /**
- * Equivalent to `appDestroy`. Identifies the app destroy method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( appInstance )
- * @property APP_DESTROY
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_DESTROY,
- * function(appInstance)
- * {
+ * );
+ */
+ APP_DESTROY_BEFORE: 'appDestroyBefore',
+ /**
+ * Equivalent to `appDestroy`. Identifies the app destroy method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( appInstance )
+ * @property APP_DESTROY
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_DESTROY,
+ * function(appInstance)
+ * {
* // call the apps destroy method, if it has one
* if(appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == 'function')
* {
@@ -577,49 +534,49 @@ F2.extend('Constants', {
* jQuery(this).remove();
* });
* }
- * );
- */
- APP_DESTROY: 'appDestroy',
- /**
- * Equivalent to `appDestroyAfter`. Identifies the after app destroy method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( appInstance )
- * @property APP_DESTROY_AFTER
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_DESTROY_AFTER,
- * function(appInstance)
- * {
+ * );
+ */
+ APP_DESTROY: 'appDestroy',
+ /**
+ * Equivalent to `appDestroyAfter`. Identifies the after app destroy method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( appInstance )
+ * @property APP_DESTROY_AFTER
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_DESTROY_AFTER,
+ * function(appInstance)
+ * {
* F2.log(appInstance);
* }
- * );
- */
- APP_DESTROY_AFTER: 'appDestroyAfter',
- /**
- * Equivalent to `appScriptLoadFailed`. Identifies the app script load failed method for use in AppHandlers.on/off.
- * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
- * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}}, scriptInfo )
- * @property APP_SCRIPT_LOAD_FAILED
- * @type string
- * @static
- * @final
- * @example
- * var _token = F2.AppHandlers.getToken();
- * F2.AppHandlers.on(
- * _token,
- * F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
- * function(appConfig, scriptInfo)
- * {
+ * );
+ */
+ APP_DESTROY_AFTER: 'appDestroyAfter',
+ /**
+ * Equivalent to `appScriptLoadFailed`. Identifies the app script load failed method for use in AppHandlers.on/off.
+ * When bound using {{#crossLink "F2.AppHandlers/on"}}F2.AppHandlers.on(){{/crossLink}} the listener function passed will receive the
+ * following argument(s): ( {{#crossLink "F2.AppConfig"}}appConfig{{/crossLink}}, scriptInfo )
+ * @property APP_SCRIPT_LOAD_FAILED
+ * @type string
+ * @static
+ * @final
+ * @example
+ * var _token = F2.AppHandlers.getToken();
+ * F2.AppHandlers.on(
+ * _token,
+ * F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
+ * function(appConfig, scriptInfo)
+ * {
* F2.log(appConfig.appId);
* }
- * );
- */
- APP_SCRIPT_LOAD_FAILED: 'appScriptLoadFailed'
- };
- })()
+ * );
+ */
+ APP_SCRIPT_LOAD_FAILED: 'appScriptLoadFailed'
+ };
+ })()
});
\ No newline at end of file
diff --git a/sdk/src/classes.js b/sdk/src/classes.js
index 2e5bf45a..a66e031a 100644
--- a/sdk/src/classes.js
+++ b/sdk/src/classes.js
@@ -3,405 +3,409 @@
* @main F2
*/
F2.extend('', {
- /**
- * The App Class is an optional class that can be namespaced onto the
- * {{#crossLink "F2\Apps"}}{{/crossLink}} namespace. The
- * [F2 Docs](../../app-development.html#app-class)
- * has more information on the usage of the App Class.
- * @class F2.App
- * @constructor
- * @param {F2.AppConfig} appConfig The F2.AppConfig object for the app
- * @param {F2.AppManifest.AppContent} appContent The F2.AppManifest.AppContent
- * object
- * @param {Element} root The root DOM Element for the app
- */
- App: function(appConfig, appContent, root) {
- return {
- /**
- * An optional init function that will automatically be called when
- * F2.{{#crossLink "F2\registerApps"}}{{/crossLink}} is called.
- * @method init
- * @optional
- */
- init:function() {}
- };
- },
- /**
- * The AppConfig object represents an app's meta data
- * @class F2.AppConfig
- */
- AppConfig: {
- /**
- * The unique ID of the app. More information can be found
- * [here](../../app-development.html#f2-appid)
- * @property appId
- * @type string
- * @required
- */
- appId: '',
- /**
- * An object that represents the context of an app
- * @property context
- * @type object
- */
- context: {},
- /**
- * True if the app should be requested in a single request with other apps.
- * @property enableBatchRequests
- * @type bool
- * @default false
- */
- enableBatchRequests: false,
- /**
- * The height of the app. The initial height will be pulled from
- * the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object, but later
- * modified by calling
- * F2.UI.{{#crossLink "F2.UI/updateHeight"}}{{/crossLink}}. This is used
- * for secure apps to be able to set the initial height of the iframe.
- * @property height
- * @type int
- */
- height: 0,
- /**
- * The unique runtime ID of the app.
- *
- * **This property is populated during the
- * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
- * @property instanceId
- * @type string
- */
- instanceId: '',
- /**
- * True if the app will be loaded in an iframe. This property
- * will be true if the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object
- * sets isSecure = true. It will also be true if the
- * [container](../../container-development.html) has made the decision to
- * run apps in iframes.
- * @property isSecure
- * @type bool
- * @default false
- */
- isSecure: false,
- /**
- * The language and region specification for this container
- * represented as an IETF-defined standard language tag,
- * e.g. `"en-us"` or `"de-de"`. This is passed during the
- * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process.
- *
- * @property containerLocale
- * @type string
- * @default null
- */
- containerLocale: null,
- /**
- * The languages and regions supported by this app represented
- * as an array of IETF-defined standard language tags,
- * e.g. `["en-us","de-de"]`.
- *
- * @property localeSupport
- * @type array
- * @default []
- */
- localeSupport: [],
- /**
- * The url to retrieve the {{#crossLink "F2.AppManifest"}}{{/crossLink}}
- * object.
- * @property manifestUrl
- * @type string
- * @required
- */
- manifestUrl: '',
- /**
- * The recommended maximum width in pixels that this app should be run.
- * **It is up to the [container](../../container-development.html) to
- * implement the logic to prevent an app from being run when the maxWidth
- * requirements are not met.**
- * @property maxWidth
- * @type int
- */
- maxWidth: 0,
- /**
- * The recommended minimum grid size that this app should be run. This
- * value corresponds to the 12-grid system that is used by the
- * [container](../../container-development.html). This property should be
- * set by apps that require a certain number of columns in their layout.
- * @property minGridSize
- * @type int
- * @default 4
- */
- minGridSize: 4,
- /**
- * The recommended minimum width in pixels that this app should be run. **It
- * is up to the [container](../../container-development.html) to implement
- * the logic to prevent an app from being run when the minWidth requirements
- * are not met.
- * @property minWidth
- * @type int
- * @default 300
- */
- minWidth: 300,
- /**
- * The name of the app
- * @property name
- * @type string
- * @required
- */
- name: '',
- /**
- * The root DOM element that contains the app
- *
- * **This property is populated during the
- * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
- * @property root
- * @type Element
- */
- root: undefined,
- /**
- * The instance of F2.UI providing easy access to F2.UI methods
- *
- * **This property is populated during the
- * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
- * @property ui
- * @type F2.UI
- */
- ui: undefined,
- /**
- * The views that this app supports. Available views
- * are defined in {{#crossLink "F2.Constants.Views"}}{{/crossLink}}. The
- * presence of a view can be checked via
- * F2.{{#crossLink "F2/inArray"}}{{/crossLink}}:
- *
- * F2.inArray(F2.Constants.Views.SETTINGS, app.views)
- *
- * @property views
- * @type Array
- */
- views: []
- },
- /**
- * The assets needed to render an app on the page
- * @class F2.AppManifest
- */
- AppManifest: {
- /**
- * The array of {{#crossLink "F2.AppManifest.AppContent"}}{{/crossLink}}
- * objects
- * @property apps
- * @type Array
- * @required
- */
- apps: [],
- /**
- * Any inline javascript tha should initially be run
- * @property inlineScripts
- * @type Array
- * @optional
- */
- inlineScripts: [],
- /**
- * Urls to javascript files required by the app
- * @property scripts
- * @type Array
- * @optional
- */
- scripts: [],
- /**
- * Urls to CSS files required by the app
- * @property styles
- * @type Array
- * @optional
- */
- styles: []
- },
- /**
- * The AppContent object
- * @class F2.AppManifest.AppContent
- **/
- AppContent: {
- /**
- * Arbitrary data to be passed along with the app
- * @property data
- * @type object
- * @optional
- */
- data: {},
- /**
- * The string of HTML representing the app
- * @property html
- * @type string
- * @required
- */
- html: '',
- /**
- * A status message
- * @property status
- * @type string
- * @optional
- */
- status: ''
- },
- /**
- * An object containing configuration information for the
- * [container](../../container-development.html)
- * @class F2.ContainerConfig
- */
- ContainerConfig: {
- /**
- * Allows the [container](../../container-development.html) to override how
- * an app's html is inserted into the page. The function should accept an
- * {{#crossLink "F2.AppConfig"}}{{/crossLink}} object and also a string of
- * html
- * @method afterAppRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {string} html The string of html representing the app
- * @return {Element} The DOM Element surrounding the app
- */
- afterAppRender: function(appConfig, html) {},
- /**
- * Allows the [container](../../container-development.html) to wrap an app
- * in extra html. The function should accept an
- * {{#crossLink "F2.AppConfig"}}{{/crossLink}} object and also a string of
- * html. The extra html can provide links to edit app settings and remove an
- * app from the container. See
- * {{#crossLink "F2.Constants.Css"}}{{/crossLink}} for CSS classes that
- * should be applied to elements.
- * @method appRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {string} html The string of html representing the app
- */
- appRender: function(appConfig, html) {},
- /**
- * Allows the container to render html for an app before the AppManifest for
- * an app has loaded. This can be useful if the design calls for loading
- * icons to appear for each app before each app is loaded and rendered to
- * the page.
- * @method beforeAppRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @return {Element} The DOM Element surrounding the app
- */
- beforeAppRender: function(appConfig) {},
- /**
- * True to enable debug mode in F2.js. Adds additional logging, resource cache busting, etc.
- * @property debugMode
- * @type bool
- * @default false
- */
- debugMode: false,
- /**
- * The default language and region specification for this container
- * represented as an IETF-defined standard language tag,
- * e.g. `"en-us"` or `"de-de"`. This value is passed to each app
- * registered as `containerLocale`.
- *
- * @property locale
- * @type string
- * @default null
- */
- locale: null,
- /**
- * Milliseconds before F2 fires callback on script resource load errors. Due to issue with the way Internet Explorer attaches load events to script elements, the error event doesn't fire.
- * @property scriptErrorTimeout
- * @type milliseconds
- * @default 7000 (7 seconds)
- */
- scriptErrorTimeout: 7000,
- /**
- * Tells the container that it is currently running within
- * a secure app page
- * @property isSecureAppPage
- * @type bool
- */
- isSecureAppPage: false,
- /**
- * Allows the container to specify which page is used when
- * loading a secure app. The page must reside on a different domain than the
- * container
- * @property secureAppPagePath
- * @type string
- * @for F2.ContainerConfig
- */
- secureAppPagePath: '',
- /**
- * Specifies what views a container will provide buttons
- * or links to. Generally, the views will be switched via buttons or links
- * in the app's header.
- * @property supportedViews
- * @type Array
- * @required
- */
- supportedViews: [],
- /**
- * An object containing configuration defaults for F2.UI
- * @class F2.ContainerConfig.UI
- */
- UI: {
- /**
- * An object containing configuration defaults for the
- * F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} and
- * F2.UI.{{#crossLink "F2.UI/hideMask"}}{{/crossLink}} methods.
- * @class F2.ContainerConfig.UI.Mask
- */
- Mask: {
- /**
- * The backround color of the overlay
- * @property backgroundColor
- * @type string
- * @default #FFF
- */
- backgroundColor: '#FFF',
- /**
- * The path to the loading icon
- * @property loadingIcon
- * @type string
- */
- loadingIcon: '',
- /**
- * The opacity of the background overlay
- * @property opacity
- * @type int
- * @default 0.6
- */
- opacity: 0.6,
- /**
- * Do not use inline styles for mask functinality. Instead classes will
- * be applied to the elements and it is up to the container provider to
- * implement the class definitions.
- * @property useClasses
- * @type bool
- * @default false
- */
- useClasses: false,
- /**
- * The z-index to use for the overlay
- * @property zIndex
- * @type int
- * @default 2
- */
- zIndex: 2
- }
- },
- /**
- * Allows the container to fully override how the AppManifest request is
- * made inside of F2.
- *
- * @method xhr
- * @param {string} url The manifest url
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
- * objects
- * @param {function} success The function to be called if the request
- * succeeds
- * @param {function} error The function to be called if the request fails
- * @param {function} complete The function to be called when the request
- * finishes (after success and error callbacks have been executed)
- * @return {XMLHttpRequest} The XMLHttpRequest object (or an object that has
- * an `abort` function (such as the jqXHR object in jQuery) to abort the
- * request)
- *
- * @example
- * F2.init({
+ /**
+ * The App Class is an optional class that can be namespaced onto the
+ * {{#crossLink "F2\Apps"}}{{/crossLink}} namespace. The
+ * [F2 Docs](../../app-development.html#app-class)
+ * has more information on the usage of the App Class.
+ * @class F2.App
+ * @constructor
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object for the app
+ * @param {F2.AppManifest.AppContent} appContent The F2.AppManifest.AppContent
+ * object
+ * @param {Element} root The root DOM Element for the app
+ */
+ App: function (appConfig, appContent, root) {
+ return {
+ /**
+ * An optional init function that will automatically be called when
+ * F2.{{#crossLink "F2\registerApps"}}{{/crossLink}} is called.
+ * @method init
+ * @optional
+ */
+ init: function () {
+ }
+ };
+ },
+ /**
+ * The AppConfig object represents an app's meta data
+ * @class F2.AppConfig
+ */
+ AppConfig: {
+ /**
+ * The unique ID of the app. More information can be found
+ * [here](../../app-development.html#f2-appid)
+ * @property appId
+ * @type string
+ * @required
+ */
+ appId: '',
+ /**
+ * An object that represents the context of an app
+ * @property context
+ * @type object
+ */
+ context: {},
+ /**
+ * True if the app should be requested in a single request with other apps.
+ * @property enableBatchRequests
+ * @type bool
+ * @default false
+ */
+ enableBatchRequests: false,
+ /**
+ * The height of the app. The initial height will be pulled from
+ * the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object, but later
+ * modified by calling
+ * F2.UI.{{#crossLink "F2.UI/updateHeight"}}{{/crossLink}}. This is used
+ * for secure apps to be able to set the initial height of the iframe.
+ * @property height
+ * @type int
+ */
+ height: 0,
+ /**
+ * The unique runtime ID of the app.
+ *
+ * **This property is populated during the
+ * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
+ * @property instanceId
+ * @type string
+ */
+ instanceId: '',
+ /**
+ * True if the app will be loaded in an iframe. This property
+ * will be true if the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object
+ * sets isSecure = true. It will also be true if the
+ * [container](../../container-development.html) has made the decision to
+ * run apps in iframes.
+ * @property isSecure
+ * @type bool
+ * @default false
+ */
+ isSecure: false,
+ /**
+ * The language and region specification for this container
+ * represented as an IETF-defined standard language tag,
+ * e.g. `"en-us"` or `"de-de"`. This is passed during the
+ * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process.
+ *
+ * @property containerLocale
+ * @type string
+ * @default null
+ */
+ containerLocale: null,
+ /**
+ * The languages and regions supported by this app represented
+ * as an array of IETF-defined standard language tags,
+ * e.g. `["en-us","de-de"]`.
+ *
+ * @property localeSupport
+ * @type array
+ * @default []
+ */
+ localeSupport: [],
+ /**
+ * The url to retrieve the {{#crossLink "F2.AppManifest"}}{{/crossLink}}
+ * object.
+ * @property manifestUrl
+ * @type string
+ * @required
+ */
+ manifestUrl: '',
+ /**
+ * The recommended maximum width in pixels that this app should be run.
+ * **It is up to the [container](../../container-development.html) to
+ * implement the logic to prevent an app from being run when the maxWidth
+ * requirements are not met.**
+ * @property maxWidth
+ * @type int
+ */
+ maxWidth: 0,
+ /**
+ * The recommended minimum grid size that this app should be run. This
+ * value corresponds to the 12-grid system that is used by the
+ * [container](../../container-development.html). This property should be
+ * set by apps that require a certain number of columns in their layout.
+ * @property minGridSize
+ * @type int
+ * @default 4
+ */
+ minGridSize: 4,
+ /**
+ * The recommended minimum width in pixels that this app should be run. **It
+ * is up to the [container](../../container-development.html) to implement
+ * the logic to prevent an app from being run when the minWidth requirements
+ * are not met.
+ * @property minWidth
+ * @type int
+ * @default 300
+ */
+ minWidth: 300,
+ /**
+ * The name of the app
+ * @property name
+ * @type string
+ * @required
+ */
+ name: '',
+ /**
+ * The root DOM element that contains the app
+ *
+ * **This property is populated during the
+ * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
+ * @property root
+ * @type Element
+ */
+ root: undefined,
+ /**
+ * The instance of F2.UI providing easy access to F2.UI methods
+ *
+ * **This property is populated during the
+ * F2.{{#crossLink "F2/registerApps"}}{{/crossLink}} process**
+ * @property ui
+ * @type F2.UI
+ */
+ ui: undefined,
+ /**
+ * The views that this app supports. Available views
+ * are defined in {{#crossLink "F2.Constants.Views"}}{{/crossLink}}. The
+ * presence of a view can be checked via
+ * F2.{{#crossLink "F2/inArray"}}{{/crossLink}}:
+ *
+ * F2.inArray(F2.Constants.Views.SETTINGS, app.views)
+ *
+ * @property views
+ * @type Array
+ */
+ views: []
+ },
+ /**
+ * The assets needed to render an app on the page
+ * @class F2.AppManifest
+ */
+ AppManifest: {
+ /**
+ * The array of {{#crossLink "F2.AppManifest.AppContent"}}{{/crossLink}}
+ * objects
+ * @property apps
+ * @type Array
+ * @required
+ */
+ apps: [],
+ /**
+ * Any inline javascript tha should initially be run
+ * @property inlineScripts
+ * @type Array
+ * @optional
+ */
+ inlineScripts: [],
+ /**
+ * Urls to javascript files required by the app
+ * @property scripts
+ * @type Array
+ * @optional
+ */
+ scripts: [],
+ /**
+ * Urls to CSS files required by the app
+ * @property styles
+ * @type Array
+ * @optional
+ */
+ styles: []
+ },
+ /**
+ * The AppContent object
+ * @class F2.AppManifest.AppContent
+ **/
+ AppContent: {
+ /**
+ * Arbitrary data to be passed along with the app
+ * @property data
+ * @type object
+ * @optional
+ */
+ data: {},
+ /**
+ * The string of HTML representing the app
+ * @property html
+ * @type string
+ * @required
+ */
+ html: '',
+ /**
+ * A status message
+ * @property status
+ * @type string
+ * @optional
+ */
+ status: ''
+ },
+ /**
+ * An object containing configuration information for the
+ * [container](../../container-development.html)
+ * @class F2.ContainerConfig
+ */
+ ContainerConfig: {
+ /**
+ * Allows the [container](../../container-development.html) to override how
+ * an app's html is inserted into the page. The function should accept an
+ * {{#crossLink "F2.AppConfig"}}{{/crossLink}} object and also a string of
+ * html
+ * @method afterAppRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {string} html The string of html representing the app
+ * @return {Element} The DOM Element surrounding the app
+ */
+ afterAppRender: function (appConfig, html) {
+ },
+ /**
+ * Allows the [container](../../container-development.html) to wrap an app
+ * in extra html. The function should accept an
+ * {{#crossLink "F2.AppConfig"}}{{/crossLink}} object and also a string of
+ * html. The extra html can provide links to edit app settings and remove an
+ * app from the container. See
+ * {{#crossLink "F2.Constants.Css"}}{{/crossLink}} for CSS classes that
+ * should be applied to elements.
+ * @method appRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {string} html The string of html representing the app
+ */
+ appRender: function (appConfig, html) {
+ },
+ /**
+ * Allows the container to render html for an app before the AppManifest for
+ * an app has loaded. This can be useful if the design calls for loading
+ * icons to appear for each app before each app is loaded and rendered to
+ * the page.
+ * @method beforeAppRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @return {Element} The DOM Element surrounding the app
+ */
+ beforeAppRender: function (appConfig) {
+ },
+ /**
+ * True to enable debug mode in F2.js. Adds additional logging, resource cache busting, etc.
+ * @property debugMode
+ * @type bool
+ * @default false
+ */
+ debugMode: false,
+ /**
+ * The default language and region specification for this container
+ * represented as an IETF-defined standard language tag,
+ * e.g. `"en-us"` or `"de-de"`. This value is passed to each app
+ * registered as `containerLocale`.
+ *
+ * @property locale
+ * @type string
+ * @default null
+ */
+ locale: null,
+ /**
+ * Milliseconds before F2 fires callback on script resource load errors. Due to issue with the way Internet Explorer attaches load events to script elements, the error event doesn't fire.
+ * @property scriptErrorTimeout
+ * @type milliseconds
+ * @default 7000 (7 seconds)
+ */
+ scriptErrorTimeout: 7000,
+ /**
+ * Tells the container that it is currently running within
+ * a secure app page
+ * @property isSecureAppPage
+ * @type bool
+ */
+ isSecureAppPage: false,
+ /**
+ * Allows the container to specify which page is used when
+ * loading a secure app. The page must reside on a different domain than the
+ * container
+ * @property secureAppPagePath
+ * @type string
+ * @for F2.ContainerConfig
+ */
+ secureAppPagePath: '',
+ /**
+ * Specifies what views a container will provide buttons
+ * or links to. Generally, the views will be switched via buttons or links
+ * in the app's header.
+ * @property supportedViews
+ * @type Array
+ * @required
+ */
+ supportedViews: [],
+ /**
+ * An object containing configuration defaults for F2.UI
+ * @class F2.ContainerConfig.UI
+ */
+ UI: {
+ /**
+ * An object containing configuration defaults for the
+ * F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} and
+ * F2.UI.{{#crossLink "F2.UI/hideMask"}}{{/crossLink}} methods.
+ * @class F2.ContainerConfig.UI.Mask
+ */
+ Mask: {
+ /**
+ * The backround color of the overlay
+ * @property backgroundColor
+ * @type string
+ * @default #FFF
+ */
+ backgroundColor: '#FFF',
+ /**
+ * The path to the loading icon
+ * @property loadingIcon
+ * @type string
+ */
+ loadingIcon: '',
+ /**
+ * The opacity of the background overlay
+ * @property opacity
+ * @type int
+ * @default 0.6
+ */
+ opacity: 0.6,
+ /**
+ * Do not use inline styles for mask functinality. Instead classes will
+ * be applied to the elements and it is up to the container provider to
+ * implement the class definitions.
+ * @property useClasses
+ * @type bool
+ * @default false
+ */
+ useClasses: false,
+ /**
+ * The z-index to use for the overlay
+ * @property zIndex
+ * @type int
+ * @default 2
+ */
+ zIndex: 2
+ }
+ },
+ /**
+ * Allows the container to fully override how the AppManifest request is
+ * made inside of F2.
+ *
+ * @method xhr
+ * @param {string} url The manifest url
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
+ * objects
+ * @param {function} success The function to be called if the request
+ * succeeds
+ * @param {function} error The function to be called if the request fails
+ * @param {function} complete The function to be called when the request
+ * finishes (after success and error callbacks have been executed)
+ * @return {XMLHttpRequest} The XMLHttpRequest object (or an object that has
+ * an `abort` function (such as the jqXHR object in jQuery) to abort the
+ * request)
+ *
+ * @example
+ * F2.init({
* xhr: function(url, appConfigs, success, error, complete) {
* $.ajax({
* url: url,
@@ -427,37 +431,37 @@ F2.extend('', {
* });
* }
* });
- *
- * @for F2.ContainerConfig
- */
- //xhr: function(url, appConfigs, success, error, complete) {},
- /**
- * Allows the container to override individual parts of the AppManifest
- * request. See properties and methods with the `xhr.` prefix.
- * @property xhr
- * @type Object
- *
- * @example
- * F2.init({
+ *
+ * @for F2.ContainerConfig
+ */
+ //xhr: function(url, appConfigs, success, error, complete) {},
+ /**
+ * Allows the container to override individual parts of the AppManifest
+ * request. See properties and methods with the `xhr.` prefix.
+ * @property xhr
+ * @type Object
+ *
+ * @example
+ * F2.init({
* xhr: {
* url: function(url, appConfigs) {
* return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
* }
* }
* });
- */
- xhr: {
- /**
- * Allows the container to override the request data type (JSON or JSONP)
- * that is used for the request
- * @method xhr.dataType
- * @param {string} url The manifest url
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
- * objects
- * @return {string} The request data type that should be used
- *
- * @example
- * F2.init({
+ */
+ xhr: {
+ /**
+ * Allows the container to override the request data type (JSON or JSONP)
+ * that is used for the request
+ * @method xhr.dataType
+ * @param {string} url The manifest url
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
+ * objects
+ * @return {string} The request data type that should be used
+ *
+ * @example
+ * F2.init({
* xhr: {
* dataType: function(url) {
* return F2.isLocalRequest(url) ? 'json' : 'jsonp';
@@ -467,19 +471,20 @@ F2.extend('', {
* }
* }
* });
- */
- dataType: function(url, appConfigs) {},
- /**
- * Allows the container to override the request method that is used (just
- * like the `type` parameter to `jQuery.ajax()`.
- * @method xhr.type
- * @param {string} url The manifest url
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
- * objects
- * @return {string} The request method that should be used
- *
- * @example
- * F2.init({
+ */
+ dataType: function (url, appConfigs) {
+ },
+ /**
+ * Allows the container to override the request method that is used (just
+ * like the `type` parameter to `jQuery.ajax()`.
+ * @method xhr.type
+ * @param {string} url The manifest url
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
+ * objects
+ * @return {string} The request method that should be used
+ *
+ * @example
+ * F2.init({
* xhr: {
* dataType: function(url) {
* return F2.isLocalRequest(url) ? 'json' : 'jsonp';
@@ -489,57 +494,61 @@ F2.extend('', {
* }
* }
* });
- */
- type: function(url, appConfigs) {},
- /**
- * Allows the container to override the url that is used to request an
- * app's F2.{{#crossLink "F2.AppManifest"}}{{/crossLink}}
- * @method xhr.url
- * @param {string} url The manifest url
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
- * objects
- * @return {string} The url that should be used for the request
- *
- * @example
- * F2.init({
+ */
+ type: function (url, appConfigs) {
+ },
+ /**
+ * Allows the container to override the url that is used to request an
+ * app's F2.{{#crossLink "F2.AppManifest"}}{{/crossLink}}
+ * @method xhr.url
+ * @param {string} url The manifest url
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
+ * objects
+ * @return {string} The url that should be used for the request
+ *
+ * @example
+ * F2.init({
* xhr: {
* url: function(url, appConfigs) {
* return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
* }
* }
* });
- */
- url: function(url, appConfigs) {}
- },
- /**
- * Allows the container to override the script loader which requests
- * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
- * @property loadScripts
- * @type function
- *
- * @example
- * F2.init({
+ */
+ url: function (url, appConfigs) {
+ }
+ },
+ /**
+ * Allows the container to override the script loader which requests
+ * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
+ * @property loadScripts
+ * @type function
+ *
+ * @example
+ * F2.init({
* loadScripts: function(scripts,inlines,callback){
* //load scripts using $.load() for each script or require(scripts)
* callback();
* }
* });
- */
- loadScripts: function(scripts,inlines,callback){},
- /**
- * Allows the container to override the stylesheet loader which requests
- * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
- * @property loadStyles
- * @type function
- *
- * @example
- * F2.init({
+ */
+ loadScripts: function (scripts, inlines, callback) {
+ },
+ /**
+ * Allows the container to override the stylesheet loader which requests
+ * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
+ * @property loadStyles
+ * @type function
+ *
+ * @example
+ * F2.init({
* loadStyles: function(styles,callback){
* //load styles using $.load() for each stylesheet or another method
* callback();
* }
* });
- */
- loadStyles: function(styles,callback){}
- }
+ */
+ loadStyles: function (styles, callback) {
+ }
+ }
});
\ No newline at end of file
diff --git a/sdk/src/constants.js b/sdk/src/constants.js
index 62cf277c..5e0b7a08 100644
--- a/sdk/src/constants.js
+++ b/sdk/src/constants.js
@@ -4,289 +4,289 @@
* @static
*/
F2.extend('Constants', {
- /**
- * CSS class constants
- * @class F2.Constants.Css
- */
- Css: (function() {
+ /**
+ * CSS class constants
+ * @class F2.Constants.Css
+ */
+ Css: (function () {
- /** @private */
- var _PREFIX = 'f2-';
+ /** @private */
+ var _PREFIX = 'f2-';
- return {
- /**
- * The APP class should be applied to the DOM Element that surrounds the
- * entire app, including any extra html that surrounds the APP\_CONTAINER
- * that is inserted by the container. See the
- * {{#crossLink "F2.ContainerConfig"}}{{/crossLink}} object.
- * @property APP
- * @type string
- * @static
- * @final
- */
- APP: _PREFIX + 'app',
- /**
- * The APP\_CONTAINER class should be applied to the outermost DOM Element
- * of the app.
- * @property APP_CONTAINER
- * @type string
- * @static
- * @final
- */
- APP_CONTAINER: _PREFIX + 'app-container',
- /**
- * The APP\_TITLE class should be applied to the DOM Element that contains
- * the title for an app. If this class is not present, then
- * F2.UI.{{#crossLink "F2.UI/setTitle"}}{{/crossLink}} will not function.
- * @property APP_TITLE
- * @type string
- * @static
- * @final
- */
- APP_TITLE: _PREFIX + 'app-title',
- /**
- * The APP\_VIEW class should be applied to the DOM Element that contains
- * a view for an app. The DOM Element should also have a
- * {{#crossLink "F2.Constants.Views"}}{{/crossLink}}.DATA_ATTRIBUTE
- * attribute that specifies which
- * {{#crossLink "F2.Constants.Views"}}{{/crossLink}} it is.
- * @property APP_VIEW
- * @type string
- * @static
- * @final
- */
- APP_VIEW: _PREFIX + 'app-view',
- /**
- * APP\_VIEW\_TRIGGER class should be applied to the DOM Elements that
- * trigger an
- * {{#crossLink "F2.Constants.Events"}}{{/crossLink}}.APP\_VIEW\_CHANGE
- * event. The DOM Element should also have a
- * {{#crossLink "F2.Constants.Views"}}{{/crossLink}}.DATA_ATTRIBUTE
- * attribute that specifies which
- * {{#crossLink "F2.Constants.Views"}}{{/crossLink}} it will trigger.
- * @property APP_VIEW_TRIGGER
- * @type string
- * @static
- * @final
- */
- APP_VIEW_TRIGGER: _PREFIX + 'app-view-trigger',
- /**
- * The MASK class is applied to the overlay element that is created
- * when the F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} method is
- * fired.
- * @property MASK
- * @type string
- * @static
- * @final
- */
- MASK: _PREFIX + 'mask',
- /**
- * The MASK_CONTAINER class is applied to the Element that is passed into
- * the F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} method.
- * @property MASK_CONTAINER
- * @type string
- * @static
- * @final
- */
- MASK_CONTAINER: _PREFIX + 'mask-container'
- };
- })(),
-
- /**
- * Events constants
- * @class F2.Constants.Events
- */
- Events: (function() {
- /** @private */
- var _APP_EVENT_PREFIX = 'App.';
- /** @private */
- var _CONTAINER_EVENT_PREFIX = 'Container.';
+ return {
+ /**
+ * The APP class should be applied to the DOM Element that surrounds the
+ * entire app, including any extra html that surrounds the APP\_CONTAINER
+ * that is inserted by the container. See the
+ * {{#crossLink "F2.ContainerConfig"}}{{/crossLink}} object.
+ * @property APP
+ * @type string
+ * @static
+ * @final
+ */
+ APP: _PREFIX + 'app',
+ /**
+ * The APP\_CONTAINER class should be applied to the outermost DOM Element
+ * of the app.
+ * @property APP_CONTAINER
+ * @type string
+ * @static
+ * @final
+ */
+ APP_CONTAINER: _PREFIX + 'app-container',
+ /**
+ * The APP\_TITLE class should be applied to the DOM Element that contains
+ * the title for an app. If this class is not present, then
+ * F2.UI.{{#crossLink "F2.UI/setTitle"}}{{/crossLink}} will not function.
+ * @property APP_TITLE
+ * @type string
+ * @static
+ * @final
+ */
+ APP_TITLE: _PREFIX + 'app-title',
+ /**
+ * The APP\_VIEW class should be applied to the DOM Element that contains
+ * a view for an app. The DOM Element should also have a
+ * {{#crossLink "F2.Constants.Views"}}{{/crossLink}}.DATA_ATTRIBUTE
+ * attribute that specifies which
+ * {{#crossLink "F2.Constants.Views"}}{{/crossLink}} it is.
+ * @property APP_VIEW
+ * @type string
+ * @static
+ * @final
+ */
+ APP_VIEW: _PREFIX + 'app-view',
+ /**
+ * APP\_VIEW\_TRIGGER class should be applied to the DOM Elements that
+ * trigger an
+ * {{#crossLink "F2.Constants.Events"}}{{/crossLink}}.APP\_VIEW\_CHANGE
+ * event. The DOM Element should also have a
+ * {{#crossLink "F2.Constants.Views"}}{{/crossLink}}.DATA_ATTRIBUTE
+ * attribute that specifies which
+ * {{#crossLink "F2.Constants.Views"}}{{/crossLink}} it will trigger.
+ * @property APP_VIEW_TRIGGER
+ * @type string
+ * @static
+ * @final
+ */
+ APP_VIEW_TRIGGER: _PREFIX + 'app-view-trigger',
+ /**
+ * The MASK class is applied to the overlay element that is created
+ * when the F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} method is
+ * fired.
+ * @property MASK
+ * @type string
+ * @static
+ * @final
+ */
+ MASK: _PREFIX + 'mask',
+ /**
+ * The MASK_CONTAINER class is applied to the Element that is passed into
+ * the F2.UI.{{#crossLink "F2.UI/showMask"}}{{/crossLink}} method.
+ * @property MASK_CONTAINER
+ * @type string
+ * @static
+ * @final
+ */
+ MASK_CONTAINER: _PREFIX + 'mask-container'
+ };
+ })(),
- return {
- /**
- * The APP\_SYMBOL\_CHANGE event is fired when the symbol is changed in an
- * app. It is up to the app developer to fire this event.
- * Returns an object with the symbol and company name:
- *
- * { symbol: 'MSFT', name: 'Microsoft Corp (NASDAQ)' }
- *
- * @property APP_SYMBOL_CHANGE
- * @type string
- * @static
- * @final
- */
- APP_SYMBOL_CHANGE: _APP_EVENT_PREFIX + 'symbolChange',
- /**
- * The APP\_WIDTH\_CHANGE event will be fired by the container when the
- * width of an app is changed. The app's instanceId should be concatenated
- * to this constant.
- * Returns an object with the gridSize and width in pixels:
- *
- * { gridSize:8, width:620 }
- *
- * @property APP_WIDTH_CHANGE
- * @type string
- * @static
- * @final
- */
- APP_WIDTH_CHANGE: _APP_EVENT_PREFIX + 'widthChange.',
- /**
- * The CONTAINER\_SYMBOL\_CHANGE event is fired when the symbol is changed
- * at the container level. This event should only be fired by the
- * container or container provider.
- * Returns an object with the symbol and company name:
- *
- * { symbol: 'MSFT', name: 'Microsoft Corp (NASDAQ)' }
- *
- * @property CONTAINER_SYMBOL_CHANGE
- * @type string
- * @static
- * @final
- */
- CONTAINER_SYMBOL_CHANGE: _CONTAINER_EVENT_PREFIX + 'symbolChange',
- /**
- * The CONTAINER\_WIDTH\_CHANGE event will be fired by the container when
- * the width of the container has changed.
- * @property CONTAINER_WIDTH_CHANGE
- * @type string
- * @static
- * @final
- */
- CONTAINER_WIDTH_CHANGE: _CONTAINER_EVENT_PREFIX + 'widthChange',
- /**
- * The CONTAINER\_LOCALE\_CHANGE event will be fired by the container when
- * the locale of the container has changed. This event should only be fired by the
- * container or container provider.
- * Returns an object with the updated locale (IETF-defined standard language tag):
- *
- * { locale: 'en-us' }
- *
- * @property CONTAINER_LOCALE_CHANGE
- * @type string
- * @static
- * @final
- */
- CONTAINER_LOCALE_CHANGE: _CONTAINER_EVENT_PREFIX + 'localeChange'
- };
- })(),
+ /**
+ * Events constants
+ * @class F2.Constants.Events
+ */
+ Events: (function () {
+ /** @private */
+ var _APP_EVENT_PREFIX = 'App.';
+ /** @private */
+ var _CONTAINER_EVENT_PREFIX = 'Container.';
- JSONP_CALLBACK: 'F2_jsonpCallback_',
+ return {
+ /**
+ * The APP\_SYMBOL\_CHANGE event is fired when the symbol is changed in an
+ * app. It is up to the app developer to fire this event.
+ * Returns an object with the symbol and company name:
+ *
+ * { symbol: 'MSFT', name: 'Microsoft Corp (NASDAQ)' }
+ *
+ * @property APP_SYMBOL_CHANGE
+ * @type string
+ * @static
+ * @final
+ */
+ APP_SYMBOL_CHANGE: _APP_EVENT_PREFIX + 'symbolChange',
+ /**
+ * The APP\_WIDTH\_CHANGE event will be fired by the container when the
+ * width of an app is changed. The app's instanceId should be concatenated
+ * to this constant.
+ * Returns an object with the gridSize and width in pixels:
+ *
+ * { gridSize:8, width:620 }
+ *
+ * @property APP_WIDTH_CHANGE
+ * @type string
+ * @static
+ * @final
+ */
+ APP_WIDTH_CHANGE: _APP_EVENT_PREFIX + 'widthChange.',
+ /**
+ * The CONTAINER\_SYMBOL\_CHANGE event is fired when the symbol is changed
+ * at the container level. This event should only be fired by the
+ * container or container provider.
+ * Returns an object with the symbol and company name:
+ *
+ * { symbol: 'MSFT', name: 'Microsoft Corp (NASDAQ)' }
+ *
+ * @property CONTAINER_SYMBOL_CHANGE
+ * @type string
+ * @static
+ * @final
+ */
+ CONTAINER_SYMBOL_CHANGE: _CONTAINER_EVENT_PREFIX + 'symbolChange',
+ /**
+ * The CONTAINER\_WIDTH\_CHANGE event will be fired by the container when
+ * the width of the container has changed.
+ * @property CONTAINER_WIDTH_CHANGE
+ * @type string
+ * @static
+ * @final
+ */
+ CONTAINER_WIDTH_CHANGE: _CONTAINER_EVENT_PREFIX + 'widthChange',
+ /**
+ * The CONTAINER\_LOCALE\_CHANGE event will be fired by the container when
+ * the locale of the container has changed. This event should only be fired by the
+ * container or container provider.
+ * Returns an object with the updated locale (IETF-defined standard language tag):
+ *
+ * { locale: 'en-us' }
+ *
+ * @property CONTAINER_LOCALE_CHANGE
+ * @type string
+ * @static
+ * @final
+ */
+ CONTAINER_LOCALE_CHANGE: _CONTAINER_EVENT_PREFIX + 'localeChange'
+ };
+ })(),
- /**
- * Constants for use with cross-domain sockets
- * @class F2.Constants.Sockets
- * @protected
- */
- Sockets: {
- /**
- * The EVENT message is sent whenever
- * F2.Events.{{#crossLink "F2.Events/emit"}}{{/crossLink}} is fired
- * @property EVENT
- * @type string
- * @static
- * @final
- */
- EVENT: '__event__',
- /**
- * The LOAD message is sent when an iframe socket initially loads.
- * Returns a JSON string that represents:
- *
- * [ App, AppManifest]
- *
- * @property LOAD
- * @type string
- * @static
- * @final
- */
- LOAD: '__socketLoad__',
- /**
- * The RPC message is sent when a method is passed up from within a secure
- * app page.
- * @property RPC
- * @type string
- * @static
- * @final
- */
- RPC: '__rpc__',
- /**
- * The RPC\_CALLBACK message is sent when a call back from an RPC method is
- * fired.
- * @property RPC_CALLBACK
- * @type string
- * @static
- * @final
- */
- RPC_CALLBACK: '__rpcCallback__',
- /**
- * The UI\_RPC message is sent when a UI method called.
- * @property UI_RPC
- * @type string
- * @static
- * @final
- */
- UI_RPC: '__uiRpc__'
- },
+ JSONP_CALLBACK: 'F2_jsonpCallback_',
- /**
- * The available view types to apps. The view should be specified by applying
- * the {{#crossLink "F2.Constants.Css"}}{{/crossLink}}.APP\_VIEW class to the
- * containing DOM Element. A DATA\_ATTRIBUTE attribute should be added to the
- * Element as well which defines what view type is represented.
- * The `hide` class can be applied to views that should be hidden by default.
- * @class F2.Constants.Views
- */
- Views: {
- /**
- * The DATA_ATTRIBUTE should be placed on the DOM Element that contains the
- * view.
- * @property DATA_ATTRIBUTE
- * @type string
- * @static
- * @final
- */
- DATA_ATTRIBUTE: 'data-f2-view',
- /**
- * The ABOUT view gives details about the app.
- * @property ABOUT
- * @type string
- * @static
- * @final
- */
- ABOUT: 'about',
- /**
- * The HELP view provides users with help information for using an app.
- * @property HELP
- * @type string
- * @static
- * @final
- */
- HELP: 'help',
- /**
- * The HOME view is the main view for an app. This view should always
- * be provided by an app.
- * @property HOME
- * @type string
- * @static
- * @final
- */
- HOME: 'home',
- /**
- * The REMOVE view is a special view that handles the removal of an app
- * from the container.
- * @property REMOVE
- * @type string
- * @static
- * @final
- */
- REMOVE: 'remove',
- /**
- * The SETTINGS view provides users the ability to modify advanced settings
- * for an app.
- * @property SETTINGS
- * @type string
- * @static
- * @final
- */
- SETTINGS: 'settings'
- }
+ /**
+ * Constants for use with cross-domain sockets
+ * @class F2.Constants.Sockets
+ * @protected
+ */
+ Sockets: {
+ /**
+ * The EVENT message is sent whenever
+ * F2.Events.{{#crossLink "F2.Events/emit"}}{{/crossLink}} is fired
+ * @property EVENT
+ * @type string
+ * @static
+ * @final
+ */
+ EVENT: '__event__',
+ /**
+ * The LOAD message is sent when an iframe socket initially loads.
+ * Returns a JSON string that represents:
+ *
+ * [ App, AppManifest]
+ *
+ * @property LOAD
+ * @type string
+ * @static
+ * @final
+ */
+ LOAD: '__socketLoad__',
+ /**
+ * The RPC message is sent when a method is passed up from within a secure
+ * app page.
+ * @property RPC
+ * @type string
+ * @static
+ * @final
+ */
+ RPC: '__rpc__',
+ /**
+ * The RPC\_CALLBACK message is sent when a call back from an RPC method is
+ * fired.
+ * @property RPC_CALLBACK
+ * @type string
+ * @static
+ * @final
+ */
+ RPC_CALLBACK: '__rpcCallback__',
+ /**
+ * The UI\_RPC message is sent when a UI method called.
+ * @property UI_RPC
+ * @type string
+ * @static
+ * @final
+ */
+ UI_RPC: '__uiRpc__'
+ },
+
+ /**
+ * The available view types to apps. The view should be specified by applying
+ * the {{#crossLink "F2.Constants.Css"}}{{/crossLink}}.APP\_VIEW class to the
+ * containing DOM Element. A DATA\_ATTRIBUTE attribute should be added to the
+ * Element as well which defines what view type is represented.
+ * The `hide` class can be applied to views that should be hidden by default.
+ * @class F2.Constants.Views
+ */
+ Views: {
+ /**
+ * The DATA_ATTRIBUTE should be placed on the DOM Element that contains the
+ * view.
+ * @property DATA_ATTRIBUTE
+ * @type string
+ * @static
+ * @final
+ */
+ DATA_ATTRIBUTE: 'data-f2-view',
+ /**
+ * The ABOUT view gives details about the app.
+ * @property ABOUT
+ * @type string
+ * @static
+ * @final
+ */
+ ABOUT: 'about',
+ /**
+ * The HELP view provides users with help information for using an app.
+ * @property HELP
+ * @type string
+ * @static
+ * @final
+ */
+ HELP: 'help',
+ /**
+ * The HOME view is the main view for an app. This view should always
+ * be provided by an app.
+ * @property HOME
+ * @type string
+ * @static
+ * @final
+ */
+ HOME: 'home',
+ /**
+ * The REMOVE view is a special view that handles the removal of an app
+ * from the container.
+ * @property REMOVE
+ * @type string
+ * @static
+ * @final
+ */
+ REMOVE: 'remove',
+ /**
+ * The SETTINGS view provides users the ability to modify advanced settings
+ * for an app.
+ * @property SETTINGS
+ * @type string
+ * @static
+ * @final
+ */
+ SETTINGS: 'settings'
+ }
});
\ No newline at end of file
diff --git a/sdk/src/container.js b/sdk/src/container.js
index 6893215c..e3ea6f60 100644
--- a/sdk/src/container.js
+++ b/sdk/src/container.js
@@ -3,1165 +3,1166 @@
* @module f2
* @class F2
*/
-F2.extend('', (function() {
-
- var _apps = {};
- var _config = false;
- var _bUsesAppHandlers = false;
- var _sAppHandlerToken = F2.AppHandlers.__f2GetToken();
-
- /**
- * Appends the app's html to the DOM
- * @method _afterAppRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {string} html The string of html
- * @return {Element} The DOM Element that contains the app
- */
- var _afterAppRender = function(appConfig, html) {
-
- var handler = _config.afterAppRender || function(appConfig, html) {
- return jQuery(html).appendTo('body');
- };
- var appContainer = handler(appConfig, html);
-
- if ( !! _config.afterAppRender && !appContainer) {
- F2.log('F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app');
- return;
- }
- else {
- // apply APP class
- jQuery(appContainer).addClass(F2.Constants.Css.APP);
- return appContainer.get(0);
- }
- };
-
- /**
- * Renders the html for an app.
- * @method _appRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {string} html The string of html
- */
- var _appRender = function(appConfig, html) {
-
- // apply APP_CONTAINER class and AppID
- html = _outerHtml(jQuery(html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId));
-
- // optionally apply wrapper html
- if (_config.appRender) {
- html = _config.appRender(appConfig, html);
- }
-
- return _outerHtml(html);
- };
-
- /**
- * Rendering hook to allow containers to render some html prior to an app
- * loading
- * @method _beforeAppRender
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @return {Element} The DOM Element surrounding the app
- */
- var _beforeAppRender = function(appConfig) {
- var handler = _config.beforeAppRender || jQuery.noop;
- return handler(appConfig);
- };
-
- /**
- * Handler to inform the container that a script failed to load
- * @method _onScriptLoadFailure
- * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param scriptInfo The path of the script that failed to load or the exception info
- * for the inline script that failed to execute
- */
- var _appScriptLoadFailed = function(appConfig, scriptInfo) {
- var handler = _config.appScriptLoadFailed || jQuery.noop;
- return handler(appConfig, scriptInfo);
- };
-
- /**
- * Adds properties to the AppConfig object
- * @method _createAppConfig
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @return {F2.AppConfig} The new F2.AppConfig object, prepopulated with
- * necessary properties
- */
- var _createAppConfig = function(appConfig) {
-
- // make a copy of the app config to ensure that the original is not modified
- appConfig = jQuery.extend(true, {}, appConfig);
-
- // create the instanceId for the app
- appConfig.instanceId = appConfig.instanceId || F2.guid();
-
- // default the views if not provided
- appConfig.views = appConfig.views || [];
- if (!F2.inArray(F2.Constants.Views.HOME, appConfig.views)) {
- appConfig.views.push(F2.Constants.Views.HOME);
- }
-
- //pass container-defined locale to each app
- if (F2.ContainerConfig.locale){
- appConfig.containerLocale = F2.ContainerConfig.locale;
- }
-
- return appConfig;
- };
-
- /**
- * Generate an AppConfig from the element's attributes
- * @method _getAppConfigFromElement
- * @private
- * @param {Element} node The DOM node from which to generate the F2.AppConfig object
- * @return {F2.AppConfig} The new F2.AppConfig object
- */
- var _getAppConfigFromElement = function(node) {
- var appConfig;
-
- if (node) {
- var appId = node.getAttribute('data-f2-appid');
- var manifestUrl = node.getAttribute('data-f2-manifesturl');
-
- if (appId && manifestUrl) {
- appConfig = {
- appId: appId,
- enableBatchRequests: node.hasAttribute('data-f2-enablebatchrequests'),
- isSecure: node.hasAttribute('data-f2-issecure'),
- manifestUrl: manifestUrl,
- root: node
- };
-
- // See if the user passed in a block of serialized json
- var contextJson = node.getAttribute('data-f2-context');
-
- if (contextJson) {
- try {
- appConfig.context = F2.parse(contextJson);
- }
- catch (e) {
- console.warn('F2: "data-f2-context" of node is not valid JSON', '"' + e + '"');
- }
- }
- }
- }
-
- return appConfig;
- };
-
- /**
- * Returns true if the DOM node has children that are not text nodes
- * @method _hasNonTextChildNodes
- * @param {Element} node The DOM node
- * @return {bool} True if there are non-text children
- */
- var _hasNonTextChildNodes = function(node) {
- var hasNodes = false;
-
- if (node.hasChildNodes()) {
- for (var i = 0, len = node.childNodes.length; i < len; i++) {
- if (node.childNodes[i].nodeType === 1) {
- hasNodes = true;
- break;
- }
- }
- }
-
- return hasNodes;
- };
-
- /**
- * Adds properties to the ContainerConfig object to take advantage of defaults
- * @method _hydrateContainerConfig
- * @private
- * @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
- */
- var _hydrateContainerConfig = function(containerConfig) {
-
- if (!containerConfig.scriptErrorTimeout) {
- containerConfig.scriptErrorTimeout = F2.ContainerConfig.scriptErrorTimeout;
- }
-
- if (containerConfig.debugMode !== true) {
- containerConfig.debugMode = F2.ContainerConfig.debugMode;
- }
-
- if (containerConfig.locale && typeof containerConfig.locale == 'string'){
- F2.ContainerConfig.locale = containerConfig.locale;
- }
- };
-
- /**
- * Attach app events
- * @method _initAppEvents
- * @private
- */
- var _initAppEvents = function(appConfig) {
-
- jQuery(appConfig.root).on('click', '.' + F2.Constants.Css.APP_VIEW_TRIGGER + '[' + F2.Constants.Views.DATA_ATTRIBUTE + ']', function(event) {
-
- event.preventDefault();
-
- var view = jQuery(this).attr(F2.Constants.Views.DATA_ATTRIBUTE).toLowerCase();
-
- // handle the special REMOVE view
- if (view == F2.Constants.Views.REMOVE) {
- F2.removeApp(appConfig.instanceId);
- }
- else {
- appConfig.ui.Views.change(view);
- }
- });
- };
-
- /**
- * Attach container Events
- * @method _initContainerEvents
- * @private
- */
- var _initContainerEvents = function() {
-
- var resizeTimeout;
- var resizeHandler = function() {
- F2.Events.emit(F2.Constants.Events.CONTAINER_WIDTH_CHANGE);
- };
-
- jQuery(window).on('resize', function() {
- clearTimeout(resizeTimeout);
- resizeTimeout = setTimeout(resizeHandler, 100);
- });
-
- //listen for container-broadcasted locale changes
- F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(data){
- if (data.locale && typeof data.locale == 'string'){
- F2.ContainerConfig.locale = data.locale;
- }
- });
- };
-
- /**
- * Checks if an element is a placeholder element
- * @method _isPlaceholderElement
- * @private
- * @param {Element} node The DOM element to check
- * @return {bool} True if the element is a placeholder
- */
- var _isPlaceholderElement = function(node) {
- return (
- F2.isNativeDOMNode(node) &&
- !_hasNonTextChildNodes(node) &&
- !!node.getAttribute('data-f2-appid') &&
- !!node.getAttribute('data-f2-manifesturl')
- );
- };
-
- /**
- * Has the container been init?
- * @method _isInit
- * @private
- * @return {bool} True if the container has been init
- */
- var _isInit = function() {
- return !!_config;
- };
-
- /**
- * Instantiates each app from it's appConfig and stores that in a local private collection
- * @method _createAppInstance
- * @private
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
- */
- var _createAppInstance = function(appConfig, appContent) {
- // instantiate F2.UI
- appConfig.ui = new F2.UI(appConfig);
-
- // instantiate F2.App
- if (F2.Apps[appConfig.appId] !== undefined) {
- if (typeof F2.Apps[appConfig.appId] === 'function') {
-
- // IE
- setTimeout(function() {
- _apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root);
- if (_apps[appConfig.instanceId].app['init'] !== undefined) {
- _apps[appConfig.instanceId].app.init();
- }
- }, 0);
-
- }
- else {
- F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')');
- }
- }
- };
-
- /**
- * Loads the app's html/css/javascript
- * @method loadApp
- * @private
- * @param {Array} appConfigs An array of
- * {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
- * @param {F2.AppManifest} [appManifest] The AppManifest object
- */
- var _loadApps = function(appConfigs, appManifest) {
- appConfigs = [].concat(appConfigs);
-
- // check for secure app
- if (appConfigs.length == 1 && appConfigs[0].isSecure && !_config.isSecureAppPage) {
- _loadSecureApp(appConfigs[0], appManifest);
- return;
- }
-
- // check that the number of apps in manifest matches the number requested
- if (appConfigs.length != appManifest.apps.length) {
- F2.log('The number of apps defined in the AppManifest do not match the number requested.', appManifest);
- return;
- }
-
- // Fn for loading manifest Styles
- var _loadStyles = function(styles, cb) {
- // Attempt to use the user provided method
- if (_config.loadStyles) {
- _config.loadStyles(styles, cb);
- }
- else {
- // load styles, see #101
- var stylesFragment = null,
- useCreateStyleSheet = !! document.createStyleSheet;
-
- jQuery.each(styles, function(i, e) {
- if (useCreateStyleSheet) {
- document.createStyleSheet(e);
- }
- else {
- stylesFragment = stylesFragment || [];
- stylesFragment.push('
');
- }
- });
-
- if (stylesFragment) {
- jQuery('head').append(stylesFragment.join(''));
- }
-
- cb();
- }
- };
-
- // Fn for loading manifest Scripts
- var _loadScripts = function(scripts, cb) {
- // Attempt to use the user provided method
- if (_config.loadScripts) {
- _config.loadScripts(scripts, cb);
- }
- else {
- if (scripts.length) {
- var scriptCount = scripts.length;
- var scriptsLoaded = 0;
-
- // Check for IE10+ so that we don't rely on onreadystatechange
- var readyStates = ('addEventListener' in window) ? {} : {
- 'loaded': true,
- 'complete': true
- };
-
- // Log and emit event for the failed (400,500) scripts
- var _error = function(e) {
- setTimeout(function() {
- var evtData = {
- src: e.target.src,
- appId: appConfigs[0].appId
- };
-
- // Send error to console
- F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\'');
-
- // Emit event
- F2.Events.emit('RESOURCE_FAILED_TO_LOAD', evtData);
-
- if (!_bUsesAppHandlers) {
- _appScriptLoadFailed(appConfigs[0], evtData.src);
- }
- else {
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
- appConfigs[0],
- evtData.src
- );
- }
- }, _config.scriptErrorTimeout); // Defaults to 7000
- };
-
- // Load scripts and eval inlines once complete
- jQuery.each(scripts, function(i, e) {
- var doc = document,
- script = doc.createElement('script'),
- resourceUrl = e;
-
- // If in debugMode, add cache buster to each script URL
- if (_config.debugMode) {
- resourceUrl += '?cachebuster=' + new Date().getTime();
- }
-
- // Scripts needed to be loaded in order they're defined in the AppManifest
- script.async = false;
- // Add other attrs
- script.src = resourceUrl;
- script.type = 'text/javascript';
- script.charset = 'utf-8';
- script.onerror = _error;
-
- // Use a closure for the load event so that we can dereference the original script
- script.onload = script.onreadystatechange = function(e) {
- e = e || window.event; // For older IE
-
- if (e.type == 'load' || readyStates[script.readyState]) {
- // Done, cleanup
- script.onload = script.onreadystatechange = script.onerror = null;
-
- // Dereference script
- script = null;
-
- // Are we done loading all scripts for this app?
- if (++scriptsLoaded === scriptCount) {
- cb();
- }
- }
- };
-
- doc.body.appendChild(script);
- });
- }
- else {
- cb();
- }
- }
- };
-
- var _loadInlineScripts = function(inlines, cb) {
- // Attempt to use the user provided method
- if (_config.loadInlineScripts) {
- _config.loadInlineScripts(inlines, cb);
- }
- else {
- for (var i = 0, len = inlines.length; i < len; i++) {
- try {
- eval(inlines[i]);
- }
- catch (exception) {
- F2.log('Error loading inline script: ' + exception + '\n\n' + inlines[i]);
-
- if (!_bUsesAppHandlers) {
- _appScriptLoadFailed(appConfigs[0], exception);
- }
- else {
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
- appConfigs[0],
- exception
- );
- }
- }
- }
- cb();
- }
- };
-
- // Determine whether an element has been added to the page
- var elementInDocument = function(element) {
- if (element) {
- while (element.parentNode) {
- element = element.parentNode;
-
- if (element === document) {
- return true;
- }
- }
- }
-
- return false;
- };
-
- // Fn for loading manifest app html
- var _loadHtml = function(apps) {
- jQuery.each(apps, function(i, a) {
- if (_isPlaceholderElement(appConfigs[i].root)) {
- jQuery(appConfigs[i].root)
- .addClass(F2.Constants.Css.APP)
- .append(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId));
- }
- else if (!_bUsesAppHandlers) {
- // load html and save the root node
- appConfigs[i].root = _afterAppRender(appConfigs[i], _appRender(appConfigs[i], a.html));
- }
- else {
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- appConfigs[i], // the app config
- _outerHtml(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId))
- );
-
- var appId = appConfigs[i].appId,
- root = appConfigs[i].root;
-
- if (!root) {
- throw ('Root for ' + appId + ' must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.');
- }
-
- if (!elementInDocument(root)) {
- throw ('App root for ' + appId + ' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.');
- }
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- appConfigs[i] // the app config
- );
-
- if (!F2.isNativeDOMNode(root)) {
- throw ('App root for ' + appId + ' must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element.');
- }
- }
-
- // init events
- _initAppEvents(appConfigs[i]);
- });
- };
-
- // Pull out the manifest data
- var scripts = appManifest.scripts || [];
- var styles = appManifest.styles || [];
- var inlines = appManifest.inlineScripts || [];
- var apps = appManifest.apps || [];
-
- // Finally, load the styles, html, and scripts
- _loadStyles(styles, function() {
- // Put the html on the page
- _loadHtml(apps);
- // Add the script content to the page
- _loadScripts(scripts, function() {
- // Load any inline scripts
- _loadInlineScripts(inlines, function() {
- // Create the apps
- jQuery.each(appConfigs, function(i, a) {
- _createAppInstance(a, appManifest.apps[i]);
- });
- });
- });
- });
- };
-
- /**
- * Loads the app's html/css/javascript into an iframe
- * @method loadSecureApp
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {F2.AppManifest} appManifest The app's html/css/js to be loaded into the
- * page.
- */
- var _loadSecureApp = function(appConfig, appManifest) {
-
- // make sure the container is configured for secure apps
- if (_config.secureAppPagePath) {
- if (_isPlaceholderElement(appConfig.root)) {
- jQuery(appConfig.root)
- .addClass(F2.Constants.Css.APP)
- .append(jQuery('
').addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId));
- }
- else if (!_bUsesAppHandlers) {
- // create the html container for the iframe
- appConfig.root = _afterAppRender(appConfig, _appRender(appConfig, '
'));
- }
- else {
- var $root = jQuery(appConfig.root);
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- appConfig, // the app config
- _outerHtml(jQuery(appManifest.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId))
- );
-
- if ($root.parents('body:first').length === 0) {
- throw ('App was never rendered on the page. Please check your AppHandler callbacks to ensure you have rendered the app root to the DOM.');
- }
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- appConfig // the app config
- );
-
- if (!appConfig.root) {
- throw ('App Root must be a native dom node and can not be null or undefined. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node.');
- }
-
- if (!F2.isNativeDOMNode(appConfig.root)) {
- throw ('App Root must be a native dom node. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node.');
- }
- }
-
- // instantiate F2.UI
- appConfig.ui = new F2.UI(appConfig);
- // init events
- _initAppEvents(appConfig);
- // create RPC socket
- F2.Rpc.register(appConfig, appManifest);
- }
- else {
- F2.log('Unable to load secure app: "secureAppPagePath" is not defined in F2.ContainerConfig.');
- }
- };
-
- var _outerHtml = function(html) {
- return jQuery('
').append(html).html();
- };
-
- /**
- * Checks if the app is valid
- * @method _validateApp
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @returns {bool} True if the app is valid
- */
- var _validateApp = function(appConfig) {
-
- // check for valid app configurations
- if (!appConfig.appId) {
- F2.log('"appId" missing from app object');
- return false;
- }
- else if (!appConfig.root && !appConfig.manifestUrl) {
- F2.log('"manifestUrl" missing from app object');
- return false;
- }
-
- return true;
- };
-
- /**
- * Checks if the ContainerConfig is valid
- * @method _validateContainerConfig
- * @private
- * @returns {bool} True if the config is valid
- */
- var _validateContainerConfig = function() {
-
- if (_config) {
- if (_config.xhr) {
- if (!(typeof _config.xhr === 'function' || typeof _config.xhr === 'object')) {
- throw ('ContainerConfig.xhr should be a function or an object');
- }
- if (_config.xhr.dataType && typeof _config.xhr.dataType !== 'function') {
- throw ('ContainerConfig.xhr.dataType should be a function');
- }
- if (_config.xhr.type && typeof _config.xhr.type !== 'function') {
- throw ('ContainerConfig.xhr.type should be a function');
- }
- if (_config.xhr.url && typeof _config.xhr.url !== 'function') {
- throw ('ContainerConfig.xhr.url should be a function');
- }
- }
- }
-
- return true;
- };
-
- return {
- /**
- * Gets the current list of apps in the container
- * @method getContainerState
- * @returns {Array} An array of objects containing the appId
- */
- getContainerState: function() {
- if (!_isInit()) {
- F2.log('F2.init() must be called before F2.getContainerState()');
- return;
- }
-
- return jQuery.map(_apps, function(app) {
- return {
- appId: app.config.appId
- };
- });
- },
- /**
- * Gets the current locale defined by the container
- * @method getContainerLocale
- * @returns {String} IETF-defined standard language tag
- */
- getContainerLocale: function() {
- if (!_isInit()) {
- F2.log('F2.init() must be called before F2.getContainerLocale()');
- return;
- }
-
- return F2.ContainerConfig.locale;
- },
- /**
- * Initializes the container. This method must be called before performing
- * any other actions in the container.
- * @method init
- * @param {F2.ContainerConfig} config The configuration object
- */
- init: function(config) {
- _config = config || {};
-
- _validateContainerConfig();
-
- _hydrateContainerConfig(_config);
-
- // dictates whether we use the old logic or the new logic.
- // TODO: Remove in v2.0
- _bUsesAppHandlers = (!_config.beforeAppRender && !_config.appRender && !_config.afterAppRender && !_config.appScriptLoadFailed);
-
- // only establish RPC connection if the container supports the secure app page
- if ( !! _config.secureAppPagePath || _config.isSecureAppPage) {
- F2.Rpc.init( !! _config.secureAppPagePath ? _config.secureAppPagePath : false);
- }
-
- F2.UI.init(_config);
-
- if (!_config.isSecureAppPage) {
- _initContainerEvents();
- }
- },
- /**
- * Has the container been init?
- * @method isInit
- * @return {bool} True if the container has been init
- */
- isInit: _isInit,
- /**
- * Automatically load apps that are already defined in the DOM. Elements will
- * be rendered into the location of the placeholder DOM element. Any AppHandlers
- * that are defined will be bypassed.
- * @method loadPlaceholders
- * @param {Element} parentNode The element to search for placeholder apps
- */
- loadPlaceholders: function(parentNode) {
-
- var elements = [],
- appConfigs = [],
- add = function(e) {
- if (!e) { return; }
- elements.push(e);
- },
- addAll = function(els) {
- if (!els) { return; }
- for (var i = 0, len = els.length; i < len; i++) {
- add(els[i]);
- }
- };
-
- if (!!parentNode && !F2.isNativeDOMNode(parentNode)) {
- throw ('"parentNode" must be null or a DOM node');
- }
-
- // if the passed in element has a data-f2-appid attribute add
- // it to the list of elements but to not search within that
- // element for other placeholders
- if (parentNode && parentNode.hasAttribute('data-f2-appid')) {
- add(parentNode);
- } else {
-
- // find placeholders within the parentNode only if
- // querySelectorAll exists
- parentNode = parentNode || document;
- if (parentNode.querySelectorAll) {
- addAll(parentNode.querySelectorAll('[data-f2-appid]'));
- }
- }
-
- for (var i = 0, len = elements.length; i < len; i++) {
- var appConfig = _getAppConfigFromElement(elements[i]);
- appConfigs.push(appConfig);
- }
-
- if (appConfigs.length) {
- F2.registerApps(appConfigs);
- }
- },
- /**
- * Begins the loading process for all apps and/or initialization process for pre-loaded apps.
- * The app will be passed the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object which will
- * contain the app's unique instanceId within the container. If the
- * {{#crossLink "F2.AppConfig"}}{{/crossLink}}.root property is populated the app is considered
- * to be a pre-loaded app and will be handled accordingly. Optionally, the
- * {{#crossLink "F2.AppManifest"}}{{/crossLink}} can be passed in and those
- * assets will be used instead of making a request.
- * @method registerApps
- * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
- * objects
- * @param {Array} [appManifests] An array of
- * {{#crossLink "F2.AppManifest"}}{{/crossLink}}
- * objects. This array must be the same length as the apps array that is
- * objects. This array must be the same length as the apps array that is
- * passed in. This can be useful if apps are loaded on the server-side and
- * passed down to the client.
- * @example
- * Traditional App requests.
- *
- * // Traditional f2 app configs
- * var arConfigs = [
- * {
+F2.extend('', (function () {
+
+ var _apps = {};
+ var _config = false;
+ var _bUsesAppHandlers = false;
+ var _sAppHandlerToken = F2.AppHandlers.__f2GetToken();
+
+ /**
+ * Appends the app's html to the DOM
+ * @method _afterAppRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {string} html The string of html
+ * @return {Element} The DOM Element that contains the app
+ */
+ var _afterAppRender = function (appConfig, html) {
+
+ var handler = _config.afterAppRender || function (appConfig, html) {
+ return jQuery(html).appendTo('body');
+ };
+ var appContainer = handler(appConfig, html);
+
+ if (!!_config.afterAppRender && !appContainer) {
+ F2.log('F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app');
+ return;
+ }
+ else {
+ // apply APP class
+ jQuery(appContainer).addClass(F2.Constants.Css.APP);
+ return appContainer.get(0);
+ }
+ };
+
+ /**
+ * Renders the html for an app.
+ * @method _appRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {string} html The string of html
+ */
+ var _appRender = function (appConfig, html) {
+
+ // apply APP_CONTAINER class and AppID
+ html = _outerHtml(jQuery(html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId));
+
+ // optionally apply wrapper html
+ if (_config.appRender) {
+ html = _config.appRender(appConfig, html);
+ }
+
+ return _outerHtml(html);
+ };
+
+ /**
+ * Rendering hook to allow containers to render some html prior to an app
+ * loading
+ * @method _beforeAppRender
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @return {Element} The DOM Element surrounding the app
+ */
+ var _beforeAppRender = function (appConfig) {
+ var handler = _config.beforeAppRender || jQuery.noop;
+ return handler(appConfig);
+ };
+
+ /**
+ * Handler to inform the container that a script failed to load
+ * @method _onScriptLoadFailure
+ * @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param scriptInfo The path of the script that failed to load or the exception info
+ * for the inline script that failed to execute
+ */
+ var _appScriptLoadFailed = function (appConfig, scriptInfo) {
+ var handler = _config.appScriptLoadFailed || jQuery.noop;
+ return handler(appConfig, scriptInfo);
+ };
+
+ /**
+ * Adds properties to the AppConfig object
+ * @method _createAppConfig
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @return {F2.AppConfig} The new F2.AppConfig object, prepopulated with
+ * necessary properties
+ */
+ var _createAppConfig = function (appConfig) {
+
+ // make a copy of the app config to ensure that the original is not modified
+ appConfig = jQuery.extend(true, {}, appConfig);
+
+ // create the instanceId for the app
+ appConfig.instanceId = appConfig.instanceId || F2.guid();
+
+ // default the views if not provided
+ appConfig.views = appConfig.views || [];
+ if (!F2.inArray(F2.Constants.Views.HOME, appConfig.views)) {
+ appConfig.views.push(F2.Constants.Views.HOME);
+ }
+
+ //pass container-defined locale to each app
+ if (F2.ContainerConfig.locale) {
+ appConfig.containerLocale = F2.ContainerConfig.locale;
+ }
+
+ return appConfig;
+ };
+
+ /**
+ * Generate an AppConfig from the element's attributes
+ * @method _getAppConfigFromElement
+ * @private
+ * @param {Element} node The DOM node from which to generate the F2.AppConfig object
+ * @return {F2.AppConfig} The new F2.AppConfig object
+ */
+ var _getAppConfigFromElement = function (node) {
+ var appConfig;
+
+ if (node) {
+ var appId = node.getAttribute('data-f2-appid');
+ var manifestUrl = node.getAttribute('data-f2-manifesturl');
+
+ if (appId && manifestUrl) {
+ appConfig = {
+ appId: appId,
+ enableBatchRequests: node.hasAttribute('data-f2-enablebatchrequests'),
+ isSecure: node.hasAttribute('data-f2-issecure'),
+ manifestUrl: manifestUrl,
+ root: node
+ };
+
+ // See if the user passed in a block of serialized json
+ var contextJson = node.getAttribute('data-f2-context');
+
+ if (contextJson) {
+ try {
+ appConfig.context = F2.parse(contextJson);
+ }
+ catch (e) {
+ console.warn('F2: "data-f2-context" of node is not valid JSON', '"' + e + '"');
+ }
+ }
+ }
+ }
+
+ return appConfig;
+ };
+
+ /**
+ * Returns true if the DOM node has children that are not text nodes
+ * @method _hasNonTextChildNodes
+ * @param {Element} node The DOM node
+ * @return {bool} True if there are non-text children
+ */
+ var _hasNonTextChildNodes = function (node) {
+ var hasNodes = false;
+
+ if (node.hasChildNodes()) {
+ for (var i = 0, len = node.childNodes.length; i < len; i++) {
+ if (node.childNodes[i].nodeType === 1) {
+ hasNodes = true;
+ break;
+ }
+ }
+ }
+
+ return hasNodes;
+ };
+
+ /**
+ * Adds properties to the ContainerConfig object to take advantage of defaults
+ * @method _hydrateContainerConfig
+ * @private
+ * @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
+ */
+ var _hydrateContainerConfig = function (containerConfig) {
+
+ if (!containerConfig.scriptErrorTimeout) {
+ containerConfig.scriptErrorTimeout = F2.ContainerConfig.scriptErrorTimeout;
+ }
+
+ if (containerConfig.debugMode !== true) {
+ containerConfig.debugMode = F2.ContainerConfig.debugMode;
+ }
+
+ if (containerConfig.locale && typeof containerConfig.locale == 'string') {
+ F2.ContainerConfig.locale = containerConfig.locale;
+ }
+ };
+
+ /**
+ * Attach app events
+ * @method _initAppEvents
+ * @private
+ */
+ var _initAppEvents = function (appConfig) {
+
+ jQuery(appConfig.root).on('click', '.' + F2.Constants.Css.APP_VIEW_TRIGGER + '[' + F2.Constants.Views.DATA_ATTRIBUTE + ']', function (event) {
+
+ event.preventDefault();
+
+ var view = jQuery(this).attr(F2.Constants.Views.DATA_ATTRIBUTE).toLowerCase();
+
+ // handle the special REMOVE view
+ if (view == F2.Constants.Views.REMOVE) {
+ F2.removeApp(appConfig.instanceId);
+ }
+ else {
+ appConfig.ui.Views.change(view);
+ }
+ });
+ };
+
+ /**
+ * Attach container Events
+ * @method _initContainerEvents
+ * @private
+ */
+ var _initContainerEvents = function () {
+
+ var resizeTimeout;
+ var resizeHandler = function () {
+ F2.Events.emit(F2.Constants.Events.CONTAINER_WIDTH_CHANGE);
+ };
+
+ jQuery(window).on('resize', function () {
+ clearTimeout(resizeTimeout);
+ resizeTimeout = setTimeout(resizeHandler, 100);
+ });
+
+ //listen for container-broadcasted locale changes
+ F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE, function (data) {
+ if (data.locale && typeof data.locale == 'string') {
+ F2.ContainerConfig.locale = data.locale;
+ }
+ });
+ };
+
+ /**
+ * Checks if an element is a placeholder element
+ * @method _isPlaceholderElement
+ * @private
+ * @param {Element} node The DOM element to check
+ * @return {bool} True if the element is a placeholder
+ */
+ var _isPlaceholderElement = function (node) {
+ return (
+ F2.isNativeDOMNode(node) && !_hasNonTextChildNodes(node) && !!node.getAttribute('data-f2-appid') && !!node.getAttribute('data-f2-manifesturl')
+ );
+ };
+
+ /**
+ * Has the container been init?
+ * @method _isInit
+ * @private
+ * @return {bool} True if the container has been init
+ */
+ var _isInit = function () {
+ return !!_config;
+ };
+
+ /**
+ * Instantiates each app from it's appConfig and stores that in a local private collection
+ * @method _createAppInstance
+ * @private
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
+ */
+ var _createAppInstance = function (appConfig, appContent) {
+ // instantiate F2.UI
+ appConfig.ui = new F2.UI(appConfig);
+
+ // instantiate F2.App
+ if (F2.Apps[appConfig.appId] !== undefined) {
+ if (typeof F2.Apps[appConfig.appId] === 'function') {
+
+ // IE
+ setTimeout(function () {
+ _apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root);
+ if (_apps[appConfig.instanceId].app['init'] !== undefined) {
+ _apps[appConfig.instanceId].app.init();
+ }
+ }, 0);
+
+ }
+ else {
+ F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')');
+ }
+ }
+ };
+
+ /**
+ * Loads the app's html/css/javascript
+ * @method loadApp
+ * @private
+ * @param {Array} appConfigs An array of
+ * {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
+ * @param {F2.AppManifest} [appManifest] The AppManifest object
+ */
+ var _loadApps = function (appConfigs, appManifest) {
+ appConfigs = [].concat(appConfigs);
+
+ // check for secure app
+ if (appConfigs.length == 1 && appConfigs[0].isSecure && !_config.isSecureAppPage) {
+ _loadSecureApp(appConfigs[0], appManifest);
+ return;
+ }
+
+ // check that the number of apps in manifest matches the number requested
+ if (appConfigs.length != appManifest.apps.length) {
+ F2.log('The number of apps defined in the AppManifest do not match the number requested.', appManifest);
+ return;
+ }
+
+ // Fn for loading manifest Styles
+ var _loadStyles = function (styles, cb) {
+ // Attempt to use the user provided method
+ if (_config.loadStyles) {
+ _config.loadStyles(styles, cb);
+ }
+ else {
+ // load styles, see #101
+ var stylesFragment = null,
+ useCreateStyleSheet = !!document.createStyleSheet;
+
+ jQuery.each(styles, function (i, e) {
+ if (useCreateStyleSheet) {
+ document.createStyleSheet(e);
+ }
+ else {
+ stylesFragment = stylesFragment || [];
+ stylesFragment.push('
');
+ }
+ });
+
+ if (stylesFragment) {
+ jQuery('head').append(stylesFragment.join(''));
+ }
+
+ cb();
+ }
+ };
+
+ // Fn for loading manifest Scripts
+ var _loadScripts = function (scripts, cb) {
+ // Attempt to use the user provided method
+ if (_config.loadScripts) {
+ _config.loadScripts(scripts, cb);
+ }
+ else {
+ if (scripts.length) {
+ var scriptCount = scripts.length;
+ var scriptsLoaded = 0;
+
+ // Check for IE10+ so that we don't rely on onreadystatechange
+ var readyStates = ('addEventListener' in window) ? {} : {
+ 'loaded': true,
+ 'complete': true
+ };
+
+ // Log and emit event for the failed (400,500) scripts
+ var _error = function (e) {
+ setTimeout(function () {
+ var evtData = {
+ src: e.target.src,
+ appId: appConfigs[0].appId
+ };
+
+ // Send error to console
+ F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\'');
+
+ // Emit event
+ F2.Events.emit('RESOURCE_FAILED_TO_LOAD', evtData);
+
+ if (!_bUsesAppHandlers) {
+ _appScriptLoadFailed(appConfigs[0], evtData.src);
+ }
+ else {
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
+ appConfigs[0],
+ evtData.src
+ );
+ }
+ }, _config.scriptErrorTimeout); // Defaults to 7000
+ };
+
+ // Load scripts and eval inlines once complete
+ jQuery.each(scripts, function (i, e) {
+ var doc = document,
+ script = doc.createElement('script'),
+ resourceUrl = e;
+
+ // If in debugMode, add cache buster to each script URL
+ if (_config.debugMode) {
+ resourceUrl += '?cachebuster=' + new Date().getTime();
+ }
+
+ // Scripts needed to be loaded in order they're defined in the AppManifest
+ script.async = false;
+ // Add other attrs
+ script.src = resourceUrl;
+ script.type = 'text/javascript';
+ script.charset = 'utf-8';
+ script.onerror = _error;
+
+ // Use a closure for the load event so that we can dereference the original script
+ script.onload = script.onreadystatechange = function (e) {
+ e = e || window.event; // For older IE
+
+ if (e.type == 'load' || readyStates[script.readyState]) {
+ // Done, cleanup
+ script.onload = script.onreadystatechange = script.onerror = null;
+
+ // Dereference script
+ script = null;
+
+ // Are we done loading all scripts for this app?
+ if (++scriptsLoaded === scriptCount) {
+ cb();
+ }
+ }
+ };
+
+ doc.body.appendChild(script);
+ });
+ }
+ else {
+ cb();
+ }
+ }
+ };
+
+ var _loadInlineScripts = function (inlines, cb) {
+ // Attempt to use the user provided method
+ if (_config.loadInlineScripts) {
+ _config.loadInlineScripts(inlines, cb);
+ }
+ else {
+ for (var i = 0, len = inlines.length; i < len; i++) {
+ try {
+ eval(inlines[i]);
+ }
+ catch (exception) {
+ F2.log('Error loading inline script: ' + exception + '\n\n' + inlines[i]);
+
+ if (!_bUsesAppHandlers) {
+ _appScriptLoadFailed(appConfigs[0], exception);
+ }
+ else {
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
+ appConfigs[0],
+ exception
+ );
+ }
+ }
+ }
+ cb();
+ }
+ };
+
+ // Determine whether an element has been added to the page
+ var elementInDocument = function (element) {
+ if (element) {
+ while (element.parentNode) {
+ element = element.parentNode;
+
+ if (element === document) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ // Fn for loading manifest app html
+ var _loadHtml = function (apps) {
+ jQuery.each(apps, function (i, a) {
+ if (_isPlaceholderElement(appConfigs[i].root)) {
+ jQuery(appConfigs[i].root)
+ .addClass(F2.Constants.Css.APP)
+ .append(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId));
+ }
+ else if (!_bUsesAppHandlers) {
+ // load html and save the root node
+ appConfigs[i].root = _afterAppRender(appConfigs[i], _appRender(appConfigs[i], a.html));
+ }
+ else {
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ appConfigs[i], // the app config
+ _outerHtml(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId))
+ );
+
+ var appId = appConfigs[i].appId,
+ root = appConfigs[i].root;
+
+ if (!root) {
+ throw ('Root for ' + appId + ' must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.');
+ }
+
+ if (!elementInDocument(root)) {
+ throw ('App root for ' + appId + ' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.');
+ }
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ appConfigs[i] // the app config
+ );
+
+ if (!F2.isNativeDOMNode(root)) {
+ throw ('App root for ' + appId + ' must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element.');
+ }
+ }
+
+ // init events
+ _initAppEvents(appConfigs[i]);
+ });
+ };
+
+ // Pull out the manifest data
+ var scripts = appManifest.scripts || [];
+ var styles = appManifest.styles || [];
+ var inlines = appManifest.inlineScripts || [];
+ var apps = appManifest.apps || [];
+
+ // Finally, load the styles, html, and scripts
+ _loadStyles(styles, function () {
+ // Put the html on the page
+ _loadHtml(apps);
+ // Add the script content to the page
+ _loadScripts(scripts, function () {
+ // Load any inline scripts
+ _loadInlineScripts(inlines, function () {
+ // Create the apps
+ jQuery.each(appConfigs, function (i, a) {
+ _createAppInstance(a, appManifest.apps[i]);
+ });
+ });
+ });
+ });
+ };
+
+ /**
+ * Loads the app's html/css/javascript into an iframe
+ * @method loadSecureApp
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {F2.AppManifest} appManifest The app's html/css/js to be loaded into the
+ * page.
+ */
+ var _loadSecureApp = function (appConfig, appManifest) {
+
+ // make sure the container is configured for secure apps
+ if (_config.secureAppPagePath) {
+ if (_isPlaceholderElement(appConfig.root)) {
+ jQuery(appConfig.root)
+ .addClass(F2.Constants.Css.APP)
+ .append(jQuery('
').addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId));
+ }
+ else if (!_bUsesAppHandlers) {
+ // create the html container for the iframe
+ appConfig.root = _afterAppRender(appConfig, _appRender(appConfig, '
'));
+ }
+ else {
+ var $root = jQuery(appConfig.root);
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ appConfig, // the app config
+ _outerHtml(jQuery(appManifest.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId))
+ );
+
+ if ($root.parents('body:first').length === 0) {
+ throw ('App was never rendered on the page. Please check your AppHandler callbacks to ensure you have rendered the app root to the DOM.');
+ }
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ appConfig // the app config
+ );
+
+ if (!appConfig.root) {
+ throw ('App Root must be a native dom node and can not be null or undefined. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node.');
+ }
+
+ if (!F2.isNativeDOMNode(appConfig.root)) {
+ throw ('App Root must be a native dom node. Please check your AppHandler callbacks to ensure you have set App Root to a native dom node.');
+ }
+ }
+
+ // instantiate F2.UI
+ appConfig.ui = new F2.UI(appConfig);
+ // init events
+ _initAppEvents(appConfig);
+ // create RPC socket
+ F2.Rpc.register(appConfig, appManifest);
+ }
+ else {
+ F2.log('Unable to load secure app: "secureAppPagePath" is not defined in F2.ContainerConfig.');
+ }
+ };
+
+ var _outerHtml = function (html) {
+ return jQuery('
').append(html).html();
+ };
+
+ /**
+ * Checks if the app is valid
+ * @method _validateApp
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @returns {bool} True if the app is valid
+ */
+ var _validateApp = function (appConfig) {
+
+ // check for valid app configurations
+ if (!appConfig.appId) {
+ F2.log('"appId" missing from app object');
+ return false;
+ }
+ else if (!appConfig.root && !appConfig.manifestUrl) {
+ F2.log('"manifestUrl" missing from app object');
+ return false;
+ }
+
+ return true;
+ };
+
+ /**
+ * Checks if the ContainerConfig is valid
+ * @method _validateContainerConfig
+ * @private
+ * @returns {bool} True if the config is valid
+ */
+ var _validateContainerConfig = function () {
+
+ if (_config) {
+ if (_config.xhr) {
+ if (!(typeof _config.xhr === 'function' || typeof _config.xhr === 'object')) {
+ throw ('ContainerConfig.xhr should be a function or an object');
+ }
+ if (_config.xhr.dataType && typeof _config.xhr.dataType !== 'function') {
+ throw ('ContainerConfig.xhr.dataType should be a function');
+ }
+ if (_config.xhr.type && typeof _config.xhr.type !== 'function') {
+ throw ('ContainerConfig.xhr.type should be a function');
+ }
+ if (_config.xhr.url && typeof _config.xhr.url !== 'function') {
+ throw ('ContainerConfig.xhr.url should be a function');
+ }
+ }
+ }
+
+ return true;
+ };
+
+ return {
+ /**
+ * Gets the current list of apps in the container
+ * @method getContainerState
+ * @returns {Array} An array of objects containing the appId
+ */
+ getContainerState: function () {
+ if (!_isInit()) {
+ F2.log('F2.init() must be called before F2.getContainerState()');
+ return;
+ }
+
+ return jQuery.map(_apps, function (app) {
+ return {
+ appId: app.config.appId
+ };
+ });
+ },
+ /**
+ * Gets the current locale defined by the container
+ * @method getContainerLocale
+ * @returns {String} IETF-defined standard language tag
+ */
+ getContainerLocale: function () {
+ if (!_isInit()) {
+ F2.log('F2.init() must be called before F2.getContainerLocale()');
+ return;
+ }
+
+ return F2.ContainerConfig.locale;
+ },
+ /**
+ * Initializes the container. This method must be called before performing
+ * any other actions in the container.
+ * @method init
+ * @param {F2.ContainerConfig} config The configuration object
+ */
+ init: function (config) {
+ _config = config || {};
+
+ _validateContainerConfig();
+
+ _hydrateContainerConfig(_config);
+
+ // dictates whether we use the old logic or the new logic.
+ // TODO: Remove in v2.0
+ _bUsesAppHandlers = (!_config.beforeAppRender && !_config.appRender && !_config.afterAppRender && !_config.appScriptLoadFailed);
+
+ // only establish RPC connection if the container supports the secure app page
+ if (!!_config.secureAppPagePath || _config.isSecureAppPage) {
+ F2.Rpc.init(!!_config.secureAppPagePath ? _config.secureAppPagePath : false);
+ }
+
+ F2.UI.init(_config);
+
+ if (!_config.isSecureAppPage) {
+ _initContainerEvents();
+ }
+ },
+ /**
+ * Has the container been init?
+ * @method isInit
+ * @return {bool} True if the container has been init
+ */
+ isInit: _isInit,
+ /**
+ * Automatically load apps that are already defined in the DOM. Elements will
+ * be rendered into the location of the placeholder DOM element. Any AppHandlers
+ * that are defined will be bypassed.
+ * @method loadPlaceholders
+ * @param {Element} parentNode The element to search for placeholder apps
+ */
+ loadPlaceholders: function (parentNode) {
+
+ var elements = [],
+ appConfigs = [],
+ add = function (e) {
+ if (!e) {
+ return;
+ }
+ elements.push(e);
+ },
+ addAll = function (els) {
+ if (!els) {
+ return;
+ }
+ for (var i = 0, len = els.length; i < len; i++) {
+ add(els[i]);
+ }
+ };
+
+ if (!!parentNode && !F2.isNativeDOMNode(parentNode)) {
+ throw ('"parentNode" must be null or a DOM node');
+ }
+
+ // if the passed in element has a data-f2-appid attribute add
+ // it to the list of elements but to not search within that
+ // element for other placeholders
+ if (parentNode && parentNode.hasAttribute('data-f2-appid')) {
+ add(parentNode);
+ } else {
+
+ // find placeholders within the parentNode only if
+ // querySelectorAll exists
+ parentNode = parentNode || document;
+ if (parentNode.querySelectorAll) {
+ addAll(parentNode.querySelectorAll('[data-f2-appid]'));
+ }
+ }
+
+ for (var i = 0, len = elements.length; i < len; i++) {
+ var appConfig = _getAppConfigFromElement(elements[i]);
+ appConfigs.push(appConfig);
+ }
+
+ if (appConfigs.length) {
+ F2.registerApps(appConfigs);
+ }
+ },
+ /**
+ * Begins the loading process for all apps and/or initialization process for pre-loaded apps.
+ * The app will be passed the {{#crossLink "F2.AppConfig"}}{{/crossLink}} object which will
+ * contain the app's unique instanceId within the container. If the
+ * {{#crossLink "F2.AppConfig"}}{{/crossLink}}.root property is populated the app is considered
+ * to be a pre-loaded app and will be handled accordingly. Optionally, the
+ * {{#crossLink "F2.AppManifest"}}{{/crossLink}} can be passed in and those
+ * assets will be used instead of making a request.
+ * @method registerApps
+ * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
+ * objects
+ * @param {Array} [appManifests] An array of
+ * {{#crossLink "F2.AppManifest"}}{{/crossLink}}
+ * objects. This array must be the same length as the apps array that is
+ * objects. This array must be the same length as the apps array that is
+ * passed in. This can be useful if apps are loaded on the server-side and
+ * passed down to the client.
+ * @example
+ * Traditional App requests.
+ *
+ * // Traditional f2 app configs
+ * var arConfigs = [
+ * {
* appId: 'com_externaldomain_example_app',
* context: {},
* manifestUrl: 'http://www.externaldomain.com/F2/AppManifest'
* },
- * {
+ * {
* appId: 'com_externaldomain_example_app',
* context: {},
* manifestUrl: 'http://www.externaldomain.com/F2/AppManifest'
* },
- * {
+ * {
* appId: 'com_externaldomain_example_app2',
* context: {},
* manifestUrl: 'http://www.externaldomain.com/F2/AppManifest'
* }
- * ];
- *
- * F2.init();
- * F2.registerApps(arConfigs);
- *
- * @example
- * Pre-loaded and tradition apps mixed.
- *
- * // Pre-loaded apps and traditional f2 app configs
- * // you can preload the same app multiple times as long as you have a unique root for each
- * var arConfigs = [
- * {
+ * ];
+ *
+ * F2.init();
+ * F2.registerApps(arConfigs);
+ *
+ * @example
+ * Pre-loaded and tradition apps mixed.
+ *
+ * // Pre-loaded apps and traditional f2 app configs
+ * // you can preload the same app multiple times as long as you have a unique root for each
+ * var arConfigs = [
+ * {
* appId: 'com_mydomain_example_app',
* context: {},
* root: 'div#example-app-1',
* manifestUrl: ''
* },
- * {
+ * {
* appId: 'com_mydomain_example_app',
* context: {},
* root: 'div#example-app-2',
* manifestUrl: ''
* },
- * {
+ * {
* appId: 'com_externaldomain_example_app',
* context: {},
* manifestUrl: 'http://www.externaldomain.com/F2/AppManifest'
* }
- * ];
- *
- * F2.init();
- * F2.registerApps(arConfigs);
- *
- * @example
- * Apps with predefined manifests.
- *
- * // Traditional f2 app configs
- * var arConfigs = [
- * {appId: 'com_externaldomain_example_app', context: {}},
- * {appId: 'com_externaldomain_example_app', context: {}},
- * {appId: 'com_externaldomain_example_app2', context: {}}
- * ];
- *
- * // Pre requested manifest responses
- * var arManifests = [
- * {
+ * ];
+ *
+ * F2.init();
+ * F2.registerApps(arConfigs);
+ *
+ * @example
+ * Apps with predefined manifests.
+ *
+ * // Traditional f2 app configs
+ * var arConfigs = [
+ * {appId: 'com_externaldomain_example_app', context: {}},
+ * {appId: 'com_externaldomain_example_app', context: {}},
+ * {appId: 'com_externaldomain_example_app2', context: {}}
+ * ];
+ *
+ * // Pre requested manifest responses
+ * var arManifests = [
+ * {
* apps: ['
Example App!
'],
* inlineScripts: [],
* scripts: ['http://www.domain.com/js/AppClass.js'],
* styles: ['http://www.domain.com/css/AppStyles.css']
* },
- * {
+ * {
* apps: ['
Example App!
'],
* inlineScripts: [],
* scripts: ['http://www.domain.com/js/AppClass.js'],
* styles: ['http://www.domain.com/css/AppStyles.css']
* },
- * {
+ * {
* apps: ['
Example App 2!
'],
* inlineScripts: [],
* scripts: ['http://www.domain.com/js/App2Class.js'],
* styles: ['http://www.domain.com/css/App2Styles.css']
* }
- * ];
- *
- * F2.init();
- * F2.registerApps(arConfigs, arManifests);
- */
- registerApps: function(appConfigs, appManifests) {
-
- if (!_isInit()) {
- F2.log('F2.init() must be called before F2.registerApps()');
- return;
- }
- else if (!appConfigs) {
- F2.log('At least one AppConfig must be passed when calling F2.registerApps()');
- return;
- }
-
- var appStack = [];
- var batches = {};
- var callbackStack = {};
- var haveManifests = false;
- appConfigs = [].concat(appConfigs);
- appManifests = [].concat(appManifests || []);
- haveManifests = !! appManifests.length;
-
- // appConfigs must have a length
- if (!appConfigs.length) {
- F2.log('At least one AppConfig must be passed when calling F2.registerApps()');
- return;
- // ensure that the array of apps and manifests are qual
- }
- else if (appConfigs.length && haveManifests && appConfigs.length != appManifests.length) {
- F2.log('The length of "apps" does not equal the length of "appManifests"');
- return;
- }
-
- // validate each app and assign it an instanceId
- // then determine which apps can be batched together
- jQuery.each(appConfigs, function(i, a) {
- // add properties and methods
- a = _createAppConfig(a);
-
- // Will set to itself, for preloaded apps, or set to null for apps that aren't already
- // on the page.
- a.root = a.root || null;
-
- // we validate the app after setting the root property because pre-load apps do no require
- // manifest url
- if (!_validateApp(a)) {
- return; // move to the next app
- }
-
- // save app
- _apps[a.instanceId] = {
- config: a
- };
-
- // If the root property is defined then this app is considered to be preloaded and we will
- // run it through that logic.
- if (a.root && !_isPlaceholderElement(a.root)) {
- if ((!a.root && typeof(a.root) != 'string') && !F2.isNativeDOMNode(a.root)) {
- F2.log('AppConfig invalid for pre-load, not a valid string and not dom node');
- F2.log('AppConfig instance:', a);
- throw ('Preloaded appConfig.root property must be a native dom node or a string representing a sizzle selector. Please check your inputs and try again.');
- }
- else if (jQuery(a.root).length != 1) {
- F2.log('AppConfig invalid for pre-load, root not unique');
- F2.log('AppConfig instance:', a);
- F2.log('Number of dom node instances:', jQuery(a.root).length);
- throw ('Preloaded appConfig.root property must map to a unique dom node. Please check your inputs and try again.');
- }
-
- // instantiate F2.App
- _createAppInstance(a);
-
- // init events
- _initAppEvents(a);
-
- // Continue on in the .each loop, no need to continue because the app is on the page
- // the js in initialized, and it is ready to role.
- return; // equivalent to continue in .each
- }
-
- if (!_isPlaceholderElement(a.root)) {
- if (!_bUsesAppHandlers) {
- // fire beforeAppRender
- a.root = _beforeAppRender(a);
- }
- else {
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- a // the app config
- );
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- a // the app config
- );
- }
- }
-
- // if we have the manifest, go ahead and load the app
- if (haveManifests) {
- _loadApps(a, appManifests[i]);
- }
- else {
- // check if this app can be batched
- if (a.enableBatchRequests && !a.isSecure) {
- batches[a.manifestUrl.toLowerCase()] = batches[a.manifestUrl.toLowerCase()] || [];
- batches[a.manifestUrl.toLowerCase()].push(a);
- }
- else {
- appStack.push({
- apps: [a],
- url: a.manifestUrl
- });
- }
- }
- });
-
- // we don't have the manifests, go ahead and load them
- if (!haveManifests) {
- // add the batches to the appStack
- jQuery.each(batches, function(i, b) {
- appStack.push({
- url: i,
- apps: b
- });
- });
-
- // if an app is being loaded more than once on the page, there is the
- // potential that the jsonp callback will be clobbered if the request
- // for the AppManifest for the app comes back at the same time as
- // another request for the same app. We'll create a callbackStack
- // that will ensure that requests for the same app are loaded in order
- // rather than at the same time
- jQuery.each(appStack, function(i, req) {
- // define the callback function based on the first app's App ID
- var jsonpCallback = F2.Constants.JSONP_CALLBACK + req.apps[0].appId;
-
- // push the request onto the callback stack
- callbackStack[jsonpCallback] = callbackStack[jsonpCallback] || [];
- callbackStack[jsonpCallback].push(req);
- });
-
- // loop through each item in the callback stack and make the request
- // for the AppManifest. When the request is complete, pop the next
- // request off the stack and make the request.
- jQuery.each(callbackStack, function(i, requests) {
-
- var manifestRequest = function(jsonpCallback, req) {
- if (!req) {
- return;
- }
-
- // setup defaults and callbacks
- var url = req.url,
- type = 'GET',
- dataType = 'jsonp',
- completeFunc = function() {
- manifestRequest(i, requests.pop());
- },
- errorFunc = function() {
- jQuery.each(req.apps, function(idx, item) {
- item.name = item.name || item.appId;
- F2.log('Removed failed ' + item.name + ' app', item);
- F2.removeApp(item.instanceId);
- });
- },
- successFunc = function(appManifest) {
- _loadApps(req.apps, appManifest);
- };
-
- // optionally fire xhr overrides
- if (_config.xhr && _config.xhr.dataType) {
- dataType = _config.xhr.dataType(req.url, req.apps);
- if (typeof dataType !== 'string') {
- throw ('ContainerConfig.xhr.dataType should return a string');
- }
- }
- if (_config.xhr && _config.xhr.type) {
- type = _config.xhr.type(req.url, req.apps);
- if (typeof type !== 'string') {
- throw ('ContainerConfig.xhr.type should return a string');
- }
- }
- if (_config.xhr && _config.xhr.url) {
- url = _config.xhr.url(req.url, req.apps);
- if (typeof url !== 'string') {
- throw ('ContainerConfig.xhr.url should return a string');
- }
- }
-
- // setup the default request function if an override is not present
- var requestFunc = _config.xhr;
- if (typeof requestFunc !== 'function') {
- requestFunc = function(url, appConfigs, successCallback, errorCallback, completeCallback) {
- jQuery.ajax({
- url: url,
- type: type,
- data: {
- params: F2.stringify(req.apps, F2.appConfigReplacer)
- },
- jsonp: false, // do not put 'callback=' in the query string
- jsonpCallback: jsonpCallback, // Unique function name
- dataType: dataType,
- success: successCallback,
- error: function(jqxhr, settings, exception) {
- F2.log('Failed to load app(s)', exception.toString(), req.apps);
- errorCallback();
- },
- complete: completeCallback
- });
- };
- }
-
- requestFunc(url, req.apps, successFunc, errorFunc, completeFunc);
- };
-
- manifestRequest(i, requests.pop());
- });
- }
- },
- /**
- * Removes all apps from the container
- * @method removeAllApps
- */
- removeAllApps: function() {
-
- if (!_isInit()) {
- F2.log('F2.init() must be called before F2.removeAllApps()');
- return;
- }
-
- jQuery.each(_apps, function(i, a) {
- F2.removeApp(a.config.instanceId);
- });
- },
- /**
- * Removes an app from the container
- * @method removeApp
- * @param {string} instanceId The app's instanceId
- */
- removeApp: function(instanceId) {
-
- if (!_isInit()) {
- F2.log('F2.init() must be called before F2.removeApp()');
- return;
- }
-
- if (_apps[instanceId]) {
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
- _apps[instanceId] // the app instance
- );
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY,
- _apps[instanceId] // the app instance
- );
-
- F2.AppHandlers.__trigger(
- _sAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_AFTER,
- _apps[instanceId] // the app instance
- );
-
- delete _apps[instanceId];
- }
- }
- };
+ * ];
+ *
+ * F2.init();
+ * F2.registerApps(arConfigs, arManifests);
+ */
+ registerApps: function (appConfigs, appManifests) {
+
+ if (!_isInit()) {
+ F2.log('F2.init() must be called before F2.registerApps()');
+ return;
+ }
+ else if (!appConfigs) {
+ F2.log('At least one AppConfig must be passed when calling F2.registerApps()');
+ return;
+ }
+
+ var appStack = [];
+ var batches = {};
+ var callbackStack = {};
+ var haveManifests = false;
+ appConfigs = [].concat(appConfigs);
+ appManifests = [].concat(appManifests || []);
+ haveManifests = !!appManifests.length;
+
+ // appConfigs must have a length
+ if (!appConfigs.length) {
+ F2.log('At least one AppConfig must be passed when calling F2.registerApps()');
+ return;
+ // ensure that the array of apps and manifests are qual
+ }
+ else if (appConfigs.length && haveManifests && appConfigs.length != appManifests.length) {
+ F2.log('The length of "apps" does not equal the length of "appManifests"');
+ return;
+ }
+
+ // validate each app and assign it an instanceId
+ // then determine which apps can be batched together
+ jQuery.each(appConfigs, function (i, a) {
+ // add properties and methods
+ a = _createAppConfig(a);
+
+ // Will set to itself, for preloaded apps, or set to null for apps that aren't already
+ // on the page.
+ a.root = a.root || null;
+
+ // we validate the app after setting the root property because pre-load apps do no require
+ // manifest url
+ if (!_validateApp(a)) {
+ return; // move to the next app
+ }
+
+ // save app
+ _apps[a.instanceId] = {
+ config: a
+ };
+
+ // If the root property is defined then this app is considered to be preloaded and we will
+ // run it through that logic.
+ if (a.root && !_isPlaceholderElement(a.root)) {
+ if ((!a.root && typeof(a.root) != 'string') && !F2.isNativeDOMNode(a.root)) {
+ F2.log('AppConfig invalid for pre-load, not a valid string and not dom node');
+ F2.log('AppConfig instance:', a);
+ throw ('Preloaded appConfig.root property must be a native dom node or a string representing a sizzle selector. Please check your inputs and try again.');
+ }
+ else if (jQuery(a.root).length != 1) {
+ F2.log('AppConfig invalid for pre-load, root not unique');
+ F2.log('AppConfig instance:', a);
+ F2.log('Number of dom node instances:', jQuery(a.root).length);
+ throw ('Preloaded appConfig.root property must map to a unique dom node. Please check your inputs and try again.');
+ }
+
+ // instantiate F2.App
+ _createAppInstance(a);
+
+ // init events
+ _initAppEvents(a);
+
+ // Continue on in the .each loop, no need to continue because the app is on the page
+ // the js in initialized, and it is ready to role.
+ return; // equivalent to continue in .each
+ }
+
+ if (!_isPlaceholderElement(a.root)) {
+ if (!_bUsesAppHandlers) {
+ // fire beforeAppRender
+ a.root = _beforeAppRender(a);
+ }
+ else {
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ a // the app config
+ );
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ a // the app config
+ );
+ }
+ }
+
+ // if we have the manifest, go ahead and load the app
+ if (haveManifests) {
+ _loadApps(a, appManifests[i]);
+ }
+ else {
+ // check if this app can be batched
+ if (a.enableBatchRequests && !a.isSecure) {
+ batches[a.manifestUrl.toLowerCase()] = batches[a.manifestUrl.toLowerCase()] || [];
+ batches[a.manifestUrl.toLowerCase()].push(a);
+ }
+ else {
+ appStack.push({
+ apps: [a],
+ url: a.manifestUrl
+ });
+ }
+ }
+ });
+
+ // we don't have the manifests, go ahead and load them
+ if (!haveManifests) {
+ // add the batches to the appStack
+ jQuery.each(batches, function (i, b) {
+ appStack.push({
+ url: i,
+ apps: b
+ });
+ });
+
+ // if an app is being loaded more than once on the page, there is the
+ // potential that the jsonp callback will be clobbered if the request
+ // for the AppManifest for the app comes back at the same time as
+ // another request for the same app. We'll create a callbackStack
+ // that will ensure that requests for the same app are loaded in order
+ // rather than at the same time
+ jQuery.each(appStack, function (i, req) {
+ // define the callback function based on the first app's App ID
+ var jsonpCallback = F2.Constants.JSONP_CALLBACK + req.apps[0].appId;
+
+ // push the request onto the callback stack
+ callbackStack[jsonpCallback] = callbackStack[jsonpCallback] || [];
+ callbackStack[jsonpCallback].push(req);
+ });
+
+ // loop through each item in the callback stack and make the request
+ // for the AppManifest. When the request is complete, pop the next
+ // request off the stack and make the request.
+ jQuery.each(callbackStack, function (i, requests) {
+
+ var manifestRequest = function (jsonpCallback, req) {
+ if (!req) {
+ return;
+ }
+
+ // setup defaults and callbacks
+ var url = req.url,
+ type = 'GET',
+ dataType = 'jsonp',
+ completeFunc = function () {
+ manifestRequest(i, requests.pop());
+ },
+ errorFunc = function () {
+ jQuery.each(req.apps, function (idx, item) {
+ item.name = item.name || item.appId;
+ F2.log('Removed failed ' + item.name + ' app', item);
+ F2.removeApp(item.instanceId);
+ });
+ },
+ successFunc = function (appManifest) {
+ _loadApps(req.apps, appManifest);
+ };
+
+ // optionally fire xhr overrides
+ if (_config.xhr && _config.xhr.dataType) {
+ dataType = _config.xhr.dataType(req.url, req.apps);
+ if (typeof dataType !== 'string') {
+ throw ('ContainerConfig.xhr.dataType should return a string');
+ }
+ }
+ if (_config.xhr && _config.xhr.type) {
+ type = _config.xhr.type(req.url, req.apps);
+ if (typeof type !== 'string') {
+ throw ('ContainerConfig.xhr.type should return a string');
+ }
+ }
+ if (_config.xhr && _config.xhr.url) {
+ url = _config.xhr.url(req.url, req.apps);
+ if (typeof url !== 'string') {
+ throw ('ContainerConfig.xhr.url should return a string');
+ }
+ }
+
+ // setup the default request function if an override is not present
+ var requestFunc = _config.xhr;
+ if (typeof requestFunc !== 'function') {
+ requestFunc = function (url, appConfigs, successCallback, errorCallback, completeCallback) {
+ jQuery.ajax({
+ url: url,
+ type: type,
+ data: {
+ params: F2.stringify(req.apps, F2.appConfigReplacer)
+ },
+ jsonp: false, // do not put 'callback=' in the query string
+ jsonpCallback: jsonpCallback, // Unique function name
+ dataType: dataType,
+ success: successCallback,
+ error: function (jqxhr, settings, exception) {
+ F2.log('Failed to load app(s)', exception.toString(), req.apps);
+ errorCallback();
+ },
+ complete: completeCallback
+ });
+ };
+ }
+
+ requestFunc(url, req.apps, successFunc, errorFunc, completeFunc);
+ };
+
+ manifestRequest(i, requests.pop());
+ });
+ }
+ },
+ /**
+ * Removes all apps from the container
+ * @method removeAllApps
+ */
+ removeAllApps: function () {
+
+ if (!_isInit()) {
+ F2.log('F2.init() must be called before F2.removeAllApps()');
+ return;
+ }
+
+ jQuery.each(_apps, function (i, a) {
+ F2.removeApp(a.config.instanceId);
+ });
+ },
+ /**
+ * Removes an app from the container
+ * @method removeApp
+ * @param {string} instanceId The app's instanceId
+ */
+ removeApp: function (instanceId) {
+
+ if (!_isInit()) {
+ F2.log('F2.init() must be called before F2.removeApp()');
+ return;
+ }
+
+ if (_apps[instanceId]) {
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
+ _apps[instanceId] // the app instance
+ );
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY,
+ _apps[instanceId] // the app instance
+ );
+
+ F2.AppHandlers.__trigger(
+ _sAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_AFTER,
+ _apps[instanceId] // the app instance
+ );
+
+ delete _apps[instanceId];
+ }
+ }
+ };
})());
diff --git a/sdk/src/events.js b/sdk/src/events.js
index 6853e3a4..ff963ce2 100644
--- a/sdk/src/events.js
+++ b/sdk/src/events.js
@@ -3,81 +3,81 @@
* containers to apps and apps to apps.
* @class F2.Events
*/
-F2.extend('Events', (function() {
- // init EventEmitter
- var _events = new EventEmitter2({
- wildcard:true
- });
+F2.extend('Events', (function () {
+ // init EventEmitter
+ var _events = new EventEmitter2({
+ wildcard: true
+ });
- // unlimited listeners, set to > 0 for debugging
- _events.setMaxListeners(0);
+ // unlimited listeners, set to > 0 for debugging
+ _events.setMaxListeners(0);
- return {
- /**
- * Same as F2.Events.emit except that it will not send the event
- * to all sockets.
- * @method _socketEmit
- * @private
- * @param {string} event The event name
- * @param {object} [arg]* The arguments to be passed
- */
- _socketEmit: function() {
- return EventEmitter2.prototype.emit.apply(_events, [].slice.call(arguments));
- },
- /**
- * Execute each of the listeners that may be listening for the specified
- * event name in order with the list of arguments.
- * @method emit
- * @param {string} event The event name
- * @param {object} [arg]* The arguments to be passed
- */
- emit: function() {
- F2.Rpc.broadcast(F2.Constants.Sockets.EVENT, [].slice.call(arguments));
- return EventEmitter2.prototype.emit.apply(_events, [].slice.call(arguments));
- },
- /**
- * Adds a listener that will execute n times for the event before being
- * removed. The listener is invoked only the first time the event is
- * fired, after which it is removed.
- * @method many
- * @param {string} event The event name
- * @param {int} timesToListen The number of times to execute the event
- * before being removed
- * @param {function} listener The function to be fired when the event is
- * emitted
- */
- many: function(event, timesToListen, listener) {
- return _events.many(event, timesToListen, listener);
- },
- /**
- * Remove a listener for the specified event.
- * @method off
- * @param {string} event The event name
- * @param {function} listener The function that will be removed
- */
- off: function(event, listener) {
- return _events.off(event, listener);
- },
- /**
- * Adds a listener for the specified event
- * @method on
- * @param {string} event The event name
- * @param {function} listener The function to be fired when the event is
- * emitted
- */
- on: function(event, listener){
- return _events.on(event, listener);
- },
- /**
- * Adds a one time listener for the event. The listener is invoked only
- * the first time the event is fired, after which it is removed.
- * @method once
- * @param {string} event The event name
- * @param {function} listener The function to be fired when the event is
- * emitted
- */
- once: function(event, listener) {
- return _events.once(event, listener);
- }
- };
+ return {
+ /**
+ * Same as F2.Events.emit except that it will not send the event
+ * to all sockets.
+ * @method _socketEmit
+ * @private
+ * @param {string} event The event name
+ * @param {object} [arg]* The arguments to be passed
+ */
+ _socketEmit: function () {
+ return EventEmitter2.prototype.emit.apply(_events, [].slice.call(arguments));
+ },
+ /**
+ * Execute each of the listeners that may be listening for the specified
+ * event name in order with the list of arguments.
+ * @method emit
+ * @param {string} event The event name
+ * @param {object} [arg]* The arguments to be passed
+ */
+ emit: function () {
+ F2.Rpc.broadcast(F2.Constants.Sockets.EVENT, [].slice.call(arguments));
+ return EventEmitter2.prototype.emit.apply(_events, [].slice.call(arguments));
+ },
+ /**
+ * Adds a listener that will execute n times for the event before being
+ * removed. The listener is invoked only the first time the event is
+ * fired, after which it is removed.
+ * @method many
+ * @param {string} event The event name
+ * @param {int} timesToListen The number of times to execute the event
+ * before being removed
+ * @param {function} listener The function to be fired when the event is
+ * emitted
+ */
+ many: function (event, timesToListen, listener) {
+ return _events.many(event, timesToListen, listener);
+ },
+ /**
+ * Remove a listener for the specified event.
+ * @method off
+ * @param {string} event The event name
+ * @param {function} listener The function that will be removed
+ */
+ off: function (event, listener) {
+ return _events.off(event, listener);
+ },
+ /**
+ * Adds a listener for the specified event
+ * @method on
+ * @param {string} event The event name
+ * @param {function} listener The function to be fired when the event is
+ * emitted
+ */
+ on: function (event, listener) {
+ return _events.on(event, listener);
+ },
+ /**
+ * Adds a one time listener for the event. The listener is invoked only
+ * the first time the event is fired, after which it is removed.
+ * @method once
+ * @param {string} event The event name
+ * @param {function} listener The function to be fired when the event is
+ * emitted
+ */
+ once: function (event, listener) {
+ return _events.once(event, listener);
+ }
+ };
})());
\ No newline at end of file
diff --git a/sdk/src/rpc.js b/sdk/src/rpc.js
index d7210387..a34b0f4c 100644
--- a/sdk/src/rpc.js
+++ b/sdk/src/rpc.js
@@ -2,324 +2,324 @@
* Handles socket communication between the container and secure apps
* @class F2.Rpc
*/
-F2.extend('Rpc', (function(){
- var _callbacks = {};
- var _secureAppPagePath = '';
- var _apps = {};
- var _rEvents = new RegExp('^' + F2.Constants.Sockets.EVENT);
- var _rRpc = new RegExp('^' + F2.Constants.Sockets.RPC);
- var _rRpcCallback = new RegExp('^' + F2.Constants.Sockets.RPC_CALLBACK);
- var _rSocketLoad = new RegExp('^' + F2.Constants.Sockets.LOAD);
- var _rUiCall = new RegExp('^' + F2.Constants.Sockets.UI_RPC);
-
- /**
- * Creates a socket connection from the app to the container using
- *
easyXDM .
- * @method _createAppToContainerSocket
- * @private
- */
- var _createAppToContainerSocket = function() {
-
- var appConfig; // socket closure
- var isLoaded = false;
- // its possible for messages to be received before the socket load event has
- // happened. We'll save off these messages and replay them once the socket
- // is ready
- var messagePlayback = [];
-
- var socket = new easyXDM.Socket({
- onMessage: function(message, origin){
-
- // handle Socket Load
- if (!isLoaded && _rSocketLoad.test(message)) {
- message = message.replace(_rSocketLoad, '');
- var appParts = F2.parse(message);
-
- // make sure we have the AppConfig and AppManifest
- if (appParts.length == 2) {
- appConfig = appParts[0];
-
- // save socket
- _apps[appConfig.instanceId] = {
- config:appConfig,
- socket:socket
- };
-
- // register app
- F2.registerApps([appConfig], [appParts[1]]);
-
- // socket message playback
- jQuery.each(messagePlayback, function(i, e) {
- _onMessage(appConfig, message, origin);
- });
-
- isLoaded = true;
- }
- } else if (isLoaded) {
- // pass everyting else to _onMessage
- _onMessage(appConfig, message, origin);
- } else {
- //F2.log('socket not ready, queuing message', message);
- messagePlayback.push(message);
- }
- }
- });
- };
-
- /**
- * Creates a socket connection from the container to the app using
- *
easyXDM .
- * @method _createContainerToAppSocket
- * @private
- * @param {appConfig} appConfig The F2.AppConfig object
- * @param {F2.AppManifest} appManifest The F2.AppManifest object
- */
- var _createContainerToAppSocket = function(appConfig, appManifest) {
-
- var container = jQuery(appConfig.root);
-
- if (!container.is('.' + F2.Constants.Css.APP_CONTAINER)) {
- container.find('.' + F2.Constants.Css.APP_CONTAINER);
- }
-
- if (!container.length) {
- F2.log('Unable to locate app in order to establish secure connection.');
- return;
- }
-
- var iframeProps = {
- scrolling:'no',
- style:{
- width:'100%'
- }
- };
-
- if (appConfig.height) {
- iframeProps.style.height = appConfig.height + 'px';
- }
-
- var socket = new easyXDM.Socket({
- remote: _secureAppPagePath,
- container: container.get(0),
- props:iframeProps,
- onMessage: function(message, origin) {
- // pass everything to _onMessage
- _onMessage(appConfig, message, origin);
- },
- onReady: function() {
- socket.postMessage(F2.Constants.Sockets.LOAD + F2.stringify([appConfig, appManifest], F2.appConfigReplacer));
- }
- });
-
- return socket;
- };
-
- /**
- * @method _createRpcCallback
- * @private
- * @param {string} instanceId The app's Instance ID
- * @param {function} callbackId The callback ID
- * @return {function} A function to make the RPC call
- */
- var _createRpcCallback = function(instanceId, callbackId) {
- return function() {
- F2.Rpc.call(
- instanceId,
- F2.Constants.Sockets.RPC_CALLBACK,
- callbackId,
- [].slice.call(arguments).slice(2)
- );
- };
- };
-
- /**
- * Handles messages that come across the sockets
- * @method _onMessage
- * @private
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- * @param {string} message The socket message
- * @param {string} origin The originator
- */
- var _onMessage = function(appConfig, message, origin) {
-
- var obj, func;
-
- function parseFunction(parent, functionName) {
- var path = String(functionName).split('.');
- for (var i = 0; i < path.length; i++) {
- if (parent[path[i]] === undefined) {
- parent = undefined;
- break;
- }
- parent = parent[path[i]];
- }
- return parent;
- }
-
- function parseMessage(regEx, message, instanceId) {
- var o = F2.parse(message.replace(regEx, ''));
-
- // if obj.callbacks
- // for each callback
- // for each params
- // if callback matches param
- // replace param with _createRpcCallback(app.instanceId, callback)
- if (o.params && o.params.length && o.callbacks && o.callbacks.length) {
- jQuery.each(o.callbacks, function(i, c) {
- jQuery.each(o.params, function(i, p) {
- if (c == p) {
- o.params[i] = _createRpcCallback(instanceId, c);
- }
- });
- });
- }
-
- return o;
- }
-
- // handle UI Call
- if (_rUiCall.test(message)) {
- obj = parseMessage(_rUiCall, message, appConfig.instanceId);
- func = parseFunction(appConfig.ui, obj.functionName);
- // if we found the function, call it
- if (func !== undefined) {
- func.apply(appConfig.ui, obj.params);
- } else {
- F2.log('Unable to locate UI RPC function: ' + obj.functionName);
- }
-
- // handle RPC
- } else if (_rRpc.test(message)) {
- obj = parseMessage(_rRpc, message, appConfig.instanceId);
- func = parseFunction(window, obj.functionName);
- if (func !== undefined) {
- func.apply(func, obj.params);
- } else {
- F2.log('Unable to locate RPC function: ' + obj.functionName);
- }
-
- // handle RPC Callback
- } else if (_rRpcCallback.test(message)) {
- obj = parseMessage(_rRpcCallback, message, appConfig.instanceId);
- if (_callbacks[obj.functionName] !== undefined) {
- _callbacks[obj.functionName].apply(_callbacks[obj.functionName], obj.params);
- delete _callbacks[obj.functionName];
- }
-
- // handle Events
- } else if (_rEvents.test(message)) {
- obj = parseMessage(_rEvents, message, appConfig.instanceId);
- F2.Events._socketEmit.apply(F2.Events, obj);
- }
- };
-
- /**
- * Registers a callback function
- * @method _registerCallback
- * @private
- * @param {function} callback The callback function
- * @return {string} The callback ID
- */
- var _registerCallback = function(callback) {
- var callbackId = F2.guid();
- _callbacks[callbackId] = callback;
- return callbackId;
- };
-
- return {
- /**
- * Broadcast an RPC function to all sockets
- * @method broadcast
- * @param {string} messageType The message type
- * @param {Array} params The parameters to broadcast
- */
- broadcast: function(messageType, params) {
- // check valid messageType
- var message = messageType + F2.stringify(params);
- jQuery.each(_apps, function(i, a) {
- a.socket.postMessage(message);
- });
- },
- /**
- * Calls a remote function
- * @method call
- * @param {string} instanceId The app's Instance ID
- * @param {string} messageType The message type
- * @param {string} functionName The name of the remote function
- * @param {Array} params An array of parameters to pass to the remote
- * function. Any functions found within the params will be treated as a
- * callback function.
- */
- call: function(instanceId, messageType, functionName, params) {
- // loop through params and find functions and convert them to callbacks
- var callbacks = [];
- jQuery.each(params, function(i, e) {
- if (typeof e === 'function') {
- var cid = _registerCallback(e);
- params[i] = cid;
- callbacks.push(cid);
- }
- });
- // check valid messageType
- _apps[instanceId].socket.postMessage(
- messageType + F2.stringify({
- functionName:functionName,
- params:params,
- callbacks:callbacks
- })
- );
- },
-
- /**
- * Init function which tells F2.Rpc whether it is running at the container-
- * level or the app-level. This method is generally called by
- * F2.{{#crossLink "F2/init"}}{{/crossLink}}
- * @method init
- * @param {string} [secureAppPagePath] The
- * {{#crossLink "F2.ContainerConfig"}}{{/crossLink}}.secureAppPagePath
- * property
- */
- init: function(secureAppPagePath) {
- _secureAppPagePath = secureAppPagePath;
- if (!_secureAppPagePath) {
- _createAppToContainerSocket();
- }
- },
-
- /**
- * Determines whether the Instance ID is considered to be 'remote'. This is
- * determined by checking if 1) the app has an open socket and 2) whether
- * F2.Rpc is running inside of an iframe
- * @method isRemote
- * @param {string} instanceId The Instance ID
- * @return {bool} True if there is an open socket
- */
- isRemote: function(instanceId) {
- return (
- // we have an app
- _apps[instanceId] !== undefined &&
- // the app is secure
- _apps[instanceId].config.isSecure &&
- // we can't access the iframe
- jQuery(_apps[instanceId].config.root).find('iframe').length === 0
- );
- },
-
- /**
- * Creates a container-to-app or app-to-container socket for communication
- * @method register
- * @param {F2.AppConfig} [appConfig] The F2.AppConfig object
- * @param {F2.AppManifest} [appManifest] The F2.AppManifest object
- */
- register: function(appConfig, appManifest) {
- if (!!appConfig && !!appManifest) {
- _apps[appConfig.instanceId] = {
- config:appConfig,
- socket:_createContainerToAppSocket(appConfig, appManifest)
- };
- } else {
- F2.log('Unable to register socket connection. Please check container configuration.');
- }
- }
- };
+F2.extend('Rpc', (function () {
+ var _callbacks = {};
+ var _secureAppPagePath = '';
+ var _apps = {};
+ var _rEvents = new RegExp('^' + F2.Constants.Sockets.EVENT);
+ var _rRpc = new RegExp('^' + F2.Constants.Sockets.RPC);
+ var _rRpcCallback = new RegExp('^' + F2.Constants.Sockets.RPC_CALLBACK);
+ var _rSocketLoad = new RegExp('^' + F2.Constants.Sockets.LOAD);
+ var _rUiCall = new RegExp('^' + F2.Constants.Sockets.UI_RPC);
+
+ /**
+ * Creates a socket connection from the app to the container using
+ *
easyXDM .
+ * @method _createAppToContainerSocket
+ * @private
+ */
+ var _createAppToContainerSocket = function () {
+
+ var appConfig; // socket closure
+ var isLoaded = false;
+ // its possible for messages to be received before the socket load event has
+ // happened. We'll save off these messages and replay them once the socket
+ // is ready
+ var messagePlayback = [];
+
+ var socket = new easyXDM.Socket({
+ onMessage: function (message, origin) {
+
+ // handle Socket Load
+ if (!isLoaded && _rSocketLoad.test(message)) {
+ message = message.replace(_rSocketLoad, '');
+ var appParts = F2.parse(message);
+
+ // make sure we have the AppConfig and AppManifest
+ if (appParts.length == 2) {
+ appConfig = appParts[0];
+
+ // save socket
+ _apps[appConfig.instanceId] = {
+ config: appConfig,
+ socket: socket
+ };
+
+ // register app
+ F2.registerApps([appConfig], [appParts[1]]);
+
+ // socket message playback
+ jQuery.each(messagePlayback, function (i, e) {
+ _onMessage(appConfig, message, origin);
+ });
+
+ isLoaded = true;
+ }
+ } else if (isLoaded) {
+ // pass everyting else to _onMessage
+ _onMessage(appConfig, message, origin);
+ } else {
+ //F2.log('socket not ready, queuing message', message);
+ messagePlayback.push(message);
+ }
+ }
+ });
+ };
+
+ /**
+ * Creates a socket connection from the container to the app using
+ *
easyXDM .
+ * @method _createContainerToAppSocket
+ * @private
+ * @param {appConfig} appConfig The F2.AppConfig object
+ * @param {F2.AppManifest} appManifest The F2.AppManifest object
+ */
+ var _createContainerToAppSocket = function (appConfig, appManifest) {
+
+ var container = jQuery(appConfig.root);
+
+ if (!container.is('.' + F2.Constants.Css.APP_CONTAINER)) {
+ container.find('.' + F2.Constants.Css.APP_CONTAINER);
+ }
+
+ if (!container.length) {
+ F2.log('Unable to locate app in order to establish secure connection.');
+ return;
+ }
+
+ var iframeProps = {
+ scrolling: 'no',
+ style: {
+ width: '100%'
+ }
+ };
+
+ if (appConfig.height) {
+ iframeProps.style.height = appConfig.height + 'px';
+ }
+
+ var socket = new easyXDM.Socket({
+ remote: _secureAppPagePath,
+ container: container.get(0),
+ props: iframeProps,
+ onMessage: function (message, origin) {
+ // pass everything to _onMessage
+ _onMessage(appConfig, message, origin);
+ },
+ onReady: function () {
+ socket.postMessage(F2.Constants.Sockets.LOAD + F2.stringify([appConfig, appManifest], F2.appConfigReplacer));
+ }
+ });
+
+ return socket;
+ };
+
+ /**
+ * @method _createRpcCallback
+ * @private
+ * @param {string} instanceId The app's Instance ID
+ * @param {function} callbackId The callback ID
+ * @return {function} A function to make the RPC call
+ */
+ var _createRpcCallback = function (instanceId, callbackId) {
+ return function () {
+ F2.Rpc.call(
+ instanceId,
+ F2.Constants.Sockets.RPC_CALLBACK,
+ callbackId,
+ [].slice.call(arguments).slice(2)
+ );
+ };
+ };
+
+ /**
+ * Handles messages that come across the sockets
+ * @method _onMessage
+ * @private
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ * @param {string} message The socket message
+ * @param {string} origin The originator
+ */
+ var _onMessage = function (appConfig, message, origin) {
+
+ var obj, func;
+
+ function parseFunction(parent, functionName) {
+ var path = String(functionName).split('.');
+ for (var i = 0; i < path.length; i++) {
+ if (parent[path[i]] === undefined) {
+ parent = undefined;
+ break;
+ }
+ parent = parent[path[i]];
+ }
+ return parent;
+ }
+
+ function parseMessage(regEx, message, instanceId) {
+ var o = F2.parse(message.replace(regEx, ''));
+
+ // if obj.callbacks
+ // for each callback
+ // for each params
+ // if callback matches param
+ // replace param with _createRpcCallback(app.instanceId, callback)
+ if (o.params && o.params.length && o.callbacks && o.callbacks.length) {
+ jQuery.each(o.callbacks, function (i, c) {
+ jQuery.each(o.params, function (i, p) {
+ if (c == p) {
+ o.params[i] = _createRpcCallback(instanceId, c);
+ }
+ });
+ });
+ }
+
+ return o;
+ }
+
+ // handle UI Call
+ if (_rUiCall.test(message)) {
+ obj = parseMessage(_rUiCall, message, appConfig.instanceId);
+ func = parseFunction(appConfig.ui, obj.functionName);
+ // if we found the function, call it
+ if (func !== undefined) {
+ func.apply(appConfig.ui, obj.params);
+ } else {
+ F2.log('Unable to locate UI RPC function: ' + obj.functionName);
+ }
+
+ // handle RPC
+ } else if (_rRpc.test(message)) {
+ obj = parseMessage(_rRpc, message, appConfig.instanceId);
+ func = parseFunction(window, obj.functionName);
+ if (func !== undefined) {
+ func.apply(func, obj.params);
+ } else {
+ F2.log('Unable to locate RPC function: ' + obj.functionName);
+ }
+
+ // handle RPC Callback
+ } else if (_rRpcCallback.test(message)) {
+ obj = parseMessage(_rRpcCallback, message, appConfig.instanceId);
+ if (_callbacks[obj.functionName] !== undefined) {
+ _callbacks[obj.functionName].apply(_callbacks[obj.functionName], obj.params);
+ delete _callbacks[obj.functionName];
+ }
+
+ // handle Events
+ } else if (_rEvents.test(message)) {
+ obj = parseMessage(_rEvents, message, appConfig.instanceId);
+ F2.Events._socketEmit.apply(F2.Events, obj);
+ }
+ };
+
+ /**
+ * Registers a callback function
+ * @method _registerCallback
+ * @private
+ * @param {function} callback The callback function
+ * @return {string} The callback ID
+ */
+ var _registerCallback = function (callback) {
+ var callbackId = F2.guid();
+ _callbacks[callbackId] = callback;
+ return callbackId;
+ };
+
+ return {
+ /**
+ * Broadcast an RPC function to all sockets
+ * @method broadcast
+ * @param {string} messageType The message type
+ * @param {Array} params The parameters to broadcast
+ */
+ broadcast: function (messageType, params) {
+ // check valid messageType
+ var message = messageType + F2.stringify(params);
+ jQuery.each(_apps, function (i, a) {
+ a.socket.postMessage(message);
+ });
+ },
+ /**
+ * Calls a remote function
+ * @method call
+ * @param {string} instanceId The app's Instance ID
+ * @param {string} messageType The message type
+ * @param {string} functionName The name of the remote function
+ * @param {Array} params An array of parameters to pass to the remote
+ * function. Any functions found within the params will be treated as a
+ * callback function.
+ */
+ call: function (instanceId, messageType, functionName, params) {
+ // loop through params and find functions and convert them to callbacks
+ var callbacks = [];
+ jQuery.each(params, function (i, e) {
+ if (typeof e === 'function') {
+ var cid = _registerCallback(e);
+ params[i] = cid;
+ callbacks.push(cid);
+ }
+ });
+ // check valid messageType
+ _apps[instanceId].socket.postMessage(
+ messageType + F2.stringify({
+ functionName: functionName,
+ params: params,
+ callbacks: callbacks
+ })
+ );
+ },
+
+ /**
+ * Init function which tells F2.Rpc whether it is running at the container-
+ * level or the app-level. This method is generally called by
+ * F2.{{#crossLink "F2/init"}}{{/crossLink}}
+ * @method init
+ * @param {string} [secureAppPagePath] The
+ * {{#crossLink "F2.ContainerConfig"}}{{/crossLink}}.secureAppPagePath
+ * property
+ */
+ init: function (secureAppPagePath) {
+ _secureAppPagePath = secureAppPagePath;
+ if (!_secureAppPagePath) {
+ _createAppToContainerSocket();
+ }
+ },
+
+ /**
+ * Determines whether the Instance ID is considered to be 'remote'. This is
+ * determined by checking if 1) the app has an open socket and 2) whether
+ * F2.Rpc is running inside of an iframe
+ * @method isRemote
+ * @param {string} instanceId The Instance ID
+ * @return {bool} True if there is an open socket
+ */
+ isRemote: function (instanceId) {
+ return (
+ // we have an app
+ _apps[instanceId] !== undefined &&
+ // the app is secure
+ _apps[instanceId].config.isSecure &&
+ // we can't access the iframe
+ jQuery(_apps[instanceId].config.root).find('iframe').length === 0
+ );
+ },
+
+ /**
+ * Creates a container-to-app or app-to-container socket for communication
+ * @method register
+ * @param {F2.AppConfig} [appConfig] The F2.AppConfig object
+ * @param {F2.AppManifest} [appManifest] The F2.AppManifest object
+ */
+ register: function (appConfig, appManifest) {
+ if (!!appConfig && !!appManifest) {
+ _apps[appConfig.instanceId] = {
+ config: appConfig,
+ socket: _createContainerToAppSocket(appConfig, appManifest)
+ };
+ } else {
+ F2.log('Unable to register socket connection. Please check container configuration.');
+ }
+ }
+ };
})());
\ No newline at end of file
diff --git a/sdk/src/template/footer.js.tmpl b/sdk/src/template/footer.js.tmpl
index d74f3681..51a9d7c2 100644
--- a/sdk/src/template/footer.js.tmpl
+++ b/sdk/src/template/footer.js.tmpl
@@ -1,42 +1,42 @@
- jQuery(function() {
- var autoloadEls = [],
- add = function(e) {
- if (!e) { return; }
- autoloadEls.push(e);
- },
- addAll = function(els) {
- if (!els) { return; }
- for (var i = 0, len = els.length; i < len; i++) {
- add(els[i]);
- }
- };
-
- // support id-based autoload
- add(document.getElementById('f2-autoload'));
-
- // support class/attribute based autoload
- if (document.querySelectorAll) {
- addAll(document.querySelectorAll('[data-f2-autoload]'));
- addAll(document.querySelectorAll('.f2-autoload'));
- }
-
- // if elements were found, auto-init F2 and load any placeholders
- if (autoloadEls.length) {
- F2.init();
- for (var i = 0, len = autoloadEls.length; i < len; i++) {
- F2.loadPlaceholders(autoloadEls[i]);
- }
- }
- });
-
- exports.F2 = F2;
-
- if (typeof define !== 'undefined' && define.amd) {
-
- define(function() {
- return F2;
- });
-
- }
+ jQuery(function() {
+ var autoloadEls = [],
+ add = function(e) {
+ if (!e) { return; }
+ autoloadEls.push(e);
+ },
+ addAll = function(els) {
+ if (!els) { return; }
+ for (var i = 0, len = els.length; i < len; i++) {
+ add(els[i]);
+ }
+ };
+
+ // support id-based autoload
+ add(document.getElementById('f2-autoload'));
+
+ // support class/attribute based autoload
+ if (document.querySelectorAll) {
+ addAll(document.querySelectorAll('[data-f2-autoload]'));
+ addAll(document.querySelectorAll('.f2-autoload'));
+ }
+
+ // if elements were found, auto-init F2 and load any placeholders
+ if (autoloadEls.length) {
+ F2.init();
+ for (var i = 0, len = autoloadEls.length; i < len; i++) {
+ F2.loadPlaceholders(autoloadEls[i]);
+ }
+ }
+ });
+
+ exports.F2 = F2;
+
+ if (typeof define !== 'undefined' && define.amd) {
+
+ define(function() {
+ return F2;
+ });
+
+ }
})(typeof exports !== 'undefined' ? exports : window);
diff --git a/sdk/src/template/header.js.tmpl b/sdk/src/template/header.js.tmpl
index aa7adc38..62b349d9 100644
--- a/sdk/src/template/header.js.tmpl
+++ b/sdk/src/template/header.js.tmpl
@@ -1,5 +1,5 @@
;(function(exports) {
- if (exports.F2 && !exports.F2_TESTING_MODE) {
- return;
- }
+ if (exports.F2 && !exports.F2_TESTING_MODE) {
+ return;
+ }
diff --git a/sdk/src/third-party/bootstrap-modal.js b/sdk/src/third-party/bootstrap-modal.js
index 9f1166d3..fbbf1d79 100644
--- a/sdk/src/third-party/bootstrap-modal.js
+++ b/sdk/src/third-party/bootstrap-modal.js
@@ -8,275 +8,275 @@
+function ($) {
- 'use strict';
-
- // MODAL CLASS DEFINITION
- // ======================
-
- var Modal = function (element, options) {
- this.options = options
- this.$body = $(document.body)
- this.$element = $(element)
- this.$backdrop =
- this.isShown = null
- this.scrollbarWidth = 0
-
- if (this.options.remote) {
- this.$element
- .find('.modal-content')
- .load(this.options.remote, $.proxy(function () {
- this.$element.trigger('loaded.bs.modal')
- }, this))
+ 'use strict';
+
+ // MODAL CLASS DEFINITION
+ // ======================
+
+ var Modal = function (element, options) {
+ this.options = options
+ this.$body = $(document.body)
+ this.$element = $(element)
+ this.$backdrop =
+ this.isShown = null
+ this.scrollbarWidth = 0
+
+ if (this.options.remote) {
+ this.$element
+ .find('.modal-content')
+ .load(this.options.remote, $.proxy(function () {
+ this.$element.trigger('loaded.bs.modal')
+ }, this))
+ }
}
- }
- Modal.VERSION = '3.2.0'
+ Modal.VERSION = '3.2.0'
- Modal.TRANSITION_DURATION = 300
- Modal.BACKDROP_TRANSITION_DURATION = 150
+ Modal.TRANSITION_DURATION = 300
+ Modal.BACKDROP_TRANSITION_DURATION = 150
- Modal.DEFAULTS = {
- backdrop: true,
- keyboard: true,
- show: true
- }
+ Modal.DEFAULTS = {
+ backdrop: true,
+ keyboard: true,
+ show: true
+ }
- Modal.prototype.toggle = function (_relatedTarget) {
- return this.isShown ? this.hide() : this.show(_relatedTarget)
- }
+ Modal.prototype.toggle = function (_relatedTarget) {
+ return this.isShown ? this.hide() : this.show(_relatedTarget)
+ }
- Modal.prototype.show = function (_relatedTarget) {
- var that = this
- var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
+ Modal.prototype.show = function (_relatedTarget) {
+ var that = this
+ var e = $.Event('show.bs.modal', {relatedTarget: _relatedTarget})
- this.$element.trigger(e)
+ this.$element.trigger(e)
- if (this.isShown || e.isDefaultPrevented()) return
+ if (this.isShown || e.isDefaultPrevented()) return
- this.isShown = true
+ this.isShown = true
- this.checkScrollbar()
- this.$body.addClass('modal-open')
+ this.checkScrollbar()
+ this.$body.addClass('modal-open')
- this.setScrollbar()
- this.escape()
+ this.setScrollbar()
+ this.escape()
- this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+ this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
- this.backdrop(function () {
- var transition = $.support.transition && that.$element.hasClass('fade')
+ this.backdrop(function () {
+ var transition = $.support.transition && that.$element.hasClass('fade')
- if (!that.$element.parent().length) {
- that.$element.appendTo(that.$body) // don't move modals dom position
- }
+ if (!that.$element.parent().length) {
+ that.$element.appendTo(that.$body) // don't move modals dom position
+ }
- that.$element
- .show()
- .scrollTop(0)
+ that.$element
+ .show()
+ .scrollTop(0)
- if (transition) {
- that.$element[0].offsetWidth // force reflow
- }
+ if (transition) {
+ that.$element[0].offsetWidth // force reflow
+ }
- that.$element
- .addClass('in')
- .attr('aria-hidden', false)
+ that.$element
+ .addClass('in')
+ .attr('aria-hidden', false)
- that.enforceFocus()
+ that.enforceFocus()
- var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
+ var e = $.Event('shown.bs.modal', {relatedTarget: _relatedTarget})
- transition ?
- that.$element.find('.modal-dialog') // wait for modal to slide in
- .one('bsTransitionEnd', function () {
- that.$element.trigger('focus').trigger(e)
- })
- .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
- that.$element.trigger('focus').trigger(e)
- })
- }
+ transition ?
+ that.$element.find('.modal-dialog') // wait for modal to slide in
+ .one('bsTransitionEnd', function () {
+ that.$element.trigger('focus').trigger(e)
+ })
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+ that.$element.trigger('focus').trigger(e)
+ })
+ }
+
+ Modal.prototype.hide = function (e) {
+ if (e) e.preventDefault()
- Modal.prototype.hide = function (e) {
- if (e) e.preventDefault()
+ e = $.Event('hide.bs.modal')
- e = $.Event('hide.bs.modal')
+ this.$element.trigger(e)
- this.$element.trigger(e)
+ if (!this.isShown || e.isDefaultPrevented()) return
- if (!this.isShown || e.isDefaultPrevented()) return
+ this.isShown = false
- this.isShown = false
+ this.escape()
- this.escape()
+ $(document).off('focusin.bs.modal')
- $(document).off('focusin.bs.modal')
+ this.$element
+ .removeClass('in')
+ .attr('aria-hidden', true)
+ .off('click.dismiss.bs.modal')
- this.$element
- .removeClass('in')
- .attr('aria-hidden', true)
- .off('click.dismiss.bs.modal')
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.$element
+ .one('bsTransitionEnd', $.proxy(this.hideModal, this))
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
+ this.hideModal()
+ }
- $.support.transition && this.$element.hasClass('fade') ?
- this.$element
- .one('bsTransitionEnd', $.proxy(this.hideModal, this))
- .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
- this.hideModal()
- }
+ Modal.prototype.enforceFocus = function () {
+ $(document)
+ .off('focusin.bs.modal') // guard against infinite focus loop
+ .on('focusin.bs.modal', $.proxy(function (e) {
+ if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
+ this.$element.trigger('focus')
+ }
+ }, this))
+ }
- Modal.prototype.enforceFocus = function () {
- $(document)
- .off('focusin.bs.modal') // guard against infinite focus loop
- .on('focusin.bs.modal', $.proxy(function (e) {
- if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
- this.$element.trigger('focus')
+ Modal.prototype.escape = function () {
+ if (this.isShown && this.options.keyboard) {
+ this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
+ e.which == 27 && this.hide()
+ }, this))
+ } else if (!this.isShown) {
+ this.$element.off('keydown.dismiss.bs.modal')
}
- }, this))
- }
-
- Modal.prototype.escape = function () {
- if (this.isShown && this.options.keyboard) {
- this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
- e.which == 27 && this.hide()
- }, this))
- } else if (!this.isShown) {
- this.$element.off('keydown.dismiss.bs.modal')
}
- }
-
- Modal.prototype.hideModal = function () {
- var that = this
- this.$element.hide()
- this.backdrop(function () {
- that.$body.removeClass('modal-open')
- that.resetScrollbar()
- that.$element.trigger('hidden.bs.modal')
- })
- }
- Modal.prototype.removeBackdrop = function () {
- this.$backdrop && this.$backdrop.remove()
- this.$backdrop = null
- }
+ Modal.prototype.hideModal = function () {
+ var that = this
+ this.$element.hide()
+ this.backdrop(function () {
+ that.$body.removeClass('modal-open')
+ that.resetScrollbar()
+ that.$element.trigger('hidden.bs.modal')
+ })
+ }
- Modal.prototype.backdrop = function (callback) {
- var that = this
- var animate = this.$element.hasClass('fade') ? 'fade' : ''
+ Modal.prototype.removeBackdrop = function () {
+ this.$backdrop && this.$backdrop.remove()
+ this.$backdrop = null
+ }
- if (this.isShown && this.options.backdrop) {
- var doAnimate = $.support.transition && animate
+ Modal.prototype.backdrop = function (callback) {
+ var that = this
+ var animate = this.$element.hasClass('fade') ? 'fade' : ''
- this.$backdrop = $('
')
- .appendTo(this.$body)
+ if (this.isShown && this.options.backdrop) {
+ var doAnimate = $.support.transition && animate
- this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
- if (e.target !== e.currentTarget) return
- this.options.backdrop == 'static'
- ? this.$element[0].focus.call(this.$element[0])
- : this.hide.call(this)
- }, this))
+ this.$backdrop = $('
')
+ .appendTo(this.$body)
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
+ this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
+ if (e.target !== e.currentTarget) return
+ this.options.backdrop == 'static'
+ ? this.$element[0].focus.call(this.$element[0])
+ : this.hide.call(this)
+ }, this))
- this.$backdrop.addClass('in')
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
- if (!callback) return
+ this.$backdrop.addClass('in')
- doAnimate ?
- this.$backdrop
- .one('bsTransitionEnd', callback)
- .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
- callback()
+ if (!callback) return
- } else if (!this.isShown && this.$backdrop) {
- this.$backdrop.removeClass('in')
+ doAnimate ?
+ this.$backdrop
+ .one('bsTransitionEnd', callback)
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+ callback()
- var callbackRemove = function () {
- that.removeBackdrop()
- callback && callback()
- }
- $.support.transition && this.$element.hasClass('fade') ?
- this.$backdrop
- .one('bsTransitionEnd', callbackRemove)
- .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
- callbackRemove()
+ } else if (!this.isShown && this.$backdrop) {
+ this.$backdrop.removeClass('in')
- } else if (callback) {
- callback()
+ var callbackRemove = function () {
+ that.removeBackdrop()
+ callback && callback()
+ }
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.$backdrop
+ .one('bsTransitionEnd', callbackRemove)
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
+ callbackRemove()
+
+ } else if (callback) {
+ callback()
+ }
}
- }
-
- Modal.prototype.checkScrollbar = function () {
- this.scrollbarWidth = this.measureScrollbar()
- }
-
- Modal.prototype.setScrollbar = function () {
- var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
- if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
- }
-
- Modal.prototype.resetScrollbar = function () {
- this.$body.css('padding-right', '')
- }
-
- Modal.prototype.measureScrollbar = function () { // thx walsh
- if (document.body.clientWidth >= window.innerWidth) return 0
- var scrollDiv = document.createElement('div')
- scrollDiv.className = 'modal-scrollbar-measure'
- this.$body.append(scrollDiv)
- var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
- this.$body[0].removeChild(scrollDiv)
- return scrollbarWidth
- }
-
-
- // MODAL PLUGIN DEFINITION
- // =======================
-
- function Plugin(option, _relatedTarget) {
- return this.each(function () {
- var $this = $(this)
- var data = $this.data('bs.modal')
- var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
-
- if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
- if (typeof option == 'string') data[option](_relatedTarget)
- else if (options.show) data.show(_relatedTarget)
- })
- }
- var old = $.fn.modal
+ Modal.prototype.checkScrollbar = function () {
+ this.scrollbarWidth = this.measureScrollbar()
+ }
+
+ Modal.prototype.setScrollbar = function () {
+ var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
+ if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
+ }
+
+ Modal.prototype.resetScrollbar = function () {
+ this.$body.css('padding-right', '')
+ }
+
+ Modal.prototype.measureScrollbar = function () { // thx walsh
+ if (document.body.clientWidth >= window.innerWidth) return 0
+ var scrollDiv = document.createElement('div')
+ scrollDiv.className = 'modal-scrollbar-measure'
+ this.$body.append(scrollDiv)
+ var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
+ this.$body[0].removeChild(scrollDiv)
+ return scrollbarWidth
+ }
- $.fn.modal = Plugin
- $.fn.modal.Constructor = Modal
+ // MODAL PLUGIN DEFINITION
+ // =======================
- // MODAL NO CONFLICT
- // =================
+ function Plugin(option, _relatedTarget) {
+ return this.each(function () {
+ var $this = $(this)
+ var data = $this.data('bs.modal')
+ var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
- $.fn.modal.noConflict = function () {
- $.fn.modal = old
- return this
- }
+ if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
+ if (typeof option == 'string') data[option](_relatedTarget)
+ else if (options.show) data.show(_relatedTarget)
+ })
+ }
+
+ var old = $.fn.modal
+
+ $.fn.modal = Plugin
+ $.fn.modal.Constructor = Modal
+
+
+ // MODAL NO CONFLICT
+ // =================
+
+ $.fn.modal.noConflict = function () {
+ $.fn.modal = old
+ return this
+ }
- // MODAL DATA-API
- // ==============
+ // MODAL DATA-API
+ // ==============
- $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
- var $this = $(this)
- var href = $this.attr('href')
- var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
- var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
+ $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
+ var $this = $(this)
+ var href = $this.attr('href')
+ var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
+ var option = $target.data('bs.modal') ? 'toggle' : $.extend({remote: !/#/.test(href) && href}, $target.data(), $this.data())
- if ($this.is('a')) e.preventDefault()
+ if ($this.is('a')) e.preventDefault()
- $target.one('show.bs.modal', function (showEvent) {
- if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
- $target.one('hidden.bs.modal', function () {
- $this.is(':visible') && $this.trigger('focus')
- })
+ $target.one('show.bs.modal', function (showEvent) {
+ if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
+ $target.one('hidden.bs.modal', function () {
+ $this.is(':visible') && $this.trigger('focus')
+ })
+ })
+ Plugin.call($target, option, this)
})
- Plugin.call($target, option, this)
- })
}(jQuery);
\ No newline at end of file
diff --git a/sdk/src/third-party/easyXDM/cors/index.html b/sdk/src/third-party/easyXDM/cors/index.html
index 9370e1d0..0a34d873 100644
--- a/sdk/src/third-party/easyXDM/cors/index.html
+++ b/sdk/src/third-party/easyXDM/cors/index.html
@@ -1,63 +1,63 @@
-
-
easyXDM cross-domain XHMLHttpRequest provider
-
-
-
+
+
-
-
-
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/easyXDM.Widgets.debug.js b/sdk/src/third-party/easyXDM/easyXDM.Widgets.debug.js
index 315770b5..cbcc22b2 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.Widgets.debug.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.Widgets.debug.js
@@ -68,7 +68,7 @@
* @param {Object} config The WidgetManagers configuration
* @namespace easyXDM
*/
-easyXDM.WidgetManager = function(config){
+easyXDM.WidgetManager = function (config) {
var WidgetManager = this, _hashUrl = config.local, _channelNr = 0;
var Events = {
WidgetInitialized: "widgetinitialized",
@@ -80,32 +80,32 @@ easyXDM.WidgetManager = function(config){
};
easyXDM.apply(_widgetSettings, config.widgetSettings);
var _container = config.container || document.body;
-
+
/**
* @private
* Raises the specified event
* @param {String} event The raised event
* @param {Object} arg
*/
- function _raiseEvent(event, arg){
+ function _raiseEvent(event, arg) {
if (config.listeners && config.listeners[event]) {
config.listeners[event](WidgetManager, arg);
}
}
-
+
/**
* @private
* Adds the widghet to the list of subscribers for the given topic
* @param {String} url The widgets url
* @param {String} topic The topic to subscribe to
*/
- function _subscribe(url, topic){
+ function _subscribe(url, topic) {
if (!(topic in _subscribers)) {
_subscribers[topic] = [];
}
_subscribers[topic].push(url);
}
-
+
/**
* @private
* Initialized the widget.
@@ -114,8 +114,8 @@ easyXDM.WidgetManager = function(config){
* @param {String} url The widgets url
* @param {Object} widgetConfig The widgets configuration
*/
- function _initializeWidget(widget, url, widgetConfig){
- widget.initialize(_widgetSettings, function(response){
+ function _initializeWidget(widget, url, widgetConfig) {
+ widget.initialize(_widgetSettings, function (response) {
if (response.isInitialized) {
_widgets[url] = widget;
var i = response.subscriptions.length;
@@ -134,7 +134,7 @@ easyXDM.WidgetManager = function(config){
}
});
}
-
+
/**
* @private
* Publishes the data to the topics subscribers
@@ -142,7 +142,7 @@ easyXDM.WidgetManager = function(config){
* @param {String} topic The datas topic
* @param {Object} data The data to publish
*/
- function _publish(url, topic, data){
+ function _publish(url, topic, data) {
var subscribers = _subscribers[topic];
if (subscribers) {
var i = subscribers.length, widgetUrl;
@@ -154,34 +154,34 @@ easyXDM.WidgetManager = function(config){
}
}
}
-
+
/**
* @private
* Sets up a new widget
* @param {String} url The widgets url
* @param {Object} widgetConfig The widgets configuration
*/
- function _setUpWidget(url, widgetConfig){
+ function _setUpWidget(url, widgetConfig) {
var widget = new easyXDM.Rpc({
channel: "widget" + _channelNr++,
local: _hashUrl,
remote: url,
container: widgetConfig.container || _container,
swf: config.swf,
- onReady: function(){
+ onReady: function () {
_initializeWidget(widget, url, widgetConfig);
}
}, {
local: {
subscribe: {
isVoid: true,
- method: function(topic){
+ method: function (topic) {
_subscribe(url, topic);
}
},
publish: {
isVoid: true,
- method: function(topic, data){
+ method: function (topic, data) {
_publish(url, topic, data);
}
}
@@ -194,24 +194,24 @@ easyXDM.WidgetManager = function(config){
}
});
}
-
+
/**
* Adds a widget to the collection
* @param {String} url The url to load the widget from
* @param {Object} widgetConfig The widgets url
*/
- this.addWidget = function(url, widgetConfig){
+ this.addWidget = function (url, widgetConfig) {
if (url in _widgets) {
throw new Error("A widget with this url has already been initialized");
}
_setUpWidget(url, widgetConfig);
};
-
+
/**
* Removes the widget
* @param {Object} url
*/
- this.removeWidget = function(url){
+ this.removeWidget = function (url) {
if (url in _widgets) {
for (var topic in _subscribers) {
if (_subscribers.hasOwnProperty(topic)) {
@@ -228,21 +228,21 @@ easyXDM.WidgetManager = function(config){
delete _widgets[url];
}
};
-
+
/**
* Publish data to a topics subscribers
* @param {String} topic The topic to publish to
* @param {Object} data The data to publish
*/
- this.publish = function(topic, data){
+ this.publish = function (topic, data) {
_publish("", topic, data);
};
-
+
/**
* Broadcasts data to all the widgets
* @param {Object} data The data to broadcast
*/
- this.broadcast = function(data){
+ this.broadcast = function (data) {
for (var url in _widgets) {
if (_widgets.hasOwnPropert(url)) {
_widgets[url].send({
@@ -263,7 +263,7 @@ easyXDM.WidgetManager = function(config){
* @param {Function} onReady A method to run after the widget has been initialized.
* @namespace easyXDM
*/
-easyXDM.Widget = function(config){
+easyXDM.Widget = function (config) {
var _widget = this;
var _incomingMessageHandler;
var _widgetHost = new easyXDM.Rpc({
@@ -279,7 +279,7 @@ easyXDM.Widget = function(config){
},
local: {
initialize: {
- method: function(settings){
+ method: function (settings) {
config.initialized(_widget, _widgetHost);
return {
isInitialized: true,
@@ -289,45 +289,45 @@ easyXDM.Widget = function(config){
},
send: {
isVoid: true,
- method: function(url, topic, data){
+ method: function (url, topic, data) {
_incomingMessageHandler(url, topic, data);
}
}
}
});
-
+
/**
* @private
* Destroy the interface on unload
*/
- window.onunload = function(){
+ window.onunload = function () {
_widgetHost.destroy();
};
-
+
/**
* Publish data to subscribers to a topic
* @param {String} topic The topic to publish to
* @param {Object} data The data to publish
*/
- this.publish = function(topic, data){
+ this.publish = function (topic, data) {
_widgetHost.publish(topic, data);
};
-
+
/**
* Subscribe to a topic
* @param {String} topic The topic to subscribe to
*/
- this.subscribe = function(topic){
+ this.subscribe = function (topic) {
_widgetHost.subscribe(topic);
};
-
+
/**
* Register the method that will handle incoming messages
* @param {Function} fn The handler
*/
- this.registerMessageHandler = function(fn){
+ this.registerMessageHandler = function (fn) {
_incomingMessageHandler = fn;
};
-
+
config.initialize(this, _widgetHost);
};
diff --git a/sdk/src/third-party/easyXDM/easyXDM.Widgets.js b/sdk/src/third-party/easyXDM/easyXDM.Widgets.js
index 315770b5..cbcc22b2 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.Widgets.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.Widgets.js
@@ -68,7 +68,7 @@
* @param {Object} config The WidgetManagers configuration
* @namespace easyXDM
*/
-easyXDM.WidgetManager = function(config){
+easyXDM.WidgetManager = function (config) {
var WidgetManager = this, _hashUrl = config.local, _channelNr = 0;
var Events = {
WidgetInitialized: "widgetinitialized",
@@ -80,32 +80,32 @@ easyXDM.WidgetManager = function(config){
};
easyXDM.apply(_widgetSettings, config.widgetSettings);
var _container = config.container || document.body;
-
+
/**
* @private
* Raises the specified event
* @param {String} event The raised event
* @param {Object} arg
*/
- function _raiseEvent(event, arg){
+ function _raiseEvent(event, arg) {
if (config.listeners && config.listeners[event]) {
config.listeners[event](WidgetManager, arg);
}
}
-
+
/**
* @private
* Adds the widghet to the list of subscribers for the given topic
* @param {String} url The widgets url
* @param {String} topic The topic to subscribe to
*/
- function _subscribe(url, topic){
+ function _subscribe(url, topic) {
if (!(topic in _subscribers)) {
_subscribers[topic] = [];
}
_subscribers[topic].push(url);
}
-
+
/**
* @private
* Initialized the widget.
@@ -114,8 +114,8 @@ easyXDM.WidgetManager = function(config){
* @param {String} url The widgets url
* @param {Object} widgetConfig The widgets configuration
*/
- function _initializeWidget(widget, url, widgetConfig){
- widget.initialize(_widgetSettings, function(response){
+ function _initializeWidget(widget, url, widgetConfig) {
+ widget.initialize(_widgetSettings, function (response) {
if (response.isInitialized) {
_widgets[url] = widget;
var i = response.subscriptions.length;
@@ -134,7 +134,7 @@ easyXDM.WidgetManager = function(config){
}
});
}
-
+
/**
* @private
* Publishes the data to the topics subscribers
@@ -142,7 +142,7 @@ easyXDM.WidgetManager = function(config){
* @param {String} topic The datas topic
* @param {Object} data The data to publish
*/
- function _publish(url, topic, data){
+ function _publish(url, topic, data) {
var subscribers = _subscribers[topic];
if (subscribers) {
var i = subscribers.length, widgetUrl;
@@ -154,34 +154,34 @@ easyXDM.WidgetManager = function(config){
}
}
}
-
+
/**
* @private
* Sets up a new widget
* @param {String} url The widgets url
* @param {Object} widgetConfig The widgets configuration
*/
- function _setUpWidget(url, widgetConfig){
+ function _setUpWidget(url, widgetConfig) {
var widget = new easyXDM.Rpc({
channel: "widget" + _channelNr++,
local: _hashUrl,
remote: url,
container: widgetConfig.container || _container,
swf: config.swf,
- onReady: function(){
+ onReady: function () {
_initializeWidget(widget, url, widgetConfig);
}
}, {
local: {
subscribe: {
isVoid: true,
- method: function(topic){
+ method: function (topic) {
_subscribe(url, topic);
}
},
publish: {
isVoid: true,
- method: function(topic, data){
+ method: function (topic, data) {
_publish(url, topic, data);
}
}
@@ -194,24 +194,24 @@ easyXDM.WidgetManager = function(config){
}
});
}
-
+
/**
* Adds a widget to the collection
* @param {String} url The url to load the widget from
* @param {Object} widgetConfig The widgets url
*/
- this.addWidget = function(url, widgetConfig){
+ this.addWidget = function (url, widgetConfig) {
if (url in _widgets) {
throw new Error("A widget with this url has already been initialized");
}
_setUpWidget(url, widgetConfig);
};
-
+
/**
* Removes the widget
* @param {Object} url
*/
- this.removeWidget = function(url){
+ this.removeWidget = function (url) {
if (url in _widgets) {
for (var topic in _subscribers) {
if (_subscribers.hasOwnProperty(topic)) {
@@ -228,21 +228,21 @@ easyXDM.WidgetManager = function(config){
delete _widgets[url];
}
};
-
+
/**
* Publish data to a topics subscribers
* @param {String} topic The topic to publish to
* @param {Object} data The data to publish
*/
- this.publish = function(topic, data){
+ this.publish = function (topic, data) {
_publish("", topic, data);
};
-
+
/**
* Broadcasts data to all the widgets
* @param {Object} data The data to broadcast
*/
- this.broadcast = function(data){
+ this.broadcast = function (data) {
for (var url in _widgets) {
if (_widgets.hasOwnPropert(url)) {
_widgets[url].send({
@@ -263,7 +263,7 @@ easyXDM.WidgetManager = function(config){
* @param {Function} onReady A method to run after the widget has been initialized.
* @namespace easyXDM
*/
-easyXDM.Widget = function(config){
+easyXDM.Widget = function (config) {
var _widget = this;
var _incomingMessageHandler;
var _widgetHost = new easyXDM.Rpc({
@@ -279,7 +279,7 @@ easyXDM.Widget = function(config){
},
local: {
initialize: {
- method: function(settings){
+ method: function (settings) {
config.initialized(_widget, _widgetHost);
return {
isInitialized: true,
@@ -289,45 +289,45 @@ easyXDM.Widget = function(config){
},
send: {
isVoid: true,
- method: function(url, topic, data){
+ method: function (url, topic, data) {
_incomingMessageHandler(url, topic, data);
}
}
}
});
-
+
/**
* @private
* Destroy the interface on unload
*/
- window.onunload = function(){
+ window.onunload = function () {
_widgetHost.destroy();
};
-
+
/**
* Publish data to subscribers to a topic
* @param {String} topic The topic to publish to
* @param {Object} data The data to publish
*/
- this.publish = function(topic, data){
+ this.publish = function (topic, data) {
_widgetHost.publish(topic, data);
};
-
+
/**
* Subscribe to a topic
* @param {String} topic The topic to subscribe to
*/
- this.subscribe = function(topic){
+ this.subscribe = function (topic) {
_widgetHost.subscribe(topic);
};
-
+
/**
* Register the method that will handle incoming messages
* @param {Function} fn The handler
*/
- this.registerMessageHandler = function(fn){
+ this.registerMessageHandler = function (fn) {
_incomingMessageHandler = fn;
};
-
+
config.initialize(this, _widgetHost);
};
diff --git a/sdk/src/third-party/easyXDM/easyXDM.Widgets.min.js b/sdk/src/third-party/easyXDM/easyXDM.Widgets.min.js
index 8ed55cdb..b84c5f45 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.Widgets.min.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.Widgets.min.js
@@ -21,4 +21,144 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-easyXDM.WidgetManager=function(e){var h=this,b=e.local,k=0;var n={WidgetInitialized:"widgetinitialized",WidgetFailed:"widgetfailed"};var j={},d={};var i={hosturl:location.href};easyXDM.apply(i,e.widgetSettings);var g=e.container||document.body;function f(p,o){if(e.listeners&&e.listeners[p]){e.listeners[p](h,o)}}function c(p,o){if(!(o in d)){d[o]=[]}d[o].push(p)}function m(p,o,q){p.initialize(i,function(r){if(r.isInitialized){j[o]=p;var s=r.subscriptions.length;while(s--){c(o,r.subscriptions[s])}f(n.WidgetInitialized,{url:o})}else{p.destroy();f(n.WidgetFailed,{url:o})}})}function a(p,o,r){var s=d[o];if(s){var q=s.length,t;while(q--){t=s[q];if(t!==p){j[t].send(p,o,r)}}}}function l(o,q){var p=new easyXDM.Rpc({channel:"widget"+k++,local:b,remote:o,container:q.container||g,swf:e.swf,onReady:function(){m(p,o,q)}},{local:{subscribe:{isVoid:true,method:function(r){c(o,r)}},publish:{isVoid:true,method:function(r,s){a(o,r,s)}}},remote:{initialize:{},send:{isVoid:true}}})}this.addWidget=function(o,p){if(o in j){throw new Error("A widget with this url has already been initialized")}l(o,p)};this.removeWidget=function(p){if(p in j){for(var o in d){if(d.hasOwnProperty(o)){var r=d[o],q=r.length;while(q--){if(r[q]===p){r.splice(q,1);break}}}}j[p].destroy();delete j[p]}};this.publish=function(o,p){a("",o,p)};this.broadcast=function(p){for(var o in j){if(j.hasOwnPropert(o)){j[o].send({url:"",topic:"broadcast",data:p})}}}};easyXDM.Widget=function(c){var a=this;var b;var d=new easyXDM.Rpc({swf:c.swf},{remote:{subscribe:{isVoid:true},publish:{isVoid:true}},local:{initialize:{method:function(e){c.initialized(a,d);return{isInitialized:true,subscriptions:c.subscriptions}}},send:{isVoid:true,method:function(f,e,g){b(f,e,g)}}}});window.onunload=function(){d.destroy()};this.publish=function(e,f){d.publish(e,f)};this.subscribe=function(e){d.subscribe(e)};this.registerMessageHandler=function(e){b=e};c.initialize(this,d)};
\ No newline at end of file
+easyXDM.WidgetManager = function (e) {
+ var h = this, b = e.local, k = 0;
+ var n = {WidgetInitialized: "widgetinitialized", WidgetFailed: "widgetfailed"};
+ var j = {}, d = {};
+ var i = {hosturl: location.href};
+ easyXDM.apply(i, e.widgetSettings);
+ var g = e.container || document.body;
+
+ function f(p, o) {
+ if (e.listeners && e.listeners[p]) {
+ e.listeners[p](h, o)
+ }
+ }
+
+ function c(p, o) {
+ if (!(o in d)) {
+ d[o] = []
+ }
+ d[o].push(p)
+ }
+
+ function m(p, o, q) {
+ p.initialize(i, function (r) {
+ if (r.isInitialized) {
+ j[o] = p;
+ var s = r.subscriptions.length;
+ while (s--) {
+ c(o, r.subscriptions[s])
+ }
+ f(n.WidgetInitialized, {url: o})
+ } else {
+ p.destroy();
+ f(n.WidgetFailed, {url: o})
+ }
+ })
+ }
+
+ function a(p, o, r) {
+ var s = d[o];
+ if (s) {
+ var q = s.length, t;
+ while (q--) {
+ t = s[q];
+ if (t !== p) {
+ j[t].send(p, o, r)
+ }
+ }
+ }
+ }
+
+ function l(o, q) {
+ var p = new easyXDM.Rpc({
+ channel: "widget" + k++,
+ local: b,
+ remote: o,
+ container: q.container || g,
+ swf: e.swf,
+ onReady: function () {
+ m(p, o, q)
+ }
+ }, {
+ local: {
+ subscribe: {
+ isVoid: true, method: function (r) {
+ c(o, r)
+ }
+ }, publish: {
+ isVoid: true, method: function (r, s) {
+ a(o, r, s)
+ }
+ }
+ }, remote: {initialize: {}, send: {isVoid: true}}
+ })
+ }
+
+ this.addWidget = function (o, p) {
+ if (o in j) {
+ throw new Error("A widget with this url has already been initialized")
+ }
+ l(o, p)
+ };
+ this.removeWidget = function (p) {
+ if (p in j) {
+ for (var o in d) {
+ if (d.hasOwnProperty(o)) {
+ var r = d[o], q = r.length;
+ while (q--) {
+ if (r[q] === p) {
+ r.splice(q, 1);
+ break
+ }
+ }
+ }
+ }
+ j[p].destroy();
+ delete j[p]
+ }
+ };
+ this.publish = function (o, p) {
+ a("", o, p)
+ };
+ this.broadcast = function (p) {
+ for (var o in j) {
+ if (j.hasOwnPropert(o)) {
+ j[o].send({url: "", topic: "broadcast", data: p})
+ }
+ }
+ }
+};
+easyXDM.Widget = function (c) {
+ var a = this;
+ var b;
+ var d = new easyXDM.Rpc({swf: c.swf}, {
+ remote: {subscribe: {isVoid: true}, publish: {isVoid: true}},
+ local: {
+ initialize: {
+ method: function (e) {
+ c.initialized(a, d);
+ return {isInitialized: true, subscriptions: c.subscriptions}
+ }
+ }, send: {
+ isVoid: true, method: function (f, e, g) {
+ b(f, e, g)
+ }
+ }
+ }
+ });
+ window.onunload = function () {
+ d.destroy()
+ };
+ this.publish = function (e, f) {
+ d.publish(e, f)
+ };
+ this.subscribe = function (e) {
+ d.subscribe(e)
+ };
+ this.registerMessageHandler = function (e) {
+ b = e
+ };
+ c.initialize(this, d)
+};
\ No newline at end of file
diff --git a/sdk/src/third-party/easyXDM/easyXDM.debug.js b/sdk/src/third-party/easyXDM/easyXDM.debug.js
index 2040bc02..852a2a36 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.debug.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.debug.js
@@ -22,8 +22,8 @@
* THE SOFTWARE.
*/
(function (window, document, location, setTimeout, decodeURIComponent, encodeURIComponent) {
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
//
// easyXDM
// http://easyxdm.net/
@@ -48,847 +48,847 @@
// THE SOFTWARE.
//
-var global = this;
-var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
-var emptyFn = Function.prototype;
-var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
-var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
-var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
-var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
-var easyXDM = {};
-var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
-var IFRAME_PREFIX = "easyXDM_";
-var HAS_NAME_PROPERTY_BUG;
-var useHash = false; // whether to use the hash over the query
-var flashVersion; // will be set if using flash
-var HAS_FLASH_THROTTLED_BUG;
-var _trace = emptyFn;
+ var global = this;
+ var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
+ var emptyFn = Function.prototype;
+ var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
+ var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
+ var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
+ var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
+ var easyXDM = {};
+ var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
+ var IFRAME_PREFIX = "easyXDM_";
+ var HAS_NAME_PROPERTY_BUG;
+ var useHash = false; // whether to use the hash over the query
+ var flashVersion; // will be set if using flash
+ var HAS_FLASH_THROTTLED_BUG;
+ var _trace = emptyFn;
// http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
-function isHostMethod(object, property){
- var t = typeof object[property];
- return t == 'function' ||
- (!!(t == 'object' && object[property])) ||
- t == 'unknown';
-}
+ function isHostMethod(object, property) {
+ var t = typeof object[property];
+ return t == 'function' ||
+ (!!(t == 'object' && object[property])) ||
+ t == 'unknown';
+ }
-function isHostObject(object, property){
- return !!(typeof(object[property]) == 'object' && object[property]);
-}
+ function isHostObject(object, property) {
+ return !!(typeof(object[property]) == 'object' && object[property]);
+ }
// end
// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/
-function isArray(o){
- return Object.prototype.toString.call(o) === '[object Array]';
-}
+ function isArray(o) {
+ return Object.prototype.toString.call(o) === '[object Array]';
+ }
// end
-function hasFlash(){
- var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
-
- if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
- // adapted from the swfobject code
- var description = navigator.plugins[name].description;
- if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
- flashVersion = description.match(/\d+/g);
+ function hasFlash() {
+ var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
+
+ if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
+ // adapted from the swfobject code
+ var description = navigator.plugins[name].description;
+ if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
+ flashVersion = description.match(/\d+/g);
+ }
}
- }
- if (!flashVersion) {
- var flash;
- try {
- flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
- flash = null;
- }
- catch (notSupportedException) {
+ if (!flashVersion) {
+ var flash;
+ try {
+ flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
+ flash = null;
+ }
+ catch (notSupportedException) {
+ }
}
+ if (!flashVersion) {
+ return false;
+ }
+ var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
+ HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
+ return true;
}
- if (!flashVersion) {
- return false;
- }
- var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
- HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
- return true;
-}
-
-/*
- * Cross Browser implementation for adding and removing event listeners.
- */
-var on, un;
-if (isHostMethod(window, "addEventListener")) {
- on = function(target, type, listener){
- _trace("adding listener " + type);
- target.addEventListener(type, listener, false);
- };
- un = function(target, type, listener){
- _trace("removing listener " + type);
- target.removeEventListener(type, listener, false);
- };
-}
-else if (isHostMethod(window, "attachEvent")) {
- on = function(object, sEvent, fpNotify){
- _trace("adding listener " + sEvent);
- object.attachEvent("on" + sEvent, fpNotify);
- };
- un = function(object, sEvent, fpNotify){
- _trace("removing listener " + sEvent);
- object.detachEvent("on" + sEvent, fpNotify);
- };
-}
-else {
- throw new Error("Browser not supported");
-}
-/*
- * Cross Browser implementation of DOMContentLoaded.
- */
-var domIsReady = false, domReadyQueue = [], readyState;
-if ("readyState" in document) {
- // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
- // 'interactive' (HTML5 specs, recent WebKit builds) states.
- // https://bugs.webkit.org/show_bug.cgi?id=45119
- readyState = document.readyState;
- domIsReady = readyState == "complete" || (~ navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
-}
-else {
- // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
- // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
- // We only need a body to add elements to, so the existence of document.body is enough for us.
- domIsReady = !!document.body;
-}
-
-function dom_onReady(){
- if (domIsReady) {
- return;
+ /*
+ * Cross Browser implementation for adding and removing event listeners.
+ */
+ var on, un;
+ if (isHostMethod(window, "addEventListener")) {
+ on = function (target, type, listener) {
+ _trace("adding listener " + type);
+ target.addEventListener(type, listener, false);
+ };
+ un = function (target, type, listener) {
+ _trace("removing listener " + type);
+ target.removeEventListener(type, listener, false);
+ };
}
- domIsReady = true;
- _trace("firing dom_onReady");
- for (var i = 0; i < domReadyQueue.length; i++) {
- domReadyQueue[i]();
+ else if (isHostMethod(window, "attachEvent")) {
+ on = function (object, sEvent, fpNotify) {
+ _trace("adding listener " + sEvent);
+ object.attachEvent("on" + sEvent, fpNotify);
+ };
+ un = function (object, sEvent, fpNotify) {
+ _trace("removing listener " + sEvent);
+ object.detachEvent("on" + sEvent, fpNotify);
+ };
+ }
+ else {
+ throw new Error("Browser not supported");
}
- domReadyQueue.length = 0;
-}
-
-if (!domIsReady) {
- if (isHostMethod(window, "addEventListener")) {
- on(document, "DOMContentLoaded", dom_onReady);
+ /*
+ * Cross Browser implementation of DOMContentLoaded.
+ */
+ var domIsReady = false, domReadyQueue = [], readyState;
+ if ("readyState" in document) {
+ // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
+ // 'interactive' (HTML5 specs, recent WebKit builds) states.
+ // https://bugs.webkit.org/show_bug.cgi?id=45119
+ readyState = document.readyState;
+ domIsReady = readyState == "complete" || (~navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
}
else {
- on(document, "readystatechange", function(){
- if (document.readyState == "complete") {
- dom_onReady();
- }
- });
- if (document.documentElement.doScroll && window === top) {
- var doScrollCheck = function(){
- if (domIsReady) {
- return;
- }
- // http://javascript.nwbox.com/IEContentLoaded/
- try {
- document.documentElement.doScroll("left");
- }
- catch (e) {
- setTimeout(doScrollCheck, 1);
- return;
- }
- dom_onReady();
- };
- doScrollCheck();
- }
+ // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
+ // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
+ // We only need a body to add elements to, so the existence of document.body is enough for us.
+ domIsReady = !!document.body;
}
-
- // A fallback to window.onload, that will always work
- on(window, "load", dom_onReady);
-}
-/**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {Object} scope An optional scope for the function to be called with.
- */
-function whenReady(fn, scope){
- if (domIsReady) {
- fn.call(scope);
- return;
+
+ function dom_onReady() {
+ if (domIsReady) {
+ return;
+ }
+ domIsReady = true;
+ _trace("firing dom_onReady");
+ for (var i = 0; i < domReadyQueue.length; i++) {
+ domReadyQueue[i]();
+ }
+ domReadyQueue.length = 0;
}
- domReadyQueue.push(function(){
- fn.call(scope);
- });
-}
-/**
- * Returns an instance of easyXDM from the parent window with
- * respect to the namespace.
- *
- * @return An instance of easyXDM (in the parent window)
- */
-function getParentObject(){
- var obj = parent;
- if (namespace !== "") {
- for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
- if (!obj) {
- throw new Error(ii.slice(0, i + 1).join('.') + ' is not an object');
+
+ if (!domIsReady) {
+ if (isHostMethod(window, "addEventListener")) {
+ on(document, "DOMContentLoaded", dom_onReady);
+ }
+ else {
+ on(document, "readystatechange", function () {
+ if (document.readyState == "complete") {
+ dom_onReady();
+ }
+ });
+ if (document.documentElement.doScroll && window === top) {
+ var doScrollCheck = function () {
+ if (domIsReady) {
+ return;
+ }
+ // http://javascript.nwbox.com/IEContentLoaded/
+ try {
+ document.documentElement.doScroll("left");
+ }
+ catch (e) {
+ setTimeout(doScrollCheck, 1);
+ return;
+ }
+ dom_onReady();
+ };
+ doScrollCheck();
}
- obj = obj[ii[i]];
}
- }
- if (!obj || !obj.easyXDM) {
- throw new Error('Could not find easyXDM in parent.' + namespace);
- }
- return obj.easyXDM;
-}
-/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
- */
-function noConflict(ns){
- if (typeof ns != "string" || !ns) {
- throw new Error('namespace must be a non-empty string');
+ // A fallback to window.onload, that will always work
+ on(window, "load", dom_onReady);
}
- _trace("Settings namespace to '" + ns + "'");
-
- window.easyXDM = _easyXDM;
- namespace = ns;
- if (namespace) {
- IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {Object} scope An optional scope for the function to be called with.
+ */
+ function whenReady(fn, scope) {
+ if (domIsReady) {
+ fn.call(scope);
+ return;
+ }
+ domReadyQueue.push(function () {
+ fn.call(scope);
+ });
}
- return easyXDM;
-}
-/*
- * Methods for working with URLs
- */
-/**
- * Get the domain name from a url.
- * @param {String} url The url to extract the domain from.
- * @return The domain part of the url.
- * @type {String}
- */
-function getDomainName(url){
- if (!url) {
- throw new Error("url is undefined or empty");
+ /**
+ * Returns an instance of easyXDM from the parent window with
+ * respect to the namespace.
+ *
+ * @return An instance of easyXDM (in the parent window)
+ */
+ function getParentObject() {
+ var obj = parent;
+ if (namespace !== "") {
+ for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
+ if (!obj) {
+ throw new Error(ii.slice(0, i + 1).join('.') + ' is not an object');
+ }
+ obj = obj[ii[i]];
+ }
+ }
+ if (!obj || !obj.easyXDM) {
+ throw new Error('Could not find easyXDM in parent.' + namespace);
+ }
+ return obj.easyXDM;
}
- return url.match(reURI)[3];
-}
-/**
- * Get the port for a given URL, or "" if none
- * @param {String} url The url to extract the port from.
- * @return The port part of the url.
- * @type {String}
- */
-function getPort(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
- return url.match(reURI)[4] || "";
-}
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ function noConflict(ns) {
+ if (typeof ns != "string" || !ns) {
+ throw new Error('namespace must be a non-empty string');
+ }
+ _trace("Settings namespace to '" + ns + "'");
-/**
- * Returns a string containing the schema, domain and if present the port
- * @param {String} url The url to extract the location from
- * @return {String} The location part of the url
- */
-function getLocation(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
- if (/^file/.test(url)) {
- throw new Error("The file:// protocol is not supported");
- }
- var m = url.toLowerCase().match(reURI);
- var proto = m[2], domain = m[3], port = m[4] || "";
- if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
- port = "";
+ window.easyXDM = _easyXDM;
+ namespace = ns;
+ if (namespace) {
+ IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
+ }
+ return easyXDM;
}
- return proto + "//" + domain + port;
-}
-/**
- * Resolves a relative url into an absolute one.
- * @param {String} url The path to resolve.
- * @return {String} The resolved url.
- */
-function resolveUrl(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
-
- // replace all // except the one in proto with /
- url = url.replace(reDoubleSlash, "$1/");
-
- // If the url is a valid url we do nothing
- if (!url.match(/^(http||https):\/\//)) {
- // If this is a relative path
- var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
- if (path.substring(path.length - 1) !== "/") {
- path = path.substring(0, path.lastIndexOf("/") + 1);
- }
-
- url = location.protocol + "//" + location.host + path + url;
+ /*
+ * Methods for working with URLs
+ */
+ /**
+ * Get the domain name from a url.
+ * @param {String} url The url to extract the domain from.
+ * @return The domain part of the url.
+ * @type {String}
+ */
+ function getDomainName(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ return url.match(reURI)[3];
}
-
- // reduce all 'xyz/../' to just ''
- while (reParent.test(url)) {
- url = url.replace(reParent, "");
+
+ /**
+ * Get the port for a given URL, or "" if none
+ * @param {String} url The url to extract the port from.
+ * @return The port part of the url.
+ * @type {String}
+ */
+ function getPort(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ return url.match(reURI)[4] || "";
}
-
- _trace("resolved url '" + url + "'");
- return url;
-}
-/**
- * Appends the parameters to the given url.
- * The base url can contain existing query parameters.
- * @param {String} url The base url.
- * @param {Object} parameters The parameters to add.
- * @return {String} A new valid url with the parameters appended.
- */
-function appendQueryParameters(url, parameters){
- if (!parameters) {
- throw new Error("parameters is undefined or null");
+ /**
+ * Returns a string containing the schema, domain and if present the port
+ * @param {String} url The url to extract the location from
+ * @return {String} The location part of the url
+ */
+ function getLocation(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ if (/^file/.test(url)) {
+ throw new Error("The file:// protocol is not supported");
+ }
+ var m = url.toLowerCase().match(reURI);
+ var proto = m[2], domain = m[3], port = m[4] || "";
+ if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
+ port = "";
+ }
+ return proto + "//" + domain + port;
}
-
- var hash = "", indexOf = url.indexOf("#");
- if (indexOf !== -1) {
- hash = url.substring(indexOf);
- url = url.substring(0, indexOf);
+
+ /**
+ * Resolves a relative url into an absolute one.
+ * @param {String} url The path to resolve.
+ * @return {String} The resolved url.
+ */
+ function resolveUrl(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+
+ // replace all // except the one in proto with /
+ url = url.replace(reDoubleSlash, "$1/");
+
+ // If the url is a valid url we do nothing
+ if (!url.match(/^(http||https):\/\//)) {
+ // If this is a relative path
+ var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
+ if (path.substring(path.length - 1) !== "/") {
+ path = path.substring(0, path.lastIndexOf("/") + 1);
+ }
+
+ url = location.protocol + "//" + location.host + path + url;
+ }
+
+ // reduce all 'xyz/../' to just ''
+ while (reParent.test(url)) {
+ url = url.replace(reParent, "");
+ }
+
+ _trace("resolved url '" + url + "'");
+ return url;
}
- var q = [];
- for (var key in parameters) {
- if (parameters.hasOwnProperty(key)) {
- q.push(key + "=" + encodeURIComponent(parameters[key]));
+
+ /**
+ * Appends the parameters to the given url.
+ * The base url can contain existing query parameters.
+ * @param {String} url The base url.
+ * @param {Object} parameters The parameters to add.
+ * @return {String} A new valid url with the parameters appended.
+ */
+ function appendQueryParameters(url, parameters) {
+ if (!parameters) {
+ throw new Error("parameters is undefined or null");
+ }
+
+ var hash = "", indexOf = url.indexOf("#");
+ if (indexOf !== -1) {
+ hash = url.substring(indexOf);
+ url = url.substring(0, indexOf);
+ }
+ var q = [];
+ for (var key in parameters) {
+ if (parameters.hasOwnProperty(key)) {
+ q.push(key + "=" + encodeURIComponent(parameters[key]));
+ }
}
+ return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
}
- return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
-}
// build the query object either from location.query, if it contains the xdm_e argument, or from location.hash
-var query = (function(input){
- input = input.substring(1).split("&");
- var data = {}, pair, i = input.length;
- while (i--) {
- pair = input[i].split("=");
- data[pair[0]] = decodeURIComponent(pair[1]);
+ var query = (function (input) {
+ input = input.substring(1).split("&");
+ var data = {}, pair, i = input.length;
+ while (i--) {
+ pair = input[i].split("=");
+ data[pair[0]] = decodeURIComponent(pair[1]);
+ }
+ return data;
+ }(/xdm_e=/.test(location.search) ? location.search : location.hash));
+
+ /*
+ * Helper methods
+ */
+ /**
+ * Helper for checking if a variable/property is undefined
+ * @param {Object} v The variable to test
+ * @return {Boolean} True if the passed variable is undefined
+ */
+ function undef(v) {
+ return typeof v === "undefined";
}
- return data;
-}(/xdm_e=/.test(location.search) ? location.search : location.hash));
-/*
- * Helper methods
- */
-/**
- * Helper for checking if a variable/property is undefined
- * @param {Object} v The variable to test
- * @return {Boolean} True if the passed variable is undefined
- */
-function undef(v){
- return typeof v === "undefined";
-}
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ var getJSON = function () {
+ var cached = {};
+ var obj = {
+ a: [1, 2, 3]
+ }, json = "{\"a\":[1,2,3]}";
-/**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
- */
-var getJSON = function(){
- var cached = {};
- var obj = {
- a: [1, 2, 3]
- }, json = "{\"a\":[1,2,3]}";
-
- if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
- // this is a working JSON instance
- return JSON;
- }
- if (Object.toJSON) {
- if (Object.toJSON(obj).replace((/\s/g), "") === json) {
- // this is a working stringify method
- cached.stringify = Object.toJSON;
+ if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
+ // this is a working JSON instance
+ return JSON;
}
- }
-
- if (typeof String.prototype.evalJSON === "function") {
- obj = json.evalJSON();
- if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
- // this is a working parse method
- cached.parse = function(str){
- return str.evalJSON();
- };
+ if (Object.toJSON) {
+ if (Object.toJSON(obj).replace((/\s/g), "") === json) {
+ // this is a working stringify method
+ cached.stringify = Object.toJSON;
+ }
}
- }
-
- if (cached.stringify && cached.parse) {
- // Only memoize the result if we have valid instance
- getJSON = function(){
+
+ if (typeof String.prototype.evalJSON === "function") {
+ obj = json.evalJSON();
+ if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
+ // this is a working parse method
+ cached.parse = function (str) {
+ return str.evalJSON();
+ };
+ }
+ }
+
+ if (cached.stringify && cached.parse) {
+ // Only memoize the result if we have valid instance
+ getJSON = function () {
+ return cached;
+ };
return cached;
- };
- return cached;
- }
- return null;
-};
+ }
+ return null;
+ };
-/**
- * Applies properties from the source object to the target object.
- * @param {Object} target The target of the properties.
- * @param {Object} source The source of the properties.
- * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
- */
-function apply(destination, source, noOverwrite){
- var member;
- for (var prop in source) {
- if (source.hasOwnProperty(prop)) {
- if (prop in destination) {
- member = source[prop];
- if (typeof member === "object") {
- apply(destination[prop], member, noOverwrite);
- }
- else if (!noOverwrite) {
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {Object} target The target of the properties.
+ * @param {Object} source The source of the properties.
+ * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ function apply(destination, source, noOverwrite) {
+ var member;
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ if (prop in destination) {
+ member = source[prop];
+ if (typeof member === "object") {
+ apply(destination[prop], member, noOverwrite);
+ }
+ else if (!noOverwrite) {
+ destination[prop] = source[prop];
+ }
+ }
+ else {
destination[prop] = source[prop];
}
}
- else {
- destination[prop] = source[prop];
- }
}
+ return destination;
}
- return destination;
-}
// This tests for the bug in IE where setting the [name] property using javascript causes the value to be redirected into [submitName].
-function testForNamePropertyBug(){
- var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
- input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
- HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
- document.body.removeChild(form);
- _trace("HAS_NAME_PROPERTY_BUG: " + HAS_NAME_PROPERTY_BUG);
-}
-
-/**
- * Creates a frame and appends it to the DOM.
- * @param config {object} This object can have the following properties
- *
- * {object} prop The properties that should be set on the frame. This should include the 'src' property.
- * {object} attr The attributes that should be set on the frame.
- * {DOMElement} container Its parent element (Optional).
- * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
- *
- * @return The frames DOMElement
- * @type DOMElement
- */
-function createFrame(config){
- _trace("creating frame: " + config.props.src);
- if (undef(HAS_NAME_PROPERTY_BUG)) {
- testForNamePropertyBug();
+ function testForNamePropertyBug() {
+ var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
+ input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
+ HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
+ document.body.removeChild(form);
+ _trace("HAS_NAME_PROPERTY_BUG: " + HAS_NAME_PROPERTY_BUG);
}
- var frame;
- // This is to work around the problems in IE6/7 with setting the name property.
- // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
- // This is not required by easyXDM itself, but is to facilitate other use cases
- if (HAS_NAME_PROPERTY_BUG) {
- frame = document.createElement("
");
- }
- else {
- frame = document.createElement("IFRAME");
- frame.name = config.props.name;
- }
-
- frame.id = frame.name = config.props.name;
- delete config.props.name;
-
- if (typeof config.container == "string") {
- config.container = document.getElementById(config.container);
- }
-
- if (!config.container) {
- // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
- apply(frame.style, {
- position: "absolute",
- top: "-2000px",
- // Avoid potential horizontal scrollbar
- left: "0px"
- });
- config.container = document.body;
- }
-
- // HACK: IE cannot have the src attribute set when the frame is appended
- // into the container, so we set it to "javascript:false" as a
- // placeholder for now. If we left the src undefined, it would
- // instead default to "about:blank", which causes SSL mixed-content
- // warnings in IE6 when on an SSL parent page.
- var src = config.props.src;
- config.props.src = "javascript:false";
-
- // transfer properties to the frame
- apply(frame, config.props);
-
- frame.border = frame.frameBorder = 0;
- frame.allowTransparency = true;
- config.container.appendChild(frame);
-
- if (config.onLoad) {
- on(frame, "load", config.onLoad);
- }
-
- // set the frame URL to the proper value (we previously set it to
- // "javascript:false" to work around the IE issue mentioned above)
- if(config.usePost) {
- var form = config.container.appendChild(document.createElement('form')), input;
- form.target = frame.name;
- form.action = src;
- form.method = 'POST';
- if (typeof(config.usePost) === 'object') {
- for (var i in config.usePost) {
- if (config.usePost.hasOwnProperty(i)) {
- if (HAS_NAME_PROPERTY_BUG) {
- input = document.createElement('
');
- } else {
- input = document.createElement("INPUT");
- input.name = i;
+
+ /**
+ * Creates a frame and appends it to the DOM.
+ * @param config {object} This object can have the following properties
+ *
+ * {object} prop The properties that should be set on the frame. This should include the 'src' property.
+ * {object} attr The attributes that should be set on the frame.
+ * {DOMElement} container Its parent element (Optional).
+ * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
+ *
+ * @return The frames DOMElement
+ * @type DOMElement
+ */
+ function createFrame(config) {
+ _trace("creating frame: " + config.props.src);
+ if (undef(HAS_NAME_PROPERTY_BUG)) {
+ testForNamePropertyBug();
+ }
+ var frame;
+ // This is to work around the problems in IE6/7 with setting the name property.
+ // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
+ // This is not required by easyXDM itself, but is to facilitate other use cases
+ if (HAS_NAME_PROPERTY_BUG) {
+ frame = document.createElement("
");
+ }
+ else {
+ frame = document.createElement("IFRAME");
+ frame.name = config.props.name;
+ }
+
+ frame.id = frame.name = config.props.name;
+ delete config.props.name;
+
+ if (typeof config.container == "string") {
+ config.container = document.getElementById(config.container);
+ }
+
+ if (!config.container) {
+ // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
+ apply(frame.style, {
+ position: "absolute",
+ top: "-2000px",
+ // Avoid potential horizontal scrollbar
+ left: "0px"
+ });
+ config.container = document.body;
+ }
+
+ // HACK: IE cannot have the src attribute set when the frame is appended
+ // into the container, so we set it to "javascript:false" as a
+ // placeholder for now. If we left the src undefined, it would
+ // instead default to "about:blank", which causes SSL mixed-content
+ // warnings in IE6 when on an SSL parent page.
+ var src = config.props.src;
+ config.props.src = "javascript:false";
+
+ // transfer properties to the frame
+ apply(frame, config.props);
+
+ frame.border = frame.frameBorder = 0;
+ frame.allowTransparency = true;
+ config.container.appendChild(frame);
+
+ if (config.onLoad) {
+ on(frame, "load", config.onLoad);
+ }
+
+ // set the frame URL to the proper value (we previously set it to
+ // "javascript:false" to work around the IE issue mentioned above)
+ if (config.usePost) {
+ var form = config.container.appendChild(document.createElement('form')), input;
+ form.target = frame.name;
+ form.action = src;
+ form.method = 'POST';
+ if (typeof(config.usePost) === 'object') {
+ for (var i in config.usePost) {
+ if (config.usePost.hasOwnProperty(i)) {
+ if (HAS_NAME_PROPERTY_BUG) {
+ input = document.createElement('
');
+ } else {
+ input = document.createElement("INPUT");
+ input.name = i;
+ }
+ input.value = config.usePost[i];
+ form.appendChild(input);
}
- input.value = config.usePost[i];
- form.appendChild(input);
}
}
+ form.submit();
+ form.parentNode.removeChild(form);
+ } else {
+ frame.src = src;
}
- form.submit();
- form.parentNode.removeChild(form);
- } else {
- frame.src = src;
- }
- config.props.src = src;
-
- return frame;
-}
+ config.props.src = src;
-/**
- * Check whether a domain is allowed using an Access Control List.
- * The ACL can contain * and ? as wildcards, or can be regular expressions.
- * If regular expressions they need to begin with ^ and end with $.
- * @param {Array/String} acl The list of allowed domains
- * @param {String} domain The domain to test.
- * @return {Boolean} True if the domain is allowed, false if not.
- */
-function checkAcl(acl, domain){
- // normalize into an array
- if (typeof acl == "string") {
- acl = [acl];
+ return frame;
}
- var re, i = acl.length;
- while (i--) {
- re = acl[i];
- re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
- if (re.test(domain)) {
- return true;
+
+ /**
+ * Check whether a domain is allowed using an Access Control List.
+ * The ACL can contain * and ? as wildcards, or can be regular expressions.
+ * If regular expressions they need to begin with ^ and end with $.
+ * @param {Array/String} acl The list of allowed domains
+ * @param {String} domain The domain to test.
+ * @return {Boolean} True if the domain is allowed, false if not.
+ */
+ function checkAcl(acl, domain) {
+ // normalize into an array
+ if (typeof acl == "string") {
+ acl = [acl];
+ }
+ var re, i = acl.length;
+ while (i--) {
+ re = acl[i];
+ re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
+ if (re.test(domain)) {
+ return true;
+ }
}
+ return false;
}
- return false;
-}
-/*
- * Functions related to stacks
- */
-/**
- * Prepares an array of stack-elements suitable for the current configuration
- * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
- * @return {Array} An array of stack-elements with the TransportElement at index 0.
- */
-function prepareTransportStack(config){
- var protocol = config.protocol, stackEls;
- config.isHost = config.isHost || undef(query.xdm_p);
- useHash = config.hash || false;
- _trace("preparing transport stack");
-
- if (!config.props) {
- config.props = {};
- }
- if (!config.isHost) {
- _trace("using parameters from query");
- config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
- config.secret = query.xdm_s;
- config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
- ;
- protocol = query.xdm_p;
- if (config.acl && !checkAcl(config.acl, config.remote)) {
- throw new Error("Access denied for " + config.remote);
+ /*
+ * Functions related to stacks
+ */
+ /**
+ * Prepares an array of stack-elements suitable for the current configuration
+ * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
+ * @return {Array} An array of stack-elements with the TransportElement at index 0.
+ */
+ function prepareTransportStack(config) {
+ var protocol = config.protocol, stackEls;
+ config.isHost = config.isHost || undef(query.xdm_p);
+ useHash = config.hash || false;
+ _trace("preparing transport stack");
+
+ if (!config.props) {
+ config.props = {};
}
- }
- else {
- config.remote = resolveUrl(config.remote);
- config.channel = config.channel || "default" + channelId++;
- config.secret = Math.random().toString(16).substring(2);
- if (undef(protocol)) {
- if (getLocation(location.href) == getLocation(config.remote)) {
- /*
- * Both documents has the same origin, lets use direct access.
- */
- protocol = "4";
- }
- else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
- /*
- * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
- */
- protocol = "1";
- }
- else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
- /*
- * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
- */
- protocol = "6";
- }
- else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
- /*
- * This is supported in Gecko (Firefox 1+)
- */
- protocol = "5";
+ if (!config.isHost) {
+ _trace("using parameters from query");
+ config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
+ config.secret = query.xdm_s;
+ config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
+ ;
+ protocol = query.xdm_p;
+ if (config.acl && !checkAcl(config.acl, config.remote)) {
+ throw new Error("Access denied for " + config.remote);
}
- else if (config.remoteHelper) {
- /*
- * This is supported in all browsers that retains the value of window.name when
- * navigating from one domain to another, and where parent.frames[foo] can be used
- * to get access to a frame from the same domain
- */
- protocol = "2";
+ }
+ else {
+ config.remote = resolveUrl(config.remote);
+ config.channel = config.channel || "default" + channelId++;
+ config.secret = Math.random().toString(16).substring(2);
+ if (undef(protocol)) {
+ if (getLocation(location.href) == getLocation(config.remote)) {
+ /*
+ * Both documents has the same origin, lets use direct access.
+ */
+ protocol = "4";
+ }
+ else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
+ /*
+ * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
+ */
+ protocol = "1";
+ }
+ else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
+ /*
+ * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
+ */
+ protocol = "6";
+ }
+ else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
+ /*
+ * This is supported in Gecko (Firefox 1+)
+ */
+ protocol = "5";
+ }
+ else if (config.remoteHelper) {
+ /*
+ * This is supported in all browsers that retains the value of window.name when
+ * navigating from one domain to another, and where parent.frames[foo] can be used
+ * to get access to a frame from the same domain
+ */
+ protocol = "2";
+ }
+ else {
+ /*
+ * This is supported in all browsers where [window].location is writable for all
+ * The resize event will be used if resize is supported and the iframe is not put
+ * into a container, else polling will be used.
+ */
+ protocol = "0";
+ }
+ _trace("selecting protocol: " + protocol);
}
else {
- /*
- * This is supported in all browsers where [window].location is writable for all
- * The resize event will be used if resize is supported and the iframe is not put
- * into a container, else polling will be used.
- */
- protocol = "0";
+ _trace("using protocol: " + protocol);
}
- _trace("selecting protocol: " + protocol);
- }
- else {
- _trace("using protocol: " + protocol);
}
- }
- config.protocol = protocol; // for conditional branching
- switch (protocol) {
- case "0":// 0 = HashTransport
- apply(config, {
- interval: 100,
- delay: 2000,
- useResize: true,
- useParent: false,
- usePolling: false
- }, true);
- if (config.isHost) {
- if (!config.local) {
- _trace("looking for image to use as local");
- // If no local is set then we need to find an image hosted on the current domain
- var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
- var i = images.length;
- while (i--) {
- image = images[i];
- if (image.src.substring(0, domain.length) === domain) {
- config.local = image.src;
- break;
+ config.protocol = protocol; // for conditional branching
+ switch (protocol) {
+ case "0":// 0 = HashTransport
+ apply(config, {
+ interval: 100,
+ delay: 2000,
+ useResize: true,
+ useParent: false,
+ usePolling: false
+ }, true);
+ if (config.isHost) {
+ if (!config.local) {
+ _trace("looking for image to use as local");
+ // If no local is set then we need to find an image hosted on the current domain
+ var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
+ var i = images.length;
+ while (i--) {
+ image = images[i];
+ if (image.src.substring(0, domain.length) === domain) {
+ config.local = image.src;
+ break;
+ }
+ }
+ if (!config.local) {
+ _trace("no image found, defaulting to using the window");
+ // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
+ config.local = window;
}
}
- if (!config.local) {
- _trace("no image found, defaulting to using the window");
- // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
- config.local = window;
+
+ var parameters = {
+ xdm_c: config.channel,
+ xdm_p: 0
+ };
+
+ if (config.local === window) {
+ // We are using the current window to listen to
+ config.usePolling = true;
+ config.useParent = true;
+ config.local = location.protocol + "//" + location.host + location.pathname + location.search;
+ parameters.xdm_e = config.local;
+ parameters.xdm_pa = 1; // use parent
}
- }
-
- var parameters = {
- xdm_c: config.channel,
- xdm_p: 0
- };
-
- if (config.local === window) {
- // We are using the current window to listen to
- config.usePolling = true;
- config.useParent = true;
- config.local = location.protocol + "//" + location.host + location.pathname + location.search;
- parameters.xdm_e = config.local;
- parameters.xdm_pa = 1; // use parent
+ else {
+ parameters.xdm_e = resolveUrl(config.local);
+ }
+
+ if (config.container) {
+ config.useResize = false;
+ parameters.xdm_po = 1; // use polling
+ }
+ config.remote = appendQueryParameters(config.remote, parameters);
}
else {
- parameters.xdm_e = resolveUrl(config.local);
+ apply(config, {
+ channel: query.xdm_c,
+ remote: query.xdm_e,
+ useParent: !undef(query.xdm_pa),
+ usePolling: !undef(query.xdm_po),
+ useResize: config.useParent ? false : config.useResize
+ });
}
-
- if (config.container) {
- config.useResize = false;
- parameters.xdm_po = 1; // use polling
+ stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
+ encode: true,
+ maxLength: 4000 - config.remote.length
+ }), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "1":
+ stackEls = [new easyXDM.stack.PostMessageTransport(config)];
+ break;
+ case "2":
+ if (config.isHost) {
+ config.remoteHelper = resolveUrl(config.remoteHelper);
}
- config.remote = appendQueryParameters(config.remote, parameters);
- }
- else {
- apply(config, {
- channel: query.xdm_c,
- remote: query.xdm_e,
- useParent: !undef(query.xdm_pa),
- usePolling: !undef(query.xdm_po),
- useResize: config.useParent ? false : config.useResize
- });
+ stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "3":
+ stackEls = [new easyXDM.stack.NixTransport(config)];
+ break;
+ case "4":
+ stackEls = [new easyXDM.stack.SameOriginTransport(config)];
+ break;
+ case "5":
+ stackEls = [new easyXDM.stack.FrameElementTransport(config)];
+ break;
+ case "6":
+ if (!flashVersion) {
+ hasFlash();
+ }
+ stackEls = [new easyXDM.stack.FlashTransport(config)];
+ break;
+ }
+ // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
+ stackEls.push(new easyXDM.stack.QueueBehavior({
+ lazy: config.lazy,
+ remove: true
+ }));
+ return stackEls;
+ }
+
+ /**
+ * Chains all the separate stack elements into a single usable stack.
+ * If an element is missing a necessary method then it will have a pass-through method applied.
+ * @param {Array} stackElements An array of stack elements to be linked.
+ * @return {easyXDM.stack.StackElement} The last element in the chain.
+ */
+ function chainStack(stackElements) {
+ var stackEl, defaults = {
+ incoming: function (message, origin) {
+ this.up.incoming(message, origin);
+ },
+ outgoing: function (message, recipient) {
+ this.down.outgoing(message, recipient);
+ },
+ callback: function (success) {
+ this.up.callback(success);
+ },
+ init: function () {
+ this.down.init();
+ },
+ destroy: function () {
+ this.down.destroy();
}
- stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
- encode: true,
- maxLength: 4000 - config.remote.length
- }), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "1":
- stackEls = [new easyXDM.stack.PostMessageTransport(config)];
- break;
- case "2":
- if (config.isHost) {
- config.remoteHelper = resolveUrl(config.remoteHelper);
+ };
+ for (var i = 0, len = stackElements.length; i < len; i++) {
+ stackEl = stackElements[i];
+ apply(stackEl, defaults, true);
+ if (i !== 0) {
+ stackEl.down = stackElements[i - 1];
}
- stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "3":
- stackEls = [new easyXDM.stack.NixTransport(config)];
- break;
- case "4":
- stackEls = [new easyXDM.stack.SameOriginTransport(config)];
- break;
- case "5":
- stackEls = [new easyXDM.stack.FrameElementTransport(config)];
- break;
- case "6":
- if (!flashVersion) {
- hasFlash();
+ if (i !== len - 1) {
+ stackEl.up = stackElements[i + 1];
}
- stackEls = [new easyXDM.stack.FlashTransport(config)];
- break;
- }
- // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
- stackEls.push(new easyXDM.stack.QueueBehavior({
- lazy: config.lazy,
- remove: true
- }));
- return stackEls;
-}
-
-/**
- * Chains all the separate stack elements into a single usable stack.
- * If an element is missing a necessary method then it will have a pass-through method applied.
- * @param {Array} stackElements An array of stack elements to be linked.
- * @return {easyXDM.stack.StackElement} The last element in the chain.
- */
-function chainStack(stackElements){
- var stackEl, defaults = {
- incoming: function(message, origin){
- this.up.incoming(message, origin);
- },
- outgoing: function(message, recipient){
- this.down.outgoing(message, recipient);
- },
- callback: function(success){
- this.up.callback(success);
- },
- init: function(){
- this.down.init();
- },
- destroy: function(){
- this.down.destroy();
- }
- };
- for (var i = 0, len = stackElements.length; i < len; i++) {
- stackEl = stackElements[i];
- apply(stackEl, defaults, true);
- if (i !== 0) {
- stackEl.down = stackElements[i - 1];
- }
- if (i !== len - 1) {
- stackEl.up = stackElements[i + 1];
}
+ return stackEl;
}
- return stackEl;
-}
-/**
- * This will remove a stackelement from its stack while leaving the stack functional.
- * @param {Object} element The elment to remove from the stack.
- */
-function removeFromStack(element){
- element.up.down = element.down;
- element.down.up = element.up;
- element.up = element.down = null;
-}
-
-/*
- * Export the main object and any other methods applicable
- */
-/**
- * @class easyXDM
- * A javascript library providing cross-browser, cross-domain messaging/RPC.
- * @version 2.4.19.3
- * @singleton
- */
-apply(easyXDM, {
/**
- * The version of the library
- * @type {string}
+ * This will remove a stackelement from its stack while leaving the stack functional.
+ * @param {Object} element The elment to remove from the stack.
*/
- version: "2.4.19.3",
- /**
- * This is a map containing all the query parameters passed to the document.
- * All the values has been decoded using decodeURIComponent.
- * @type {object}
- */
- query: query,
- /**
- * @private
- */
- stack: {},
- /**
- * Applies properties from the source object to the target object.
- * @param {object} target The target of the properties.
- * @param {object} source The source of the properties.
- * @param {boolean} noOverwrite Set to True to only set non-existing properties.
- */
- apply: apply,
-
- /**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
- */
- getJSONObject: getJSON,
- /**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {object} scope An optional scope for the function to be called with.
+ function removeFromStack(element) {
+ element.up.down = element.down;
+ element.down.up = element.up;
+ element.up = element.down = null;
+ }
+
+ /*
+ * Export the main object and any other methods applicable
*/
- whenReady: whenReady,
/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
+ * @class easyXDM
+ * A javascript library providing cross-browser, cross-domain messaging/RPC.
+ * @version 2.4.19.3
+ * @singleton
*/
- noConflict: noConflict
-});
+ apply(easyXDM, {
+ /**
+ * The version of the library
+ * @type {string}
+ */
+ version: "2.4.19.3",
+ /**
+ * This is a map containing all the query parameters passed to the document.
+ * All the values has been decoded using decodeURIComponent.
+ * @type {object}
+ */
+ query: query,
+ /**
+ * @private
+ */
+ stack: {},
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {object} target The target of the properties.
+ * @param {object} source The source of the properties.
+ * @param {boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ apply: apply,
+
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ getJSONObject: getJSON,
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {object} scope An optional scope for the function to be called with.
+ */
+ whenReady: whenReady,
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ noConflict: noConflict
+ });
// Expose helper functions so we can test them
-apply(easyXDM, {
- checkAcl: checkAcl,
- getDomainName: getDomainName,
- getLocation: getLocation,
- appendQueryParameters: appendQueryParameters
-});
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
+ apply(easyXDM, {
+ checkAcl: checkAcl,
+ getDomainName: getDomainName,
+ getLocation: getLocation,
+ appendQueryParameters: appendQueryParameters
+ });
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
//
// easyXDM
// http://easyxdm.net/
@@ -913,154 +913,154 @@ apply(easyXDM, {
// THE SOFTWARE.
//
-var debug = {
- _deferred: [],
- flush: function(){
- this.trace("... deferred messages ...");
- for (var i = 0, len = this._deferred.length; i < len; i++) {
- this.trace(this._deferred[i]);
- }
- this._deferred.length = 0;
- this.trace("... end of deferred messages ...");
- },
- getTime: function(){
- var d = new Date(), h = d.getHours() + "", m = d.getMinutes() + "", s = d.getSeconds() + "", ms = d.getMilliseconds() + "", zeros = "000";
- if (h.length == 1) {
- h = "0" + h;
- }
- if (m.length == 1) {
- m = "0" + m;
- }
- if (s.length == 1) {
- s = "0" + s;
- }
- ms = zeros.substring(ms.length) + ms;
- return h + ":" + m + ":" + s + "." + ms;
- },
- /**
- * Logs the message to console.log if available
- * @param {String} msg The message to log
- */
- log: function(msg){
- // Uses memoizing to cache the implementation
- if (!isHostObject(window, "console") || undef(console.log)) {
- /**
- * Sets log to be an empty function since we have no output available
- * @ignore
- */
- this.log = emptyFn;
- }
- else {
- /**
- * Sets log to be a wrapper around console.log
- * @ignore
- * @param {String} msg
- */
- this.log = function(msg){
- console.log(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ": " + msg);
- };
- }
- this.log(msg);
- },
- /**
- * Will try to trace the given message either to a DOMElement with the id "log",
- * or by using console.info.
- * @param {String} msg The message to trace
- */
- trace: function(msg){
- // Uses memoizing to cache the implementation
- if (!domIsReady) {
- if (this._deferred.length === 0) {
- easyXDM.whenReady(debug.flush, debug);
+ var debug = {
+ _deferred: [],
+ flush: function () {
+ this.trace("... deferred messages ...");
+ for (var i = 0, len = this._deferred.length; i < len; i++) {
+ this.trace(this._deferred[i]);
+ }
+ this._deferred.length = 0;
+ this.trace("... end of deferred messages ...");
+ },
+ getTime: function () {
+ var d = new Date(), h = d.getHours() + "", m = d.getMinutes() + "", s = d.getSeconds() + "", ms = d.getMilliseconds() + "", zeros = "000";
+ if (h.length == 1) {
+ h = "0" + h;
}
- this._deferred.push(msg);
- this.log(msg);
- }
- else {
- var el = document.getElementById("log");
- // is there a log element present?
- if (el) {
+ if (m.length == 1) {
+ m = "0" + m;
+ }
+ if (s.length == 1) {
+ s = "0" + s;
+ }
+ ms = zeros.substring(ms.length) + ms;
+ return h + ":" + m + ":" + s + "." + ms;
+ },
+ /**
+ * Logs the message to console.log if available
+ * @param {String} msg The message to log
+ */
+ log: function (msg) {
+ // Uses memoizing to cache the implementation
+ if (!isHostObject(window, "console") || undef(console.log)) {
/**
- * Sets trace to be a function that outputs the messages to the DOMElement with id "log"
+ * Sets log to be an empty function since we have no output available
* @ignore
- * @param {String} msg
*/
- this.trace = function(msg){
- try {
- el.appendChild(document.createElement("div")).appendChild(document.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
- el.scrollTop = el.scrollHeight;
- }
- catch (e) {
- //In case we are unloading
- }
- };
+ this.log = emptyFn;
}
- else if (isHostObject(window, "console") && !undef(console.info)) {
+ else {
/**
- * Sets trace to be a wrapper around console.info
+ * Sets log to be a wrapper around console.log
* @ignore
* @param {String} msg
*/
- this.trace = function(msg){
- console.info(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg);
+ this.log = function (msg) {
+ console.log(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ": " + msg);
};
}
- else {
- /**
- * Create log window
- * @ignore
- */
- var domain = location.host, windowname = domain.replace(/[\-.:]/g, "") + "easyxdm_log", logWin;
- try {
- logWin = window.open("", windowname, "width=800,height=200,status=0,navigation=0,scrollbars=1");
- }
- catch (e) {
+ this.log(msg);
+ },
+ /**
+ * Will try to trace the given message either to a DOMElement with the id "log",
+ * or by using console.info.
+ * @param {String} msg The message to trace
+ */
+ trace: function (msg) {
+ // Uses memoizing to cache the implementation
+ if (!domIsReady) {
+ if (this._deferred.length === 0) {
+ easyXDM.whenReady(debug.flush, debug);
}
- if (logWin) {
- var doc = logWin.document;
- el = doc.getElementById("log");
- if (!el) {
- doc.write("
easyXDM log " + domain + " ");
- doc.write("
");
- doc.close();
- el = doc.getElementById("log");
- }
- this.trace = function(msg){
+ this._deferred.push(msg);
+ this.log(msg);
+ }
+ else {
+ var el = document.getElementById("log");
+ // is there a log element present?
+ if (el) {
+ /**
+ * Sets trace to be a function that outputs the messages to the DOMElement with id "log"
+ * @ignore
+ * @param {String} msg
+ */
+ this.trace = function (msg) {
try {
- el.appendChild(doc.createElement("div")).appendChild(doc.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
+ el.appendChild(document.createElement("div")).appendChild(document.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
el.scrollTop = el.scrollHeight;
- }
+ }
catch (e) {
//In case we are unloading
}
};
- this.trace("---- new logger at " + location.href);
}
-
- if (!el) {
- // We are unable to use any logging
- this.trace = emptyFn;
+ else if (isHostObject(window, "console") && !undef(console.info)) {
+ /**
+ * Sets trace to be a wrapper around console.info
+ * @ignore
+ * @param {String} msg
+ */
+ this.trace = function (msg) {
+ console.info(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg);
+ };
+ }
+ else {
+ /**
+ * Create log window
+ * @ignore
+ */
+ var domain = location.host, windowname = domain.replace(/[\-.:]/g, "") + "easyxdm_log", logWin;
+ try {
+ logWin = window.open("", windowname, "width=800,height=200,status=0,navigation=0,scrollbars=1");
+ }
+ catch (e) {
+ }
+ if (logWin) {
+ var doc = logWin.document;
+ el = doc.getElementById("log");
+ if (!el) {
+ doc.write("
easyXDM log " + domain + " ");
+ doc.write("
");
+ doc.close();
+ el = doc.getElementById("log");
+ }
+ this.trace = function (msg) {
+ try {
+ el.appendChild(doc.createElement("div")).appendChild(doc.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
+ el.scrollTop = el.scrollHeight;
+ }
+ catch (e) {
+ //In case we are unloading
+ }
+ };
+ this.trace("---- new logger at " + location.href);
+ }
+
+ if (!el) {
+ // We are unable to use any logging
+ this.trace = emptyFn;
+ }
}
+ this.trace(msg);
}
- this.trace(msg);
+ },
+ /**
+ * Creates a method usable for tracing.
+ * @param {String} name The name the messages should be marked with
+ * @return {Function} A function that accepts a single string as argument.
+ */
+ getTracer: function (name) {
+ return function (msg) {
+ debug.trace(name + ": " + msg);
+ };
}
- },
- /**
- * Creates a method usable for tracing.
- * @param {String} name The name the messages should be marked with
- * @return {Function} A function that accepts a single string as argument.
- */
- getTracer: function(name){
- return function(msg){
- debug.trace(name + ": " + msg);
- };
- }
-};
-debug.log("easyXDM present on '" + location.href);
-easyXDM.Debug = debug;
-_trace = debug.getTracer("{Private}");
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
+ };
+ debug.log("easyXDM present on '" + location.href);
+ easyXDM.Debug = debug;
+ _trace = debug.getTracer("{Private}");
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1085,47 +1085,47 @@ _trace = debug.getTracer("{Private}");
// THE SOFTWARE.
//
-/**
- * @class easyXDM.DomHelper
- * Contains methods for dealing with the DOM
- * @singleton
- */
-easyXDM.DomHelper = {
- /**
- * Provides a consistent interface for adding eventhandlers
- * @param {Object} target The target to add the event to
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- on: on,
- /**
- * Provides a consistent interface for removing eventhandlers
- * @param {Object} target The target to remove the event from
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- un: un,
/**
- * Checks for the presence of the JSON object.
- * If it is not present it will use the supplied path to load the JSON2 library.
- * This should be called in the documents head right after the easyXDM script tag.
- * http://json.org/json2.js
- * @param {String} path A valid path to json2.js
+ * @class easyXDM.DomHelper
+ * Contains methods for dealing with the DOM
+ * @singleton
*/
- requiresJSON: function(path){
- if (!isHostObject(window, "JSON")) {
- debug.log("loading external JSON");
- // we need to encode the < in order to avoid an illegal token error
- // when the script is inlined in a document.
- document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
- }
- else {
- debug.log("native JSON found");
+ easyXDM.DomHelper = {
+ /**
+ * Provides a consistent interface for adding eventhandlers
+ * @param {Object} target The target to add the event to
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ on: on,
+ /**
+ * Provides a consistent interface for removing eventhandlers
+ * @param {Object} target The target to remove the event from
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ un: un,
+ /**
+ * Checks for the presence of the JSON object.
+ * If it is not present it will use the supplied path to load the JSON2 library.
+ * This should be called in the documents head right after the easyXDM script tag.
+ * http://json.org/json2.js
+ * @param {String} path A valid path to json2.js
+ */
+ requiresJSON: function (path) {
+ if (!isHostObject(window, "JSON")) {
+ debug.log("loading external JSON");
+ // we need to encode the < in order to avoid an illegal token error
+ // when the script is inlined in a document.
+ document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
+ }
+ else {
+ debug.log("native JSON found");
+ }
}
- }
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1150,55 +1150,55 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-(function(){
- // The map containing the stored functions
- var _map = {};
-
- /**
- * @class easyXDM.Fn
- * This contains methods related to function handling, such as storing callbacks.
- * @singleton
- * @namespace easyXDM
- */
- easyXDM.Fn = {
- /**
- * Stores a function using the given name for reference
- * @param {String} name The name that the function should be referred by
- * @param {Function} fn The function to store
- * @namespace easyXDM.fn
- */
- set: function(name, fn){
- this._trace("storing function " + name);
- _map[name] = fn;
- },
+ (function () {
+ // The map containing the stored functions
+ var _map = {};
+
/**
- * Retrieves the function referred to by the given name
- * @param {String} name The name of the function to retrieve
- * @param {Boolean} del If the function should be deleted after retrieval
- * @return {Function} The stored function
- * @namespace easyXDM.fn
+ * @class easyXDM.Fn
+ * This contains methods related to function handling, such as storing callbacks.
+ * @singleton
+ * @namespace easyXDM
*/
- get: function(name, del){
- this._trace("retrieving function " + name);
- if (!_map.hasOwnProperty(name)) {
- return;
- }
- var fn = _map[name];
- if (!fn) {
- this._trace(name + " not found");
- }
-
- if (del) {
- delete _map[name];
+ easyXDM.Fn = {
+ /**
+ * Stores a function using the given name for reference
+ * @param {String} name The name that the function should be referred by
+ * @param {Function} fn The function to store
+ * @namespace easyXDM.fn
+ */
+ set: function (name, fn) {
+ this._trace("storing function " + name);
+ _map[name] = fn;
+ },
+ /**
+ * Retrieves the function referred to by the given name
+ * @param {String} name The name of the function to retrieve
+ * @param {Boolean} del If the function should be deleted after retrieval
+ * @return {Function} The stored function
+ * @namespace easyXDM.fn
+ */
+ get: function (name, del) {
+ this._trace("retrieving function " + name);
+ if (!_map.hasOwnProperty(name)) {
+ return;
+ }
+ var fn = _map[name];
+ if (!fn) {
+ this._trace(name + " not found");
+ }
+
+ if (del) {
+ delete _map[name];
+ }
+ return fn;
}
- return fn;
- }
- };
-
- easyXDM.Fn._trace = debug.getTracer("easyXDM.Fn");
-}());
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
+ };
+
+ easyXDM.Fn._trace = debug.getTracer("easyXDM.Fn");
+ }());
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1223,15 +1223,15 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Socket
- * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
- * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
- * Internally different stacks will be used depending on the browsers features and the available parameters.
- *
How to set up
- * Setting up the provider:
- *
- * var socket = new easyXDM.Socket({
+ /**
+ * @class easyXDM.Socket
+ * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
+ * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
+ * Internally different stacks will be used depending on the browsers features and the available parameters.
+ * How to set up
+ * Setting up the provider:
+ *
+ * var socket = new easyXDM.Socket({
* local: "name.html",
* onReady: function(){
* // you need to wait for the onReady callback before using the socket
@@ -1241,10 +1241,10 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * Setting up the consumer:
- *
- * var socket = new easyXDM.Socket({
+ *
+ * Setting up the consumer:
+ *
+ * var socket = new easyXDM.Socket({
* remote: "http://remotedomain/page.html",
* remoteHelper: "http://remotedomain/name.html",
* onReady: function(){
@@ -1255,65 +1255,65 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * If you are unable to upload the name.html file to the consumers domain then remove the remoteHelper property
- * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
- * @namespace easyXDM
- * @constructor
- * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
- * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
- * @cfg {String} remote (Consumer only) The url to the providers document.
- * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
- * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
- * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
- * @cfg {Function} onMessage The method that should handle incoming messages. This method should accept two arguments, the message as a string, and the origin as a string. Optional.
- * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
- * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
- * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
- * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
- * If none of the patterns match an Error will be thrown.
- * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g: {style:{width:"100px", height:"100px"}}.
- * Properties such as 'name' and 'src' will be overrided. Optional.
- */
-easyXDM.Socket = function(config){
- var trace = debug.getTracer("easyXDM.Socket");
- trace("constructor");
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([{
- incoming: function(message, origin){
- config.onMessage(message, origin);
- },
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
- }
- }
- }])), recipient = getLocation(config.remote);
-
- // set the origin
- this.origin = getLocation(config.remote);
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
- };
-
- /**
- * Posts a message to the remote end of the channel
- * @param {String} message The message to send
+ *
+ * If you are unable to upload the
name.html file to the consumers domain then remove the
remoteHelper property
+ * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
+ * @namespace easyXDM
+ * @constructor
+ * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
+ * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
+ * @cfg {String} remote (Consumer only) The url to the providers document.
+ * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
+ * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
+ * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
+ * @cfg {Function} onMessage The method that should handle incoming messages.
This method should accept two arguments, the message as a string, and the origin as a string. Optional.
+ * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
+ * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
+ * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
+ * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
+ * If none of the patterns match an Error will be thrown.
+ * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g:
{style:{width:"100px", height:"100px"}}.
+ * Properties such as 'name' and 'src' will be overrided. Optional.
*/
- this.postMessage = function(message){
- stack.outgoing(message, recipient);
+ easyXDM.Socket = function (config) {
+ var trace = debug.getTracer("easyXDM.Socket");
+ trace("constructor");
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([{
+ incoming: function (message, origin) {
+ config.onMessage(message, origin);
+ },
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
+ }
+ }])), recipient = getLocation(config.remote);
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ /**
+ * Posts a message to the remote end of the channel
+ * @param {String} message The message to send
+ */
+ this.postMessage = function (message) {
+ stack.outgoing(message, recipient);
+ };
+
+ stack.init();
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
//
// easyXDM
// http://easyxdm.net/
@@ -1338,15 +1338,15 @@ easyXDM.Socket = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Rpc
- * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
- * of methods to be called from the remote end.
- * The instantiated object will have methods matching those specified in
config.remote.
- * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
- *
How to set up
- *
- * var rpc = new easyXDM.Rpc({
+ /**
+ * @class easyXDM.Rpc
+ * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
+ * of methods to be called from the remote end.
+ * The instantiated object will have methods matching those specified in config.remote.
+ * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
+ * How to set up
+ *
+ * var rpc = new easyXDM.Rpc({
* // this configuration is equal to that used by the Socket.
* remote: "http://remotedomain/...",
* onReady: function(){
@@ -1357,11 +1357,11 @@ easyXDM.Socket = function(config){
* local: {..},
* remote: {..}
* });
- *
- *
- * Exposing functions (procedures)
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ *
+ * Exposing functions (procedures)
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {
@@ -1376,30 +1376,30 @@ easyXDM.Socket = function(config){
* },
* remote: {...}
* });
- *
-
- * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
- * To send a successfull result back you can use
- *
- * return foo;
- *
- * or
- *
- * success(foo);
- *
- * To return an error you can use
- *
- * throw new Error("foo error");
- *
- * or
- *
- * error("foo error");
- *
- *
- * Defining remotely exposed methods (procedures/notifications)
- * The definition of the remote end is quite similar:
- *
- * var rpc = new easyXDM.Rpc({
+ *
+
+ * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
+ * To send a successfull result back you can use
+ *
+ * return foo;
+ *
+ * or
+ *
+ * success(foo);
+ *
+ * To return an error you can use
+ *
+ * throw new Error("foo error");
+ *
+ * or
+ *
+ * error("foo error");
+ *
+ *
+ * Defining remotely exposed methods (procedures/notifications)
+ * The definition of the remote end is quite similar:
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1407,24 +1407,24 @@ easyXDM.Socket = function(config){
* nameOfMethod: {}
* }
* });
- *
- * To call a remote method use
- *
- * rpc.nameOfMethod("arg1", "arg2", function(value) {
+ *
+ * To call a remote method use
+ *
+ * rpc.nameOfMethod("arg1", "arg2", function(value) {
* alert("success: " + value);
* }, function(message) {
* alert("error: " + message + );
* });
- *
- * Both the success and errror callbacks are optional.
- * When called with no callback a JSON-RPC 2.0 notification will be executed.
- * Be aware that you will not be notified of any errors with this method.
- *
- * Specifying a custom serializer
- * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
- * then you can specify a custom serializer using serializer: foo
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ * Both the success and errror callbacks are optional.
+ * When called with no callback a JSON-RPC 2.0 notification will be executed.
+ * Be aware that you will not be notified of any errors with this method.
+ *
+ * Specifying a custom serializer
+ * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
+ * then you can specify a custom serializer using serializer: foo
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1434,55 +1434,55 @@ easyXDM.Socket = function(config){
* stringify: function(object) {...}
* }
* });
- *
- * If serializer is set then the class will not attempt to use the native implementation.
- * @namespace easyXDM
- * @constructor
- * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
- * @param {Object} jsonRpcConfig The description of the interface to implement.
- */
-easyXDM.Rpc = function(config, jsonRpcConfig){
- var trace = debug.getTracer("easyXDM.Rpc");
- trace("constructor");
-
- // expand shorthand notation
- if (jsonRpcConfig.local) {
- for (var method in jsonRpcConfig.local) {
- if (jsonRpcConfig.local.hasOwnProperty(method)) {
- var member = jsonRpcConfig.local[method];
- if (typeof member === "function") {
- jsonRpcConfig.local[method] = {
- method: member
- };
+ *
+ * If
serializer is set then the class will not attempt to use the native implementation.
+ * @namespace easyXDM
+ * @constructor
+ * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
+ * @param {Object} jsonRpcConfig The description of the interface to implement.
+ */
+ easyXDM.Rpc = function (config, jsonRpcConfig) {
+ var trace = debug.getTracer("easyXDM.Rpc");
+ trace("constructor");
+
+ // expand shorthand notation
+ if (jsonRpcConfig.local) {
+ for (var method in jsonRpcConfig.local) {
+ if (jsonRpcConfig.local.hasOwnProperty(method)) {
+ var member = jsonRpcConfig.local[method];
+ if (typeof member === "function") {
+ jsonRpcConfig.local[method] = {
+ method: member
+ };
+ }
}
}
}
- }
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
}
- }
- }]));
-
- // set the origin
- this.origin = getLocation(config.remote);
-
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
+ }]));
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ stack.init();
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1507,75 +1507,75 @@ easyXDM.Rpc = function(config, jsonRpcConfig){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.SameOriginTransport
- * SameOriginTransport is a transport class that can be used when both domains have the same origin.
- * This can be useful for testing and for when the main application supports both internal and external sources.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.SameOriginTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.SameOriginTransport");
- trace("constructor");
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send(message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: location.protocol + "//" + location.host + location.pathname,
- xdm_c: config.channel,
- xdm_p: 4 // 4 = SameOriginTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- easyXDM.Fn.set(config.channel, function(sendFn){
- send = sendFn;
- setTimeout(function(){
+ /**
+ * @class easyXDM.stack.SameOriginTransport
+ * SameOriginTransport is a transport class that can be used when both domains have the same origin.
+ * This can be useful for testing and for when the main application supports both internal and external sources.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
+ */
+ easyXDM.stack.SameOriginTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.SameOriginTransport");
+ trace("constructor");
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send(message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: location.protocol + "//" + location.host + location.pathname,
+ xdm_c: config.channel,
+ xdm_p: 4 // 4 = SameOriginTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ easyXDM.Fn.set(config.channel, function (sendFn) {
+ send = sendFn;
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
+ });
+ }
+ else {
+ send = getParentObject().Fn.get(config.channel, true)(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
+ setTimeout(function () {
pub.up.callback(true);
}, 0);
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
- };
- });
- }
- else {
- send = getParentObject().Fn.get(config.channel, true)(function(msg){
- pub.up.incoming(msg, targetOrigin);
- });
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
//
// easyXDM
// http://easyxdm.net/
@@ -1600,199 +1600,199 @@ easyXDM.stack.SameOriginTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FlashTransport
- * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- * @cfg {String} secret the pre-shared secret used to secure the communication.
- * @cfg {String} swf The path to the swf file
- * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
- * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
- */
-easyXDM.stack.FlashTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.FlashTransport");
- trace("constructor");
- if (!config.swf) {
- throw new Error("Path to easyxdm.swf is missing");
- }
- var pub, // the public interface
- frame, send, targetOrigin, swf, swfContainer;
-
- function onMessage(message, origin){
- setTimeout(function(){
- trace("received message");
- pub.up.incoming(message, targetOrigin);
- }, 0);
- }
-
/**
- * This method adds the SWF to the DOM and prepares the initialization of the channel
+ * @class easyXDM.stack.FlashTransport
+ * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
+ * @cfg {String} secret the pre-shared secret used to secure the communication.
+ * @cfg {String} swf The path to the swf file
+ * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
+ * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
*/
- function addSwf(domain){
- trace("creating factory with SWF from " + domain);
- // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
- var url = config.swf + "?host=" + config.isHost;
- var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
-
- // prepare the init function that will fire once the swf is ready
- easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function(){
- easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
- var queue = easyXDM.stack.FlashTransport[domain].queue;
- for (var i = 0; i < queue.length; i++) {
- queue[i]();
- }
- queue.length = 0;
- });
-
- if (config.swfContainer) {
- swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
+ easyXDM.stack.FlashTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.FlashTransport");
+ trace("constructor");
+ if (!config.swf) {
+ throw new Error("Path to easyxdm.swf is missing");
}
- else {
- // create the container that will hold the swf
- swfContainer = document.createElement('div');
-
- // http://bugs.adobe.com/jira/browse/FP-4796
- // http://tech.groups.yahoo.com/group/flexcoders/message/162365
- // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
- apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
- height: "20px",
- width: "20px",
- position: "fixed",
- right: 0,
- top: 0
- } : {
- height: "1px",
- width: "1px",
- position: "absolute",
- overflow: "hidden",
- right: 0,
- top: 0
+ var pub, // the public interface
+ frame, send, targetOrigin, swf, swfContainer;
+
+ function onMessage(message, origin) {
+ setTimeout(function () {
+ trace("received message");
+ pub.up.incoming(message, targetOrigin);
+ }, 0);
+ }
+
+ /**
+ * This method adds the SWF to the DOM and prepares the initialization of the channel
+ */
+ function addSwf(domain) {
+ trace("creating factory with SWF from " + domain);
+ // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
+ var url = config.swf + "?host=" + config.isHost;
+ var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
+
+ // prepare the init function that will fire once the swf is ready
+ easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function () {
+ easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
+ var queue = easyXDM.stack.FlashTransport[domain].queue;
+ for (var i = 0; i < queue.length; i++) {
+ queue[i]();
+ }
+ queue.length = 0;
});
- document.body.appendChild(swfContainer);
- }
-
- // create the object/embed
- var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
- + "&proto=" + global.location.protocol
- + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
- + "&port=" + encodeURIComponent(getPort(global.location.href))
- + "&ns=" + encodeURIComponent(namespace);
- flashVars += "&log=true";
- swfContainer.innerHTML = "
" +
- " " +
- " " +
- " " +
- " " +
- " " +
- " ";
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- swf.postMessage(config.channel, message.toString());
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- try {
- swf.destroyChannel(config.channel);
- }
- catch (e) {
+
+ if (config.swfContainer) {
+ swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
}
- swf = null;
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
+ else {
+ // create the container that will hold the swf
+ swfContainer = document.createElement('div');
+
+ // http://bugs.adobe.com/jira/browse/FP-4796
+ // http://tech.groups.yahoo.com/group/flexcoders/message/162365
+ // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
+ apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
+ height: "20px",
+ width: "20px",
+ position: "fixed",
+ right: 0,
+ top: 0
+ } : {
+ height: "1px",
+ width: "1px",
+ position: "absolute",
+ overflow: "hidden",
+ right: 0,
+ top: 0
+ });
+ document.body.appendChild(swfContainer);
}
- },
- onDOMReady: function(){
- trace("init");
-
- targetOrigin = config.remote;
-
- // Prepare the code that will be run after the swf has been intialized
- easyXDM.Fn.set("flash_" + config.channel + "_init", function(){
- setTimeout(function(){
- trace("firing onReady");
- pub.up.callback(true);
+
+ // create the object/embed
+ var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
+ + "&proto=" + global.location.protocol
+ + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
+ + "&port=" + encodeURIComponent(getPort(global.location.href))
+ + "&ns=" + encodeURIComponent(namespace);
+ flashVars += "&log=true";
+ swfContainer.innerHTML = "
" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " ";
+ }
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ swf.postMessage(config.channel, message.toString());
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ try {
+ swf.destroyChannel(config.channel);
+ }
+ catch (e) {
+ }
+ swf = null;
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+
+ targetOrigin = config.remote;
+
+ // Prepare the code that will be run after the swf has been intialized
+ easyXDM.Fn.set("flash_" + config.channel + "_init", function () {
+ setTimeout(function () {
+ trace("firing onReady");
+ pub.up.callback(true);
+ });
});
- });
-
- // set up the omMessage handler
- easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
-
- config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
- var swfdomain = getDomainName(config.swf);
- var fn = function(){
- // set init to true in case the fn was called was invoked from a separate instance
- easyXDM.stack.FlashTransport[swfdomain].init = true;
- swf = easyXDM.stack.FlashTransport[swfdomain].swf;
- // create the channel
- swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
-
- if (config.isHost) {
- // if Flash is going to be throttled and we want to avoid this
- if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
+
+ // set up the omMessage handler
+ easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
+
+ config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
+ var swfdomain = getDomainName(config.swf);
+ var fn = function () {
+ // set init to true in case the fn was called was invoked from a separate instance
+ easyXDM.stack.FlashTransport[swfdomain].init = true;
+ swf = easyXDM.stack.FlashTransport[swfdomain].swf;
+ // create the channel
+ swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
+
+ if (config.isHost) {
+ // if Flash is going to be throttled and we want to avoid this
+ if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
+ apply(config.props, {
+ position: "fixed",
+ right: 0,
+ top: 0,
+ height: "20px",
+ width: "20px"
+ });
+ }
+ // set up the iframe
apply(config.props, {
- position: "fixed",
- right: 0,
- top: 0,
- height: "20px",
- width: "20px"
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 6, // 6 = FlashTransport
+ xdm_s: config.secret
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
});
+ frame = createFrame(config);
}
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 6, // 6 = FlashTransport
- xdm_s: config.secret
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- }
- };
-
- if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
- // if the swf is in place and we are the consumer
- fn();
- }
- else {
- // if the swf does not yet exist
- if (!easyXDM.stack.FlashTransport[swfdomain]) {
- // add the queue to hold the init fn's
- easyXDM.stack.FlashTransport[swfdomain] = {
- queue: [fn]
- };
- addSwf(swfdomain);
+ };
+
+ if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
+ // if the swf is in place and we are the consumer
+ fn();
}
else {
- easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ // if the swf does not yet exist
+ if (!easyXDM.stack.FlashTransport[swfdomain]) {
+ // add the queue to hold the init fn's
+ easyXDM.stack.FlashTransport[swfdomain] = {
+ queue: [fn]
+ };
+ addSwf(swfdomain);
+ }
+ else {
+ easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ }
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1817,124 +1817,124 @@ easyXDM.stack.FlashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.PostMessageTransport
- * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
- *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
- *
https://developer.mozilla.org/en/DOM/window.postMessage
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- */
-easyXDM.stack.PostMessageTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.PostMessageTransport");
- trace("constructor");
- var pub, // the public interface
- frame, // the remote frame, if any
- callerWindow, // the window that we will call with
- targetOrigin; // the domain to communicate with
- /**
- * Resolves the origin from the event object
- * @private
- * @param {Object} event The messageevent
- * @return {String} The scheme, host and port of the origin
- */
- function _getOrigin(event){
- if (event.origin) {
- // This is the HTML5 property
- return getLocation(event.origin);
- }
- if (event.uri) {
- // From earlier implementations
- return getLocation(event.uri);
- }
- if (event.domain) {
- // This is the last option and will fail if the
- // origin is not using the same schema as we are
- return location.protocol + "//" + event.domain;
- }
- throw "Unable to retrieve the origin of the event";
- }
-
/**
- * This is the main implementation for the onMessage event.
- * It checks the validity of the origin and passes the message on if appropriate.
- * @private
- * @param {Object} event The messageevent
+ * @class easyXDM.stack.PostMessageTransport
+ * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
+ *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
+ *
https://developer.mozilla.org/en/DOM/window.postMessage
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
*/
- function _window_onMessage(event){
- var origin = _getOrigin(event);
- trace("received message '" + event.data + "' from " + origin);
- if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
- pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
- }
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
- if (fn) {
- fn();
+ easyXDM.stack.PostMessageTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.PostMessageTransport");
+ trace("constructor");
+ var pub, // the public interface
+ frame, // the remote frame, if any
+ callerWindow, // the window that we will call with
+ targetOrigin; // the domain to communicate with
+ /**
+ * Resolves the origin from the event object
+ * @private
+ * @param {Object} event The messageevent
+ * @return {String} The scheme, host and port of the origin
+ */
+ function _getOrigin(event) {
+ if (event.origin) {
+ // This is the HTML5 property
+ return getLocation(event.origin);
}
- },
- destroy: function(){
- trace("destroy");
- un(window, "message", _window_onMessage);
- if (frame) {
- callerWindow = null;
- frame.parentNode.removeChild(frame);
- frame = null;
+ if (event.uri) {
+ // From earlier implementations
+ return getLocation(event.uri);
}
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
- if (config.isHost) {
- // add the event handler for listening
- var waitForReady = function(event){
- if (event.data == config.channel + "-ready") {
- trace("firing onReady");
- // replace the eventlistener
- callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
- un(window, "message", waitForReady);
- on(window, "message", _window_onMessage);
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- }
- };
- on(window, "message", waitForReady);
-
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 1 // 1 = PostMessage
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
+ if (event.domain) {
+ // This is the last option and will fail if the
+ // origin is not using the same schema as we are
+ return location.protocol + "//" + event.domain;
}
- else {
- // add the event handler for listening
- on(window, "message", _window_onMessage);
- callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
- callerWindow.postMessage(config.channel + "-ready", targetOrigin);
-
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
+ throw "Unable to retrieve the origin of the event";
+ }
+
+ /**
+ * This is the main implementation for the onMessage event.
+ * It checks the validity of the origin and passes the message on if appropriate.
+ * @private
+ * @param {Object} event The messageevent
+ */
+ function _window_onMessage(event) {
+ var origin = _getOrigin(event);
+ trace("received message '" + event.data + "' from " + origin);
+ if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
+ pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ un(window, "message", _window_onMessage);
+ if (frame) {
+ callerWindow = null;
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
+ if (config.isHost) {
+ // add the event handler for listening
+ var waitForReady = function (event) {
+ if (event.data == config.channel + "-ready") {
+ trace("firing onReady");
+ // replace the eventlistener
+ callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
+ un(window, "message", waitForReady);
+ on(window, "message", _window_onMessage);
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ }
+ };
+ on(window, "message", waitForReady);
+
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 1 // 1 = PostMessage
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ }
+ else {
+ // add the event handler for listening
+ on(window, "message", _window_onMessage);
+ callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
+ callerWindow.postMessage(config.channel + "-ready", targetOrigin);
+
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
+ }
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1959,79 +1959,79 @@ easyXDM.stack.PostMessageTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FrameElementTransport
- * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
- * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.FrameElementTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.FrameElementTransport");
- trace("constructor");
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send.call(this, message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 5 // 5 = FrameElementTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- frame.fn = function(sendFn){
- delete frame.fn;
- send = sendFn;
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- // remove the function so that it cannot be used to overwrite the send function later on
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
+ /**
+ * @class easyXDM.stack.FrameElementTransport
+ * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
+ * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
+ */
+ easyXDM.stack.FrameElementTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.FrameElementTransport");
+ trace("constructor");
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send.call(this, message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 5 // 5 = FrameElementTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ frame.fn = function (sendFn) {
+ delete frame.fn;
+ send = sendFn;
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ // remove the function so that it cannot be used to overwrite the send function later on
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
};
- };
- }
- else {
- // This is to mitigate origin-spoofing
- if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
- window.top.location = query.xdm_e;
}
- send = window.frameElement.fn(function(msg){
- pub.up.incoming(msg, targetOrigin);
- });
- pub.up.callback(true);
+ else {
+ // This is to mitigate origin-spoofing
+ if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
+ window.top.location = query.xdm_e;
+ }
+ send = window.frameElement.fn(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
+ pub.up.callback(true);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -2056,139 +2056,139 @@ easyXDM.stack.FrameElementTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.NameTransport
- * NameTransport uses the window.name property to relay data.
- * The
local parameter needs to be set on both the consumer and provider,
- * and the
remoteHelper parameter needs to be set on the consumer.
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
- * @namespace easyXDM.stack
- */
-easyXDM.stack.NameTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.NameTransport");
- trace("constructor");
- if (config.isHost && undef(config.remoteHelper)) {
- trace("missing remoteHelper");
- throw new Error("missing remoteHelper");
- }
-
- var pub; // the public interface
- var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
-
- function _sendMessage(message){
- var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
- trace("sending message " + message);
- trace("navigating to '" + url + "'");
- callerWindow.contentWindow.sendMessage(message, url);
- }
-
- function _onReady(){
- if (isHost) {
- if (++readyCount === 2 || !isHost) {
- pub.up.callback(true);
- }
- }
- else {
- _sendMessage("ready");
- trace("calling onReady");
- pub.up.callback(true);
+ /**
+ * @class easyXDM.stack.NameTransport
+ * NameTransport uses the window.name property to relay data.
+ * The
local parameter needs to be set on both the consumer and provider,
+ * and the
remoteHelper parameter needs to be set on the consumer.
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
+ * @namespace easyXDM.stack
+ */
+ easyXDM.stack.NameTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.NameTransport");
+ trace("constructor");
+ if (config.isHost && undef(config.remoteHelper)) {
+ trace("missing remoteHelper");
+ throw new Error("missing remoteHelper");
}
- }
-
- function _onMessage(message){
- trace("received message " + message);
- pub.up.incoming(message, remoteOrigin);
- }
-
- function _onLoad(){
- if (callback) {
- setTimeout(function(){
- callback(true);
- }, 0);
+
+ var pub; // the public interface
+ var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
+
+ function _sendMessage(message) {
+ var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
+ trace("sending message " + message);
+ trace("navigating to '" + url + "'");
+ callerWindow.contentWindow.sendMessage(message, url);
}
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callback = fn;
- _sendMessage(message);
- },
- destroy: function(){
- trace("destroy");
- callerWindow.parentNode.removeChild(callerWindow);
- callerWindow = null;
- if (isHost) {
- remoteWindow.parentNode.removeChild(remoteWindow);
- remoteWindow = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- isHost = config.isHost;
- readyCount = 0;
- remoteOrigin = getLocation(config.remote);
- config.local = resolveUrl(config.local);
-
+
+ function _onReady() {
if (isHost) {
- // Register the callback
- easyXDM.Fn.set(config.channel, function(message){
- trace("received initial message " + message);
- if (isHost && message === "ready") {
- // Replace the handler
- easyXDM.Fn.set(config.channel, _onMessage);
- _onReady();
- }
- });
-
- // Set up the frame that points to the remote instance
- remoteUrl = appendQueryParameters(config.remote, {
- xdm_e: config.local,
- xdm_c: config.channel,
- xdm_p: 2
- });
- apply(config.props, {
- src: remoteUrl + '#' + config.channel,
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- remoteWindow = createFrame(config);
+ if (++readyCount === 2 || !isHost) {
+ pub.up.callback(true);
+ }
}
else {
- config.remoteHelper = config.remote;
- easyXDM.Fn.set(config.channel, _onMessage);
+ _sendMessage("ready");
+ trace("calling onReady");
+ pub.up.callback(true);
}
-
- // Set up the iframe that will be used for the transport
- var onLoad = function(){
- // Remove the handler
- var w = callerWindow || this;
- un(w, "load", onLoad);
- easyXDM.Fn.set(config.channel + "_load", _onLoad);
- (function test(){
- if (typeof w.contentWindow.sendMessage == "function") {
- _onReady();
- }
- else {
- setTimeout(test, 50);
- }
- }());
- };
-
- callerWindow = createFrame({
- props: {
- src: config.local + "#_4" + config.channel
- },
- onLoad: onLoad
- });
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+
+ function _onMessage(message) {
+ trace("received message " + message);
+ pub.up.incoming(message, remoteOrigin);
+ }
+
+ function _onLoad() {
+ if (callback) {
+ setTimeout(function () {
+ callback(true);
+ }, 0);
+ }
+ }
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callback = fn;
+ _sendMessage(message);
+ },
+ destroy: function () {
+ trace("destroy");
+ callerWindow.parentNode.removeChild(callerWindow);
+ callerWindow = null;
+ if (isHost) {
+ remoteWindow.parentNode.removeChild(remoteWindow);
+ remoteWindow = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ isHost = config.isHost;
+ readyCount = 0;
+ remoteOrigin = getLocation(config.remote);
+ config.local = resolveUrl(config.local);
+
+ if (isHost) {
+ // Register the callback
+ easyXDM.Fn.set(config.channel, function (message) {
+ trace("received initial message " + message);
+ if (isHost && message === "ready") {
+ // Replace the handler
+ easyXDM.Fn.set(config.channel, _onMessage);
+ _onReady();
+ }
+ });
+
+ // Set up the frame that points to the remote instance
+ remoteUrl = appendQueryParameters(config.remote, {
+ xdm_e: config.local,
+ xdm_c: config.channel,
+ xdm_p: 2
+ });
+ apply(config.props, {
+ src: remoteUrl + '#' + config.channel,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ remoteWindow = createFrame(config);
+ }
+ else {
+ config.remoteHelper = config.remote;
+ easyXDM.Fn.set(config.channel, _onMessage);
+ }
+
+ // Set up the iframe that will be used for the transport
+ var onLoad = function () {
+ // Remove the handler
+ var w = callerWindow || this;
+ un(w, "load", onLoad);
+ easyXDM.Fn.set(config.channel + "_load", _onLoad);
+ (function test() {
+ if (typeof w.contentWindow.sendMessage == "function") {
+ _onReady();
+ }
+ else {
+ setTimeout(test, 50);
+ }
+ }());
+ };
+
+ callerWindow = createFrame({
+ props: {
+ src: config.local + "#_4" + config.channel
+ },
+ onLoad: onLoad
+ });
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
+ }
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -2208,150 +2208,150 @@ easyXDM.stack.NameTransport = function(config){
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-
-/**
- * @class easyXDM.stack.HashTransport
- * HashTransport is a transport class that uses the IFrame URL Technique for communication.
- *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
- * @cfg {Number} interval The interval used when polling for messages.
- */
-easyXDM.stack.HashTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.HashTransport");
- trace("constructor");
- var pub;
- var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
- var useParent, _remoteOrigin;
-
- function _sendMessage(message){
- trace("sending message '" + (_msgNr + 1) + " " + message + "' to " + _remoteOrigin);
- if (!_callerWindow) {
- trace("no caller window");
- return;
- }
- var url = config.remote + "#" + (_msgNr++) + "_" + message;
- ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
- }
-
- function _handleHash(hash){
- _lastMsg = hash;
- trace("received message '" + _lastMsg + "' from " + _remoteOrigin);
- pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
- }
-
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
/**
- * Checks location.hash for a new message and relays this to the receiver.
- * @private
+ * @class easyXDM.stack.HashTransport
+ * HashTransport is a transport class that uses the IFrame URL Technique for communication.
+ *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
+ * @cfg {Number} interval The interval used when polling for messages.
*/
- function _pollHash(){
- if (!_listenerWindow) {
- return;
- }
- var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
- if (indexOf != -1) {
- hash = href.substring(indexOf);
+ easyXDM.stack.HashTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.HashTransport");
+ trace("constructor");
+ var pub;
+ var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
+ var useParent, _remoteOrigin;
+
+ function _sendMessage(message) {
+ trace("sending message '" + (_msgNr + 1) + " " + message + "' to " + _remoteOrigin);
+ if (!_callerWindow) {
+ trace("no caller window");
+ return;
+ }
+ var url = config.remote + "#" + (_msgNr++) + "_" + message;
+ ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
}
- if (hash && hash != _lastMsg) {
- trace("poll: new message");
- _handleHash(hash);
+
+ function _handleHash(hash) {
+ _lastMsg = hash;
+ trace("received message '" + _lastMsg + "' from " + _remoteOrigin);
+ pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
}
- }
-
- function _attachListeners(){
- trace("starting polling");
- _timer = setInterval(_pollHash, pollInterval);
- }
-
- return (pub = {
- outgoing: function(message, domain){
- _sendMessage(message);
- },
- destroy: function(){
- window.clearInterval(_timer);
- if (isHost || !useParent) {
- _callerWindow.parentNode.removeChild(_callerWindow);
+
+ /**
+ * Checks location.hash for a new message and relays this to the receiver.
+ * @private
+ */
+ function _pollHash() {
+ if (!_listenerWindow) {
+ return;
}
- _callerWindow = null;
- },
- onDOMReady: function(){
- isHost = config.isHost;
- pollInterval = config.interval;
- _lastMsg = "#" + config.channel;
- _msgNr = 0;
- useParent = config.useParent;
- _remoteOrigin = getLocation(config.remote);
- if (isHost) {
- apply(config.props, {
- src: config.remote,
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- if (useParent) {
- config.onLoad = function(){
- _listenerWindow = window;
- _attachListeners();
- pub.up.callback(true);
- };
+ var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
+ if (indexOf != -1) {
+ hash = href.substring(indexOf);
+ }
+ if (hash && hash != _lastMsg) {
+ trace("poll: new message");
+ _handleHash(hash);
+ }
+ }
+
+ function _attachListeners() {
+ trace("starting polling");
+ _timer = setInterval(_pollHash, pollInterval);
+ }
+
+ return (pub = {
+ outgoing: function (message, domain) {
+ _sendMessage(message);
+ },
+ destroy: function () {
+ window.clearInterval(_timer);
+ if (isHost || !useParent) {
+ _callerWindow.parentNode.removeChild(_callerWindow);
}
- else {
- var tries = 0, max = config.delay / 50;
- (function getRef(){
- if (++tries > max) {
- trace("unable to get reference to _listenerWindow, giving up");
- throw new Error("Unable to reference listenerwindow");
- }
- try {
- _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
- }
- catch (ex) {
- }
- if (_listenerWindow) {
+ _callerWindow = null;
+ },
+ onDOMReady: function () {
+ isHost = config.isHost;
+ pollInterval = config.interval;
+ _lastMsg = "#" + config.channel;
+ _msgNr = 0;
+ useParent = config.useParent;
+ _remoteOrigin = getLocation(config.remote);
+ if (isHost) {
+ apply(config.props, {
+ src: config.remote,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ if (useParent) {
+ config.onLoad = function () {
+ _listenerWindow = window;
_attachListeners();
- trace("got a reference to _listenerWindow");
pub.up.callback(true);
- }
- else {
- setTimeout(getRef, 50);
- }
- }());
- }
- _callerWindow = createFrame(config);
- }
- else {
- _listenerWindow = window;
- _attachListeners();
- if (useParent) {
- _callerWindow = parent;
- pub.up.callback(true);
+ };
+ }
+ else {
+ var tries = 0, max = config.delay / 50;
+ (function getRef() {
+ if (++tries > max) {
+ trace("unable to get reference to _listenerWindow, giving up");
+ throw new Error("Unable to reference listenerwindow");
+ }
+ try {
+ _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
+ }
+ catch (ex) {
+ }
+ if (_listenerWindow) {
+ _attachListeners();
+ trace("got a reference to _listenerWindow");
+ pub.up.callback(true);
+ }
+ else {
+ setTimeout(getRef, 50);
+ }
+ }());
+ }
+ _callerWindow = createFrame(config);
}
else {
- apply(config, {
- props: {
- src: config.remote + "#" + config.channel + new Date(),
- name: IFRAME_PREFIX + config.channel + "_consumer"
- },
- onLoad: function(){
- pub.up.callback(true);
- }
- });
- _callerWindow = createFrame(config);
+ _listenerWindow = window;
+ _attachListeners();
+ if (useParent) {
+ _callerWindow = parent;
+ pub.up.callback(true);
+ }
+ else {
+ apply(config, {
+ props: {
+ src: config.remote + "#" + config.channel + new Date(),
+ name: IFRAME_PREFIX + config.channel + "_consumer"
+ },
+ onLoad: function () {
+ pub.up.callback(true);
+ }
+ });
+ _callerWindow = createFrame(config);
+ }
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2376,52 +2376,52 @@ easyXDM.stack.HashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.ReliableBehavior
- * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- */
-easyXDM.stack.ReliableBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.ReliableBehavior");
- trace("constructor");
- var pub, // the public interface
- callback; // the callback to execute when we have a confirmed success/failure
- var idOut = 0, idIn = 0, currentMessage = "";
-
- return (pub = {
- incoming: function(message, origin){
- trace("incoming: " + message);
- var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
- message = message.substring(indexOf + 1);
-
- if (ack[0] == idOut) {
- trace("message delivered");
- currentMessage = "";
- if (callback) {
- callback(true);
+ /**
+ * @class easyXDM.stack.ReliableBehavior
+ * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ */
+ easyXDM.stack.ReliableBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.ReliableBehavior");
+ trace("constructor");
+ var pub, // the public interface
+ callback; // the callback to execute when we have a confirmed success/failure
+ var idOut = 0, idIn = 0, currentMessage = "";
+
+ return (pub = {
+ incoming: function (message, origin) {
+ trace("incoming: " + message);
+ var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
+ message = message.substring(indexOf + 1);
+
+ if (ack[0] == idOut) {
+ trace("message delivered");
+ currentMessage = "";
+ if (callback) {
+ callback(true);
+ }
}
- }
- if (message.length > 0) {
- trace("sending ack, and passing on " + message);
- pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
- if (idIn != ack[1]) {
- idIn = ack[1];
- pub.up.incoming(message, origin);
+ if (message.length > 0) {
+ trace("sending ack, and passing on " + message);
+ pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
+ if (idIn != ack[1]) {
+ idIn = ack[1];
+ pub.up.incoming(message, origin);
+ }
}
+
+ },
+ outgoing: function (message, origin, fn) {
+ currentMessage = message;
+ callback = fn;
+ pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
}
-
- },
- outgoing: function(message, origin, fn){
- currentMessage = message;
- callback = fn;
- pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
//
// easyXDM
// http://easyxdm.net/
@@ -2446,132 +2446,133 @@ easyXDM.stack.ReliableBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.QueueBehavior
- * This is a behavior that enables queueing of messages.
- * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
- * This will also fragment/defragment messages so that the outgoing message is never bigger than the
- * set length.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration. Optional.
- * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
- */
-easyXDM.stack.QueueBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.QueueBehavior");
- trace("constructor");
- var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
-
- function dispatch(){
- if (config.remove && queue.length === 0) {
- trace("removing myself from the stack");
- removeFromStack(pub);
- return;
- }
- if (waiting || queue.length === 0 || destroying) {
- return;
- }
- trace("dispatching from queue");
- waiting = true;
- var message = queue.shift();
-
- pub.down.outgoing(message.data, message.origin, function(success){
- waiting = false;
- if (message.callback) {
- setTimeout(function(){
- message.callback(success);
- }, 0);
- }
- dispatch();
- });
- }
- return (pub = {
- init: function(){
- if (undef(config)) {
- config = {};
- }
- if (config.maxLength) {
- maxLength = config.maxLength;
- doFragment = true;
- }
- if (config.lazy) {
- lazy = true;
+ /**
+ * @class easyXDM.stack.QueueBehavior
+ * This is a behavior that enables queueing of messages.
+ * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
+ * This will also fragment/defragment messages so that the outgoing message is never bigger than the
+ * set length.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration. Optional.
+ * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
+ */
+ easyXDM.stack.QueueBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.QueueBehavior");
+ trace("constructor");
+ var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
+
+ function dispatch() {
+ if (config.remove && queue.length === 0) {
+ trace("removing myself from the stack");
+ removeFromStack(pub);
+ return;
}
- else {
- pub.down.init();
+ if (waiting || queue.length === 0 || destroying) {
+ return;
}
- },
- callback: function(success){
- waiting = false;
- var up = pub.up; // in case dispatch calls removeFromStack
- dispatch();
- up.callback(success);
- },
- incoming: function(message, origin){
- if (doFragment) {
- var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
- incoming += message.substring(indexOf + 1);
- if (seq === 0) {
- trace("received the last fragment");
- if (config.encode) {
- incoming = decodeURIComponent(incoming);
+ trace("dispatching from queue");
+ waiting = true;
+ var message = queue.shift();
+
+ pub.down.outgoing(message.data, message.origin, function (success) {
+ waiting = false;
+ if (message.callback) {
+ setTimeout(function () {
+ message.callback(success);
+ }, 0);
+ }
+ dispatch();
+ });
+ }
+
+ return (pub = {
+ init: function () {
+ if (undef(config)) {
+ config = {};
+ }
+ if (config.maxLength) {
+ maxLength = config.maxLength;
+ doFragment = true;
+ }
+ if (config.lazy) {
+ lazy = true;
+ }
+ else {
+ pub.down.init();
+ }
+ },
+ callback: function (success) {
+ waiting = false;
+ var up = pub.up; // in case dispatch calls removeFromStack
+ dispatch();
+ up.callback(success);
+ },
+ incoming: function (message, origin) {
+ if (doFragment) {
+ var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
+ incoming += message.substring(indexOf + 1);
+ if (seq === 0) {
+ trace("received the last fragment");
+ if (config.encode) {
+ incoming = decodeURIComponent(incoming);
+ }
+ pub.up.incoming(incoming, origin);
+ incoming = "";
+ }
+ else {
+ trace("waiting for more fragments, seq=" + message);
}
- pub.up.incoming(incoming, origin);
- incoming = "";
}
else {
- trace("waiting for more fragments, seq=" + message);
+ pub.up.incoming(message, origin);
}
- }
- else {
- pub.up.incoming(message, origin);
- }
- },
- outgoing: function(message, origin, fn){
- if (config.encode) {
- message = encodeURIComponent(message);
- }
- var fragments = [], fragment;
- if (doFragment) {
- // fragment into chunks
- while (message.length !== 0) {
- fragment = message.substring(0, maxLength);
- message = message.substring(fragment.length);
- fragments.push(fragment);
- }
- // enqueue the chunks
- while ((fragment = fragments.shift())) {
- trace("enqueuing");
+ },
+ outgoing: function (message, origin, fn) {
+ if (config.encode) {
+ message = encodeURIComponent(message);
+ }
+ var fragments = [], fragment;
+ if (doFragment) {
+ // fragment into chunks
+ while (message.length !== 0) {
+ fragment = message.substring(0, maxLength);
+ message = message.substring(fragment.length);
+ fragments.push(fragment);
+ }
+ // enqueue the chunks
+ while ((fragment = fragments.shift())) {
+ trace("enqueuing");
+ queue.push({
+ data: fragments.length + "_" + fragment,
+ origin: origin,
+ callback: fragments.length === 0 ? fn : null
+ });
+ }
+ }
+ else {
queue.push({
- data: fragments.length + "_" + fragment,
+ data: message,
origin: origin,
- callback: fragments.length === 0 ? fn : null
+ callback: fn
});
}
+ if (lazy) {
+ pub.down.init();
+ }
+ else {
+ dispatch();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ destroying = true;
+ pub.down.destroy();
}
- else {
- queue.push({
- data: message,
- origin: origin,
- callback: fn
- });
- }
- if (lazy) {
- pub.down.init();
- }
- else {
- dispatch();
- }
- },
- destroy: function(){
- trace("destroy");
- destroying = true;
- pub.down.destroy();
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2596,64 +2597,64 @@ easyXDM.stack.QueueBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.VerifyBehavior
- * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
- * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- * @cfg {Boolean} initiate If the verification should be initiated from this end.
- */
-easyXDM.stack.VerifyBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.VerifyBehavior");
- trace("constructor");
- if (undef(config.initiate)) {
- throw new Error("settings.initiate is not set");
- }
- var pub, mySecret, theirSecret, verified = false;
-
- function startVerification(){
- trace("requesting verification");
- mySecret = Math.random().toString(16).substring(2);
- pub.down.outgoing(mySecret);
- }
-
- return (pub = {
- incoming: function(message, origin){
- var indexOf = message.indexOf("_");
- if (indexOf === -1) {
- if (message === mySecret) {
- trace("verified, calling callback");
- pub.up.callback(true);
+ /**
+ * @class easyXDM.stack.VerifyBehavior
+ * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
+ * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ * @cfg {Boolean} initiate If the verification should be initiated from this end.
+ */
+ easyXDM.stack.VerifyBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.VerifyBehavior");
+ trace("constructor");
+ if (undef(config.initiate)) {
+ throw new Error("settings.initiate is not set");
+ }
+ var pub, mySecret, theirSecret, verified = false;
+
+ function startVerification() {
+ trace("requesting verification");
+ mySecret = Math.random().toString(16).substring(2);
+ pub.down.outgoing(mySecret);
+ }
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var indexOf = message.indexOf("_");
+ if (indexOf === -1) {
+ if (message === mySecret) {
+ trace("verified, calling callback");
+ pub.up.callback(true);
+ }
+ else if (!theirSecret) {
+ trace("returning secret");
+ theirSecret = message;
+ if (!config.initiate) {
+ startVerification();
+ }
+ pub.down.outgoing(message);
+ }
}
- else if (!theirSecret) {
- trace("returning secret");
- theirSecret = message;
- if (!config.initiate) {
- startVerification();
+ else {
+ if (message.substring(0, indexOf) === theirSecret) {
+ pub.up.incoming(message.substring(indexOf + 1), origin);
}
- pub.down.outgoing(message);
}
- }
- else {
- if (message.substring(0, indexOf) === theirSecret) {
- pub.up.incoming(message.substring(indexOf + 1), origin);
+ },
+ outgoing: function (message, origin, fn) {
+ pub.down.outgoing(mySecret + "_" + message, origin, fn);
+ },
+ callback: function (success) {
+ if (config.initiate) {
+ startVerification();
}
}
- },
- outgoing: function(message, origin, fn){
- pub.down.outgoing(mySecret + "_" + message, origin, fn);
- },
- callback: function(success){
- if (config.initiate) {
- startVerification();
- }
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
//
// easyXDM
// http://easyxdm.net/
@@ -2678,202 +2679,202 @@ easyXDM.stack.VerifyBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.RpcBehavior
- * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
- * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} proxy The object to apply the methods to.
- * @param {Object} config The definition of the local and remote interface to implement.
- * @cfg {Object} local The local interface to expose.
- * @cfg {Object} remote The remote methods to expose through the proxy.
- * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
- */
-easyXDM.stack.RpcBehavior = function(proxy, config){
- var trace = debug.getTracer("easyXDM.stack.RpcBehavior");
- var pub, serializer = config.serializer || getJSON();
- var _callbackCounter = 0, _callbacks = {};
-
/**
- * Serializes and sends the message
- * @private
- * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
+ * @class easyXDM.stack.RpcBehavior
+ * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
+ * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} proxy The object to apply the methods to.
+ * @param {Object} config The definition of the local and remote interface to implement.
+ * @cfg {Object} local The local interface to expose.
+ * @cfg {Object} remote The remote methods to expose through the proxy.
+ * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
*/
- function _send(data){
- data.jsonrpc = "2.0";
- pub.down.outgoing(serializer.stringify(data));
- }
-
- /**
- * Creates a method that implements the given definition
- * @private
- * @param {Object} The method configuration
- * @param {String} method The name of the method
- * @return {Function} A stub capable of proxying the requested method call
- */
- function _createMethod(definition, method){
- var slice = Array.prototype.slice;
-
- trace("creating method " + method);
- return function(){
- trace("executing method " + method);
- var l = arguments.length, callback, message = {
- method: method
- };
-
- if (l > 0 && typeof arguments[l - 1] === "function") {
- //with callback, procedure
- if (l > 1 && typeof arguments[l - 2] === "function") {
- // two callbacks, success and error
- callback = {
- success: arguments[l - 2],
- error: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 2);
+ easyXDM.stack.RpcBehavior = function (proxy, config) {
+ var trace = debug.getTracer("easyXDM.stack.RpcBehavior");
+ var pub, serializer = config.serializer || getJSON();
+ var _callbackCounter = 0, _callbacks = {};
+
+ /**
+ * Serializes and sends the message
+ * @private
+ * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
+ */
+ function _send(data) {
+ data.jsonrpc = "2.0";
+ pub.down.outgoing(serializer.stringify(data));
+ }
+
+ /**
+ * Creates a method that implements the given definition
+ * @private
+ * @param {Object} The method configuration
+ * @param {String} method The name of the method
+ * @return {Function} A stub capable of proxying the requested method call
+ */
+ function _createMethod(definition, method) {
+ var slice = Array.prototype.slice;
+
+ trace("creating method " + method);
+ return function () {
+ trace("executing method " + method);
+ var l = arguments.length, callback, message = {
+ method: method
+ };
+
+ if (l > 0 && typeof arguments[l - 1] === "function") {
+ //with callback, procedure
+ if (l > 1 && typeof arguments[l - 2] === "function") {
+ // two callbacks, success and error
+ callback = {
+ success: arguments[l - 2],
+ error: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 2);
+ }
+ else {
+ // single callback, success
+ callback = {
+ success: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 1);
+ }
+ _callbacks["" + (++_callbackCounter)] = callback;
+ message.id = _callbackCounter;
}
else {
- // single callback, success
- callback = {
- success: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 1);
+ // no callbacks, a notification
+ message.params = slice.call(arguments, 0);
}
- _callbacks["" + (++_callbackCounter)] = callback;
- message.id = _callbackCounter;
- }
- else {
- // no callbacks, a notification
- message.params = slice.call(arguments, 0);
- }
- if (definition.namedParams && message.params.length === 1) {
- message.params = message.params[0];
+ if (definition.namedParams && message.params.length === 1) {
+ message.params = message.params[0];
+ }
+ // Send the method request
+ _send(message);
+ };
+ }
+
+ /**
+ * Executes the exposed method
+ * @private
+ * @param {String} method The name of the method
+ * @param {Number} id The callback id to use
+ * @param {Function} method The exposed implementation
+ * @param {Array} params The parameters supplied by the remote end
+ */
+ function _executeMethod(method, id, fn, params) {
+ if (!fn) {
+ trace("requested to execute non-existent procedure " + method);
+ if (id) {
+ _send({
+ id: id,
+ error: {
+ code: -32601,
+ message: "Procedure not found."
+ }
+ });
+ }
+ return;
}
- // Send the method request
- _send(message);
- };
- }
-
- /**
- * Executes the exposed method
- * @private
- * @param {String} method The name of the method
- * @param {Number} id The callback id to use
- * @param {Function} method The exposed implementation
- * @param {Array} params The parameters supplied by the remote end
- */
- function _executeMethod(method, id, fn, params){
- if (!fn) {
- trace("requested to execute non-existent procedure " + method);
+
+ trace("requested to execute procedure " + method);
+ var success, error;
if (id) {
- _send({
- id: id,
- error: {
- code: -32601,
- message: "Procedure not found."
- }
- });
- }
- return;
- }
-
- trace("requested to execute procedure " + method);
- var success, error;
- if (id) {
- success = function(result){
- success = emptyFn;
- _send({
- id: id,
- result: result
- });
- };
- error = function(message, data){
- error = emptyFn;
- var msg = {
- id: id,
- error: {
- code: -32099,
- message: message
+ success = function (result) {
+ success = emptyFn;
+ _send({
+ id: id,
+ result: result
+ });
+ };
+ error = function (message, data) {
+ error = emptyFn;
+ var msg = {
+ id: id,
+ error: {
+ code: -32099,
+ message: message
+ }
+ };
+ if (data) {
+ msg.error.data = data;
}
+ _send(msg);
};
- if (data) {
- msg.error.data = data;
+ }
+ else {
+ success = error = emptyFn;
+ }
+ // Call local method
+ if (!isArray(params)) {
+ params = [params];
+ }
+ try {
+ var result = fn.method.apply(fn.scope, params.concat([success, error]));
+ if (!undef(result)) {
+ success(result);
}
- _send(msg);
- };
- }
- else {
- success = error = emptyFn;
- }
- // Call local method
- if (!isArray(params)) {
- params = [params];
- }
- try {
- var result = fn.method.apply(fn.scope, params.concat([success, error]));
- if (!undef(result)) {
- success(result);
}
- }
- catch (ex1) {
- error(ex1.message);
+ catch (ex1) {
+ error(ex1.message);
+ }
}
- }
-
- return (pub = {
- incoming: function(message, origin){
- var data = serializer.parse(message);
- if (data.method) {
- trace("received request to execute method " + data.method + (data.id ? (" using callback id " + data.id) : ""));
- // A method call from the remote end
- if (config.handle) {
- config.handle(data, _send);
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var data = serializer.parse(message);
+ if (data.method) {
+ trace("received request to execute method " + data.method + (data.id ? (" using callback id " + data.id) : ""));
+ // A method call from the remote end
+ if (config.handle) {
+ config.handle(data, _send);
+ }
+ else {
+ _executeMethod(data.method, data.id, config.local[data.method], data.params);
+ }
}
else {
- _executeMethod(data.method, data.id, config.local[data.method], data.params);
- }
- }
- else {
- trace("received return value destined to callback with id " + data.id);
- // A method response from the other end
- var callback = _callbacks[data.id];
- if (data.error) {
- if (callback.error) {
- callback.error(data.error);
+ trace("received return value destined to callback with id " + data.id);
+ // A method response from the other end
+ var callback = _callbacks[data.id];
+ if (data.error) {
+ if (callback.error) {
+ callback.error(data.error);
+ }
+ else {
+ trace("unhandled error returned.");
+ }
}
- else {
- trace("unhandled error returned.");
+ else if (callback.success) {
+ callback.success(data.result);
}
+ delete _callbacks[data.id];
}
- else if (callback.success) {
- callback.success(data.result);
+ },
+ init: function () {
+ trace("init");
+ if (config.remote) {
+ trace("creating stubs");
+ // Implement the remote sides exposed methods
+ for (var method in config.remote) {
+ if (config.remote.hasOwnProperty(method)) {
+ proxy[method] = _createMethod(config.remote[method], method);
+ }
+ }
}
- delete _callbacks[data.id];
- }
- },
- init: function(){
- trace("init");
- if (config.remote) {
- trace("creating stubs");
- // Implement the remote sides exposed methods
+ pub.down.init();
+ },
+ destroy: function () {
+ trace("destroy");
for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method)) {
- proxy[method] = _createMethod(config.remote[method], method);
+ if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
+ delete proxy[method];
}
}
+ pub.down.destroy();
}
- pub.down.init();
- },
- destroy: function(){
- trace("destroy");
- for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
- delete proxy[method];
- }
- }
- pub.down.destroy();
- }
- });
-};
-global.easyXDM = easyXDM;
+ });
+ };
+ global.easyXDM = easyXDM;
})(window, document, location, window.setTimeout, decodeURIComponent, encodeURIComponent);
diff --git a/sdk/src/third-party/easyXDM/easyXDM.js b/sdk/src/third-party/easyXDM/easyXDM.js
index eb2b5c54..04cc1e90 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.js
@@ -22,8 +22,8 @@
* THE SOFTWARE.
*/
(function (window, document, location, setTimeout, decodeURIComponent, encodeURIComponent) {
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
//
// easyXDM
// http://easyxdm.net/
@@ -48,795 +48,795 @@
// THE SOFTWARE.
//
-var global = this;
-var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
-var emptyFn = Function.prototype;
-var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
-var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
-var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
-var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
-var easyXDM = {};
-var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
-var IFRAME_PREFIX = "easyXDM_";
-var HAS_NAME_PROPERTY_BUG;
-var useHash = false; // whether to use the hash over the query
-var flashVersion; // will be set if using flash
-var HAS_FLASH_THROTTLED_BUG;
+ var global = this;
+ var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
+ var emptyFn = Function.prototype;
+ var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
+ var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
+ var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
+ var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
+ var easyXDM = {};
+ var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
+ var IFRAME_PREFIX = "easyXDM_";
+ var HAS_NAME_PROPERTY_BUG;
+ var useHash = false; // whether to use the hash over the query
+ var flashVersion; // will be set if using flash
+ var HAS_FLASH_THROTTLED_BUG;
// http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
-function isHostMethod(object, property){
- var t = typeof object[property];
- return t == 'function' ||
- (!!(t == 'object' && object[property])) ||
- t == 'unknown';
-}
+ function isHostMethod(object, property) {
+ var t = typeof object[property];
+ return t == 'function' ||
+ (!!(t == 'object' && object[property])) ||
+ t == 'unknown';
+ }
-function isHostObject(object, property){
- return !!(typeof(object[property]) == 'object' && object[property]);
-}
+ function isHostObject(object, property) {
+ return !!(typeof(object[property]) == 'object' && object[property]);
+ }
// end
// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/
-function isArray(o){
- return Object.prototype.toString.call(o) === '[object Array]';
-}
+ function isArray(o) {
+ return Object.prototype.toString.call(o) === '[object Array]';
+ }
// end
-function hasFlash(){
- var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
-
- if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
- // adapted from the swfobject code
- var description = navigator.plugins[name].description;
- if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
- flashVersion = description.match(/\d+/g);
+ function hasFlash() {
+ var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
+
+ if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
+ // adapted from the swfobject code
+ var description = navigator.plugins[name].description;
+ if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
+ flashVersion = description.match(/\d+/g);
+ }
}
- }
- if (!flashVersion) {
- var flash;
- try {
- flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
- flash = null;
- }
- catch (notSupportedException) {
+ if (!flashVersion) {
+ var flash;
+ try {
+ flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
+ flash = null;
+ }
+ catch (notSupportedException) {
+ }
}
+ if (!flashVersion) {
+ return false;
+ }
+ var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
+ HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
+ return true;
}
- if (!flashVersion) {
- return false;
- }
- var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
- HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
- return true;
-}
-/*
- * Cross Browser implementation for adding and removing event listeners.
- */
-var on, un;
-if (isHostMethod(window, "addEventListener")) {
- on = function(target, type, listener){
- target.addEventListener(type, listener, false);
- };
- un = function(target, type, listener){
- target.removeEventListener(type, listener, false);
- };
-}
-else if (isHostMethod(window, "attachEvent")) {
- on = function(object, sEvent, fpNotify){
- object.attachEvent("on" + sEvent, fpNotify);
- };
- un = function(object, sEvent, fpNotify){
- object.detachEvent("on" + sEvent, fpNotify);
- };
-}
-else {
- throw new Error("Browser not supported");
-}
-
-/*
- * Cross Browser implementation of DOMContentLoaded.
- */
-var domIsReady = false, domReadyQueue = [], readyState;
-if ("readyState" in document) {
- // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
- // 'interactive' (HTML5 specs, recent WebKit builds) states.
- // https://bugs.webkit.org/show_bug.cgi?id=45119
- readyState = document.readyState;
- domIsReady = readyState == "complete" || (~ navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
-}
-else {
- // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
- // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
- // We only need a body to add elements to, so the existence of document.body is enough for us.
- domIsReady = !!document.body;
-}
-
-function dom_onReady(){
- if (domIsReady) {
- return;
+ /*
+ * Cross Browser implementation for adding and removing event listeners.
+ */
+ var on, un;
+ if (isHostMethod(window, "addEventListener")) {
+ on = function (target, type, listener) {
+ target.addEventListener(type, listener, false);
+ };
+ un = function (target, type, listener) {
+ target.removeEventListener(type, listener, false);
+ };
+ }
+ else if (isHostMethod(window, "attachEvent")) {
+ on = function (object, sEvent, fpNotify) {
+ object.attachEvent("on" + sEvent, fpNotify);
+ };
+ un = function (object, sEvent, fpNotify) {
+ object.detachEvent("on" + sEvent, fpNotify);
+ };
}
- domIsReady = true;
- for (var i = 0; i < domReadyQueue.length; i++) {
- domReadyQueue[i]();
+ else {
+ throw new Error("Browser not supported");
}
- domReadyQueue.length = 0;
-}
-
-if (!domIsReady) {
- if (isHostMethod(window, "addEventListener")) {
- on(document, "DOMContentLoaded", dom_onReady);
+ /*
+ * Cross Browser implementation of DOMContentLoaded.
+ */
+ var domIsReady = false, domReadyQueue = [], readyState;
+ if ("readyState" in document) {
+ // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
+ // 'interactive' (HTML5 specs, recent WebKit builds) states.
+ // https://bugs.webkit.org/show_bug.cgi?id=45119
+ readyState = document.readyState;
+ domIsReady = readyState == "complete" || (~navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
}
else {
- on(document, "readystatechange", function(){
- if (document.readyState == "complete") {
- dom_onReady();
- }
- });
- if (document.documentElement.doScroll && window === top) {
- var doScrollCheck = function(){
- if (domIsReady) {
- return;
- }
- // http://javascript.nwbox.com/IEContentLoaded/
- try {
- document.documentElement.doScroll("left");
- }
- catch (e) {
- setTimeout(doScrollCheck, 1);
- return;
+ // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
+ // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
+ // We only need a body to add elements to, so the existence of document.body is enough for us.
+ domIsReady = !!document.body;
+ }
+
+ function dom_onReady() {
+ if (domIsReady) {
+ return;
+ }
+ domIsReady = true;
+ for (var i = 0; i < domReadyQueue.length; i++) {
+ domReadyQueue[i]();
+ }
+ domReadyQueue.length = 0;
+ }
+
+
+ if (!domIsReady) {
+ if (isHostMethod(window, "addEventListener")) {
+ on(document, "DOMContentLoaded", dom_onReady);
+ }
+ else {
+ on(document, "readystatechange", function () {
+ if (document.readyState == "complete") {
+ dom_onReady();
}
- dom_onReady();
- };
- doScrollCheck();
+ });
+ if (document.documentElement.doScroll && window === top) {
+ var doScrollCheck = function () {
+ if (domIsReady) {
+ return;
+ }
+ // http://javascript.nwbox.com/IEContentLoaded/
+ try {
+ document.documentElement.doScroll("left");
+ }
+ catch (e) {
+ setTimeout(doScrollCheck, 1);
+ return;
+ }
+ dom_onReady();
+ };
+ doScrollCheck();
+ }
}
+
+ // A fallback to window.onload, that will always work
+ on(window, "load", dom_onReady);
}
-
- // A fallback to window.onload, that will always work
- on(window, "load", dom_onReady);
-}
-/**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {Object} scope An optional scope for the function to be called with.
- */
-function whenReady(fn, scope){
- if (domIsReady) {
- fn.call(scope);
- return;
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {Object} scope An optional scope for the function to be called with.
+ */
+ function whenReady(fn, scope) {
+ if (domIsReady) {
+ fn.call(scope);
+ return;
+ }
+ domReadyQueue.push(function () {
+ fn.call(scope);
+ });
}
- domReadyQueue.push(function(){
- fn.call(scope);
- });
-}
-/**
- * Returns an instance of easyXDM from the parent window with
- * respect to the namespace.
- *
- * @return An instance of easyXDM (in the parent window)
- */
-function getParentObject(){
- var obj = parent;
- if (namespace !== "") {
- for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
- obj = obj[ii[i]];
+ /**
+ * Returns an instance of easyXDM from the parent window with
+ * respect to the namespace.
+ *
+ * @return An instance of easyXDM (in the parent window)
+ */
+ function getParentObject() {
+ var obj = parent;
+ if (namespace !== "") {
+ for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
+ obj = obj[ii[i]];
+ }
}
+ return obj.easyXDM;
}
- return obj.easyXDM;
-}
-/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
- */
-function noConflict(ns){
-
- window.easyXDM = _easyXDM;
- namespace = ns;
- if (namespace) {
- IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
- }
- return easyXDM;
-}
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ function noConflict(ns) {
-/*
- * Methods for working with URLs
- */
-/**
- * Get the domain name from a url.
- * @param {String} url The url to extract the domain from.
- * @return The domain part of the url.
- * @type {String}
- */
-function getDomainName(url){
- return url.match(reURI)[3];
-}
+ window.easyXDM = _easyXDM;
+ namespace = ns;
+ if (namespace) {
+ IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
+ }
+ return easyXDM;
+ }
-/**
- * Get the port for a given URL, or "" if none
- * @param {String} url The url to extract the port from.
- * @return The port part of the url.
- * @type {String}
- */
-function getPort(url){
- return url.match(reURI)[4] || "";
-}
+ /*
+ * Methods for working with URLs
+ */
+ /**
+ * Get the domain name from a url.
+ * @param {String} url The url to extract the domain from.
+ * @return The domain part of the url.
+ * @type {String}
+ */
+ function getDomainName(url) {
+ return url.match(reURI)[3];
+ }
-/**
- * Returns a string containing the schema, domain and if present the port
- * @param {String} url The url to extract the location from
- * @return {String} The location part of the url
- */
-function getLocation(url){
- var m = url.toLowerCase().match(reURI);
- var proto = m[2], domain = m[3], port = m[4] || "";
- if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
- port = "";
+ /**
+ * Get the port for a given URL, or "" if none
+ * @param {String} url The url to extract the port from.
+ * @return The port part of the url.
+ * @type {String}
+ */
+ function getPort(url) {
+ return url.match(reURI)[4] || "";
}
- return proto + "//" + domain + port;
-}
-/**
- * Resolves a relative url into an absolute one.
- * @param {String} url The path to resolve.
- * @return {String} The resolved url.
- */
-function resolveUrl(url){
-
- // replace all // except the one in proto with /
- url = url.replace(reDoubleSlash, "$1/");
-
- // If the url is a valid url we do nothing
- if (!url.match(/^(http||https):\/\//)) {
- // If this is a relative path
- var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
- if (path.substring(path.length - 1) !== "/") {
- path = path.substring(0, path.lastIndexOf("/") + 1);
+ /**
+ * Returns a string containing the schema, domain and if present the port
+ * @param {String} url The url to extract the location from
+ * @return {String} The location part of the url
+ */
+ function getLocation(url) {
+ var m = url.toLowerCase().match(reURI);
+ var proto = m[2], domain = m[3], port = m[4] || "";
+ if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
+ port = "";
}
-
- url = location.protocol + "//" + location.host + path + url;
+ return proto + "//" + domain + port;
}
-
- // reduce all 'xyz/../' to just ''
- while (reParent.test(url)) {
- url = url.replace(reParent, "");
- }
-
- return url;
-}
-/**
- * Appends the parameters to the given url.
- * The base url can contain existing query parameters.
- * @param {String} url The base url.
- * @param {Object} parameters The parameters to add.
- * @return {String} A new valid url with the parameters appended.
- */
-function appendQueryParameters(url, parameters){
-
- var hash = "", indexOf = url.indexOf("#");
- if (indexOf !== -1) {
- hash = url.substring(indexOf);
- url = url.substring(0, indexOf);
+ /**
+ * Resolves a relative url into an absolute one.
+ * @param {String} url The path to resolve.
+ * @return {String} The resolved url.
+ */
+ function resolveUrl(url) {
+
+ // replace all // except the one in proto with /
+ url = url.replace(reDoubleSlash, "$1/");
+
+ // If the url is a valid url we do nothing
+ if (!url.match(/^(http||https):\/\//)) {
+ // If this is a relative path
+ var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
+ if (path.substring(path.length - 1) !== "/") {
+ path = path.substring(0, path.lastIndexOf("/") + 1);
+ }
+
+ url = location.protocol + "//" + location.host + path + url;
+ }
+
+ // reduce all 'xyz/../' to just ''
+ while (reParent.test(url)) {
+ url = url.replace(reParent, "");
+ }
+
+ return url;
}
- var q = [];
- for (var key in parameters) {
- if (parameters.hasOwnProperty(key)) {
- q.push(key + "=" + encodeURIComponent(parameters[key]));
+
+ /**
+ * Appends the parameters to the given url.
+ * The base url can contain existing query parameters.
+ * @param {String} url The base url.
+ * @param {Object} parameters The parameters to add.
+ * @return {String} A new valid url with the parameters appended.
+ */
+ function appendQueryParameters(url, parameters) {
+
+ var hash = "", indexOf = url.indexOf("#");
+ if (indexOf !== -1) {
+ hash = url.substring(indexOf);
+ url = url.substring(0, indexOf);
+ }
+ var q = [];
+ for (var key in parameters) {
+ if (parameters.hasOwnProperty(key)) {
+ q.push(key + "=" + encodeURIComponent(parameters[key]));
+ }
}
+ return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
}
- return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
-}
// build the query object either from location.query, if it contains the xdm_e argument, or from location.hash
-var query = (function(input){
- input = input.substring(1).split("&");
- var data = {}, pair, i = input.length;
- while (i--) {
- pair = input[i].split("=");
- data[pair[0]] = decodeURIComponent(pair[1]);
+ var query = (function (input) {
+ input = input.substring(1).split("&");
+ var data = {}, pair, i = input.length;
+ while (i--) {
+ pair = input[i].split("=");
+ data[pair[0]] = decodeURIComponent(pair[1]);
+ }
+ return data;
+ }(/xdm_e=/.test(location.search) ? location.search : location.hash));
+
+ /*
+ * Helper methods
+ */
+ /**
+ * Helper for checking if a variable/property is undefined
+ * @param {Object} v The variable to test
+ * @return {Boolean} True if the passed variable is undefined
+ */
+ function undef(v) {
+ return typeof v === "undefined";
}
- return data;
-}(/xdm_e=/.test(location.search) ? location.search : location.hash));
-/*
- * Helper methods
- */
-/**
- * Helper for checking if a variable/property is undefined
- * @param {Object} v The variable to test
- * @return {Boolean} True if the passed variable is undefined
- */
-function undef(v){
- return typeof v === "undefined";
-}
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ var getJSON = function () {
+ var cached = {};
+ var obj = {
+ a: [1, 2, 3]
+ }, json = "{\"a\":[1,2,3]}";
-/**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
- */
-var getJSON = function(){
- var cached = {};
- var obj = {
- a: [1, 2, 3]
- }, json = "{\"a\":[1,2,3]}";
-
- if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
- // this is a working JSON instance
- return JSON;
- }
- if (Object.toJSON) {
- if (Object.toJSON(obj).replace((/\s/g), "") === json) {
- // this is a working stringify method
- cached.stringify = Object.toJSON;
+ if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
+ // this is a working JSON instance
+ return JSON;
}
- }
-
- if (typeof String.prototype.evalJSON === "function") {
- obj = json.evalJSON();
- if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
- // this is a working parse method
- cached.parse = function(str){
- return str.evalJSON();
- };
+ if (Object.toJSON) {
+ if (Object.toJSON(obj).replace((/\s/g), "") === json) {
+ // this is a working stringify method
+ cached.stringify = Object.toJSON;
+ }
}
- }
-
- if (cached.stringify && cached.parse) {
- // Only memoize the result if we have valid instance
- getJSON = function(){
+
+ if (typeof String.prototype.evalJSON === "function") {
+ obj = json.evalJSON();
+ if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
+ // this is a working parse method
+ cached.parse = function (str) {
+ return str.evalJSON();
+ };
+ }
+ }
+
+ if (cached.stringify && cached.parse) {
+ // Only memoize the result if we have valid instance
+ getJSON = function () {
+ return cached;
+ };
return cached;
- };
- return cached;
- }
- return null;
-};
+ }
+ return null;
+ };
-/**
- * Applies properties from the source object to the target object.
- * @param {Object} target The target of the properties.
- * @param {Object} source The source of the properties.
- * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
- */
-function apply(destination, source, noOverwrite){
- var member;
- for (var prop in source) {
- if (source.hasOwnProperty(prop)) {
- if (prop in destination) {
- member = source[prop];
- if (typeof member === "object") {
- apply(destination[prop], member, noOverwrite);
- }
- else if (!noOverwrite) {
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {Object} target The target of the properties.
+ * @param {Object} source The source of the properties.
+ * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ function apply(destination, source, noOverwrite) {
+ var member;
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ if (prop in destination) {
+ member = source[prop];
+ if (typeof member === "object") {
+ apply(destination[prop], member, noOverwrite);
+ }
+ else if (!noOverwrite) {
+ destination[prop] = source[prop];
+ }
+ }
+ else {
destination[prop] = source[prop];
}
}
- else {
- destination[prop] = source[prop];
- }
}
+ return destination;
}
- return destination;
-}
// This tests for the bug in IE where setting the [name] property using javascript causes the value to be redirected into [submitName].
-function testForNamePropertyBug(){
- var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
- input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
- HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
- document.body.removeChild(form);
-}
-
-/**
- * Creates a frame and appends it to the DOM.
- * @param config {object} This object can have the following properties
- *
- * {object} prop The properties that should be set on the frame. This should include the 'src' property.
- * {object} attr The attributes that should be set on the frame.
- * {DOMElement} container Its parent element (Optional).
- * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
- *
- * @return The frames DOMElement
- * @type DOMElement
- */
-function createFrame(config){
- if (undef(HAS_NAME_PROPERTY_BUG)) {
- testForNamePropertyBug();
+ function testForNamePropertyBug() {
+ var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
+ input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
+ HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
+ document.body.removeChild(form);
}
- var frame;
- // This is to work around the problems in IE6/7 with setting the name property.
- // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
- // This is not required by easyXDM itself, but is to facilitate other use cases
- if (HAS_NAME_PROPERTY_BUG) {
- frame = document.createElement("
");
- }
- else {
- frame = document.createElement("IFRAME");
- frame.name = config.props.name;
- }
-
- frame.id = frame.name = config.props.name;
- delete config.props.name;
-
- if (typeof config.container == "string") {
- config.container = document.getElementById(config.container);
- }
-
- if (!config.container) {
- // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
- apply(frame.style, {
- position: "absolute",
- top: "-2000px",
- // Avoid potential horizontal scrollbar
- left: "0px"
- });
- config.container = document.body;
- }
-
- // HACK: IE cannot have the src attribute set when the frame is appended
- // into the container, so we set it to "javascript:false" as a
- // placeholder for now. If we left the src undefined, it would
- // instead default to "about:blank", which causes SSL mixed-content
- // warnings in IE6 when on an SSL parent page.
- var src = config.props.src;
- config.props.src = "javascript:false";
-
- // transfer properties to the frame
- apply(frame, config.props);
-
- frame.border = frame.frameBorder = 0;
- frame.allowTransparency = true;
- config.container.appendChild(frame);
-
- if (config.onLoad) {
- on(frame, "load", config.onLoad);
- }
-
- // set the frame URL to the proper value (we previously set it to
- // "javascript:false" to work around the IE issue mentioned above)
- if(config.usePost) {
- var form = config.container.appendChild(document.createElement('form')), input;
- form.target = frame.name;
- form.action = src;
- form.method = 'POST';
- if (typeof(config.usePost) === 'object') {
- for (var i in config.usePost) {
- if (config.usePost.hasOwnProperty(i)) {
- if (HAS_NAME_PROPERTY_BUG) {
- input = document.createElement('
');
- } else {
- input = document.createElement("INPUT");
- input.name = i;
+
+ /**
+ * Creates a frame and appends it to the DOM.
+ * @param config {object} This object can have the following properties
+ *
+ * {object} prop The properties that should be set on the frame. This should include the 'src' property.
+ * {object} attr The attributes that should be set on the frame.
+ * {DOMElement} container Its parent element (Optional).
+ * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
+ *
+ * @return The frames DOMElement
+ * @type DOMElement
+ */
+ function createFrame(config) {
+ if (undef(HAS_NAME_PROPERTY_BUG)) {
+ testForNamePropertyBug();
+ }
+ var frame;
+ // This is to work around the problems in IE6/7 with setting the name property.
+ // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
+ // This is not required by easyXDM itself, but is to facilitate other use cases
+ if (HAS_NAME_PROPERTY_BUG) {
+ frame = document.createElement("
");
+ }
+ else {
+ frame = document.createElement("IFRAME");
+ frame.name = config.props.name;
+ }
+
+ frame.id = frame.name = config.props.name;
+ delete config.props.name;
+
+ if (typeof config.container == "string") {
+ config.container = document.getElementById(config.container);
+ }
+
+ if (!config.container) {
+ // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
+ apply(frame.style, {
+ position: "absolute",
+ top: "-2000px",
+ // Avoid potential horizontal scrollbar
+ left: "0px"
+ });
+ config.container = document.body;
+ }
+
+ // HACK: IE cannot have the src attribute set when the frame is appended
+ // into the container, so we set it to "javascript:false" as a
+ // placeholder for now. If we left the src undefined, it would
+ // instead default to "about:blank", which causes SSL mixed-content
+ // warnings in IE6 when on an SSL parent page.
+ var src = config.props.src;
+ config.props.src = "javascript:false";
+
+ // transfer properties to the frame
+ apply(frame, config.props);
+
+ frame.border = frame.frameBorder = 0;
+ frame.allowTransparency = true;
+ config.container.appendChild(frame);
+
+ if (config.onLoad) {
+ on(frame, "load", config.onLoad);
+ }
+
+ // set the frame URL to the proper value (we previously set it to
+ // "javascript:false" to work around the IE issue mentioned above)
+ if (config.usePost) {
+ var form = config.container.appendChild(document.createElement('form')), input;
+ form.target = frame.name;
+ form.action = src;
+ form.method = 'POST';
+ if (typeof(config.usePost) === 'object') {
+ for (var i in config.usePost) {
+ if (config.usePost.hasOwnProperty(i)) {
+ if (HAS_NAME_PROPERTY_BUG) {
+ input = document.createElement('
');
+ } else {
+ input = document.createElement("INPUT");
+ input.name = i;
+ }
+ input.value = config.usePost[i];
+ form.appendChild(input);
}
- input.value = config.usePost[i];
- form.appendChild(input);
}
}
+ form.submit();
+ form.parentNode.removeChild(form);
+ } else {
+ frame.src = src;
}
- form.submit();
- form.parentNode.removeChild(form);
- } else {
- frame.src = src;
- }
- config.props.src = src;
-
- return frame;
-}
+ config.props.src = src;
-/**
- * Check whether a domain is allowed using an Access Control List.
- * The ACL can contain * and ? as wildcards, or can be regular expressions.
- * If regular expressions they need to begin with ^ and end with $.
- * @param {Array/String} acl The list of allowed domains
- * @param {String} domain The domain to test.
- * @return {Boolean} True if the domain is allowed, false if not.
- */
-function checkAcl(acl, domain){
- // normalize into an array
- if (typeof acl == "string") {
- acl = [acl];
+ return frame;
}
- var re, i = acl.length;
- while (i--) {
- re = acl[i];
- re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
- if (re.test(domain)) {
- return true;
+
+ /**
+ * Check whether a domain is allowed using an Access Control List.
+ * The ACL can contain * and ? as wildcards, or can be regular expressions.
+ * If regular expressions they need to begin with ^ and end with $.
+ * @param {Array/String} acl The list of allowed domains
+ * @param {String} domain The domain to test.
+ * @return {Boolean} True if the domain is allowed, false if not.
+ */
+ function checkAcl(acl, domain) {
+ // normalize into an array
+ if (typeof acl == "string") {
+ acl = [acl];
+ }
+ var re, i = acl.length;
+ while (i--) {
+ re = acl[i];
+ re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
+ if (re.test(domain)) {
+ return true;
+ }
}
+ return false;
}
- return false;
-}
-/*
- * Functions related to stacks
- */
-/**
- * Prepares an array of stack-elements suitable for the current configuration
- * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
- * @return {Array} An array of stack-elements with the TransportElement at index 0.
- */
-function prepareTransportStack(config){
- var protocol = config.protocol, stackEls;
- config.isHost = config.isHost || undef(query.xdm_p);
- useHash = config.hash || false;
-
- if (!config.props) {
- config.props = {};
- }
- if (!config.isHost) {
- config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
- config.secret = query.xdm_s;
- config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
- ;
- protocol = query.xdm_p;
- if (config.acl && !checkAcl(config.acl, config.remote)) {
- throw new Error("Access denied for " + config.remote);
+ /*
+ * Functions related to stacks
+ */
+ /**
+ * Prepares an array of stack-elements suitable for the current configuration
+ * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
+ * @return {Array} An array of stack-elements with the TransportElement at index 0.
+ */
+ function prepareTransportStack(config) {
+ var protocol = config.protocol, stackEls;
+ config.isHost = config.isHost || undef(query.xdm_p);
+ useHash = config.hash || false;
+
+ if (!config.props) {
+ config.props = {};
}
- }
- else {
- config.remote = resolveUrl(config.remote);
- config.channel = config.channel || "default" + channelId++;
- config.secret = Math.random().toString(16).substring(2);
- if (undef(protocol)) {
- if (getLocation(location.href) == getLocation(config.remote)) {
- /*
- * Both documents has the same origin, lets use direct access.
- */
- protocol = "4";
+ if (!config.isHost) {
+ config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
+ config.secret = query.xdm_s;
+ config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
+ ;
+ protocol = query.xdm_p;
+ if (config.acl && !checkAcl(config.acl, config.remote)) {
+ throw new Error("Access denied for " + config.remote);
}
- else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
- /*
- * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
- */
- protocol = "1";
- }
- else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
- /*
- * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
- */
- protocol = "6";
- }
- else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
- /*
- * This is supported in Gecko (Firefox 1+)
- */
- protocol = "5";
- }
- else if (config.remoteHelper) {
- /*
- * This is supported in all browsers that retains the value of window.name when
- * navigating from one domain to another, and where parent.frames[foo] can be used
- * to get access to a frame from the same domain
- */
- protocol = "2";
- }
- else {
- /*
- * This is supported in all browsers where [window].location is writable for all
- * The resize event will be used if resize is supported and the iframe is not put
- * into a container, else polling will be used.
- */
- protocol = "0";
+ }
+ else {
+ config.remote = resolveUrl(config.remote);
+ config.channel = config.channel || "default" + channelId++;
+ config.secret = Math.random().toString(16).substring(2);
+ if (undef(protocol)) {
+ if (getLocation(location.href) == getLocation(config.remote)) {
+ /*
+ * Both documents has the same origin, lets use direct access.
+ */
+ protocol = "4";
+ }
+ else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
+ /*
+ * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
+ */
+ protocol = "1";
+ }
+ else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
+ /*
+ * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
+ */
+ protocol = "6";
+ }
+ else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
+ /*
+ * This is supported in Gecko (Firefox 1+)
+ */
+ protocol = "5";
+ }
+ else if (config.remoteHelper) {
+ /*
+ * This is supported in all browsers that retains the value of window.name when
+ * navigating from one domain to another, and where parent.frames[foo] can be used
+ * to get access to a frame from the same domain
+ */
+ protocol = "2";
+ }
+ else {
+ /*
+ * This is supported in all browsers where [window].location is writable for all
+ * The resize event will be used if resize is supported and the iframe is not put
+ * into a container, else polling will be used.
+ */
+ protocol = "0";
+ }
}
}
- }
- config.protocol = protocol; // for conditional branching
- switch (protocol) {
- case "0":// 0 = HashTransport
- apply(config, {
- interval: 100,
- delay: 2000,
- useResize: true,
- useParent: false,
- usePolling: false
- }, true);
- if (config.isHost) {
- if (!config.local) {
- // If no local is set then we need to find an image hosted on the current domain
- var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
- var i = images.length;
- while (i--) {
- image = images[i];
- if (image.src.substring(0, domain.length) === domain) {
- config.local = image.src;
- break;
+ config.protocol = protocol; // for conditional branching
+ switch (protocol) {
+ case "0":// 0 = HashTransport
+ apply(config, {
+ interval: 100,
+ delay: 2000,
+ useResize: true,
+ useParent: false,
+ usePolling: false
+ }, true);
+ if (config.isHost) {
+ if (!config.local) {
+ // If no local is set then we need to find an image hosted on the current domain
+ var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
+ var i = images.length;
+ while (i--) {
+ image = images[i];
+ if (image.src.substring(0, domain.length) === domain) {
+ config.local = image.src;
+ break;
+ }
+ }
+ if (!config.local) {
+ // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
+ config.local = window;
}
}
- if (!config.local) {
- // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
- config.local = window;
+
+ var parameters = {
+ xdm_c: config.channel,
+ xdm_p: 0
+ };
+
+ if (config.local === window) {
+ // We are using the current window to listen to
+ config.usePolling = true;
+ config.useParent = true;
+ config.local = location.protocol + "//" + location.host + location.pathname + location.search;
+ parameters.xdm_e = config.local;
+ parameters.xdm_pa = 1; // use parent
}
- }
-
- var parameters = {
- xdm_c: config.channel,
- xdm_p: 0
- };
-
- if (config.local === window) {
- // We are using the current window to listen to
- config.usePolling = true;
- config.useParent = true;
- config.local = location.protocol + "//" + location.host + location.pathname + location.search;
- parameters.xdm_e = config.local;
- parameters.xdm_pa = 1; // use parent
+ else {
+ parameters.xdm_e = resolveUrl(config.local);
+ }
+
+ if (config.container) {
+ config.useResize = false;
+ parameters.xdm_po = 1; // use polling
+ }
+ config.remote = appendQueryParameters(config.remote, parameters);
}
else {
- parameters.xdm_e = resolveUrl(config.local);
+ apply(config, {
+ channel: query.xdm_c,
+ remote: query.xdm_e,
+ useParent: !undef(query.xdm_pa),
+ usePolling: !undef(query.xdm_po),
+ useResize: config.useParent ? false : config.useResize
+ });
}
-
- if (config.container) {
- config.useResize = false;
- parameters.xdm_po = 1; // use polling
+ stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
+ encode: true,
+ maxLength: 4000 - config.remote.length
+ }), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "1":
+ stackEls = [new easyXDM.stack.PostMessageTransport(config)];
+ break;
+ case "2":
+ if (config.isHost) {
+ config.remoteHelper = resolveUrl(config.remoteHelper);
}
- config.remote = appendQueryParameters(config.remote, parameters);
- }
- else {
- apply(config, {
- channel: query.xdm_c,
- remote: query.xdm_e,
- useParent: !undef(query.xdm_pa),
- usePolling: !undef(query.xdm_po),
- useResize: config.useParent ? false : config.useResize
- });
+ stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "3":
+ stackEls = [new easyXDM.stack.NixTransport(config)];
+ break;
+ case "4":
+ stackEls = [new easyXDM.stack.SameOriginTransport(config)];
+ break;
+ case "5":
+ stackEls = [new easyXDM.stack.FrameElementTransport(config)];
+ break;
+ case "6":
+ if (!flashVersion) {
+ hasFlash();
+ }
+ stackEls = [new easyXDM.stack.FlashTransport(config)];
+ break;
+ }
+ // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
+ stackEls.push(new easyXDM.stack.QueueBehavior({
+ lazy: config.lazy,
+ remove: true
+ }));
+ return stackEls;
+ }
+
+ /**
+ * Chains all the separate stack elements into a single usable stack.
+ * If an element is missing a necessary method then it will have a pass-through method applied.
+ * @param {Array} stackElements An array of stack elements to be linked.
+ * @return {easyXDM.stack.StackElement} The last element in the chain.
+ */
+ function chainStack(stackElements) {
+ var stackEl, defaults = {
+ incoming: function (message, origin) {
+ this.up.incoming(message, origin);
+ },
+ outgoing: function (message, recipient) {
+ this.down.outgoing(message, recipient);
+ },
+ callback: function (success) {
+ this.up.callback(success);
+ },
+ init: function () {
+ this.down.init();
+ },
+ destroy: function () {
+ this.down.destroy();
}
- stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
- encode: true,
- maxLength: 4000 - config.remote.length
- }), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "1":
- stackEls = [new easyXDM.stack.PostMessageTransport(config)];
- break;
- case "2":
- if (config.isHost) {
- config.remoteHelper = resolveUrl(config.remoteHelper);
+ };
+ for (var i = 0, len = stackElements.length; i < len; i++) {
+ stackEl = stackElements[i];
+ apply(stackEl, defaults, true);
+ if (i !== 0) {
+ stackEl.down = stackElements[i - 1];
}
- stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "3":
- stackEls = [new easyXDM.stack.NixTransport(config)];
- break;
- case "4":
- stackEls = [new easyXDM.stack.SameOriginTransport(config)];
- break;
- case "5":
- stackEls = [new easyXDM.stack.FrameElementTransport(config)];
- break;
- case "6":
- if (!flashVersion) {
- hasFlash();
+ if (i !== len - 1) {
+ stackEl.up = stackElements[i + 1];
}
- stackEls = [new easyXDM.stack.FlashTransport(config)];
- break;
- }
- // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
- stackEls.push(new easyXDM.stack.QueueBehavior({
- lazy: config.lazy,
- remove: true
- }));
- return stackEls;
-}
-
-/**
- * Chains all the separate stack elements into a single usable stack.
- * If an element is missing a necessary method then it will have a pass-through method applied.
- * @param {Array} stackElements An array of stack elements to be linked.
- * @return {easyXDM.stack.StackElement} The last element in the chain.
- */
-function chainStack(stackElements){
- var stackEl, defaults = {
- incoming: function(message, origin){
- this.up.incoming(message, origin);
- },
- outgoing: function(message, recipient){
- this.down.outgoing(message, recipient);
- },
- callback: function(success){
- this.up.callback(success);
- },
- init: function(){
- this.down.init();
- },
- destroy: function(){
- this.down.destroy();
- }
- };
- for (var i = 0, len = stackElements.length; i < len; i++) {
- stackEl = stackElements[i];
- apply(stackEl, defaults, true);
- if (i !== 0) {
- stackEl.down = stackElements[i - 1];
- }
- if (i !== len - 1) {
- stackEl.up = stackElements[i + 1];
}
+ return stackEl;
}
- return stackEl;
-}
-/**
- * This will remove a stackelement from its stack while leaving the stack functional.
- * @param {Object} element The elment to remove from the stack.
- */
-function removeFromStack(element){
- element.up.down = element.down;
- element.down.up = element.up;
- element.up = element.down = null;
-}
-
-/*
- * Export the main object and any other methods applicable
- */
-/**
- * @class easyXDM
- * A javascript library providing cross-browser, cross-domain messaging/RPC.
- * @version 2.4.19.3
- * @singleton
- */
-apply(easyXDM, {
- /**
- * The version of the library
- * @type {string}
- */
- version: "2.4.19.3",
- /**
- * This is a map containing all the query parameters passed to the document.
- * All the values has been decoded using decodeURIComponent.
- * @type {object}
- */
- query: query,
/**
- * @private
+ * This will remove a stackelement from its stack while leaving the stack functional.
+ * @param {Object} element The elment to remove from the stack.
*/
- stack: {},
- /**
- * Applies properties from the source object to the target object.
- * @param {object} target The target of the properties.
- * @param {object} source The source of the properties.
- * @param {boolean} noOverwrite Set to True to only set non-existing properties.
- */
- apply: apply,
-
- /**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
- */
- getJSONObject: getJSON,
- /**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {object} scope An optional scope for the function to be called with.
+ function removeFromStack(element) {
+ element.up.down = element.down;
+ element.down.up = element.up;
+ element.up = element.down = null;
+ }
+
+ /*
+ * Export the main object and any other methods applicable
*/
- whenReady: whenReady,
/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
+ * @class easyXDM
+ * A javascript library providing cross-browser, cross-domain messaging/RPC.
+ * @version 2.4.19.3
+ * @singleton
*/
- noConflict: noConflict
-});
+ apply(easyXDM, {
+ /**
+ * The version of the library
+ * @type {string}
+ */
+ version: "2.4.19.3",
+ /**
+ * This is a map containing all the query parameters passed to the document.
+ * All the values has been decoded using decodeURIComponent.
+ * @type {object}
+ */
+ query: query,
+ /**
+ * @private
+ */
+ stack: {},
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {object} target The target of the properties.
+ * @param {object} source The source of the properties.
+ * @param {boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ apply: apply,
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ getJSONObject: getJSON,
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {object} scope An optional scope for the function to be called with.
+ */
+ whenReady: whenReady,
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ noConflict: noConflict
+ });
+
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
//
// easyXDM
// http://easyxdm.net/
@@ -861,8 +861,8 @@ apply(easyXDM, {
// THE SOFTWARE.
//
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -887,43 +887,43 @@ apply(easyXDM, {
// THE SOFTWARE.
//
-/**
- * @class easyXDM.DomHelper
- * Contains methods for dealing with the DOM
- * @singleton
- */
-easyXDM.DomHelper = {
- /**
- * Provides a consistent interface for adding eventhandlers
- * @param {Object} target The target to add the event to
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- on: on,
- /**
- * Provides a consistent interface for removing eventhandlers
- * @param {Object} target The target to remove the event from
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- un: un,
/**
- * Checks for the presence of the JSON object.
- * If it is not present it will use the supplied path to load the JSON2 library.
- * This should be called in the documents head right after the easyXDM script tag.
- * http://json.org/json2.js
- * @param {String} path A valid path to json2.js
+ * @class easyXDM.DomHelper
+ * Contains methods for dealing with the DOM
+ * @singleton
*/
- requiresJSON: function(path){
- if (!isHostObject(window, "JSON")) {
- // we need to encode the < in order to avoid an illegal token error
- // when the script is inlined in a document.
- document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
+ easyXDM.DomHelper = {
+ /**
+ * Provides a consistent interface for adding eventhandlers
+ * @param {Object} target The target to add the event to
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ on: on,
+ /**
+ * Provides a consistent interface for removing eventhandlers
+ * @param {Object} target The target to remove the event from
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ un: un,
+ /**
+ * Checks for the presence of the JSON object.
+ * If it is not present it will use the supplied path to load the JSON2 library.
+ * This should be called in the documents head right after the easyXDM script tag.
+ * http://json.org/json2.js
+ * @param {String} path A valid path to json2.js
+ */
+ requiresJSON: function (path) {
+ if (!isHostObject(window, "JSON")) {
+ // we need to encode the < in order to avoid an illegal token error
+ // when the script is inlined in a document.
+ document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
+ }
}
- }
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -948,49 +948,49 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-(function(){
- // The map containing the stored functions
- var _map = {};
-
- /**
- * @class easyXDM.Fn
- * This contains methods related to function handling, such as storing callbacks.
- * @singleton
- * @namespace easyXDM
- */
- easyXDM.Fn = {
- /**
- * Stores a function using the given name for reference
- * @param {String} name The name that the function should be referred by
- * @param {Function} fn The function to store
- * @namespace easyXDM.fn
- */
- set: function(name, fn){
- _map[name] = fn;
- },
+ (function () {
+ // The map containing the stored functions
+ var _map = {};
+
/**
- * Retrieves the function referred to by the given name
- * @param {String} name The name of the function to retrieve
- * @param {Boolean} del If the function should be deleted after retrieval
- * @return {Function} The stored function
- * @namespace easyXDM.fn
+ * @class easyXDM.Fn
+ * This contains methods related to function handling, such as storing callbacks.
+ * @singleton
+ * @namespace easyXDM
*/
- get: function(name, del){
- if (!_map.hasOwnProperty(name)) {
- return;
- }
- var fn = _map[name];
-
- if (del) {
- delete _map[name];
+ easyXDM.Fn = {
+ /**
+ * Stores a function using the given name for reference
+ * @param {String} name The name that the function should be referred by
+ * @param {Function} fn The function to store
+ * @namespace easyXDM.fn
+ */
+ set: function (name, fn) {
+ _map[name] = fn;
+ },
+ /**
+ * Retrieves the function referred to by the given name
+ * @param {String} name The name of the function to retrieve
+ * @param {Boolean} del If the function should be deleted after retrieval
+ * @return {Function} The stored function
+ * @namespace easyXDM.fn
+ */
+ get: function (name, del) {
+ if (!_map.hasOwnProperty(name)) {
+ return;
+ }
+ var fn = _map[name];
+
+ if (del) {
+ delete _map[name];
+ }
+ return fn;
}
- return fn;
- }
- };
-
-}());
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
+ };
+
+ }());
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1015,15 +1015,15 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Socket
- * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
- * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
- * Internally different stacks will be used depending on the browsers features and the available parameters.
- *
How to set up
- * Setting up the provider:
- *
- * var socket = new easyXDM.Socket({
+ /**
+ * @class easyXDM.Socket
+ * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
+ * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
+ * Internally different stacks will be used depending on the browsers features and the available parameters.
+ * How to set up
+ * Setting up the provider:
+ *
+ * var socket = new easyXDM.Socket({
* local: "name.html",
* onReady: function(){
* // you need to wait for the onReady callback before using the socket
@@ -1033,10 +1033,10 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * Setting up the consumer:
- *
- * var socket = new easyXDM.Socket({
+ *
+ * Setting up the consumer:
+ *
+ * var socket = new easyXDM.Socket({
* remote: "http://remotedomain/page.html",
* remoteHelper: "http://remotedomain/name.html",
* onReady: function(){
@@ -1047,63 +1047,63 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * If you are unable to upload the name.html file to the consumers domain then remove the remoteHelper property
- * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
- * @namespace easyXDM
- * @constructor
- * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
- * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
- * @cfg {String} remote (Consumer only) The url to the providers document.
- * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
- * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
- * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
- * @cfg {Function} onMessage The method that should handle incoming messages. This method should accept two arguments, the message as a string, and the origin as a string. Optional.
- * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
- * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
- * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
- * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
- * If none of the patterns match an Error will be thrown.
- * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g: {style:{width:"100px", height:"100px"}}.
- * Properties such as 'name' and 'src' will be overrided. Optional.
- */
-easyXDM.Socket = function(config){
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([{
- incoming: function(message, origin){
- config.onMessage(message, origin);
- },
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
- }
- }
- }])), recipient = getLocation(config.remote);
-
- // set the origin
- this.origin = getLocation(config.remote);
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
- };
-
- /**
- * Posts a message to the remote end of the channel
- * @param {String} message The message to send
+ *
+ * If you are unable to upload the
name.html file to the consumers domain then remove the
remoteHelper property
+ * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
+ * @namespace easyXDM
+ * @constructor
+ * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
+ * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
+ * @cfg {String} remote (Consumer only) The url to the providers document.
+ * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
+ * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
+ * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
+ * @cfg {Function} onMessage The method that should handle incoming messages.
This method should accept two arguments, the message as a string, and the origin as a string. Optional.
+ * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
+ * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
+ * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
+ * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
+ * If none of the patterns match an Error will be thrown.
+ * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g:
{style:{width:"100px", height:"100px"}}.
+ * Properties such as 'name' and 'src' will be overrided. Optional.
*/
- this.postMessage = function(message){
- stack.outgoing(message, recipient);
+ easyXDM.Socket = function (config) {
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([{
+ incoming: function (message, origin) {
+ config.onMessage(message, origin);
+ },
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
+ }
+ }])), recipient = getLocation(config.remote);
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ /**
+ * Posts a message to the remote end of the channel
+ * @param {String} message The message to send
+ */
+ this.postMessage = function (message) {
+ stack.outgoing(message, recipient);
+ };
+
+ stack.init();
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
//
// easyXDM
// http://easyxdm.net/
@@ -1128,15 +1128,15 @@ easyXDM.Socket = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Rpc
- * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
- * of methods to be called from the remote end.
- * The instantiated object will have methods matching those specified in
config.remote.
- * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
- *
How to set up
- *
- * var rpc = new easyXDM.Rpc({
+ /**
+ * @class easyXDM.Rpc
+ * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
+ * of methods to be called from the remote end.
+ * The instantiated object will have methods matching those specified in config.remote.
+ * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
+ * How to set up
+ *
+ * var rpc = new easyXDM.Rpc({
* // this configuration is equal to that used by the Socket.
* remote: "http://remotedomain/...",
* onReady: function(){
@@ -1147,11 +1147,11 @@ easyXDM.Socket = function(config){
* local: {..},
* remote: {..}
* });
- *
- *
- * Exposing functions (procedures)
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ *
+ * Exposing functions (procedures)
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {
@@ -1166,30 +1166,30 @@ easyXDM.Socket = function(config){
* },
* remote: {...}
* });
- *
-
- * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
- * To send a successfull result back you can use
- *
- * return foo;
- *
- * or
- *
- * success(foo);
- *
- * To return an error you can use
- *
- * throw new Error("foo error");
- *
- * or
- *
- * error("foo error");
- *
- *
- * Defining remotely exposed methods (procedures/notifications)
- * The definition of the remote end is quite similar:
- *
- * var rpc = new easyXDM.Rpc({
+ *
+
+ * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
+ * To send a successfull result back you can use
+ *
+ * return foo;
+ *
+ * or
+ *
+ * success(foo);
+ *
+ * To return an error you can use
+ *
+ * throw new Error("foo error");
+ *
+ * or
+ *
+ * error("foo error");
+ *
+ *
+ * Defining remotely exposed methods (procedures/notifications)
+ * The definition of the remote end is quite similar:
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1197,24 +1197,24 @@ easyXDM.Socket = function(config){
* nameOfMethod: {}
* }
* });
- *
- * To call a remote method use
- *
- * rpc.nameOfMethod("arg1", "arg2", function(value) {
+ *
+ * To call a remote method use
+ *
+ * rpc.nameOfMethod("arg1", "arg2", function(value) {
* alert("success: " + value);
* }, function(message) {
* alert("error: " + message + );
* });
- *
- * Both the success and errror callbacks are optional.
- * When called with no callback a JSON-RPC 2.0 notification will be executed.
- * Be aware that you will not be notified of any errors with this method.
- *
- * Specifying a custom serializer
- * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
- * then you can specify a custom serializer using serializer: foo
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ * Both the success and errror callbacks are optional.
+ * When called with no callback a JSON-RPC 2.0 notification will be executed.
+ * Be aware that you will not be notified of any errors with this method.
+ *
+ * Specifying a custom serializer
+ * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
+ * then you can specify a custom serializer using serializer: foo
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1224,53 +1224,53 @@ easyXDM.Socket = function(config){
* stringify: function(object) {...}
* }
* });
- *
- * If serializer is set then the class will not attempt to use the native implementation.
- * @namespace easyXDM
- * @constructor
- * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
- * @param {Object} jsonRpcConfig The description of the interface to implement.
- */
-easyXDM.Rpc = function(config, jsonRpcConfig){
-
- // expand shorthand notation
- if (jsonRpcConfig.local) {
- for (var method in jsonRpcConfig.local) {
- if (jsonRpcConfig.local.hasOwnProperty(method)) {
- var member = jsonRpcConfig.local[method];
- if (typeof member === "function") {
- jsonRpcConfig.local[method] = {
- method: member
- };
+ *
+ * If
serializer is set then the class will not attempt to use the native implementation.
+ * @namespace easyXDM
+ * @constructor
+ * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
+ * @param {Object} jsonRpcConfig The description of the interface to implement.
+ */
+ easyXDM.Rpc = function (config, jsonRpcConfig) {
+
+ // expand shorthand notation
+ if (jsonRpcConfig.local) {
+ for (var method in jsonRpcConfig.local) {
+ if (jsonRpcConfig.local.hasOwnProperty(method)) {
+ var member = jsonRpcConfig.local[method];
+ if (typeof member === "function") {
+ jsonRpcConfig.local[method] = {
+ method: member
+ };
+ }
}
}
}
- }
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
}
- }
- }]));
-
- // set the origin
- this.origin = getLocation(config.remote);
-
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
+ }]));
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ stack.init();
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1295,71 +1295,71 @@ easyXDM.Rpc = function(config, jsonRpcConfig){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.SameOriginTransport
- * SameOriginTransport is a transport class that can be used when both domains have the same origin.
- * This can be useful for testing and for when the main application supports both internal and external sources.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.SameOriginTransport = function(config){
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send(message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: location.protocol + "//" + location.host + location.pathname,
- xdm_c: config.channel,
- xdm_p: 4 // 4 = SameOriginTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- easyXDM.Fn.set(config.channel, function(sendFn){
- send = sendFn;
- setTimeout(function(){
+ /**
+ * @class easyXDM.stack.SameOriginTransport
+ * SameOriginTransport is a transport class that can be used when both domains have the same origin.
+ * This can be useful for testing and for when the main application supports both internal and external sources.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
+ */
+ easyXDM.stack.SameOriginTransport = function (config) {
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send(message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: location.protocol + "//" + location.host + location.pathname,
+ xdm_c: config.channel,
+ xdm_p: 4 // 4 = SameOriginTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ easyXDM.Fn.set(config.channel, function (sendFn) {
+ send = sendFn;
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
+ });
+ }
+ else {
+ send = getParentObject().Fn.get(config.channel, true)(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
+ setTimeout(function () {
pub.up.callback(true);
}, 0);
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
- };
- });
- }
- else {
- send = getParentObject().Fn.get(config.channel, true)(function(msg){
- pub.up.incoming(msg, targetOrigin);
- });
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
//
// easyXDM
// http://easyxdm.net/
@@ -1384,188 +1384,188 @@ easyXDM.stack.SameOriginTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FlashTransport
- * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- * @cfg {String} secret the pre-shared secret used to secure the communication.
- * @cfg {String} swf The path to the swf file
- * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
- * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
- */
-easyXDM.stack.FlashTransport = function(config){
- var pub, // the public interface
- frame, send, targetOrigin, swf, swfContainer;
-
- function onMessage(message, origin){
- setTimeout(function(){
- pub.up.incoming(message, targetOrigin);
- }, 0);
- }
-
/**
- * This method adds the SWF to the DOM and prepares the initialization of the channel
+ * @class easyXDM.stack.FlashTransport
+ * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
+ * @cfg {String} secret the pre-shared secret used to secure the communication.
+ * @cfg {String} swf The path to the swf file
+ * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
+ * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
*/
- function addSwf(domain){
- // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
- var url = config.swf + "?host=" + config.isHost;
- var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
-
- // prepare the init function that will fire once the swf is ready
- easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function(){
- easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
- var queue = easyXDM.stack.FlashTransport[domain].queue;
- for (var i = 0; i < queue.length; i++) {
- queue[i]();
- }
- queue.length = 0;
- });
-
- if (config.swfContainer) {
- swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
+ easyXDM.stack.FlashTransport = function (config) {
+ var pub, // the public interface
+ frame, send, targetOrigin, swf, swfContainer;
+
+ function onMessage(message, origin) {
+ setTimeout(function () {
+ pub.up.incoming(message, targetOrigin);
+ }, 0);
}
- else {
- // create the container that will hold the swf
- swfContainer = document.createElement('div');
-
- // http://bugs.adobe.com/jira/browse/FP-4796
- // http://tech.groups.yahoo.com/group/flexcoders/message/162365
- // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
- apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
- height: "20px",
- width: "20px",
- position: "fixed",
- right: 0,
- top: 0
- } : {
- height: "1px",
- width: "1px",
- position: "absolute",
- overflow: "hidden",
- right: 0,
- top: 0
+
+ /**
+ * This method adds the SWF to the DOM and prepares the initialization of the channel
+ */
+ function addSwf(domain) {
+ // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
+ var url = config.swf + "?host=" + config.isHost;
+ var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
+
+ // prepare the init function that will fire once the swf is ready
+ easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function () {
+ easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
+ var queue = easyXDM.stack.FlashTransport[domain].queue;
+ for (var i = 0; i < queue.length; i++) {
+ queue[i]();
+ }
+ queue.length = 0;
});
- document.body.appendChild(swfContainer);
- }
-
- // create the object/embed
- var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
- + "&proto=" + global.location.protocol
- + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
- + "&port=" + encodeURIComponent(getPort(global.location.href))
- + "&ns=" + encodeURIComponent(namespace);
- swfContainer.innerHTML = "
" +
- " " +
- " " +
- " " +
- " " +
- " " +
- " ";
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- swf.postMessage(config.channel, message.toString());
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- try {
- swf.destroyChannel(config.channel);
- }
- catch (e) {
+
+ if (config.swfContainer) {
+ swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
}
- swf = null;
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
+ else {
+ // create the container that will hold the swf
+ swfContainer = document.createElement('div');
+
+ // http://bugs.adobe.com/jira/browse/FP-4796
+ // http://tech.groups.yahoo.com/group/flexcoders/message/162365
+ // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
+ apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
+ height: "20px",
+ width: "20px",
+ position: "fixed",
+ right: 0,
+ top: 0
+ } : {
+ height: "1px",
+ width: "1px",
+ position: "absolute",
+ overflow: "hidden",
+ right: 0,
+ top: 0
+ });
+ document.body.appendChild(swfContainer);
}
- },
- onDOMReady: function(){
-
- targetOrigin = config.remote;
-
- // Prepare the code that will be run after the swf has been intialized
- easyXDM.Fn.set("flash_" + config.channel + "_init", function(){
- setTimeout(function(){
- pub.up.callback(true);
+
+ // create the object/embed
+ var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
+ + "&proto=" + global.location.protocol
+ + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
+ + "&port=" + encodeURIComponent(getPort(global.location.href))
+ + "&ns=" + encodeURIComponent(namespace);
+ swfContainer.innerHTML = "
" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " ";
+ }
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ swf.postMessage(config.channel, message.toString());
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ try {
+ swf.destroyChannel(config.channel);
+ }
+ catch (e) {
+ }
+ swf = null;
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+
+ targetOrigin = config.remote;
+
+ // Prepare the code that will be run after the swf has been intialized
+ easyXDM.Fn.set("flash_" + config.channel + "_init", function () {
+ setTimeout(function () {
+ pub.up.callback(true);
+ });
});
- });
-
- // set up the omMessage handler
- easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
-
- config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
- var swfdomain = getDomainName(config.swf);
- var fn = function(){
- // set init to true in case the fn was called was invoked from a separate instance
- easyXDM.stack.FlashTransport[swfdomain].init = true;
- swf = easyXDM.stack.FlashTransport[swfdomain].swf;
- // create the channel
- swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
-
- if (config.isHost) {
- // if Flash is going to be throttled and we want to avoid this
- if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
+
+ // set up the omMessage handler
+ easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
+
+ config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
+ var swfdomain = getDomainName(config.swf);
+ var fn = function () {
+ // set init to true in case the fn was called was invoked from a separate instance
+ easyXDM.stack.FlashTransport[swfdomain].init = true;
+ swf = easyXDM.stack.FlashTransport[swfdomain].swf;
+ // create the channel
+ swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
+
+ if (config.isHost) {
+ // if Flash is going to be throttled and we want to avoid this
+ if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
+ apply(config.props, {
+ position: "fixed",
+ right: 0,
+ top: 0,
+ height: "20px",
+ width: "20px"
+ });
+ }
+ // set up the iframe
apply(config.props, {
- position: "fixed",
- right: 0,
- top: 0,
- height: "20px",
- width: "20px"
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 6, // 6 = FlashTransport
+ xdm_s: config.secret
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
});
+ frame = createFrame(config);
}
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 6, // 6 = FlashTransport
- xdm_s: config.secret
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- }
- };
-
- if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
- // if the swf is in place and we are the consumer
- fn();
- }
- else {
- // if the swf does not yet exist
- if (!easyXDM.stack.FlashTransport[swfdomain]) {
- // add the queue to hold the init fn's
- easyXDM.stack.FlashTransport[swfdomain] = {
- queue: [fn]
- };
- addSwf(swfdomain);
+ };
+
+ if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
+ // if the swf is in place and we are the consumer
+ fn();
}
else {
- easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ // if the swf does not yet exist
+ if (!easyXDM.stack.FlashTransport[swfdomain]) {
+ // add the queue to hold the init fn's
+ easyXDM.stack.FlashTransport[swfdomain] = {
+ queue: [fn]
+ };
+ addSwf(swfdomain);
+ }
+ else {
+ easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ }
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1590,118 +1590,118 @@ easyXDM.stack.FlashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.PostMessageTransport
- * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
- *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
- *
https://developer.mozilla.org/en/DOM/window.postMessage
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- */
-easyXDM.stack.PostMessageTransport = function(config){
- var pub, // the public interface
- frame, // the remote frame, if any
- callerWindow, // the window that we will call with
- targetOrigin; // the domain to communicate with
- /**
- * Resolves the origin from the event object
- * @private
- * @param {Object} event The messageevent
- * @return {String} The scheme, host and port of the origin
- */
- function _getOrigin(event){
- if (event.origin) {
- // This is the HTML5 property
- return getLocation(event.origin);
- }
- if (event.uri) {
- // From earlier implementations
- return getLocation(event.uri);
- }
- if (event.domain) {
- // This is the last option and will fail if the
- // origin is not using the same schema as we are
- return location.protocol + "//" + event.domain;
- }
- throw "Unable to retrieve the origin of the event";
- }
-
/**
- * This is the main implementation for the onMessage event.
- * It checks the validity of the origin and passes the message on if appropriate.
- * @private
- * @param {Object} event The messageevent
+ * @class easyXDM.stack.PostMessageTransport
+ * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
+ *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
+ *
https://developer.mozilla.org/en/DOM/window.postMessage
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
*/
- function _window_onMessage(event){
- var origin = _getOrigin(event);
- if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
- pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
- }
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
- if (fn) {
- fn();
+ easyXDM.stack.PostMessageTransport = function (config) {
+ var pub, // the public interface
+ frame, // the remote frame, if any
+ callerWindow, // the window that we will call with
+ targetOrigin; // the domain to communicate with
+ /**
+ * Resolves the origin from the event object
+ * @private
+ * @param {Object} event The messageevent
+ * @return {String} The scheme, host and port of the origin
+ */
+ function _getOrigin(event) {
+ if (event.origin) {
+ // This is the HTML5 property
+ return getLocation(event.origin);
}
- },
- destroy: function(){
- un(window, "message", _window_onMessage);
- if (frame) {
- callerWindow = null;
- frame.parentNode.removeChild(frame);
- frame = null;
+ if (event.uri) {
+ // From earlier implementations
+ return getLocation(event.uri);
}
- },
- onDOMReady: function(){
- targetOrigin = getLocation(config.remote);
- if (config.isHost) {
- // add the event handler for listening
- var waitForReady = function(event){
- if (event.data == config.channel + "-ready") {
- // replace the eventlistener
- callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
- un(window, "message", waitForReady);
- on(window, "message", _window_onMessage);
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- }
- };
- on(window, "message", waitForReady);
-
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 1 // 1 = PostMessage
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
+ if (event.domain) {
+ // This is the last option and will fail if the
+ // origin is not using the same schema as we are
+ return location.protocol + "//" + event.domain;
}
- else {
- // add the event handler for listening
- on(window, "message", _window_onMessage);
- callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
- callerWindow.postMessage(config.channel + "-ready", targetOrigin);
-
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
+ throw "Unable to retrieve the origin of the event";
+ }
+
+ /**
+ * This is the main implementation for the onMessage event.
+ * It checks the validity of the origin and passes the message on if appropriate.
+ * @private
+ * @param {Object} event The messageevent
+ */
+ function _window_onMessage(event) {
+ var origin = _getOrigin(event);
+ if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
+ pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ un(window, "message", _window_onMessage);
+ if (frame) {
+ callerWindow = null;
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ targetOrigin = getLocation(config.remote);
+ if (config.isHost) {
+ // add the event handler for listening
+ var waitForReady = function (event) {
+ if (event.data == config.channel + "-ready") {
+ // replace the eventlistener
+ callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
+ un(window, "message", waitForReady);
+ on(window, "message", _window_onMessage);
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ }
+ };
+ on(window, "message", waitForReady);
+
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 1 // 1 = PostMessage
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ }
+ else {
+ // add the event handler for listening
+ on(window, "message", _window_onMessage);
+ callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
+ callerWindow.postMessage(config.channel + "-ready", targetOrigin);
+
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
+ }
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1726,75 +1726,75 @@ easyXDM.stack.PostMessageTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FrameElementTransport
- * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
- * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.FrameElementTransport = function(config){
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send.call(this, message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 5 // 5 = FrameElementTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- frame.fn = function(sendFn){
- delete frame.fn;
- send = sendFn;
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- // remove the function so that it cannot be used to overwrite the send function later on
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
+ /**
+ * @class easyXDM.stack.FrameElementTransport
+ * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
+ * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
+ */
+ easyXDM.stack.FrameElementTransport = function (config) {
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send.call(this, message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 5 // 5 = FrameElementTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ frame.fn = function (sendFn) {
+ delete frame.fn;
+ send = sendFn;
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ // remove the function so that it cannot be used to overwrite the send function later on
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
};
- };
- }
- else {
- // This is to mitigate origin-spoofing
- if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
- window.top.location = query.xdm_e;
}
- send = window.frameElement.fn(function(msg){
- pub.up.incoming(msg, targetOrigin);
- });
- pub.up.callback(true);
+ else {
+ // This is to mitigate origin-spoofing
+ if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
+ window.top.location = query.xdm_e;
+ }
+ send = window.frameElement.fn(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
+ pub.up.callback(true);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1819,126 +1819,126 @@ easyXDM.stack.FrameElementTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.NameTransport
- * NameTransport uses the window.name property to relay data.
- * The
local parameter needs to be set on both the consumer and provider,
- * and the
remoteHelper parameter needs to be set on the consumer.
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
- * @namespace easyXDM.stack
- */
-easyXDM.stack.NameTransport = function(config){
-
- var pub; // the public interface
- var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
-
- function _sendMessage(message){
- var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
- callerWindow.contentWindow.sendMessage(message, url);
- }
-
- function _onReady(){
- if (isHost) {
- if (++readyCount === 2 || !isHost) {
+ /**
+ * @class easyXDM.stack.NameTransport
+ * NameTransport uses the window.name property to relay data.
+ * The
local parameter needs to be set on both the consumer and provider,
+ * and the
remoteHelper parameter needs to be set on the consumer.
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
+ * @namespace easyXDM.stack
+ */
+ easyXDM.stack.NameTransport = function (config) {
+
+ var pub; // the public interface
+ var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
+
+ function _sendMessage(message) {
+ var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
+ callerWindow.contentWindow.sendMessage(message, url);
+ }
+
+ function _onReady() {
+ if (isHost) {
+ if (++readyCount === 2 || !isHost) {
+ pub.up.callback(true);
+ }
+ }
+ else {
+ _sendMessage("ready");
pub.up.callback(true);
}
}
- else {
- _sendMessage("ready");
- pub.up.callback(true);
- }
- }
-
- function _onMessage(message){
- pub.up.incoming(message, remoteOrigin);
- }
-
- function _onLoad(){
- if (callback) {
- setTimeout(function(){
- callback(true);
- }, 0);
+
+ function _onMessage(message) {
+ pub.up.incoming(message, remoteOrigin);
}
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callback = fn;
- _sendMessage(message);
- },
- destroy: function(){
- callerWindow.parentNode.removeChild(callerWindow);
- callerWindow = null;
- if (isHost) {
- remoteWindow.parentNode.removeChild(remoteWindow);
- remoteWindow = null;
+
+ function _onLoad() {
+ if (callback) {
+ setTimeout(function () {
+ callback(true);
+ }, 0);
}
- },
- onDOMReady: function(){
- isHost = config.isHost;
- readyCount = 0;
- remoteOrigin = getLocation(config.remote);
- config.local = resolveUrl(config.local);
-
- if (isHost) {
- // Register the callback
- easyXDM.Fn.set(config.channel, function(message){
- if (isHost && message === "ready") {
- // Replace the handler
- easyXDM.Fn.set(config.channel, _onMessage);
- _onReady();
- }
- });
-
- // Set up the frame that points to the remote instance
- remoteUrl = appendQueryParameters(config.remote, {
- xdm_e: config.local,
- xdm_c: config.channel,
- xdm_p: 2
- });
- apply(config.props, {
- src: remoteUrl + '#' + config.channel,
- name: IFRAME_PREFIX + config.channel + "_provider"
+ }
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callback = fn;
+ _sendMessage(message);
+ },
+ destroy: function () {
+ callerWindow.parentNode.removeChild(callerWindow);
+ callerWindow = null;
+ if (isHost) {
+ remoteWindow.parentNode.removeChild(remoteWindow);
+ remoteWindow = null;
+ }
+ },
+ onDOMReady: function () {
+ isHost = config.isHost;
+ readyCount = 0;
+ remoteOrigin = getLocation(config.remote);
+ config.local = resolveUrl(config.local);
+
+ if (isHost) {
+ // Register the callback
+ easyXDM.Fn.set(config.channel, function (message) {
+ if (isHost && message === "ready") {
+ // Replace the handler
+ easyXDM.Fn.set(config.channel, _onMessage);
+ _onReady();
+ }
+ });
+
+ // Set up the frame that points to the remote instance
+ remoteUrl = appendQueryParameters(config.remote, {
+ xdm_e: config.local,
+ xdm_c: config.channel,
+ xdm_p: 2
+ });
+ apply(config.props, {
+ src: remoteUrl + '#' + config.channel,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ remoteWindow = createFrame(config);
+ }
+ else {
+ config.remoteHelper = config.remote;
+ easyXDM.Fn.set(config.channel, _onMessage);
+ }
+
+ // Set up the iframe that will be used for the transport
+ var onLoad = function () {
+ // Remove the handler
+ var w = callerWindow || this;
+ un(w, "load", onLoad);
+ easyXDM.Fn.set(config.channel + "_load", _onLoad);
+ (function test() {
+ if (typeof w.contentWindow.sendMessage == "function") {
+ _onReady();
+ }
+ else {
+ setTimeout(test, 50);
+ }
+ }());
+ };
+
+ callerWindow = createFrame({
+ props: {
+ src: config.local + "#_4" + config.channel
+ },
+ onLoad: onLoad
});
- remoteWindow = createFrame(config);
- }
- else {
- config.remoteHelper = config.remote;
- easyXDM.Fn.set(config.channel, _onMessage);
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
-
- // Set up the iframe that will be used for the transport
- var onLoad = function(){
- // Remove the handler
- var w = callerWindow || this;
- un(w, "load", onLoad);
- easyXDM.Fn.set(config.channel + "_load", _onLoad);
- (function test(){
- if (typeof w.contentWindow.sendMessage == "function") {
- _onReady();
- }
- else {
- setTimeout(test, 50);
- }
- }());
- };
-
- callerWindow = createFrame({
- props: {
- src: config.local + "#_4" + config.channel
- },
- onLoad: onLoad
- });
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1963,136 +1963,136 @@ easyXDM.stack.NameTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.HashTransport
- * HashTransport is a transport class that uses the IFrame URL Technique for communication.
- *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
- * @cfg {Number} interval The interval used when polling for messages.
- */
-easyXDM.stack.HashTransport = function(config){
- var pub;
- var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
- var useParent, _remoteOrigin;
-
- function _sendMessage(message){
- if (!_callerWindow) {
- return;
- }
- var url = config.remote + "#" + (_msgNr++) + "_" + message;
- ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
- }
-
- function _handleHash(hash){
- _lastMsg = hash;
- pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
- }
-
/**
- * Checks location.hash for a new message and relays this to the receiver.
- * @private
+ * @class easyXDM.stack.HashTransport
+ * HashTransport is a transport class that uses the IFrame URL Technique for communication.
+ *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
+ * @cfg {Number} interval The interval used when polling for messages.
*/
- function _pollHash(){
- if (!_listenerWindow) {
- return;
- }
- var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
- if (indexOf != -1) {
- hash = href.substring(indexOf);
+ easyXDM.stack.HashTransport = function (config) {
+ var pub;
+ var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
+ var useParent, _remoteOrigin;
+
+ function _sendMessage(message) {
+ if (!_callerWindow) {
+ return;
+ }
+ var url = config.remote + "#" + (_msgNr++) + "_" + message;
+ ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
}
- if (hash && hash != _lastMsg) {
- _handleHash(hash);
+
+ function _handleHash(hash) {
+ _lastMsg = hash;
+ pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
}
- }
-
- function _attachListeners(){
- _timer = setInterval(_pollHash, pollInterval);
- }
-
- return (pub = {
- outgoing: function(message, domain){
- _sendMessage(message);
- },
- destroy: function(){
- window.clearInterval(_timer);
- if (isHost || !useParent) {
- _callerWindow.parentNode.removeChild(_callerWindow);
+
+ /**
+ * Checks location.hash for a new message and relays this to the receiver.
+ * @private
+ */
+ function _pollHash() {
+ if (!_listenerWindow) {
+ return;
}
- _callerWindow = null;
- },
- onDOMReady: function(){
- isHost = config.isHost;
- pollInterval = config.interval;
- _lastMsg = "#" + config.channel;
- _msgNr = 0;
- useParent = config.useParent;
- _remoteOrigin = getLocation(config.remote);
- if (isHost) {
- apply(config.props, {
- src: config.remote,
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- if (useParent) {
- config.onLoad = function(){
- _listenerWindow = window;
- _attachListeners();
- pub.up.callback(true);
- };
+ var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
+ if (indexOf != -1) {
+ hash = href.substring(indexOf);
+ }
+ if (hash && hash != _lastMsg) {
+ _handleHash(hash);
+ }
+ }
+
+ function _attachListeners() {
+ _timer = setInterval(_pollHash, pollInterval);
+ }
+
+ return (pub = {
+ outgoing: function (message, domain) {
+ _sendMessage(message);
+ },
+ destroy: function () {
+ window.clearInterval(_timer);
+ if (isHost || !useParent) {
+ _callerWindow.parentNode.removeChild(_callerWindow);
}
- else {
- var tries = 0, max = config.delay / 50;
- (function getRef(){
- if (++tries > max) {
- throw new Error("Unable to reference listenerwindow");
- }
- try {
- _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
- }
- catch (ex) {
- }
- if (_listenerWindow) {
+ _callerWindow = null;
+ },
+ onDOMReady: function () {
+ isHost = config.isHost;
+ pollInterval = config.interval;
+ _lastMsg = "#" + config.channel;
+ _msgNr = 0;
+ useParent = config.useParent;
+ _remoteOrigin = getLocation(config.remote);
+ if (isHost) {
+ apply(config.props, {
+ src: config.remote,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ if (useParent) {
+ config.onLoad = function () {
+ _listenerWindow = window;
_attachListeners();
pub.up.callback(true);
- }
- else {
- setTimeout(getRef, 50);
- }
- }());
- }
- _callerWindow = createFrame(config);
- }
- else {
- _listenerWindow = window;
- _attachListeners();
- if (useParent) {
- _callerWindow = parent;
- pub.up.callback(true);
+ };
+ }
+ else {
+ var tries = 0, max = config.delay / 50;
+ (function getRef() {
+ if (++tries > max) {
+ throw new Error("Unable to reference listenerwindow");
+ }
+ try {
+ _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
+ }
+ catch (ex) {
+ }
+ if (_listenerWindow) {
+ _attachListeners();
+ pub.up.callback(true);
+ }
+ else {
+ setTimeout(getRef, 50);
+ }
+ }());
+ }
+ _callerWindow = createFrame(config);
}
else {
- apply(config, {
- props: {
- src: config.remote + "#" + config.channel + new Date(),
- name: IFRAME_PREFIX + config.channel + "_consumer"
- },
- onLoad: function(){
- pub.up.callback(true);
- }
- });
- _callerWindow = createFrame(config);
+ _listenerWindow = window;
+ _attachListeners();
+ if (useParent) {
+ _callerWindow = parent;
+ pub.up.callback(true);
+ }
+ else {
+ apply(config, {
+ props: {
+ src: config.remote + "#" + config.channel + new Date(),
+ name: IFRAME_PREFIX + config.channel + "_consumer"
+ },
+ onLoad: function () {
+ pub.up.callback(true);
+ }
+ });
+ _callerWindow = createFrame(config);
+ }
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2117,47 +2117,47 @@ easyXDM.stack.HashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.ReliableBehavior
- * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- */
-easyXDM.stack.ReliableBehavior = function(config){
- var pub, // the public interface
- callback; // the callback to execute when we have a confirmed success/failure
- var idOut = 0, idIn = 0, currentMessage = "";
-
- return (pub = {
- incoming: function(message, origin){
- var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
- message = message.substring(indexOf + 1);
-
- if (ack[0] == idOut) {
- currentMessage = "";
- if (callback) {
- callback(true);
+ /**
+ * @class easyXDM.stack.ReliableBehavior
+ * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ */
+ easyXDM.stack.ReliableBehavior = function (config) {
+ var pub, // the public interface
+ callback; // the callback to execute when we have a confirmed success/failure
+ var idOut = 0, idIn = 0, currentMessage = "";
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
+ message = message.substring(indexOf + 1);
+
+ if (ack[0] == idOut) {
+ currentMessage = "";
+ if (callback) {
+ callback(true);
+ }
}
- }
- if (message.length > 0) {
- pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
- if (idIn != ack[1]) {
- idIn = ack[1];
- pub.up.incoming(message, origin);
+ if (message.length > 0) {
+ pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
+ if (idIn != ack[1]) {
+ idIn = ack[1];
+ pub.up.incoming(message, origin);
+ }
}
+
+ },
+ outgoing: function (message, origin, fn) {
+ currentMessage = message;
+ callback = fn;
+ pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
}
-
- },
- outgoing: function(message, origin, fn){
- currentMessage = message;
- callback = fn;
- pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
//
// easyXDM
// http://easyxdm.net/
@@ -2182,122 +2182,123 @@ easyXDM.stack.ReliableBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.QueueBehavior
- * This is a behavior that enables queueing of messages.
- * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
- * This will also fragment/defragment messages so that the outgoing message is never bigger than the
- * set length.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration. Optional.
- * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
- */
-easyXDM.stack.QueueBehavior = function(config){
- var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
-
- function dispatch(){
- if (config.remove && queue.length === 0) {
- removeFromStack(pub);
- return;
- }
- if (waiting || queue.length === 0 || destroying) {
- return;
- }
- waiting = true;
- var message = queue.shift();
-
- pub.down.outgoing(message.data, message.origin, function(success){
- waiting = false;
- if (message.callback) {
- setTimeout(function(){
- message.callback(success);
- }, 0);
- }
- dispatch();
- });
- }
- return (pub = {
- init: function(){
- if (undef(config)) {
- config = {};
- }
- if (config.maxLength) {
- maxLength = config.maxLength;
- doFragment = true;
- }
- if (config.lazy) {
- lazy = true;
+ /**
+ * @class easyXDM.stack.QueueBehavior
+ * This is a behavior that enables queueing of messages.
+ * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
+ * This will also fragment/defragment messages so that the outgoing message is never bigger than the
+ * set length.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration. Optional.
+ * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
+ */
+ easyXDM.stack.QueueBehavior = function (config) {
+ var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
+
+ function dispatch() {
+ if (config.remove && queue.length === 0) {
+ removeFromStack(pub);
+ return;
}
- else {
- pub.down.init();
+ if (waiting || queue.length === 0 || destroying) {
+ return;
}
- },
- callback: function(success){
- waiting = false;
- var up = pub.up; // in case dispatch calls removeFromStack
- dispatch();
- up.callback(success);
- },
- incoming: function(message, origin){
- if (doFragment) {
- var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
- incoming += message.substring(indexOf + 1);
- if (seq === 0) {
- if (config.encode) {
- incoming = decodeURIComponent(incoming);
+ waiting = true;
+ var message = queue.shift();
+
+ pub.down.outgoing(message.data, message.origin, function (success) {
+ waiting = false;
+ if (message.callback) {
+ setTimeout(function () {
+ message.callback(success);
+ }, 0);
+ }
+ dispatch();
+ });
+ }
+
+ return (pub = {
+ init: function () {
+ if (undef(config)) {
+ config = {};
+ }
+ if (config.maxLength) {
+ maxLength = config.maxLength;
+ doFragment = true;
+ }
+ if (config.lazy) {
+ lazy = true;
+ }
+ else {
+ pub.down.init();
+ }
+ },
+ callback: function (success) {
+ waiting = false;
+ var up = pub.up; // in case dispatch calls removeFromStack
+ dispatch();
+ up.callback(success);
+ },
+ incoming: function (message, origin) {
+ if (doFragment) {
+ var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
+ incoming += message.substring(indexOf + 1);
+ if (seq === 0) {
+ if (config.encode) {
+ incoming = decodeURIComponent(incoming);
+ }
+ pub.up.incoming(incoming, origin);
+ incoming = "";
}
- pub.up.incoming(incoming, origin);
- incoming = "";
}
- }
- else {
- pub.up.incoming(message, origin);
- }
- },
- outgoing: function(message, origin, fn){
- if (config.encode) {
- message = encodeURIComponent(message);
- }
- var fragments = [], fragment;
- if (doFragment) {
- // fragment into chunks
- while (message.length !== 0) {
- fragment = message.substring(0, maxLength);
- message = message.substring(fragment.length);
- fragments.push(fragment);
- }
- // enqueue the chunks
- while ((fragment = fragments.shift())) {
+ else {
+ pub.up.incoming(message, origin);
+ }
+ },
+ outgoing: function (message, origin, fn) {
+ if (config.encode) {
+ message = encodeURIComponent(message);
+ }
+ var fragments = [], fragment;
+ if (doFragment) {
+ // fragment into chunks
+ while (message.length !== 0) {
+ fragment = message.substring(0, maxLength);
+ message = message.substring(fragment.length);
+ fragments.push(fragment);
+ }
+ // enqueue the chunks
+ while ((fragment = fragments.shift())) {
+ queue.push({
+ data: fragments.length + "_" + fragment,
+ origin: origin,
+ callback: fragments.length === 0 ? fn : null
+ });
+ }
+ }
+ else {
queue.push({
- data: fragments.length + "_" + fragment,
+ data: message,
origin: origin,
- callback: fragments.length === 0 ? fn : null
+ callback: fn
});
}
+ if (lazy) {
+ pub.down.init();
+ }
+ else {
+ dispatch();
+ }
+ },
+ destroy: function () {
+ destroying = true;
+ pub.down.destroy();
}
- else {
- queue.push({
- data: message,
- origin: origin,
- callback: fn
- });
- }
- if (lazy) {
- pub.down.init();
- }
- else {
- dispatch();
- }
- },
- destroy: function(){
- destroying = true;
- pub.down.destroy();
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2322,56 +2323,56 @@ easyXDM.stack.QueueBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.VerifyBehavior
- * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
- * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- * @cfg {Boolean} initiate If the verification should be initiated from this end.
- */
-easyXDM.stack.VerifyBehavior = function(config){
- var pub, mySecret, theirSecret, verified = false;
-
- function startVerification(){
- mySecret = Math.random().toString(16).substring(2);
- pub.down.outgoing(mySecret);
- }
-
- return (pub = {
- incoming: function(message, origin){
- var indexOf = message.indexOf("_");
- if (indexOf === -1) {
- if (message === mySecret) {
- pub.up.callback(true);
+ /**
+ * @class easyXDM.stack.VerifyBehavior
+ * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
+ * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ * @cfg {Boolean} initiate If the verification should be initiated from this end.
+ */
+ easyXDM.stack.VerifyBehavior = function (config) {
+ var pub, mySecret, theirSecret, verified = false;
+
+ function startVerification() {
+ mySecret = Math.random().toString(16).substring(2);
+ pub.down.outgoing(mySecret);
+ }
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var indexOf = message.indexOf("_");
+ if (indexOf === -1) {
+ if (message === mySecret) {
+ pub.up.callback(true);
+ }
+ else if (!theirSecret) {
+ theirSecret = message;
+ if (!config.initiate) {
+ startVerification();
+ }
+ pub.down.outgoing(message);
+ }
}
- else if (!theirSecret) {
- theirSecret = message;
- if (!config.initiate) {
- startVerification();
+ else {
+ if (message.substring(0, indexOf) === theirSecret) {
+ pub.up.incoming(message.substring(indexOf + 1), origin);
}
- pub.down.outgoing(message);
}
- }
- else {
- if (message.substring(0, indexOf) === theirSecret) {
- pub.up.incoming(message.substring(indexOf + 1), origin);
+ },
+ outgoing: function (message, origin, fn) {
+ pub.down.outgoing(mySecret + "_" + message, origin, fn);
+ },
+ callback: function (success) {
+ if (config.initiate) {
+ startVerification();
}
}
- },
- outgoing: function(message, origin, fn){
- pub.down.outgoing(mySecret + "_" + message, origin, fn);
- },
- callback: function(success){
- if (config.initiate) {
- startVerification();
- }
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
//
// easyXDM
// http://easyxdm.net/
@@ -2396,189 +2397,189 @@ easyXDM.stack.VerifyBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.RpcBehavior
- * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
- * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} proxy The object to apply the methods to.
- * @param {Object} config The definition of the local and remote interface to implement.
- * @cfg {Object} local The local interface to expose.
- * @cfg {Object} remote The remote methods to expose through the proxy.
- * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
- */
-easyXDM.stack.RpcBehavior = function(proxy, config){
- var pub, serializer = config.serializer || getJSON();
- var _callbackCounter = 0, _callbacks = {};
-
- /**
- * Serializes and sends the message
- * @private
- * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
- */
- function _send(data){
- data.jsonrpc = "2.0";
- pub.down.outgoing(serializer.stringify(data));
- }
-
/**
- * Creates a method that implements the given definition
- * @private
- * @param {Object} The method configuration
- * @param {String} method The name of the method
- * @return {Function} A stub capable of proxying the requested method call
+ * @class easyXDM.stack.RpcBehavior
+ * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
+ * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} proxy The object to apply the methods to.
+ * @param {Object} config The definition of the local and remote interface to implement.
+ * @cfg {Object} local The local interface to expose.
+ * @cfg {Object} remote The remote methods to expose through the proxy.
+ * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
*/
- function _createMethod(definition, method){
- var slice = Array.prototype.slice;
-
- return function(){
- var l = arguments.length, callback, message = {
- method: method
- };
-
- if (l > 0 && typeof arguments[l - 1] === "function") {
- //with callback, procedure
- if (l > 1 && typeof arguments[l - 2] === "function") {
- // two callbacks, success and error
- callback = {
- success: arguments[l - 2],
- error: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 2);
+ easyXDM.stack.RpcBehavior = function (proxy, config) {
+ var pub, serializer = config.serializer || getJSON();
+ var _callbackCounter = 0, _callbacks = {};
+
+ /**
+ * Serializes and sends the message
+ * @private
+ * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
+ */
+ function _send(data) {
+ data.jsonrpc = "2.0";
+ pub.down.outgoing(serializer.stringify(data));
+ }
+
+ /**
+ * Creates a method that implements the given definition
+ * @private
+ * @param {Object} The method configuration
+ * @param {String} method The name of the method
+ * @return {Function} A stub capable of proxying the requested method call
+ */
+ function _createMethod(definition, method) {
+ var slice = Array.prototype.slice;
+
+ return function () {
+ var l = arguments.length, callback, message = {
+ method: method
+ };
+
+ if (l > 0 && typeof arguments[l - 1] === "function") {
+ //with callback, procedure
+ if (l > 1 && typeof arguments[l - 2] === "function") {
+ // two callbacks, success and error
+ callback = {
+ success: arguments[l - 2],
+ error: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 2);
+ }
+ else {
+ // single callback, success
+ callback = {
+ success: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 1);
+ }
+ _callbacks["" + (++_callbackCounter)] = callback;
+ message.id = _callbackCounter;
}
else {
- // single callback, success
- callback = {
- success: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 1);
+ // no callbacks, a notification
+ message.params = slice.call(arguments, 0);
}
- _callbacks["" + (++_callbackCounter)] = callback;
- message.id = _callbackCounter;
- }
- else {
- // no callbacks, a notification
- message.params = slice.call(arguments, 0);
- }
- if (definition.namedParams && message.params.length === 1) {
- message.params = message.params[0];
+ if (definition.namedParams && message.params.length === 1) {
+ message.params = message.params[0];
+ }
+ // Send the method request
+ _send(message);
+ };
+ }
+
+ /**
+ * Executes the exposed method
+ * @private
+ * @param {String} method The name of the method
+ * @param {Number} id The callback id to use
+ * @param {Function} method The exposed implementation
+ * @param {Array} params The parameters supplied by the remote end
+ */
+ function _executeMethod(method, id, fn, params) {
+ if (!fn) {
+ if (id) {
+ _send({
+ id: id,
+ error: {
+ code: -32601,
+ message: "Procedure not found."
+ }
+ });
+ }
+ return;
}
- // Send the method request
- _send(message);
- };
- }
-
- /**
- * Executes the exposed method
- * @private
- * @param {String} method The name of the method
- * @param {Number} id The callback id to use
- * @param {Function} method The exposed implementation
- * @param {Array} params The parameters supplied by the remote end
- */
- function _executeMethod(method, id, fn, params){
- if (!fn) {
+
+ var success, error;
if (id) {
- _send({
- id: id,
- error: {
- code: -32601,
- message: "Procedure not found."
- }
- });
- }
- return;
- }
-
- var success, error;
- if (id) {
- success = function(result){
- success = emptyFn;
- _send({
- id: id,
- result: result
- });
- };
- error = function(message, data){
- error = emptyFn;
- var msg = {
- id: id,
- error: {
- code: -32099,
- message: message
+ success = function (result) {
+ success = emptyFn;
+ _send({
+ id: id,
+ result: result
+ });
+ };
+ error = function (message, data) {
+ error = emptyFn;
+ var msg = {
+ id: id,
+ error: {
+ code: -32099,
+ message: message
+ }
+ };
+ if (data) {
+ msg.error.data = data;
}
+ _send(msg);
};
- if (data) {
- msg.error.data = data;
+ }
+ else {
+ success = error = emptyFn;
+ }
+ // Call local method
+ if (!isArray(params)) {
+ params = [params];
+ }
+ try {
+ var result = fn.method.apply(fn.scope, params.concat([success, error]));
+ if (!undef(result)) {
+ success(result);
}
- _send(msg);
- };
- }
- else {
- success = error = emptyFn;
- }
- // Call local method
- if (!isArray(params)) {
- params = [params];
- }
- try {
- var result = fn.method.apply(fn.scope, params.concat([success, error]));
- if (!undef(result)) {
- success(result);
}
- }
- catch (ex1) {
- error(ex1.message);
+ catch (ex1) {
+ error(ex1.message);
+ }
}
- }
-
- return (pub = {
- incoming: function(message, origin){
- var data = serializer.parse(message);
- if (data.method) {
- // A method call from the remote end
- if (config.handle) {
- config.handle(data, _send);
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var data = serializer.parse(message);
+ if (data.method) {
+ // A method call from the remote end
+ if (config.handle) {
+ config.handle(data, _send);
+ }
+ else {
+ _executeMethod(data.method, data.id, config.local[data.method], data.params);
+ }
}
else {
- _executeMethod(data.method, data.id, config.local[data.method], data.params);
- }
- }
- else {
- // A method response from the other end
- var callback = _callbacks[data.id];
- if (data.error) {
- if (callback.error) {
- callback.error(data.error);
+ // A method response from the other end
+ var callback = _callbacks[data.id];
+ if (data.error) {
+ if (callback.error) {
+ callback.error(data.error);
+ }
+ }
+ else if (callback.success) {
+ callback.success(data.result);
}
+ delete _callbacks[data.id];
}
- else if (callback.success) {
- callback.success(data.result);
+ },
+ init: function () {
+ if (config.remote) {
+ // Implement the remote sides exposed methods
+ for (var method in config.remote) {
+ if (config.remote.hasOwnProperty(method)) {
+ proxy[method] = _createMethod(config.remote[method], method);
+ }
+ }
}
- delete _callbacks[data.id];
- }
- },
- init: function(){
- if (config.remote) {
- // Implement the remote sides exposed methods
+ pub.down.init();
+ },
+ destroy: function () {
for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method)) {
- proxy[method] = _createMethod(config.remote[method], method);
+ if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
+ delete proxy[method];
}
}
+ pub.down.destroy();
}
- pub.down.init();
- },
- destroy: function(){
- for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
- delete proxy[method];
- }
- }
- pub.down.destroy();
- }
- });
-};
-global.easyXDM = easyXDM;
+ });
+ };
+ global.easyXDM = easyXDM;
})(window, document, location, window.setTimeout, decodeURIComponent, encodeURIComponent);
diff --git a/sdk/src/third-party/easyXDM/easyXDM.min.js b/sdk/src/third-party/easyXDM/easyXDM.min.js
index 5bddcff3..235c569d 100644
--- a/sdk/src/third-party/easyXDM/easyXDM.min.js
+++ b/sdk/src/third-party/easyXDM/easyXDM.min.js
@@ -21,4 +21,1254 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-(function(N,d,p,K,k,H){var b=this;var n=Math.floor(Math.random()*10000);var q=Function.prototype;var Q=/^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/;var R=/[\-\w]+\/\.\.\//;var F=/([^:])\/\//g;var I="";var o={};var M=N.easyXDM;var U="easyXDM_";var E;var y=false;var i;var h;function C(X,Z){var Y=typeof X[Z];return Y=="function"||(!!(Y=="object"&&X[Z]))||Y=="unknown"}function u(X,Y){return !!(typeof(X[Y])=="object"&&X[Y])}function r(X){return Object.prototype.toString.call(X)==="[object Array]"}function c(){var Z="Shockwave Flash",ad="application/x-shockwave-flash";if(!t(navigator.plugins)&&typeof navigator.plugins[Z]=="object"){var ab=navigator.plugins[Z].description;if(ab&&!t(navigator.mimeTypes)&&navigator.mimeTypes[ad]&&navigator.mimeTypes[ad].enabledPlugin){i=ab.match(/\d+/g)}}if(!i){var Y;try{Y=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");i=Array.prototype.slice.call(Y.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/),1);Y=null}catch(ac){}}if(!i){return false}var X=parseInt(i[0],10),aa=parseInt(i[1],10);h=X>9&&aa>0;return true}var v,x;if(C(N,"addEventListener")){v=function(Z,X,Y){Z.addEventListener(X,Y,false)};x=function(Z,X,Y){Z.removeEventListener(X,Y,false)}}else{if(C(N,"attachEvent")){v=function(X,Z,Y){X.attachEvent("on"+Z,Y)};x=function(X,Z,Y){X.detachEvent("on"+Z,Y)}}else{throw new Error("Browser not supported")}}var W=false,J=[],L;if("readyState" in d){L=d.readyState;W=L=="complete"||(~navigator.userAgent.indexOf("AppleWebKit/")&&(L=="loaded"||L=="interactive"))}else{W=!!d.body}function s(){if(W){return}W=true;for(var X=0;X
')}else{ac=d.createElement("IFRAME");ac.name=Y.props.name}ac.id=ac.name=Y.props.name;delete Y.props.name;if(typeof Y.container=="string"){Y.container=d.getElementById(Y.container)}if(!Y.container){T(ac.style,{position:"absolute",top:"-2000px",left:"0px"});Y.container=d.body}var ab=Y.props.src;Y.props.src="javascript:false";T(ac,Y.props);ac.border=ac.frameBorder=0;ac.allowTransparency=true;Y.container.appendChild(ac);if(Y.onLoad){v(ac,"load",Y.onLoad)}if(Y.usePost){var aa=Y.container.appendChild(d.createElement("form")),X;aa.target=ac.name;aa.action=ab;aa.method="POST";if(typeof(Y.usePost)==="object"){for(var Z in Y.usePost){if(Y.usePost.hasOwnProperty(Z)){if(E){X=d.createElement('
')}else{X=d.createElement("INPUT");X.name=Z}X.value=Y.usePost[Z];aa.appendChild(X)}}}aa.submit();aa.parentNode.removeChild(aa)}else{ac.src=ab}Y.props.src=ab;return ac}function V(aa,Z){if(typeof aa=="string"){aa=[aa]}var Y,X=aa.length;while(X--){Y=aa[X];Y=new RegExp(Y.substr(0,1)=="^"?Y:("^"+Y.replace(/(\*)/g,".$1").replace(/\?/g,".")+"$"));if(Y.test(Z)){return true}}return false}function l(Z){var ae=Z.protocol,Y;Z.isHost=Z.isHost||t(S.xdm_p);y=Z.hash||false;if(!Z.props){Z.props={}}if(!Z.isHost){Z.channel=S.xdm_c.replace(/["'<>\\]/g,"");Z.secret=S.xdm_s;Z.remote=S.xdm_e.replace(/["'<>\\]/g,"");ae=S.xdm_p;if(Z.acl&&!V(Z.acl,Z.remote)){throw new Error("Access denied for "+Z.remote)}}else{Z.remote=B(Z.remote);Z.channel=Z.channel||"default"+n++;Z.secret=Math.random().toString(16).substring(2);if(t(ae)){if(j(p.href)==j(Z.remote)){ae="4"}else{if(C(N,"postMessage")||C(d,"postMessage")){ae="1"}else{if(Z.swf&&C(N,"ActiveXObject")&&c()){ae="6"}else{if(navigator.product==="Gecko"&&"frameElement" in N&&navigator.userAgent.indexOf("WebKit")==-1){ae="5"}else{if(Z.remoteHelper){ae="2"}else{ae="0"}}}}}}}Z.protocol=ae;switch(ae){case"0":T(Z,{interval:100,delay:2000,useResize:true,useParent:false,usePolling:false},true);if(Z.isHost){if(!Z.local){var ac=p.protocol+"//"+p.host,X=d.body.getElementsByTagName("img"),ad;var aa=X.length;while(aa--){ad=X[aa];if(ad.src.substring(0,ac.length)===ac){Z.local=ad.src;break}}if(!Z.local){Z.local=N}}var ab={xdm_c:Z.channel,xdm_p:0};if(Z.local===N){Z.usePolling=true;Z.useParent=true;Z.local=p.protocol+"//"+p.host+p.pathname+p.search;ab.xdm_e=Z.local;ab.xdm_pa=1}else{ab.xdm_e=B(Z.local)}if(Z.container){Z.useResize=false;ab.xdm_po=1}Z.remote=P(Z.remote,ab)}else{T(Z,{channel:S.xdm_c,remote:S.xdm_e,useParent:!t(S.xdm_pa),usePolling:!t(S.xdm_po),useResize:Z.useParent?false:Z.useResize})}Y=[new o.stack.HashTransport(Z),new o.stack.ReliableBehavior({}),new o.stack.QueueBehavior({encode:true,maxLength:4000-Z.remote.length}),new o.stack.VerifyBehavior({initiate:Z.isHost})];break;case"1":Y=[new o.stack.PostMessageTransport(Z)];break;case"2":if(Z.isHost){Z.remoteHelper=B(Z.remoteHelper)}Y=[new o.stack.NameTransport(Z),new o.stack.QueueBehavior(),new o.stack.VerifyBehavior({initiate:Z.isHost})];break;case"3":Y=[new o.stack.NixTransport(Z)];break;case"4":Y=[new o.stack.SameOriginTransport(Z)];break;case"5":Y=[new o.stack.FrameElementTransport(Z)];break;case"6":if(!i){c()}Y=[new o.stack.FlashTransport(Z)];break}Y.push(new o.stack.QueueBehavior({lazy:Z.lazy,remove:true}));return Y}function D(aa){var ab,Z={incoming:function(ad,ac){this.up.incoming(ad,ac)},outgoing:function(ac,ad){this.down.outgoing(ac,ad)},callback:function(ac){this.up.callback(ac)},init:function(){this.down.init()},destroy:function(){this.down.destroy()}};for(var Y=0,X=aa.length;Y
<\/script>')}}};(function(){var X={};o.Fn={set:function(Y,Z){X[Y]=Z},get:function(Z,Y){if(!X.hasOwnProperty(Z)){return}var aa=X[Z];if(Y){delete X[Z]}return aa}}}());o.Socket=function(Y){var X=D(l(Y).concat([{incoming:function(ab,aa){Y.onMessage(ab,aa)},callback:function(aa){if(Y.onReady){Y.onReady(aa)}}}])),Z=j(Y.remote);this.origin=j(Y.remote);this.destroy=function(){X.destroy()};this.postMessage=function(aa){X.outgoing(aa,Z)};X.init()};o.Rpc=function(Z,Y){if(Y.local){for(var ab in Y.local){if(Y.local.hasOwnProperty(ab)){var aa=Y.local[ab];if(typeof aa==="function"){Y.local[ab]={method:aa}}}}}var X=D(l(Z).concat([new o.stack.RpcBehavior(this,Y),{callback:function(ac){if(Z.onReady){Z.onReady(ac)}}}]));this.origin=j(Z.remote);this.destroy=function(){X.destroy()};X.init()};o.stack.SameOriginTransport=function(Y){var Z,ab,aa,X;return(Z={outgoing:function(ad,ae,ac){aa(ad);if(ac){ac()}},destroy:function(){if(ab){ab.parentNode.removeChild(ab);ab=null}},onDOMReady:function(){X=j(Y.remote);if(Y.isHost){T(Y.props,{src:P(Y.remote,{xdm_e:p.protocol+"//"+p.host+p.pathname,xdm_c:Y.channel,xdm_p:4}),name:U+Y.channel+"_provider"});ab=A(Y);o.Fn.set(Y.channel,function(ac){aa=ac;K(function(){Z.up.callback(true)},0);return function(ad){Z.up.incoming(ad,X)}})}else{aa=m().Fn.get(Y.channel,true)(function(ac){Z.up.incoming(ac,X)});K(function(){Z.up.callback(true)},0)}},init:function(){G(Z.onDOMReady,Z)}})};o.stack.FlashTransport=function(aa){var ac,X,ab,ad,Y,ae;function af(ah,ag){K(function(){ac.up.incoming(ah,ad)},0)}function Z(ah){var ag=aa.swf+"?host="+aa.isHost;var aj="easyXDM_swf_"+Math.floor(Math.random()*10000);o.Fn.set("flash_loaded"+ah.replace(/[\-.]/g,"_"),function(){o.stack.FlashTransport[ah].swf=Y=ae.firstChild;var ak=o.stack.FlashTransport[ah].queue;for(var al=0;al "}return(ac={outgoing:function(ah,ai,ag){Y.postMessage(aa.channel,ah.toString());if(ag){ag()}},destroy:function(){try{Y.destroyChannel(aa.channel)}catch(ag){}Y=null;if(X){X.parentNode.removeChild(X);X=null}},onDOMReady:function(){ad=aa.remote;o.Fn.set("flash_"+aa.channel+"_init",function(){K(function(){ac.up.callback(true)})});o.Fn.set("flash_"+aa.channel+"_onMessage",af);aa.swf=B(aa.swf);var ah=z(aa.swf);var ag=function(){o.stack.FlashTransport[ah].init=true;Y=o.stack.FlashTransport[ah].swf;Y.createChannel(aa.channel,aa.secret,j(aa.remote),aa.isHost);if(aa.isHost){if(h&&aa.swfNoThrottle){T(aa.props,{position:"fixed",right:0,top:0,height:"20px",width:"20px"})}T(aa.props,{src:P(aa.remote,{xdm_e:j(p.href),xdm_c:aa.channel,xdm_p:6,xdm_s:aa.secret}),name:U+aa.channel+"_provider"});X=A(aa)}};if(o.stack.FlashTransport[ah]&&o.stack.FlashTransport[ah].init){ag()}else{if(!o.stack.FlashTransport[ah]){o.stack.FlashTransport[ah]={queue:[ag]};Z(ah)}else{o.stack.FlashTransport[ah].queue.push(ag)}}},init:function(){G(ac.onDOMReady,ac)}})};o.stack.PostMessageTransport=function(aa){var ac,ad,Y,Z;function X(ae){if(ae.origin){return j(ae.origin)}if(ae.uri){return j(ae.uri)}if(ae.domain){return p.protocol+"//"+ae.domain}throw"Unable to retrieve the origin of the event"}function ab(af){var ae=X(af);if(ae==Z&&af.data.substring(0,aa.channel.length+1)==aa.channel+" "){ac.up.incoming(af.data.substring(aa.channel.length+1),ae)}}return(ac={outgoing:function(af,ag,ae){Y.postMessage(aa.channel+" "+af,ag||Z);if(ae){ae()}},destroy:function(){x(N,"message",ab);if(ad){Y=null;ad.parentNode.removeChild(ad);ad=null}},onDOMReady:function(){Z=j(aa.remote);if(aa.isHost){var ae=function(af){if(af.data==aa.channel+"-ready"){Y=("postMessage" in ad.contentWindow)?ad.contentWindow:ad.contentWindow.document;x(N,"message",ae);v(N,"message",ab);K(function(){ac.up.callback(true)},0)}};v(N,"message",ae);T(aa.props,{src:P(aa.remote,{xdm_e:j(p.href),xdm_c:aa.channel,xdm_p:1}),name:U+aa.channel+"_provider"});ad=A(aa)}else{v(N,"message",ab);Y=("postMessage" in N.parent)?N.parent:N.parent.document;Y.postMessage(aa.channel+"-ready",Z);K(function(){ac.up.callback(true)},0)}},init:function(){G(ac.onDOMReady,ac)}})};o.stack.FrameElementTransport=function(Y){var Z,ab,aa,X;return(Z={outgoing:function(ad,ae,ac){aa.call(this,ad);if(ac){ac()}},destroy:function(){if(ab){ab.parentNode.removeChild(ab);ab=null}},onDOMReady:function(){X=j(Y.remote);if(Y.isHost){T(Y.props,{src:P(Y.remote,{xdm_e:j(p.href),xdm_c:Y.channel,xdm_p:5}),name:U+Y.channel+"_provider"});ab=A(Y);ab.fn=function(ac){delete ab.fn;aa=ac;K(function(){Z.up.callback(true)},0);return function(ad){Z.up.incoming(ad,X)}}}else{if(d.referrer&&j(d.referrer)!=S.xdm_e){N.top.location=S.xdm_e}aa=N.frameElement.fn(function(ac){Z.up.incoming(ac,X)});Z.up.callback(true)}},init:function(){G(Z.onDOMReady,Z)}})};o.stack.NameTransport=function(ab){var ac;var ae,ai,aa,ag,ah,Y,X;function af(al){var ak=ab.remoteHelper+(ae?"#_3":"#_2")+ab.channel;ai.contentWindow.sendMessage(al,ak)}function ad(){if(ae){if(++ag===2||!ae){ac.up.callback(true)}}else{af("ready");ac.up.callback(true)}}function aj(ak){ac.up.incoming(ak,Y)}function Z(){if(ah){K(function(){ah(true)},0)}}return(ac={outgoing:function(al,am,ak){ah=ak;af(al)},destroy:function(){ai.parentNode.removeChild(ai);ai=null;if(ae){aa.parentNode.removeChild(aa);aa=null}},onDOMReady:function(){ae=ab.isHost;ag=0;Y=j(ab.remote);ab.local=B(ab.local);if(ae){o.Fn.set(ab.channel,function(al){if(ae&&al==="ready"){o.Fn.set(ab.channel,aj);ad()}});X=P(ab.remote,{xdm_e:ab.local,xdm_c:ab.channel,xdm_p:2});T(ab.props,{src:X+"#"+ab.channel,name:U+ab.channel+"_provider"});aa=A(ab)}else{ab.remoteHelper=ab.remote;o.Fn.set(ab.channel,aj)}var ak=function(){var al=ai||this;x(al,"load",ak);o.Fn.set(ab.channel+"_load",Z);(function am(){if(typeof al.contentWindow.sendMessage=="function"){ad()}else{K(am,50)}}())};ai=A({props:{src:ab.local+"#_4"+ab.channel},onLoad:ak})},init:function(){G(ac.onDOMReady,ac)}})};o.stack.HashTransport=function(Z){var ac;var ah=this,af,aa,X,ad,am,ab,al;var ag,Y;function ak(ao){if(!al){return}var an=Z.remote+"#"+(am++)+"_"+ao;((af||!ag)?al.contentWindow:al).location=an}function ae(an){ad=an;ac.up.incoming(ad.substring(ad.indexOf("_")+1),Y)}function aj(){if(!ab){return}var an=ab.location.href,ap="",ao=an.indexOf("#");if(ao!=-1){ap=an.substring(ao)}if(ap&&ap!=ad){ae(ap)}}function ai(){aa=setInterval(aj,X)}return(ac={outgoing:function(an,ao){ak(an)},destroy:function(){N.clearInterval(aa);if(af||!ag){al.parentNode.removeChild(al)}al=null},onDOMReady:function(){af=Z.isHost;X=Z.interval;ad="#"+Z.channel;am=0;ag=Z.useParent;Y=j(Z.remote);if(af){T(Z.props,{src:Z.remote,name:U+Z.channel+"_provider"});if(ag){Z.onLoad=function(){ab=N;ai();ac.up.callback(true)}}else{var ap=0,an=Z.delay/50;(function ao(){if(++ap>an){throw new Error("Unable to reference listenerwindow")}try{ab=al.contentWindow.frames[U+Z.channel+"_consumer"]}catch(aq){}if(ab){ai();ac.up.callback(true)}else{K(ao,50)}}())}al=A(Z)}else{ab=N;ai();if(ag){al=parent;ac.up.callback(true)}else{T(Z,{props:{src:Z.remote+"#"+Z.channel+new Date(),name:U+Z.channel+"_consumer"},onLoad:function(){ac.up.callback(true)}});al=A(Z)}}},init:function(){G(ac.onDOMReady,ac)}})};o.stack.ReliableBehavior=function(Y){var aa,ac;var ab=0,X=0,Z="";return(aa={incoming:function(af,ad){var ae=af.indexOf("_"),ag=af.substring(0,ae).split(",");af=af.substring(ae+1);if(ag[0]==ab){Z="";if(ac){ac(true)}}if(af.length>0){aa.down.outgoing(ag[1]+","+ab+"_"+Z,ad);if(X!=ag[1]){X=ag[1];aa.up.incoming(af,ad)}}},outgoing:function(af,ad,ae){Z=af;ac=ae;aa.down.outgoing(X+","+(++ab)+"_"+af,ad)}})};o.stack.QueueBehavior=function(Z){var ac,ad=[],ag=true,aa="",af,X=0,Y=false,ab=false;function ae(){if(Z.remove&&ad.length===0){w(ac);return}if(ag||ad.length===0||af){return}ag=true;var ah=ad.shift();ac.down.outgoing(ah.data,ah.origin,function(ai){ag=false;if(ah.callback){K(function(){ah.callback(ai)},0)}ae()})}return(ac={init:function(){if(t(Z)){Z={}}if(Z.maxLength){X=Z.maxLength;ab=true}if(Z.lazy){Y=true}else{ac.down.init()}},callback:function(ai){ag=false;var ah=ac.up;ae();ah.callback(ai)},incoming:function(ak,ai){if(ab){var aj=ak.indexOf("_"),ah=parseInt(ak.substring(0,aj),10);aa+=ak.substring(aj+1);if(ah===0){if(Z.encode){aa=k(aa)}ac.up.incoming(aa,ai);aa=""}}else{ac.up.incoming(ak,ai)}},outgoing:function(al,ai,ak){if(Z.encode){al=H(al)}var ah=[],aj;if(ab){while(al.length!==0){aj=al.substring(0,X);al=al.substring(aj.length);ah.push(aj)}while((aj=ah.shift())){ad.push({data:ah.length+"_"+aj,origin:ai,callback:ah.length===0?ak:null})}}else{ad.push({data:al,origin:ai,callback:ak})}if(Y){ac.down.init()}else{ae()}},destroy:function(){af=true;ac.down.destroy()}})};o.stack.VerifyBehavior=function(ab){var ac,aa,Y,Z=false;function X(){aa=Math.random().toString(16).substring(2);ac.down.outgoing(aa)}return(ac={incoming:function(af,ad){var ae=af.indexOf("_");if(ae===-1){if(af===aa){ac.up.callback(true)}else{if(!Y){Y=af;if(!ab.initiate){X()}ac.down.outgoing(af)}}}else{if(af.substring(0,ae)===Y){ac.up.incoming(af.substring(ae+1),ad)}}},outgoing:function(af,ad,ae){ac.down.outgoing(aa+"_"+af,ad,ae)},callback:function(ad){if(ab.initiate){X()}}})};o.stack.RpcBehavior=function(ad,Y){var aa,af=Y.serializer||O();var ae=0,ac={};function X(ag){ag.jsonrpc="2.0";aa.down.outgoing(af.stringify(ag))}function ab(ag,ai){var ah=Array.prototype.slice;return function(){var aj=arguments.length,al,ak={method:ai};if(aj>0&&typeof arguments[aj-1]==="function"){if(aj>1&&typeof arguments[aj-2]==="function"){al={success:arguments[aj-2],error:arguments[aj-1]};ak.params=ah.call(arguments,0,aj-2)}else{al={success:arguments[aj-1]};ak.params=ah.call(arguments,0,aj-1)}ac[""+(++ae)]=al;ak.id=ae}else{ak.params=ah.call(arguments,0)}if(ag.namedParams&&ak.params.length===1){ak.params=ak.params[0]}X(ak)}}function Z(an,am,ai,al){if(!ai){if(am){X({id:am,error:{code:-32601,message:"Procedure not found."}})}return}var ak,ah;if(am){ak=function(ao){ak=q;X({id:am,result:ao})};ah=function(ao,ap){ah=q;var aq={id:am,error:{code:-32099,message:ao}};if(ap){aq.error.data=ap}X(aq)}}else{ak=ah=q}if(!r(al)){al=[al]}try{var ag=ai.method.apply(ai.scope,al.concat([ak,ah]));if(!t(ag)){ak(ag)}}catch(aj){ah(aj.message)}}return(aa={incoming:function(ah,ag){var ai=af.parse(ah);if(ai.method){if(Y.handle){Y.handle(ai,X)}else{Z(ai.method,ai.id,Y.local[ai.method],ai.params)}}else{var aj=ac[ai.id];if(ai.error){if(aj.error){aj.error(ai.error)}}else{if(aj.success){aj.success(ai.result)}}delete ac[ai.id]}},init:function(){if(Y.remote){for(var ag in Y.remote){if(Y.remote.hasOwnProperty(ag)){ad[ag]=ab(Y.remote[ag],ag)}}}aa.down.init()},destroy:function(){for(var ag in Y.remote){if(Y.remote.hasOwnProperty(ag)&&ad.hasOwnProperty(ag)){delete ad[ag]}}aa.down.destroy()}})};b.easyXDM=o})(window,document,location,window.setTimeout,decodeURIComponent,encodeURIComponent);
\ No newline at end of file
+(function (N, d, p, K, k, H) {
+ var b = this;
+ var n = Math.floor(Math.random() * 10000);
+ var q = Function.prototype;
+ var Q = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/;
+ var R = /[\-\w]+\/\.\.\//;
+ var F = /([^:])\/\//g;
+ var I = "";
+ var o = {};
+ var M = N.easyXDM;
+ var U = "easyXDM_";
+ var E;
+ var y = false;
+ var i;
+ var h;
+
+ function C(X, Z) {
+ var Y = typeof X[Z];
+ return Y == "function" || (!!(Y == "object" && X[Z])) || Y == "unknown"
+ }
+
+ function u(X, Y) {
+ return !!(typeof(X[Y]) == "object" && X[Y])
+ }
+
+ function r(X) {
+ return Object.prototype.toString.call(X) === "[object Array]"
+ }
+
+ function c() {
+ var Z = "Shockwave Flash", ad = "application/x-shockwave-flash";
+ if (!t(navigator.plugins) && typeof navigator.plugins[Z] == "object") {
+ var ab = navigator.plugins[Z].description;
+ if (ab && !t(navigator.mimeTypes) && navigator.mimeTypes[ad] && navigator.mimeTypes[ad].enabledPlugin) {
+ i = ab.match(/\d+/g)
+ }
+ }
+ if (!i) {
+ var Y;
+ try {
+ Y = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ i = Array.prototype.slice.call(Y.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
+ Y = null
+ } catch (ac) {
+ }
+ }
+ if (!i) {
+ return false
+ }
+ var X = parseInt(i[0], 10), aa = parseInt(i[1], 10);
+ h = X > 9 && aa > 0;
+ return true
+ }
+
+ var v, x;
+ if (C(N, "addEventListener")) {
+ v = function (Z, X, Y) {
+ Z.addEventListener(X, Y, false)
+ };
+ x = function (Z, X, Y) {
+ Z.removeEventListener(X, Y, false)
+ }
+ } else {
+ if (C(N, "attachEvent")) {
+ v = function (X, Z, Y) {
+ X.attachEvent("on" + Z, Y)
+ };
+ x = function (X, Z, Y) {
+ X.detachEvent("on" + Z, Y)
+ }
+ } else {
+ throw new Error("Browser not supported")
+ }
+ }
+ var W = false, J = [], L;
+ if ("readyState" in d) {
+ L = d.readyState;
+ W = L == "complete" || (~navigator.userAgent.indexOf("AppleWebKit/") && (L == "loaded" || L == "interactive"))
+ } else {
+ W = !!d.body
+ }
+ function s() {
+ if (W) {
+ return
+ }
+ W = true;
+ for (var X = 0; X < J.length; X++) {
+ J[X]()
+ }
+ J.length = 0
+ }
+
+ if (!W) {
+ if (C(N, "addEventListener")) {
+ v(d, "DOMContentLoaded", s)
+ } else {
+ v(d, "readystatechange", function () {
+ if (d.readyState == "complete") {
+ s()
+ }
+ });
+ if (d.documentElement.doScroll && N === top) {
+ var g = function () {
+ if (W) {
+ return
+ }
+ try {
+ d.documentElement.doScroll("left")
+ } catch (X) {
+ K(g, 1);
+ return
+ }
+ s()
+ };
+ g()
+ }
+ }
+ v(N, "load", s)
+ }
+ function G(Y, X) {
+ if (W) {
+ Y.call(X);
+ return
+ }
+ J.push(function () {
+ Y.call(X)
+ })
+ }
+
+ function m() {
+ var Z = parent;
+ if (I !== "") {
+ for (var X = 0, Y = I.split("."); X < Y.length; X++) {
+ Z = Z[Y[X]]
+ }
+ }
+ return Z.easyXDM
+ }
+
+ function e(X) {
+ N.easyXDM = M;
+ I = X;
+ if (I) {
+ U = "easyXDM_" + I.replace(".", "_") + "_"
+ }
+ return o
+ }
+
+ function z(X) {
+ return X.match(Q)[3]
+ }
+
+ function f(X) {
+ return X.match(Q)[4] || ""
+ }
+
+ function j(Z) {
+ var X = Z.toLowerCase().match(Q);
+ var aa = X[2], ab = X[3], Y = X[4] || "";
+ if ((aa == "http:" && Y == ":80") || (aa == "https:" && Y == ":443")) {
+ Y = ""
+ }
+ return aa + "//" + ab + Y
+ }
+
+ function B(X) {
+ X = X.replace(F, "$1/");
+ if (!X.match(/^(http||https):\/\//)) {
+ var Y = (X.substring(0, 1) === "/") ? "" : p.pathname;
+ if (Y.substring(Y.length - 1) !== "/") {
+ Y = Y.substring(0, Y.lastIndexOf("/") + 1)
+ }
+ X = p.protocol + "//" + p.host + Y + X
+ }
+ while (R.test(X)) {
+ X = X.replace(R, "")
+ }
+ return X
+ }
+
+ function P(X, aa) {
+ var ac = "", Z = X.indexOf("#");
+ if (Z !== -1) {
+ ac = X.substring(Z);
+ X = X.substring(0, Z)
+ }
+ var ab = [];
+ for (var Y in aa) {
+ if (aa.hasOwnProperty(Y)) {
+ ab.push(Y + "=" + H(aa[Y]))
+ }
+ }
+ return X + (y ? "#" : (X.indexOf("?") == -1 ? "?" : "&")) + ab.join("&") + ac
+ }
+
+ var S = (function (X) {
+ X = X.substring(1).split("&");
+ var Z = {}, aa, Y = X.length;
+ while (Y--) {
+ aa = X[Y].split("=");
+ Z[aa[0]] = k(aa[1])
+ }
+ return Z
+ }(/xdm_e=/.test(p.search) ? p.search : p.hash));
+
+ function t(X) {
+ return typeof X === "undefined"
+ }
+
+ var O = function () {
+ var Y = {};
+ var Z = {a: [1, 2, 3]}, X = '{"a":[1,2,3]}';
+ if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(Z).replace((/\s/g), "") === X) {
+ return JSON
+ }
+ if (Object.toJSON) {
+ if (Object.toJSON(Z).replace((/\s/g), "") === X) {
+ Y.stringify = Object.toJSON
+ }
+ }
+ if (typeof String.prototype.evalJSON === "function") {
+ Z = X.evalJSON();
+ if (Z.a && Z.a.length === 3 && Z.a[2] === 3) {
+ Y.parse = function (aa) {
+ return aa.evalJSON()
+ }
+ }
+ }
+ if (Y.stringify && Y.parse) {
+ O = function () {
+ return Y
+ };
+ return Y
+ }
+ return null
+ };
+
+ function T(X, Y, Z) {
+ var ab;
+ for (var aa in Y) {
+ if (Y.hasOwnProperty(aa)) {
+ if (aa in X) {
+ ab = Y[aa];
+ if (typeof ab === "object") {
+ T(X[aa], ab, Z)
+ } else {
+ if (!Z) {
+ X[aa] = Y[aa]
+ }
+ }
+ } else {
+ X[aa] = Y[aa]
+ }
+ }
+ }
+ return X
+ }
+
+ function a() {
+ var Y = d.body.appendChild(d.createElement("form")), X = Y.appendChild(d.createElement("input"));
+ X.name = U + "TEST" + n;
+ E = X !== Y.elements[X.name];
+ d.body.removeChild(Y)
+ }
+
+ function A(Y) {
+ if (t(E)) {
+ a()
+ }
+ var ac;
+ if (E) {
+ ac = d.createElement('')
+ } else {
+ ac = d.createElement("IFRAME");
+ ac.name = Y.props.name
+ }
+ ac.id = ac.name = Y.props.name;
+ delete Y.props.name;
+ if (typeof Y.container == "string") {
+ Y.container = d.getElementById(Y.container)
+ }
+ if (!Y.container) {
+ T(ac.style, {position: "absolute", top: "-2000px", left: "0px"});
+ Y.container = d.body
+ }
+ var ab = Y.props.src;
+ Y.props.src = "javascript:false";
+ T(ac, Y.props);
+ ac.border = ac.frameBorder = 0;
+ ac.allowTransparency = true;
+ Y.container.appendChild(ac);
+ if (Y.onLoad) {
+ v(ac, "load", Y.onLoad)
+ }
+ if (Y.usePost) {
+ var aa = Y.container.appendChild(d.createElement("form")), X;
+ aa.target = ac.name;
+ aa.action = ab;
+ aa.method = "POST";
+ if (typeof(Y.usePost) === "object") {
+ for (var Z in Y.usePost) {
+ if (Y.usePost.hasOwnProperty(Z)) {
+ if (E) {
+ X = d.createElement(' ')
+ } else {
+ X = d.createElement("INPUT");
+ X.name = Z
+ }
+ X.value = Y.usePost[Z];
+ aa.appendChild(X)
+ }
+ }
+ }
+ aa.submit();
+ aa.parentNode.removeChild(aa)
+ } else {
+ ac.src = ab
+ }
+ Y.props.src = ab;
+ return ac
+ }
+
+ function V(aa, Z) {
+ if (typeof aa == "string") {
+ aa = [aa]
+ }
+ var Y, X = aa.length;
+ while (X--) {
+ Y = aa[X];
+ Y = new RegExp(Y.substr(0, 1) == "^" ? Y : ("^" + Y.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
+ if (Y.test(Z)) {
+ return true
+ }
+ }
+ return false
+ }
+
+ function l(Z) {
+ var ae = Z.protocol, Y;
+ Z.isHost = Z.isHost || t(S.xdm_p);
+ y = Z.hash || false;
+ if (!Z.props) {
+ Z.props = {}
+ }
+ if (!Z.isHost) {
+ Z.channel = S.xdm_c.replace(/["'<>\\]/g, "");
+ Z.secret = S.xdm_s;
+ Z.remote = S.xdm_e.replace(/["'<>\\]/g, "");
+ ae = S.xdm_p;
+ if (Z.acl && !V(Z.acl, Z.remote)) {
+ throw new Error("Access denied for " + Z.remote)
+ }
+ } else {
+ Z.remote = B(Z.remote);
+ Z.channel = Z.channel || "default" + n++;
+ Z.secret = Math.random().toString(16).substring(2);
+ if (t(ae)) {
+ if (j(p.href) == j(Z.remote)) {
+ ae = "4"
+ } else {
+ if (C(N, "postMessage") || C(d, "postMessage")) {
+ ae = "1"
+ } else {
+ if (Z.swf && C(N, "ActiveXObject") && c()) {
+ ae = "6"
+ } else {
+ if (navigator.product === "Gecko" && "frameElement" in N && navigator.userAgent.indexOf("WebKit") == -1) {
+ ae = "5"
+ } else {
+ if (Z.remoteHelper) {
+ ae = "2"
+ } else {
+ ae = "0"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Z.protocol = ae;
+ switch (ae) {
+ case"0":
+ T(Z, {interval: 100, delay: 2000, useResize: true, useParent: false, usePolling: false}, true);
+ if (Z.isHost) {
+ if (!Z.local) {
+ var ac = p.protocol + "//" + p.host, X = d.body.getElementsByTagName("img"), ad;
+ var aa = X.length;
+ while (aa--) {
+ ad = X[aa];
+ if (ad.src.substring(0, ac.length) === ac) {
+ Z.local = ad.src;
+ break
+ }
+ }
+ if (!Z.local) {
+ Z.local = N
+ }
+ }
+ var ab = {xdm_c: Z.channel, xdm_p: 0};
+ if (Z.local === N) {
+ Z.usePolling = true;
+ Z.useParent = true;
+ Z.local = p.protocol + "//" + p.host + p.pathname + p.search;
+ ab.xdm_e = Z.local;
+ ab.xdm_pa = 1
+ } else {
+ ab.xdm_e = B(Z.local)
+ }
+ if (Z.container) {
+ Z.useResize = false;
+ ab.xdm_po = 1
+ }
+ Z.remote = P(Z.remote, ab)
+ } else {
+ T(Z, {
+ channel: S.xdm_c,
+ remote: S.xdm_e,
+ useParent: !t(S.xdm_pa),
+ usePolling: !t(S.xdm_po),
+ useResize: Z.useParent ? false : Z.useResize
+ })
+ }
+ Y = [new o.stack.HashTransport(Z), new o.stack.ReliableBehavior({}), new o.stack.QueueBehavior({
+ encode: true,
+ maxLength: 4000 - Z.remote.length
+ }), new o.stack.VerifyBehavior({initiate: Z.isHost})];
+ break;
+ case"1":
+ Y = [new o.stack.PostMessageTransport(Z)];
+ break;
+ case"2":
+ if (Z.isHost) {
+ Z.remoteHelper = B(Z.remoteHelper)
+ }
+ Y = [new o.stack.NameTransport(Z), new o.stack.QueueBehavior(), new o.stack.VerifyBehavior({initiate: Z.isHost})];
+ break;
+ case"3":
+ Y = [new o.stack.NixTransport(Z)];
+ break;
+ case"4":
+ Y = [new o.stack.SameOriginTransport(Z)];
+ break;
+ case"5":
+ Y = [new o.stack.FrameElementTransport(Z)];
+ break;
+ case"6":
+ if (!i) {
+ c()
+ }
+ Y = [new o.stack.FlashTransport(Z)];
+ break
+ }
+ Y.push(new o.stack.QueueBehavior({lazy: Z.lazy, remove: true}));
+ return Y
+ }
+
+ function D(aa) {
+ var ab, Z = {
+ incoming: function (ad, ac) {
+ this.up.incoming(ad, ac)
+ }, outgoing: function (ac, ad) {
+ this.down.outgoing(ac, ad)
+ }, callback: function (ac) {
+ this.up.callback(ac)
+ }, init: function () {
+ this.down.init()
+ }, destroy: function () {
+ this.down.destroy()
+ }
+ };
+ for (var Y = 0, X = aa.length; Y < X; Y++) {
+ ab = aa[Y];
+ T(ab, Z, true);
+ if (Y !== 0) {
+ ab.down = aa[Y - 1]
+ }
+ if (Y !== X - 1) {
+ ab.up = aa[Y + 1]
+ }
+ }
+ return ab
+ }
+
+ function w(X) {
+ X.up.down = X.down;
+ X.down.up = X.up;
+ X.up = X.down = null
+ }
+
+ T(o, {version: "2.4.19.3", query: S, stack: {}, apply: T, getJSONObject: O, whenReady: G, noConflict: e});
+ o.DomHelper = {
+ on: v, un: x, requiresJSON: function (X) {
+ if (!u(N, "JSON")) {
+ d.write('
-
- Bookmark
-
-
+
+
+
+
+
+
+
+
+Bookmark
+
+
diff --git a/sdk/src/third-party/easyXDM/example/bookmark.js b/sdk/src/third-party/easyXDM/example/bookmark.js
index 22ff781d..0a472444 100644
--- a/sdk/src/third-party/easyXDM/example/bookmark.js
+++ b/sdk/src/third-party/easyXDM/example/bookmark.js
@@ -1,7 +1,7 @@
-var myBookmark = (function(){
+var myBookmark = (function () {
var s1, s2, isLoaded = false, xhr, head = document.getElementsByTagName('head')[0];
var scripts = document.getElementsByTagName("script");
- var REMOTE = (function(){
+ var REMOTE = (function () {
var remote = location.href;
switch (location.host) {
case "provider.easyxdm.net":
@@ -15,27 +15,27 @@ var myBookmark = (function(){
}
return remote.substring(0, remote.lastIndexOf("/"));
}());
-
- function run(){
+
+ function run() {
if (typeof xhr === "undefined") {
return;
}
xhr.post("example/glossary.php", {
param1: "a",
param2: "b"
- }, function(json){
+ }, function (json) {
alert(json.glossary.title);
});
}
-
- function scriptOnLoad(){
+
+ function scriptOnLoad() {
if (isLoaded || typeof easyXDM === "undefined" || typeof JSON === "undefined") {
return;
}
isLoaded = true;
xhr = new easyXDM.Rpc({
remote: REMOTE + "/../xhr.html",
- onReady: function(){
+ onReady: function () {
run();
}
}, {
@@ -43,24 +43,25 @@ var myBookmark = (function(){
post: {}
}
});
-
+
}
+
s1 = document.createElement("script");
s1.type = "text/javascript";
s1.src = REMOTE + "/../easyXDM.debug.js";
- s1.onreadystatechange = function(){
+ s1.onreadystatechange = function () {
if (this.readyState === "complete" || this.readyState === "loaded") {
scriptOnLoad();
}
};
s1.onload = scriptOnLoad;
head.appendChild(s1);
-
+
if (typeof JSON === "undefined" || !JSON) {
s2 = document.createElement("script");
s2.type = "text/javascript";
s2.src = REMOTE + "/../json2.js";
- s2.onreadystatechange = function(){
+ s2.onreadystatechange = function () {
if (this.readyState === "complete" || this.readyState === "loaded") {
scriptOnLoad();
}
diff --git a/sdk/src/third-party/easyXDM/example/bridge.html b/sdk/src/third-party/easyXDM/example/bridge.html
index af840e84..b8d6c436 100644
--- a/sdk/src/third-party/easyXDM/example/bridge.html
+++ b/sdk/src/third-party/easyXDM/example/bridge.html
@@ -1,135 +1,136 @@
-
- easyXDM
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+ });
+
+ // lets tell the proxy to open up the window as soon as possible
+ proxy.open("mainapp");
+ }
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/data.html b/sdk/src/third-party/easyXDM/example/data.html
index 47eaeed0..dc7ed337 100644
--- a/sdk/src/third-party/easyXDM/example/data.html
+++ b/sdk/src/third-party/easyXDM/example/data.html
@@ -1,133 +1,134 @@
-
- easyXDM
-
-
+
-
-
-
-
-
-
-
+ channel.postMessage(serializer.stringify({
+ propA: "abc",
+ propB: "def",
+ propC: 44
+ }));
+ }
+ });
+ };
+
+
+
+
+
Index of examples
+ |
Readme at github
+ |
+ |
easyXDM.net
+ |
easyXDM at Google Groups
+ The examples are executing slower than the production build due to the extensive tracing.
-
-
- eval code
-
-
-
+
+ catch (err) {
+ }
+ }
+
diff --git a/sdk/src/third-party/easyXDM/example/index.html b/sdk/src/third-party/easyXDM/example/index.html
index 80188999..e902ed0f 100644
--- a/sdk/src/third-party/easyXDM/example/index.html
+++ b/sdk/src/third-party/easyXDM/example/index.html
@@ -1,75 +1,76 @@
-
-
easyXDM
-
-
-
-
Readme at github
- |
- |
easyXDM.net
- |
easyXDM at Google Groups
-
- The examples are executing slower than the production build due to the extensive tracing.
-
- If you are alerted about a popup, then this is only the trace log feature. You can ignore this.
-
-
-
- Transport
-
- Example of passing a string message from one domain to another using the Socket.
-
-
- Data
-
- Example of passing data using a Socket and a custom serializer/deserializer.
-
-
- Methods
-
- Example of using the Rpc object for executing Remote Procedure Calls with arguments and having results returned.
-
-
- Resize iframe
-
- Example on how to use easyXDM to automatically resize an iframe. This uses an intermediate frame to enable navigation of the contained document
-
-
- Upload
-
- Example on how to facilitate 'cross domain AJAX upload'.
-
-
- Widgets
-
- Example on how to use easyXDM to build a framework for widgets using a pub/sub schema.
-
-
- XHR
-
- Example of using the shipped /cors/ endpoint to retrieve resources across the domain boundary.
-
-
- Bridge
-
- Experimental example of how to 'bridge' two web apps together.
-
-
-
-
-
+
+
easyXDM
+
+
+
+
Readme at github
+ |
+ |
easyXDM.net
+ |
easyXDM at Google Groups
+
+ The examples are executing slower than the production build due to the extensive tracing.
+
+ If you are alerted about a popup, then this is only the trace log feature. You can ignore this.
+
+
+
+ Transport
+
+ Example of passing a string message from one domain to another using the Socket.
+
+
+ Data
+
+ Example of passing data using a Socket and a custom serializer/deserializer.
+
+
+ Methods
+
+ Example of using the Rpc object for executing Remote Procedure Calls with arguments and having results returned.
+
+
+ Resize iframe
+
+ Example on how to use easyXDM to automatically resize an iframe. This uses an intermediate frame to enable
+ navigation of the contained document
+
+
+ Upload
+
+ Example on how to facilitate 'cross domain AJAX upload'.
+
+
+ Widgets
+
+ Example on how to use easyXDM to build a framework for widgets using a pub/sub schema.
+
+
+ XHR
+
+ Example of using the shipped /cors/ endpoint to retrieve resources across the domain boundary.
+
+
+ Bridge
+
+ Experimental example of how to 'bridge' two web apps together.
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/methods.html b/sdk/src/third-party/easyXDM/example/methods.html
index 9bbd15a1..ff87344c 100644
--- a/sdk/src/third-party/easyXDM/example/methods.html
+++ b/sdk/src/third-party/easyXDM/example/methods.html
@@ -1,148 +1,148 @@
-
-
easyXDM
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
- The remote implementation is synchronous and will return immediately
-
-
-
-
- The remote implementation of multiplyNumbers is asynchronous and will return after 5seconds
-
- This shows that you can use async calls in the remote method, eg. XHR calls
-
-
-
-
- This calls a non-returning method on the remote side
-
-
-
-
-
-
+ });
+
+ function add(a, b) {
+ remote.addNumbers(a, b, function (result) {
+ alert(a + " + " + b + " = " + result);
+ });
+ }
+
+ function multiply(a, b) {
+ remote.multiplyNumbers(a, b, function (result) {
+ alert(a + " x " + b + " = " + result);
+ });
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ The remote implementation is synchronous and will return immediately
+
+
+
+
+ The remote implementation of multiplyNumbers is asynchronous and will return after 5seconds
+
+ This shows that you can use async calls in the remote method, eg. XHR calls
+
+
+
+
+ This calls a non-returning method on the remote side
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/remote.html b/sdk/src/third-party/easyXDM/example/remote.html
index ad82e8a9..7f9c6c5a 100644
--- a/sdk/src/third-party/easyXDM/example/remote.html
+++ b/sdk/src/third-party/easyXDM/example/remote.html
@@ -1,83 +1,83 @@
-
-
easyXDM
-
-
-
+
+
-
-
-
+ });
+
+
+ /**
+ * The popup must use this window to register itself
+ * @param {DOMWindow} app The window object of the popup
+ */
+ function setApp(app) {
+ remoteapp = app;
+ }
+
+ /**
+ * The popup must use this method to send data. This clones the object in order to
+ * work around a but in IE
+ * @param {Object} data The data to send
+ */
+ function sendData(data) {
+ var copy = {};
+ // copy the object in order to avoid the JSON serialization bug
+ easyXDM.apply(copy, data);
+ proxy.postMessage(copy);
+ }
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/remoteapp.html b/sdk/src/third-party/easyXDM/example/remoteapp.html
index e493b688..1a58153c 100644
--- a/sdk/src/third-party/easyXDM/example/remoteapp.html
+++ b/sdk/src/third-party/easyXDM/example/remoteapp.html
@@ -1,37 +1,39 @@
-
-
easyXDM
-
-
-
-
-
+ }
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/src/third-party/easyXDM/example/remotedata.html b/sdk/src/third-party/easyXDM/example/remotedata.html
index 814355c2..fd7552f4 100644
--- a/sdk/src/third-party/easyXDM/example/remotedata.html
+++ b/sdk/src/third-party/easyXDM/example/remotedata.html
@@ -1,64 +1,64 @@
-
-
easyXDM
-
-
+
-
-
-
+ }
+ });
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/remotemethods.html b/sdk/src/third-party/easyXDM/example/remotemethods.html
index 2ea8c1fb..51963745 100644
--- a/sdk/src/third-party/easyXDM/example/remotemethods.html
+++ b/sdk/src/third-party/easyXDM/example/remotemethods.html
@@ -1,46 +1,46 @@
-
-
easyXDM
-
-
-
+
+
-
-
-
-
-
-
-
-
+ }
+ });
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/src/third-party/easyXDM/example/remoterpcbackend.html b/sdk/src/third-party/easyXDM/example/remoterpcbackend.html
index 59a411ad..cb302920 100644
--- a/sdk/src/third-party/easyXDM/example/remoterpcbackend.html
+++ b/sdk/src/third-party/easyXDM/example/remoterpcbackend.html
@@ -1,36 +1,36 @@
-
-
easyXDM
-
-
+
+
-
-
-
-
-
-
-
-
+ handle: function (rpc, reply) {
+ alert("requested to execute procedure '" + rpc.method + "'");
+ }
+ });
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/remotetransport.html b/sdk/src/third-party/easyXDM/example/remotetransport.html
index 64093a7a..22919309 100644
--- a/sdk/src/third-party/easyXDM/example/remotetransport.html
+++ b/sdk/src/third-party/easyXDM/example/remotetransport.html
@@ -1,24 +1,24 @@
-
-
easyXDM
-
-
-
-
-
+
+
easyXDM
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/resize_iframe.html b/sdk/src/third-party/easyXDM/example/resize_iframe.html
index e0b0adb7..56a13b01 100644
--- a/sdk/src/third-party/easyXDM/example/resize_iframe.html
+++ b/sdk/src/third-party/easyXDM/example/resize_iframe.html
@@ -1,70 +1,70 @@
-
-
easyXDM
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+ return remote.substring(0, remote.lastIndexOf("/"));
+ }());
+
+ var transport = new easyXDM.Socket(/** The configuration */{
+ remote: REMOTE + "/resize_intermediate.html?url=resized_iframe_1.html",
+ swf: REMOTE + "/../easyxdm.swf",
+ container: "embedded",
+ onMessage: function (message, origin) {
+ this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
+ }
+ });
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/resize_intermediate.html b/sdk/src/third-party/easyXDM/example/resize_intermediate.html
index 8b5f03e4..3f5dcc24 100644
--- a/sdk/src/third-party/easyXDM/example/resize_intermediate.html
+++ b/sdk/src/third-party/easyXDM/example/resize_intermediate.html
@@ -1,67 +1,68 @@
-
-
easyXDM
-
-
+
-
-
-
+ });
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/resized_iframe_1.html b/sdk/src/third-party/easyXDM/example/resized_iframe_1.html
index 8b4b7ad3..accaf476 100644
--- a/sdk/src/third-party/easyXDM/example/resized_iframe_1.html
+++ b/sdk/src/third-party/easyXDM/example/resized_iframe_1.html
@@ -1,21 +1,40 @@
-
-
easyXDM
-
-
-
-
resized_iframe_2.html
-
- Nam nulla nibh, tempus ut dictum eget, euismod vitae metus. Donec vitae nulla nec quam sagittis gravida vel quis eros. Nullam vel est justo. Donec euismod interdum magna, et rutrum libero tincidunt vel. Praesent imperdiet, magna et suscipit facilisis, nulla justo consequat nisl, et mollis elit nunc a est. Sed felis quam, condimentum eget gravida non, semper non quam. Duis vestibulum sem id erat tristique eleifend. Phasellus ante nunc, pulvinar nec facilisis at, hendrerit sed leo. Morbi lacinia nisl id nunc faucibus lacinia. Curabitur adipiscing leo a odio aliquet hendrerit. Nullam laoreet pulvinar suscipit.
- Cras ante tortor, rutrum non pharetra vel, tempor et velit. Mauris semper, libero sit amet interdum interdum, metus purus rutrum libero, eget suscipit lectus augue eu magna. Aliquam quis dui a nunc luctus faucibus. Sed viverra augue rutrum odio placerat laoreet. Nulla scelerisque augue nec enim condimentum sollicitudin. Proin accumsan, turpis in viverra lobortis, nulla mauris euismod turpis, sit amet auctor felis lacus sed leo. Nullam posuere bibendum urna, ut mattis eros varius ac. Mauris sed metus orci, ut lobortis eros. Sed imperdiet bibendum tincidunt. Donec adipiscing sapien vitae ligula faucibus quis auctor nisi pretium. Morbi at nulla quam, in aliquet quam. Suspendisse potenti. Fusce varius gravida egestas. Nulla lectus velit, posuere et auctor a, congue id massa. Quisque ut lectus eu metus malesuada sollicitudin ac a risus.
- Nullam massa ipsum, pulvinar ut facilisis a, commodo ut orci. Mauris ac ipsum diam, sit amet laoreet tortor. In pretium, nulla vel ornare euismod, nibh augue pharetra magna, at semper felis diam in ipsum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus blandit ornare dignissim. Fusce et nulla urna. Morbi nec ante erat. Nullam ut urna libero. Nulla non ipsum purus, et cursus lectus. Etiam vehicula, mauris in faucibus vehicula, dolor quam sodales neque, sed laoreet est augue at lacus. Nunc tincidunt lacinia elit eu dignissim. Mauris at enim mauris. Donec congue auctor dui, eget posuere ante accumsan in. Nulla non quam enim, eget tempor arcu. Suspendisse nec nibh diam, ut congue est. Fusce at urna eget velit posuere ornare nec eget mauris. Sed accumsan magna et enim mollis dignissim.
-
+
+
easyXDM
+
+
+
+
resized_iframe_2.html
+
+Nam nulla nibh, tempus ut dictum eget, euismod vitae metus. Donec vitae nulla nec quam sagittis gravida vel quis eros.
+Nullam vel est justo. Donec euismod interdum magna, et rutrum libero tincidunt vel. Praesent imperdiet, magna et
+suscipit facilisis, nulla justo consequat nisl, et mollis elit nunc a est. Sed felis quam, condimentum eget gravida non,
+semper non quam. Duis vestibulum sem id erat tristique eleifend. Phasellus ante nunc, pulvinar nec facilisis at,
+hendrerit sed leo. Morbi lacinia nisl id nunc faucibus lacinia. Curabitur adipiscing leo a odio aliquet hendrerit.
+Nullam laoreet pulvinar suscipit.
+Cras ante tortor, rutrum non pharetra vel, tempor et velit. Mauris semper, libero sit amet interdum interdum, metus
+purus rutrum libero, eget suscipit lectus augue eu magna. Aliquam quis dui a nunc luctus faucibus. Sed viverra augue
+rutrum odio placerat laoreet. Nulla scelerisque augue nec enim condimentum sollicitudin. Proin accumsan, turpis in
+viverra lobortis, nulla mauris euismod turpis, sit amet auctor felis lacus sed leo. Nullam posuere bibendum urna, ut
+mattis eros varius ac. Mauris sed metus orci, ut lobortis eros. Sed imperdiet bibendum tincidunt. Donec adipiscing
+sapien vitae ligula faucibus quis auctor nisi pretium. Morbi at nulla quam, in aliquet quam. Suspendisse potenti. Fusce
+varius gravida egestas. Nulla lectus velit, posuere et auctor a, congue id massa. Quisque ut lectus eu metus malesuada
+sollicitudin ac a risus.
+Nullam massa ipsum, pulvinar ut facilisis a, commodo ut orci. Mauris ac ipsum diam, sit amet laoreet tortor. In pretium,
+nulla vel ornare euismod, nibh augue pharetra magna, at semper felis diam in ipsum. Cum sociis natoque penatibus et
+magnis dis parturient montes, nascetur ridiculus mus. Vivamus blandit ornare dignissim. Fusce et nulla urna. Morbi nec
+ante erat. Nullam ut urna libero. Nulla non ipsum purus, et cursus lectus. Etiam vehicula, mauris in faucibus vehicula,
+dolor quam sodales neque, sed laoreet est augue at lacus. Nunc tincidunt lacinia elit eu dignissim. Mauris at enim
+mauris. Donec congue auctor dui, eget posuere ante accumsan in. Nulla non quam enim, eget tempor arcu. Suspendisse nec
+nibh diam, ut congue est. Fusce at urna eget velit posuere ornare nec eget mauris. Sed accumsan magna et enim mollis
+dignissim.
+
diff --git a/sdk/src/third-party/easyXDM/example/resized_iframe_2.html b/sdk/src/third-party/easyXDM/example/resized_iframe_2.html
index 7c4085d3..91780d08 100644
--- a/sdk/src/third-party/easyXDM/example/resized_iframe_2.html
+++ b/sdk/src/third-party/easyXDM/example/resized_iframe_2.html
@@ -1,33 +1,64 @@
-
-
easyXDM
-
-
-
-
resized_iframe_1.html
-
- (This page will resize its content after three seconds)
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu felis libero, non ultricies ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in lorem libero. Phasellus malesuada, mauris eget suscipit tristique, dolor dui blandit purus, ut mollis eros dolor et elit. Ut consequat ultrices metus, pretium mattis dui adipiscing vitae. Nunc cursus, sapien vehicula auctor faucibus, enim orci pretium risus, id congue ligula justo sed felis. Proin nec quam justo. Cras tempor odio eget orci lacinia sit amet malesuada leo feugiat. In accumsan tincidunt enim, vitae ultricies arcu egestas in. Nulla rhoncus eros vel ipsum venenatis porta. Suspendisse id erat nec mauris ultricies consectetur id feugiat odio. Vestibulum pretium tristique magna sed ultrices. Suspendisse tortor mauris, facilisis et lobortis quis, suscipit sed est. Sed vitae tortor at lacus pretium blandit. Donec vitae nibh quis orci mollis fringilla. Duis tempus augue nec ipsum euismod elementum.
- Donec pharetra sem nec lacus posuere et lacinia ligula sollicitudin. Morbi semper commodo posuere. In adipiscing nulla ut urna fermentum vestibulum. Sed consectetur massa non neque facilisis interdum. Quisque semper massa et urna euismod nec fermentum metus feugiat. Morbi tempor commodo enim non lacinia. Aliquam elementum tortor mattis odio congue a egestas lacus bibendum. Integer nec leo massa, a ullamcorper mi. Morbi vitae massa arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
- Nam nulla nibh, tempus ut dictum eget, euismod vitae metus. Donec vitae nulla nec quam sagittis gravida vel quis eros. Nullam vel est justo. Donec euismod interdum magna, et rutrum libero tincidunt vel. Praesent imperdiet, magna et suscipit facilisis, nulla justo consequat nisl, et mollis elit nunc a est. Sed felis quam, condimentum eget gravida non, semper non quam. Duis vestibulum sem id erat tristique eleifend. Phasellus ante nunc, pulvinar nec facilisis at, hendrerit sed leo. Morbi lacinia nisl id nunc faucibus lacinia. Curabitur adipiscing leo a odio aliquet hendrerit. Nullam laoreet pulvinar suscipit.
- Cras ante tortor, rutrum non pharetra vel, tempor et velit. Mauris semper, libero sit amet interdum interdum, metus purus rutrum libero, eget suscipit lectus augue eu magna. Aliquam quis dui a nunc luctus faucibus. Sed viverra augue rutrum odio placerat laoreet. Nulla scelerisque augue nec enim condimentum sollicitudin. Proin accumsan, turpis in viverra lobortis, nulla mauris euismod turpis, sit amet auctor felis lacus sed leo. Nullam posuere bibendum urna, ut mattis eros varius ac. Mauris sed metus orci, ut lobortis eros. Sed imperdiet bibendum tincidunt. Donec adipiscing sapien vitae ligula faucibus quis auctor nisi pretium. Morbi at nulla quam, in aliquet quam. Suspendisse potenti. Fusce varius gravida egestas. Nulla lectus velit, posuere et auctor a, congue id massa. Quisque ut lectus eu metus malesuada sollicitudin ac a risus.
- Nullam massa ipsum, pulvinar ut facilisis a, commodo ut orci. Mauris ac ipsum diam, sit amet laoreet tortor. In pretium, nulla vel ornare euismod, nibh augue pharetra magna, at semper felis diam in ipsum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus blandit ornare dignissim. Fusce et nulla urna. Morbi nec ante erat. Nullam ut urna libero. Nulla non ipsum purus, et cursus lectus. Etiam vehicula, mauris in faucibus vehicula, dolor quam sodales neque, sed laoreet est augue at lacus. Nunc tincidunt lacinia elit eu dignissim. Mauris at enim mauris. Donec congue auctor dui, eget posuere ante accumsan in. Nulla non quam enim, eget tempor arcu. Suspendisse nec nibh diam, ut congue est. Fusce at urna eget velit posuere ornare nec eget mauris. Sed accumsan magna et enim mollis dignissim.
-
-
+
+
diff --git a/sdk/src/third-party/easyXDM/example/transport.html b/sdk/src/third-party/easyXDM/example/transport.html
index 769feb01..889b890c 100644
--- a/sdk/src/third-party/easyXDM/example/transport.html
+++ b/sdk/src/third-party/easyXDM/example/transport.html
@@ -1,82 +1,82 @@
-
-
easyXDM
-
-
+
-
-
-
-
-
-
-
-
-
+ });
+ // messages will be buffered until the transport is ready
+ transport.postMessage("This is a message sent from " + location);
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/upload.html b/sdk/src/third-party/easyXDM/example/upload.html
index 569feb43..9750605c 100644
--- a/sdk/src/third-party/easyXDM/example/upload.html
+++ b/sdk/src/third-party/easyXDM/example/upload.html
@@ -1,100 +1,100 @@
-
-
easyXDM
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/upload_rpc.html b/sdk/src/third-party/easyXDM/example/upload_rpc.html
index 37123ece..df18a410 100644
--- a/sdk/src/third-party/easyXDM/example/upload_rpc.html
+++ b/sdk/src/third-party/easyXDM/example/upload_rpc.html
@@ -1,25 +1,25 @@
-
-
easyXDM
-
-
-
-
-
-
-
+
+
easyXDM
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/widget.html b/sdk/src/third-party/easyXDM/example/widget.html
index 5093eeb9..0d584279 100644
--- a/sdk/src/third-party/easyXDM/example/widget.html
+++ b/sdk/src/third-party/easyXDM/example/widget.html
@@ -1,49 +1,49 @@
-
-
easyXDM.Widget
-
-
-
-
+
+
+
-
-
-
+ });
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/widgets.html b/sdk/src/third-party/easyXDM/example/widgets.html
index 17bff037..1a196378 100644
--- a/sdk/src/third-party/easyXDM/example/widgets.html
+++ b/sdk/src/third-party/easyXDM/example/widgets.html
@@ -1,75 +1,85 @@
-
-
easyXDM
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ document.getElementById("widget1url").value = location.href.replace("consumer", "provider").replace("widgets.html", "widget.html");
+ document.getElementById("widget2url").value = location.href.replace("consumer.", "").replace("widgets.html", "widget.html");
+ });
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/example/xhr.html b/sdk/src/third-party/easyXDM/example/xhr.html
index a6d7f5d9..a49a5a4e 100644
--- a/sdk/src/third-party/easyXDM/example/xhr.html
+++ b/sdk/src/third-party/easyXDM/example/xhr.html
@@ -1,112 +1,112 @@
-
-
easyXDM
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
- This example shows how to use easyXDM to call regular ajax/cors services (no JSONP) from remote domains.
-
-
-
- Data from response:
-
- Data from header:
-
-
-
-
+ });
+
+ function getGlossary() {
+ xhr.request({
+ url: "../example/glossary.aspx",
+ method: "POST",
+ headers: {
+ "x-auth-token": "abcde"
+ },
+ data: {
+ param1: "a",
+ param2: "b"
+ }
+ }, function (rpcdata) {
+ var json = easyXDM.getJSONObject().parse(rpcdata.data);
+
+ document.getElementById("response").innerHTML = json.glossary.title;
+ document.getElementById("header").innerHTML = rpcdata.headers["x-foo"];
+ });
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+ This example shows how to use easyXDM to call regular ajax/cors services (no JSONP) from remote domains.
+
+
+
+ Data from response:
+
+ Data from header:
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/json2.js b/sdk/src/third-party/easyXDM/json2.js
index a1a3b170..2393eff6 100644
--- a/sdk/src/third-party/easyXDM/json2.js
+++ b/sdk/src/third-party/easyXDM/json2.js
@@ -1,159 +1,159 @@
/*
- http://www.JSON.org/json2.js
- 2010-03-20
+ http://www.JSON.org/json2.js
+ 2010-03-20
- Public Domain.
+ Public Domain.
- NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
- See http://www.JSON.org/js.html
+ See http://www.JSON.org/js.html
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
- This file creates a global JSON object containing two methods: stringify
- and parse.
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or ' '),
- it contains the characters used to indent at each level.
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
- This method produces a JSON text from a JavaScript value.
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
- For example, this would serialize Dates as ISO strings.
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
- Example:
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+ Example:
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
- Example:
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+ */
/*jslint evil: true, strict: false */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+ */
// Create a JSON object only if one does not already exist. We create the
@@ -175,19 +175,19 @@ if (!this.JSON) {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf()) ?
- this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z' : null;
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -200,7 +200,7 @@ if (!this.JSON) {
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
- '"' : '\\"',
+ '"': '\\"',
'\\': '\\\\'
},
rep;
@@ -215,12 +215,12 @@ if (!this.JSON) {
escapable.lastIndex = 0;
return escapable.test(string) ?
- '"' + string.replace(escapable, function (a) {
- var c = meta[a];
- return typeof c === 'string' ? c :
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- }) + '"' :
- '"' + string + '"';
+ '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' :
+ '"' + string + '"';
}
@@ -239,7 +239,7 @@ if (!this.JSON) {
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
+ typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
@@ -253,100 +253,100 @@ if (!this.JSON) {
// What happens next depends on the value's type.
switch (typeof value) {
- case 'string':
- return quote(value);
+ case 'string':
+ return quote(value);
- case 'number':
+ case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
- return isFinite(value) ? String(value) : 'null';
+ return isFinite(value) ? String(value) : 'null';
- case 'boolean':
- case 'null':
+ case 'boolean':
+ case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
- return String(value);
+ return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
- case 'object':
+ case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
- if (!value) {
- return 'null';
- }
+ if (!value) {
+ return 'null';
+ }
// Make an array to hold the partial results of stringifying this object value.
- gap += indent;
- partial = [];
+ gap += indent;
+ partial = [];
// Is the value an array?
- if (Object.prototype.toString.apply(value) === '[object Array]') {
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
- v = partial.length === 0 ? '[]' :
- gap ? '[\n' + gap +
- partial.join(',\n' + gap) + '\n' +
- mind + ']' :
- '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
+ v = partial.length === 0 ? '[]' :
+ gap ? '[\n' + gap +
+ partial.join(',\n' + gap) + '\n' +
+ mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
// If the replacer is an array, use it to select the members to be stringified.
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- k = rep[i];
- if (typeof k === 'string') {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ k = rep[i];
+ if (typeof k === 'string') {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
}
}
- }
- } else {
+ } else {
// Otherwise, iterate through all of the keys in the object.
- for (k in value) {
- if (Object.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ for (k in value) {
+ if (Object.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
}
}
}
- }
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
- v = partial.length === 0 ? '{}' :
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
- mind + '}' : '{' + partial.join(',') + '}';
- gap = mind;
- return v;
+ v = partial.length === 0 ? '{}' :
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
+ mind + '}' : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
}
}
@@ -384,8 +384,8 @@ if (!this.JSON) {
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
@@ -456,9 +456,9 @@ if (!this.JSON) {
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.
-test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
-replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
-replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+ test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
diff --git a/sdk/src/third-party/easyXDM/name.html b/sdk/src/third-party/easyXDM/name.html
index 137ef91e..1b12b9c5 100644
--- a/sdk/src/third-party/easyXDM/name.html
+++ b/sdk/src/third-party/easyXDM/name.html
@@ -1,58 +1,58 @@
-
-
-
-
-
-
-
-
+ }
+
+
diff --git a/sdk/src/third-party/easyXDM/tests/easyTest.js b/sdk/src/third-party/easyXDM/tests/easyTest.js
index 1da48125..8d61674c 100644
--- a/sdk/src/third-party/easyXDM/tests/easyTest.js
+++ b/sdk/src/third-party/easyXDM/tests/easyTest.js
@@ -1,4 +1,4 @@
-var easyTest = (function(){
+var easyTest = (function () {
var _messages;
var _start;
var MessageType = {
@@ -6,13 +6,13 @@ var easyTest = (function(){
Success: 2,
Info: 3
};
-
+
/**
* Logs the message to the body
* @param {String} msg The message to displey
* @param {MessageType} type The messagetype
*/
- function _log(msg, type){
+ function _log(msg, type) {
var el = _messages.appendChild(document.createElement("div"));
el.innerHTML = msg;
_messages.scrollTop = _messages.scrollHeight;
@@ -28,61 +28,61 @@ var easyTest = (function(){
break;
}
}
-
+
var Assert = {
// Type checks
- isTypeOf: function(type, obj){
+ isTypeOf: function (type, obj) {
return typeof obj === type;
},
- isInstanceOf: function(type, obj){
+ isInstanceOf: function (type, obj) {
return obj instanceof type;
},
- isString: function(obj){
+ isString: function (obj) {
return this.isTypeOf("string", obj);
},
- isNumber: function(obj){
+ isNumber: function (obj) {
return this.isTypeOf("number", obj);
},
- isObject: function(obj){
+ isObject: function (obj) {
return this.isTypeOf("object", obj);
},
- isBoolean: function(obj){
+ isBoolean: function (obj) {
return this.isTypeOf("boolean", obj);
},
- isFunction: function(obj){
+ isFunction: function (obj) {
return this.isTypeOf("function", obj);
},
// Equality
- areEqual: function(a, b){
+ areEqual: function (a, b) {
return a == b;
},
- areNotEqual: function(a, b){
+ areNotEqual: function (a, b) {
return a != b;
},
// Identical
- areSame: function(a, b){
+ areSame: function (a, b) {
return a === b;
},
- areNotSame: function(a, b){
+ areNotSame: function (a, b) {
return a !== b;
}
-
+
};
-
- function Test(test, fn){
+
+ function Test(test, fn) {
var _scope, _steps = test.steps, _step, _stepIndex = 0;
var _timer, _runStep, _startedAt, _stepStartedAt;
-
+
/**
* Clean up and tear down the test.
* Calls back to notify that the test is complete
*/
- function _endTest(){
+ function _endTest() {
// Tear down the test
if (test.tearDown) {
try {
test.tearDown.call(_scope);
- }
+ }
catch (ex) {
_log("Teardown '" + ex.message + "(" + ex.fileName + ", " + ex.lineNumber + ")" + "'", MessageType.Error);
}
@@ -92,23 +92,23 @@ var easyTest = (function(){
delete _scope[key];
}
}
-
+
// Call back
fn();
}
-
+
/**
* Used to notify the framework of the result of the test
* @param {String} name The name of the test
* @param {Boolean} result The result of the test
* @param {String} reason An optional reason why the test returned the result
*/
- function _notifyResult(name, result, reason){
+ function _notifyResult(name, result, reason) {
var now = new Date().getTime();
var testsetTime = now - _start.getTime();
var testTime = now - _startedAt.getTime();
var stepTime = now - _stepStartedAt.getTime();
-
+
var times = testsetTime + "ms, " + testTime + "ms, " + stepTime + "ms - ";
if (result) {
_log(times + name + " succeeded! " + (reason || ""), MessageType.Success);
@@ -122,7 +122,7 @@ var easyTest = (function(){
// Go to next step
if (result) {
_stepIndex++;
- window.setTimeout(function(){
+ window.setTimeout(function () {
_runStep();
}, 0);
}
@@ -130,24 +130,24 @@ var easyTest = (function(){
_endTest();
}
}
-
-
+
+
/**
* Runs through the test step
*/
- _runStep = function(){
+ _runStep = function () {
if (_stepIndex < _steps.length) {
// We still have steps to run
_step = _steps[_stepIndex];
_stepStartedAt = new Date();
if (_step.timeout) {
// This an asynchronous test
- _timer = window.setTimeout(function(){
+ _timer = window.setTimeout(function () {
_notifyResult(_step.name, false, "Failed due to timeout.");
}, _step.timeout);
try {
_step.run.call(_scope);
- }
+ }
catch (ex) {
//If it fails we cancel the timeout
window.clearTimeout(_timer);
@@ -159,7 +159,7 @@ var easyTest = (function(){
try {
var result = _step.run.call(_scope);
_notifyResult(_step.name, result);
- }
+ }
catch (ex) {
_notifyResult(_step.name, false, "'" + ex.message + "(" + ex.fileName + ", " + ex.lineNumber + ")" + "'");
}
@@ -169,13 +169,13 @@ var easyTest = (function(){
_endTest();
}
};
-
+
return {
/**
* Runs the test.
* Will first try to execute the setup method before continuing the steps
*/
- run: function(){
+ run: function () {
var excuse;
if (test.runIf) {
excuse = test.runIf();
@@ -189,7 +189,7 @@ var easyTest = (function(){
_scope = {
Assert: Assert,
log: _log,
- notifyResult: function(result){
+ notifyResult: function (result) {
window.clearTimeout(_timer);
_notifyResult(_step.name, result);
}
@@ -199,7 +199,7 @@ var easyTest = (function(){
try {
test.setUp.call(_scope);
_log("Setup succeeded", MessageType.Success);
- }
+ }
catch (ex) {
_log("Setup failed", MessageType.Error);
}
@@ -210,15 +210,15 @@ var easyTest = (function(){
}
};
}
-
+
return {
/**
* Runs through all the tests
* @param {Array} tests The tests to run
*/
- test: function(testset){
+ test: function (testset) {
var tests = [], testConfig, i = testset.length, test;
-
+
// Prepare the messaging facilities
if (!_messages) {
_messages = document.createElement("div");
@@ -228,7 +228,7 @@ var easyTest = (function(){
else {
_messages.innerHTML = "";
}
-
+
// Convert the testset
while (i--) {
testConfig = testset[i];
@@ -238,13 +238,13 @@ var easyTest = (function(){
steps: testConfig
};
}
-
- tests.push(new Test(testConfig, function(){
+
+ tests.push(new Test(testConfig, function () {
// Get the next test to run
test = tests.pop();
if (test) {
// This is needed to avoid a strange bug in Opera,
- window.setTimeout(function(){
+ window.setTimeout(function () {
test.run();
}, 0);
}
diff --git a/sdk/src/third-party/easyXDM/tests/easyXDM.debug.js b/sdk/src/third-party/easyXDM/tests/easyXDM.debug.js
index 2ee6f377..ccccbb83 100644
--- a/sdk/src/third-party/easyXDM/tests/easyXDM.debug.js
+++ b/sdk/src/third-party/easyXDM/tests/easyXDM.debug.js
@@ -1,6 +1,6 @@
(function (window, document, location, setTimeout, decodeURIComponent, encodeURIComponent) {
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global JSON, XMLHttpRequest, window, escape, unescape, ActiveXObject */
//
// easyXDM
// http://easyxdm.net/
@@ -25,847 +25,847 @@
// THE SOFTWARE.
//
-var global = this;
-var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
-var emptyFn = Function.prototype;
-var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
-var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
-var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
-var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
-var easyXDM = {};
-var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
-var IFRAME_PREFIX = "easyXDM_";
-var HAS_NAME_PROPERTY_BUG;
-var useHash = false; // whether to use the hash over the query
-var flashVersion; // will be set if using flash
-var HAS_FLASH_THROTTLED_BUG;
-var _trace = emptyFn;
+ var global = this;
+ var channelId = Math.floor(Math.random() * 10000); // randomize the initial id in case of multiple closures loaded
+ var emptyFn = Function.prototype;
+ var reURI = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/; // returns groups for protocol (2), domain (3) and port (4)
+ var reParent = /[\-\w]+\/\.\.\//; // matches a foo/../ expression
+ var reDoubleSlash = /([^:])\/\//g; // matches // anywhere but in the protocol
+ var namespace = ""; // stores namespace under which easyXDM object is stored on the page (empty if object is global)
+ var easyXDM = {};
+ var _easyXDM = window.easyXDM; // map over global easyXDM in case of overwrite
+ var IFRAME_PREFIX = "easyXDM_";
+ var HAS_NAME_PROPERTY_BUG;
+ var useHash = false; // whether to use the hash over the query
+ var flashVersion; // will be set if using flash
+ var HAS_FLASH_THROTTLED_BUG;
+ var _trace = emptyFn;
// http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
-function isHostMethod(object, property){
- var t = typeof object[property];
- return t == 'function' ||
- (!!(t == 'object' && object[property])) ||
- t == 'unknown';
-}
+ function isHostMethod(object, property) {
+ var t = typeof object[property];
+ return t == 'function' ||
+ (!!(t == 'object' && object[property])) ||
+ t == 'unknown';
+ }
-function isHostObject(object, property){
- return !!(typeof(object[property]) == 'object' && object[property]);
-}
+ function isHostObject(object, property) {
+ return !!(typeof(object[property]) == 'object' && object[property]);
+ }
// end
// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/
-function isArray(o){
- return Object.prototype.toString.call(o) === '[object Array]';
-}
+ function isArray(o) {
+ return Object.prototype.toString.call(o) === '[object Array]';
+ }
// end
-function hasFlash(){
- var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
-
- if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
- // adapted from the swfobject code
- var description = navigator.plugins[name].description;
- if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
- flashVersion = description.match(/\d+/g);
+ function hasFlash() {
+ var name = "Shockwave Flash", mimeType = "application/x-shockwave-flash";
+
+ if (!undef(navigator.plugins) && typeof navigator.plugins[name] == "object") {
+ // adapted from the swfobject code
+ var description = navigator.plugins[name].description;
+ if (description && !undef(navigator.mimeTypes) && navigator.mimeTypes[mimeType] && navigator.mimeTypes[mimeType].enabledPlugin) {
+ flashVersion = description.match(/\d+/g);
+ }
}
- }
- if (!flashVersion) {
- var flash;
- try {
- flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
- flash = null;
- }
- catch (notSupportedException) {
+ if (!flashVersion) {
+ var flash;
+ try {
+ flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ flashVersion = Array.prototype.slice.call(flash.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1);
+ flash = null;
+ }
+ catch (notSupportedException) {
+ }
+ }
+ if (!flashVersion) {
+ return false;
}
+ var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
+ HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
+ return true;
}
- if (!flashVersion) {
- return false;
+
+ /*
+ * Cross Browser implementation for adding and removing event listeners.
+ */
+ var on, un;
+ if (isHostMethod(window, "addEventListener")) {
+ on = function (target, type, listener) {
+ _trace("adding listener " + type);
+ target.addEventListener(type, listener, false);
+ };
+ un = function (target, type, listener) {
+ _trace("removing listener " + type);
+ target.removeEventListener(type, listener, false);
+ };
}
- var major = parseInt(flashVersion[0], 10), minor = parseInt(flashVersion[1], 10);
- HAS_FLASH_THROTTLED_BUG = major > 9 && minor > 0;
- return true;
-}
-
-/*
- * Cross Browser implementation for adding and removing event listeners.
- */
-var on, un;
-if (isHostMethod(window, "addEventListener")) {
- on = function(target, type, listener){
- _trace("adding listener " + type);
- target.addEventListener(type, listener, false);
- };
- un = function(target, type, listener){
- _trace("removing listener " + type);
- target.removeEventListener(type, listener, false);
- };
-}
-else if (isHostMethod(window, "attachEvent")) {
- on = function(object, sEvent, fpNotify){
- _trace("adding listener " + sEvent);
- object.attachEvent("on" + sEvent, fpNotify);
- };
- un = function(object, sEvent, fpNotify){
- _trace("removing listener " + sEvent);
- object.detachEvent("on" + sEvent, fpNotify);
- };
-}
-else {
- throw new Error("Browser not supported");
-}
-
-/*
- * Cross Browser implementation of DOMContentLoaded.
- */
-var domIsReady = false, domReadyQueue = [], readyState;
-if ("readyState" in document) {
- // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
- // 'interactive' (HTML5 specs, recent WebKit builds) states.
- // https://bugs.webkit.org/show_bug.cgi?id=45119
- readyState = document.readyState;
- domIsReady = readyState == "complete" || (~ navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
-}
-else {
- // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
- // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
- // We only need a body to add elements to, so the existence of document.body is enough for us.
- domIsReady = !!document.body;
-}
-
-function dom_onReady(){
- if (domIsReady) {
- return;
+ else if (isHostMethod(window, "attachEvent")) {
+ on = function (object, sEvent, fpNotify) {
+ _trace("adding listener " + sEvent);
+ object.attachEvent("on" + sEvent, fpNotify);
+ };
+ un = function (object, sEvent, fpNotify) {
+ _trace("removing listener " + sEvent);
+ object.detachEvent("on" + sEvent, fpNotify);
+ };
}
- domIsReady = true;
- _trace("firing dom_onReady");
- for (var i = 0; i < domReadyQueue.length; i++) {
- domReadyQueue[i]();
+ else {
+ throw new Error("Browser not supported");
}
- domReadyQueue.length = 0;
-}
-
-if (!domIsReady) {
- if (isHostMethod(window, "addEventListener")) {
- on(document, "DOMContentLoaded", dom_onReady);
+ /*
+ * Cross Browser implementation of DOMContentLoaded.
+ */
+ var domIsReady = false, domReadyQueue = [], readyState;
+ if ("readyState" in document) {
+ // If browser is WebKit-powered, check for both 'loaded' (legacy browsers) and
+ // 'interactive' (HTML5 specs, recent WebKit builds) states.
+ // https://bugs.webkit.org/show_bug.cgi?id=45119
+ readyState = document.readyState;
+ domIsReady = readyState == "complete" || (~navigator.userAgent.indexOf('AppleWebKit/') && (readyState == "loaded" || readyState == "interactive"));
}
else {
- on(document, "readystatechange", function(){
- if (document.readyState == "complete") {
- dom_onReady();
- }
- });
- if (document.documentElement.doScroll && window === top) {
- var doScrollCheck = function(){
- if (domIsReady) {
- return;
- }
- // http://javascript.nwbox.com/IEContentLoaded/
- try {
- document.documentElement.doScroll("left");
- }
- catch (e) {
- setTimeout(doScrollCheck, 1);
- return;
- }
- dom_onReady();
- };
- doScrollCheck();
- }
+ // If readyState is not supported in the browser, then in order to be able to fire whenReady functions apropriately
+ // when added dynamically _after_ DOM load, we have to deduce wether the DOM is ready or not.
+ // We only need a body to add elements to, so the existence of document.body is enough for us.
+ domIsReady = !!document.body;
}
-
- // A fallback to window.onload, that will always work
- on(window, "load", dom_onReady);
-}
-/**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {Object} scope An optional scope for the function to be called with.
- */
-function whenReady(fn, scope){
- if (domIsReady) {
- fn.call(scope);
- return;
+
+ function dom_onReady() {
+ if (domIsReady) {
+ return;
+ }
+ domIsReady = true;
+ _trace("firing dom_onReady");
+ for (var i = 0; i < domReadyQueue.length; i++) {
+ domReadyQueue[i]();
+ }
+ domReadyQueue.length = 0;
}
- domReadyQueue.push(function(){
- fn.call(scope);
- });
-}
-
-/**
- * Returns an instance of easyXDM from the parent window with
- * respect to the namespace.
- *
- * @return An instance of easyXDM (in the parent window)
- */
-function getParentObject(){
- var obj = parent;
- if (namespace !== "") {
- for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
- if (!obj) {
- throw new Error(ii.slice(0, i + 1).join('.') + ' is not an object');
+
+
+ if (!domIsReady) {
+ if (isHostMethod(window, "addEventListener")) {
+ on(document, "DOMContentLoaded", dom_onReady);
+ }
+ else {
+ on(document, "readystatechange", function () {
+ if (document.readyState == "complete") {
+ dom_onReady();
+ }
+ });
+ if (document.documentElement.doScroll && window === top) {
+ var doScrollCheck = function () {
+ if (domIsReady) {
+ return;
+ }
+ // http://javascript.nwbox.com/IEContentLoaded/
+ try {
+ document.documentElement.doScroll("left");
+ }
+ catch (e) {
+ setTimeout(doScrollCheck, 1);
+ return;
+ }
+ dom_onReady();
+ };
+ doScrollCheck();
}
- obj = obj[ii[i]];
}
+
+ // A fallback to window.onload, that will always work
+ on(window, "load", dom_onReady);
}
- if (!obj || !obj.easyXDM) {
- throw new Error('Could not find easyXDM in parent.' + namespace);
- }
- return obj.easyXDM;
-}
-
-/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
- */
-function noConflict(ns){
- if (typeof ns != "string" || !ns) {
- throw new Error('namespace must be a non-empty string');
- }
- _trace("Settings namespace to '" + ns + "'");
-
- window.easyXDM = _easyXDM;
- namespace = ns;
- if (namespace) {
- IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
- }
- return easyXDM;
-}
-
-/*
- * Methods for working with URLs
- */
-/**
- * Get the domain name from a url.
- * @param {String} url The url to extract the domain from.
- * @return The domain part of the url.
- * @type {String}
- */
-function getDomainName(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
- return url.match(reURI)[3];
-}
-
-/**
- * Get the port for a given URL, or "" if none
- * @param {String} url The url to extract the port from.
- * @return The port part of the url.
- * @type {String}
- */
-function getPort(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
- return url.match(reURI)[4] || "";
-}
-
-/**
- * Returns a string containing the schema, domain and if present the port
- * @param {String} url The url to extract the location from
- * @return {String} The location part of the url
- */
-function getLocation(url){
- if (!url) {
- throw new Error("url is undefined or empty");
- }
- if (/^file/.test(url)) {
- throw new Error("The file:// protocol is not supported");
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {Object} scope An optional scope for the function to be called with.
+ */
+ function whenReady(fn, scope) {
+ if (domIsReady) {
+ fn.call(scope);
+ return;
+ }
+ domReadyQueue.push(function () {
+ fn.call(scope);
+ });
}
- var m = url.toLowerCase().match(reURI);
- var proto = m[2], domain = m[3], port = m[4] || "";
- if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
- port = "";
+
+ /**
+ * Returns an instance of easyXDM from the parent window with
+ * respect to the namespace.
+ *
+ * @return An instance of easyXDM (in the parent window)
+ */
+ function getParentObject() {
+ var obj = parent;
+ if (namespace !== "") {
+ for (var i = 0, ii = namespace.split("."); i < ii.length; i++) {
+ if (!obj) {
+ throw new Error(ii.slice(0, i + 1).join('.') + ' is not an object');
+ }
+ obj = obj[ii[i]];
+ }
+ }
+ if (!obj || !obj.easyXDM) {
+ throw new Error('Could not find easyXDM in parent.' + namespace);
+ }
+ return obj.easyXDM;
}
- return proto + "//" + domain + port;
-}
-
-/**
- * Resolves a relative url into an absolute one.
- * @param {String} url The path to resolve.
- * @return {String} The resolved url.
- */
-function resolveUrl(url){
- if (!url) {
- throw new Error("url is undefined or empty");
+
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ function noConflict(ns) {
+ if (typeof ns != "string" || !ns) {
+ throw new Error('namespace must be a non-empty string');
+ }
+ _trace("Settings namespace to '" + ns + "'");
+
+ window.easyXDM = _easyXDM;
+ namespace = ns;
+ if (namespace) {
+ IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_";
+ }
+ return easyXDM;
}
-
- // replace all // except the one in proto with /
- url = url.replace(reDoubleSlash, "$1/");
-
- // If the url is a valid url we do nothing
- if (!url.match(/^(http||https):\/\//)) {
- // If this is a relative path
- var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
- if (path.substring(path.length - 1) !== "/") {
- path = path.substring(0, path.lastIndexOf("/") + 1);
- }
-
- url = location.protocol + "//" + location.host + path + url;
+
+ /*
+ * Methods for working with URLs
+ */
+ /**
+ * Get the domain name from a url.
+ * @param {String} url The url to extract the domain from.
+ * @return The domain part of the url.
+ * @type {String}
+ */
+ function getDomainName(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ return url.match(reURI)[3];
}
-
- // reduce all 'xyz/../' to just ''
- while (reParent.test(url)) {
- url = url.replace(reParent, "");
+
+ /**
+ * Get the port for a given URL, or "" if none
+ * @param {String} url The url to extract the port from.
+ * @return The port part of the url.
+ * @type {String}
+ */
+ function getPort(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ return url.match(reURI)[4] || "";
}
-
- _trace("resolved url '" + url + "'");
- return url;
-}
-
-/**
- * Appends the parameters to the given url.
- * The base url can contain existing query parameters.
- * @param {String} url The base url.
- * @param {Object} parameters The parameters to add.
- * @return {String} A new valid url with the parameters appended.
- */
-function appendQueryParameters(url, parameters){
- if (!parameters) {
- throw new Error("parameters is undefined or null");
+
+ /**
+ * Returns a string containing the schema, domain and if present the port
+ * @param {String} url The url to extract the location from
+ * @return {String} The location part of the url
+ */
+ function getLocation(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+ if (/^file/.test(url)) {
+ throw new Error("The file:// protocol is not supported");
+ }
+ var m = url.toLowerCase().match(reURI);
+ var proto = m[2], domain = m[3], port = m[4] || "";
+ if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) {
+ port = "";
+ }
+ return proto + "//" + domain + port;
}
-
- var hash = "", indexOf = url.indexOf("#");
- if (indexOf !== -1) {
- hash = url.substring(indexOf);
- url = url.substring(0, indexOf);
+
+ /**
+ * Resolves a relative url into an absolute one.
+ * @param {String} url The path to resolve.
+ * @return {String} The resolved url.
+ */
+ function resolveUrl(url) {
+ if (!url) {
+ throw new Error("url is undefined or empty");
+ }
+
+ // replace all // except the one in proto with /
+ url = url.replace(reDoubleSlash, "$1/");
+
+ // If the url is a valid url we do nothing
+ if (!url.match(/^(http||https):\/\//)) {
+ // If this is a relative path
+ var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
+ if (path.substring(path.length - 1) !== "/") {
+ path = path.substring(0, path.lastIndexOf("/") + 1);
+ }
+
+ url = location.protocol + "//" + location.host + path + url;
+ }
+
+ // reduce all 'xyz/../' to just ''
+ while (reParent.test(url)) {
+ url = url.replace(reParent, "");
+ }
+
+ _trace("resolved url '" + url + "'");
+ return url;
}
- var q = [];
- for (var key in parameters) {
- if (parameters.hasOwnProperty(key)) {
- q.push(key + "=" + encodeURIComponent(parameters[key]));
+
+ /**
+ * Appends the parameters to the given url.
+ * The base url can contain existing query parameters.
+ * @param {String} url The base url.
+ * @param {Object} parameters The parameters to add.
+ * @return {String} A new valid url with the parameters appended.
+ */
+ function appendQueryParameters(url, parameters) {
+ if (!parameters) {
+ throw new Error("parameters is undefined or null");
}
+
+ var hash = "", indexOf = url.indexOf("#");
+ if (indexOf !== -1) {
+ hash = url.substring(indexOf);
+ url = url.substring(0, indexOf);
+ }
+ var q = [];
+ for (var key in parameters) {
+ if (parameters.hasOwnProperty(key)) {
+ q.push(key + "=" + encodeURIComponent(parameters[key]));
+ }
+ }
+ return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
}
- return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
-}
// build the query object either from location.query, if it contains the xdm_e argument, or from location.hash
-var query = (function(input){
- input = input.substring(1).split("&");
- var data = {}, pair, i = input.length;
- while (i--) {
- pair = input[i].split("=");
- data[pair[0]] = decodeURIComponent(pair[1]);
- }
- return data;
-}(/xdm_e=/.test(location.search) ? location.search : location.hash));
-
-/*
- * Helper methods
- */
-/**
- * Helper for checking if a variable/property is undefined
- * @param {Object} v The variable to test
- * @return {Boolean} True if the passed variable is undefined
- */
-function undef(v){
- return typeof v === "undefined";
-}
-
-/**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
- */
-var getJSON = function(){
- var cached = {};
- var obj = {
- a: [1, 2, 3]
- }, json = "{\"a\":[1,2,3]}";
-
- if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
- // this is a working JSON instance
- return JSON;
- }
- if (Object.toJSON) {
- if (Object.toJSON(obj).replace((/\s/g), "") === json) {
- // this is a working stringify method
- cached.stringify = Object.toJSON;
+ var query = (function (input) {
+ input = input.substring(1).split("&");
+ var data = {}, pair, i = input.length;
+ while (i--) {
+ pair = input[i].split("=");
+ data[pair[0]] = decodeURIComponent(pair[1]);
}
+ return data;
+ }(/xdm_e=/.test(location.search) ? location.search : location.hash));
+
+ /*
+ * Helper methods
+ */
+ /**
+ * Helper for checking if a variable/property is undefined
+ * @param {Object} v The variable to test
+ * @return {Boolean} True if the passed variable is undefined
+ */
+ function undef(v) {
+ return typeof v === "undefined";
}
-
- if (typeof String.prototype.evalJSON === "function") {
- obj = json.evalJSON();
- if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
- // this is a working parse method
- cached.parse = function(str){
- return str.evalJSON();
- };
+
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ var getJSON = function () {
+ var cached = {};
+ var obj = {
+ a: [1, 2, 3]
+ }, json = "{\"a\":[1,2,3]}";
+
+ if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) {
+ // this is a working JSON instance
+ return JSON;
}
- }
-
- if (cached.stringify && cached.parse) {
- // Only memoize the result if we have valid instance
- getJSON = function(){
+ if (Object.toJSON) {
+ if (Object.toJSON(obj).replace((/\s/g), "") === json) {
+ // this is a working stringify method
+ cached.stringify = Object.toJSON;
+ }
+ }
+
+ if (typeof String.prototype.evalJSON === "function") {
+ obj = json.evalJSON();
+ if (obj.a && obj.a.length === 3 && obj.a[2] === 3) {
+ // this is a working parse method
+ cached.parse = function (str) {
+ return str.evalJSON();
+ };
+ }
+ }
+
+ if (cached.stringify && cached.parse) {
+ // Only memoize the result if we have valid instance
+ getJSON = function () {
+ return cached;
+ };
return cached;
- };
- return cached;
- }
- return null;
-};
-
-/**
- * Applies properties from the source object to the target object.
- * @param {Object} target The target of the properties.
- * @param {Object} source The source of the properties.
- * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
- */
-function apply(destination, source, noOverwrite){
- var member;
- for (var prop in source) {
- if (source.hasOwnProperty(prop)) {
- if (prop in destination) {
- member = source[prop];
- if (typeof member === "object") {
- apply(destination[prop], member, noOverwrite);
- }
- else if (!noOverwrite) {
+ }
+ return null;
+ };
+
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {Object} target The target of the properties.
+ * @param {Object} source The source of the properties.
+ * @param {Boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ function apply(destination, source, noOverwrite) {
+ var member;
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ if (prop in destination) {
+ member = source[prop];
+ if (typeof member === "object") {
+ apply(destination[prop], member, noOverwrite);
+ }
+ else if (!noOverwrite) {
+ destination[prop] = source[prop];
+ }
+ }
+ else {
destination[prop] = source[prop];
}
}
- else {
- destination[prop] = source[prop];
- }
}
+ return destination;
}
- return destination;
-}
// This tests for the bug in IE where setting the [name] property using javascript causes the value to be redirected into [submitName].
-function testForNamePropertyBug(){
- var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
- input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
- HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
- document.body.removeChild(form);
- _trace("HAS_NAME_PROPERTY_BUG: " + HAS_NAME_PROPERTY_BUG);
-}
-
-/**
- * Creates a frame and appends it to the DOM.
- * @param config {object} This object can have the following properties
- *
- * {object} prop The properties that should be set on the frame. This should include the 'src' property.
- * {object} attr The attributes that should be set on the frame.
- * {DOMElement} container Its parent element (Optional).
- * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
- *
- * @return The frames DOMElement
- * @type DOMElement
- */
-function createFrame(config){
- _trace("creating frame: " + config.props.src);
- if (undef(HAS_NAME_PROPERTY_BUG)) {
- testForNamePropertyBug();
+ function testForNamePropertyBug() {
+ var form = document.body.appendChild(document.createElement("form")), input = form.appendChild(document.createElement("input"));
+ input.name = IFRAME_PREFIX + "TEST" + channelId; // append channelId in order to avoid caching issues
+ HAS_NAME_PROPERTY_BUG = input !== form.elements[input.name];
+ document.body.removeChild(form);
+ _trace("HAS_NAME_PROPERTY_BUG: " + HAS_NAME_PROPERTY_BUG);
}
- var frame;
- // This is to work around the problems in IE6/7 with setting the name property.
- // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
- // This is not required by easyXDM itself, but is to facilitate other use cases
- if (HAS_NAME_PROPERTY_BUG) {
- frame = document.createElement("
");
- }
- else {
- frame = document.createElement("IFRAME");
- frame.name = config.props.name;
- }
-
- frame.id = frame.name = config.props.name;
- delete config.props.name;
-
- if (typeof config.container == "string") {
- config.container = document.getElementById(config.container);
- }
-
- if (!config.container) {
- // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
- apply(frame.style, {
- position: "absolute",
- top: "-2000px",
- // Avoid potential horizontal scrollbar
- left: "0px"
- });
- config.container = document.body;
- }
-
- // HACK: IE cannot have the src attribute set when the frame is appended
- // into the container, so we set it to "javascript:false" as a
- // placeholder for now. If we left the src undefined, it would
- // instead default to "about:blank", which causes SSL mixed-content
- // warnings in IE6 when on an SSL parent page.
- var src = config.props.src;
- config.props.src = "javascript:false";
-
- // transfer properties to the frame
- apply(frame, config.props);
-
- frame.border = frame.frameBorder = 0;
- frame.allowTransparency = true;
- config.container.appendChild(frame);
-
- if (config.onLoad) {
- on(frame, "load", config.onLoad);
- }
-
- // set the frame URL to the proper value (we previously set it to
- // "javascript:false" to work around the IE issue mentioned above)
- if(config.usePost) {
- var form = config.container.appendChild(document.createElement('form')), input;
- form.target = frame.name;
- form.action = src;
- form.method = 'POST';
- if (typeof(config.usePost) === 'object') {
- for (var i in config.usePost) {
- if (config.usePost.hasOwnProperty(i)) {
- if (HAS_NAME_PROPERTY_BUG) {
- input = document.createElement('
');
- } else {
- input = document.createElement("INPUT");
- input.name = i;
+
+ /**
+ * Creates a frame and appends it to the DOM.
+ * @param config {object} This object can have the following properties
+ *
+ * {object} prop The properties that should be set on the frame. This should include the 'src' property.
+ * {object} attr The attributes that should be set on the frame.
+ * {DOMElement} container Its parent element (Optional).
+ * {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)
+ *
+ * @return The frames DOMElement
+ * @type DOMElement
+ */
+ function createFrame(config) {
+ _trace("creating frame: " + config.props.src);
+ if (undef(HAS_NAME_PROPERTY_BUG)) {
+ testForNamePropertyBug();
+ }
+ var frame;
+ // This is to work around the problems in IE6/7 with setting the name property.
+ // Internally this is set as 'submitName' instead when using 'iframe.name = ...'
+ // This is not required by easyXDM itself, but is to facilitate other use cases
+ if (HAS_NAME_PROPERTY_BUG) {
+ frame = document.createElement("
");
+ }
+ else {
+ frame = document.createElement("IFRAME");
+ frame.name = config.props.name;
+ }
+
+ frame.id = frame.name = config.props.name;
+ delete config.props.name;
+
+ if (typeof config.container == "string") {
+ config.container = document.getElementById(config.container);
+ }
+
+ if (!config.container) {
+ // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.
+ apply(frame.style, {
+ position: "absolute",
+ top: "-2000px",
+ // Avoid potential horizontal scrollbar
+ left: "0px"
+ });
+ config.container = document.body;
+ }
+
+ // HACK: IE cannot have the src attribute set when the frame is appended
+ // into the container, so we set it to "javascript:false" as a
+ // placeholder for now. If we left the src undefined, it would
+ // instead default to "about:blank", which causes SSL mixed-content
+ // warnings in IE6 when on an SSL parent page.
+ var src = config.props.src;
+ config.props.src = "javascript:false";
+
+ // transfer properties to the frame
+ apply(frame, config.props);
+
+ frame.border = frame.frameBorder = 0;
+ frame.allowTransparency = true;
+ config.container.appendChild(frame);
+
+ if (config.onLoad) {
+ on(frame, "load", config.onLoad);
+ }
+
+ // set the frame URL to the proper value (we previously set it to
+ // "javascript:false" to work around the IE issue mentioned above)
+ if (config.usePost) {
+ var form = config.container.appendChild(document.createElement('form')), input;
+ form.target = frame.name;
+ form.action = src;
+ form.method = 'POST';
+ if (typeof(config.usePost) === 'object') {
+ for (var i in config.usePost) {
+ if (config.usePost.hasOwnProperty(i)) {
+ if (HAS_NAME_PROPERTY_BUG) {
+ input = document.createElement('
');
+ } else {
+ input = document.createElement("INPUT");
+ input.name = i;
+ }
+ input.value = config.usePost[i];
+ form.appendChild(input);
}
- input.value = config.usePost[i];
- form.appendChild(input);
}
}
+ form.submit();
+ form.parentNode.removeChild(form);
+ } else {
+ frame.src = src;
}
- form.submit();
- form.parentNode.removeChild(form);
- } else {
- frame.src = src;
- }
- config.props.src = src;
-
- return frame;
-}
-
-/**
- * Check whether a domain is allowed using an Access Control List.
- * The ACL can contain * and ? as wildcards, or can be regular expressions.
- * If regular expressions they need to begin with ^ and end with $.
- * @param {Array/String} acl The list of allowed domains
- * @param {String} domain The domain to test.
- * @return {Boolean} True if the domain is allowed, false if not.
- */
-function checkAcl(acl, domain){
- // normalize into an array
- if (typeof acl == "string") {
- acl = [acl];
+ config.props.src = src;
+
+ return frame;
}
- var re, i = acl.length;
- while (i--) {
- re = acl[i];
- re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
- if (re.test(domain)) {
- return true;
+
+ /**
+ * Check whether a domain is allowed using an Access Control List.
+ * The ACL can contain * and ? as wildcards, or can be regular expressions.
+ * If regular expressions they need to begin with ^ and end with $.
+ * @param {Array/String} acl The list of allowed domains
+ * @param {String} domain The domain to test.
+ * @return {Boolean} True if the domain is allowed, false if not.
+ */
+ function checkAcl(acl, domain) {
+ // normalize into an array
+ if (typeof acl == "string") {
+ acl = [acl];
}
- }
- return false;
-}
-
-/*
- * Functions related to stacks
- */
-/**
- * Prepares an array of stack-elements suitable for the current configuration
- * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
- * @return {Array} An array of stack-elements with the TransportElement at index 0.
- */
-function prepareTransportStack(config){
- var protocol = config.protocol, stackEls;
- config.isHost = config.isHost || undef(query.xdm_p);
- useHash = config.hash || false;
- _trace("preparing transport stack");
-
- if (!config.props) {
- config.props = {};
- }
- if (!config.isHost) {
- _trace("using parameters from query");
- config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
- config.secret = query.xdm_s;
- config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
- ;
- protocol = query.xdm_p;
- if (config.acl && !checkAcl(config.acl, config.remote)) {
- throw new Error("Access denied for " + config.remote);
+ var re, i = acl.length;
+ while (i--) {
+ re = acl[i];
+ re = new RegExp(re.substr(0, 1) == "^" ? re : ("^" + re.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"));
+ if (re.test(domain)) {
+ return true;
+ }
}
+ return false;
}
- else {
- config.remote = resolveUrl(config.remote);
- config.channel = config.channel || "default" + channelId++;
- config.secret = Math.random().toString(16).substring(2);
- if (undef(protocol)) {
- if (getLocation(location.href) == getLocation(config.remote)) {
- /*
- * Both documents has the same origin, lets use direct access.
- */
- protocol = "4";
- }
- else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
- /*
- * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
- */
- protocol = "1";
- }
- else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
- /*
- * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
- */
- protocol = "6";
- }
- else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
- /*
- * This is supported in Gecko (Firefox 1+)
- */
- protocol = "5";
+
+ /*
+ * Functions related to stacks
+ */
+ /**
+ * Prepares an array of stack-elements suitable for the current configuration
+ * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
+ * @return {Array} An array of stack-elements with the TransportElement at index 0.
+ */
+ function prepareTransportStack(config) {
+ var protocol = config.protocol, stackEls;
+ config.isHost = config.isHost || undef(query.xdm_p);
+ useHash = config.hash || false;
+ _trace("preparing transport stack");
+
+ if (!config.props) {
+ config.props = {};
+ }
+ if (!config.isHost) {
+ _trace("using parameters from query");
+ config.channel = query.xdm_c.replace(/["'<>\\]/g, "");
+ config.secret = query.xdm_s;
+ config.remote = query.xdm_e.replace(/["'<>\\]/g, "");
+ ;
+ protocol = query.xdm_p;
+ if (config.acl && !checkAcl(config.acl, config.remote)) {
+ throw new Error("Access denied for " + config.remote);
}
- else if (config.remoteHelper) {
- /*
- * This is supported in all browsers that retains the value of window.name when
- * navigating from one domain to another, and where parent.frames[foo] can be used
- * to get access to a frame from the same domain
- */
- protocol = "2";
+ }
+ else {
+ config.remote = resolveUrl(config.remote);
+ config.channel = config.channel || "default" + channelId++;
+ config.secret = Math.random().toString(16).substring(2);
+ if (undef(protocol)) {
+ if (getLocation(location.href) == getLocation(config.remote)) {
+ /*
+ * Both documents has the same origin, lets use direct access.
+ */
+ protocol = "4";
+ }
+ else if (isHostMethod(window, "postMessage") || isHostMethod(document, "postMessage")) {
+ /*
+ * This is supported in IE8+, Firefox 3+, Opera 9+, Chrome 2+ and Safari 4+
+ */
+ protocol = "1";
+ }
+ else if (config.swf && isHostMethod(window, "ActiveXObject") && hasFlash()) {
+ /*
+ * The Flash transport superseedes the NixTransport as the NixTransport has been blocked by MS
+ */
+ protocol = "6";
+ }
+ else if (navigator.product === "Gecko" && "frameElement" in window && navigator.userAgent.indexOf('WebKit') == -1) {
+ /*
+ * This is supported in Gecko (Firefox 1+)
+ */
+ protocol = "5";
+ }
+ else if (config.remoteHelper) {
+ /*
+ * This is supported in all browsers that retains the value of window.name when
+ * navigating from one domain to another, and where parent.frames[foo] can be used
+ * to get access to a frame from the same domain
+ */
+ protocol = "2";
+ }
+ else {
+ /*
+ * This is supported in all browsers where [window].location is writable for all
+ * The resize event will be used if resize is supported and the iframe is not put
+ * into a container, else polling will be used.
+ */
+ protocol = "0";
+ }
+ _trace("selecting protocol: " + protocol);
}
else {
- /*
- * This is supported in all browsers where [window].location is writable for all
- * The resize event will be used if resize is supported and the iframe is not put
- * into a container, else polling will be used.
- */
- protocol = "0";
+ _trace("using protocol: " + protocol);
}
- _trace("selecting protocol: " + protocol);
}
- else {
- _trace("using protocol: " + protocol);
- }
- }
- config.protocol = protocol; // for conditional branching
- switch (protocol) {
- case "0":// 0 = HashTransport
- apply(config, {
- interval: 100,
- delay: 2000,
- useResize: true,
- useParent: false,
- usePolling: false
- }, true);
- if (config.isHost) {
- if (!config.local) {
- _trace("looking for image to use as local");
- // If no local is set then we need to find an image hosted on the current domain
- var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
- var i = images.length;
- while (i--) {
- image = images[i];
- if (image.src.substring(0, domain.length) === domain) {
- config.local = image.src;
- break;
+ config.protocol = protocol; // for conditional branching
+ switch (protocol) {
+ case "0":// 0 = HashTransport
+ apply(config, {
+ interval: 100,
+ delay: 2000,
+ useResize: true,
+ useParent: false,
+ usePolling: false
+ }, true);
+ if (config.isHost) {
+ if (!config.local) {
+ _trace("looking for image to use as local");
+ // If no local is set then we need to find an image hosted on the current domain
+ var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), image;
+ var i = images.length;
+ while (i--) {
+ image = images[i];
+ if (image.src.substring(0, domain.length) === domain) {
+ config.local = image.src;
+ break;
+ }
+ }
+ if (!config.local) {
+ _trace("no image found, defaulting to using the window");
+ // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
+ config.local = window;
}
}
- if (!config.local) {
- _trace("no image found, defaulting to using the window");
- // If no local was set, and we are unable to find a suitable file, then we resort to using the current window
- config.local = window;
+
+ var parameters = {
+ xdm_c: config.channel,
+ xdm_p: 0
+ };
+
+ if (config.local === window) {
+ // We are using the current window to listen to
+ config.usePolling = true;
+ config.useParent = true;
+ config.local = location.protocol + "//" + location.host + location.pathname + location.search;
+ parameters.xdm_e = config.local;
+ parameters.xdm_pa = 1; // use parent
}
- }
-
- var parameters = {
- xdm_c: config.channel,
- xdm_p: 0
- };
-
- if (config.local === window) {
- // We are using the current window to listen to
- config.usePolling = true;
- config.useParent = true;
- config.local = location.protocol + "//" + location.host + location.pathname + location.search;
- parameters.xdm_e = config.local;
- parameters.xdm_pa = 1; // use parent
+ else {
+ parameters.xdm_e = resolveUrl(config.local);
+ }
+
+ if (config.container) {
+ config.useResize = false;
+ parameters.xdm_po = 1; // use polling
+ }
+ config.remote = appendQueryParameters(config.remote, parameters);
}
else {
- parameters.xdm_e = resolveUrl(config.local);
+ apply(config, {
+ channel: query.xdm_c,
+ remote: query.xdm_e,
+ useParent: !undef(query.xdm_pa),
+ usePolling: !undef(query.xdm_po),
+ useResize: config.useParent ? false : config.useResize
+ });
}
-
- if (config.container) {
- config.useResize = false;
- parameters.xdm_po = 1; // use polling
+ stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
+ encode: true,
+ maxLength: 4000 - config.remote.length
+ }), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "1":
+ stackEls = [new easyXDM.stack.PostMessageTransport(config)];
+ break;
+ case "2":
+ if (config.isHost) {
+ config.remoteHelper = resolveUrl(config.remoteHelper);
}
- config.remote = appendQueryParameters(config.remote, parameters);
- }
- else {
- apply(config, {
- channel: query.xdm_c,
- remote: query.xdm_e,
- useParent: !undef(query.xdm_pa),
- usePolling: !undef(query.xdm_po),
- useResize: config.useParent ? false : config.useResize
- });
+ stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
+ initiate: config.isHost
+ })];
+ break;
+ case "3":
+ stackEls = [new easyXDM.stack.NixTransport(config)];
+ break;
+ case "4":
+ stackEls = [new easyXDM.stack.SameOriginTransport(config)];
+ break;
+ case "5":
+ stackEls = [new easyXDM.stack.FrameElementTransport(config)];
+ break;
+ case "6":
+ if (!flashVersion) {
+ hasFlash();
+ }
+ stackEls = [new easyXDM.stack.FlashTransport(config)];
+ break;
+ }
+ // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
+ stackEls.push(new easyXDM.stack.QueueBehavior({
+ lazy: config.lazy,
+ remove: true
+ }));
+ return stackEls;
+ }
+
+ /**
+ * Chains all the separate stack elements into a single usable stack.
+ * If an element is missing a necessary method then it will have a pass-through method applied.
+ * @param {Array} stackElements An array of stack elements to be linked.
+ * @return {easyXDM.stack.StackElement} The last element in the chain.
+ */
+ function chainStack(stackElements) {
+ var stackEl, defaults = {
+ incoming: function (message, origin) {
+ this.up.incoming(message, origin);
+ },
+ outgoing: function (message, recipient) {
+ this.down.outgoing(message, recipient);
+ },
+ callback: function (success) {
+ this.up.callback(success);
+ },
+ init: function () {
+ this.down.init();
+ },
+ destroy: function () {
+ this.down.destroy();
}
- stackEls = [new easyXDM.stack.HashTransport(config), new easyXDM.stack.ReliableBehavior({}), new easyXDM.stack.QueueBehavior({
- encode: true,
- maxLength: 4000 - config.remote.length
- }), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "1":
- stackEls = [new easyXDM.stack.PostMessageTransport(config)];
- break;
- case "2":
- if (config.isHost) {
- config.remoteHelper = resolveUrl(config.remoteHelper);
+ };
+ for (var i = 0, len = stackElements.length; i < len; i++) {
+ stackEl = stackElements[i];
+ apply(stackEl, defaults, true);
+ if (i !== 0) {
+ stackEl.down = stackElements[i - 1];
}
- stackEls = [new easyXDM.stack.NameTransport(config), new easyXDM.stack.QueueBehavior(), new easyXDM.stack.VerifyBehavior({
- initiate: config.isHost
- })];
- break;
- case "3":
- stackEls = [new easyXDM.stack.NixTransport(config)];
- break;
- case "4":
- stackEls = [new easyXDM.stack.SameOriginTransport(config)];
- break;
- case "5":
- stackEls = [new easyXDM.stack.FrameElementTransport(config)];
- break;
- case "6":
- if (!flashVersion) {
- hasFlash();
+ if (i !== len - 1) {
+ stackEl.up = stackElements[i + 1];
}
- stackEls = [new easyXDM.stack.FlashTransport(config)];
- break;
- }
- // this behavior is responsible for buffering outgoing messages, and for performing lazy initialization
- stackEls.push(new easyXDM.stack.QueueBehavior({
- lazy: config.lazy,
- remove: true
- }));
- return stackEls;
-}
-
-/**
- * Chains all the separate stack elements into a single usable stack.
- * If an element is missing a necessary method then it will have a pass-through method applied.
- * @param {Array} stackElements An array of stack elements to be linked.
- * @return {easyXDM.stack.StackElement} The last element in the chain.
- */
-function chainStack(stackElements){
- var stackEl, defaults = {
- incoming: function(message, origin){
- this.up.incoming(message, origin);
- },
- outgoing: function(message, recipient){
- this.down.outgoing(message, recipient);
- },
- callback: function(success){
- this.up.callback(success);
- },
- init: function(){
- this.down.init();
- },
- destroy: function(){
- this.down.destroy();
- }
- };
- for (var i = 0, len = stackElements.length; i < len; i++) {
- stackEl = stackElements[i];
- apply(stackEl, defaults, true);
- if (i !== 0) {
- stackEl.down = stackElements[i - 1];
- }
- if (i !== len - 1) {
- stackEl.up = stackElements[i + 1];
}
+ return stackEl;
}
- return stackEl;
-}
-
-/**
- * This will remove a stackelement from its stack while leaving the stack functional.
- * @param {Object} element The elment to remove from the stack.
- */
-function removeFromStack(element){
- element.up.down = element.down;
- element.down.up = element.up;
- element.up = element.down = null;
-}
-
-/*
- * Export the main object and any other methods applicable
- */
-/**
- * @class easyXDM
- * A javascript library providing cross-browser, cross-domain messaging/RPC.
- * @version 2.4.19.3
- * @singleton
- */
-apply(easyXDM, {
- /**
- * The version of the library
- * @type {string}
- */
- version: "2.4.19.3",
- /**
- * This is a map containing all the query parameters passed to the document.
- * All the values has been decoded using decodeURIComponent.
- * @type {object}
- */
- query: query,
- /**
- * @private
- */
- stack: {},
- /**
- * Applies properties from the source object to the target object.
- * @param {object} target The target of the properties.
- * @param {object} source The source of the properties.
- * @param {boolean} noOverwrite Set to True to only set non-existing properties.
- */
- apply: apply,
-
+
/**
- * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
- * @return {JSON} A valid JSON conforming object, or null if not found.
+ * This will remove a stackelement from its stack while leaving the stack functional.
+ * @param {Object} element The elment to remove from the stack.
*/
- getJSONObject: getJSON,
- /**
- * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
- * If functions are added after this event then they will be executed immediately.
- * @param {function} fn The function to add
- * @param {object} scope An optional scope for the function to be called with.
+ function removeFromStack(element) {
+ element.up.down = element.down;
+ element.down.up = element.up;
+ element.up = element.down = null;
+ }
+
+ /*
+ * Export the main object and any other methods applicable
*/
- whenReady: whenReady,
/**
- * Removes easyXDM variable from the global scope. It also returns control
- * of the easyXDM variable to whatever code used it before.
- *
- * @param {String} ns A string representation of an object that will hold
- * an instance of easyXDM.
- * @return An instance of easyXDM
+ * @class easyXDM
+ * A javascript library providing cross-browser, cross-domain messaging/RPC.
+ * @version 2.4.19.3
+ * @singleton
*/
- noConflict: noConflict
-});
+ apply(easyXDM, {
+ /**
+ * The version of the library
+ * @type {string}
+ */
+ version: "2.4.19.3",
+ /**
+ * This is a map containing all the query parameters passed to the document.
+ * All the values has been decoded using decodeURIComponent.
+ * @type {object}
+ */
+ query: query,
+ /**
+ * @private
+ */
+ stack: {},
+ /**
+ * Applies properties from the source object to the target object.
+ * @param {object} target The target of the properties.
+ * @param {object} source The source of the properties.
+ * @param {boolean} noOverwrite Set to True to only set non-existing properties.
+ */
+ apply: apply,
+
+ /**
+ * A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works.
+ * @return {JSON} A valid JSON conforming object, or null if not found.
+ */
+ getJSONObject: getJSON,
+ /**
+ * This will add a function to the queue of functions to be run once the DOM reaches a ready state.
+ * If functions are added after this event then they will be executed immediately.
+ * @param {function} fn The function to add
+ * @param {object} scope An optional scope for the function to be called with.
+ */
+ whenReady: whenReady,
+ /**
+ * Removes easyXDM variable from the global scope. It also returns control
+ * of the easyXDM variable to whatever code used it before.
+ *
+ * @param {String} ns A string representation of an object that will hold
+ * an instance of easyXDM.
+ * @return An instance of easyXDM
+ */
+ noConflict: noConflict
+ });
// Expose helper functions so we can test them
-apply(easyXDM, {
- checkAcl: checkAcl,
- getDomainName: getDomainName,
- getLocation: getLocation,
- appendQueryParameters: appendQueryParameters
-});
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
+ apply(easyXDM, {
+ checkAcl: checkAcl,
+ getDomainName: getDomainName,
+ getLocation: getLocation,
+ appendQueryParameters: appendQueryParameters
+ });
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global console, _FirebugCommandLine, easyXDM, window, escape, unescape, isHostObject, undef, _trace, domIsReady, emptyFn, namespace */
//
// easyXDM
// http://easyxdm.net/
@@ -890,154 +890,154 @@ apply(easyXDM, {
// THE SOFTWARE.
//
-var debug = {
- _deferred: [],
- flush: function(){
- this.trace("... deferred messages ...");
- for (var i = 0, len = this._deferred.length; i < len; i++) {
- this.trace(this._deferred[i]);
- }
- this._deferred.length = 0;
- this.trace("... end of deferred messages ...");
- },
- getTime: function(){
- var d = new Date(), h = d.getHours() + "", m = d.getMinutes() + "", s = d.getSeconds() + "", ms = d.getMilliseconds() + "", zeros = "000";
- if (h.length == 1) {
- h = "0" + h;
- }
- if (m.length == 1) {
- m = "0" + m;
- }
- if (s.length == 1) {
- s = "0" + s;
- }
- ms = zeros.substring(ms.length) + ms;
- return h + ":" + m + ":" + s + "." + ms;
- },
- /**
- * Logs the message to console.log if available
- * @param {String} msg The message to log
- */
- log: function(msg){
- // Uses memoizing to cache the implementation
- if (!isHostObject(window, "console") || undef(console.log)) {
- /**
- * Sets log to be an empty function since we have no output available
- * @ignore
- */
- this.log = emptyFn;
- }
- else {
- /**
- * Sets log to be a wrapper around console.log
- * @ignore
- * @param {String} msg
- */
- this.log = function(msg){
- console.log(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ": " + msg);
- };
- }
- this.log(msg);
- },
- /**
- * Will try to trace the given message either to a DOMElement with the id "log",
- * or by using console.info.
- * @param {String} msg The message to trace
- */
- trace: function(msg){
- // Uses memoizing to cache the implementation
- if (!domIsReady) {
- if (this._deferred.length === 0) {
- easyXDM.whenReady(debug.flush, debug);
+ var debug = {
+ _deferred: [],
+ flush: function () {
+ this.trace("... deferred messages ...");
+ for (var i = 0, len = this._deferred.length; i < len; i++) {
+ this.trace(this._deferred[i]);
+ }
+ this._deferred.length = 0;
+ this.trace("... end of deferred messages ...");
+ },
+ getTime: function () {
+ var d = new Date(), h = d.getHours() + "", m = d.getMinutes() + "", s = d.getSeconds() + "", ms = d.getMilliseconds() + "", zeros = "000";
+ if (h.length == 1) {
+ h = "0" + h;
}
- this._deferred.push(msg);
- this.log(msg);
- }
- else {
- var el = document.getElementById("log");
- // is there a log element present?
- if (el) {
+ if (m.length == 1) {
+ m = "0" + m;
+ }
+ if (s.length == 1) {
+ s = "0" + s;
+ }
+ ms = zeros.substring(ms.length) + ms;
+ return h + ":" + m + ":" + s + "." + ms;
+ },
+ /**
+ * Logs the message to console.log if available
+ * @param {String} msg The message to log
+ */
+ log: function (msg) {
+ // Uses memoizing to cache the implementation
+ if (!isHostObject(window, "console") || undef(console.log)) {
/**
- * Sets trace to be a function that outputs the messages to the DOMElement with id "log"
+ * Sets log to be an empty function since we have no output available
* @ignore
- * @param {String} msg
*/
- this.trace = function(msg){
- try {
- el.appendChild(document.createElement("div")).appendChild(document.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
- el.scrollTop = el.scrollHeight;
- }
- catch (e) {
- //In case we are unloading
- }
- };
+ this.log = emptyFn;
}
- else if (isHostObject(window, "console") && !undef(console.info)) {
+ else {
/**
- * Sets trace to be a wrapper around console.info
+ * Sets log to be a wrapper around console.log
* @ignore
* @param {String} msg
*/
- this.trace = function(msg){
- console.info(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg);
+ this.log = function (msg) {
+ console.log(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ": " + msg);
};
}
- else {
- /**
- * Create log window
- * @ignore
- */
- var domain = location.host, windowname = domain.replace(/[\-.:]/g, "") + "easyxdm_log", logWin;
- try {
- logWin = window.open("", windowname, "width=800,height=200,status=0,navigation=0,scrollbars=1");
- }
- catch (e) {
+ this.log(msg);
+ },
+ /**
+ * Will try to trace the given message either to a DOMElement with the id "log",
+ * or by using console.info.
+ * @param {String} msg The message to trace
+ */
+ trace: function (msg) {
+ // Uses memoizing to cache the implementation
+ if (!domIsReady) {
+ if (this._deferred.length === 0) {
+ easyXDM.whenReady(debug.flush, debug);
}
- if (logWin) {
- var doc = logWin.document;
- el = doc.getElementById("log");
- if (!el) {
- doc.write("
easyXDM log " + domain + " ");
- doc.write("
");
- doc.close();
- el = doc.getElementById("log");
- }
- this.trace = function(msg){
+ this._deferred.push(msg);
+ this.log(msg);
+ }
+ else {
+ var el = document.getElementById("log");
+ // is there a log element present?
+ if (el) {
+ /**
+ * Sets trace to be a function that outputs the messages to the DOMElement with id "log"
+ * @ignore
+ * @param {String} msg
+ */
+ this.trace = function (msg) {
try {
- el.appendChild(doc.createElement("div")).appendChild(doc.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
+ el.appendChild(document.createElement("div")).appendChild(document.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
el.scrollTop = el.scrollHeight;
- }
+ }
catch (e) {
//In case we are unloading
}
};
- this.trace("---- new logger at " + location.href);
}
-
- if (!el) {
- // We are unable to use any logging
- this.trace = emptyFn;
+ else if (isHostObject(window, "console") && !undef(console.info)) {
+ /**
+ * Sets trace to be a wrapper around console.info
+ * @ignore
+ * @param {String} msg
+ */
+ this.trace = function (msg) {
+ console.info(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg);
+ };
+ }
+ else {
+ /**
+ * Create log window
+ * @ignore
+ */
+ var domain = location.host, windowname = domain.replace(/[\-.:]/g, "") + "easyxdm_log", logWin;
+ try {
+ logWin = window.open("", windowname, "width=800,height=200,status=0,navigation=0,scrollbars=1");
+ }
+ catch (e) {
+ }
+ if (logWin) {
+ var doc = logWin.document;
+ el = doc.getElementById("log");
+ if (!el) {
+ doc.write("
easyXDM log " + domain + " ");
+ doc.write("
");
+ doc.close();
+ el = doc.getElementById("log");
+ }
+ this.trace = function (msg) {
+ try {
+ el.appendChild(doc.createElement("div")).appendChild(doc.createTextNode(location.host + (namespace ? ":" + namespace : "") + " - " + this.getTime() + ":" + msg));
+ el.scrollTop = el.scrollHeight;
+ }
+ catch (e) {
+ //In case we are unloading
+ }
+ };
+ this.trace("---- new logger at " + location.href);
+ }
+
+ if (!el) {
+ // We are unable to use any logging
+ this.trace = emptyFn;
+ }
}
+ this.trace(msg);
}
- this.trace(msg);
+ },
+ /**
+ * Creates a method usable for tracing.
+ * @param {String} name The name the messages should be marked with
+ * @return {Function} A function that accepts a single string as argument.
+ */
+ getTracer: function (name) {
+ return function (msg) {
+ debug.trace(name + ": " + msg);
+ };
}
- },
- /**
- * Creates a method usable for tracing.
- * @param {String} name The name the messages should be marked with
- * @return {Function} A function that accepts a single string as argument.
- */
- getTracer: function(name){
- return function(msg){
- debug.trace(name + ": " + msg);
- };
- }
-};
-debug.log("easyXDM present on '" + location.href);
-easyXDM.Debug = debug;
-_trace = debug.getTracer("{Private}");
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
+ };
+ debug.log("easyXDM present on '" + location.href);
+ easyXDM.Debug = debug;
+ _trace = debug.getTracer("{Private}");
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, isHostObject, isHostMethod, un, on, createFrame, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1062,47 +1062,47 @@ _trace = debug.getTracer("{Private}");
// THE SOFTWARE.
//
-/**
- * @class easyXDM.DomHelper
- * Contains methods for dealing with the DOM
- * @singleton
- */
-easyXDM.DomHelper = {
/**
- * Provides a consistent interface for adding eventhandlers
- * @param {Object} target The target to add the event to
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- on: on,
- /**
- * Provides a consistent interface for removing eventhandlers
- * @param {Object} target The target to remove the event from
- * @param {String} type The name of the event
- * @param {Function} listener The listener
- */
- un: un,
- /**
- * Checks for the presence of the JSON object.
- * If it is not present it will use the supplied path to load the JSON2 library.
- * This should be called in the documents head right after the easyXDM script tag.
- * http://json.org/json2.js
- * @param {String} path A valid path to json2.js
+ * @class easyXDM.DomHelper
+ * Contains methods for dealing with the DOM
+ * @singleton
*/
- requiresJSON: function(path){
- if (!isHostObject(window, "JSON")) {
- debug.log("loading external JSON");
- // we need to encode the < in order to avoid an illegal token error
- // when the script is inlined in a document.
- document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
- }
- else {
- debug.log("native JSON found");
+ easyXDM.DomHelper = {
+ /**
+ * Provides a consistent interface for adding eventhandlers
+ * @param {Object} target The target to add the event to
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ on: on,
+ /**
+ * Provides a consistent interface for removing eventhandlers
+ * @param {Object} target The target to remove the event from
+ * @param {String} type The name of the event
+ * @param {Function} listener The listener
+ */
+ un: un,
+ /**
+ * Checks for the presence of the JSON object.
+ * If it is not present it will use the supplied path to load the JSON2 library.
+ * This should be called in the documents head right after the easyXDM script tag.
+ * http://json.org/json2.js
+ * @param {String} path A valid path to json2.js
+ */
+ requiresJSON: function (path) {
+ if (!isHostObject(window, "JSON")) {
+ debug.log("loading external JSON");
+ // we need to encode the < in order to avoid an illegal token error
+ // when the script is inlined in a document.
+ document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>');
+ }
+ else {
+ debug.log("native JSON found");
+ }
}
- }
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1127,55 +1127,55 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-(function(){
- // The map containing the stored functions
- var _map = {};
-
- /**
- * @class easyXDM.Fn
- * This contains methods related to function handling, such as storing callbacks.
- * @singleton
- * @namespace easyXDM
- */
- easyXDM.Fn = {
- /**
- * Stores a function using the given name for reference
- * @param {String} name The name that the function should be referred by
- * @param {Function} fn The function to store
- * @namespace easyXDM.fn
- */
- set: function(name, fn){
- this._trace("storing function " + name);
- _map[name] = fn;
- },
+ (function () {
+ // The map containing the stored functions
+ var _map = {};
+
/**
- * Retrieves the function referred to by the given name
- * @param {String} name The name of the function to retrieve
- * @param {Boolean} del If the function should be deleted after retrieval
- * @return {Function} The stored function
- * @namespace easyXDM.fn
+ * @class easyXDM.Fn
+ * This contains methods related to function handling, such as storing callbacks.
+ * @singleton
+ * @namespace easyXDM
*/
- get: function(name, del){
- this._trace("retrieving function " + name);
- if (!_map.hasOwnProperty(name)) {
- return;
- }
- var fn = _map[name];
- if (!fn) {
- this._trace(name + " not found");
- }
-
- if (del) {
- delete _map[name];
+ easyXDM.Fn = {
+ /**
+ * Stores a function using the given name for reference
+ * @param {String} name The name that the function should be referred by
+ * @param {Function} fn The function to store
+ * @namespace easyXDM.fn
+ */
+ set: function (name, fn) {
+ this._trace("storing function " + name);
+ _map[name] = fn;
+ },
+ /**
+ * Retrieves the function referred to by the given name
+ * @param {String} name The name of the function to retrieve
+ * @param {Boolean} del If the function should be deleted after retrieval
+ * @return {Function} The stored function
+ * @namespace easyXDM.fn
+ */
+ get: function (name, del) {
+ this._trace("retrieving function " + name);
+ if (!_map.hasOwnProperty(name)) {
+ return;
+ }
+ var fn = _map[name];
+ if (!fn) {
+ this._trace(name + " not found");
+ }
+
+ if (del) {
+ delete _map[name];
+ }
+ return fn;
}
- return fn;
- }
- };
-
- easyXDM.Fn._trace = debug.getTracer("easyXDM.Fn");
-}());
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
+ };
+
+ easyXDM.Fn._trace = debug.getTracer("easyXDM.Fn");
+ }());
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, chainStack, prepareTransportStack, getLocation, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -1200,15 +1200,15 @@ easyXDM.DomHelper = {
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Socket
- * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
- * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
- * Internally different stacks will be used depending on the browsers features and the available parameters.
- *
How to set up
- * Setting up the provider:
- *
- * var socket = new easyXDM.Socket({
+ /**
+ * @class easyXDM.Socket
+ * This class creates a transport channel between two domains that is usable for sending and receiving string-based messages.
+ * The channel is reliable, supports queueing, and ensures that the message originates from the expected domain.
+ * Internally different stacks will be used depending on the browsers features and the available parameters.
+ * How to set up
+ * Setting up the provider:
+ *
+ * var socket = new easyXDM.Socket({
* local: "name.html",
* onReady: function(){
* // you need to wait for the onReady callback before using the socket
@@ -1218,10 +1218,10 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * Setting up the consumer:
- *
- * var socket = new easyXDM.Socket({
+ *
+ * Setting up the consumer:
+ *
+ * var socket = new easyXDM.Socket({
* remote: "http://remotedomain/page.html",
* remoteHelper: "http://remotedomain/name.html",
* onReady: function(){
@@ -1232,65 +1232,65 @@ easyXDM.DomHelper = {
* alert("received " + message + " from " + origin);
* }
* });
- *
- * If you are unable to upload the name.html file to the consumers domain then remove the remoteHelper property
- * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
- * @namespace easyXDM
- * @constructor
- * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
- * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
- * @cfg {String} remote (Consumer only) The url to the providers document.
- * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
- * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
- * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
- * @cfg {Function} onMessage The method that should handle incoming messages. This method should accept two arguments, the message as a string, and the origin as a string. Optional.
- * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
- * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
- * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
- * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
- * If none of the patterns match an Error will be thrown.
- * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g: {style:{width:"100px", height:"100px"}}.
- * Properties such as 'name' and 'src' will be overrided. Optional.
- */
-easyXDM.Socket = function(config){
- var trace = debug.getTracer("easyXDM.Socket");
- trace("constructor");
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([{
- incoming: function(message, origin){
- config.onMessage(message, origin);
- },
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
- }
- }
- }])), recipient = getLocation(config.remote);
-
- // set the origin
- this.origin = getLocation(config.remote);
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
- };
-
- /**
- * Posts a message to the remote end of the channel
- * @param {String} message The message to send
+ *
+ * If you are unable to upload the
name.html file to the consumers domain then remove the
remoteHelper property
+ * and easyXDM will fall back to using the HashTransport instead of the NameTransport when not able to use any of the primary transports.
+ * @namespace easyXDM
+ * @constructor
+ * @cfg {String/Window} local The url to the local name.html document, a local static file, or a reference to the local window.
+ * @cfg {Boolean} lazy (Consumer only) Set this to true if you want easyXDM to defer creating the transport until really needed.
+ * @cfg {String} remote (Consumer only) The url to the providers document.
+ * @cfg {String} remoteHelper (Consumer only) The url to the remote name.html file. This is to support NameTransport as a fallback. Optional.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window. Optional, defaults to 2000.
+ * @cfg {Number} interval The interval used when polling for messages. Optional, defaults to 300.
+ * @cfg {String} channel (Consumer only) The name of the channel to use. Can be used to set consistent iframe names. Must be unique. Optional.
+ * @cfg {Function} onMessage The method that should handle incoming messages.
This method should accept two arguments, the message as a string, and the origin as a string. Optional.
+ * @cfg {Function} onReady A method that should be called when the transport is ready. Optional.
+ * @cfg {DOMElement|String} container (Consumer only) The element, or the id of the element that the primary iframe should be inserted into. If not set then the iframe will be positioned off-screen. Optional.
+ * @cfg {Array/String} acl (Provider only) Here you can specify which '[protocol]://[domain]' patterns that should be allowed to act as the consumer towards this provider.
+ * This can contain the wildcards ? and *. Examples are 'http://example.com', '*.foo.com' and '*dom?.com'. If you want to use reqular expressions then you pattern needs to start with ^ and end with $.
+ * If none of the patterns match an Error will be thrown.
+ * @cfg {Object} props (Consumer only) Additional properties that should be applied to the iframe. This can also contain nested objects e.g:
{style:{width:"100px", height:"100px"}}.
+ * Properties such as 'name' and 'src' will be overrided. Optional.
*/
- this.postMessage = function(message){
- stack.outgoing(message, recipient);
+ easyXDM.Socket = function (config) {
+ var trace = debug.getTracer("easyXDM.Socket");
+ trace("constructor");
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([{
+ incoming: function (message, origin) {
+ config.onMessage(message, origin);
+ },
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
+ }
+ }])), recipient = getLocation(config.remote);
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ /**
+ * Posts a message to the remote end of the channel
+ * @param {String} message The message to send
+ */
+ this.postMessage = function (message) {
+ stack.outgoing(message, recipient);
+ };
+
+ stack.init();
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef,, chainStack, prepareTransportStack, debug, getLocation */
//
// easyXDM
// http://easyxdm.net/
@@ -1315,15 +1315,15 @@ easyXDM.Socket = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.Rpc
- * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
- * of methods to be called from the remote end.
- * The instantiated object will have methods matching those specified in
config.remote.
- * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
- *
How to set up
- *
- * var rpc = new easyXDM.Rpc({
+ /**
+ * @class easyXDM.Rpc
+ * Creates a proxy object that can be used to call methods implemented on the remote end of the channel, and also to provide the implementation
+ * of methods to be called from the remote end.
+ * The instantiated object will have methods matching those specified in config.remote.
+ * This requires the JSON object present in the document, either natively, using json.org's json2 or as a wrapper around library spesific methods.
+ * How to set up
+ *
+ * var rpc = new easyXDM.Rpc({
* // this configuration is equal to that used by the Socket.
* remote: "http://remotedomain/...",
* onReady: function(){
@@ -1334,11 +1334,11 @@ easyXDM.Socket = function(config){
* local: {..},
* remote: {..}
* });
- *
- *
- * Exposing functions (procedures)
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ *
+ * Exposing functions (procedures)
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {
@@ -1353,30 +1353,30 @@ easyXDM.Socket = function(config){
* },
* remote: {...}
* });
- *
-
- * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
- * To send a successfull result back you can use
- *
- * return foo;
- *
- * or
- *
- * success(foo);
- *
- * To return an error you can use
- *
- * throw new Error("foo error");
- *
- * or
- *
- * error("foo error");
- *
- *
- * Defining remotely exposed methods (procedures/notifications)
- * The definition of the remote end is quite similar:
- *
- * var rpc = new easyXDM.Rpc({
+ *
+
+ * The function referenced by [method] will receive the passed arguments followed by the callback functions success and error.
+ * To send a successfull result back you can use
+ *
+ * return foo;
+ *
+ * or
+ *
+ * success(foo);
+ *
+ * To return an error you can use
+ *
+ * throw new Error("foo error");
+ *
+ * or
+ *
+ * error("foo error");
+ *
+ *
+ * Defining remotely exposed methods (procedures/notifications)
+ * The definition of the remote end is quite similar:
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1384,24 +1384,24 @@ easyXDM.Socket = function(config){
* nameOfMethod: {}
* }
* });
- *
- * To call a remote method use
- *
- * rpc.nameOfMethod("arg1", "arg2", function(value) {
+ *
+ * To call a remote method use
+ *
+ * rpc.nameOfMethod("arg1", "arg2", function(value) {
* alert("success: " + value);
* }, function(message) {
* alert("error: " + message + );
* });
- *
- * Both the success and errror callbacks are optional.
- * When called with no callback a JSON-RPC 2.0 notification will be executed.
- * Be aware that you will not be notified of any errors with this method.
- *
- * Specifying a custom serializer
- * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
- * then you can specify a custom serializer using serializer: foo
- *
- * var rpc = new easyXDM.Rpc({
+ *
+ * Both the success and errror callbacks are optional.
+ * When called with no callback a JSON-RPC 2.0 notification will be executed.
+ * Be aware that you will not be notified of any errors with this method.
+ *
+ * Specifying a custom serializer
+ * If you do not want to use the JSON2 library for non-native JSON support, but instead capabilities provided by some other library
+ * then you can specify a custom serializer using serializer: foo
+ *
+ * var rpc = new easyXDM.Rpc({
* ...
* },{
* local: {...},
@@ -1411,55 +1411,148 @@ easyXDM.Socket = function(config){
* stringify: function(object) {...}
* }
* });
- *
- * If serializer is set then the class will not attempt to use the native implementation.
- * @namespace easyXDM
- * @constructor
- * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
- * @param {Object} jsonRpcConfig The description of the interface to implement.
- */
-easyXDM.Rpc = function(config, jsonRpcConfig){
- var trace = debug.getTracer("easyXDM.Rpc");
- trace("constructor");
-
- // expand shorthand notation
- if (jsonRpcConfig.local) {
- for (var method in jsonRpcConfig.local) {
- if (jsonRpcConfig.local.hasOwnProperty(method)) {
- var member = jsonRpcConfig.local[method];
- if (typeof member === "function") {
- jsonRpcConfig.local[method] = {
- method: member
- };
+ *
+ * If
serializer is set then the class will not attempt to use the native implementation.
+ * @namespace easyXDM
+ * @constructor
+ * @param {Object} config The underlying transports configuration. See easyXDM.Socket for available parameters.
+ * @param {Object} jsonRpcConfig The description of the interface to implement.
+ */
+ easyXDM.Rpc = function (config, jsonRpcConfig) {
+ var trace = debug.getTracer("easyXDM.Rpc");
+ trace("constructor");
+
+ // expand shorthand notation
+ if (jsonRpcConfig.local) {
+ for (var method in jsonRpcConfig.local) {
+ if (jsonRpcConfig.local.hasOwnProperty(method)) {
+ var member = jsonRpcConfig.local[method];
+ if (typeof member === "function") {
+ jsonRpcConfig.local[method] = {
+ method: member
+ };
+ }
+ }
+ }
+ }
+
+ // create the stack
+ var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
+ callback: function (success) {
+ if (config.onReady) {
+ config.onReady(success);
+ }
+ }
+ }]));
+
+ // set the origin
+ this.origin = getLocation(config.remote);
+
+
+ /**
+ * Initiates the destruction of the stack.
+ */
+ this.destroy = function () {
+ stack.destroy();
+ };
+
+ stack.init();
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
+//
+// easyXDM
+// http://easyxdm.net/
+// Copyright(c) 2009-2011, Øyvind Sean Kinsey, oyvind@kinsey.no.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+ /**
+ * @class easyXDM.stack.SameOriginTransport
+ * SameOriginTransport is a transport class that can be used when both domains have the same origin.
+ * This can be useful for testing and for when the main application supports both internal and external sources.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
+ */
+ easyXDM.stack.SameOriginTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.SameOriginTransport");
+ trace("constructor");
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send(message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: location.protocol + "//" + location.host + location.pathname,
+ xdm_c: config.channel,
+ xdm_p: 4 // 4 = SameOriginTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ easyXDM.Fn.set(config.channel, function (sendFn) {
+ send = sendFn;
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
+ });
+ }
+ else {
+ send = getParentObject().Fn.get(config.channel, true)(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- }
- }
-
- // create the stack
- var stack = chainStack(prepareTransportStack(config).concat([new easyXDM.stack.RpcBehavior(this, jsonRpcConfig), {
- callback: function(success){
- if (config.onReady) {
- config.onReady(success);
- }
- }
- }]));
-
- // set the origin
- this.origin = getLocation(config.remote);
-
-
- /**
- * Initiates the destruction of the stack.
- */
- this.destroy = function(){
- stack.destroy();
+ });
};
-
- stack.init();
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, getParentObject, IFRAME_PREFIX*/
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
//
// easyXDM
// http://easyxdm.net/
@@ -1484,75 +1577,199 @@ easyXDM.Rpc = function(config, jsonRpcConfig){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.SameOriginTransport
- * SameOriginTransport is a transport class that can be used when both domains have the same origin.
- * This can be useful for testing and for when the main application supports both internal and external sources.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.SameOriginTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.SameOriginTransport");
- trace("constructor");
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send(message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: location.protocol + "//" + location.host + location.pathname,
- xdm_c: config.channel,
- xdm_p: 4 // 4 = SameOriginTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- easyXDM.Fn.set(config.channel, function(sendFn){
- send = sendFn;
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
- };
- });
+ /**
+ * @class easyXDM.stack.FlashTransport
+ * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
+ * @cfg {String} secret the pre-shared secret used to secure the communication.
+ * @cfg {String} swf The path to the swf file
+ * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
+ * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
+ */
+ easyXDM.stack.FlashTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.FlashTransport");
+ trace("constructor");
+ if (!config.swf) {
+ throw new Error("Path to easyxdm.swf is missing");
+ }
+ var pub, // the public interface
+ frame, send, targetOrigin, swf, swfContainer;
+
+ function onMessage(message, origin) {
+ setTimeout(function () {
+ trace("received message");
+ pub.up.incoming(message, targetOrigin);
+ }, 0);
+ }
+
+ /**
+ * This method adds the SWF to the DOM and prepares the initialization of the channel
+ */
+ function addSwf(domain) {
+ trace("creating factory with SWF from " + domain);
+ // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
+ var url = config.swf + "?host=" + config.isHost;
+ var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
+
+ // prepare the init function that will fire once the swf is ready
+ easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function () {
+ easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
+ var queue = easyXDM.stack.FlashTransport[domain].queue;
+ for (var i = 0; i < queue.length; i++) {
+ queue[i]();
+ }
+ queue.length = 0;
+ });
+
+ if (config.swfContainer) {
+ swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
}
else {
- send = getParentObject().Fn.get(config.channel, true)(function(msg){
- pub.up.incoming(msg, targetOrigin);
+ // create the container that will hold the swf
+ swfContainer = document.createElement('div');
+
+ // http://bugs.adobe.com/jira/browse/FP-4796
+ // http://tech.groups.yahoo.com/group/flexcoders/message/162365
+ // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
+ apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
+ height: "20px",
+ width: "20px",
+ position: "fixed",
+ right: 0,
+ top: 0
+ } : {
+ height: "1px",
+ width: "1px",
+ position: "absolute",
+ overflow: "hidden",
+ right: 0,
+ top: 0
});
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
+ document.body.appendChild(swfContainer);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
+
+ // create the object/embed
+ var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
+ + "&proto=" + global.location.protocol
+ + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
+ + "&port=" + encodeURIComponent(getPort(global.location.href))
+ + "&ns=" + encodeURIComponent(namespace);
+ flashVars += "&log=true";
+ swfContainer.innerHTML = "
" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " ";
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global global, easyXDM, window, getLocation, appendQueryParameters, createFrame, debug, apply, whenReady, IFRAME_PREFIX, namespace, resolveUrl, getDomainName, HAS_FLASH_THROTTLED_BUG, getPort, query*/
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ swf.postMessage(config.channel, message.toString());
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ try {
+ swf.destroyChannel(config.channel);
+ }
+ catch (e) {
+ }
+ swf = null;
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+
+ targetOrigin = config.remote;
+
+ // Prepare the code that will be run after the swf has been intialized
+ easyXDM.Fn.set("flash_" + config.channel + "_init", function () {
+ setTimeout(function () {
+ trace("firing onReady");
+ pub.up.callback(true);
+ });
+ });
+
+ // set up the omMessage handler
+ easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
+
+ config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
+ var swfdomain = getDomainName(config.swf);
+ var fn = function () {
+ // set init to true in case the fn was called was invoked from a separate instance
+ easyXDM.stack.FlashTransport[swfdomain].init = true;
+ swf = easyXDM.stack.FlashTransport[swfdomain].swf;
+ // create the channel
+ swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
+
+ if (config.isHost) {
+ // if Flash is going to be throttled and we want to avoid this
+ if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
+ apply(config.props, {
+ position: "fixed",
+ right: 0,
+ top: 0,
+ height: "20px",
+ width: "20px"
+ });
+ }
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 6, // 6 = FlashTransport
+ xdm_s: config.secret
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ }
+ };
+
+ if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
+ // if the swf is in place and we are the consumer
+ fn();
+ }
+ else {
+ // if the swf does not yet exist
+ if (!easyXDM.stack.FlashTransport[swfdomain]) {
+ // add the queue to hold the init fn's
+ easyXDM.stack.FlashTransport[swfdomain] = {
+ queue: [fn]
+ };
+ addSwf(swfdomain);
+ }
+ else {
+ easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ }
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
+ }
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1577,199 +1794,124 @@ easyXDM.stack.SameOriginTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FlashTransport
- * FlashTransport is a transport class that uses an SWF with LocalConnection to pass messages back and forth.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- * @cfg {String} secret the pre-shared secret used to secure the communication.
- * @cfg {String} swf The path to the swf file
- * @cfg {Boolean} swfNoThrottle Set this to true if you want to take steps to avoid beeing throttled when hidden.
- * @cfg {String || DOMElement} swfContainer Set this if you want to control where the swf is placed
- */
-easyXDM.stack.FlashTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.FlashTransport");
- trace("constructor");
- if (!config.swf) {
- throw new Error("Path to easyxdm.swf is missing");
- }
- var pub, // the public interface
- frame, send, targetOrigin, swf, swfContainer;
-
- function onMessage(message, origin){
- setTimeout(function(){
- trace("received message");
- pub.up.incoming(message, targetOrigin);
- }, 0);
- }
-
/**
- * This method adds the SWF to the DOM and prepares the initialization of the channel
+ * @class easyXDM.stack.PostMessageTransport
+ * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
+ *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
+ *
https://developer.mozilla.org/en/DOM/window.postMessage
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote domain to communicate with.
*/
- function addSwf(domain){
- trace("creating factory with SWF from " + domain);
- // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.
- var url = config.swf + "?host=" + config.isHost;
- var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000);
-
- // prepare the init function that will fire once the swf is ready
- easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function(){
- easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild;
- var queue = easyXDM.stack.FlashTransport[domain].queue;
- for (var i = 0; i < queue.length; i++) {
- queue[i]();
+ easyXDM.stack.PostMessageTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.PostMessageTransport");
+ trace("constructor");
+ var pub, // the public interface
+ frame, // the remote frame, if any
+ callerWindow, // the window that we will call with
+ targetOrigin; // the domain to communicate with
+ /**
+ * Resolves the origin from the event object
+ * @private
+ * @param {Object} event The messageevent
+ * @return {String} The scheme, host and port of the origin
+ */
+ function _getOrigin(event) {
+ if (event.origin) {
+ // This is the HTML5 property
+ return getLocation(event.origin);
}
- queue.length = 0;
- });
-
- if (config.swfContainer) {
- swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer;
- }
- else {
- // create the container that will hold the swf
- swfContainer = document.createElement('div');
-
- // http://bugs.adobe.com/jira/browse/FP-4796
- // http://tech.groups.yahoo.com/group/flexcoders/message/162365
- // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc
- apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? {
- height: "20px",
- width: "20px",
- position: "fixed",
- right: 0,
- top: 0
- } : {
- height: "1px",
- width: "1px",
- position: "absolute",
- overflow: "hidden",
- right: 0,
- top: 0
- });
- document.body.appendChild(swfContainer);
- }
-
- // create the object/embed
- var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_"))
- + "&proto=" + global.location.protocol
- + "&domain=" + encodeURIComponent(getDomainName(global.location.href))
- + "&port=" + encodeURIComponent(getPort(global.location.href))
- + "&ns=" + encodeURIComponent(namespace);
- flashVars += "&log=true";
- swfContainer.innerHTML = "
" +
- " " +
- " " +
- " " +
- " " +
- " " +
- " ";
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- swf.postMessage(config.channel, message.toString());
- if (fn) {
- fn();
+ if (event.uri) {
+ // From earlier implementations
+ return getLocation(event.uri);
}
- },
- destroy: function(){
- trace("destroy");
- try {
- swf.destroyChannel(config.channel);
- }
- catch (e) {
+ if (event.domain) {
+ // This is the last option and will fail if the
+ // origin is not using the same schema as we are
+ return location.protocol + "//" + event.domain;
}
- swf = null;
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
+ throw "Unable to retrieve the origin of the event";
+ }
+
+ /**
+ * This is the main implementation for the onMessage event.
+ * It checks the validity of the origin and passes the message on if appropriate.
+ * @private
+ * @param {Object} event The messageevent
+ */
+ function _window_onMessage(event) {
+ var origin = _getOrigin(event);
+ trace("received message '" + event.data + "' from " + origin);
+ if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
+ pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
}
- },
- onDOMReady: function(){
- trace("init");
-
- targetOrigin = config.remote;
-
- // Prepare the code that will be run after the swf has been intialized
- easyXDM.Fn.set("flash_" + config.channel + "_init", function(){
- setTimeout(function(){
- trace("firing onReady");
- pub.up.callback(true);
- });
- });
-
- // set up the omMessage handler
- easyXDM.Fn.set("flash_" + config.channel + "_onMessage", onMessage);
-
- config.swf = resolveUrl(config.swf); // reports have been made of requests gone rogue when using relative paths
- var swfdomain = getDomainName(config.swf);
- var fn = function(){
- // set init to true in case the fn was called was invoked from a separate instance
- easyXDM.stack.FlashTransport[swfdomain].init = true;
- swf = easyXDM.stack.FlashTransport[swfdomain].swf;
- // create the channel
- swf.createChannel(config.channel, config.secret, getLocation(config.remote), config.isHost);
-
+ }
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ un(window, "message", _window_onMessage);
+ if (frame) {
+ callerWindow = null;
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
if (config.isHost) {
- // if Flash is going to be throttled and we want to avoid this
- if (HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle) {
- apply(config.props, {
- position: "fixed",
- right: 0,
- top: 0,
- height: "20px",
- width: "20px"
- });
- }
+ // add the event handler for listening
+ var waitForReady = function (event) {
+ if (event.data == config.channel + "-ready") {
+ trace("firing onReady");
+ // replace the eventlistener
+ callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
+ un(window, "message", waitForReady);
+ on(window, "message", _window_onMessage);
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
+ }
+ };
+ on(window, "message", waitForReady);
+
// set up the iframe
apply(config.props, {
src: appendQueryParameters(config.remote, {
xdm_e: getLocation(location.href),
xdm_c: config.channel,
- xdm_p: 6, // 6 = FlashTransport
- xdm_s: config.secret
+ xdm_p: 1 // 1 = PostMessage
}),
name: IFRAME_PREFIX + config.channel + "_provider"
});
frame = createFrame(config);
}
- };
-
- if (easyXDM.stack.FlashTransport[swfdomain] && easyXDM.stack.FlashTransport[swfdomain].init) {
- // if the swf is in place and we are the consumer
- fn();
- }
- else {
- // if the swf does not yet exist
- if (!easyXDM.stack.FlashTransport[swfdomain]) {
- // add the queue to hold the init fn's
- easyXDM.stack.FlashTransport[swfdomain] = {
- queue: [fn]
- };
- addSwf(swfdomain);
- }
else {
- easyXDM.stack.FlashTransport[swfdomain].queue.push(fn);
+ // add the event handler for listening
+ on(window, "message", _window_onMessage);
+ callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
+ callerWindow.postMessage(config.channel + "-ready", targetOrigin);
+
+ setTimeout(function () {
+ pub.up.callback(true);
+ }, 0);
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1794,124 +1936,79 @@ easyXDM.stack.FlashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.PostMessageTransport
- * PostMessageTransport is a transport class that uses HTML5 postMessage for communication.
- *
http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx
- *
https://developer.mozilla.org/en/DOM/window.postMessage
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote domain to communicate with.
- */
-easyXDM.stack.PostMessageTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.PostMessageTransport");
- trace("constructor");
- var pub, // the public interface
- frame, // the remote frame, if any
- callerWindow, // the window that we will call with
- targetOrigin; // the domain to communicate with
- /**
- * Resolves the origin from the event object
- * @private
- * @param {Object} event The messageevent
- * @return {String} The scheme, host and port of the origin
- */
- function _getOrigin(event){
- if (event.origin) {
- // This is the HTML5 property
- return getLocation(event.origin);
- }
- if (event.uri) {
- // From earlier implementations
- return getLocation(event.uri);
- }
- if (event.domain) {
- // This is the last option and will fail if the
- // origin is not using the same schema as we are
- return location.protocol + "//" + event.domain;
- }
- throw "Unable to retrieve the origin of the event";
- }
-
/**
- * This is the main implementation for the onMessage event.
- * It checks the validity of the origin and passes the message on if appropriate.
- * @private
- * @param {Object} event The messageevent
+ * @class easyXDM.stack.FrameElementTransport
+ * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
+ * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remote The remote document to communicate with.
*/
- function _window_onMessage(event){
- var origin = _getOrigin(event);
- trace("received message '" + event.data + "' from " + origin);
- if (origin == targetOrigin && event.data.substring(0, config.channel.length + 1) == config.channel + " ") {
- pub.up.incoming(event.data.substring(config.channel.length + 1), origin);
- }
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callerWindow.postMessage(config.channel + " " + message, domain || targetOrigin);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- un(window, "message", _window_onMessage);
- if (frame) {
- callerWindow = null;
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
- if (config.isHost) {
- // add the event handler for listening
- var waitForReady = function(event){
- if (event.data == config.channel + "-ready") {
- trace("firing onReady");
- // replace the eventlistener
- callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
- un(window, "message", waitForReady);
- on(window, "message", _window_onMessage);
- setTimeout(function(){
+ easyXDM.stack.FrameElementTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.FrameElementTransport");
+ trace("constructor");
+ var pub, frame, send, targetOrigin;
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ send.call(this, message);
+ if (fn) {
+ fn();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ frame = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ targetOrigin = getLocation(config.remote);
+
+ if (config.isHost) {
+ // set up the iframe
+ apply(config.props, {
+ src: appendQueryParameters(config.remote, {
+ xdm_e: getLocation(location.href),
+ xdm_c: config.channel,
+ xdm_p: 5 // 5 = FrameElementTransport
+ }),
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ frame = createFrame(config);
+ frame.fn = function (sendFn) {
+ delete frame.fn;
+ send = sendFn;
+ setTimeout(function () {
pub.up.callback(true);
}, 0);
+ // remove the function so that it cannot be used to overwrite the send function later on
+ return function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ };
+ };
+ }
+ else {
+ // This is to mitigate origin-spoofing
+ if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
+ window.top.location = query.xdm_e;
}
- };
- on(window, "message", waitForReady);
-
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 1 // 1 = PostMessage
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- }
- else {
- // add the event handler for listening
- on(window, "message", _window_onMessage);
- callerWindow = ("postMessage" in window.parent) ? window.parent : window.parent.document;
- callerWindow.postMessage(config.channel + "-ready", targetOrigin);
-
- setTimeout(function(){
+ send = window.frameElement.fn(function (msg) {
+ pub.up.incoming(msg, targetOrigin);
+ });
pub.up.callback(true);
- }, 0);
+ }
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, appendQueryParameters, createFrame, debug, apply, query, whenReady, IFRAME_PREFIX*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -1936,236 +2033,139 @@ easyXDM.stack.PostMessageTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.FrameElementTransport
- * FrameElementTransport is a transport class that can be used with Gecko-browser as these allow passing variables using the frameElement property.
- * Security is maintained as Gecho uses Lexical Authorization to determine under which scope a function is running.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remote The remote document to communicate with.
- */
-easyXDM.stack.FrameElementTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.FrameElementTransport");
- trace("constructor");
- var pub, frame, send, targetOrigin;
-
- return (pub = {
- outgoing: function(message, domain, fn){
- send.call(this, message);
- if (fn) {
- fn();
- }
- },
- destroy: function(){
- trace("destroy");
- if (frame) {
- frame.parentNode.removeChild(frame);
- frame = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- targetOrigin = getLocation(config.remote);
-
- if (config.isHost) {
- // set up the iframe
- apply(config.props, {
- src: appendQueryParameters(config.remote, {
- xdm_e: getLocation(location.href),
- xdm_c: config.channel,
- xdm_p: 5 // 5 = FrameElementTransport
- }),
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- frame = createFrame(config);
- frame.fn = function(sendFn){
- delete frame.fn;
- send = sendFn;
- setTimeout(function(){
- pub.up.callback(true);
- }, 0);
- // remove the function so that it cannot be used to overwrite the send function later on
- return function(msg){
- pub.up.incoming(msg, targetOrigin);
- };
- };
+ /**
+ * @class easyXDM.stack.NameTransport
+ * NameTransport uses the window.name property to relay data.
+ * The
local parameter needs to be set on both the consumer and provider,
+ * and the
remoteHelper parameter needs to be set on the consumer.
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
+ * @namespace easyXDM.stack
+ */
+ easyXDM.stack.NameTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.NameTransport");
+ trace("constructor");
+ if (config.isHost && undef(config.remoteHelper)) {
+ trace("missing remoteHelper");
+ throw new Error("missing remoteHelper");
+ }
+
+ var pub; // the public interface
+ var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
+
+ function _sendMessage(message) {
+ var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
+ trace("sending message " + message);
+ trace("navigating to '" + url + "'");
+ callerWindow.contentWindow.sendMessage(message, url);
+ }
+
+ function _onReady() {
+ if (isHost) {
+ if (++readyCount === 2 || !isHost) {
+ pub.up.callback(true);
+ }
}
else {
- // This is to mitigate origin-spoofing
- if (document.referrer && getLocation(document.referrer) != query.xdm_e) {
- window.top.location = query.xdm_e;
- }
- send = window.frameElement.fn(function(msg){
- pub.up.incoming(msg, targetOrigin);
- });
+ _sendMessage("ready");
+ trace("calling onReady");
pub.up.callback(true);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getLocation, appendQueryParameters, resolveUrl, createFrame, debug, un, apply, whenReady, IFRAME_PREFIX*/
-//
-// easyXDM
-// http://easyxdm.net/
-// Copyright(c) 2009-2011, Øyvind Sean Kinsey, oyvind@kinsey.no.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-/**
- * @class easyXDM.stack.NameTransport
- * NameTransport uses the window.name property to relay data.
- * The
local parameter needs to be set on both the consumer and provider,
- * and the
remoteHelper parameter needs to be set on the consumer.
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String} remoteHelper The url to the remote instance of hash.html - this is only needed for the host.
- * @namespace easyXDM.stack
- */
-easyXDM.stack.NameTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.NameTransport");
- trace("constructor");
- if (config.isHost && undef(config.remoteHelper)) {
- trace("missing remoteHelper");
- throw new Error("missing remoteHelper");
- }
-
- var pub; // the public interface
- var isHost, callerWindow, remoteWindow, readyCount, callback, remoteOrigin, remoteUrl;
-
- function _sendMessage(message){
- var url = config.remoteHelper + (isHost ? "#_3" : "#_2") + config.channel;
- trace("sending message " + message);
- trace("navigating to '" + url + "'");
- callerWindow.contentWindow.sendMessage(message, url);
- }
-
- function _onReady(){
- if (isHost) {
- if (++readyCount === 2 || !isHost) {
- pub.up.callback(true);
- }
- }
- else {
- _sendMessage("ready");
- trace("calling onReady");
- pub.up.callback(true);
- }
- }
-
- function _onMessage(message){
- trace("received message " + message);
- pub.up.incoming(message, remoteOrigin);
- }
-
- function _onLoad(){
- if (callback) {
- setTimeout(function(){
- callback(true);
- }, 0);
+ function _onMessage(message) {
+ trace("received message " + message);
+ pub.up.incoming(message, remoteOrigin);
}
- }
-
- return (pub = {
- outgoing: function(message, domain, fn){
- callback = fn;
- _sendMessage(message);
- },
- destroy: function(){
- trace("destroy");
- callerWindow.parentNode.removeChild(callerWindow);
- callerWindow = null;
- if (isHost) {
- remoteWindow.parentNode.removeChild(remoteWindow);
- remoteWindow = null;
- }
- },
- onDOMReady: function(){
- trace("init");
- isHost = config.isHost;
- readyCount = 0;
- remoteOrigin = getLocation(config.remote);
- config.local = resolveUrl(config.local);
-
- if (isHost) {
- // Register the callback
- easyXDM.Fn.set(config.channel, function(message){
- trace("received initial message " + message);
- if (isHost && message === "ready") {
- // Replace the handler
- easyXDM.Fn.set(config.channel, _onMessage);
- _onReady();
- }
- });
-
- // Set up the frame that points to the remote instance
- remoteUrl = appendQueryParameters(config.remote, {
- xdm_e: config.local,
- xdm_c: config.channel,
- xdm_p: 2
- });
- apply(config.props, {
- src: remoteUrl + '#' + config.channel,
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- remoteWindow = createFrame(config);
- }
- else {
- config.remoteHelper = config.remote;
- easyXDM.Fn.set(config.channel, _onMessage);
+
+ function _onLoad() {
+ if (callback) {
+ setTimeout(function () {
+ callback(true);
+ }, 0);
}
-
- // Set up the iframe that will be used for the transport
- var onLoad = function(){
- // Remove the handler
- var w = callerWindow || this;
- un(w, "load", onLoad);
- easyXDM.Fn.set(config.channel + "_load", _onLoad);
- (function test(){
- if (typeof w.contentWindow.sendMessage == "function") {
- _onReady();
- }
- else {
- setTimeout(test, 50);
- }
- }());
- };
-
- callerWindow = createFrame({
- props: {
- src: config.local + "#_4" + config.channel
- },
- onLoad: onLoad
- });
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
}
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
+
+ return (pub = {
+ outgoing: function (message, domain, fn) {
+ callback = fn;
+ _sendMessage(message);
+ },
+ destroy: function () {
+ trace("destroy");
+ callerWindow.parentNode.removeChild(callerWindow);
+ callerWindow = null;
+ if (isHost) {
+ remoteWindow.parentNode.removeChild(remoteWindow);
+ remoteWindow = null;
+ }
+ },
+ onDOMReady: function () {
+ trace("init");
+ isHost = config.isHost;
+ readyCount = 0;
+ remoteOrigin = getLocation(config.remote);
+ config.local = resolveUrl(config.local);
+
+ if (isHost) {
+ // Register the callback
+ easyXDM.Fn.set(config.channel, function (message) {
+ trace("received initial message " + message);
+ if (isHost && message === "ready") {
+ // Replace the handler
+ easyXDM.Fn.set(config.channel, _onMessage);
+ _onReady();
+ }
+ });
+
+ // Set up the frame that points to the remote instance
+ remoteUrl = appendQueryParameters(config.remote, {
+ xdm_e: config.local,
+ xdm_c: config.channel,
+ xdm_p: 2
+ });
+ apply(config.props, {
+ src: remoteUrl + '#' + config.channel,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ remoteWindow = createFrame(config);
+ }
+ else {
+ config.remoteHelper = config.remote;
+ easyXDM.Fn.set(config.channel, _onMessage);
+ }
+
+ // Set up the iframe that will be used for the transport
+ var onLoad = function () {
+ // Remove the handler
+ var w = callerWindow || this;
+ un(w, "load", onLoad);
+ easyXDM.Fn.set(config.channel + "_load", _onLoad);
+ (function test() {
+ if (typeof w.contentWindow.sendMessage == "function") {
+ _onReady();
+ }
+ else {
+ setTimeout(test, 50);
+ }
+ }());
+ };
+
+ callerWindow = createFrame({
+ props: {
+ src: config.local + "#_4" + config.channel
+ },
+ onLoad: onLoad
+ });
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
+ }
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, getLocation, createFrame, debug, un, on, apply, whenReady, IFRAME_PREFIX*/
//
// easyXDM
// http://easyxdm.net/
@@ -2190,145 +2190,145 @@ easyXDM.stack.NameTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.HashTransport
- * HashTransport is a transport class that uses the IFrame URL Technique for communication.
- *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The transports configuration.
- * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
- * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
- * @cfg {Number} interval The interval used when polling for messages.
- */
-easyXDM.stack.HashTransport = function(config){
- var trace = debug.getTracer("easyXDM.stack.HashTransport");
- trace("constructor");
- var pub;
- var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
- var useParent, _remoteOrigin;
-
- function _sendMessage(message){
- trace("sending message '" + (_msgNr + 1) + " " + message + "' to " + _remoteOrigin);
- if (!_callerWindow) {
- trace("no caller window");
- return;
- }
- var url = config.remote + "#" + (_msgNr++) + "_" + message;
- ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
- }
-
- function _handleHash(hash){
- _lastMsg = hash;
- trace("received message '" + _lastMsg + "' from " + _remoteOrigin);
- pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
- }
-
/**
- * Checks location.hash for a new message and relays this to the receiver.
- * @private
+ * @class easyXDM.stack.HashTransport
+ * HashTransport is a transport class that uses the IFrame URL Technique for communication.
+ *
http://msdn.microsoft.com/en-us/library/bb735305.aspx
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The transports configuration.
+ * @cfg {String/Window} local The url to the local file used for proxying messages, or the local window.
+ * @cfg {Number} delay The number of milliseconds easyXDM should try to get a reference to the local window.
+ * @cfg {Number} interval The interval used when polling for messages.
*/
- function _pollHash(){
- if (!_listenerWindow) {
- return;
- }
- var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
- if (indexOf != -1) {
- hash = href.substring(indexOf);
+ easyXDM.stack.HashTransport = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.HashTransport");
+ trace("constructor");
+ var pub;
+ var me = this, isHost, _timer, pollInterval, _lastMsg, _msgNr, _listenerWindow, _callerWindow;
+ var useParent, _remoteOrigin;
+
+ function _sendMessage(message) {
+ trace("sending message '" + (_msgNr + 1) + " " + message + "' to " + _remoteOrigin);
+ if (!_callerWindow) {
+ trace("no caller window");
+ return;
+ }
+ var url = config.remote + "#" + (_msgNr++) + "_" + message;
+ ((isHost || !useParent) ? _callerWindow.contentWindow : _callerWindow).location = url;
}
- if (hash && hash != _lastMsg) {
- trace("poll: new message");
- _handleHash(hash);
+
+ function _handleHash(hash) {
+ _lastMsg = hash;
+ trace("received message '" + _lastMsg + "' from " + _remoteOrigin);
+ pub.up.incoming(_lastMsg.substring(_lastMsg.indexOf("_") + 1), _remoteOrigin);
}
- }
-
- function _attachListeners(){
- trace("starting polling");
- _timer = setInterval(_pollHash, pollInterval);
- }
-
- return (pub = {
- outgoing: function(message, domain){
- _sendMessage(message);
- },
- destroy: function(){
- window.clearInterval(_timer);
- if (isHost || !useParent) {
- _callerWindow.parentNode.removeChild(_callerWindow);
+
+ /**
+ * Checks location.hash for a new message and relays this to the receiver.
+ * @private
+ */
+ function _pollHash() {
+ if (!_listenerWindow) {
+ return;
}
- _callerWindow = null;
- },
- onDOMReady: function(){
- isHost = config.isHost;
- pollInterval = config.interval;
- _lastMsg = "#" + config.channel;
- _msgNr = 0;
- useParent = config.useParent;
- _remoteOrigin = getLocation(config.remote);
- if (isHost) {
- apply(config.props, {
- src: config.remote,
- name: IFRAME_PREFIX + config.channel + "_provider"
- });
- if (useParent) {
- config.onLoad = function(){
- _listenerWindow = window;
- _attachListeners();
- pub.up.callback(true);
- };
+ var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#");
+ if (indexOf != -1) {
+ hash = href.substring(indexOf);
+ }
+ if (hash && hash != _lastMsg) {
+ trace("poll: new message");
+ _handleHash(hash);
+ }
+ }
+
+ function _attachListeners() {
+ trace("starting polling");
+ _timer = setInterval(_pollHash, pollInterval);
+ }
+
+ return (pub = {
+ outgoing: function (message, domain) {
+ _sendMessage(message);
+ },
+ destroy: function () {
+ window.clearInterval(_timer);
+ if (isHost || !useParent) {
+ _callerWindow.parentNode.removeChild(_callerWindow);
}
- else {
- var tries = 0, max = config.delay / 50;
- (function getRef(){
- if (++tries > max) {
- trace("unable to get reference to _listenerWindow, giving up");
- throw new Error("Unable to reference listenerwindow");
- }
- try {
- _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
- }
- catch (ex) {
- }
- if (_listenerWindow) {
+ _callerWindow = null;
+ },
+ onDOMReady: function () {
+ isHost = config.isHost;
+ pollInterval = config.interval;
+ _lastMsg = "#" + config.channel;
+ _msgNr = 0;
+ useParent = config.useParent;
+ _remoteOrigin = getLocation(config.remote);
+ if (isHost) {
+ apply(config.props, {
+ src: config.remote,
+ name: IFRAME_PREFIX + config.channel + "_provider"
+ });
+ if (useParent) {
+ config.onLoad = function () {
+ _listenerWindow = window;
_attachListeners();
- trace("got a reference to _listenerWindow");
pub.up.callback(true);
- }
- else {
- setTimeout(getRef, 50);
- }
- }());
- }
- _callerWindow = createFrame(config);
- }
- else {
- _listenerWindow = window;
- _attachListeners();
- if (useParent) {
- _callerWindow = parent;
- pub.up.callback(true);
+ };
+ }
+ else {
+ var tries = 0, max = config.delay / 50;
+ (function getRef() {
+ if (++tries > max) {
+ trace("unable to get reference to _listenerWindow, giving up");
+ throw new Error("Unable to reference listenerwindow");
+ }
+ try {
+ _listenerWindow = _callerWindow.contentWindow.frames[IFRAME_PREFIX + config.channel + "_consumer"];
+ }
+ catch (ex) {
+ }
+ if (_listenerWindow) {
+ _attachListeners();
+ trace("got a reference to _listenerWindow");
+ pub.up.callback(true);
+ }
+ else {
+ setTimeout(getRef, 50);
+ }
+ }());
+ }
+ _callerWindow = createFrame(config);
}
else {
- apply(config, {
- props: {
- src: config.remote + "#" + config.channel + new Date(),
- name: IFRAME_PREFIX + config.channel + "_consumer"
- },
- onLoad: function(){
- pub.up.callback(true);
- }
- });
- _callerWindow = createFrame(config);
+ _listenerWindow = window;
+ _attachListeners();
+ if (useParent) {
+ _callerWindow = parent;
+ pub.up.callback(true);
+ }
+ else {
+ apply(config, {
+ props: {
+ src: config.remote + "#" + config.channel + new Date(),
+ name: IFRAME_PREFIX + config.channel + "_consumer"
+ },
+ onLoad: function () {
+ pub.up.callback(true);
+ }
+ });
+ _callerWindow = createFrame(config);
+ }
}
+ },
+ init: function () {
+ whenReady(pub.onDOMReady, pub);
}
- },
- init: function(){
- whenReady(pub.onDOMReady, pub);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2353,52 +2353,52 @@ easyXDM.stack.HashTransport = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.ReliableBehavior
- * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- */
-easyXDM.stack.ReliableBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.ReliableBehavior");
- trace("constructor");
- var pub, // the public interface
- callback; // the callback to execute when we have a confirmed success/failure
- var idOut = 0, idIn = 0, currentMessage = "";
-
- return (pub = {
- incoming: function(message, origin){
- trace("incoming: " + message);
- var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
- message = message.substring(indexOf + 1);
-
- if (ack[0] == idOut) {
- trace("message delivered");
- currentMessage = "";
- if (callback) {
- callback(true);
+ /**
+ * @class easyXDM.stack.ReliableBehavior
+ * This is a behavior that tries to make the underlying transport reliable by using acknowledgements.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ */
+ easyXDM.stack.ReliableBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.ReliableBehavior");
+ trace("constructor");
+ var pub, // the public interface
+ callback; // the callback to execute when we have a confirmed success/failure
+ var idOut = 0, idIn = 0, currentMessage = "";
+
+ return (pub = {
+ incoming: function (message, origin) {
+ trace("incoming: " + message);
+ var indexOf = message.indexOf("_"), ack = message.substring(0, indexOf).split(",");
+ message = message.substring(indexOf + 1);
+
+ if (ack[0] == idOut) {
+ trace("message delivered");
+ currentMessage = "";
+ if (callback) {
+ callback(true);
+ }
}
- }
- if (message.length > 0) {
- trace("sending ack, and passing on " + message);
- pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
- if (idIn != ack[1]) {
- idIn = ack[1];
- pub.up.incoming(message, origin);
+ if (message.length > 0) {
+ trace("sending ack, and passing on " + message);
+ pub.down.outgoing(ack[1] + "," + idOut + "_" + currentMessage, origin);
+ if (idIn != ack[1]) {
+ idIn = ack[1];
+ pub.up.incoming(message, origin);
+ }
}
+
+ },
+ outgoing: function (message, origin, fn) {
+ currentMessage = message;
+ callback = fn;
+ pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
}
-
- },
- outgoing: function(message, origin, fn){
- currentMessage = message;
- callback = fn;
- pub.down.outgoing(idIn + "," + (++idOut) + "_" + message, origin);
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, debug, undef, removeFromStack*/
//
// easyXDM
// http://easyxdm.net/
@@ -2423,132 +2423,133 @@ easyXDM.stack.ReliableBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.QueueBehavior
- * This is a behavior that enables queueing of messages.
- * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
- * This will also fragment/defragment messages so that the outgoing message is never bigger than the
- * set length.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration. Optional.
- * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
- */
-easyXDM.stack.QueueBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.QueueBehavior");
- trace("constructor");
- var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
-
- function dispatch(){
- if (config.remove && queue.length === 0) {
- trace("removing myself from the stack");
- removeFromStack(pub);
- return;
- }
- if (waiting || queue.length === 0 || destroying) {
- return;
- }
- trace("dispatching from queue");
- waiting = true;
- var message = queue.shift();
-
- pub.down.outgoing(message.data, message.origin, function(success){
- waiting = false;
- if (message.callback) {
- setTimeout(function(){
- message.callback(success);
- }, 0);
- }
- dispatch();
- });
- }
- return (pub = {
- init: function(){
- if (undef(config)) {
- config = {};
- }
- if (config.maxLength) {
- maxLength = config.maxLength;
- doFragment = true;
- }
- if (config.lazy) {
- lazy = true;
+ /**
+ * @class easyXDM.stack.QueueBehavior
+ * This is a behavior that enables queueing of messages.
+ * It will buffer incoming messages and dispach these as fast as the underlying transport allows.
+ * This will also fragment/defragment messages so that the outgoing message is never bigger than the
+ * set length.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration. Optional.
+ * @cfg {Number} maxLength The maximum length of each outgoing message. Set this to enable fragmentation.
+ */
+ easyXDM.stack.QueueBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.QueueBehavior");
+ trace("constructor");
+ var pub, queue = [], waiting = true, incoming = "", destroying, maxLength = 0, lazy = false, doFragment = false;
+
+ function dispatch() {
+ if (config.remove && queue.length === 0) {
+ trace("removing myself from the stack");
+ removeFromStack(pub);
+ return;
}
- else {
- pub.down.init();
+ if (waiting || queue.length === 0 || destroying) {
+ return;
}
- },
- callback: function(success){
- waiting = false;
- var up = pub.up; // in case dispatch calls removeFromStack
- dispatch();
- up.callback(success);
- },
- incoming: function(message, origin){
- if (doFragment) {
- var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
- incoming += message.substring(indexOf + 1);
- if (seq === 0) {
- trace("received the last fragment");
- if (config.encode) {
- incoming = decodeURIComponent(incoming);
+ trace("dispatching from queue");
+ waiting = true;
+ var message = queue.shift();
+
+ pub.down.outgoing(message.data, message.origin, function (success) {
+ waiting = false;
+ if (message.callback) {
+ setTimeout(function () {
+ message.callback(success);
+ }, 0);
+ }
+ dispatch();
+ });
+ }
+
+ return (pub = {
+ init: function () {
+ if (undef(config)) {
+ config = {};
+ }
+ if (config.maxLength) {
+ maxLength = config.maxLength;
+ doFragment = true;
+ }
+ if (config.lazy) {
+ lazy = true;
+ }
+ else {
+ pub.down.init();
+ }
+ },
+ callback: function (success) {
+ waiting = false;
+ var up = pub.up; // in case dispatch calls removeFromStack
+ dispatch();
+ up.callback(success);
+ },
+ incoming: function (message, origin) {
+ if (doFragment) {
+ var indexOf = message.indexOf("_"), seq = parseInt(message.substring(0, indexOf), 10);
+ incoming += message.substring(indexOf + 1);
+ if (seq === 0) {
+ trace("received the last fragment");
+ if (config.encode) {
+ incoming = decodeURIComponent(incoming);
+ }
+ pub.up.incoming(incoming, origin);
+ incoming = "";
+ }
+ else {
+ trace("waiting for more fragments, seq=" + message);
}
- pub.up.incoming(incoming, origin);
- incoming = "";
}
else {
- trace("waiting for more fragments, seq=" + message);
+ pub.up.incoming(message, origin);
}
- }
- else {
- pub.up.incoming(message, origin);
- }
- },
- outgoing: function(message, origin, fn){
- if (config.encode) {
- message = encodeURIComponent(message);
- }
- var fragments = [], fragment;
- if (doFragment) {
- // fragment into chunks
- while (message.length !== 0) {
- fragment = message.substring(0, maxLength);
- message = message.substring(fragment.length);
- fragments.push(fragment);
- }
- // enqueue the chunks
- while ((fragment = fragments.shift())) {
- trace("enqueuing");
+ },
+ outgoing: function (message, origin, fn) {
+ if (config.encode) {
+ message = encodeURIComponent(message);
+ }
+ var fragments = [], fragment;
+ if (doFragment) {
+ // fragment into chunks
+ while (message.length !== 0) {
+ fragment = message.substring(0, maxLength);
+ message = message.substring(fragment.length);
+ fragments.push(fragment);
+ }
+ // enqueue the chunks
+ while ((fragment = fragments.shift())) {
+ trace("enqueuing");
+ queue.push({
+ data: fragments.length + "_" + fragment,
+ origin: origin,
+ callback: fragments.length === 0 ? fn : null
+ });
+ }
+ }
+ else {
queue.push({
- data: fragments.length + "_" + fragment,
+ data: message,
origin: origin,
- callback: fragments.length === 0 ? fn : null
+ callback: fn
});
}
+ if (lazy) {
+ pub.down.init();
+ }
+ else {
+ dispatch();
+ }
+ },
+ destroy: function () {
+ trace("destroy");
+ destroying = true;
+ pub.down.destroy();
}
- else {
- queue.push({
- data: message,
- origin: origin,
- callback: fn
- });
- }
- if (lazy) {
- pub.down.init();
- }
- else {
- dispatch();
- }
- },
- destroy: function(){
- trace("destroy");
- destroying = true;
- pub.down.destroy();
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, debug */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, debug */
//
// easyXDM
// http://easyxdm.net/
@@ -2573,64 +2574,64 @@ easyXDM.stack.QueueBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.VerifyBehavior
- * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
- * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} config The behaviors configuration.
- * @cfg {Boolean} initiate If the verification should be initiated from this end.
- */
-easyXDM.stack.VerifyBehavior = function(config){
- var trace = debug.getTracer("easyXDM.stack.VerifyBehavior");
- trace("constructor");
- if (undef(config.initiate)) {
- throw new Error("settings.initiate is not set");
- }
- var pub, mySecret, theirSecret, verified = false;
-
- function startVerification(){
- trace("requesting verification");
- mySecret = Math.random().toString(16).substring(2);
- pub.down.outgoing(mySecret);
- }
-
- return (pub = {
- incoming: function(message, origin){
- var indexOf = message.indexOf("_");
- if (indexOf === -1) {
- if (message === mySecret) {
- trace("verified, calling callback");
- pub.up.callback(true);
+ /**
+ * @class easyXDM.stack.VerifyBehavior
+ * This behavior will verify that communication with the remote end is possible, and will also sign all outgoing,
+ * and verify all incoming messages. This removes the risk of someone hijacking the iframe to send malicious messages.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} config The behaviors configuration.
+ * @cfg {Boolean} initiate If the verification should be initiated from this end.
+ */
+ easyXDM.stack.VerifyBehavior = function (config) {
+ var trace = debug.getTracer("easyXDM.stack.VerifyBehavior");
+ trace("constructor");
+ if (undef(config.initiate)) {
+ throw new Error("settings.initiate is not set");
+ }
+ var pub, mySecret, theirSecret, verified = false;
+
+ function startVerification() {
+ trace("requesting verification");
+ mySecret = Math.random().toString(16).substring(2);
+ pub.down.outgoing(mySecret);
+ }
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var indexOf = message.indexOf("_");
+ if (indexOf === -1) {
+ if (message === mySecret) {
+ trace("verified, calling callback");
+ pub.up.callback(true);
+ }
+ else if (!theirSecret) {
+ trace("returning secret");
+ theirSecret = message;
+ if (!config.initiate) {
+ startVerification();
+ }
+ pub.down.outgoing(message);
+ }
}
- else if (!theirSecret) {
- trace("returning secret");
- theirSecret = message;
- if (!config.initiate) {
- startVerification();
+ else {
+ if (message.substring(0, indexOf) === theirSecret) {
+ pub.up.incoming(message.substring(indexOf + 1), origin);
}
- pub.down.outgoing(message);
}
- }
- else {
- if (message.substring(0, indexOf) === theirSecret) {
- pub.up.incoming(message.substring(indexOf + 1), origin);
+ },
+ outgoing: function (message, origin, fn) {
+ pub.down.outgoing(mySecret + "_" + message, origin, fn);
+ },
+ callback: function (success) {
+ if (config.initiate) {
+ startVerification();
}
}
- },
- outgoing: function(message, origin, fn){
- pub.down.outgoing(mySecret + "_" + message, origin, fn);
- },
- callback: function(success){
- if (config.initiate) {
- startVerification();
- }
- }
- });
-};
-/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
-/*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
+ });
+ };
+ /*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
+ /*global easyXDM, window, escape, unescape, undef, getJSON, debug, emptyFn, isArray */
//
// easyXDM
// http://easyxdm.net/
@@ -2655,202 +2656,202 @@ easyXDM.stack.VerifyBehavior = function(config){
// THE SOFTWARE.
//
-/**
- * @class easyXDM.stack.RpcBehavior
- * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
- * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
- * @namespace easyXDM.stack
- * @constructor
- * @param {Object} proxy The object to apply the methods to.
- * @param {Object} config The definition of the local and remote interface to implement.
- * @cfg {Object} local The local interface to expose.
- * @cfg {Object} remote The remote methods to expose through the proxy.
- * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
- */
-easyXDM.stack.RpcBehavior = function(proxy, config){
- var trace = debug.getTracer("easyXDM.stack.RpcBehavior");
- var pub, serializer = config.serializer || getJSON();
- var _callbackCounter = 0, _callbacks = {};
-
/**
- * Serializes and sends the message
- * @private
- * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
+ * @class easyXDM.stack.RpcBehavior
+ * This uses JSON-RPC 2.0 to expose local methods and to invoke remote methods and have responses returned over the the string based transport stack.
+ * Exposed methods can return values synchronous, asyncronous, or bet set up to not return anything.
+ * @namespace easyXDM.stack
+ * @constructor
+ * @param {Object} proxy The object to apply the methods to.
+ * @param {Object} config The definition of the local and remote interface to implement.
+ * @cfg {Object} local The local interface to expose.
+ * @cfg {Object} remote The remote methods to expose through the proxy.
+ * @cfg {Object} serializer The serializer to use for serializing and deserializing the JSON. Should be compatible with the HTML5 JSON object. Optional, will default to JSON.
*/
- function _send(data){
- data.jsonrpc = "2.0";
- pub.down.outgoing(serializer.stringify(data));
- }
-
- /**
- * Creates a method that implements the given definition
- * @private
- * @param {Object} The method configuration
- * @param {String} method The name of the method
- * @return {Function} A stub capable of proxying the requested method call
- */
- function _createMethod(definition, method){
- var slice = Array.prototype.slice;
-
- trace("creating method " + method);
- return function(){
- trace("executing method " + method);
- var l = arguments.length, callback, message = {
- method: method
- };
-
- if (l > 0 && typeof arguments[l - 1] === "function") {
- //with callback, procedure
- if (l > 1 && typeof arguments[l - 2] === "function") {
- // two callbacks, success and error
- callback = {
- success: arguments[l - 2],
- error: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 2);
+ easyXDM.stack.RpcBehavior = function (proxy, config) {
+ var trace = debug.getTracer("easyXDM.stack.RpcBehavior");
+ var pub, serializer = config.serializer || getJSON();
+ var _callbackCounter = 0, _callbacks = {};
+
+ /**
+ * Serializes and sends the message
+ * @private
+ * @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
+ */
+ function _send(data) {
+ data.jsonrpc = "2.0";
+ pub.down.outgoing(serializer.stringify(data));
+ }
+
+ /**
+ * Creates a method that implements the given definition
+ * @private
+ * @param {Object} The method configuration
+ * @param {String} method The name of the method
+ * @return {Function} A stub capable of proxying the requested method call
+ */
+ function _createMethod(definition, method) {
+ var slice = Array.prototype.slice;
+
+ trace("creating method " + method);
+ return function () {
+ trace("executing method " + method);
+ var l = arguments.length, callback, message = {
+ method: method
+ };
+
+ if (l > 0 && typeof arguments[l - 1] === "function") {
+ //with callback, procedure
+ if (l > 1 && typeof arguments[l - 2] === "function") {
+ // two callbacks, success and error
+ callback = {
+ success: arguments[l - 2],
+ error: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 2);
+ }
+ else {
+ // single callback, success
+ callback = {
+ success: arguments[l - 1]
+ };
+ message.params = slice.call(arguments, 0, l - 1);
+ }
+ _callbacks["" + (++_callbackCounter)] = callback;
+ message.id = _callbackCounter;
}
else {
- // single callback, success
- callback = {
- success: arguments[l - 1]
- };
- message.params = slice.call(arguments, 0, l - 1);
+ // no callbacks, a notification
+ message.params = slice.call(arguments, 0);
}
- _callbacks["" + (++_callbackCounter)] = callback;
- message.id = _callbackCounter;
- }
- else {
- // no callbacks, a notification
- message.params = slice.call(arguments, 0);
- }
- if (definition.namedParams && message.params.length === 1) {
- message.params = message.params[0];
+ if (definition.namedParams && message.params.length === 1) {
+ message.params = message.params[0];
+ }
+ // Send the method request
+ _send(message);
+ };
+ }
+
+ /**
+ * Executes the exposed method
+ * @private
+ * @param {String} method The name of the method
+ * @param {Number} id The callback id to use
+ * @param {Function} method The exposed implementation
+ * @param {Array} params The parameters supplied by the remote end
+ */
+ function _executeMethod(method, id, fn, params) {
+ if (!fn) {
+ trace("requested to execute non-existent procedure " + method);
+ if (id) {
+ _send({
+ id: id,
+ error: {
+ code: -32601,
+ message: "Procedure not found."
+ }
+ });
+ }
+ return;
}
- // Send the method request
- _send(message);
- };
- }
-
- /**
- * Executes the exposed method
- * @private
- * @param {String} method The name of the method
- * @param {Number} id The callback id to use
- * @param {Function} method The exposed implementation
- * @param {Array} params The parameters supplied by the remote end
- */
- function _executeMethod(method, id, fn, params){
- if (!fn) {
- trace("requested to execute non-existent procedure " + method);
+
+ trace("requested to execute procedure " + method);
+ var success, error;
if (id) {
- _send({
- id: id,
- error: {
- code: -32601,
- message: "Procedure not found."
- }
- });
- }
- return;
- }
-
- trace("requested to execute procedure " + method);
- var success, error;
- if (id) {
- success = function(result){
- success = emptyFn;
- _send({
- id: id,
- result: result
- });
- };
- error = function(message, data){
- error = emptyFn;
- var msg = {
- id: id,
- error: {
- code: -32099,
- message: message
+ success = function (result) {
+ success = emptyFn;
+ _send({
+ id: id,
+ result: result
+ });
+ };
+ error = function (message, data) {
+ error = emptyFn;
+ var msg = {
+ id: id,
+ error: {
+ code: -32099,
+ message: message
+ }
+ };
+ if (data) {
+ msg.error.data = data;
}
+ _send(msg);
};
- if (data) {
- msg.error.data = data;
+ }
+ else {
+ success = error = emptyFn;
+ }
+ // Call local method
+ if (!isArray(params)) {
+ params = [params];
+ }
+ try {
+ var result = fn.method.apply(fn.scope, params.concat([success, error]));
+ if (!undef(result)) {
+ success(result);
}
- _send(msg);
- };
- }
- else {
- success = error = emptyFn;
- }
- // Call local method
- if (!isArray(params)) {
- params = [params];
- }
- try {
- var result = fn.method.apply(fn.scope, params.concat([success, error]));
- if (!undef(result)) {
- success(result);
}
- }
- catch (ex1) {
- error(ex1.message);
+ catch (ex1) {
+ error(ex1.message);
+ }
}
- }
-
- return (pub = {
- incoming: function(message, origin){
- var data = serializer.parse(message);
- if (data.method) {
- trace("received request to execute method " + data.method + (data.id ? (" using callback id " + data.id) : ""));
- // A method call from the remote end
- if (config.handle) {
- config.handle(data, _send);
+
+ return (pub = {
+ incoming: function (message, origin) {
+ var data = serializer.parse(message);
+ if (data.method) {
+ trace("received request to execute method " + data.method + (data.id ? (" using callback id " + data.id) : ""));
+ // A method call from the remote end
+ if (config.handle) {
+ config.handle(data, _send);
+ }
+ else {
+ _executeMethod(data.method, data.id, config.local[data.method], data.params);
+ }
}
else {
- _executeMethod(data.method, data.id, config.local[data.method], data.params);
- }
- }
- else {
- trace("received return value destined to callback with id " + data.id);
- // A method response from the other end
- var callback = _callbacks[data.id];
- if (data.error) {
- if (callback.error) {
- callback.error(data.error);
+ trace("received return value destined to callback with id " + data.id);
+ // A method response from the other end
+ var callback = _callbacks[data.id];
+ if (data.error) {
+ if (callback.error) {
+ callback.error(data.error);
+ }
+ else {
+ trace("unhandled error returned.");
+ }
}
- else {
- trace("unhandled error returned.");
+ else if (callback.success) {
+ callback.success(data.result);
}
+ delete _callbacks[data.id];
}
- else if (callback.success) {
- callback.success(data.result);
+ },
+ init: function () {
+ trace("init");
+ if (config.remote) {
+ trace("creating stubs");
+ // Implement the remote sides exposed methods
+ for (var method in config.remote) {
+ if (config.remote.hasOwnProperty(method)) {
+ proxy[method] = _createMethod(config.remote[method], method);
+ }
+ }
}
- delete _callbacks[data.id];
- }
- },
- init: function(){
- trace("init");
- if (config.remote) {
- trace("creating stubs");
- // Implement the remote sides exposed methods
+ pub.down.init();
+ },
+ destroy: function () {
+ trace("destroy");
for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method)) {
- proxy[method] = _createMethod(config.remote[method], method);
+ if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
+ delete proxy[method];
}
}
+ pub.down.destroy();
}
- pub.down.init();
- },
- destroy: function(){
- trace("destroy");
- for (var method in config.remote) {
- if (config.remote.hasOwnProperty(method) && proxy.hasOwnProperty(method)) {
- delete proxy[method];
- }
- }
- pub.down.destroy();
- }
- });
-};
-global.easyXDM = easyXDM;
+ });
+ };
+ global.easyXDM = easyXDM;
})(window, document, location, window.setTimeout, decodeURIComponent, encodeURIComponent);
diff --git a/sdk/src/third-party/easyXDM/tests/index.html b/sdk/src/third-party/easyXDM/tests/index.html
index 0232da95..5c4ca323 100644
--- a/sdk/src/third-party/easyXDM/tests/index.html
+++ b/sdk/src/third-party/easyXDM/tests/index.html
@@ -1,91 +1,92 @@
-
-
-
-
easyTest results
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
easyXDM test suite
-
easyTest messages
-
-
-
easyXDM tracelog
-
-
-
-
-
-
-
-
+ }
+
+
+
+
+
+
+
+
easyXDM test suite
+
easyTest messages
+
+
+
+
easyXDM tracelog
+
+
+
+
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/tests/test_namespace.html b/sdk/src/third-party/easyXDM/tests/test_namespace.html
index 63d7a3e4..95dad1a1 100644
--- a/sdk/src/third-party/easyXDM/tests/test_namespace.html
+++ b/sdk/src/third-party/easyXDM/tests/test_namespace.html
@@ -1,32 +1,32 @@
-
-
easyXDM
-
-
+
-
-
-
+ });
+ };
+ window.onunload = function () {
+ if (transport) {
+ transport.destroy();
+ }
+ };
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/tests/test_rpc.html b/sdk/src/third-party/easyXDM/tests/test_rpc.html
index 11a489ff..75b3da1f 100644
--- a/sdk/src/third-party/easyXDM/tests/test_rpc.html
+++ b/sdk/src/third-party/easyXDM/tests/test_rpc.html
@@ -1,65 +1,65 @@
-
-
easyXDM
-
-
+
-
-
+
+
-
-
-
+ }
+ });
+ window.onunload = function () {
+ if (remote) {
+ remote.destroy();
+ }
+ };
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/tests/test_transport.html b/sdk/src/third-party/easyXDM/tests/test_transport.html
index 8210dbc9..ea050e08 100644
--- a/sdk/src/third-party/easyXDM/tests/test_transport.html
+++ b/sdk/src/third-party/easyXDM/tests/test_transport.html
@@ -1,28 +1,28 @@
-
-
easyXDM
-
-
+
-
-
-
+ });
+ };
+ window.onunload = function () {
+ if (transport) {
+ transport.destroy();
+ }
+ };
+
+
+
+
diff --git a/sdk/src/third-party/easyXDM/tests/tests.js b/sdk/src/third-party/easyXDM/tests/tests.js
index d0a940a6..613df70a 100644
--- a/sdk/src/third-party/easyXDM/tests/tests.js
+++ b/sdk/src/third-party/easyXDM/tests/tests.js
@@ -1,6 +1,6 @@
/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
/*global easyTest, easyXDM, window, modules*/
-var REMOTE = (function(){
+var REMOTE = (function () {
var remote = location.href;
switch (location.host) {
case "provider.easyxdm.net":
@@ -21,13 +21,13 @@ var REMOTE = (function(){
var LOCAL = location.protocol + "//" + location.host + location.pathname.substring(0, location.pathname.lastIndexOf("/"));
-function runTests(){
+function runTests() {
var i = 0;
easyTest.test([/**Tests for the presence of namespaces and classes*/{
name: "Check that the library is complete",
steps: [{
name: "check for the presence of easyXDM",
- run: function(){
+ run: function () {
if (this.Assert.isObject(easyXDM) && this.Assert.isString(easyXDM.version)) {
this.log("found easyXDM, version=" + easyXDM.version);
return true;
@@ -36,176 +36,176 @@ function runTests(){
}
}, {
name: "check for the presence of easyXDM.DomHelper",
- run: function(){
+ run: function () {
return this.Assert.isObject(easyXDM.DomHelper);
}
}, {
name: "check for the presence of easyXDM.Socket",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.Socket);
}
}, {
name: "check for the presence of easyXDM.Rpc",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.Rpc);
}
}, {
name: "check for the presence of easyXDM.stack",
- run: function(){
+ run: function () {
return this.Assert.isObject(easyXDM.stack);
}
}, {
name: "check for the presence of easyXDM.stack.SameOriginTransport",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.SameOriginTransport);
}
}, {
name: "check for the presence of easyXDM.stack.PostMessageTransport",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.PostMessageTransport);
}
}, {
name: "check for the presence of easyXDM.stack.FlashTransport",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.FlashTransport);
}
}, {
name: "check for the presence of easyXDM.stack.NameTransport",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.NameTransport);
}
}, {
name: "check for the presence of easyXDM.stack.HashTransport",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.HashTransport);
}
}, {
name: "check for the presence of easyXDM.stack.ReliableBehavior",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.ReliableBehavior);
}
}, {
name: "check for the presence of easyXDM.stack.QueueBehavior",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.QueueBehavior);
}
}, {
name: "check for the presence of easyXDM.stack.VerifyBehavior",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.VerifyBehavior);
}
}, {
name: "check for the presence of easyXDM.stack.RpcBehavior",
- run: function(){
+ run: function () {
return this.Assert.isFunction(easyXDM.stack.RpcBehavior);
}
}]
}, {
name: "Check helper functions",
- runIf: function(){
+ runIf: function () {
if (location.href.indexOf("/src/") == -1) {
return "This can only be run in development.";
}
},
- setUp: function(){
+ setUp: function () {
this.url1 = "http://foo.bar/a/b/c?d=e#f";
this.url2 = "http://foo.bar:80/a/b/c?d=e#f";
this.url3 = "http://foo.bar:88/a/b/c?d=e#f";
this.url4 = "hTtp://Foo.Bar:88/a/b/c?d=e#f";
-
+
},
steps: [{
name: "getDomainName",
- run: function(){
+ run: function () {
return easyXDM.getDomainName(this.url1) === "foo.bar";
}
}, {
name: "getLocation",
- run: function(){
+ run: function () {
return easyXDM.getLocation(this.url1) === "http://foo.bar";
}
}, {
name: "getLocation with standard port",
- run: function(){
+ run: function () {
return easyXDM.getLocation(this.url2) === "http://foo.bar";
}
}, {
name: "getLocation with non-standard port",
- run: function(){
+ run: function () {
return easyXDM.getLocation(this.url3) === "http://foo.bar:88";
}
}, {
name: "getLocation with capitals",
- run: function(){
+ run: function () {
return easyXDM.getLocation(this.url4) === "http://foo.bar:88";
}
}, {
name: "appendQueryParameters",
- run: function(){
+ run: function () {
return easyXDM.appendQueryParameters(this.url2, {
- g: "h"
- }) ===
- "http://foo.bar:80/a/b/c?d=e&g=h#f";
+ g: "h"
+ }) ===
+ "http://foo.bar:80/a/b/c?d=e&g=h#f";
}
}]
}, {
name: "Check the ACL feature",
- runIf: function(){
+ runIf: function () {
if (location.href.indexOf("/src/") == -1) {
return "This can only be run in development.";
}
},
- setUp: function(){
+ setUp: function () {
this.acl = ["http://www.domain.invalid", "*.domaina.com", "http://dom?inb.com", "^http://domc{3}ain\\.com$"];
},
steps: [{
name: "Match complete string",
- run: function(){
+ run: function () {
return easyXDM.checkAcl(this.acl, "http://www.domain.invalid");
}
}, {
name: "Match *",
- run: function(){
+ run: function () {
return easyXDM.checkAcl(this.acl, "http://www.domaina.com");
}
}, {
name: "Match ?",
- run: function(){
+ run: function () {
return easyXDM.checkAcl(this.acl, "http://domainb.com");
}
}, {
name: "Match RegExp",
- run: function(){
+ run: function () {
return easyXDM.checkAcl(this.acl, "http://domcccain.com");
}
}, {
name: "No match",
- run: function(){
+ run: function () {
return !easyXDM.checkAcl(this.acl, "http://foo.com");
}
}]
}, {
name: "test easyXDM.Socket{SameOriginTransport}",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "4",
remote: LOCAL + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
}
}
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -213,46 +213,46 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}, {
name: "destroy",
- run: function(){
+ run: function () {
this.transport.destroy();
return ((document.getElementsByTagName("iframe").length === 0));
}
}]
}, {
name: "test easyXDM.Socket{PostMessageTransport}",
- runIf: function(){
+ runIf: function () {
if (!("postMessage" in window || "postMessage" in document)) {
return "This test requires the HTML5 postMessage interface.";
}
},
-
- setUp: function(){
+
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "1",
local: "../name.html",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
}
}
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -260,33 +260,33 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}, {
name: "destroy",
- run: function(){
+ run: function () {
this.transport.destroy();
return ((document.getElementsByTagName("iframe").length === 0));
}
}]
}, {
name: "test easyXDM.Socket{FlashTransport}",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "6",
remote: REMOTE + "/test_transport.html",
swf: REMOTE + "/../easyxdm.swf",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
@@ -294,7 +294,7 @@ function runTests(){
}
},
container: "embedded",
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -302,44 +302,44 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}, {
name: "destroy",
- run: function(){
+ run: function () {
this.transport.destroy();
return ((document.getElementsByTagName("iframe").length === 0));
}
}]
}, {
name: "test easyXDM.Socket{FrameElementTransport}",
- runIf: function(){
+ runIf: function () {
if (!(navigator.product === "Gecko" && "frameElement" in window && !("postMessage" in window) && navigator.userAgent.indexOf('WebKit') == -1)) {
return "This test requires an older Gecko browser and the presence of the frameElement object";
}
},
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "5",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
}
}
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -347,13 +347,13 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}, {
name: "destroy",
- run: function(){
+ run: function () {
this.transport.destroy();
return ((document.getElementsByTagName("iframe").length === 0));
}
@@ -361,10 +361,10 @@ function runTests(){
}, {
name: "test easyXDM.Socket{NameTransport}",
failedMessage: "This might fail in modern browsers due to restrictions in referencing existing windows",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -373,7 +373,7 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
@@ -381,7 +381,7 @@ function runTests(){
local: "../name.html",
remote: REMOTE + "/test_transport.html",
remoteHelper: REMOTE + "/../name.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
@@ -389,7 +389,7 @@ function runTests(){
}
},
container: document.getElementById("embedded"),
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -397,17 +397,17 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}]
}, {
name: "test easyXDM.Socket{HashTransport} using window",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -416,14 +416,14 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "0", // This is just to override the automatic selection
local: window,
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
@@ -431,7 +431,7 @@ function runTests(){
}
},
container: document.getElementById("embedded"),
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -439,7 +439,7 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
@@ -447,13 +447,13 @@ function runTests(){
}, {
name: "test easyXDM.Socket{HashTransport} with no blank local, available image and resize",
failedMessage: "This might fail in modern browsers due to restrictions in referencing existing windows",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
this.img = document.createElement("img");
this.img.src = "s.gif";
document.body.appendChild(this.img);
},
- tearDown: function(){
+ tearDown: function () {
document.body.removeChild(this.img);
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
@@ -463,18 +463,18 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "0", // This is just to override the automatic selection
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (++messages === 2) {
scope.notifyResult(true);
}
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -482,7 +482,7 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
@@ -490,10 +490,10 @@ function runTests(){
}, {
name: "test easyXDM.Socket{HashTransport} with s.gif and polling",
failedMessage: "This might fail in modern browsers due to restrictions in referencing existing windows",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -502,20 +502,20 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new easyXDM.Socket({
protocol: "0", // This is just to override the automatic selection
local: "s.gif",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (++messages === 2) {
scope.notifyResult(true);
}
},
container: document.getElementById("embedded"),
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -523,7 +523,7 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
@@ -531,14 +531,14 @@ function runTests(){
}, {
name: "test easyXDM.Socket{HashTransport} with fragmentation (8192)",
failedMessage: "This might fail in modern browsers due to restrictions in referencing existing windows",
- setUp: function(){
+ setUp: function () {
var i = 11;
this.expectedMessage = "aaaa";
while (i--) {
this.expectedMessage += this.expectedMessage;
}
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -547,17 +547,17 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.transport = new easyXDM.Socket({
protocol: "0", // This is just to override the automatic selection
local: "../name.html",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
scope.notifyResult(scope.expectedMessage === message);
},
container: document.getElementById("embedded"),
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -565,38 +565,38 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
}
}]
}, {
name: "test easyXDM.noConflict {SameOriginTransport}",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
steps: [{
name: "window.easyXDM is released {namespace}",
timeout: 5000,
- run: function(){
+ run: function () {
this.notifyResult(window.easyXDM._test_global && !modules.easyXDM._test_global);
}
}, {
name: "onReady is fired {namespace}",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
var messages = 0;
this.transport = new modules.easyXDM.Socket({
protocol: "4",
remote: LOCAL + "/test_namespace.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
if (scope.expectedMessage === message) {
if (++messages === 2) {
scope.notifyResult(true);
}
}
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -604,23 +604,23 @@ function runTests(){
}, {
name: "message is echoed back {namespace}",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
this.transport.postMessage(this.expectedMessage);
}
}, {
name: "destroy {namespace}",
- run: function(){
+ run: function () {
this.transport.destroy();
return ((document.getElementsByTagName("iframe").length === 0));
}
}]
}, {
name: "test easyXDM.Socket{}",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -629,16 +629,16 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.transport = new easyXDM.Socket({
local: "../name.html",
swf: REMOTE + "/../easyxdm.swf",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
scope.notifyResult((scope.expectedMessage === message));
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -646,16 +646,16 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
}
}]
}, {
name: "test easyXDM.Socket{} using hash for passing data",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -664,17 +664,17 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.transport = new easyXDM.Socket({
local: "../name.html",
swf: REMOTE + "/../easyxdm.swf",
remote: REMOTE + "/test_transport.html?foo=bar",
hash: true,
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
scope.notifyResult((scope.expectedMessage === message));
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -682,16 +682,16 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
}
}]
}, {
name: "test easyXDM.Socket{} with buffering",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -700,13 +700,13 @@ function runTests(){
steps: [{
name: "Buffered messages are sent",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.transport = new easyXDM.Socket({
local: "../name.html",
swf: REMOTE + "/../easyxdm.swf",
remote: REMOTE + "/test_transport.html",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
scope.notifyResult((scope.expectedMessage === message));
}
});
@@ -715,10 +715,10 @@ function runTests(){
}]
}, {
name: "test easyXDM.Socket{} with query parameters",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.transport.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -727,16 +727,16 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.transport = new easyXDM.Socket({
local: "../name.html",
swf: REMOTE + "/../easyxdm.swf",
remote: REMOTE + "/test_transport.html?a=b&c=d#foo,faa",
- onMessage: function(message, origin){
+ onMessage: function (message, origin) {
scope.notifyResult((scope.expectedMessage === message));
},
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
});
@@ -744,16 +744,16 @@ function runTests(){
}, {
name: "message is echoed back",
timeout: 5000,
- run: function(){
+ run: function () {
this.transport.postMessage(this.expectedMessage);
}
}]
}, {
name: "test easyXDM.Rpc",
- setUp: function(){
+ setUp: function () {
this.expectedMessage = ++i + "_abcd1234%@¤/";
},
- tearDown: function(){
+ tearDown: function () {
this.remote.destroy();
if (document.getElementsByTagName("iframe").length !== 0) {
throw new Error("iframe still present");
@@ -762,7 +762,7 @@ function runTests(){
steps: [{
name: "onReady is fired",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.remote = new easyXDM.Rpc({
local: "../name.html",
@@ -770,7 +770,7 @@ function runTests(){
remote: REMOTE + "/test_rpc.html",
remoteHelper: REMOTE + "/../name.html",
container: document.getElementById("embedded"),
- onReady: function(){
+ onReady: function () {
scope.notifyResult(true);
}
}, {
@@ -786,7 +786,7 @@ function runTests(){
},
local: {
voidCallback: {
- method: function(message){
+ method: function (message) {
scope.notifyResult((scope.expectedMessage === message));
}
}
@@ -796,57 +796,57 @@ function runTests(){
}, {
name: "void method",
timeout: 5000,
- run: function(){
+ run: function () {
this.remote.voidMethod(this.expectedMessage);
}
}, {
name: "async method",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
- this.remote.asyncMethod(this.expectedMessage, function(message){
+ this.remote.asyncMethod(this.expectedMessage, function (message) {
scope.notifyResult((scope.expectedMessage === message));
});
}
}, {
name: "regular method",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
- this.remote.method(this.expectedMessage, function(message){
+ this.remote.method(this.expectedMessage, function (message) {
scope.notifyResult((scope.expectedMessage === message));
});
}
}, {
name: "with error",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
- this.remote.error(this.expectedMessage, function(){
+ this.remote.error(this.expectedMessage, function () {
this.notifyResult(false, "success handler called");
- }, function(message){
+ }, function (message) {
scope.notifyResult(true);
});
}
}, {
name: "calling nonexistent method",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
- this.remote.nonexistent(this.expectedMessage, function(){
+ this.remote.nonexistent(this.expectedMessage, function () {
this.notifyResult(false, "success handler called");
- }, function(message){
+ }, function (message) {
scope.notifyResult(true);
});
}
}, {
name: "using named parameters",
timeout: 5000,
- run: function(){
+ run: function () {
var scope = this;
this.remote.namedParamsMethod({
msg: this.expectedMessage
- }, function(message){
+ }, function (message) {
scope.notifyResult((scope.expectedMessage === message));
});
}
diff --git a/sdk/src/third-party/eventemitter2.js b/sdk/src/third-party/eventemitter2.js
index ba0deeaf..6a8f1c50 100644
--- a/sdk/src/third-party/eventemitter2.js
+++ b/sdk/src/third-party/eventemitter2.js
@@ -23,565 +23,566 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
- ;!function(exports, undefined) {
-
- var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
- return Object.prototype.toString.call(obj) === "[object Array]";
- };
- var defaultMaxListeners = 10;
-
- function init() {
- this._events = {};
- if (this._conf) {
- configure.call(this, this._conf);
+;
+!function (exports, undefined) {
+
+ var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
+ return Object.prototype.toString.call(obj) === "[object Array]";
+ };
+ var defaultMaxListeners = 10;
+
+ function init() {
+ this._events = {};
+ if (this._conf) {
+ configure.call(this, this._conf);
+ }
}
- }
- function configure(conf) {
- if (conf) {
+ function configure(conf) {
+ if (conf) {
- this._conf = conf;
+ this._conf = conf;
- conf.delimiter && (this.delimiter = conf.delimiter);
- conf.maxListeners && (this._events.maxListeners = conf.maxListeners);
- conf.wildcard && (this.wildcard = conf.wildcard);
- conf.newListener && (this.newListener = conf.newListener);
+ conf.delimiter && (this.delimiter = conf.delimiter);
+ conf.maxListeners && (this._events.maxListeners = conf.maxListeners);
+ conf.wildcard && (this.wildcard = conf.wildcard);
+ conf.newListener && (this.newListener = conf.newListener);
- if (this.wildcard) {
- this.listenerTree = {};
- }
- }
- }
-
- function EventEmitter(conf) {
- this._events = {};
- this.newListener = false;
- configure.call(this, conf);
- }
-
- //
- // Attention, function return type now is array, always !
- // It has zero elements if no any matches found and one or more
- // elements (leafs) if there are matches
- //
- function searchListenerTree(handlers, type, tree, i) {
- if (!tree) {
- return [];
+ if (this.wildcard) {
+ this.listenerTree = {};
+ }
+ }
}
- var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached,
- typeLength = type.length, currentType = type[i], nextType = type[i+1];
- if (i === typeLength && tree._listeners) {
- //
- // If at the end of the event(s) list and the tree has listeners
- // invoke those listeners.
- //
- if (typeof tree._listeners === 'function') {
- handlers && handlers.push(tree._listeners);
- return [tree];
- } else {
- for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) {
- handlers && handlers.push(tree._listeners[leaf]);
- }
- return [tree];
- }
+
+ function EventEmitter(conf) {
+ this._events = {};
+ this.newListener = false;
+ configure.call(this, conf);
}
- if ((currentType === '*' || currentType === '**') || tree[currentType]) {
- //
- // If the event emitted is '*' at this part
- // or there is a concrete match at this patch
- //
- if (currentType === '*') {
- for (branch in tree) {
- if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1));
- }
+ //
+ // Attention, function return type now is array, always !
+ // It has zero elements if no any matches found and one or more
+ // elements (leafs) if there are matches
+ //
+ function searchListenerTree(handlers, type, tree, i) {
+ if (!tree) {
+ return [];
}
- return listeners;
- } else if(currentType === '**') {
- endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*'));
- if(endReached && tree._listeners) {
- // The next element has a _listeners, add it to the handlers.
- listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength));
- }
-
- for (branch in tree) {
- if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
- if(branch === '*' || branch === '**') {
- if(tree[branch]._listeners && !endReached) {
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength));
- }
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
- } else if(branch === nextType) {
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2));
+ var listeners = [], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached,
+ typeLength = type.length, currentType = type[i], nextType = type[i + 1];
+ if (i === typeLength && tree._listeners) {
+ //
+ // If at the end of the event(s) list and the tree has listeners
+ // invoke those listeners.
+ //
+ if (typeof tree._listeners === 'function') {
+ handlers && handlers.push(tree._listeners);
+ return [tree];
} else {
- // No match on this one, shift into the tree but not in the type array.
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
+ for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) {
+ handlers && handlers.push(tree._listeners[leaf]);
+ }
+ return [tree];
}
- }
}
- return listeners;
- }
- listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1));
- }
+ if ((currentType === '*' || currentType === '**') || tree[currentType]) {
+ //
+ // If the event emitted is '*' at this part
+ // or there is a concrete match at this patch
+ //
+ if (currentType === '*') {
+ for (branch in tree) {
+ if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i + 1));
+ }
+ }
+ return listeners;
+ } else if (currentType === '**') {
+ endReached = (i + 1 === typeLength || (i + 2 === typeLength && nextType === '*'));
+ if (endReached && tree._listeners) {
+ // The next element has a _listeners, add it to the handlers.
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength));
+ }
+
+ for (branch in tree) {
+ if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
+ if (branch === '*' || branch === '**') {
+ if (tree[branch]._listeners && !endReached) {
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength));
+ }
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
+ } else if (branch === nextType) {
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i + 2));
+ } else {
+ // No match on this one, shift into the tree but not in the type array.
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
+ }
+ }
+ }
+ return listeners;
+ }
- xTree = tree['*'];
- if (xTree) {
- //
- // If the listener tree will allow any match for this part,
- // then recursively explore all branches of the tree
- //
- searchListenerTree(handlers, type, xTree, i+1);
- }
+ listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i + 1));
+ }
- xxTree = tree['**'];
- if(xxTree) {
- if(i < typeLength) {
- if(xxTree._listeners) {
- // If we have a listener on a '**', it will catch all, so add its handler.
- searchListenerTree(handlers, type, xxTree, typeLength);
- }
-
- // Build arrays of matching next branches and others.
- for(branch in xxTree) {
- if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) {
- if(branch === nextType) {
- // We know the next element will match, so jump twice.
- searchListenerTree(handlers, type, xxTree[branch], i+2);
- } else if(branch === currentType) {
- // Current node matches, move into the tree.
- searchListenerTree(handlers, type, xxTree[branch], i+1);
- } else {
- isolatedBranch = {};
- isolatedBranch[branch] = xxTree[branch];
- searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1);
+ xTree = tree['*'];
+ if (xTree) {
+ //
+ // If the listener tree will allow any match for this part,
+ // then recursively explore all branches of the tree
+ //
+ searchListenerTree(handlers, type, xTree, i + 1);
+ }
+
+ xxTree = tree['**'];
+ if (xxTree) {
+ if (i < typeLength) {
+ if (xxTree._listeners) {
+ // If we have a listener on a '**', it will catch all, so add its handler.
+ searchListenerTree(handlers, type, xxTree, typeLength);
+ }
+
+ // Build arrays of matching next branches and others.
+ for (branch in xxTree) {
+ if (branch !== '_listeners' && xxTree.hasOwnProperty(branch)) {
+ if (branch === nextType) {
+ // We know the next element will match, so jump twice.
+ searchListenerTree(handlers, type, xxTree[branch], i + 2);
+ } else if (branch === currentType) {
+ // Current node matches, move into the tree.
+ searchListenerTree(handlers, type, xxTree[branch], i + 1);
+ } else {
+ isolatedBranch = {};
+ isolatedBranch[branch] = xxTree[branch];
+ searchListenerTree(handlers, type, {'**': isolatedBranch}, i + 1);
+ }
+ }
+ }
+ } else if (xxTree._listeners) {
+ // We have reached the end and still on a '**'
+ searchListenerTree(handlers, type, xxTree, typeLength);
+ } else if (xxTree['*'] && xxTree['*']._listeners) {
+ searchListenerTree(handlers, type, xxTree['*'], typeLength);
}
- }
- }
- } else if(xxTree._listeners) {
- // We have reached the end and still on a '**'
- searchListenerTree(handlers, type, xxTree, typeLength);
- } else if(xxTree['*'] && xxTree['*']._listeners) {
- searchListenerTree(handlers, type, xxTree['*'], typeLength);
- }
- }
+ }
- return listeners;
- }
+ return listeners;
+ }
- function growListenerTree(type, listener) {
+ function growListenerTree(type, listener) {
- type = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ type = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
- //
- // Looks for two consecutive '**', if so, don't add the event at all.
- //
- for(var i = 0, len = type.length; i+1 < len; i++) {
- if(type[i] === '**' && type[i+1] === '**') {
- return;
- }
- }
+ //
+ // Looks for two consecutive '**', if so, don't add the event at all.
+ //
+ for (var i = 0, len = type.length; i + 1 < len; i++) {
+ if (type[i] === '**' && type[i + 1] === '**') {
+ return;
+ }
+ }
- var tree = this.listenerTree;
- var name = type.shift();
+ var tree = this.listenerTree;
+ var name = type.shift();
- while (name) {
+ while (name) {
- if (!tree[name]) {
- tree[name] = {};
- }
+ if (!tree[name]) {
+ tree[name] = {};
+ }
- tree = tree[name];
+ tree = tree[name];
- if (type.length === 0) {
+ if (type.length === 0) {
- if (!tree._listeners) {
- tree._listeners = listener;
- }
- else if(typeof tree._listeners === 'function') {
- tree._listeners = [tree._listeners, listener];
- }
- else if (isArray(tree._listeners)) {
+ if (!tree._listeners) {
+ tree._listeners = listener;
+ }
+ else if (typeof tree._listeners === 'function') {
+ tree._listeners = [tree._listeners, listener];
+ }
+ else if (isArray(tree._listeners)) {
- tree._listeners.push(listener);
+ tree._listeners.push(listener);
- if (!tree._listeners.warned) {
+ if (!tree._listeners.warned) {
- var m = defaultMaxListeners;
+ var m = defaultMaxListeners;
- if (typeof this._events.maxListeners !== 'undefined') {
- m = this._events.maxListeners;
- }
+ if (typeof this._events.maxListeners !== 'undefined') {
+ m = this._events.maxListeners;
+ }
- if (m > 0 && tree._listeners.length > m) {
+ if (m > 0 && tree._listeners.length > m) {
- tree._listeners.warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- tree._listeners.length);
- console.trace();
+ tree._listeners.warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ tree._listeners.length);
+ console.trace();
+ }
+ }
+ }
+ return true;
}
- }
+ name = type.shift();
}
return true;
- }
- name = type.shift();
}
- return true;
- }
- // By default EventEmitters will print a warning if more than
- // 10 listeners are added to it. This is a useful default which
- // helps finding memory leaks.
- //
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
+ // By default EventEmitters will print a warning if more than
+ // 10 listeners are added to it. This is a useful default which
+ // helps finding memory leaks.
+ //
+ // Obviously not all Emitters should be limited to 10. This function allows
+ // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.delimiter = '.';
+ EventEmitter.prototype.delimiter = '.';
- EventEmitter.prototype.setMaxListeners = function(n) {
- this._events || init.call(this);
- this._events.maxListeners = n;
- if (!this._conf) this._conf = {};
- this._conf.maxListeners = n;
- };
+ EventEmitter.prototype.setMaxListeners = function (n) {
+ this._events || init.call(this);
+ this._events.maxListeners = n;
+ if (!this._conf) this._conf = {};
+ this._conf.maxListeners = n;
+ };
- EventEmitter.prototype.event = '';
+ EventEmitter.prototype.event = '';
- EventEmitter.prototype.once = function(event, fn) {
- this.many(event, 1, fn);
- return this;
- };
+ EventEmitter.prototype.once = function (event, fn) {
+ this.many(event, 1, fn);
+ return this;
+ };
- EventEmitter.prototype.many = function(event, ttl, fn) {
- var self = this;
+ EventEmitter.prototype.many = function (event, ttl, fn) {
+ var self = this;
- if (typeof fn !== 'function') {
- throw new Error('many only accepts instances of Function');
- }
+ if (typeof fn !== 'function') {
+ throw new Error('many only accepts instances of Function');
+ }
- function listener() {
- if (--ttl === 0) {
- self.off(event, listener);
- }
- fn.apply(this, arguments);
- }
+ function listener() {
+ if (--ttl === 0) {
+ self.off(event, listener);
+ }
+ fn.apply(this, arguments);
+ }
- listener._origin = fn;
+ listener._origin = fn;
- this.on(event, listener);
+ this.on(event, listener);
- return self;
- };
+ return self;
+ };
- EventEmitter.prototype.emit = function() {
+ EventEmitter.prototype.emit = function () {
- this._events || init.call(this);
+ this._events || init.call(this);
- var type = arguments[0];
+ var type = arguments[0];
- if (type === 'newListener' && !this.newListener) {
- if (!this._events.newListener) { return false; }
- }
+ if (type === 'newListener' && !this.newListener) {
+ if (!this._events.newListener) {
+ return false;
+ }
+ }
- // Loop through the *_all* functions and invoke them.
- if (this._all) {
- var l = arguments.length;
- var args = new Array(l - 1);
- for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
- for (i = 0, l = this._all.length; i < l; i++) {
- this.event = type;
- this._all[i].apply(this, args);
- }
- }
+ // Loop through the *_all* functions and invoke them.
+ if (this._all) {
+ var l = arguments.length;
+ var args = new Array(l - 1);
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
+ for (i = 0, l = this._all.length; i < l; i++) {
+ this.event = type;
+ this._all[i].apply(this, args);
+ }
+ }
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
- if (!this._all &&
- !this._events.error &&
- !(this.wildcard && this.listenerTree.error)) {
+ if (!this._all && !this._events.error && !(this.wildcard && this.listenerTree.error)) {
- if (arguments[1] instanceof Error) {
- throw arguments[1]; // Unhandled 'error' event
- } else {
- throw new Error("Uncaught, unspecified 'error' event.");
+ if (arguments[1] instanceof Error) {
+ throw arguments[1]; // Unhandled 'error' event
+ } else {
+ throw new Error("Uncaught, unspecified 'error' event.");
+ }
+ return false;
+ }
}
- return false;
- }
- }
- var handler;
+ var handler;
- if(this.wildcard) {
- handler = [];
- var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
- searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
- }
- else {
- handler = this._events[type];
- }
+ if (this.wildcard) {
+ handler = [];
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
+ }
+ else {
+ handler = this._events[type];
+ }
- if (typeof handler === 'function') {
- this.event = type;
- if (arguments.length === 1) {
- handler.call(this);
- }
- else if (arguments.length > 1)
- switch (arguments.length) {
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
+ if (typeof handler === 'function') {
+ this.event = type;
+ if (arguments.length === 1) {
+ handler.call(this);
+ }
+ else if (arguments.length > 1)
+ switch (arguments.length) {
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ var l = arguments.length;
+ var args = new Array(l - 1);
+ for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
+ handler.apply(this, args);
+ }
+ return true;
+ }
+ else if (handler) {
var l = arguments.length;
var args = new Array(l - 1);
for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
- handler.apply(this, args);
+
+ var listeners = handler.slice();
+ for (var i = 0, l = listeners.length; i < l; i++) {
+ this.event = type;
+ listeners[i].apply(this, args);
+ }
+ return (listeners.length > 0) || this._all;
+ }
+ else {
+ return this._all;
}
- return true;
- }
- else if (handler) {
- var l = arguments.length;
- var args = new Array(l - 1);
- for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
-
- var listeners = handler.slice();
- for (var i = 0, l = listeners.length; i < l; i++) {
- this.event = type;
- listeners[i].apply(this, args);
- }
- return (listeners.length > 0) || this._all;
- }
- else {
- return this._all;
- }
- };
+ };
- EventEmitter.prototype.on = function(type, listener) {
+ EventEmitter.prototype.on = function (type, listener) {
- if (typeof type === 'function') {
- this.onAny(type);
- return this;
- }
+ if (typeof type === 'function') {
+ this.onAny(type);
+ return this;
+ }
- if (typeof listener !== 'function') {
- throw new Error('on only accepts instances of Function');
- }
- this._events || init.call(this);
+ if (typeof listener !== 'function') {
+ throw new Error('on only accepts instances of Function');
+ }
+ this._events || init.call(this);
- // To avoid recursion in the case that type == "newListeners"! Before
- // adding it to the listeners, first emit "newListeners".
- this.emit('newListener', type, listener);
+ // To avoid recursion in the case that type == "newListeners"! Before
+ // adding it to the listeners, first emit "newListeners".
+ this.emit('newListener', type, listener);
- if(this.wildcard) {
- growListenerTree.call(this, type, listener);
- return this;
- }
+ if (this.wildcard) {
+ growListenerTree.call(this, type, listener);
+ return this;
+ }
- if (!this._events[type]) {
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- }
- else if(typeof this._events[type] === 'function') {
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
- }
- else if (isArray(this._events[type])) {
- // If we've already got an array, just append.
- this._events[type].push(listener);
+ if (!this._events[type]) {
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ }
+ else if (typeof this._events[type] === 'function') {
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+ }
+ else if (isArray(this._events[type])) {
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
- // Check for listener leak
- if (!this._events[type].warned) {
+ // Check for listener leak
+ if (!this._events[type].warned) {
- var m = defaultMaxListeners;
+ var m = defaultMaxListeners;
- if (typeof this._events.maxListeners !== 'undefined') {
- m = this._events.maxListeners;
- }
+ if (typeof this._events.maxListeners !== 'undefined') {
+ m = this._events.maxListeners;
+ }
- if (m > 0 && this._events[type].length > m) {
+ if (m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
- console.trace();
+ console.trace();
+ }
+ }
}
- }
- }
- return this;
- };
-
- EventEmitter.prototype.onAny = function(fn) {
-
- if(!this._all) {
- this._all = [];
- }
-
- if (typeof fn !== 'function') {
- throw new Error('onAny only accepts instances of Function');
- }
-
- // Add the function to the event listener collection.
- this._all.push(fn);
- return this;
- };
-
- EventEmitter.prototype.addListener = EventEmitter.prototype.on;
+ return this;
+ };
- EventEmitter.prototype.off = function(type, listener) {
- if (typeof listener !== 'function') {
- throw new Error('removeListener only takes instances of Function');
- }
+ EventEmitter.prototype.onAny = function (fn) {
- var handlers,leafs=[];
+ if (!this._all) {
+ this._all = [];
+ }
- if(this.wildcard) {
- var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
- leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
- }
- else {
- // does not use listeners(), so no side effect of creating _events[type]
- if (!this._events[type]) return this;
- handlers = this._events[type];
- leafs.push({_listeners:handlers});
- }
+ if (typeof fn !== 'function') {
+ throw new Error('onAny only accepts instances of Function');
+ }
- for (var iLeaf=0; iLeaf
0) {
+ fns = this._all;
+ for (i = 0, l = fns.length; i < l; i++) {
+ if (fn === fns[i]) {
+ fns.splice(i, 1);
+ return this;
+ }
+ }
+ } else {
+ this._all = [];
}
- }
- }
-
- return this;
- };
-
- EventEmitter.prototype.offAny = function(fn) {
- var i = 0, l = 0, fns;
- if (fn && this._all && this._all.length > 0) {
- fns = this._all;
- for(i = 0, l = fns.length; i < l; i++) {
- if(fn === fns[i]) {
- fns.splice(i, 1);
- return this;
- }
- }
- } else {
- this._all = [];
- }
- return this;
- };
+ return this;
+ };
- EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
+ EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
- EventEmitter.prototype.removeAllListeners = function(type) {
- if (arguments.length === 0) {
- !this._events || init.call(this);
- return this;
- }
+ EventEmitter.prototype.removeAllListeners = function (type) {
+ if (arguments.length === 0) {
+ !this._events || init.call(this);
+ return this;
+ }
- if(this.wildcard) {
- var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
- var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
+ if (this.wildcard) {
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
- for (var iLeaf=0; iLeaf= 0 && j < len ? [ this[j] ] : [] );
- },
-
- end: function() {
- return this.prevObject || this.constructor(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: deletedIds.sort,
- splice: deletedIds.splice
-};
-
-jQuery.extend = jQuery.fn.extend = function() {
- var src, copyIsArray, copy, name, options, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
-
- // skip the boolean and the target
- target = arguments[ i ] || {};
- i++;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( i === length ) {
- target = this;
- i--;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- // Unique for each copy of jQuery on the page
- expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
-
- // Assume jQuery is ready without the ready module
- isReady: true,
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- noop: function() {},
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- isWindow: function( obj ) {
- /* jshint eqeqeq: false */
- return obj != null && obj == obj.window;
- },
-
- isNumeric: function( obj ) {
- // parseFloat NaNs numeric-cast false positives (null|true|false|"")
- // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
- // subtraction forces infinities to NaN
- return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
- },
-
- isEmptyObject: function( obj ) {
- var name;
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- isPlainObject: function( obj ) {
- var key;
-
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- } catch ( e ) {
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Support: IE<9
- // Handle iteration over inherited properties before own properties.
- if ( support.ownLast ) {
- for ( key in obj ) {
- return hasOwn.call( obj, key );
- }
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- for ( key in obj ) {}
-
- return key === undefined || hasOwn.call( obj, key );
- },
-
- type: function( obj ) {
- if ( obj == null ) {
- return obj + "";
- }
- return typeof obj === "object" || typeof obj === "function" ?
- class2type[ toString.call(obj) ] || "object" :
- typeof obj;
- },
-
- // Evaluates a script in a global context
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && jQuery.trim( data ) ) {
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data );
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
- },
-
- // args is for internal usage only
- each: function( obj, callback, args ) {
- var value,
- i = 0,
- length = obj.length,
- isArray = isArraylike( obj );
-
- if ( args ) {
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback.apply( obj[ i ], args );
-
- if ( value === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- value = callback.apply( obj[ i ], args );
-
- if ( value === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback.call( obj[ i ], i, obj[ i ] );
-
- if ( value === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- value = callback.call( obj[ i ], i, obj[ i ] );
-
- if ( value === false ) {
- break;
- }
- }
- }
- }
-
- return obj;
- },
-
- // Support: Android<4.1, IE<9
- trim: function( text ) {
- return text == null ?
- "" :
- ( text + "" ).replace( rtrim, "" );
- },
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var ret = results || [];
-
- if ( arr != null ) {
- if ( isArraylike( Object(arr) ) ) {
- jQuery.merge( ret,
- typeof arr === "string" ?
- [ arr ] : arr
- );
- } else {
- push.call( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- var len;
-
- if ( arr ) {
- if ( indexOf ) {
- return indexOf.call( arr, elem, i );
- }
-
- len = arr.length;
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
-
- for ( ; i < len; i++ ) {
- // Skip accessing in sparse arrays
- if ( i in arr && arr[ i ] === elem ) {
- return i;
- }
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var len = +second.length,
- j = 0,
- i = first.length;
-
- while ( j < len ) {
- first[ i++ ] = second[ j++ ];
- }
-
- // Support: IE<9
- // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
- if ( len !== len ) {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, invert ) {
- var callbackInverse,
- matches = [],
- i = 0,
- length = elems.length,
- callbackExpect = !invert;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- callbackInverse = !callback( elems[ i ], i );
- if ( callbackInverse !== callbackExpect ) {
- matches.push( elems[ i ] );
- }
- }
-
- return matches;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var value,
- i = 0,
- length = elems.length,
- isArray = isArraylike( elems ),
- ret = [];
-
- // Go through the array, translating each of the items to their new values
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( i in elems ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
- }
-
- // Flatten any nested arrays
- return concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- var args, proxy, tmp;
-
- if ( typeof context === "string" ) {
- tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- args = slice.call( arguments, 2 );
- proxy = function() {
- return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || jQuery.guid++;
-
- return proxy;
- },
-
- now: function() {
- return +( new Date() );
- },
-
- // jQuery.support is not used in Core but other projects attach their
- // properties to it so it needs to exist.
- support: support
-});
+ slice: function () {
+ return this.pushStack(slice.apply(this, arguments));
+ },
+
+ first: function () {
+ return this.eq(0);
+ },
+
+ last: function () {
+ return this.eq(-1);
+ },
+
+ eq: function (i) {
+ var len = this.length,
+ j = +i + ( i < 0 ? len : 0 );
+ return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
+ },
+
+ end: function () {
+ return this.prevObject || this.constructor(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: deletedIds.sort,
+ splice: deletedIds.splice
+ };
+
+ jQuery.extend = jQuery.fn.extend = function () {
+ var src, copyIsArray, copy, name, options, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if (typeof target === "boolean") {
+ deep = target;
+
+ // skip the boolean and the target
+ target = arguments[i] || {};
+ i++;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if (typeof target !== "object" && !jQuery.isFunction(target)) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if (i === length) {
+ target = this;
+ i--;
+ }
+
+ for (; i < length; i++) {
+ // Only deal with non-null/undefined values
+ if ((options = arguments[i]) != null) {
+ // Extend the base object
+ for (name in options) {
+ src = target[name];
+ copy = options[name];
+
+ // Prevent never-ending loop
+ if (target === copy) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if (deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) )) {
+ if (copyIsArray) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[name] = jQuery.extend(deep, clone, copy);
+
+ // Don't bring in undefined values
+ } else if (copy !== undefined) {
+ target[name] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+ };
+
+ jQuery.extend({
+ // Unique for each copy of jQuery on the page
+ expando: "jQuery" + ( version + Math.random() ).replace(/\D/g, ""),
+
+ // Assume jQuery is ready without the ready module
+ isReady: true,
+
+ error: function (msg) {
+ throw new Error(msg);
+ },
+
+ noop: function () {
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function (obj) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function (obj) {
+ return jQuery.type(obj) === "array";
+ },
+
+ isWindow: function (obj) {
+ /* jshint eqeqeq: false */
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function (obj) {
+ // parseFloat NaNs numeric-cast false positives (null|true|false|"")
+ // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+ // subtraction forces infinities to NaN
+ return !jQuery.isArray(obj) && obj - parseFloat(obj) >= 0;
+ },
+
+ isEmptyObject: function (obj) {
+ var name;
+ for (name in obj) {
+ return false;
+ }
+ return true;
+ },
+
+ isPlainObject: function (obj) {
+ var key;
+
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if (!obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow(obj)) {
+ return false;
+ }
+
+ try {
+ // Not own constructor property must be Object
+ if (obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
+ return false;
+ }
+ } catch (e) {
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Support: IE<9
+ // Handle iteration over inherited properties before own properties.
+ if (support.ownLast) {
+ for (key in obj) {
+ return hasOwn.call(obj, key);
+ }
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+ for (key in obj) {
+ }
+
+ return key === undefined || hasOwn.call(obj, key);
+ },
+
+ type: function (obj) {
+ if (obj == null) {
+ return obj + "";
+ }
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[toString.call(obj)] || "object" :
+ typeof obj;
+ },
+
+ // Evaluates a script in a global context
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function (data) {
+ if (data && jQuery.trim(data)) {
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function (data) {
+ window["eval"].call(window, data);
+ } )(data);
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function (string) {
+ return string.replace(rmsPrefix, "ms-").replace(rdashAlpha, fcamelCase);
+ },
+
+ nodeName: function (elem, name) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ // args is for internal usage only
+ each: function (obj, callback, args) {
+ var value,
+ i = 0,
+ length = obj.length,
+ isArray = isArraylike(obj);
+
+ if (args) {
+ if (isArray) {
+ for (; i < length; i++) {
+ value = callback.apply(obj[i], args);
+
+ if (value === false) {
+ break;
+ }
+ }
+ } else {
+ for (i in obj) {
+ value = callback.apply(obj[i], args);
+
+ if (value === false) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if (isArray) {
+ for (; i < length; i++) {
+ value = callback.call(obj[i], i, obj[i]);
+
+ if (value === false) {
+ break;
+ }
+ }
+ } else {
+ for (i in obj) {
+ value = callback.call(obj[i], i, obj[i]);
+
+ if (value === false) {
+ break;
+ }
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Support: Android<4.1, IE<9
+ trim: function (text) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace(rtrim, "");
+ },
+
+ // results is for internal usage only
+ makeArray: function (arr, results) {
+ var ret = results || [];
+
+ if (arr != null) {
+ if (isArraylike(Object(arr))) {
+ jQuery.merge(ret,
+ typeof arr === "string" ?
+ [arr] : arr
+ );
+ } else {
+ push.call(ret, arr);
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function (elem, arr, i) {
+ var len;
+
+ if (arr) {
+ if (indexOf) {
+ return indexOf.call(arr, elem, i);
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
+
+ for (; i < len; i++) {
+ // Skip accessing in sparse arrays
+ if (i in arr && arr[i] === elem) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function (first, second) {
+ var len = +second.length,
+ j = 0,
+ i = first.length;
+
+ while (j < len) {
+ first[i++] = second[j++];
+ }
+
+ // Support: IE<9
+ // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
+ if (len !== len) {
+ while (second[j] !== undefined) {
+ first[i++] = second[j++];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function (elems, callback, invert) {
+ var callbackInverse,
+ matches = [],
+ i = 0,
+ length = elems.length,
+ callbackExpect = !invert;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for (; i < length; i++) {
+ callbackInverse = !callback(elems[i], i);
+ if (callbackInverse !== callbackExpect) {
+ matches.push(elems[i]);
+ }
+ }
+
+ return matches;
+ },
+
+ // arg is for internal usage only
+ map: function (elems, callback, arg) {
+ var value,
+ i = 0,
+ length = elems.length,
+ isArray = isArraylike(elems),
+ ret = [];
+
+ // Go through the array, translating each of the items to their new values
+ if (isArray) {
+ for (; i < length; i++) {
+ value = callback(elems[i], i, arg);
+
+ if (value != null) {
+ ret.push(value);
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for (i in elems) {
+ value = callback(elems[i], i, arg);
+
+ if (value != null) {
+ ret.push(value);
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return concat.apply([], ret);
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function (fn, context) {
+ var args, proxy, tmp;
+
+ if (typeof context === "string") {
+ tmp = fn[context];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if (!jQuery.isFunction(fn)) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = slice.call(arguments, 2);
+ proxy = function () {
+ return fn.apply(context || this, args.concat(slice.call(arguments)));
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ now: function () {
+ return +( new Date() );
+ },
+
+ // jQuery.support is not used in Core but other projects attach their
+ // properties to it so it needs to exist.
+ support: support
+ });
// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-function isArraylike( obj ) {
- var length = obj.length,
- type = jQuery.type( obj );
-
- if ( type === "function" || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- if ( obj.nodeType === 1 && length ) {
- return true;
- }
-
- return type === "array" || length === 0 ||
- typeof length === "number" && length > 0 && ( length - 1 ) in obj;
-}
-var Sizzle =
-/*!
- * Sizzle CSS Selector Engine v1.10.19
- * http://sizzlejs.com/
- *
- * Copyright 2013 jQuery Foundation, Inc. and other contributors
- * Released under the MIT license
- * http://jquery.org/license
- *
- * Date: 2014-04-18
- */
-(function( window ) {
-
-var i,
- support,
- Expr,
- getText,
- isXML,
- tokenize,
- compile,
- select,
- outermostContext,
- sortInput,
- hasDuplicate,
-
- // Local document vars
- setDocument,
- document,
- docElem,
- documentIsHTML,
- rbuggyQSA,
- rbuggyMatches,
- matches,
- contains,
-
- // Instance-specific data
- expando = "sizzle" + -(new Date()),
- preferredDoc = window.document,
- dirruns = 0,
- done = 0,
- classCache = createCache(),
- tokenCache = createCache(),
- compilerCache = createCache(),
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- }
- return 0;
- },
-
- // General-purpose constants
- strundefined = typeof undefined,
- MAX_NEGATIVE = 1 << 31,
-
- // Instance methods
- hasOwn = ({}).hasOwnProperty,
- arr = [],
- pop = arr.pop,
- push_native = arr.push,
- push = arr.push,
- slice = arr.slice,
- // Use a stripped-down indexOf if we can't use a native one
- indexOf = arr.indexOf || function( elem ) {
- var i = 0,
- len = this.length;
- for ( ; i < len; i++ ) {
- if ( this[i] === elem ) {
- return i;
- }
- }
- return -1;
- },
-
- booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
-
- // Regular expressions
-
- // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
- whitespace = "[\\x20\\t\\r\\n\\f]",
- // http://www.w3.org/TR/css3-syntax/#characters
- characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
-
- // Loosely modeled on CSS identifier characters
- // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
- // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
- identifier = characterEncoding.replace( "w", "w#" ),
-
- // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
- attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
- // Operator (capture 2)
- "*([*^$|!~]?=)" + whitespace +
- // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
- "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
- "*\\]",
-
- pseudos = ":(" + characterEncoding + ")(?:\\((" +
- // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
- // 1. quoted (capture 3; capture 4 or capture 5)
- "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
- // 2. simple (capture 6)
- "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
- // 3. anything else (capture 2)
- ".*" +
- ")\\)|)",
-
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
-
- rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
- rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
-
- rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
-
- rpseudo = new RegExp( pseudos ),
- ridentifier = new RegExp( "^" + identifier + "$" ),
-
- matchExpr = {
- "ID": new RegExp( "^#(" + characterEncoding + ")" ),
- "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
- "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
- "ATTR": new RegExp( "^" + attributes ),
- "PSEUDO": new RegExp( "^" + pseudos ),
- "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
- "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
- "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
- // For use in libraries implementing .is()
- // We use this for POS matching in `select`
- "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
- whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
- },
-
- rinputs = /^(?:input|select|textarea|button)$/i,
- rheader = /^h\d$/i,
-
- rnative = /^[^{]+\{\s*\[native \w/,
-
- // Easily-parseable/retrievable ID or TAG or CLASS selectors
- rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
-
- rsibling = /[+~]/,
- rescape = /'|\\/g,
-
- // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
- runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
- funescape = function( _, escaped, escapedWhitespace ) {
- var high = "0x" + escaped - 0x10000;
- // NaN means non-codepoint
- // Support: Firefox<24
- // Workaround erroneous numeric interpretation of +"0x"
- return high !== high || escapedWhitespace ?
- escaped :
- high < 0 ?
- // BMP codepoint
- String.fromCharCode( high + 0x10000 ) :
- // Supplemental Plane codepoint (surrogate pair)
- String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
- };
+ jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (i, name) {
+ class2type["[object " + name + "]"] = name.toLowerCase();
+ });
+
+ function isArraylike(obj) {
+ var length = obj.length,
+ type = jQuery.type(obj);
+
+ if (type === "function" || jQuery.isWindow(obj)) {
+ return false;
+ }
+
+ if (obj.nodeType === 1 && length) {
+ return true;
+ }
+
+ return type === "array" || length === 0 ||
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj;
+ }
+
+ var Sizzle =
+ /*!
+ * Sizzle CSS Selector Engine v1.10.19
+ * http://sizzlejs.com/
+ *
+ * Copyright 2013 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2014-04-18
+ */
+ (function (window) {
+
+ var i,
+ support,
+ Expr,
+ getText,
+ isXML,
+ tokenize,
+ compile,
+ select,
+ outermostContext,
+ sortInput,
+ hasDuplicate,
+
+ // Local document vars
+ setDocument,
+ document,
+ docElem,
+ documentIsHTML,
+ rbuggyQSA,
+ rbuggyMatches,
+ matches,
+ contains,
+
+ // Instance-specific data
+ expando = "sizzle" + -(new Date()),
+ preferredDoc = window.document,
+ dirruns = 0,
+ done = 0,
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+ sortOrder = function (a, b) {
+ if (a === b) {
+ hasDuplicate = true;
+ }
+ return 0;
+ },
+
+ // General-purpose constants
+ strundefined = typeof undefined,
+ MAX_NEGATIVE = 1 << 31,
+
+ // Instance methods
+ hasOwn = ({}).hasOwnProperty,
+ arr = [],
+ pop = arr.pop,
+ push_native = arr.push,
+ push = arr.push,
+ slice = arr.slice,
+ // Use a stripped-down indexOf if we can't use a native one
+ indexOf = arr.indexOf || function (elem) {
+ var i = 0,
+ len = this.length;
+ for (; i < len; i++) {
+ if (this[i] === elem) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
+
+ // Regular expressions
+
+ // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+ // http://www.w3.org/TR/css3-syntax/#characters
+ characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
+
+ // Loosely modeled on CSS identifier characters
+ // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
+ // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = characterEncoding.replace("w", "w#"),
+
+ // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
+ attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
+ // Operator (capture 2)
+ "*([*^$|!~]?=)" + whitespace +
+ // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
+ "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
+ "*\\]",
+
+ pseudos = ":(" + characterEncoding + ")(?:\\((" +
+ // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
+ // 1. quoted (capture 3; capture 4 or capture 5)
+ "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
+ // 2. simple (capture 6)
+ "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
+ // 3. anything else (capture 2)
+ ".*" +
+ ")\\)|)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
+
+ rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*"),
+ rcombinators = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*"),
+
+ rattributeQuotes = new RegExp("=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g"),
+
+ rpseudo = new RegExp(pseudos),
+ ridentifier = new RegExp("^" + identifier + "$"),
+
+ matchExpr = {
+ "ID": new RegExp("^#(" + characterEncoding + ")"),
+ "CLASS": new RegExp("^\\.(" + characterEncoding + ")"),
+ "TAG": new RegExp("^(" + characterEncoding.replace("w", "w*") + ")"),
+ "ATTR": new RegExp("^" + attributes),
+ "PSEUDO": new RegExp("^" + pseudos),
+ "CHILD": new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i"),
+ "bool": new RegExp("^(?:" + booleans + ")$", "i"),
+ // For use in libraries implementing .is()
+ // We use this for POS matching in `select`
+ "needsContext": new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
+ whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
+ },
+
+ rinputs = /^(?:input|select|textarea|button)$/i,
+ rheader = /^h\d$/i,
+
+ rnative = /^[^{]+\{\s*\[native \w/,
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+ rsibling = /[+~]/,
+ rescape = /'|\\/g,
+
+ // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+ runescape = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig"),
+ funescape = function (_, escaped, escapedWhitespace) {
+ var high = "0x" + escaped - 0x10000;
+ // NaN means non-codepoint
+ // Support: Firefox<24
+ // Workaround erroneous numeric interpretation of +"0x"
+ return high !== high || escapedWhitespace ?
+ escaped :
+ high < 0 ?
+ // BMP codepoint
+ String.fromCharCode(high + 0x10000) :
+ // Supplemental Plane codepoint (surrogate pair)
+ String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00);
+ };
// Optimize for push.apply( _, NodeList )
-try {
- push.apply(
- (arr = slice.call( preferredDoc.childNodes )),
- preferredDoc.childNodes
- );
- // Support: Android<4.0
- // Detect silently failing push.apply
- arr[ preferredDoc.childNodes.length ].nodeType;
-} catch ( e ) {
- push = { apply: arr.length ?
-
- // Leverage slice if possible
- function( target, els ) {
- push_native.apply( target, slice.call(els) );
- } :
-
- // Support: IE<9
- // Otherwise append directly
- function( target, els ) {
- var j = target.length,
- i = 0;
- // Can't trust NodeList.length
- while ( (target[j++] = els[i++]) ) {}
- target.length = j - 1;
- }
- };
-}
-
-function Sizzle( selector, context, results, seed ) {
- var match, elem, m, nodeType,
- // QSA vars
- i, groups, old, nid, newContext, newSelector;
-
- if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
- setDocument( context );
- }
-
- context = context || document;
- results = results || [];
-
- if ( !selector || typeof selector !== "string" ) {
- return results;
- }
-
- if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
- return [];
- }
-
- if ( documentIsHTML && !seed ) {
-
- // Shortcuts
- if ( (match = rquickExpr.exec( selector )) ) {
- // Speed-up: Sizzle("#ID")
- if ( (m = match[1]) ) {
- if ( nodeType === 9 ) {
- elem = context.getElementById( m );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document (jQuery #6963)
- if ( elem && elem.parentNode ) {
- // Handle the case where IE, Opera, and Webkit return items
- // by name instead of ID
- if ( elem.id === m ) {
- results.push( elem );
- return results;
- }
- } else {
- return results;
- }
- } else {
- // Context is not a document
- if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
- contains( context, elem ) && elem.id === m ) {
- results.push( elem );
- return results;
- }
- }
-
- // Speed-up: Sizzle("TAG")
- } else if ( match[2] ) {
- push.apply( results, context.getElementsByTagName( selector ) );
- return results;
-
- // Speed-up: Sizzle(".CLASS")
- } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
- push.apply( results, context.getElementsByClassName( m ) );
- return results;
- }
- }
-
- // QSA path
- if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
- nid = old = expando;
- newContext = context;
- newSelector = nodeType === 9 && selector;
-
- // qSA works strangely on Element-rooted queries
- // We can work around this by specifying an extra ID on the root
- // and working up from there (Thanks to Andrew Dupont for the technique)
- // IE 8 doesn't work on object elements
- if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- groups = tokenize( selector );
-
- if ( (old = context.getAttribute("id")) ) {
- nid = old.replace( rescape, "\\$&" );
- } else {
- context.setAttribute( "id", nid );
- }
- nid = "[id='" + nid + "'] ";
-
- i = groups.length;
- while ( i-- ) {
- groups[i] = nid + toSelector( groups[i] );
- }
- newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
- newSelector = groups.join(",");
- }
-
- if ( newSelector ) {
- try {
- push.apply( results,
- newContext.querySelectorAll( newSelector )
- );
- return results;
- } catch(qsaError) {
- } finally {
- if ( !old ) {
- context.removeAttribute("id");
- }
- }
- }
- }
- }
-
- // All others
- return select( selector.replace( rtrim, "$1" ), context, results, seed );
-}
-
-/**
- * Create key-value caches of limited size
- * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
- * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
- * deleting the oldest entry
- */
-function createCache() {
- var keys = [];
-
- function cache( key, value ) {
- // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
- if ( keys.push( key + " " ) > Expr.cacheLength ) {
- // Only keep the most recent entries
- delete cache[ keys.shift() ];
- }
- return (cache[ key + " " ] = value);
- }
- return cache;
-}
-
-/**
- * Mark a function for special use by Sizzle
- * @param {Function} fn The function to mark
- */
-function markFunction( fn ) {
- fn[ expando ] = true;
- return fn;
-}
-
-/**
- * Support testing using an element
- * @param {Function} fn Passed the created div and expects a boolean result
- */
-function assert( fn ) {
- var div = document.createElement("div");
-
- try {
- return !!fn( div );
- } catch (e) {
- return false;
- } finally {
- // Remove from its parent by default
- if ( div.parentNode ) {
- div.parentNode.removeChild( div );
- }
- // release memory in IE
- div = null;
- }
-}
-
-/**
- * Adds the same handler for all of the specified attrs
- * @param {String} attrs Pipe-separated list of attributes
- * @param {Function} handler The method that will be applied
- */
-function addHandle( attrs, handler ) {
- var arr = attrs.split("|"),
- i = attrs.length;
-
- while ( i-- ) {
- Expr.attrHandle[ arr[i] ] = handler;
- }
-}
-
-/**
- * Checks document order of two siblings
- * @param {Element} a
- * @param {Element} b
- * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
- */
-function siblingCheck( a, b ) {
- var cur = b && a,
- diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
- ( ~b.sourceIndex || MAX_NEGATIVE ) -
- ( ~a.sourceIndex || MAX_NEGATIVE );
-
- // Use IE sourceIndex if available on both nodes
- if ( diff ) {
- return diff;
- }
-
- // Check if b follows a
- if ( cur ) {
- while ( (cur = cur.nextSibling) ) {
- if ( cur === b ) {
- return -1;
- }
- }
- }
-
- return a ? 1 : -1;
-}
-
-/**
- * Returns a function to use in pseudos for input types
- * @param {String} type
- */
-function createInputPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for buttons
- * @param {String} type
- */
-function createButtonPseudo( type ) {
- return function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return (name === "input" || name === "button") && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for positionals
- * @param {Function} fn
- */
-function createPositionalPseudo( fn ) {
- return markFunction(function( argument ) {
- argument = +argument;
- return markFunction(function( seed, matches ) {
- var j,
- matchIndexes = fn( [], seed.length, argument ),
- i = matchIndexes.length;
-
- // Match elements found at the specified indexes
- while ( i-- ) {
- if ( seed[ (j = matchIndexes[i]) ] ) {
- seed[j] = !(matches[j] = seed[j]);
- }
- }
- });
- });
-}
-
-/**
- * Checks a node for validity as a Sizzle context
- * @param {Element|Object=} context
- * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
- */
-function testContext( context ) {
- return context && typeof context.getElementsByTagName !== strundefined && context;
-}
+ try {
+ push.apply(
+ (arr = slice.call(preferredDoc.childNodes)),
+ preferredDoc.childNodes
+ );
+ // Support: Android<4.0
+ // Detect silently failing push.apply
+ arr[preferredDoc.childNodes.length].nodeType;
+ } catch (e) {
+ push = {
+ apply: arr.length ?
+
+ // Leverage slice if possible
+ function (target, els) {
+ push_native.apply(target, slice.call(els));
+ } :
+
+ // Support: IE<9
+ // Otherwise append directly
+ function (target, els) {
+ var j = target.length,
+ i = 0;
+ // Can't trust NodeList.length
+ while ((target[j++] = els[i++])) {
+ }
+ target.length = j - 1;
+ }
+ };
+ }
+
+ function Sizzle(selector, context, results, seed) {
+ var match, elem, m, nodeType,
+ // QSA vars
+ i, groups, old, nid, newContext, newSelector;
+
+ if (( context ? context.ownerDocument || context : preferredDoc ) !== document) {
+ setDocument(context);
+ }
+
+ context = context || document;
+ results = results || [];
+
+ if (!selector || typeof selector !== "string") {
+ return results;
+ }
+
+ if ((nodeType = context.nodeType) !== 1 && nodeType !== 9) {
+ return [];
+ }
+
+ if (documentIsHTML && !seed) {
+
+ // Shortcuts
+ if ((match = rquickExpr.exec(selector))) {
+ // Speed-up: Sizzle("#ID")
+ if ((m = match[1])) {
+ if (nodeType === 9) {
+ elem = context.getElementById(m);
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document (jQuery #6963)
+ if (elem && elem.parentNode) {
+ // Handle the case where IE, Opera, and Webkit return items
+ // by name instead of ID
+ if (elem.id === m) {
+ results.push(elem);
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ // Context is not a document
+ if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) &&
+ contains(context, elem) && elem.id === m) {
+ results.push(elem);
+ return results;
+ }
+ }
+
+ // Speed-up: Sizzle("TAG")
+ } else if (match[2]) {
+ push.apply(results, context.getElementsByTagName(selector));
+ return results;
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ((m = match[3]) && support.getElementsByClassName && context.getElementsByClassName) {
+ push.apply(results, context.getElementsByClassName(m));
+ return results;
+ }
+ }
+
+ // QSA path
+ if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
+ nid = old = expando;
+ newContext = context;
+ newSelector = nodeType === 9 && selector;
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ if (nodeType === 1 && context.nodeName.toLowerCase() !== "object") {
+ groups = tokenize(selector);
+
+ if ((old = context.getAttribute("id"))) {
+ nid = old.replace(rescape, "\\$&");
+ } else {
+ context.setAttribute("id", nid);
+ }
+ nid = "[id='" + nid + "'] ";
+
+ i = groups.length;
+ while (i--) {
+ groups[i] = nid + toSelector(groups[i]);
+ }
+ newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
+ newSelector = groups.join(",");
+ }
+
+ if (newSelector) {
+ try {
+ push.apply(results,
+ newContext.querySelectorAll(newSelector)
+ );
+ return results;
+ } catch (qsaError) {
+ } finally {
+ if (!old) {
+ context.removeAttribute("id");
+ }
+ }
+ }
+ }
+ }
+
+ // All others
+ return select(selector.replace(rtrim, "$1"), context, results, seed);
+ }
+
+ /**
+ * Create key-value caches of limited size
+ * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
+ * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ * deleting the oldest entry
+ */
+ function createCache() {
+ var keys = [];
+
+ function cache(key, value) {
+ // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+ if (keys.push(key + " ") > Expr.cacheLength) {
+ // Only keep the most recent entries
+ delete cache[keys.shift()];
+ }
+ return (cache[key + " "] = value);
+ }
+
+ return cache;
+ }
+
+ /**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+ function markFunction(fn) {
+ fn[expando] = true;
+ return fn;
+ }
+
+ /**
+ * Support testing using an element
+ * @param {Function} fn Passed the created div and expects a boolean result
+ */
+ function assert(fn) {
+ var div = document.createElement("div");
+
+ try {
+ return !!fn(div);
+ } catch (e) {
+ return false;
+ } finally {
+ // Remove from its parent by default
+ if (div.parentNode) {
+ div.parentNode.removeChild(div);
+ }
+ // release memory in IE
+ div = null;
+ }
+ }
+
+ /**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+ function addHandle(attrs, handler) {
+ var arr = attrs.split("|"),
+ i = attrs.length;
+
+ while (i--) {
+ Expr.attrHandle[arr[i]] = handler;
+ }
+ }
+
+ /**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+ function siblingCheck(a, b) {
+ var cur = b && a,
+ diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+ ( ~b.sourceIndex || MAX_NEGATIVE ) -
+ ( ~a.sourceIndex || MAX_NEGATIVE );
+
+ // Use IE sourceIndex if available on both nodes
+ if (diff) {
+ return diff;
+ }
+
+ // Check if b follows a
+ if (cur) {
+ while ((cur = cur.nextSibling)) {
+ if (cur === b) {
+ return -1;
+ }
+ }
+ }
+
+ return a ? 1 : -1;
+ }
+
+ /**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+ function createInputPseudo(type) {
+ return function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+ }
+
+ /**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+ function createButtonPseudo(type) {
+ return function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+ }
+
+ /**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+ function createPositionalPseudo(fn) {
+ return markFunction(function (argument) {
+ argument = +argument;
+ return markFunction(function (seed, matches) {
+ var j,
+ matchIndexes = fn([], seed.length, argument),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while (i--) {
+ if (seed[(j = matchIndexes[i])]) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+ }
+
+ /**
+ * Checks a node for validity as a Sizzle context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+ function testContext(context) {
+ return context && typeof context.getElementsByTagName !== strundefined && context;
+ }
// Expose support vars for convenience
-support = Sizzle.support = {};
-
-/**
- * Detects XML nodes
- * @param {Element|Object} elem An element or a document
- * @returns {Boolean} True iff elem is a non-HTML XML node
- */
-isXML = Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = elem && (elem.ownerDocument || elem).documentElement;
- return documentElement ? documentElement.nodeName !== "HTML" : false;
-};
-
-/**
- * Sets document-related variables once based on the current document
- * @param {Element|Object} [doc] An element or document object to use to set the document
- * @returns {Object} Returns the current document
- */
-setDocument = Sizzle.setDocument = function( node ) {
- var hasCompare,
- doc = node ? node.ownerDocument || node : preferredDoc,
- parent = doc.defaultView;
-
- // If no document and documentElement is available, return
- if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
- return document;
- }
-
- // Set our document
- document = doc;
- docElem = doc.documentElement;
-
- // Support tests
- documentIsHTML = !isXML( doc );
-
- // Support: IE>8
- // If iframe document is assigned to "document" variable and if iframe has been reloaded,
- // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
- // IE6-8 do not support the defaultView property so parent will be undefined
- if ( parent && parent !== parent.top ) {
- // IE11 does not have attachEvent, so all must suffer
- if ( parent.addEventListener ) {
- parent.addEventListener( "unload", function() {
- setDocument();
- }, false );
- } else if ( parent.attachEvent ) {
- parent.attachEvent( "onunload", function() {
- setDocument();
- });
- }
- }
-
- /* Attributes
- ---------------------------------------------------------------------- */
-
- // Support: IE<8
- // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
- support.attributes = assert(function( div ) {
- div.className = "i";
- return !div.getAttribute("className");
- });
-
- /* getElement(s)By*
- ---------------------------------------------------------------------- */
-
- // Check if getElementsByTagName("*") returns only elements
- support.getElementsByTagName = assert(function( div ) {
- div.appendChild( doc.createComment("") );
- return !div.getElementsByTagName("*").length;
- });
-
- // Check if getElementsByClassName can be trusted
- support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
- div.innerHTML = "
";
-
- // Support: Safari<4
- // Catch class over-caching
- div.firstChild.className = "i";
- // Support: Opera<10
- // Catch gEBCN failure to find non-leading classes
- return div.getElementsByClassName("i").length === 2;
- });
-
- // Support: IE<10
- // Check if getElementById returns elements by name
- // The broken getElementById methods don't pick up programatically-set names,
- // so use a roundabout getElementsByName test
- support.getById = assert(function( div ) {
- docElem.appendChild( div ).id = expando;
- return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
- });
-
- // ID find and filter
- if ( support.getById ) {
- Expr.find["ID"] = function( id, context ) {
- if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
- var m = context.getElementById( id );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- return m && m.parentNode ? [ m ] : [];
- }
- };
- Expr.filter["ID"] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- return elem.getAttribute("id") === attrId;
- };
- };
- } else {
- // Support: IE6/7
- // getElementById is not reliable as a find shortcut
- delete Expr.find["ID"];
-
- Expr.filter["ID"] = function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
- return node && node.value === attrId;
- };
- };
- }
-
- // Tag
- Expr.find["TAG"] = support.getElementsByTagName ?
- function( tag, context ) {
- if ( typeof context.getElementsByTagName !== strundefined ) {
- return context.getElementsByTagName( tag );
- }
- } :
- function( tag, context ) {
- var elem,
- tmp = [],
- i = 0,
- results = context.getElementsByTagName( tag );
-
- // Filter out possible comments
- if ( tag === "*" ) {
- while ( (elem = results[i++]) ) {
- if ( elem.nodeType === 1 ) {
- tmp.push( elem );
- }
- }
-
- return tmp;
- }
- return results;
- };
-
- // Class
- Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
- if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
- return context.getElementsByClassName( className );
- }
- };
-
- /* QSA/matchesSelector
- ---------------------------------------------------------------------- */
-
- // QSA and matchesSelector support
-
- // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
- rbuggyMatches = [];
-
- // qSa(:focus) reports false when true (Chrome 21)
- // We allow this because of a bug in IE8/9 that throws an error
- // whenever `document.activeElement` is accessed on an iframe
- // So, we allow :focus to pass through QSA all the time to avoid the IE error
- // See http://bugs.jquery.com/ticket/13378
- rbuggyQSA = [];
-
- if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
- // Build QSA regex
- // Regex strategy adopted from Diego Perini
- assert(function( div ) {
- // Select is set to empty string on purpose
- // This is to test IE's treatment of not explicitly
- // setting a boolean content attribute,
- // since its presence should be enough
- // http://bugs.jquery.com/ticket/12359
- div.innerHTML = " ";
-
- // Support: IE8, Opera 11-12.16
- // Nothing should be selected when empty strings follow ^= or $= or *=
- // The test attribute must be unknown in Opera but "safe" for WinRT
- // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
- if ( div.querySelectorAll("[msallowclip^='']").length ) {
- rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
- }
-
- // Support: IE8
- // Boolean attributes and "value" are not treated correctly
- if ( !div.querySelectorAll("[selected]").length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
- }
-
- // Webkit/Opera - :checked should return selected option elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- // IE8 throws error here and will not see later tests
- if ( !div.querySelectorAll(":checked").length ) {
- rbuggyQSA.push(":checked");
- }
- });
-
- assert(function( div ) {
- // Support: Windows 8 Native Apps
- // The type and name attributes are restricted during .innerHTML assignment
- var input = doc.createElement("input");
- input.setAttribute( "type", "hidden" );
- div.appendChild( input ).setAttribute( "name", "D" );
-
- // Support: IE8
- // Enforce case-sensitivity of name attribute
- if ( div.querySelectorAll("[name=d]").length ) {
- rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
- }
-
- // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
- // IE8 throws error here and will not see later tests
- if ( !div.querySelectorAll(":enabled").length ) {
- rbuggyQSA.push( ":enabled", ":disabled" );
- }
-
- // Opera 10-11 does not throw on post-comma invalid pseudos
- div.querySelectorAll("*,:x");
- rbuggyQSA.push(",.*:");
- });
- }
-
- if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
- docElem.webkitMatchesSelector ||
- docElem.mozMatchesSelector ||
- docElem.oMatchesSelector ||
- docElem.msMatchesSelector) )) ) {
-
- assert(function( div ) {
- // Check to see if it's possible to do matchesSelector
- // on a disconnected node (IE 9)
- support.disconnectedMatch = matches.call( div, "div" );
-
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( div, "[s!='']:x" );
- rbuggyMatches.push( "!=", pseudos );
- });
- }
-
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
- rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
-
- /* Contains
- ---------------------------------------------------------------------- */
- hasCompare = rnative.test( docElem.compareDocumentPosition );
-
- // Element contains another
- // Purposefully does not implement inclusive descendent
- // As in, an element does not contain itself
- contains = hasCompare || rnative.test( docElem.contains ) ?
- function( a, b ) {
- var adown = a.nodeType === 9 ? a.documentElement : a,
- bup = b && b.parentNode;
- return a === bup || !!( bup && bup.nodeType === 1 && (
- adown.contains ?
- adown.contains( bup ) :
- a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
- ));
- } :
- function( a, b ) {
- if ( b ) {
- while ( (b = b.parentNode) ) {
- if ( b === a ) {
- return true;
- }
- }
- }
- return false;
- };
-
- /* Sorting
- ---------------------------------------------------------------------- */
-
- // Document order sorting
- sortOrder = hasCompare ?
- function( a, b ) {
-
- // Flag for duplicate removal
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- // Sort on method existence if only one input has compareDocumentPosition
- var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
- if ( compare ) {
- return compare;
- }
-
- // Calculate position if both inputs belong to the same document
- compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
- a.compareDocumentPosition( b ) :
-
- // Otherwise we know they are disconnected
- 1;
-
- // Disconnected nodes
- if ( compare & 1 ||
- (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
-
- // Choose the first element that is related to our preferred document
- if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
- return -1;
- }
- if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
- return 1;
- }
-
- // Maintain original order
- return sortInput ?
- ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
- 0;
- }
-
- return compare & 4 ? -1 : 1;
- } :
- function( a, b ) {
- // Exit early if the nodes are identical
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- var cur,
- i = 0,
- aup = a.parentNode,
- bup = b.parentNode,
- ap = [ a ],
- bp = [ b ];
-
- // Parentless nodes are either documents or disconnected
- if ( !aup || !bup ) {
- return a === doc ? -1 :
- b === doc ? 1 :
- aup ? -1 :
- bup ? 1 :
- sortInput ?
- ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
- 0;
-
- // If the nodes are siblings, we can do a quick check
- } else if ( aup === bup ) {
- return siblingCheck( a, b );
- }
-
- // Otherwise we need full lists of their ancestors for comparison
- cur = a;
- while ( (cur = cur.parentNode) ) {
- ap.unshift( cur );
- }
- cur = b;
- while ( (cur = cur.parentNode) ) {
- bp.unshift( cur );
- }
-
- // Walk down the tree looking for a discrepancy
- while ( ap[i] === bp[i] ) {
- i++;
- }
-
- return i ?
- // Do a sibling check if the nodes have a common ancestor
- siblingCheck( ap[i], bp[i] ) :
-
- // Otherwise nodes in our document sort first
- ap[i] === preferredDoc ? -1 :
- bp[i] === preferredDoc ? 1 :
- 0;
- };
-
- return doc;
-};
-
-Sizzle.matches = function( expr, elements ) {
- return Sizzle( expr, null, null, elements );
-};
-
-Sizzle.matchesSelector = function( elem, expr ) {
- // Set document vars if needed
- if ( ( elem.ownerDocument || elem ) !== document ) {
- setDocument( elem );
- }
-
- // Make sure that attribute selectors are quoted
- expr = expr.replace( rattributeQuotes, "='$1']" );
-
- if ( support.matchesSelector && documentIsHTML &&
- ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
- ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
-
- try {
- var ret = matches.call( elem, expr );
-
- // IE 9's matchesSelector returns false on disconnected nodes
- if ( ret || support.disconnectedMatch ||
- // As well, disconnected nodes are said to be in a document
- // fragment in IE 9
- elem.document && elem.document.nodeType !== 11 ) {
- return ret;
- }
- } catch(e) {}
- }
-
- return Sizzle( expr, document, null, [ elem ] ).length > 0;
-};
-
-Sizzle.contains = function( context, elem ) {
- // Set document vars if needed
- if ( ( context.ownerDocument || context ) !== document ) {
- setDocument( context );
- }
- return contains( context, elem );
-};
-
-Sizzle.attr = function( elem, name ) {
- // Set document vars if needed
- if ( ( elem.ownerDocument || elem ) !== document ) {
- setDocument( elem );
- }
-
- var fn = Expr.attrHandle[ name.toLowerCase() ],
- // Don't get fooled by Object.prototype properties (jQuery #13807)
- val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
- fn( elem, name, !documentIsHTML ) :
- undefined;
-
- return val !== undefined ?
- val :
- support.attributes || !documentIsHTML ?
- elem.getAttribute( name ) :
- (val = elem.getAttributeNode(name)) && val.specified ?
- val.value :
- null;
-};
-
-Sizzle.error = function( msg ) {
- throw new Error( "Syntax error, unrecognized expression: " + msg );
-};
-
-/**
- * Document sorting and removing duplicates
- * @param {ArrayLike} results
- */
-Sizzle.uniqueSort = function( results ) {
- var elem,
- duplicates = [],
- j = 0,
- i = 0;
-
- // Unless we *know* we can detect duplicates, assume their presence
- hasDuplicate = !support.detectDuplicates;
- sortInput = !support.sortStable && results.slice( 0 );
- results.sort( sortOrder );
-
- if ( hasDuplicate ) {
- while ( (elem = results[i++]) ) {
- if ( elem === results[ i ] ) {
- j = duplicates.push( i );
- }
- }
- while ( j-- ) {
- results.splice( duplicates[ j ], 1 );
- }
- }
-
- // Clear input after sorting to release objects
- // See https://github.com/jquery/sizzle/pull/225
- sortInput = null;
-
- return results;
-};
-
-/**
- * Utility function for retrieving the text value of an array of DOM nodes
- * @param {Array|Element} elem
- */
-getText = Sizzle.getText = function( elem ) {
- var node,
- ret = "",
- i = 0,
- nodeType = elem.nodeType;
-
- if ( !nodeType ) {
- // If no nodeType, this is expected to be an array
- while ( (node = elem[i++]) ) {
- // Do not traverse comment nodes
- ret += getText( node );
- }
- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
- // Use textContent for elements
- // innerText usage removed for consistency of new lines (jQuery #11153)
- if ( typeof elem.textContent === "string" ) {
- return elem.textContent;
- } else {
- // Traverse its children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- ret += getText( elem );
- }
- }
- } else if ( nodeType === 3 || nodeType === 4 ) {
- return elem.nodeValue;
- }
- // Do not include comment or processing instruction nodes
-
- return ret;
-};
-
-Expr = Sizzle.selectors = {
-
- // Can be adjusted by the user
- cacheLength: 50,
-
- createPseudo: markFunction,
-
- match: matchExpr,
-
- attrHandle: {},
-
- find: {},
-
- relative: {
- ">": { dir: "parentNode", first: true },
- " ": { dir: "parentNode" },
- "+": { dir: "previousSibling", first: true },
- "~": { dir: "previousSibling" }
- },
-
- preFilter: {
- "ATTR": function( match ) {
- match[1] = match[1].replace( runescape, funescape );
-
- // Move the given value to match[3] whether quoted or unquoted
- match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
-
- if ( match[2] === "~=" ) {
- match[3] = " " + match[3] + " ";
- }
-
- return match.slice( 0, 4 );
- },
-
- "CHILD": function( match ) {
- /* matches from matchExpr["CHILD"]
- 1 type (only|nth|...)
- 2 what (child|of-type)
- 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
- 4 xn-component of xn+y argument ([+-]?\d*n|)
- 5 sign of xn-component
- 6 x of xn-component
- 7 sign of y-component
- 8 y of y-component
- */
- match[1] = match[1].toLowerCase();
-
- if ( match[1].slice( 0, 3 ) === "nth" ) {
- // nth-* requires argument
- if ( !match[3] ) {
- Sizzle.error( match[0] );
- }
-
- // numeric x and y parameters for Expr.filter.CHILD
- // remember that false/true cast respectively to 0/1
- match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
- match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
-
- // other types prohibit arguments
- } else if ( match[3] ) {
- Sizzle.error( match[0] );
- }
-
- return match;
- },
-
- "PSEUDO": function( match ) {
- var excess,
- unquoted = !match[6] && match[2];
-
- if ( matchExpr["CHILD"].test( match[0] ) ) {
- return null;
- }
-
- // Accept quoted arguments as-is
- if ( match[3] ) {
- match[2] = match[4] || match[5] || "";
-
- // Strip excess characters from unquoted arguments
- } else if ( unquoted && rpseudo.test( unquoted ) &&
- // Get excess from tokenize (recursively)
- (excess = tokenize( unquoted, true )) &&
- // advance to the next closing parenthesis
- (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
-
- // excess is a negative index
- match[0] = match[0].slice( 0, excess );
- match[2] = unquoted.slice( 0, excess );
- }
-
- // Return only captures needed by the pseudo filter method (type and argument)
- return match.slice( 0, 3 );
- }
- },
-
- filter: {
-
- "TAG": function( nodeNameSelector ) {
- var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
- return nodeNameSelector === "*" ?
- function() { return true; } :
- function( elem ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
- };
- },
-
- "CLASS": function( className ) {
- var pattern = classCache[ className + " " ];
-
- return pattern ||
- (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
- classCache( className, function( elem ) {
- return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
- });
- },
-
- "ATTR": function( name, operator, check ) {
- return function( elem ) {
- var result = Sizzle.attr( elem, name );
-
- if ( result == null ) {
- return operator === "!=";
- }
- if ( !operator ) {
- return true;
- }
-
- result += "";
-
- return operator === "=" ? result === check :
- operator === "!=" ? result !== check :
- operator === "^=" ? check && result.indexOf( check ) === 0 :
- operator === "*=" ? check && result.indexOf( check ) > -1 :
- operator === "$=" ? check && result.slice( -check.length ) === check :
- operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
- operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
- false;
- };
- },
-
- "CHILD": function( type, what, argument, first, last ) {
- var simple = type.slice( 0, 3 ) !== "nth",
- forward = type.slice( -4 ) !== "last",
- ofType = what === "of-type";
-
- return first === 1 && last === 0 ?
-
- // Shortcut for :nth-*(n)
- function( elem ) {
- return !!elem.parentNode;
- } :
-
- function( elem, context, xml ) {
- var cache, outerCache, node, diff, nodeIndex, start,
- dir = simple !== forward ? "nextSibling" : "previousSibling",
- parent = elem.parentNode,
- name = ofType && elem.nodeName.toLowerCase(),
- useCache = !xml && !ofType;
-
- if ( parent ) {
-
- // :(first|last|only)-(child|of-type)
- if ( simple ) {
- while ( dir ) {
- node = elem;
- while ( (node = node[ dir ]) ) {
- if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
- return false;
- }
- }
- // Reverse direction for :only-* (if we haven't yet done so)
- start = dir = type === "only" && !start && "nextSibling";
- }
- return true;
- }
-
- start = [ forward ? parent.firstChild : parent.lastChild ];
-
- // non-xml :nth-child(...) stores cache data on `parent`
- if ( forward && useCache ) {
- // Seek `elem` from a previously-cached index
- outerCache = parent[ expando ] || (parent[ expando ] = {});
- cache = outerCache[ type ] || [];
- nodeIndex = cache[0] === dirruns && cache[1];
- diff = cache[0] === dirruns && cache[2];
- node = nodeIndex && parent.childNodes[ nodeIndex ];
-
- while ( (node = ++nodeIndex && node && node[ dir ] ||
-
- // Fallback to seeking `elem` from the start
- (diff = nodeIndex = 0) || start.pop()) ) {
-
- // When found, cache indexes on `parent` and break
- if ( node.nodeType === 1 && ++diff && node === elem ) {
- outerCache[ type ] = [ dirruns, nodeIndex, diff ];
- break;
- }
- }
-
- // Use previously-cached element index if available
- } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
- diff = cache[1];
-
- // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
- } else {
- // Use the same loop as above to seek `elem` from the start
- while ( (node = ++nodeIndex && node && node[ dir ] ||
- (diff = nodeIndex = 0) || start.pop()) ) {
-
- if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
- // Cache the index of each encountered element
- if ( useCache ) {
- (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
- }
-
- if ( node === elem ) {
- break;
- }
- }
- }
- }
-
- // Incorporate the offset, then check against cycle size
- diff -= last;
- return diff === first || ( diff % first === 0 && diff / first >= 0 );
- }
- };
- },
-
- "PSEUDO": function( pseudo, argument ) {
- // pseudo-class names are case-insensitive
- // http://www.w3.org/TR/selectors/#pseudo-classes
- // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
- // Remember that setFilters inherits from pseudos
- var args,
- fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
- Sizzle.error( "unsupported pseudo: " + pseudo );
-
- // The user may use createPseudo to indicate that
- // arguments are needed to create the filter function
- // just as Sizzle does
- if ( fn[ expando ] ) {
- return fn( argument );
- }
-
- // But maintain support for old signatures
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
- markFunction(function( seed, matches ) {
- var idx,
- matched = fn( seed, argument ),
- i = matched.length;
- while ( i-- ) {
- idx = indexOf.call( seed, matched[i] );
- seed[ idx ] = !( matches[ idx ] = matched[i] );
- }
- }) :
- function( elem ) {
- return fn( elem, 0, args );
- };
- }
-
- return fn;
- }
- },
-
- pseudos: {
- // Potentially complex pseudos
- "not": markFunction(function( selector ) {
- // Trim the selector passed to compile
- // to avoid treating leading and trailing
- // spaces as combinators
- var input = [],
- results = [],
- matcher = compile( selector.replace( rtrim, "$1" ) );
-
- return matcher[ expando ] ?
- markFunction(function( seed, matches, context, xml ) {
- var elem,
- unmatched = matcher( seed, null, xml, [] ),
- i = seed.length;
-
- // Match elements unmatched by `matcher`
- while ( i-- ) {
- if ( (elem = unmatched[i]) ) {
- seed[i] = !(matches[i] = elem);
- }
- }
- }) :
- function( elem, context, xml ) {
- input[0] = elem;
- matcher( input, null, xml, results );
- return !results.pop();
- };
- }),
-
- "has": markFunction(function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- }),
-
- "contains": markFunction(function( text ) {
- return function( elem ) {
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
- };
- }),
-
- // "Whether an element is represented by a :lang() selector
- // is based solely on the element's language value
- // being equal to the identifier C,
- // or beginning with the identifier C immediately followed by "-".
- // The matching of C against the element's language value is performed case-insensitively.
- // The identifier C does not have to be a valid language name."
- // http://www.w3.org/TR/selectors/#lang-pseudo
- "lang": markFunction( function( lang ) {
- // lang value must be a valid identifier
- if ( !ridentifier.test(lang || "") ) {
- Sizzle.error( "unsupported lang: " + lang );
- }
- lang = lang.replace( runescape, funescape ).toLowerCase();
- return function( elem ) {
- var elemLang;
- do {
- if ( (elemLang = documentIsHTML ?
- elem.lang :
- elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
-
- elemLang = elemLang.toLowerCase();
- return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
- }
- } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
- return false;
- };
- }),
-
- // Miscellaneous
- "target": function( elem ) {
- var hash = window.location && window.location.hash;
- return hash && hash.slice( 1 ) === elem.id;
- },
-
- "root": function( elem ) {
- return elem === docElem;
- },
-
- "focus": function( elem ) {
- return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
- },
-
- // Boolean properties
- "enabled": function( elem ) {
- return elem.disabled === false;
- },
-
- "disabled": function( elem ) {
- return elem.disabled === true;
- },
-
- "checked": function( elem ) {
- // In CSS3, :checked should return both checked and selected elements
- // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- var nodeName = elem.nodeName.toLowerCase();
- return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
- },
-
- "selected": function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- if ( elem.parentNode ) {
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- // Contents
- "empty": function( elem ) {
- // http://www.w3.org/TR/selectors/#empty-pseudo
- // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
- // but not by others (comment: 8; processing instruction: 7; etc.)
- // nodeType < 6 works because attributes (2) do not appear as children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- if ( elem.nodeType < 6 ) {
- return false;
- }
- }
- return true;
- },
-
- "parent": function( elem ) {
- return !Expr.pseudos["empty"]( elem );
- },
-
- // Element/input types
- "header": function( elem ) {
- return rheader.test( elem.nodeName );
- },
-
- "input": function( elem ) {
- return rinputs.test( elem.nodeName );
- },
-
- "button": function( elem ) {
- var name = elem.nodeName.toLowerCase();
- return name === "input" && elem.type === "button" || name === "button";
- },
-
- "text": function( elem ) {
- var attr;
- return elem.nodeName.toLowerCase() === "input" &&
- elem.type === "text" &&
-
- // Support: IE<8
- // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
- ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
- },
-
- // Position-in-collection
- "first": createPositionalPseudo(function() {
- return [ 0 ];
- }),
-
- "last": createPositionalPseudo(function( matchIndexes, length ) {
- return [ length - 1 ];
- }),
-
- "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
- return [ argument < 0 ? argument + length : argument ];
- }),
-
- "even": createPositionalPseudo(function( matchIndexes, length ) {
- var i = 0;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "odd": createPositionalPseudo(function( matchIndexes, length ) {
- var i = 1;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; --i >= 0; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- }),
-
- "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; ++i < length; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- })
- }
-};
-
-Expr.pseudos["nth"] = Expr.pseudos["eq"];
+ support = Sizzle.support = {};
+
+ /**
+ * Detects XML nodes
+ * @param {Element|Object} elem An element or a document
+ * @returns {Boolean} True iff elem is a non-HTML XML node
+ */
+ isXML = Sizzle.isXML = function (elem) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+ };
+
+ /**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+ setDocument = Sizzle.setDocument = function (node) {
+ var hasCompare,
+ doc = node ? node.ownerDocument || node : preferredDoc,
+ parent = doc.defaultView;
+
+ // If no document and documentElement is available, return
+ if (doc === document || doc.nodeType !== 9 || !doc.documentElement) {
+ return document;
+ }
+
+ // Set our document
+ document = doc;
+ docElem = doc.documentElement;
+
+ // Support tests
+ documentIsHTML = !isXML(doc);
+
+ // Support: IE>8
+ // If iframe document is assigned to "document" variable and if iframe has been reloaded,
+ // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
+ // IE6-8 do not support the defaultView property so parent will be undefined
+ if (parent && parent !== parent.top) {
+ // IE11 does not have attachEvent, so all must suffer
+ if (parent.addEventListener) {
+ parent.addEventListener("unload", function () {
+ setDocument();
+ }, false);
+ } else if (parent.attachEvent) {
+ parent.attachEvent("onunload", function () {
+ setDocument();
+ });
+ }
+ }
+
+ /* Attributes
+ ---------------------------------------------------------------------- */
+
+ // Support: IE<8
+ // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
+ support.attributes = assert(function (div) {
+ div.className = "i";
+ return !div.getAttribute("className");
+ });
+
+ /* getElement(s)By*
+ ---------------------------------------------------------------------- */
+
+ // Check if getElementsByTagName("*") returns only elements
+ support.getElementsByTagName = assert(function (div) {
+ div.appendChild(doc.createComment(""));
+ return !div.getElementsByTagName("*").length;
+ });
+
+ // Check if getElementsByClassName can be trusted
+ support.getElementsByClassName = rnative.test(doc.getElementsByClassName) && assert(function (div) {
+ div.innerHTML = "
";
+
+ // Support: Safari<4
+ // Catch class over-caching
+ div.firstChild.className = "i";
+ // Support: Opera<10
+ // Catch gEBCN failure to find non-leading classes
+ return div.getElementsByClassName("i").length === 2;
+ });
+
+ // Support: IE<10
+ // Check if getElementById returns elements by name
+ // The broken getElementById methods don't pick up programatically-set names,
+ // so use a roundabout getElementsByName test
+ support.getById = assert(function (div) {
+ docElem.appendChild(div).id = expando;
+ return !doc.getElementsByName || !doc.getElementsByName(expando).length;
+ });
+
+ // ID find and filter
+ if (support.getById) {
+ Expr.find["ID"] = function (id, context) {
+ if (typeof context.getElementById !== strundefined && documentIsHTML) {
+ var m = context.getElementById(id);
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ };
+ Expr.filter["ID"] = function (id) {
+ var attrId = id.replace(runescape, funescape);
+ return function (elem) {
+ return elem.getAttribute("id") === attrId;
+ };
+ };
+ } else {
+ // Support: IE6/7
+ // getElementById is not reliable as a find shortcut
+ delete Expr.find["ID"];
+
+ Expr.filter["ID"] = function (id) {
+ var attrId = id.replace(runescape, funescape);
+ return function (elem) {
+ var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+ return node && node.value === attrId;
+ };
+ };
+ }
+
+ // Tag
+ Expr.find["TAG"] = support.getElementsByTagName ?
+ function (tag, context) {
+ if (typeof context.getElementsByTagName !== strundefined) {
+ return context.getElementsByTagName(tag);
+ }
+ } :
+ function (tag, context) {
+ var elem,
+ tmp = [],
+ i = 0,
+ results = context.getElementsByTagName(tag);
+
+ // Filter out possible comments
+ if (tag === "*") {
+ while ((elem = results[i++])) {
+ if (elem.nodeType === 1) {
+ tmp.push(elem);
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ };
+
+ // Class
+ Expr.find["CLASS"] = support.getElementsByClassName && function (className, context) {
+ if (typeof context.getElementsByClassName !== strundefined && documentIsHTML) {
+ return context.getElementsByClassName(className);
+ }
+ };
+
+ /* QSA/matchesSelector
+ ---------------------------------------------------------------------- */
+
+ // QSA and matchesSelector support
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ rbuggyMatches = [];
+
+ // qSa(:focus) reports false when true (Chrome 21)
+ // We allow this because of a bug in IE8/9 that throws an error
+ // whenever `document.activeElement` is accessed on an iframe
+ // So, we allow :focus to pass through QSA all the time to avoid the IE error
+ // See http://bugs.jquery.com/ticket/13378
+ rbuggyQSA = [];
+
+ if ((support.qsa = rnative.test(doc.querySelectorAll))) {
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function (div) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explicitly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ div.innerHTML = " ";
+
+ // Support: IE8, Opera 11-12.16
+ // Nothing should be selected when empty strings follow ^= or $= or *=
+ // The test attribute must be unknown in Opera but "safe" for WinRT
+ // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
+ if (div.querySelectorAll("[msallowclip^='']").length) {
+ rbuggyQSA.push("[*^$]=" + whitespace + "*(?:''|\"\")");
+ }
+
+ // Support: IE8
+ // Boolean attributes and "value" are not treated correctly
+ if (!div.querySelectorAll("[selected]").length) {
+ rbuggyQSA.push("\\[" + whitespace + "*(?:value|" + booleans + ")");
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here and will not see later tests
+ if (!div.querySelectorAll(":checked").length) {
+ rbuggyQSA.push(":checked");
+ }
+ });
+
+ assert(function (div) {
+ // Support: Windows 8 Native Apps
+ // The type and name attributes are restricted during .innerHTML assignment
+ var input = doc.createElement("input");
+ input.setAttribute("type", "hidden");
+ div.appendChild(input).setAttribute("name", "D");
+
+ // Support: IE8
+ // Enforce case-sensitivity of name attribute
+ if (div.querySelectorAll("[name=d]").length) {
+ rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=");
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here and will not see later tests
+ if (!div.querySelectorAll(":enabled").length) {
+ rbuggyQSA.push(":enabled", ":disabled");
+ }
+
+ // Opera 10-11 does not throw on post-comma invalid pseudos
+ div.querySelectorAll("*,:x");
+ rbuggyQSA.push(",.*:");
+ });
+ }
+
+ if ((support.matchesSelector = rnative.test((matches = docElem.matches ||
+ docElem.webkitMatchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector)))) {
+
+ assert(function (div) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ support.disconnectedMatch = matches.call(div, "div");
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call(div, "[s!='']:x");
+ rbuggyMatches.push("!=", pseudos);
+ });
+ }
+
+ rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
+ rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join("|"));
+
+ /* Contains
+ ---------------------------------------------------------------------- */
+ hasCompare = rnative.test(docElem.compareDocumentPosition);
+
+ // Element contains another
+ // Purposefully does not implement inclusive descendent
+ // As in, an element does not contain itself
+ contains = hasCompare || rnative.test(docElem.contains) ?
+ function (a, b) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && (
+ adown.contains ?
+ adown.contains(bup) :
+ a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16
+ ));
+ } :
+ function (a, b) {
+ if (b) {
+ while ((b = b.parentNode)) {
+ if (b === a) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ /* Sorting
+ ---------------------------------------------------------------------- */
+
+ // Document order sorting
+ sortOrder = hasCompare ?
+ function (a, b) {
+
+ // Flag for duplicate removal
+ if (a === b) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ // Sort on method existence if only one input has compareDocumentPosition
+ var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ if (compare) {
+ return compare;
+ }
+
+ // Calculate position if both inputs belong to the same document
+ compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
+ a.compareDocumentPosition(b) :
+
+ // Otherwise we know they are disconnected
+ 1;
+
+ // Disconnected nodes
+ if (compare & 1 ||
+ (!support.sortDetached && b.compareDocumentPosition(a) === compare)) {
+
+ // Choose the first element that is related to our preferred document
+ if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) {
+ return -1;
+ }
+ if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) {
+ return 1;
+ }
+
+ // Maintain original order
+ return sortInput ?
+ ( indexOf.call(sortInput, a) - indexOf.call(sortInput, b) ) :
+ 0;
+ }
+
+ return compare & 4 ? -1 : 1;
+ } :
+ function (a, b) {
+ // Exit early if the nodes are identical
+ if (a === b) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ var cur,
+ i = 0,
+ aup = a.parentNode,
+ bup = b.parentNode,
+ ap = [a],
+ bp = [b];
+
+ // Parentless nodes are either documents or disconnected
+ if (!aup || !bup) {
+ return a === doc ? -1 :
+ b === doc ? 1 :
+ aup ? -1 :
+ bup ? 1 :
+ sortInput ?
+ ( indexOf.call(sortInput, a) - indexOf.call(sortInput, b) ) :
+ 0;
+
+ // If the nodes are siblings, we can do a quick check
+ } else if (aup === bup) {
+ return siblingCheck(a, b);
+ }
+
+ // Otherwise we need full lists of their ancestors for comparison
+ cur = a;
+ while ((cur = cur.parentNode)) {
+ ap.unshift(cur);
+ }
+ cur = b;
+ while ((cur = cur.parentNode)) {
+ bp.unshift(cur);
+ }
+
+ // Walk down the tree looking for a discrepancy
+ while (ap[i] === bp[i]) {
+ i++;
+ }
+
+ return i ?
+ // Do a sibling check if the nodes have a common ancestor
+ siblingCheck(ap[i], bp[i]) :
+
+ // Otherwise nodes in our document sort first
+ ap[i] === preferredDoc ? -1 :
+ bp[i] === preferredDoc ? 1 :
+ 0;
+ };
+
+ return doc;
+ };
+
+ Sizzle.matches = function (expr, elements) {
+ return Sizzle(expr, null, null, elements);
+ };
+
+ Sizzle.matchesSelector = function (elem, expr) {
+ // Set document vars if needed
+ if (( elem.ownerDocument || elem ) !== document) {
+ setDocument(elem);
+ }
+
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace(rattributeQuotes, "='$1']");
+
+ if (support.matchesSelector && documentIsHTML &&
+ ( !rbuggyMatches || !rbuggyMatches.test(expr) ) &&
+ ( !rbuggyQSA || !rbuggyQSA.test(expr) )) {
+
+ try {
+ var ret = matches.call(elem, expr);
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if (ret || support.disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11) {
+ return ret;
+ }
+ } catch (e) {
+ }
+ }
+
+ return Sizzle(expr, document, null, [elem]).length > 0;
+ };
+
+ Sizzle.contains = function (context, elem) {
+ // Set document vars if needed
+ if (( context.ownerDocument || context ) !== document) {
+ setDocument(context);
+ }
+ return contains(context, elem);
+ };
+
+ Sizzle.attr = function (elem, name) {
+ // Set document vars if needed
+ if (( elem.ownerDocument || elem ) !== document) {
+ setDocument(elem);
+ }
+
+ var fn = Expr.attrHandle[name.toLowerCase()],
+ // Don't get fooled by Object.prototype properties (jQuery #13807)
+ val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ?
+ fn(elem, name, !documentIsHTML) :
+ undefined;
+
+ return val !== undefined ?
+ val :
+ support.attributes || !documentIsHTML ?
+ elem.getAttribute(name) :
+ (val = elem.getAttributeNode(name)) && val.specified ?
+ val.value :
+ null;
+ };
+
+ Sizzle.error = function (msg) {
+ throw new Error("Syntax error, unrecognized expression: " + msg);
+ };
+
+ /**
+ * Document sorting and removing duplicates
+ * @param {ArrayLike} results
+ */
+ Sizzle.uniqueSort = function (results) {
+ var elem,
+ duplicates = [],
+ j = 0,
+ i = 0;
+
+ // Unless we *know* we can detect duplicates, assume their presence
+ hasDuplicate = !support.detectDuplicates;
+ sortInput = !support.sortStable && results.slice(0);
+ results.sort(sortOrder);
+
+ if (hasDuplicate) {
+ while ((elem = results[i++])) {
+ if (elem === results[i]) {
+ j = duplicates.push(i);
+ }
+ }
+ while (j--) {
+ results.splice(duplicates[j], 1);
+ }
+ }
+
+ // Clear input after sorting to release objects
+ // See https://github.com/jquery/sizzle/pull/225
+ sortInput = null;
+
+ return results;
+ };
+
+ /**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+ getText = Sizzle.getText = function (elem) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if (!nodeType) {
+ // If no nodeType, this is expected to be an array
+ while ((node = elem[i++])) {
+ // Do not traverse comment nodes
+ ret += getText(node);
+ }
+ } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) {
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (jQuery #11153)
+ if (typeof elem.textContent === "string") {
+ return elem.textContent;
+ } else {
+ // Traverse its children
+ for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
+ ret += getText(elem);
+ }
+ }
+ } else if (nodeType === 3 || nodeType === 4) {
+ return elem.nodeValue;
+ }
+ // Do not include comment or processing instruction nodes
+
+ return ret;
+ };
+
+ Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ attrHandle: {},
+
+ find: {},
+
+ relative: {
+ ">": {dir: "parentNode", first: true},
+ " ": {dir: "parentNode"},
+ "+": {dir: "previousSibling", first: true},
+ "~": {dir: "previousSibling"}
+ },
+
+ preFilter: {
+ "ATTR": function (match) {
+ match[1] = match[1].replace(runescape, funescape);
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[3] = ( match[3] || match[4] || match[5] || "" ).replace(runescape, funescape);
+
+ if (match[2] === "~=") {
+ match[3] = " " + match[3] + " ";
+ }
+
+ return match.slice(0, 4);
+ },
+
+ "CHILD": function (match) {
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 what (child|of-type)
+ 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 4 xn-component of xn+y argument ([+-]?\d*n|)
+ 5 sign of xn-component
+ 6 x of xn-component
+ 7 sign of y-component
+ 8 y of y-component
+ */
+ match[1] = match[1].toLowerCase();
+
+ if (match[1].slice(0, 3) === "nth") {
+ // nth-* requires argument
+ if (!match[3]) {
+ Sizzle.error(match[0]);
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
+ match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
+
+ // other types prohibit arguments
+ } else if (match[3]) {
+ Sizzle.error(match[0]);
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function (match) {
+ var excess,
+ unquoted = !match[6] && match[2];
+
+ if (matchExpr["CHILD"].test(match[0])) {
+ return null;
+ }
+
+ // Accept quoted arguments as-is
+ if (match[3]) {
+ match[2] = match[4] || match[5] || "";
+
+ // Strip excess characters from unquoted arguments
+ } else if (unquoted && rpseudo.test(unquoted) &&
+ // Get excess from tokenize (recursively)
+ (excess = tokenize(unquoted, true)) &&
+ // advance to the next closing parenthesis
+ (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
+
+ // excess is a negative index
+ match[0] = match[0].slice(0, excess);
+ match[2] = unquoted.slice(0, excess);
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice(0, 3);
+ }
+ },
+
+ filter: {
+
+ "TAG": function (nodeNameSelector) {
+ var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase();
+ return nodeNameSelector === "*" ?
+ function () {
+ return true;
+ } :
+ function (elem) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function (className) {
+ var pattern = classCache[className + " "];
+
+ return pattern ||
+ (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) &&
+ classCache(className, function (elem) {
+ return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "");
+ });
+ },
+
+ "ATTR": function (name, operator, check) {
+ return function (elem) {
+ var result = Sizzle.attr(elem, name);
+
+ if (result == null) {
+ return operator === "!=";
+ }
+ if (!operator) {
+ return true;
+ }
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf(check) === 0 :
+ operator === "*=" ? check && result.indexOf(check) > -1 :
+ operator === "$=" ? check && result.slice(-check.length) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf(check) > -1 :
+ operator === "|=" ? result === check || result.slice(0, check.length + 1) === check + "-" :
+ false;
+ };
+ },
+
+ "CHILD": function (type, what, argument, first, last) {
+ var simple = type.slice(0, 3) !== "nth",
+ forward = type.slice(-4) !== "last",
+ ofType = what === "of-type";
+
+ return first === 1 && last === 0 ?
+
+ // Shortcut for :nth-*(n)
+ function (elem) {
+ return !!elem.parentNode;
+ } :
+
+ function (elem, context, xml) {
+ var cache, outerCache, node, diff, nodeIndex, start,
+ dir = simple !== forward ? "nextSibling" : "previousSibling",
+ parent = elem.parentNode,
+ name = ofType && elem.nodeName.toLowerCase(),
+ useCache = !xml && !ofType;
+
+ if (parent) {
+
+ // :(first|last|only)-(child|of-type)
+ if (simple) {
+ while (dir) {
+ node = elem;
+ while ((node = node[dir])) {
+ if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
+ return false;
+ }
+ }
+ // Reverse direction for :only-* (if we haven't yet done so)
+ start = dir = type === "only" && !start && "nextSibling";
+ }
+ return true;
+ }
+
+ start = [forward ? parent.firstChild : parent.lastChild];
+
+ // non-xml :nth-child(...) stores cache data on `parent`
+ if (forward && useCache) {
+ // Seek `elem` from a previously-cached index
+ outerCache = parent[expando] || (parent[expando] = {});
+ cache = outerCache[type] || [];
+ nodeIndex = cache[0] === dirruns && cache[1];
+ diff = cache[0] === dirruns && cache[2];
+ node = nodeIndex && parent.childNodes[nodeIndex];
+
+ while ((node = ++nodeIndex && node && node[dir] ||
+
+ // Fallback to seeking `elem` from the start
+ (diff = nodeIndex = 0) || start.pop())) {
+
+ // When found, cache indexes on `parent` and break
+ if (node.nodeType === 1 && ++diff && node === elem) {
+ outerCache[type] = [dirruns, nodeIndex, diff];
+ break;
+ }
+ }
+
+ // Use previously-cached element index if available
+ } else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) {
+ diff = cache[1];
+
+ // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
+ } else {
+ // Use the same loop as above to seek `elem` from the start
+ while ((node = ++nodeIndex && node && node[dir] ||
+ (diff = nodeIndex = 0) || start.pop())) {
+
+ if (( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff) {
+ // Cache the index of each encountered element
+ if (useCache) {
+ (node[expando] || (node[expando] = {}))[type] = [dirruns, diff];
+ }
+
+ if (node === elem) {
+ break;
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset, then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ }
+ };
+ },
+
+ "PSEUDO": function (pseudo, argument) {
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[pseudo] || Expr.setFilters[pseudo.toLowerCase()] ||
+ Sizzle.error("unsupported pseudo: " + pseudo);
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if (fn[expando]) {
+ return fn(argument);
+ }
+
+ // But maintain support for old signatures
+ if (fn.length > 1) {
+ args = [pseudo, pseudo, "", argument];
+ return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ?
+ markFunction(function (seed, matches) {
+ var idx,
+ matched = fn(seed, argument),
+ i = matched.length;
+ while (i--) {
+ idx = indexOf.call(seed, matched[i]);
+ seed[idx] = !( matches[idx] = matched[i] );
+ }
+ }) :
+ function (elem) {
+ return fn(elem, 0, args);
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+ // Potentially complex pseudos
+ "not": markFunction(function (selector) {
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile(selector.replace(rtrim, "$1"));
+
+ return matcher[expando] ?
+ markFunction(function (seed, matches, context, xml) {
+ var elem,
+ unmatched = matcher(seed, null, xml, []),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while (i--) {
+ if ((elem = unmatched[i])) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function (elem, context, xml) {
+ input[0] = elem;
+ matcher(input, null, xml, results);
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function (selector) {
+ return function (elem) {
+ return Sizzle(selector, elem).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function (text) {
+ return function (elem) {
+ return ( elem.textContent || elem.innerText || getText(elem) ).indexOf(text) > -1;
+ };
+ }),
+
+ // "Whether an element is represented by a :lang() selector
+ // is based solely on the element's language value
+ // being equal to the identifier C,
+ // or beginning with the identifier C immediately followed by "-".
+ // The matching of C against the element's language value is performed case-insensitively.
+ // The identifier C does not have to be a valid language name."
+ // http://www.w3.org/TR/selectors/#lang-pseudo
+ "lang": markFunction(function (lang) {
+ // lang value must be a valid identifier
+ if (!ridentifier.test(lang || "")) {
+ Sizzle.error("unsupported lang: " + lang);
+ }
+ lang = lang.replace(runescape, funescape).toLowerCase();
+ return function (elem) {
+ var elemLang;
+ do {
+ if ((elemLang = documentIsHTML ?
+ elem.lang :
+ elem.getAttribute("xml:lang") || elem.getAttribute("lang"))) {
+
+ elemLang = elemLang.toLowerCase();
+ return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
+ }
+ } while ((elem = elem.parentNode) && elem.nodeType === 1);
+ return false;
+ };
+ }),
+
+ // Miscellaneous
+ "target": function (elem) {
+ var hash = window.location && window.location.hash;
+ return hash && hash.slice(1) === elem.id;
+ },
+
+ "root": function (elem) {
+ return elem === docElem;
+ },
+
+ "focus": function (elem) {
+ return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+ },
+
+ // Boolean properties
+ "enabled": function (elem) {
+ return elem.disabled === false;
+ },
+
+ "disabled": function (elem) {
+ return elem.disabled === true;
+ },
+
+ "checked": function (elem) {
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+ },
+
+ "selected": function (elem) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if (elem.parentNode) {
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ // Contents
+ "empty": function (elem) {
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
+ // but not by others (comment: 8; processing instruction: 7; etc.)
+ // nodeType < 6 works because attributes (2) do not appear as children
+ for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
+ if (elem.nodeType < 6) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ "parent": function (elem) {
+ return !Expr.pseudos["empty"](elem);
+ },
+
+ // Element/input types
+ "header": function (elem) {
+ return rheader.test(elem.nodeName);
+ },
+
+ "input": function (elem) {
+ return rinputs.test(elem.nodeName);
+ },
+
+ "button": function (elem) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "text": function (elem) {
+ var attr;
+ return elem.nodeName.toLowerCase() === "input" &&
+ elem.type === "text" &&
+
+ // Support: IE<8
+ // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
+ ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
+ },
+
+ // Position-in-collection
+ "first": createPositionalPseudo(function () {
+ return [0];
+ }),
+
+ "last": createPositionalPseudo(function (matchIndexes, length) {
+ return [length - 1];
+ }),
+
+ "eq": createPositionalPseudo(function (matchIndexes, length, argument) {
+ return [argument < 0 ? argument + length : argument];
+ }),
+
+ "even": createPositionalPseudo(function (matchIndexes, length) {
+ var i = 0;
+ for (; i < length; i += 2) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+
+ "odd": createPositionalPseudo(function (matchIndexes, length) {
+ var i = 1;
+ for (; i < length; i += 2) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+
+ "lt": createPositionalPseudo(function (matchIndexes, length, argument) {
+ var i = argument < 0 ? argument + length : argument;
+ for (; --i >= 0;) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ }),
+
+ "gt": createPositionalPseudo(function (matchIndexes, length, argument) {
+ var i = argument < 0 ? argument + length : argument;
+ for (; ++i < length;) {
+ matchIndexes.push(i);
+ }
+ return matchIndexes;
+ })
+ }
+ };
+
+ Expr.pseudos["nth"] = Expr.pseudos["eq"];
// Add button/input type pseudos
-for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
- Expr.pseudos[ i ] = createInputPseudo( i );
-}
-for ( i in { submit: true, reset: true } ) {
- Expr.pseudos[ i ] = createButtonPseudo( i );
-}
+ for (i in {radio: true, checkbox: true, file: true, password: true, image: true}) {
+ Expr.pseudos[i] = createInputPseudo(i);
+ }
+ for (i in {submit: true, reset: true}) {
+ Expr.pseudos[i] = createButtonPseudo(i);
+ }
// Easy API for creating new setFilters
-function setFilters() {}
-setFilters.prototype = Expr.filters = Expr.pseudos;
-Expr.setFilters = new setFilters();
-
-tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
- var matched, match, tokens, type,
- soFar, groups, preFilters,
- cached = tokenCache[ selector + " " ];
-
- if ( cached ) {
- return parseOnly ? 0 : cached.slice( 0 );
- }
-
- soFar = selector;
- groups = [];
- preFilters = Expr.preFilter;
-
- while ( soFar ) {
-
- // Comma and first run
- if ( !matched || (match = rcomma.exec( soFar )) ) {
- if ( match ) {
- // Don't consume trailing commas as valid
- soFar = soFar.slice( match[0].length ) || soFar;
- }
- groups.push( (tokens = []) );
- }
-
- matched = false;
-
- // Combinators
- if ( (match = rcombinators.exec( soFar )) ) {
- matched = match.shift();
- tokens.push({
- value: matched,
- // Cast descendant combinators to space
- type: match[0].replace( rtrim, " " )
- });
- soFar = soFar.slice( matched.length );
- }
-
- // Filters
- for ( type in Expr.filter ) {
- if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
- (match = preFilters[ type ]( match ))) ) {
- matched = match.shift();
- tokens.push({
- value: matched,
- type: type,
- matches: match
- });
- soFar = soFar.slice( matched.length );
- }
- }
-
- if ( !matched ) {
- break;
- }
- }
-
- // Return the length of the invalid excess
- // if we're just parsing
- // Otherwise, throw an error or return tokens
- return parseOnly ?
- soFar.length :
- soFar ?
- Sizzle.error( selector ) :
- // Cache the tokens
- tokenCache( selector, groups ).slice( 0 );
-};
-
-function toSelector( tokens ) {
- var i = 0,
- len = tokens.length,
- selector = "";
- for ( ; i < len; i++ ) {
- selector += tokens[i].value;
- }
- return selector;
-}
-
-function addCombinator( matcher, combinator, base ) {
- var dir = combinator.dir,
- checkNonElements = base && dir === "parentNode",
- doneName = done++;
-
- return combinator.first ?
- // Check against closest ancestor/preceding element
- function( elem, context, xml ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- return matcher( elem, context, xml );
- }
- }
- } :
-
- // Check against all ancestor/preceding elements
- function( elem, context, xml ) {
- var oldCache, outerCache,
- newCache = [ dirruns, doneName ];
-
- // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
- if ( xml ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- if ( matcher( elem, context, xml ) ) {
- return true;
- }
- }
- }
- } else {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- outerCache = elem[ expando ] || (elem[ expando ] = {});
- if ( (oldCache = outerCache[ dir ]) &&
- oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
-
- // Assign to newCache so results back-propagate to previous elements
- return (newCache[ 2 ] = oldCache[ 2 ]);
- } else {
- // Reuse newcache so results back-propagate to previous elements
- outerCache[ dir ] = newCache;
-
- // A match means we're done; a fail means we have to keep checking
- if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
- return true;
- }
- }
- }
- }
- }
- };
-}
-
-function elementMatcher( matchers ) {
- return matchers.length > 1 ?
- function( elem, context, xml ) {
- var i = matchers.length;
- while ( i-- ) {
- if ( !matchers[i]( elem, context, xml ) ) {
- return false;
- }
- }
- return true;
- } :
- matchers[0];
-}
-
-function multipleContexts( selector, contexts, results ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- Sizzle( selector, contexts[i], results );
- }
- return results;
-}
-
-function condense( unmatched, map, filter, context, xml ) {
- var elem,
- newUnmatched = [],
- i = 0,
- len = unmatched.length,
- mapped = map != null;
-
- for ( ; i < len; i++ ) {
- if ( (elem = unmatched[i]) ) {
- if ( !filter || filter( elem, context, xml ) ) {
- newUnmatched.push( elem );
- if ( mapped ) {
- map.push( i );
- }
- }
- }
- }
-
- return newUnmatched;
-}
-
-function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
- if ( postFilter && !postFilter[ expando ] ) {
- postFilter = setMatcher( postFilter );
- }
- if ( postFinder && !postFinder[ expando ] ) {
- postFinder = setMatcher( postFinder, postSelector );
- }
- return markFunction(function( seed, results, context, xml ) {
- var temp, i, elem,
- preMap = [],
- postMap = [],
- preexisting = results.length,
-
- // Get initial elements from seed or context
- elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
-
- // Prefilter to get matcher input, preserving a map for seed-results synchronization
- matcherIn = preFilter && ( seed || !selector ) ?
- condense( elems, preMap, preFilter, context, xml ) :
- elems,
-
- matcherOut = matcher ?
- // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
- postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-
- // ...intermediate processing is necessary
- [] :
-
- // ...otherwise use results directly
- results :
- matcherIn;
-
- // Find primary matches
- if ( matcher ) {
- matcher( matcherIn, matcherOut, context, xml );
- }
-
- // Apply postFilter
- if ( postFilter ) {
- temp = condense( matcherOut, postMap );
- postFilter( temp, [], context, xml );
-
- // Un-match failing elements by moving them back to matcherIn
- i = temp.length;
- while ( i-- ) {
- if ( (elem = temp[i]) ) {
- matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
- }
- }
- }
-
- if ( seed ) {
- if ( postFinder || preFilter ) {
- if ( postFinder ) {
- // Get the final matcherOut by condensing this intermediate into postFinder contexts
- temp = [];
- i = matcherOut.length;
- while ( i-- ) {
- if ( (elem = matcherOut[i]) ) {
- // Restore matcherIn since elem is not yet a final match
- temp.push( (matcherIn[i] = elem) );
- }
- }
- postFinder( null, (matcherOut = []), temp, xml );
- }
-
- // Move matched elements from seed to results to keep them synchronized
- i = matcherOut.length;
- while ( i-- ) {
- if ( (elem = matcherOut[i]) &&
- (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
-
- seed[temp] = !(results[temp] = elem);
- }
- }
- }
-
- // Add elements to results, through postFinder if defined
- } else {
- matcherOut = condense(
- matcherOut === results ?
- matcherOut.splice( preexisting, matcherOut.length ) :
- matcherOut
- );
- if ( postFinder ) {
- postFinder( null, results, matcherOut, xml );
- } else {
- push.apply( results, matcherOut );
- }
- }
- });
-}
-
-function matcherFromTokens( tokens ) {
- var checkContext, matcher, j,
- len = tokens.length,
- leadingRelative = Expr.relative[ tokens[0].type ],
- implicitRelative = leadingRelative || Expr.relative[" "],
- i = leadingRelative ? 1 : 0,
-
- // The foundational matcher ensures that elements are reachable from top-level context(s)
- matchContext = addCombinator( function( elem ) {
- return elem === checkContext;
- }, implicitRelative, true ),
- matchAnyContext = addCombinator( function( elem ) {
- return indexOf.call( checkContext, elem ) > -1;
- }, implicitRelative, true ),
- matchers = [ function( elem, context, xml ) {
- return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
- (checkContext = context).nodeType ?
- matchContext( elem, context, xml ) :
- matchAnyContext( elem, context, xml ) );
- } ];
-
- for ( ; i < len; i++ ) {
- if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
- matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
- } else {
- matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
-
- // Return special upon seeing a positional matcher
- if ( matcher[ expando ] ) {
- // Find the next relative operator (if any) for proper handling
- j = ++i;
- for ( ; j < len; j++ ) {
- if ( Expr.relative[ tokens[j].type ] ) {
- break;
- }
- }
- return setMatcher(
- i > 1 && elementMatcher( matchers ),
- i > 1 && toSelector(
- // If the preceding token was a descendant combinator, insert an implicit any-element `*`
- tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
- ).replace( rtrim, "$1" ),
- matcher,
- i < j && matcherFromTokens( tokens.slice( i, j ) ),
- j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
- j < len && toSelector( tokens )
- );
- }
- matchers.push( matcher );
- }
- }
-
- return elementMatcher( matchers );
-}
-
-function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
- var bySet = setMatchers.length > 0,
- byElement = elementMatchers.length > 0,
- superMatcher = function( seed, context, xml, results, outermost ) {
- var elem, j, matcher,
- matchedCount = 0,
- i = "0",
- unmatched = seed && [],
- setMatched = [],
- contextBackup = outermostContext,
- // We must always have either seed elements or outermost context
- elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
- // Use integer dirruns iff this is the outermost matcher
- dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
- len = elems.length;
-
- if ( outermost ) {
- outermostContext = context !== document && context;
- }
-
- // Add elements passing elementMatchers directly to results
- // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
- // Support: IE<9, Safari
- // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id
- for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
- if ( byElement && elem ) {
- j = 0;
- while ( (matcher = elementMatchers[j++]) ) {
- if ( matcher( elem, context, xml ) ) {
- results.push( elem );
- break;
- }
- }
- if ( outermost ) {
- dirruns = dirrunsUnique;
- }
- }
-
- // Track unmatched elements for set filters
- if ( bySet ) {
- // They will have gone through all possible matchers
- if ( (elem = !matcher && elem) ) {
- matchedCount--;
- }
-
- // Lengthen the array for every element, matched or not
- if ( seed ) {
- unmatched.push( elem );
- }
- }
- }
-
- // Apply set filters to unmatched elements
- matchedCount += i;
- if ( bySet && i !== matchedCount ) {
- j = 0;
- while ( (matcher = setMatchers[j++]) ) {
- matcher( unmatched, setMatched, context, xml );
- }
-
- if ( seed ) {
- // Reintegrate element matches to eliminate the need for sorting
- if ( matchedCount > 0 ) {
- while ( i-- ) {
- if ( !(unmatched[i] || setMatched[i]) ) {
- setMatched[i] = pop.call( results );
- }
- }
- }
-
- // Discard index placeholder values to get only actual matches
- setMatched = condense( setMatched );
- }
-
- // Add matches to results
- push.apply( results, setMatched );
-
- // Seedless set matches succeeding multiple successful matchers stipulate sorting
- if ( outermost && !seed && setMatched.length > 0 &&
- ( matchedCount + setMatchers.length ) > 1 ) {
-
- Sizzle.uniqueSort( results );
- }
- }
-
- // Override manipulation of globals by nested matchers
- if ( outermost ) {
- dirruns = dirrunsUnique;
- outermostContext = contextBackup;
- }
-
- return unmatched;
- };
-
- return bySet ?
- markFunction( superMatcher ) :
- superMatcher;
-}
-
-compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
- var i,
- setMatchers = [],
- elementMatchers = [],
- cached = compilerCache[ selector + " " ];
-
- if ( !cached ) {
- // Generate a function of recursive functions that can be used to check each element
- if ( !match ) {
- match = tokenize( selector );
- }
- i = match.length;
- while ( i-- ) {
- cached = matcherFromTokens( match[i] );
- if ( cached[ expando ] ) {
- setMatchers.push( cached );
- } else {
- elementMatchers.push( cached );
- }
- }
-
- // Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
-
- // Save selector and tokenization
- cached.selector = selector;
- }
- return cached;
-};
-
-/**
- * A low-level selection function that works with Sizzle's compiled
- * selector functions
- * @param {String|Function} selector A selector or a pre-compiled
- * selector function built with Sizzle.compile
- * @param {Element} context
- * @param {Array} [results]
- * @param {Array} [seed] A set of elements to match against
- */
-select = Sizzle.select = function( selector, context, results, seed ) {
- var i, tokens, token, type, find,
- compiled = typeof selector === "function" && selector,
- match = !seed && tokenize( (selector = compiled.selector || selector) );
-
- results = results || [];
-
- // Try to minimize operations if there is no seed and only one group
- if ( match.length === 1 ) {
-
- // Take a shortcut and set the context if the root selector is an ID
- tokens = match[0] = match[0].slice( 0 );
- if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
- support.getById && context.nodeType === 9 && documentIsHTML &&
- Expr.relative[ tokens[1].type ] ) {
-
- context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
- if ( !context ) {
- return results;
-
- // Precompiled matchers will still verify ancestry, so step up a level
- } else if ( compiled ) {
- context = context.parentNode;
- }
-
- selector = selector.slice( tokens.shift().value.length );
- }
-
- // Fetch a seed set for right-to-left matching
- i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
- while ( i-- ) {
- token = tokens[i];
-
- // Abort if we hit a combinator
- if ( Expr.relative[ (type = token.type) ] ) {
- break;
- }
- if ( (find = Expr.find[ type ]) ) {
- // Search, expanding context for leading sibling combinators
- if ( (seed = find(
- token.matches[0].replace( runescape, funescape ),
- rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
- )) ) {
-
- // If seed is empty or no tokens remain, we can return early
- tokens.splice( i, 1 );
- selector = seed.length && toSelector( tokens );
- if ( !selector ) {
- push.apply( results, seed );
- return results;
- }
-
- break;
- }
- }
- }
- }
-
- // Compile and execute a filtering function if one is not provided
- // Provide `match` to avoid retokenization if we modified the selector above
- ( compiled || compile( selector, match ) )(
- seed,
- context,
- !documentIsHTML,
- results,
- rsibling.test( selector ) && testContext( context.parentNode ) || context
- );
- return results;
-};
+ function setFilters() {
+ }
+
+ setFilters.prototype = Expr.filters = Expr.pseudos;
+ Expr.setFilters = new setFilters();
+
+ tokenize = Sizzle.tokenize = function (selector, parseOnly) {
+ var matched, match, tokens, type,
+ soFar, groups, preFilters,
+ cached = tokenCache[selector + " "];
+
+ if (cached) {
+ return parseOnly ? 0 : cached.slice(0);
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while (soFar) {
+
+ // Comma and first run
+ if (!matched || (match = rcomma.exec(soFar))) {
+ if (match) {
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice(match[0].length) || soFar;
+ }
+ groups.push((tokens = []));
+ }
+
+ matched = false;
+
+ // Combinators
+ if ((match = rcombinators.exec(soFar))) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ // Cast descendant combinators to space
+ type: match[0].replace(rtrim, " ")
+ });
+ soFar = soFar.slice(matched.length);
+ }
+
+ // Filters
+ for (type in Expr.filter) {
+ if ((match = matchExpr[type].exec(soFar)) && (!preFilters[type] ||
+ (match = preFilters[type](match)))) {
+ matched = match.shift();
+ tokens.push({
+ value: matched,
+ type: type,
+ matches: match
+ });
+ soFar = soFar.slice(matched.length);
+ }
+ }
+
+ if (!matched) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error(selector) :
+ // Cache the tokens
+ tokenCache(selector, groups).slice(0);
+ };
+
+ function toSelector(tokens) {
+ var i = 0,
+ len = tokens.length,
+ selector = "";
+ for (; i < len; i++) {
+ selector += tokens[i].value;
+ }
+ return selector;
+ }
+
+ function addCombinator(matcher, combinator, base) {
+ var dir = combinator.dir,
+ checkNonElements = base && dir === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+ // Check against closest ancestor/preceding element
+ function (elem, context, xml) {
+ while ((elem = elem[dir])) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ return matcher(elem, context, xml);
+ }
+ }
+ } :
+
+ // Check against all ancestor/preceding elements
+ function (elem, context, xml) {
+ var oldCache, outerCache,
+ newCache = [dirruns, doneName];
+
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if (xml) {
+ while ((elem = elem[dir])) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ if (matcher(elem, context, xml)) {
+ return true;
+ }
+ }
+ }
+ } else {
+ while ((elem = elem[dir])) {
+ if (elem.nodeType === 1 || checkNonElements) {
+ outerCache = elem[expando] || (elem[expando] = {});
+ if ((oldCache = outerCache[dir]) &&
+ oldCache[0] === dirruns && oldCache[1] === doneName) {
+
+ // Assign to newCache so results back-propagate to previous elements
+ return (newCache[2] = oldCache[2]);
+ } else {
+ // Reuse newcache so results back-propagate to previous elements
+ outerCache[dir] = newCache;
+
+ // A match means we're done; a fail means we have to keep checking
+ if ((newCache[2] = matcher(elem, context, xml))) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+
+ function elementMatcher(matchers) {
+ return matchers.length > 1 ?
+ function (elem, context, xml) {
+ var i = matchers.length;
+ while (i--) {
+ if (!matchers[i](elem, context, xml)) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[0];
+ }
+
+ function multipleContexts(selector, contexts, results) {
+ var i = 0,
+ len = contexts.length;
+ for (; i < len; i++) {
+ Sizzle(selector, contexts[i], results);
+ }
+ return results;
+ }
+
+ function condense(unmatched, map, filter, context, xml) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for (; i < len; i++) {
+ if ((elem = unmatched[i])) {
+ if (!filter || filter(elem, context, xml)) {
+ newUnmatched.push(elem);
+ if (mapped) {
+ map.push(i);
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+ }
+
+ function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
+ if (postFilter && !postFilter[expando]) {
+ postFilter = setMatcher(postFilter);
+ }
+ if (postFinder && !postFinder[expando]) {
+ postFinder = setMatcher(postFinder, postSelector);
+ }
+ return markFunction(function (seed, results, context, xml) {
+ var temp, i, elem,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense(elems, preMap, preFilter, context, xml) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if (matcher) {
+ matcher(matcherIn, matcherOut, context, xml);
+ }
+
+ // Apply postFilter
+ if (postFilter) {
+ temp = condense(matcherOut, postMap);
+ postFilter(temp, [], context, xml);
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while (i--) {
+ if ((elem = temp[i])) {
+ matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);
+ }
+ }
+ }
+
+ if (seed) {
+ if (postFinder || preFilter) {
+ if (postFinder) {
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while (i--) {
+ if ((elem = matcherOut[i])) {
+ // Restore matcherIn since elem is not yet a final match
+ temp.push((matcherIn[i] = elem));
+ }
+ }
+ postFinder(null, (matcherOut = []), temp, xml);
+ }
+
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while (i--) {
+ if ((elem = matcherOut[i]) &&
+ (temp = postFinder ? indexOf.call(seed, elem) : preMap[i]) > -1) {
+
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
+
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice(preexisting, matcherOut.length) :
+ matcherOut
+ );
+ if (postFinder) {
+ postFinder(null, results, matcherOut, xml);
+ } else {
+ push.apply(results, matcherOut);
+ }
+ }
+ });
+ }
+
+ function matcherFromTokens(tokens) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[tokens[0].type],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator(function (elem) {
+ return elem === checkContext;
+ }, implicitRelative, true),
+ matchAnyContext = addCombinator(function (elem) {
+ return indexOf.call(checkContext, elem) > -1;
+ }, implicitRelative, true),
+ matchers = [function (elem, context, xml) {
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext(elem, context, xml) :
+ matchAnyContext(elem, context, xml) );
+ }];
+
+ for (; i < len; i++) {
+ if ((matcher = Expr.relative[tokens[i].type])) {
+ matchers = [addCombinator(elementMatcher(matchers), matcher)];
+ } else {
+ matcher = Expr.filter[tokens[i].type].apply(null, tokens[i].matches);
+
+ // Return special upon seeing a positional matcher
+ if (matcher[expando]) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for (; j < len; j++) {
+ if (Expr.relative[tokens[j].type]) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher(matchers),
+ i > 1 && toSelector(
+ // If the preceding token was a descendant combinator, insert an implicit any-element `*`
+ tokens.slice(0, i - 1).concat({value: tokens[i - 2].type === " " ? "*" : ""})
+ ).replace(rtrim, "$1"),
+ matcher,
+ i < j && matcherFromTokens(tokens.slice(i, j)),
+ j < len && matcherFromTokens((tokens = tokens.slice(j))),
+ j < len && toSelector(tokens)
+ );
+ }
+ matchers.push(matcher);
+ }
+ }
+
+ return elementMatcher(matchers);
+ }
+
+ function matcherFromGroupMatchers(elementMatchers, setMatchers) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function (seed, context, xml, results, outermost) {
+ var elem, j, matcher,
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ setMatched = [],
+ contextBackup = outermostContext,
+ // We must always have either seed elements or outermost context
+ elems = seed || byElement && Expr.find["TAG"]("*", outermost),
+ // Use integer dirruns iff this is the outermost matcher
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
+ len = elems.length;
+
+ if (outermost) {
+ outermostContext = context !== document && context;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
+ // Support: IE<9, Safari
+ // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id
+ for (; i !== len && (elem = elems[i]) != null; i++) {
+ if (byElement && elem) {
+ j = 0;
+ while ((matcher = elementMatchers[j++])) {
+ if (matcher(elem, context, xml)) {
+ results.push(elem);
+ break;
+ }
+ }
+ if (outermost) {
+ dirruns = dirrunsUnique;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if (bySet) {
+ // They will have gone through all possible matchers
+ if ((elem = !matcher && elem)) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if (seed) {
+ unmatched.push(elem);
+ }
+ }
+ }
+
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if (bySet && i !== matchedCount) {
+ j = 0;
+ while ((matcher = setMatchers[j++])) {
+ matcher(unmatched, setMatched, context, xml);
+ }
+
+ if (seed) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if (matchedCount > 0) {
+ while (i--) {
+ if (!(unmatched[i] || setMatched[i])) {
+ setMatched[i] = pop.call(results);
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense(setMatched);
+ }
+
+ // Add matches to results
+ push.apply(results, setMatched);
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if (outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1) {
+
+ Sizzle.uniqueSort(results);
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if (outermost) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ return bySet ?
+ markFunction(superMatcher) :
+ superMatcher;
+ }
+
+ compile = Sizzle.compile = function (selector, match /* Internal Use Only */) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[selector + " "];
+
+ if (!cached) {
+ // Generate a function of recursive functions that can be used to check each element
+ if (!match) {
+ match = tokenize(selector);
+ }
+ i = match.length;
+ while (i--) {
+ cached = matcherFromTokens(match[i]);
+ if (cached[expando]) {
+ setMatchers.push(cached);
+ } else {
+ elementMatchers.push(cached);
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
+
+ // Save selector and tokenization
+ cached.selector = selector;
+ }
+ return cached;
+ };
+
+ /**
+ * A low-level selection function that works with Sizzle's compiled
+ * selector functions
+ * @param {String|Function} selector A selector or a pre-compiled
+ * selector function built with Sizzle.compile
+ * @param {Element} context
+ * @param {Array} [results]
+ * @param {Array} [seed] A set of elements to match against
+ */
+ select = Sizzle.select = function (selector, context, results, seed) {
+ var i, tokens, token, type, find,
+ compiled = typeof selector === "function" && selector,
+ match = !seed && tokenize((selector = compiled.selector || selector));
+
+ results = results || [];
+
+ // Try to minimize operations if there is no seed and only one group
+ if (match.length === 1) {
+
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice(0);
+ if (tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ support.getById && context.nodeType === 9 && documentIsHTML &&
+ Expr.relative[tokens[1].type]) {
+
+ context = ( Expr.find["ID"](token.matches[0].replace(runescape, funescape), context) || [] )[0];
+ if (!context) {
+ return results;
+
+ // Precompiled matchers will still verify ancestry, so step up a level
+ } else if (compiled) {
+ context = context.parentNode;
+ }
+
+ selector = selector.slice(tokens.shift().value.length);
+ }
+
+ // Fetch a seed set for right-to-left matching
+ i = matchExpr["needsContext"].test(selector) ? 0 : tokens.length;
+ while (i--) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if (Expr.relative[(type = token.type)]) {
+ break;
+ }
+ if ((find = Expr.find[type])) {
+ // Search, expanding context for leading sibling combinators
+ if ((seed = find(
+ token.matches[0].replace(runescape, funescape),
+ rsibling.test(tokens[0].type) && testContext(context.parentNode) || context
+ ))) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice(i, 1);
+ selector = seed.length && toSelector(tokens);
+ if (!selector) {
+ push.apply(results, seed);
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function if one is not provided
+ // Provide `match` to avoid retokenization if we modified the selector above
+ ( compiled || compile(selector, match) )(
+ seed,
+ context,
+ !documentIsHTML,
+ results,
+ rsibling.test(selector) && testContext(context.parentNode) || context
+ );
+ return results;
+ };
// One-time assignments
// Sort stability
-support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
+ support.sortStable = expando.split("").sort(sortOrder).join("") === expando;
// Support: Chrome<14
// Always assume duplicates if they aren't passed to the comparison function
-support.detectDuplicates = !!hasDuplicate;
+ support.detectDuplicates = !!hasDuplicate;
// Initialize against the default document
-setDocument();
+ setDocument();
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
// Detached nodes confoundingly follow *each other*
-support.sortDetached = assert(function( div1 ) {
- // Should return 1, but returns 4 (following)
- return div1.compareDocumentPosition( document.createElement("div") ) & 1;
-});
+ support.sortDetached = assert(function (div1) {
+ // Should return 1, but returns 4 (following)
+ return div1.compareDocumentPosition(document.createElement("div")) & 1;
+ });
// Support: IE<8
// Prevent attribute/property "interpolation"
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !assert(function( div ) {
- div.innerHTML = " ";
- return div.firstChild.getAttribute("href") === "#" ;
-}) ) {
- addHandle( "type|href|height|width", function( elem, name, isXML ) {
- if ( !isXML ) {
- return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
- }
- });
-}
+ if (!assert(function (div) {
+ div.innerHTML = " ";
+ return div.firstChild.getAttribute("href") === "#";
+ })) {
+ addHandle("type|href|height|width", function (elem, name, isXML) {
+ if (!isXML) {
+ return elem.getAttribute(name, name.toLowerCase() === "type" ? 1 : 2);
+ }
+ });
+ }
// Support: IE<9
// Use defaultValue in place of getAttribute("value")
-if ( !support.attributes || !assert(function( div ) {
- div.innerHTML = " ";
- div.firstChild.setAttribute( "value", "" );
- return div.firstChild.getAttribute( "value" ) === "";
-}) ) {
- addHandle( "value", function( elem, name, isXML ) {
- if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
- return elem.defaultValue;
- }
- });
-}
+ if (!support.attributes || !assert(function (div) {
+ div.innerHTML = " ";
+ div.firstChild.setAttribute("value", "");
+ return div.firstChild.getAttribute("value") === "";
+ })) {
+ addHandle("value", function (elem, name, isXML) {
+ if (!isXML && elem.nodeName.toLowerCase() === "input") {
+ return elem.defaultValue;
+ }
+ });
+ }
// Support: IE<9
// Use getAttributeNode to fetch booleans when getAttribute lies
-if ( !assert(function( div ) {
- return div.getAttribute("disabled") == null;
-}) ) {
- addHandle( booleans, function( elem, name, isXML ) {
- var val;
- if ( !isXML ) {
- return elem[ name ] === true ? name.toLowerCase() :
- (val = elem.getAttributeNode( name )) && val.specified ?
- val.value :
- null;
- }
- });
-}
-
-return Sizzle;
-
-})( window );
+ if (!assert(function (div) {
+ return div.getAttribute("disabled") == null;
+ })) {
+ addHandle(booleans, function (elem, name, isXML) {
+ var val;
+ if (!isXML) {
+ return elem[name] === true ? name.toLowerCase() :
+ (val = elem.getAttributeNode(name)) && val.specified ?
+ val.value :
+ null;
+ }
+ });
+ }
+ return Sizzle;
+ })(window);
-jQuery.find = Sizzle;
-jQuery.expr = Sizzle.selectors;
-jQuery.expr[":"] = jQuery.expr.pseudos;
-jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = Sizzle.getText;
-jQuery.isXMLDoc = Sizzle.isXML;
-jQuery.contains = Sizzle.contains;
+ jQuery.find = Sizzle;
+ jQuery.expr = Sizzle.selectors;
+ jQuery.expr[":"] = jQuery.expr.pseudos;
+ jQuery.unique = Sizzle.uniqueSort;
+ jQuery.text = Sizzle.getText;
+ jQuery.isXMLDoc = Sizzle.isXML;
+ jQuery.contains = Sizzle.contains;
-var rneedsContext = jQuery.expr.match.needsContext;
+ var rneedsContext = jQuery.expr.match.needsContext;
-var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
+ var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
-
-var risSimple = /^.[^:#\[\.,]*$/;
+ var risSimple = /^.[^:#\[\.,]*$/;
// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, not ) {
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep( elements, function( elem, i ) {
- /* jshint -W018 */
- return !!qualifier.call( elem, i, elem ) !== not;
- });
-
- }
-
- if ( qualifier.nodeType ) {
- return jQuery.grep( elements, function( elem ) {
- return ( elem === qualifier ) !== not;
- });
-
- }
-
- if ( typeof qualifier === "string" ) {
- if ( risSimple.test( qualifier ) ) {
- return jQuery.filter( qualifier, elements, not );
- }
-
- qualifier = jQuery.filter( qualifier, elements );
- }
-
- return jQuery.grep( elements, function( elem ) {
- return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
- });
-}
-
-jQuery.filter = function( expr, elems, not ) {
- var elem = elems[ 0 ];
-
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- return elems.length === 1 && elem.nodeType === 1 ?
- jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
- jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
- return elem.nodeType === 1;
- }));
-};
-
-jQuery.fn.extend({
- find: function( selector ) {
- var i,
- ret = [],
- self = this,
- len = self.length;
-
- if ( typeof selector !== "string" ) {
- return this.pushStack( jQuery( selector ).filter(function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- }) );
- }
-
- for ( i = 0; i < len; i++ ) {
- jQuery.find( selector, self[ i ], ret );
- }
-
- // Needed because $( selector, context ) becomes $( context ).find( selector )
- ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
- ret.selector = this.selector ? this.selector + " " + selector : selector;
- return ret;
- },
- filter: function( selector ) {
- return this.pushStack( winnow(this, selector || [], false) );
- },
- not: function( selector ) {
- return this.pushStack( winnow(this, selector || [], true) );
- },
- is: function( selector ) {
- return !!winnow(
- this,
-
- // If this is a positional/relative selector, check membership in the returned set
- // so $("p:first").is("p:last") won't return true for a doc with two "p".
- typeof selector === "string" && rneedsContext.test( selector ) ?
- jQuery( selector ) :
- selector || [],
- false
- ).length;
- }
-});
+ function winnow(elements, qualifier, not) {
+ if (jQuery.isFunction(qualifier)) {
+ return jQuery.grep(elements, function (elem, i) {
+ /* jshint -W018 */
+ return !!qualifier.call(elem, i, elem) !== not;
+ });
+
+ }
+
+ if (qualifier.nodeType) {
+ return jQuery.grep(elements, function (elem) {
+ return ( elem === qualifier ) !== not;
+ });
+
+ }
+
+ if (typeof qualifier === "string") {
+ if (risSimple.test(qualifier)) {
+ return jQuery.filter(qualifier, elements, not);
+ }
+
+ qualifier = jQuery.filter(qualifier, elements);
+ }
+
+ return jQuery.grep(elements, function (elem) {
+ return ( jQuery.inArray(elem, qualifier) >= 0 ) !== not;
+ });
+ }
+
+ jQuery.filter = function (expr, elems, not) {
+ var elem = elems[0];
+
+ if (not) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 && elem.nodeType === 1 ?
+ jQuery.find.matchesSelector(elem, expr) ? [elem] : [] :
+ jQuery.find.matches(expr, jQuery.grep(elems, function (elem) {
+ return elem.nodeType === 1;
+ }));
+ };
+
+ jQuery.fn.extend({
+ find: function (selector) {
+ var i,
+ ret = [],
+ self = this,
+ len = self.length;
+
+ if (typeof selector !== "string") {
+ return this.pushStack(jQuery(selector).filter(function () {
+ for (i = 0; i < len; i++) {
+ if (jQuery.contains(self[i], this)) {
+ return true;
+ }
+ }
+ }));
+ }
+
+ for (i = 0; i < len; i++) {
+ jQuery.find(selector, self[i], ret);
+ }
+
+ // Needed because $( selector, context ) becomes $( context ).find( selector )
+ ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret);
+ ret.selector = this.selector ? this.selector + " " + selector : selector;
+ return ret;
+ },
+ filter: function (selector) {
+ return this.pushStack(winnow(this, selector || [], false));
+ },
+ not: function (selector) {
+ return this.pushStack(winnow(this, selector || [], true));
+ },
+ is: function (selector) {
+ return !!winnow(
+ this,
+
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ typeof selector === "string" && rneedsContext.test(selector) ?
+ jQuery(selector) :
+ selector || [],
+ false
+ ).length;
+ }
+ });
// Initialize a jQuery object
// A central reference to the root jQuery(document)
-var rootjQuery,
-
- // Use the correct document accordingly with window argument (sandbox)
- document = window.document,
-
- // A simple way to check for HTML strings
- // Prioritize #id over to avoid XSS via location.hash (#9521)
- // Strict HTML recognition (#11290: must start with <)
- rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
-
- init = jQuery.fn.init = function( selector, context ) {
- var match, elem;
-
- // HANDLE: $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
-
- // scripts is true for back-compat
- // Intentionally let the error be thrown if parseHTML is not present
- jQuery.merge( this, jQuery.parseHTML(
- match[1],
- context && context.nodeType ? context.ownerDocument || context : document,
- true
- ) );
-
- // HANDLE: $(html, props)
- if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
- for ( match in context ) {
- // Properties of context are called as methods if possible
- if ( jQuery.isFunction( this[ match ] ) ) {
- this[ match ]( context[ match ] );
-
- // ...and otherwise set as attributes
- } else {
- this.attr( match, context[ match ] );
- }
- }
- }
-
- return this;
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || rootjQuery ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(DOMElement)
- } else if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return typeof rootjQuery.ready !== "undefined" ?
- rootjQuery.ready( selector ) :
- // Execute immediately if ready is not present
- selector( jQuery );
- }
-
- if ( selector.selector !== undefined ) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- };
+ var rootjQuery,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over to avoid XSS via location.hash (#9521)
+ // Strict HTML recognition (#11290: must start with <)
+ rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+
+ init = jQuery.fn.init = function (selector, context) {
+ var match, elem;
+
+ // HANDLE: $(""), $(null), $(undefined), $(false)
+ if (!selector) {
+ return this;
+ }
+
+ // Handle HTML strings
+ if (typeof selector === "string") {
+ if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) {
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [null, selector, null];
+
+ } else {
+ match = rquickExpr.exec(selector);
+ }
+
+ // Match html or make sure no context is specified for #id
+ if (match && (match[1] || !context)) {
+
+ // HANDLE: $(html) -> $(array)
+ if (match[1]) {
+ context = context instanceof jQuery ? context[0] : context;
+
+ // scripts is true for back-compat
+ // Intentionally let the error be thrown if parseHTML is not present
+ jQuery.merge(this, jQuery.parseHTML(
+ match[1],
+ context && context.nodeType ? context.ownerDocument || context : document,
+ true
+ ));
+
+ // HANDLE: $(html, props)
+ if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) {
+ for (match in context) {
+ // Properties of context are called as methods if possible
+ if (jQuery.isFunction(this[match])) {
+ this[match](context[match]);
+
+ // ...and otherwise set as attributes
+ } else {
+ this.attr(match, context[match]);
+ }
+ }
+ }
+
+ return this;
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById(match[2]);
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if (elem && elem.parentNode) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if (elem.id !== match[2]) {
+ return rootjQuery.find(selector);
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if (!context || context.jquery) {
+ return ( context || rootjQuery ).find(selector);
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor(context).find(selector);
+ }
+
+ // HANDLE: $(DOMElement)
+ } else if (selector.nodeType) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if (jQuery.isFunction(selector)) {
+ return typeof rootjQuery.ready !== "undefined" ?
+ rootjQuery.ready(selector) :
+ // Execute immediately if ready is not present
+ selector(jQuery);
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray(selector, this);
+ };
// Give the init function the jQuery prototype for later instantiation
-init.prototype = jQuery.fn;
+ init.prototype = jQuery.fn;
// Initialize central reference
-rootjQuery = jQuery( document );
-
-
-var rparentsprev = /^(?:parents|prev(?:Until|All))/,
- // methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.extend({
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
-
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
-
- sibling: function( n, elem ) {
- var r = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
-
- return r;
- }
-});
-
-jQuery.fn.extend({
- has: function( target ) {
- var i,
- targets = jQuery( target, this ),
- len = targets.length;
-
- return this.filter(function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
- return true;
- }
- }
- });
- },
-
- closest: function( selectors, context ) {
- var cur,
- i = 0,
- l = this.length,
- matched = [],
- pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
- jQuery( selectors, context || this.context ) :
- 0;
-
- for ( ; i < l; i++ ) {
- for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
- // Always skip document fragments
- if ( cur.nodeType < 11 && (pos ?
- pos.index(cur) > -1 :
-
- // Don't pass non-elements to Sizzle
- cur.nodeType === 1 &&
- jQuery.find.matchesSelector(cur, selectors)) ) {
-
- matched.push( cur );
- break;
- }
- }
- }
-
- return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
- },
-
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
- }
-
- // index in selector
- if ( typeof elem === "string" ) {
- return jQuery.inArray( this[0], jQuery( elem ) );
- }
-
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
-
- add: function( selector, context ) {
- return this.pushStack(
- jQuery.unique(
- jQuery.merge( this.get(), jQuery( selector, context ) )
- )
- );
- },
-
- addBack: function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter(selector)
- );
- }
-});
-
-function sibling( cur, dir ) {
- do {
- cur = cur[ dir ];
- } while ( cur && cur.nodeType !== 1 );
-
- return cur;
-}
-
-jQuery.each({
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return jQuery.dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return sibling( elem, "nextSibling" );
- },
- prev: function( elem ) {
- return sibling( elem, "previousSibling" );
- },
- nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
- },
- children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.merge( [], elem.childNodes );
- }
-}, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until );
-
- if ( name.slice( -5 ) !== "Until" ) {
- selector = until;
- }
-
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
-
- if ( this.length > 1 ) {
- // Remove duplicates
- if ( !guaranteedUnique[ name ] ) {
- ret = jQuery.unique( ret );
- }
-
- // Reverse order for parents* and prev-derivatives
- if ( rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
- }
-
- return this.pushStack( ret );
- };
-});
-var rnotwhite = (/\S+/g);
-
+ rootjQuery = jQuery(document);
+
+
+ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+ jQuery.extend({
+ dir: function (elem, dir, until) {
+ var matched = [],
+ cur = elem[dir];
+
+ while (cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery(cur).is(until))) {
+ if (cur.nodeType === 1) {
+ matched.push(cur);
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ sibling: function (n, elem) {
+ var r = [];
+
+ for (; n; n = n.nextSibling) {
+ if (n.nodeType === 1 && n !== elem) {
+ r.push(n);
+ }
+ }
+
+ return r;
+ }
+ });
+
+ jQuery.fn.extend({
+ has: function (target) {
+ var i,
+ targets = jQuery(target, this),
+ len = targets.length;
+
+ return this.filter(function () {
+ for (i = 0; i < len; i++) {
+ if (jQuery.contains(this, targets[i])) {
+ return true;
+ }
+ }
+ });
+ },
+
+ closest: function (selectors, context) {
+ var cur,
+ i = 0,
+ l = this.length,
+ matched = [],
+ pos = rneedsContext.test(selectors) || typeof selectors !== "string" ?
+ jQuery(selectors, context || this.context) :
+ 0;
+
+ for (; i < l; i++) {
+ for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) {
+ // Always skip document fragments
+ if (cur.nodeType < 11 && (pos ?
+ pos.index(cur) > -1 :
+
+ // Don't pass non-elements to Sizzle
+ cur.nodeType === 1 &&
+ jQuery.find.matchesSelector(cur, selectors))) {
+
+ matched.push(cur);
+ break;
+ }
+ }
+ }
+
+ return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched);
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function (elem) {
+
+ // No argument, return index in parent
+ if (!elem) {
+ return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
+ }
+
+ // index in selector
+ if (typeof elem === "string") {
+ return jQuery.inArray(this[0], jQuery(elem));
+ }
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this);
+ },
+
+ add: function (selector, context) {
+ return this.pushStack(
+ jQuery.unique(
+ jQuery.merge(this.get(), jQuery(selector, context))
+ )
+ );
+ },
+
+ addBack: function (selector) {
+ return this.add(selector == null ?
+ this.prevObject : this.prevObject.filter(selector)
+ );
+ }
+ });
+
+ function sibling(cur, dir) {
+ do {
+ cur = cur[dir];
+ } while (cur && cur.nodeType !== 1);
+
+ return cur;
+ }
+
+ jQuery.each({
+ parent: function (elem) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function (elem) {
+ return jQuery.dir(elem, "parentNode");
+ },
+ parentsUntil: function (elem, i, until) {
+ return jQuery.dir(elem, "parentNode", until);
+ },
+ next: function (elem) {
+ return sibling(elem, "nextSibling");
+ },
+ prev: function (elem) {
+ return sibling(elem, "previousSibling");
+ },
+ nextAll: function (elem) {
+ return jQuery.dir(elem, "nextSibling");
+ },
+ prevAll: function (elem) {
+ return jQuery.dir(elem, "previousSibling");
+ },
+ nextUntil: function (elem, i, until) {
+ return jQuery.dir(elem, "nextSibling", until);
+ },
+ prevUntil: function (elem, i, until) {
+ return jQuery.dir(elem, "previousSibling", until);
+ },
+ siblings: function (elem) {
+ return jQuery.sibling(( elem.parentNode || {} ).firstChild, elem);
+ },
+ children: function (elem) {
+ return jQuery.sibling(elem.firstChild);
+ },
+ contents: function (elem) {
+ return jQuery.nodeName(elem, "iframe") ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.merge([], elem.childNodes);
+ }
+ }, function (name, fn) {
+ jQuery.fn[name] = function (until, selector) {
+ var ret = jQuery.map(this, fn, until);
+
+ if (name.slice(-5) !== "Until") {
+ selector = until;
+ }
+
+ if (selector && typeof selector === "string") {
+ ret = jQuery.filter(selector, ret);
+ }
+
+ if (this.length > 1) {
+ // Remove duplicates
+ if (!guaranteedUnique[name]) {
+ ret = jQuery.unique(ret);
+ }
+
+ // Reverse order for parents* and prev-derivatives
+ if (rparentsprev.test(name)) {
+ ret = ret.reverse();
+ }
+ }
+
+ return this.pushStack(ret);
+ };
+ });
+ var rnotwhite = (/\S+/g);
// String to Object options format cache
-var optionsCache = {};
+ var optionsCache = {};
// Convert String-formatted options into Object-formatted ones and store in cache
-function createOptions( options ) {
- var object = optionsCache[ options ] = {};
- jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
- object[ flag ] = true;
- });
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * options: an optional list of space-separated options that will change how
- * the callback list behaves or a more traditional option object
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible options:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( options ) {
-
- // Convert options from String-formatted to Object-formatted if needed
- // (we check in cache first)
- options = typeof options === "string" ?
- ( optionsCache[ options ] || createOptions( options ) ) :
- jQuery.extend( {}, options );
-
- var // Flag to know if list is currently firing
- firing,
- // Last fire value (for non-forgettable lists)
- memory,
- // Flag to know if list was already fired
- fired,
- // End of the loop when firing
- firingLength,
- // Index of currently firing callback (modified by remove if needed)
- firingIndex,
- // First callback to fire (used internally by add and fireWith)
- firingStart,
- // Actual callback list
- list = [],
- // Stack of fire calls for repeatable lists
- stack = !options.once && [],
- // Fire callbacks
- fire = function( data ) {
- memory = options.memory && data;
- fired = true;
- firingIndex = firingStart || 0;
- firingStart = 0;
- firingLength = list.length;
- firing = true;
- for ( ; list && firingIndex < firingLength; firingIndex++ ) {
- if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
- memory = false; // To prevent further calls using add
- break;
- }
- }
- firing = false;
- if ( list ) {
- if ( stack ) {
- if ( stack.length ) {
- fire( stack.shift() );
- }
- } else if ( memory ) {
- list = [];
- } else {
- self.disable();
- }
- }
- },
- // Actual Callbacks object
- self = {
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
- // First, we save the current length
- var start = list.length;
- (function add( args ) {
- jQuery.each( args, function( _, arg ) {
- var type = jQuery.type( arg );
- if ( type === "function" ) {
- if ( !options.unique || !self.has( arg ) ) {
- list.push( arg );
- }
- } else if ( arg && arg.length && type !== "string" ) {
- // Inspect recursively
- add( arg );
- }
- });
- })( arguments );
- // Do we need to add the callbacks to the
- // current firing batch?
- if ( firing ) {
- firingLength = list.length;
- // With memory, if we're not firing then
- // we should call right away
- } else if ( memory ) {
- firingStart = start;
- fire( memory );
- }
- }
- return this;
- },
- // Remove a callback from the list
- remove: function() {
- if ( list ) {
- jQuery.each( arguments, function( _, arg ) {
- var index;
- while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
- list.splice( index, 1 );
- // Handle firing indexes
- if ( firing ) {
- if ( index <= firingLength ) {
- firingLength--;
- }
- if ( index <= firingIndex ) {
- firingIndex--;
- }
- }
- }
- });
- }
- return this;
- },
- // Check if a given callback is in the list.
- // If no argument is given, return whether or not list has callbacks attached.
- has: function( fn ) {
- return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
- },
- // Remove all callbacks from the list
- empty: function() {
- list = [];
- firingLength = 0;
- return this;
- },
- // Have the list do nothing anymore
- disable: function() {
- list = stack = memory = undefined;
- return this;
- },
- // Is it disabled?
- disabled: function() {
- return !list;
- },
- // Lock the list in its current state
- lock: function() {
- stack = undefined;
- if ( !memory ) {
- self.disable();
- }
- return this;
- },
- // Is it locked?
- locked: function() {
- return !stack;
- },
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- if ( list && ( !fired || stack ) ) {
- args = args || [];
- args = [ context, args.slice ? args.slice() : args ];
- if ( firing ) {
- stack.push( args );
- } else {
- fire( args );
- }
- }
- return this;
- },
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!fired;
- }
- };
-
- return self;
-};
-
-
-jQuery.extend({
-
- Deferred: function( func ) {
- var tuples = [
- // action, add listener, listener list, final state
- [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
- [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
- [ "notify", "progress", jQuery.Callbacks("memory") ]
- ],
- state = "pending",
- promise = {
- state: function() {
- return state;
- },
- always: function() {
- deferred.done( arguments ).fail( arguments );
- return this;
- },
- then: function( /* fnDone, fnFail, fnProgress */ ) {
- var fns = arguments;
- return jQuery.Deferred(function( newDefer ) {
- jQuery.each( tuples, function( i, tuple ) {
- var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
- // deferred[ done | fail | progress ] for forwarding actions to newDefer
- deferred[ tuple[1] ](function() {
- var returned = fn && fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise()
- .done( newDefer.resolve )
- .fail( newDefer.reject )
- .progress( newDefer.notify );
- } else {
- newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
- }
- });
- });
- fns = null;
- }).promise();
- },
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- return obj != null ? jQuery.extend( obj, promise ) : promise;
- }
- },
- deferred = {};
-
- // Keep pipe for back-compat
- promise.pipe = promise.then;
-
- // Add list-specific methods
- jQuery.each( tuples, function( i, tuple ) {
- var list = tuple[ 2 ],
- stateString = tuple[ 3 ];
-
- // promise[ done | fail | progress ] = list.add
- promise[ tuple[1] ] = list.add;
-
- // Handle state
- if ( stateString ) {
- list.add(function() {
- // state = [ resolved | rejected ]
- state = stateString;
-
- // [ reject_list | resolve_list ].disable; progress_list.lock
- }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
- }
-
- // deferred[ resolve | reject | notify ]
- deferred[ tuple[0] ] = function() {
- deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
- return this;
- };
- deferred[ tuple[0] + "With" ] = list.fireWith;
- });
-
- // Make the deferred a promise
- promise.promise( deferred );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( subordinate /* , ..., subordinateN */ ) {
- var i = 0,
- resolveValues = slice.call( arguments ),
- length = resolveValues.length,
-
- // the count of uncompleted subordinates
- remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
-
- // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
- deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
-
- // Update function for both resolve and progress values
- updateFunc = function( i, contexts, values ) {
- return function( value ) {
- contexts[ i ] = this;
- values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
- if ( values === progressValues ) {
- deferred.notifyWith( contexts, values );
-
- } else if ( !(--remaining) ) {
- deferred.resolveWith( contexts, values );
- }
- };
- },
-
- progressValues, progressContexts, resolveContexts;
-
- // add listeners to Deferred subordinates; treat others as resolved
- if ( length > 1 ) {
- progressValues = new Array( length );
- progressContexts = new Array( length );
- resolveContexts = new Array( length );
- for ( ; i < length; i++ ) {
- if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
- resolveValues[ i ].promise()
- .done( updateFunc( i, resolveContexts, resolveValues ) )
- .fail( deferred.reject )
- .progress( updateFunc( i, progressContexts, progressValues ) );
- } else {
- --remaining;
- }
- }
- }
-
- // if we're not waiting on anything, resolve the master
- if ( !remaining ) {
- deferred.resolveWith( resolveContexts, resolveValues );
- }
-
- return deferred.promise();
- }
-});
+ function createOptions(options) {
+ var object = optionsCache[options] = {};
+ jQuery.each(options.match(rnotwhite) || [], function (_, flag) {
+ object[flag] = true;
+ });
+ return object;
+ }
+
+ /*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+ jQuery.Callbacks = function (options) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ ( optionsCache[options] || createOptions(options) ) :
+ jQuery.extend({}, options);
+
+ var // Flag to know if list is currently firing
+ firing,
+ // Last fire value (for non-forgettable lists)
+ memory,
+ // Flag to know if list was already fired
+ fired,
+ // End of the loop when firing
+ firingLength,
+ // Index of currently firing callback (modified by remove if needed)
+ firingIndex,
+ // First callback to fire (used internally by add and fireWith)
+ firingStart,
+ // Actual callback list
+ list = [],
+ // Stack of fire calls for repeatable lists
+ stack = !options.once && [],
+ // Fire callbacks
+ fire = function (data) {
+ memory = options.memory && data;
+ fired = true;
+ firingIndex = firingStart || 0;
+ firingStart = 0;
+ firingLength = list.length;
+ firing = true;
+ for (; list && firingIndex < firingLength; firingIndex++) {
+ if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) {
+ memory = false; // To prevent further calls using add
+ break;
+ }
+ }
+ firing = false;
+ if (list) {
+ if (stack) {
+ if (stack.length) {
+ fire(stack.shift());
+ }
+ } else if (memory) {
+ list = [];
+ } else {
+ self.disable();
+ }
+ }
+ },
+ // Actual Callbacks object
+ self = {
+ // Add a callback or a collection of callbacks to the list
+ add: function () {
+ if (list) {
+ // First, we save the current length
+ var start = list.length;
+ (function add(args) {
+ jQuery.each(args, function (_, arg) {
+ var type = jQuery.type(arg);
+ if (type === "function") {
+ if (!options.unique || !self.has(arg)) {
+ list.push(arg);
+ }
+ } else if (arg && arg.length && type !== "string") {
+ // Inspect recursively
+ add(arg);
+ }
+ });
+ })(arguments);
+ // Do we need to add the callbacks to the
+ // current firing batch?
+ if (firing) {
+ firingLength = list.length;
+ // With memory, if we're not firing then
+ // we should call right away
+ } else if (memory) {
+ firingStart = start;
+ fire(memory);
+ }
+ }
+ return this;
+ },
+ // Remove a callback from the list
+ remove: function () {
+ if (list) {
+ jQuery.each(arguments, function (_, arg) {
+ var index;
+ while (( index = jQuery.inArray(arg, list, index) ) > -1) {
+ list.splice(index, 1);
+ // Handle firing indexes
+ if (firing) {
+ if (index <= firingLength) {
+ firingLength--;
+ }
+ if (index <= firingIndex) {
+ firingIndex--;
+ }
+ }
+ }
+ });
+ }
+ return this;
+ },
+ // Check if a given callback is in the list.
+ // If no argument is given, return whether or not list has callbacks attached.
+ has: function (fn) {
+ return fn ? jQuery.inArray(fn, list) > -1 : !!( list && list.length );
+ },
+ // Remove all callbacks from the list
+ empty: function () {
+ list = [];
+ firingLength = 0;
+ return this;
+ },
+ // Have the list do nothing anymore
+ disable: function () {
+ list = stack = memory = undefined;
+ return this;
+ },
+ // Is it disabled?
+ disabled: function () {
+ return !list;
+ },
+ // Lock the list in its current state
+ lock: function () {
+ stack = undefined;
+ if (!memory) {
+ self.disable();
+ }
+ return this;
+ },
+ // Is it locked?
+ locked: function () {
+ return !stack;
+ },
+ // Call all callbacks with the given context and arguments
+ fireWith: function (context, args) {
+ if (list && ( !fired || stack )) {
+ args = args || [];
+ args = [context, args.slice ? args.slice() : args];
+ if (firing) {
+ stack.push(args);
+ } else {
+ fire(args);
+ }
+ }
+ return this;
+ },
+ // Call all the callbacks with the given arguments
+ fire: function () {
+ self.fireWith(this, arguments);
+ return this;
+ },
+ // To know if the callbacks have already been called at least once
+ fired: function () {
+ return !!fired;
+ }
+ };
+
+ return self;
+ };
+
+
+ jQuery.extend({
+
+ Deferred: function (func) {
+ var tuples = [
+ // action, add listener, listener list, final state
+ ["resolve", "done", jQuery.Callbacks("once memory"), "resolved"],
+ ["reject", "fail", jQuery.Callbacks("once memory"), "rejected"],
+ ["notify", "progress", jQuery.Callbacks("memory")]
+ ],
+ state = "pending",
+ promise = {
+ state: function () {
+ return state;
+ },
+ always: function () {
+ deferred.done(arguments).fail(arguments);
+ return this;
+ },
+ then: function (/* fnDone, fnFail, fnProgress */) {
+ var fns = arguments;
+ return jQuery.Deferred(function (newDefer) {
+ jQuery.each(tuples, function (i, tuple) {
+ var fn = jQuery.isFunction(fns[i]) && fns[i];
+ // deferred[ done | fail | progress ] for forwarding actions to newDefer
+ deferred[tuple[1]](function () {
+ var returned = fn && fn.apply(this, arguments);
+ if (returned && jQuery.isFunction(returned.promise)) {
+ returned.promise()
+ .done(newDefer.resolve)
+ .fail(newDefer.reject)
+ .progress(newDefer.notify);
+ } else {
+ newDefer[tuple[0] + "With"](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments);
+ }
+ });
+ });
+ fns = null;
+ }).promise();
+ },
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function (obj) {
+ return obj != null ? jQuery.extend(obj, promise) : promise;
+ }
+ },
+ deferred = {};
+
+ // Keep pipe for back-compat
+ promise.pipe = promise.then;
+
+ // Add list-specific methods
+ jQuery.each(tuples, function (i, tuple) {
+ var list = tuple[2],
+ stateString = tuple[3];
+
+ // promise[ done | fail | progress ] = list.add
+ promise[tuple[1]] = list.add;
+
+ // Handle state
+ if (stateString) {
+ list.add(function () {
+ // state = [ resolved | rejected ]
+ state = stateString;
+
+ // [ reject_list | resolve_list ].disable; progress_list.lock
+ }, tuples[i ^ 1][2].disable, tuples[2][2].lock);
+ }
+
+ // deferred[ resolve | reject | notify ]
+ deferred[tuple[0]] = function () {
+ deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments);
+ return this;
+ };
+ deferred[tuple[0] + "With"] = list.fireWith;
+ });
+
+ // Make the deferred a promise
+ promise.promise(deferred);
+
+ // Call given func if any
+ if (func) {
+ func.call(deferred, deferred);
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function (subordinate /* , ..., subordinateN */) {
+ var i = 0,
+ resolveValues = slice.call(arguments),
+ length = resolveValues.length,
+
+ // the count of uncompleted subordinates
+ remaining = length !== 1 || ( subordinate && jQuery.isFunction(subordinate.promise) ) ? length : 0,
+
+ // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
+ deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+ // Update function for both resolve and progress values
+ updateFunc = function (i, contexts, values) {
+ return function (value) {
+ contexts[i] = this;
+ values[i] = arguments.length > 1 ? slice.call(arguments) : value;
+ if (values === progressValues) {
+ deferred.notifyWith(contexts, values);
+
+ } else if (!(--remaining)) {
+ deferred.resolveWith(contexts, values);
+ }
+ };
+ },
+
+ progressValues, progressContexts, resolveContexts;
+
+ // add listeners to Deferred subordinates; treat others as resolved
+ if (length > 1) {
+ progressValues = new Array(length);
+ progressContexts = new Array(length);
+ resolveContexts = new Array(length);
+ for (; i < length; i++) {
+ if (resolveValues[i] && jQuery.isFunction(resolveValues[i].promise)) {
+ resolveValues[i].promise()
+ .done(updateFunc(i, resolveContexts, resolveValues))
+ .fail(deferred.reject)
+ .progress(updateFunc(i, progressContexts, progressValues));
+ } else {
+ --remaining;
+ }
+ }
+ }
+
+ // if we're not waiting on anything, resolve the master
+ if (!remaining) {
+ deferred.resolveWith(resolveContexts, resolveValues);
+ }
+
+ return deferred.promise();
+ }
+ });
// The deferred used on DOM ready
-var readyList;
-
-jQuery.fn.ready = function( fn ) {
- // Add the callback
- jQuery.ready.promise().done( fn );
-
- return this;
-};
-
-jQuery.extend({
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.triggerHandler ) {
- jQuery( document ).triggerHandler( "ready" );
- jQuery( document ).off( "ready" );
- }
- }
-});
-
-/**
- * Clean-up method for dom ready events
- */
-function detach() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", completed, false );
- window.removeEventListener( "load", completed, false );
-
- } else {
- document.detachEvent( "onreadystatechange", completed );
- window.detachEvent( "onload", completed );
- }
-}
-
-/**
- * The ready event handler and self cleanup method
- */
-function completed() {
- // readyState === "complete" is good enough for us to call the dom ready in oldIE
- if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
- detach();
- jQuery.ready();
- }
-}
-
-jQuery.ready.promise = function( obj ) {
- if ( !readyList ) {
-
- readyList = jQuery.Deferred();
-
- // Catch cases where $(document).ready() is called after the browser event has already occurred.
- // we once tried to use readyState "interactive" here, but it caused issues like the one
- // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- setTimeout( jQuery.ready );
-
- // Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", completed, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", completed, false );
-
- // If IE event model is used
- } else {
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", completed );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", completed );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch(e) {}
-
- if ( top && top.doScroll ) {
- (function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll("left");
- } catch(e) {
- return setTimeout( doScrollCheck, 50 );
- }
-
- // detach all dom ready events
- detach();
-
- // and execute any waiting functions
- jQuery.ready();
- }
- })();
- }
- }
- }
- return readyList.promise( obj );
-};
-
-
-var strundefined = typeof undefined;
-
+ var readyList;
+
+ jQuery.fn.ready = function (fn) {
+ // Add the callback
+ jQuery.ready.promise().done(fn);
+
+ return this;
+ };
+
+ jQuery.extend({
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function (hold) {
+ if (hold) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready(true);
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function (wait) {
+
+ // Abort if there are pending holds or we're already ready
+ if (wait === true ? --jQuery.readyWait : jQuery.isReady) {
+ return;
+ }
+
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if (!document.body) {
+ return setTimeout(jQuery.ready);
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if (wait !== true && --jQuery.readyWait > 0) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith(document, [jQuery]);
+
+ // Trigger any bound ready events
+ if (jQuery.fn.triggerHandler) {
+ jQuery(document).triggerHandler("ready");
+ jQuery(document).off("ready");
+ }
+ }
+ });
+
+ /**
+ * Clean-up method for dom ready events
+ */
+ function detach() {
+ if (document.addEventListener) {
+ document.removeEventListener("DOMContentLoaded", completed, false);
+ window.removeEventListener("load", completed, false);
+
+ } else {
+ document.detachEvent("onreadystatechange", completed);
+ window.detachEvent("onload", completed);
+ }
+ }
+
+ /**
+ * The ready event handler and self cleanup method
+ */
+ function completed() {
+ // readyState === "complete" is good enough for us to call the dom ready in oldIE
+ if (document.addEventListener || event.type === "load" || document.readyState === "complete") {
+ detach();
+ jQuery.ready();
+ }
+ }
+
+ jQuery.ready.promise = function (obj) {
+ if (!readyList) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if (document.readyState === "complete") {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout(jQuery.ready);
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if (document.addEventListener) {
+ // Use the handy event callback
+ document.addEventListener("DOMContentLoaded", completed, false);
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener("load", completed, false);
+
+ // If IE event model is used
+ } else {
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", completed);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent("onload", completed);
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch (e) {
+ }
+
+ if (top && top.doScroll) {
+ (function doScrollCheck() {
+ if (!jQuery.isReady) {
+
+ try {
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll("left");
+ } catch (e) {
+ return setTimeout(doScrollCheck, 50);
+ }
+
+ // detach all dom ready events
+ detach();
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ })();
+ }
+ }
+ }
+ return readyList.promise(obj);
+ };
+
+
+ var strundefined = typeof undefined;
// Support: IE<9
// Iteration over object's inherited properties before its own
-var i;
-for ( i in jQuery( support ) ) {
- break;
-}
-support.ownLast = i !== "0";
+ var i;
+ for (i in jQuery(support)) {
+ break;
+ }
+ support.ownLast = i !== "0";
// Note: most support tests are defined in their respective modules.
// false until the test is run
-support.inlineBlockNeedsLayout = false;
+ support.inlineBlockNeedsLayout = false;
// Execute ASAP in case we need to set body.style.zoom
-jQuery(function() {
- // Minified: var a,b,c,d
- var val, div, body, container;
-
- body = document.getElementsByTagName( "body" )[ 0 ];
- if ( !body || !body.style ) {
- // Return for frameset docs that don't have a body
- return;
- }
-
- // Setup
- div = document.createElement( "div" );
- container = document.createElement( "div" );
- container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
- body.appendChild( container ).appendChild( div );
-
- if ( typeof div.style.zoom !== strundefined ) {
- // Support: IE<8
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
-
- support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
- if ( val ) {
- // Prevent IE 6 from affecting layout for positioned elements #11048
- // Prevent IE from shrinking the body in IE 7 mode #12869
- // Support: IE<8
- body.style.zoom = 1;
- }
- }
-
- body.removeChild( container );
-});
-
-
-
-
-(function() {
- var div = document.createElement( "div" );
-
- // Execute the test only if not already executed in another module.
- if (support.deleteExpando == null) {
- // Support: IE<9
- support.deleteExpando = true;
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
- }
-
- // Null elements to avoid leaks in IE.
- div = null;
-})();
-
-
-/**
- * Determines whether an object can have data
- */
-jQuery.acceptData = function( elem ) {
- var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
- nodeType = +elem.nodeType || 1;
-
- // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
- return nodeType !== 1 && nodeType !== 9 ?
- false :
-
- // Nodes accept data unless otherwise specified; rejection can be conditional
- !noData || noData !== true && elem.getAttribute("classid") === noData;
-};
-
-
-var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
- rmultiDash = /([A-Z])/g;
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- // Only convert to a number if it doesn't change the string
- +data + "" === data ? +data :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
+ jQuery(function () {
+ // Minified: var a,b,c,d
+ var val, div, body, container;
+
+ body = document.getElementsByTagName("body")[0];
+ if (!body || !body.style) {
+ // Return for frameset docs that don't have a body
+ return;
+ }
+
+ // Setup
+ div = document.createElement("div");
+ container = document.createElement("div");
+ container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
+ body.appendChild(container).appendChild(div);
+
+ if (typeof div.style.zoom !== strundefined) {
+ // Support: IE<8
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
+
+ support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
+ if (val) {
+ // Prevent IE 6 from affecting layout for positioned elements #11048
+ // Prevent IE from shrinking the body in IE 7 mode #12869
+ // Support: IE<8
+ body.style.zoom = 1;
+ }
+ }
+
+ body.removeChild(container);
+ });
+
+
+ (function () {
+ var div = document.createElement("div");
+
+ // Execute the test only if not already executed in another module.
+ if (support.deleteExpando == null) {
+ // Support: IE<9
+ support.deleteExpando = true;
+ try {
+ delete div.test;
+ } catch (e) {
+ support.deleteExpando = false;
+ }
+ }
+
+ // Null elements to avoid leaks in IE.
+ div = null;
+ })();
+
+
+ /**
+ * Determines whether an object can have data
+ */
+ jQuery.acceptData = function (elem) {
+ var noData = jQuery.noData[(elem.nodeName + " ").toLowerCase()],
+ nodeType = +elem.nodeType || 1;
+
+ // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
+ return nodeType !== 1 && nodeType !== 9 ?
+ false :
+
+ // Nodes accept data unless otherwise specified; rejection can be conditional
+ !noData || noData !== true && elem.getAttribute("classid") === noData;
+ };
+
+
+ var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+ function dataAttr(elem, key, data) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if (data === undefined && elem.nodeType === 1) {
+
+ var name = "data-" + key.replace(rmultiDash, "-$1").toLowerCase();
+
+ data = elem.getAttribute(name);
+
+ if (typeof data === "string") {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ // Only convert to a number if it doesn't change the string
+ +data + "" === data ? +data :
+ rbrace.test(data) ? jQuery.parseJSON(data) :
+ data;
+ } catch (e) {
+ }
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data(elem, key, data);
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+ }
// checks a cache object for emptiness
-function isEmptyDataObject( obj ) {
- var name;
- for ( name in obj ) {
-
- // if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
- continue;
- }
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-
-function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var ret, thisCache,
- internalKey = jQuery.expando,
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
- return;
- }
-
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
- } else {
- id = internalKey;
- }
- }
-
- if ( !cache[ id ] ) {
- // Avoid exposing jQuery metadata on plain JS objects when the object
- // is serialized using JSON.stringify
- cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ] = jQuery.extend( cache[ id ], name );
- } else {
- cache[ id ].data = jQuery.extend( cache[ id ].data, name );
- }
- }
-
- thisCache = cache[ id ];
-
- // jQuery data() is stored in a separate object inside the object's internal data
- // cache in order to avoid key collisions between internal data and user-defined
- // data.
- if ( !pvt ) {
- if ( !thisCache.data ) {
- thisCache.data = {};
- }
-
- thisCache = thisCache.data;
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( typeof name === "string" ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
-}
-
-function internalRemoveData( elem, name, pvt ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, i,
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ] : cache[ id ].data;
-
- if ( thisCache ) {
-
- // Support array or space separated string names for data keys
- if ( !jQuery.isArray( name ) ) {
-
- // try the string as a key before any manipulation
- if ( name in thisCache ) {
- name = [ name ];
- } else {
-
- // split the camel cased version by spaces unless a key with the spaces exists
- name = jQuery.camelCase( name );
- if ( name in thisCache ) {
- name = [ name ];
- } else {
- name = name.split(" ");
- }
- }
- } else {
- // If "name" is an array of keys...
- // When data is initially created, via ("key", "val") signature,
- // keys will be converted to camelCase.
- // Since there is no way to tell _how_ a key was added, remove
- // both plain key and camelCase key. #12786
- // This will only penalize the array argument path.
- name = name.concat( jQuery.map( name, jQuery.camelCase ) );
- }
-
- i = name.length;
- while ( i-- ) {
- delete thisCache[ name[i] ];
- }
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( !pvt ) {
- delete cache[ id ].data;
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject( cache[ id ] ) ) {
- return;
- }
- }
-
- // Destroy the cache
- if ( isNode ) {
- jQuery.cleanData( [ elem ], true );
-
- // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
- /* jshint eqeqeq: false */
- } else if ( support.deleteExpando || cache != cache.window ) {
- /* jshint eqeqeq: true */
- delete cache[ id ];
-
- // When all else fails, null
- } else {
- cache[ id ] = null;
- }
-}
-
-jQuery.extend({
- cache: {},
-
- // The following elements (space-suffixed to avoid Object.prototype collisions)
- // throw uncatchable exceptions if you attempt to set expando properties
- noData: {
- "applet ": true,
- "embed ": true,
- // ...but Flash objects (which have this classid) *can* handle expandos
- "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data ) {
- return internalData( elem, name, data );
- },
-
- removeData: function( elem, name ) {
- return internalRemoveData( elem, name );
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return internalData( elem, name, data, true );
- },
-
- _removeData: function( elem, name ) {
- return internalRemoveData( elem, name, true );
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var i, name, data,
- elem = this[0],
- attrs = elem && elem.attributes;
-
- // Special expections of .data basically thwart jQuery.access,
- // so implement the relevant behavior ourselves
-
- // Gets all values
- if ( key === undefined ) {
- if ( this.length ) {
- data = jQuery.data( elem );
-
- if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
- i = attrs.length;
- while ( i-- ) {
-
- // Support: IE11+
- // The attrs elements can be null (#14894)
- if ( attrs[ i ] ) {
- name = attrs[ i ].name;
- if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.slice(5) );
- dataAttr( elem, name, data[ name ] );
- }
- }
- }
- jQuery._data( elem, "parsedAttrs", true );
- }
- }
-
- return data;
- }
-
- // Sets multiple values
- if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- return arguments.length > 1 ?
-
- // Sets one value
- this.each(function() {
- jQuery.data( this, key, value );
- }) :
-
- // Gets one value
- // Try to fetch any internally stored data first
- elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-
-jQuery.extend({
- queue: function( elem, type, data ) {
- var queue;
-
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- queue = jQuery._data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !queue || jQuery.isArray(data) ) {
- queue = jQuery._data( elem, type, jQuery.makeArray(data) );
- } else {
- queue.push( data );
- }
- }
- return queue || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- startLength = queue.length,
- fn = queue.shift(),
- hooks = jQuery._queueHooks( elem, type ),
- next = function() {
- jQuery.dequeue( elem, type );
- };
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- startLength--;
- }
-
- if ( fn ) {
-
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- // clear up the last queue stop function
- delete hooks.stop;
- fn.call( elem, next, hooks );
- }
-
- if ( !startLength && hooks ) {
- hooks.empty.fire();
- }
- },
-
- // not intended for public consumption - generates a queueHooks object, or returns the current one
- _queueHooks: function( elem, type ) {
- var key = type + "queueHooks";
- return jQuery._data( elem, key ) || jQuery._data( elem, key, {
- empty: jQuery.Callbacks("once memory").add(function() {
- jQuery._removeData( elem, type + "queue" );
- jQuery._removeData( elem, key );
- })
- });
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- var setter = 2;
-
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- setter--;
- }
-
- if ( arguments.length < setter ) {
- return jQuery.queue( this[0], type );
- }
-
- return data === undefined ?
- this :
- this.each(function() {
- var queue = jQuery.queue( this, type, data );
-
- // ensure a hooks for this queue
- jQuery._queueHooks( this, type );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, obj ) {
- var tmp,
- count = 1,
- defer = jQuery.Deferred(),
- elements = this,
- i = this.length,
- resolve = function() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- };
-
- if ( typeof type !== "string" ) {
- obj = type;
- type = undefined;
- }
- type = type || "fx";
-
- while ( i-- ) {
- tmp = jQuery._data( elements[ i ], type + "queueHooks" );
- if ( tmp && tmp.empty ) {
- count++;
- tmp.empty.add( resolve );
- }
- }
- resolve();
- return defer.promise( obj );
- }
-});
-var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
-
-var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
-
-var isHidden = function( elem, el ) {
- // isHidden might be called from jQuery#filter function;
- // in that case, element will be second argument
- elem = el || elem;
- return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
- };
-
+ function isEmptyDataObject(obj) {
+ var name;
+ for (name in obj) {
+
+ // if the public data object is empty, the private is still empty
+ if (name === "data" && jQuery.isEmptyObject(obj[name])) {
+ continue;
+ }
+ if (name !== "toJSON") {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ function internalData(elem, name, data, pvt /* Internal Use Only */) {
+ if (!jQuery.acceptData(elem)) {
+ return;
+ }
+
+ var ret, thisCache,
+ internalKey = jQuery.expando,
+
+ // We have to handle DOM nodes and JS objects differently because IE6-7
+ // can't GC object references properly across the DOM-JS boundary
+ isNode = elem.nodeType,
+
+ // Only DOM nodes need the global jQuery cache; JS object data is
+ // attached directly to the object so GC can occur automatically
+ cache = isNode ? jQuery.cache : elem,
+
+ // Only defining an ID for JS objects if its cache already exists allows
+ // the code to shortcut on the same path as a DOM node with no cache
+ id = isNode ? elem[internalKey] : elem[internalKey] && internalKey;
+
+ // Avoid doing any more work than we need to when trying to get data on an
+ // object that has no data at all
+ if ((!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string") {
+ return;
+ }
+
+ if (!id) {
+ // Only DOM nodes need a new unique ID for each element since their data
+ // ends up in the global cache
+ if (isNode) {
+ id = elem[internalKey] = deletedIds.pop() || jQuery.guid++;
+ } else {
+ id = internalKey;
+ }
+ }
+
+ if (!cache[id]) {
+ // Avoid exposing jQuery metadata on plain JS objects when the object
+ // is serialized using JSON.stringify
+ cache[id] = isNode ? {} : {toJSON: jQuery.noop};
+ }
+
+ // An object can be passed to jQuery.data instead of a key/value pair; this gets
+ // shallow copied over onto the existing cache
+ if (typeof name === "object" || typeof name === "function") {
+ if (pvt) {
+ cache[id] = jQuery.extend(cache[id], name);
+ } else {
+ cache[id].data = jQuery.extend(cache[id].data, name);
+ }
+ }
+
+ thisCache = cache[id];
+
+ // jQuery data() is stored in a separate object inside the object's internal data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data.
+ if (!pvt) {
+ if (!thisCache.data) {
+ thisCache.data = {};
+ }
+
+ thisCache = thisCache.data;
+ }
+
+ if (data !== undefined) {
+ thisCache[jQuery.camelCase(name)] = data;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if (typeof name === "string") {
+
+ // First Try to find as-is property data
+ ret = thisCache[name];
+
+ // Test for null|undefined property data
+ if (ret == null) {
+
+ // Try to find the camelCased property
+ ret = thisCache[jQuery.camelCase(name)];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+ }
+
+ function internalRemoveData(elem, name, pvt) {
+ if (!jQuery.acceptData(elem)) {
+ return;
+ }
+
+ var thisCache, i,
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+ id = isNode ? elem[jQuery.expando] : jQuery.expando;
+
+ // If there is already no cache entry for this object, there is no
+ // purpose in continuing
+ if (!cache[id]) {
+ return;
+ }
+
+ if (name) {
+
+ thisCache = pvt ? cache[id] : cache[id].data;
+
+ if (thisCache) {
+
+ // Support array or space separated string names for data keys
+ if (!jQuery.isArray(name)) {
+
+ // try the string as a key before any manipulation
+ if (name in thisCache) {
+ name = [name];
+ } else {
+
+ // split the camel cased version by spaces unless a key with the spaces exists
+ name = jQuery.camelCase(name);
+ if (name in thisCache) {
+ name = [name];
+ } else {
+ name = name.split(" ");
+ }
+ }
+ } else {
+ // If "name" is an array of keys...
+ // When data is initially created, via ("key", "val") signature,
+ // keys will be converted to camelCase.
+ // Since there is no way to tell _how_ a key was added, remove
+ // both plain key and camelCase key. #12786
+ // This will only penalize the array argument path.
+ name = name.concat(jQuery.map(name, jQuery.camelCase));
+ }
+
+ i = name.length;
+ while (i--) {
+ delete thisCache[name[i]];
+ }
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if (pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache)) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if (!pvt) {
+ delete cache[id].data;
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if (!isEmptyDataObject(cache[id])) {
+ return;
+ }
+ }
+
+ // Destroy the cache
+ if (isNode) {
+ jQuery.cleanData([elem], true);
+
+ // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+ /* jshint eqeqeq: false */
+ } else if (support.deleteExpando || cache != cache.window) {
+ /* jshint eqeqeq: true */
+ delete cache[id];
+
+ // When all else fails, null
+ } else {
+ cache[id] = null;
+ }
+ }
+
+ jQuery.extend({
+ cache: {},
+
+ // The following elements (space-suffixed to avoid Object.prototype collisions)
+ // throw uncatchable exceptions if you attempt to set expando properties
+ noData: {
+ "applet ": true,
+ "embed ": true,
+ // ...but Flash objects (which have this classid) *can* handle expandos
+ "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+ },
+
+ hasData: function (elem) {
+ elem = elem.nodeType ? jQuery.cache[elem[jQuery.expando]] : elem[jQuery.expando];
+ return !!elem && !isEmptyDataObject(elem);
+ },
+
+ data: function (elem, name, data) {
+ return internalData(elem, name, data);
+ },
+
+ removeData: function (elem, name) {
+ return internalRemoveData(elem, name);
+ },
+
+ // For internal use only.
+ _data: function (elem, name, data) {
+ return internalData(elem, name, data, true);
+ },
+
+ _removeData: function (elem, name) {
+ return internalRemoveData(elem, name, true);
+ }
+ });
+
+ jQuery.fn.extend({
+ data: function (key, value) {
+ var i, name, data,
+ elem = this[0],
+ attrs = elem && elem.attributes;
+
+ // Special expections of .data basically thwart jQuery.access,
+ // so implement the relevant behavior ourselves
+
+ // Gets all values
+ if (key === undefined) {
+ if (this.length) {
+ data = jQuery.data(elem);
+
+ if (elem.nodeType === 1 && !jQuery._data(elem, "parsedAttrs")) {
+ i = attrs.length;
+ while (i--) {
+
+ // Support: IE11+
+ // The attrs elements can be null (#14894)
+ if (attrs[i]) {
+ name = attrs[i].name;
+ if (name.indexOf("data-") === 0) {
+ name = jQuery.camelCase(name.slice(5));
+ dataAttr(elem, name, data[name]);
+ }
+ }
+ }
+ jQuery._data(elem, "parsedAttrs", true);
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if (typeof key === "object") {
+ return this.each(function () {
+ jQuery.data(this, key);
+ });
+ }
+
+ return arguments.length > 1 ?
+
+ // Sets one value
+ this.each(function () {
+ jQuery.data(this, key, value);
+ }) :
+
+ // Gets one value
+ // Try to fetch any internally stored data first
+ elem ? dataAttr(elem, key, jQuery.data(elem, key)) : undefined;
+ },
+
+ removeData: function (key) {
+ return this.each(function () {
+ jQuery.removeData(this, key);
+ });
+ }
+ });
+
+
+ jQuery.extend({
+ queue: function (elem, type, data) {
+ var queue;
+
+ if (elem) {
+ type = ( type || "fx" ) + "queue";
+ queue = jQuery._data(elem, type);
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if (data) {
+ if (!queue || jQuery.isArray(data)) {
+ queue = jQuery._data(elem, type, jQuery.makeArray(data));
+ } else {
+ queue.push(data);
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function (elem, type) {
+ type = type || "fx";
+
+ var queue = jQuery.queue(elem, type),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks(elem, type),
+ next = function () {
+ jQuery.dequeue(elem, type);
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if (fn === "inprogress") {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ if (fn) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if (type === "fx") {
+ queue.unshift("inprogress");
+ }
+
+ // clear up the last queue stop function
+ delete hooks.stop;
+ fn.call(elem, next, hooks);
+ }
+
+ if (!startLength && hooks) {
+ hooks.empty.fire();
+ }
+ },
+
+ // not intended for public consumption - generates a queueHooks object, or returns the current one
+ _queueHooks: function (elem, type) {
+ var key = type + "queueHooks";
+ return jQuery._data(elem, key) || jQuery._data(elem, key, {
+ empty: jQuery.Callbacks("once memory").add(function () {
+ jQuery._removeData(elem, type + "queue");
+ jQuery._removeData(elem, key);
+ })
+ });
+ }
+ });
+
+ jQuery.fn.extend({
+ queue: function (type, data) {
+ var setter = 2;
+
+ if (typeof type !== "string") {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if (arguments.length < setter) {
+ return jQuery.queue(this[0], type);
+ }
+
+ return data === undefined ?
+ this :
+ this.each(function () {
+ var queue = jQuery.queue(this, type, data);
+
+ // ensure a hooks for this queue
+ jQuery._queueHooks(this, type);
+
+ if (type === "fx" && queue[0] !== "inprogress") {
+ jQuery.dequeue(this, type);
+ }
+ });
+ },
+ dequeue: function (type) {
+ return this.each(function () {
+ jQuery.dequeue(this, type);
+ });
+ },
+ clearQueue: function (type) {
+ return this.queue(type || "fx", []);
+ },
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function (type, obj) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function () {
+ if (!( --count )) {
+ defer.resolveWith(elements, [elements]);
+ }
+ };
+
+ if (typeof type !== "string") {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while (i--) {
+ tmp = jQuery._data(elements[i], type + "queueHooks");
+ if (tmp && tmp.empty) {
+ count++;
+ tmp.empty.add(resolve);
+ }
+ }
+ resolve();
+ return defer.promise(obj);
+ }
+ });
+ var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
+
+ var cssExpand = ["Top", "Right", "Bottom", "Left"];
+
+ var isHidden = function (elem, el) {
+ // isHidden might be called from jQuery#filter function;
+ // in that case, element will be second argument
+ elem = el || elem;
+ return jQuery.css(elem, "display") === "none" || !jQuery.contains(elem.ownerDocument, elem);
+ };
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
-var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
- var i = 0,
- length = elems.length,
- bulk = key == null;
-
- // Sets many values
- if ( jQuery.type( key ) === "object" ) {
- chainable = true;
- for ( i in key ) {
- jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
- }
-
- // Sets one value
- } else if ( value !== undefined ) {
- chainable = true;
-
- if ( !jQuery.isFunction( value ) ) {
- raw = true;
- }
-
- if ( bulk ) {
- // Bulk operations run against the entire set
- if ( raw ) {
- fn.call( elems, value );
- fn = null;
-
- // ...except when executing function values
- } else {
- bulk = fn;
- fn = function( elem, key, value ) {
- return bulk.call( jQuery( elem ), value );
- };
- }
- }
-
- if ( fn ) {
- for ( ; i < length; i++ ) {
- fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
- }
- }
- }
-
- return chainable ?
- elems :
-
- // Gets
- bulk ?
- fn.call( elems ) :
- length ? fn( elems[0], key ) : emptyGet;
-};
-var rcheckableType = (/^(?:checkbox|radio)$/i);
-
-
-
-(function() {
- // Minified: var a,b,c
- var input = document.createElement( "input" ),
- div = document.createElement( "div" ),
- fragment = document.createDocumentFragment();
-
- // Setup
- div.innerHTML = " a ";
-
- // IE strips leading whitespace when .innerHTML is used
- support.leadingWhitespace = div.firstChild.nodeType === 3;
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- support.tbody = !div.getElementsByTagName( "tbody" ).length;
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
-
- // Makes sure cloning an html5 element does not cause problems
- // Where outerHTML is undefined, this still works
- support.html5Clone =
- document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav>";
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- input.type = "checkbox";
- input.checked = true;
- fragment.appendChild( input );
- support.appendChecked = input.checked;
-
- // Make sure textarea (and checkbox) defaultValue is properly cloned
- // Support: IE6-IE11+
- div.innerHTML = "";
- support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
-
- // #11217 - WebKit loses check when the name is after the checked attribute
- fragment.appendChild( div );
- div.innerHTML = " ";
-
- // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
- // old WebKit doesn't clone checked state correctly in fragments
- support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Support: IE<9
- // Opera does not clone events (and typeof div.attachEvent === undefined).
- // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
- support.noCloneEvent = true;
- if ( div.attachEvent ) {
- div.attachEvent( "onclick", function() {
- support.noCloneEvent = false;
- });
-
- div.cloneNode( true ).click();
- }
-
- // Execute the test only if not already executed in another module.
- if (support.deleteExpando == null) {
- // Support: IE<9
- support.deleteExpando = true;
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
- }
-})();
-
-
-(function() {
- var i, eventName,
- div = document.createElement( "div" );
-
- // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
- for ( i in { submit: true, change: true, focusin: true }) {
- eventName = "on" + i;
-
- if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
- // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
- div.setAttribute( eventName, "t" );
- support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
- }
- }
-
- // Null elements to avoid leaks in IE.
- div = null;
-})();
-
-
-var rformElems = /^(?:input|select|textarea)$/i,
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
-
-function returnTrue() {
- return true;
-}
-
-function returnFalse() {
- return false;
-}
-
-function safeActiveElement() {
- try {
- return document.activeElement;
- } catch ( err ) { }
-}
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- global: {},
-
- add: function( elem, types, handler, data, selector ) {
- var tmp, events, t, handleObjIn,
- special, eventHandle, handleObj,
- handlers, type, namespaces, origType,
- elemData = jQuery._data( elem );
-
- // Don't attach events to noData or text/comment nodes (but allow plain objects)
- if ( !elemData ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- selector = handleObjIn.selector;
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- if ( !(events = elemData.events) ) {
- events = elemData.events = {};
- }
- if ( !(eventHandle = elemData.handle) ) {
- eventHandle = elemData.handle = function( e ) {
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
- jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
- eventHandle.elem = elem;
- }
-
- // Handle multiple events separated by a space
- types = ( types || "" ).match( rnotwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[t] ) || [];
- type = origType = tmp[1];
- namespaces = ( tmp[2] || "" ).split( "." ).sort();
-
- // There *must* be a type, no attaching namespace-only handlers
- if ( !type ) {
- continue;
- }
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend({
- type: type,
- origType: origType,
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
- namespace: namespaces.join(".")
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- if ( !(handlers = events[ type ]) ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener/attachEvent if the special events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
- var j, handleObj, tmp,
- origCount, t, events,
- special, handlers, type,
- namespaces, origType,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem );
-
- if ( !elemData || !(events = elemData.events) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).match( rnotwhite ) || [ "" ];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[t] ) || [];
- type = origType = tmp[1];
- namespaces = ( tmp[2] || "" ).split( "." ).sort();
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector ? special.delegateType : special.bindType ) || type;
- handlers = events[ type ] || [];
- tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
-
- // Remove matching events
- origCount = j = handlers.length;
- while ( j-- ) {
- handleObj = handlers[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !tmp || tmp.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
- handlers.splice( j, 1 );
-
- if ( handleObj.selector ) {
- handlers.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( origCount && !handlers.length ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- delete elemData.handle;
-
- // removeData also checks for emptiness and clears the expando if empty
- // so use it instead of delete
- jQuery._removeData( elem, "events" );
- }
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- var handle, ontype, cur,
- bubbleType, special, tmp, i,
- eventPath = [ elem || document ],
- type = hasOwn.call( event, "type" ) ? event.type : event,
- namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
-
- cur = tmp = elem = elem || document;
-
- // Don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf(".") >= 0 ) {
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split(".");
- type = namespaces.shift();
- namespaces.sort();
- }
- ontype = type.indexOf(":") < 0 && "on" + type;
-
- // Caller can pass in a jQuery.Event object, Object, or just an event type string
- event = event[ jQuery.expando ] ?
- event :
- new jQuery.Event( type, typeof event === "object" && event );
-
- // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
- event.isTrigger = onlyHandlers ? 2 : 3;
- event.namespace = namespaces.join(".");
- event.namespace_re = event.namespace ?
- new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
- null;
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data == null ?
- [ event ] :
- jQuery.makeArray( data, [ event ] );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- if ( !rfocusMorph.test( bubbleType + type ) ) {
- cur = cur.parentNode;
- }
- for ( ; cur; cur = cur.parentNode ) {
- eventPath.push( cur );
- tmp = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( tmp === (elem.ownerDocument || document) ) {
- eventPath.push( tmp.defaultView || tmp.parentWindow || window );
- }
- }
-
- // Fire handlers on the event path
- i = 0;
- while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
-
- event.type = i > 1 ?
- bubbleType :
- special.bindType || type;
-
- // jQuery handler
- handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
- if ( handle ) {
- handle.apply( cur, data );
- }
-
- // Native handler
- handle = ontype && cur[ ontype ];
- if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
- event.result = handle.apply( cur, data );
- if ( event.result === false ) {
- event.preventDefault();
- }
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
- jQuery.acceptData( elem ) ) {
-
- // Call a native DOM method on the target with the same name name as the event.
- // Can't use an .isFunction() check here because IE6/7 fails that test.
- // Don't do default actions on window, that's where global variables be (#6170)
- if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
-
- // Don't re-trigger an onFOO event when we call its FOO() method
- tmp = elem[ ontype ];
-
- if ( tmp ) {
- elem[ ontype ] = null;
- }
-
- // Prevent re-triggering of the same event, since we already bubbled it above
- jQuery.event.triggered = type;
- try {
- elem[ type ]();
- } catch ( e ) {
- // IE<9 dies on focus/blur to hidden element (#1486,#12518)
- // only reproducible on winXP IE8 native, not IE9 in IE8 mode
- }
- jQuery.event.triggered = undefined;
-
- if ( tmp ) {
- elem[ ontype ] = tmp;
- }
- }
- }
- }
-
- return event.result;
- },
-
- dispatch: function( event ) {
-
- // Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( event );
-
- var i, ret, handleObj, matched, j,
- handlerQueue = [],
- args = slice.call( arguments ),
- handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
- special = jQuery.event.special[ event.type ] || {};
-
- // Use the fix-ed jQuery.Event rather than the (read-only) native event
- args[0] = event;
- event.delegateTarget = this;
-
- // Call the preDispatch hook for the mapped type, and let it bail if desired
- if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
- return;
- }
-
- // Determine handlers
- handlerQueue = jQuery.event.handlers.call( this, event, handlers );
-
- // Run delegates first; they may want to stop propagation beneath us
- i = 0;
- while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
- event.currentTarget = matched.elem;
-
- j = 0;
- while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
-
- // Triggered event must either 1) have no namespace, or
- // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
- if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
-
- event.handleObj = handleObj;
- event.data = handleObj.data;
-
- ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
- .apply( matched.elem, args );
-
- if ( ret !== undefined ) {
- if ( (event.result = ret) === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- }
- }
- }
-
- // Call the postDispatch hook for the mapped type
- if ( special.postDispatch ) {
- special.postDispatch.call( this, event );
- }
-
- return event.result;
- },
-
- handlers: function( event, handlers ) {
- var sel, handleObj, matches, i,
- handlerQueue = [],
- delegateCount = handlers.delegateCount,
- cur = event.target;
-
- // Find delegate handlers
- // Black-hole SVG instance trees (#13180)
- // Avoid non-left-click bubbling in Firefox (#3861)
- if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
-
- /* jshint eqeqeq: false */
- for ( ; cur != this; cur = cur.parentNode || this ) {
- /* jshint eqeqeq: true */
-
- // Don't check non-elements (#13208)
- // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
- if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
- matches = [];
- for ( i = 0; i < delegateCount; i++ ) {
- handleObj = handlers[ i ];
-
- // Don't conflict with Object.prototype properties (#13203)
- sel = handleObj.selector + " ";
-
- if ( matches[ sel ] === undefined ) {
- matches[ sel ] = handleObj.needsContext ?
- jQuery( sel, this ).index( cur ) >= 0 :
- jQuery.find( sel, this, null, [ cur ] ).length;
- }
- if ( matches[ sel ] ) {
- matches.push( handleObj );
- }
- }
- if ( matches.length ) {
- handlerQueue.push({ elem: cur, handlers: matches });
- }
- }
- }
- }
-
- // Add the remaining (directly-bound) handlers
- if ( delegateCount < handlers.length ) {
- handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
- }
-
- return handlerQueue;
- },
-
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
-
- // Create a writable copy of the event object and normalize some properties
- var i, prop, copy,
- type = event.type,
- originalEvent = event,
- fixHook = this.fixHooks[ type ];
-
- if ( !fixHook ) {
- this.fixHooks[ type ] = fixHook =
- rmouseEvent.test( type ) ? this.mouseHooks :
- rkeyEvent.test( type ) ? this.keyHooks :
- {};
- }
- copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
-
- event = new jQuery.Event( originalEvent );
-
- i = copy.length;
- while ( i-- ) {
- prop = copy[ i ];
- event[ prop ] = originalEvent[ prop ];
- }
-
- // Support: IE<9
- // Fix target property (#1925)
- if ( !event.target ) {
- event.target = originalEvent.srcElement || document;
- }
-
- // Support: Chrome 23+, Safari?
- // Target should not be a text node (#504, #13143)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
-
- // Support: IE<9
- // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
- event.metaKey = !!event.metaKey;
-
- return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
- },
-
- // Includes some event props shared by KeyEvent and MouseEvent
- props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
-
- fixHooks: {},
-
- keyHooks: {
- props: "char charCode key keyCode".split(" "),
- filter: function( event, original ) {
-
- // Add which for key events
- if ( event.which == null ) {
- event.which = original.charCode != null ? original.charCode : original.keyCode;
- }
-
- return event;
- }
- },
-
- mouseHooks: {
- props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
- filter: function( event, original ) {
- var body, eventDoc, doc,
- button = original.button,
- fromElement = original.fromElement;
-
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && original.clientX != null ) {
- eventDoc = event.target.ownerDocument || document;
- doc = eventDoc.documentElement;
- body = eventDoc.body;
-
- event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
- event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
- }
-
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && fromElement ) {
- event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
- }
-
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && button !== undefined ) {
- event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
- }
-
- return event;
- }
- },
-
- special: {
- load: {
- // Prevent triggered image.load events from bubbling to window.load
- noBubble: true
- },
- focus: {
- // Fire native event if possible so blur/focus sequence is correct
- trigger: function() {
- if ( this !== safeActiveElement() && this.focus ) {
- try {
- this.focus();
- return false;
- } catch ( e ) {
- // Support: IE<9
- // If we error on focus to hidden element (#1486, #12518),
- // let .trigger() run the handlers
- }
- }
- },
- delegateType: "focusin"
- },
- blur: {
- trigger: function() {
- if ( this === safeActiveElement() && this.blur ) {
- this.blur();
- return false;
- }
- },
- delegateType: "focusout"
- },
- click: {
- // For checkbox, fire native event so checked state will be right
- trigger: function() {
- if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
- this.click();
- return false;
- }
- },
-
- // For cross-browser consistency, don't fire native .click() on links
- _default: function( event ) {
- return jQuery.nodeName( event.target, "a" );
- }
- },
-
- beforeunload: {
- postDispatch: function( event ) {
-
- // Support: Firefox 20+
- // Firefox doesn't alert if the returnValue field is not set.
- if ( event.result !== undefined && event.originalEvent ) {
- event.originalEvent.returnValue = event.result;
- }
- }
- }
- },
-
- simulate: function( type, elem, event, bubble ) {
- // Piggyback on a donor event to simulate a different one.
- // Fake originalEvent to avoid donor's stopPropagation, but if the
- // simulated event prevents default then we do the same on the donor.
- var e = jQuery.extend(
- new jQuery.Event(),
- event,
- {
- type: type,
- isSimulated: true,
- originalEvent: {}
- }
- );
- if ( bubble ) {
- jQuery.event.trigger( e, null, elem );
- } else {
- jQuery.event.dispatch.call( elem, e );
- }
- if ( e.isDefaultPrevented() ) {
- event.preventDefault();
- }
- }
-};
-
-jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle, false );
- }
- } :
- function( elem, type, handle ) {
- var name = "on" + type;
-
- if ( elem.detachEvent ) {
-
- // #8545, #7054, preventing memory leaks for custom events in IE6-8
- // detachEvent needed property on element, by name of that event, to properly expose it to GC
- if ( typeof elem[ name ] === strundefined ) {
- elem[ name ] = null;
- }
-
- elem.detachEvent( name, handle );
- }
- };
-
-jQuery.Event = function( src, props ) {
- // Allow instantiation without the 'new' keyword
- if ( !(this instanceof jQuery.Event) ) {
- return new jQuery.Event( src, props );
- }
-
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
-
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = src.defaultPrevented ||
- src.defaultPrevented === undefined &&
- // Support: IE < 9, Android < 4.0
- src.returnValue === false ?
- returnTrue :
- returnFalse;
-
- // Event type
- } else {
- this.type = src;
- }
-
- // Put explicitly provided properties onto the event object
- if ( props ) {
- jQuery.extend( this, props );
- }
-
- // Create a timestamp if incoming event doesn't have one
- this.timeStamp = src && src.timeStamp || jQuery.now();
-
- // Mark it as fixed
- this[ jQuery.expando ] = true;
-};
+ var access = jQuery.access = function (elems, fn, key, value, chainable, emptyGet, raw) {
+ var i = 0,
+ length = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if (jQuery.type(key) === "object") {
+ chainable = true;
+ for (i in key) {
+ jQuery.access(elems, fn, i, key[i], true, emptyGet, raw);
+ }
+
+ // Sets one value
+ } else if (value !== undefined) {
+ chainable = true;
+
+ if (!jQuery.isFunction(value)) {
+ raw = true;
+ }
+
+ if (bulk) {
+ // Bulk operations run against the entire set
+ if (raw) {
+ fn.call(elems, value);
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function (elem, key, value) {
+ return bulk.call(jQuery(elem), value);
+ };
+ }
+ }
+
+ if (fn) {
+ for (; i < length; i++) {
+ fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key)));
+ }
+ }
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call(elems) :
+ length ? fn(elems[0], key) : emptyGet;
+ };
+ var rcheckableType = (/^(?:checkbox|radio)$/i);
+
+
+ (function () {
+ // Minified: var a,b,c
+ var input = document.createElement("input"),
+ div = document.createElement("div"),
+ fragment = document.createDocumentFragment();
+
+ // Setup
+ div.innerHTML = " a ";
+
+ // IE strips leading whitespace when .innerHTML is used
+ support.leadingWhitespace = div.firstChild.nodeType === 3;
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ support.tbody = !div.getElementsByTagName("tbody").length;
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ support.htmlSerialize = !!div.getElementsByTagName("link").length;
+
+ // Makes sure cloning an html5 element does not cause problems
+ // Where outerHTML is undefined, this still works
+ support.html5Clone =
+ document.createElement("nav").cloneNode(true).outerHTML !== "<:nav>";
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ input.type = "checkbox";
+ input.checked = true;
+ fragment.appendChild(input);
+ support.appendChecked = input.checked;
+
+ // Make sure textarea (and checkbox) defaultValue is properly cloned
+ // Support: IE6-IE11+
+ div.innerHTML = "";
+ support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue;
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ fragment.appendChild(div);
+ div.innerHTML = " ";
+
+ // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
+ // old WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked;
+
+ // Support: IE<9
+ // Opera does not clone events (and typeof div.attachEvent === undefined).
+ // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
+ support.noCloneEvent = true;
+ if (div.attachEvent) {
+ div.attachEvent("onclick", function () {
+ support.noCloneEvent = false;
+ });
+
+ div.cloneNode(true).click();
+ }
+
+ // Execute the test only if not already executed in another module.
+ if (support.deleteExpando == null) {
+ // Support: IE<9
+ support.deleteExpando = true;
+ try {
+ delete div.test;
+ } catch (e) {
+ support.deleteExpando = false;
+ }
+ }
+ })();
+
+
+ (function () {
+ var i, eventName,
+ div = document.createElement("div");
+
+ // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
+ for (i in {submit: true, change: true, focusin: true}) {
+ eventName = "on" + i;
+
+ if (!(support[i + "Bubbles"] = eventName in window)) {
+ // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
+ div.setAttribute(eventName, "t");
+ support[i + "Bubbles"] = div.attributes[eventName].expando === false;
+ }
+ }
+
+ // Null elements to avoid leaks in IE.
+ div = null;
+ })();
+
+
+ var rformElems = /^(?:input|select|textarea)$/i,
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
+ rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
+
+ function returnTrue() {
+ return true;
+ }
+
+ function returnFalse() {
+ return false;
+ }
+
+ function safeActiveElement() {
+ try {
+ return document.activeElement;
+ } catch (err) {
+ }
+ }
+
+ /*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+ jQuery.event = {
+
+ global: {},
+
+ add: function (elem, types, handler, data, selector) {
+ var tmp, events, t, handleObjIn,
+ special, eventHandle, handleObj,
+ handlers, type, namespaces, origType,
+ elemData = jQuery._data(elem);
+
+ // Don't attach events to noData or text/comment nodes (but allow plain objects)
+ if (!elemData) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if (handler.handler) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if (!handler.guid) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ if (!(events = elemData.events)) {
+ events = elemData.events = {};
+ }
+ if (!(eventHandle = elemData.handle)) {
+ eventHandle = elemData.handle = function (e) {
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
+ jQuery.event.dispatch.apply(eventHandle.elem, arguments) :
+ undefined;
+ };
+ // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
+ eventHandle.elem = elem;
+ }
+
+ // Handle multiple events separated by a space
+ types = ( types || "" ).match(rnotwhite) || [""];
+ t = types.length;
+ while (t--) {
+ tmp = rtypenamespace.exec(types[t]) || [];
+ type = origType = tmp[1];
+ namespaces = ( tmp[2] || "" ).split(".").sort();
+
+ // There *must* be a type, no attaching namespace-only handlers
+ if (!type) {
+ continue;
+ }
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[type] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[type] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend({
+ type: type,
+ origType: origType,
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test(selector),
+ namespace: namespaces.join(".")
+ }, handleObjIn);
+
+ // Init the event handler queue if we're the first
+ if (!(handlers = events[type])) {
+ handlers = events[type] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener/attachEvent if the special events handler returns false
+ if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener) {
+ elem.addEventListener(type, eventHandle, false);
+
+ } else if (elem.attachEvent) {
+ elem.attachEvent("on" + type, eventHandle);
+ }
+ }
+ }
+
+ if (special.add) {
+ special.add.call(elem, handleObj);
+
+ if (!handleObj.handler.guid) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if (selector) {
+ handlers.splice(handlers.delegateCount++, 0, handleObj);
+ } else {
+ handlers.push(handleObj);
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[type] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ // Detach an event or set of events from an element
+ remove: function (elem, types, handler, selector, mappedTypes) {
+ var j, handleObj, tmp,
+ origCount, t, events,
+ special, handlers, type,
+ namespaces, origType,
+ elemData = jQuery.hasData(elem) && jQuery._data(elem);
+
+ if (!elemData || !(events = elemData.events)) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = ( types || "" ).match(rnotwhite) || [""];
+ t = types.length;
+ while (t--) {
+ tmp = rtypenamespace.exec(types[t]) || [];
+ type = origType = tmp[1];
+ namespaces = ( tmp[2] || "" ).split(".").sort();
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if (!type) {
+ for (type in events) {
+ jQuery.event.remove(elem, type + types[t], handler, selector, true);
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[type] || {};
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+ handlers = events[type] || [];
+ tmp = tmp[2] && new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)");
+
+ // Remove matching events
+ origCount = j = handlers.length;
+ while (j--) {
+ handleObj = handlers[j];
+
+ if (( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !tmp || tmp.test(handleObj.namespace) ) &&
+ ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector )) {
+ handlers.splice(j, 1);
+
+ if (handleObj.selector) {
+ handlers.delegateCount--;
+ }
+ if (special.remove) {
+ special.remove.call(elem, handleObj);
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if (origCount && !handlers.length) {
+ if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) {
+ jQuery.removeEvent(elem, type, elemData.handle);
+ }
+
+ delete events[type];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if (jQuery.isEmptyObject(events)) {
+ delete elemData.handle;
+
+ // removeData also checks for emptiness and clears the expando if empty
+ // so use it instead of delete
+ jQuery._removeData(elem, "events");
+ }
+ },
+
+ trigger: function (event, data, elem, onlyHandlers) {
+ var handle, ontype, cur,
+ bubbleType, special, tmp, i,
+ eventPath = [elem || document],
+ type = hasOwn.call(event, "type") ? event.type : event,
+ namespaces = hasOwn.call(event, "namespace") ? event.namespace.split(".") : [];
+
+ cur = tmp = elem = elem || document;
+
+ // Don't do events on text and comment nodes
+ if (elem.nodeType === 3 || elem.nodeType === 8) {
+ return;
+ }
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if (rfocusMorph.test(type + jQuery.event.triggered)) {
+ return;
+ }
+
+ if (type.indexOf(".") >= 0) {
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+ ontype = type.indexOf(":") < 0 && "on" + type;
+
+ // Caller can pass in a jQuery.Event object, Object, or just an event type string
+ event = event[jQuery.expando] ?
+ event :
+ new jQuery.Event(type, typeof event === "object" && event);
+
+ // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
+ event.isTrigger = onlyHandlers ? 2 : 3;
+ event.namespace = namespaces.join(".");
+ event.namespace_re = event.namespace ?
+ new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") :
+ null;
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if (!event.target) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data == null ?
+ [event] :
+ jQuery.makeArray(data, [event]);
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[type] || {};
+ if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) {
+
+ bubbleType = special.delegateType || type;
+ if (!rfocusMorph.test(bubbleType + type)) {
+ cur = cur.parentNode;
+ }
+ for (; cur; cur = cur.parentNode) {
+ eventPath.push(cur);
+ tmp = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if (tmp === (elem.ownerDocument || document)) {
+ eventPath.push(tmp.defaultView || tmp.parentWindow || window);
+ }
+ }
+
+ // Fire handlers on the event path
+ i = 0;
+ while ((cur = eventPath[i++]) && !event.isPropagationStopped()) {
+
+ event.type = i > 1 ?
+ bubbleType :
+ special.bindType || type;
+
+ // jQuery handler
+ handle = ( jQuery._data(cur, "events") || {} )[event.type] && jQuery._data(cur, "handle");
+ if (handle) {
+ handle.apply(cur, data);
+ }
+
+ // Native handler
+ handle = ontype && cur[ontype];
+ if (handle && handle.apply && jQuery.acceptData(cur)) {
+ event.result = handle.apply(cur, data);
+ if (event.result === false) {
+ event.preventDefault();
+ }
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if (!onlyHandlers && !event.isDefaultPrevented()) {
+
+ if ((!special._default || special._default.apply(eventPath.pop(), data) === false) &&
+ jQuery.acceptData(elem)) {
+
+ // Call a native DOM method on the target with the same name name as the event.
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ if (ontype && elem[type] && !jQuery.isWindow(elem)) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ tmp = elem[ontype];
+
+ if (tmp) {
+ elem[ontype] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+ try {
+ elem[type]();
+ } catch (e) {
+ // IE<9 dies on focus/blur to hidden element (#1486,#12518)
+ // only reproducible on winXP IE8 native, not IE9 in IE8 mode
+ }
+ jQuery.event.triggered = undefined;
+
+ if (tmp) {
+ elem[ontype] = tmp;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ dispatch: function (event) {
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix(event);
+
+ var i, ret, handleObj, matched, j,
+ handlerQueue = [],
+ args = slice.call(arguments),
+ handlers = ( jQuery._data(this, "events") || {} )[event.type] || [],
+ special = jQuery.event.special[event.type] || {};
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[0] = event;
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if (special.preDispatch && special.preDispatch.call(this, event) === false) {
+ return;
+ }
+
+ // Determine handlers
+ handlerQueue = jQuery.event.handlers.call(this, event, handlers);
+
+ // Run delegates first; they may want to stop propagation beneath us
+ i = 0;
+ while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {
+ event.currentTarget = matched.elem;
+
+ j = 0;
+ while ((handleObj = matched.handlers[j++]) && !event.isImmediatePropagationStopped()) {
+
+ // Triggered event must either 1) have no namespace, or
+ // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
+ if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) {
+
+ event.handleObj = handleObj;
+ event.data = handleObj.data;
+
+ ret = ( (jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler )
+ .apply(matched.elem, args);
+
+ if (ret !== undefined) {
+ if ((event.result = ret) === false) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if (special.postDispatch) {
+ special.postDispatch.call(this, event);
+ }
+
+ return event.result;
+ },
+
+ handlers: function (event, handlers) {
+ var sel, handleObj, matches, i,
+ handlerQueue = [],
+ delegateCount = handlers.delegateCount,
+ cur = event.target;
+
+ // Find delegate handlers
+ // Black-hole SVG instance trees (#13180)
+ // Avoid non-left-click bubbling in Firefox (#3861)
+ if (delegateCount && cur.nodeType && (!event.button || event.type !== "click")) {
+
+ /* jshint eqeqeq: false */
+ for (; cur != this; cur = cur.parentNode || this) {
+ /* jshint eqeqeq: true */
+
+ // Don't check non-elements (#13208)
+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+ if (cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click")) {
+ matches = [];
+ for (i = 0; i < delegateCount; i++) {
+ handleObj = handlers[i];
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
+
+ if (matches[sel] === undefined) {
+ matches[sel] = handleObj.needsContext ?
+ jQuery(sel, this).index(cur) >= 0 :
+ jQuery.find(sel, this, null, [cur]).length;
+ }
+ if (matches[sel]) {
+ matches.push(handleObj);
+ }
+ }
+ if (matches.length) {
+ handlerQueue.push({elem: cur, handlers: matches});
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ if (delegateCount < handlers.length) {
+ handlerQueue.push({elem: this, handlers: handlers.slice(delegateCount)});
+ }
+
+ return handlerQueue;
+ },
+
+ fix: function (event) {
+ if (event[jQuery.expando]) {
+ return event;
+ }
+
+ // Create a writable copy of the event object and normalize some properties
+ var i, prop, copy,
+ type = event.type,
+ originalEvent = event,
+ fixHook = this.fixHooks[type];
+
+ if (!fixHook) {
+ this.fixHooks[type] = fixHook =
+ rmouseEvent.test(type) ? this.mouseHooks :
+ rkeyEvent.test(type) ? this.keyHooks :
+ {};
+ }
+ copy = fixHook.props ? this.props.concat(fixHook.props) : this.props;
+
+ event = new jQuery.Event(originalEvent);
+
+ i = copy.length;
+ while (i--) {
+ prop = copy[i];
+ event[prop] = originalEvent[prop];
+ }
+
+ // Support: IE<9
+ // Fix target property (#1925)
+ if (!event.target) {
+ event.target = originalEvent.srcElement || document;
+ }
+
+ // Support: Chrome 23+, Safari?
+ // Target should not be a text node (#504, #13143)
+ if (event.target.nodeType === 3) {
+ event.target = event.target.parentNode;
+ }
+
+ // Support: IE<9
+ // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
+ event.metaKey = !!event.metaKey;
+
+ return fixHook.filter ? fixHook.filter(event, originalEvent) : event;
+ },
+
+ // Includes some event props shared by KeyEvent and MouseEvent
+ props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+
+ fixHooks: {},
+
+ keyHooks: {
+ props: "char charCode key keyCode".split(" "),
+ filter: function (event, original) {
+
+ // Add which for key events
+ if (event.which == null) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+
+ return event;
+ }
+ },
+
+ mouseHooks: {
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+ filter: function (event, original) {
+ var body, eventDoc, doc,
+ button = original.button,
+ fromElement = original.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if (event.pageX == null && original.clientX != null) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+
+ event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+ event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
+ }
+
+ // Add relatedTarget, if necessary
+ if (!event.relatedTarget && fromElement) {
+ event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if (!event.which && button !== undefined) {
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+ }
+
+ return event;
+ }
+ },
+
+ special: {
+ load: {
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+ focus: {
+ // Fire native event if possible so blur/focus sequence is correct
+ trigger: function () {
+ if (this !== safeActiveElement() && this.focus) {
+ try {
+ this.focus();
+ return false;
+ } catch (e) {
+ // Support: IE<9
+ // If we error on focus to hidden element (#1486, #12518),
+ // let .trigger() run the handlers
+ }
+ }
+ },
+ delegateType: "focusin"
+ },
+ blur: {
+ trigger: function () {
+ if (this === safeActiveElement() && this.blur) {
+ this.blur();
+ return false;
+ }
+ },
+ delegateType: "focusout"
+ },
+ click: {
+ // For checkbox, fire native event so checked state will be right
+ trigger: function () {
+ if (jQuery.nodeName(this, "input") && this.type === "checkbox" && this.click) {
+ this.click();
+ return false;
+ }
+ },
+
+ // For cross-browser consistency, don't fire native .click() on links
+ _default: function (event) {
+ return jQuery.nodeName(event.target, "a");
+ }
+ },
+
+ beforeunload: {
+ postDispatch: function (event) {
+
+ // Support: Firefox 20+
+ // Firefox doesn't alert if the returnValue field is not set.
+ if (event.result !== undefined && event.originalEvent) {
+ event.originalEvent.returnValue = event.result;
+ }
+ }
+ }
+ },
+
+ simulate: function (type, elem, event, bubble) {
+ // Piggyback on a donor event to simulate a different one.
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
+ // simulated event prevents default then we do the same on the donor.
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ {
+ type: type,
+ isSimulated: true,
+ originalEvent: {}
+ }
+ );
+ if (bubble) {
+ jQuery.event.trigger(e, null, elem);
+ } else {
+ jQuery.event.dispatch.call(elem, e);
+ }
+ if (e.isDefaultPrevented()) {
+ event.preventDefault();
+ }
+ }
+ };
+
+ jQuery.removeEvent = document.removeEventListener ?
+ function (elem, type, handle) {
+ if (elem.removeEventListener) {
+ elem.removeEventListener(type, handle, false);
+ }
+ } :
+ function (elem, type, handle) {
+ var name = "on" + type;
+
+ if (elem.detachEvent) {
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
+ // detachEvent needed property on element, by name of that event, to properly expose it to GC
+ if (typeof elem[name] === strundefined) {
+ elem[name] = null;
+ }
+
+ elem.detachEvent(name, handle);
+ }
+ };
+
+ jQuery.Event = function (src, props) {
+ // Allow instantiation without the 'new' keyword
+ if (!(this instanceof jQuery.Event)) {
+ return new jQuery.Event(src, props);
+ }
+
+ // Event object
+ if (src && src.type) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = src.defaultPrevented ||
+ src.defaultPrevented === undefined &&
+ // Support: IE < 9, Android < 4.0
+ src.returnValue === false ?
+ returnTrue :
+ returnFalse;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if (props) {
+ jQuery.extend(this, props);
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+
+ // Mark it as fixed
+ this[jQuery.expando] = true;
+ };
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
-jQuery.Event.prototype = {
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse,
-
- preventDefault: function() {
- var e = this.originalEvent;
-
- this.isDefaultPrevented = returnTrue;
- if ( !e ) {
- return;
- }
-
- // If preventDefault exists, run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
-
- // Support: IE
- // Otherwise set the returnValue property of the original event to false
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- var e = this.originalEvent;
-
- this.isPropagationStopped = returnTrue;
- if ( !e ) {
- return;
- }
- // If stopPropagation exists, run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
-
- // Support: IE
- // Set the cancelBubble property of the original event to true
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- var e = this.originalEvent;
-
- this.isImmediatePropagationStopped = returnTrue;
-
- if ( e && e.stopImmediatePropagation ) {
- e.stopImmediatePropagation();
- }
-
- this.stopPropagation();
- }
-};
+ jQuery.Event.prototype = {
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse,
+
+ preventDefault: function () {
+ var e = this.originalEvent;
+
+ this.isDefaultPrevented = returnTrue;
+ if (!e) {
+ return;
+ }
+
+ // If preventDefault exists, run it on the original event
+ if (e.preventDefault) {
+ e.preventDefault();
+
+ // Support: IE
+ // Otherwise set the returnValue property of the original event to false
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function () {
+ var e = this.originalEvent;
+
+ this.isPropagationStopped = returnTrue;
+ if (!e) {
+ return;
+ }
+ // If stopPropagation exists, run it on the original event
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+
+ // Support: IE
+ // Set the cancelBubble property of the original event to true
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function () {
+ var e = this.originalEvent;
+
+ this.isImmediatePropagationStopped = returnTrue;
+
+ if (e && e.stopImmediatePropagation) {
+ e.stopImmediatePropagation();
+ }
+
+ this.stopPropagation();
+ }
+ };
// Create mouseenter/leave events using mouseover/out and event-time checks
-jQuery.each({
- mouseenter: "mouseover",
- mouseleave: "mouseout",
- pointerenter: "pointerover",
- pointerleave: "pointerout"
-}, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- delegateType: fix,
- bindType: fix,
-
- handle: function( event ) {
- var ret,
- target = this,
- related = event.relatedTarget,
- handleObj = event.handleObj;
-
- // For mousenter/leave call the handler if related is outside the target.
- // NB: No relatedTarget if the mouse left/entered the browser window
- if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
- event.type = handleObj.origType;
- ret = handleObj.handler.apply( this, arguments );
- event.type = fix;
- }
- return ret;
- }
- };
-});
+ jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout",
+ pointerenter: "pointerover",
+ pointerleave: "pointerout"
+ }, function (orig, fix) {
+ jQuery.event.special[orig] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function (event) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj;
+
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if (!related || (related !== target && !jQuery.contains(target, related))) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply(this, arguments);
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+ });
// IE submit delegation
-if ( !support.submitBubbles ) {
-
- jQuery.event.special.submit = {
- setup: function() {
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Lazy-add a submit handler when a descendant form may potentially be submitted
- jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
- // Node name check avoids a VML-related crash in IE (#9807)
- var elem = e.target,
- form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
- if ( form && !jQuery._data( form, "submitBubbles" ) ) {
- jQuery.event.add( form, "submit._submit", function( event ) {
- event._submit_bubble = true;
- });
- jQuery._data( form, "submitBubbles", true );
- }
- });
- // return undefined since we don't need an event listener
- },
-
- postDispatch: function( event ) {
- // If form was submitted by the user, bubble the event up the tree
- if ( event._submit_bubble ) {
- delete event._submit_bubble;
- if ( this.parentNode && !event.isTrigger ) {
- jQuery.event.simulate( "submit", this.parentNode, event, true );
- }
- }
- },
-
- teardown: function() {
- // Only need this for delegated form submit events
- if ( jQuery.nodeName( this, "form" ) ) {
- return false;
- }
-
- // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
- jQuery.event.remove( this, "._submit" );
- }
- };
-}
+ if (!support.submitBubbles) {
+
+ jQuery.event.special.submit = {
+ setup: function () {
+ // Only need this for delegated form submit events
+ if (jQuery.nodeName(this, "form")) {
+ return false;
+ }
+
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
+ jQuery.event.add(this, "click._submit keypress._submit", function (e) {
+ // Node name check avoids a VML-related crash in IE (#9807)
+ var elem = e.target,
+ form = jQuery.nodeName(elem, "input") || jQuery.nodeName(elem, "button") ? elem.form : undefined;
+ if (form && !jQuery._data(form, "submitBubbles")) {
+ jQuery.event.add(form, "submit._submit", function (event) {
+ event._submit_bubble = true;
+ });
+ jQuery._data(form, "submitBubbles", true);
+ }
+ });
+ // return undefined since we don't need an event listener
+ },
+
+ postDispatch: function (event) {
+ // If form was submitted by the user, bubble the event up the tree
+ if (event._submit_bubble) {
+ delete event._submit_bubble;
+ if (this.parentNode && !event.isTrigger) {
+ jQuery.event.simulate("submit", this.parentNode, event, true);
+ }
+ }
+ },
+
+ teardown: function () {
+ // Only need this for delegated form submit events
+ if (jQuery.nodeName(this, "form")) {
+ return false;
+ }
+
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+ jQuery.event.remove(this, "._submit");
+ }
+ };
+ }
// IE change delegation and checkbox/radio fix
-if ( !support.changeBubbles ) {
-
- jQuery.event.special.change = {
-
- setup: function() {
-
- if ( rformElems.test( this.nodeName ) ) {
- // IE doesn't fire change on a check/radio until blur; trigger it on click
- // after a propertychange. Eat the blur-change in special.change.handle.
- // This still fires onchange a second time for check/radio after blur.
- if ( this.type === "checkbox" || this.type === "radio" ) {
- jQuery.event.add( this, "propertychange._change", function( event ) {
- if ( event.originalEvent.propertyName === "checked" ) {
- this._just_changed = true;
- }
- });
- jQuery.event.add( this, "click._change", function( event ) {
- if ( this._just_changed && !event.isTrigger ) {
- this._just_changed = false;
- }
- // Allow triggered, simulated change events (#11500)
- jQuery.event.simulate( "change", this, event, true );
- });
- }
- return false;
- }
- // Delegated event; lazy-add a change handler on descendant inputs
- jQuery.event.add( this, "beforeactivate._change", function( e ) {
- var elem = e.target;
-
- if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
- jQuery.event.add( elem, "change._change", function( event ) {
- if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
- jQuery.event.simulate( "change", this.parentNode, event, true );
- }
- });
- jQuery._data( elem, "changeBubbles", true );
- }
- });
- },
-
- handle: function( event ) {
- var elem = event.target;
-
- // Swallow native change events from checkbox/radio, we already triggered them above
- if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
- return event.handleObj.handler.apply( this, arguments );
- }
- },
-
- teardown: function() {
- jQuery.event.remove( this, "._change" );
-
- return !rformElems.test( this.nodeName );
- }
- };
-}
+ if (!support.changeBubbles) {
+
+ jQuery.event.special.change = {
+
+ setup: function () {
+
+ if (rformElems.test(this.nodeName)) {
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
+ // after a propertychange. Eat the blur-change in special.change.handle.
+ // This still fires onchange a second time for check/radio after blur.
+ if (this.type === "checkbox" || this.type === "radio") {
+ jQuery.event.add(this, "propertychange._change", function (event) {
+ if (event.originalEvent.propertyName === "checked") {
+ this._just_changed = true;
+ }
+ });
+ jQuery.event.add(this, "click._change", function (event) {
+ if (this._just_changed && !event.isTrigger) {
+ this._just_changed = false;
+ }
+ // Allow triggered, simulated change events (#11500)
+ jQuery.event.simulate("change", this, event, true);
+ });
+ }
+ return false;
+ }
+ // Delegated event; lazy-add a change handler on descendant inputs
+ jQuery.event.add(this, "beforeactivate._change", function (e) {
+ var elem = e.target;
+
+ if (rformElems.test(elem.nodeName) && !jQuery._data(elem, "changeBubbles")) {
+ jQuery.event.add(elem, "change._change", function (event) {
+ if (this.parentNode && !event.isSimulated && !event.isTrigger) {
+ jQuery.event.simulate("change", this.parentNode, event, true);
+ }
+ });
+ jQuery._data(elem, "changeBubbles", true);
+ }
+ });
+ },
+
+ handle: function (event) {
+ var elem = event.target;
+
+ // Swallow native change events from checkbox/radio, we already triggered them above
+ if (this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox")) {
+ return event.handleObj.handler.apply(this, arguments);
+ }
+ },
+
+ teardown: function () {
+ jQuery.event.remove(this, "._change");
+
+ return !rformElems.test(this.nodeName);
+ }
+ };
+ }
// Create "bubbling" focus and blur events
-if ( !support.focusinBubbles ) {
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
-
- // Attach a single capturing handler on the document while someone wants focusin/focusout
- var handler = function( event ) {
- jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
- };
-
- jQuery.event.special[ fix ] = {
- setup: function() {
- var doc = this.ownerDocument || this,
- attaches = jQuery._data( doc, fix );
-
- if ( !attaches ) {
- doc.addEventListener( orig, handler, true );
- }
- jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
- },
- teardown: function() {
- var doc = this.ownerDocument || this,
- attaches = jQuery._data( doc, fix ) - 1;
-
- if ( !attaches ) {
- doc.removeEventListener( orig, handler, true );
- jQuery._removeData( doc, fix );
- } else {
- jQuery._data( doc, fix, attaches );
- }
- }
- };
- });
-}
-
-jQuery.fn.extend({
-
- on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
- var type, origFn;
-
- // Types can be a map of types/handlers
- if ( typeof types === "object" ) {
- // ( types-Object, selector, data )
- if ( typeof selector !== "string" ) {
- // ( types-Object, data )
- data = data || selector;
- selector = undefined;
- }
- for ( type in types ) {
- this.on( type, selector, data, types[ type ], one );
- }
- return this;
- }
-
- if ( data == null && fn == null ) {
- // ( types, fn )
- fn = selector;
- data = selector = undefined;
- } else if ( fn == null ) {
- if ( typeof selector === "string" ) {
- // ( types, selector, fn )
- fn = data;
- data = undefined;
- } else {
- // ( types, data, fn )
- fn = data;
- data = selector;
- selector = undefined;
- }
- }
- if ( fn === false ) {
- fn = returnFalse;
- } else if ( !fn ) {
- return this;
- }
-
- if ( one === 1 ) {
- origFn = fn;
- fn = function( event ) {
- // Can use an empty set, since event contains the info
- jQuery().off( event );
- return origFn.apply( this, arguments );
- };
- // Use same guid so caller can remove using origFn
- fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
- }
- return this.each( function() {
- jQuery.event.add( this, types, fn, data, selector );
- });
- },
- one: function( types, selector, data, fn ) {
- return this.on( types, selector, data, fn, 1 );
- },
- off: function( types, selector, fn ) {
- var handleObj, type;
- if ( types && types.preventDefault && types.handleObj ) {
- // ( event ) dispatched jQuery.Event
- handleObj = types.handleObj;
- jQuery( types.delegateTarget ).off(
- handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
- handleObj.selector,
- handleObj.handler
- );
- return this;
- }
- if ( typeof types === "object" ) {
- // ( types-object [, selector] )
- for ( type in types ) {
- this.off( type, selector, types[ type ] );
- }
- return this;
- }
- if ( selector === false || typeof selector === "function" ) {
- // ( types [, fn] )
- fn = selector;
- selector = undefined;
- }
- if ( fn === false ) {
- fn = returnFalse;
- }
- return this.each(function() {
- jQuery.event.remove( this, types, fn, selector );
- });
- },
-
- trigger: function( type, data ) {
- return this.each(function() {
- jQuery.event.trigger( type, data, this );
- });
- },
- triggerHandler: function( type, data ) {
- var elem = this[0];
- if ( elem ) {
- return jQuery.event.trigger( type, data, elem, true );
- }
- }
-});
-
-
-function createSafeFragment( document ) {
- var list = nodeNames.split( "|" ),
- safeFrag = document.createDocumentFragment();
-
- if ( safeFrag.createElement ) {
- while ( list.length ) {
- safeFrag.createElement(
- list.pop()
- );
- }
- }
- return safeFrag;
-}
-
-var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
- "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
- rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
- rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
- rleadingWhitespace = /^\s+/,
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
- rtagName = /<([\w:]+)/,
- rtbody = /\s*$/g,
-
- // We have to close these tags to support XHTML (#13200)
- wrapMap = {
- option: [ 1, "", " " ],
- legend: [ 1, "", " " ],
- area: [ 1, "", " " ],
- param: [ 1, "", " " ],
- thead: [ 1, "" ],
- tr: [ 2, "" ],
- col: [ 2, "" ],
- td: [ 3, "" ],
-
- // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
- // unless wrapped in a div with non-breaking characters in front of it.
- _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X", "
" ]
- },
- safeFragment = createSafeFragment( document ),
- fragmentDiv = safeFragment.appendChild( document.createElement("div") );
-
-wrapMap.optgroup = wrapMap.option;
-wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
-wrapMap.th = wrapMap.td;
-
-function getAll( context, tag ) {
- var elems, elem,
- i = 0,
- found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
- typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
- undefined;
-
- if ( !found ) {
- for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
- if ( !tag || jQuery.nodeName( elem, tag ) ) {
- found.push( elem );
- } else {
- jQuery.merge( found, getAll( elem, tag ) );
- }
- }
- }
-
- return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
- jQuery.merge( [ context ], found ) :
- found;
-}
+ if (!support.focusinBubbles) {
+ jQuery.each({focus: "focusin", blur: "focusout"}, function (orig, fix) {
+
+ // Attach a single capturing handler on the document while someone wants focusin/focusout
+ var handler = function (event) {
+ jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true);
+ };
+
+ jQuery.event.special[fix] = {
+ setup: function () {
+ var doc = this.ownerDocument || this,
+ attaches = jQuery._data(doc, fix);
+
+ if (!attaches) {
+ doc.addEventListener(orig, handler, true);
+ }
+ jQuery._data(doc, fix, ( attaches || 0 ) + 1);
+ },
+ teardown: function () {
+ var doc = this.ownerDocument || this,
+ attaches = jQuery._data(doc, fix) - 1;
+
+ if (!attaches) {
+ doc.removeEventListener(orig, handler, true);
+ jQuery._removeData(doc, fix);
+ } else {
+ jQuery._data(doc, fix, attaches);
+ }
+ }
+ };
+ });
+ }
+
+ jQuery.fn.extend({
+
+ on: function (types, selector, data, fn, /*INTERNAL*/ one) {
+ var type, origFn;
+
+ // Types can be a map of types/handlers
+ if (typeof types === "object") {
+ // ( types-Object, selector, data )
+ if (typeof selector !== "string") {
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for (type in types) {
+ this.on(type, selector, data, types[type], one);
+ }
+ return this;
+ }
+
+ if (data == null && fn == null) {
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if (fn == null) {
+ if (typeof selector === "string") {
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if (fn === false) {
+ fn = returnFalse;
+ } else if (!fn) {
+ return this;
+ }
+
+ if (one === 1) {
+ origFn = fn;
+ fn = function (event) {
+ // Can use an empty set, since event contains the info
+ jQuery().off(event);
+ return origFn.apply(this, arguments);
+ };
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return this.each(function () {
+ jQuery.event.add(this, types, fn, data, selector);
+ });
+ },
+ one: function (types, selector, data, fn) {
+ return this.on(types, selector, data, fn, 1);
+ },
+ off: function (types, selector, fn) {
+ var handleObj, type;
+ if (types && types.preventDefault && types.handleObj) {
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery(types.delegateTarget).off(
+ handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if (typeof types === "object") {
+ // ( types-object [, selector] )
+ for (type in types) {
+ this.off(type, selector, types[type]);
+ }
+ return this;
+ }
+ if (selector === false || typeof selector === "function") {
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if (fn === false) {
+ fn = returnFalse;
+ }
+ return this.each(function () {
+ jQuery.event.remove(this, types, fn, selector);
+ });
+ },
+
+ trigger: function (type, data) {
+ return this.each(function () {
+ jQuery.event.trigger(type, data, this);
+ });
+ },
+ triggerHandler: function (type, data) {
+ var elem = this[0];
+ if (elem) {
+ return jQuery.event.trigger(type, data, elem, true);
+ }
+ }
+ });
+
+
+ function createSafeFragment(document) {
+ var list = nodeNames.split("|"),
+ safeFrag = document.createDocumentFragment();
+
+ if (safeFrag.createElement) {
+ while (list.length) {
+ safeFrag.createElement(
+ list.pop()
+ );
+ }
+ }
+ return safeFrag;
+ }
+
+ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+ "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
+ rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+ rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
+ rtagName = /<([\w:]+)/,
+ rtbody = / \s*$/g,
+
+ // We have to close these tags to support XHTML (#13200)
+ wrapMap = {
+ option: [1, "", " "],
+ legend: [1, "", " "],
+ area: [1, "", " "],
+ param: [1, "", " "],
+ thead: [1, ""],
+ tr: [2, ""],
+ col: [2, ""],
+ td: [3, ""],
+
+ // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+ // unless wrapped in a div with non-breaking characters in front of it.
+ _default: support.htmlSerialize ? [0, "", ""] : [1, "X", "
"]
+ },
+ safeFragment = createSafeFragment(document),
+ fragmentDiv = safeFragment.appendChild(document.createElement("div"));
+
+ wrapMap.optgroup = wrapMap.option;
+ wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+ wrapMap.th = wrapMap.td;
+
+ function getAll(context, tag) {
+ var elems, elem,
+ i = 0,
+ found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName(tag || "*") :
+ typeof context.querySelectorAll !== strundefined ? context.querySelectorAll(tag || "*") :
+ undefined;
+
+ if (!found) {
+ for (found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++) {
+ if (!tag || jQuery.nodeName(elem, tag)) {
+ found.push(elem);
+ } else {
+ jQuery.merge(found, getAll(elem, tag));
+ }
+ }
+ }
+
+ return tag === undefined || tag && jQuery.nodeName(context, tag) ?
+ jQuery.merge([context], found) :
+ found;
+ }
// Used in buildFragment, fixes the defaultChecked property
-function fixDefaultChecked( elem ) {
- if ( rcheckableType.test( elem.type ) ) {
- elem.defaultChecked = elem.checked;
- }
-}
+ function fixDefaultChecked(elem) {
+ if (rcheckableType.test(elem.type)) {
+ elem.defaultChecked = elem.checked;
+ }
+ }
// Support: IE<8
// Manipulating tables requires a tbody
-function manipulationTarget( elem, content ) {
- return jQuery.nodeName( elem, "table" ) &&
- jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
+ function manipulationTarget(elem, content) {
+ return jQuery.nodeName(elem, "table") &&
+ jQuery.nodeName(content.nodeType !== 11 ? content : content.firstChild, "tr") ?
- elem.getElementsByTagName("tbody")[0] ||
- elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
- elem;
-}
+ elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody")) :
+ elem;
+ }
// Replace/restore the type attribute of script elements for safe DOM manipulation
-function disableScript( elem ) {
- elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
- return elem;
-}
-function restoreScript( elem ) {
- var match = rscriptTypeMasked.exec( elem.type );
- if ( match ) {
- elem.type = match[1];
- } else {
- elem.removeAttribute("type");
- }
- return elem;
-}
+ function disableScript(elem) {
+ elem.type = (jQuery.find.attr(elem, "type") !== null) + "/" + elem.type;
+ return elem;
+ }
+
+ function restoreScript(elem) {
+ var match = rscriptTypeMasked.exec(elem.type);
+ if (match) {
+ elem.type = match[1];
+ } else {
+ elem.removeAttribute("type");
+ }
+ return elem;
+ }
// Mark scripts as having already been evaluated
-function setGlobalEval( elems, refElements ) {
- var elem,
- i = 0;
- for ( ; (elem = elems[i]) != null; i++ ) {
- jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
- }
-}
-
-function cloneCopyEvent( src, dest ) {
-
- if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
- return;
- }
-
- var type, i, l,
- oldData = jQuery._data( src ),
- curData = jQuery._data( dest, oldData ),
- events = oldData.events;
-
- if ( events ) {
- delete curData.handle;
- curData.events = {};
-
- for ( type in events ) {
- for ( i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ] );
- }
- }
- }
-
- // make the cloned public data object a copy from the original
- if ( curData.data ) {
- curData.data = jQuery.extend( {}, curData.data );
- }
-}
-
-function fixCloneNodeIssues( src, dest ) {
- var nodeName, e, data;
-
- // We do not need to do anything for non-Elements
- if ( dest.nodeType !== 1 ) {
- return;
- }
-
- nodeName = dest.nodeName.toLowerCase();
-
- // IE6-8 copies events bound via attachEvent when using cloneNode.
- if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
- data = jQuery._data( dest );
-
- for ( e in data.events ) {
- jQuery.removeEvent( dest, e, data.handle );
- }
-
- // Event data gets referenced instead of copied if the expando gets copied too
- dest.removeAttribute( jQuery.expando );
- }
-
- // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
- if ( nodeName === "script" && dest.text !== src.text ) {
- disableScript( dest ).text = src.text;
- restoreScript( dest );
-
- // IE6-10 improperly clones children of object elements using classid.
- // IE10 throws NoModificationAllowedError if parent is null, #12132.
- } else if ( nodeName === "object" ) {
- if ( dest.parentNode ) {
- dest.outerHTML = src.outerHTML;
- }
-
- // This path appears unavoidable for IE9. When cloning an object
- // element in IE9, the outerHTML strategy above is not sufficient.
- // If the src has innerHTML and the destination does not,
- // copy the src.innerHTML into the dest.innerHTML. #10324
- if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
- dest.innerHTML = src.innerHTML;
- }
-
- } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
- // IE6-8 fails to persist the checked state of a cloned checkbox
- // or radio button. Worse, IE6-7 fail to give the cloned element
- // a checked appearance if the defaultChecked value isn't also set
-
- dest.defaultChecked = dest.checked = src.checked;
-
- // IE6-7 get confused and end up setting the value of a cloned
- // checkbox/radio button to an empty string instead of "on"
- if ( dest.value !== src.value ) {
- dest.value = src.value;
- }
-
- // IE6-8 fails to return the selected option to the default selected
- // state when cloning options
- } else if ( nodeName === "option" ) {
- dest.defaultSelected = dest.selected = src.defaultSelected;
-
- // IE6-8 fails to set the defaultValue to the correct value when
- // cloning other types of input fields
- } else if ( nodeName === "input" || nodeName === "textarea" ) {
- dest.defaultValue = src.defaultValue;
- }
-}
-
-jQuery.extend({
- clone: function( elem, dataAndEvents, deepDataAndEvents ) {
- var destElements, node, clone, i, srcElements,
- inPage = jQuery.contains( elem.ownerDocument, elem );
-
- if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
- clone = elem.cloneNode( true );
-
- // IE<=8 does not properly clone detached, unknown element nodes
- } else {
- fragmentDiv.innerHTML = elem.outerHTML;
- fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
- }
-
- if ( (!support.noCloneEvent || !support.noCloneChecked) &&
- (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
-
- // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
- destElements = getAll( clone );
- srcElements = getAll( elem );
-
- // Fix all IE cloning issues
- for ( i = 0; (node = srcElements[i]) != null; ++i ) {
- // Ensure that the destination node is not null; Fixes #9587
- if ( destElements[i] ) {
- fixCloneNodeIssues( node, destElements[i] );
- }
- }
- }
-
- // Copy the events from the original to the clone
- if ( dataAndEvents ) {
- if ( deepDataAndEvents ) {
- srcElements = srcElements || getAll( elem );
- destElements = destElements || getAll( clone );
-
- for ( i = 0; (node = srcElements[i]) != null; i++ ) {
- cloneCopyEvent( node, destElements[i] );
- }
- } else {
- cloneCopyEvent( elem, clone );
- }
- }
-
- // Preserve script evaluation history
- destElements = getAll( clone, "script" );
- if ( destElements.length > 0 ) {
- setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
- }
-
- destElements = srcElements = node = null;
-
- // Return the cloned set
- return clone;
- },
-
- buildFragment: function( elems, context, scripts, selection ) {
- var j, elem, contains,
- tmp, tag, tbody, wrap,
- l = elems.length,
-
- // Ensure a safe fragment
- safe = createSafeFragment( context ),
-
- nodes = [],
- i = 0;
-
- for ( ; i < l; i++ ) {
- elem = elems[ i ];
-
- if ( elem || elem === 0 ) {
-
- // Add nodes directly
- if ( jQuery.type( elem ) === "object" ) {
- jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
-
- // Convert non-html into a text node
- } else if ( !rhtml.test( elem ) ) {
- nodes.push( context.createTextNode( elem ) );
-
- // Convert html into DOM nodes
- } else {
- tmp = tmp || safe.appendChild( context.createElement("div") );
-
- // Deserialize a standard representation
- tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
- wrap = wrapMap[ tag ] || wrapMap._default;
-
- tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>$2>" ) + wrap[2];
-
- // Descend through wrappers to the right content
- j = wrap[0];
- while ( j-- ) {
- tmp = tmp.lastChild;
- }
-
- // Manually add leading whitespace removed by IE
- if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
- }
-
- // Remove IE's autoinserted from table fragments
- if ( !support.tbody ) {
-
- // String was a , *may* have spurious
- elem = tag === "table" && !rtbody.test( elem ) ?
- tmp.firstChild :
-
- // String was a bare or
- wrap[1] === "" && !rtbody.test( elem ) ?
- tmp :
- 0;
-
- j = elem && elem.childNodes.length;
- while ( j-- ) {
- if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
- elem.removeChild( tbody );
- }
- }
- }
-
- jQuery.merge( nodes, tmp.childNodes );
-
- // Fix #12392 for WebKit and IE > 9
- tmp.textContent = "";
-
- // Fix #12392 for oldIE
- while ( tmp.firstChild ) {
- tmp.removeChild( tmp.firstChild );
- }
-
- // Remember the top-level container for proper cleanup
- tmp = safe.lastChild;
- }
- }
- }
-
- // Fix #11356: Clear elements from fragment
- if ( tmp ) {
- safe.removeChild( tmp );
- }
-
- // Reset defaultChecked for any radios and checkboxes
- // about to be appended to the DOM in IE 6/7 (#8060)
- if ( !support.appendChecked ) {
- jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
- }
-
- i = 0;
- while ( (elem = nodes[ i++ ]) ) {
-
- // #4087 - If origin and destination elements are the same, and this is
- // that element, do not do anything
- if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
- continue;
- }
-
- contains = jQuery.contains( elem.ownerDocument, elem );
-
- // Append to fragment
- tmp = getAll( safe.appendChild( elem ), "script" );
-
- // Preserve script evaluation history
- if ( contains ) {
- setGlobalEval( tmp );
- }
-
- // Capture executables
- if ( scripts ) {
- j = 0;
- while ( (elem = tmp[ j++ ]) ) {
- if ( rscriptType.test( elem.type || "" ) ) {
- scripts.push( elem );
- }
- }
- }
- }
-
- tmp = null;
-
- return safe;
- },
-
- cleanData: function( elems, /* internal */ acceptData ) {
- var elem, type, id, data,
- i = 0,
- internalKey = jQuery.expando,
- cache = jQuery.cache,
- deleteExpando = support.deleteExpando,
- special = jQuery.event.special;
-
- for ( ; (elem = elems[i]) != null; i++ ) {
- if ( acceptData || jQuery.acceptData( elem ) ) {
-
- id = elem[ internalKey ];
- data = id && cache[ id ];
-
- if ( data ) {
- if ( data.events ) {
- for ( type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
-
- // This is a shortcut to avoid jQuery.event.remove's overhead
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- }
-
- // Remove cache only if it was not already removed by jQuery.event.remove
- if ( cache[ id ] ) {
-
- delete cache[ id ];
-
- // IE does not allow us to delete expando properties from nodes,
- // nor does it have a removeAttribute function on Document nodes;
- // we must handle all of these cases
- if ( deleteExpando ) {
- delete elem[ internalKey ];
-
- } else if ( typeof elem.removeAttribute !== strundefined ) {
- elem.removeAttribute( internalKey );
-
- } else {
- elem[ internalKey ] = null;
- }
-
- deletedIds.push( id );
- }
- }
- }
- }
- }
-});
-
-jQuery.fn.extend({
- text: function( value ) {
- return access( this, function( value ) {
- return value === undefined ?
- jQuery.text( this ) :
- this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
- }, null, value, arguments.length );
- },
-
- append: function() {
- return this.domManip( arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.appendChild( elem );
- }
- });
- },
-
- prepend: function() {
- return this.domManip( arguments, function( elem ) {
- if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
- var target = manipulationTarget( this, elem );
- target.insertBefore( elem, target.firstChild );
- }
- });
- },
-
- before: function() {
- return this.domManip( arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this );
- }
- });
- },
-
- after: function() {
- return this.domManip( arguments, function( elem ) {
- if ( this.parentNode ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- }
- });
- },
-
- remove: function( selector, keepData /* Internal Use Only */ ) {
- var elem,
- elems = selector ? jQuery.filter( selector, this ) : this,
- i = 0;
-
- for ( ; (elem = elems[i]) != null; i++ ) {
-
- if ( !keepData && elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem ) );
- }
-
- if ( elem.parentNode ) {
- if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
- setGlobalEval( getAll( elem, "script" ) );
- }
- elem.parentNode.removeChild( elem );
- }
- }
-
- return this;
- },
-
- empty: function() {
- var elem,
- i = 0;
-
- for ( ; (elem = this[i]) != null; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem, false ) );
- }
-
- // Remove any remaining nodes
- while ( elem.firstChild ) {
- elem.removeChild( elem.firstChild );
- }
-
- // If this is a select, ensure that it displays empty (#12336)
- // Support: IE<9
- if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
- elem.options.length = 0;
- }
- }
-
- return this;
- },
-
- clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
-
- return this.map(function() {
- return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
- });
- },
-
- html: function( value ) {
- return access( this, function( value ) {
- var elem = this[ 0 ] || {},
- i = 0,
- l = this.length;
-
- if ( value === undefined ) {
- return elem.nodeType === 1 ?
- elem.innerHTML.replace( rinlinejQuery, "" ) :
- undefined;
- }
-
- // See if we can take a shortcut and just use innerHTML
- if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
- ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
- ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
- !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
-
- value = value.replace( rxhtmlTag, "<$1>$2>" );
-
- try {
- for (; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- elem = this[i] || {};
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( getAll( elem, false ) );
- elem.innerHTML = value;
- }
- }
-
- elem = 0;
-
- // If using innerHTML throws an exception, use the fallback method
- } catch(e) {}
- }
-
- if ( elem ) {
- this.empty().append( value );
- }
- }, null, value, arguments.length );
- },
-
- replaceWith: function() {
- var arg = arguments[ 0 ];
-
- // Make the changes, replacing each context element with the new content
- this.domManip( arguments, function( elem ) {
- arg = this.parentNode;
-
- jQuery.cleanData( getAll( this ) );
-
- if ( arg ) {
- arg.replaceChild( elem, this );
- }
- });
-
- // Force removal if there was no new content (e.g., from empty arguments)
- return arg && (arg.length || arg.nodeType) ? this : this.remove();
- },
-
- detach: function( selector ) {
- return this.remove( selector, true );
- },
-
- domManip: function( args, callback ) {
-
- // Flatten any nested arrays
- args = concat.apply( [], args );
-
- var first, node, hasScripts,
- scripts, doc, fragment,
- i = 0,
- l = this.length,
- set = this,
- iNoClone = l - 1,
- value = args[0],
- isFunction = jQuery.isFunction( value );
-
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( isFunction ||
- ( l > 1 && typeof value === "string" &&
- !support.checkClone && rchecked.test( value ) ) ) {
- return this.each(function( index ) {
- var self = set.eq( index );
- if ( isFunction ) {
- args[0] = value.call( this, index, self.html() );
- }
- self.domManip( args, callback );
- });
- }
-
- if ( l ) {
- fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
- first = fragment.firstChild;
-
- if ( fragment.childNodes.length === 1 ) {
- fragment = first;
- }
-
- if ( first ) {
- scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
- hasScripts = scripts.length;
-
- // Use the original fragment for the last item instead of the first because it can end up
- // being emptied incorrectly in certain situations (#8070).
- for ( ; i < l; i++ ) {
- node = fragment;
-
- if ( i !== iNoClone ) {
- node = jQuery.clone( node, true, true );
-
- // Keep references to cloned scripts for later restoration
- if ( hasScripts ) {
- jQuery.merge( scripts, getAll( node, "script" ) );
- }
- }
-
- callback.call( this[i], node, i );
- }
-
- if ( hasScripts ) {
- doc = scripts[ scripts.length - 1 ].ownerDocument;
-
- // Reenable scripts
- jQuery.map( scripts, restoreScript );
-
- // Evaluate executable scripts on first document insertion
- for ( i = 0; i < hasScripts; i++ ) {
- node = scripts[ i ];
- if ( rscriptType.test( node.type || "" ) &&
- !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
-
- if ( node.src ) {
- // Optional AJAX dependency, but won't run scripts if not present
- if ( jQuery._evalUrl ) {
- jQuery._evalUrl( node.src );
- }
- } else {
- jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
- }
- }
- }
- }
-
- // Fix #11809: Avoid leaking memory
- fragment = first = null;
- }
- }
-
- return this;
- }
-});
-
-jQuery.each({
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
-}, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var elems,
- i = 0,
- ret = [],
- insert = jQuery( selector ),
- last = insert.length - 1;
-
- for ( ; i <= last; i++ ) {
- elems = i === last ? this : this.clone(true);
- jQuery( insert[i] )[ original ]( elems );
-
- // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
- push.apply( ret, elems.get() );
- }
-
- return this.pushStack( ret );
- };
-});
-
-
-var iframe,
- elemdisplay = {};
-
-/**
- * Retrieve the actual display of a element
- * @param {String} name nodeName of the element
- * @param {Object} doc Document object
- */
+ function setGlobalEval(elems, refElements) {
+ var elem,
+ i = 0;
+ for (; (elem = elems[i]) != null; i++) {
+ jQuery._data(elem, "globalEval", !refElements || jQuery._data(refElements[i], "globalEval"));
+ }
+ }
+
+ function cloneCopyEvent(src, dest) {
+
+ if (dest.nodeType !== 1 || !jQuery.hasData(src)) {
+ return;
+ }
+
+ var type, i, l,
+ oldData = jQuery._data(src),
+ curData = jQuery._data(dest, oldData),
+ events = oldData.events;
+
+ if (events) {
+ delete curData.handle;
+ curData.events = {};
+
+ for (type in events) {
+ for (i = 0, l = events[type].length; i < l; i++) {
+ jQuery.event.add(dest, type, events[type][i]);
+ }
+ }
+ }
+
+ // make the cloned public data object a copy from the original
+ if (curData.data) {
+ curData.data = jQuery.extend({}, curData.data);
+ }
+ }
+
+ function fixCloneNodeIssues(src, dest) {
+ var nodeName, e, data;
+
+ // We do not need to do anything for non-Elements
+ if (dest.nodeType !== 1) {
+ return;
+ }
+
+ nodeName = dest.nodeName.toLowerCase();
+
+ // IE6-8 copies events bound via attachEvent when using cloneNode.
+ if (!support.noCloneEvent && dest[jQuery.expando]) {
+ data = jQuery._data(dest);
+
+ for (e in data.events) {
+ jQuery.removeEvent(dest, e, data.handle);
+ }
+
+ // Event data gets referenced instead of copied if the expando gets copied too
+ dest.removeAttribute(jQuery.expando);
+ }
+
+ // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
+ if (nodeName === "script" && dest.text !== src.text) {
+ disableScript(dest).text = src.text;
+ restoreScript(dest);
+
+ // IE6-10 improperly clones children of object elements using classid.
+ // IE10 throws NoModificationAllowedError if parent is null, #12132.
+ } else if (nodeName === "object") {
+ if (dest.parentNode) {
+ dest.outerHTML = src.outerHTML;
+ }
+
+ // This path appears unavoidable for IE9. When cloning an object
+ // element in IE9, the outerHTML strategy above is not sufficient.
+ // If the src has innerHTML and the destination does not,
+ // copy the src.innerHTML into the dest.innerHTML. #10324
+ if (support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) )) {
+ dest.innerHTML = src.innerHTML;
+ }
+
+ } else if (nodeName === "input" && rcheckableType.test(src.type)) {
+ // IE6-8 fails to persist the checked state of a cloned checkbox
+ // or radio button. Worse, IE6-7 fail to give the cloned element
+ // a checked appearance if the defaultChecked value isn't also set
+
+ dest.defaultChecked = dest.checked = src.checked;
+
+ // IE6-7 get confused and end up setting the value of a cloned
+ // checkbox/radio button to an empty string instead of "on"
+ if (dest.value !== src.value) {
+ dest.value = src.value;
+ }
+
+ // IE6-8 fails to return the selected option to the default selected
+ // state when cloning options
+ } else if (nodeName === "option") {
+ dest.defaultSelected = dest.selected = src.defaultSelected;
+
+ // IE6-8 fails to set the defaultValue to the correct value when
+ // cloning other types of input fields
+ } else if (nodeName === "input" || nodeName === "textarea") {
+ dest.defaultValue = src.defaultValue;
+ }
+ }
+
+ jQuery.extend({
+ clone: function (elem, dataAndEvents, deepDataAndEvents) {
+ var destElements, node, clone, i, srcElements,
+ inPage = jQuery.contains(elem.ownerDocument, elem);
+
+ if (support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test("<" + elem.nodeName + ">")) {
+ clone = elem.cloneNode(true);
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild(clone = fragmentDiv.firstChild);
+ }
+
+ if ((!support.noCloneEvent || !support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
+
+ // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
+ destElements = getAll(clone);
+ srcElements = getAll(elem);
+
+ // Fix all IE cloning issues
+ for (i = 0; (node = srcElements[i]) != null; ++i) {
+ // Ensure that the destination node is not null; Fixes #9587
+ if (destElements[i]) {
+ fixCloneNodeIssues(node, destElements[i]);
+ }
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if (dataAndEvents) {
+ if (deepDataAndEvents) {
+ srcElements = srcElements || getAll(elem);
+ destElements = destElements || getAll(clone);
+
+ for (i = 0; (node = srcElements[i]) != null; i++) {
+ cloneCopyEvent(node, destElements[i]);
+ }
+ } else {
+ cloneCopyEvent(elem, clone);
+ }
+ }
+
+ // Preserve script evaluation history
+ destElements = getAll(clone, "script");
+ if (destElements.length > 0) {
+ setGlobalEval(destElements, !inPage && getAll(elem, "script"));
+ }
+
+ destElements = srcElements = node = null;
+
+ // Return the cloned set
+ return clone;
+ },
+
+ buildFragment: function (elems, context, scripts, selection) {
+ var j, elem, contains,
+ tmp, tag, tbody, wrap,
+ l = elems.length,
+
+ // Ensure a safe fragment
+ safe = createSafeFragment(context),
+
+ nodes = [],
+ i = 0;
+
+ for (; i < l; i++) {
+ elem = elems[i];
+
+ if (elem || elem === 0) {
+
+ // Add nodes directly
+ if (jQuery.type(elem) === "object") {
+ jQuery.merge(nodes, elem.nodeType ? [elem] : elem);
+
+ // Convert non-html into a text node
+ } else if (!rhtml.test(elem)) {
+ nodes.push(context.createTextNode(elem));
+
+ // Convert html into DOM nodes
+ } else {
+ tmp = tmp || safe.appendChild(context.createElement("div"));
+
+ // Deserialize a standard representation
+ tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
+ wrap = wrapMap[tag] || wrapMap._default;
+
+ tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1>$2>") + wrap[2];
+
+ // Descend through wrappers to the right content
+ j = wrap[0];
+ while (j--) {
+ tmp = tmp.lastChild;
+ }
+
+ // Manually add leading whitespace removed by IE
+ if (!support.leadingWhitespace && rleadingWhitespace.test(elem)) {
+ nodes.push(context.createTextNode(rleadingWhitespace.exec(elem)[0]));
+ }
+
+ // Remove IE's autoinserted from table fragments
+ if (!support.tbody) {
+
+ // String was a , *may* have spurious
+ elem = tag === "table" && !rtbody.test(elem) ?
+ tmp.firstChild :
+
+ // String was a bare or
+ wrap[1] === "" && !rtbody.test(elem) ?
+ tmp :
+ 0;
+
+ j = elem && elem.childNodes.length;
+ while (j--) {
+ if (jQuery.nodeName((tbody = elem.childNodes[j]), "tbody") && !tbody.childNodes.length) {
+ elem.removeChild(tbody);
+ }
+ }
+ }
+
+ jQuery.merge(nodes, tmp.childNodes);
+
+ // Fix #12392 for WebKit and IE > 9
+ tmp.textContent = "";
+
+ // Fix #12392 for oldIE
+ while (tmp.firstChild) {
+ tmp.removeChild(tmp.firstChild);
+ }
+
+ // Remember the top-level container for proper cleanup
+ tmp = safe.lastChild;
+ }
+ }
+ }
+
+ // Fix #11356: Clear elements from fragment
+ if (tmp) {
+ safe.removeChild(tmp);
+ }
+
+ // Reset defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ if (!support.appendChecked) {
+ jQuery.grep(getAll(nodes, "input"), fixDefaultChecked);
+ }
+
+ i = 0;
+ while ((elem = nodes[i++])) {
+
+ // #4087 - If origin and destination elements are the same, and this is
+ // that element, do not do anything
+ if (selection && jQuery.inArray(elem, selection) !== -1) {
+ continue;
+ }
+
+ contains = jQuery.contains(elem.ownerDocument, elem);
+
+ // Append to fragment
+ tmp = getAll(safe.appendChild(elem), "script");
+
+ // Preserve script evaluation history
+ if (contains) {
+ setGlobalEval(tmp);
+ }
+
+ // Capture executables
+ if (scripts) {
+ j = 0;
+ while ((elem = tmp[j++])) {
+ if (rscriptType.test(elem.type || "")) {
+ scripts.push(elem);
+ }
+ }
+ }
+ }
+
+ tmp = null;
+
+ return safe;
+ },
+
+ cleanData: function (elems, /* internal */ acceptData) {
+ var elem, type, id, data,
+ i = 0,
+ internalKey = jQuery.expando,
+ cache = jQuery.cache,
+ deleteExpando = support.deleteExpando,
+ special = jQuery.event.special;
+
+ for (; (elem = elems[i]) != null; i++) {
+ if (acceptData || jQuery.acceptData(elem)) {
+
+ id = elem[internalKey];
+ data = id && cache[id];
+
+ if (data) {
+ if (data.events) {
+ for (type in data.events) {
+ if (special[type]) {
+ jQuery.event.remove(elem, type);
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent(elem, type, data.handle);
+ }
+ }
+ }
+
+ // Remove cache only if it was not already removed by jQuery.event.remove
+ if (cache[id]) {
+
+ delete cache[id];
+
+ // IE does not allow us to delete expando properties from nodes,
+ // nor does it have a removeAttribute function on Document nodes;
+ // we must handle all of these cases
+ if (deleteExpando) {
+ delete elem[internalKey];
+
+ } else if (typeof elem.removeAttribute !== strundefined) {
+ elem.removeAttribute(internalKey);
+
+ } else {
+ elem[internalKey] = null;
+ }
+
+ deletedIds.push(id);
+ }
+ }
+ }
+ }
+ }
+ });
+
+ jQuery.fn.extend({
+ text: function (value) {
+ return access(this, function (value) {
+ return value === undefined ?
+ jQuery.text(this) :
+ this.empty().append(( this[0] && this[0].ownerDocument || document ).createTextNode(value));
+ }, null, value, arguments.length);
+ },
+
+ append: function () {
+ return this.domManip(arguments, function (elem) {
+ if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
+ var target = manipulationTarget(this, elem);
+ target.appendChild(elem);
+ }
+ });
+ },
+
+ prepend: function () {
+ return this.domManip(arguments, function (elem) {
+ if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) {
+ var target = manipulationTarget(this, elem);
+ target.insertBefore(elem, target.firstChild);
+ }
+ });
+ },
+
+ before: function () {
+ return this.domManip(arguments, function (elem) {
+ if (this.parentNode) {
+ this.parentNode.insertBefore(elem, this);
+ }
+ });
+ },
+
+ after: function () {
+ return this.domManip(arguments, function (elem) {
+ if (this.parentNode) {
+ this.parentNode.insertBefore(elem, this.nextSibling);
+ }
+ });
+ },
+
+ remove: function (selector, keepData /* Internal Use Only */) {
+ var elem,
+ elems = selector ? jQuery.filter(selector, this) : this,
+ i = 0;
+
+ for (; (elem = elems[i]) != null; i++) {
+
+ if (!keepData && elem.nodeType === 1) {
+ jQuery.cleanData(getAll(elem));
+ }
+
+ if (elem.parentNode) {
+ if (keepData && jQuery.contains(elem.ownerDocument, elem)) {
+ setGlobalEval(getAll(elem, "script"));
+ }
+ elem.parentNode.removeChild(elem);
+ }
+ }
+
+ return this;
+ },
+
+ empty: function () {
+ var elem,
+ i = 0;
+
+ for (; (elem = this[i]) != null; i++) {
+ // Remove element nodes and prevent memory leaks
+ if (elem.nodeType === 1) {
+ jQuery.cleanData(getAll(elem, false));
+ }
+
+ // Remove any remaining nodes
+ while (elem.firstChild) {
+ elem.removeChild(elem.firstChild);
+ }
+
+ // If this is a select, ensure that it displays empty (#12336)
+ // Support: IE<9
+ if (elem.options && jQuery.nodeName(elem, "select")) {
+ elem.options.length = 0;
+ }
+ }
+
+ return this;
+ },
+
+ clone: function (dataAndEvents, deepDataAndEvents) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map(function () {
+ return jQuery.clone(this, dataAndEvents, deepDataAndEvents);
+ });
+ },
+
+ html: function (value) {
+ return access(this, function (value) {
+ var elem = this[0] || {},
+ i = 0,
+ l = this.length;
+
+ if (value === undefined) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace(rinlinejQuery, "") :
+ undefined;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if (typeof value === "string" && !rnoInnerhtml.test(value) &&
+ ( support.htmlSerialize || !rnoshimcache.test(value) ) &&
+ ( support.leadingWhitespace || !rleadingWhitespace.test(value) ) && !wrapMap[(rtagName.exec(value) || ["", ""])[1].toLowerCase()]) {
+
+ value = value.replace(rxhtmlTag, "<$1>$2>");
+
+ try {
+ for (; i < l; i++) {
+ // Remove element nodes and prevent memory leaks
+ elem = this[i] || {};
+ if (elem.nodeType === 1) {
+ jQuery.cleanData(getAll(elem, false));
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch (e) {
+ }
+ }
+
+ if (elem) {
+ this.empty().append(value);
+ }
+ }, null, value, arguments.length);
+ },
+
+ replaceWith: function () {
+ var arg = arguments[0];
+
+ // Make the changes, replacing each context element with the new content
+ this.domManip(arguments, function (elem) {
+ arg = this.parentNode;
+
+ jQuery.cleanData(getAll(this));
+
+ if (arg) {
+ arg.replaceChild(elem, this);
+ }
+ });
+
+ // Force removal if there was no new content (e.g., from empty arguments)
+ return arg && (arg.length || arg.nodeType) ? this : this.remove();
+ },
+
+ detach: function (selector) {
+ return this.remove(selector, true);
+ },
+
+ domManip: function (args, callback) {
+
+ // Flatten any nested arrays
+ args = concat.apply([], args);
+
+ var first, node, hasScripts,
+ scripts, doc, fragment,
+ i = 0,
+ l = this.length,
+ set = this,
+ iNoClone = l - 1,
+ value = args[0],
+ isFunction = jQuery.isFunction(value);
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if (isFunction ||
+ ( l > 1 && typeof value === "string" && !support.checkClone && rchecked.test(value) )) {
+ return this.each(function (index) {
+ var self = set.eq(index);
+ if (isFunction) {
+ args[0] = value.call(this, index, self.html());
+ }
+ self.domManip(args, callback);
+ });
+ }
+
+ if (l) {
+ fragment = jQuery.buildFragment(args, this[0].ownerDocument, false, this);
+ first = fragment.firstChild;
+
+ if (fragment.childNodes.length === 1) {
+ fragment = first;
+ }
+
+ if (first) {
+ scripts = jQuery.map(getAll(fragment, "script"), disableScript);
+ hasScripts = scripts.length;
+
+ // Use the original fragment for the last item instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ for (; i < l; i++) {
+ node = fragment;
+
+ if (i !== iNoClone) {
+ node = jQuery.clone(node, true, true);
+
+ // Keep references to cloned scripts for later restoration
+ if (hasScripts) {
+ jQuery.merge(scripts, getAll(node, "script"));
+ }
+ }
+
+ callback.call(this[i], node, i);
+ }
+
+ if (hasScripts) {
+ doc = scripts[scripts.length - 1].ownerDocument;
+
+ // Reenable scripts
+ jQuery.map(scripts, restoreScript);
+
+ // Evaluate executable scripts on first document insertion
+ for (i = 0; i < hasScripts; i++) {
+ node = scripts[i];
+ if (rscriptType.test(node.type || "") && !jQuery._data(node, "globalEval") && jQuery.contains(doc, node)) {
+
+ if (node.src) {
+ // Optional AJAX dependency, but won't run scripts if not present
+ if (jQuery._evalUrl) {
+ jQuery._evalUrl(node.src);
+ }
+ } else {
+ jQuery.globalEval(( node.text || node.textContent || node.innerHTML || "" ).replace(rcleanScript, ""));
+ }
+ }
+ }
+ }
+
+ // Fix #11809: Avoid leaking memory
+ fragment = first = null;
+ }
+ }
+
+ return this;
+ }
+ });
+
+ jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+ }, function (name, original) {
+ jQuery.fn[name] = function (selector) {
+ var elems,
+ i = 0,
+ ret = [],
+ insert = jQuery(selector),
+ last = insert.length - 1;
+
+ for (; i <= last; i++) {
+ elems = i === last ? this : this.clone(true);
+ jQuery(insert[i])[original](elems);
+
+ // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
+ push.apply(ret, elems.get());
+ }
+
+ return this.pushStack(ret);
+ };
+ });
+
+
+ var iframe,
+ elemdisplay = {};
+
+ /**
+ * Retrieve the actual display of a element
+ * @param {String} name nodeName of the element
+ * @param {Object} doc Document object
+ */
// Called only from within defaultDisplay
-function actualDisplay( name, doc ) {
- var style,
- elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
-
- // getDefaultComputedStyle might be reliably used only on attached element
- display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
-
- // Use of this method is a temporary fix (more like optmization) until something better comes along,
- // since it was removed from specification and supported only in FF
- style.display : jQuery.css( elem[ 0 ], "display" );
-
- // We don't have any data stored on the element,
- // so use "detach" method as fast way to get rid of the element
- elem.detach();
-
- return display;
-}
-
-/**
- * Try to determine the default display value of an element
- * @param {String} nodeName
- */
-function defaultDisplay( nodeName ) {
- var doc = document,
- display = elemdisplay[ nodeName ];
+ function actualDisplay(name, doc) {
+ var style,
+ elem = jQuery(doc.createElement(name)).appendTo(doc.body),
- if ( !display ) {
- display = actualDisplay( nodeName, doc );
+ // getDefaultComputedStyle might be reliably used only on attached element
+ display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle(elem[0]) ) ?
- // If the simple way fails, read from inside an iframe
- if ( display === "none" || !display ) {
+ // Use of this method is a temporary fix (more like optmization) until something better comes along,
+ // since it was removed from specification and supported only in FF
+ style.display : jQuery.css(elem[0], "display");
- // Use the already-created iframe if possible
- iframe = (iframe || jQuery( "" )).appendTo( doc.documentElement );
+ // We don't have any data stored on the element,
+ // so use "detach" method as fast way to get rid of the element
+ elem.detach();
- // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
- doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
+ return display;
+ }
- // Support: IE
- doc.write();
- doc.close();
+ /**
+ * Try to determine the default display value of an element
+ * @param {String} nodeName
+ */
+ function defaultDisplay(nodeName) {
+ var doc = document,
+ display = elemdisplay[nodeName];
- display = actualDisplay( nodeName, doc );
- iframe.detach();
- }
+ if (!display) {
+ display = actualDisplay(nodeName, doc);
- // Store the correct default display
- elemdisplay[ nodeName ] = display;
- }
+ // If the simple way fails, read from inside an iframe
+ if (display === "none" || !display) {
- return display;
-}
+ // Use the already-created iframe if possible
+ iframe = (iframe || jQuery("")).appendTo(doc.documentElement);
+ // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
+ doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
-(function() {
- var shrinkWrapBlocksVal;
+ // Support: IE
+ doc.write();
+ doc.close();
- support.shrinkWrapBlocks = function() {
- if ( shrinkWrapBlocksVal != null ) {
- return shrinkWrapBlocksVal;
- }
+ display = actualDisplay(nodeName, doc);
+ iframe.detach();
+ }
- // Will be changed later if needed.
- shrinkWrapBlocksVal = false;
+ // Store the correct default display
+ elemdisplay[nodeName] = display;
+ }
- // Minified: var b,c,d
- var div, body, container;
+ return display;
+ }
- body = document.getElementsByTagName( "body" )[ 0 ];
- if ( !body || !body.style ) {
- // Test fired too early or in an unsupported environment, exit.
- return;
- }
-
- // Setup
- div = document.createElement( "div" );
- container = document.createElement( "div" );
- container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
- body.appendChild( container ).appendChild( div );
- // Support: IE6
- // Check if elements with layout shrink-wrap their children
- if ( typeof div.style.zoom !== strundefined ) {
- // Reset CSS: box-sizing; display; margin; border
- div.style.cssText =
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
- "box-sizing:content-box;display:block;margin:0;border:0;" +
- "padding:1px;width:1px;zoom:1";
- div.appendChild( document.createElement( "div" ) ).style.width = "5px";
- shrinkWrapBlocksVal = div.offsetWidth !== 3;
- }
-
- body.removeChild( container );
-
- return shrinkWrapBlocksVal;
- };
-
-})();
-var rmargin = (/^margin/);
-
-var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
-
-
-
-var getStyles, curCSS,
- rposition = /^(top|right|bottom|left)$/;
-
-if ( window.getComputedStyle ) {
- getStyles = function( elem ) {
- return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
- };
-
- curCSS = function( elem, name, computed ) {
- var width, minWidth, maxWidth, ret,
- style = elem.style;
-
- computed = computed || getStyles( elem );
-
- // getPropertyValue is only needed for .css('filter') in IE9, see #12537
- ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
-
- if ( computed ) {
-
- if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
- ret = jQuery.style( elem, name );
- }
-
- // A tribute to the "awesome hack by Dean Edwards"
- // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
- // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
- // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
- if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
-
- // Remember the original values
- width = style.width;
- minWidth = style.minWidth;
- maxWidth = style.maxWidth;
-
- // Put in the new values to get a computed value out
- style.minWidth = style.maxWidth = style.width = ret;
- ret = computed.width;
-
- // Revert the changed values
- style.width = width;
- style.minWidth = minWidth;
- style.maxWidth = maxWidth;
- }
- }
-
- // Support: IE
- // IE returns zIndex value as an integer.
- return ret === undefined ?
- ret :
- ret + "";
- };
-} else if ( document.documentElement.currentStyle ) {
- getStyles = function( elem ) {
- return elem.currentStyle;
- };
-
- curCSS = function( elem, name, computed ) {
- var left, rs, rsLeft, ret,
- style = elem.style;
-
- computed = computed || getStyles( elem );
- ret = computed ? computed[ name ] : undefined;
-
- // Avoid setting ret to empty string here
- // so we don't default to auto
- if ( ret == null && style && style[ name ] ) {
- ret = style[ name ];
- }
-
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
-
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- // but not position css attributes, as those are proportional to the parent element instead
- // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
- if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
-
- // Remember the original values
- left = style.left;
- rs = elem.runtimeStyle;
- rsLeft = rs && rs.left;
-
- // Put in the new values to get a computed value out
- if ( rsLeft ) {
- rs.left = elem.currentStyle.left;
- }
- style.left = name === "fontSize" ? "1em" : ret;
- ret = style.pixelLeft + "px";
-
- // Revert the changed values
- style.left = left;
- if ( rsLeft ) {
- rs.left = rsLeft;
- }
- }
-
- // Support: IE
- // IE returns zIndex value as an integer.
- return ret === undefined ?
- ret :
- ret + "" || "auto";
- };
-}
-
-
-
-
-function addGetHookIf( conditionFn, hookFn ) {
- // Define the hook, we'll check on the first run if it's really needed.
- return {
- get: function() {
- var condition = conditionFn();
-
- if ( condition == null ) {
- // The test was not ready at this point; screw the hook this time
- // but check again when needed next time.
- return;
- }
-
- if ( condition ) {
- // Hook not needed (or it's not possible to use it due to missing dependency),
- // remove it.
- // Since there are no other hooks for marginRight, remove the whole object.
- delete this.get;
- return;
- }
-
- // Hook needed; redefine it so that the support test is not executed again.
-
- return (this.get = hookFn).apply( this, arguments );
- }
- };
-}
-
-
-(function() {
- // Minified: var b,c,d,e,f,g, h,i
- var div, style, a, pixelPositionVal, boxSizingReliableVal,
- reliableHiddenOffsetsVal, reliableMarginRightVal;
-
- // Setup
- div = document.createElement( "div" );
- div.innerHTML = " a ";
- a = div.getElementsByTagName( "a" )[ 0 ];
- style = a && a.style;
-
- // Finish early in limited (non-browser) environments
- if ( !style ) {
- return;
- }
-
- style.cssText = "float:left;opacity:.5";
-
- // Support: IE<9
- // Make sure that element opacity exists (as opposed to filter)
- support.opacity = style.opacity === "0.5";
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- support.cssFloat = !!style.cssFloat;
-
- div.style.backgroundClip = "content-box";
- div.cloneNode( true ).style.backgroundClip = "";
- support.clearCloneStyle = div.style.backgroundClip === "content-box";
-
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
- style.WebkitBoxSizing === "";
-
- jQuery.extend(support, {
- reliableHiddenOffsets: function() {
- if ( reliableHiddenOffsetsVal == null ) {
- computeStyleTests();
- }
- return reliableHiddenOffsetsVal;
- },
-
- boxSizingReliable: function() {
- if ( boxSizingReliableVal == null ) {
- computeStyleTests();
- }
- return boxSizingReliableVal;
- },
-
- pixelPosition: function() {
- if ( pixelPositionVal == null ) {
- computeStyleTests();
- }
- return pixelPositionVal;
- },
-
- // Support: Android 2.3
- reliableMarginRight: function() {
- if ( reliableMarginRightVal == null ) {
- computeStyleTests();
- }
- return reliableMarginRightVal;
- }
- });
-
- function computeStyleTests() {
- // Minified: var b,c,d,j
- var div, body, container, contents;
-
- body = document.getElementsByTagName( "body" )[ 0 ];
- if ( !body || !body.style ) {
- // Test fired too early or in an unsupported environment, exit.
- return;
- }
-
- // Setup
- div = document.createElement( "div" );
- container = document.createElement( "div" );
- container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
- body.appendChild( container ).appendChild( div );
-
- div.style.cssText =
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
- "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
- "border:1px;padding:1px;width:4px;position:absolute";
-
- // Support: IE<9
- // Assume reasonable values in the absence of getComputedStyle
- pixelPositionVal = boxSizingReliableVal = false;
- reliableMarginRightVal = true;
-
- // Check for getComputedStyle so that this code is not run in IE<9.
- if ( window.getComputedStyle ) {
- pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
- boxSizingReliableVal =
- ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
-
- // Support: Android 2.3
- // Div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container (#3333)
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- contents = div.appendChild( document.createElement( "div" ) );
-
- // Reset CSS: box-sizing; display; margin; border; padding
- contents.style.cssText = div.style.cssText =
- // Support: Firefox<29, Android 2.3
- // Vendor-prefix box-sizing
- "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
- "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
- contents.style.marginRight = contents.style.width = "0";
- div.style.width = "1px";
-
- reliableMarginRightVal =
- !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
- }
-
- // Support: IE8
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- div.innerHTML = "";
- contents = div.getElementsByTagName( "td" );
- contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
- reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
- if ( reliableHiddenOffsetsVal ) {
- contents[ 0 ].style.display = "";
- contents[ 1 ].style.display = "none";
- reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
- }
-
- body.removeChild( container );
- }
-
-})();
+ (function () {
+ var shrinkWrapBlocksVal;
+
+ support.shrinkWrapBlocks = function () {
+ if (shrinkWrapBlocksVal != null) {
+ return shrinkWrapBlocksVal;
+ }
+
+ // Will be changed later if needed.
+ shrinkWrapBlocksVal = false;
+
+ // Minified: var b,c,d
+ var div, body, container;
+
+ body = document.getElementsByTagName("body")[0];
+ if (!body || !body.style) {
+ // Test fired too early or in an unsupported environment, exit.
+ return;
+ }
+
+ // Setup
+ div = document.createElement("div");
+ container = document.createElement("div");
+ container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
+ body.appendChild(container).appendChild(div);
+
+ // Support: IE6
+ // Check if elements with layout shrink-wrap their children
+ if (typeof div.style.zoom !== strundefined) {
+ // Reset CSS: box-sizing; display; margin; border
+ div.style.cssText =
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
+ "box-sizing:content-box;display:block;margin:0;border:0;" +
+ "padding:1px;width:1px;zoom:1";
+ div.appendChild(document.createElement("div")).style.width = "5px";
+ shrinkWrapBlocksVal = div.offsetWidth !== 3;
+ }
+
+ body.removeChild(container);
+
+ return shrinkWrapBlocksVal;
+ };
+
+ })();
+ var rmargin = (/^margin/);
+
+ var rnumnonpx = new RegExp("^(" + pnum + ")(?!px)[a-z%]+$", "i");
+
+
+ var getStyles, curCSS,
+ rposition = /^(top|right|bottom|left)$/;
+
+ if (window.getComputedStyle) {
+ getStyles = function (elem) {
+ return elem.ownerDocument.defaultView.getComputedStyle(elem, null);
+ };
+
+ curCSS = function (elem, name, computed) {
+ var width, minWidth, maxWidth, ret,
+ style = elem.style;
+
+ computed = computed || getStyles(elem);
+
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+ ret = computed ? computed.getPropertyValue(name) || computed[name] : undefined;
+
+ if (computed) {
+
+ if (ret === "" && !jQuery.contains(elem.ownerDocument, elem)) {
+ ret = jQuery.style(elem, name);
+ }
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
+ // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
+ // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+ if (rnumnonpx.test(ret) && rmargin.test(name)) {
+
+ // Remember the original values
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ // Put in the new values to get a computed value out
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ // Revert the changed values
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ // Support: IE
+ // IE returns zIndex value as an integer.
+ return ret === undefined ?
+ ret :
+ ret + "";
+ };
+ } else if (document.documentElement.currentStyle) {
+ getStyles = function (elem) {
+ return elem.currentStyle;
+ };
+
+ curCSS = function (elem, name, computed) {
+ var left, rs, rsLeft, ret,
+ style = elem.style;
+
+ computed = computed || getStyles(elem);
+ ret = computed ? computed[name] : undefined;
+
+ // Avoid setting ret to empty string here
+ // so we don't default to auto
+ if (ret == null && style && style[name]) {
+ ret = style[name];
+ }
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ // but not position css attributes, as those are proportional to the parent element instead
+ // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
+ if (rnumnonpx.test(ret) && !rposition.test(name)) {
+
+ // Remember the original values
+ left = style.left;
+ rs = elem.runtimeStyle;
+ rsLeft = rs && rs.left;
+
+ // Put in the new values to get a computed value out
+ if (rsLeft) {
+ rs.left = elem.currentStyle.left;
+ }
+ style.left = name === "fontSize" ? "1em" : ret;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ if (rsLeft) {
+ rs.left = rsLeft;
+ }
+ }
+
+ // Support: IE
+ // IE returns zIndex value as an integer.
+ return ret === undefined ?
+ ret :
+ ret + "" || "auto";
+ };
+ }
+
+
+ function addGetHookIf(conditionFn, hookFn) {
+ // Define the hook, we'll check on the first run if it's really needed.
+ return {
+ get: function () {
+ var condition = conditionFn();
+
+ if (condition == null) {
+ // The test was not ready at this point; screw the hook this time
+ // but check again when needed next time.
+ return;
+ }
+
+ if (condition) {
+ // Hook not needed (or it's not possible to use it due to missing dependency),
+ // remove it.
+ // Since there are no other hooks for marginRight, remove the whole object.
+ delete this.get;
+ return;
+ }
+
+ // Hook needed; redefine it so that the support test is not executed again.
+
+ return (this.get = hookFn).apply(this, arguments);
+ }
+ };
+ }
+
+
+ (function () {
+ // Minified: var b,c,d,e,f,g, h,i
+ var div, style, a, pixelPositionVal, boxSizingReliableVal,
+ reliableHiddenOffsetsVal, reliableMarginRightVal;
+
+ // Setup
+ div = document.createElement("div");
+ div.innerHTML = " a ";
+ a = div.getElementsByTagName("a")[0];
+ style = a && a.style;
+
+ // Finish early in limited (non-browser) environments
+ if (!style) {
+ return;
+ }
+
+ style.cssText = "float:left;opacity:.5";
+
+ // Support: IE<9
+ // Make sure that element opacity exists (as opposed to filter)
+ support.opacity = style.opacity === "0.5";
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ support.cssFloat = !!style.cssFloat;
+
+ div.style.backgroundClip = "content-box";
+ div.cloneNode(true).style.backgroundClip = "";
+ support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
+ style.WebkitBoxSizing === "";
+
+ jQuery.extend(support, {
+ reliableHiddenOffsets: function () {
+ if (reliableHiddenOffsetsVal == null) {
+ computeStyleTests();
+ }
+ return reliableHiddenOffsetsVal;
+ },
+
+ boxSizingReliable: function () {
+ if (boxSizingReliableVal == null) {
+ computeStyleTests();
+ }
+ return boxSizingReliableVal;
+ },
+
+ pixelPosition: function () {
+ if (pixelPositionVal == null) {
+ computeStyleTests();
+ }
+ return pixelPositionVal;
+ },
+
+ // Support: Android 2.3
+ reliableMarginRight: function () {
+ if (reliableMarginRightVal == null) {
+ computeStyleTests();
+ }
+ return reliableMarginRightVal;
+ }
+ });
+
+ function computeStyleTests() {
+ // Minified: var b,c,d,j
+ var div, body, container, contents;
+
+ body = document.getElementsByTagName("body")[0];
+ if (!body || !body.style) {
+ // Test fired too early or in an unsupported environment, exit.
+ return;
+ }
+
+ // Setup
+ div = document.createElement("div");
+ container = document.createElement("div");
+ container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
+ body.appendChild(container).appendChild(div);
+
+ div.style.cssText =
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
+ "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
+ "border:1px;padding:1px;width:4px;position:absolute";
+
+ // Support: IE<9
+ // Assume reasonable values in the absence of getComputedStyle
+ pixelPositionVal = boxSizingReliableVal = false;
+ reliableMarginRightVal = true;
+
+ // Check for getComputedStyle so that this code is not run in IE<9.
+ if (window.getComputedStyle) {
+ pixelPositionVal = ( window.getComputedStyle(div, null) || {} ).top !== "1%";
+ boxSizingReliableVal =
+ ( window.getComputedStyle(div, null) || {width: "4px"} ).width === "4px";
+
+ // Support: Android 2.3
+ // Div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container (#3333)
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ contents = div.appendChild(document.createElement("div"));
+
+ // Reset CSS: box-sizing; display; margin; border; padding
+ contents.style.cssText = div.style.cssText =
+ // Support: Firefox<29, Android 2.3
+ // Vendor-prefix box-sizing
+ "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
+ "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
+ contents.style.marginRight = contents.style.width = "0";
+ div.style.width = "1px";
+
+ reliableMarginRightVal = !parseFloat(( window.getComputedStyle(contents, null) || {} ).marginRight);
+ }
+
+ // Support: IE8
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ div.innerHTML = "";
+ contents = div.getElementsByTagName("td");
+ contents[0].style.cssText = "margin:0;border:0;padding:0;display:none";
+ reliableHiddenOffsetsVal = contents[0].offsetHeight === 0;
+ if (reliableHiddenOffsetsVal) {
+ contents[0].style.display = "";
+ contents[1].style.display = "none";
+ reliableHiddenOffsetsVal = contents[0].offsetHeight === 0;
+ }
+
+ body.removeChild(container);
+ }
+
+ })();
// A method for quickly swapping in/out CSS properties to get correct calculations.
-jQuery.swap = function( elem, options, callback, args ) {
- var ret, name,
- old = {};
+ jQuery.swap = function (elem, options, callback, args) {
+ var ret, name,
+ old = {};
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
+ // Remember the old values, and insert the new ones
+ for (name in options) {
+ old[name] = elem.style[name];
+ elem.style[name] = options[name];
+ }
- ret = callback.apply( elem, args || [] );
+ ret = callback.apply(elem, args || []);
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
+ // Revert the old values
+ for (name in options) {
+ elem.style[name] = old[name];
+ }
- return ret;
-};
+ return ret;
+ };
-var
- ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity\s*=\s*([^)]*)/,
+ var
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity\s*=\s*([^)]*)/,
- // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
- // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
- rdisplayswap = /^(none|table(?!-c[ea]).+)/,
- rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
- rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rnumsplit = new RegExp("^(" + pnum + ")(.*)$", "i"),
+ rrelNum = new RegExp("^([+-])=(" + pnum + ")", "i"),
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssNormalTransform = {
- letterSpacing: "0",
- fontWeight: "400"
- },
+ cssShow = {position: "absolute", visibility: "hidden", display: "block"},
+ cssNormalTransform = {
+ letterSpacing: "0",
+ fontWeight: "400"
+ },
- cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
+ cssPrefixes = ["Webkit", "O", "Moz", "ms"];
// return a css property mapped to a potentially vendor prefixed property
-function vendorPropName( style, name ) {
-
- // shortcut for names that are not vendor prefixed
- if ( name in style ) {
- return name;
- }
-
- // check for vendor prefixed names
- var capName = name.charAt(0).toUpperCase() + name.slice(1),
- origName = name,
- i = cssPrefixes.length;
-
- while ( i-- ) {
- name = cssPrefixes[ i ] + capName;
- if ( name in style ) {
- return name;
- }
- }
-
- return origName;
-}
-
-function showHide( elements, show ) {
- var display, elem, hidden,
- values = [],
- index = 0,
- length = elements.length;
-
- for ( ; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
-
- values[ index ] = jQuery._data( elem, "olddisplay" );
- display = elem.style.display;
- if ( show ) {
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !values[ index ] && display === "none" ) {
- elem.style.display = "";
- }
-
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( elem.style.display === "" && isHidden( elem ) ) {
- values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
- }
- } else {
- hidden = isHidden( elem );
-
- if ( display && display !== "none" || !hidden ) {
- jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
- }
- }
- }
-
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( index = 0; index < length; index++ ) {
- elem = elements[ index ];
- if ( !elem.style ) {
- continue;
- }
- if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
- elem.style.display = show ? values[ index ] || "" : "none";
- }
- }
-
- return elements;
-}
-
-function setPositiveNumber( elem, value, subtract ) {
- var matches = rnumsplit.exec( value );
- return matches ?
- // Guard against undefined "subtract", e.g., when used as in cssHooks
- Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
- value;
-}
-
-function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
- var i = extra === ( isBorderBox ? "border" : "content" ) ?
- // If we already have the right measurement, avoid augmentation
- 4 :
- // Otherwise initialize for horizontal or vertical properties
- name === "width" ? 1 : 0,
-
- val = 0;
-
- for ( ; i < 4; i += 2 ) {
- // both box models exclude margin, so add it if we want it
- if ( extra === "margin" ) {
- val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
- }
-
- if ( isBorderBox ) {
- // border-box includes padding, so remove it if we want content
- if ( extra === "content" ) {
- val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
- }
-
- // at this point, extra isn't border nor margin, so remove border
- if ( extra !== "margin" ) {
- val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
- } else {
- // at this point, extra isn't content, so add padding
- val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
-
- // at this point, extra isn't content nor padding, so add border
- if ( extra !== "padding" ) {
- val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
- }
- }
- }
-
- return val;
-}
-
-function getWidthOrHeight( elem, name, extra ) {
-
- // Start with offset property, which is equivalent to the border-box value
- var valueIsBorderBox = true,
- val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
- styles = getStyles( elem ),
- isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
-
- // some non-html elements return undefined for offsetWidth, so check for null/undefined
- // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
- // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
- if ( val <= 0 || val == null ) {
- // Fall back to computed then uncomputed css if necessary
- val = curCSS( elem, name, styles );
- if ( val < 0 || val == null ) {
- val = elem.style[ name ];
- }
-
- // Computed unit is not pixels. Stop here and return.
- if ( rnumnonpx.test(val) ) {
- return val;
- }
-
- // we need the check for style in case a browser which returns unreliable values
- // for getComputedStyle silently falls back to the reliable elem.style
- valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
-
- // Normalize "", auto, and prepare for extra
- val = parseFloat( val ) || 0;
- }
-
- // use the active box-sizing model to add/subtract irrelevant styles
- return ( val +
- augmentWidthOrHeight(
- elem,
- name,
- extra || ( isBorderBox ? "border" : "content" ),
- valueIsBorderBox,
- styles
- )
- ) + "px";
-}
-
-jQuery.extend({
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity" );
- return ret === "" ? "1" : ret;
- }
- }
- }
- },
-
- // Don't automatically add "px" to these possibly-unitless properties
- cssNumber: {
- "columnCount": true,
- "fillOpacity": true,
- "flexGrow": true,
- "flexShrink": true,
- "fontWeight": true,
- "lineHeight": true,
- "opacity": true,
- "order": true,
- "orphans": true,
- "widows": true,
- "zIndex": true,
- "zoom": true
- },
-
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {
- // normalize float css property
- "float": support.cssFloat ? "cssFloat" : "styleFloat"
- },
-
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
-
- // Make sure that we're working with the right name
- var ret, type, hooks,
- origName = jQuery.camelCase( name ),
- style = elem.style;
-
- name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // Check if we're setting a value
- if ( value !== undefined ) {
- type = typeof value;
-
- // convert relative number strings (+= or -=) to relative numbers. #7345
- if ( type === "string" && (ret = rrelNum.exec( value )) ) {
- value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
- // Fixes bug #9237
- type = "number";
- }
-
- // Make sure that null and NaN values aren't set. See: #7116
- if ( value == null || value !== value ) {
- return;
- }
-
- // If a number was passed in, add 'px' to the (except for certain CSS properties)
- if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
- value += "px";
- }
-
- // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
- // but it would mean to define eight (for every problematic property) identical functions
- if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
- style[ name ] = "inherit";
- }
-
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
-
- // Support: IE
- // Swallow errors from 'invalid' CSS values (#5509)
- try {
- style[ name ] = value;
- } catch(e) {}
- }
-
- } else {
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
- return ret;
- }
-
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
-
- css: function( elem, name, extra, styles ) {
- var num, val, hooks,
- origName = jQuery.camelCase( name );
-
- // Make sure that we're working with the right name
- name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
-
- // gets hook for the prefixed version
- // followed by the unprefixed version
- hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
-
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks ) {
- val = hooks.get( elem, true, extra );
- }
-
- // Otherwise, if a way to get the computed value exists, use that
- if ( val === undefined ) {
- val = curCSS( elem, name, styles );
- }
-
- //convert "normal" to computed value
- if ( val === "normal" && name in cssNormalTransform ) {
- val = cssNormalTransform[ name ];
- }
-
- // Return, converting to number if forced or a qualifier was provided and val looks numeric
- if ( extra === "" || extra ) {
- num = parseFloat( val );
- return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
- }
- return val;
- }
-});
-
-jQuery.each([ "height", "width" ], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- if ( computed ) {
- // certain elements can have dimension info if we invisibly show them
- // however, it must have a current display style that would benefit from this
- return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
- jQuery.swap( elem, cssShow, function() {
- return getWidthOrHeight( elem, name, extra );
- }) :
- getWidthOrHeight( elem, name, extra );
- }
- },
-
- set: function( elem, value, extra ) {
- var styles = extra && getStyles( elem );
- return setPositiveNumber( elem, value, extra ?
- augmentWidthOrHeight(
- elem,
- name,
- extra,
- support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
- styles
- ) : 0
- );
- }
- };
-});
-
-if ( !support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
- // IE uses filters for opacity
- return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
- ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
- computed ? "1" : "";
- },
-
- set: function( elem, value ) {
- var style = elem.style,
- currentStyle = elem.currentStyle,
- opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
- filter = currentStyle && currentStyle.filter || style.filter || "";
-
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
-
- // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
- // if value === "", then remove inline opacity #12685
- if ( ( value >= 1 || value === "" ) &&
- jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
- style.removeAttribute ) {
-
- // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
- // if "filter:" is present at all, clearType is disabled, we want to avoid this
- // style.removeAttribute is IE Only, but so apparently is this code path...
- style.removeAttribute( "filter" );
-
- // if there is no filter style applied in a css rule or unset inline opacity, we are done
- if ( value === "" || currentStyle && !currentStyle.filter ) {
- return;
- }
- }
-
- // otherwise, set new filter values
- style.filter = ralpha.test( filter ) ?
- filter.replace( ralpha, opacity ) :
- filter + " " + opacity;
- }
- };
-}
-
-jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
- function( elem, computed ) {
- if ( computed ) {
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- // Work around by temporarily setting element display to inline-block
- return jQuery.swap( elem, { "display": "inline-block" },
- curCSS, [ elem, "marginRight" ] );
- }
- }
-);
+ function vendorPropName(style, name) {
+
+ // shortcut for names that are not vendor prefixed
+ if (name in style) {
+ return name;
+ }
+
+ // check for vendor prefixed names
+ var capName = name.charAt(0).toUpperCase() + name.slice(1),
+ origName = name,
+ i = cssPrefixes.length;
+
+ while (i--) {
+ name = cssPrefixes[i] + capName;
+ if (name in style) {
+ return name;
+ }
+ }
+
+ return origName;
+ }
+
+ function showHide(elements, show) {
+ var display, elem, hidden,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ for (; index < length; index++) {
+ elem = elements[index];
+ if (!elem.style) {
+ continue;
+ }
+
+ values[index] = jQuery._data(elem, "olddisplay");
+ display = elem.style.display;
+ if (show) {
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if (!values[index] && display === "none") {
+ elem.style.display = "";
+ }
+
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if (elem.style.display === "" && isHidden(elem)) {
+ values[index] = jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
+ }
+ } else {
+ hidden = isHidden(elem);
+
+ if (display && display !== "none" || !hidden) {
+ jQuery._data(elem, "olddisplay", hidden ? display : jQuery.css(elem, "display"));
+ }
+ }
+ }
+
+ // Set the display of most of the elements in a second loop
+ // to avoid the constant reflow
+ for (index = 0; index < length; index++) {
+ elem = elements[index];
+ if (!elem.style) {
+ continue;
+ }
+ if (!show || elem.style.display === "none" || elem.style.display === "") {
+ elem.style.display = show ? values[index] || "" : "none";
+ }
+ }
+
+ return elements;
+ }
+
+ function setPositiveNumber(elem, value, subtract) {
+ var matches = rnumsplit.exec(value);
+ return matches ?
+ // Guard against undefined "subtract", e.g., when used as in cssHooks
+ Math.max(0, matches[1] - ( subtract || 0 )) + ( matches[2] || "px" ) :
+ value;
+ }
+
+ function augmentWidthOrHeight(elem, name, extra, isBorderBox, styles) {
+ var i = extra === ( isBorderBox ? "border" : "content" ) ?
+ // If we already have the right measurement, avoid augmentation
+ 4 :
+ // Otherwise initialize for horizontal or vertical properties
+ name === "width" ? 1 : 0,
+
+ val = 0;
+
+ for (; i < 4; i += 2) {
+ // both box models exclude margin, so add it if we want it
+ if (extra === "margin") {
+ val += jQuery.css(elem, extra + cssExpand[i], true, styles);
+ }
+
+ if (isBorderBox) {
+ // border-box includes padding, so remove it if we want content
+ if (extra === "content") {
+ val -= jQuery.css(elem, "padding" + cssExpand[i], true, styles);
+ }
+
+ // at this point, extra isn't border nor margin, so remove border
+ if (extra !== "margin") {
+ val -= jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
+ }
+ } else {
+ // at this point, extra isn't content, so add padding
+ val += jQuery.css(elem, "padding" + cssExpand[i], true, styles);
+
+ // at this point, extra isn't content nor padding, so add border
+ if (extra !== "padding") {
+ val += jQuery.css(elem, "border" + cssExpand[i] + "Width", true, styles);
+ }
+ }
+ }
+
+ return val;
+ }
+
+ function getWidthOrHeight(elem, name, extra) {
+
+ // Start with offset property, which is equivalent to the border-box value
+ var valueIsBorderBox = true,
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+ styles = getStyles(elem),
+ isBorderBox = support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box";
+
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if (val <= 0 || val == null) {
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS(elem, name, styles);
+ if (val < 0 || val == null) {
+ val = elem.style[name];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if (rnumnonpx.test(val)) {
+ return val;
+ }
+
+ // we need the check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[name] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat(val) || 0;
+ }
+
+ // use the active box-sizing model to add/subtract irrelevant styles
+ return ( val +
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox,
+ styles
+ )
+ ) + "px";
+ }
+
+ jQuery.extend({
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function (elem, computed) {
+ if (computed) {
+ // We should always get a number back from opacity
+ var ret = curCSS(elem, "opacity");
+ return ret === "" ? "1" : ret;
+ }
+ }
+ }
+ },
+
+ // Don't automatically add "px" to these possibly-unitless properties
+ cssNumber: {
+ "columnCount": true,
+ "fillOpacity": true,
+ "flexGrow": true,
+ "flexShrink": true,
+ "fontWeight": true,
+ "lineHeight": true,
+ "opacity": true,
+ "order": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {
+ // normalize float css property
+ "float": support.cssFloat ? "cssFloat" : "styleFloat"
+ },
+
+ // Get and set the style property on a DOM Node
+ style: function (elem, name, value, extra) {
+ // Don't set styles on text and comment nodes
+ if (!elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = jQuery.camelCase(name),
+ style = elem.style;
+
+ name = jQuery.cssProps[origName] || ( jQuery.cssProps[origName] = vendorPropName(style, origName) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
+
+ // Check if we're setting a value
+ if (value !== undefined) {
+ type = typeof value;
+
+ // convert relative number strings (+= or -=) to relative numbers. #7345
+ if (type === "string" && (ret = rrelNum.exec(value))) {
+ value = ( ret[1] + 1 ) * ret[2] + parseFloat(jQuery.css(elem, name));
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that null and NaN values aren't set. See: #7116
+ if (value == null || value !== value) {
+ return;
+ }
+
+ // If a number was passed in, add 'px' to the (except for certain CSS properties)
+ if (type === "number" && !jQuery.cssNumber[origName]) {
+ value += "px";
+ }
+
+ // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
+ // but it would mean to define eight (for every problematic property) identical functions
+ if (!support.clearCloneStyle && value === "" && name.indexOf("background") === 0) {
+ style[name] = "inherit";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if (!hooks || !("set" in hooks) || (value = hooks.set(elem, value, extra)) !== undefined) {
+
+ // Support: IE
+ // Swallow errors from 'invalid' CSS values (#5509)
+ try {
+ style[name] = value;
+ } catch (e) {
+ }
+ }
+
+ } else {
+ // If a hook was provided get the non-computed value from there
+ if (hooks && "get" in hooks && (ret = hooks.get(elem, false, extra)) !== undefined) {
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[name];
+ }
+ },
+
+ css: function (elem, name, extra, styles) {
+ var num, val, hooks,
+ origName = jQuery.camelCase(name);
+
+ // Make sure that we're working with the right name
+ name = jQuery.cssProps[origName] || ( jQuery.cssProps[origName] = vendorPropName(elem.style, origName) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[name] || jQuery.cssHooks[origName];
+
+ // If a hook was provided get the computed value from there
+ if (hooks && "get" in hooks) {
+ val = hooks.get(elem, true, extra);
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if (val === undefined) {
+ val = curCSS(elem, name, styles);
+ }
+
+ //convert "normal" to computed value
+ if (val === "normal" && name in cssNormalTransform) {
+ val = cssNormalTransform[name];
+ }
+
+ // Return, converting to number if forced or a qualifier was provided and val looks numeric
+ if (extra === "" || extra) {
+ num = parseFloat(val);
+ return extra === true || jQuery.isNumeric(num) ? num || 0 : val;
+ }
+ return val;
+ }
+ });
+
+ jQuery.each(["height", "width"], function (i, name) {
+ jQuery.cssHooks[name] = {
+ get: function (elem, computed, extra) {
+ if (computed) {
+ // certain elements can have dimension info if we invisibly show them
+ // however, it must have a current display style that would benefit from this
+ return rdisplayswap.test(jQuery.css(elem, "display")) && elem.offsetWidth === 0 ?
+ jQuery.swap(elem, cssShow, function () {
+ return getWidthOrHeight(elem, name, extra);
+ }) :
+ getWidthOrHeight(elem, name, extra);
+ }
+ },
+
+ set: function (elem, value, extra) {
+ var styles = extra && getStyles(elem);
+ return setPositiveNumber(elem, value, extra ?
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra,
+ support.boxSizing && jQuery.css(elem, "boxSizing", false, styles) === "border-box",
+ styles
+ ) : 0
+ );
+ }
+ };
+ });
+
+ if (!support.opacity) {
+ jQuery.cssHooks.opacity = {
+ get: function (elem, computed) {
+ // IE uses filters for opacity
+ return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
+ ( 0.01 * parseFloat(RegExp.$1) ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function (elem, value) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric(value) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ // if value === "", then remove inline opacity #12685
+ if (( value >= 1 || value === "" ) &&
+ jQuery.trim(filter.replace(ralpha, "")) === "" &&
+ style.removeAttribute) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute("filter");
+
+ // if there is no filter style applied in a css rule or unset inline opacity, we are done
+ if (value === "" || currentStyle && !currentStyle.filter) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test(filter) ?
+ filter.replace(ralpha, opacity) :
+ filter + " " + opacity;
+ }
+ };
+ }
+
+ jQuery.cssHooks.marginRight = addGetHookIf(support.reliableMarginRight,
+ function (elem, computed) {
+ if (computed) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ return jQuery.swap(elem, {"display": "inline-block"},
+ curCSS, [elem, "marginRight"]);
+ }
+ }
+ );
// These hooks are used by animate to expand properties
-jQuery.each({
- margin: "",
- padding: "",
- border: "Width"
-}, function( prefix, suffix ) {
- jQuery.cssHooks[ prefix + suffix ] = {
- expand: function( value ) {
- var i = 0,
- expanded = {},
-
- // assumes a single number if not a string
- parts = typeof value === "string" ? value.split(" ") : [ value ];
-
- for ( ; i < 4; i++ ) {
- expanded[ prefix + cssExpand[ i ] + suffix ] =
- parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
- }
-
- return expanded;
- }
- };
-
- if ( !rmargin.test( prefix ) ) {
- jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
- }
-});
-
-jQuery.fn.extend({
- css: function( name, value ) {
- return access( this, function( elem, name, value ) {
- var styles, len,
- map = {},
- i = 0;
-
- if ( jQuery.isArray( name ) ) {
- styles = getStyles( elem );
- len = name.length;
-
- for ( ; i < len; i++ ) {
- map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
- }
-
- return map;
- }
-
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- }, name, value, arguments.length > 1 );
- },
- show: function() {
- return showHide( this, true );
- },
- hide: function() {
- return showHide( this );
- },
- toggle: function( state ) {
- if ( typeof state === "boolean" ) {
- return state ? this.show() : this.hide();
- }
-
- return this.each(function() {
- if ( isHidden( this ) ) {
- jQuery( this ).show();
- } else {
- jQuery( this ).hide();
- }
- });
- }
-});
-
-
-function Tween( elem, options, prop, end, easing ) {
- return new Tween.prototype.init( elem, options, prop, end, easing );
-}
-jQuery.Tween = Tween;
-
-Tween.prototype = {
- constructor: Tween,
- init: function( elem, options, prop, end, easing, unit ) {
- this.elem = elem;
- this.prop = prop;
- this.easing = easing || "swing";
- this.options = options;
- this.start = this.now = this.cur();
- this.end = end;
- this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
- },
- cur: function() {
- var hooks = Tween.propHooks[ this.prop ];
-
- return hooks && hooks.get ?
- hooks.get( this ) :
- Tween.propHooks._default.get( this );
- },
- run: function( percent ) {
- var eased,
- hooks = Tween.propHooks[ this.prop ];
-
- if ( this.options.duration ) {
- this.pos = eased = jQuery.easing[ this.easing ](
- percent, this.options.duration * percent, 0, 1, this.options.duration
- );
- } else {
- this.pos = eased = percent;
- }
- this.now = ( this.end - this.start ) * eased + this.start;
-
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
-
- if ( hooks && hooks.set ) {
- hooks.set( this );
- } else {
- Tween.propHooks._default.set( this );
- }
- return this;
- }
-};
-
-Tween.prototype.init.prototype = Tween.prototype;
-
-Tween.propHooks = {
- _default: {
- get: function( tween ) {
- var result;
-
- if ( tween.elem[ tween.prop ] != null &&
- (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
- return tween.elem[ tween.prop ];
- }
-
- // passing an empty string as a 3rd parameter to .css will automatically
- // attempt a parseFloat and fallback to a string if the parse fails
- // so, simple values such as "10px" are parsed to Float.
- // complex values such as "rotate(1rad)" are returned as is.
- result = jQuery.css( tween.elem, tween.prop, "" );
- // Empty strings, null, undefined and "auto" are converted to 0.
- return !result || result === "auto" ? 0 : result;
- },
- set: function( tween ) {
- // use step hook for back compat - use cssHook if its there - use .style if its
- // available and use plain properties where available
- if ( jQuery.fx.step[ tween.prop ] ) {
- jQuery.fx.step[ tween.prop ]( tween );
- } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
- jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
- } else {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- }
-};
+ jQuery.each({
+ margin: "",
+ padding: "",
+ border: "Width"
+ }, function (prefix, suffix) {
+ jQuery.cssHooks[prefix + suffix] = {
+ expand: function (value) {
+ var i = 0,
+ expanded = {},
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split(" ") : [value];
+
+ for (; i < 4; i++) {
+ expanded[prefix + cssExpand[i] + suffix] =
+ parts[i] || parts[i - 2] || parts[0];
+ }
+
+ return expanded;
+ }
+ };
+
+ if (!rmargin.test(prefix)) {
+ jQuery.cssHooks[prefix + suffix].set = setPositiveNumber;
+ }
+ });
+
+ jQuery.fn.extend({
+ css: function (name, value) {
+ return access(this, function (elem, name, value) {
+ var styles, len,
+ map = {},
+ i = 0;
+
+ if (jQuery.isArray(name)) {
+ styles = getStyles(elem);
+ len = name.length;
+
+ for (; i < len; i++) {
+ map[name[i]] = jQuery.css(elem, name[i], false, styles);
+ }
+
+ return map;
+ }
+
+ return value !== undefined ?
+ jQuery.style(elem, name, value) :
+ jQuery.css(elem, name);
+ }, name, value, arguments.length > 1);
+ },
+ show: function () {
+ return showHide(this, true);
+ },
+ hide: function () {
+ return showHide(this);
+ },
+ toggle: function (state) {
+ if (typeof state === "boolean") {
+ return state ? this.show() : this.hide();
+ }
+
+ return this.each(function () {
+ if (isHidden(this)) {
+ jQuery(this).show();
+ } else {
+ jQuery(this).hide();
+ }
+ });
+ }
+ });
+
+
+ function Tween(elem, options, prop, end, easing) {
+ return new Tween.prototype.init(elem, options, prop, end, easing);
+ }
+
+ jQuery.Tween = Tween;
+
+ Tween.prototype = {
+ constructor: Tween,
+ init: function (elem, options, prop, end, easing, unit) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[prop] ? "" : "px" );
+ },
+ cur: function () {
+ var hooks = Tween.propHooks[this.prop];
+
+ return hooks && hooks.get ?
+ hooks.get(this) :
+ Tween.propHooks._default.get(this);
+ },
+ run: function (percent) {
+ var eased,
+ hooks = Tween.propHooks[this.prop];
+
+ if (this.options.duration) {
+ this.pos = eased = jQuery.easing[this.easing](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if (this.options.step) {
+ this.options.step.call(this.elem, this.now, this);
+ }
+
+ if (hooks && hooks.set) {
+ hooks.set(this);
+ } else {
+ Tween.propHooks._default.set(this);
+ }
+ return this;
+ }
+ };
+
+ Tween.prototype.init.prototype = Tween.prototype;
+
+ Tween.propHooks = {
+ _default: {
+ get: function (tween) {
+ var result;
+
+ if (tween.elem[tween.prop] != null &&
+ (!tween.elem.style || tween.elem.style[tween.prop] == null)) {
+ return tween.elem[tween.prop];
+ }
+
+ // passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css(tween.elem, tween.prop, "");
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function (tween) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if (jQuery.fx.step[tween.prop]) {
+ jQuery.fx.step[tween.prop](tween);
+ } else if (tween.elem.style && ( tween.elem.style[jQuery.cssProps[tween.prop]] != null || jQuery.cssHooks[tween.prop] )) {
+ jQuery.style(tween.elem, tween.prop, tween.now + tween.unit);
+ } else {
+ tween.elem[tween.prop] = tween.now;
+ }
+ }
+ }
+ };
// Support: IE <=9
// Panic based approach to setting things on disconnected nodes
-Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
- set: function( tween ) {
- if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
-};
-
-jQuery.easing = {
- linear: function( p ) {
- return p;
- },
- swing: function( p ) {
- return 0.5 - Math.cos( p * Math.PI ) / 2;
- }
-};
-
-jQuery.fx = Tween.prototype.init;
+ Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function (tween) {
+ if (tween.elem.nodeType && tween.elem.parentNode) {
+ tween.elem[tween.prop] = tween.now;
+ }
+ }
+ };
+
+ jQuery.easing = {
+ linear: function (p) {
+ return p;
+ },
+ swing: function (p) {
+ return 0.5 - Math.cos(p * Math.PI) / 2;
+ }
+ };
+
+ jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point
-jQuery.fx.step = {};
-
-
-
-
-var
- fxNow, timerId,
- rfxtypes = /^(?:toggle|show|hide)$/,
- rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
- rrun = /queueHooks$/,
- animationPrefilters = [ defaultPrefilter ],
- tweeners = {
- "*": [ function( prop, value ) {
- var tween = this.createTween( prop, value ),
- target = tween.cur(),
- parts = rfxnum.exec( value ),
- unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
-
- // Starting value computation is required for potential unit mismatches
- start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
- rfxnum.exec( jQuery.css( tween.elem, prop ) ),
- scale = 1,
- maxIterations = 20;
-
- if ( start && start[ 3 ] !== unit ) {
- // Trust units reported by jQuery.css
- unit = unit || start[ 3 ];
-
- // Make sure we update the tween properties later on
- parts = parts || [];
-
- // Iteratively approximate from a nonzero starting point
- start = +target || 1;
-
- do {
- // If previous iteration zeroed out, double until we get *something*
- // Use a string for doubling factor so we don't accidentally see scale as unchanged below
- scale = scale || ".5";
-
- // Adjust and apply
- start = start / scale;
- jQuery.style( tween.elem, prop, start + unit );
-
- // Update scale, tolerating zero or NaN from tween.cur()
- // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
- } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
- }
-
- // Update tween properties
- if ( parts ) {
- start = tween.start = +start || +target || 0;
- tween.unit = unit;
- // If a +=/-= token was provided, we're doing a relative animation
- tween.end = parts[ 1 ] ?
- start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
- +parts[ 2 ];
- }
-
- return tween;
- } ]
- };
+ jQuery.fx.step = {};
+
+
+ var
+ fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rfxnum = new RegExp("^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i"),
+ rrun = /queueHooks$/,
+ animationPrefilters = [defaultPrefilter],
+ tweeners = {
+ "*": [function (prop, value) {
+ var tween = this.createTween(prop, value),
+ target = tween.cur(),
+ parts = rfxnum.exec(value),
+ unit = parts && parts[3] || ( jQuery.cssNumber[prop] ? "" : "px" ),
+
+ // Starting value computation is required for potential unit mismatches
+ start = ( jQuery.cssNumber[prop] || unit !== "px" && +target ) &&
+ rfxnum.exec(jQuery.css(tween.elem, prop)),
+ scale = 1,
+ maxIterations = 20;
+
+ if (start && start[3] !== unit) {
+ // Trust units reported by jQuery.css
+ unit = unit || start[3];
+
+ // Make sure we update the tween properties later on
+ parts = parts || [];
+
+ // Iteratively approximate from a nonzero starting point
+ start = +target || 1;
+
+ do {
+ // If previous iteration zeroed out, double until we get *something*
+ // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ start = start / scale;
+ jQuery.style(tween.elem, prop, start + unit);
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while (scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations);
+ }
+
+ // Update tween properties
+ if (parts) {
+ start = tween.start = +start || +target || 0;
+ tween.unit = unit;
+ // If a +=/-= token was provided, we're doing a relative animation
+ tween.end = parts[1] ?
+ start + ( parts[1] + 1 ) * parts[2] :
+ +parts[2];
+ }
+
+ return tween;
+ }]
+ };
// Animations created synchronously will run synchronously
-function createFxNow() {
- setTimeout(function() {
- fxNow = undefined;
- });
- return ( fxNow = jQuery.now() );
-}
+ function createFxNow() {
+ setTimeout(function () {
+ fxNow = undefined;
+ });
+ return ( fxNow = jQuery.now() );
+ }
// Generate parameters to create a standard animation
-function genFx( type, includeWidth ) {
- var which,
- attrs = { height: type },
- i = 0;
-
- // if we include width, step value is 1 to do all cssExpand values,
- // if we don't include width, step value is 2 to skip over Left and Right
- includeWidth = includeWidth ? 1 : 0;
- for ( ; i < 4 ; i += 2 - includeWidth ) {
- which = cssExpand[ i ];
- attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
- }
-
- if ( includeWidth ) {
- attrs.opacity = attrs.width = type;
- }
-
- return attrs;
-}
-
-function createTween( value, prop, animation ) {
- var tween,
- collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
- index = 0,
- length = collection.length;
- for ( ; index < length; index++ ) {
- if ( (tween = collection[ index ].call( animation, prop, value )) ) {
-
- // we're done with this property
- return tween;
- }
- }
-}
-
-function defaultPrefilter( elem, props, opts ) {
- /* jshint validthis: true */
- var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
- anim = this,
- orig = {},
- style = elem.style,
- hidden = elem.nodeType && isHidden( elem ),
- dataShow = jQuery._data( elem, "fxshow" );
-
- // handle queue: false promises
- if ( !opts.queue ) {
- hooks = jQuery._queueHooks( elem, "fx" );
- if ( hooks.unqueued == null ) {
- hooks.unqueued = 0;
- oldfire = hooks.empty.fire;
- hooks.empty.fire = function() {
- if ( !hooks.unqueued ) {
- oldfire();
- }
- };
- }
- hooks.unqueued++;
-
- anim.always(function() {
- // doing this makes sure that the complete handler will be called
- // before this completes
- anim.always(function() {
- hooks.unqueued--;
- if ( !jQuery.queue( elem, "fx" ).length ) {
- hooks.empty.fire();
- }
- });
- });
- }
-
- // height/width overflow pass
- if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
- // Make sure that nothing sneaks out
- // Record all 3 overflow attributes because IE does not
- // change the overflow attribute when overflowX and
- // overflowY are set to the same value
- opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
-
- // Set display property to inline-block for height/width
- // animations on inline elements that are having width/height animated
- display = jQuery.css( elem, "display" );
-
- // Test default display if display is currently "none"
- checkDisplay = display === "none" ?
- jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
-
- if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
-
- // inline-level elements accept inline-block;
- // block-level elements need to be inline with layout
- if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
- style.display = "inline-block";
- } else {
- style.zoom = 1;
- }
- }
- }
-
- if ( opts.overflow ) {
- style.overflow = "hidden";
- if ( !support.shrinkWrapBlocks() ) {
- anim.always(function() {
- style.overflow = opts.overflow[ 0 ];
- style.overflowX = opts.overflow[ 1 ];
- style.overflowY = opts.overflow[ 2 ];
- });
- }
- }
-
- // show/hide pass
- for ( prop in props ) {
- value = props[ prop ];
- if ( rfxtypes.exec( value ) ) {
- delete props[ prop ];
- toggle = toggle || value === "toggle";
- if ( value === ( hidden ? "hide" : "show" ) ) {
-
- // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
- if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
- hidden = true;
- } else {
- continue;
- }
- }
- orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
-
- // Any non-fx value stops us from restoring the original display value
- } else {
- display = undefined;
- }
- }
-
- if ( !jQuery.isEmptyObject( orig ) ) {
- if ( dataShow ) {
- if ( "hidden" in dataShow ) {
- hidden = dataShow.hidden;
- }
- } else {
- dataShow = jQuery._data( elem, "fxshow", {} );
- }
-
- // store state if its toggle - enables .stop().toggle() to "reverse"
- if ( toggle ) {
- dataShow.hidden = !hidden;
- }
- if ( hidden ) {
- jQuery( elem ).show();
- } else {
- anim.done(function() {
- jQuery( elem ).hide();
- });
- }
- anim.done(function() {
- var prop;
- jQuery._removeData( elem, "fxshow" );
- for ( prop in orig ) {
- jQuery.style( elem, prop, orig[ prop ] );
- }
- });
- for ( prop in orig ) {
- tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
-
- if ( !( prop in dataShow ) ) {
- dataShow[ prop ] = tween.start;
- if ( hidden ) {
- tween.end = tween.start;
- tween.start = prop === "width" || prop === "height" ? 1 : 0;
- }
- }
- }
-
- // If this is a noop like .hide().hide(), restore an overwritten display value
- } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
- style.display = display;
- }
-}
-
-function propFilter( props, specialEasing ) {
- var index, name, easing, value, hooks;
-
- // camelCase, specialEasing and expand cssHook pass
- for ( index in props ) {
- name = jQuery.camelCase( index );
- easing = specialEasing[ name ];
- value = props[ index ];
- if ( jQuery.isArray( value ) ) {
- easing = value[ 1 ];
- value = props[ index ] = value[ 0 ];
- }
-
- if ( index !== name ) {
- props[ name ] = value;
- delete props[ index ];
- }
-
- hooks = jQuery.cssHooks[ name ];
- if ( hooks && "expand" in hooks ) {
- value = hooks.expand( value );
- delete props[ name ];
-
- // not quite $.extend, this wont overwrite keys already present.
- // also - reusing 'index' from above because we have the correct "name"
- for ( index in value ) {
- if ( !( index in props ) ) {
- props[ index ] = value[ index ];
- specialEasing[ index ] = easing;
- }
- }
- } else {
- specialEasing[ name ] = easing;
- }
- }
-}
-
-function Animation( elem, properties, options ) {
- var result,
- stopped,
- index = 0,
- length = animationPrefilters.length,
- deferred = jQuery.Deferred().always( function() {
- // don't match elem in the :animated selector
- delete tick.elem;
- }),
- tick = function() {
- if ( stopped ) {
- return false;
- }
- var currentTime = fxNow || createFxNow(),
- remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
- // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
- temp = remaining / animation.duration || 0,
- percent = 1 - temp,
- index = 0,
- length = animation.tweens.length;
-
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( percent );
- }
-
- deferred.notifyWith( elem, [ animation, percent, remaining ]);
-
- if ( percent < 1 && length ) {
- return remaining;
- } else {
- deferred.resolveWith( elem, [ animation ] );
- return false;
- }
- },
- animation = deferred.promise({
- elem: elem,
- props: jQuery.extend( {}, properties ),
- opts: jQuery.extend( true, { specialEasing: {} }, options ),
- originalProperties: properties,
- originalOptions: options,
- startTime: fxNow || createFxNow(),
- duration: options.duration,
- tweens: [],
- createTween: function( prop, end ) {
- var tween = jQuery.Tween( elem, animation.opts, prop, end,
- animation.opts.specialEasing[ prop ] || animation.opts.easing );
- animation.tweens.push( tween );
- return tween;
- },
- stop: function( gotoEnd ) {
- var index = 0,
- // if we are going to the end, we want to run all the tweens
- // otherwise we skip this part
- length = gotoEnd ? animation.tweens.length : 0;
- if ( stopped ) {
- return this;
- }
- stopped = true;
- for ( ; index < length ; index++ ) {
- animation.tweens[ index ].run( 1 );
- }
-
- // resolve when we played the last frame
- // otherwise, reject
- if ( gotoEnd ) {
- deferred.resolveWith( elem, [ animation, gotoEnd ] );
- } else {
- deferred.rejectWith( elem, [ animation, gotoEnd ] );
- }
- return this;
- }
- }),
- props = animation.props;
-
- propFilter( props, animation.opts.specialEasing );
-
- for ( ; index < length ; index++ ) {
- result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
- if ( result ) {
- return result;
- }
- }
-
- jQuery.map( props, createTween, animation );
-
- if ( jQuery.isFunction( animation.opts.start ) ) {
- animation.opts.start.call( elem, animation );
- }
-
- jQuery.fx.timer(
- jQuery.extend( tick, {
- elem: elem,
- anim: animation,
- queue: animation.opts.queue
- })
- );
-
- // attach callbacks from options
- return animation.progress( animation.opts.progress )
- .done( animation.opts.done, animation.opts.complete )
- .fail( animation.opts.fail )
- .always( animation.opts.always );
-}
-
-jQuery.Animation = jQuery.extend( Animation, {
- tweener: function( props, callback ) {
- if ( jQuery.isFunction( props ) ) {
- callback = props;
- props = [ "*" ];
- } else {
- props = props.split(" ");
- }
-
- var prop,
- index = 0,
- length = props.length;
-
- for ( ; index < length ; index++ ) {
- prop = props[ index ];
- tweeners[ prop ] = tweeners[ prop ] || [];
- tweeners[ prop ].unshift( callback );
- }
- },
-
- prefilter: function( callback, prepend ) {
- if ( prepend ) {
- animationPrefilters.unshift( callback );
- } else {
- animationPrefilters.push( callback );
- }
- }
-});
-
-jQuery.speed = function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
- complete: fn || !fn && easing ||
- jQuery.isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
- };
-
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
-
- // normalize opt.queue - true/undefined/null -> "fx"
- if ( opt.queue == null || opt.queue === true ) {
- opt.queue = "fx";
- }
-
- // Queueing
- opt.old = opt.complete;
-
- opt.complete = function() {
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
-
- if ( opt.queue ) {
- jQuery.dequeue( this, opt.queue );
- }
- };
-
- return opt;
-};
-
-jQuery.fn.extend({
- fadeTo: function( speed, to, easing, callback ) {
-
- // show any hidden elements after setting opacity to 0
- return this.filter( isHidden ).css( "opacity", 0 ).show()
-
- // animate to the value specified
- .end().animate({ opacity: to }, speed, easing, callback );
- },
- animate: function( prop, speed, easing, callback ) {
- var empty = jQuery.isEmptyObject( prop ),
- optall = jQuery.speed( speed, easing, callback ),
- doAnimation = function() {
- // Operate on a copy of prop so per-property easing won't be lost
- var anim = Animation( this, jQuery.extend( {}, prop ), optall );
-
- // Empty animations, or finishing resolves immediately
- if ( empty || jQuery._data( this, "finish" ) ) {
- anim.stop( true );
- }
- };
- doAnimation.finish = doAnimation;
-
- return empty || optall.queue === false ?
- this.each( doAnimation ) :
- this.queue( optall.queue, doAnimation );
- },
- stop: function( type, clearQueue, gotoEnd ) {
- var stopQueue = function( hooks ) {
- var stop = hooks.stop;
- delete hooks.stop;
- stop( gotoEnd );
- };
-
- if ( typeof type !== "string" ) {
- gotoEnd = clearQueue;
- clearQueue = type;
- type = undefined;
- }
- if ( clearQueue && type !== false ) {
- this.queue( type || "fx", [] );
- }
-
- return this.each(function() {
- var dequeue = true,
- index = type != null && type + "queueHooks",
- timers = jQuery.timers,
- data = jQuery._data( this );
-
- if ( index ) {
- if ( data[ index ] && data[ index ].stop ) {
- stopQueue( data[ index ] );
- }
- } else {
- for ( index in data ) {
- if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
- stopQueue( data[ index ] );
- }
- }
- }
-
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
- timers[ index ].anim.stop( gotoEnd );
- dequeue = false;
- timers.splice( index, 1 );
- }
- }
-
- // start the next in the queue if the last step wasn't forced
- // timers currently will call their complete callbacks, which will dequeue
- // but only if they were gotoEnd
- if ( dequeue || !gotoEnd ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- finish: function( type ) {
- if ( type !== false ) {
- type = type || "fx";
- }
- return this.each(function() {
- var index,
- data = jQuery._data( this ),
- queue = data[ type + "queue" ],
- hooks = data[ type + "queueHooks" ],
- timers = jQuery.timers,
- length = queue ? queue.length : 0;
-
- // enable finishing flag on private data
- data.finish = true;
-
- // empty the queue first
- jQuery.queue( this, type, [] );
-
- if ( hooks && hooks.stop ) {
- hooks.stop.call( this, true );
- }
-
- // look for any active animations, and finish them
- for ( index = timers.length; index--; ) {
- if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
- timers[ index ].anim.stop( true );
- timers.splice( index, 1 );
- }
- }
-
- // look for any animations in the old queue and finish them
- for ( index = 0; index < length; index++ ) {
- if ( queue[ index ] && queue[ index ].finish ) {
- queue[ index ].finish.call( this );
- }
- }
-
- // turn off finishing flag
- delete data.finish;
- });
- }
-});
-
-jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
- var cssFn = jQuery.fn[ name ];
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return speed == null || typeof speed === "boolean" ?
- cssFn.apply( this, arguments ) :
- this.animate( genFx( name, true ), speed, easing, callback );
- };
-});
+ function genFx(type, includeWidth) {
+ var which,
+ attrs = {height: type},
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth ? 1 : 0;
+ for (; i < 4; i += 2 - includeWidth) {
+ which = cssExpand[i];
+ attrs["margin" + which] = attrs["padding" + which] = type;
+ }
+
+ if (includeWidth) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+ }
+
+ function createTween(value, prop, animation) {
+ var tween,
+ collection = ( tweeners[prop] || [] ).concat(tweeners["*"]),
+ index = 0,
+ length = collection.length;
+ for (; index < length; index++) {
+ if ((tween = collection[index].call(animation, prop, value))) {
+
+ // we're done with this property
+ return tween;
+ }
+ }
+ }
+
+ function defaultPrefilter(elem, props, opts) {
+ /* jshint validthis: true */
+ var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
+ anim = this,
+ orig = {},
+ style = elem.style,
+ hidden = elem.nodeType && isHidden(elem),
+ dataShow = jQuery._data(elem, "fxshow");
+
+ // handle queue: false promises
+ if (!opts.queue) {
+ hooks = jQuery._queueHooks(elem, "fx");
+ if (hooks.unqueued == null) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function () {
+ if (!hooks.unqueued) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always(function () {
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always(function () {
+ hooks.unqueued--;
+ if (!jQuery.queue(elem, "fx").length) {
+ hooks.empty.fire();
+ }
+ });
+ });
+ }
+
+ // height/width overflow pass
+ if (elem.nodeType === 1 && ( "height" in props || "width" in props )) {
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [style.overflow, style.overflowX, style.overflowY];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ display = jQuery.css(elem, "display");
+
+ // Test default display if display is currently "none"
+ checkDisplay = display === "none" ?
+ jQuery._data(elem, "olddisplay") || defaultDisplay(elem.nodeName) : display;
+
+ if (checkDisplay === "inline" && jQuery.css(elem, "float") === "none") {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if (!support.inlineBlockNeedsLayout || defaultDisplay(elem.nodeName) === "inline") {
+ style.display = "inline-block";
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if (opts.overflow) {
+ style.overflow = "hidden";
+ if (!support.shrinkWrapBlocks()) {
+ anim.always(function () {
+ style.overflow = opts.overflow[0];
+ style.overflowX = opts.overflow[1];
+ style.overflowY = opts.overflow[2];
+ });
+ }
+ }
+
+ // show/hide pass
+ for (prop in props) {
+ value = props[prop];
+ if (rfxtypes.exec(value)) {
+ delete props[prop];
+ toggle = toggle || value === "toggle";
+ if (value === ( hidden ? "hide" : "show" )) {
+
+ // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
+ if (value === "show" && dataShow && dataShow[prop] !== undefined) {
+ hidden = true;
+ } else {
+ continue;
+ }
+ }
+ orig[prop] = dataShow && dataShow[prop] || jQuery.style(elem, prop);
+
+ // Any non-fx value stops us from restoring the original display value
+ } else {
+ display = undefined;
+ }
+ }
+
+ if (!jQuery.isEmptyObject(orig)) {
+ if (dataShow) {
+ if ("hidden" in dataShow) {
+ hidden = dataShow.hidden;
+ }
+ } else {
+ dataShow = jQuery._data(elem, "fxshow", {});
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if (toggle) {
+ dataShow.hidden = !hidden;
+ }
+ if (hidden) {
+ jQuery(elem).show();
+ } else {
+ anim.done(function () {
+ jQuery(elem).hide();
+ });
+ }
+ anim.done(function () {
+ var prop;
+ jQuery._removeData(elem, "fxshow");
+ for (prop in orig) {
+ jQuery.style(elem, prop, orig[prop]);
+ }
+ });
+ for (prop in orig) {
+ tween = createTween(hidden ? dataShow[prop] : 0, prop, anim);
+
+ if (!( prop in dataShow )) {
+ dataShow[prop] = tween.start;
+ if (hidden) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+
+ // If this is a noop like .hide().hide(), restore an overwritten display value
+ } else if ((display === "none" ? defaultDisplay(elem.nodeName) : display) === "inline") {
+ style.display = display;
+ }
+ }
+
+ function propFilter(props, specialEasing) {
+ var index, name, easing, value, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for (index in props) {
+ name = jQuery.camelCase(index);
+ easing = specialEasing[name];
+ value = props[index];
+ if (jQuery.isArray(value)) {
+ easing = value[1];
+ value = props[index] = value[0];
+ }
+
+ if (index !== name) {
+ props[name] = value;
+ delete props[index];
+ }
+
+ hooks = jQuery.cssHooks[name];
+ if (hooks && "expand" in hooks) {
+ value = hooks.expand(value);
+ delete props[name];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for (index in value) {
+ if (!( index in props )) {
+ props[index] = value[index];
+ specialEasing[index] = easing;
+ }
+ }
+ } else {
+ specialEasing[name] = easing;
+ }
+ }
+ }
+
+ function Animation(elem, properties, options) {
+ var result,
+ stopped,
+ index = 0,
+ length = animationPrefilters.length,
+ deferred = jQuery.Deferred().always(function () {
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ }),
+ tick = function () {
+ if (stopped) {
+ return false;
+ }
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max(0, animation.startTime + animation.duration - currentTime),
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for (; index < length; index++) {
+ animation.tweens[index].run(percent);
+ }
+
+ deferred.notifyWith(elem, [animation, percent, remaining]);
+
+ if (percent < 1 && length) {
+ return remaining;
+ } else {
+ deferred.resolveWith(elem, [animation]);
+ return false;
+ }
+ },
+ animation = deferred.promise({
+ elem: elem,
+ props: jQuery.extend({}, properties),
+ opts: jQuery.extend(true, {specialEasing: {}}, options),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function (prop, end) {
+ var tween = jQuery.Tween(elem, animation.opts, prop, end,
+ animation.opts.specialEasing[prop] || animation.opts.easing);
+ animation.tweens.push(tween);
+ return tween;
+ },
+ stop: function (gotoEnd) {
+ var index = 0,
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+ if (stopped) {
+ return this;
+ }
+ stopped = true;
+ for (; index < length; index++) {
+ animation.tweens[index].run(1);
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if (gotoEnd) {
+ deferred.resolveWith(elem, [animation, gotoEnd]);
+ } else {
+ deferred.rejectWith(elem, [animation, gotoEnd]);
+ }
+ return this;
+ }
+ }),
+ props = animation.props;
+
+ propFilter(props, animation.opts.specialEasing);
+
+ for (; index < length; index++) {
+ result = animationPrefilters[index].call(animation, elem, props, animation.opts);
+ if (result) {
+ return result;
+ }
+ }
+
+ jQuery.map(props, createTween, animation);
+
+ if (jQuery.isFunction(animation.opts.start)) {
+ animation.opts.start.call(elem, animation);
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend(tick, {
+ elem: elem,
+ anim: animation,
+ queue: animation.opts.queue
+ })
+ );
+
+ // attach callbacks from options
+ return animation.progress(animation.opts.progress)
+ .done(animation.opts.done, animation.opts.complete)
+ .fail(animation.opts.fail)
+ .always(animation.opts.always);
+ }
+
+ jQuery.Animation = jQuery.extend(Animation, {
+ tweener: function (props, callback) {
+ if (jQuery.isFunction(props)) {
+ callback = props;
+ props = ["*"];
+ } else {
+ props = props.split(" ");
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for (; index < length; index++) {
+ prop = props[index];
+ tweeners[prop] = tweeners[prop] || [];
+ tweeners[prop].unshift(callback);
+ }
+ },
+
+ prefilter: function (callback, prepend) {
+ if (prepend) {
+ animationPrefilters.unshift(callback);
+ } else {
+ animationPrefilters.push(callback);
+ }
+ }
+ });
+
+ jQuery.speed = function (speed, easing, fn) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction(speed) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if (opt.queue == null || opt.queue === true) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function () {
+ if (jQuery.isFunction(opt.old)) {
+ opt.old.call(this);
+ }
+
+ if (opt.queue) {
+ jQuery.dequeue(this, opt.queue);
+ }
+ };
+
+ return opt;
+ };
+
+ jQuery.fn.extend({
+ fadeTo: function (speed, to, easing, callback) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter(isHidden).css("opacity", 0).show()
+
+ // animate to the value specified
+ .end().animate({opacity: to}, speed, easing, callback);
+ },
+ animate: function (prop, speed, easing, callback) {
+ var empty = jQuery.isEmptyObject(prop),
+ optall = jQuery.speed(speed, easing, callback),
+ doAnimation = function () {
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation(this, jQuery.extend({}, prop), optall);
+
+ // Empty animations, or finishing resolves immediately
+ if (empty || jQuery._data(this, "finish")) {
+ anim.stop(true);
+ }
+ };
+ doAnimation.finish = doAnimation;
+
+ return empty || optall.queue === false ?
+ this.each(doAnimation) :
+ this.queue(optall.queue, doAnimation);
+ },
+ stop: function (type, clearQueue, gotoEnd) {
+ var stopQueue = function (hooks) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop(gotoEnd);
+ };
+
+ if (typeof type !== "string") {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if (clearQueue && type !== false) {
+ this.queue(type || "fx", []);
+ }
+
+ return this.each(function () {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data(this);
+
+ if (index) {
+ if (data[index] && data[index].stop) {
+ stopQueue(data[index]);
+ }
+ } else {
+ for (index in data) {
+ if (data[index] && data[index].stop && rrun.test(index)) {
+ stopQueue(data[index]);
+ }
+ }
+ }
+
+ for (index = timers.length; index--;) {
+ if (timers[index].elem === this && (type == null || timers[index].queue === type)) {
+ timers[index].anim.stop(gotoEnd);
+ dequeue = false;
+ timers.splice(index, 1);
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if (dequeue || !gotoEnd) {
+ jQuery.dequeue(this, type);
+ }
+ });
+ },
+ finish: function (type) {
+ if (type !== false) {
+ type = type || "fx";
+ }
+ return this.each(function () {
+ var index,
+ data = jQuery._data(this),
+ queue = data[type + "queue"],
+ hooks = data[type + "queueHooks"],
+ timers = jQuery.timers,
+ length = queue ? queue.length : 0;
+
+ // enable finishing flag on private data
+ data.finish = true;
+
+ // empty the queue first
+ jQuery.queue(this, type, []);
+
+ if (hooks && hooks.stop) {
+ hooks.stop.call(this, true);
+ }
+
+ // look for any active animations, and finish them
+ for (index = timers.length; index--;) {
+ if (timers[index].elem === this && timers[index].queue === type) {
+ timers[index].anim.stop(true);
+ timers.splice(index, 1);
+ }
+ }
+
+ // look for any animations in the old queue and finish them
+ for (index = 0; index < length; index++) {
+ if (queue[index] && queue[index].finish) {
+ queue[index].finish.call(this);
+ }
+ }
+
+ // turn off finishing flag
+ delete data.finish;
+ });
+ }
+ });
+
+ jQuery.each(["toggle", "show", "hide"], function (i, name) {
+ var cssFn = jQuery.fn[name];
+ jQuery.fn[name] = function (speed, easing, callback) {
+ return speed == null || typeof speed === "boolean" ?
+ cssFn.apply(this, arguments) :
+ this.animate(genFx(name, true), speed, easing, callback);
+ };
+ });
// Generate shortcuts for custom animations
-jQuery.each({
- slideDown: genFx("show"),
- slideUp: genFx("hide"),
- slideToggle: genFx("toggle"),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
-}, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
-});
-
-jQuery.timers = [];
-jQuery.fx.tick = function() {
- var timer,
- timers = jQuery.timers,
- i = 0;
-
- fxNow = jQuery.now();
-
- for ( ; i < timers.length; i++ ) {
- timer = timers[ i ];
- // Checks the timer has not already been removed
- if ( !timer() && timers[ i ] === timer ) {
- timers.splice( i--, 1 );
- }
- }
-
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
- fxNow = undefined;
-};
-
-jQuery.fx.timer = function( timer ) {
- jQuery.timers.push( timer );
- if ( timer() ) {
- jQuery.fx.start();
- } else {
- jQuery.timers.pop();
- }
-};
-
-jQuery.fx.interval = 13;
-
-jQuery.fx.start = function() {
- if ( !timerId ) {
- timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
- }
-};
-
-jQuery.fx.stop = function() {
- clearInterval( timerId );
- timerId = null;
-};
-
-jQuery.fx.speeds = {
- slow: 600,
- fast: 200,
- // Default speed
- _default: 400
-};
+ jQuery.each({
+ slideDown: genFx("show"),
+ slideUp: genFx("hide"),
+ slideToggle: genFx("toggle"),
+ fadeIn: {opacity: "show"},
+ fadeOut: {opacity: "hide"},
+ fadeToggle: {opacity: "toggle"}
+ }, function (name, props) {
+ jQuery.fn[name] = function (speed, easing, callback) {
+ return this.animate(props, speed, easing, callback);
+ };
+ });
+
+ jQuery.timers = [];
+ jQuery.fx.tick = function () {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ fxNow = jQuery.now();
+
+ for (; i < timers.length; i++) {
+ timer = timers[i];
+ // Checks the timer has not already been removed
+ if (!timer() && timers[i] === timer) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if (!timers.length) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+ };
+
+ jQuery.fx.timer = function (timer) {
+ jQuery.timers.push(timer);
+ if (timer()) {
+ jQuery.fx.start();
+ } else {
+ jQuery.timers.pop();
+ }
+ };
+
+ jQuery.fx.interval = 13;
+
+ jQuery.fx.start = function () {
+ if (!timerId) {
+ timerId = setInterval(jQuery.fx.tick, jQuery.fx.interval);
+ }
+ };
+
+ jQuery.fx.stop = function () {
+ clearInterval(timerId);
+ timerId = null;
+ };
+
+ jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ };
// Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/
-jQuery.fn.delay = function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
+ jQuery.fn.delay = function (time, type) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
- return this.queue( type, function( next, hooks ) {
- var timeout = setTimeout( next, time );
- hooks.stop = function() {
- clearTimeout( timeout );
- };
- });
-};
+ return this.queue(type, function (next, hooks) {
+ var timeout = setTimeout(next, time);
+ hooks.stop = function () {
+ clearTimeout(timeout);
+ };
+ });
+ };
-(function() {
- // Minified: var a,b,c,d,e
- var input, div, select, a, opt;
-
- // Setup
- div = document.createElement( "div" );
- div.setAttribute( "className", "t" );
- div.innerHTML = " a ";
- a = div.getElementsByTagName("a")[ 0 ];
-
- // First batch of tests.
- select = document.createElement("select");
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName("input")[ 0 ];
-
- a.style.cssText = "top:1px";
-
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- support.getSetAttribute = div.className !== "t";
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- support.style = /top/.test( a.getAttribute("style") );
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- support.hrefNormalized = a.getAttribute("href") === "/a";
-
- // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
- support.checkOn = !!input.value;
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- support.optSelected = opt.selected;
-
- // Tests for enctype support on a form (#6743)
- support.enctype = !!document.createElement("form").enctype;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Support: IE8 only
- // Check if we can trust getAttribute("value")
- input = document.createElement( "input" );
- input.setAttribute( "value", "" );
- support.input = input.getAttribute( "value" ) === "";
-
- // Check if an input maintains its value after becoming a radio
- input.value = "t";
- input.setAttribute( "type", "radio" );
- support.radioValue = input.value === "t";
-})();
-
-
-var rreturn = /\r/g;
-
-jQuery.fn.extend({
- val: function( value ) {
- var hooks, ret, isFunction,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var val;
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, jQuery( this ).val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map( val, function( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- var val = jQuery.find.attr( elem, "value" );
- return val != null ?
- val :
- // Support: IE10-11+
- // option.text throws exceptions (#14686, #14858)
- jQuery.trim( jQuery.text( elem ) );
- }
- },
- select: {
- get: function( elem ) {
- var value, option,
- options = elem.options,
- index = elem.selectedIndex,
- one = elem.type === "select-one" || index < 0,
- values = one ? null : [],
- max = one ? index + 1 : options.length,
- i = index < 0 ?
- max :
- one ? index : 0;
-
- // Loop through all the selected options
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // oldIE doesn't update selected after form reset (#2551)
- if ( ( option.selected || i === index ) &&
- // Don't return options that are disabled or in a disabled optgroup
- ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
- ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var optionSet, option,
- options = elem.options,
- values = jQuery.makeArray( value ),
- i = options.length;
-
- while ( i-- ) {
- option = options[ i ];
-
- if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
-
- // Support: IE6
- // When new option element is added to select box we need to
- // force reflow of newly added node in order to workaround delay
- // of initialization properties
- try {
- option.selected = optionSet = true;
-
- } catch ( _ ) {
-
- // Will be executed only in IE6
- option.scrollHeight;
- }
-
- } else {
- option.selected = false;
- }
- }
-
- // Force browsers to behave consistently when non-matching value is set
- if ( !optionSet ) {
- elem.selectedIndex = -1;
- }
-
- return options;
- }
- }
- }
-});
+ (function () {
+ // Minified: var a,b,c,d,e
+ var input, div, select, a, opt;
+
+ // Setup
+ div = document.createElement("div");
+ div.setAttribute("className", "t");
+ div.innerHTML = " a ";
+ a = div.getElementsByTagName("a")[0];
+
+ // First batch of tests.
+ select = document.createElement("select");
+ opt = select.appendChild(document.createElement("option"));
+ input = div.getElementsByTagName("input")[0];
+
+ a.style.cssText = "top:1px";
+
+ // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ support.getSetAttribute = div.className !== "t";
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ support.style = /top/.test(a.getAttribute("style"));
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ support.hrefNormalized = a.getAttribute("href") === "/a";
+
+ // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
+ support.checkOn = !!input.value;
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ support.optSelected = opt.selected;
+
+ // Tests for enctype support on a form (#6743)
+ support.enctype = !!document.createElement("form").enctype;
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as disabled)
+ select.disabled = true;
+ support.optDisabled = !opt.disabled;
+
+ // Support: IE8 only
+ // Check if we can trust getAttribute("value")
+ input = document.createElement("input");
+ input.setAttribute("value", "");
+ support.input = input.getAttribute("value") === "";
+
+ // Check if an input maintains its value after becoming a radio
+ input.value = "t";
+ input.setAttribute("type", "radio");
+ support.radioValue = input.value === "t";
+ })();
+
+
+ var rreturn = /\r/g;
+
+ jQuery.fn.extend({
+ val: function (value) {
+ var hooks, ret, isFunction,
+ elem = this[0];
+
+ if (!arguments.length) {
+ if (elem) {
+ hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()];
+
+ if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction(value);
+
+ return this.each(function (i) {
+ var val;
+
+ if (this.nodeType !== 1) {
+ return;
+ }
+
+ if (isFunction) {
+ val = value.call(this, i, jQuery(this).val());
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if (val == null) {
+ val = "";
+ } else if (typeof val === "number") {
+ val += "";
+ } else if (jQuery.isArray(val)) {
+ val = jQuery.map(val, function (value) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[this.type] || jQuery.valHooks[this.nodeName.toLowerCase()];
+
+ // If set returns undefined, fall back to normal setting
+ if (!hooks || !("set" in hooks) || hooks.set(this, val, "value") === undefined) {
+ this.value = val;
+ }
+ });
+ }
+ });
+
+ jQuery.extend({
+ valHooks: {
+ option: {
+ get: function (elem) {
+ var val = jQuery.find.attr(elem, "value");
+ return val != null ?
+ val :
+ // Support: IE10-11+
+ // option.text throws exceptions (#14686, #14858)
+ jQuery.trim(jQuery.text(elem));
+ }
+ },
+ select: {
+ get: function (elem) {
+ var value, option,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
+
+ // Loop through all the selected options
+ for (; i < max; i++) {
+ option = options[i];
+
+ // oldIE doesn't update selected after form reset (#2551)
+ if (( option.selected || i === index ) &&
+ // Don't return options that are disabled or in a disabled optgroup
+ ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+ ( !option.parentNode.disabled || !jQuery.nodeName(option.parentNode, "optgroup") )) {
+
+ // Get the specific value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if (one) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push(value);
+ }
+ }
+
+ return values;
+ },
+
+ set: function (elem, value) {
+ var optionSet, option,
+ options = elem.options,
+ values = jQuery.makeArray(value),
+ i = options.length;
+
+ while (i--) {
+ option = options[i];
+
+ if (jQuery.inArray(jQuery.valHooks.option.get(option), values) >= 0) {
+
+ // Support: IE6
+ // When new option element is added to select box we need to
+ // force reflow of newly added node in order to workaround delay
+ // of initialization properties
+ try {
+ option.selected = optionSet = true;
+
+ } catch (_) {
+
+ // Will be executed only in IE6
+ option.scrollHeight;
+ }
+
+ } else {
+ option.selected = false;
+ }
+ }
+
+ // Force browsers to behave consistently when non-matching value is set
+ if (!optionSet) {
+ elem.selectedIndex = -1;
+ }
+
+ return options;
+ }
+ }
+ }
+ });
// Radios and checkboxes getter/setter
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
- }
- }
- };
- if ( !support.checkOn ) {
- jQuery.valHooks[ this ].get = function( elem ) {
- // Support: Webkit
- // "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- };
- }
-});
-
-
-
-
-var nodeHook, boolHook,
- attrHandle = jQuery.expr.attrHandle,
- ruseDefault = /^(?:checked|selected)$/i,
- getSetAttribute = support.getSetAttribute,
- getSetInput = support.input;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- }
-});
-
-jQuery.extend({
- attr: function( elem, name, value ) {
- var hooks, ret,
- nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === strundefined ) {
- return jQuery.prop( elem, name, value );
- }
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] ||
- ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
-
- } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- ret = jQuery.find.attr( elem, name );
-
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, value ) {
- var name, propName,
- i = 0,
- attrNames = value && value.match( rnotwhite );
-
- if ( attrNames && elem.nodeType === 1 ) {
- while ( (name = attrNames[i++]) ) {
- propName = jQuery.propFix[ name ] || name;
-
- // Boolean attributes get special treatment (#10870)
- if ( jQuery.expr.match.bool.test( name ) ) {
- // Set corresponding property to false
- if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
- elem[ propName ] = false;
- // Support: IE<9
- // Also clear defaultChecked/defaultSelected (if appropriate)
- } else {
- elem[ jQuery.camelCase( "default-" + name ) ] =
- elem[ propName ] = false;
- }
-
- // See #9699 for explanation of this approach (setting first, then removal)
- } else {
- jQuery.attr( elem, name, "" );
- }
-
- elem.removeAttribute( getSetAttribute ? name : propName );
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to default in case type is set after value during creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- }
-});
+ jQuery.each(["radio", "checkbox"], function () {
+ jQuery.valHooks[this] = {
+ set: function (elem, value) {
+ if (jQuery.isArray(value)) {
+ return ( elem.checked = jQuery.inArray(jQuery(elem).val(), value) >= 0 );
+ }
+ }
+ };
+ if (!support.checkOn) {
+ jQuery.valHooks[this].get = function (elem) {
+ // Support: Webkit
+ // "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ };
+ }
+ });
+
+
+ var nodeHook, boolHook,
+ attrHandle = jQuery.expr.attrHandle,
+ ruseDefault = /^(?:checked|selected)$/i,
+ getSetAttribute = support.getSetAttribute,
+ getSetInput = support.input;
+
+ jQuery.fn.extend({
+ attr: function (name, value) {
+ return access(this, jQuery.attr, name, value, arguments.length > 1);
+ },
+
+ removeAttr: function (name) {
+ return this.each(function () {
+ jQuery.removeAttr(this, name);
+ });
+ }
+ });
+
+ jQuery.extend({
+ attr: function (elem, name, value) {
+ var hooks, ret,
+ nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if (!elem || nType === 3 || nType === 8 || nType === 2) {
+ return;
+ }
+
+ // Fallback to prop when attributes are not supported
+ if (typeof elem.getAttribute === strundefined) {
+ return jQuery.prop(elem, name, value);
+ }
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if (nType !== 1 || !jQuery.isXMLDoc(elem)) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[name] ||
+ ( jQuery.expr.match.bool.test(name) ? boolHook : nodeHook );
+ }
+
+ if (value !== undefined) {
+
+ if (value === null) {
+ jQuery.removeAttr(elem, name);
+
+ } else if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) {
+ return ret;
+
+ } else {
+ elem.setAttribute(name, value + "");
+ return value;
+ }
+
+ } else if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) {
+ return ret;
+
+ } else {
+ ret = jQuery.find.attr(elem, name);
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == null ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function (elem, value) {
+ var name, propName,
+ i = 0,
+ attrNames = value && value.match(rnotwhite);
+
+ if (attrNames && elem.nodeType === 1) {
+ while ((name = attrNames[i++])) {
+ propName = jQuery.propFix[name] || name;
+
+ // Boolean attributes get special treatment (#10870)
+ if (jQuery.expr.match.bool.test(name)) {
+ // Set corresponding property to false
+ if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
+ elem[propName] = false;
+ // Support: IE<9
+ // Also clear defaultChecked/defaultSelected (if appropriate)
+ } else {
+ elem[jQuery.camelCase("default-" + name)] =
+ elem[propName] = false;
+ }
+
+ // See #9699 for explanation of this approach (setting first, then removal)
+ } else {
+ jQuery.attr(elem, name, "");
+ }
+
+ elem.removeAttribute(getSetAttribute ? name : propName);
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function (elem, value) {
+ if (!support.radioValue && value === "radio" && jQuery.nodeName(elem, "input")) {
+ // Setting the type on a radio button after the value resets the value in IE6-9
+ // Reset value to default in case type is set after value during creation
+ var val = elem.value;
+ elem.setAttribute("type", value);
+ if (val) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ }
+ }
+ });
// Hook for boolean attributes
-boolHook = {
- set: function( elem, value, name ) {
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
- // IE<8 needs the *property* name
- elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
-
- // Use defaultChecked and defaultSelected for oldIE
- } else {
- elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
- }
-
- return name;
- }
-};
+ boolHook = {
+ set: function (elem, value, name) {
+ if (value === false) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr(elem, name);
+ } else if (getSetInput && getSetAttribute || !ruseDefault.test(name)) {
+ // IE<8 needs the *property* name
+ elem.setAttribute(!getSetAttribute && jQuery.propFix[name] || name, name);
+
+ // Use defaultChecked and defaultSelected for oldIE
+ } else {
+ elem[jQuery.camelCase("default-" + name)] = elem[name] = true;
+ }
+
+ return name;
+ }
+ };
// Retrieve booleans specially
-jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
-
- var getter = attrHandle[ name ] || jQuery.find.attr;
-
- attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
- function( elem, name, isXML ) {
- var ret, handle;
- if ( !isXML ) {
- // Avoid an infinite loop by temporarily removing this function from the getter
- handle = attrHandle[ name ];
- attrHandle[ name ] = ret;
- ret = getter( elem, name, isXML ) != null ?
- name.toLowerCase() :
- null;
- attrHandle[ name ] = handle;
- }
- return ret;
- } :
- function( elem, name, isXML ) {
- if ( !isXML ) {
- return elem[ jQuery.camelCase( "default-" + name ) ] ?
- name.toLowerCase() :
- null;
- }
- };
-});
+ jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g), function (i, name) {
+
+ var getter = attrHandle[name] || jQuery.find.attr;
+
+ attrHandle[name] = getSetInput && getSetAttribute || !ruseDefault.test(name) ?
+ function (elem, name, isXML) {
+ var ret, handle;
+ if (!isXML) {
+ // Avoid an infinite loop by temporarily removing this function from the getter
+ handle = attrHandle[name];
+ attrHandle[name] = ret;
+ ret = getter(elem, name, isXML) != null ?
+ name.toLowerCase() :
+ null;
+ attrHandle[name] = handle;
+ }
+ return ret;
+ } :
+ function (elem, name, isXML) {
+ if (!isXML) {
+ return elem[jQuery.camelCase("default-" + name)] ?
+ name.toLowerCase() :
+ null;
+ }
+ };
+ });
// fix oldIE attroperties
-if ( !getSetInput || !getSetAttribute ) {
- jQuery.attrHooks.value = {
- set: function( elem, value, name ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
- // Does not return so that setAttribute is also used
- elem.defaultValue = value;
- } else {
- // Use nodeHook if defined (#1954); otherwise setAttribute is fine
- return nodeHook && nodeHook.set( elem, value, name );
- }
- }
- };
-}
+ if (!getSetInput || !getSetAttribute) {
+ jQuery.attrHooks.value = {
+ set: function (elem, value, name) {
+ if (jQuery.nodeName(elem, "input")) {
+ // Does not return so that setAttribute is also used
+ elem.defaultValue = value;
+ } else {
+ // Use nodeHook if defined (#1954); otherwise setAttribute is fine
+ return nodeHook && nodeHook.set(elem, value, name);
+ }
+ }
+ };
+ }
// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !getSetAttribute ) {
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = {
- set: function( elem, value, name ) {
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- elem.setAttributeNode(
- (ret = elem.ownerDocument.createAttribute( name ))
- );
- }
-
- ret.value = value += "";
-
- // Break association with cloned elements by also using setAttribute (#9646)
- if ( name === "value" || value === elem.getAttribute( name ) ) {
- return value;
- }
- }
- };
-
- // Some attributes are constructed with empty-string values when not defined
- attrHandle.id = attrHandle.name = attrHandle.coords =
- function( elem, name, isXML ) {
- var ret;
- if ( !isXML ) {
- return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
- ret.value :
- null;
- }
- };
-
- // Fixing value retrieval on a button requires this module
- jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret = elem.getAttributeNode( name );
- if ( ret && ret.specified ) {
- return ret.value;
- }
- },
- set: nodeHook.set
- };
-
- // Set contenteditable to false on removals(#10429)
- // Setting to empty string throws an error as an invalid value
- jQuery.attrHooks.contenteditable = {
- set: function( elem, value, name ) {
- nodeHook.set( elem, value === "" ? false : value, name );
- }
- };
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each([ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- };
- });
-}
-
-if ( !support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
- // Return undefined in the case of empty string
- // Note: IE uppercases css property names, but if we were to .toLowerCase()
- // .cssText, that would destroy case senstitivity in URL's, like in "background"
- return elem.style.cssText || undefined;
- },
- set: function( elem, value ) {
- return ( elem.style.cssText = value + "" );
- }
- };
-}
-
-
-
-
-var rfocusable = /^(?:input|select|textarea|button|object)$/i,
- rclickable = /^(?:a|area)$/i;
-
-jQuery.fn.extend({
- prop: function( name, value ) {
- return access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each(function() {
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch( e ) {}
- });
- }
-});
-
-jQuery.extend({
- propFix: {
- "for": "htmlFor",
- "class": "className"
- },
-
- prop: function( elem, name, value ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
- ret :
- ( elem[ name ] = value );
-
- } else {
- return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
- ret :
- elem[ name ];
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- // Use proper attribute retrieval(#12072)
- var tabindex = jQuery.find.attr( elem, "tabindex" );
-
- return tabindex ?
- parseInt( tabindex, 10 ) :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- -1;
- }
- }
- }
-});
+ if (!getSetAttribute) {
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = {
+ set: function (elem, value, name) {
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode(name);
+ if (!ret) {
+ elem.setAttributeNode(
+ (ret = elem.ownerDocument.createAttribute(name))
+ );
+ }
+
+ ret.value = value += "";
+
+ // Break association with cloned elements by also using setAttribute (#9646)
+ if (name === "value" || value === elem.getAttribute(name)) {
+ return value;
+ }
+ }
+ };
+
+ // Some attributes are constructed with empty-string values when not defined
+ attrHandle.id = attrHandle.name = attrHandle.coords =
+ function (elem, name, isXML) {
+ var ret;
+ if (!isXML) {
+ return (ret = elem.getAttributeNode(name)) && ret.value !== "" ?
+ ret.value :
+ null;
+ }
+ };
+
+ // Fixing value retrieval on a button requires this module
+ jQuery.valHooks.button = {
+ get: function (elem, name) {
+ var ret = elem.getAttributeNode(name);
+ if (ret && ret.specified) {
+ return ret.value;
+ }
+ },
+ set: nodeHook.set
+ };
+
+ // Set contenteditable to false on removals(#10429)
+ // Setting to empty string throws an error as an invalid value
+ jQuery.attrHooks.contenteditable = {
+ set: function (elem, value, name) {
+ nodeHook.set(elem, value === "" ? false : value, name);
+ }
+ };
+
+ // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+ // This is for removals
+ jQuery.each(["width", "height"], function (i, name) {
+ jQuery.attrHooks[name] = {
+ set: function (elem, value) {
+ if (value === "") {
+ elem.setAttribute(name, "auto");
+ return value;
+ }
+ }
+ };
+ });
+ }
+
+ if (!support.style) {
+ jQuery.attrHooks.style = {
+ get: function (elem) {
+ // Return undefined in the case of empty string
+ // Note: IE uppercases css property names, but if we were to .toLowerCase()
+ // .cssText, that would destroy case senstitivity in URL's, like in "background"
+ return elem.style.cssText || undefined;
+ },
+ set: function (elem, value) {
+ return ( elem.style.cssText = value + "" );
+ }
+ };
+ }
+
+
+ var rfocusable = /^(?:input|select|textarea|button|object)$/i,
+ rclickable = /^(?:a|area)$/i;
+
+ jQuery.fn.extend({
+ prop: function (name, value) {
+ return access(this, jQuery.prop, name, value, arguments.length > 1);
+ },
+
+ removeProp: function (name) {
+ name = jQuery.propFix[name] || name;
+ return this.each(function () {
+ // try/catch handles cases where IE balks (such as removing a property on window)
+ try {
+ this[name] = undefined;
+ delete this[name];
+ } catch (e) {
+ }
+ });
+ }
+ });
+
+ jQuery.extend({
+ propFix: {
+ "for": "htmlFor",
+ "class": "className"
+ },
+
+ prop: function (elem, name, value) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if (!elem || nType === 3 || nType === 8 || nType === 2) {
+ return;
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc(elem);
+
+ if (notxml) {
+ // Fix name and attach hooks
+ name = jQuery.propFix[name] || name;
+ hooks = jQuery.propHooks[name];
+ }
+
+ if (value !== undefined) {
+ return hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined ?
+ ret :
+ ( elem[name] = value );
+
+ } else {
+ return hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null ?
+ ret :
+ elem[name];
+ }
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function (elem) {
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ // Use proper attribute retrieval(#12072)
+ var tabindex = jQuery.find.attr(elem, "tabindex");
+
+ return tabindex ?
+ parseInt(tabindex, 10) :
+ rfocusable.test(elem.nodeName) || rclickable.test(elem.nodeName) && elem.href ?
+ 0 :
+ -1;
+ }
+ }
+ }
+ });
// Some attributes require a special call on IE
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !support.hrefNormalized ) {
- // href/src property should get the full normalized URL (#10299/#12915)
- jQuery.each([ "href", "src" ], function( i, name ) {
- jQuery.propHooks[ name ] = {
- get: function( elem ) {
- return elem.getAttribute( name, 4 );
- }
- };
- });
-}
+ if (!support.hrefNormalized) {
+ // href/src property should get the full normalized URL (#10299/#12915)
+ jQuery.each(["href", "src"], function (i, name) {
+ jQuery.propHooks[name] = {
+ get: function (elem) {
+ return elem.getAttribute(name, 4);
+ }
+ };
+ });
+ }
// Support: Safari, IE9+
// mis-reports the default selected property of an option
// Accessing the parent's selectedIndex property fixes it
-if ( !support.optSelected ) {
- jQuery.propHooks.selected = {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- }
- };
-}
-
-jQuery.each([
- "tabIndex",
- "readOnly",
- "maxLength",
- "cellSpacing",
- "cellPadding",
- "rowSpan",
- "colSpan",
- "useMap",
- "frameBorder",
- "contentEditable"
-], function() {
- jQuery.propFix[ this.toLowerCase() ] = this;
-});
+ if (!support.optSelected) {
+ jQuery.propHooks.selected = {
+ get: function (elem) {
+ var parent = elem.parentNode;
+
+ if (parent) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if (parent.parentNode) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ return null;
+ }
+ };
+ }
+
+ jQuery.each([
+ "tabIndex",
+ "readOnly",
+ "maxLength",
+ "cellSpacing",
+ "cellPadding",
+ "rowSpan",
+ "colSpan",
+ "useMap",
+ "frameBorder",
+ "contentEditable"
+ ], function () {
+ jQuery.propFix[this.toLowerCase()] = this;
+ });
// IE6/7 call enctype encoding
-if ( !support.enctype ) {
- jQuery.propFix.enctype = "encoding";
-}
-
-
-
-
-var rclass = /[\t\r\n\f]/g;
-
-jQuery.fn.extend({
- addClass: function( value ) {
- var classes, elem, cur, clazz, j, finalValue,
- i = 0,
- len = this.length,
- proceed = typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call( this, j, this.className ) );
- });
- }
-
- if ( proceed ) {
- // The disjunction here is for better compressibility (see removeClass)
- classes = ( value || "" ).match( rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- " "
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
- cur += clazz + " ";
- }
- }
-
- // only assign if different to avoid unneeded rendering.
- finalValue = jQuery.trim( cur );
- if ( elem.className !== finalValue ) {
- elem.className = finalValue;
- }
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classes, elem, cur, clazz, j, finalValue,
- i = 0,
- len = this.length,
- proceed = arguments.length === 0 || typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call( this, j, this.className ) );
- });
- }
- if ( proceed ) {
- classes = ( value || "" ).match( rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- // This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- ""
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- // Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
- cur = cur.replace( " " + clazz + " ", " " );
- }
- }
-
- // only assign if different to avoid unneeded rendering.
- finalValue = value ? jQuery.trim( cur ) : "";
- if ( elem.className !== finalValue ) {
- elem.className = finalValue;
- }
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value;
-
- if ( typeof stateVal === "boolean" && type === "string" ) {
- return stateVal ? this.addClass( value ) : this.removeClass( value );
- }
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- classNames = value.match( rnotwhite ) || [];
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space separated list
- if ( self.hasClass( className ) ) {
- self.removeClass( className );
- } else {
- self.addClass( className );
- }
- }
-
- // Toggle whole class name
- } else if ( type === strundefined || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
-
- // If the element has a class name or if we're passed "false",
- // then remove the whole classname (if there was one, the above saved it).
- // Otherwise bring back whatever was previously saved (if anything),
- // falling back to the empty string if nothing was stored.
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
- return true;
- }
- }
-
- return false;
- }
-});
-
-
+ if (!support.enctype) {
+ jQuery.propFix.enctype = "encoding";
+ }
+
+
+ var rclass = /[\t\r\n\f]/g;
+
+ jQuery.fn.extend({
+ addClass: function (value) {
+ var classes, elem, cur, clazz, j, finalValue,
+ i = 0,
+ len = this.length,
+ proceed = typeof value === "string" && value;
+
+ if (jQuery.isFunction(value)) {
+ return this.each(function (j) {
+ jQuery(this).addClass(value.call(this, j, this.className));
+ });
+ }
+
+ if (proceed) {
+ // The disjunction here is for better compressibility (see removeClass)
+ classes = ( value || "" ).match(rnotwhite) || [];
+
+ for (; i < len; i++) {
+ elem = this[i];
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace(rclass, " ") :
+ " "
+ );
+
+ if (cur) {
+ j = 0;
+ while ((clazz = classes[j++])) {
+ if (cur.indexOf(" " + clazz + " ") < 0) {
+ cur += clazz + " ";
+ }
+ }
+
+ // only assign if different to avoid unneeded rendering.
+ finalValue = jQuery.trim(cur);
+ if (elem.className !== finalValue) {
+ elem.className = finalValue;
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function (value) {
+ var classes, elem, cur, clazz, j, finalValue,
+ i = 0,
+ len = this.length,
+ proceed = arguments.length === 0 || typeof value === "string" && value;
+
+ if (jQuery.isFunction(value)) {
+ return this.each(function (j) {
+ jQuery(this).removeClass(value.call(this, j, this.className));
+ });
+ }
+ if (proceed) {
+ classes = ( value || "" ).match(rnotwhite) || [];
+
+ for (; i < len; i++) {
+ elem = this[i];
+ // This expression is here for better compressibility (see addClass)
+ cur = elem.nodeType === 1 && ( elem.className ?
+ ( " " + elem.className + " " ).replace(rclass, " ") :
+ ""
+ );
+
+ if (cur) {
+ j = 0;
+ while ((clazz = classes[j++])) {
+ // Remove *all* instances
+ while (cur.indexOf(" " + clazz + " ") >= 0) {
+ cur = cur.replace(" " + clazz + " ", " ");
+ }
+ }
+
+ // only assign if different to avoid unneeded rendering.
+ finalValue = value ? jQuery.trim(cur) : "";
+ if (elem.className !== finalValue) {
+ elem.className = finalValue;
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function (value, stateVal) {
+ var type = typeof value;
+
+ if (typeof stateVal === "boolean" && type === "string") {
+ return stateVal ? this.addClass(value) : this.removeClass(value);
+ }
+
+ if (jQuery.isFunction(value)) {
+ return this.each(function (i) {
+ jQuery(this).toggleClass(value.call(this, i, this.className, stateVal), stateVal);
+ });
+ }
+
+ return this.each(function () {
+ if (type === "string") {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery(this),
+ classNames = value.match(rnotwhite) || [];
+
+ while ((className = classNames[i++])) {
+ // check each className given, space separated list
+ if (self.hasClass(className)) {
+ self.removeClass(className);
+ } else {
+ self.addClass(className);
+ }
+ }
+
+ // Toggle whole class name
+ } else if (type === strundefined || type === "boolean") {
+ if (this.className) {
+ // store className if set
+ jQuery._data(this, "__className__", this.className);
+ }
+
+ // If the element has a class name or if we're passed "false",
+ // then remove the whole classname (if there was one, the above saved it).
+ // Otherwise bring back whatever was previously saved (if anything),
+ // falling back to the empty string if nothing was stored.
+ this.className = this.className || value === false ? "" : jQuery._data(this, "__className__") || "";
+ }
+ });
+ },
+
+ hasClass: function (selector) {
+ var className = " " + selector + " ",
+ i = 0,
+ l = this.length;
+ for (; i < l; i++) {
+ if (this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf(className) >= 0) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ });
// Return jQuery for attributes-only inclusion
-jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
+ jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error contextmenu").split(" "), function (i, name) {
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- return arguments.length > 0 ?
- this.on( name, null, data, fn ) :
- this.trigger( name );
- };
-});
+ // Handle event binding
+ jQuery.fn[name] = function (data, fn) {
+ return arguments.length > 0 ?
+ this.on(name, null, data, fn) :
+ this.trigger(name);
+ };
+ });
-jQuery.fn.extend({
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- },
+ jQuery.fn.extend({
+ hover: function (fnOver, fnOut) {
+ return this.mouseenter(fnOver).mouseleave(fnOut || fnOver);
+ },
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
+ bind: function (types, data, fn) {
+ return this.on(types, null, data, fn);
+ },
+ unbind: function (types, fn) {
+ return this.off(types, null, fn);
+ },
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
- }
-});
+ delegate: function (selector, types, data, fn) {
+ return this.on(types, selector, data, fn);
+ },
+ undelegate: function (selector, types, fn) {
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ? this.off(selector, "**") : this.off(types, selector || "**", fn);
+ }
+ });
-var nonce = jQuery.now();
+ var nonce = jQuery.now();
-var rquery = (/\?/);
+ var rquery = (/\?/);
+ var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
-var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
+ jQuery.parseJSON = function (data) {
+ // Attempt to parse using the native JSON parser first
+ if (window.JSON && window.JSON.parse) {
+ // Support: Android 2.3
+ // Workaround failure to string-cast null input
+ return window.JSON.parse(data + "");
+ }
-jQuery.parseJSON = function( data ) {
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- // Support: Android 2.3
- // Workaround failure to string-cast null input
- return window.JSON.parse( data + "" );
- }
+ var requireNonComma,
+ depth = null,
+ str = jQuery.trim(data + "");
- var requireNonComma,
- depth = null,
- str = jQuery.trim( data + "" );
+ // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
+ // after removing valid tokens
+ return str && !jQuery.trim(str.replace(rvalidtokens, function (token, comma, open, close) {
- // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
- // after removing valid tokens
- return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
+ // Force termination if we see a misplaced comma
+ if (requireNonComma && comma) {
+ depth = 0;
+ }
- // Force termination if we see a misplaced comma
- if ( requireNonComma && comma ) {
- depth = 0;
- }
+ // Perform no more replacements after returning to outermost depth
+ if (depth === 0) {
+ return token;
+ }
- // Perform no more replacements after returning to outermost depth
- if ( depth === 0 ) {
- return token;
- }
+ // Commas must not follow "[", "{", or ","
+ requireNonComma = open || comma;
- // Commas must not follow "[", "{", or ","
- requireNonComma = open || comma;
+ // Determine new depth
+ // array/object open ("[" or "{"): depth += true - false (increment)
+ // array/object close ("]" or "}"): depth += false - true (decrement)
+ // other cases ("," or primitive): depth += true - true (numeric cast)
+ depth += !close - !open;
- // Determine new depth
- // array/object open ("[" or "{"): depth += true - false (increment)
- // array/object close ("]" or "}"): depth += false - true (decrement)
- // other cases ("," or primitive): depth += true - true (numeric cast)
- depth += !close - !open;
-
- // Remove this token
- return "";
- }) ) ?
- ( Function( "return " + str ) )() :
- jQuery.error( "Invalid JSON: " + data );
-};
+ // Remove this token
+ return "";
+ })) ?
+ ( Function("return " + str) )() :
+ jQuery.error("Invalid JSON: " + data);
+ };
// Cross-browser xml parsing
-jQuery.parseXML = function( data ) {
- var xml, tmp;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data, "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
-};
-
-
-var
- // Document location
- ajaxLocParts,
- ajaxLocation,
-
- rhash = /#.*$/,
- rts = /([?&])_=[^&]*/,
- rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
- // #7653, #8125, #8152: local protocol detection
- rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
- rnoContent = /^(?:GET|HEAD)$/,
- rprotocol = /^\/\//,
- rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
-
- /* Prefilters
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
- * 2) These are called:
- * - BEFORE asking for a transport
- * - AFTER param serialization (s.data is a string if s.processData is true)
- * 3) key is the dataType
- * 4) the catchall symbol "*" can be used
- * 5) execution will start with transport dataType and THEN continue down to "*" if needed
- */
- prefilters = {},
-
- /* Transports bindings
- * 1) key is the dataType
- * 2) the catchall symbol "*" can be used
- * 3) selection will start with transport dataType and THEN go to "*" if needed
- */
- transports = {},
-
- // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
- allTypes = "*/".concat("*");
+ jQuery.parseXML = function (data) {
+ var xml, tmp;
+ if (!data || typeof data !== "string") {
+ return null;
+ }
+ try {
+ if (window.DOMParser) { // Standard
+ tmp = new DOMParser();
+ xml = tmp.parseFromString(data, "text/xml");
+ } else { // IE
+ xml = new ActiveXObject("Microsoft.XMLDOM");
+ xml.async = "false";
+ xml.loadXML(data);
+ }
+ } catch (e) {
+ xml = undefined;
+ }
+ if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length) {
+ jQuery.error("Invalid XML: " + data);
+ }
+ return xml;
+ };
+
+
+ var
+ // Document location
+ ajaxLocParts,
+ ajaxLocation,
+
+ rhash = /#.*$/,
+ rts = /([?&])_=[^&]*/,
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+ rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = "*/".concat("*");
// #8138, IE may throw an exception when accessing
// a field from window.location if document.domain has been set
-try {
- ajaxLocation = location.href;
-} catch( e ) {
- // Use the href attribute of an A element
- // since IE will modify it given document.location
- ajaxLocation = document.createElement( "a" );
- ajaxLocation.href = "";
- ajaxLocation = ajaxLocation.href;
-}
+ try {
+ ajaxLocation = location.href;
+ } catch (e) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement("a");
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+ }
// Segment location into parts
-ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+ ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || [];
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
-function addToPrefiltersOrTransports( structure ) {
-
- // dataTypeExpression is optional and defaults to "*"
- return function( dataTypeExpression, func ) {
-
- if ( typeof dataTypeExpression !== "string" ) {
- func = dataTypeExpression;
- dataTypeExpression = "*";
- }
-
- var dataType,
- i = 0,
- dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
-
- if ( jQuery.isFunction( func ) ) {
- // For each dataType in the dataTypeExpression
- while ( (dataType = dataTypes[i++]) ) {
- // Prepend if requested
- if ( dataType.charAt( 0 ) === "+" ) {
- dataType = dataType.slice( 1 ) || "*";
- (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
-
- // Otherwise append
- } else {
- (structure[ dataType ] = structure[ dataType ] || []).push( func );
- }
- }
- }
- };
-}
+ function addToPrefiltersOrTransports(structure) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function (dataTypeExpression, func) {
+
+ if (typeof dataTypeExpression !== "string") {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType,
+ i = 0,
+ dataTypes = dataTypeExpression.toLowerCase().match(rnotwhite) || [];
+
+ if (jQuery.isFunction(func)) {
+ // For each dataType in the dataTypeExpression
+ while ((dataType = dataTypes[i++])) {
+ // Prepend if requested
+ if (dataType.charAt(0) === "+") {
+ dataType = dataType.slice(1) || "*";
+ (structure[dataType] = structure[dataType] || []).unshift(func);
+
+ // Otherwise append
+ } else {
+ (structure[dataType] = structure[dataType] || []).push(func);
+ }
+ }
+ }
+ };
+ }
// Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
-
- var inspected = {},
- seekingTransport = ( structure === transports );
-
- function inspect( dataType ) {
- var selected;
- inspected[ dataType ] = true;
- jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
- var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
- if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
- options.dataTypes.unshift( dataTypeOrTransport );
- inspect( dataTypeOrTransport );
- return false;
- } else if ( seekingTransport ) {
- return !( selected = dataTypeOrTransport );
- }
- });
- return selected;
- }
-
- return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
-}
+ function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) {
+
+ var inspected = {},
+ seekingTransport = ( structure === transports );
+
+ function inspect(dataType) {
+ var selected;
+ inspected[dataType] = true;
+ jQuery.each(structure[dataType] || [], function (_, prefilterOrFactory) {
+ var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR);
+ if (typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[dataTypeOrTransport]) {
+ options.dataTypes.unshift(dataTypeOrTransport);
+ inspect(dataTypeOrTransport);
+ return false;
+ } else if (seekingTransport) {
+ return !( selected = dataTypeOrTransport );
+ }
+ });
+ return selected;
+ }
+
+ return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*");
+ }
// A special extend for ajax options
// that takes "flat" options (not to be deep extended)
// Fixes #9887
-function ajaxExtend( target, src ) {
- var deep, key,
- flatOptions = jQuery.ajaxSettings.flatOptions || {};
-
- for ( key in src ) {
- if ( src[ key ] !== undefined ) {
- ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
- }
- }
- if ( deep ) {
- jQuery.extend( true, target, deep );
- }
-
- return target;
-}
-
-/* Handles responses to an ajax request:
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
-function ajaxHandleResponses( s, jqXHR, responses ) {
- var firstDataType, ct, finalDataType, type,
- contents = s.contents,
- dataTypes = s.dataTypes;
-
- // Remove auto dataType and get content-type in the process
- while ( dataTypes[ 0 ] === "*" ) {
- dataTypes.shift();
- if ( ct === undefined ) {
- ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
- }
- }
-
- // Check if we're dealing with a known content-type
- if ( ct ) {
- for ( type in contents ) {
- if ( contents[ type ] && contents[ type ].test( ct ) ) {
- dataTypes.unshift( type );
- break;
- }
- }
- }
-
- // Check to see if we have a response for the expected dataType
- if ( dataTypes[ 0 ] in responses ) {
- finalDataType = dataTypes[ 0 ];
- } else {
- // Try convertible dataTypes
- for ( type in responses ) {
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
- finalDataType = type;
- break;
- }
- if ( !firstDataType ) {
- firstDataType = type;
- }
- }
- // Or just use first one
- finalDataType = finalDataType || firstDataType;
- }
-
- // If we found a dataType
- // We add the dataType to the list if needed
- // and return the corresponding response
- if ( finalDataType ) {
- if ( finalDataType !== dataTypes[ 0 ] ) {
- dataTypes.unshift( finalDataType );
- }
- return responses[ finalDataType ];
- }
-}
-
-/* Chain conversions given the request and the original response
- * Also sets the responseXXX fields on the jqXHR instance
- */
-function ajaxConvert( s, response, jqXHR, isSuccess ) {
- var conv2, current, conv, tmp, prev,
- converters = {},
- // Work with a copy of dataTypes in case we need to modify it for conversion
- dataTypes = s.dataTypes.slice();
-
- // Create converters map with lowercased keys
- if ( dataTypes[ 1 ] ) {
- for ( conv in s.converters ) {
- converters[ conv.toLowerCase() ] = s.converters[ conv ];
- }
- }
-
- current = dataTypes.shift();
-
- // Convert to each sequential dataType
- while ( current ) {
-
- if ( s.responseFields[ current ] ) {
- jqXHR[ s.responseFields[ current ] ] = response;
- }
-
- // Apply the dataFilter if provided
- if ( !prev && isSuccess && s.dataFilter ) {
- response = s.dataFilter( response, s.dataType );
- }
-
- prev = current;
- current = dataTypes.shift();
-
- if ( current ) {
-
- // There's only work to do if current dataType is non-auto
- if ( current === "*" ) {
-
- current = prev;
-
- // Convert response if prev dataType is non-auto and differs from current
- } else if ( prev !== "*" && prev !== current ) {
-
- // Seek a direct converter
- conv = converters[ prev + " " + current ] || converters[ "* " + current ];
-
- // If none found, seek a pair
- if ( !conv ) {
- for ( conv2 in converters ) {
-
- // If conv2 outputs current
- tmp = conv2.split( " " );
- if ( tmp[ 1 ] === current ) {
-
- // If prev can be converted to accepted input
- conv = converters[ prev + " " + tmp[ 0 ] ] ||
- converters[ "* " + tmp[ 0 ] ];
- if ( conv ) {
- // Condense equivalence converters
- if ( conv === true ) {
- conv = converters[ conv2 ];
-
- // Otherwise, insert the intermediate dataType
- } else if ( converters[ conv2 ] !== true ) {
- current = tmp[ 0 ];
- dataTypes.unshift( tmp[ 1 ] );
- }
- break;
- }
- }
- }
- }
-
- // Apply converter (if not an equivalence)
- if ( conv !== true ) {
-
- // Unless errors are allowed to bubble, catch and return them
- if ( conv && s[ "throws" ] ) {
- response = conv( response );
- } else {
- try {
- response = conv( response );
- } catch ( e ) {
- return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
- }
- }
- }
- }
- }
- }
-
- return { state: "success", data: response };
-}
-
-jQuery.extend({
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {},
-
- ajaxSettings: {
- url: ajaxLocation,
- type: "GET",
- isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
- global: true,
- processData: true,
- async: true,
- contentType: "application/x-www-form-urlencoded; charset=UTF-8",
- /*
- timeout: 0,
- data: null,
- dataType: null,
- username: null,
- password: null,
- cache: null,
- throws: false,
- traditional: false,
- headers: {},
- */
-
- accepts: {
- "*": allTypes,
- text: "text/plain",
- html: "text/html",
- xml: "application/xml, text/xml",
- json: "application/json, text/javascript"
- },
-
- contents: {
- xml: /xml/,
- html: /html/,
- json: /json/
- },
-
- responseFields: {
- xml: "responseXML",
- text: "responseText",
- json: "responseJSON"
- },
-
- // Data converters
- // Keys separate source (or catchall "*") and destination types with a single space
- converters: {
-
- // Convert anything to text
- "* text": String,
-
- // Text to html (true = no transformation)
- "text html": true,
-
- // Evaluate text as a json expression
- "text json": jQuery.parseJSON,
-
- // Parse text as xml
- "text xml": jQuery.parseXML
- },
-
- // For options that shouldn't be deep extended:
- // you can add your own custom options here if
- // and when you create one that shouldn't be
- // deep extended (see ajaxExtend)
- flatOptions: {
- url: true,
- context: true
- }
- },
-
- // Creates a full fledged settings object into target
- // with both ajaxSettings and settings fields.
- // If target is omitted, writes into ajaxSettings.
- ajaxSetup: function( target, settings ) {
- return settings ?
-
- // Building a settings object
- ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
-
- // Extending ajaxSettings
- ajaxExtend( jQuery.ajaxSettings, target );
- },
-
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
- ajaxTransport: addToPrefiltersOrTransports( transports ),
-
- // Main method
- ajax: function( url, options ) {
-
- // If url is an object, simulate pre-1.5 signature
- if ( typeof url === "object" ) {
- options = url;
- url = undefined;
- }
-
- // Force options to be an object
- options = options || {};
-
- var // Cross-domain detection vars
- parts,
- // Loop variable
- i,
- // URL without anti-cache param
- cacheURL,
- // Response headers as string
- responseHeadersString,
- // timeout handle
- timeoutTimer,
-
- // To know if global events are to be dispatched
- fireGlobals,
-
- transport,
- // Response headers
- responseHeaders,
- // Create the final options object
- s = jQuery.ajaxSetup( {}, options ),
- // Callbacks context
- callbackContext = s.context || s,
- // Context for global events is callbackContext if it is a DOM node or jQuery collection
- globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
- jQuery( callbackContext ) :
- jQuery.event,
- // Deferreds
- deferred = jQuery.Deferred(),
- completeDeferred = jQuery.Callbacks("once memory"),
- // Status-dependent callbacks
- statusCode = s.statusCode || {},
- // Headers (they are sent all at once)
- requestHeaders = {},
- requestHeadersNames = {},
- // The jqXHR state
- state = 0,
- // Default abort message
- strAbort = "canceled",
- // Fake xhr
- jqXHR = {
- readyState: 0,
-
- // Builds headers hashtable if needed
- getResponseHeader: function( key ) {
- var match;
- if ( state === 2 ) {
- if ( !responseHeaders ) {
- responseHeaders = {};
- while ( (match = rheaders.exec( responseHeadersString )) ) {
- responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
- }
- }
- match = responseHeaders[ key.toLowerCase() ];
- }
- return match == null ? null : match;
- },
-
- // Raw string
- getAllResponseHeaders: function() {
- return state === 2 ? responseHeadersString : null;
- },
-
- // Caches the header
- setRequestHeader: function( name, value ) {
- var lname = name.toLowerCase();
- if ( !state ) {
- name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
- requestHeaders[ name ] = value;
- }
- return this;
- },
-
- // Overrides response content-type header
- overrideMimeType: function( type ) {
- if ( !state ) {
- s.mimeType = type;
- }
- return this;
- },
-
- // Status-dependent callbacks
- statusCode: function( map ) {
- var code;
- if ( map ) {
- if ( state < 2 ) {
- for ( code in map ) {
- // Lazy-add the new callback in a way that preserves old ones
- statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
- }
- } else {
- // Execute the appropriate callbacks
- jqXHR.always( map[ jqXHR.status ] );
- }
- }
- return this;
- },
-
- // Cancel the request
- abort: function( statusText ) {
- var finalText = statusText || strAbort;
- if ( transport ) {
- transport.abort( finalText );
- }
- done( 0, finalText );
- return this;
- }
- };
-
- // Attach deferreds
- deferred.promise( jqXHR ).complete = completeDeferred.add;
- jqXHR.success = jqXHR.done;
- jqXHR.error = jqXHR.fail;
-
- // Remove hash character (#7531: and string promotion)
- // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
- // Handle falsy url in the settings object (#10093: consistency with old signature)
- // We also use the url parameter if available
- s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
-
- // Alias method option to type as per ticket #12004
- s.type = options.method || options.type || s.method || s.type;
-
- // Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
-
- // A cross-domain request is in order when we have a protocol:host:port mismatch
- if ( s.crossDomain == null ) {
- parts = rurl.exec( s.url.toLowerCase() );
- s.crossDomain = !!( parts &&
- ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
- ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
- ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
- );
- }
-
- // Convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
-
- // Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
-
- // If request was aborted inside a prefilter, stop there
- if ( state === 2 ) {
- return jqXHR;
- }
-
- // We can fire global events as of now if asked to
- fireGlobals = s.global;
-
- // Watch for a new set of requests
- if ( fireGlobals && jQuery.active++ === 0 ) {
- jQuery.event.trigger("ajaxStart");
- }
-
- // Uppercase the type
- s.type = s.type.toUpperCase();
-
- // Determine if request has content
- s.hasContent = !rnoContent.test( s.type );
-
- // Save the URL in case we're toying with the If-Modified-Since
- // and/or If-None-Match header later on
- cacheURL = s.url;
-
- // More options handling for requests with no content
- if ( !s.hasContent ) {
-
- // If data is available, append data to url
- if ( s.data ) {
- cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
- // #9682: remove data so that it's not used in an eventual retry
- delete s.data;
- }
-
- // Add anti-cache in url if needed
- if ( s.cache === false ) {
- s.url = rts.test( cacheURL ) ?
-
- // If there is already a '_' parameter, set its value
- cacheURL.replace( rts, "$1_=" + nonce++ ) :
-
- // Otherwise add one to the end
- cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
- }
- }
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( jQuery.lastModified[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
- }
- if ( jQuery.etag[ cacheURL ] ) {
- jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
- }
- }
-
- // Set the correct header, if data is being sent
- if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- jqXHR.setRequestHeader( "Content-Type", s.contentType );
- }
-
- // Set the Accepts header for the server, depending on the dataType
- jqXHR.setRequestHeader(
- "Accept",
- s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
- s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
- s.accepts[ "*" ]
- );
-
- // Check for headers option
- for ( i in s.headers ) {
- jqXHR.setRequestHeader( i, s.headers[ i ] );
- }
-
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
- // Abort if not done already and return
- return jqXHR.abort();
- }
-
- // aborting is no longer a cancellation
- strAbort = "abort";
-
- // Install callbacks on deferreds
- for ( i in { success: 1, error: 1, complete: 1 } ) {
- jqXHR[ i ]( s[ i ] );
- }
-
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
-
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- jqXHR.readyState = 1;
-
- // Send global event
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
- }
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = setTimeout(function() {
- jqXHR.abort("timeout");
- }, s.timeout );
- }
-
- try {
- state = 1;
- transport.send( requestHeaders, done );
- } catch ( e ) {
- // Propagate exception as error if not done
- if ( state < 2 ) {
- done( -1, e );
- // Simply rethrow otherwise
- } else {
- throw e;
- }
- }
- }
-
- // Callback for when everything is done
- function done( status, nativeStatusText, responses, headers ) {
- var isSuccess, success, error, response, modified,
- statusText = nativeStatusText;
-
- // Called once
- if ( state === 2 ) {
- return;
- }
-
- // State is "done" now
- state = 2;
-
- // Clear timeout if it exists
- if ( timeoutTimer ) {
- clearTimeout( timeoutTimer );
- }
-
- // Dereference transport for early garbage collection
- // (no matter how long the jqXHR object will be used)
- transport = undefined;
-
- // Cache response headers
- responseHeadersString = headers || "";
-
- // Set readyState
- jqXHR.readyState = status > 0 ? 4 : 0;
-
- // Determine if successful
- isSuccess = status >= 200 && status < 300 || status === 304;
-
- // Get response data
- if ( responses ) {
- response = ajaxHandleResponses( s, jqXHR, responses );
- }
-
- // Convert no matter what (that way responseXXX fields are always set)
- response = ajaxConvert( s, response, jqXHR, isSuccess );
-
- // If successful, handle type chaining
- if ( isSuccess ) {
-
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- modified = jqXHR.getResponseHeader("Last-Modified");
- if ( modified ) {
- jQuery.lastModified[ cacheURL ] = modified;
- }
- modified = jqXHR.getResponseHeader("etag");
- if ( modified ) {
- jQuery.etag[ cacheURL ] = modified;
- }
- }
-
- // if no content
- if ( status === 204 || s.type === "HEAD" ) {
- statusText = "nocontent";
-
- // if not modified
- } else if ( status === 304 ) {
- statusText = "notmodified";
-
- // If we have data, let's convert it
- } else {
- statusText = response.state;
- success = response.data;
- error = response.error;
- isSuccess = !error;
- }
- } else {
- // We extract error from statusText
- // then normalize statusText and status for non-aborts
- error = statusText;
- if ( status || !statusText ) {
- statusText = "error";
- if ( status < 0 ) {
- status = 0;
- }
- }
- }
-
- // Set data for the fake xhr object
- jqXHR.status = status;
- jqXHR.statusText = ( nativeStatusText || statusText ) + "";
-
- // Success/Error
- if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
- } else {
- deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
- }
-
- // Status-dependent callbacks
- jqXHR.statusCode( statusCode );
- statusCode = undefined;
-
- if ( fireGlobals ) {
- globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
- [ jqXHR, s, isSuccess ? success : error ] );
- }
-
- // Complete
- completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
-
- if ( fireGlobals ) {
- globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
- // Handle the global AJAX counter
- if ( !( --jQuery.active ) ) {
- jQuery.event.trigger("ajaxStop");
- }
- }
- }
-
- return jqXHR;
- },
-
- getJSON: function( url, data, callback ) {
- return jQuery.get( url, data, callback, "json" );
- },
-
- getScript: function( url, callback ) {
- return jQuery.get( url, undefined, callback, "script" );
- }
-});
-
-jQuery.each( [ "get", "post" ], function( i, method ) {
- jQuery[ method ] = function( url, data, callback, type ) {
- // shift arguments if data argument was omitted
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = undefined;
- }
-
- return jQuery.ajax({
- url: url,
- type: method,
- dataType: type,
- data: data,
- success: callback
- });
- };
-});
+ function ajaxExtend(target, src) {
+ var deep, key,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+ for (key in src) {
+ if (src[key] !== undefined) {
+ ( flatOptions[key] ? target : ( deep || (deep = {}) ) )[key] = src[key];
+ }
+ }
+ if (deep) {
+ jQuery.extend(true, target, deep);
+ }
+
+ return target;
+ }
+
+ /* Handles responses to an ajax request:
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+ function ajaxHandleResponses(s, jqXHR, responses) {
+ var firstDataType, ct, finalDataType, type,
+ contents = s.contents,
+ dataTypes = s.dataTypes;
+
+ // Remove auto dataType and get content-type in the process
+ while (dataTypes[0] === "*") {
+ dataTypes.shift();
+ if (ct === undefined) {
+ ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if (ct) {
+ for (type in contents) {
+ if (contents[type] && contents[type].test(ct)) {
+ dataTypes.unshift(type);
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if (dataTypes[0] in responses) {
+ finalDataType = dataTypes[0];
+ } else {
+ // Try convertible dataTypes
+ for (type in responses) {
+ if (!dataTypes[0] || s.converters[type + " " + dataTypes[0]]) {
+ finalDataType = type;
+ break;
+ }
+ if (!firstDataType) {
+ firstDataType = type;
+ }
+ }
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if (finalDataType) {
+ if (finalDataType !== dataTypes[0]) {
+ dataTypes.unshift(finalDataType);
+ }
+ return responses[finalDataType];
+ }
+ }
+
+ /* Chain conversions given the request and the original response
+ * Also sets the responseXXX fields on the jqXHR instance
+ */
+ function ajaxConvert(s, response, jqXHR, isSuccess) {
+ var conv2, current, conv, tmp, prev,
+ converters = {},
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice();
+
+ // Create converters map with lowercased keys
+ if (dataTypes[1]) {
+ for (conv in s.converters) {
+ converters[conv.toLowerCase()] = s.converters[conv];
+ }
+ }
+
+ current = dataTypes.shift();
+
+ // Convert to each sequential dataType
+ while (current) {
+
+ if (s.responseFields[current]) {
+ jqXHR[s.responseFields[current]] = response;
+ }
+
+ // Apply the dataFilter if provided
+ if (!prev && isSuccess && s.dataFilter) {
+ response = s.dataFilter(response, s.dataType);
+ }
+
+ prev = current;
+ current = dataTypes.shift();
+
+ if (current) {
+
+ // There's only work to do if current dataType is non-auto
+ if (current === "*") {
+
+ current = prev;
+
+ // Convert response if prev dataType is non-auto and differs from current
+ } else if (prev !== "*" && prev !== current) {
+
+ // Seek a direct converter
+ conv = converters[prev + " " + current] || converters["* " + current];
+
+ // If none found, seek a pair
+ if (!conv) {
+ for (conv2 in converters) {
+
+ // If conv2 outputs current
+ tmp = conv2.split(" ");
+ if (tmp[1] === current) {
+
+ // If prev can be converted to accepted input
+ conv = converters[prev + " " + tmp[0]] ||
+ converters["* " + tmp[0]];
+ if (conv) {
+ // Condense equivalence converters
+ if (conv === true) {
+ conv = converters[conv2];
+
+ // Otherwise, insert the intermediate dataType
+ } else if (converters[conv2] !== true) {
+ current = tmp[0];
+ dataTypes.unshift(tmp[1]);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if (conv !== true) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if (conv && s["throws"]) {
+ response = conv(response);
+ } else {
+ try {
+ response = conv(response);
+ } catch (e) {
+ return {
+ state: "parsererror",
+ error: conv ? e : "No conversion from " + prev + " to " + current
+ };
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return {state: "success", data: response};
+ }
+
+ jQuery.extend({
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ type: "GET",
+ isLocal: rlocalProtocol.test(ajaxLocParts[1]),
+ global: true,
+ processData: true,
+ async: true,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ "*": allTypes,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+
+ contents: {
+ xml: /xml/,
+ html: /html/,
+ json: /json/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText",
+ json: "responseJSON"
+ },
+
+ // Data converters
+ // Keys separate source (or catchall "*") and destination types with a single space
+ converters: {
+
+ // Convert anything to text
+ "* text": String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ url: true,
+ context: true
+ }
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function (target, settings) {
+ return settings ?
+
+ // Building a settings object
+ ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) :
+
+ // Extending ajaxSettings
+ ajaxExtend(jQuery.ajaxSettings, target);
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports(prefilters),
+ ajaxTransport: addToPrefiltersOrTransports(transports),
+
+ // Main method
+ ajax: function (url, options) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if (typeof url === "object") {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var // Cross-domain detection vars
+ parts,
+ // Loop variable
+ i,
+ // URL without anti-cache param
+ cacheURL,
+ // Response headers as string
+ responseHeadersString,
+ // timeout handle
+ timeoutTimer,
+
+ // To know if global events are to be dispatched
+ fireGlobals,
+
+ transport,
+ // Response headers
+ responseHeaders,
+ // Create the final options object
+ s = jQuery.ajaxSetup({}, options),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
+ globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
+ jQuery(callbackContext) :
+ jQuery.event,
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks("once memory"),
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+ // The jqXHR state
+ state = 0,
+ // Default abort message
+ strAbort = "canceled",
+ // Fake xhr
+ jqXHR = {
+ readyState: 0,
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function (key) {
+ var match;
+ if (state === 2) {
+ if (!responseHeaders) {
+ responseHeaders = {};
+ while ((match = rheaders.exec(responseHeadersString))) {
+ responseHeaders[match[1].toLowerCase()] = match[2];
+ }
+ }
+ match = responseHeaders[key.toLowerCase()];
+ }
+ return match == null ? null : match;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function () {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Caches the header
+ setRequestHeader: function (name, value) {
+ var lname = name.toLowerCase();
+ if (!state) {
+ name = requestHeadersNames[lname] = requestHeadersNames[lname] || name;
+ requestHeaders[name] = value;
+ }
+ return this;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function (type) {
+ if (!state) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Status-dependent callbacks
+ statusCode: function (map) {
+ var code;
+ if (map) {
+ if (state < 2) {
+ for (code in map) {
+ // Lazy-add the new callback in a way that preserves old ones
+ statusCode[code] = [statusCode[code], map[code]];
+ }
+ } else {
+ // Execute the appropriate callbacks
+ jqXHR.always(map[jqXHR.status]);
+ }
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function (statusText) {
+ var finalText = statusText || strAbort;
+ if (transport) {
+ transport.abort(finalText);
+ }
+ done(0, finalText);
+ return this;
+ }
+ };
+
+ // Attach deferreds
+ deferred.promise(jqXHR).complete = completeDeferred.add;
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace(rhash, "").replace(rprotocol, ajaxLocParts[1] + "//");
+
+ // Alias method option to type as per ticket #12004
+ s.type = options.method || options.type || s.method || s.type;
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim(s.dataType || "*").toLowerCase().match(rnotwhite) || [""];
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if (s.crossDomain == null) {
+ parts = rurl.exec(s.url.toLowerCase());
+ s.crossDomain = !!( parts &&
+ ( parts[1] !== ajaxLocParts[1] || parts[2] !== ajaxLocParts[2] ||
+ ( parts[3] || ( parts[1] === "http:" ? "80" : "443" ) ) !==
+ ( ajaxLocParts[3] || ( ajaxLocParts[1] === "http:" ? "80" : "443" ) ) )
+ );
+ }
+
+ // Convert data if not already a string
+ if (s.data && s.processData && typeof s.data !== "string") {
+ s.data = jQuery.param(s.data, s.traditional);
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports(prefilters, s, options, jqXHR);
+
+ // If request was aborted inside a prefilter, stop there
+ if (state === 2) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
+
+ // Watch for a new set of requests
+ if (fireGlobals && jQuery.active++ === 0) {
+ jQuery.event.trigger("ajaxStart");
+ }
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test(s.type);
+
+ // Save the URL in case we're toying with the If-Modified-Since
+ // and/or If-None-Match header later on
+ cacheURL = s.url;
+
+ // More options handling for requests with no content
+ if (!s.hasContent) {
+
+ // If data is available, append data to url
+ if (s.data) {
+ cacheURL = ( s.url += ( rquery.test(cacheURL) ? "&" : "?" ) + s.data );
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Add anti-cache in url if needed
+ if (s.cache === false) {
+ s.url = rts.test(cacheURL) ?
+
+ // If there is already a '_' parameter, set its value
+ cacheURL.replace(rts, "$1_=" + nonce++) :
+
+ // Otherwise add one to the end
+ cacheURL + ( rquery.test(cacheURL) ? "&" : "?" ) + "_=" + nonce++;
+ }
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if (s.ifModified) {
+ if (jQuery.lastModified[cacheURL]) {
+ jqXHR.setRequestHeader("If-Modified-Since", jQuery.lastModified[cacheURL]);
+ }
+ if (jQuery.etag[cacheURL]) {
+ jqXHR.setRequestHeader("If-None-Match", jQuery.etag[cacheURL]);
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if (s.data && s.hasContent && s.contentType !== false || options.contentType) {
+ jqXHR.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[0] && s.accepts[s.dataTypes[0]] ?
+ s.accepts[s.dataTypes[0]] + ( s.dataTypes[0] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts["*"]
+ );
+
+ // Check for headers option
+ for (i in s.headers) {
+ jqXHR.setRequestHeader(i, s.headers[i]);
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if (s.beforeSend && ( s.beforeSend.call(callbackContext, jqXHR, s) === false || state === 2 )) {
+ // Abort if not done already and return
+ return jqXHR.abort();
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for (i in {success: 1, error: 1, complete: 1}) {
+ jqXHR[i](s[i]);
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports(transports, s, options, jqXHR);
+
+ // If no transport, we auto-abort
+ if (!transport) {
+ done(-1, "No Transport");
+ } else {
+ jqXHR.readyState = 1;
+
+ // Send global event
+ if (fireGlobals) {
+ globalEventContext.trigger("ajaxSend", [jqXHR, s]);
+ }
+ // Timeout
+ if (s.async && s.timeout > 0) {
+ timeoutTimer = setTimeout(function () {
+ jqXHR.abort("timeout");
+ }, s.timeout);
+ }
+
+ try {
+ state = 1;
+ transport.send(requestHeaders, done);
+ } catch (e) {
+ // Propagate exception as error if not done
+ if (state < 2) {
+ done(-1, e);
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ // Callback for when everything is done
+ function done(status, nativeStatusText, responses, headers) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if (state === 2) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if (timeoutTimer) {
+ clearTimeout(timeoutTimer);
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Determine if successful
+ isSuccess = status >= 200 && status < 300 || status === 304;
+
+ // Get response data
+ if (responses) {
+ response = ajaxHandleResponses(s, jqXHR, responses);
+ }
+
+ // Convert no matter what (that way responseXXX fields are always set)
+ response = ajaxConvert(s, response, jqXHR, isSuccess);
+
+ // If successful, handle type chaining
+ if (isSuccess) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if (s.ifModified) {
+ modified = jqXHR.getResponseHeader("Last-Modified");
+ if (modified) {
+ jQuery.lastModified[cacheURL] = modified;
+ }
+ modified = jqXHR.getResponseHeader("etag");
+ if (modified) {
+ jQuery.etag[cacheURL] = modified;
+ }
+ }
+
+ // if no content
+ if (status === 204 || s.type === "HEAD") {
+ statusText = "nocontent";
+
+ // if not modified
+ } else if (status === 304) {
+ statusText = "notmodified";
+
+ // If we have data, let's convert it
+ } else {
+ statusText = response.state;
+ success = response.data;
+ error = response.error;
+ isSuccess = !error;
+ }
+ } else {
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if (status || !statusText) {
+ statusText = "error";
+ if (status < 0) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if (isSuccess) {
+ deferred.resolveWith(callbackContext, [success, statusText, jqXHR]);
+ } else {
+ deferred.rejectWith(callbackContext, [jqXHR, statusText, error]);
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode(statusCode);
+ statusCode = undefined;
+
+ if (fireGlobals) {
+ globalEventContext.trigger(isSuccess ? "ajaxSuccess" : "ajaxError",
+ [jqXHR, s, isSuccess ? success : error]);
+ }
+
+ // Complete
+ completeDeferred.fireWith(callbackContext, [jqXHR, statusText]);
+
+ if (fireGlobals) {
+ globalEventContext.trigger("ajaxComplete", [jqXHR, s]);
+ // Handle the global AJAX counter
+ if (!( --jQuery.active )) {
+ jQuery.event.trigger("ajaxStop");
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ getJSON: function (url, data, callback) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ getScript: function (url, callback) {
+ return jQuery.get(url, undefined, callback, "script");
+ }
+ });
+
+ jQuery.each(["get", "post"], function (i, method) {
+ jQuery[method] = function (url, data, callback, type) {
+ // shift arguments if data argument was omitted
+ if (jQuery.isFunction(data)) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ return jQuery.ajax({
+ url: url,
+ type: method,
+ dataType: type,
+ data: data,
+ success: callback
+ });
+ };
+ });
// Attach a bunch of functions for handling common AJAX events
-jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
- jQuery.fn[ type ] = function( fn ) {
- return this.on( type, fn );
- };
-});
-
-
-jQuery._evalUrl = function( url ) {
- return jQuery.ajax({
- url: url,
- type: "GET",
- dataType: "script",
- async: false,
- global: false,
- "throws": true
- });
-};
-
-
-jQuery.fn.extend({
- wrapAll: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapAll( html.call(this, i) );
- });
- }
-
- if ( this[0] ) {
- // The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
-
- if ( this[0].parentNode ) {
- wrap.insertBefore( this[0] );
- }
-
- wrap.map(function() {
- var elem = this;
-
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
- }
-
- return elem;
- }).append( this );
- }
-
- return this;
- },
-
- wrapInner: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapInner( html.call(this, i) );
- });
- }
-
- return this.each(function() {
- var self = jQuery( this ),
- contents = self.contents();
-
- if ( contents.length ) {
- contents.wrapAll( html );
-
- } else {
- self.append( html );
- }
- });
- },
-
- wrap: function( html ) {
- var isFunction = jQuery.isFunction( html );
-
- return this.each(function(i) {
- jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
- });
- },
-
- unwrap: function() {
- return this.parent().each(function() {
- if ( !jQuery.nodeName( this, "body" ) ) {
- jQuery( this ).replaceWith( this.childNodes );
- }
- }).end();
- }
-});
-
-
-jQuery.expr.filters.hidden = function( elem ) {
- // Support: Opera <= 12.12
- // Opera reports offsetWidths and offsetHeights less than zero on some elements
- return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
- (!support.reliableHiddenOffsets() &&
- ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
-};
-
-jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
-};
-
-
-
-
-var r20 = /%20/g,
- rbracket = /\[\]$/,
- rCRLF = /\r?\n/g,
- rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
- rsubmittable = /^(?:input|select|textarea|keygen)/i;
-
-function buildParams( prefix, obj, traditional, add ) {
- var name;
-
- if ( jQuery.isArray( obj ) ) {
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
- // Treat each array item as a scalar.
- add( prefix, v );
-
- } else {
- // Item is non-scalar (array or object), encode its numeric index.
- buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
- }
- });
-
- } else if ( !traditional && jQuery.type( obj ) === "object" ) {
- // Serialize object item.
- for ( name in obj ) {
- buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
- }
-
- } else {
- // Serialize scalar item.
- add( prefix, obj );
- }
-}
+ jQuery.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function (i, type) {
+ jQuery.fn[type] = function (fn) {
+ return this.on(type, fn);
+ };
+ });
+
+
+ jQuery._evalUrl = function (url) {
+ return jQuery.ajax({
+ url: url,
+ type: "GET",
+ dataType: "script",
+ async: false,
+ global: false,
+ "throws": true
+ });
+ };
+
+
+ jQuery.fn.extend({
+ wrapAll: function (html) {
+ if (jQuery.isFunction(html)) {
+ return this.each(function (i) {
+ jQuery(this).wrapAll(html.call(this, i));
+ });
+ }
+
+ if (this[0]) {
+ // The elements to wrap the target around
+ var wrap = jQuery(html, this[0].ownerDocument).eq(0).clone(true);
+
+ if (this[0].parentNode) {
+ wrap.insertBefore(this[0]);
+ }
+
+ wrap.map(function () {
+ var elem = this;
+
+ while (elem.firstChild && elem.firstChild.nodeType === 1) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function (html) {
+ if (jQuery.isFunction(html)) {
+ return this.each(function (i) {
+ jQuery(this).wrapInner(html.call(this, i));
+ });
+ }
+
+ return this.each(function () {
+ var self = jQuery(this),
+ contents = self.contents();
+
+ if (contents.length) {
+ contents.wrapAll(html);
+
+ } else {
+ self.append(html);
+ }
+ });
+ },
+
+ wrap: function (html) {
+ var isFunction = jQuery.isFunction(html);
+
+ return this.each(function (i) {
+ jQuery(this).wrapAll(isFunction ? html.call(this, i) : html);
+ });
+ },
+
+ unwrap: function () {
+ return this.parent().each(function () {
+ if (!jQuery.nodeName(this, "body")) {
+ jQuery(this).replaceWith(this.childNodes);
+ }
+ }).end();
+ }
+ });
+
+
+ jQuery.expr.filters.hidden = function (elem) {
+ // Support: Opera <= 12.12
+ // Opera reports offsetWidths and offsetHeights less than zero on some elements
+ return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
+ (!support.reliableHiddenOffsets() &&
+ ((elem.style && elem.style.display) || jQuery.css(elem, "display")) === "none");
+ };
+
+ jQuery.expr.filters.visible = function (elem) {
+ return !jQuery.expr.filters.hidden(elem);
+ };
+
+
+ var r20 = /%20/g,
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+ rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+ function buildParams(prefix, obj, traditional, add) {
+ var name;
+
+ if (jQuery.isArray(obj)) {
+ // Serialize array item.
+ jQuery.each(obj, function (i, v) {
+ if (traditional || rbracket.test(prefix)) {
+ // Treat each array item as a scalar.
+ add(prefix, v);
+
+ } else {
+ // Item is non-scalar (array or object), encode its numeric index.
+ buildParams(prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add);
+ }
+ });
+
+ } else if (!traditional && jQuery.type(obj) === "object") {
+ // Serialize object item.
+ for (name in obj) {
+ buildParams(prefix + "[" + name + "]", obj[name], traditional, add);
+ }
+
+ } else {
+ // Serialize scalar item.
+ add(prefix, obj);
+ }
+ }
// Serialize an array of form elements or a set of
// key/values into a query string
-jQuery.param = function( a, traditional ) {
- var prefix,
- s = [],
- add = function( key, value ) {
- // If value is a function, invoke it and return its value
- value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
- s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
- };
-
- // Set traditional to true for jQuery <= 1.3.2 behavior.
- if ( traditional === undefined ) {
- traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
- }
-
- // If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- });
-
- } else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( prefix in a ) {
- buildParams( prefix, a[ prefix ], traditional, add );
- }
- }
-
- // Return the resulting serialization
- return s.join( "&" ).replace( r20, "+" );
-};
-
-jQuery.fn.extend({
- serialize: function() {
- return jQuery.param( this.serializeArray() );
- },
- serializeArray: function() {
- return this.map(function() {
- // Can add propHook for "elements" to filter or add form elements
- var elements = jQuery.prop( this, "elements" );
- return elements ? jQuery.makeArray( elements ) : this;
- })
- .filter(function() {
- var type = this.type;
- // Use .is(":disabled") so that fieldset[disabled] works
- return this.name && !jQuery( this ).is( ":disabled" ) &&
- rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
- ( this.checked || !rcheckableType.test( type ) );
- })
- .map(function( i, elem ) {
- var val = jQuery( this ).val();
-
- return val == null ?
- null :
- jQuery.isArray( val ) ?
- jQuery.map( val, function( val ) {
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }) :
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }).get();
- }
-});
+ jQuery.param = function (a, traditional) {
+ var prefix,
+ s = [],
+ add = function (key, value) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : ( value == null ? "" : value );
+ s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ };
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if (traditional === undefined) {
+ traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if (jQuery.isArray(a) || ( a.jquery && !jQuery.isPlainObject(a) )) {
+ // Serialize the form elements
+ jQuery.each(a, function () {
+ add(this.name, this.value);
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for (prefix in a) {
+ buildParams(prefix, a[prefix], traditional, add);
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ };
+
+ jQuery.fn.extend({
+ serialize: function () {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function () {
+ return this.map(function () {
+ // Can add propHook for "elements" to filter or add form elements
+ var elements = jQuery.prop(this, "elements");
+ return elements ? jQuery.makeArray(elements) : this;
+ })
+ .filter(function () {
+ var type = this.type;
+ // Use .is(":disabled") so that fieldset[disabled] works
+ return this.name && !jQuery(this).is(":disabled") &&
+ rsubmittable.test(this.nodeName) && !rsubmitterTypes.test(type) &&
+ ( this.checked || !rcheckableType.test(type) );
+ })
+ .map(function (i, elem) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map(val, function (val) {
+ return {name: elem.name, value: val.replace(rCRLF, "\r\n")};
+ }) :
+ {name: elem.name, value: val.replace(rCRLF, "\r\n")};
+ }).get();
+ }
+ });
// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
-jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
- // Support: IE6+
- function() {
-
- // XHR cannot access local files, always use ActiveX for that case
- return !this.isLocal &&
-
- // Support: IE7-8
- // oldIE XHR does not support non-RFC2616 methods (#13240)
- // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
- // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
- // Although this check for six methods instead of eight
- // since IE also does not support "trace" and "connect"
- /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
-
- createStandardXHR() || createActiveXHR();
- } :
- // For all other browsers, use the standard XMLHttpRequest object
- createStandardXHR;
-
-var xhrId = 0,
- xhrCallbacks = {},
- xhrSupported = jQuery.ajaxSettings.xhr();
+ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
+ // Support: IE6+
+ function () {
+
+ // XHR cannot access local files, always use ActiveX for that case
+ return !this.isLocal &&
+
+ // Support: IE7-8
+ // oldIE XHR does not support non-RFC2616 methods (#13240)
+ // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
+ // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
+ // Although this check for six methods instead of eight
+ // since IE also does not support "trace" and "connect"
+ /^(get|post|head|put|delete|options)$/i.test(this.type) &&
+
+ createStandardXHR() || createActiveXHR();
+ } :
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+ var xhrId = 0,
+ xhrCallbacks = {},
+ xhrSupported = jQuery.ajaxSettings.xhr();
// Support: IE<10
// Open requests must be manually aborted on unload (#5280)
-if ( window.ActiveXObject ) {
- jQuery( window ).on( "unload", function() {
- for ( var key in xhrCallbacks ) {
- xhrCallbacks[ key ]( undefined, true );
- }
- });
-}
+ if (window.ActiveXObject) {
+ jQuery(window).on("unload", function () {
+ for (var key in xhrCallbacks) {
+ xhrCallbacks[key](undefined, true);
+ }
+ });
+ }
// Determine support properties
-support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
-xhrSupported = support.ajax = !!xhrSupported;
+ support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+ xhrSupported = support.ajax = !!xhrSupported;
// Create transport if the browser can provide an xhr
-if ( xhrSupported ) {
-
- jQuery.ajaxTransport(function( options ) {
- // Cross domain only allowed if supported through XMLHttpRequest
- if ( !options.crossDomain || support.cors ) {
-
- var callback;
-
- return {
- send: function( headers, complete ) {
- var i,
- xhr = options.xhr(),
- id = ++xhrId;
-
- // Open the socket
- xhr.open( options.type, options.url, options.async, options.username, options.password );
-
- // Apply custom fields if provided
- if ( options.xhrFields ) {
- for ( i in options.xhrFields ) {
- xhr[ i ] = options.xhrFields[ i ];
- }
- }
-
- // Override mime type if needed
- if ( options.mimeType && xhr.overrideMimeType ) {
- xhr.overrideMimeType( options.mimeType );
- }
-
- // X-Requested-With header
- // For cross-domain requests, seeing as conditions for a preflight are
- // akin to a jigsaw puzzle, we simply never set it to be sure.
- // (it can always be set on a per-request basis or even using ajaxSetup)
- // For same-domain requests, won't change header if already provided.
- if ( !options.crossDomain && !headers["X-Requested-With"] ) {
- headers["X-Requested-With"] = "XMLHttpRequest";
- }
-
- // Set headers
- for ( i in headers ) {
- // Support: IE<9
- // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
- // request header to a null-value.
- //
- // To keep consistent with other XHR implementations, cast the value
- // to string and ignore `undefined`.
- if ( headers[ i ] !== undefined ) {
- xhr.setRequestHeader( i, headers[ i ] + "" );
- }
- }
-
- // Do send the request
- // This may raise an exception which is actually
- // handled in jQuery.ajax (so no try/catch here)
- xhr.send( ( options.hasContent && options.data ) || null );
-
- // Listener
- callback = function( _, isAbort ) {
- var status, statusText, responses;
-
- // Was never called and is aborted or complete
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
- // Clean up
- delete xhrCallbacks[ id ];
- callback = undefined;
- xhr.onreadystatechange = jQuery.noop;
-
- // Abort manually if needed
- if ( isAbort ) {
- if ( xhr.readyState !== 4 ) {
- xhr.abort();
- }
- } else {
- responses = {};
- status = xhr.status;
-
- // Support: IE<10
- // Accessing binary-data responseText throws an exception
- // (#11426)
- if ( typeof xhr.responseText === "string" ) {
- responses.text = xhr.responseText;
- }
-
- // Firefox throws an exception when accessing
- // statusText for faulty cross-domain requests
- try {
- statusText = xhr.statusText;
- } catch( e ) {
- // We normalize with Webkit giving an empty statusText
- statusText = "";
- }
-
- // Filter status for non standard behaviors
-
- // If the request is local and we have data: assume a success
- // (success with no data won't get notified, that's the best we
- // can do given current implementations)
- if ( !status && options.isLocal && !options.crossDomain ) {
- status = responses.text ? 200 : 404;
- // IE - #1450: sometimes returns 1223 when it should be 204
- } else if ( status === 1223 ) {
- status = 204;
- }
- }
- }
-
- // Call complete if needed
- if ( responses ) {
- complete( status, statusText, responses, xhr.getAllResponseHeaders() );
- }
- };
-
- if ( !options.async ) {
- // if we're in sync mode we fire the callback
- callback();
- } else if ( xhr.readyState === 4 ) {
- // (IE6 & IE7) if it's in cache and has been
- // retrieved directly we need to fire the callback
- setTimeout( callback );
- } else {
- // Add to the list of active xhr callbacks
- xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
- }
- },
-
- abort: function() {
- if ( callback ) {
- callback( undefined, true );
- }
- }
- };
- }
- });
-}
+ if (xhrSupported) {
+
+ jQuery.ajaxTransport(function (options) {
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if (!options.crossDomain || support.cors) {
+
+ var callback;
+
+ return {
+ send: function (headers, complete) {
+ var i,
+ xhr = options.xhr(),
+ id = ++xhrId;
+
+ // Open the socket
+ xhr.open(options.type, options.url, options.async, options.username, options.password);
+
+ // Apply custom fields if provided
+ if (options.xhrFields) {
+ for (i in options.xhrFields) {
+ xhr[i] = options.xhrFields[i];
+ }
+ }
+
+ // Override mime type if needed
+ if (options.mimeType && xhr.overrideMimeType) {
+ xhr.overrideMimeType(options.mimeType);
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if (!options.crossDomain && !headers["X-Requested-With"]) {
+ headers["X-Requested-With"] = "XMLHttpRequest";
+ }
+
+ // Set headers
+ for (i in headers) {
+ // Support: IE<9
+ // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
+ // request header to a null-value.
+ //
+ // To keep consistent with other XHR implementations, cast the value
+ // to string and ignore `undefined`.
+ if (headers[i] !== undefined) {
+ xhr.setRequestHeader(i, headers[i] + "");
+ }
+ }
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send(( options.hasContent && options.data ) || null);
+
+ // Listener
+ callback = function (_, isAbort) {
+ var status, statusText, responses;
+
+ // Was never called and is aborted or complete
+ if (callback && ( isAbort || xhr.readyState === 4 )) {
+ // Clean up
+ delete xhrCallbacks[id];
+ callback = undefined;
+ xhr.onreadystatechange = jQuery.noop;
+
+ // Abort manually if needed
+ if (isAbort) {
+ if (xhr.readyState !== 4) {
+ xhr.abort();
+ }
+ } else {
+ responses = {};
+ status = xhr.status;
+
+ // Support: IE<10
+ // Accessing binary-data responseText throws an exception
+ // (#11426)
+ if (typeof xhr.responseText === "string") {
+ responses.text = xhr.responseText;
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch (e) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if (!status && options.isLocal && !options.crossDomain) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if (status === 1223) {
+ status = 204;
+ }
+ }
+ }
+
+ // Call complete if needed
+ if (responses) {
+ complete(status, statusText, responses, xhr.getAllResponseHeaders());
+ }
+ };
+
+ if (!options.async) {
+ // if we're in sync mode we fire the callback
+ callback();
+ } else if (xhr.readyState === 4) {
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ setTimeout(callback);
+ } else {
+ // Add to the list of active xhr callbacks
+ xhr.onreadystatechange = xhrCallbacks[id] = callback;
+ }
+ },
+
+ abort: function () {
+ if (callback) {
+ callback(undefined, true);
+ }
+ }
+ };
+ }
+ });
+ }
// Functions to create xhrs
-function createStandardXHR() {
- try {
- return new window.XMLHttpRequest();
- } catch( e ) {}
-}
-
-function createActiveXHR() {
- try {
- return new window.ActiveXObject( "Microsoft.XMLHTTP" );
- } catch( e ) {}
-}
-
+ function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch (e) {
+ }
+ }
+ function createActiveXHR() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ }
+ }
// Install script dataType
-jQuery.ajaxSetup({
- accepts: {
- script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
- },
- contents: {
- script: /(?:java|ecma)script/
- },
- converters: {
- "text script": function( text ) {
- jQuery.globalEval( text );
- return text;
- }
- }
-});
+ jQuery.ajaxSetup({
+ accepts: {
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /(?:java|ecma)script/
+ },
+ converters: {
+ "text script": function (text) {
+ jQuery.globalEval(text);
+ return text;
+ }
+ }
+ });
// Handle cache's special case and global
-jQuery.ajaxPrefilter( "script", function( s ) {
- if ( s.cache === undefined ) {
- s.cache = false;
- }
- if ( s.crossDomain ) {
- s.type = "GET";
- s.global = false;
- }
-});
+ jQuery.ajaxPrefilter("script", function (s) {
+ if (s.cache === undefined) {
+ s.cache = false;
+ }
+ if (s.crossDomain) {
+ s.type = "GET";
+ s.global = false;
+ }
+ });
// Bind script tag hack transport
-jQuery.ajaxTransport( "script", function(s) {
-
- // This transport only deals with cross domain requests
- if ( s.crossDomain ) {
+ jQuery.ajaxTransport("script", function (s) {
- var script,
- head = document.head || jQuery("head")[0] || document.documentElement;
+ // This transport only deals with cross domain requests
+ if (s.crossDomain) {
- return {
+ var script,
+ head = document.head || jQuery("head")[0] || document.documentElement;
- send: function( _, callback ) {
+ return {
- script = document.createElement("script");
+ send: function (_, callback) {
- script.async = true;
+ script = document.createElement("script");
- if ( s.scriptCharset ) {
- script.charset = s.scriptCharset;
- }
+ script.async = true;
- script.src = s.url;
+ if (s.scriptCharset) {
+ script.charset = s.scriptCharset;
+ }
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function( _, isAbort ) {
+ script.src = s.url;
- if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function (_, isAbort) {
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
+ if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
- // Remove the script
- if ( script.parentNode ) {
- script.parentNode.removeChild( script );
- }
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
- // Dereference the script
- script = null;
+ // Remove the script
+ if (script.parentNode) {
+ script.parentNode.removeChild(script);
+ }
- // Callback if not abort
- if ( !isAbort ) {
- callback( 200, "success" );
- }
- }
- };
+ // Dereference the script
+ script = null;
- // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
- // Use native DOM manipulation to avoid our domManip AJAX trickery
- head.insertBefore( script, head.firstChild );
- },
+ // Callback if not abort
+ if (!isAbort) {
+ callback(200, "success");
+ }
+ }
+ };
- abort: function() {
- if ( script ) {
- script.onload( undefined, true );
- }
- }
- };
- }
-});
+ // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
+ head.insertBefore(script, head.firstChild);
+ },
+ abort: function () {
+ if (script) {
+ script.onload(undefined, true);
+ }
+ }
+ };
+ }
+ });
-
-var oldCallbacks = [],
- rjsonp = /(=)\?(?=&|$)|\?\?/;
+ var oldCallbacks = [],
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
-jQuery.ajaxSetup({
- jsonp: "callback",
- jsonpCallback: function() {
- var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
- this[ callback ] = true;
- return callback;
- }
-});
+ jQuery.ajaxSetup({
+ jsonp: "callback",
+ jsonpCallback: function () {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
+ this[callback] = true;
+ return callback;
+ }
+ });
// Detect, normalize options and install callbacks for jsonp requests
-jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
-
- var callbackName, overwritten, responseContainer,
- jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
- "url" :
- typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
- );
-
- // Handle iff the expected data type is "jsonp" or we have a parameter to set
- if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
-
- // Get callback name, remembering preexisting value associated with it
- callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
- s.jsonpCallback() :
- s.jsonpCallback;
-
- // Insert callback into url or form data
- if ( jsonProp ) {
- s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
- } else if ( s.jsonp !== false ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
- }
-
- // Use data converter to retrieve json after script execution
- s.converters["script json"] = function() {
- if ( !responseContainer ) {
- jQuery.error( callbackName + " was not called" );
- }
- return responseContainer[ 0 ];
- };
-
- // force json dataType
- s.dataTypes[ 0 ] = "json";
-
- // Install callback
- overwritten = window[ callbackName ];
- window[ callbackName ] = function() {
- responseContainer = arguments;
- };
-
- // Clean-up function (fires after converters)
- jqXHR.always(function() {
- // Restore preexisting value
- window[ callbackName ] = overwritten;
-
- // Save back as free
- if ( s[ callbackName ] ) {
- // make sure that re-using the options doesn't screw things around
- s.jsonpCallback = originalSettings.jsonpCallback;
-
- // save the callback name for future use
- oldCallbacks.push( callbackName );
- }
-
- // Call if it was a function and we have a response
- if ( responseContainer && jQuery.isFunction( overwritten ) ) {
- overwritten( responseContainer[ 0 ] );
- }
-
- responseContainer = overwritten = undefined;
- });
-
- // Delegate to script
- return "script";
- }
-});
-
-
+ jQuery.ajaxPrefilter("json jsonp", function (s, originalSettings, jqXHR) {
+
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test(s.url) ?
+ "url" :
+ typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test(s.data) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if (jsonProp || s.dataTypes[0] === "jsonp") {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction(s.jsonpCallback) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if (jsonProp) {
+ s[jsonProp] = s[jsonProp].replace(rjsonp, "$1" + callbackName);
+ } else if (s.jsonp !== false) {
+ s.url += ( rquery.test(s.url) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters["script json"] = function () {
+ if (!responseContainer) {
+ jQuery.error(callbackName + " was not called");
+ }
+ return responseContainer[0];
+ };
+
+ // force json dataType
+ s.dataTypes[0] = "json";
+
+ // Install callback
+ overwritten = window[callbackName];
+ window[callbackName] = function () {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always(function () {
+ // Restore preexisting value
+ window[callbackName] = overwritten;
+
+ // Save back as free
+ if (s[callbackName]) {
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push(callbackName);
+ }
+
+ // Call if it was a function and we have a response
+ if (responseContainer && jQuery.isFunction(overwritten)) {
+ overwritten(responseContainer[0]);
+ }
+
+ responseContainer = overwritten = undefined;
+ });
+
+ // Delegate to script
+ return "script";
+ }
+ });
// data: string of html
// context (optional): If specified, the fragment will be created in this context, defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
-jQuery.parseHTML = function( data, context, keepScripts ) {
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- if ( typeof context === "boolean" ) {
- keepScripts = context;
- context = false;
- }
- context = context || document;
+ jQuery.parseHTML = function (data, context, keepScripts) {
+ if (!data || typeof data !== "string") {
+ return null;
+ }
+ if (typeof context === "boolean") {
+ keepScripts = context;
+ context = false;
+ }
+ context = context || document;
- var parsed = rsingleTag.exec( data ),
- scripts = !keepScripts && [];
+ var parsed = rsingleTag.exec(data),
+ scripts = !keepScripts && [];
- // Single tag
- if ( parsed ) {
- return [ context.createElement( parsed[1] ) ];
- }
+ // Single tag
+ if (parsed) {
+ return [context.createElement(parsed[1])];
+ }
- parsed = jQuery.buildFragment( [ data ], context, scripts );
+ parsed = jQuery.buildFragment([data], context, scripts);
- if ( scripts && scripts.length ) {
- jQuery( scripts ).remove();
- }
+ if (scripts && scripts.length) {
+ jQuery(scripts).remove();
+ }
- return jQuery.merge( [], parsed.childNodes );
-};
+ return jQuery.merge([], parsed.childNodes);
+ };
// Keep a copy of the old load method
-var _load = jQuery.fn.load;
-
-/**
- * Load a url into a page
- */
-jQuery.fn.load = function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
- }
-
- var selector, response, type,
- self = this,
- off = url.indexOf(" ");
-
- if ( off >= 0 ) {
- selector = jQuery.trim( url.slice( off, url.length ) );
- url = url.slice( 0, off );
- }
-
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
-
- // We assume that it's the callback
- callback = params;
- params = undefined;
-
- // Otherwise, build a param string
- } else if ( params && typeof params === "object" ) {
- type = "POST";
- }
-
- // If we have elements to modify, make the request
- if ( self.length > 0 ) {
- jQuery.ajax({
- url: url,
-
- // if "type" variable is undefined, then "GET" method will be used
- type: type,
- dataType: "html",
- data: params
- }).done(function( responseText ) {
-
- // Save response for use in complete callback
- response = arguments;
-
- self.html( selector ?
-
- // If a selector was specified, locate the right elements in a dummy div
- // Exclude scripts to avoid IE 'Permission Denied' errors
- jQuery("").append( jQuery.parseHTML( responseText ) ).find( selector ) :
-
- // Otherwise use the full result
- responseText );
-
- }).complete( callback && function( jqXHR, status ) {
- self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
- });
- }
-
- return this;
-};
-
-
-
-
-jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep(jQuery.timers, function( fn ) {
- return elem === fn.elem;
- }).length;
-};
-
-
-
-
-
-var docElem = window.document.documentElement;
-
-/**
- * Gets a window from an element
- */
-function getWindow( elem ) {
- return jQuery.isWindow( elem ) ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
-}
-
-jQuery.offset = {
- setOffset: function( elem, options, i ) {
- var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
- position = jQuery.css( elem, "position" ),
- curElem = jQuery( elem ),
- props = {};
-
- // set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
-
- curOffset = curElem.offset();
- curCSSTop = jQuery.css( elem, "top" );
- curCSSLeft = jQuery.css( elem, "left" );
- calculatePosition = ( position === "absolute" || position === "fixed" ) &&
- jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
-
- // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
- if ( calculatePosition ) {
- curPosition = curElem.position();
- curTop = curPosition.top;
- curLeft = curPosition.left;
- } else {
- curTop = parseFloat( curCSSTop ) || 0;
- curLeft = parseFloat( curCSSLeft ) || 0;
- }
-
- if ( jQuery.isFunction( options ) ) {
- options = options.call( elem, i, curOffset );
- }
-
- if ( options.top != null ) {
- props.top = ( options.top - curOffset.top ) + curTop;
- }
- if ( options.left != null ) {
- props.left = ( options.left - curOffset.left ) + curLeft;
- }
-
- if ( "using" in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- }
-};
-
-jQuery.fn.extend({
- offset: function( options ) {
- if ( arguments.length ) {
- return options === undefined ?
- this :
- this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- var docElem, win,
- box = { top: 0, left: 0 },
- elem = this[ 0 ],
- doc = elem && elem.ownerDocument;
-
- if ( !doc ) {
- return;
- }
-
- docElem = doc.documentElement;
-
- // Make sure it's not a disconnected DOM node
- if ( !jQuery.contains( docElem, elem ) ) {
- return box;
- }
-
- // If we don't have gBCR, just use 0,0 rather than error
- // BlackBerry 5, iOS 3 (original iPhone)
- if ( typeof elem.getBoundingClientRect !== strundefined ) {
- box = elem.getBoundingClientRect();
- }
- win = getWindow( doc );
- return {
- top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
- left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
- };
- },
-
- position: function() {
- if ( !this[ 0 ] ) {
- return;
- }
-
- var offsetParent, offset,
- parentOffset = { top: 0, left: 0 },
- elem = this[ 0 ];
-
- // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
- if ( jQuery.css( elem, "position" ) === "fixed" ) {
- // we assume that getBoundingClientRect is available when computed position is fixed
- offset = elem.getBoundingClientRect();
- } else {
- // Get *real* offsetParent
- offsetParent = this.offsetParent();
-
- // Get correct offsets
- offset = this.offset();
- if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
- parentOffset = offsetParent.offset();
- }
-
- // Add offsetParent borders
- parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
- parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
- }
-
- // Subtract parent offsets and element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
- // are the same in Safari causing offset.left to incorrectly be 0
- return {
- top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
- left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
- };
- },
-
- offsetParent: function() {
- return this.map(function() {
- var offsetParent = this.offsetParent || docElem;
-
- while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent || docElem;
- });
- }
-});
+ var _load = jQuery.fn.load;
+
+ /**
+ * Load a url into a page
+ */
+ jQuery.fn.load = function (url, params, callback) {
+ if (typeof url !== "string" && _load) {
+ return _load.apply(this, arguments);
+ }
+
+ var selector, response, type,
+ self = this,
+ off = url.indexOf(" ");
+
+ if (off >= 0) {
+ selector = jQuery.trim(url.slice(off, url.length));
+ url = url.slice(0, off);
+ }
+
+ // If it's a function
+ if (jQuery.isFunction(params)) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if (params && typeof params === "object") {
+ type = "POST";
+ }
+
+ // If we have elements to modify, make the request
+ if (self.length > 0) {
+ jQuery.ajax({
+ url: url,
+
+ // if "type" variable is undefined, then "GET" method will be used
+ type: type,
+ dataType: "html",
+ data: params
+ }).done(function (responseText) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ self.html(selector ?
+
+ // If a selector was specified, locate the right elements in a dummy div
+ // Exclude scripts to avoid IE 'Permission Denied' errors
+ jQuery("
").append(jQuery.parseHTML(responseText)).find(selector) :
+
+ // Otherwise use the full result
+ responseText);
+
+ }).complete(callback && function (jqXHR, status) {
+ self.each(callback, response || [jqXHR.responseText, status, jqXHR]);
+ });
+ }
+
+ return this;
+ };
+
+
+ jQuery.expr.filters.animated = function (elem) {
+ return jQuery.grep(jQuery.timers, function (fn) {
+ return elem === fn.elem;
+ }).length;
+ };
+
+
+ var docElem = window.document.documentElement;
+
+ /**
+ * Gets a window from an element
+ */
+ function getWindow(elem) {
+ return jQuery.isWindow(elem) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+ }
+
+ jQuery.offset = {
+ setOffset: function (elem, options, i) {
+ var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
+ position = jQuery.css(elem, "position"),
+ curElem = jQuery(elem),
+ props = {};
+
+ // set position first, in-case top/left are set even on static elem
+ if (position === "static") {
+ elem.style.position = "relative";
+ }
+
+ curOffset = curElem.offset();
+ curCSSTop = jQuery.css(elem, "top");
+ curCSSLeft = jQuery.css(elem, "left");
+ calculatePosition = ( position === "absolute" || position === "fixed" ) &&
+ jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1;
+
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+ if (calculatePosition) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat(curCSSTop) || 0;
+ curLeft = parseFloat(curCSSLeft) || 0;
+ }
+
+ if (jQuery.isFunction(options)) {
+ options = options.call(elem, i, curOffset);
+ }
+
+ if (options.top != null) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if (options.left != null) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ("using" in options) {
+ options.using.call(elem, props);
+ } else {
+ curElem.css(props);
+ }
+ }
+ };
+
+ jQuery.fn.extend({
+ offset: function (options) {
+ if (arguments.length) {
+ return options === undefined ?
+ this :
+ this.each(function (i) {
+ jQuery.offset.setOffset(this, options, i);
+ });
+ }
+
+ var docElem, win,
+ box = {top: 0, left: 0},
+ elem = this[0],
+ doc = elem && elem.ownerDocument;
+
+ if (!doc) {
+ return;
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if (!jQuery.contains(docElem, elem)) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if (typeof elem.getBoundingClientRect !== strundefined) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow(doc);
+ return {
+ top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
+ left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
+ };
+ },
+
+ position: function () {
+ if (!this[0]) {
+ return;
+ }
+
+ var offsetParent, offset,
+ parentOffset = {top: 0, left: 0},
+ elem = this[0];
+
+ // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
+ if (jQuery.css(elem, "position") === "fixed") {
+ // we assume that getBoundingClientRect is available when computed position is fixed
+ offset = elem.getBoundingClientRect();
+ } else {
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent();
+
+ // Get correct offsets
+ offset = this.offset();
+ if (!jQuery.nodeName(offsetParent[0], "html")) {
+ parentOffset = offsetParent.offset();
+ }
+
+ // Add offsetParent borders
+ parentOffset.top += jQuery.css(offsetParent[0], "borderTopWidth", true);
+ parentOffset.left += jQuery.css(offsetParent[0], "borderLeftWidth", true);
+ }
+
+ // Subtract parent offsets and element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ return {
+ top: offset.top - parentOffset.top - jQuery.css(elem, "marginTop", true),
+ left: offset.left - parentOffset.left - jQuery.css(elem, "marginLeft", true)
+ };
+ },
+
+ offsetParent: function () {
+ return this.map(function () {
+ var offsetParent = this.offsetParent || docElem;
+
+ while (offsetParent && ( !jQuery.nodeName(offsetParent, "html") && jQuery.css(offsetParent, "position") === "static" )) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || docElem;
+ });
+ }
+ });
// Create scrollLeft and scrollTop methods
-jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
- var top = /Y/.test( prop );
-
- jQuery.fn[ method ] = function( val ) {
- return access( this, function( elem, method, val ) {
- var win = getWindow( elem );
-
- if ( val === undefined ) {
- return win ? (prop in win) ? win[ prop ] :
- win.document.documentElement[ method ] :
- elem[ method ];
- }
-
- if ( win ) {
- win.scrollTo(
- !top ? val : jQuery( win ).scrollLeft(),
- top ? val : jQuery( win ).scrollTop()
- );
-
- } else {
- elem[ method ] = val;
- }
- }, method, val, arguments.length, null );
- };
-});
+ jQuery.each({scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function (method, prop) {
+ var top = /Y/.test(prop);
+
+ jQuery.fn[method] = function (val) {
+ return access(this, function (elem, method, val) {
+ var win = getWindow(elem);
+
+ if (val === undefined) {
+ return win ? (prop in win) ? win[prop] :
+ win.document.documentElement[method] :
+ elem[method];
+ }
+
+ if (win) {
+ win.scrollTo(
+ !top ? val : jQuery(win).scrollLeft(),
+ top ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ elem[method] = val;
+ }
+ }, method, val, arguments.length, null);
+ };
+ });
// Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right
// rather than make the css module depend on the offset module, we just check for it here
-jQuery.each( [ "top", "left" ], function( i, prop ) {
- jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
- function( elem, computed ) {
- if ( computed ) {
- computed = curCSS( elem, prop );
- // if curCSS returns percentage, fallback to offset
- return rnumnonpx.test( computed ) ?
- jQuery( elem ).position()[ prop ] + "px" :
- computed;
- }
- }
- );
-});
+ jQuery.each(["top", "left"], function (i, prop) {
+ jQuery.cssHooks[prop] = addGetHookIf(support.pixelPosition,
+ function (elem, computed) {
+ if (computed) {
+ computed = curCSS(elem, prop);
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test(computed) ?
+ jQuery(elem).position()[prop] + "px" :
+ computed;
+ }
+ }
+ );
+ });
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
-jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
- jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
- // margin is only for outerHeight, outerWidth
- jQuery.fn[ funcName ] = function( margin, value ) {
- var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
- extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
-
- return access( this, function( elem, type, value ) {
- var doc;
-
- if ( jQuery.isWindow( elem ) ) {
- // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
- // isn't a whole lot we can do. See pull request at this URL for discussion:
- // https://github.com/jquery/jquery/pull/764
- return elem.document.documentElement[ "client" + name ];
- }
-
- // Get document width or height
- if ( elem.nodeType === 9 ) {
- doc = elem.documentElement;
-
- // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
- // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
- return Math.max(
- elem.body[ "scroll" + name ], doc[ "scroll" + name ],
- elem.body[ "offset" + name ], doc[ "offset" + name ],
- doc[ "client" + name ]
- );
- }
-
- return value === undefined ?
- // Get width or height on the element, requesting but not forcing parseFloat
- jQuery.css( elem, type, extra ) :
-
- // Set width or height on the element
- jQuery.style( elem, type, value, extra );
- }, type, chainable ? margin : undefined, chainable, null );
- };
- });
-});
+ jQuery.each({Height: "height", Width: "width"}, function (name, type) {
+ jQuery.each({padding: "inner" + name, content: type, "": "outer" + name}, function (defaultExtra, funcName) {
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[funcName] = function (margin, value) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return access(this, function (elem, type, value) {
+ var doc;
+
+ if (jQuery.isWindow(elem)) {
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement["client" + name];
+ }
+
+ // Get document width or height
+ if (elem.nodeType === 9) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body["scroll" + name], doc["scroll" + name],
+ elem.body["offset" + name], doc["offset" + name],
+ doc["client" + name]
+ );
+ }
+
+ return value === undefined ?
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css(elem, type, extra) :
+
+ // Set width or height on the element
+ jQuery.style(elem, type, value, extra);
+ }, type, chainable ? margin : undefined, chainable, null);
+ };
+ });
+ });
// The number of elements contained in the matched element set
-jQuery.fn.size = function() {
- return this.length;
-};
-
-jQuery.fn.andSelf = jQuery.fn.addBack;
-
+ jQuery.fn.size = function () {
+ return this.length;
+ };
+ jQuery.fn.andSelf = jQuery.fn.addBack;
// Register as a named AMD module, since jQuery can be concatenated with other
@@ -10265,44 +10244,40 @@ jQuery.fn.andSelf = jQuery.fn.addBack;
// AMD loader is present. jQuery is a special case. For more information, see
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
-if ( typeof define === "function" && define.amd ) {
- define( "jquery", [], function() {
- return jQuery;
- });
-}
+ if (typeof define === "function" && define.amd) {
+ define("jquery", [], function () {
+ return jQuery;
+ });
+ }
+ var
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+ // Map over the $ in case of overwrite
+ _$ = window.$;
-var
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
+ jQuery.noConflict = function (deep) {
+ if (window.$ === jQuery) {
+ window.$ = _$;
+ }
- // Map over the $ in case of overwrite
- _$ = window.$;
+ if (deep && window.jQuery === jQuery) {
+ window.jQuery = _jQuery;
+ }
-jQuery.noConflict = function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
-};
+ return jQuery;
+ };
// Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
-if ( typeof noGlobal === strundefined ) {
- window.jQuery = window.$ = jQuery;
-}
-
-
+ if (typeof noGlobal === strundefined) {
+ window.jQuery = window.$ = jQuery;
+ }
-return jQuery;
+ return jQuery;
}));
\ No newline at end of file
diff --git a/sdk/src/third-party/jquery.min.js b/sdk/src/third-party/jquery.min.js
index d1608e37..c28ef3b7 100644
--- a/sdk/src/third-party/jquery.min.js
+++ b/sdk/src/third-party/jquery.min.js
@@ -1,4 +1,2629 @@
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
-!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="
",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d
b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML=" ","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML=" ",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;
-if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" a ",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML=" ",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h ]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""," "],legend:[1,""," "],area:[1,""," "],param:[1,""," "],thead:[1,""],tr:[2,""],col:[2,""],td:[3,""],_default:k.htmlSerialize?[0,"",""]:[1,"X","
"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML=" a ",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")
-},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();ca ",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});
\ No newline at end of file
+!function (a, b) {
+ "object" == typeof module && "object" == typeof module.exports ? module.exports = a.document ? b(a, !0) : function (a) {
+ if (!a.document)throw new Error("jQuery requires a window with a document");
+ return b(a)
+ } : b(a)
+}("undefined" != typeof window ? window : this, function (a, b) {
+ var c = [], d = c.slice, e = c.concat, f = c.push, g = c.indexOf, h = {}, i = h.toString, j = h.hasOwnProperty, k = {}, l = "1.11.1", m = function (a, b) {
+ return new m.fn.init(a, b)
+ }, n = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, o = /^-ms-/, p = /-([\da-z])/gi, q = function (a, b) {
+ return b.toUpperCase()
+ };
+ m.fn = m.prototype = {
+ jquery: l, constructor: m, selector: "", length: 0, toArray: function () {
+ return d.call(this)
+ }, get: function (a) {
+ return null != a ? 0 > a ? this[a + this.length] : this[a] : d.call(this)
+ }, pushStack: function (a) {
+ var b = m.merge(this.constructor(), a);
+ return b.prevObject = this, b.context = this.context, b
+ }, each: function (a, b) {
+ return m.each(this, a, b)
+ }, map: function (a) {
+ return this.pushStack(m.map(this, function (b, c) {
+ return a.call(b, c, b)
+ }))
+ }, slice: function () {
+ return this.pushStack(d.apply(this, arguments))
+ }, first: function () {
+ return this.eq(0)
+ }, last: function () {
+ return this.eq(-1)
+ }, eq: function (a) {
+ var b = this.length, c = +a + (0 > a ? b : 0);
+ return this.pushStack(c >= 0 && b > c ? [this[c]] : [])
+ }, end: function () {
+ return this.prevObject || this.constructor(null)
+ }, push: f, sort: c.sort, splice: c.splice
+ }, m.extend = m.fn.extend = function () {
+ var a, b, c, d, e, f, g = arguments[0] || {}, h = 1, i = arguments.length, j = !1;
+ for ("boolean" == typeof g && (j = g, g = arguments[h] || {}, h++), "object" == typeof g || m.isFunction(g) || (g = {}), h === i && (g = this, h--); i > h; h++)if (null != (e = arguments[h]))for (d in e)a = g[d], c = e[d], g !== c && (j && c && (m.isPlainObject(c) || (b = m.isArray(c))) ? (b ? (b = !1, f = a && m.isArray(a) ? a : []) : f = a && m.isPlainObject(a) ? a : {}, g[d] = m.extend(j, f, c)) : void 0 !== c && (g[d] = c));
+ return g
+ }, m.extend({
+ expando: "jQuery" + (l + Math.random()).replace(/\D/g, ""), isReady: !0, error: function (a) {
+ throw new Error(a)
+ }, noop: function () {
+ }, isFunction: function (a) {
+ return "function" === m.type(a)
+ }, isArray: Array.isArray || function (a) {
+ return "array" === m.type(a)
+ }, isWindow: function (a) {
+ return null != a && a == a.window
+ }, isNumeric: function (a) {
+ return !m.isArray(a) && a - parseFloat(a) >= 0
+ }, isEmptyObject: function (a) {
+ var b;
+ for (b in a)return !1;
+ return !0
+ }, isPlainObject: function (a) {
+ var b;
+ if (!a || "object" !== m.type(a) || a.nodeType || m.isWindow(a))return !1;
+ try {
+ if (a.constructor && !j.call(a, "constructor") && !j.call(a.constructor.prototype, "isPrototypeOf"))return !1
+ } catch (c) {
+ return !1
+ }
+ if (k.ownLast)for (b in a)return j.call(a, b);
+ for (b in a);
+ return void 0 === b || j.call(a, b)
+ }, type: function (a) {
+ return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h[i.call(a)] || "object" : typeof a
+ }, globalEval: function (b) {
+ b && m.trim(b) && (a.execScript || function (b) {
+ a.eval.call(a, b)
+ })(b)
+ }, camelCase: function (a) {
+ return a.replace(o, "ms-").replace(p, q)
+ }, nodeName: function (a, b) {
+ return a.nodeName && a.nodeName.toLowerCase() === b.toLowerCase()
+ }, each: function (a, b, c) {
+ var d, e = 0, f = a.length, g = r(a);
+ if (c) {
+ if (g) {
+ for (; f > e; e++)if (d = b.apply(a[e], c), d === !1)break
+ } else for (e in a)if (d = b.apply(a[e], c), d === !1)break
+ } else if (g) {
+ for (; f > e; e++)if (d = b.call(a[e], e, a[e]), d === !1)break
+ } else for (e in a)if (d = b.call(a[e], e, a[e]), d === !1)break;
+ return a
+ }, trim: function (a) {
+ return null == a ? "" : (a + "").replace(n, "")
+ }, makeArray: function (a, b) {
+ var c = b || [];
+ return null != a && (r(Object(a)) ? m.merge(c, "string" == typeof a ? [a] : a) : f.call(c, a)), c
+ }, inArray: function (a, b, c) {
+ var d;
+ if (b) {
+ if (g)return g.call(b, a, c);
+ for (d = b.length, c = c ? 0 > c ? Math.max(0, d + c) : c : 0; d > c; c++)if (c in b && b[c] === a)return c
+ }
+ return -1
+ }, merge: function (a, b) {
+ var c = +b.length, d = 0, e = a.length;
+ while (c > d)a[e++] = b[d++];
+ if (c !== c)while (void 0 !== b[d])a[e++] = b[d++];
+ return a.length = e, a
+ }, grep: function (a, b, c) {
+ for (var d, e = [], f = 0, g = a.length, h = !c; g > f; f++)d = !b(a[f], f), d !== h && e.push(a[f]);
+ return e
+ }, map: function (a, b, c) {
+ var d, f = 0, g = a.length, h = r(a), i = [];
+ if (h)for (; g > f; f++)d = b(a[f], f, c), null != d && i.push(d); else for (f in a)d = b(a[f], f, c), null != d && i.push(d);
+ return e.apply([], i)
+ }, guid: 1, proxy: function (a, b) {
+ var c, e, f;
+ return "string" == typeof b && (f = a[b], b = a, a = f), m.isFunction(a) ? (c = d.call(arguments, 2), e = function () {
+ return a.apply(b || this, c.concat(d.call(arguments)))
+ }, e.guid = a.guid = a.guid || m.guid++, e) : void 0
+ }, now: function () {
+ return +new Date
+ }, support: k
+ }), m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (a, b) {
+ h["[object " + b + "]"] = b.toLowerCase()
+ });
+ function r(a) {
+ var b = a.length, c = m.type(a);
+ return "function" === c || m.isWindow(a) ? !1 : 1 === a.nodeType && b ? !0 : "array" === c || 0 === b || "number" == typeof b && b > 0 && b - 1 in a
+ }
+
+ var s = function (a) {
+ var b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u = "sizzle" + -new Date, v = a.document, w = 0, x = 0, y = gb(), z = gb(), A = gb(), B = function (a, b) {
+ return a === b && (l = !0), 0
+ }, C = "undefined", D = 1 << 31, E = {}.hasOwnProperty, F = [], G = F.pop, H = F.push, I = F.push, J = F.slice, K = F.indexOf || function (a) {
+ for (var b = 0, c = this.length; c > b; b++)if (this[b] === a)return b;
+ return -1
+ }, L = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", M = "[\\x20\\t\\r\\n\\f]", N = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", O = N.replace("w", "w#"), P = "\\[" + M + "*(" + N + ")(?:" + M + "*([*^$|!~]?=)" + M + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + O + "))|)" + M + "*\\]", Q = ":(" + N + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + P + ")*)|.*)\\)|)", R = new RegExp("^" + M + "+|((?:^|[^\\\\])(?:\\\\.)*)" + M + "+$", "g"), S = new RegExp("^" + M + "*," + M + "*"), T = new RegExp("^" + M + "*([>+~]|" + M + ")" + M + "*"), U = new RegExp("=" + M + "*([^\\]'\"]*?)" + M + "*\\]", "g"), V = new RegExp(Q), W = new RegExp("^" + O + "$"), X = {
+ ID: new RegExp("^#(" + N + ")"),
+ CLASS: new RegExp("^\\.(" + N + ")"),
+ TAG: new RegExp("^(" + N.replace("w", "w*") + ")"),
+ ATTR: new RegExp("^" + P),
+ PSEUDO: new RegExp("^" + Q),
+ CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + M + "*(even|odd|(([+-]|)(\\d*)n|)" + M + "*(?:([+-]|)" + M + "*(\\d+)|))" + M + "*\\)|)", "i"),
+ bool: new RegExp("^(?:" + L + ")$", "i"),
+ needsContext: new RegExp("^" + M + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + M + "*((?:-\\d)?\\d*)" + M + "*\\)|)(?=[^-]|$)", "i")
+ }, Y = /^(?:input|select|textarea|button)$/i, Z = /^h\d$/i, $ = /^[^{]+\{\s*\[native \w/, _ = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, ab = /[+~]/, bb = /'|\\/g, cb = new RegExp("\\\\([\\da-f]{1,6}" + M + "?|(" + M + ")|.)", "ig"), db = function (a, b, c) {
+ var d = "0x" + b - 65536;
+ return d !== d || c ? b : 0 > d ? String.fromCharCode(d + 65536) : String.fromCharCode(d >> 10 | 55296, 1023 & d | 56320)
+ };
+ try {
+ I.apply(F = J.call(v.childNodes), v.childNodes), F[v.childNodes.length].nodeType
+ } catch (eb) {
+ I = {
+ apply: F.length ? function (a, b) {
+ H.apply(a, J.call(b))
+ } : function (a, b) {
+ var c = a.length, d = 0;
+ while (a[c++] = b[d++]);
+ a.length = c - 1
+ }
+ }
+ }
+ function fb(a, b, d, e) {
+ var f, h, j, k, l, o, r, s, w, x;
+ if ((b ? b.ownerDocument || b : v) !== n && m(b), b = b || n, d = d || [], !a || "string" != typeof a)return d;
+ if (1 !== (k = b.nodeType) && 9 !== k)return [];
+ if (p && !e) {
+ if (f = _.exec(a))if (j = f[1]) {
+ if (9 === k) {
+ if (h = b.getElementById(j), !h || !h.parentNode)return d;
+ if (h.id === j)return d.push(h), d
+ } else if (b.ownerDocument && (h = b.ownerDocument.getElementById(j)) && t(b, h) && h.id === j)return d.push(h), d
+ } else {
+ if (f[2])return I.apply(d, b.getElementsByTagName(a)), d;
+ if ((j = f[3]) && c.getElementsByClassName && b.getElementsByClassName)return I.apply(d, b.getElementsByClassName(j)), d
+ }
+ if (c.qsa && (!q || !q.test(a))) {
+ if (s = r = u, w = b, x = 9 === k && a, 1 === k && "object" !== b.nodeName.toLowerCase()) {
+ o = g(a), (r = b.getAttribute("id")) ? s = r.replace(bb, "\\$&") : b.setAttribute("id", s), s = "[id='" + s + "'] ", l = o.length;
+ while (l--)o[l] = s + qb(o[l]);
+ w = ab.test(a) && ob(b.parentNode) || b, x = o.join(",")
+ }
+ if (x)try {
+ return I.apply(d, w.querySelectorAll(x)), d
+ } catch (y) {
+ } finally {
+ r || b.removeAttribute("id")
+ }
+ }
+ }
+ return i(a.replace(R, "$1"), b, d, e)
+ }
+
+ function gb() {
+ var a = [];
+
+ function b(c, e) {
+ return a.push(c + " ") > d.cacheLength && delete b[a.shift()], b[c + " "] = e
+ }
+
+ return b
+ }
+
+ function hb(a) {
+ return a[u] = !0, a
+ }
+
+ function ib(a) {
+ var b = n.createElement("div");
+ try {
+ return !!a(b)
+ } catch (c) {
+ return !1
+ } finally {
+ b.parentNode && b.parentNode.removeChild(b), b = null
+ }
+ }
+
+ function jb(a, b) {
+ var c = a.split("|"), e = a.length;
+ while (e--)d.attrHandle[c[e]] = b
+ }
+
+ function kb(a, b) {
+ var c = b && a, d = c && 1 === a.nodeType && 1 === b.nodeType && (~b.sourceIndex || D) - (~a.sourceIndex || D);
+ if (d)return d;
+ if (c)while (c = c.nextSibling)if (c === b)return -1;
+ return a ? 1 : -1
+ }
+
+ function lb(a) {
+ return function (b) {
+ var c = b.nodeName.toLowerCase();
+ return "input" === c && b.type === a
+ }
+ }
+
+ function mb(a) {
+ return function (b) {
+ var c = b.nodeName.toLowerCase();
+ return ("input" === c || "button" === c) && b.type === a
+ }
+ }
+
+ function nb(a) {
+ return hb(function (b) {
+ return b = +b, hb(function (c, d) {
+ var e, f = a([], c.length, b), g = f.length;
+ while (g--)c[e = f[g]] && (c[e] = !(d[e] = c[e]))
+ })
+ })
+ }
+
+ function ob(a) {
+ return a && typeof a.getElementsByTagName !== C && a
+ }
+
+ c = fb.support = {}, f = fb.isXML = function (a) {
+ var b = a && (a.ownerDocument || a).documentElement;
+ return b ? "HTML" !== b.nodeName : !1
+ }, m = fb.setDocument = function (a) {
+ var b, e = a ? a.ownerDocument || a : v, g = e.defaultView;
+ return e !== n && 9 === e.nodeType && e.documentElement ? (n = e, o = e.documentElement, p = !f(e), g && g !== g.top && (g.addEventListener ? g.addEventListener("unload", function () {
+ m()
+ }, !1) : g.attachEvent && g.attachEvent("onunload", function () {
+ m()
+ })), c.attributes = ib(function (a) {
+ return a.className = "i", !a.getAttribute("className")
+ }), c.getElementsByTagName = ib(function (a) {
+ return a.appendChild(e.createComment("")), !a.getElementsByTagName("*").length
+ }), c.getElementsByClassName = $.test(e.getElementsByClassName) && ib(function (a) {
+ return a.innerHTML = "
", a.firstChild.className = "i", 2 === a.getElementsByClassName("i").length
+ }), c.getById = ib(function (a) {
+ return o.appendChild(a).id = u, !e.getElementsByName || !e.getElementsByName(u).length
+ }), c.getById ? (d.find.ID = function (a, b) {
+ if (typeof b.getElementById !== C && p) {
+ var c = b.getElementById(a);
+ return c && c.parentNode ? [c] : []
+ }
+ }, d.filter.ID = function (a) {
+ var b = a.replace(cb, db);
+ return function (a) {
+ return a.getAttribute("id") === b
+ }
+ }) : (delete d.find.ID, d.filter.ID = function (a) {
+ var b = a.replace(cb, db);
+ return function (a) {
+ var c = typeof a.getAttributeNode !== C && a.getAttributeNode("id");
+ return c && c.value === b
+ }
+ }), d.find.TAG = c.getElementsByTagName ? function (a, b) {
+ return typeof b.getElementsByTagName !== C ? b.getElementsByTagName(a) : void 0
+ } : function (a, b) {
+ var c, d = [], e = 0, f = b.getElementsByTagName(a);
+ if ("*" === a) {
+ while (c = f[e++])1 === c.nodeType && d.push(c);
+ return d
+ }
+ return f
+ }, d.find.CLASS = c.getElementsByClassName && function (a, b) {
+ return typeof b.getElementsByClassName !== C && p ? b.getElementsByClassName(a) : void 0
+ }, r = [], q = [], (c.qsa = $.test(e.querySelectorAll)) && (ib(function (a) {
+ a.innerHTML = "
", a.querySelectorAll("[msallowclip^='']").length && q.push("[*^$]=" + M + "*(?:''|\"\")"), a.querySelectorAll("[selected]").length || q.push("\\[" + M + "*(?:value|" + L + ")"), a.querySelectorAll(":checked").length || q.push(":checked")
+ }), ib(function (a) {
+ var b = e.createElement("input");
+ b.setAttribute("type", "hidden"), a.appendChild(b).setAttribute("name", "D"), a.querySelectorAll("[name=d]").length && q.push("name" + M + "*[*^$|!~]?="), a.querySelectorAll(":enabled").length || q.push(":enabled", ":disabled"), a.querySelectorAll("*,:x"), q.push(",.*:")
+ })), (c.matchesSelector = $.test(s = o.matches || o.webkitMatchesSelector || o.mozMatchesSelector || o.oMatchesSelector || o.msMatchesSelector)) && ib(function (a) {
+ c.disconnectedMatch = s.call(a, "div"), s.call(a, "[s!='']:x"), r.push("!=", Q)
+ }), q = q.length && new RegExp(q.join("|")), r = r.length && new RegExp(r.join("|")), b = $.test(o.compareDocumentPosition), t = b || $.test(o.contains) ? function (a, b) {
+ var c = 9 === a.nodeType ? a.documentElement : a, d = b && b.parentNode;
+ return a === d || !(!d || 1 !== d.nodeType || !(c.contains ? c.contains(d) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(d)))
+ } : function (a, b) {
+ if (b)while (b = b.parentNode)if (b === a)return !0;
+ return !1
+ }, B = b ? function (a, b) {
+ if (a === b)return l = !0, 0;
+ var d = !a.compareDocumentPosition - !b.compareDocumentPosition;
+ return d ? d : (d = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1, 1 & d || !c.sortDetached && b.compareDocumentPosition(a) === d ? a === e || a.ownerDocument === v && t(v, a) ? -1 : b === e || b.ownerDocument === v && t(v, b) ? 1 : k ? K.call(k, a) - K.call(k, b) : 0 : 4 & d ? -1 : 1)
+ } : function (a, b) {
+ if (a === b)return l = !0, 0;
+ var c, d = 0, f = a.parentNode, g = b.parentNode, h = [a], i = [b];
+ if (!f || !g)return a === e ? -1 : b === e ? 1 : f ? -1 : g ? 1 : k ? K.call(k, a) - K.call(k, b) : 0;
+ if (f === g)return kb(a, b);
+ c = a;
+ while (c = c.parentNode)h.unshift(c);
+ c = b;
+ while (c = c.parentNode)i.unshift(c);
+ while (h[d] === i[d])d++;
+ return d ? kb(h[d], i[d]) : h[d] === v ? -1 : i[d] === v ? 1 : 0
+ }, e) : n
+ }, fb.matches = function (a, b) {
+ return fb(a, null, null, b)
+ }, fb.matchesSelector = function (a, b) {
+ if ((a.ownerDocument || a) !== n && m(a), b = b.replace(U, "='$1']"), !(!c.matchesSelector || !p || r && r.test(b) || q && q.test(b)))try {
+ var d = s.call(a, b);
+ if (d || c.disconnectedMatch || a.document && 11 !== a.document.nodeType)return d
+ } catch (e) {
+ }
+ return fb(b, n, null, [a]).length > 0
+ }, fb.contains = function (a, b) {
+ return (a.ownerDocument || a) !== n && m(a), t(a, b)
+ }, fb.attr = function (a, b) {
+ (a.ownerDocument || a) !== n && m(a);
+ var e = d.attrHandle[b.toLowerCase()], f = e && E.call(d.attrHandle, b.toLowerCase()) ? e(a, b, !p) : void 0;
+ return void 0 !== f ? f : c.attributes || !p ? a.getAttribute(b) : (f = a.getAttributeNode(b)) && f.specified ? f.value : null
+ }, fb.error = function (a) {
+ throw new Error("Syntax error, unrecognized expression: " + a)
+ }, fb.uniqueSort = function (a) {
+ var b, d = [], e = 0, f = 0;
+ if (l = !c.detectDuplicates, k = !c.sortStable && a.slice(0), a.sort(B), l) {
+ while (b = a[f++])b === a[f] && (e = d.push(f));
+ while (e--)a.splice(d[e], 1)
+ }
+ return k = null, a
+ }, e = fb.getText = function (a) {
+ var b, c = "", d = 0, f = a.nodeType;
+ if (f) {
+ if (1 === f || 9 === f || 11 === f) {
+ if ("string" == typeof a.textContent)return a.textContent;
+ for (a = a.firstChild; a; a = a.nextSibling)c += e(a)
+ } else if (3 === f || 4 === f)return a.nodeValue
+ } else while (b = a[d++])c += e(b);
+ return c
+ }, d = fb.selectors = {
+ cacheLength: 50,
+ createPseudo: hb,
+ match: X,
+ attrHandle: {},
+ find: {},
+ relative: {
+ ">": {dir: "parentNode", first: !0},
+ " ": {dir: "parentNode"},
+ "+": {dir: "previousSibling", first: !0},
+ "~": {dir: "previousSibling"}
+ },
+ preFilter: {
+ ATTR: function (a) {
+ return a[1] = a[1].replace(cb, db), a[3] = (a[3] || a[4] || a[5] || "").replace(cb, db), "~=" === a[2] && (a[3] = " " + a[3] + " "), a.slice(0, 4)
+ }, CHILD: function (a) {
+ return a[1] = a[1].toLowerCase(), "nth" === a[1].slice(0, 3) ? (a[3] || fb.error(a[0]), a[4] = +(a[4] ? a[5] + (a[6] || 1) : 2 * ("even" === a[3] || "odd" === a[3])), a[5] = +(a[7] + a[8] || "odd" === a[3])) : a[3] && fb.error(a[0]), a
+ }, PSEUDO: function (a) {
+ var b, c = !a[6] && a[2];
+ return X.CHILD.test(a[0]) ? null : (a[3] ? a[2] = a[4] || a[5] || "" : c && V.test(c) && (b = g(c, !0)) && (b = c.indexOf(")", c.length - b) - c.length) && (a[0] = a[0].slice(0, b), a[2] = c.slice(0, b)), a.slice(0, 3))
+ }
+ },
+ filter: {
+ TAG: function (a) {
+ var b = a.replace(cb, db).toLowerCase();
+ return "*" === a ? function () {
+ return !0
+ } : function (a) {
+ return a.nodeName && a.nodeName.toLowerCase() === b
+ }
+ }, CLASS: function (a) {
+ var b = y[a + " "];
+ return b || (b = new RegExp("(^|" + M + ")" + a + "(" + M + "|$)")) && y(a, function (a) {
+ return b.test("string" == typeof a.className && a.className || typeof a.getAttribute !== C && a.getAttribute("class") || "")
+ })
+ }, ATTR: function (a, b, c) {
+ return function (d) {
+ var e = fb.attr(d, a);
+ return null == e ? "!=" === b : b ? (e += "", "=" === b ? e === c : "!=" === b ? e !== c : "^=" === b ? c && 0 === e.indexOf(c) : "*=" === b ? c && e.indexOf(c) > -1 : "$=" === b ? c && e.slice(-c.length) === c : "~=" === b ? (" " + e + " ").indexOf(c) > -1 : "|=" === b ? e === c || e.slice(0, c.length + 1) === c + "-" : !1) : !0
+ }
+ }, CHILD: function (a, b, c, d, e) {
+ var f = "nth" !== a.slice(0, 3), g = "last" !== a.slice(-4), h = "of-type" === b;
+ return 1 === d && 0 === e ? function (a) {
+ return !!a.parentNode
+ } : function (b, c, i) {
+ var j, k, l, m, n, o, p = f !== g ? "nextSibling" : "previousSibling", q = b.parentNode, r = h && b.nodeName.toLowerCase(), s = !i && !h;
+ if (q) {
+ if (f) {
+ while (p) {
+ l = b;
+ while (l = l[p])if (h ? l.nodeName.toLowerCase() === r : 1 === l.nodeType)return !1;
+ o = p = "only" === a && !o && "nextSibling"
+ }
+ return !0
+ }
+ if (o = [g ? q.firstChild : q.lastChild], g && s) {
+ k = q[u] || (q[u] = {}), j = k[a] || [], n = j[0] === w && j[1], m = j[0] === w && j[2], l = n && q.childNodes[n];
+ while (l = ++n && l && l[p] || (m = n = 0) || o.pop())if (1 === l.nodeType && ++m && l === b) {
+ k[a] = [w, n, m];
+ break
+ }
+ } else if (s && (j = (b[u] || (b[u] = {}))[a]) && j[0] === w)m = j[1]; else while (l = ++n && l && l[p] || (m = n = 0) || o.pop())if ((h ? l.nodeName.toLowerCase() === r : 1 === l.nodeType) && ++m && (s && ((l[u] || (l[u] = {}))[a] = [w, m]), l === b))break;
+ return m -= e, m === d || m % d === 0 && m / d >= 0
+ }
+ }
+ }, PSEUDO: function (a, b) {
+ var c, e = d.pseudos[a] || d.setFilters[a.toLowerCase()] || fb.error("unsupported pseudo: " + a);
+ return e[u] ? e(b) : e.length > 1 ? (c = [a, a, "", b], d.setFilters.hasOwnProperty(a.toLowerCase()) ? hb(function (a, c) {
+ var d, f = e(a, b), g = f.length;
+ while (g--)d = K.call(a, f[g]), a[d] = !(c[d] = f[g])
+ }) : function (a) {
+ return e(a, 0, c)
+ }) : e
+ }
+ },
+ pseudos: {
+ not: hb(function (a) {
+ var b = [], c = [], d = h(a.replace(R, "$1"));
+ return d[u] ? hb(function (a, b, c, e) {
+ var f, g = d(a, null, e, []), h = a.length;
+ while (h--)(f = g[h]) && (a[h] = !(b[h] = f))
+ }) : function (a, e, f) {
+ return b[0] = a, d(b, null, f, c), !c.pop()
+ }
+ }), has: hb(function (a) {
+ return function (b) {
+ return fb(a, b).length > 0
+ }
+ }), contains: hb(function (a) {
+ return function (b) {
+ return (b.textContent || b.innerText || e(b)).indexOf(a) > -1
+ }
+ }), lang: hb(function (a) {
+ return W.test(a || "") || fb.error("unsupported lang: " + a), a = a.replace(cb, db).toLowerCase(), function (b) {
+ var c;
+ do if (c = p ? b.lang : b.getAttribute("xml:lang") || b.getAttribute("lang"))return c = c.toLowerCase(), c === a || 0 === c.indexOf(a + "-"); while ((b = b.parentNode) && 1 === b.nodeType);
+ return !1
+ }
+ }), target: function (b) {
+ var c = a.location && a.location.hash;
+ return c && c.slice(1) === b.id
+ }, root: function (a) {
+ return a === o
+ }, focus: function (a) {
+ return a === n.activeElement && (!n.hasFocus || n.hasFocus()) && !!(a.type || a.href || ~a.tabIndex)
+ }, enabled: function (a) {
+ return a.disabled === !1
+ }, disabled: function (a) {
+ return a.disabled === !0
+ }, checked: function (a) {
+ var b = a.nodeName.toLowerCase();
+ return "input" === b && !!a.checked || "option" === b && !!a.selected
+ }, selected: function (a) {
+ return a.parentNode && a.parentNode.selectedIndex, a.selected === !0
+ }, empty: function (a) {
+ for (a = a.firstChild; a; a = a.nextSibling)if (a.nodeType < 6)return !1;
+ return !0
+ }, parent: function (a) {
+ return !d.pseudos.empty(a)
+ }, header: function (a) {
+ return Z.test(a.nodeName)
+ }, input: function (a) {
+ return Y.test(a.nodeName)
+ }, button: function (a) {
+ var b = a.nodeName.toLowerCase();
+ return "input" === b && "button" === a.type || "button" === b
+ }, text: function (a) {
+ var b;
+ return "input" === a.nodeName.toLowerCase() && "text" === a.type && (null == (b = a.getAttribute("type")) || "text" === b.toLowerCase())
+ }, first: nb(function () {
+ return [0]
+ }), last: nb(function (a, b) {
+ return [b - 1]
+ }), eq: nb(function (a, b, c) {
+ return [0 > c ? c + b : c]
+ }), even: nb(function (a, b) {
+ for (var c = 0; b > c; c += 2)a.push(c);
+ return a
+ }), odd: nb(function (a, b) {
+ for (var c = 1; b > c; c += 2)a.push(c);
+ return a
+ }), lt: nb(function (a, b, c) {
+ for (var d = 0 > c ? c + b : c; --d >= 0;)a.push(d);
+ return a
+ }), gt: nb(function (a, b, c) {
+ for (var d = 0 > c ? c + b : c; ++d < b;)a.push(d);
+ return a
+ })
+ }
+ }, d.pseudos.nth = d.pseudos.eq;
+ for (b in{radio: !0, checkbox: !0, file: !0, password: !0, image: !0})d.pseudos[b] = lb(b);
+ for (b in{submit: !0, reset: !0})d.pseudos[b] = mb(b);
+ function pb() {
+ }
+
+ pb.prototype = d.filters = d.pseudos, d.setFilters = new pb, g = fb.tokenize = function (a, b) {
+ var c, e, f, g, h, i, j, k = z[a + " "];
+ if (k)return b ? 0 : k.slice(0);
+ h = a, i = [], j = d.preFilter;
+ while (h) {
+ (!c || (e = S.exec(h))) && (e && (h = h.slice(e[0].length) || h), i.push(f = [])), c = !1, (e = T.exec(h)) && (c = e.shift(), f.push({
+ value: c,
+ type: e[0].replace(R, " ")
+ }), h = h.slice(c.length));
+ for (g in d.filter)!(e = X[g].exec(h)) || j[g] && !(e = j[g](e)) || (c = e.shift(), f.push({
+ value: c,
+ type: g,
+ matches: e
+ }), h = h.slice(c.length));
+ if (!c)break
+ }
+ return b ? h.length : h ? fb.error(a) : z(a, i).slice(0)
+ };
+ function qb(a) {
+ for (var b = 0, c = a.length, d = ""; c > b; b++)d += a[b].value;
+ return d
+ }
+
+ function rb(a, b, c) {
+ var d = b.dir, e = c && "parentNode" === d, f = x++;
+ return b.first ? function (b, c, f) {
+ while (b = b[d])if (1 === b.nodeType || e)return a(b, c, f)
+ } : function (b, c, g) {
+ var h, i, j = [w, f];
+ if (g) {
+ while (b = b[d])if ((1 === b.nodeType || e) && a(b, c, g))return !0
+ } else while (b = b[d])if (1 === b.nodeType || e) {
+ if (i = b[u] || (b[u] = {}), (h = i[d]) && h[0] === w && h[1] === f)return j[2] = h[2];
+ if (i[d] = j, j[2] = a(b, c, g))return !0
+ }
+ }
+ }
+
+ function sb(a) {
+ return a.length > 1 ? function (b, c, d) {
+ var e = a.length;
+ while (e--)if (!a[e](b, c, d))return !1;
+ return !0
+ } : a[0]
+ }
+
+ function tb(a, b, c) {
+ for (var d = 0, e = b.length; e > d; d++)fb(a, b[d], c);
+ return c
+ }
+
+ function ub(a, b, c, d, e) {
+ for (var f, g = [], h = 0, i = a.length, j = null != b; i > h; h++)(f = a[h]) && (!c || c(f, d, e)) && (g.push(f), j && b.push(h));
+ return g
+ }
+
+ function vb(a, b, c, d, e, f) {
+ return d && !d[u] && (d = vb(d)), e && !e[u] && (e = vb(e, f)), hb(function (f, g, h, i) {
+ var j, k, l, m = [], n = [], o = g.length, p = f || tb(b || "*", h.nodeType ? [h] : h, []), q = !a || !f && b ? p : ub(p, m, a, h, i), r = c ? e || (f ? a : o || d) ? [] : g : q;
+ if (c && c(q, r, h, i), d) {
+ j = ub(r, n), d(j, [], h, i), k = j.length;
+ while (k--)(l = j[k]) && (r[n[k]] = !(q[n[k]] = l))
+ }
+ if (f) {
+ if (e || a) {
+ if (e) {
+ j = [], k = r.length;
+ while (k--)(l = r[k]) && j.push(q[k] = l);
+ e(null, r = [], j, i)
+ }
+ k = r.length;
+ while (k--)(l = r[k]) && (j = e ? K.call(f, l) : m[k]) > -1 && (f[j] = !(g[j] = l))
+ }
+ } else r = ub(r === g ? r.splice(o, r.length) : r), e ? e(null, g, r, i) : I.apply(g, r)
+ })
+ }
+
+ function wb(a) {
+ for (var b, c, e, f = a.length, g = d.relative[a[0].type], h = g || d.relative[" "], i = g ? 1 : 0, k = rb(function (a) {
+ return a === b
+ }, h, !0), l = rb(function (a) {
+ return K.call(b, a) > -1
+ }, h, !0), m = [function (a, c, d) {
+ return !g && (d || c !== j) || ((b = c).nodeType ? k(a, c, d) : l(a, c, d))
+ }]; f > i; i++)if (c = d.relative[a[i].type])m = [rb(sb(m), c)]; else {
+ if (c = d.filter[a[i].type].apply(null, a[i].matches), c[u]) {
+ for (e = ++i; f > e; e++)if (d.relative[a[e].type])break;
+ return vb(i > 1 && sb(m), i > 1 && qb(a.slice(0, i - 1).concat({value: " " === a[i - 2].type ? "*" : ""})).replace(R, "$1"), c, e > i && wb(a.slice(i, e)), f > e && wb(a = a.slice(e)), f > e && qb(a))
+ }
+ m.push(c)
+ }
+ return sb(m)
+ }
+
+ function xb(a, b) {
+ var c = b.length > 0, e = a.length > 0, f = function (f, g, h, i, k) {
+ var l, m, o, p = 0, q = "0", r = f && [], s = [], t = j, u = f || e && d.find.TAG("*", k), v = w += null == t ? 1 : Math.random() || .1, x = u.length;
+ for (k && (j = g !== n && g); q !== x && null != (l = u[q]); q++) {
+ if (e && l) {
+ m = 0;
+ while (o = a[m++])if (o(l, g, h)) {
+ i.push(l);
+ break
+ }
+ k && (w = v)
+ }
+ c && ((l = !o && l) && p--, f && r.push(l))
+ }
+ if (p += q, c && q !== p) {
+ m = 0;
+ while (o = b[m++])o(r, s, g, h);
+ if (f) {
+ if (p > 0)while (q--)r[q] || s[q] || (s[q] = G.call(i));
+ s = ub(s)
+ }
+ I.apply(i, s), k && !f && s.length > 0 && p + b.length > 1 && fb.uniqueSort(i)
+ }
+ return k && (w = v, j = t), r
+ };
+ return c ? hb(f) : f
+ }
+
+ return h = fb.compile = function (a, b) {
+ var c, d = [], e = [], f = A[a + " "];
+ if (!f) {
+ b || (b = g(a)), c = b.length;
+ while (c--)f = wb(b[c]), f[u] ? d.push(f) : e.push(f);
+ f = A(a, xb(e, d)), f.selector = a
+ }
+ return f
+ }, i = fb.select = function (a, b, e, f) {
+ var i, j, k, l, m, n = "function" == typeof a && a, o = !f && g(a = n.selector || a);
+ if (e = e || [], 1 === o.length) {
+ if (j = o[0] = o[0].slice(0), j.length > 2 && "ID" === (k = j[0]).type && c.getById && 9 === b.nodeType && p && d.relative[j[1].type]) {
+ if (b = (d.find.ID(k.matches[0].replace(cb, db), b) || [])[0], !b)return e;
+ n && (b = b.parentNode), a = a.slice(j.shift().value.length)
+ }
+ i = X.needsContext.test(a) ? 0 : j.length;
+ while (i--) {
+ if (k = j[i], d.relative[l = k.type])break;
+ if ((m = d.find[l]) && (f = m(k.matches[0].replace(cb, db), ab.test(j[0].type) && ob(b.parentNode) || b))) {
+ if (j.splice(i, 1), a = f.length && qb(j), !a)return I.apply(e, f), e;
+ break
+ }
+ }
+ }
+ return (n || h(a, o))(f, b, !p, e, ab.test(a) && ob(b.parentNode) || b), e
+ }, c.sortStable = u.split("").sort(B).join("") === u, c.detectDuplicates = !!l, m(), c.sortDetached = ib(function (a) {
+ return 1 & a.compareDocumentPosition(n.createElement("div"))
+ }), ib(function (a) {
+ return a.innerHTML = "
", "#" === a.firstChild.getAttribute("href")
+ }) || jb("type|href|height|width", function (a, b, c) {
+ return c ? void 0 : a.getAttribute(b, "type" === b.toLowerCase() ? 1 : 2)
+ }), c.attributes && ib(function (a) {
+ return a.innerHTML = "
", a.firstChild.setAttribute("value", ""), "" === a.firstChild.getAttribute("value")
+ }) || jb("value", function (a, b, c) {
+ return c || "input" !== a.nodeName.toLowerCase() ? void 0 : a.defaultValue
+ }), ib(function (a) {
+ return null == a.getAttribute("disabled")
+ }) || jb(L, function (a, b, c) {
+ var d;
+ return c ? void 0 : a[b] === !0 ? b.toLowerCase() : (d = a.getAttributeNode(b)) && d.specified ? d.value : null
+ }), fb
+ }(a);
+ m.find = s, m.expr = s.selectors, m.expr[":"] = m.expr.pseudos, m.unique = s.uniqueSort, m.text = s.getText, m.isXMLDoc = s.isXML, m.contains = s.contains;
+ var t = m.expr.match.needsContext, u = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, v = /^.[^:#\[\.,]*$/;
+
+ function w(a, b, c) {
+ if (m.isFunction(b))return m.grep(a, function (a, d) {
+ return !!b.call(a, d, a) !== c
+ });
+ if (b.nodeType)return m.grep(a, function (a) {
+ return a === b !== c
+ });
+ if ("string" == typeof b) {
+ if (v.test(b))return m.filter(b, a, c);
+ b = m.filter(b, a)
+ }
+ return m.grep(a, function (a) {
+ return m.inArray(a, b) >= 0 !== c
+ })
+ }
+
+ m.filter = function (a, b, c) {
+ var d = b[0];
+ return c && (a = ":not(" + a + ")"), 1 === b.length && 1 === d.nodeType ? m.find.matchesSelector(d, a) ? [d] : [] : m.find.matches(a, m.grep(b, function (a) {
+ return 1 === a.nodeType
+ }))
+ }, m.fn.extend({
+ find: function (a) {
+ var b, c = [], d = this, e = d.length;
+ if ("string" != typeof a)return this.pushStack(m(a).filter(function () {
+ for (b = 0; e > b; b++)if (m.contains(d[b], this))return !0
+ }));
+ for (b = 0; e > b; b++)m.find(a, d[b], c);
+ return c = this.pushStack(e > 1 ? m.unique(c) : c), c.selector = this.selector ? this.selector + " " + a : a, c
+ }, filter: function (a) {
+ return this.pushStack(w(this, a || [], !1))
+ }, not: function (a) {
+ return this.pushStack(w(this, a || [], !0))
+ }, is: function (a) {
+ return !!w(this, "string" == typeof a && t.test(a) ? m(a) : a || [], !1).length
+ }
+ });
+ var x, y = a.document, z = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, A = m.fn.init = function (a, b) {
+ var c, d;
+ if (!a)return this;
+ if ("string" == typeof a) {
+ if (c = "<" === a.charAt(0) && ">" === a.charAt(a.length - 1) && a.length >= 3 ? [null, a, null] : z.exec(a), !c || !c[1] && b)return !b || b.jquery ? (b || x).find(a) : this.constructor(b).find(a);
+ if (c[1]) {
+ if (b = b instanceof m ? b[0] : b, m.merge(this, m.parseHTML(c[1], b && b.nodeType ? b.ownerDocument || b : y, !0)), u.test(c[1]) && m.isPlainObject(b))for (c in b)m.isFunction(this[c]) ? this[c](b[c]) : this.attr(c, b[c]);
+ return this
+ }
+ if (d = y.getElementById(c[2]), d && d.parentNode) {
+ if (d.id !== c[2])return x.find(a);
+ this.length = 1, this[0] = d
+ }
+ return this.context = y, this.selector = a, this
+ }
+ return a.nodeType ? (this.context = this[0] = a, this.length = 1, this) : m.isFunction(a) ? "undefined" != typeof x.ready ? x.ready(a) : a(m) : (void 0 !== a.selector && (this.selector = a.selector, this.context = a.context), m.makeArray(a, this))
+ };
+ A.prototype = m.fn, x = m(y);
+ var B = /^(?:parents|prev(?:Until|All))/, C = {children: !0, contents: !0, next: !0, prev: !0};
+ m.extend({
+ dir: function (a, b, c) {
+ var d = [], e = a[b];
+ while (e && 9 !== e.nodeType && (void 0 === c || 1 !== e.nodeType || !m(e).is(c)))1 === e.nodeType && d.push(e), e = e[b];
+ return d
+ }, sibling: function (a, b) {
+ for (var c = []; a; a = a.nextSibling)1 === a.nodeType && a !== b && c.push(a);
+ return c
+ }
+ }), m.fn.extend({
+ has: function (a) {
+ var b, c = m(a, this), d = c.length;
+ return this.filter(function () {
+ for (b = 0; d > b; b++)if (m.contains(this, c[b]))return !0
+ })
+ }, closest: function (a, b) {
+ for (var c, d = 0, e = this.length, f = [], g = t.test(a) || "string" != typeof a ? m(a, b || this.context) : 0; e > d; d++)for (c = this[d]; c && c !== b; c = c.parentNode)if (c.nodeType < 11 && (g ? g.index(c) > -1 : 1 === c.nodeType && m.find.matchesSelector(c, a))) {
+ f.push(c);
+ break
+ }
+ return this.pushStack(f.length > 1 ? m.unique(f) : f)
+ }, index: function (a) {
+ return a ? "string" == typeof a ? m.inArray(this[0], m(a)) : m.inArray(a.jquery ? a[0] : a, this) : this[0] && this[0].parentNode ? this.first().prevAll().length : -1
+ }, add: function (a, b) {
+ return this.pushStack(m.unique(m.merge(this.get(), m(a, b))))
+ }, addBack: function (a) {
+ return this.add(null == a ? this.prevObject : this.prevObject.filter(a))
+ }
+ });
+ function D(a, b) {
+ do a = a[b]; while (a && 1 !== a.nodeType);
+ return a
+ }
+
+ m.each({
+ parent: function (a) {
+ var b = a.parentNode;
+ return b && 11 !== b.nodeType ? b : null
+ }, parents: function (a) {
+ return m.dir(a, "parentNode")
+ }, parentsUntil: function (a, b, c) {
+ return m.dir(a, "parentNode", c)
+ }, next: function (a) {
+ return D(a, "nextSibling")
+ }, prev: function (a) {
+ return D(a, "previousSibling")
+ }, nextAll: function (a) {
+ return m.dir(a, "nextSibling")
+ }, prevAll: function (a) {
+ return m.dir(a, "previousSibling")
+ }, nextUntil: function (a, b, c) {
+ return m.dir(a, "nextSibling", c)
+ }, prevUntil: function (a, b, c) {
+ return m.dir(a, "previousSibling", c)
+ }, siblings: function (a) {
+ return m.sibling((a.parentNode || {}).firstChild, a)
+ }, children: function (a) {
+ return m.sibling(a.firstChild)
+ }, contents: function (a) {
+ return m.nodeName(a, "iframe") ? a.contentDocument || a.contentWindow.document : m.merge([], a.childNodes)
+ }
+ }, function (a, b) {
+ m.fn[a] = function (c, d) {
+ var e = m.map(this, b, c);
+ return "Until" !== a.slice(-5) && (d = c), d && "string" == typeof d && (e = m.filter(d, e)), this.length > 1 && (C[a] || (e = m.unique(e)), B.test(a) && (e = e.reverse())), this.pushStack(e)
+ }
+ });
+ var E = /\S+/g, F = {};
+
+ function G(a) {
+ var b = F[a] = {};
+ return m.each(a.match(E) || [], function (a, c) {
+ b[c] = !0
+ }), b
+ }
+
+ m.Callbacks = function (a) {
+ a = "string" == typeof a ? F[a] || G(a) : m.extend({}, a);
+ var b, c, d, e, f, g, h = [], i = !a.once && [], j = function (l) {
+ for (c = a.memory && l, d = !0, f = g || 0, g = 0, e = h.length, b = !0; h && e > f; f++)if (h[f].apply(l[0], l[1]) === !1 && a.stopOnFalse) {
+ c = !1;
+ break
+ }
+ b = !1, h && (i ? i.length && j(i.shift()) : c ? h = [] : k.disable())
+ }, k = {
+ add: function () {
+ if (h) {
+ var d = h.length;
+ !function f(b) {
+ m.each(b, function (b, c) {
+ var d = m.type(c);
+ "function" === d ? a.unique && k.has(c) || h.push(c) : c && c.length && "string" !== d && f(c)
+ })
+ }(arguments), b ? e = h.length : c && (g = d, j(c))
+ }
+ return this
+ }, remove: function () {
+ return h && m.each(arguments, function (a, c) {
+ var d;
+ while ((d = m.inArray(c, h, d)) > -1)h.splice(d, 1), b && (e >= d && e--, f >= d && f--)
+ }), this
+ }, has: function (a) {
+ return a ? m.inArray(a, h) > -1 : !(!h || !h.length)
+ }, empty: function () {
+ return h = [], e = 0, this
+ }, disable: function () {
+ return h = i = c = void 0, this
+ }, disabled: function () {
+ return !h
+ }, lock: function () {
+ return i = void 0, c || k.disable(), this
+ }, locked: function () {
+ return !i
+ }, fireWith: function (a, c) {
+ return !h || d && !i || (c = c || [], c = [a, c.slice ? c.slice() : c], b ? i.push(c) : j(c)), this
+ }, fire: function () {
+ return k.fireWith(this, arguments), this
+ }, fired: function () {
+ return !!d
+ }
+ };
+ return k
+ }, m.extend({
+ Deferred: function (a) {
+ var b = [["resolve", "done", m.Callbacks("once memory"), "resolved"], ["reject", "fail", m.Callbacks("once memory"), "rejected"], ["notify", "progress", m.Callbacks("memory")]], c = "pending", d = {
+ state: function () {
+ return c
+ }, always: function () {
+ return e.done(arguments).fail(arguments), this
+ }, then: function () {
+ var a = arguments;
+ return m.Deferred(function (c) {
+ m.each(b, function (b, f) {
+ var g = m.isFunction(a[b]) && a[b];
+ e[f[1]](function () {
+ var a = g && g.apply(this, arguments);
+ a && m.isFunction(a.promise) ? a.promise().done(c.resolve).fail(c.reject).progress(c.notify) : c[f[0] + "With"](this === d ? c.promise() : this, g ? [a] : arguments)
+ })
+ }), a = null
+ }).promise()
+ }, promise: function (a) {
+ return null != a ? m.extend(a, d) : d
+ }
+ }, e = {};
+ return d.pipe = d.then, m.each(b, function (a, f) {
+ var g = f[2], h = f[3];
+ d[f[1]] = g.add, h && g.add(function () {
+ c = h
+ }, b[1 ^ a][2].disable, b[2][2].lock), e[f[0]] = function () {
+ return e[f[0] + "With"](this === e ? d : this, arguments), this
+ }, e[f[0] + "With"] = g.fireWith
+ }), d.promise(e), a && a.call(e, e), e
+ }, when: function (a) {
+ var b = 0, c = d.call(arguments), e = c.length, f = 1 !== e || a && m.isFunction(a.promise) ? e : 0, g = 1 === f ? a : m.Deferred(), h = function (a, b, c) {
+ return function (e) {
+ b[a] = this, c[a] = arguments.length > 1 ? d.call(arguments) : e, c === i ? g.notifyWith(b, c) : --f || g.resolveWith(b, c)
+ }
+ }, i, j, k;
+ if (e > 1)for (i = new Array(e), j = new Array(e), k = new Array(e); e > b; b++)c[b] && m.isFunction(c[b].promise) ? c[b].promise().done(h(b, k, c)).fail(g.reject).progress(h(b, j, i)) : --f;
+ return f || g.resolveWith(k, c), g.promise()
+ }
+ });
+ var H;
+ m.fn.ready = function (a) {
+ return m.ready.promise().done(a), this
+ }, m.extend({
+ isReady: !1, readyWait: 1, holdReady: function (a) {
+ a ? m.readyWait++ : m.ready(!0)
+ }, ready: function (a) {
+ if (a === !0 ? !--m.readyWait : !m.isReady) {
+ if (!y.body)return setTimeout(m.ready);
+ m.isReady = !0, a !== !0 && --m.readyWait > 0 || (H.resolveWith(y, [m]), m.fn.triggerHandler && (m(y).triggerHandler("ready"), m(y).off("ready")))
+ }
+ }
+ });
+ function I() {
+ y.addEventListener ? (y.removeEventListener("DOMContentLoaded", J, !1), a.removeEventListener("load", J, !1)) : (y.detachEvent("onreadystatechange", J), a.detachEvent("onload", J))
+ }
+
+ function J() {
+ (y.addEventListener || "load" === event.type || "complete" === y.readyState) && (I(), m.ready())
+ }
+
+ m.ready.promise = function (b) {
+ if (!H)if (H = m.Deferred(), "complete" === y.readyState)setTimeout(m.ready); else if (y.addEventListener)y.addEventListener("DOMContentLoaded", J, !1), a.addEventListener("load", J, !1); else {
+ y.attachEvent("onreadystatechange", J), a.attachEvent("onload", J);
+ var c = !1;
+ try {
+ c = null == a.frameElement && y.documentElement
+ } catch (d) {
+ }
+ c && c.doScroll && !function e() {
+ if (!m.isReady) {
+ try {
+ c.doScroll("left")
+ } catch (a) {
+ return setTimeout(e, 50)
+ }
+ I(), m.ready()
+ }
+ }()
+ }
+ return H.promise(b)
+ };
+ var K = "undefined", L;
+ for (L in m(k))break;
+ k.ownLast = "0" !== L, k.inlineBlockNeedsLayout = !1, m(function () {
+ var a, b, c, d;
+ c = y.getElementsByTagName("body")[0], c && c.style && (b = y.createElement("div"), d = y.createElement("div"), d.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px", c.appendChild(d).appendChild(b), typeof b.style.zoom !== K && (b.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1", k.inlineBlockNeedsLayout = a = 3 === b.offsetWidth, a && (c.style.zoom = 1)), c.removeChild(d))
+ }), function () {
+ var a = y.createElement("div");
+ if (null == k.deleteExpando) {
+ k.deleteExpando = !0;
+ try {
+ delete a.test
+ } catch (b) {
+ k.deleteExpando = !1
+ }
+ }
+ a = null
+ }(), m.acceptData = function (a) {
+ var b = m.noData[(a.nodeName + " ").toLowerCase()], c = +a.nodeType || 1;
+ return 1 !== c && 9 !== c ? !1 : !b || b !== !0 && a.getAttribute("classid") === b
+ };
+ var M = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, N = /([A-Z])/g;
+
+ function O(a, b, c) {
+ if (void 0 === c && 1 === a.nodeType) {
+ var d = "data-" + b.replace(N, "-$1").toLowerCase();
+ if (c = a.getAttribute(d), "string" == typeof c) {
+ try {
+ c = "true" === c ? !0 : "false" === c ? !1 : "null" === c ? null : +c + "" === c ? +c : M.test(c) ? m.parseJSON(c) : c
+ } catch (e) {
+ }
+ m.data(a, b, c)
+ } else c = void 0
+ }
+ return c
+ }
+
+ function P(a) {
+ var b;
+ for (b in a)if (("data" !== b || !m.isEmptyObject(a[b])) && "toJSON" !== b)return !1;
+ return !0
+ }
+
+ function Q(a, b, d, e) {
+ if (m.acceptData(a)) {
+ var f, g, h = m.expando, i = a.nodeType, j = i ? m.cache : a, k = i ? a[h] : a[h] && h;
+ if (k && j[k] && (e || j[k].data) || void 0 !== d || "string" != typeof b)return k || (k = i ? a[h] = c.pop() || m.guid++ : h), j[k] || (j[k] = i ? {} : {toJSON: m.noop}), ("object" == typeof b || "function" == typeof b) && (e ? j[k] = m.extend(j[k], b) : j[k].data = m.extend(j[k].data, b)), g = j[k], e || (g.data || (g.data = {}), g = g.data), void 0 !== d && (g[m.camelCase(b)] = d), "string" == typeof b ? (f = g[b], null == f && (f = g[m.camelCase(b)])) : f = g, f
+ }
+ }
+
+ function R(a, b, c) {
+ if (m.acceptData(a)) {
+ var d, e, f = a.nodeType, g = f ? m.cache : a, h = f ? a[m.expando] : m.expando;
+ if (g[h]) {
+ if (b && (d = c ? g[h] : g[h].data)) {
+ m.isArray(b) ? b = b.concat(m.map(b, m.camelCase)) : b in d ? b = [b] : (b = m.camelCase(b), b = b in d ? [b] : b.split(" ")), e = b.length;
+ while (e--)delete d[b[e]];
+ if (c ? !P(d) : !m.isEmptyObject(d))return
+ }
+ (c || (delete g[h].data, P(g[h]))) && (f ? m.cleanData([a], !0) : k.deleteExpando || g != g.window ? delete g[h] : g[h] = null)
+ }
+ }
+ }
+
+ m.extend({
+ cache: {},
+ noData: {"applet ": !0, "embed ": !0, "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},
+ hasData: function (a) {
+ return a = a.nodeType ? m.cache[a[m.expando]] : a[m.expando], !!a && !P(a)
+ },
+ data: function (a, b, c) {
+ return Q(a, b, c)
+ },
+ removeData: function (a, b) {
+ return R(a, b)
+ },
+ _data: function (a, b, c) {
+ return Q(a, b, c, !0)
+ },
+ _removeData: function (a, b) {
+ return R(a, b, !0)
+ }
+ }), m.fn.extend({
+ data: function (a, b) {
+ var c, d, e, f = this[0], g = f && f.attributes;
+ if (void 0 === a) {
+ if (this.length && (e = m.data(f), 1 === f.nodeType && !m._data(f, "parsedAttrs"))) {
+ c = g.length;
+ while (c--)g[c] && (d = g[c].name, 0 === d.indexOf("data-") && (d = m.camelCase(d.slice(5)), O(f, d, e[d])));
+ m._data(f, "parsedAttrs", !0)
+ }
+ return e
+ }
+ return "object" == typeof a ? this.each(function () {
+ m.data(this, a)
+ }) : arguments.length > 1 ? this.each(function () {
+ m.data(this, a, b)
+ }) : f ? O(f, a, m.data(f, a)) : void 0
+ }, removeData: function (a) {
+ return this.each(function () {
+ m.removeData(this, a)
+ })
+ }
+ }), m.extend({
+ queue: function (a, b, c) {
+ var d;
+ return a ? (b = (b || "fx") + "queue", d = m._data(a, b), c && (!d || m.isArray(c) ? d = m._data(a, b, m.makeArray(c)) : d.push(c)), d || []) : void 0
+ }, dequeue: function (a, b) {
+ b = b || "fx";
+ var c = m.queue(a, b), d = c.length, e = c.shift(), f = m._queueHooks(a, b), g = function () {
+ m.dequeue(a, b)
+ };
+ "inprogress" === e && (e = c.shift(), d--), e && ("fx" === b && c.unshift("inprogress"), delete f.stop, e.call(a, g, f)), !d && f && f.empty.fire()
+ }, _queueHooks: function (a, b) {
+ var c = b + "queueHooks";
+ return m._data(a, c) || m._data(a, c, {
+ empty: m.Callbacks("once memory").add(function () {
+ m._removeData(a, b + "queue"), m._removeData(a, c)
+ })
+ })
+ }
+ }), m.fn.extend({
+ queue: function (a, b) {
+ var c = 2;
+ return "string" != typeof a && (b = a, a = "fx", c--), arguments.length < c ? m.queue(this[0], a) : void 0 === b ? this : this.each(function () {
+ var c = m.queue(this, a, b);
+ m._queueHooks(this, a), "fx" === a && "inprogress" !== c[0] && m.dequeue(this, a)
+ })
+ }, dequeue: function (a) {
+ return this.each(function () {
+ m.dequeue(this, a)
+ })
+ }, clearQueue: function (a) {
+ return this.queue(a || "fx", [])
+ }, promise: function (a, b) {
+ var c, d = 1, e = m.Deferred(), f = this, g = this.length, h = function () {
+ --d || e.resolveWith(f, [f])
+ };
+ "string" != typeof a && (b = a, a = void 0), a = a || "fx";
+ while (g--)c = m._data(f[g], a + "queueHooks"), c && c.empty && (d++, c.empty.add(h));
+ return h(), e.promise(b)
+ }
+ });
+ var S = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, T = ["Top", "Right", "Bottom", "Left"], U = function (a, b) {
+ return a = b || a, "none" === m.css(a, "display") || !m.contains(a.ownerDocument, a)
+ }, V = m.access = function (a, b, c, d, e, f, g) {
+ var h = 0, i = a.length, j = null == c;
+ if ("object" === m.type(c)) {
+ e = !0;
+ for (h in c)m.access(a, b, h, c[h], !0, f, g)
+ } else if (void 0 !== d && (e = !0, m.isFunction(d) || (g = !0), j && (g ? (b.call(a, d), b = null) : (j = b, b = function (a, b, c) {
+ return j.call(m(a), c)
+ })), b))for (; i > h; h++)b(a[h], c, g ? d : d.call(a[h], h, b(a[h], c)));
+ return e ? a : j ? b.call(a) : i ? b(a[0], c) : f
+ }, W = /^(?:checkbox|radio)$/i;
+ !function () {
+ var a = y.createElement("input"), b = y.createElement("div"), c = y.createDocumentFragment();
+ if (b.innerHTML = "
a ", k.leadingWhitespace = 3 === b.firstChild.nodeType, k.tbody = !b.getElementsByTagName("tbody").length, k.htmlSerialize = !!b.getElementsByTagName("link").length, k.html5Clone = "<:nav>" !== y.createElement("nav").cloneNode(!0).outerHTML, a.type = "checkbox", a.checked = !0, c.appendChild(a), k.appendChecked = a.checked, b.innerHTML = "
", k.noCloneChecked = !!b.cloneNode(!0).lastChild.defaultValue, c.appendChild(b), b.innerHTML = "
", k.checkClone = b.cloneNode(!0).cloneNode(!0).lastChild.checked, k.noCloneEvent = !0, b.attachEvent && (b.attachEvent("onclick", function () {
+ k.noCloneEvent = !1
+ }), b.cloneNode(!0).click()), null == k.deleteExpando) {
+ k.deleteExpando = !0;
+ try {
+ delete b.test
+ } catch (d) {
+ k.deleteExpando = !1
+ }
+ }
+ }(), function () {
+ var b, c, d = y.createElement("div");
+ for (b in{
+ submit: !0,
+ change: !0,
+ focusin: !0
+ })c = "on" + b, (k[b + "Bubbles"] = c in a) || (d.setAttribute(c, "t"), k[b + "Bubbles"] = d.attributes[c].expando === !1);
+ d = null
+ }();
+ var X = /^(?:input|select|textarea)$/i, Y = /^key/, Z = /^(?:mouse|pointer|contextmenu)|click/, $ = /^(?:focusinfocus|focusoutblur)$/, _ = /^([^.]*)(?:\.(.+)|)$/;
+
+ function ab() {
+ return !0
+ }
+
+ function bb() {
+ return !1
+ }
+
+ function cb() {
+ try {
+ return y.activeElement
+ } catch (a) {
+ }
+ }
+
+ m.event = {
+ global: {},
+ add: function (a, b, c, d, e) {
+ var f, g, h, i, j, k, l, n, o, p, q, r = m._data(a);
+ if (r) {
+ c.handler && (i = c, c = i.handler, e = i.selector), c.guid || (c.guid = m.guid++), (g = r.events) || (g = r.events = {}), (k = r.handle) || (k = r.handle = function (a) {
+ return typeof m === K || a && m.event.triggered === a.type ? void 0 : m.event.dispatch.apply(k.elem, arguments)
+ }, k.elem = a), b = (b || "").match(E) || [""], h = b.length;
+ while (h--)f = _.exec(b[h]) || [], o = q = f[1], p = (f[2] || "").split(".").sort(), o && (j = m.event.special[o] || {}, o = (e ? j.delegateType : j.bindType) || o, j = m.event.special[o] || {}, l = m.extend({
+ type: o,
+ origType: q,
+ data: d,
+ handler: c,
+ guid: c.guid,
+ selector: e,
+ needsContext: e && m.expr.match.needsContext.test(e),
+ namespace: p.join(".")
+ }, i), (n = g[o]) || (n = g[o] = [], n.delegateCount = 0, j.setup && j.setup.call(a, d, p, k) !== !1 || (a.addEventListener ? a.addEventListener(o, k, !1) : a.attachEvent && a.attachEvent("on" + o, k))), j.add && (j.add.call(a, l), l.handler.guid || (l.handler.guid = c.guid)), e ? n.splice(n.delegateCount++, 0, l) : n.push(l), m.event.global[o] = !0);
+ a = null
+ }
+ },
+ remove: function (a, b, c, d, e) {
+ var f, g, h, i, j, k, l, n, o, p, q, r = m.hasData(a) && m._data(a);
+ if (r && (k = r.events)) {
+ b = (b || "").match(E) || [""], j = b.length;
+ while (j--)if (h = _.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o) {
+ l = m.event.special[o] || {}, o = (d ? l.delegateType : l.bindType) || o, n = k[o] || [], h = h[2] && new RegExp("(^|\\.)" + p.join("\\.(?:.*\\.|)") + "(\\.|$)"), i = f = n.length;
+ while (f--)g = n[f], !e && q !== g.origType || c && c.guid !== g.guid || h && !h.test(g.namespace) || d && d !== g.selector && ("**" !== d || !g.selector) || (n.splice(f, 1), g.selector && n.delegateCount--, l.remove && l.remove.call(a, g));
+ i && !n.length && (l.teardown && l.teardown.call(a, p, r.handle) !== !1 || m.removeEvent(a, o, r.handle), delete k[o])
+ } else for (o in k)m.event.remove(a, o + b[j], c, d, !0);
+ m.isEmptyObject(k) && (delete r.handle, m._removeData(a, "events"))
+ }
+ },
+ trigger: function (b, c, d, e) {
+ var f, g, h, i, k, l, n, o = [d || y], p = j.call(b, "type") ? b.type : b, q = j.call(b, "namespace") ? b.namespace.split(".") : [];
+ if (h = l = d = d || y, 3 !== d.nodeType && 8 !== d.nodeType && !$.test(p + m.event.triggered) && (p.indexOf(".") >= 0 && (q = p.split("."), p = q.shift(), q.sort()), g = p.indexOf(":") < 0 && "on" + p, b = b[m.expando] ? b : new m.Event(p, "object" == typeof b && b), b.isTrigger = e ? 2 : 3, b.namespace = q.join("."), b.namespace_re = b.namespace ? new RegExp("(^|\\.)" + q.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, b.result = void 0, b.target || (b.target = d), c = null == c ? [b] : m.makeArray(c, [b]), k = m.event.special[p] || {}, e || !k.trigger || k.trigger.apply(d, c) !== !1)) {
+ if (!e && !k.noBubble && !m.isWindow(d)) {
+ for (i = k.delegateType || p, $.test(i + p) || (h = h.parentNode); h; h = h.parentNode)o.push(h), l = h;
+ l === (d.ownerDocument || y) && o.push(l.defaultView || l.parentWindow || a)
+ }
+ n = 0;
+ while ((h = o[n++]) && !b.isPropagationStopped())b.type = n > 1 ? i : k.bindType || p, f = (m._data(h, "events") || {})[b.type] && m._data(h, "handle"), f && f.apply(h, c), f = g && h[g], f && f.apply && m.acceptData(h) && (b.result = f.apply(h, c), b.result === !1 && b.preventDefault());
+ if (b.type = p, !e && !b.isDefaultPrevented() && (!k._default || k._default.apply(o.pop(), c) === !1) && m.acceptData(d) && g && d[p] && !m.isWindow(d)) {
+ l = d[g], l && (d[g] = null), m.event.triggered = p;
+ try {
+ d[p]()
+ } catch (r) {
+ }
+ m.event.triggered = void 0, l && (d[g] = l)
+ }
+ return b.result
+ }
+ },
+ dispatch: function (a) {
+ a = m.event.fix(a);
+ var b, c, e, f, g, h = [], i = d.call(arguments), j = (m._data(this, "events") || {})[a.type] || [], k = m.event.special[a.type] || {};
+ if (i[0] = a, a.delegateTarget = this, !k.preDispatch || k.preDispatch.call(this, a) !== !1) {
+ h = m.event.handlers.call(this, a, j), b = 0;
+ while ((f = h[b++]) && !a.isPropagationStopped()) {
+ a.currentTarget = f.elem, g = 0;
+ while ((e = f.handlers[g++]) && !a.isImmediatePropagationStopped())(!a.namespace_re || a.namespace_re.test(e.namespace)) && (a.handleObj = e, a.data = e.data, c = ((m.event.special[e.origType] || {}).handle || e.handler).apply(f.elem, i), void 0 !== c && (a.result = c) === !1 && (a.preventDefault(), a.stopPropagation()))
+ }
+ return k.postDispatch && k.postDispatch.call(this, a), a.result
+ }
+ },
+ handlers: function (a, b) {
+ var c, d, e, f, g = [], h = b.delegateCount, i = a.target;
+ if (h && i.nodeType && (!a.button || "click" !== a.type))for (; i != this; i = i.parentNode || this)if (1 === i.nodeType && (i.disabled !== !0 || "click" !== a.type)) {
+ for (e = [], f = 0; h > f; f++)d = b[f], c = d.selector + " ", void 0 === e[c] && (e[c] = d.needsContext ? m(c, this).index(i) >= 0 : m.find(c, this, null, [i]).length), e[c] && e.push(d);
+ e.length && g.push({elem: i, handlers: e})
+ }
+ return h < b.length && g.push({elem: this, handlers: b.slice(h)}), g
+ },
+ fix: function (a) {
+ if (a[m.expando])return a;
+ var b, c, d, e = a.type, f = a, g = this.fixHooks[e];
+ g || (this.fixHooks[e] = g = Z.test(e) ? this.mouseHooks : Y.test(e) ? this.keyHooks : {}), d = g.props ? this.props.concat(g.props) : this.props, a = new m.Event(f), b = d.length;
+ while (b--)c = d[b], a[c] = f[c];
+ return a.target || (a.target = f.srcElement || y), 3 === a.target.nodeType && (a.target = a.target.parentNode), a.metaKey = !!a.metaKey, g.filter ? g.filter(a, f) : a
+ },
+ props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+ fixHooks: {},
+ keyHooks: {
+ props: "char charCode key keyCode".split(" "), filter: function (a, b) {
+ return null == a.which && (a.which = null != b.charCode ? b.charCode : b.keyCode), a
+ }
+ },
+ mouseHooks: {
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+ filter: function (a, b) {
+ var c, d, e, f = b.button, g = b.fromElement;
+ return null == a.pageX && null != b.clientX && (d = a.target.ownerDocument || y, e = d.documentElement, c = d.body, a.pageX = b.clientX + (e && e.scrollLeft || c && c.scrollLeft || 0) - (e && e.clientLeft || c && c.clientLeft || 0), a.pageY = b.clientY + (e && e.scrollTop || c && c.scrollTop || 0) - (e && e.clientTop || c && c.clientTop || 0)), !a.relatedTarget && g && (a.relatedTarget = g === a.target ? b.toElement : g), a.which || void 0 === f || (a.which = 1 & f ? 1 : 2 & f ? 3 : 4 & f ? 2 : 0), a
+ }
+ },
+ special: {
+ load: {noBubble: !0}, focus: {
+ trigger: function () {
+ if (this !== cb() && this.focus)try {
+ return this.focus(), !1
+ } catch (a) {
+ }
+ }, delegateType: "focusin"
+ }, blur: {
+ trigger: function () {
+ return this === cb() && this.blur ? (this.blur(), !1) : void 0
+ }, delegateType: "focusout"
+ }, click: {
+ trigger: function () {
+ return m.nodeName(this, "input") && "checkbox" === this.type && this.click ? (this.click(), !1) : void 0
+ }, _default: function (a) {
+ return m.nodeName(a.target, "a")
+ }
+ }, beforeunload: {
+ postDispatch: function (a) {
+ void 0 !== a.result && a.originalEvent && (a.originalEvent.returnValue = a.result)
+ }
+ }
+ },
+ simulate: function (a, b, c, d) {
+ var e = m.extend(new m.Event, c, {type: a, isSimulated: !0, originalEvent: {}});
+ d ? m.event.trigger(e, null, b) : m.event.dispatch.call(b, e), e.isDefaultPrevented() && c.preventDefault()
+ }
+ }, m.removeEvent = y.removeEventListener ? function (a, b, c) {
+ a.removeEventListener && a.removeEventListener(b, c, !1)
+ } : function (a, b, c) {
+ var d = "on" + b;
+ a.detachEvent && (typeof a[d] === K && (a[d] = null), a.detachEvent(d, c))
+ }, m.Event = function (a, b) {
+ return this instanceof m.Event ? (a && a.type ? (this.originalEvent = a, this.type = a.type, this.isDefaultPrevented = a.defaultPrevented || void 0 === a.defaultPrevented && a.returnValue === !1 ? ab : bb) : this.type = a, b && m.extend(this, b), this.timeStamp = a && a.timeStamp || m.now(), void(this[m.expando] = !0)) : new m.Event(a, b)
+ }, m.Event.prototype = {
+ isDefaultPrevented: bb,
+ isPropagationStopped: bb,
+ isImmediatePropagationStopped: bb,
+ preventDefault: function () {
+ var a = this.originalEvent;
+ this.isDefaultPrevented = ab, a && (a.preventDefault ? a.preventDefault() : a.returnValue = !1)
+ },
+ stopPropagation: function () {
+ var a = this.originalEvent;
+ this.isPropagationStopped = ab, a && (a.stopPropagation && a.stopPropagation(), a.cancelBubble = !0)
+ },
+ stopImmediatePropagation: function () {
+ var a = this.originalEvent;
+ this.isImmediatePropagationStopped = ab, a && a.stopImmediatePropagation && a.stopImmediatePropagation(), this.stopPropagation()
+ }
+ }, m.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout",
+ pointerenter: "pointerover",
+ pointerleave: "pointerout"
+ }, function (a, b) {
+ m.event.special[a] = {
+ delegateType: b, bindType: b, handle: function (a) {
+ var c, d = this, e = a.relatedTarget, f = a.handleObj;
+ return (!e || e !== d && !m.contains(d, e)) && (a.type = f.origType, c = f.handler.apply(this, arguments), a.type = b), c
+ }
+ }
+ }), k.submitBubbles || (m.event.special.submit = {
+ setup: function () {
+ return m.nodeName(this, "form") ? !1 : void m.event.add(this, "click._submit keypress._submit", function (a) {
+ var b = a.target, c = m.nodeName(b, "input") || m.nodeName(b, "button") ? b.form : void 0;
+ c && !m._data(c, "submitBubbles") && (m.event.add(c, "submit._submit", function (a) {
+ a._submit_bubble = !0
+ }), m._data(c, "submitBubbles", !0))
+ })
+ }, postDispatch: function (a) {
+ a._submit_bubble && (delete a._submit_bubble, this.parentNode && !a.isTrigger && m.event.simulate("submit", this.parentNode, a, !0))
+ }, teardown: function () {
+ return m.nodeName(this, "form") ? !1 : void m.event.remove(this, "._submit")
+ }
+ }), k.changeBubbles || (m.event.special.change = {
+ setup: function () {
+ return X.test(this.nodeName) ? (("checkbox" === this.type || "radio" === this.type) && (m.event.add(this, "propertychange._change", function (a) {
+ "checked" === a.originalEvent.propertyName && (this._just_changed = !0)
+ }), m.event.add(this, "click._change", function (a) {
+ this._just_changed && !a.isTrigger && (this._just_changed = !1), m.event.simulate("change", this, a, !0)
+ })), !1) : void m.event.add(this, "beforeactivate._change", function (a) {
+ var b = a.target;
+ X.test(b.nodeName) && !m._data(b, "changeBubbles") && (m.event.add(b, "change._change", function (a) {
+ !this.parentNode || a.isSimulated || a.isTrigger || m.event.simulate("change", this.parentNode, a, !0)
+ }), m._data(b, "changeBubbles", !0))
+ })
+ }, handle: function (a) {
+ var b = a.target;
+ return this !== b || a.isSimulated || a.isTrigger || "radio" !== b.type && "checkbox" !== b.type ? a.handleObj.handler.apply(this, arguments) : void 0
+ }, teardown: function () {
+ return m.event.remove(this, "._change"), !X.test(this.nodeName)
+ }
+ }), k.focusinBubbles || m.each({focus: "focusin", blur: "focusout"}, function (a, b) {
+ var c = function (a) {
+ m.event.simulate(b, a.target, m.event.fix(a), !0)
+ };
+ m.event.special[b] = {
+ setup: function () {
+ var d = this.ownerDocument || this, e = m._data(d, b);
+ e || d.addEventListener(a, c, !0), m._data(d, b, (e || 0) + 1)
+ }, teardown: function () {
+ var d = this.ownerDocument || this, e = m._data(d, b) - 1;
+ e ? m._data(d, b, e) : (d.removeEventListener(a, c, !0), m._removeData(d, b))
+ }
+ }
+ }), m.fn.extend({
+ on: function (a, b, c, d, e) {
+ var f, g;
+ if ("object" == typeof a) {
+ "string" != typeof b && (c = c || b, b = void 0);
+ for (f in a)this.on(f, b, c, a[f], e);
+ return this
+ }
+ if (null == c && null == d ? (d = b, c = b = void 0) : null == d && ("string" == typeof b ? (d = c, c = void 0) : (d = c, c = b, b = void 0)), d === !1)d = bb; else if (!d)return this;
+ return 1 === e && (g = d, d = function (a) {
+ return m().off(a), g.apply(this, arguments)
+ }, d.guid = g.guid || (g.guid = m.guid++)), this.each(function () {
+ m.event.add(this, a, d, c, b)
+ })
+ }, one: function (a, b, c, d) {
+ return this.on(a, b, c, d, 1)
+ }, off: function (a, b, c) {
+ var d, e;
+ if (a && a.preventDefault && a.handleObj)return d = a.handleObj, m(a.delegateTarget).off(d.namespace ? d.origType + "." + d.namespace : d.origType, d.selector, d.handler), this;
+ if ("object" == typeof a) {
+ for (e in a)this.off(e, b, a[e]);
+ return this
+ }
+ return (b === !1 || "function" == typeof b) && (c = b, b = void 0), c === !1 && (c = bb), this.each(function () {
+ m.event.remove(this, a, c, b)
+ })
+ }, trigger: function (a, b) {
+ return this.each(function () {
+ m.event.trigger(a, b, this)
+ })
+ }, triggerHandler: function (a, b) {
+ var c = this[0];
+ return c ? m.event.trigger(a, b, c, !0) : void 0
+ }
+ });
+ function db(a) {
+ var b = eb.split("|"), c = a.createDocumentFragment();
+ if (c.createElement)while (b.length)c.createElement(b.pop());
+ return c
+ }
+
+ var eb = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", fb = / jQuery\d+="(?:null|\d+)"/g, gb = new RegExp("<(?:" + eb + ")[\\s/>]", "i"), hb = /^\s+/, ib = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, jb = /<([\w:]+)/, kb = /
\s*$/g, rb = {
+ option: [1, "", " "],
+ legend: [1, "", " "],
+ area: [1, "", " "],
+ param: [1, "", " "],
+ thead: [1, ""],
+ tr: [2, ""],
+ col: [2, ""],
+ td: [3, ""],
+ _default: k.htmlSerialize ? [0, "", ""] : [1, "X", "
"]
+ }, sb = db(y), tb = sb.appendChild(y.createElement("div"));
+ rb.optgroup = rb.option, rb.tbody = rb.tfoot = rb.colgroup = rb.caption = rb.thead, rb.th = rb.td;
+ function ub(a, b) {
+ var c, d, e = 0, f = typeof a.getElementsByTagName !== K ? a.getElementsByTagName(b || "*") : typeof a.querySelectorAll !== K ? a.querySelectorAll(b || "*") : void 0;
+ if (!f)for (f = [], c = a.childNodes || a; null != (d = c[e]); e++)!b || m.nodeName(d, b) ? f.push(d) : m.merge(f, ub(d, b));
+ return void 0 === b || b && m.nodeName(a, b) ? m.merge([a], f) : f
+ }
+
+ function vb(a) {
+ W.test(a.type) && (a.defaultChecked = a.checked)
+ }
+
+ function wb(a, b) {
+ return m.nodeName(a, "table") && m.nodeName(11 !== b.nodeType ? b : b.firstChild, "tr") ? a.getElementsByTagName("tbody")[0] || a.appendChild(a.ownerDocument.createElement("tbody")) : a
+ }
+
+ function xb(a) {
+ return a.type = (null !== m.find.attr(a, "type")) + "/" + a.type, a
+ }
+
+ function yb(a) {
+ var b = pb.exec(a.type);
+ return b ? a.type = b[1] : a.removeAttribute("type"), a
+ }
+
+ function zb(a, b) {
+ for (var c, d = 0; null != (c = a[d]); d++)m._data(c, "globalEval", !b || m._data(b[d], "globalEval"))
+ }
+
+ function Ab(a, b) {
+ if (1 === b.nodeType && m.hasData(a)) {
+ var c, d, e, f = m._data(a), g = m._data(b, f), h = f.events;
+ if (h) {
+ delete g.handle, g.events = {};
+ for (c in h)for (d = 0, e = h[c].length; e > d; d++)m.event.add(b, c, h[c][d])
+ }
+ g.data && (g.data = m.extend({}, g.data))
+ }
+ }
+
+ function Bb(a, b) {
+ var c, d, e;
+ if (1 === b.nodeType) {
+ if (c = b.nodeName.toLowerCase(), !k.noCloneEvent && b[m.expando]) {
+ e = m._data(b);
+ for (d in e.events)m.removeEvent(b, d, e.handle);
+ b.removeAttribute(m.expando)
+ }
+ "script" === c && b.text !== a.text ? (xb(b).text = a.text, yb(b)) : "object" === c ? (b.parentNode && (b.outerHTML = a.outerHTML), k.html5Clone && a.innerHTML && !m.trim(b.innerHTML) && (b.innerHTML = a.innerHTML)) : "input" === c && W.test(a.type) ? (b.defaultChecked = b.checked = a.checked, b.value !== a.value && (b.value = a.value)) : "option" === c ? b.defaultSelected = b.selected = a.defaultSelected : ("input" === c || "textarea" === c) && (b.defaultValue = a.defaultValue)
+ }
+ }
+
+ m.extend({
+ clone: function (a, b, c) {
+ var d, e, f, g, h, i = m.contains(a.ownerDocument, a);
+ if (k.html5Clone || m.isXMLDoc(a) || !gb.test("<" + a.nodeName + ">") ? f = a.cloneNode(!0) : (tb.innerHTML = a.outerHTML, tb.removeChild(f = tb.firstChild)), !(k.noCloneEvent && k.noCloneChecked || 1 !== a.nodeType && 11 !== a.nodeType || m.isXMLDoc(a)))for (d = ub(f), h = ub(a), g = 0; null != (e = h[g]); ++g)d[g] && Bb(e, d[g]);
+ if (b)if (c)for (h = h || ub(a), d = d || ub(f), g = 0; null != (e = h[g]); g++)Ab(e, d[g]); else Ab(a, f);
+ return d = ub(f, "script"), d.length > 0 && zb(d, !i && ub(a, "script")), d = h = e = null, f
+ }, buildFragment: function (a, b, c, d) {
+ for (var e, f, g, h, i, j, l, n = a.length, o = db(b), p = [], q = 0; n > q; q++)if (f = a[q], f || 0 === f)if ("object" === m.type(f))m.merge(p, f.nodeType ? [f] : f); else if (lb.test(f)) {
+ h = h || o.appendChild(b.createElement("div")), i = (jb.exec(f) || ["", ""])[1].toLowerCase(), l = rb[i] || rb._default, h.innerHTML = l[1] + f.replace(ib, "<$1>$2>") + l[2], e = l[0];
+ while (e--)h = h.lastChild;
+ if (!k.leadingWhitespace && hb.test(f) && p.push(b.createTextNode(hb.exec(f)[0])), !k.tbody) {
+ f = "table" !== i || kb.test(f) ? "" !== l[1] || kb.test(f) ? 0 : h : h.firstChild, e = f && f.childNodes.length;
+ while (e--)m.nodeName(j = f.childNodes[e], "tbody") && !j.childNodes.length && f.removeChild(j)
+ }
+ m.merge(p, h.childNodes), h.textContent = "";
+ while (h.firstChild)h.removeChild(h.firstChild);
+ h = o.lastChild
+ } else p.push(b.createTextNode(f));
+ h && o.removeChild(h), k.appendChecked || m.grep(ub(p, "input"), vb), q = 0;
+ while (f = p[q++])if ((!d || -1 === m.inArray(f, d)) && (g = m.contains(f.ownerDocument, f), h = ub(o.appendChild(f), "script"), g && zb(h), c)) {
+ e = 0;
+ while (f = h[e++])ob.test(f.type || "") && c.push(f)
+ }
+ return h = null, o
+ }, cleanData: function (a, b) {
+ for (var d, e, f, g, h = 0, i = m.expando, j = m.cache, l = k.deleteExpando, n = m.event.special; null != (d = a[h]); h++)if ((b || m.acceptData(d)) && (f = d[i], g = f && j[f])) {
+ if (g.events)for (e in g.events)n[e] ? m.event.remove(d, e) : m.removeEvent(d, e, g.handle);
+ j[f] && (delete j[f], l ? delete d[i] : typeof d.removeAttribute !== K ? d.removeAttribute(i) : d[i] = null, c.push(f))
+ }
+ }
+ }), m.fn.extend({
+ text: function (a) {
+ return V(this, function (a) {
+ return void 0 === a ? m.text(this) : this.empty().append((this[0] && this[0].ownerDocument || y).createTextNode(a))
+ }, null, a, arguments.length)
+ }, append: function () {
+ return this.domManip(arguments, function (a) {
+ if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) {
+ var b = wb(this, a);
+ b.appendChild(a)
+ }
+ })
+ }, prepend: function () {
+ return this.domManip(arguments, function (a) {
+ if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) {
+ var b = wb(this, a);
+ b.insertBefore(a, b.firstChild)
+ }
+ })
+ }, before: function () {
+ return this.domManip(arguments, function (a) {
+ this.parentNode && this.parentNode.insertBefore(a, this)
+ })
+ }, after: function () {
+ return this.domManip(arguments, function (a) {
+ this.parentNode && this.parentNode.insertBefore(a, this.nextSibling)
+ })
+ }, remove: function (a, b) {
+ for (var c, d = a ? m.filter(a, this) : this, e = 0; null != (c = d[e]); e++)b || 1 !== c.nodeType || m.cleanData(ub(c)), c.parentNode && (b && m.contains(c.ownerDocument, c) && zb(ub(c, "script")), c.parentNode.removeChild(c));
+ return this
+ }, empty: function () {
+ for (var a, b = 0; null != (a = this[b]); b++) {
+ 1 === a.nodeType && m.cleanData(ub(a, !1));
+ while (a.firstChild)a.removeChild(a.firstChild);
+ a.options && m.nodeName(a, "select") && (a.options.length = 0)
+ }
+ return this
+ }, clone: function (a, b) {
+ return a = null == a ? !1 : a, b = null == b ? a : b, this.map(function () {
+ return m.clone(this, a, b)
+ })
+ }, html: function (a) {
+ return V(this, function (a) {
+ var b = this[0] || {}, c = 0, d = this.length;
+ if (void 0 === a)return 1 === b.nodeType ? b.innerHTML.replace(fb, "") : void 0;
+ if (!("string" != typeof a || mb.test(a) || !k.htmlSerialize && gb.test(a) || !k.leadingWhitespace && hb.test(a) || rb[(jb.exec(a) || ["", ""])[1].toLowerCase()])) {
+ a = a.replace(ib, "<$1>$2>");
+ try {
+ for (; d > c; c++)b = this[c] || {}, 1 === b.nodeType && (m.cleanData(ub(b, !1)), b.innerHTML = a);
+ b = 0
+ } catch (e) {
+ }
+ }
+ b && this.empty().append(a)
+ }, null, a, arguments.length)
+ }, replaceWith: function () {
+ var a = arguments[0];
+ return this.domManip(arguments, function (b) {
+ a = this.parentNode, m.cleanData(ub(this)), a && a.replaceChild(b, this)
+ }), a && (a.length || a.nodeType) ? this : this.remove()
+ }, detach: function (a) {
+ return this.remove(a, !0)
+ }, domManip: function (a, b) {
+ a = e.apply([], a);
+ var c, d, f, g, h, i, j = 0, l = this.length, n = this, o = l - 1, p = a[0], q = m.isFunction(p);
+ if (q || l > 1 && "string" == typeof p && !k.checkClone && nb.test(p))return this.each(function (c) {
+ var d = n.eq(c);
+ q && (a[0] = p.call(this, c, d.html())), d.domManip(a, b)
+ });
+ if (l && (i = m.buildFragment(a, this[0].ownerDocument, !1, this), c = i.firstChild, 1 === i.childNodes.length && (i = c), c)) {
+ for (g = m.map(ub(i, "script"), xb), f = g.length; l > j; j++)d = i, j !== o && (d = m.clone(d, !0, !0), f && m.merge(g, ub(d, "script"))), b.call(this[j], d, j);
+ if (f)for (h = g[g.length - 1].ownerDocument, m.map(g, yb), j = 0; f > j; j++)d = g[j], ob.test(d.type || "") && !m._data(d, "globalEval") && m.contains(h, d) && (d.src ? m._evalUrl && m._evalUrl(d.src) : m.globalEval((d.text || d.textContent || d.innerHTML || "").replace(qb, "")));
+ i = c = null
+ }
+ return this
+ }
+ }), m.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+ }, function (a, b) {
+ m.fn[a] = function (a) {
+ for (var c, d = 0, e = [], g = m(a), h = g.length - 1; h >= d; d++)c = d === h ? this : this.clone(!0), m(g[d])[b](c), f.apply(e, c.get());
+ return this.pushStack(e)
+ }
+ });
+ var Cb, Db = {};
+
+ function Eb(b, c) {
+ var d, e = m(c.createElement(b)).appendTo(c.body), f = a.getDefaultComputedStyle && (d = a.getDefaultComputedStyle(e[0])) ? d.display : m.css(e[0], "display");
+ return e.detach(), f
+ }
+
+ function Fb(a) {
+ var b = y, c = Db[a];
+ return c || (c = Eb(a, b), "none" !== c && c || (Cb = (Cb || m("")).appendTo(b.documentElement), b = (Cb[0].contentWindow || Cb[0].contentDocument).document, b.write(), b.close(), c = Eb(a, b), Cb.detach()), Db[a] = c), c
+ }
+
+ !function () {
+ var a;
+ k.shrinkWrapBlocks = function () {
+ if (null != a)return a;
+ a = !1;
+ var b, c, d;
+ return c = y.getElementsByTagName("body")[0], c && c.style ? (b = y.createElement("div"), d = y.createElement("div"), d.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px", c.appendChild(d).appendChild(b), typeof b.style.zoom !== K && (b.style.cssText = "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1", b.appendChild(y.createElement("div")).style.width = "5px", a = 3 !== b.offsetWidth), c.removeChild(d), a) : void 0
+ }
+ }();
+ var Gb = /^margin/, Hb = new RegExp("^(" + S + ")(?!px)[a-z%]+$", "i"), Ib, Jb, Kb = /^(top|right|bottom|left)$/;
+ a.getComputedStyle ? (Ib = function (a) {
+ return a.ownerDocument.defaultView.getComputedStyle(a, null)
+ }, Jb = function (a, b, c) {
+ var d, e, f, g, h = a.style;
+ return c = c || Ib(a), g = c ? c.getPropertyValue(b) || c[b] : void 0, c && ("" !== g || m.contains(a.ownerDocument, a) || (g = m.style(a, b)), Hb.test(g) && Gb.test(b) && (d = h.width, e = h.minWidth, f = h.maxWidth, h.minWidth = h.maxWidth = h.width = g, g = c.width, h.width = d, h.minWidth = e, h.maxWidth = f)), void 0 === g ? g : g + ""
+ }) : y.documentElement.currentStyle && (Ib = function (a) {
+ return a.currentStyle
+ }, Jb = function (a, b, c) {
+ var d, e, f, g, h = a.style;
+ return c = c || Ib(a), g = c ? c[b] : void 0, null == g && h && h[b] && (g = h[b]), Hb.test(g) && !Kb.test(b) && (d = h.left, e = a.runtimeStyle, f = e && e.left, f && (e.left = a.currentStyle.left), h.left = "fontSize" === b ? "1em" : g, g = h.pixelLeft + "px", h.left = d, f && (e.left = f)), void 0 === g ? g : g + "" || "auto"
+ });
+ function Lb(a, b) {
+ return {
+ get: function () {
+ var c = a();
+ if (null != c)return c ? void delete this.get : (this.get = b).apply(this, arguments)
+ }
+ }
+ }
+
+ !function () {
+ var b, c, d, e, f, g, h;
+ if (b = y.createElement("div"), b.innerHTML = " a ", d = b.getElementsByTagName("a")[0], c = d && d.style) {
+ c.cssText = "float:left;opacity:.5", k.opacity = "0.5" === c.opacity, k.cssFloat = !!c.cssFloat, b.style.backgroundClip = "content-box", b.cloneNode(!0).style.backgroundClip = "", k.clearCloneStyle = "content-box" === b.style.backgroundClip, k.boxSizing = "" === c.boxSizing || "" === c.MozBoxSizing || "" === c.WebkitBoxSizing, m.extend(k, {
+ reliableHiddenOffsets: function () {
+ return null == g && i(), g
+ }, boxSizingReliable: function () {
+ return null == f && i(), f
+ }, pixelPosition: function () {
+ return null == e && i(), e
+ }, reliableMarginRight: function () {
+ return null == h && i(), h
+ }
+ });
+ function i() {
+ var b, c, d, i;
+ c = y.getElementsByTagName("body")[0], c && c.style && (b = y.createElement("div"), d = y.createElement("div"), d.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px", c.appendChild(d).appendChild(b), b.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute", e = f = !1, h = !0, a.getComputedStyle && (e = "1%" !== (a.getComputedStyle(b, null) || {}).top, f = "4px" === (a.getComputedStyle(b, null) || {width: "4px"}).width, i = b.appendChild(y.createElement("div")), i.style.cssText = b.style.cssText = "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0", i.style.marginRight = i.style.width = "0", b.style.width = "1px", h = !parseFloat((a.getComputedStyle(i, null) || {}).marginRight)), b.innerHTML = "", i = b.getElementsByTagName("td"), i[0].style.cssText = "margin:0;border:0;padding:0;display:none", g = 0 === i[0].offsetHeight, g && (i[0].style.display = "", i[1].style.display = "none", g = 0 === i[0].offsetHeight), c.removeChild(d))
+ }
+ }
+ }(), m.swap = function (a, b, c, d) {
+ var e, f, g = {};
+ for (f in b)g[f] = a.style[f], a.style[f] = b[f];
+ e = c.apply(a, d || []);
+ for (f in b)a.style[f] = g[f];
+ return e
+ };
+ var Mb = /alpha\([^)]*\)/i, Nb = /opacity\s*=\s*([^)]*)/, Ob = /^(none|table(?!-c[ea]).+)/, Pb = new RegExp("^(" + S + ")(.*)$", "i"), Qb = new RegExp("^([+-])=(" + S + ")", "i"), Rb = {
+ position: "absolute",
+ visibility: "hidden",
+ display: "block"
+ }, Sb = {letterSpacing: "0", fontWeight: "400"}, Tb = ["Webkit", "O", "Moz", "ms"];
+
+ function Ub(a, b) {
+ if (b in a)return b;
+ var c = b.charAt(0).toUpperCase() + b.slice(1), d = b, e = Tb.length;
+ while (e--)if (b = Tb[e] + c, b in a)return b;
+ return d
+ }
+
+ function Vb(a, b) {
+ for (var c, d, e, f = [], g = 0, h = a.length; h > g; g++)d = a[g], d.style && (f[g] = m._data(d, "olddisplay"), c = d.style.display, b ? (f[g] || "none" !== c || (d.style.display = ""), "" === d.style.display && U(d) && (f[g] = m._data(d, "olddisplay", Fb(d.nodeName)))) : (e = U(d), (c && "none" !== c || !e) && m._data(d, "olddisplay", e ? c : m.css(d, "display"))));
+ for (g = 0; h > g; g++)d = a[g], d.style && (b && "none" !== d.style.display && "" !== d.style.display || (d.style.display = b ? f[g] || "" : "none"));
+ return a
+ }
+
+ function Wb(a, b, c) {
+ var d = Pb.exec(b);
+ return d ? Math.max(0, d[1] - (c || 0)) + (d[2] || "px") : b
+ }
+
+ function Xb(a, b, c, d, e) {
+ for (var f = c === (d ? "border" : "content") ? 4 : "width" === b ? 1 : 0, g = 0; 4 > f; f += 2)"margin" === c && (g += m.css(a, c + T[f], !0, e)), d ? ("content" === c && (g -= m.css(a, "padding" + T[f], !0, e)), "margin" !== c && (g -= m.css(a, "border" + T[f] + "Width", !0, e))) : (g += m.css(a, "padding" + T[f], !0, e), "padding" !== c && (g += m.css(a, "border" + T[f] + "Width", !0, e)));
+ return g
+ }
+
+ function Yb(a, b, c) {
+ var d = !0, e = "width" === b ? a.offsetWidth : a.offsetHeight, f = Ib(a), g = k.boxSizing && "border-box" === m.css(a, "boxSizing", !1, f);
+ if (0 >= e || null == e) {
+ if (e = Jb(a, b, f), (0 > e || null == e) && (e = a.style[b]), Hb.test(e))return e;
+ d = g && (k.boxSizingReliable() || e === a.style[b]), e = parseFloat(e) || 0
+ }
+ return e + Xb(a, b, c || (g ? "border" : "content"), d, f) + "px"
+ }
+
+ m.extend({
+ cssHooks: {
+ opacity: {
+ get: function (a, b) {
+ if (b) {
+ var c = Jb(a, "opacity");
+ return "" === c ? "1" : c
+ }
+ }
+ }
+ },
+ cssNumber: {
+ columnCount: !0,
+ fillOpacity: !0,
+ flexGrow: !0,
+ flexShrink: !0,
+ fontWeight: !0,
+ lineHeight: !0,
+ opacity: !0,
+ order: !0,
+ orphans: !0,
+ widows: !0,
+ zIndex: !0,
+ zoom: !0
+ },
+ cssProps: {"float": k.cssFloat ? "cssFloat" : "styleFloat"},
+ style: function (a, b, c, d) {
+ if (a && 3 !== a.nodeType && 8 !== a.nodeType && a.style) {
+ var e, f, g, h = m.camelCase(b), i = a.style;
+ if (b = m.cssProps[h] || (m.cssProps[h] = Ub(i, h)), g = m.cssHooks[b] || m.cssHooks[h], void 0 === c)return g && "get"in g && void 0 !== (e = g.get(a, !1, d)) ? e : i[b];
+ if (f = typeof c, "string" === f && (e = Qb.exec(c)) && (c = (e[1] + 1) * e[2] + parseFloat(m.css(a, b)), f = "number"), null != c && c === c && ("number" !== f || m.cssNumber[h] || (c += "px"), k.clearCloneStyle || "" !== c || 0 !== b.indexOf("background") || (i[b] = "inherit"), !(g && "set"in g && void 0 === (c = g.set(a, c, d)))))try {
+ i[b] = c
+ } catch (j) {
+ }
+ }
+ },
+ css: function (a, b, c, d) {
+ var e, f, g, h = m.camelCase(b);
+ return b = m.cssProps[h] || (m.cssProps[h] = Ub(a.style, h)), g = m.cssHooks[b] || m.cssHooks[h], g && "get"in g && (f = g.get(a, !0, c)), void 0 === f && (f = Jb(a, b, d)), "normal" === f && b in Sb && (f = Sb[b]), "" === c || c ? (e = parseFloat(f), c === !0 || m.isNumeric(e) ? e || 0 : f) : f
+ }
+ }), m.each(["height", "width"], function (a, b) {
+ m.cssHooks[b] = {
+ get: function (a, c, d) {
+ return c ? Ob.test(m.css(a, "display")) && 0 === a.offsetWidth ? m.swap(a, Rb, function () {
+ return Yb(a, b, d)
+ }) : Yb(a, b, d) : void 0
+ }, set: function (a, c, d) {
+ var e = d && Ib(a);
+ return Wb(a, c, d ? Xb(a, b, d, k.boxSizing && "border-box" === m.css(a, "boxSizing", !1, e), e) : 0)
+ }
+ }
+ }), k.opacity || (m.cssHooks.opacity = {
+ get: function (a, b) {
+ return Nb.test((b && a.currentStyle ? a.currentStyle.filter : a.style.filter) || "") ? .01 * parseFloat(RegExp.$1) + "" : b ? "1" : ""
+ }, set: function (a, b) {
+ var c = a.style, d = a.currentStyle, e = m.isNumeric(b) ? "alpha(opacity=" + 100 * b + ")" : "", f = d && d.filter || c.filter || "";
+ c.zoom = 1, (b >= 1 || "" === b) && "" === m.trim(f.replace(Mb, "")) && c.removeAttribute && (c.removeAttribute("filter"), "" === b || d && !d.filter) || (c.filter = Mb.test(f) ? f.replace(Mb, e) : f + " " + e)
+ }
+ }), m.cssHooks.marginRight = Lb(k.reliableMarginRight, function (a, b) {
+ return b ? m.swap(a, {display: "inline-block"}, Jb, [a, "marginRight"]) : void 0
+ }), m.each({margin: "", padding: "", border: "Width"}, function (a, b) {
+ m.cssHooks[a + b] = {
+ expand: function (c) {
+ for (var d = 0, e = {}, f = "string" == typeof c ? c.split(" ") : [c]; 4 > d; d++)e[a + T[d] + b] = f[d] || f[d - 2] || f[0];
+ return e
+ }
+ }, Gb.test(a) || (m.cssHooks[a + b].set = Wb)
+ }), m.fn.extend({
+ css: function (a, b) {
+ return V(this, function (a, b, c) {
+ var d, e, f = {}, g = 0;
+ if (m.isArray(b)) {
+ for (d = Ib(a), e = b.length; e > g; g++)f[b[g]] = m.css(a, b[g], !1, d);
+ return f
+ }
+ return void 0 !== c ? m.style(a, b, c) : m.css(a, b)
+ }, a, b, arguments.length > 1)
+ }, show: function () {
+ return Vb(this, !0)
+ }, hide: function () {
+ return Vb(this)
+ }, toggle: function (a) {
+ return "boolean" == typeof a ? a ? this.show() : this.hide() : this.each(function () {
+ U(this) ? m(this).show() : m(this).hide()
+ })
+ }
+ });
+ function Zb(a, b, c, d, e) {
+ return new Zb.prototype.init(a, b, c, d, e)
+ }
+
+ m.Tween = Zb, Zb.prototype = {
+ constructor: Zb, init: function (a, b, c, d, e, f) {
+ this.elem = a, this.prop = c, this.easing = e || "swing", this.options = b, this.start = this.now = this.cur(), this.end = d, this.unit = f || (m.cssNumber[c] ? "" : "px")
+ }, cur: function () {
+ var a = Zb.propHooks[this.prop];
+ return a && a.get ? a.get(this) : Zb.propHooks._default.get(this)
+ }, run: function (a) {
+ var b, c = Zb.propHooks[this.prop];
+ return this.pos = b = this.options.duration ? m.easing[this.easing](a, this.options.duration * a, 0, 1, this.options.duration) : a, this.now = (this.end - this.start) * b + this.start, this.options.step && this.options.step.call(this.elem, this.now, this), c && c.set ? c.set(this) : Zb.propHooks._default.set(this), this
+ }
+ }, Zb.prototype.init.prototype = Zb.prototype, Zb.propHooks = {
+ _default: {
+ get: function (a) {
+ var b;
+ return null == a.elem[a.prop] || a.elem.style && null != a.elem.style[a.prop] ? (b = m.css(a.elem, a.prop, ""), b && "auto" !== b ? b : 0) : a.elem[a.prop]
+ }, set: function (a) {
+ m.fx.step[a.prop] ? m.fx.step[a.prop](a) : a.elem.style && (null != a.elem.style[m.cssProps[a.prop]] || m.cssHooks[a.prop]) ? m.style(a.elem, a.prop, a.now + a.unit) : a.elem[a.prop] = a.now
+ }
+ }
+ }, Zb.propHooks.scrollTop = Zb.propHooks.scrollLeft = {
+ set: function (a) {
+ a.elem.nodeType && a.elem.parentNode && (a.elem[a.prop] = a.now)
+ }
+ }, m.easing = {
+ linear: function (a) {
+ return a
+ }, swing: function (a) {
+ return .5 - Math.cos(a * Math.PI) / 2
+ }
+ }, m.fx = Zb.prototype.init, m.fx.step = {};
+ var $b, _b, ac = /^(?:toggle|show|hide)$/, bc = new RegExp("^(?:([+-])=|)(" + S + ")([a-z%]*)$", "i"), cc = /queueHooks$/, dc = [ic], ec = {
+ "*": [function (a, b) {
+ var c = this.createTween(a, b), d = c.cur(), e = bc.exec(b), f = e && e[3] || (m.cssNumber[a] ? "" : "px"), g = (m.cssNumber[a] || "px" !== f && +d) && bc.exec(m.css(c.elem, a)), h = 1, i = 20;
+ if (g && g[3] !== f) {
+ f = f || g[3], e = e || [], g = +d || 1;
+ do h = h || ".5", g /= h, m.style(c.elem, a, g + f); while (h !== (h = c.cur() / d) && 1 !== h && --i)
+ }
+ return e && (g = c.start = +g || +d || 0, c.unit = f, c.end = e[1] ? g + (e[1] + 1) * e[2] : +e[2]), c
+ }]
+ };
+
+ function fc() {
+ return setTimeout(function () {
+ $b = void 0
+ }), $b = m.now()
+ }
+
+ function gc(a, b) {
+ var c, d = {height: a}, e = 0;
+ for (b = b ? 1 : 0; 4 > e; e += 2 - b)c = T[e], d["margin" + c] = d["padding" + c] = a;
+ return b && (d.opacity = d.width = a), d
+ }
+
+ function hc(a, b, c) {
+ for (var d, e = (ec[b] || []).concat(ec["*"]), f = 0, g = e.length; g > f; f++)if (d = e[f].call(c, b, a))return d
+ }
+
+ function ic(a, b, c) {
+ var d, e, f, g, h, i, j, l, n = this, o = {}, p = a.style, q = a.nodeType && U(a), r = m._data(a, "fxshow");
+ c.queue || (h = m._queueHooks(a, "fx"), null == h.unqueued && (h.unqueued = 0, i = h.empty.fire, h.empty.fire = function () {
+ h.unqueued || i()
+ }), h.unqueued++, n.always(function () {
+ n.always(function () {
+ h.unqueued--, m.queue(a, "fx").length || h.empty.fire()
+ })
+ })), 1 === a.nodeType && ("height"in b || "width"in b) && (c.overflow = [p.overflow, p.overflowX, p.overflowY], j = m.css(a, "display"), l = "none" === j ? m._data(a, "olddisplay") || Fb(a.nodeName) : j, "inline" === l && "none" === m.css(a, "float") && (k.inlineBlockNeedsLayout && "inline" !== Fb(a.nodeName) ? p.zoom = 1 : p.display = "inline-block")), c.overflow && (p.overflow = "hidden", k.shrinkWrapBlocks() || n.always(function () {
+ p.overflow = c.overflow[0], p.overflowX = c.overflow[1], p.overflowY = c.overflow[2]
+ }));
+ for (d in b)if (e = b[d], ac.exec(e)) {
+ if (delete b[d], f = f || "toggle" === e, e === (q ? "hide" : "show")) {
+ if ("show" !== e || !r || void 0 === r[d])continue;
+ q = !0
+ }
+ o[d] = r && r[d] || m.style(a, d)
+ } else j = void 0;
+ if (m.isEmptyObject(o))"inline" === ("none" === j ? Fb(a.nodeName) : j) && (p.display = j); else {
+ r ? "hidden"in r && (q = r.hidden) : r = m._data(a, "fxshow", {}), f && (r.hidden = !q), q ? m(a).show() : n.done(function () {
+ m(a).hide()
+ }), n.done(function () {
+ var b;
+ m._removeData(a, "fxshow");
+ for (b in o)m.style(a, b, o[b])
+ });
+ for (d in o)g = hc(q ? r[d] : 0, d, n), d in r || (r[d] = g.start, q && (g.end = g.start, g.start = "width" === d || "height" === d ? 1 : 0))
+ }
+ }
+
+ function jc(a, b) {
+ var c, d, e, f, g;
+ for (c in a)if (d = m.camelCase(c), e = b[d], f = a[c], m.isArray(f) && (e = f[1], f = a[c] = f[0]), c !== d && (a[d] = f, delete a[c]), g = m.cssHooks[d], g && "expand"in g) {
+ f = g.expand(f), delete a[d];
+ for (c in f)c in a || (a[c] = f[c], b[c] = e)
+ } else b[d] = e
+ }
+
+ function kc(a, b, c) {
+ var d, e, f = 0, g = dc.length, h = m.Deferred().always(function () {
+ delete i.elem
+ }), i = function () {
+ if (e)return !1;
+ for (var b = $b || fc(), c = Math.max(0, j.startTime + j.duration - b), d = c / j.duration || 0, f = 1 - d, g = 0, i = j.tweens.length; i > g; g++)j.tweens[g].run(f);
+ return h.notifyWith(a, [j, f, c]), 1 > f && i ? c : (h.resolveWith(a, [j]), !1)
+ }, j = h.promise({
+ elem: a,
+ props: m.extend({}, b),
+ opts: m.extend(!0, {specialEasing: {}}, c),
+ originalProperties: b,
+ originalOptions: c,
+ startTime: $b || fc(),
+ duration: c.duration,
+ tweens: [],
+ createTween: function (b, c) {
+ var d = m.Tween(a, j.opts, b, c, j.opts.specialEasing[b] || j.opts.easing);
+ return j.tweens.push(d), d
+ },
+ stop: function (b) {
+ var c = 0, d = b ? j.tweens.length : 0;
+ if (e)return this;
+ for (e = !0; d > c; c++)j.tweens[c].run(1);
+ return b ? h.resolveWith(a, [j, b]) : h.rejectWith(a, [j, b]), this
+ }
+ }), k = j.props;
+ for (jc(k, j.opts.specialEasing); g > f; f++)if (d = dc[f].call(j, a, k, j.opts))return d;
+ return m.map(k, hc, j), m.isFunction(j.opts.start) && j.opts.start.call(a, j), m.fx.timer(m.extend(i, {
+ elem: a,
+ anim: j,
+ queue: j.opts.queue
+ })), j.progress(j.opts.progress).done(j.opts.done, j.opts.complete).fail(j.opts.fail).always(j.opts.always)
+ }
+
+ m.Animation = m.extend(kc, {
+ tweener: function (a, b) {
+ m.isFunction(a) ? (b = a, a = ["*"]) : a = a.split(" ");
+ for (var c, d = 0, e = a.length; e > d; d++)c = a[d], ec[c] = ec[c] || [], ec[c].unshift(b)
+ }, prefilter: function (a, b) {
+ b ? dc.unshift(a) : dc.push(a)
+ }
+ }), m.speed = function (a, b, c) {
+ var d = a && "object" == typeof a ? m.extend({}, a) : {
+ complete: c || !c && b || m.isFunction(a) && a,
+ duration: a,
+ easing: c && b || b && !m.isFunction(b) && b
+ };
+ return d.duration = m.fx.off ? 0 : "number" == typeof d.duration ? d.duration : d.duration in m.fx.speeds ? m.fx.speeds[d.duration] : m.fx.speeds._default, (null == d.queue || d.queue === !0) && (d.queue = "fx"), d.old = d.complete, d.complete = function () {
+ m.isFunction(d.old) && d.old.call(this), d.queue && m.dequeue(this, d.queue)
+ }, d
+ }, m.fn.extend({
+ fadeTo: function (a, b, c, d) {
+ return this.filter(U).css("opacity", 0).show().end().animate({opacity: b}, a, c, d)
+ }, animate: function (a, b, c, d) {
+ var e = m.isEmptyObject(a), f = m.speed(b, c, d), g = function () {
+ var b = kc(this, m.extend({}, a), f);
+ (e || m._data(this, "finish")) && b.stop(!0)
+ };
+ return g.finish = g, e || f.queue === !1 ? this.each(g) : this.queue(f.queue, g)
+ }, stop: function (a, b, c) {
+ var d = function (a) {
+ var b = a.stop;
+ delete a.stop, b(c)
+ };
+ return "string" != typeof a && (c = b, b = a, a = void 0), b && a !== !1 && this.queue(a || "fx", []), this.each(function () {
+ var b = !0, e = null != a && a + "queueHooks", f = m.timers, g = m._data(this);
+ if (e)g[e] && g[e].stop && d(g[e]); else for (e in g)g[e] && g[e].stop && cc.test(e) && d(g[e]);
+ for (e = f.length; e--;)f[e].elem !== this || null != a && f[e].queue !== a || (f[e].anim.stop(c), b = !1, f.splice(e, 1));
+ (b || !c) && m.dequeue(this, a)
+ })
+ }, finish: function (a) {
+ return a !== !1 && (a = a || "fx"), this.each(function () {
+ var b, c = m._data(this), d = c[a + "queue"], e = c[a + "queueHooks"], f = m.timers, g = d ? d.length : 0;
+ for (c.finish = !0, m.queue(this, a, []), e && e.stop && e.stop.call(this, !0), b = f.length; b--;)f[b].elem === this && f[b].queue === a && (f[b].anim.stop(!0), f.splice(b, 1));
+ for (b = 0; g > b; b++)d[b] && d[b].finish && d[b].finish.call(this);
+ delete c.finish
+ })
+ }
+ }), m.each(["toggle", "show", "hide"], function (a, b) {
+ var c = m.fn[b];
+ m.fn[b] = function (a, d, e) {
+ return null == a || "boolean" == typeof a ? c.apply(this, arguments) : this.animate(gc(b, !0), a, d, e)
+ }
+ }), m.each({
+ slideDown: gc("show"),
+ slideUp: gc("hide"),
+ slideToggle: gc("toggle"),
+ fadeIn: {opacity: "show"},
+ fadeOut: {opacity: "hide"},
+ fadeToggle: {opacity: "toggle"}
+ }, function (a, b) {
+ m.fn[a] = function (a, c, d) {
+ return this.animate(b, a, c, d)
+ }
+ }), m.timers = [], m.fx.tick = function () {
+ var a, b = m.timers, c = 0;
+ for ($b = m.now(); c < b.length; c++)a = b[c], a() || b[c] !== a || b.splice(c--, 1);
+ b.length || m.fx.stop(), $b = void 0
+ }, m.fx.timer = function (a) {
+ m.timers.push(a), a() ? m.fx.start() : m.timers.pop()
+ }, m.fx.interval = 13, m.fx.start = function () {
+ _b || (_b = setInterval(m.fx.tick, m.fx.interval))
+ }, m.fx.stop = function () {
+ clearInterval(_b), _b = null
+ }, m.fx.speeds = {slow: 600, fast: 200, _default: 400}, m.fn.delay = function (a, b) {
+ return a = m.fx ? m.fx.speeds[a] || a : a, b = b || "fx", this.queue(b, function (b, c) {
+ var d = setTimeout(b, a);
+ c.stop = function () {
+ clearTimeout(d)
+ }
+ })
+ }, function () {
+ var a, b, c, d, e;
+ b = y.createElement("div"), b.setAttribute("className", "t"), b.innerHTML = " a ", d = b.getElementsByTagName("a")[0], c = y.createElement("select"), e = c.appendChild(y.createElement("option")), a = b.getElementsByTagName("input")[0], d.style.cssText = "top:1px", k.getSetAttribute = "t" !== b.className, k.style = /top/.test(d.getAttribute("style")), k.hrefNormalized = "/a" === d.getAttribute("href"), k.checkOn = !!a.value, k.optSelected = e.selected, k.enctype = !!y.createElement("form").enctype, c.disabled = !0, k.optDisabled = !e.disabled, a = y.createElement("input"), a.setAttribute("value", ""), k.input = "" === a.getAttribute("value"), a.value = "t", a.setAttribute("type", "radio"), k.radioValue = "t" === a.value
+ }();
+ var lc = /\r/g;
+ m.fn.extend({
+ val: function (a) {
+ var b, c, d, e = this[0];
+ {
+ if (arguments.length)return d = m.isFunction(a), this.each(function (c) {
+ var e;
+ 1 === this.nodeType && (e = d ? a.call(this, c, m(this).val()) : a, null == e ? e = "" : "number" == typeof e ? e += "" : m.isArray(e) && (e = m.map(e, function (a) {
+ return null == a ? "" : a + ""
+ })), b = m.valHooks[this.type] || m.valHooks[this.nodeName.toLowerCase()], b && "set"in b && void 0 !== b.set(this, e, "value") || (this.value = e))
+ });
+ if (e)return b = m.valHooks[e.type] || m.valHooks[e.nodeName.toLowerCase()], b && "get"in b && void 0 !== (c = b.get(e, "value")) ? c : (c = e.value, "string" == typeof c ? c.replace(lc, "") : null == c ? "" : c)
+ }
+ }
+ }), m.extend({
+ valHooks: {
+ option: {
+ get: function (a) {
+ var b = m.find.attr(a, "value");
+ return null != b ? b : m.trim(m.text(a))
+ }
+ }, select: {
+ get: function (a) {
+ for (var b, c, d = a.options, e = a.selectedIndex, f = "select-one" === a.type || 0 > e, g = f ? null : [], h = f ? e + 1 : d.length, i = 0 > e ? h : f ? e : 0; h > i; i++)if (c = d[i], !(!c.selected && i !== e || (k.optDisabled ? c.disabled : null !== c.getAttribute("disabled")) || c.parentNode.disabled && m.nodeName(c.parentNode, "optgroup"))) {
+ if (b = m(c).val(), f)return b;
+ g.push(b)
+ }
+ return g
+ }, set: function (a, b) {
+ var c, d, e = a.options, f = m.makeArray(b), g = e.length;
+ while (g--)if (d = e[g], m.inArray(m.valHooks.option.get(d), f) >= 0)try {
+ d.selected = c = !0
+ } catch (h) {
+ d.scrollHeight
+ } else d.selected = !1;
+ return c || (a.selectedIndex = -1), e
+ }
+ }
+ }
+ }), m.each(["radio", "checkbox"], function () {
+ m.valHooks[this] = {
+ set: function (a, b) {
+ return m.isArray(b) ? a.checked = m.inArray(m(a).val(), b) >= 0 : void 0
+ }
+ }, k.checkOn || (m.valHooks[this].get = function (a) {
+ return null === a.getAttribute("value") ? "on" : a.value
+ })
+ });
+ var mc, nc, oc = m.expr.attrHandle, pc = /^(?:checked|selected)$/i, qc = k.getSetAttribute, rc = k.input;
+ m.fn.extend({
+ attr: function (a, b) {
+ return V(this, m.attr, a, b, arguments.length > 1)
+ }, removeAttr: function (a) {
+ return this.each(function () {
+ m.removeAttr(this, a)
+ })
+ }
+ }), m.extend({
+ attr: function (a, b, c) {
+ var d, e, f = a.nodeType;
+ if (a && 3 !== f && 8 !== f && 2 !== f)return typeof a.getAttribute === K ? m.prop(a, b, c) : (1 === f && m.isXMLDoc(a) || (b = b.toLowerCase(), d = m.attrHooks[b] || (m.expr.match.bool.test(b) ? nc : mc)), void 0 === c ? d && "get"in d && null !== (e = d.get(a, b)) ? e : (e = m.find.attr(a, b), null == e ? void 0 : e) : null !== c ? d && "set"in d && void 0 !== (e = d.set(a, c, b)) ? e : (a.setAttribute(b, c + ""), c) : void m.removeAttr(a, b))
+ }, removeAttr: function (a, b) {
+ var c, d, e = 0, f = b && b.match(E);
+ if (f && 1 === a.nodeType)while (c = f[e++])d = m.propFix[c] || c, m.expr.match.bool.test(c) ? rc && qc || !pc.test(c) ? a[d] = !1 : a[m.camelCase("default-" + c)] = a[d] = !1 : m.attr(a, c, ""), a.removeAttribute(qc ? c : d)
+ }, attrHooks: {
+ type: {
+ set: function (a, b) {
+ if (!k.radioValue && "radio" === b && m.nodeName(a, "input")) {
+ var c = a.value;
+ return a.setAttribute("type", b), c && (a.value = c), b
+ }
+ }
+ }
+ }
+ }), nc = {
+ set: function (a, b, c) {
+ return b === !1 ? m.removeAttr(a, c) : rc && qc || !pc.test(c) ? a.setAttribute(!qc && m.propFix[c] || c, c) : a[m.camelCase("default-" + c)] = a[c] = !0, c
+ }
+ }, m.each(m.expr.match.bool.source.match(/\w+/g), function (a, b) {
+ var c = oc[b] || m.find.attr;
+ oc[b] = rc && qc || !pc.test(b) ? function (a, b, d) {
+ var e, f;
+ return d || (f = oc[b], oc[b] = e, e = null != c(a, b, d) ? b.toLowerCase() : null, oc[b] = f), e
+ } : function (a, b, c) {
+ return c ? void 0 : a[m.camelCase("default-" + b)] ? b.toLowerCase() : null
+ }
+ }), rc && qc || (m.attrHooks.value = {
+ set: function (a, b, c) {
+ return m.nodeName(a, "input") ? void(a.defaultValue = b) : mc && mc.set(a, b, c)
+ }
+ }), qc || (mc = {
+ set: function (a, b, c) {
+ var d = a.getAttributeNode(c);
+ return d || a.setAttributeNode(d = a.ownerDocument.createAttribute(c)), d.value = b += "", "value" === c || b === a.getAttribute(c) ? b : void 0
+ }
+ }, oc.id = oc.name = oc.coords = function (a, b, c) {
+ var d;
+ return c ? void 0 : (d = a.getAttributeNode(b)) && "" !== d.value ? d.value : null
+ }, m.valHooks.button = {
+ get: function (a, b) {
+ var c = a.getAttributeNode(b);
+ return c && c.specified ? c.value : void 0
+ }, set: mc.set
+ }, m.attrHooks.contenteditable = {
+ set: function (a, b, c) {
+ mc.set(a, "" === b ? !1 : b, c)
+ }
+ }, m.each(["width", "height"], function (a, b) {
+ m.attrHooks[b] = {
+ set: function (a, c) {
+ return "" === c ? (a.setAttribute(b, "auto"), c) : void 0
+ }
+ }
+ })), k.style || (m.attrHooks.style = {
+ get: function (a) {
+ return a.style.cssText || void 0
+ }, set: function (a, b) {
+ return a.style.cssText = b + ""
+ }
+ });
+ var sc = /^(?:input|select|textarea|button|object)$/i, tc = /^(?:a|area)$/i;
+ m.fn.extend({
+ prop: function (a, b) {
+ return V(this, m.prop, a, b, arguments.length > 1)
+ }, removeProp: function (a) {
+ return a = m.propFix[a] || a, this.each(function () {
+ try {
+ this[a] = void 0, delete this[a]
+ } catch (b) {
+ }
+ })
+ }
+ }), m.extend({
+ propFix: {"for": "htmlFor", "class": "className"}, prop: function (a, b, c) {
+ var d, e, f, g = a.nodeType;
+ if (a && 3 !== g && 8 !== g && 2 !== g)return f = 1 !== g || !m.isXMLDoc(a), f && (b = m.propFix[b] || b, e = m.propHooks[b]), void 0 !== c ? e && "set"in e && void 0 !== (d = e.set(a, c, b)) ? d : a[b] = c : e && "get"in e && null !== (d = e.get(a, b)) ? d : a[b]
+ }, propHooks: {
+ tabIndex: {
+ get: function (a) {
+ var b = m.find.attr(a, "tabindex");
+ return b ? parseInt(b, 10) : sc.test(a.nodeName) || tc.test(a.nodeName) && a.href ? 0 : -1
+ }
+ }
+ }
+ }), k.hrefNormalized || m.each(["href", "src"], function (a, b) {
+ m.propHooks[b] = {
+ get: function (a) {
+ return a.getAttribute(b, 4)
+ }
+ }
+ }), k.optSelected || (m.propHooks.selected = {
+ get: function (a) {
+ var b = a.parentNode;
+ return b && (b.selectedIndex, b.parentNode && b.parentNode.selectedIndex), null
+ }
+ }), m.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function () {
+ m.propFix[this.toLowerCase()] = this
+ }), k.enctype || (m.propFix.enctype = "encoding");
+ var uc = /[\t\r\n\f]/g;
+ m.fn.extend({
+ addClass: function (a) {
+ var b, c, d, e, f, g, h = 0, i = this.length, j = "string" == typeof a && a;
+ if (m.isFunction(a))return this.each(function (b) {
+ m(this).addClass(a.call(this, b, this.className))
+ });
+ if (j)for (b = (a || "").match(E) || []; i > h; h++)if (c = this[h], d = 1 === c.nodeType && (c.className ? (" " + c.className + " ").replace(uc, " ") : " ")) {
+ f = 0;
+ while (e = b[f++])d.indexOf(" " + e + " ") < 0 && (d += e + " ");
+ g = m.trim(d), c.className !== g && (c.className = g)
+ }
+ return this
+ }, removeClass: function (a) {
+ var b, c, d, e, f, g, h = 0, i = this.length, j = 0 === arguments.length || "string" == typeof a && a;
+ if (m.isFunction(a))return this.each(function (b) {
+ m(this).removeClass(a.call(this, b, this.className))
+ });
+ if (j)for (b = (a || "").match(E) || []; i > h; h++)if (c = this[h], d = 1 === c.nodeType && (c.className ? (" " + c.className + " ").replace(uc, " ") : "")) {
+ f = 0;
+ while (e = b[f++])while (d.indexOf(" " + e + " ") >= 0)d = d.replace(" " + e + " ", " ");
+ g = a ? m.trim(d) : "", c.className !== g && (c.className = g)
+ }
+ return this
+ }, toggleClass: function (a, b) {
+ var c = typeof a;
+ return "boolean" == typeof b && "string" === c ? b ? this.addClass(a) : this.removeClass(a) : this.each(m.isFunction(a) ? function (c) {
+ m(this).toggleClass(a.call(this, c, this.className, b), b)
+ } : function () {
+ if ("string" === c) {
+ var b, d = 0, e = m(this), f = a.match(E) || [];
+ while (b = f[d++])e.hasClass(b) ? e.removeClass(b) : e.addClass(b)
+ } else(c === K || "boolean" === c) && (this.className && m._data(this, "__className__", this.className), this.className = this.className || a === !1 ? "" : m._data(this, "__className__") || "")
+ })
+ }, hasClass: function (a) {
+ for (var b = " " + a + " ", c = 0, d = this.length; d > c; c++)if (1 === this[c].nodeType && (" " + this[c].className + " ").replace(uc, " ").indexOf(b) >= 0)return !0;
+ return !1
+ }
+ }), m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "), function (a, b) {
+ m.fn[b] = function (a, c) {
+ return arguments.length > 0 ? this.on(b, null, a, c) : this.trigger(b)
+ }
+ }), m.fn.extend({
+ hover: function (a, b) {
+ return this.mouseenter(a).mouseleave(b || a)
+ }, bind: function (a, b, c) {
+ return this.on(a, null, b, c)
+ }, unbind: function (a, b) {
+ return this.off(a, null, b)
+ }, delegate: function (a, b, c, d) {
+ return this.on(b, a, c, d)
+ }, undelegate: function (a, b, c) {
+ return 1 === arguments.length ? this.off(a, "**") : this.off(b, a || "**", c)
+ }
+ });
+ var vc = m.now(), wc = /\?/, xc = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
+ m.parseJSON = function (b) {
+ if (a.JSON && a.JSON.parse)return a.JSON.parse(b + "");
+ var c, d = null, e = m.trim(b + "");
+ return e && !m.trim(e.replace(xc, function (a, b, e, f) {
+ return c && b && (d = 0), 0 === d ? a : (c = e || b, d += !f - !e, "")
+ })) ? Function("return " + e)() : m.error("Invalid JSON: " + b)
+ }, m.parseXML = function (b) {
+ var c, d;
+ if (!b || "string" != typeof b)return null;
+ try {
+ a.DOMParser ? (d = new DOMParser, c = d.parseFromString(b, "text/xml")) : (c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(b))
+ } catch (e) {
+ c = void 0
+ }
+ return c && c.documentElement && !c.getElementsByTagName("parsererror").length || m.error("Invalid XML: " + b), c
+ };
+ var yc, zc, Ac = /#.*$/, Bc = /([?&])_=[^&]*/, Cc = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm, Dc = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, Ec = /^(?:GET|HEAD)$/, Fc = /^\/\//, Gc = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, Hc = {}, Ic = {}, Jc = "*/".concat("*");
+ try {
+ zc = location.href
+ } catch (Kc) {
+ zc = y.createElement("a"), zc.href = "", zc = zc.href
+ }
+ yc = Gc.exec(zc.toLowerCase()) || [];
+ function Lc(a) {
+ return function (b, c) {
+ "string" != typeof b && (c = b, b = "*");
+ var d, e = 0, f = b.toLowerCase().match(E) || [];
+ if (m.isFunction(c))while (d = f[e++])"+" === d.charAt(0) ? (d = d.slice(1) || "*", (a[d] = a[d] || []).unshift(c)) : (a[d] = a[d] || []).push(c)
+ }
+ }
+
+ function Mc(a, b, c, d) {
+ var e = {}, f = a === Ic;
+
+ function g(h) {
+ var i;
+ return e[h] = !0, m.each(a[h] || [], function (a, h) {
+ var j = h(b, c, d);
+ return "string" != typeof j || f || e[j] ? f ? !(i = j) : void 0 : (b.dataTypes.unshift(j), g(j), !1)
+ }), i
+ }
+
+ return g(b.dataTypes[0]) || !e["*"] && g("*")
+ }
+
+ function Nc(a, b) {
+ var c, d, e = m.ajaxSettings.flatOptions || {};
+ for (d in b)void 0 !== b[d] && ((e[d] ? a : c || (c = {}))[d] = b[d]);
+ return c && m.extend(!0, a, c), a
+ }
+
+ function Oc(a, b, c) {
+ var d, e, f, g, h = a.contents, i = a.dataTypes;
+ while ("*" === i[0])i.shift(), void 0 === e && (e = a.mimeType || b.getResponseHeader("Content-Type"));
+ if (e)for (g in h)if (h[g] && h[g].test(e)) {
+ i.unshift(g);
+ break
+ }
+ if (i[0]in c)f = i[0]; else {
+ for (g in c) {
+ if (!i[0] || a.converters[g + " " + i[0]]) {
+ f = g;
+ break
+ }
+ d || (d = g)
+ }
+ f = f || d
+ }
+ return f ? (f !== i[0] && i.unshift(f), c[f]) : void 0
+ }
+
+ function Pc(a, b, c, d) {
+ var e, f, g, h, i, j = {}, k = a.dataTypes.slice();
+ if (k[1])for (g in a.converters)j[g.toLowerCase()] = a.converters[g];
+ f = k.shift();
+ while (f)if (a.responseFields[f] && (c[a.responseFields[f]] = b), !i && d && a.dataFilter && (b = a.dataFilter(b, a.dataType)), i = f, f = k.shift())if ("*" === f)f = i; else if ("*" !== i && i !== f) {
+ if (g = j[i + " " + f] || j["* " + f], !g)for (e in j)if (h = e.split(" "), h[1] === f && (g = j[i + " " + h[0]] || j["* " + h[0]])) {
+ g === !0 ? g = j[e] : j[e] !== !0 && (f = h[0], k.unshift(h[1]));
+ break
+ }
+ if (g !== !0)if (g && a["throws"])b = g(b); else try {
+ b = g(b)
+ } catch (l) {
+ return {state: "parsererror", error: g ? l : "No conversion from " + i + " to " + f}
+ }
+ }
+ return {state: "success", data: b}
+ }
+
+ m.extend({
+ active: 0,
+ lastModified: {},
+ etag: {},
+ ajaxSettings: {
+ url: zc,
+ type: "GET",
+ isLocal: Dc.test(yc[1]),
+ global: !0,
+ processData: !0,
+ async: !0,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ accepts: {
+ "*": Jc,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+ contents: {xml: /xml/, html: /html/, json: /json/},
+ responseFields: {xml: "responseXML", text: "responseText", json: "responseJSON"},
+ converters: {"* text": String, "text html": !0, "text json": m.parseJSON, "text xml": m.parseXML},
+ flatOptions: {url: !0, context: !0}
+ },
+ ajaxSetup: function (a, b) {
+ return b ? Nc(Nc(a, m.ajaxSettings), b) : Nc(m.ajaxSettings, a)
+ },
+ ajaxPrefilter: Lc(Hc),
+ ajaxTransport: Lc(Ic),
+ ajax: function (a, b) {
+ "object" == typeof a && (b = a, a = void 0), b = b || {};
+ var c, d, e, f, g, h, i, j, k = m.ajaxSetup({}, b), l = k.context || k, n = k.context && (l.nodeType || l.jquery) ? m(l) : m.event, o = m.Deferred(), p = m.Callbacks("once memory"), q = k.statusCode || {}, r = {}, s = {}, t = 0, u = "canceled", v = {
+ readyState: 0,
+ getResponseHeader: function (a) {
+ var b;
+ if (2 === t) {
+ if (!j) {
+ j = {};
+ while (b = Cc.exec(f))j[b[1].toLowerCase()] = b[2]
+ }
+ b = j[a.toLowerCase()]
+ }
+ return null == b ? null : b
+ },
+ getAllResponseHeaders: function () {
+ return 2 === t ? f : null
+ },
+ setRequestHeader: function (a, b) {
+ var c = a.toLowerCase();
+ return t || (a = s[c] = s[c] || a, r[a] = b), this
+ },
+ overrideMimeType: function (a) {
+ return t || (k.mimeType = a), this
+ },
+ statusCode: function (a) {
+ var b;
+ if (a)if (2 > t)for (b in a)q[b] = [q[b], a[b]]; else v.always(a[v.status]);
+ return this
+ },
+ abort: function (a) {
+ var b = a || u;
+ return i && i.abort(b), x(0, b), this
+ }
+ };
+ if (o.promise(v).complete = p.add, v.success = v.done, v.error = v.fail, k.url = ((a || k.url || zc) + "").replace(Ac, "").replace(Fc, yc[1] + "//"), k.type = b.method || b.type || k.method || k.type, k.dataTypes = m.trim(k.dataType || "*").toLowerCase().match(E) || [""], null == k.crossDomain && (c = Gc.exec(k.url.toLowerCase()), k.crossDomain = !(!c || c[1] === yc[1] && c[2] === yc[2] && (c[3] || ("http:" === c[1] ? "80" : "443")) === (yc[3] || ("http:" === yc[1] ? "80" : "443")))), k.data && k.processData && "string" != typeof k.data && (k.data = m.param(k.data, k.traditional)), Mc(Hc, k, b, v), 2 === t)return v;
+ h = k.global, h && 0 === m.active++ && m.event.trigger("ajaxStart"), k.type = k.type.toUpperCase(), k.hasContent = !Ec.test(k.type), e = k.url, k.hasContent || (k.data && (e = k.url += (wc.test(e) ? "&" : "?") + k.data, delete k.data), k.cache === !1 && (k.url = Bc.test(e) ? e.replace(Bc, "$1_=" + vc++) : e + (wc.test(e) ? "&" : "?") + "_=" + vc++)), k.ifModified && (m.lastModified[e] && v.setRequestHeader("If-Modified-Since", m.lastModified[e]), m.etag[e] && v.setRequestHeader("If-None-Match", m.etag[e])), (k.data && k.hasContent && k.contentType !== !1 || b.contentType) && v.setRequestHeader("Content-Type", k.contentType), v.setRequestHeader("Accept", k.dataTypes[0] && k.accepts[k.dataTypes[0]] ? k.accepts[k.dataTypes[0]] + ("*" !== k.dataTypes[0] ? ", " + Jc + "; q=0.01" : "") : k.accepts["*"]);
+ for (d in k.headers)v.setRequestHeader(d, k.headers[d]);
+ if (k.beforeSend && (k.beforeSend.call(l, v, k) === !1 || 2 === t))return v.abort();
+ u = "abort";
+ for (d in{success: 1, error: 1, complete: 1})v[d](k[d]);
+ if (i = Mc(Ic, k, b, v)) {
+ v.readyState = 1, h && n.trigger("ajaxSend", [v, k]), k.async && k.timeout > 0 && (g = setTimeout(function () {
+ v.abort("timeout")
+ }, k.timeout));
+ try {
+ t = 1, i.send(r, x)
+ } catch (w) {
+ if (!(2 > t))throw w;
+ x(-1, w)
+ }
+ } else x(-1, "No Transport");
+ function x(a, b, c, d) {
+ var j, r, s, u, w, x = b;
+ 2 !== t && (t = 2, g && clearTimeout(g), i = void 0, f = d || "", v.readyState = a > 0 ? 4 : 0, j = a >= 200 && 300 > a || 304 === a, c && (u = Oc(k, v, c)), u = Pc(k, u, v, j), j ? (k.ifModified && (w = v.getResponseHeader("Last-Modified"), w && (m.lastModified[e] = w), w = v.getResponseHeader("etag"), w && (m.etag[e] = w)), 204 === a || "HEAD" === k.type ? x = "nocontent" : 304 === a ? x = "notmodified" : (x = u.state, r = u.data, s = u.error, j = !s)) : (s = x, (a || !x) && (x = "error", 0 > a && (a = 0))), v.status = a, v.statusText = (b || x) + "", j ? o.resolveWith(l, [r, x, v]) : o.rejectWith(l, [v, x, s]), v.statusCode(q), q = void 0, h && n.trigger(j ? "ajaxSuccess" : "ajaxError", [v, k, j ? r : s]), p.fireWith(l, [v, x]), h && (n.trigger("ajaxComplete", [v, k]), --m.active || m.event.trigger("ajaxStop")))
+ }
+
+ return v
+ },
+ getJSON: function (a, b, c) {
+ return m.get(a, b, c, "json")
+ },
+ getScript: function (a, b) {
+ return m.get(a, void 0, b, "script")
+ }
+ }), m.each(["get", "post"], function (a, b) {
+ m[b] = function (a, c, d, e) {
+ return m.isFunction(c) && (e = e || d, d = c, c = void 0), m.ajax({
+ url: a,
+ type: b,
+ dataType: e,
+ data: c,
+ success: d
+ })
+ }
+ }), m.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function (a, b) {
+ m.fn[b] = function (a) {
+ return this.on(b, a)
+ }
+ }), m._evalUrl = function (a) {
+ return m.ajax({url: a, type: "GET", dataType: "script", async: !1, global: !1, "throws": !0})
+ }, m.fn.extend({
+ wrapAll: function (a) {
+ if (m.isFunction(a))return this.each(function (b) {
+ m(this).wrapAll(a.call(this, b))
+ });
+ if (this[0]) {
+ var b = m(a, this[0].ownerDocument).eq(0).clone(!0);
+ this[0].parentNode && b.insertBefore(this[0]), b.map(function () {
+ var a = this;
+ while (a.firstChild && 1 === a.firstChild.nodeType)a = a.firstChild;
+ return a
+ }).append(this)
+ }
+ return this
+ }, wrapInner: function (a) {
+ return this.each(m.isFunction(a) ? function (b) {
+ m(this).wrapInner(a.call(this, b))
+ } : function () {
+ var b = m(this), c = b.contents();
+ c.length ? c.wrapAll(a) : b.append(a)
+ })
+ }, wrap: function (a) {
+ var b = m.isFunction(a);
+ return this.each(function (c) {
+ m(this).wrapAll(b ? a.call(this, c) : a)
+ })
+ }, unwrap: function () {
+ return this.parent().each(function () {
+ m.nodeName(this, "body") || m(this).replaceWith(this.childNodes)
+ }).end()
+ }
+ }), m.expr.filters.hidden = function (a) {
+ return a.offsetWidth <= 0 && a.offsetHeight <= 0 || !k.reliableHiddenOffsets() && "none" === (a.style && a.style.display || m.css(a, "display"))
+ }, m.expr.filters.visible = function (a) {
+ return !m.expr.filters.hidden(a)
+ };
+ var Qc = /%20/g, Rc = /\[\]$/, Sc = /\r?\n/g, Tc = /^(?:submit|button|image|reset|file)$/i, Uc = /^(?:input|select|textarea|keygen)/i;
+
+ function Vc(a, b, c, d) {
+ var e;
+ if (m.isArray(b))m.each(b, function (b, e) {
+ c || Rc.test(a) ? d(a, e) : Vc(a + "[" + ("object" == typeof e ? b : "") + "]", e, c, d)
+ }); else if (c || "object" !== m.type(b))d(a, b); else for (e in b)Vc(a + "[" + e + "]", b[e], c, d)
+ }
+
+ m.param = function (a, b) {
+ var c, d = [], e = function (a, b) {
+ b = m.isFunction(b) ? b() : null == b ? "" : b, d[d.length] = encodeURIComponent(a) + "=" + encodeURIComponent(b)
+ };
+ if (void 0 === b && (b = m.ajaxSettings && m.ajaxSettings.traditional), m.isArray(a) || a.jquery && !m.isPlainObject(a))m.each(a, function () {
+ e(this.name, this.value)
+ }); else for (c in a)Vc(c, a[c], b, e);
+ return d.join("&").replace(Qc, "+")
+ }, m.fn.extend({
+ serialize: function () {
+ return m.param(this.serializeArray())
+ }, serializeArray: function () {
+ return this.map(function () {
+ var a = m.prop(this, "elements");
+ return a ? m.makeArray(a) : this
+ }).filter(function () {
+ var a = this.type;
+ return this.name && !m(this).is(":disabled") && Uc.test(this.nodeName) && !Tc.test(a) && (this.checked || !W.test(a))
+ }).map(function (a, b) {
+ var c = m(this).val();
+ return null == c ? null : m.isArray(c) ? m.map(c, function (a) {
+ return {name: b.name, value: a.replace(Sc, "\r\n")}
+ }) : {name: b.name, value: c.replace(Sc, "\r\n")}
+ }).get()
+ }
+ }), m.ajaxSettings.xhr = void 0 !== a.ActiveXObject ? function () {
+ return !this.isLocal && /^(get|post|head|put|delete|options)$/i.test(this.type) && Zc() || $c()
+ } : Zc;
+ var Wc = 0, Xc = {}, Yc = m.ajaxSettings.xhr();
+ a.ActiveXObject && m(a).on("unload", function () {
+ for (var a in Xc)Xc[a](void 0, !0)
+ }), k.cors = !!Yc && "withCredentials"in Yc, Yc = k.ajax = !!Yc, Yc && m.ajaxTransport(function (a) {
+ if (!a.crossDomain || k.cors) {
+ var b;
+ return {
+ send: function (c, d) {
+ var e, f = a.xhr(), g = ++Wc;
+ if (f.open(a.type, a.url, a.async, a.username, a.password), a.xhrFields)for (e in a.xhrFields)f[e] = a.xhrFields[e];
+ a.mimeType && f.overrideMimeType && f.overrideMimeType(a.mimeType), a.crossDomain || c["X-Requested-With"] || (c["X-Requested-With"] = "XMLHttpRequest");
+ for (e in c)void 0 !== c[e] && f.setRequestHeader(e, c[e] + "");
+ f.send(a.hasContent && a.data || null), b = function (c, e) {
+ var h, i, j;
+ if (b && (e || 4 === f.readyState))if (delete Xc[g], b = void 0, f.onreadystatechange = m.noop, e)4 !== f.readyState && f.abort(); else {
+ j = {}, h = f.status, "string" == typeof f.responseText && (j.text = f.responseText);
+ try {
+ i = f.statusText
+ } catch (k) {
+ i = ""
+ }
+ h || !a.isLocal || a.crossDomain ? 1223 === h && (h = 204) : h = j.text ? 200 : 404
+ }
+ j && d(h, i, j, f.getAllResponseHeaders())
+ }, a.async ? 4 === f.readyState ? setTimeout(b) : f.onreadystatechange = Xc[g] = b : b()
+ }, abort: function () {
+ b && b(void 0, !0)
+ }
+ }
+ }
+ });
+ function Zc() {
+ try {
+ return new a.XMLHttpRequest
+ } catch (b) {
+ }
+ }
+
+ function $c() {
+ try {
+ return new a.ActiveXObject("Microsoft.XMLHTTP")
+ } catch (b) {
+ }
+ }
+
+ m.ajaxSetup({
+ accepts: {script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},
+ contents: {script: /(?:java|ecma)script/},
+ converters: {
+ "text script": function (a) {
+ return m.globalEval(a), a
+ }
+ }
+ }), m.ajaxPrefilter("script", function (a) {
+ void 0 === a.cache && (a.cache = !1), a.crossDomain && (a.type = "GET", a.global = !1)
+ }), m.ajaxTransport("script", function (a) {
+ if (a.crossDomain) {
+ var b, c = y.head || m("head")[0] || y.documentElement;
+ return {
+ send: function (d, e) {
+ b = y.createElement("script"), b.async = !0, a.scriptCharset && (b.charset = a.scriptCharset), b.src = a.url, b.onload = b.onreadystatechange = function (a, c) {
+ (c || !b.readyState || /loaded|complete/.test(b.readyState)) && (b.onload = b.onreadystatechange = null, b.parentNode && b.parentNode.removeChild(b), b = null, c || e(200, "success"))
+ }, c.insertBefore(b, c.firstChild)
+ }, abort: function () {
+ b && b.onload(void 0, !0)
+ }
+ }
+ }
+ });
+ var _c = [], ad = /(=)\?(?=&|$)|\?\?/;
+ m.ajaxSetup({
+ jsonp: "callback", jsonpCallback: function () {
+ var a = _c.pop() || m.expando + "_" + vc++;
+ return this[a] = !0, a
+ }
+ }), m.ajaxPrefilter("json jsonp", function (b, c, d) {
+ var e, f, g, h = b.jsonp !== !1 && (ad.test(b.url) ? "url" : "string" == typeof b.data && !(b.contentType || "").indexOf("application/x-www-form-urlencoded") && ad.test(b.data) && "data");
+ return h || "jsonp" === b.dataTypes[0] ? (e = b.jsonpCallback = m.isFunction(b.jsonpCallback) ? b.jsonpCallback() : b.jsonpCallback, h ? b[h] = b[h].replace(ad, "$1" + e) : b.jsonp !== !1 && (b.url += (wc.test(b.url) ? "&" : "?") + b.jsonp + "=" + e), b.converters["script json"] = function () {
+ return g || m.error(e + " was not called"), g[0]
+ }, b.dataTypes[0] = "json", f = a[e], a[e] = function () {
+ g = arguments
+ }, d.always(function () {
+ a[e] = f, b[e] && (b.jsonpCallback = c.jsonpCallback, _c.push(e)), g && m.isFunction(f) && f(g[0]), g = f = void 0
+ }), "script") : void 0
+ }), m.parseHTML = function (a, b, c) {
+ if (!a || "string" != typeof a)return null;
+ "boolean" == typeof b && (c = b, b = !1), b = b || y;
+ var d = u.exec(a), e = !c && [];
+ return d ? [b.createElement(d[1])] : (d = m.buildFragment([a], b, e), e && e.length && m(e).remove(), m.merge([], d.childNodes))
+ };
+ var bd = m.fn.load;
+ m.fn.load = function (a, b, c) {
+ if ("string" != typeof a && bd)return bd.apply(this, arguments);
+ var d, e, f, g = this, h = a.indexOf(" ");
+ return h >= 0 && (d = m.trim(a.slice(h, a.length)), a = a.slice(0, h)), m.isFunction(b) ? (c = b, b = void 0) : b && "object" == typeof b && (f = "POST"), g.length > 0 && m.ajax({
+ url: a,
+ type: f,
+ dataType: "html",
+ data: b
+ }).done(function (a) {
+ e = arguments, g.html(d ? m("").append(m.parseHTML(a)).find(d) : a)
+ }).complete(c && function (a, b) {
+ g.each(c, e || [a.responseText, b, a])
+ }), this
+ }, m.expr.filters.animated = function (a) {
+ return m.grep(m.timers, function (b) {
+ return a === b.elem
+ }).length
+ };
+ var cd = a.document.documentElement;
+
+ function dd(a) {
+ return m.isWindow(a) ? a : 9 === a.nodeType ? a.defaultView || a.parentWindow : !1
+ }
+
+ m.offset = {
+ setOffset: function (a, b, c) {
+ var d, e, f, g, h, i, j, k = m.css(a, "position"), l = m(a), n = {};
+ "static" === k && (a.style.position = "relative"), h = l.offset(), f = m.css(a, "top"), i = m.css(a, "left"), j = ("absolute" === k || "fixed" === k) && m.inArray("auto", [f, i]) > -1, j ? (d = l.position(), g = d.top, e = d.left) : (g = parseFloat(f) || 0, e = parseFloat(i) || 0), m.isFunction(b) && (b = b.call(a, c, h)), null != b.top && (n.top = b.top - h.top + g), null != b.left && (n.left = b.left - h.left + e), "using"in b ? b.using.call(a, n) : l.css(n)
+ }
+ }, m.fn.extend({
+ offset: function (a) {
+ if (arguments.length)return void 0 === a ? this : this.each(function (b) {
+ m.offset.setOffset(this, a, b)
+ });
+ var b, c, d = {top: 0, left: 0}, e = this[0], f = e && e.ownerDocument;
+ if (f)return b = f.documentElement, m.contains(b, e) ? (typeof e.getBoundingClientRect !== K && (d = e.getBoundingClientRect()), c = dd(f), {
+ top: d.top + (c.pageYOffset || b.scrollTop) - (b.clientTop || 0),
+ left: d.left + (c.pageXOffset || b.scrollLeft) - (b.clientLeft || 0)
+ }) : d
+ }, position: function () {
+ if (this[0]) {
+ var a, b, c = {top: 0, left: 0}, d = this[0];
+ return "fixed" === m.css(d, "position") ? b = d.getBoundingClientRect() : (a = this.offsetParent(), b = this.offset(), m.nodeName(a[0], "html") || (c = a.offset()), c.top += m.css(a[0], "borderTopWidth", !0), c.left += m.css(a[0], "borderLeftWidth", !0)), {
+ top: b.top - c.top - m.css(d, "marginTop", !0),
+ left: b.left - c.left - m.css(d, "marginLeft", !0)
+ }
+ }
+ }, offsetParent: function () {
+ return this.map(function () {
+ var a = this.offsetParent || cd;
+ while (a && !m.nodeName(a, "html") && "static" === m.css(a, "position"))a = a.offsetParent;
+ return a || cd
+ })
+ }
+ }), m.each({scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function (a, b) {
+ var c = /Y/.test(b);
+ m.fn[a] = function (d) {
+ return V(this, function (a, d, e) {
+ var f = dd(a);
+ return void 0 === e ? f ? b in f ? f[b] : f.document.documentElement[d] : a[d] : void(f ? f.scrollTo(c ? m(f).scrollLeft() : e, c ? e : m(f).scrollTop()) : a[d] = e)
+ }, a, d, arguments.length, null)
+ }
+ }), m.each(["top", "left"], function (a, b) {
+ m.cssHooks[b] = Lb(k.pixelPosition, function (a, c) {
+ return c ? (c = Jb(a, b), Hb.test(c) ? m(a).position()[b] + "px" : c) : void 0
+ })
+ }), m.each({Height: "height", Width: "width"}, function (a, b) {
+ m.each({padding: "inner" + a, content: b, "": "outer" + a}, function (c, d) {
+ m.fn[d] = function (d, e) {
+ var f = arguments.length && (c || "boolean" != typeof d), g = c || (d === !0 || e === !0 ? "margin" : "border");
+ return V(this, function (b, c, d) {
+ var e;
+ return m.isWindow(b) ? b.document.documentElement["client" + a] : 9 === b.nodeType ? (e = b.documentElement, Math.max(b.body["scroll" + a], e["scroll" + a], b.body["offset" + a], e["offset" + a], e["client" + a])) : void 0 === d ? m.css(b, c, g) : m.style(b, c, d, g)
+ }, b, f ? d : void 0, f, null)
+ }
+ })
+ }), m.fn.size = function () {
+ return this.length
+ }, m.fn.andSelf = m.fn.addBack, "function" == typeof define && define.amd && define("jquery", [], function () {
+ return m
+ });
+ var ed = a.jQuery, fd = a.$;
+ return m.noConflict = function (b) {
+ return a.$ === m && (a.$ = fd), b && a.jQuery === m && (a.jQuery = ed), m
+ }, typeof b === K && (a.jQuery = a.$ = m), m
+});
\ No newline at end of file
diff --git a/sdk/src/third-party/json2.js b/sdk/src/third-party/json2.js
index 30697608..adaffa5f 100644
--- a/sdk/src/third-party/json2.js
+++ b/sdk/src/third-party/json2.js
@@ -1,168 +1,168 @@
/*!
- JSON.org requires the following notice to accompany json2:
+ JSON.org requires the following notice to accompany json2:
- Copyright (c) 2002 JSON.org
+ Copyright (c) 2002 JSON.org
- http://json.org
+ http://json.org
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- The Software shall be used for Good, not Evil.
+ The Software shall be used for Good, not Evil.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- IN THE SOFTWARE.
-*/
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+ */
/*
- This code should be minified before deployment.
- See http://javascript.crockford.com/jsmin.html
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
- NOT CONTROL.
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
- This file creates a global JSON object containing two methods: stringify
- and parse.
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
- JSON.stringify(value, replacer, space)
- value any JavaScript value, usually an object or array.
-
- replacer an optional parameter that determines how object
- values are stringified for objects. It can be a
- function or an array of strings.
-
- space an optional parameter that specifies the indentation
- of nested structures. If it is omitted, the text will
- be packed without extra whitespace. If it is a number,
- it will specify the number of spaces to indent at each
- level. If it is a string (such as '\t' or ' '),
- it contains the characters used to indent at each level.
-
- This method produces a JSON text from a JavaScript value.
-
- When an object value is found, if the object contains a toJSON
- method, its toJSON method will be called and the result will be
- stringified. A toJSON method does not serialize: it returns the
- value represented by the name/value pair that should be serialized,
- or undefined if nothing should be serialized. The toJSON method
- will be passed the key associated with the value, and this will be
- bound to the value
-
- For example, this would serialize Dates as ISO strings.
-
- Date.prototype.toJSON = function (key) {
- function f(n) {
- // Format integers to have at least two digits.
- return n < 10 ? '0' + n : n;
- }
-
- return this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z';
- };
-
- You can provide an optional replacer method. It will be passed the
- key and value of each member, with this bound to the containing
- object. The value that is returned from your method will be
- serialized. If your method returns undefined, then the member will
- be excluded from the serialization.
-
- If the replacer parameter is an array of strings, then it will be
- used to select the members to be serialized. It filters the results
- such that only members with keys listed in the replacer array are
- stringified.
-
- Values that do not have JSON representations, such as undefined or
- functions, will not be serialized. Such values in objects will be
- dropped; in arrays they will be replaced with null. You can use
- a replacer function to replace those with JSON values.
- JSON.stringify(undefined) returns undefined.
-
- The optional space parameter produces a stringification of the
- value that is filled with line breaks and indentation to make it
- easier to read.
-
- If the space parameter is a non-empty string, then that string will
- be used for indentation. If the space parameter is a number, then
- the indentation will be that many spaces.
-
- Example:
-
- text = JSON.stringify(['e', {pluribus: 'unum'}]);
- // text is '["e",{"pluribus":"unum"}]'
-
-
- text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
- // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
-
- text = JSON.stringify([new Date()], function (key, value) {
- return this[key] instanceof Date ?
- 'Date(' + this[key] + ')' : value;
- });
- // text is '["Date(---current time---)"]'
-
-
- JSON.parse(text, reviver)
- This method parses a JSON text to produce an object or array.
- It can throw a SyntaxError exception.
-
- The optional reviver parameter is a function that can filter and
- transform the results. It receives each of the keys and values,
- and its return value is used instead of the original value.
- If it returns what it received, then the structure is not modified.
- If it returns undefined then the member is deleted.
-
- Example:
-
- // Parse the text. Values that look like ISO date strings will
- // be converted to Date objects.
-
- myData = JSON.parse(text, function (key, value) {
- var a;
- if (typeof value === 'string') {
- a =
-/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (a) {
- return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
- +a[5], +a[6]));
- }
- }
- return value;
- });
-
- myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
- var d;
- if (typeof value === 'string' &&
- value.slice(0, 5) === 'Date(' &&
- value.slice(-1) === ')') {
- d = new Date(value.slice(5, -1));
- if (d) {
- return d;
- }
- }
- return value;
- });
-
-
- This is a reference implementation. You are free to copy, modify, or
- redistribute.
-*/
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+ */
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
- call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
- getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
- lastIndex, length, parse, prototype, push, replace, slice, stringify,
- test, toJSON, toString, valueOf
-*/
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+ */
// Create a JSON object only if one does not already exist. We create the
@@ -185,20 +185,20 @@ if (typeof JSON !== 'object') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf())
- ? this.getUTCFullYear() + '-' +
- f(this.getUTCMonth() + 1) + '-' +
- f(this.getUTCDate()) + 'T' +
- f(this.getUTCHours()) + ':' +
- f(this.getUTCMinutes()) + ':' +
- f(this.getUTCSeconds()) + 'Z'
+ ? this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z'
: null;
};
- String.prototype.toJSON =
- Number.prototype.toJSON =
- Boolean.prototype.toJSON = function (key) {
- return this.valueOf();
- };
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -211,7 +211,7 @@ if (typeof JSON !== 'object') {
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
- '"' : '\\"',
+ '"': '\\"',
'\\': '\\\\'
},
rep;
@@ -249,7 +249,7 @@ if (typeof JSON !== 'object') {
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
- typeof value.toJSON === 'function') {
+ typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
@@ -263,102 +263,102 @@ if (typeof JSON !== 'object') {
// What happens next depends on the value's type.
switch (typeof value) {
- case 'string':
- return quote(value);
+ case 'string':
+ return quote(value);
- case 'number':
+ case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
- return isFinite(value) ? String(value) : 'null';
+ return isFinite(value) ? String(value) : 'null';
- case 'boolean':
- case 'null':
+ case 'boolean':
+ case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
- return String(value);
+ return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
- case 'object':
+ case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
- if (!value) {
- return 'null';
- }
+ if (!value) {
+ return 'null';
+ }
// Make an array to hold the partial results of stringifying this object value.
- gap += indent;
- partial = [];
+ gap += indent;
+ partial = [];
// Is the value an array?
- if (Object.prototype.toString.apply(value) === '[object Array]') {
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
- length = value.length;
- for (i = 0; i < length; i += 1) {
- partial[i] = str(i, value) || 'null';
- }
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
- v = partial.length === 0
- ? '[]'
- : gap
- ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
- : '[' + partial.join(',') + ']';
- gap = mind;
- return v;
- }
+ v = partial.length === 0
+ ? '[]'
+ : gap
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+ : '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
// If the replacer is an array, use it to select the members to be stringified.
- if (rep && typeof rep === 'object') {
- length = rep.length;
- for (i = 0; i < length; i += 1) {
- if (typeof rep[i] === 'string') {
- k = rep[i];
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
}
}
- }
- } else {
+ } else {
// Otherwise, iterate through all of the keys in the object.
- for (k in value) {
- if (Object.prototype.hasOwnProperty.call(value, k)) {
- v = str(k, value);
- if (v) {
- partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
}
}
}
- }
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
- v = partial.length === 0
- ? '{}'
- : gap
- ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
- : '{' + partial.join(',') + '}';
- gap = mind;
- return v;
+ v = partial.length === 0
+ ? '{}'
+ : gap
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+ : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
}
}
@@ -396,8 +396,8 @@ if (typeof JSON !== 'object') {
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
- (typeof replacer !== 'object' ||
- typeof replacer.length !== 'number')) {
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
diff --git a/sdk/src/third-party/json3.js b/sdk/src/third-party/json3.js
index d90119aa..14ca6457 100644
--- a/sdk/src/third-party/json3.js
+++ b/sdk/src/third-party/json3.js
@@ -1,767 +1,771 @@
/*! JSON v3.2.3 | http://bestiejs.github.com/json3 | Copyright 2012, Kit Cambridge | http://kit.mit-license.org */
-;(function () {
- // Convenience aliases.
- var getClass = {}.toString, isProperty, forEach, undef;
+;
+(function () {
+ // Convenience aliases.
+ var getClass = {}.toString, isProperty, forEach, undef;
- // Detect the `define` function exposed by asynchronous module loaders and set
- // up the internal `JSON3` namespace. The strict equality check for `define`
- // is necessary for compatibility with the RequireJS optimizer (`r.js`).
- var isLoader = typeof define === "function" && define.amd, JSON3 = typeof exports == "object" && exports;
+ // Detect the `define` function exposed by asynchronous module loaders and set
+ // up the internal `JSON3` namespace. The strict equality check for `define`
+ // is necessary for compatibility with the RequireJS optimizer (`r.js`).
+ var isLoader = typeof define === "function" && define.amd, JSON3 = typeof exports == "object" && exports;
- // A JSON source string used to test the native `stringify` and `parse`
- // implementations.
- var serialized = '{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
+ // A JSON source string used to test the native `stringify` and `parse`
+ // implementations.
+ var serialized = '{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
- // Feature tests to determine whether the native `JSON.stringify` and `parse`
- // implementations are spec-compliant. Based on work by Ken Snyder.
- var stringifySupported, Escapes, toPaddedString, quote, serialize;
- var parseSupported, fromCharCode, Unescapes, abort, lex, get, walk, update, Index, Source;
+ // Feature tests to determine whether the native `JSON.stringify` and `parse`
+ // implementations are spec-compliant. Based on work by Ken Snyder.
+ var stringifySupported, Escapes, toPaddedString, quote, serialize;
+ var parseSupported, fromCharCode, Unescapes, abort, lex, get, walk, update, Index, Source;
- // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
- var value = new Date(-3509827334573292), floor, Months, getDay;
+ // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
+ var value = new Date(-3509827334573292), floor, Months, getDay;
- try {
- // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
- // results for certain dates in Opera >= 10.53.
- value = value.getUTCFullYear() == -109252 && value.getUTCMonth() === 0 && value.getUTCDate() == 1 &&
- // Safari < 2.0.2 stores the internal millisecond time value correctly,
- // but clips the values returned by the date methods to the range of
- // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
- value.getUTCHours() == 10 && value.getUTCMinutes() == 37 && value.getUTCSeconds() == 6 && value.getUTCMilliseconds() == 708;
- } catch (exception) {}
-
- // Define additional utility methods if the `Date` methods are buggy.
- if (!value) {
- floor = Math.floor;
- // A mapping between the months of the year and the number of days between
- // January 1st and the first of the respective month.
- Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
- // Internal: Calculates the number of days between the Unix epoch and the
- // first day of the given month.
- getDay = function (year, month) {
- return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
- };
- }
-
- // Export JSON 3 for asynchronous module loaders, CommonJS environments, web
- // browsers, and JavaScript engines. Credits: Oyvind Sean Kinsey.
- if (isLoader || JSON3) {
- if (isLoader) {
- // Export for asynchronous module loaders. The `JSON3` namespace is
- // redefined because module loaders do not provide the `exports` object.
- define("json", (JSON3 = {}));
- }
- if (typeof JSON == "object" && JSON) {
- // Delegate to the native `stringify` and `parse` implementations in
- // asynchronous module loaders and CommonJS environments.
- JSON3.stringify = JSON.stringify;
- JSON3.parse = JSON.parse;
- }
- } else {
- // Export for browsers and JavaScript engines.
- JSON3 = this.JSON || (this.JSON = {});
- }
-
- // Test `JSON.stringify`.
- if ((stringifySupported = typeof JSON3.stringify == "function" && !getDay)) {
- // A test function object with a custom `toJSON` method.
- (value = function () {
- return 1;
- }).toJSON = value;
try {
- stringifySupported =
- // Firefox 3.1b1 and b2 serialize string, number, and boolean
- // primitives as object literals.
- JSON3.stringify(0) === "0" &&
- // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
- // literals.
- JSON3.stringify(new Number()) === "0" &&
- JSON3.stringify(new String()) == '""' &&
- // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
- // does not define a canonical JSON representation (this applies to
- // objects with `toJSON` properties as well, *unless* they are nested
- // within an object or array).
- JSON3.stringify(getClass) === undef &&
- // IE 8 serializes `undefined` as `"undefined"`. Safari 5.1.2 and FF
- // 3.1b3 pass this test.
- JSON3.stringify(undef) === undef &&
- // Safari 5.1.2 and FF 3.1b3 throw `Error`s and `TypeError`s,
- // respectively, if the value is omitted entirely.
- JSON3.stringify() === undef &&
- // FF 3.1b1, 2 throw an error if the given value is not a number,
- // string, array, object, Boolean, or `null` literal. This applies to
- // objects with custom `toJSON` methods as well, unless they are nested
- // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
- // methods entirely.
- JSON3.stringify(value) === "1" &&
- JSON3.stringify([value]) == "[1]" &&
- // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
- // `"[null]"`.
- JSON3.stringify([undef]) == "[null]" &&
- // YUI 3.0.0b1 fails to serialize `null` literals.
- JSON3.stringify(null) == "null" &&
- // FF 3.1b1, 2 halts serialization if an array contains a function:
- // `[1, true, getClass, 1]` serializes as "[1,true,],". These versions
- // of Firefox also allow trailing commas in JSON objects and arrays.
- // FF 3.1b3 elides non-JSON values from objects and arrays, unless they
- // define custom `toJSON` methods.
- JSON3.stringify([undef, getClass, null]) == "[null,null,null]" &&
- // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
- // where character escape codes are expected (e.g., `\b` => `\u0008`).
- JSON3.stringify({ "result": [value, true, false, null, "\0\b\n\f\r\t"] }) == serialized &&
- // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
- JSON3.stringify(null, value) === "1" &&
- JSON3.stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
- // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
- // serialize extended years.
- JSON3.stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
- // The milliseconds are optional in ES 5, but required in 5.1.
- JSON3.stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
- // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
- // four-digit years instead of six-digit years. Credits: @Yaffle.
- JSON3.stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
- // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
- // values less than 1000. Credits: @Yaffle.
- JSON3.stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
+ // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
+ // results for certain dates in Opera >= 10.53.
+ value = value.getUTCFullYear() == -109252 && value.getUTCMonth() === 0 && value.getUTCDate() == 1 &&
+ // Safari < 2.0.2 stores the internal millisecond time value correctly,
+ // but clips the values returned by the date methods to the range of
+ // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
+ value.getUTCHours() == 10 && value.getUTCMinutes() == 37 && value.getUTCSeconds() == 6 && value.getUTCMilliseconds() == 708;
} catch (exception) {
- stringifySupported = false;
}
- }
- // Test `JSON.parse`.
- if (typeof JSON3.parse == "function") {
- try {
- // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
- // Conforming implementations should also coerce the initial argument to
- // a string prior to parsing.
- if (JSON3.parse("0") === 0 && !JSON3.parse(false)) {
- // Simple parsing test.
- value = JSON3.parse(serialized);
- if ((parseSupported = value.A.length == 5 && value.A[0] == 1)) {
- try {
- // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
- parseSupported = !JSON3.parse('"\t"');
- } catch (exception) {}
- if (parseSupported) {
- try {
- // FF 4.0 and 4.0.1 allow leading `+` signs, and leading and
- // trailing decimal points. FF 4.0, 4.0.1, and IE 9 also allow
- // certain octal literals.
- parseSupported = JSON3.parse("01") != 1;
- } catch (exception) {}
- }
- }
- }
- } catch (exception) {
- parseSupported = false;
+ // Define additional utility methods if the `Date` methods are buggy.
+ if (!value) {
+ floor = Math.floor;
+ // A mapping between the months of the year and the number of days between
+ // January 1st and the first of the respective month.
+ Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
+ // Internal: Calculates the number of days between the Unix epoch and the
+ // first day of the given month.
+ getDay = function (year, month) {
+ return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
+ };
}
- }
- // Clean up the variables used for the feature tests.
- value = serialized = null;
+ // Export JSON 3 for asynchronous module loaders, CommonJS environments, web
+ // browsers, and JavaScript engines. Credits: Oyvind Sean Kinsey.
+ if (isLoader || JSON3) {
+ if (isLoader) {
+ // Export for asynchronous module loaders. The `JSON3` namespace is
+ // redefined because module loaders do not provide the `exports` object.
+ define("json", (JSON3 = {}));
+ }
+ if (typeof JSON == "object" && JSON) {
+ // Delegate to the native `stringify` and `parse` implementations in
+ // asynchronous module loaders and CommonJS environments.
+ JSON3.stringify = JSON.stringify;
+ JSON3.parse = JSON.parse;
+ }
+ } else {
+ // Export for browsers and JavaScript engines.
+ JSON3 = this.JSON || (this.JSON = {});
+ }
- if (!stringifySupported || !parseSupported) {
- // Internal: Determines if a property is a direct property of the given
- // object. Delegates to the native `Object#hasOwnProperty` method.
- if (!(isProperty = {}.hasOwnProperty)) {
- isProperty = function (property) {
- var members = {}, constructor;
- if ((members.__proto__ = null, members.__proto__ = {
- // The *proto* property cannot be set multiple times in recent
- // versions of Firefox and SeaMonkey.
- "toString": 1
- }, members).toString != getClass) {
- // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
- // supports the mutable *proto* property.
- isProperty = function (property) {
- // Capture and break the object's prototype chain (see section 8.6.2
- // of the ES 5.1 spec). The parenthesized expression prevents an
- // unsafe transformation by the Closure Compiler.
- var original = this.__proto__, result = property in (this.__proto__ = null, this);
- // Restore the original prototype chain.
- this.__proto__ = original;
- return result;
- };
- } else {
- // Capture a reference to the top-level `Object` constructor.
- constructor = members.constructor;
- // Use the `constructor` property to simulate `Object#hasOwnProperty` in
- // other environments.
- isProperty = function (property) {
- var parent = (this.constructor || constructor).prototype;
- return property in this && !(property in parent && this[property] === parent[property]);
- };
+ // Test `JSON.stringify`.
+ if ((stringifySupported = typeof JSON3.stringify == "function" && !getDay)) {
+ // A test function object with a custom `toJSON` method.
+ (value = function () {
+ return 1;
+ }).toJSON = value;
+ try {
+ stringifySupported =
+ // Firefox 3.1b1 and b2 serialize string, number, and boolean
+ // primitives as object literals.
+ JSON3.stringify(0) === "0" &&
+ // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
+ // literals.
+ JSON3.stringify(new Number()) === "0" &&
+ JSON3.stringify(new String()) == '""' &&
+ // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
+ // does not define a canonical JSON representation (this applies to
+ // objects with `toJSON` properties as well, *unless* they are nested
+ // within an object or array).
+ JSON3.stringify(getClass) === undef &&
+ // IE 8 serializes `undefined` as `"undefined"`. Safari 5.1.2 and FF
+ // 3.1b3 pass this test.
+ JSON3.stringify(undef) === undef &&
+ // Safari 5.1.2 and FF 3.1b3 throw `Error`s and `TypeError`s,
+ // respectively, if the value is omitted entirely.
+ JSON3.stringify() === undef &&
+ // FF 3.1b1, 2 throw an error if the given value is not a number,
+ // string, array, object, Boolean, or `null` literal. This applies to
+ // objects with custom `toJSON` methods as well, unless they are nested
+ // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
+ // methods entirely.
+ JSON3.stringify(value) === "1" &&
+ JSON3.stringify([value]) == "[1]" &&
+ // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
+ // `"[null]"`.
+ JSON3.stringify([undef]) == "[null]" &&
+ // YUI 3.0.0b1 fails to serialize `null` literals.
+ JSON3.stringify(null) == "null" &&
+ // FF 3.1b1, 2 halts serialization if an array contains a function:
+ // `[1, true, getClass, 1]` serializes as "[1,true,],". These versions
+ // of Firefox also allow trailing commas in JSON objects and arrays.
+ // FF 3.1b3 elides non-JSON values from objects and arrays, unless they
+ // define custom `toJSON` methods.
+ JSON3.stringify([undef, getClass, null]) == "[null,null,null]" &&
+ // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
+ // where character escape codes are expected (e.g., `\b` => `\u0008`).
+ JSON3.stringify({"result": [value, true, false, null, "\0\b\n\f\r\t"]}) == serialized &&
+ // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
+ JSON3.stringify(null, value) === "1" &&
+ JSON3.stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
+ // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
+ // serialize extended years.
+ JSON3.stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
+ // The milliseconds are optional in ES 5, but required in 5.1.
+ JSON3.stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
+ // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
+ // four-digit years instead of six-digit years. Credits: @Yaffle.
+ JSON3.stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
+ // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
+ // values less than 1000. Credits: @Yaffle.
+ JSON3.stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
+ } catch (exception) {
+ stringifySupported = false;
}
- members = null;
- return isProperty.call(this, property);
- };
}
- // Internal: Normalizes the `for...in` iteration algorithm across
- // environments. Each enumerated key is yielded to a `callback` function.
- forEach = function (object, callback) {
- var size = 0, Properties, members, property, forEach;
+ // Test `JSON.parse`.
+ if (typeof JSON3.parse == "function") {
+ try {
+ // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
+ // Conforming implementations should also coerce the initial argument to
+ // a string prior to parsing.
+ if (JSON3.parse("0") === 0 && !JSON3.parse(false)) {
+ // Simple parsing test.
+ value = JSON3.parse(serialized);
+ if ((parseSupported = value.A.length == 5 && value.A[0] == 1)) {
+ try {
+ // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
+ parseSupported = !JSON3.parse('"\t"');
+ } catch (exception) {
+ }
+ if (parseSupported) {
+ try {
+ // FF 4.0 and 4.0.1 allow leading `+` signs, and leading and
+ // trailing decimal points. FF 4.0, 4.0.1, and IE 9 also allow
+ // certain octal literals.
+ parseSupported = JSON3.parse("01") != 1;
+ } catch (exception) {
+ }
+ }
+ }
+ }
+ } catch (exception) {
+ parseSupported = false;
+ }
+ }
- // Tests for bugs in the current environment's `for...in` algorithm. The
- // `valueOf` property inherits the non-enumerable flag from
- // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
- (Properties = function () {
- this.valueOf = 0;
- }).prototype.valueOf = 0;
+ // Clean up the variables used for the feature tests.
+ value = serialized = null;
- // Iterate over a new instance of the `Properties` class.
- members = new Properties();
- for (property in members) {
- // Ignore all properties inherited from `Object.prototype`.
- if (isProperty.call(members, property)) {
- size++;
+ if (!stringifySupported || !parseSupported) {
+ // Internal: Determines if a property is a direct property of the given
+ // object. Delegates to the native `Object#hasOwnProperty` method.
+ if (!(isProperty = {}.hasOwnProperty)) {
+ isProperty = function (property) {
+ var members = {}, constructor;
+ if ((members.__proto__ = null, members.__proto__ = {
+ // The *proto* property cannot be set multiple times in recent
+ // versions of Firefox and SeaMonkey.
+ "toString": 1
+ }, members).toString != getClass) {
+ // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
+ // supports the mutable *proto* property.
+ isProperty = function (property) {
+ // Capture and break the object's prototype chain (see section 8.6.2
+ // of the ES 5.1 spec). The parenthesized expression prevents an
+ // unsafe transformation by the Closure Compiler.
+ var original = this.__proto__, result = property in (this.__proto__ = null, this);
+ // Restore the original prototype chain.
+ this.__proto__ = original;
+ return result;
+ };
+ } else {
+ // Capture a reference to the top-level `Object` constructor.
+ constructor = members.constructor;
+ // Use the `constructor` property to simulate `Object#hasOwnProperty` in
+ // other environments.
+ isProperty = function (property) {
+ var parent = (this.constructor || constructor).prototype;
+ return property in this && !(property in parent && this[property] === parent[property]);
+ };
+ }
+ members = null;
+ return isProperty.call(this, property);
+ };
}
- }
- Properties = members = null;
- // Normalize the iteration algorithm.
- if (!size) {
- // A list of non-enumerable properties inherited from `Object.prototype`.
- members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
- // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
- // properties.
- forEach = function (object, callback) {
- var isFunction = getClass.call(object) == "[object Function]", property, length;
- for (property in object) {
- // Gecko <= 1.0 enumerates the `prototype` property of functions under
- // certain conditions; IE does not.
- if (!(isFunction && property == "prototype") && isProperty.call(object, property)) {
- callback(property);
- }
- }
- // Manually invoke the callback for each non-enumerable property.
- for (length = members.length; property = members[--length]; isProperty.call(object, property) && callback(property));
- };
- } else if (size == 2) {
- // Safari <= 2.0.4 enumerates shadowed properties twice.
- forEach = function (object, callback) {
- // Create a set of iterated properties.
- var members = {}, isFunction = getClass.call(object) == "[object Function]", property;
- for (property in object) {
- // Store each property name to prevent double enumeration. The
- // `prototype` property of functions is not enumerated due to cross-
- // environment inconsistencies.
- if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
- callback(property);
- }
- }
- };
- } else {
- // No bugs detected; use the standard `for...in` algorithm.
+ // Internal: Normalizes the `for...in` iteration algorithm across
+ // environments. Each enumerated key is yielded to a `callback` function.
forEach = function (object, callback) {
- var isFunction = getClass.call(object) == "[object Function]", property, isConstructor;
- for (property in object) {
- if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
- callback(property);
- }
- }
- // Manually invoke the callback for the `constructor` property due to
- // cross-environment inconsistencies.
- if (isConstructor || isProperty.call(object, (property = "constructor"))) {
- callback(property);
- }
- };
- }
- return forEach(object, callback);
- };
+ var size = 0, Properties, members, property, forEach;
- // Public: Serializes a JavaScript `value` as a JSON string. The optional
- // `filter` argument may specify either a function that alters how object and
- // array members are serialized, or an array of strings and numbers that
- // indicates which properties should be serialized. The optional `width`
- // argument may be either a string or number that specifies the indentation
- // level of the output.
- if (!stringifySupported) {
- // Internal: A map of control characters and their escaped equivalents.
- Escapes = {
- "\\": "\\\\",
- '"': '\\"',
- "\b": "\\b",
- "\f": "\\f",
- "\n": "\\n",
- "\r": "\\r",
- "\t": "\\t"
- };
+ // Tests for bugs in the current environment's `for...in` algorithm. The
+ // `valueOf` property inherits the non-enumerable flag from
+ // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
+ (Properties = function () {
+ this.valueOf = 0;
+ }).prototype.valueOf = 0;
- // Internal: Converts `value` into a zero-padded string such that its
- // length is at least equal to `width`. The `width` must be <= 6.
- toPaddedString = function (width, value) {
- // The `|| 0` expression is necessary to work around a bug in
- // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
- return ("000000" + (value || 0)).slice(-width);
- };
-
- // Internal: Double-quotes a string `value`, replacing all ASCII control
- // characters (characters with code unit values between 0 and 31) with
- // their escaped equivalents. This is an implementation of the
- // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
- quote = function (value) {
- var result = '"', index = 0, symbol;
- for (; symbol = value.charAt(index); index++) {
- // Escape the reverse solidus, double quote, backspace, form feed, line
- // feed, carriage return, and tab characters.
- result += '\\"\b\f\n\r\t'.indexOf(symbol) > -1 ? Escapes[symbol] :
- // If the character is a control character, append its Unicode escape
- // sequence; otherwise, append the character as-is.
- symbol < " " ? "\\u00" + toPaddedString(2, symbol.charCodeAt(0).toString(16)) : symbol;
- }
- return result + '"';
- };
+ // Iterate over a new instance of the `Properties` class.
+ members = new Properties();
+ for (property in members) {
+ // Ignore all properties inherited from `Object.prototype`.
+ if (isProperty.call(members, property)) {
+ size++;
+ }
+ }
+ Properties = members = null;
- // Internal: Recursively serializes an object. Implements the
- // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
- serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
- var value = object[property], className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, any;
- if (typeof value == "object" && value) {
- className = getClass.call(value);
- if (className == "[object Date]" && !isProperty.call(value, "toJSON")) {
- if (value > -1 / 0 && value < 1 / 0) {
- // Dates are serialized according to the `Date#toJSON` method
- // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
- // for the ISO 8601 date time string format.
- if (getDay) {
- // Manually compute the year, month, date, hours, minutes,
- // seconds, and milliseconds if the `getUTC*` methods are
- // buggy. Adapted from @Yaffle's `date-shim` project.
- date = floor(value / 864e5);
- for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
- for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
- date = 1 + date - getDay(year, month);
- // The `time` value specifies the time within the day (see ES
- // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
- // to compute `A modulo B`, as the `%` operator does not
- // correspond to the `modulo` operation for negative numbers.
- time = (value % 864e5 + 864e5) % 864e5;
- // The hours, minutes, seconds, and milliseconds are obtained by
- // decomposing the time within the day. See section 15.9.1.10.
- hours = floor(time / 36e5) % 24;
- minutes = floor(time / 6e4) % 60;
- seconds = floor(time / 1e3) % 60;
- milliseconds = time % 1e3;
- } else {
- year = value.getUTCFullYear();
- month = value.getUTCMonth();
- date = value.getUTCDate();
- hours = value.getUTCHours();
- minutes = value.getUTCMinutes();
- seconds = value.getUTCSeconds();
- milliseconds = value.getUTCMilliseconds();
- }
- // Serialize extended years correctly.
- value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
- "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
- // Months, dates, hours, minutes, and seconds should have two
- // digits; milliseconds should have three.
- "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
- // Milliseconds are optional in ES 5.0, but required in 5.1.
- "." + toPaddedString(3, milliseconds) + "Z";
+ // Normalize the iteration algorithm.
+ if (!size) {
+ // A list of non-enumerable properties inherited from `Object.prototype`.
+ members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
+ // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
+ // properties.
+ forEach = function (object, callback) {
+ var isFunction = getClass.call(object) == "[object Function]", property, length;
+ for (property in object) {
+ // Gecko <= 1.0 enumerates the `prototype` property of functions under
+ // certain conditions; IE does not.
+ if (!(isFunction && property == "prototype") && isProperty.call(object, property)) {
+ callback(property);
+ }
+ }
+ // Manually invoke the callback for each non-enumerable property.
+ for (length = members.length; property = members[--length]; isProperty.call(object, property) && callback(property));
+ };
+ } else if (size == 2) {
+ // Safari <= 2.0.4 enumerates shadowed properties twice.
+ forEach = function (object, callback) {
+ // Create a set of iterated properties.
+ var members = {}, isFunction = getClass.call(object) == "[object Function]", property;
+ for (property in object) {
+ // Store each property name to prevent double enumeration. The
+ // `prototype` property of functions is not enumerated due to cross-
+ // environment inconsistencies.
+ if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
+ callback(property);
+ }
+ }
+ };
} else {
- value = null;
- }
- } else if (typeof value.toJSON == "function" && ((className != "[object Number]" && className != "[object String]" && className != "[object Array]") || isProperty.call(value, "toJSON"))) {
- // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
- // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
- // ignores all `toJSON` methods on these objects unless they are
- // defined directly on an instance.
- value = value.toJSON(property);
- }
- }
- if (callback) {
- // If a replacement function was provided, call it to obtain the value
- // for serialization.
- value = callback.call(object, property, value);
- }
- if (value === null) {
- return "null";
- }
- className = getClass.call(value);
- if (className == "[object Boolean]") {
- // Booleans are represented literally.
- return "" + value;
- } else if (className == "[object Number]") {
- // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
- // `"null"`.
- return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
- } else if (className == "[object String]") {
- // Strings are double-quoted and escaped.
- return quote(value);
- }
- // Recursively serialize objects and arrays.
- if (typeof value == "object") {
- // Check for cyclic structures. This is a linear search; performance
- // is inversely proportional to the number of unique nested objects.
- for (length = stack.length; length--;) {
- if (stack[length] === value) {
- // Cyclic structures cannot be serialized by `JSON.stringify`.
- throw TypeError();
- }
- }
- // Add the object to the stack of traversed objects.
- stack.push(value);
- results = [];
- // Save the current indentation level and indent one additional level.
- prefix = indentation;
- indentation += whitespace;
- if (className == "[object Array]") {
- // Recursively serialize array elements.
- for (index = 0, length = value.length; index < length; any || (any = true), index++) {
- element = serialize(index, value, callback, properties, whitespace, indentation, stack);
- results.push(element === undef ? "null" : element);
+ // No bugs detected; use the standard `for...in` algorithm.
+ forEach = function (object, callback) {
+ var isFunction = getClass.call(object) == "[object Function]", property, isConstructor;
+ for (property in object) {
+ if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
+ callback(property);
+ }
+ }
+ // Manually invoke the callback for the `constructor` property due to
+ // cross-environment inconsistencies.
+ if (isConstructor || isProperty.call(object, (property = "constructor"))) {
+ callback(property);
+ }
+ };
}
- return any ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
- } else {
- // Recursively serialize object members. Members are selected from
- // either a user-specified list of property names, or the object
- // itself.
- forEach(properties || value, function (property) {
- var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
- if (element !== undef) {
- // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
- // is not the empty string, let `member` {quote(property) + ":"}
- // be the concatenation of `member` and the `space` character."
- // The "`space` character" refers to the literal space
- // character, not the `space` {width} argument provided to
- // `JSON.stringify`.
- results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
- }
- any || (any = true);
- });
- return any ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
- }
- // Remove the object from the traversed object stack.
- stack.pop();
- }
- };
+ return forEach(object, callback);
+ };
- // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
- JSON3.stringify = function (source, filter, width) {
- var whitespace, callback, properties, index, length, value;
- if (typeof filter == "function" || typeof filter == "object" && filter) {
- if (getClass.call(filter) == "[object Function]") {
- callback = filter;
- } else if (getClass.call(filter) == "[object Array]") {
- // Convert the property names array into a makeshift set.
- properties = {};
- for (index = 0, length = filter.length; index < length; value = filter[index++], ((getClass.call(value) == "[object String]" || getClass.call(value) == "[object Number]") && (properties[value] = 1)));
- }
- }
- if (width) {
- if (getClass.call(width) == "[object Number]") {
- // Convert the `width` to an integer and create a string containing
- // `width` number of space characters.
- if ((width -= width % 1) > 0) {
- for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
- }
- } else if (getClass.call(width) == "[object String]") {
- whitespace = width.length <= 10 ? width : width.slice(0, 10);
- }
- }
- // Opera <= 7.54u2 discards the values associated with empty string keys
- // (`""`) only if they are used directly within an object member list
- // (e.g., `!("" in { "": 1})`).
- return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
- };
- }
+ // Public: Serializes a JavaScript `value` as a JSON string. The optional
+ // `filter` argument may specify either a function that alters how object and
+ // array members are serialized, or an array of strings and numbers that
+ // indicates which properties should be serialized. The optional `width`
+ // argument may be either a string or number that specifies the indentation
+ // level of the output.
+ if (!stringifySupported) {
+ // Internal: A map of control characters and their escaped equivalents.
+ Escapes = {
+ "\\": "\\\\",
+ '"': '\\"',
+ "\b": "\\b",
+ "\f": "\\f",
+ "\n": "\\n",
+ "\r": "\\r",
+ "\t": "\\t"
+ };
- // Public: Parses a JSON source string.
- if (!parseSupported) {
- fromCharCode = String.fromCharCode;
- // Internal: A map of escaped control characters and their unescaped
- // equivalents.
- Unescapes = {
- "\\": "\\",
- '"': '"',
- "/": "/",
- "b": "\b",
- "t": "\t",
- "n": "\n",
- "f": "\f",
- "r": "\r"
- };
+ // Internal: Converts `value` into a zero-padded string such that its
+ // length is at least equal to `width`. The `width` must be <= 6.
+ toPaddedString = function (width, value) {
+ // The `|| 0` expression is necessary to work around a bug in
+ // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
+ return ("000000" + (value || 0)).slice(-width);
+ };
- // Internal: Resets the parser state and throws a `SyntaxError`.
- abort = function() {
- Index = Source = null;
- throw SyntaxError();
- };
+ // Internal: Double-quotes a string `value`, replacing all ASCII control
+ // characters (characters with code unit values between 0 and 31) with
+ // their escaped equivalents. This is an implementation of the
+ // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
+ quote = function (value) {
+ var result = '"', index = 0, symbol;
+ for (; symbol = value.charAt(index); index++) {
+ // Escape the reverse solidus, double quote, backspace, form feed, line
+ // feed, carriage return, and tab characters.
+ result += '\\"\b\f\n\r\t'.indexOf(symbol) > -1 ? Escapes[symbol] :
+ // If the character is a control character, append its Unicode escape
+ // sequence; otherwise, append the character as-is.
+ symbol < " " ? "\\u00" + toPaddedString(2, symbol.charCodeAt(0).toString(16)) : symbol;
+ }
+ return result + '"';
+ };
- // Internal: Returns the next token, or `"$"` if the parser has reached
- // the end of the source string. A token may be a string, number, `null`
- // literal, or Boolean literal.
- lex = function () {
- var source = Source, length = source.length, symbol, value, begin, position, sign;
- while (Index < length) {
- symbol = source.charAt(Index);
- if ("\t\r\n ".indexOf(symbol) > -1) {
- // Skip whitespace tokens, including tabs, carriage returns, line
- // feeds, and space characters.
- Index++;
- } else if ("{}[]:,".indexOf(symbol) > -1) {
- // Parse a punctuator token at the current position.
- Index++;
- return symbol;
- } else if (symbol == '"') {
- // Advance to the next character and parse a JSON string at the
- // current position. String tokens are prefixed with the sentinel
- // `@` character to distinguish them from punctuators.
- for (value = "@", Index++; Index < length;) {
- symbol = source.charAt(Index);
- if (symbol < " ") {
- // Unescaped ASCII control characters are not permitted.
- abort();
- } else if (symbol == "\\") {
- // Parse escaped JSON control characters, `"`, `\`, `/`, and
- // Unicode escape sequences.
- symbol = source.charAt(++Index);
- if ('\\"/btnfr'.indexOf(symbol) > -1) {
- // Revive escaped control characters.
- value += Unescapes[symbol];
- Index++;
- } else if (symbol == "u") {
- // Advance to the first character of the escape sequence.
- begin = ++Index;
- // Validate the Unicode escape sequence.
- for (position = Index + 4; Index < position; Index++) {
- symbol = source.charAt(Index);
- // A valid sequence comprises four hexdigits that form a
- // single hexadecimal value.
- if (!(symbol >= "0" && symbol <= "9" || symbol >= "a" && symbol <= "f" || symbol >= "A" && symbol <= "F")) {
- // Invalid Unicode escape sequence.
- abort();
+ // Internal: Recursively serializes an object. Implements the
+ // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
+ serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
+ var value = object[property], className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, any;
+ if (typeof value == "object" && value) {
+ className = getClass.call(value);
+ if (className == "[object Date]" && !isProperty.call(value, "toJSON")) {
+ if (value > -1 / 0 && value < 1 / 0) {
+ // Dates are serialized according to the `Date#toJSON` method
+ // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
+ // for the ISO 8601 date time string format.
+ if (getDay) {
+ // Manually compute the year, month, date, hours, minutes,
+ // seconds, and milliseconds if the `getUTC*` methods are
+ // buggy. Adapted from @Yaffle's `date-shim` project.
+ date = floor(value / 864e5);
+ for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
+ for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
+ date = 1 + date - getDay(year, month);
+ // The `time` value specifies the time within the day (see ES
+ // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
+ // to compute `A modulo B`, as the `%` operator does not
+ // correspond to the `modulo` operation for negative numbers.
+ time = (value % 864e5 + 864e5) % 864e5;
+ // The hours, minutes, seconds, and milliseconds are obtained by
+ // decomposing the time within the day. See section 15.9.1.10.
+ hours = floor(time / 36e5) % 24;
+ minutes = floor(time / 6e4) % 60;
+ seconds = floor(time / 1e3) % 60;
+ milliseconds = time % 1e3;
+ } else {
+ year = value.getUTCFullYear();
+ month = value.getUTCMonth();
+ date = value.getUTCDate();
+ hours = value.getUTCHours();
+ minutes = value.getUTCMinutes();
+ seconds = value.getUTCSeconds();
+ milliseconds = value.getUTCMilliseconds();
+ }
+ // Serialize extended years correctly.
+ value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
+ "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
+ // Months, dates, hours, minutes, and seconds should have two
+ // digits; milliseconds should have three.
+ "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
+ // Milliseconds are optional in ES 5.0, but required in 5.1.
+ "." + toPaddedString(3, milliseconds) + "Z";
+ } else {
+ value = null;
+ }
+ } else if (typeof value.toJSON == "function" && ((className != "[object Number]" && className != "[object String]" && className != "[object Array]") || isProperty.call(value, "toJSON"))) {
+ // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
+ // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
+ // ignores all `toJSON` methods on these objects unless they are
+ // defined directly on an instance.
+ value = value.toJSON(property);
}
- }
- // Revive the escaped character.
- value += fromCharCode("0x" + source.slice(begin, Index));
- } else {
- // Invalid escape sequence.
- abort();
}
- } else {
- if (symbol == '"') {
- // An unescaped double-quote character marks the end of the
- // string.
- break;
+ if (callback) {
+ // If a replacement function was provided, call it to obtain the value
+ // for serialization.
+ value = callback.call(object, property, value);
}
- // Append the original character as-is.
- value += symbol;
- Index++;
- }
- }
- if (source.charAt(Index) == '"') {
- Index++;
- // Return the revived string.
- return value;
- }
- // Unterminated string.
- abort();
- } else {
- // Parse numbers and literals.
- begin = Index;
- // Advance the scanner's position past the sign, if one is
- // specified.
- if (symbol == "-") {
- sign = true;
- symbol = source.charAt(++Index);
- }
- // Parse an integer or floating-point value.
- if (symbol >= "0" && symbol <= "9") {
- // Leading zeroes are interpreted as octal literals.
- if (symbol == "0" && (symbol = source.charAt(Index + 1), symbol >= "0" && symbol <= "9")) {
- // Illegal octal literal.
- abort();
- }
- sign = false;
- // Parse the integer component.
- for (; Index < length && (symbol = source.charAt(Index), symbol >= "0" && symbol <= "9"); Index++);
- // Floats cannot contain a leading decimal point; however, this
- // case is already accounted for by the parser.
- if (source.charAt(Index) == ".") {
- position = ++Index;
- // Parse the decimal component.
- for (; position < length && (symbol = source.charAt(position), symbol >= "0" && symbol <= "9"); position++);
- if (position == Index) {
- // Illegal trailing decimal.
- abort();
+ if (value === null) {
+ return "null";
+ }
+ className = getClass.call(value);
+ if (className == "[object Boolean]") {
+ // Booleans are represented literally.
+ return "" + value;
+ } else if (className == "[object Number]") {
+ // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
+ // `"null"`.
+ return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
+ } else if (className == "[object String]") {
+ // Strings are double-quoted and escaped.
+ return quote(value);
}
- Index = position;
- }
- // Parse exponents.
- symbol = source.charAt(Index);
- if (symbol == "e" || symbol == "E") {
- // Skip past the sign following the exponent, if one is
- // specified.
- symbol = source.charAt(++Index);
- if (symbol == "+" || symbol == "-") {
- Index++;
+ // Recursively serialize objects and arrays.
+ if (typeof value == "object") {
+ // Check for cyclic structures. This is a linear search; performance
+ // is inversely proportional to the number of unique nested objects.
+ for (length = stack.length; length--;) {
+ if (stack[length] === value) {
+ // Cyclic structures cannot be serialized by `JSON.stringify`.
+ throw TypeError();
+ }
+ }
+ // Add the object to the stack of traversed objects.
+ stack.push(value);
+ results = [];
+ // Save the current indentation level and indent one additional level.
+ prefix = indentation;
+ indentation += whitespace;
+ if (className == "[object Array]") {
+ // Recursively serialize array elements.
+ for (index = 0, length = value.length; index < length; any || (any = true), index++) {
+ element = serialize(index, value, callback, properties, whitespace, indentation, stack);
+ results.push(element === undef ? "null" : element);
+ }
+ return any ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
+ } else {
+ // Recursively serialize object members. Members are selected from
+ // either a user-specified list of property names, or the object
+ // itself.
+ forEach(properties || value, function (property) {
+ var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
+ if (element !== undef) {
+ // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
+ // is not the empty string, let `member` {quote(property) + ":"}
+ // be the concatenation of `member` and the `space` character."
+ // The "`space` character" refers to the literal space
+ // character, not the `space` {width} argument provided to
+ // `JSON.stringify`.
+ results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
+ }
+ any || (any = true);
+ });
+ return any ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
+ }
+ // Remove the object from the traversed object stack.
+ stack.pop();
}
- // Parse the exponential component.
- for (position = Index; position < length && (symbol = source.charAt(position), symbol >= "0" && symbol <= "9"); position++);
- if (position == Index) {
- // Illegal empty exponent.
- abort();
+ };
+
+ // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
+ JSON3.stringify = function (source, filter, width) {
+ var whitespace, callback, properties, index, length, value;
+ if (typeof filter == "function" || typeof filter == "object" && filter) {
+ if (getClass.call(filter) == "[object Function]") {
+ callback = filter;
+ } else if (getClass.call(filter) == "[object Array]") {
+ // Convert the property names array into a makeshift set.
+ properties = {};
+ for (index = 0, length = filter.length; index < length; value = filter[index++], ((getClass.call(value) == "[object String]" || getClass.call(value) == "[object Number]") && (properties[value] = 1)));
+ }
}
- Index = position;
- }
- // Coerce the parsed value to a JavaScript number.
- return +source.slice(begin, Index);
- }
- // A negative sign may only precede numbers.
- if (sign) {
- abort();
- }
- // `true`, `false`, and `null` literals.
- if (source.slice(Index, Index + 4) == "true") {
- Index += 4;
- return true;
- } else if (source.slice(Index, Index + 5) == "false") {
- Index += 5;
- return false;
- } else if (source.slice(Index, Index + 4) == "null") {
- Index += 4;
- return null;
- }
- // Unrecognized token.
- abort();
- }
+ if (width) {
+ if (getClass.call(width) == "[object Number]") {
+ // Convert the `width` to an integer and create a string containing
+ // `width` number of space characters.
+ if ((width -= width % 1) > 0) {
+ for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
+ }
+ } else if (getClass.call(width) == "[object String]") {
+ whitespace = width.length <= 10 ? width : width.slice(0, 10);
+ }
+ }
+ // Opera <= 7.54u2 discards the values associated with empty string keys
+ // (`""`) only if they are used directly within an object member list
+ // (e.g., `!("" in { "": 1})`).
+ return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
+ };
}
- // Return the sentinel `$` character if the parser has reached the end
- // of the source string.
- return "$";
- };
- // Internal: Parses a JSON `value` token.
- get = function (value) {
- var results, any, key;
- if (value == "$") {
- // Unexpected end of input.
- abort();
- }
- if (typeof value == "string") {
- if (value.charAt(0) == "@") {
- // Remove the sentinel `@` character.
- return value.slice(1);
- }
- // Parse object and array literals.
- if (value == "[") {
- // Parses a JSON array, returning a new JavaScript array.
- results = [];
- for (;; any || (any = true)) {
- value = lex();
- // A closing square bracket marks the end of the array literal.
- if (value == "]") {
- break;
- }
- // If the array literal contains elements, the current token
- // should be a comma separating the previous element from the
- // next.
- if (any) {
- if (value == ",") {
- value = lex();
- if (value == "]") {
- // Unexpected trailing `,` in array literal.
+ // Public: Parses a JSON source string.
+ if (!parseSupported) {
+ fromCharCode = String.fromCharCode;
+ // Internal: A map of escaped control characters and their unescaped
+ // equivalents.
+ Unescapes = {
+ "\\": "\\",
+ '"': '"',
+ "/": "/",
+ "b": "\b",
+ "t": "\t",
+ "n": "\n",
+ "f": "\f",
+ "r": "\r"
+ };
+
+ // Internal: Resets the parser state and throws a `SyntaxError`.
+ abort = function () {
+ Index = Source = null;
+ throw SyntaxError();
+ };
+
+ // Internal: Returns the next token, or `"$"` if the parser has reached
+ // the end of the source string. A token may be a string, number, `null`
+ // literal, or Boolean literal.
+ lex = function () {
+ var source = Source, length = source.length, symbol, value, begin, position, sign;
+ while (Index < length) {
+ symbol = source.charAt(Index);
+ if ("\t\r\n ".indexOf(symbol) > -1) {
+ // Skip whitespace tokens, including tabs, carriage returns, line
+ // feeds, and space characters.
+ Index++;
+ } else if ("{}[]:,".indexOf(symbol) > -1) {
+ // Parse a punctuator token at the current position.
+ Index++;
+ return symbol;
+ } else if (symbol == '"') {
+ // Advance to the next character and parse a JSON string at the
+ // current position. String tokens are prefixed with the sentinel
+ // `@` character to distinguish them from punctuators.
+ for (value = "@", Index++; Index < length;) {
+ symbol = source.charAt(Index);
+ if (symbol < " ") {
+ // Unescaped ASCII control characters are not permitted.
+ abort();
+ } else if (symbol == "\\") {
+ // Parse escaped JSON control characters, `"`, `\`, `/`, and
+ // Unicode escape sequences.
+ symbol = source.charAt(++Index);
+ if ('\\"/btnfr'.indexOf(symbol) > -1) {
+ // Revive escaped control characters.
+ value += Unescapes[symbol];
+ Index++;
+ } else if (symbol == "u") {
+ // Advance to the first character of the escape sequence.
+ begin = ++Index;
+ // Validate the Unicode escape sequence.
+ for (position = Index + 4; Index < position; Index++) {
+ symbol = source.charAt(Index);
+ // A valid sequence comprises four hexdigits that form a
+ // single hexadecimal value.
+ if (!(symbol >= "0" && symbol <= "9" || symbol >= "a" && symbol <= "f" || symbol >= "A" && symbol <= "F")) {
+ // Invalid Unicode escape sequence.
+ abort();
+ }
+ }
+ // Revive the escaped character.
+ value += fromCharCode("0x" + source.slice(begin, Index));
+ } else {
+ // Invalid escape sequence.
+ abort();
+ }
+ } else {
+ if (symbol == '"') {
+ // An unescaped double-quote character marks the end of the
+ // string.
+ break;
+ }
+ // Append the original character as-is.
+ value += symbol;
+ Index++;
+ }
+ }
+ if (source.charAt(Index) == '"') {
+ Index++;
+ // Return the revived string.
+ return value;
+ }
+ // Unterminated string.
+ abort();
+ } else {
+ // Parse numbers and literals.
+ begin = Index;
+ // Advance the scanner's position past the sign, if one is
+ // specified.
+ if (symbol == "-") {
+ sign = true;
+ symbol = source.charAt(++Index);
+ }
+ // Parse an integer or floating-point value.
+ if (symbol >= "0" && symbol <= "9") {
+ // Leading zeroes are interpreted as octal literals.
+ if (symbol == "0" && (symbol = source.charAt(Index + 1), symbol >= "0" && symbol <= "9")) {
+ // Illegal octal literal.
+ abort();
+ }
+ sign = false;
+ // Parse the integer component.
+ for (; Index < length && (symbol = source.charAt(Index), symbol >= "0" && symbol <= "9"); Index++);
+ // Floats cannot contain a leading decimal point; however, this
+ // case is already accounted for by the parser.
+ if (source.charAt(Index) == ".") {
+ position = ++Index;
+ // Parse the decimal component.
+ for (; position < length && (symbol = source.charAt(position), symbol >= "0" && symbol <= "9"); position++);
+ if (position == Index) {
+ // Illegal trailing decimal.
+ abort();
+ }
+ Index = position;
+ }
+ // Parse exponents.
+ symbol = source.charAt(Index);
+ if (symbol == "e" || symbol == "E") {
+ // Skip past the sign following the exponent, if one is
+ // specified.
+ symbol = source.charAt(++Index);
+ if (symbol == "+" || symbol == "-") {
+ Index++;
+ }
+ // Parse the exponential component.
+ for (position = Index; position < length && (symbol = source.charAt(position), symbol >= "0" && symbol <= "9"); position++);
+ if (position == Index) {
+ // Illegal empty exponent.
+ abort();
+ }
+ Index = position;
+ }
+ // Coerce the parsed value to a JavaScript number.
+ return +source.slice(begin, Index);
+ }
+ // A negative sign may only precede numbers.
+ if (sign) {
+ abort();
+ }
+ // `true`, `false`, and `null` literals.
+ if (source.slice(Index, Index + 4) == "true") {
+ Index += 4;
+ return true;
+ } else if (source.slice(Index, Index + 5) == "false") {
+ Index += 5;
+ return false;
+ } else if (source.slice(Index, Index + 4) == "null") {
+ Index += 4;
+ return null;
+ }
+ // Unrecognized token.
+ abort();
+ }
+ }
+ // Return the sentinel `$` character if the parser has reached the end
+ // of the source string.
+ return "$";
+ };
+
+ // Internal: Parses a JSON `value` token.
+ get = function (value) {
+ var results, any, key;
+ if (value == "$") {
+ // Unexpected end of input.
abort();
- }
- } else {
- // A `,` must separate each array element.
- abort();
}
- }
- // Elisions and leading commas are not permitted.
- if (value == ",") {
- abort();
- }
- results.push(get(value));
- }
- return results;
- } else if (value == "{") {
- // Parses a JSON object, returning a new JavaScript object.
- results = {};
- for (;; any || (any = true)) {
- value = lex();
- // A closing curly brace marks the end of the object literal.
- if (value == "}") {
- break;
- }
- // If the object literal contains members, the current token
- // should be a comma separator.
- if (any) {
- if (value == ",") {
- value = lex();
- if (value == "}") {
- // Unexpected trailing `,` in object literal.
+ if (typeof value == "string") {
+ if (value.charAt(0) == "@") {
+ // Remove the sentinel `@` character.
+ return value.slice(1);
+ }
+ // Parse object and array literals.
+ if (value == "[") {
+ // Parses a JSON array, returning a new JavaScript array.
+ results = [];
+ for (; ; any || (any = true)) {
+ value = lex();
+ // A closing square bracket marks the end of the array literal.
+ if (value == "]") {
+ break;
+ }
+ // If the array literal contains elements, the current token
+ // should be a comma separating the previous element from the
+ // next.
+ if (any) {
+ if (value == ",") {
+ value = lex();
+ if (value == "]") {
+ // Unexpected trailing `,` in array literal.
+ abort();
+ }
+ } else {
+ // A `,` must separate each array element.
+ abort();
+ }
+ }
+ // Elisions and leading commas are not permitted.
+ if (value == ",") {
+ abort();
+ }
+ results.push(get(value));
+ }
+ return results;
+ } else if (value == "{") {
+ // Parses a JSON object, returning a new JavaScript object.
+ results = {};
+ for (; ; any || (any = true)) {
+ value = lex();
+ // A closing curly brace marks the end of the object literal.
+ if (value == "}") {
+ break;
+ }
+ // If the object literal contains members, the current token
+ // should be a comma separator.
+ if (any) {
+ if (value == ",") {
+ value = lex();
+ if (value == "}") {
+ // Unexpected trailing `,` in object literal.
+ abort();
+ }
+ } else {
+ // A `,` must separate each object member.
+ abort();
+ }
+ }
+ // Leading commas are not permitted, object property names must be
+ // double-quoted strings, and a `:` must separate each property
+ // name and value.
+ if (value == "," || typeof value != "string" || value.charAt(0) != "@" || lex() != ":") {
+ abort();
+ }
+ results[value.slice(1)] = get(lex());
+ }
+ return results;
+ }
+ // Unexpected token encountered.
abort();
- }
- } else {
- // A `,` must separate each object member.
- abort();
}
- }
- // Leading commas are not permitted, object property names must be
- // double-quoted strings, and a `:` must separate each property
- // name and value.
- if (value == "," || typeof value != "string" || value.charAt(0) != "@" || lex() != ":") {
- abort();
- }
- results[value.slice(1)] = get(lex());
- }
- return results;
- }
- // Unexpected token encountered.
- abort();
- }
- return value;
- };
+ return value;
+ };
- // Internal: Updates a traversed object member.
- update = function(source, property, callback) {
- var element = walk(source, property, callback);
- if (element === undef) {
- delete source[property];
- } else {
- source[property] = element;
- }
- };
+ // Internal: Updates a traversed object member.
+ update = function (source, property, callback) {
+ var element = walk(source, property, callback);
+ if (element === undef) {
+ delete source[property];
+ } else {
+ source[property] = element;
+ }
+ };
- // Internal: Recursively traverses a parsed JSON object, invoking the
- // `callback` function for each value. This is an implementation of the
- // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
- walk = function (source, property, callback) {
- var value = source[property], length;
- if (typeof value == "object" && value) {
- if (getClass.call(value) == "[object Array]") {
- for (length = value.length; length--;) {
- update(value, length, callback);
- }
- } else {
- // `forEach` can't be used to traverse an array in Opera <= 8.54,
- // as `Object#hasOwnProperty` returns `false` for array indices
- // (e.g., `![1, 2, 3].hasOwnProperty("0")`).
- forEach(value, function (property) {
- update(value, property, callback);
- });
- }
- }
- return callback.call(source, property, value);
- };
+ // Internal: Recursively traverses a parsed JSON object, invoking the
+ // `callback` function for each value. This is an implementation of the
+ // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
+ walk = function (source, property, callback) {
+ var value = source[property], length;
+ if (typeof value == "object" && value) {
+ if (getClass.call(value) == "[object Array]") {
+ for (length = value.length; length--;) {
+ update(value, length, callback);
+ }
+ } else {
+ // `forEach` can't be used to traverse an array in Opera <= 8.54,
+ // as `Object#hasOwnProperty` returns `false` for array indices
+ // (e.g., `![1, 2, 3].hasOwnProperty("0")`).
+ forEach(value, function (property) {
+ update(value, property, callback);
+ });
+ }
+ }
+ return callback.call(source, property, value);
+ };
- // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
- JSON3.parse = function (source, callback) {
- Index = 0;
- Source = source;
- var result = get(lex());
- // If a JSON string contains multiple tokens, it is invalid.
- if (lex() != "$") {
- abort();
+ // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
+ JSON3.parse = function (source, callback) {
+ Index = 0;
+ Source = source;
+ var result = get(lex());
+ // If a JSON string contains multiple tokens, it is invalid.
+ if (lex() != "$") {
+ abort();
+ }
+ // Reset the parser state.
+ Index = Source = null;
+ return callback && getClass.call(callback) == "[object Function]" ? walk((value = {}, value[""] = result, value), "", callback) : result;
+ };
}
- // Reset the parser state.
- Index = Source = null;
- return callback && getClass.call(callback) == "[object Function]" ? walk((value = {}, value[""] = result, value), "", callback) : result;
- };
}
- }
}).call(this);
\ No newline at end of file
diff --git a/sdk/src/third-party/json3.min.js b/sdk/src/third-party/json3.min.js
index 94896f18..c2b23250 100644
--- a/sdk/src/third-party/json3.min.js
+++ b/sdk/src/third-party/json3.min.js
@@ -1,17 +1,314 @@
/*! JSON v3.2.3 | http://bestiejs.github.com/json3 | Copyright 2012, Kit Cambridge | http://kit.mit-license.org */
-;(function(){var e=void 0,i=!0,k=null,l={}.toString,m,n,o="function"===typeof define&&define.c,q="object"==typeof exports&&exports,r='{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}',t,u,x,y,z,C,D,E,F,G,H,I,J,K,O,P=new Date(-3509827334573292),Q,R,S;try{P=-109252==P.getUTCFullYear()&&0===P.getUTCMonth()&&1==P.getUTCDate()&&10==P.getUTCHours()&&37==P.getUTCMinutes()&&6==P.getUTCSeconds()&&708==P.getUTCMilliseconds()}catch(T){}
-P||(Q=Math.floor,R=[0,31,59,90,120,151,181,212,243,273,304,334],S=function(b,c){return R[c]+365*(b-1970)+Q((b-1969+(c=+(1
-1?u[d]:d<" "?"\\u00"+x(2,d.charCodeAt(0).toString(16)):d);return c+'"'},z=function(b,c,a,d,j,f,p){var g=c[b],h,s,v,w,L,M,N,A,B;if(typeof g=="object"&&g){h=l.call(g);if(h=="[object Date]"&&!m.call(g,"toJSON"))if(g>
--1/0&&g<1/0){if(S){v=Q(g/864E5);for(h=Q(v/365.2425)+1970-1;S(h+1,0)<=v;h++);for(s=Q((v-S(h,0))/30.42);S(h,s+1)<=v;s++);v=1+v-S(h,s);w=(g%864E5+864E5)%864E5;L=Q(w/36E5)%24;M=Q(w/6E4)%60;N=Q(w/1E3)%60;w=w%1E3}else{h=g.getUTCFullYear();s=g.getUTCMonth();v=g.getUTCDate();L=g.getUTCHours();M=g.getUTCMinutes();N=g.getUTCSeconds();w=g.getUTCMilliseconds()}g=(h<=0||h>=1E4?(h<0?"-":"+")+x(6,h<0?-h:h):x(4,h))+"-"+x(2,s+1)+"-"+x(2,v)+"T"+x(2,L)+":"+x(2,M)+":"+x(2,N)+"."+x(3,w)+"Z"}else g=k;else if(typeof g.toJSON==
-"function"&&(h!="[object Number]"&&h!="[object String]"&&h!="[object Array]"||m.call(g,"toJSON")))g=g.toJSON(b)}a&&(g=a.call(c,b,g));if(g===k)return"null";h=l.call(g);if(h=="[object Boolean]")return""+g;if(h=="[object Number]")return g>-1/0&&g<1/0?""+g:"null";if(h=="[object String]")return y(g);if(typeof g=="object"){for(b=p.length;b--;)if(p[b]===g)throw TypeError();p.push(g);A=[];c=f;f=f+j;if(h=="[object Array]"){s=0;for(b=g.length;s0){d="";for(a>10&&(a=10);d.length-1)K++;else{if("{}[]:,".indexOf(a)>-1){K++;return a}if(a=='"'){d="@";for(K++;K-1){d=d+E[a];K++}else if(a=="u"){j=++K;for(f=K+4;K="0"&&a<="9"||a>="a"&&a<="f"||a>="A"&&a<="F"||F()}d=d+D("0x"+b.slice(j,K))}else F()}else{if(a=='"')break;d=d+a;K++}}if(b.charAt(K)=='"'){K++;return d}}else{j=K;if(a=="-"){p=i;a=b.charAt(++K)}if(a>="0"&&a<="9"){for(a=="0"&&(a=b.charAt(K+1),a>="0"&&a<="9")&&F();K="0"&&a<="9");K++);if(b.charAt(K)=="."){for(f=++K;f="0"&&a<="9");f++);f==K&&F();K=f}a=b.charAt(K);if(a=="e"||a=="E"){a=b.charAt(++K);(a=="+"||a=="-")&&K++;for(f=K;f="0"&&a<="9");f++);f==K&&F();K=f}return+b.slice(j,K)}p&&F();if(b.slice(K,K+4)=="true"){K=K+4;return i}if(b.slice(K,K+5)=="false"){K=K+5;return false}if(b.slice(K,K+4)=="null"){K=K+4;return k}}F()}}return"$"},H=function(b){var c,a;b=="$"&&F();if(typeof b=="string"){if(b.charAt(0)=="@")return b.slice(1);if(b=="["){for(c=[];;a||(a=i)){b=G();if(b=="]")break;if(a)if(b==
-","){b=G();b=="]"&&F()}else F();b==","&&F();c.push(H(b))}return c}if(b=="{"){for(c={};;a||(a=i)){b=G();if(b=="}")break;if(a)if(b==","){b=G();b=="}"&&F()}else F();(b==","||typeof b!="string"||b.charAt(0)!="@"||G()!=":")&&F();c[b.slice(1)]=H(G())}return c}F()}return b},J=function(b,c,a){a=I(b,c,a);a===e?delete b[c]:b[c]=a},I=function(b,c,a){var d=b[c],j;if(typeof d=="object"&&d)if(l.call(d)=="[object Array]")for(j=d.length;j--;)J(d,j,a);else n(d,function(b){J(d,b,a)});return a.call(b,c,d)},q.parse=
-function(b,c){K=0;O=b;var a=H(G());G()!="$"&&F();K=O=k;return c&&l.call(c)=="[object Function]"?I((P={},P[""]=a,P),"",c):a})};
+;
+(function () {
+ var e = void 0, i = !0, k = null, l = {}.toString, m, n, o = "function" === typeof define && define.c, q = "object" == typeof exports && exports, r = '{"A":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}', t, u, x, y, z, C, D, E, F, G, H, I, J, K, O, P = new Date(-3509827334573292), Q, R, S;
+ try {
+ P = -109252 == P.getUTCFullYear() && 0 === P.getUTCMonth() && 1 == P.getUTCDate() && 10 == P.getUTCHours() && 37 == P.getUTCMinutes() && 6 == P.getUTCSeconds() && 708 == P.getUTCMilliseconds()
+ } catch (T) {
+ }
+ P || (Q = Math.floor, R = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], S = function (b, c) {
+ return R[c] + 365 * (b - 1970) + Q((b - 1969 + (c = +(1 < c))) / 4) - Q((b - 1901 + c) / 100) + Q((b - 1601 + c) / 400)
+ });
+ o || q ? (o && define("json", q = {}), "object" == typeof JSON && JSON && (q.stringify = JSON.stringify, q.parse = JSON.parse)) : q = this.JSON || (this.JSON = {});
+ if (t = "function" == typeof q.stringify && !S) {
+ (P = function () {
+ return 1
+ }).toJSON = P;
+ try {
+ t = "0" === q.stringify(0) && "0" === q.stringify(new Number) && '""' == q.stringify(new String) && q.stringify(l) === e && q.stringify(e) === e && q.stringify() === e && "1" === q.stringify(P) && "[1]" == q.stringify([P]) && "[null]" == q.stringify([e]) && "null" == q.stringify(k) && "[null,null,null]" == q.stringify([e, l, k]) && q.stringify({result: [P, i, !1, k, "\x00\u0008\n\u000c\r\t"]}) == r && "1" === q.stringify(k, P) && "[\n 1,\n 2\n]" == q.stringify([1, 2], k, 1) && '"-271821-04-20T00:00:00.000Z"' ==
+ q.stringify(new Date(-864E13)) && '"+275760-09-13T00:00:00.000Z"' == q.stringify(new Date(864E13)) && '"-000001-01-01T00:00:00.000Z"' == q.stringify(new Date(-621987552E5)) && '"1969-12-31T23:59:59.999Z"' == q.stringify(new Date(-1))
+ } catch (U) {
+ t = !1
+ }
+ }
+ if ("function" == typeof q.parse)try {
+ if (0 === q.parse("0") && !q.parse(!1) && (P = q.parse(r), C = 5 == P.a.length && 1 == P.a[0])) {
+ try {
+ C = !q.parse('"\t"')
+ } catch (V) {
+ }
+ if (C)try {
+ C = 1 != q.parse("01")
+ } catch (W) {
+ }
+ }
+ } catch (X) {
+ C = !1
+ }
+ P = r = k;
+ if (!t || !C) {
+ if (!(m = {}.hasOwnProperty))m = function (b) {
+ var c = {}, a;
+ if ((c.__proto__ = k, c.__proto__ = {toString: 1}, c).toString != l)m = function (a) {
+ var b = this.__proto__, a = a in(this.__proto__ = k, this);
+ this.__proto__ = b;
+ return a
+ }; else {
+ a = c.constructor;
+ m = function (b) {
+ var c = (this.constructor || a).prototype;
+ return b in this && !(b in c && this[b] === c[b])
+ }
+ }
+ c = k;
+ return m.call(this, b)
+ };
+ n = function (b, c) {
+ var a = 0, d, j, f;
+ (d = function () {
+ this.valueOf = 0
+ }).prototype.valueOf = 0;
+ j = new d;
+ for (f in j)m.call(j, f) && a++;
+ d = j = k;
+ if (a)a = a == 2 ? function (a,
+ b) {
+ var c = {}, d = l.call(a) == "[object Function]", f;
+ for (f in a)!(d && f == "prototype") && !m.call(c, f) && (c[f] = 1) && m.call(a, f) && b(f)
+ } : function (a, b) {
+ var c = l.call(a) == "[object Function]", d, f;
+ for (d in a)!(c && d == "prototype") && m.call(a, d) && !(f = d === "constructor") && b(d);
+ (f || m.call(a, d = "constructor")) && b(d)
+ }; else {
+ j = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
+ a = function (a, b) {
+ var c = l.call(a) == "[object Function]", d;
+ for (d in a)!(c && d == "prototype") && m.call(a,
+ d) && b(d);
+ for (c = j.length; d = j[--c]; m.call(a, d) && b(d));
+ }
+ }
+ a(b, c)
+ };
+ t || (u = {
+ "\\": "\\\\",
+ '"': '\\"',
+ "\u0008": "\\b",
+ "\u000c": "\\f",
+ "\n": "\\n",
+ "\r": "\\r",
+ "\t": "\\t"
+ }, x = function (b, c) {
+ return ("000000" + (c || 0)).slice(-b)
+ }, y = function (b) {
+ for (var c = '"', a = 0, d; d = b.charAt(a); a++)c = c + ('\\"\u0008\u000c\n\r\t'.indexOf(d) > -1 ? u[d] : d < " " ? "\\u00" + x(2, d.charCodeAt(0).toString(16)) : d);
+ return c + '"'
+ }, z = function (b, c, a, d, j, f, p) {
+ var g = c[b], h, s, v, w, L, M, N, A, B;
+ if (typeof g == "object" && g) {
+ h = l.call(g);
+ if (h == "[object Date]" && !m.call(g, "toJSON"))if (g >
+ -1 / 0 && g < 1 / 0) {
+ if (S) {
+ v = Q(g / 864E5);
+ for (h = Q(v / 365.2425) + 1970 - 1; S(h + 1, 0) <= v; h++);
+ for (s = Q((v - S(h, 0)) / 30.42); S(h, s + 1) <= v; s++);
+ v = 1 + v - S(h, s);
+ w = (g % 864E5 + 864E5) % 864E5;
+ L = Q(w / 36E5) % 24;
+ M = Q(w / 6E4) % 60;
+ N = Q(w / 1E3) % 60;
+ w = w % 1E3
+ } else {
+ h = g.getUTCFullYear();
+ s = g.getUTCMonth();
+ v = g.getUTCDate();
+ L = g.getUTCHours();
+ M = g.getUTCMinutes();
+ N = g.getUTCSeconds();
+ w = g.getUTCMilliseconds()
+ }
+ g = (h <= 0 || h >= 1E4 ? (h < 0 ? "-" : "+") + x(6, h < 0 ? -h : h) : x(4, h)) + "-" + x(2, s + 1) + "-" + x(2, v) + "T" + x(2, L) + ":" + x(2, M) + ":" + x(2, N) + "." + x(3, w) + "Z"
+ } else g = k; else if (typeof g.toJSON ==
+ "function" && (h != "[object Number]" && h != "[object String]" && h != "[object Array]" || m.call(g, "toJSON")))g = g.toJSON(b)
+ }
+ a && (g = a.call(c, b, g));
+ if (g === k)return "null";
+ h = l.call(g);
+ if (h == "[object Boolean]")return "" + g;
+ if (h == "[object Number]")return g > -1 / 0 && g < 1 / 0 ? "" + g : "null";
+ if (h == "[object String]")return y(g);
+ if (typeof g == "object") {
+ for (b = p.length; b--;)if (p[b] === g)throw TypeError();
+ p.push(g);
+ A = [];
+ c = f;
+ f = f + j;
+ if (h == "[object Array]") {
+ s = 0;
+ for (b = g.length; s < b; B || (B = i), s++) {
+ h = z(s, g, a, d, j, f, p);
+ A.push(h === e ? "null" : h)
+ }
+ return B ?
+ j ? "[\n" + f + A.join(",\n" + f) + "\n" + c + "]" : "[" + A.join(",") + "]" : "[]"
+ }
+ n(d || g, function (b) {
+ var c = z(b, g, a, d, j, f, p);
+ c !== e && A.push(y(b) + ":" + (j ? " " : "") + c);
+ B || (B = i)
+ });
+ return B ? j ? "{\n" + f + A.join(",\n" + f) + "\n" + c + "}" : "{" + A.join(",") + "}" : "{}"
+ }
+ }, q.stringify = function (b, c, a) {
+ var d, j, f, p, g, h;
+ if (typeof c == "function" || typeof c == "object" && c)if (l.call(c) == "[object Function]")j = c; else if (l.call(c) == "[object Array]") {
+ f = {};
+ p = 0;
+ for (g = c.length; p < g; h = c[p++], (l.call(h) == "[object String]" || l.call(h) == "[object Number]") && (f[h] = 1));
+ }
+ if (a)if (l.call(a) ==
+ "[object Number]") {
+ if ((a = a - a % 1) > 0) {
+ d = "";
+ for (a > 10 && (a = 10); d.length < a; d = d + " ");
+ }
+ } else l.call(a) == "[object String]" && (d = a.length <= 10 ? a : a.slice(0, 10));
+ return z("", (h = {}, h[""] = b, h), j, f, d, "", [])
+ });
+ C || (D = String.fromCharCode, E = {
+ "\\": "\\",
+ '"': '"',
+ "/": "/",
+ b: "\u0008",
+ t: "\t",
+ n: "\n",
+ f: "\u000c",
+ r: "\r"
+ }, F = function () {
+ K = O = k;
+ throw SyntaxError();
+ }, G = function () {
+ for (var b = O, c = b.length, a, d, j, f, p; K < c;) {
+ a = b.charAt(K);
+ if ("\t\r\n ".indexOf(a) > -1)K++; else {
+ if ("{}[]:,".indexOf(a) > -1) {
+ K++;
+ return a
+ }
+ if (a == '"') {
+ d = "@";
+ for (K++; K < c;) {
+ a =
+ b.charAt(K);
+ if (a < " ")F(); else if (a == "\\") {
+ a = b.charAt(++K);
+ if ('\\"/btnfr'.indexOf(a) > -1) {
+ d = d + E[a];
+ K++
+ } else if (a == "u") {
+ j = ++K;
+ for (f = K + 4; K < f; K++) {
+ a = b.charAt(K);
+ a >= "0" && a <= "9" || a >= "a" && a <= "f" || a >= "A" && a <= "F" || F()
+ }
+ d = d + D("0x" + b.slice(j, K))
+ } else F()
+ } else {
+ if (a == '"')break;
+ d = d + a;
+ K++
+ }
+ }
+ if (b.charAt(K) == '"') {
+ K++;
+ return d
+ }
+ } else {
+ j = K;
+ if (a == "-") {
+ p = i;
+ a = b.charAt(++K)
+ }
+ if (a >= "0" && a <= "9") {
+ for (a == "0" && (a = b.charAt(K + 1), a >= "0" && a <= "9") && F(); K < c && (a = b.charAt(K), a >= "0" && a <= "9"); K++);
+ if (b.charAt(K) == ".") {
+ for (f = ++K; f < c && (a = b.charAt(f),
+ a >= "0" && a <= "9"); f++);
+ f == K && F();
+ K = f
+ }
+ a = b.charAt(K);
+ if (a == "e" || a == "E") {
+ a = b.charAt(++K);
+ (a == "+" || a == "-") && K++;
+ for (f = K; f < c && (a = b.charAt(f), a >= "0" && a <= "9"); f++);
+ f == K && F();
+ K = f
+ }
+ return +b.slice(j, K)
+ }
+ p && F();
+ if (b.slice(K, K + 4) == "true") {
+ K = K + 4;
+ return i
+ }
+ if (b.slice(K, K + 5) == "false") {
+ K = K + 5;
+ return false
+ }
+ if (b.slice(K, K + 4) == "null") {
+ K = K + 4;
+ return k
+ }
+ }
+ F()
+ }
+ }
+ return "$"
+ }, H = function (b) {
+ var c, a;
+ b == "$" && F();
+ if (typeof b == "string") {
+ if (b.charAt(0) == "@")return b.slice(1);
+ if (b == "[") {
+ for (c = []; ; a || (a = i)) {
+ b = G();
+ if (b == "]")break;
+ if (a)if (b ==
+ ",") {
+ b = G();
+ b == "]" && F()
+ } else F();
+ b == "," && F();
+ c.push(H(b))
+ }
+ return c
+ }
+ if (b == "{") {
+ for (c = {}; ; a || (a = i)) {
+ b = G();
+ if (b == "}")break;
+ if (a)if (b == ",") {
+ b = G();
+ b == "}" && F()
+ } else F();
+ (b == "," || typeof b != "string" || b.charAt(0) != "@" || G() != ":") && F();
+ c[b.slice(1)] = H(G())
+ }
+ return c
+ }
+ F()
+ }
+ return b
+ }, J = function (b, c, a) {
+ a = I(b, c, a);
+ a === e ? delete b[c] : b[c] = a
+ }, I = function (b, c, a) {
+ var d = b[c], j;
+ if (typeof d == "object" && d)if (l.call(d) == "[object Array]")for (j = d.length; j--;)J(d, j, a); else n(d, function (b) {
+ J(d, b, a)
+ });
+ return a.call(b, c, d)
+ }, q.parse =
+ function (b, c) {
+ K = 0;
+ O = b;
+ var a = H(G());
+ G() != "$" && F();
+ K = O = k;
+ return c && l.call(c) == "[object Function]" ? I((P = {}, P[""] = a, P), "", c) : a
+ })
+ }
+ ;
}());
\ No newline at end of file
diff --git a/sdk/src/third-party/require.min.js b/sdk/src/third-party/require.min.js
index df3d5db1..19ab1e58 100644
--- a/sdk/src/third-party/require.min.js
+++ b/sdk/src/third-party/require.min.js
@@ -2,35 +2,638 @@
RequireJS 2.1.9 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
-*/
-var requirejs,require,define;
-(function(Z){function H(b){return"[object Function]"===L.call(b)}function I(b){return"[object Array]"===L.call(b)}function y(b,c){if(b){var e;for(e=0;ethis.depCount&&!this.defined){if(H(m)){if(this.events.error&&this.map.isDefine||j.onError!==aa)try{d=i.execCb(c,m,b,d)}catch(e){a=e}else d=i.execCb(c,m,b,d);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==
-this.exports?d=b.exports:void 0===d&&this.usingExports&&(d=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",v(this.error=a)}else d=m;this.exports=d;if(this.map.isDefine&&!this.ignore&&(r[c]=d,j.onResourceLoad))j.onResourceLoad(i,this.map,this.depMaps);x(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=
-!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,e=n(a.prefix);this.depMaps.push(e);s(e,"defined",u(this,function(d){var m,e;e=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,h=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(d.normalize&&(e=d.normalize(e,function(a){return c(a,g,!0)})||""),d=n(a.prefix+"!"+e,this.map.parentMap),s(d,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),
-e=l(p,d.id)){this.depMaps.push(d);if(this.events.error)e.on("error",u(this,function(a){this.emit("error",a)}));e.enable()}}else m=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];F(p,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&x(a.map.id)});v(a)}),m.fromText=u(this,function(d,c){var e=a.name,g=n(e),B=O;c&&(d=c);B&&(O=!1);q(g);t(k.config,b)&&(k.config[e]=k.config[b]);try{j.exec(d)}catch(ca){return v(A("fromtexteval",
-"fromText eval for "+b+" failed: "+ca,ca,[b]))}B&&(O=!0);this.depMaps.push(g);i.completeLoad(e);h([e],m)}),d.load(a.name,h,m,k)}));i.enable(e,this);this.pluginMaps[e.id]=e},enable:function(){T[this.map.id]=this;this.enabling=this.enabled=!0;y(this.depMaps,u(this,function(a,b){var c,d;if("string"===typeof a){a=n(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=l(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",u(this,function(a){this.defineDep(b,
-a);this.check()}));this.errback&&s(a,"error",u(this,this.errback))}c=a.id;d=p[c];!t(N,c)&&(d&&!d.enabled)&&i.enable(a,this)}));F(this.pluginMaps,u(this,function(a){var b=l(p,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){y(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:k,contextName:b,registry:p,defined:r,urlFetched:S,defQueue:G,Module:X,makeModuleMap:n,
-nextTick:j.nextTick,onError:v,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,d={paths:!0,config:!0,map:!0};F(a,function(a,b){d[b]?"map"===b?(k.map||(k.map={}),Q(k[b],a,!0,!0)):Q(k[b],a,!0):k[b]=a});a.shim&&(F(a.shim,function(a,b){I(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);c[b]=a}),k.shim=c);a.packages&&(y(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,
-location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ea,"")}}),k.pkgs=b);F(p,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=n(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Z,arguments));return b||a.exports&&ba(a.exports)}},makeRequire:function(a,f){function h(d,c,e){var g,k;f.enableBuildCallback&&(c&&H(c))&&(c.__requireJsBuild=!0);if("string"===typeof d){if(H(c))return v(A("requireargs",
-"Invalid require call"),e);if(a&&t(N,d))return N[d](p[a.id]);if(j.get)return j.get(i,d,a,h);g=n(d,a,!1,!0);g=g.id;return!t(r,g)?v(A("notloaded",'Module name "'+g+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[g]}K();i.nextTick(function(){K();k=q(n(null,a));k.skipMap=f.skipMap;k.init(d,c,e,{enabled:!0});C()});return h}f=f||{};Q(h,{isBrowser:z,toUrl:function(b){var f,e=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==e&&(!("."===g||".."===g)||1h.attachEvent.toString().indexOf("[native code"))&&!W?(O=!0,h.attachEvent("onreadystatechange",b.onScriptLoad)):(h.addEventListener("load",b.onScriptLoad,!1),h.addEventListener("error",
-b.onScriptError,!1)),h.src=e,K=h,C?x.insertBefore(h,C):x.appendChild(h),K=null,h;if(da)try{importScripts(e),b.completeLoad(c)}catch(l){b.onError(A("importscripts","importScripts failed for "+c+" at "+e,l,[c]))}};z&&!s.skipDataMain&&M(document.getElementsByTagName("script"),function(b){x||(x=b.parentNode);if(J=b.getAttribute("data-main"))return q=J,s.baseUrl||(D=q.split("/"),q=D.pop(),fa=D.length?D.join("/")+"/":"./",s.baseUrl=fa),q=q.replace(ea,""),j.jsExtRegExp.test(q)&&(q=J),s.deps=s.deps?s.deps.concat(q):
-[q],!0});define=function(b,c,e){var h,j;"string"!==typeof b&&(e=c,c=b,b=null);I(c)||(e=c,c=null);!c&&H(e)&&(c=[],e.length&&(e.toString().replace(la,"").replace(ma,function(b,e){c.push(e)}),c=(1===e.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(h=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),h=P;h&&(b||(b=h.getAttribute("data-requiremodule")),j=E[h.getAttribute("data-requirecontext")])}(j?
-j.defQueue:R).push([b,c,e])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(s)}})(this);
\ No newline at end of file
+ */
+var requirejs, require, define;
+(function (Z) {
+ function H(b) {
+ return "[object Function]" === L.call(b)
+ }
+
+ function I(b) {
+ return "[object Array]" === L.call(b)
+ }
+
+ function y(b, c) {
+ if (b) {
+ var e;
+ for (e = 0; e < b.length && (!b[e] || !c(b[e], e, b)); e += 1);
+ }
+ }
+
+ function M(b, c) {
+ if (b) {
+ var e;
+ for (e = b.length - 1; -1 < e && (!b[e] || !c(b[e], e, b)); e -= 1);
+ }
+ }
+
+ function t(b, c) {
+ return ga.call(b, c)
+ }
+
+ function l(b, c) {
+ return t(b, c) && b[c]
+ }
+
+ function F(b, c) {
+ for (var e in b)if (t(b, e) && c(b[e], e))break
+ }
+
+ function Q(b, c, e, h) {
+ c && F(c, function (c, j) {
+ if (e || !t(b, j))h && "string" !== typeof c ? (b[j] || (b[j] = {}), Q(b[j],
+ c, e, h)) : b[j] = c
+ });
+ return b
+ }
+
+ function u(b, c) {
+ return function () {
+ return c.apply(b, arguments)
+ }
+ }
+
+ function aa(b) {
+ throw b;
+ }
+
+ function ba(b) {
+ if (!b)return b;
+ var c = Z;
+ y(b.split("."), function (b) {
+ c = c[b]
+ });
+ return c
+ }
+
+ function A(b, c, e, h) {
+ c = Error(c + "\nhttp://requirejs.org/docs/errors.html#" + b);
+ c.requireType = b;
+ c.requireModules = h;
+ e && (c.originalError = e);
+ return c
+ }
+
+ function ha(b) {
+ function c(a, f, b) {
+ var d, m, c, g, e, h, j, i = f && f.split("/");
+ d = i;
+ var n = k.map, p = n && n["*"];
+ if (a && "." === a.charAt(0))if (f) {
+ d = l(k.pkgs, f) ? i = [f] : i.slice(0, i.length -
+ 1);
+ f = a = d.concat(a.split("/"));
+ for (d = 0; f[d]; d += 1)if (m = f[d], "." === m)f.splice(d, 1), d -= 1; else if (".." === m)if (1 === d && (".." === f[2] || ".." === f[0]))break; else 0 < d && (f.splice(d - 1, 2), d -= 2);
+ d = l(k.pkgs, f = a[0]);
+ a = a.join("/");
+ d && a === f + "/" + d.main && (a = f)
+ } else 0 === a.indexOf("./") && (a = a.substring(2));
+ if (b && n && (i || p)) {
+ f = a.split("/");
+ for (d = f.length; 0 < d; d -= 1) {
+ c = f.slice(0, d).join("/");
+ if (i)for (m = i.length; 0 < m; m -= 1)if (b = l(n, i.slice(0, m).join("/")))if (b = l(b, c)) {
+ g = b;
+ e = d;
+ break
+ }
+ if (g)break;
+ !h && (p && l(p, c)) && (h = l(p, c), j = d)
+ }
+ !g &&
+ h && (g = h, e = j);
+ g && (f.splice(0, e, g), a = f.join("/"))
+ }
+ return a
+ }
+
+ function e(a) {
+ z && y(document.getElementsByTagName("script"), function (f) {
+ if (f.getAttribute("data-requiremodule") === a && f.getAttribute("data-requirecontext") === i.contextName)return f.parentNode.removeChild(f), !0
+ })
+ }
+
+ function h(a) {
+ var f = l(k.paths, a);
+ if (f && I(f) && 1 < f.length)return f.shift(), i.require.undef(a), i.require([a]), !0
+ }
+
+ function $(a) {
+ var f, b = a ? a.indexOf("!") : -1;
+ -1 < b && (f = a.substring(0, b), a = a.substring(b + 1, a.length));
+ return [f, a]
+ }
+
+ function n(a, f,
+ b, d) {
+ var m, B, g = null, e = f ? f.name : null, h = a, j = !0, k = "";
+ a || (j = !1, a = "_@r" + (L += 1));
+ a = $(a);
+ g = a[0];
+ a = a[1];
+ g && (g = c(g, e, d), B = l(r, g));
+ a && (g ? k = B && B.normalize ? B.normalize(a, function (a) {
+ return c(a, e, d)
+ }) : c(a, e, d) : (k = c(a, e, d), a = $(k), g = a[0], k = a[1], b = !0, m = i.nameToUrl(k)));
+ b = g && !B && !b ? "_unnormalized" + (M += 1) : "";
+ return {
+ prefix: g,
+ name: k,
+ parentMap: f,
+ unnormalized: !!b,
+ url: m,
+ originalName: h,
+ isDefine: j,
+ id: (g ? g + "!" + k : k) + b
+ }
+ }
+
+ function q(a) {
+ var f = a.id, b = l(p, f);
+ b || (b = p[f] = new i.Module(a));
+ return b
+ }
+
+ function s(a, f, b) {
+ var d = a.id, m = l(p,
+ d);
+ if (t(r, d) && (!m || m.defineEmitComplete))"defined" === f && b(r[d]); else if (m = q(a), m.error && "error" === f)b(m.error); else m.on(f, b)
+ }
+
+ function v(a, f) {
+ var b = a.requireModules, d = !1;
+ if (f)f(a); else if (y(b, function (f) {
+ if (f = l(p, f))f.error = a, f.events.error && (d = !0, f.emit("error", a))
+ }), !d)j.onError(a)
+ }
+
+ function w() {
+ R.length && (ia.apply(G, [G.length - 1, 0].concat(R)), R = [])
+ }
+
+ function x(a) {
+ delete p[a];
+ delete T[a]
+ }
+
+ function E(a, f, b) {
+ var d = a.map.id;
+ a.error ? a.emit("error", a.error) : (f[d] = !0, y(a.depMaps, function (d, c) {
+ var g = d.id,
+ e = l(p, g);
+ e && (!a.depMatched[c] && !b[g]) && (l(f, g) ? (a.defineDep(c, r[g]), a.check()) : E(e, f, b))
+ }), b[d] = !0)
+ }
+
+ function C() {
+ var a, f, b, d, m = (b = 1E3 * k.waitSeconds) && i.startTime + b < (new Date).getTime(), c = [], g = [], j = !1, l = !0;
+ if (!U) {
+ U = !0;
+ F(T, function (b) {
+ a = b.map;
+ f = a.id;
+ if (b.enabled && (a.isDefine || g.push(b), !b.error))if (!b.inited && m)h(f) ? j = d = !0 : (c.push(f), e(f)); else if (!b.inited && (b.fetched && a.isDefine) && (j = !0, !a.prefix))return l = !1
+ });
+ if (m && c.length)return b = A("timeout", "Load timeout for modules: " + c, null, c), b.contextName =
+ i.contextName, v(b);
+ l && y(g, function (a) {
+ E(a, {}, {})
+ });
+ if ((!m || d) && j)if ((z || da) && !V)V = setTimeout(function () {
+ V = 0;
+ C()
+ }, 50);
+ U = !1
+ }
+ }
+
+ function D(a) {
+ t(r, a[0]) || q(n(a[0], null, !0)).init(a[1], a[2])
+ }
+
+ function J(a) {
+ var a = a.currentTarget || a.srcElement, b = i.onScriptLoad;
+ a.detachEvent && !W ? a.detachEvent("onreadystatechange", b) : a.removeEventListener("load", b, !1);
+ b = i.onScriptError;
+ (!a.detachEvent || W) && a.removeEventListener("error", b, !1);
+ return {node: a, id: a && a.getAttribute("data-requiremodule")}
+ }
+
+ function K() {
+ var a;
+ for (w(); G.length;) {
+ a =
+ G.shift();
+ if (null === a[0])return v(A("mismatch", "Mismatched anonymous define() module: " + a[a.length - 1]));
+ D(a)
+ }
+ }
+
+ var U, X, i, N, V, k = {
+ waitSeconds: 7,
+ baseUrl: "./",
+ paths: {},
+ pkgs: {},
+ shim: {},
+ config: {}
+ }, p = {}, T = {}, Y = {}, G = [], r = {}, S = {}, L = 1, M = 1;
+ N = {
+ require: function (a) {
+ return a.require ? a.require : a.require = i.makeRequire(a.map)
+ }, exports: function (a) {
+ a.usingExports = !0;
+ if (a.map.isDefine)return a.exports ? a.exports : a.exports = r[a.map.id] = {}
+ }, module: function (a) {
+ return a.module ? a.module : a.module = {
+ id: a.map.id, uri: a.map.url, config: function () {
+ var b =
+ l(k.pkgs, a.map.id);
+ return (b ? l(k.config, a.map.id + "/" + b.main) : l(k.config, a.map.id)) || {}
+ }, exports: r[a.map.id]
+ }
+ }
+ };
+ X = function (a) {
+ this.events = l(Y, a.id) || {};
+ this.map = a;
+ this.shim = l(k.shim, a.id);
+ this.depExports = [];
+ this.depMaps = [];
+ this.depMatched = [];
+ this.pluginMaps = {};
+ this.depCount = 0
+ };
+ X.prototype = {
+ init: function (a, b, c, d) {
+ d = d || {};
+ if (!this.inited) {
+ this.factory = b;
+ if (c)this.on("error", c); else this.events.error && (c = u(this, function (a) {
+ this.emit("error", a)
+ }));
+ this.depMaps = a && a.slice(0);
+ this.errback = c;
+ this.inited = !0;
+ this.ignore = d.ignore;
+ d.enabled || this.enabled ? this.enable() : this.check()
+ }
+ }, defineDep: function (a, b) {
+ this.depMatched[a] || (this.depMatched[a] = !0, this.depCount -= 1, this.depExports[a] = b)
+ }, fetch: function () {
+ if (!this.fetched) {
+ this.fetched = !0;
+ i.startTime = (new Date).getTime();
+ var a = this.map;
+ if (this.shim)i.makeRequire(this.map, {enableBuildCallback: !0})(this.shim.deps || [], u(this, function () {
+ return a.prefix ? this.callPlugin() : this.load()
+ })); else return a.prefix ? this.callPlugin() : this.load()
+ }
+ }, load: function () {
+ var a =
+ this.map.url;
+ S[a] || (S[a] = !0, i.load(this.map.id, a))
+ }, check: function () {
+ if (this.enabled && !this.enabling) {
+ var a, b, c = this.map.id;
+ b = this.depExports;
+ var d = this.exports, m = this.factory;
+ if (this.inited)if (this.error)this.emit("error", this.error); else {
+ if (!this.defining) {
+ this.defining = !0;
+ if (1 > this.depCount && !this.defined) {
+ if (H(m)) {
+ if (this.events.error && this.map.isDefine || j.onError !== aa)try {
+ d = i.execCb(c, m, b, d)
+ } catch (e) {
+ a = e
+ } else d = i.execCb(c, m, b, d);
+ this.map.isDefine && ((b = this.module) && void 0 !== b.exports && b.exports !==
+ this.exports ? d = b.exports : void 0 === d && this.usingExports && (d = this.exports));
+ if (a)return a.requireMap = this.map, a.requireModules = this.map.isDefine ? [this.map.id] : null, a.requireType = this.map.isDefine ? "define" : "require", v(this.error = a)
+ } else d = m;
+ this.exports = d;
+ if (this.map.isDefine && !this.ignore && (r[c] = d, j.onResourceLoad))j.onResourceLoad(i, this.map, this.depMaps);
+ x(c);
+ this.defined = !0
+ }
+ this.defining = !1;
+ this.defined && !this.defineEmitted && (this.defineEmitted = !0, this.emit("defined", this.exports), this.defineEmitComplete = !0)
+ }
+ } else this.fetch()
+ }
+ }, callPlugin: function () {
+ var a = this.map, b = a.id, e = n(a.prefix);
+ this.depMaps.push(e);
+ s(e, "defined", u(this, function (d) {
+ var m, e;
+ e = this.map.name;
+ var g = this.map.parentMap ? this.map.parentMap.name : null, h = i.makeRequire(a.parentMap, {enableBuildCallback: !0});
+ if (this.map.unnormalized) {
+ if (d.normalize && (e = d.normalize(e, function (a) {
+ return c(a, g, !0)
+ }) || ""), d = n(a.prefix + "!" + e, this.map.parentMap), s(d, "defined", u(this, function (a) {
+ this.init([], function () {
+ return a
+ }, null, {enabled: !0, ignore: !0})
+ })),
+ e = l(p, d.id)) {
+ this.depMaps.push(d);
+ if (this.events.error)e.on("error", u(this, function (a) {
+ this.emit("error", a)
+ }));
+ e.enable()
+ }
+ } else m = u(this, function (a) {
+ this.init([], function () {
+ return a
+ }, null, {enabled: !0})
+ }), m.error = u(this, function (a) {
+ this.inited = !0;
+ this.error = a;
+ a.requireModules = [b];
+ F(p, function (a) {
+ 0 === a.map.id.indexOf(b + "_unnormalized") && x(a.map.id)
+ });
+ v(a)
+ }), m.fromText = u(this, function (d, c) {
+ var e = a.name, g = n(e), B = O;
+ c && (d = c);
+ B && (O = !1);
+ q(g);
+ t(k.config, b) && (k.config[e] = k.config[b]);
+ try {
+ j.exec(d)
+ } catch (ca) {
+ return v(A("fromtexteval",
+ "fromText eval for " + b + " failed: " + ca, ca, [b]))
+ }
+ B && (O = !0);
+ this.depMaps.push(g);
+ i.completeLoad(e);
+ h([e], m)
+ }), d.load(a.name, h, m, k)
+ }));
+ i.enable(e, this);
+ this.pluginMaps[e.id] = e
+ }, enable: function () {
+ T[this.map.id] = this;
+ this.enabling = this.enabled = !0;
+ y(this.depMaps, u(this, function (a, b) {
+ var c, d;
+ if ("string" === typeof a) {
+ a = n(a, this.map.isDefine ? this.map : this.map.parentMap, !1, !this.skipMap);
+ this.depMaps[b] = a;
+ if (c = l(N, a.id)) {
+ this.depExports[b] = c(this);
+ return
+ }
+ this.depCount += 1;
+ s(a, "defined", u(this, function (a) {
+ this.defineDep(b,
+ a);
+ this.check()
+ }));
+ this.errback && s(a, "error", u(this, this.errback))
+ }
+ c = a.id;
+ d = p[c];
+ !t(N, c) && (d && !d.enabled) && i.enable(a, this)
+ }));
+ F(this.pluginMaps, u(this, function (a) {
+ var b = l(p, a.id);
+ b && !b.enabled && i.enable(a, this)
+ }));
+ this.enabling = !1;
+ this.check()
+ }, on: function (a, b) {
+ var c = this.events[a];
+ c || (c = this.events[a] = []);
+ c.push(b)
+ }, emit: function (a, b) {
+ y(this.events[a], function (a) {
+ a(b)
+ });
+ "error" === a && delete this.events[a]
+ }
+ };
+ i = {
+ config: k, contextName: b, registry: p, defined: r, urlFetched: S, defQueue: G, Module: X, makeModuleMap: n,
+ nextTick: j.nextTick, onError: v, configure: function (a) {
+ a.baseUrl && "/" !== a.baseUrl.charAt(a.baseUrl.length - 1) && (a.baseUrl += "/");
+ var b = k.pkgs, c = k.shim, d = {paths: !0, config: !0, map: !0};
+ F(a, function (a, b) {
+ d[b] ? "map" === b ? (k.map || (k.map = {}), Q(k[b], a, !0, !0)) : Q(k[b], a, !0) : k[b] = a
+ });
+ a.shim && (F(a.shim, function (a, b) {
+ I(a) && (a = {deps: a});
+ if ((a.exports || a.init) && !a.exportsFn)a.exportsFn = i.makeShimExports(a);
+ c[b] = a
+ }), k.shim = c);
+ a.packages && (y(a.packages, function (a) {
+ a = "string" === typeof a ? {name: a} : a;
+ b[a.name] = {
+ name: a.name,
+ location: a.location || a.name, main: (a.main || "main").replace(ja, "").replace(ea, "")
+ }
+ }), k.pkgs = b);
+ F(p, function (a, b) {
+ !a.inited && !a.map.unnormalized && (a.map = n(b))
+ });
+ if (a.deps || a.callback)i.require(a.deps || [], a.callback)
+ }, makeShimExports: function (a) {
+ return function () {
+ var b;
+ a.init && (b = a.init.apply(Z, arguments));
+ return b || a.exports && ba(a.exports)
+ }
+ }, makeRequire: function (a, f) {
+ function h(d, c, e) {
+ var g, k;
+ f.enableBuildCallback && (c && H(c)) && (c.__requireJsBuild = !0);
+ if ("string" === typeof d) {
+ if (H(c))return v(A("requireargs",
+ "Invalid require call"), e);
+ if (a && t(N, d))return N[d](p[a.id]);
+ if (j.get)return j.get(i, d, a, h);
+ g = n(d, a, !1, !0);
+ g = g.id;
+ return !t(r, g) ? v(A("notloaded", 'Module name "' + g + '" has not been loaded yet for context: ' + b + (a ? "" : ". Use require([])"))) : r[g]
+ }
+ K();
+ i.nextTick(function () {
+ K();
+ k = q(n(null, a));
+ k.skipMap = f.skipMap;
+ k.init(d, c, e, {enabled: !0});
+ C()
+ });
+ return h
+ }
+
+ f = f || {};
+ Q(h, {
+ isBrowser: z, toUrl: function (b) {
+ var f, e = b.lastIndexOf("."), g = b.split("/")[0];
+ if (-1 !== e && (!("." === g || ".." === g) || 1 < e))f = b.substring(e, b.length), b =
+ b.substring(0, e);
+ return i.nameToUrl(c(b, a && a.id, !0), f, !0)
+ }, defined: function (b) {
+ return t(r, n(b, a, !1, !0).id)
+ }, specified: function (b) {
+ b = n(b, a, !1, !0).id;
+ return t(r, b) || t(p, b)
+ }
+ });
+ a || (h.undef = function (b) {
+ w();
+ var c = n(b, a, !0), f = l(p, b);
+ e(b);
+ delete r[b];
+ delete S[c.url];
+ delete Y[b];
+ f && (f.events.defined && (Y[b] = f.events), x(b))
+ });
+ return h
+ }, enable: function (a) {
+ l(p, a.id) && q(a).enable()
+ }, completeLoad: function (a) {
+ var b, c, d = l(k.shim, a) || {}, e = d.exports;
+ for (w(); G.length;) {
+ c = G.shift();
+ if (null === c[0]) {
+ c[0] = a;
+ if (b)break;
+ b = !0
+ } else c[0] === a && (b = !0);
+ D(c)
+ }
+ c = l(p, a);
+ if (!b && !t(r, a) && c && !c.inited) {
+ if (k.enforceDefine && (!e || !ba(e)))return h(a) ? void 0 : v(A("nodefine", "No define call for " + a, null, [a]));
+ D([a, d.deps || [], d.exportsFn])
+ }
+ C()
+ }, nameToUrl: function (a, b, c) {
+ var d, e, h, g, i, n;
+ if (j.jsExtRegExp.test(a))g = a + (b || ""); else {
+ d = k.paths;
+ e = k.pkgs;
+ g = a.split("/");
+ for (i = g.length; 0 < i; i -= 1)if (n = g.slice(0, i).join("/"), h = l(e, n), n = l(d, n)) {
+ I(n) && (n = n[0]);
+ g.splice(0, i, n);
+ break
+ } else if (h) {
+ a = a === h.name ? h.location + "/" + h.main : h.location;
+ g.splice(0, i,
+ a);
+ break
+ }
+ g = g.join("/");
+ g += b || (/^data\:|\?/.test(g) || c ? "" : ".js");
+ g = ("/" === g.charAt(0) || g.match(/^[\w\+\.\-]+:/) ? "" : k.baseUrl) + g
+ }
+ return k.urlArgs ? g + ((-1 === g.indexOf("?") ? "?" : "&") + k.urlArgs) : g
+ }, load: function (a, b) {
+ j.load(i, a, b)
+ }, execCb: function (a, b, c, d) {
+ return b.apply(d, c)
+ }, onScriptLoad: function (a) {
+ if ("load" === a.type || ka.test((a.currentTarget || a.srcElement).readyState))P = null, a = J(a), i.completeLoad(a.id)
+ }, onScriptError: function (a) {
+ var b = J(a);
+ if (!h(b.id))return v(A("scripterror", "Script error for: " + b.id,
+ a, [b.id]))
+ }
+ };
+ i.require = i.makeRequire();
+ return i
+ }
+
+ var j, w, x, C, J, D, P, K, q, fa, la = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, ma = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, ea = /\.js$/, ja = /^\.\//;
+ w = Object.prototype;
+ var L = w.toString, ga = w.hasOwnProperty, ia = Array.prototype.splice, z = !!("undefined" !== typeof window && "undefined" !== typeof navigator && window.document), da = !z && "undefined" !== typeof importScripts, ka = z && "PLAYSTATION 3" === navigator.platform ? /^complete$/ : /^(complete|loaded)$/, W = "undefined" !== typeof opera &&
+ "[object Opera]" === opera.toString(), E = {}, s = {}, R = [], O = !1;
+ if ("undefined" === typeof define) {
+ if ("undefined" !== typeof requirejs) {
+ if (H(requirejs))return;
+ s = requirejs;
+ requirejs = void 0
+ }
+ "undefined" !== typeof require && !H(require) && (s = require, require = void 0);
+ j = requirejs = function (b, c, e, h) {
+ var q, n = "_";
+ !I(b) && "string" !== typeof b && (q = b, I(c) ? (b = c, c = e, e = h) : b = []);
+ q && q.context && (n = q.context);
+ (h = l(E, n)) || (h = E[n] = j.s.newContext(n));
+ q && h.configure(q);
+ return h.require(b, c, e)
+ };
+ j.config = function (b) {
+ return j(b)
+ };
+ j.nextTick = "undefined" !== typeof setTimeout ? function (b) {
+ setTimeout(b, 4)
+ } : function (b) {
+ b()
+ };
+ require || (require = j);
+ j.version = "2.1.9";
+ j.jsExtRegExp = /^\/|:|\?|\.js$/;
+ j.isBrowser = z;
+ w = j.s = {contexts: E, newContext: ha};
+ j({});
+ y(["toUrl", "undef", "defined", "specified"], function (b) {
+ j[b] = function () {
+ var c = E._;
+ return c.require[b].apply(c, arguments)
+ }
+ });
+ if (z && (x = w.head = document.getElementsByTagName("head")[0], C = document.getElementsByTagName("base")[0]))x = w.head = C.parentNode;
+ j.onError = aa;
+ j.createNode = function (b) {
+ var c = b.xhtml ? document.createElementNS("http://www.w3.org/1999/xhtml",
+ "html:script") : document.createElement("script");
+ c.type = b.scriptType || "text/javascript";
+ c.charset = "utf-8";
+ c.async = !0;
+ return c
+ };
+ j.load = function (b, c, e) {
+ var h = b && b.config || {};
+ if (z)return h = j.createNode(h, c, e), h.setAttribute("data-requirecontext", b.contextName), h.setAttribute("data-requiremodule", c), h.attachEvent && !(h.attachEvent.toString && 0 > h.attachEvent.toString().indexOf("[native code")) && !W ? (O = !0, h.attachEvent("onreadystatechange", b.onScriptLoad)) : (h.addEventListener("load", b.onScriptLoad, !1), h.addEventListener("error",
+ b.onScriptError, !1)), h.src = e, K = h, C ? x.insertBefore(h, C) : x.appendChild(h), K = null, h;
+ if (da)try {
+ importScripts(e), b.completeLoad(c)
+ } catch (l) {
+ b.onError(A("importscripts", "importScripts failed for " + c + " at " + e, l, [c]))
+ }
+ };
+ z && !s.skipDataMain && M(document.getElementsByTagName("script"), function (b) {
+ x || (x = b.parentNode);
+ if (J = b.getAttribute("data-main"))return q = J, s.baseUrl || (D = q.split("/"), q = D.pop(), fa = D.length ? D.join("/") + "/" : "./", s.baseUrl = fa), q = q.replace(ea, ""), j.jsExtRegExp.test(q) && (q = J), s.deps = s.deps ? s.deps.concat(q) :
+ [q], !0
+ });
+ define = function (b, c, e) {
+ var h, j;
+ "string" !== typeof b && (e = c, c = b, b = null);
+ I(c) || (e = c, c = null);
+ !c && H(e) && (c = [], e.length && (e.toString().replace(la, "").replace(ma, function (b, e) {
+ c.push(e)
+ }), c = (1 === e.length ? ["require"] : ["require", "exports", "module"]).concat(c)));
+ if (O) {
+ if (!(h = K))P && "interactive" === P.readyState || M(document.getElementsByTagName("script"), function (b) {
+ if ("interactive" === b.readyState)return P = b
+ }), h = P;
+ h && (b || (b = h.getAttribute("data-requiremodule")), j = E[h.getAttribute("data-requirecontext")])
+ }
+ (j ?
+ j.defQueue : R).push([b, c, e])
+ };
+ define.amd = {jQuery: !0};
+ j.exec = function (b) {
+ return eval(b)
+ };
+ j(s)
+ }
+})(this);
\ No newline at end of file
diff --git a/sdk/src/ui.js b/sdk/src/ui.js
index d4f7ddbc..90bd0a98 100644
--- a/sdk/src/ui.js
+++ b/sdk/src/ui.js
@@ -1,420 +1,420 @@
-F2.extend('UI', (function(){
-
- var _containerConfig;
-
- /**
- * UI helper methods
- * @class F2.UI
- * @constructor
- * @param {F2.AppConfig} appConfig The F2.AppConfig object
- */
- var UI_Class = function(appConfig) {
-
- var _appConfig = appConfig;
- var $root = jQuery(appConfig.root);
-
- var _updateHeight = function(height) {
- height = height || jQuery(_appConfig.root).outerHeight();
-
- if (F2.Rpc.isRemote(_appConfig.instanceId)) {
- F2.Rpc.call(
- _appConfig.instanceId,
- F2.Constants.Sockets.UI_RPC,
- 'updateHeight',
- [
- height
- ]
- );
- } else {
- _appConfig.height = height;
- $root.find('iframe').height(_appConfig.height);
- }
- };
-
- //http://getbootstrap.com/javascript/#modals
- var _modalHtml = function(type,message,showCancel){
- return [
- ''
- ].join('');
- };
-
- return {
- /**
- * Removes a overlay from an Element on the page
- * @method hideMask
- * @param {string|Element} selector The Element or selector to an Element
- * that currently contains the loader
- */
- hideMask: function(selector) {
- F2.UI.hideMask(_appConfig.instanceId, selector);
- },
- /**
- * Helper methods for creating and using Modals
- * @class F2.UI.Modals
- * @for F2.UI
- */
- Modals: (function(){
-
- var _renderAlert = function(message) {
- return _modalHtml('Alert',message);
- };
-
- var _renderConfirm = function(message) {
- return _modalHtml('Confirm',message,true);
- };
-
- return {
- /**
- * Display an alert message on the page
- * @method alert
- * @param {string} message The message to be displayed
- * @param {function} [callback] The callback to be fired when the user
- * closes the dialog
- * @for F2.UI.Modals
- */
- alert: function(message, callback) {
-
- if (!F2.isInit()) {
- F2.log('F2.init() must be called before F2.UI.Modals.alert()');
- return;
- }
-
- if (F2.Rpc.isRemote(_appConfig.instanceId)) {
- F2.Rpc.call(
- _appConfig.instanceId,
- F2.Constants.Sockets.UI_RPC,
- 'Modals.alert',
- [].slice.call(arguments)
- );
- } else {
- // display the alert
- jQuery(_renderAlert(message))
- .on('show.bs.modal', function() {
- var modal = this;
- jQuery(modal).find('.btn-primary').on('click', function() {
- jQuery(modal).modal('hide').remove();
- (callback || jQuery.noop)();
- });
- })
- .modal({backdrop:true});
- }
- },
- /**
- * Display a confirm message on the page
- * @method confirm
- * @param {string} message The message to be displayed
- * @param {function} okCallback The function that will be called when the OK
- * button is pressed
- * @param {function} cancelCallback The function that will be called when
- * the Cancel button is pressed
- * @for F2.UI.Modals
- */
- confirm: function(message, okCallback, cancelCallback) {
-
- if (!F2.isInit()) {
- F2.log('F2.init() must be called before F2.UI.Modals.confirm()');
- return;
- }
-
- if (F2.Rpc.isRemote(_appConfig.instanceId)) {
- F2.Rpc.call(
- _appConfig.instanceId,
- F2.Constants.Sockets.UI_RPC,
- 'Modals.confirm',
- [].slice.call(arguments)
- );
- } else {
- // display the alert
- jQuery(_renderConfirm(message))
- .on('show.bs.modal', function() {
- var modal = this;
-
- jQuery(modal).find('.btn-ok').on('click', function() {
- jQuery(modal).modal('hide').remove();
- (okCallback || jQuery.noop)();
- });
-
- jQuery(modal).find('.btn-cancel').on('click', function() {
- jQuery(modal).modal('hide').remove();
- (cancelCallback || jQuery.noop)();
- });
- })
- .modal({backdrop:true});
- }
- }
- };
- })(),
- /**
- * Sets the title of the app as shown in the browser. Depending on the
- * container HTML, this method may do nothing if the container has not been
- * configured properly or else the container provider does not allow Title's
- * to be set.
- * @method setTitle
- * @params {string} title The title of the app
- * @for F2.UI
- */
- setTitle: function(title) {
-
- if (F2.Rpc.isRemote(_appConfig.instanceId)) {
- F2.Rpc.call(
- _appConfig.instanceId,
- F2.Constants.Sockets.UI_RPC,
- 'setTitle',
- [
- title
- ]
- );
- } else {
- jQuery(_appConfig.root).find('.' + F2.Constants.Css.APP_TITLE).text(title);
- }
- },
- /**
- * Display an ovarlay over an Element on the page
- * @method showMask
- * @param {string|Element} selector The Element or selector to an Element
- * over which to display the loader
- * @param {bool} showLoading Display a loading icon
- */
- showMask: function(selector, showLoader) {
- F2.UI.showMask(_appConfig.instanceId, selector, showLoader);
- },
- /**
- * For secure apps, this method updates the size of the iframe that
- * contains the app. **Note: It is recommended that app developers call
- * this method anytime Elements are added or removed from the DOM**
- * @method updateHeight
- * @params {int} height The height of the app
- */
- updateHeight: _updateHeight,
- /**
- * Helper methods for creating and using Views
- * @class F2.UI.Views
- * @for F2.UI
- */
- Views: (function(){
-
- var _events = new EventEmitter2();
- var _rValidEvents = /change/i;
-
- // unlimited listeners, set to > 0 for debugging
- _events.setMaxListeners(0);
-
- var _isValid = function(eventName) {
- if (_rValidEvents.test(eventName)) {
- return true;
- } else {
- F2.log('"' + eventName + '" is not a valid F2.UI.Views event name');
- return false;
- }
- };
-
- return {
- /**
- * Change the current view for the app or add an event listener
- * @method change
- * @param {string|function} [input] If a string is passed in, the view
- * will be changed for the app. If a function is passed in, a change
- * event listener will be added.
- * @for F2.UI.Views
- */
- change: function(input) {
-
- if (typeof input === 'function') {
- this.on('change', input);
- } else if (typeof input === 'string') {
-
- if (_appConfig.isSecure && !F2.Rpc.isRemote(_appConfig.instanceId)) {
- F2.Rpc.call(
- _appConfig.instanceId,
- F2.Constants.Sockets.UI_RPC,
- 'Views.change',
- [].slice.call(arguments)
- );
- } else if (F2.inArray(input, _appConfig.views)) {
- jQuery('.' + F2.Constants.Css.APP_VIEW, $root)
- .addClass('hide')
- .filter('[data-f2-view="' + input + '"]', $root)
- .removeClass('hide');
-
- _updateHeight();
- _events.emit('change', input);
- }
- }
- },
- /**
- * Removes a view event listener
- * @method off
- * @param {string} event The event name
- * @param {function} listener The function that will be removed
- * @for F2.UI.Views
- */
- off: function(event, listener) {
- if (_isValid(event)) {
- _events.off(event, listener);
- }
- },
- /**
- * Adds a view event listener
- * @method on
- * @param {string} event The event name
- * @param {function} listener The function to be fired when the event is
- * emitted
- * @for F2.UI.Views
- */
- on: function(event, listener) {
- if (_isValid(event)) {
- _events.on(event, listener);
- }
- }
- };
- })()
- };
- };
-
- /**
- * Removes a overlay from an Element on the page
- * @method hideMask
- * @static
- * @param {string} instanceId The Instance ID of the app
- * @param {string|Element} selector The Element or selector to an Element
- * that currently contains the loader
- * @for F2.UI
- */
- UI_Class.hideMask = function(instanceId, selector) {
-
- if (!F2.isInit()) {
- F2.log('F2.init() must be called before F2.UI.hideMask()');
- return;
- }
-
- if (F2.Rpc.isRemote(instanceId) && !jQuery(selector).is('.' + F2.Constants.Css.APP)) {
- F2.Rpc.call(
- instanceId,
- F2.Constants.Sockets.RPC,
- 'F2.UI.hideMask',
- [
- instanceId,
- // must only pass the selector argument. if we pass an Element there
- // will be F2.stringify() errors
- jQuery(selector).selector
- ]
- );
- } else {
-
- var container = jQuery(selector);
- container.find('> .' + F2.Constants.Css.MASK).remove();
- container.removeClass(F2.Constants.Css.MASK_CONTAINER);
-
- // if the element contains this data property, we need to reset static
- // position
- if (container.data(F2.Constants.Css.MASK_CONTAINER)) {
- container.css({'position':'static'});
- }
- }
- };
-
- /**
- *
- * @method init
- * @static
- * @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
- */
- UI_Class.init = function(containerConfig) {
- _containerConfig = containerConfig;
-
- // set defaults
- _containerConfig.UI = jQuery.extend(true, {}, F2.ContainerConfig.UI, _containerConfig.UI || {});
- };
-
- /**
- * Display an ovarlay over an Element on the page
- * @method showMask
- * @static
- * @param {string} instanceId The Instance ID of the app
- * @param {string|Element} selector The Element or selector to an Element
- * over which to display the loader
- * @param {bool} showLoading Display a loading icon
- */
- UI_Class.showMask = function(instanceId, selector, showLoading) {
-
- if (!F2.isInit()) {
- F2.log('F2.init() must be called before F2.UI.showMask()');
- return;
- }
-
- if (F2.Rpc.isRemote(instanceId) && jQuery(selector).is('.' + F2.Constants.Css.APP)) {
- F2.Rpc.call(
- instanceId,
- F2.Constants.Sockets.RPC,
- 'F2.UI.showMask',
- [
- instanceId,
- // must only pass the selector argument. if we pass an Element there
- // will be F2.stringify() errors
- jQuery(selector).selector,
- showLoading
- ]
- );
- } else {
-
- if (showLoading && !_containerConfig.UI.Mask.loadingIcon) {
- F2.log('Unable to display loading icon. Please set F2.ContainerConfig.UI.Mask.loadingIcon when calling F2.init();');
- }
-
- var container = jQuery(selector).addClass(F2.Constants.Css.MASK_CONTAINER);
- var mask = jQuery('')
- .height('100%' /*container.outerHeight()*/)
- .width('100%' /*container.outerWidth()*/)
- .addClass(F2.Constants.Css.MASK);
-
- // set inline styles if useClasses is false
- if (!_containerConfig.UI.Mask.useClasses) {
- mask.css({
- 'background-color':_containerConfig.UI.Mask.backgroundColor,
- 'background-image': !!_containerConfig.UI.Mask.loadingIcon ? ('url(' + _containerConfig.UI.Mask.loadingIcon + ')') : '',
- 'background-position':'50% 50%',
- 'background-repeat':'no-repeat',
- 'display':'block',
- 'left':0,
- 'min-height':30,
- 'padding':0,
- 'position':'absolute',
- 'top':0,
- 'z-index':_containerConfig.UI.Mask.zIndex,
-
- 'filter':'alpha(opacity=' + (_containerConfig.UI.Mask.opacity * 100) + ')',
- 'opacity':_containerConfig.UI.Mask.opacity
- });
- }
-
- // only set the position if the container is currently static
- if (container.css('position') === 'static') {
- container.css({'position':'relative'});
- // setting this data property tells hideMask to set the position
- // back to static
- container.data(F2.Constants.Css.MASK_CONTAINER, true);
- }
-
- // add the mask to the container
- container.append(mask);
- }
- };
-
- return UI_Class;
+F2.extend('UI', (function () {
+
+ var _containerConfig;
+
+ /**
+ * UI helper methods
+ * @class F2.UI
+ * @constructor
+ * @param {F2.AppConfig} appConfig The F2.AppConfig object
+ */
+ var UI_Class = function (appConfig) {
+
+ var _appConfig = appConfig;
+ var $root = jQuery(appConfig.root);
+
+ var _updateHeight = function (height) {
+ height = height || jQuery(_appConfig.root).outerHeight();
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'updateHeight',
+ [
+ height
+ ]
+ );
+ } else {
+ _appConfig.height = height;
+ $root.find('iframe').height(_appConfig.height);
+ }
+ };
+
+ //http://getbootstrap.com/javascript/#modals
+ var _modalHtml = function (type, message, showCancel) {
+ return [
+ '
'
+ ].join('');
+ };
+
+ return {
+ /**
+ * Removes a overlay from an Element on the page
+ * @method hideMask
+ * @param {string|Element} selector The Element or selector to an Element
+ * that currently contains the loader
+ */
+ hideMask: function (selector) {
+ F2.UI.hideMask(_appConfig.instanceId, selector);
+ },
+ /**
+ * Helper methods for creating and using Modals
+ * @class F2.UI.Modals
+ * @for F2.UI
+ */
+ Modals: (function () {
+
+ var _renderAlert = function (message) {
+ return _modalHtml('Alert', message);
+ };
+
+ var _renderConfirm = function (message) {
+ return _modalHtml('Confirm', message, true);
+ };
+
+ return {
+ /**
+ * Display an alert message on the page
+ * @method alert
+ * @param {string} message The message to be displayed
+ * @param {function} [callback] The callback to be fired when the user
+ * closes the dialog
+ * @for F2.UI.Modals
+ */
+ alert: function (message, callback) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.Modals.alert()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Modals.alert',
+ [].slice.call(arguments)
+ );
+ } else {
+ // display the alert
+ jQuery(_renderAlert(message))
+ .on('show.bs.modal', function () {
+ var modal = this;
+ jQuery(modal).find('.btn-primary').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (callback || jQuery.noop)();
+ });
+ })
+ .modal({backdrop: true});
+ }
+ },
+ /**
+ * Display a confirm message on the page
+ * @method confirm
+ * @param {string} message The message to be displayed
+ * @param {function} okCallback The function that will be called when the OK
+ * button is pressed
+ * @param {function} cancelCallback The function that will be called when
+ * the Cancel button is pressed
+ * @for F2.UI.Modals
+ */
+ confirm: function (message, okCallback, cancelCallback) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.Modals.confirm()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Modals.confirm',
+ [].slice.call(arguments)
+ );
+ } else {
+ // display the alert
+ jQuery(_renderConfirm(message))
+ .on('show.bs.modal', function () {
+ var modal = this;
+
+ jQuery(modal).find('.btn-ok').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (okCallback || jQuery.noop)();
+ });
+
+ jQuery(modal).find('.btn-cancel').on('click', function () {
+ jQuery(modal).modal('hide').remove();
+ (cancelCallback || jQuery.noop)();
+ });
+ })
+ .modal({backdrop: true});
+ }
+ }
+ };
+ })(),
+ /**
+ * Sets the title of the app as shown in the browser. Depending on the
+ * container HTML, this method may do nothing if the container has not been
+ * configured properly or else the container provider does not allow Title's
+ * to be set.
+ * @method setTitle
+ * @params {string} title The title of the app
+ * @for F2.UI
+ */
+ setTitle: function (title) {
+
+ if (F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'setTitle',
+ [
+ title
+ ]
+ );
+ } else {
+ jQuery(_appConfig.root).find('.' + F2.Constants.Css.APP_TITLE).text(title);
+ }
+ },
+ /**
+ * Display an ovarlay over an Element on the page
+ * @method showMask
+ * @param {string|Element} selector The Element or selector to an Element
+ * over which to display the loader
+ * @param {bool} showLoading Display a loading icon
+ */
+ showMask: function (selector, showLoader) {
+ F2.UI.showMask(_appConfig.instanceId, selector, showLoader);
+ },
+ /**
+ * For secure apps, this method updates the size of the iframe that
+ * contains the app. **Note: It is recommended that app developers call
+ * this method anytime Elements are added or removed from the DOM**
+ * @method updateHeight
+ * @params {int} height The height of the app
+ */
+ updateHeight: _updateHeight,
+ /**
+ * Helper methods for creating and using Views
+ * @class F2.UI.Views
+ * @for F2.UI
+ */
+ Views: (function () {
+
+ var _events = new EventEmitter2();
+ var _rValidEvents = /change/i;
+
+ // unlimited listeners, set to > 0 for debugging
+ _events.setMaxListeners(0);
+
+ var _isValid = function (eventName) {
+ if (_rValidEvents.test(eventName)) {
+ return true;
+ } else {
+ F2.log('"' + eventName + '" is not a valid F2.UI.Views event name');
+ return false;
+ }
+ };
+
+ return {
+ /**
+ * Change the current view for the app or add an event listener
+ * @method change
+ * @param {string|function} [input] If a string is passed in, the view
+ * will be changed for the app. If a function is passed in, a change
+ * event listener will be added.
+ * @for F2.UI.Views
+ */
+ change: function (input) {
+
+ if (typeof input === 'function') {
+ this.on('change', input);
+ } else if (typeof input === 'string') {
+
+ if (_appConfig.isSecure && !F2.Rpc.isRemote(_appConfig.instanceId)) {
+ F2.Rpc.call(
+ _appConfig.instanceId,
+ F2.Constants.Sockets.UI_RPC,
+ 'Views.change',
+ [].slice.call(arguments)
+ );
+ } else if (F2.inArray(input, _appConfig.views)) {
+ jQuery('.' + F2.Constants.Css.APP_VIEW, $root)
+ .addClass('hide')
+ .filter('[data-f2-view="' + input + '"]', $root)
+ .removeClass('hide');
+
+ _updateHeight();
+ _events.emit('change', input);
+ }
+ }
+ },
+ /**
+ * Removes a view event listener
+ * @method off
+ * @param {string} event The event name
+ * @param {function} listener The function that will be removed
+ * @for F2.UI.Views
+ */
+ off: function (event, listener) {
+ if (_isValid(event)) {
+ _events.off(event, listener);
+ }
+ },
+ /**
+ * Adds a view event listener
+ * @method on
+ * @param {string} event The event name
+ * @param {function} listener The function to be fired when the event is
+ * emitted
+ * @for F2.UI.Views
+ */
+ on: function (event, listener) {
+ if (_isValid(event)) {
+ _events.on(event, listener);
+ }
+ }
+ };
+ })()
+ };
+ };
+
+ /**
+ * Removes a overlay from an Element on the page
+ * @method hideMask
+ * @static
+ * @param {string} instanceId The Instance ID of the app
+ * @param {string|Element} selector The Element or selector to an Element
+ * that currently contains the loader
+ * @for F2.UI
+ */
+ UI_Class.hideMask = function (instanceId, selector) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.hideMask()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(instanceId) && !jQuery(selector).is('.' + F2.Constants.Css.APP)) {
+ F2.Rpc.call(
+ instanceId,
+ F2.Constants.Sockets.RPC,
+ 'F2.UI.hideMask',
+ [
+ instanceId,
+ // must only pass the selector argument. if we pass an Element there
+ // will be F2.stringify() errors
+ jQuery(selector).selector
+ ]
+ );
+ } else {
+
+ var container = jQuery(selector);
+ container.find('> .' + F2.Constants.Css.MASK).remove();
+ container.removeClass(F2.Constants.Css.MASK_CONTAINER);
+
+ // if the element contains this data property, we need to reset static
+ // position
+ if (container.data(F2.Constants.Css.MASK_CONTAINER)) {
+ container.css({'position': 'static'});
+ }
+ }
+ };
+
+ /**
+ *
+ * @method init
+ * @static
+ * @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
+ */
+ UI_Class.init = function (containerConfig) {
+ _containerConfig = containerConfig;
+
+ // set defaults
+ _containerConfig.UI = jQuery.extend(true, {}, F2.ContainerConfig.UI, _containerConfig.UI || {});
+ };
+
+ /**
+ * Display an ovarlay over an Element on the page
+ * @method showMask
+ * @static
+ * @param {string} instanceId The Instance ID of the app
+ * @param {string|Element} selector The Element or selector to an Element
+ * over which to display the loader
+ * @param {bool} showLoading Display a loading icon
+ */
+ UI_Class.showMask = function (instanceId, selector, showLoading) {
+
+ if (!F2.isInit()) {
+ F2.log('F2.init() must be called before F2.UI.showMask()');
+ return;
+ }
+
+ if (F2.Rpc.isRemote(instanceId) && jQuery(selector).is('.' + F2.Constants.Css.APP)) {
+ F2.Rpc.call(
+ instanceId,
+ F2.Constants.Sockets.RPC,
+ 'F2.UI.showMask',
+ [
+ instanceId,
+ // must only pass the selector argument. if we pass an Element there
+ // will be F2.stringify() errors
+ jQuery(selector).selector,
+ showLoading
+ ]
+ );
+ } else {
+
+ if (showLoading && !_containerConfig.UI.Mask.loadingIcon) {
+ F2.log('Unable to display loading icon. Please set F2.ContainerConfig.UI.Mask.loadingIcon when calling F2.init();');
+ }
+
+ var container = jQuery(selector).addClass(F2.Constants.Css.MASK_CONTAINER);
+ var mask = jQuery('
')
+ .height('100%' /*container.outerHeight()*/)
+ .width('100%' /*container.outerWidth()*/)
+ .addClass(F2.Constants.Css.MASK);
+
+ // set inline styles if useClasses is false
+ if (!_containerConfig.UI.Mask.useClasses) {
+ mask.css({
+ 'background-color': _containerConfig.UI.Mask.backgroundColor,
+ 'background-image': !!_containerConfig.UI.Mask.loadingIcon ? ('url(' + _containerConfig.UI.Mask.loadingIcon + ')') : '',
+ 'background-position': '50% 50%',
+ 'background-repeat': 'no-repeat',
+ 'display': 'block',
+ 'left': 0,
+ 'min-height': 30,
+ 'padding': 0,
+ 'position': 'absolute',
+ 'top': 0,
+ 'z-index': _containerConfig.UI.Mask.zIndex,
+
+ 'filter': 'alpha(opacity=' + (_containerConfig.UI.Mask.opacity * 100) + ')',
+ 'opacity': _containerConfig.UI.Mask.opacity
+ });
+ }
+
+ // only set the position if the container is currently static
+ if (container.css('position') === 'static') {
+ container.css({'position': 'relative'});
+ // setting this data property tells hideMask to set the position
+ // back to static
+ container.data(F2.Constants.Css.MASK_CONTAINER, true);
+ }
+
+ // add the mask to the container
+ container.append(mask);
+ }
+ };
+
+ return UI_Class;
})());
\ No newline at end of file
diff --git a/tests/index-amd.html b/tests/index-amd.html
index 076fc3cc..9f9888dd 100644
--- a/tests/index-amd.html
+++ b/tests/index-amd.html
@@ -1,91 +1,97 @@
-
F2 (AMD) - Jasmine Unit Tests
-
-
-
+
F2 (AMD) - Jasmine Unit Tests
+
+
+
-
- The Node.js Test Server is not running. Some tests will not be run.
-
-
-
Testing
-
-
Preload test
-
Preload test2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ The Node.js Test Server is not running. Some tests will not be run.
+
+
+
Testing
+
+
Preload
+ test
+
+
Preload
+ test2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/index.html b/tests/index.html
index f66fbf64..2a9d8f1f 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -1,92 +1,98 @@
+ "http://www.w3.org/TR/html4/loose.dtd">
-
F2 - Jasmine Unit Tests
-
-
-
-
+
F2 - Jasmine Unit Tests
+
+
+
+
-
- The Node.js Test Server is not running. Some tests will not be run.
-
-
-
Testing
-
-
Preload test
-
Preload test2
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ The Node.js Test Server is not running. Some tests will not be run.
+
+
+
Testing
+
+
Preload
+ test
+
+
Preload
+ test2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/js/console-runner.js b/tests/js/console-runner.js
index e1975959..a8474516 100644
--- a/tests/js/console-runner.js
+++ b/tests/js/console-runner.js
@@ -1,104 +1,108 @@
/**
- Jasmine Reporter that outputs test results to the browser console.
+ Jasmine Reporter that outputs test results to the browser console.
Useful for running in a headless environment such as PhantomJs, ZombieJs etc.
Usage:
- // From your html file that loads jasmine:
+ // From your html file that loads jasmine:
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
jasmine.getEnv().execute();
-*/
-
-(function(jasmine, console) {
- if (!jasmine) {
- throw "jasmine library isn't loaded!";
- }
-
- var ANSI = {}
- ANSI.color_map = {
- "green" : 32,
- "red" : 31
- }
-
- ANSI.colorize_text = function(text, color) {
- var color_code = this.color_map[color];
- return "\033[" + color_code + "m" + text + "\033[0m";
- }
-
- var ConsoleReporter = function() {
- if (!console || !console.log) { throw "console isn't present!"; }
- this.status = this.statuses.stopped;
- };
-
- var proto = ConsoleReporter.prototype;
- proto.statuses = {
- stopped : "stopped",
- running : "running",
- fail : "fail",
- success : "success"
- };
-
- proto.reportRunnerStarting = function(runner) {
- this.status = this.statuses.running;
- this.start_time = (new Date()).getTime();
- this.executed_specs = 0;
- this.passed_specs = 0;
- this.log("Starting...");
- };
-
- proto.reportRunnerResults = function(runner) {
- var failed = this.executed_specs - this.passed_specs;
- var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
- var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
- var color = (failed > 0)? "red" : "green";
- var dur = (new Date()).getTime() - this.start_time;
-
- this.log("");
- this.log("Finished");
- this.log("-----------------");
- this.log(spec_str + fail_str + (dur/1000) + "s.", color);
-
- this.status = (failed > 0)? this.statuses.fail : this.statuses.success;
-
- /* Print something that signals that testing is over so that headless browsers
- like PhantomJs know when to terminate. */
- this.log("");
- this.log("ConsoleReporter finished");
- };
-
-
- proto.reportSpecStarting = function(spec) {
- this.executed_specs++;
- };
-
- proto.reportSpecResults = function(spec) {
- if (spec.results().passed()) {
- this.passed_specs++;
- return;
+ */
+
+(function (jasmine, console) {
+ if (!jasmine) {
+ throw "jasmine library isn't loaded!";
}
- var resultText = spec.suite.description + " : " + spec.description;
- this.log(resultText, "red");
+ var ANSI = {}
+ ANSI.color_map = {
+ "green": 32,
+ "red": 31
+ }
- var items = spec.results().getItems()
- for (var i = 0; i < items.length; i++) {
- var trace = items[i].trace.stack || items[i].trace;
- this.log(trace, "red");
+ ANSI.colorize_text = function (text, color) {
+ var color_code = this.color_map[color];
+ return "\033[" + color_code + "m" + text + "\033[0m";
}
- };
-
- proto.reportSuiteResults = function(suite) {
- if (!suite.parentSuite) { return; }
- var results = suite.results();
- var failed = results.totalCount - results.passedCount;
- var color = (failed > 0)? "red" : "green";
- this.log(suite.getFullName() + ": " + results.passedCount + " of " + results.totalCount + " passed.", color);
- };
-
- proto.log = function(str, color) {
- var text = (color != undefined)? ANSI.colorize_text(str, color) : str;
- console.log(text)
- };
-
- jasmine.ConsoleReporter = ConsoleReporter;
+
+ var ConsoleReporter = function () {
+ if (!console || !console.log) {
+ throw "console isn't present!";
+ }
+ this.status = this.statuses.stopped;
+ };
+
+ var proto = ConsoleReporter.prototype;
+ proto.statuses = {
+ stopped: "stopped",
+ running: "running",
+ fail: "fail",
+ success: "success"
+ };
+
+ proto.reportRunnerStarting = function (runner) {
+ this.status = this.statuses.running;
+ this.start_time = (new Date()).getTime();
+ this.executed_specs = 0;
+ this.passed_specs = 0;
+ this.log("Starting...");
+ };
+
+ proto.reportRunnerResults = function (runner) {
+ var failed = this.executed_specs - this.passed_specs;
+ var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
+ var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
+ var color = (failed > 0) ? "red" : "green";
+ var dur = (new Date()).getTime() - this.start_time;
+
+ this.log("");
+ this.log("Finished");
+ this.log("-----------------");
+ this.log(spec_str + fail_str + (dur / 1000) + "s.", color);
+
+ this.status = (failed > 0) ? this.statuses.fail : this.statuses.success;
+
+ /* Print something that signals that testing is over so that headless browsers
+ like PhantomJs know when to terminate. */
+ this.log("");
+ this.log("ConsoleReporter finished");
+ };
+
+
+ proto.reportSpecStarting = function (spec) {
+ this.executed_specs++;
+ };
+
+ proto.reportSpecResults = function (spec) {
+ if (spec.results().passed()) {
+ this.passed_specs++;
+ return;
+ }
+
+ var resultText = spec.suite.description + " : " + spec.description;
+ this.log(resultText, "red");
+
+ var items = spec.results().getItems()
+ for (var i = 0; i < items.length; i++) {
+ var trace = items[i].trace.stack || items[i].trace;
+ this.log(trace, "red");
+ }
+ };
+
+ proto.reportSuiteResults = function (suite) {
+ if (!suite.parentSuite) {
+ return;
+ }
+ var results = suite.results();
+ var failed = results.totalCount - results.passedCount;
+ var color = (failed > 0) ? "red" : "green";
+ this.log(suite.getFullName() + ": " + results.passedCount + " of " + results.totalCount + " passed.", color);
+ };
+
+ proto.log = function (str, color) {
+ var text = (color != undefined) ? ANSI.colorize_text(str, color) : str;
+ console.log(text)
+ };
+
+ jasmine.ConsoleReporter = ConsoleReporter;
})(jasmine, console);
diff --git a/tests/js/initialize.js b/tests/js/initialize.js
index 95fc18e6..713536bb 100644
--- a/tests/js/initialize.js
+++ b/tests/js/initialize.js
@@ -1,18 +1,18 @@
-(function(window) {
+(function (window) {
- // set a variable so that the index page knows the server is up and running
- window.F2_NODE_TEST_SERVER = {};
+ // set a variable so that the index page knows the server is up and running
+ window.F2_NODE_TEST_SERVER = {};
- // pick apart the url to verify that we're running on the node server
- var rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
- url = window.location.href.toLowerCase(),
- parts = rurl.exec(url);
- //console.log(parts);
+ // pick apart the url to verify that we're running on the node server
+ var rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
+ url = window.location.href.toLowerCase(),
+ parts = rurl.exec(url);
+ //console.log(parts);
- // run the tests on the node server if it is running so that the port numbers
- // will match
- if (parts[1] != 'http:' || parts[2] != 'localhost' || parts[3] != '8080') {
- window.location = 'http://localhost:8080/tests' + /\/[\w.+-]+\.html$/.exec(window.location.pathname)[0];
- }
+ // run the tests on the node server if it is running so that the port numbers
+ // will match
+ if (parts[1] != 'http:' || parts[2] != 'localhost' || parts[3] != '8080') {
+ window.location = 'http://localhost:8080/tests' + /\/[\w.+-]+\.html$/.exec(window.location.pathname)[0];
+ }
})(window);
\ No newline at end of file
diff --git a/tests/js/preloadedTest-amd.js b/tests/js/preloadedTest-amd.js
index 45d8ac82..269671c6 100644
--- a/tests/js/preloadedTest-amd.js
+++ b/tests/js/preloadedTest-amd.js
@@ -1,29 +1,33 @@
-require(['../sdk/f2.min.js'], function () {
- F2.Apps[TEST_APP_ID] = (function() {
+require(['../sdk/f2.min.js'], function () {
+ F2.Apps[TEST_APP_ID] = (function () {
- var App_Class = function (appConfig, appContent, root) {
- this.appConfig = appConfig;
- this.appContent = appContent;
- this.ui = appConfig.ui;
- this.$root = $(root);
- this.doNotCallAgain = false;
- };
+ var App_Class = function (appConfig, appContent, root) {
+ this.appConfig = appConfig;
+ this.appContent = appContent;
+ this.ui = appConfig.ui;
+ this.$root = $(root);
+ this.doNotCallAgain = false;
+ };
- App_Class.prototype.init = function () {
- F2.PreloadAppInitializedCounter++;
- var context = this;
- F2.Events.on('PreloadAppCommuncation', function(){ if(!context.doNotCallAgain) { context._handleEmit(); } });
- F2.PreloadAppInitialized = true;
- };
+ App_Class.prototype.init = function () {
+ F2.PreloadAppInitializedCounter++;
+ var context = this;
+ F2.Events.on('PreloadAppCommuncation', function () {
+ if (!context.doNotCallAgain) {
+ context._handleEmit();
+ }
+ });
+ F2.PreloadAppInitialized = true;
+ };
- App_Class.prototype._handleEmit = function (bArg) {
- F2.PreloadRetrievedEmit = true;
- F2.PreloadRetrievedEmitCounter++;
- F2.PreloadTestCompleteCounter++;
- F2.PreloadTestComplete = true;
- this.doNotCallAgain = true;
- };
+ App_Class.prototype._handleEmit = function (bArg) {
+ F2.PreloadRetrievedEmit = true;
+ F2.PreloadRetrievedEmitCounter++;
+ F2.PreloadTestCompleteCounter++;
+ F2.PreloadTestComplete = true;
+ this.doNotCallAgain = true;
+ };
- return App_Class;
- })();
+ return App_Class;
+ })();
});
\ No newline at end of file
diff --git a/tests/js/preloadedTest.js b/tests/js/preloadedTest.js
index 52eb0f94..a422fd1e 100644
--- a/tests/js/preloadedTest.js
+++ b/tests/js/preloadedTest.js
@@ -1,27 +1,31 @@
-F2.Apps[TEST_APP_ID] = (function() {
+F2.Apps[TEST_APP_ID] = (function () {
- var App_Class = function (appConfig, appContent, root) {
- this.appConfig = appConfig;
- this.appContent = appContent;
- this.ui = appConfig.ui;
- this.$root = $(root);
- this.doNotCallAgain = false;
- };
+ var App_Class = function (appConfig, appContent, root) {
+ this.appConfig = appConfig;
+ this.appContent = appContent;
+ this.ui = appConfig.ui;
+ this.$root = $(root);
+ this.doNotCallAgain = false;
+ };
- App_Class.prototype.init = function () {
- F2.PreloadAppInitializedCounter++;
- var context = this;
- F2.Events.on("PreloadAppCommuncation", function(){ if(!context.doNotCallAgain) { context._handleEmit(); } });
- F2.PreloadAppInitialized = true;
- };
+ App_Class.prototype.init = function () {
+ F2.PreloadAppInitializedCounter++;
+ var context = this;
+ F2.Events.on("PreloadAppCommuncation", function () {
+ if (!context.doNotCallAgain) {
+ context._handleEmit();
+ }
+ });
+ F2.PreloadAppInitialized = true;
+ };
- App_Class.prototype._handleEmit = function (bArg) {
- F2.PreloadRetrievedEmit = true;
- F2.PreloadRetrievedEmitCounter++;
- F2.PreloadTestCompleteCounter++;
- F2.PreloadTestComplete = true;
- this.doNotCallAgain = true;
- };
+ App_Class.prototype._handleEmit = function (bArg) {
+ F2.PreloadRetrievedEmit = true;
+ F2.PreloadRetrievedEmitCounter++;
+ F2.PreloadTestCompleteCounter++;
+ F2.PreloadTestComplete = true;
+ this.doNotCallAgain = true;
+ };
- return App_Class;
+ return App_Class;
})();
\ No newline at end of file
diff --git a/tests/js/test.js b/tests/js/test.js
index 4b4fa137..8ce6267f 100644
--- a/tests/js/test.js
+++ b/tests/js/test.js
@@ -1,24 +1,24 @@
-F2.Apps["com_openf2_tests_helloworld"] = (function() {
-
- F2.testAppInitialized = false;
+F2.Apps["com_openf2_tests_helloworld"] = (function () {
- var App_Class = function (appConfig, appContent, root) {
- this.appConfig = appConfig;
- this.appContent = appContent;
- this.ui = appConfig.ui;
- };
+ F2.testAppInitialized = false;
- App_Class.prototype.init = function () {
- F2.destroyAppMethodCalled = false;
- F2.testAppInstanceID = this.appConfig.instanceId;
- F2.testAppInitialized = true;
- F2.testLocaleFromAppConfig = this.appConfig.containerLocale;
- F2.testLocaleSupportFromAppConfig = this.appConfig.localeSupport;
- };
+ var App_Class = function (appConfig, appContent, root) {
+ this.appConfig = appConfig;
+ this.appContent = appContent;
+ this.ui = appConfig.ui;
+ };
- App_Class.prototype.destroy = function () {
- F2.destroyAppMethodCalled = true;
- };
+ App_Class.prototype.init = function () {
+ F2.destroyAppMethodCalled = false;
+ F2.testAppInstanceID = this.appConfig.instanceId;
+ F2.testAppInitialized = true;
+ F2.testLocaleFromAppConfig = this.appConfig.containerLocale;
+ F2.testLocaleSupportFromAppConfig = this.appConfig.localeSupport;
+ };
- return App_Class;
+ App_Class.prototype.destroy = function () {
+ F2.destroyAppMethodCalled = true;
+ };
+
+ return App_Class;
})();
\ No newline at end of file
diff --git a/tests/server.js b/tests/server.js
index 6469f29b..2c9d4fed 100644
--- a/tests/server.js
+++ b/tests/server.js
@@ -3,13 +3,13 @@ var app = express();
app.set('json spaces', 2);
//wrap up AppManifest response
-var getResponse = function(req,id,manifest){
- var body = JSON.stringify(manifest);
- if (req.method == 'POST'){
- return body;
- } else {
- return 'F2_jsonpCallback_' + id + '(' + body + ');';
- }
+var getResponse = function (req, id, manifest) {
+ var body = JSON.stringify(manifest);
+ if (req.method == 'POST') {
+ return body;
+ } else {
+ return 'F2_jsonpCallback_' + id + '(' + body + ');';
+ }
};
/**
@@ -17,67 +17,67 @@ var getResponse = function(req,id,manifest){
* will output an AppManifest with an AppClass that will log some data.
* See container-spec.js and search for httpPostTest
*/
-app.use('/F2/apps/test/http-post', function(req, res) {
- res.setHeader('Content-Type', 'text/javascript');
- res.send(getResponse(req,'com_test_app',{
- inlineScripts: [
- [
- 'F2.Apps["com_test_app"] = function(appConfig, appContent, root) {',
- 'F2.log(appContent.data.method == "POST");',
- '};'
- ].join('')
- ],
- apps: [
- {
- data: {
- method: req.method
- },
- html: '
'
- }
- ]
- }));
+app.use('/F2/apps/test/http-post', function (req, res) {
+ res.setHeader('Content-Type', 'text/javascript');
+ res.send(getResponse(req, 'com_test_app', {
+ inlineScripts: [
+ [
+ 'F2.Apps["com_test_app"] = function(appConfig, appContent, root) {',
+ 'F2.log(appContent.data.method == "POST");',
+ '};'
+ ].join('')
+ ],
+ apps: [
+ {
+ data: {
+ method: req.method
+ },
+ html: '
'
+ }
+ ]
+ }));
});
-app.all('/F2/apps/test/hello-world', function(req,res){
- var manifest = {
- inlineScripts: [],
- scripts: [],
- styles: [],
- apps: [{
- html: '
Hello world!
',
- status: 'success'
- }]
- };
- res.setHeader('Content-Type', 'text/javascript');
- res.send(getResponse(req,'com_openf2_examples_javascript_helloworld',manifest));
+app.all('/F2/apps/test/hello-world', function (req, res) {
+ var manifest = {
+ inlineScripts: [],
+ scripts: [],
+ styles: [],
+ apps: [{
+ html: '
Hello world!
',
+ status: 'success'
+ }]
+ };
+ res.setHeader('Content-Type', 'text/javascript');
+ res.send(getResponse(req, 'com_openf2_examples_javascript_helloworld', manifest));
});
-app.all('/F2/apps/test/market-news', function(req,res){
- var manifest = {
- inlineScripts: [],
- scripts: [],
- styles: [],
- apps: [{
- html: '
Hello market news!
',
- status: 'success'
- }]
- };
- res.setHeader('Content-Type', 'text/javascript');
- res.send(getResponse(req,'com_openf2_examples_csharp_marketnews',manifest));
+app.all('/F2/apps/test/market-news', function (req, res) {
+ var manifest = {
+ inlineScripts: [],
+ scripts: [],
+ styles: [],
+ apps: [{
+ html: '
Hello market news!
',
+ status: 'success'
+ }]
+ };
+ res.setHeader('Content-Type', 'text/javascript');
+ res.send(getResponse(req, 'com_openf2_examples_csharp_marketnews', manifest));
});
-app.all('/F2/apps/test/com_openf2_tests_helloworld', function(req,res){
- var manifest = {
- inlineScripts: [],
- scripts: [],
- styles: [],
- apps: [{
- html: '
Hello world test!
',
- status: 'success'
- }]
- };
- res.setHeader('Content-Type', 'text/javascript');
- res.send(getResponse(req,'com_openf2_tests_helloworld',manifest));
+app.all('/F2/apps/test/com_openf2_tests_helloworld', function (req, res) {
+ var manifest = {
+ inlineScripts: [],
+ scripts: [],
+ styles: [],
+ apps: [{
+ html: '
Hello world test!
',
+ status: 'success'
+ }]
+ };
+ res.setHeader('Content-Type', 'text/javascript');
+ res.send(getResponse(req, 'com_openf2_tests_helloworld', manifest));
});
// export the module for use with grunt
diff --git a/tests/spec/amd-spec.js b/tests/spec/amd-spec.js
index db80c33b..0e71a070 100644
--- a/tests/spec/amd-spec.js
+++ b/tests/spec/amd-spec.js
@@ -1,23 +1,24 @@
-describe('AMD', function() {
+describe('AMD', function () {
- it('should define F2', function() {
+ it('should define F2', function () {
- var isLoaded = false;
+ var isLoaded = false;
- require(["../sdk/f2.min.js"], function (nonGlobalF2) {
- isLoaded = typeof nonGlobalF2 !== "undefined";
- });
+ require(["../sdk/f2.min.js"], function (nonGlobalF2) {
+ isLoaded = typeof nonGlobalF2 !== "undefined";
+ });
- waitsFor(function() {
- //console.log('ping');
- return isLoaded;
- }, 'F2-AMD never loaded', 10000);
+ waitsFor(function () {
+ //console.log('ping');
+ return isLoaded;
+ }, 'F2-AMD never loaded', 10000);
- runs(function() { });
- });
+ runs(function () {
+ });
+ });
+
+ it('should still globally define F2', function () {
+ expect(F2).toBeDefined();
+ });
- it('should still globally define F2', function() {
- expect(F2).toBeDefined();
- });
-
});
\ No newline at end of file
diff --git a/tests/spec/app-handlers-spec.js b/tests/spec/app-handlers-spec.js
index 5fbcad58..7621e85d 100644
--- a/tests/spec/app-handlers-spec.js
+++ b/tests/spec/app-handlers-spec.js
@@ -1,2355 +1,2281 @@
-describe('F2.AppHandlers', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- }
- };
-
- it(
-
- 'should fire beforeAppRender, appRender, or afterAppRender if they are defined in container config and not APP_RENDER_* AppHandler methods.',
- function() {
- var isBeforeAppRenderFired = false;
-
- F2.init({
- beforeAppRender: function()
- {
- isBeforeAppRenderFired = true;
- }
- });
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- throw("I should not fire!");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- throw("I should not fire!");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- throw("I should not fire!");
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return isBeforeAppRenderFired;
- },
- 'beforeAppRender was never fired',
- 3000
- );
-
- runs(function() { expect(isBeforeAppRenderFired).toBeTruthy(); });
- }
- );
-
- it(
- 'should fire app handlers if beforeAppRender, appRender, and afterAppRender are NOT defined in container config',
- function() {
- var isAppRenderBeforeFired = false;
-
- F2.init();
-
- F2.AppHandlers.on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- setTimeout(function(){ isAppRenderBeforeFired = true}, 100);
- }
- ).on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- setTimeout(function(){ isAppRenderBeforeFired = true}, 100);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return isAppRenderBeforeFired;
- },
- 'F2.AppHandlers.on("appRenderBefore") was never fired',
- 3000
- );
-
- runs(function() { expect(isAppRenderBeforeFired).toBeTruthy(); });
- }
- );
-
- it(
- 'should not allow F2.AppHandlers.on() handler registration without valid token',
- function() {
- expect(function(){
- F2.init();
-
- F2.AppHandlers.on(
- "",
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig) {}
- );
-
- F2.registerApps(appConfig(), appManifest());
- }).toThrow();
- }
- );
-
- it(
- 'should not allow F2.AppHandlers.off() handler registration without valid token',
- function() {
- expect(function(){
- F2.init();
-
- F2.AppHandlers.off(
- "",
- F2.Constants.AppHandlers.APP_RENDER_BEFORE
- );
-
- F2.registerApps(appConfig(), appManifest());
- }).toThrow();
- }
- );
-
- it(
- 'F2.AppHandlers.getToken() method should be destroyed after first call.',
- function() {
- // F2.AppHandlers.getToken is called above in the async.beforeEachReloadF2
- expect(F2.AppHandlers.getToken).toBeFalsy();
- }
- );
-
- it(
- 'F2.AppHandlers.__f2GetToken() method should be destroyed after first call.',
- function() {
- // F2.AppHandlers.__f2GetToken is called internally and should no longer exist
- expect(F2.AppHandlers.__f2GetToken).toBeFalsy();
- }
- );
-
- it(
- 'container should not be allowed to trigger F2.AppHandlers.on() events.',
- function() {
- expect(function(){
- F2.init();
-
- F2.AppHandlers.__trigger(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE
- );
- }).toThrow();
- }
- );
-
- it(
- 'F2.AppHandlers should not be required to load apps.',
- function() {
- expect(function(){
- F2.init();
- F2.registerApps(appConfig(), appManifest());
- }).not.toThrow();
- }
- );
-
- it(
- 'render methods should fire sequentially appCreateRoot, appRenderBefore, appRender, and then appRenderAfter.',
- function() {
- var bDone = false;
- var sOrder = null;
- var arOrder = [];
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push(F2.Constants.AppHandlers.APP_CREATE_ROOT);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- arOrder.push(F2.Constants.AppHandlers.APP_RENDER_BEFORE);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- $("body").append($(appConfig.root));
- arOrder.push(F2.Constants.AppHandlers.APP_RENDER);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- arOrder.push(F2.Constants.AppHandlers.APP_RENDER_AFTER);
- sOrder = arOrder.join(",");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers were never fired',
- 3000
- );
-
- runs(function() { expect(sOrder).toBe("appCreateRoot,appRenderBefore,appRender,appRenderAfter"); });
- }
- );
+describe('F2.AppHandlers', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ }
+ };
+
+ it(
+ 'should fire beforeAppRender, appRender, or afterAppRender if they are defined in container config and not APP_RENDER_* AppHandler methods.',
+ function () {
+ var isBeforeAppRenderFired = false;
+
+ F2.init({
+ beforeAppRender: function () {
+ isBeforeAppRenderFired = true;
+ }
+ });
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ throw("I should not fire!");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ throw("I should not fire!");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ throw("I should not fire!");
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return isBeforeAppRenderFired;
+ },
+ 'beforeAppRender was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(isBeforeAppRenderFired).toBeTruthy();
+ });
+ }
+ );
+
+ it(
+ 'should fire app handlers if beforeAppRender, appRender, and afterAppRender are NOT defined in container config',
+ function () {
+ var isAppRenderBeforeFired = false;
+
+ F2.init();
+
+ F2.AppHandlers.on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ setTimeout(function () {
+ isAppRenderBeforeFired = true
+ }, 100);
+ }
+ ).on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ setTimeout(function () {
+ isAppRenderBeforeFired = true
+ }, 100);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return isAppRenderBeforeFired;
+ },
+ 'F2.AppHandlers.on("appRenderBefore") was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(isAppRenderBeforeFired).toBeTruthy();
+ });
+ }
+ );
+
+ it(
+ 'should not allow F2.AppHandlers.on() handler registration without valid token',
+ function () {
+ expect(function () {
+ F2.init();
+
+ F2.AppHandlers.on(
+ "",
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+ }).toThrow();
+ }
+ );
+
+ it(
+ 'should not allow F2.AppHandlers.off() handler registration without valid token',
+ function () {
+ expect(function () {
+ F2.init();
+
+ F2.AppHandlers.off(
+ "",
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+ }).toThrow();
+ }
+ );
+
+ it(
+ 'F2.AppHandlers.getToken() method should be destroyed after first call.',
+ function () {
+ // F2.AppHandlers.getToken is called above in the async.beforeEachReloadF2
+ expect(F2.AppHandlers.getToken).toBeFalsy();
+ }
+ );
+
+ it(
+ 'F2.AppHandlers.__f2GetToken() method should be destroyed after first call.',
+ function () {
+ // F2.AppHandlers.__f2GetToken is called internally and should no longer exist
+ expect(F2.AppHandlers.__f2GetToken).toBeFalsy();
+ }
+ );
+
+ it(
+ 'container should not be allowed to trigger F2.AppHandlers.on() events.',
+ function () {
+ expect(function () {
+ F2.init();
+
+ F2.AppHandlers.__trigger(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE
+ );
+ }).toThrow();
+ }
+ );
+
+ it(
+ 'F2.AppHandlers should not be required to load apps.',
+ function () {
+ expect(function () {
+ F2.init();
+ F2.registerApps(appConfig(), appManifest());
+ }).not.toThrow();
+ }
+ );
+
+ it(
+ 'render methods should fire sequentially appCreateRoot, appRenderBefore, appRender, and then appRenderAfter.',
+ function () {
+ var bDone = false;
+ var sOrder = null;
+ var arOrder = [];
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push(F2.Constants.AppHandlers.APP_CREATE_ROOT);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ arOrder.push(F2.Constants.AppHandlers.APP_RENDER_BEFORE);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ $("body").append($(appConfig.root));
+ arOrder.push(F2.Constants.AppHandlers.APP_RENDER);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ arOrder.push(F2.Constants.AppHandlers.APP_RENDER_AFTER);
+ sOrder = arOrder.join(",");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers were never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(sOrder).toBe("appCreateRoot,appRenderBefore,appRender,appRenderAfter");
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appCreateRoot', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should create appRoot using the apps html if appCreateRoot event is not bound and render appRoot to the page automatically.',
- function() {
- var bDone = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
- var bHasTestAppClass = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bHasTestAppClass = $root.hasClass("test-app");
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasTestAppClass).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'should pass appConfig as only argument to appCreateRoot.',
- function() {
- var bDone = false;
- var bHasAppConfig = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasAppConfig).toBe(true);
- });
- }
- );
-
- it(
- 'respects appCreateRoot setting appConfig.root and appends app html by default.',
- function() {
- var bDone = false;
- var bRootIsH1 = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsH1 = $root.is("h1");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() { expect(bRootIsH1).toBe(true); expect(bRootOnPage).toBe(true); expect(bAppHtmlInRoot).toBe(true); });
- }
- );
-
- it(
- 'fires appCreateRoot functions sequentially.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows manipulation of appConfig.root through out appCreateRoot methods.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
- var bHasBlueClass = false;
- var bHasRedClass = false;
- var bHasTestAttr = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- $(appConfig.root).addClass("blue");
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- $(appConfig.root).addClass("red").attr("data-test", "test");
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bHasBlueClass = $root.hasClass("blue");
- bHasRedClass = $root.hasClass("red");
- bHasTestAttr = !!$root.attr("data-test");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasBlueClass).toBe(true);
- expect(bHasRedClass).toBe(true);
- expect(bHasTestAttr).toBe(true);
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows resetting of appConfig.root.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("specialapp");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appCreateRoot', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should create appRoot using the apps html if appCreateRoot event is not bound and render appRoot to the page automatically.',
+ function () {
+ var bDone = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+ var bHasTestAppClass = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bHasTestAppClass = $root.hasClass("test-app");
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasTestAppClass).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'should pass appConfig as only argument to appCreateRoot.',
+ function () {
+ var bDone = false;
+ var bHasAppConfig = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasAppConfig).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'respects appCreateRoot setting appConfig.root and appends app html by default.',
+ function () {
+ var bDone = false;
+ var bRootIsH1 = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsH1 = $root.is("h1");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bRootIsH1).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'fires appCreateRoot functions sequentially.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows manipulation of appConfig.root through out appCreateRoot methods.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+ var bHasBlueClass = false;
+ var bHasRedClass = false;
+ var bHasTestAttr = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ $(appConfig.root).addClass("blue");
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ $(appConfig.root).addClass("red").attr("data-test", "test");
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bHasBlueClass = $root.hasClass("blue");
+ bHasRedClass = $root.hasClass("red");
+ bHasTestAttr = !!$root.attr("data-test");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasBlueClass).toBe(true);
+ expect(bHasRedClass).toBe(true);
+ expect(bHasTestAttr).toBe(true);
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows resetting of appConfig.root.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("specialapp");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appRenderBefore', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should pass appConfig as only argument to appRenderBefore.',
- function() {
- var bDone = false;
- var bHasAppConfig = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasAppConfig).toBe(true);
- });
- }
- );
-
- it(
- 'should create appRoot using the apps html if appCreateRoot event is not bound and render appRoot to the page automatically.',
- function() {
- var bDone = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
- var bHasTestAppClass = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bHasTestAppClass = $root.hasClass("test-app");
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bHasTestAppClass = $root.hasClass("test-app");
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasTestAppClass).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
-
-
- it(
- 'respects appRenderBefore setting appConfig.root and appends app html by default.',
- function() {
- var bDone = false;
- var bRootIsH1 = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsH1 = $root.is("h1");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bRootIsH1).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'fires appRenderBefore functions sequentially.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows manipulation of appConfig.root through out appRenderBefore methods.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
- var bHasBlueClass = false;
- var bHasRedClass = false;
- var bHasTestAttr = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- $(appConfig.root).addClass("blue");
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- $(appConfig.root).addClass("red").attr("data-test", "test");
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bHasBlueClass = $root.hasClass("blue");
- bHasRedClass = $root.hasClass("red");
- bHasTestAttr = !!$root.attr("data-test");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasBlueClass).toBe(true);
- expect(bHasRedClass).toBe(true);
- expect(bHasTestAttr).toBe(true);
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows resetting of appConfig.root.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_BEFORE,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("specialapp");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appRenderBefore', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should pass appConfig as only argument to appRenderBefore.',
+ function () {
+ var bDone = false;
+ var bHasAppConfig = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasAppConfig).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'should create appRoot using the apps html if appCreateRoot event is not bound and render appRoot to the page automatically.',
+ function () {
+ var bDone = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+ var bHasTestAppClass = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bHasTestAppClass = $root.hasClass("test-app");
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bHasTestAppClass = $root.hasClass("test-app");
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasTestAppClass).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+
+ it(
+ 'respects appRenderBefore setting appConfig.root and appends app html by default.',
+ function () {
+ var bDone = false;
+ var bRootIsH1 = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsH1 = $root.is("h1");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bRootIsH1).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'fires appRenderBefore functions sequentially.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows manipulation of appConfig.root through out appRenderBefore methods.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+ var bHasBlueClass = false;
+ var bHasRedClass = false;
+ var bHasTestAttr = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ $(appConfig.root).addClass("blue");
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ $(appConfig.root).addClass("red").attr("data-test", "test");
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bHasBlueClass = $root.hasClass("blue");
+ bHasRedClass = $root.hasClass("red");
+ bHasTestAttr = !!$root.attr("data-test");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasBlueClass).toBe(true);
+ expect(bHasRedClass).toBe(true);
+ expect(bHasTestAttr).toBe(true);
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows resetting of appConfig.root.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_BEFORE,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("specialapp");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appRender', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should pass appConfig and html as only arguments to appRender.',
- function() {
- var bDone = false;
- var bHasAppConfig = false;
- var bHasHtml = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig, html)
- {
- bHasAppConfig = (arguments.length == 2 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
- bHasHtml = (arguments.length == 2 && html && typeof(html) === "string") ? true : false;
- var $root = $(appConfig.root);
- $root.append(html);
- $("body").append($root);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasAppConfig).toBe(true);
- expect(bHasHtml).toBe(true);
- });
- }
- );
-
- it(
- 'should automatically create appRoot from app html and add app to the page if no appRender method is bound.',
- function() {
- var bDone = false;
- var bRootOnPage = false;
- var bAppIsRoot = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppIsRoot = $root.hasClass("test-app");
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bAppIsRoot).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'respects appRender appending html and putting it on the page manually.',
- function() {
- var bDone = false;
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bRootInParent = false;
- var bAppHtmlInRoot = false;
-
- $("div.app-area").remove();
- $("
").appendTo("body");
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig, html)
- {
- var $root = $(appConfig.root);
- $root.append(html);
-
- $("body div.app-area:first").append($root);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bRootInParent = $root.parent().is("div.app-area");
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bRootInParent).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows dom node to be only argument to appRender. Which renders the app to the dom node.',
- function() {
- var bDone = false;
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bRootInParent = false;
- var bAppHtmlInRoot = false;
-
- // append a placeholder for the app
- $("
").appendTo("body");
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- $("div.app-area:last").get(0)
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bRootInParent = $root.parent().is("div.app-area");
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- $("div.app-area").remove();
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bRootInParent).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'should allow dom node to be only argument to appRender. Which renders the app to the dom node without needing to specifiy appCreateRoot handler.',
- function() {
- var bDone = false;
- var bRootOnPage = false;
- var bRootInParent = false;
- var bRootIsAppHtml = false;
-
- // append a placeholder for the app
- $("
").appendTo("body");
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- $("div.app-area:last").get(0)
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bRootInParent = $root.parent().is("div.app-area");
- bRootIsAppHtml = $root.hasClass("test-app");
- bDone = true;
- $("div.app-area").remove();
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bRootOnPage).toBe(true);
- expect(bRootInParent).toBe(true);
- expect(bRootIsAppHtml).toBe(true);
- });
- }
- );
-
- it(
- 'fires appRender functions sequentially.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bRootInParent = false;
- var bAppHtmlInRoot = false;
-
- // append a placeholder for the app
- $("
").appendTo("body");
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- $("div.app-area").get(0)
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bRootInParent = $root.parent().is("div.app-area");
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bDone = true;
- $("div.app-area").remove();
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bRootInParent).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'allows manipulation of appConfig.root through out appRender methods.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootIsApp = false;
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
- var bHasBlueClass = false;
- var bHasRedClass = false;
- var bHasTestAttr = false;
- var bRootInParent = false;
-
- $("
").appendTo("body");
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_CREATE_ROOT,
- function(appConfig)
- {
- appConfig.root = $("
").get(0);
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- $(appConfig.root).addClass("blue");
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- $("div.app-area").get(0)
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER,
- function(appConfig)
- {
- $(appConfig.root).addClass("red").attr("data-test", "test");
- arOrder.push("3");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootIsApp = $root.is("app");
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
- bHasBlueClass = $root.hasClass("blue");
- bRootInParent = $root.parent().is("div.app-area");
- bHasRedClass = $root.hasClass("red");
- bHasTestAttr = !!$root.attr("data-test");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasBlueClass).toBe(true);
- expect(bHasRedClass).toBe(true);
- expect(bHasTestAttr).toBe(true);
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootIsApp).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- expect(bRootInParent).toBe(true);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appRender', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should pass appConfig and html as only arguments to appRender.',
+ function () {
+ var bDone = false;
+ var bHasAppConfig = false;
+ var bHasHtml = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig, html) {
+ bHasAppConfig = (arguments.length == 2 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
+ bHasHtml = (arguments.length == 2 && html && typeof(html) === "string") ? true : false;
+ var $root = $(appConfig.root);
+ $root.append(html);
+ $("body").append($root);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasAppConfig).toBe(true);
+ expect(bHasHtml).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'should automatically create appRoot from app html and add app to the page if no appRender method is bound.',
+ function () {
+ var bDone = false;
+ var bRootOnPage = false;
+ var bAppIsRoot = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppIsRoot = $root.hasClass("test-app");
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bAppIsRoot).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'respects appRender appending html and putting it on the page manually.',
+ function () {
+ var bDone = false;
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bRootInParent = false;
+ var bAppHtmlInRoot = false;
+
+ $("div.app-area").remove();
+ $("
").appendTo("body");
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig, html) {
+ var $root = $(appConfig.root);
+ $root.append(html);
+
+ $("body div.app-area:first").append($root);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bRootInParent = $root.parent().is("div.app-area");
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bRootInParent).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows dom node to be only argument to appRender. Which renders the app to the dom node.',
+ function () {
+ var bDone = false;
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bRootInParent = false;
+ var bAppHtmlInRoot = false;
+
+ // append a placeholder for the app
+ $("
").appendTo("body");
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ $("div.app-area:last").get(0)
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bRootInParent = $root.parent().is("div.app-area");
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ $("div.app-area").remove();
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bRootInParent).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'should allow dom node to be only argument to appRender. Which renders the app to the dom node without needing to specifiy appCreateRoot handler.',
+ function () {
+ var bDone = false;
+ var bRootOnPage = false;
+ var bRootInParent = false;
+ var bRootIsAppHtml = false;
+
+ // append a placeholder for the app
+ $("
").appendTo("body");
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ $("div.app-area:last").get(0)
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bRootInParent = $root.parent().is("div.app-area");
+ bRootIsAppHtml = $root.hasClass("test-app");
+ bDone = true;
+ $("div.app-area").remove();
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bRootOnPage).toBe(true);
+ expect(bRootInParent).toBe(true);
+ expect(bRootIsAppHtml).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'fires appRender functions sequentially.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bRootInParent = false;
+ var bAppHtmlInRoot = false;
+
+ // append a placeholder for the app
+ $("
").appendTo("body");
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ $("div.app-area").get(0)
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bRootInParent = $root.parent().is("div.app-area");
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bDone = true;
+ $("div.app-area").remove();
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bRootInParent).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'allows manipulation of appConfig.root through out appRender methods.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootIsApp = false;
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+ var bHasBlueClass = false;
+ var bHasRedClass = false;
+ var bHasTestAttr = false;
+ var bRootInParent = false;
+
+ $("
").appendTo("body");
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_CREATE_ROOT,
+ function (appConfig) {
+ appConfig.root = $("
").get(0);
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ $(appConfig.root).addClass("blue");
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ $("div.app-area").get(0)
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER,
+ function (appConfig) {
+ $(appConfig.root).addClass("red").attr("data-test", "test");
+ arOrder.push("3");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootIsApp = $root.is("app");
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.find("div.test-app").length > 0);
+ bHasBlueClass = $root.hasClass("blue");
+ bRootInParent = $root.parent().is("div.app-area");
+ bHasRedClass = $root.hasClass("red");
+ bHasTestAttr = !!$root.attr("data-test");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasBlueClass).toBe(true);
+ expect(bHasRedClass).toBe(true);
+ expect(bHasTestAttr).toBe(true);
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootIsApp).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ expect(bRootInParent).toBe(true);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appRenderAfter', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should pass appConfig as only argument to appRenderAfter.',
- function() {
- var bDone = false;
- var bHasAppConfig = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bHasAppConfig).toBe(true);
- });
- }
- );
-
- it(
- 'should fire appRenderAfter only after app is in dom.',
- function() {
- var bDone = false;
- var bRootOnPage = false;
- var bAppIsRoot = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppIsRoot = $root.hasClass("test-app");
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bAppIsRoot).toBe(true);
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
-
- it(
- 'fires appRenderAfter functions sequentially.',
- function() {
- var bDone = false;
- var arOrder = [];
- var bRootOnPage = false;
- var bAppHtmlInRoot = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- arOrder.push("1");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- arOrder.push("2");
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- arOrder.push("3");
- var $root = $(appConfig.root);
- bRootOnPage = ($root.parents("body:first").length > 0);
- bAppHtmlInRoot = ($root.text() == "Testing");
- bDone = true;
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bDone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(arOrder.join(",")).toBe("1,2,3");
- expect(bRootOnPage).toBe(true);
- expect(bAppHtmlInRoot).toBe(true);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appRenderAfter', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should pass appConfig as only argument to appRenderAfter.',
+ function () {
+ var bDone = false;
+ var bHasAppConfig = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ bHasAppConfig = (arguments.length == 1 && appConfig && appConfig.appId && appConfig.manifestUrl) ? true : false;
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bHasAppConfig).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'should fire appRenderAfter only after app is in dom.',
+ function () {
+ var bDone = false;
+ var bRootOnPage = false;
+ var bAppIsRoot = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppIsRoot = $root.hasClass("test-app");
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bAppIsRoot).toBe(true);
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'fires appRenderAfter functions sequentially.',
+ function () {
+ var bDone = false;
+ var arOrder = [];
+ var bRootOnPage = false;
+ var bAppHtmlInRoot = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ arOrder.push("1");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ arOrder.push("2");
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ arOrder.push("3");
+ var $root = $(appConfig.root);
+ bRootOnPage = ($root.parents("body:first").length > 0);
+ bAppHtmlInRoot = ($root.text() == "Testing");
+ bDone = true;
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bDone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(arOrder.join(",")).toBe("1,2,3");
+ expect(bRootOnPage).toBe(true);
+ expect(bAppHtmlInRoot).toBe(true);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appDestroyBefore', function() {
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should remove on() appDestroyBefore handlers regardless of namespace if no namespace passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
- function()
- {
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace",
- function()
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 700);
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE);
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(false);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
-
- it(
- 'should only remove on() from appDestroyBefore handlers if namespace matches what was passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
- function()
- {
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace",
- function()
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 700);
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace");
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(true);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appDestroyBefore', function () {
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should remove on() appDestroyBefore handlers regardless of namespace if no namespace passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
+ function () {
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace",
+ function () {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 700);
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE);
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(false);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
+
+ it(
+ 'should only remove on() from appDestroyBefore handlers if namespace matches what was passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
+ function () {
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace",
+ function () {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 700);
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE + ".specialNamespace");
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(true);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appDestroy', function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should remove app from page if no appHandlers are declared.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig) {
- $root = $(appConfig.root);
- // setup a boolean to make sure the app is on the page
- bAppStillAround = true;
- // delay execution of removing the app
- setTimeout(function() {
- F2.removeApp(appConfig.instanceId);
- }, 0);
- // delay execution to test that the app is now gone
- setTimeout(function() { bAppGone = true; }, 600);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function() {
- return bAppStillAround;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length).toEqual(1);
- });
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length).toEqual(0);
- });
- }
- );
-
- it('should call app instance .destroy() method if destory method exists.', function(){
- F2.inlineScriptsEvaluated = false;
- F2.init();
- F2.registerApps([{appId:'com_openf2_tests_helloworld', manifestUrl:'/F2/apps/test/com_openf2_tests_helloworld'}], [{"inlineScripts": [], "scripts":["js/test.js"],"apps":[{ html: '
Testing
' }]}]);
-
- waitsFor(
- function()
- {
- return F2.testAppInitialized;
- },
- 'Inline scripts were never evaluated',
- 3000
- );
-
- runs(function() {
- F2.removeApp(F2.testAppInstanceID);
-
- waitsFor(
- function()
- {
- return F2.destroyAppMethodCalled;
- },
- 'destroy() method was never evaluated',
- 3000
- );
-
- runs(function() {
- expect(F2.destroyAppMethodCalled).toBe(true);
- });
- });
- });
-
- it(
- 'should remove on() appDestroy handlers regardless of namespace if no namespace passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY,
- function(appConfig)
- {
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- "appDestroy.specialNamespace",
- function(appConfig)
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 600);
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY);
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(false);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
-
- it(
- 'should only remove on() from appDestroy handlers if namespace matches what was passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY,
- function(appInstance)
- {
- // call the apps destroy method, if it has one
- if(appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == "function")
- {
- appInstance.app.destroy();
- }
- // warn the container developer/app developer that even though they have a destroy method it hasn't been
- else if(appInstance && appInstance.app && appInstance.app.destroy)
- {
- F2.log(app.config.appId + " has a destroy property, but destroy is not of type function and as such will not be executed.");
- }
-
- // fade out and remove the root
- jQuery(appInstance.config.root).fadeOut(250, function() {
- jQuery(this).remove();
- });
-
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- "appDestroy.specialNamespace",
- function(appConfig)
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 400);
- F2.AppHandlers.off(containerAppHandlerToken, "appDestroy.specialNamespace");
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(true);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appDestroy', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should remove app from page if no appHandlers are declared.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ // setup a boolean to make sure the app is on the page
+ bAppStillAround = true;
+ // delay execution of removing the app
+ setTimeout(function () {
+ F2.removeApp(appConfig.instanceId);
+ }, 0);
+ // delay execution to test that the app is now gone
+ setTimeout(function () {
+ bAppGone = true;
+ }, 600);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppStillAround;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length).toEqual(1);
+ });
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length).toEqual(0);
+ });
+ }
+ );
+
+ it('should call app instance .destroy() method if destory method exists.', function () {
+ F2.inlineScriptsEvaluated = false;
+ F2.init();
+ F2.registerApps([{
+ appId: 'com_openf2_tests_helloworld',
+ manifestUrl: '/F2/apps/test/com_openf2_tests_helloworld'
+ }], [{
+ "inlineScripts": [],
+ "scripts": ["js/test.js"],
+ "apps": [{html: '
Testing
'}]
+ }]);
+
+ waitsFor(
+ function () {
+ return F2.testAppInitialized;
+ },
+ 'Inline scripts were never evaluated',
+ 3000
+ );
+
+ runs(function () {
+ F2.removeApp(F2.testAppInstanceID);
+
+ waitsFor(
+ function () {
+ return F2.destroyAppMethodCalled;
+ },
+ 'destroy() method was never evaluated',
+ 3000
+ );
+
+ runs(function () {
+ expect(F2.destroyAppMethodCalled).toBe(true);
+ });
+ });
+ });
+
+ it(
+ 'should remove on() appDestroy handlers regardless of namespace if no namespace passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY,
+ function (appConfig) {
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ "appDestroy.specialNamespace",
+ function (appConfig) {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 600);
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY);
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(false);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
+
+ it(
+ 'should only remove on() from appDestroy handlers if namespace matches what was passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY,
+ function (appInstance) {
+ // call the apps destroy method, if it has one
+ if (appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == "function") {
+ appInstance.app.destroy();
+ }
+ // warn the container developer/app developer that even though they have a destroy method it hasn't been
+ else if (appInstance && appInstance.app && appInstance.app.destroy) {
+ F2.log(app.config.appId + " has a destroy property, but destroy is not of type function and as such will not be executed.");
+ }
+
+ // fade out and remove the root
+ jQuery(appInstance.config.root).fadeOut(250, function () {
+ jQuery(this).remove();
+ });
+
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ "appDestroy.specialNamespace",
+ function (appConfig) {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 400);
+ F2.AppHandlers.off(containerAppHandlerToken, "appDestroy.specialNamespace");
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(true);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - rendering - appDestroyBefore', function() {
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:[],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- it(
- 'should remove on() appDestroyAfter handlers regardless of namespace if no namespace passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_AFTER,
- function()
- {
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace",
- function()
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 700);
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER);
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(false);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
-
- it(
- 'should only remove on() from appDestroyAfter handlers if namespace matches what was passed to off() event.',
- function() {
- var bAppStillAround = false;
- var bAppGone = false;
- var $root = null;
- var bAppDestroyOnMethodCalled = false;
- var bAppDestroyWithNamespaceOnMethodCalled = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_AFTER,
- function()
- {
- bAppDestroyOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace",
- function()
- {
- bAppDestroyWithNamespaceOnMethodCalled = true;
- }
- )
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_RENDER_AFTER,
- function(appConfig)
- {
- $root = $(appConfig.root);
- setTimeout(function() { bAppGone = true; }, 700);
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace");
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bAppGone;
- },
- 'AppHandlers.On( appRenderAfter ) was never fired',
- 3000
- );
-
- runs(function() {
- expect($root.parent().length == 0).toBe(true);
- expect(bAppDestroyOnMethodCalled).toBe(true);
- expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
- });
- }
- );
+describe('F2.AppHandlers - rendering - appDestroyBefore', function () {
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ it(
+ 'should remove on() appDestroyAfter handlers regardless of namespace if no namespace passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_AFTER,
+ function () {
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace",
+ function () {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 700);
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER);
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(false);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
+
+ it(
+ 'should only remove on() from appDestroyAfter handlers if namespace matches what was passed to off() event.',
+ function () {
+ var bAppStillAround = false;
+ var bAppGone = false;
+ var $root = null;
+ var bAppDestroyOnMethodCalled = false;
+ var bAppDestroyWithNamespaceOnMethodCalled = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_AFTER,
+ function () {
+ bAppDestroyOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace",
+ function () {
+ bAppDestroyWithNamespaceOnMethodCalled = true;
+ }
+ )
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_RENDER_AFTER,
+ function (appConfig) {
+ $root = $(appConfig.root);
+ setTimeout(function () {
+ bAppGone = true;
+ }, 700);
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER + ".specialNamespace");
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bAppGone;
+ },
+ 'AppHandlers.On( appRenderAfter ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect($root.parent().length == 0).toBe(true);
+ expect(bAppDestroyOnMethodCalled).toBe(true);
+ expect(bAppDestroyWithNamespaceOnMethodCalled).toBe(false);
+ });
+ }
+ );
});
-describe('F2.AppHandlers - error handling - appScriptLoadFailed',function() {
-
- var containerAppHandlerToken = null;
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() { if(F2.AppHandlers.getToken) { containerAppHandlerToken = F2.AppHandlers.getToken(); } });
-
- var appConfig = function()
- {
- return {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- };
-
- var appManifest = function()
- {
- return {
- scripts:['http://docs.openf2.org/demos/apps/JavaScript/HelloWorld/doesNotExist.js'],
- styles:[],
- inlineScripts:[],
- apps:[
- {
- html: '
Testing
'
- }
- ]
- };
- };
-
- var invalidInlineAppManifest = appManifest();
- invalidInlineAppManifest.scripts = [];
- invalidInlineAppManifest.inlineScripts = ['1alert("a");'];
-
- it(
- 'handler should receive appScriptLoadFailed event due to invalid appjs path',
- function() {
- var bScriptLoadFailedReceived = false;
-
- // Reduce timeout so this unit test doesn't take 7 seconds
- F2.init({scriptErrorTimeout: 100});
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
- function(appConfig, scriptInfo)
- {
- bScriptLoadFailedReceived = true;
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED);
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), appManifest());
-
- waitsFor(
- function()
- {
- return bScriptLoadFailedReceived;
- },
- 'AppHandlers.On( appScriptLoadFailed ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bScriptLoadFailedReceived).toBe(true);
- });
- }
- );
-
- it(
- 'handler should receive appScriptLoadFailed event due to invalid inline script',
- function() {
- var bScriptLoadFailedReceived = false;
-
- F2.init();
-
- F2.AppHandlers
- .on(
- containerAppHandlerToken,
- F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
- function(appConfig, scriptInfo)
- {
- bScriptLoadFailedReceived = true;
- F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED);
- F2.removeApp(appConfig.instanceId);
- }
- );
-
- F2.registerApps(appConfig(), invalidInlineAppManifest);
-
- waitsFor(
- function()
- {
- return bScriptLoadFailedReceived;
- },
- 'AppHandlers.On( appScriptLoadFailed ) was never fired',
- 3000
- );
-
- runs(function() {
- expect(bScriptLoadFailedReceived).toBe(true);
- });
- }
- );
+describe('F2.AppHandlers - error handling - appScriptLoadFailed', function () {
+
+ var containerAppHandlerToken = null;
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ if (F2.AppHandlers.getToken) {
+ containerAppHandlerToken = F2.AppHandlers.getToken();
+ }
+ });
+
+ var appConfig = function () {
+ return {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ };
+
+ var appManifest = function () {
+ return {
+ scripts: ['http://docs.openf2.org/demos/apps/JavaScript/HelloWorld/doesNotExist.js'],
+ styles: [],
+ inlineScripts: [],
+ apps: [
+ {
+ html: '
Testing
'
+ }
+ ]
+ };
+ };
+
+ var invalidInlineAppManifest = appManifest();
+ invalidInlineAppManifest.scripts = [];
+ invalidInlineAppManifest.inlineScripts = ['1alert("a");'];
+
+ it(
+ 'handler should receive appScriptLoadFailed event due to invalid appjs path',
+ function () {
+ var bScriptLoadFailedReceived = false;
+
+ // Reduce timeout so this unit test doesn't take 7 seconds
+ F2.init({scriptErrorTimeout: 100});
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
+ function (appConfig, scriptInfo) {
+ bScriptLoadFailedReceived = true;
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED);
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), appManifest());
+
+ waitsFor(
+ function () {
+ return bScriptLoadFailedReceived;
+ },
+ 'AppHandlers.On( appScriptLoadFailed ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bScriptLoadFailedReceived).toBe(true);
+ });
+ }
+ );
+
+ it(
+ 'handler should receive appScriptLoadFailed event due to invalid inline script',
+ function () {
+ var bScriptLoadFailedReceived = false;
+
+ F2.init();
+
+ F2.AppHandlers
+ .on(
+ containerAppHandlerToken,
+ F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
+ function (appConfig, scriptInfo) {
+ bScriptLoadFailedReceived = true;
+ F2.AppHandlers.off(containerAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED);
+ F2.removeApp(appConfig.instanceId);
+ }
+ );
+
+ F2.registerApps(appConfig(), invalidInlineAppManifest);
+
+ waitsFor(
+ function () {
+ return bScriptLoadFailedReceived;
+ },
+ 'AppHandlers.On( appScriptLoadFailed ) was never fired',
+ 3000
+ );
+
+ runs(function () {
+ expect(bScriptLoadFailedReceived).toBe(true);
+ });
+ }
+ );
});
diff --git a/tests/spec/console-test.js b/tests/spec/console-test.js
index 10fa3699..598fad39 100644
--- a/tests/spec/console-test.js
+++ b/tests/spec/console-test.js
@@ -1,14 +1,14 @@
-describe("Console", function() {
- it ("should fail", function() {
- expect(false).toBeFalsy();
- });
-
- it ("should succeed", function() {
- expect(true).toBeTruthy();
- });
-
- it ("jQuery exists", function() {
- expect(!!jQuery).toBeTruthy();
- });
-
+describe("Console", function () {
+ it("should fail", function () {
+ expect(false).toBeFalsy();
+ });
+
+ it("should succeed", function () {
+ expect(true).toBeTruthy();
+ });
+
+ it("jQuery exists", function () {
+ expect(!!jQuery).toBeTruthy();
+ });
+
});
\ No newline at end of file
diff --git a/tests/spec/container-spec.js b/tests/spec/container-spec.js
index 6140b876..4f3e8588 100644
--- a/tests/spec/container-spec.js
+++ b/tests/spec/container-spec.js
@@ -1,1637 +1,1672 @@
-describe('F2.registerApps - pre-load', function() {
-
- it('should throw exception if F2.init() is not called prior', function() {
- expect(function() {
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL,
- root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
- };
-
- F2.registerApps([appConfig]);
- }).toLog('F2.init() must be called before F2.registerApps()');
- });
-
- it('should throw exception if no appConfigs are passed.', function() {
- expect(function() {
- F2.init();
- F2.registerApps();
- }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
- });
-
- it('should allow you to pass single appConfig as object to F2.registerApps', function() {
- expect(function() {
- F2.init();
- var appConfig = {
- appId: TEST_APP_ID,
- root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
- };
- F2.registerApps(appConfig);
- }).not.toThrow();
- });
-
- it('should not require appConfig.manifestUrl when passing pre-load appConfig to F2.registerApps', function() {
- expect(function() {
- F2.init();
- var appConfig = {
- appId: TEST_APP_ID,
- root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
- };
- F2.registerApps(appConfig);
- }).not.toLog('"manifestUrl" missing from app object');
- });
-
- it('should throw exception if you pass an invalid appConfig to F2.registerApps', function() {
- expect(function() {
- F2.init();
- F2.registerApps({});
- }).toLog('"appId" missing from app object');
- });
-
- it('should request apps without valid root property and auto init pre-load apps with root when passing mix to F2.registerApps', function() {
- var bAfterFired = false
- F2.PreloadTestComplete = false;
- F2.PreloadAppInitialized = false;
- F2.PreloadRetrievedEmit = false;
-
- var appConfigs = [{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }, {
- appId: TEST_APP_ID,
- root: $("body").find('div.' + TEST_APP_ID + ':first').get(0)
- }];
-
- F2.init();
-
- F2.AppHandlers.on(F2.AppHandlers.getToken(), F2.Constants.AppHandlers.APP_RENDER_AFTER, function() {
- bAfterFired = true;
- });
-
- F2.registerApps(appConfigs);
-
- waitsFor(
- function() {
- return bAfterFired;
- },
- 'appRenderAfter was never fired',
- 10000
- );
-
- runs(function() {
- F2.Events.emit("PreloadAppCommuncation", [true]);
- expect(bAfterFired).toBeTruthy();
- expect(F2.PreloadTestComplete).toBe(true);
- //expect(F2.PreloadRetrievedEmit).toBe(true);
- });
- });
-
- it('should allow you to init/register apps that are already on the page.', function() {
-
- F2.PreloadTestComplete = false;
- F2.PreloadAppInitialized = false;
- F2.PreloadRetrievedEmit = false;
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL,
- root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
- };
-
- F2.init();
-
- // init is called above
- F2.registerApps([appConfig]);
-
- waitsFor(
- function() {
- return F2.PreloadAppInitialized;
- },
- 'Emit retrieve was never fired',
- 10000
- );
-
- runs(function() {
- // fires the emit to make sure the app is actually listening
- F2.Events.emit("PreloadAppCommuncation", [true]);
- expect(F2.PreloadTestComplete).toBe(true);
- expect(F2.PreloadRetrievedEmit).toBe(true);
- F2.removeApp(appConfig.removeApp);
- });
- });
-
- it('should allow you to init/register multiple of the same app that are already on the page.', function() {
-
- F2.PreloadTestComplete = false;
- F2.PreloadAppInitialized = false;
- F2.PreloadRetrievedEmit = false;
- F2.PreloadTestCompleteCounter = 0;
- F2.PreloadAppInitializedCounter = 0;
- F2.PreloadRetrievedEmitCounter = 0;
-
- var $appsOnPage = $("body").find("div." + TEST_APP_ID);
- var appConfigs = [{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL,
- root: $appsOnPage.get(0)
- }, {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL,
- root: $appsOnPage.get(1)
- }];
-
- // init is called above
- F2.registerApps(appConfigs);
-
- waitsFor(
- function() {
- return (F2.PreloadAppInitializedCounter == 2);
- },
- 'Emit retrieve was never fired',
- 10000
- );
-
- runs(function() {
- // fires the emit to make sure the app is actually listening
- F2.Events.emit("PreloadAppCommuncation", [true]);
- expect(F2.PreloadTestCompleteCounter).toBe(2);
- expect(F2.PreloadRetrievedEmitCounter).toBe(2);
- });
- });
+describe('F2.registerApps - pre-load', function () {
+
+ it('should throw exception if F2.init() is not called prior', function () {
+ expect(function () {
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL,
+ root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
+ };
+
+ F2.registerApps([appConfig]);
+ }).toLog('F2.init() must be called before F2.registerApps()');
+ });
+
+ it('should throw exception if no appConfigs are passed.', function () {
+ expect(function () {
+ F2.init();
+ F2.registerApps();
+ }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
+ });
+
+ it('should allow you to pass single appConfig as object to F2.registerApps', function () {
+ expect(function () {
+ F2.init();
+ var appConfig = {
+ appId: TEST_APP_ID,
+ root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
+ };
+ F2.registerApps(appConfig);
+ }).not.toThrow();
+ });
+
+ it('should not require appConfig.manifestUrl when passing pre-load appConfig to F2.registerApps', function () {
+ expect(function () {
+ F2.init();
+ var appConfig = {
+ appId: TEST_APP_ID,
+ root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
+ };
+ F2.registerApps(appConfig);
+ }).not.toLog('"manifestUrl" missing from app object');
+ });
+
+ it('should throw exception if you pass an invalid appConfig to F2.registerApps', function () {
+ expect(function () {
+ F2.init();
+ F2.registerApps({});
+ }).toLog('"appId" missing from app object');
+ });
+
+ it('should request apps without valid root property and auto init pre-load apps with root when passing mix to F2.registerApps', function () {
+ var bAfterFired = false
+ F2.PreloadTestComplete = false;
+ F2.PreloadAppInitialized = false;
+ F2.PreloadRetrievedEmit = false;
+
+ var appConfigs = [{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }, {
+ appId: TEST_APP_ID,
+ root: $("body").find('div.' + TEST_APP_ID + ':first').get(0)
+ }];
+
+ F2.init();
+
+ F2.AppHandlers.on(F2.AppHandlers.getToken(), F2.Constants.AppHandlers.APP_RENDER_AFTER, function () {
+ bAfterFired = true;
+ });
+
+ F2.registerApps(appConfigs);
+
+ waitsFor(
+ function () {
+ return bAfterFired;
+ },
+ 'appRenderAfter was never fired',
+ 10000
+ );
+
+ runs(function () {
+ F2.Events.emit("PreloadAppCommuncation", [true]);
+ expect(bAfterFired).toBeTruthy();
+ expect(F2.PreloadTestComplete).toBe(true);
+ //expect(F2.PreloadRetrievedEmit).toBe(true);
+ });
+ });
+
+ it('should allow you to init/register apps that are already on the page.', function () {
+
+ F2.PreloadTestComplete = false;
+ F2.PreloadAppInitialized = false;
+ F2.PreloadRetrievedEmit = false;
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL,
+ root: $("body").find("div." + TEST_APP_ID + ":first").get(0)
+ };
+
+ F2.init();
+
+ // init is called above
+ F2.registerApps([appConfig]);
+
+ waitsFor(
+ function () {
+ return F2.PreloadAppInitialized;
+ },
+ 'Emit retrieve was never fired',
+ 10000
+ );
+
+ runs(function () {
+ // fires the emit to make sure the app is actually listening
+ F2.Events.emit("PreloadAppCommuncation", [true]);
+ expect(F2.PreloadTestComplete).toBe(true);
+ expect(F2.PreloadRetrievedEmit).toBe(true);
+ F2.removeApp(appConfig.removeApp);
+ });
+ });
+
+ it('should allow you to init/register multiple of the same app that are already on the page.', function () {
+
+ F2.PreloadTestComplete = false;
+ F2.PreloadAppInitialized = false;
+ F2.PreloadRetrievedEmit = false;
+ F2.PreloadTestCompleteCounter = 0;
+ F2.PreloadAppInitializedCounter = 0;
+ F2.PreloadRetrievedEmitCounter = 0;
+
+ var $appsOnPage = $("body").find("div." + TEST_APP_ID);
+ var appConfigs = [{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL,
+ root: $appsOnPage.get(0)
+ }, {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL,
+ root: $appsOnPage.get(1)
+ }];
+
+ // init is called above
+ F2.registerApps(appConfigs);
+
+ waitsFor(
+ function () {
+ return (F2.PreloadAppInitializedCounter == 2);
+ },
+ 'Emit retrieve was never fired',
+ 10000
+ );
+
+ runs(function () {
+ // fires the emit to make sure the app is actually listening
+ F2.Events.emit("PreloadAppCommuncation", [true]);
+ expect(F2.PreloadTestCompleteCounter).toBe(2);
+ expect(F2.PreloadRetrievedEmitCounter).toBe(2);
+ });
+ });
});
-describe('F2.init', function() {
+describe('F2.init', function () {
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
- it('should allow for no parameters', function() {
- F2.init();
- });
+ it('should allow for no parameters', function () {
+ F2.init();
+ });
- it('should allow for an empty object parameter', function() {
- F2.init({});
- });
+ it('should allow for an empty object parameter', function () {
+ F2.init({});
+ });
});
-describe('F2.init - loader overrides', function() {
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
-
- var appManifest = {
- scripts: [],
- styles: [],
- inlineScripts: [],
- apps: [{
- html: '
Testing
'
- }]
- };
-
- it('should allow the container to provide a custom "loadScripts", "loadInlineScripts", "loadStyles" function', function() {
- var didCallScripts = false;
- var didCallInlineScripts = false;
- var didCallStyles = false;
- var didRender = false;
-
- F2.init({
- loadScripts: function(scripts, cb) {
- didCallScripts = true;
- cb();
- },
- loadInlineScripts: function(inlines, cb) {
- didCallInlineScripts = true;
- cb();
- },
- loadStyles: function(styles, cb) {
- didCallStyles = true;
- cb();
- },
- beforeAppRender: function() {
- didRender = true;
- }
- });
-
- F2.registerApps([appConfig], [appManifest]);
-
- waitsFor(function() {
- return didRender;
- }, 3000);
-
- runs(function() {
- expect(didCallScripts && didCallInlineScripts && didCallStyles).toBe(true);
- });
- });
-
- it('should not load scripts, inlines, or styles if the user provides overrides', function() {
- var didRender = false;
- var didLoadScripts = false;
- var didLoadInlineScripts = false;
- var didLoadStyles = false;
-
- F2.init({
- loadScripts: function(scripts, cb) {
- cb();
- },
- loadInlineScripts: function(inlines, cb) {
- cb();
- },
- loadStyles: function(styles, cb) {
- cb();
- },
- beforeAppRender: function() {
- didRender = true;
- }
- });
-
- F2.registerApps([appConfig], [{
- 'inlineScripts': ['window.inlinesLoaded = true;'],
- 'scripts': ['js/test_global.js'],
- 'styles': ['css/test.css'],
- 'apps': [{
- 'html': '
'
- }]
- }]);
-
- waitsFor(function() {
- return didRender;
- }, 3000);
-
- // See if the script exists
- if (window.test_global) {
- didLoadScripts = true;
- }
-
- // See if the inlines exist
- if (window.inlinesLoaded) {
- didLoadInlineScripts = true;
- }
-
- // See if the styles exist
- $("head link[rel=stylesheet]").each(function(i, link) {
- if (link.href.indexOf("test.css") != -1) {
- didLoadStyles = true;
- return false;
- }
- });
-
- runs(function() {
- expect(didLoadScripts && didLoadInlineScripts && didLoadStyles).toBe(false);
- });
- });
+describe('F2.init - loader overrides', function () {
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+
+ var appManifest = {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [{
+ html: '
Testing
'
+ }]
+ };
+
+ it('should allow the container to provide a custom "loadScripts", "loadInlineScripts", "loadStyles" function', function () {
+ var didCallScripts = false;
+ var didCallInlineScripts = false;
+ var didCallStyles = false;
+ var didRender = false;
+
+ F2.init({
+ loadScripts: function (scripts, cb) {
+ didCallScripts = true;
+ cb();
+ },
+ loadInlineScripts: function (inlines, cb) {
+ didCallInlineScripts = true;
+ cb();
+ },
+ loadStyles: function (styles, cb) {
+ didCallStyles = true;
+ cb();
+ },
+ beforeAppRender: function () {
+ didRender = true;
+ }
+ });
+
+ F2.registerApps([appConfig], [appManifest]);
+
+ waitsFor(function () {
+ return didRender;
+ }, 3000);
+
+ runs(function () {
+ expect(didCallScripts && didCallInlineScripts && didCallStyles).toBe(true);
+ });
+ });
+
+ it('should not load scripts, inlines, or styles if the user provides overrides', function () {
+ var didRender = false;
+ var didLoadScripts = false;
+ var didLoadInlineScripts = false;
+ var didLoadStyles = false;
+
+ F2.init({
+ loadScripts: function (scripts, cb) {
+ cb();
+ },
+ loadInlineScripts: function (inlines, cb) {
+ cb();
+ },
+ loadStyles: function (styles, cb) {
+ cb();
+ },
+ beforeAppRender: function () {
+ didRender = true;
+ }
+ });
+
+ F2.registerApps([appConfig], [{
+ 'inlineScripts': ['window.inlinesLoaded = true;'],
+ 'scripts': ['js/test_global.js'],
+ 'styles': ['css/test.css'],
+ 'apps': [{
+ 'html': '
'
+ }]
+ }]);
+
+ waitsFor(function () {
+ return didRender;
+ }, 3000);
+
+ // See if the script exists
+ if (window.test_global) {
+ didLoadScripts = true;
+ }
+
+ // See if the inlines exist
+ if (window.inlinesLoaded) {
+ didLoadInlineScripts = true;
+ }
+
+ // See if the styles exist
+ $("head link[rel=stylesheet]").each(function (i, link) {
+ if (link.href.indexOf("test.css") != -1) {
+ didLoadStyles = true;
+ return false;
+ }
+ });
+
+ runs(function () {
+ expect(didLoadScripts && didLoadInlineScripts && didLoadStyles).toBe(false);
+ });
+ });
});
-describe('F2.init - xhr overrides', function() {
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() {
- // nothing to do after reload
- });
-
- it('should throw an exception when ContainerConfig.xhr is not an object or function', function() {
- expect(function() {
- F2.init({
- xhr: true
- });
- }).toThrow('ContainerConfig.xhr should be a function or an object');
- });
-
- it('should throw an exception when xhr.dataType is not a function', function() {
- expect(function() {
- F2.init({
- xhr: {
- dataType: true
- }
- });
- }).toThrow(new Error('ContainerConfig.xhr.dataType should be a function'));
- });
-
- it('should throw an exception when xhr.type is not a function', function() {
- expect(function() {
- F2.init({
- xhr: {
- type: true
- }
- });
- F2.registerApps(appConfig);
- }).toThrow(new Error('ContainerConfig.xhr.type should be a function'));
- });
-
- it('should throw an exception when xhr.url is not a function', function() {
- expect(function() {
- F2.init({
- xhr: {
- url: true
- }
- });
- F2.registerApps(appConfig);
- }).toThrow(new Error('ContainerConfig.xhr.url should be a function'));
- });
+describe('F2.init - xhr overrides', function () {
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ // nothing to do after reload
+ });
+
+ it('should throw an exception when ContainerConfig.xhr is not an object or function', function () {
+ expect(function () {
+ F2.init({
+ xhr: true
+ });
+ }).toThrow('ContainerConfig.xhr should be a function or an object');
+ });
+
+ it('should throw an exception when xhr.dataType is not a function', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ dataType: true
+ }
+ });
+ }).toThrow(new Error('ContainerConfig.xhr.dataType should be a function'));
+ });
+
+ it('should throw an exception when xhr.type is not a function', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ type: true
+ }
+ });
+ F2.registerApps(appConfig);
+ }).toThrow(new Error('ContainerConfig.xhr.type should be a function'));
+ });
+
+ it('should throw an exception when xhr.url is not a function', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ url: true
+ }
+ });
+ F2.registerApps(appConfig);
+ }).toThrow(new Error('ContainerConfig.xhr.url should be a function'));
+ });
});
-describe('F2.isInit', function() {
+describe('F2.isInit', function () {
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
- it('should return false when F2.init has not been called', function() {
- expect(F2.isInit()).toBeFalsy();
- });
+ it('should return false when F2.init has not been called', function () {
+ expect(F2.isInit()).toBeFalsy();
+ });
- it('should return true when F2.init has been called', function() {
- F2.init();
- expect(F2.isInit()).toBeTruthy();
- });
+ it('should return true when F2.init has been called', function () {
+ F2.init();
+ expect(F2.isInit()).toBeTruthy();
+ });
});
-describe('F2.init - internationalization', function() {
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL,
- localeSupport: ['en-us','de-de']
- };
-
- var appManifest = {
- scripts: [],
- styles: [],
- inlineScripts: [],
- apps: [{
- html: '
Testing
'
- }]
- };
-
- it('should not fail F2.init when locale is undefined', function() {
- F2.init();
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(F2.isInit()).toBeTruthy();
- });
- });
-
- it('F2.getContainerLocale() should return null when locale is undefined', function() {
- F2.init();
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(F2.getContainerLocale()).toBe(null);
- });
- });
-
- it('F2.getContainerLocale() should return current locale', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(F2.getContainerLocale()).toBe('en-us');
- });
- });
-
- it('F2.getContainerLocale() should be a string', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(typeof F2.getContainerLocale() == 'string').toBeTruthy();
- });
- });
-
- it('F2.getContainerLocale() should be a valid IETF tag', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- //see http://www.w3.org/TR/xmlschema11-2/#language
- expect( /[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*/.test( F2.getContainerLocale() ) ).toBeTruthy();
- });
- });
-
- it('should not modify original appConfig', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(appConfig.containerLocale).toBeFalsy();
- expect(appConfig.locale).toBeFalsy();
- });
- });
-
- it('app should receive locale as "containerLocale" in appConfig', function() {
- F2.testLocaleFromAppConfig = false;
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps([{appId:'com_openf2_tests_helloworld', manifestUrl:'/F2/apps/test/com_openf2_tests_helloworld'}], [{"inlineScripts": [], "scripts":["js/test.js"],"apps":[{ html: '
Testing
' }]}]);
-
- waitsFor(
- function(){
- return F2.testLocaleFromAppConfig;
- },
- 'containerLocale not defined in AppClass',
- 3000
- );
-
- runs(function() {
- expect(F2.testLocaleFromAppConfig == F2.getContainerLocale()).toBeTruthy();
- });
- });
-
- it('app should not receive locale as "containerLocale" in appConfig when locale is not defined', function() {
- F2.init();
- F2.registerApps([{appId:'com_openf2_tests_helloworld', manifestUrl:'/F2/apps/test/com_openf2_tests_helloworld'}], [{"inlineScripts": [], "scripts":["js/test.js"],"apps":[{ html: '
Testing
' }]}]);
-
- waitsFor(
- function(){
- return !F2.testLocaleFromAppConfig;
- },
- 'containerLocale is defined in AppClass',
- 3000
- );
-
- runs(function() {
- expect(F2.testLocaleFromAppConfig).toBeFalsy();
- });
- });
-
- it('should update containerLocale when CONTAINER_LOCALE_CHANGE is fired', function() {
- var _locale;
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- //listen for changes
- F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(data){
- _locale = data.locale;
- });
- //nothing should be changed
- expect(F2.getContainerLocale() == 'en-us').toBeTruthy();
- //now change locale
- F2.Events.emit(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,{
- locale: 'de-de'
- });
- //now locale should be changed
- expect(F2.getContainerLocale() == 'de-de').toBeTruthy();
- });
- });
-
- it('should update containerLocale when CONTAINER_LOCALE_CHANGE is fired after being undefined', function() {
- var _locale;
- F2.init();
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- //listen for changes
- F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(data){
- _locale = data.locale;
- });
- //locale was not defined, should be null
- expect(F2.getContainerLocale()).toBe(null);
- //now change locale
- F2.Events.emit(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,{
- locale: 'de-de'
- });
- //now locale should be changed
- expect(F2.getContainerLocale() == 'de-de').toBeTruthy();
- });
- });
-
- it('AppManifest should support localeSupport property', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(appConfig.localeSupport).toBeTruthy();
- });
- });
-
- it('AppManifest\'s localeSupport property should be an array', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(typeof appConfig.localeSupport == 'object').toBeTruthy();
- });
- });
-
- it('AppManifest\'s localeSupport property should have 2 items', function() {
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps(appConfig,appManifest);
- runs(function() {
- expect(appConfig.localeSupport.length == 2).toBeTruthy();
- });
- });
-
- it('app should receive localeSupport in appConfig', function() {
- F2.testLocaleSupportFromAppConfig = false;
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps([{appId:'com_openf2_tests_helloworld', manifestUrl:'/F2/apps/test/com_openf2_tests_helloworld',localeSupport:['en-us','de-de']}], [{"inlineScripts": [], "scripts":["js/test.js"],"apps":[{ html: '
Testing
' }]}]);
-
- waitsFor(
- function(){
- return F2.testLocaleSupportFromAppConfig;
- },
- 'localeSupport not defined in AppClass',
- 3000
- );
-
- runs(function() {
- expect(F2.testLocaleSupportFromAppConfig).toBeTruthy();
- });
- });
-
- it('app should receive localeSupport in appConfig and have 2 items', function() {
- F2.testLocaleSupportFromAppConfig = false;
- F2.init({
- locale: 'en-us'
- });
- F2.registerApps([{appId:'com_openf2_tests_helloworld', manifestUrl:'/F2/apps/test/com_openf2_tests_helloworld',localeSupport:['en-us','de-de']}], [{"inlineScripts": [], "scripts":["js/test.js"],"apps":[{ html: '
Testing
' }]}]);
-
- waitsFor(
- function(){
- return F2.testLocaleSupportFromAppConfig;
- },
- 'localeSupport not defined in AppClass',
- 3000
- );
-
- runs(function() {
- expect(F2.testLocaleSupportFromAppConfig.length == 2).toBeTruthy();
- });
- });
+describe('F2.init - internationalization', function () {
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL,
+ localeSupport: ['en-us', 'de-de']
+ };
+
+ var appManifest = {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [{
+ html: '
Testing
'
+ }]
+ };
+
+ it('should not fail F2.init when locale is undefined', function () {
+ F2.init();
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(F2.isInit()).toBeTruthy();
+ });
+ });
+
+ it('F2.getContainerLocale() should return null when locale is undefined', function () {
+ F2.init();
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(F2.getContainerLocale()).toBe(null);
+ });
+ });
+
+ it('F2.getContainerLocale() should return current locale', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(F2.getContainerLocale()).toBe('en-us');
+ });
+ });
+
+ it('F2.getContainerLocale() should be a string', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(typeof F2.getContainerLocale() == 'string').toBeTruthy();
+ });
+ });
+
+ it('F2.getContainerLocale() should be a valid IETF tag', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ //see http://www.w3.org/TR/xmlschema11-2/#language
+ expect(/[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*/.test(F2.getContainerLocale())).toBeTruthy();
+ });
+ });
+
+ it('should not modify original appConfig', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(appConfig.containerLocale).toBeFalsy();
+ expect(appConfig.locale).toBeFalsy();
+ });
+ });
+
+ it('app should receive locale as "containerLocale" in appConfig', function () {
+ F2.testLocaleFromAppConfig = false;
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps([{
+ appId: 'com_openf2_tests_helloworld',
+ manifestUrl: '/F2/apps/test/com_openf2_tests_helloworld'
+ }], [{
+ "inlineScripts": [],
+ "scripts": ["js/test.js"],
+ "apps": [{html: '
Testing
'}]
+ }]);
+
+ waitsFor(
+ function () {
+ return F2.testLocaleFromAppConfig;
+ },
+ 'containerLocale not defined in AppClass',
+ 3000
+ );
+
+ runs(function () {
+ expect(F2.testLocaleFromAppConfig == F2.getContainerLocale()).toBeTruthy();
+ });
+ });
+
+ it('app should not receive locale as "containerLocale" in appConfig when locale is not defined', function () {
+ F2.init();
+ F2.registerApps([{
+ appId: 'com_openf2_tests_helloworld',
+ manifestUrl: '/F2/apps/test/com_openf2_tests_helloworld'
+ }], [{
+ "inlineScripts": [],
+ "scripts": ["js/test.js"],
+ "apps": [{html: '
Testing
'}]
+ }]);
+
+ waitsFor(
+ function () {
+ return !F2.testLocaleFromAppConfig;
+ },
+ 'containerLocale is defined in AppClass',
+ 3000
+ );
+
+ runs(function () {
+ expect(F2.testLocaleFromAppConfig).toBeFalsy();
+ });
+ });
+
+ it('should update containerLocale when CONTAINER_LOCALE_CHANGE is fired', function () {
+ var _locale;
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ //listen for changes
+ F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE, function (data) {
+ _locale = data.locale;
+ });
+ //nothing should be changed
+ expect(F2.getContainerLocale() == 'en-us').toBeTruthy();
+ //now change locale
+ F2.Events.emit(F2.Constants.Events.CONTAINER_LOCALE_CHANGE, {
+ locale: 'de-de'
+ });
+ //now locale should be changed
+ expect(F2.getContainerLocale() == 'de-de').toBeTruthy();
+ });
+ });
+
+ it('should update containerLocale when CONTAINER_LOCALE_CHANGE is fired after being undefined', function () {
+ var _locale;
+ F2.init();
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ //listen for changes
+ F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE, function (data) {
+ _locale = data.locale;
+ });
+ //locale was not defined, should be null
+ expect(F2.getContainerLocale()).toBe(null);
+ //now change locale
+ F2.Events.emit(F2.Constants.Events.CONTAINER_LOCALE_CHANGE, {
+ locale: 'de-de'
+ });
+ //now locale should be changed
+ expect(F2.getContainerLocale() == 'de-de').toBeTruthy();
+ });
+ });
+
+ it('AppManifest should support localeSupport property', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(appConfig.localeSupport).toBeTruthy();
+ });
+ });
+
+ it('AppManifest\'s localeSupport property should be an array', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(typeof appConfig.localeSupport == 'object').toBeTruthy();
+ });
+ });
+
+ it('AppManifest\'s localeSupport property should have 2 items', function () {
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps(appConfig, appManifest);
+ runs(function () {
+ expect(appConfig.localeSupport.length == 2).toBeTruthy();
+ });
+ });
+
+ it('app should receive localeSupport in appConfig', function () {
+ F2.testLocaleSupportFromAppConfig = false;
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps([{
+ appId: 'com_openf2_tests_helloworld',
+ manifestUrl: '/F2/apps/test/com_openf2_tests_helloworld',
+ localeSupport: ['en-us', 'de-de']
+ }], [{
+ "inlineScripts": [],
+ "scripts": ["js/test.js"],
+ "apps": [{html: '
Testing
'}]
+ }]);
+
+ waitsFor(
+ function () {
+ return F2.testLocaleSupportFromAppConfig;
+ },
+ 'localeSupport not defined in AppClass',
+ 3000
+ );
+
+ runs(function () {
+ expect(F2.testLocaleSupportFromAppConfig).toBeTruthy();
+ });
+ });
+
+ it('app should receive localeSupport in appConfig and have 2 items', function () {
+ F2.testLocaleSupportFromAppConfig = false;
+ F2.init({
+ locale: 'en-us'
+ });
+ F2.registerApps([{
+ appId: 'com_openf2_tests_helloworld',
+ manifestUrl: '/F2/apps/test/com_openf2_tests_helloworld',
+ localeSupport: ['en-us', 'de-de']
+ }], [{
+ "inlineScripts": [],
+ "scripts": ["js/test.js"],
+ "apps": [{html: '
Testing
'}]
+ }]);
+
+ waitsFor(
+ function () {
+ return F2.testLocaleSupportFromAppConfig;
+ },
+ 'localeSupport not defined in AppClass',
+ 3000
+ );
+
+ runs(function () {
+ expect(F2.testLocaleSupportFromAppConfig.length == 2).toBeTruthy();
+ });
+ });
});
-describe('F2.registerApps - basic', function() {
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() {
- F2.init();
- });
-
- it('should fail on empty parameters', function() {
- expect(function() {
- F2.registerApps();
- }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
- });
-
- it('should fail when passed an empty array', function() {
- expect(function() {
- F2.registerApps([]);
- }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
- });
-
- it('should fail when the parameters are invalid', function() {
- expect(function() {
- F2.registerApps(null, []);
- }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
- });
-
- it('should fail when the AppConfig is invalid', function() {
- expect(function() {
- F2.registerApps({});
- }).toLog('"appId" missing from app object');
-
- expect(function() {
- F2.registerApps({
- appId: TEST_APP_ID
- });
- }).toLog('"manifestUrl" missing from app object');
- });
-
- it('should fail when the parameter lengths do not match', function() {
- expect(function() {
- F2.registerApps({
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }, [{}, {}]);
- }).toLog('The length of "apps" does not equal the length of "appManifests"');
- });
-
- it('should not fail when a single appManifest is passed (#55)', function() {
-
- var passedMessage = false;
- F2.log = function(message) {
- passedMessage = true;
- };
-
- runs(function() {
- F2.registerApps({
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }, {
- apps: [{
- html: '
'
- }]
- });
- });
-
- // wait long enough for registerApps to have failed
- waits(1000);
-
- // F2.log should not have run
- runs(function() {
- expect(passedMessage).toBeFalsy();
- });
- });
-
- it('should not modify the original AppConfig that was passed in', function() {
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- F2.registerApps(appConfig);
-
- // original appConfig object should remain clean
- expect(appConfig.instanceId).toBeFalsy();
- });
+describe('F2.registerApps - basic', function () {
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ F2.init();
+ });
+
+ it('should fail on empty parameters', function () {
+ expect(function () {
+ F2.registerApps();
+ }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
+ });
+
+ it('should fail when passed an empty array', function () {
+ expect(function () {
+ F2.registerApps([]);
+ }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
+ });
+
+ it('should fail when the parameters are invalid', function () {
+ expect(function () {
+ F2.registerApps(null, []);
+ }).toLog('At least one AppConfig must be passed when calling F2.registerApps()');
+ });
+
+ it('should fail when the AppConfig is invalid', function () {
+ expect(function () {
+ F2.registerApps({});
+ }).toLog('"appId" missing from app object');
+
+ expect(function () {
+ F2.registerApps({
+ appId: TEST_APP_ID
+ });
+ }).toLog('"manifestUrl" missing from app object');
+ });
+
+ it('should fail when the parameter lengths do not match', function () {
+ expect(function () {
+ F2.registerApps({
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }, [{}, {}]);
+ }).toLog('The length of "apps" does not equal the length of "appManifests"');
+ });
+
+ it('should not fail when a single appManifest is passed (#55)', function () {
+
+ var passedMessage = false;
+ F2.log = function (message) {
+ passedMessage = true;
+ };
+
+ runs(function () {
+ F2.registerApps({
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }, {
+ apps: [{
+ html: '
'
+ }]
+ });
+ });
+
+ // wait long enough for registerApps to have failed
+ waits(1000);
+
+ // F2.log should not have run
+ runs(function () {
+ expect(passedMessage).toBeFalsy();
+ });
+ });
+
+ it('should not modify the original AppConfig that was passed in', function () {
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ F2.registerApps(appConfig);
+
+ // original appConfig object should remain clean
+ expect(appConfig.instanceId).toBeFalsy();
+ });
});
-describe('F2.registerApps - xhr overrides', function() {
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() {
- // nothing to do after reload
- });
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
-
- it('should call xhr if it is defined', function() {
- var isFired = false;
- runs(function() {
- F2.init({
- xhr: function(url, apps, success, error, complete) {
- $.ajax({
- url: url,
- type: 'POST',
- data: {
- params: F2.stringify(apps[0], F2.appConfigReplacer)
- },
- jsonp: false, // do not put 'callback=' in the query string
- jsonpCallback: F2.Constants.JSONP_CALLBACK + apps[0].appId, // Unique function name
- dataType: 'json',
- success: function(appManifest) {
- // custom success logic
- success(appManifest); // fire success callback
- },
- error: function() {
- // custom error logic
- error(); // fire error callback
- },
- complete: function() {
- // custom complete logic
- complete(); // fire complete callback
- }
- });
- isFired = true;
- }
- });
- F2.registerApps(appConfig);
- });
- waitsFor(function() {
- return isFired;
- });
- runs(function() {
- expect(isFired).toBeTruthy();
- })
- });
-
- it('should pass 5 parameters to xhr', function() {
- var isFired = false,
- numArgs = 0,
- urlParam, appConfigsParam, successParam, errorParam, completeParam;
-
- runs(function() {
- F2.init({
- xhr: function(url, appConfigs, success, error, complete) {
- numArgs = arguments.length;
- urlParam = url;
- appConfigsParam = appConfigs;
- successParam = success;
- errorParam = error;
- completeParam = complete;
-
- isFired = true;
- }
- });
- F2.registerApps(appConfig);
- });
-
- waitsFor(function() {
- return isFired;
- });
-
- runs(function() {
- expect(numArgs).toBe(5);
- expect(typeof urlParam).toBe('string');
- expect(appConfigsParam instanceof Array).toBeTruthy();
- expect(typeof successParam).toBe('function');
- expect(typeof errorParam).toBe('function');
- expect(typeof completeParam).toBe('function');
- })
- });
-
- it('should call xhr.dataType', function() {
- var isFired = false;
- runs(function() {
- F2.init({
- xhr: {
- dataType: function() {
- isFired = true;
- return 'jsonp';
- }
- }
- });
- F2.registerApps(appConfig);
- });
- waitsFor(function() {
- return isFired;
- }, 'xhr.dataType was not fired', 10000);
- runs(function() {
- expect(isFired).toBeTruthy();
- });
- });
-
- it('should throw an exception when xhr.dataType does not return a string', function() {
- expect(function() {
- F2.init({
- xhr: {
- dataType: function() {}
- }
- });
- F2.registerApps(appConfig);
- }).toThrow(new Error('ContainerConfig.xhr.dataType should return a string'));
- });
-
- it('should call xhr.type', function() {
- var isFired = false;
- F2.init({
- xhr: {
- type: function() {
- isFired = true;
- return 'GET';
- }
- }
- });
- F2.registerApps(appConfig);
- waitsFor(function() {
- return isFired;
- }, 'xhr.type was not fired', 10000);
- runs(function() {
- expect(isFired).toBeTruthy();
- });
- });
-
- it('should throw an exception when xhr.type does not return a string', function() {
- expect(function() {
- F2.init({
- xhr: {
- type: function() {}
- }
- });
- F2.registerApps(appConfig);
- }).toThrow(new Error('ContainerConfig.xhr.type should return a string'));
- });
-
- it('should call xhr.url', function() {
- var isFired = false;
- F2.init({
- xhr: {
- url: function() {
- isFired = true;
- return '/F2/apps/test/hello-world';
- }
- }
- });
- F2.registerApps(appConfig);
- waitsFor(function() {
- return isFired;
- }, 'xhr.url was not fired', 10000);
- runs(function() {
- expect(isFired).toBeTruthy();
- });
- });
-
- it('should throw an exception when xhr.url does not return a string', function() {
- expect(function() {
- F2.init({
- xhr: {
- url: function() {}
- }
- });
- F2.registerApps(appConfig);
- }).toThrow(new Error('ContainerConfig.xhr.url should return a string'));
- });
-
- itConditionally(window.F2_NODE_TEST_SERVER, 'should use POST when the domain of the container matches that of the app (#41, #59)', function() {
-
- var isPost = false,
- hasReturned = false;
- F2.log = function(message) {
- hasReturned = true;
- isPost = message;
- };
-
- runs(function() {
- F2.init({
- xhr: {
- dataType: function(url) {
- return F2.isLocalRequest(url) ? 'json' : 'jsonp';
- },
- type: function(url) {
- return F2.isLocalRequest(url) ? 'POST' : 'GET';
- }
- }
- });
- F2.registerApps({
- appId: 'com_test_app',
- manifestUrl: TEST_MANIFEST_URL_HTTP_POST
- });
- });
-
- // wait for registerApps to complete and load the app
- waitsFor(function() {
- return hasReturned;
- }, 'test app was never loaded', 10000);
-
- runs(function() {
- expect(isPost).toBeTruthy();
- });
- });
-
- itConditionally(window.F2_NODE_TEST_SERVER, 'should use GET when the domain of the container does not match that of the app (#41, #59)', function() {
-
- var isPost = false,
- hasReturned = false;
- F2.log = function(message) {
- hasReturned = true;
- isPost = message;
- };
-
- runs(function() {
- F2.init({
- xhr: {
- dataType: function(url) {
- return F2.isLocalRequest(url) ? 'json' : 'jsonp';
- },
- type: function(url) {
- return F2.isLocalRequest(url) ? 'POST' : 'GET';
- }
- }
- });
- F2.registerApps({
- appId: 'com_test_app',
- manifestUrl: 'http://www.openf2.org/httpPostTest'
- });
- });
-
- // wait for registerApps to complete and load the app
- waitsFor(function() {
- return hasReturned;
- }, 'test app was never loaded', 10000);
-
- runs(function() {
- expect(isPost).toBeFalsy();
- });
- });
+describe('F2.registerApps - xhr overrides', function () {
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ // nothing to do after reload
+ });
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+
+ it('should call xhr if it is defined', function () {
+ var isFired = false;
+ runs(function () {
+ F2.init({
+ xhr: function (url, apps, success, error, complete) {
+ $.ajax({
+ url: url,
+ type: 'POST',
+ data: {
+ params: F2.stringify(apps[0], F2.appConfigReplacer)
+ },
+ jsonp: false, // do not put 'callback=' in the query string
+ jsonpCallback: F2.Constants.JSONP_CALLBACK + apps[0].appId, // Unique function name
+ dataType: 'json',
+ success: function (appManifest) {
+ // custom success logic
+ success(appManifest); // fire success callback
+ },
+ error: function () {
+ // custom error logic
+ error(); // fire error callback
+ },
+ complete: function () {
+ // custom complete logic
+ complete(); // fire complete callback
+ }
+ });
+ isFired = true;
+ }
+ });
+ F2.registerApps(appConfig);
+ });
+ waitsFor(function () {
+ return isFired;
+ });
+ runs(function () {
+ expect(isFired).toBeTruthy();
+ })
+ });
+
+ it('should pass 5 parameters to xhr', function () {
+ var isFired = false,
+ numArgs = 0,
+ urlParam, appConfigsParam, successParam, errorParam, completeParam;
+
+ runs(function () {
+ F2.init({
+ xhr: function (url, appConfigs, success, error, complete) {
+ numArgs = arguments.length;
+ urlParam = url;
+ appConfigsParam = appConfigs;
+ successParam = success;
+ errorParam = error;
+ completeParam = complete;
+
+ isFired = true;
+ }
+ });
+ F2.registerApps(appConfig);
+ });
+
+ waitsFor(function () {
+ return isFired;
+ });
+
+ runs(function () {
+ expect(numArgs).toBe(5);
+ expect(typeof urlParam).toBe('string');
+ expect(appConfigsParam instanceof Array).toBeTruthy();
+ expect(typeof successParam).toBe('function');
+ expect(typeof errorParam).toBe('function');
+ expect(typeof completeParam).toBe('function');
+ })
+ });
+
+ it('should call xhr.dataType', function () {
+ var isFired = false;
+ runs(function () {
+ F2.init({
+ xhr: {
+ dataType: function () {
+ isFired = true;
+ return 'jsonp';
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ });
+ waitsFor(function () {
+ return isFired;
+ }, 'xhr.dataType was not fired', 10000);
+ runs(function () {
+ expect(isFired).toBeTruthy();
+ });
+ });
+
+ it('should throw an exception when xhr.dataType does not return a string', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ dataType: function () {
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ }).toThrow(new Error('ContainerConfig.xhr.dataType should return a string'));
+ });
+
+ it('should call xhr.type', function () {
+ var isFired = false;
+ F2.init({
+ xhr: {
+ type: function () {
+ isFired = true;
+ return 'GET';
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ waitsFor(function () {
+ return isFired;
+ }, 'xhr.type was not fired', 10000);
+ runs(function () {
+ expect(isFired).toBeTruthy();
+ });
+ });
+
+ it('should throw an exception when xhr.type does not return a string', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ type: function () {
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ }).toThrow(new Error('ContainerConfig.xhr.type should return a string'));
+ });
+
+ it('should call xhr.url', function () {
+ var isFired = false;
+ F2.init({
+ xhr: {
+ url: function () {
+ isFired = true;
+ return '/F2/apps/test/hello-world';
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ waitsFor(function () {
+ return isFired;
+ }, 'xhr.url was not fired', 10000);
+ runs(function () {
+ expect(isFired).toBeTruthy();
+ });
+ });
+
+ it('should throw an exception when xhr.url does not return a string', function () {
+ expect(function () {
+ F2.init({
+ xhr: {
+ url: function () {
+ }
+ }
+ });
+ F2.registerApps(appConfig);
+ }).toThrow(new Error('ContainerConfig.xhr.url should return a string'));
+ });
+
+ itConditionally(window.F2_NODE_TEST_SERVER, 'should use POST when the domain of the container matches that of the app (#41, #59)', function () {
+
+ var isPost = false,
+ hasReturned = false;
+ F2.log = function (message) {
+ hasReturned = true;
+ isPost = message;
+ };
+
+ runs(function () {
+ F2.init({
+ xhr: {
+ dataType: function (url) {
+ return F2.isLocalRequest(url) ? 'json' : 'jsonp';
+ },
+ type: function (url) {
+ return F2.isLocalRequest(url) ? 'POST' : 'GET';
+ }
+ }
+ });
+ F2.registerApps({
+ appId: 'com_test_app',
+ manifestUrl: TEST_MANIFEST_URL_HTTP_POST
+ });
+ });
+
+ // wait for registerApps to complete and load the app
+ waitsFor(function () {
+ return hasReturned;
+ }, 'test app was never loaded', 10000);
+
+ runs(function () {
+ expect(isPost).toBeTruthy();
+ });
+ });
+
+ itConditionally(window.F2_NODE_TEST_SERVER, 'should use GET when the domain of the container does not match that of the app (#41, #59)', function () {
+
+ var isPost = false,
+ hasReturned = false;
+ F2.log = function (message) {
+ hasReturned = true;
+ isPost = message;
+ };
+
+ runs(function () {
+ F2.init({
+ xhr: {
+ dataType: function (url) {
+ return F2.isLocalRequest(url) ? 'json' : 'jsonp';
+ },
+ type: function (url) {
+ return F2.isLocalRequest(url) ? 'POST' : 'GET';
+ }
+ }
+ });
+ F2.registerApps({
+ appId: 'com_test_app',
+ manifestUrl: 'http://www.openf2.org/httpPostTest'
+ });
+ });
+
+ // wait for registerApps to complete and load the app
+ waitsFor(function () {
+ return hasReturned;
+ }, 'test app was never loaded', 10000);
+
+ runs(function () {
+ expect(isPost).toBeFalsy();
+ });
+ });
});
-describe('F2.registerApps - rendering', function() {
-
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2(function() {
- // nothing to do after reload
- });
-
- var appConfig = {
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- };
- var appManifest = {
- scripts: [],
- styles: [],
- inlineScripts: [],
- apps: [{
- html: '
Testing
'
- }]
- };
-
- it('should fire beforeAppRender when it is defined', function() {
- var isFired = false;
- F2.init({
- beforeAppRender: function() {
- isFired = true;
- }
- });
- F2.registerApps(appConfig, [appManifest]);
- waitsFor(function() {
- return isFired;
- }, 'beforeAppRender was never fired', 10000);
- runs(function() {
- expect(isFired).toBe(true);
- });
- });
-
- it('should allow beforeAppRender to return null', function() {
- F2.init({
- beforeAppRender: function() {
- return null;
- }
- });
-
- F2.registerApps(appConfig, [appManifest]);
- });
-
-
- it('should eval AppManifest.inlineScripts when AppManifest.scripts are defined', function() {
- F2.inlineScriptsEvaluated = false;
- F2.init();
- F2.registerApps([{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }], [{
- 'inlineScripts': ['(function(){F2.inlineScriptsEvaluated=true;})()'],
- 'scripts': ['js/test.js'],
- 'apps': [{
- 'html': '
Testing
'
- }]
- }]);
-
- waitsFor(
- function() {
- return F2.inlineScriptsEvaluated;
- },
- 'Inline scripts were never evaluated',
- 10000
- );
-
- runs(function() {
- expect(F2.inlineScriptsEvaluated).toBe(true);
- });
- });
-
- it('should eval AppManifest.inlineScripts when AppManifest.scripts are not defined', function() {
- F2.inlineScriptsEvaluated = false;
- F2.init();
- F2.registerApps([{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }], [{
- 'inlineScripts': ['(function(){F2.inlineScriptsEvaluated=true;})()'],
- 'apps': [{
- 'html': '
Testing
'
- }]
- }]);
- waitsFor(
- function() {
- return F2.inlineScriptsEvaluated;
- },
- 'Inline scripts were never evaluated',
- 10000
- );
-
- runs(function() {
- expect(F2.inlineScriptsEvaluated).toBe(true);
- });
- });
-
- it('should add cache buster to AppManifest.scripts when F2.ContainerConfig.debugMode is true', function() {
- var bustedCache = false;
- F2.init({
- debugMode: true
- });
- F2.registerApps([{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }], [{
- 'scripts': ['js/cacheBusterAdded.js'],
- 'apps': [{
- 'html': '
Testing
'
- }]
- }]);
- runs(function() {
-
- $('script').each(function(idx, item) {
- var src = $(item).attr('src');
- //find script, test for cachebuster string
- if (/cacheBusterAdded.js\?cachebuster/.test(src)) {
- bustedCache = true;
- return false; //break from $.each
- }
- });
-
- expect(bustedCache).toBe(true);
- });
- });
-
- it('should not add cache buster to AppManifest.scripts when F2.ContainerConfig.debugMode is undefined or false', function() {
- var bustedCache = false;
- F2.init();
- F2.registerApps([{
- appId: TEST_APP_ID,
- manifestUrl: TEST_MANIFEST_URL
- }], [{
- 'scripts': ['js/cacheBusterNotAdded.js'],
- 'apps': [{
- 'html': '
Testing
'
- }]
- }]);
-
- runs(function() {
-
- $('script').each(function(idx, item) {
- var src = $(item).attr('src');
- //find script
- if (/cacheBusterNotAdded.js/.test(src)) {
- bustedCache = /cachebuster/.test(src);
- return false; //break from $.each
- }
- });
-
- expect(bustedCache).toBe(false);
- });
- });
+describe('F2.registerApps - rendering', function () {
+
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2(function () {
+ // nothing to do after reload
+ });
+
+ var appConfig = {
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ };
+ var appManifest = {
+ scripts: [],
+ styles: [],
+ inlineScripts: [],
+ apps: [{
+ html: '
Testing
'
+ }]
+ };
+
+ it('should fire beforeAppRender when it is defined', function () {
+ var isFired = false;
+ F2.init({
+ beforeAppRender: function () {
+ isFired = true;
+ }
+ });
+ F2.registerApps(appConfig, [appManifest]);
+ waitsFor(function () {
+ return isFired;
+ }, 'beforeAppRender was never fired', 10000);
+ runs(function () {
+ expect(isFired).toBe(true);
+ });
+ });
+
+ it('should allow beforeAppRender to return null', function () {
+ F2.init({
+ beforeAppRender: function () {
+ return null;
+ }
+ });
+
+ F2.registerApps(appConfig, [appManifest]);
+ });
+
+
+ it('should eval AppManifest.inlineScripts when AppManifest.scripts are defined', function () {
+ F2.inlineScriptsEvaluated = false;
+ F2.init();
+ F2.registerApps([{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }], [{
+ 'inlineScripts': ['(function(){F2.inlineScriptsEvaluated=true;})()'],
+ 'scripts': ['js/test.js'],
+ 'apps': [{
+ 'html': '
Testing
'
+ }]
+ }]);
+
+ waitsFor(
+ function () {
+ return F2.inlineScriptsEvaluated;
+ },
+ 'Inline scripts were never evaluated',
+ 10000
+ );
+
+ runs(function () {
+ expect(F2.inlineScriptsEvaluated).toBe(true);
+ });
+ });
+
+ it('should eval AppManifest.inlineScripts when AppManifest.scripts are not defined', function () {
+ F2.inlineScriptsEvaluated = false;
+ F2.init();
+ F2.registerApps([{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }], [{
+ 'inlineScripts': ['(function(){F2.inlineScriptsEvaluated=true;})()'],
+ 'apps': [{
+ 'html': '
Testing
'
+ }]
+ }]);
+ waitsFor(
+ function () {
+ return F2.inlineScriptsEvaluated;
+ },
+ 'Inline scripts were never evaluated',
+ 10000
+ );
+
+ runs(function () {
+ expect(F2.inlineScriptsEvaluated).toBe(true);
+ });
+ });
+
+ it('should add cache buster to AppManifest.scripts when F2.ContainerConfig.debugMode is true', function () {
+ var bustedCache = false;
+ F2.init({
+ debugMode: true
+ });
+ F2.registerApps([{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }], [{
+ 'scripts': ['js/cacheBusterAdded.js'],
+ 'apps': [{
+ 'html': '
Testing
'
+ }]
+ }]);
+ runs(function () {
+
+ $('script').each(function (idx, item) {
+ var src = $(item).attr('src');
+ //find script, test for cachebuster string
+ if (/cacheBusterAdded.js\?cachebuster/.test(src)) {
+ bustedCache = true;
+ return false; //break from $.each
+ }
+ });
+
+ expect(bustedCache).toBe(true);
+ });
+ });
+
+ it('should not add cache buster to AppManifest.scripts when F2.ContainerConfig.debugMode is undefined or false', function () {
+ var bustedCache = false;
+ F2.init();
+ F2.registerApps([{
+ appId: TEST_APP_ID,
+ manifestUrl: TEST_MANIFEST_URL
+ }], [{
+ 'scripts': ['js/cacheBusterNotAdded.js'],
+ 'apps': [{
+ 'html': '
Testing
'
+ }]
+ }]);
+
+ runs(function () {
+
+ $('script').each(function (idx, item) {
+ var src = $(item).attr('src');
+ //find script
+ if (/cacheBusterNotAdded.js/.test(src)) {
+ bustedCache = /cachebuster/.test(src);
+ return false; //break from $.each
+ }
+ });
+
+ expect(bustedCache).toBe(false);
+ });
+ });
});
-describe('F2.loadPlaceholders - auto', function() {
-
- describe('single app by id', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append(
- '
'
- );
- });
-
- it('should automatically auto-init F2 when f2-autoload id is on the page', function() {
- // need to wait for dom ready before F2.init() will be called
- waitsFor(
- function() {
- return F2.isInit();
- },
- 'F2.init() never called',
- 3000
- );
- runs(function() {
- expect(F2.isInit()).toBe(true);
- });
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('single app by id, with children', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append(
- '
'
- );
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
-
- it('should ignore apps within apps', function() {
-
- var proceed = false;
- var timeout;
-
- waitsFor(
- function() {
- // wait an arbitrary 5 seconds for the apps to load
- timeout = timeout || setTimeout(function() { proceed = true; }, 5000);
- return proceed;
- },
- 'placeholder app to load',
- 10000
- );
-
- runs(function() {
- expect($('#f2-autoload').children().length).toEqual(1);
- expect($('#f2-autoload [data-f2-appid]').length).toEqual(0);
- });
- });
- });
-
- describe('single app by attribute', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append(
- '
'
- );
- });
-
- it('should automatically auto-init F2 when data-f2-autoload attribute is on the page', function() {
- // need to wait for dom ready before F2.init() will be called
- waitsFor(
- function() {
- return F2.isInit();
- },
- 'F2.init() never called',
- 3000
- );
- runs(function() {
- expect(F2.isInit()).toBe(true);
- });
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#test-fixture [data-f2-appid]').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('single app by class', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append(
- '
'
- );
- });
-
- it('should automatically auto-init F2 when f2-autoload class is on the page', function() {
- // need to wait for dom ready before F2.init() will be called
- waitsFor(
- function() {
- return F2.isInit();
- },
- 'F2.init() never called',
- 3000
- );
- runs(function() {
- expect(F2.isInit()).toBe(true);
- });
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#test-fixture [data-f2-appid]').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('single app by id, nested', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload [data-f2-appid]').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('single app by attribute, nested', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload-single [data-f2-appid]').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('single app by class, nested', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload-single [data-f2-appid]').children().length;
- return children;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
- });
-
- describe('many apps by id', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register multiple apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload [data-f2-appid]').children().length;
- return children == 2;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
- });
-
- describe('many apps by attribute', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register multiple apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload-many [data-f2-appid]').children().length;
- return children == 2;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
- });
-
- describe('many apps by class', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
'
- ].join(''));
- });
-
- it('should automatically find and register multiple apps', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload-many [data-f2-appid]').children().length;
- return children == 2;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
- });
-
- describe('many placeholders by attribute', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
',
- '
',
- ].join(''));
- });
-
- it('should automatically find and register apps within multiple placeholders', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#test-fixture [data-f2-appid]').children().length;
- return children == 2;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
- });
-
- describe('many placeholders by class', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- beforeEach(function() {
- $('#test-fixture').append([
- '
',
- '
',
- ].join(''));
- });
-
- it('should automatically find and register apps within multiple placeholders', function() {
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#test-fixture [data-f2-appid]').children().length;
- return children == 2;
- },
- 'placeholder app to load',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
- });
+describe('F2.loadPlaceholders - auto', function () {
+
+ describe('single app by id', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append(
+ '
'
+ );
+ });
+
+ it('should automatically auto-init F2 when f2-autoload id is on the page', function () {
+ // need to wait for dom ready before F2.init() will be called
+ waitsFor(
+ function () {
+ return F2.isInit();
+ },
+ 'F2.init() never called',
+ 3000
+ );
+ runs(function () {
+ expect(F2.isInit()).toBe(true);
+ });
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('single app by id, with children', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append(
+ '
'
+ );
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+
+ it('should ignore apps within apps', function () {
+
+ var proceed = false;
+ var timeout;
+
+ waitsFor(
+ function () {
+ // wait an arbitrary 5 seconds for the apps to load
+ timeout = timeout || setTimeout(function () {
+ proceed = true;
+ }, 5000);
+ return proceed;
+ },
+ 'placeholder app to load',
+ 10000
+ );
+
+ runs(function () {
+ expect($('#f2-autoload').children().length).toEqual(1);
+ expect($('#f2-autoload [data-f2-appid]').length).toEqual(0);
+ });
+ });
+ });
+
+ describe('single app by attribute', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append(
+ '
'
+ );
+ });
+
+ it('should automatically auto-init F2 when data-f2-autoload attribute is on the page', function () {
+ // need to wait for dom ready before F2.init() will be called
+ waitsFor(
+ function () {
+ return F2.isInit();
+ },
+ 'F2.init() never called',
+ 3000
+ );
+ runs(function () {
+ expect(F2.isInit()).toBe(true);
+ });
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#test-fixture [data-f2-appid]').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('single app by class', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append(
+ '
'
+ );
+ });
+
+ it('should automatically auto-init F2 when f2-autoload class is on the page', function () {
+ // need to wait for dom ready before F2.init() will be called
+ waitsFor(
+ function () {
+ return F2.isInit();
+ },
+ 'F2.init() never called',
+ 3000
+ );
+ runs(function () {
+ expect(F2.isInit()).toBe(true);
+ });
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#test-fixture [data-f2-appid]').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('single app by id, nested', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload [data-f2-appid]').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('single app by attribute, nested', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload-single [data-f2-appid]').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('single app by class, nested', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload-single [data-f2-appid]').children().length;
+ return children;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+ });
+
+ describe('many apps by id', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register multiple apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+ });
+
+ describe('many apps by attribute', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register multiple apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload-many [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+ });
+
+ describe('many apps by class', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
'
+ ].join(''));
+ });
+
+ it('should automatically find and register multiple apps', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload-many [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+ });
+
+ describe('many placeholders by attribute', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
',
+ '
',
+ ].join(''));
+ });
+
+ it('should automatically find and register apps within multiple placeholders', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#test-fixture [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+ });
+
+ describe('many placeholders by class', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ beforeEach(function () {
+ $('#test-fixture').append([
+ '
',
+ '
',
+ ].join(''));
+ });
+
+ it('should automatically find and register apps within multiple placeholders', function () {
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#test-fixture [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'placeholder app to load',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+ });
});
-describe('F2.loadPlaceholders - manual', function() {
- // force F2 to be reloaded
- var async = new AsyncSpec(this);
- async.beforeEachReloadF2();
-
- // add the f2-autoload element to the test fixture for use in each
- // test
- beforeEach(function() {
- $('#test-fixture').append('
');
- });
-
- it('should require the presence of data-f2-manifesturl', function() {
- // add the invalid placeholder
- $('#f2-autoload').append('
');
-
- // even though the manifesturl is missing, the message is generic because a null AppConfig was generated
- expect(function() {
- F2.init();
- F2.loadPlaceholders();
- }).toLog('"appId" missing from app object');
- });
-
- it('should find and register apps', function() {
-
- // add the placeholder
- var $f2Autoload = $('
');
- $f2Autoload.append('
');
- $('#test-fixture').append($f2Autoload);
-
- F2.init();
- F2.loadPlaceholders();
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload [data-f2-appid]').children().length;
- return children;
- },
- 'app never loaded',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
-
- it('should find and register multiple apps', function() {
- // add the placeholder
- var $f2Autoload = $('
');
- $f2Autoload
- .append('
')
- .append('
');
- $('#test-fixture').append($f2Autoload);
-
- F2.init();
- F2.loadPlaceholders();
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload [data-f2-appid]').children().length;
- return children == 2;
- },
- 'app never loaded',
- 10000
- );
-
- runs(function() {
- expect(children).toEqual(2);
- });
- });
-
- it('should throw an exception when an invalid parentNode is passed', function() {
- expect(function() {
- F2.init();
- F2.loadPlaceholders('foo');
- }).toThrow('"parentNode" must be null or a DOM node');
- });
-
- it('should find and register apps within a given scope', function() {
- // add the placeholder
- var $f2Autoload = $('
');
- $f2Autoload
- .append('
');
- $('#test-fixture').append($f2Autoload);
-
- F2.init();
- F2.loadPlaceholders(document.getElementById('test-fixture'));
-
- var children = 0;
-
- waitsFor(
- function() {
- children = $('#f2-autoload [data-f2-appid]').children().length;
- return children;
- },
- 'app never loaded',
- 3000
- );
-
- runs(function() {
- expect(children).toEqual(1);
- });
- });
+describe('F2.loadPlaceholders - manual', function () {
+ // force F2 to be reloaded
+ var async = new AsyncSpec(this);
+ async.beforeEachReloadF2();
+
+ // add the f2-autoload element to the test fixture for use in each
+ // test
+ beforeEach(function () {
+ $('#test-fixture').append('
');
+ });
+
+ it('should require the presence of data-f2-manifesturl', function () {
+ // add the invalid placeholder
+ $('#f2-autoload').append('
');
+
+ // even though the manifesturl is missing, the message is generic because a null AppConfig was generated
+ expect(function () {
+ F2.init();
+ F2.loadPlaceholders();
+ }).toLog('"appId" missing from app object');
+ });
+
+ it('should find and register apps', function () {
+
+ // add the placeholder
+ var $f2Autoload = $('
');
+ $f2Autoload.append('
');
+ $('#test-fixture').append($f2Autoload);
+
+ F2.init();
+ F2.loadPlaceholders();
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload [data-f2-appid]').children().length;
+ return children;
+ },
+ 'app never loaded',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
+
+ it('should find and register multiple apps', function () {
+ // add the placeholder
+ var $f2Autoload = $('
');
+ $f2Autoload
+ .append('
')
+ .append('
');
+ $('#test-fixture').append($f2Autoload);
+
+ F2.init();
+ F2.loadPlaceholders();
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload [data-f2-appid]').children().length;
+ return children == 2;
+ },
+ 'app never loaded',
+ 10000
+ );
+
+ runs(function () {
+ expect(children).toEqual(2);
+ });
+ });
+
+ it('should throw an exception when an invalid parentNode is passed', function () {
+ expect(function () {
+ F2.init();
+ F2.loadPlaceholders('foo');
+ }).toThrow('"parentNode" must be null or a DOM node');
+ });
+
+ it('should find and register apps within a given scope', function () {
+ // add the placeholder
+ var $f2Autoload = $('
');
+ $f2Autoload
+ .append('
');
+ $('#test-fixture').append($f2Autoload);
+
+ F2.init();
+ F2.loadPlaceholders(document.getElementById('test-fixture'));
+
+ var children = 0;
+
+ waitsFor(
+ function () {
+ children = $('#f2-autoload [data-f2-appid]').children().length;
+ return children;
+ },
+ 'app never loaded',
+ 3000
+ );
+
+ runs(function () {
+ expect(children).toEqual(1);
+ });
+ });
});
diff --git a/tests/spec/misc-spec.js b/tests/spec/misc-spec.js
index 9f26f5f8..dee5b319 100644
--- a/tests/spec/misc-spec.js
+++ b/tests/spec/misc-spec.js
@@ -1,11 +1,11 @@
-describe('misc', function() {
+describe('misc', function () {
- it('should not overwrite existing jQuery versions', function() {
- // the AMD test page does not include jquery
- if (typeof $ !== 'undefined') {
- // the jasmine test page loads 1.11.1 while 1.10.2 is bundled with F2
- expect($.fn.jquery).toEqual('1.11.1');
- }
- });
+ it('should not overwrite existing jQuery versions', function () {
+ // the AMD test page does not include jquery
+ if (typeof $ !== 'undefined') {
+ // the jasmine test page loads 1.11.1 while 1.10.2 is bundled with F2
+ expect($.fn.jquery).toEqual('1.11.1');
+ }
+ });
});
\ No newline at end of file
diff --git a/tests/spec/preamble-spec.js b/tests/spec/preamble-spec.js
index 1f231c60..815ad89b 100644
--- a/tests/spec/preamble-spec.js
+++ b/tests/spec/preamble-spec.js
@@ -1,56 +1,56 @@
-describe('F2.extend', function() {
+describe('F2.extend', function () {
- it('should ignore extra F2 namespace', function() {
- F2.extend('F2.TestObj', { foo: 'bar' });
- expect(F2.TestObj).toEqual({ foo: 'bar' })
- });
+ it('should ignore extra F2 namespace', function () {
+ F2.extend('F2.TestObj', {foo: 'bar'});
+ expect(F2.TestObj).toEqual({foo: 'bar'})
+ });
- it('should not overwrite properties by default', function() {
- F2.extend('F2.TestObj', { foo: 'bar' });
- F2.extend('F2.TestObj', { foo: 'foo' });
- expect(F2.TestObj).toEqual({ foo: 'bar' });
- });
+ it('should not overwrite properties by default', function () {
+ F2.extend('F2.TestObj', {foo: 'bar'});
+ F2.extend('F2.TestObj', {foo: 'foo'});
+ expect(F2.TestObj).toEqual({foo: 'bar'});
+ });
- it('should overwrite properties', function() {
- F2.extend('F2.TestObj', { foo: 'bar' });
- F2.extend('F2.TestObj', { foo: 'foo' }, true);
- expect(F2.TestObj).toEqual({ foo: 'foo' });
- });
+ it('should overwrite properties', function () {
+ F2.extend('F2.TestObj', {foo: 'bar'});
+ F2.extend('F2.TestObj', {foo: 'foo'}, true);
+ expect(F2.TestObj).toEqual({foo: 'foo'});
+ });
});
-describe('F2.guid', function() {
+describe('F2.guid', function () {
- it('should not produce equal guids', function() {
- expect(F2.guid()).not.toMatch(F2.guid());
- });
+ it('should not produce equal guids', function () {
+ expect(F2.guid()).not.toMatch(F2.guid());
+ });
});
-describe('F2.inArray', function() {
+describe('F2.inArray', function () {
- it('returns true if an item is in the array', function() {
- expect(F2.inArray(1, [3, 2, 1])).toBeTruthy();
- });
+ it('returns true if an item is in the array', function () {
+ expect(F2.inArray(1, [3, 2, 1])).toBeTruthy();
+ });
- it('returns false if an item is not in the array', function() {
- expect(F2.inArray(1, [7, 8, 9])).toBeFalsy();
- });
+ it('returns false if an item is not in the array', function () {
+ expect(F2.inArray(1, [7, 8, 9])).toBeFalsy();
+ });
});
-describe('F2.parse', function() {
+describe('F2.parse', function () {
- it('should parse a json object', function() {
- expect(F2.parse('{"foo":"bar"}')).toEqual({ foo: 'bar' });
- });
+ it('should parse a json object', function () {
+ expect(F2.parse('{"foo":"bar"}')).toEqual({foo: 'bar'});
+ });
});
-describe('F2.stringify', function() {
+describe('F2.stringify', function () {
- it('should convert an object to a json string', function() {
- expect(F2.stringify({ foo: 'bar' })).toMatch('{"foo":"bar"}');
- });
+ it('should convert an object to a json string', function () {
+ expect(F2.stringify({foo: 'bar'})).toMatch('{"foo":"bar"}');
+ });
});
\ No newline at end of file
diff --git a/tests/spec/spec-helpers.js b/tests/spec/spec-helpers.js
index ac72146b..019da100 100644
--- a/tests/spec/spec-helpers.js
+++ b/tests/spec/spec-helpers.js
@@ -1,90 +1,90 @@
var TEST_MANIFEST_URL = 'http://localhost:8080/F2/apps/test/hello-world',
- TEST_APP_ID = 'com_openf2_examples_javascript_helloworld',
- TEST_MANIFEST_URL2 = 'http://localhost:8080/F2/apps/test/market-news',
- TEST_APP_ID2 = 'com_openf2_examples_csharp_marketnews',
- TEST_MANIFEST_URL_HTTP_POST = 'http://localhost:8080/F2/apps/test/http-post'
-;
+ TEST_APP_ID = 'com_openf2_examples_javascript_helloworld',
+ TEST_MANIFEST_URL2 = 'http://localhost:8080/F2/apps/test/market-news',
+ TEST_APP_ID2 = 'com_openf2_examples_csharp_marketnews',
+ TEST_MANIFEST_URL_HTTP_POST = 'http://localhost:8080/F2/apps/test/http-post'
+ ;
/**
* Addition to Jasmine Async that reloads F2
*/
-AsyncSpec.prototype.beforeEachReloadF2 = function(callback) {
- this.beforeEach(function(done) {
- window.F2 = null;
- window.F2 = window.F2 || { Apps:{} };
- $.ajax({
- url: '../sdk/f2.min.js',
- dataType: 'script',
- complete: function() {
- callback && callback();
- done();
- }
- });
- });
+AsyncSpec.prototype.beforeEachReloadF2 = function (callback) {
+ this.beforeEach(function (done) {
+ window.F2 = null;
+ window.F2 = window.F2 || {Apps: {}};
+ $.ajax({
+ url: '../sdk/f2.min.js',
+ dataType: 'script',
+ complete: function () {
+ callback && callback();
+ done();
+ }
+ });
+ });
};
/**
*
*/
-itConditionally = function(condition, desc, func) {
- if (condition) {
- return jasmine.getEnv().it(desc, func);
- } else {
- var el = document.getElementById('tests-skipped');
- var count = Number(el.getAttribute('data-count')) + 1;
- el.innerHTML = 'Skipping ' + count + ' spec' + ((count > 1) ? 's' : '');
- el.setAttribute('data-count', count);
- el.style.display = 'block';
- return jasmine.getEnv().xit(desc, func);
- }
+itConditionally = function (condition, desc, func) {
+ if (condition) {
+ return jasmine.getEnv().it(desc, func);
+ } else {
+ var el = document.getElementById('tests-skipped');
+ var count = Number(el.getAttribute('data-count')) + 1;
+ el.innerHTML = 'Skipping ' + count + ' spec' + ((count > 1) ? 's' : '');
+ el.setAttribute('data-count', count);
+ el.style.display = 'block';
+ return jasmine.getEnv().xit(desc, func);
+ }
};
/**
* Clean out the test fixture before each spec
*/
-beforeEach(function() {
- $('#test-fixture').empty();
+beforeEach(function () {
+ $('#test-fixture').empty();
});
/**
* Adds .toLog matcher for checking for F2.log messages
*/
-beforeEach(function() {
+beforeEach(function () {
- this.addMatchers({
+ this.addMatchers({
- toLog: function(expectedMessage) {
+ toLog: function (expectedMessage) {
- // copy F2.log before overriding
- var log = F2.log;
- var result = false;
- var suite = this;
- var passedMessage;
-
- F2.log = function(message) {
- passedMessage = message;
- };
+ // copy F2.log before overriding
+ var log = F2.log;
+ var result = false;
+ var suite = this;
+ var passedMessage;
- // fire the test function which should call the F2.log override above
- suite.actual();
+ F2.log = function (message) {
+ passedMessage = message;
+ };
- result = passedMessage == expectedMessage;
+ // fire the test function which should call the F2.log override above
+ suite.actual();
- if (!result) {
- suite.message = function() {
- if (!passedMessage) {
- return 'Expected function ' + (suite.isNot ? 'not' : '') + 'to pass \'' + expectedMessage + '\' to F2.log, but nothing was passed.';
- } else {
- return 'Expected function ' + (suite.isNot ? 'not' : '') + 'to pass \'' + expectedMessage + '\' to F2.log, but \'' + passedMessage + '\' was passed.';
- }
- };
- }
+ result = passedMessage == expectedMessage;
- // return F2.log to its original state
- F2.log = log;
+ if (!result) {
+ suite.message = function () {
+ if (!passedMessage) {
+ return 'Expected function ' + (suite.isNot ? 'not' : '') + 'to pass \'' + expectedMessage + '\' to F2.log, but nothing was passed.';
+ } else {
+ return 'Expected function ' + (suite.isNot ? 'not' : '') + 'to pass \'' + expectedMessage + '\' to F2.log, but \'' + passedMessage + '\' was passed.';
+ }
+ };
+ }
- return result;
- }
+ // return F2.log to its original state
+ F2.log = log;
- });
+ return result;
+ }
+
+ });
});
\ No newline at end of file