diff --git a/README.md b/README.md index 91a6aa8..5c6d848 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Before using luminateExtend.js, there are a few basic steps you must follow: Including the library --------------------- +### Quick start Once you've uploaded [luminateExtend.min.js](https://github.com/noahcooper/luminateExtend/blob/master/luminateExtend.min.js) to your website, including the library on a page is easy — simply pull in the library somewhere below where @@ -97,6 +98,28 @@ As of v1.6, luminateExtend.js can be used with [Zepto](http://zeptojs.com) in li ``` +### Install with NPM +``` +npm install luminateExtend --save +``` + +#### Load luminateExtend module +```js +var jQuery = require('jquery'); +var luminateExtend = require('luminateExtend'); +``` + +### Install with Bower +``` +bower install luminateExtend +``` + +```html + + +``` + + The luminateExtend object ------------------------- diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..d53c5bd --- /dev/null +++ b/bower.json @@ -0,0 +1,30 @@ +{ + "name": "luminateExtend", + "description": "A JavaScript library for use with Blackbaud's Luminate Online product suite", + "version": "1.8.1", + "main": "luminateExtend.js", + "authors": [ + "noahcooper" + ], + "dependencies": { + "jquery": ">=1.5.1" + }, + "license": "MIT", + "keywords": [ + "luminate", + "blackbaud", + "teamraiser", + "team", + "raiser", + "convio" + ], + "homepage": "https://github.com/noahcooper/luminateExtend", + "moduleType": [], + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/luminateExtend.js b/luminateExtend.js index eef0f75..7f6780a 100644 --- a/luminateExtend.js +++ b/luminateExtend.js @@ -1,12 +1,31 @@ /* * luminateExtend.js - * Version: 1.8.1 (18-OCT-2016) + * Version: 1.8.1 (23-FEB-2017) * Requires: jQuery v1.5.1+ or Zepto v1.1+ * Includes: SimpleDateFormatJS v1.3 (https://github.com/noahcooper/SimpleDateFormatJS) */ -(function($) { - /* private helper functions */ + +(function (factory) { + // If there is a variable named module and it has an exports property, + // then we're working in a Node-like environment. Use require to load + // the jQuery object that the module system is using and pass it in. + if (typeof define === 'function' && define.amd) { + define(['jquery'], function(jquery){ + return factory(jquery, window, document); + }); + } else if(typeof module === "object" && typeof module.exports === "object") { + module.exports = factory(require('jQuery'), window, document); + } + // Otherwise, we're working in a browser, so just pass in the global + // jQuery or Zepto object. + else { + factory(typeof jQuery === 'undefined' && typeof Zepto === 'function' ? Zepto : jQuery, window, document); + } +}(function($, window, document, undefined) { + // This code will receive whatever jQuery object was passed in from + // the function above and will attach the tipso plugin to it. + // var validateLocale = function(locale) { /* if a locale is provided that is not supported, default to "en_US" */ if(locale && $.inArray(locale, ['es_US', 'en_CA', 'fr_CA', 'en_GB', 'en_AU']) < 0) { @@ -33,10 +52,32 @@ (data ? ('&' + data) : ''); }, - apiCallbackHandler = function(requestSettings, responseData) { - if(requestSettings.responseFilter && + apiCallbackHandler = function(requestSettings, responseData, jqXHR_textStatus) { + // test if response data is a jqXHR object. This means, we have had a AJAX error for some reason + if (typeof responseData.getResponseHeader === 'function') { + // if the XML HTTP status is 0, it could be due to a Cross-site scripting issue related to CORS header. + // Normally we would use the error directly from the ajax request but a status of 0 has an empty response text + if (responseData.status == 0) { + var port = window.location.port; + var addendum = '. You need to whitelist the domain and port API requests are originating from'; + + if (port !== '') { + port = ':' + port; + } else { + addendum = ''; + } + + var message = 'Check your Luminate API settings to make sure ' + window.location.hostname + port + ' is whitelisted' + addendum; + + responseData = new luminateExtend.api.error(message); + } else { + responseData = new luminateExtend.api.error(jqXHR_textStatus); + } + + } else if(requestSettings.responseFilter && requestSettings.responseFilter.array && requestSettings.responseFilter.filter) { + if(luminateExtend.utils.stringToObj(requestSettings.responseFilter.array, responseData)) { var filterKey = requestSettings.responseFilter.filter.split('==')[0].split('!=')[0].replace(/^\s+|\s+$/g, ''), filterOperator, @@ -104,7 +145,7 @@ if(typeof requestSettings.callback === 'function') { callbackFn = requestSettings.callback; } - else if(requestSettings.callback.error && responseData.errorResponse) { + else if((requestSettings.callback.error && responseData.errorResponse) || responseData instanceof Error) { callbackFn = requestSettings.callback.error; } else if(requestSettings.callback.success && !responseData.errorResponse) { @@ -114,22 +155,21 @@ var isLoginRequest = requestSettings.data.indexOf('&method=login') !== -1 && requestSettings.data.indexOf('&method=loginTest') === -1, isLogoutRequest = requestSettings.data.indexOf('&method=logout') !== -1; - - if(!isLoginRequest && !isLogoutRequest) { + + if((!isLoginRequest && !isLogoutRequest) || responseData instanceof Error) { callbackFn(responseData); } - /* get a new auth token after login or logout */ else { var newAuthCallback = function() { callbackFn(responseData); - }, + }, getAuthOptions = { callback: newAuthCallback, useCache: false, useHTTPS: requestSettings.useHTTPS }; - + if(isLoginRequest && responseData.loginResponse && responseData.loginResponse.nonce) { getAuthOptions.nonce = 'NONCE_TOKEN=' + responseData.loginResponse.nonce; } @@ -146,7 +186,7 @@ /* library info */ luminateExtend.library = { - version: '1.7.1' + version: '1.8.1' }; /* global settings */ @@ -285,6 +325,8 @@ if(settings.callback) { settings.callback(); + } else { + return luminateExtend.global.auth; } } else { @@ -294,6 +336,8 @@ if(settings.callback) { settings.callback(); + } else { + return uminateExtend.global.auth; } }; @@ -350,6 +394,7 @@ luminateExtend.api.getAuthLoad = true; var sendRequest = function(options) { + var settings = $.extend({ contentType: 'application/x-www-form-urlencoded', data: '', @@ -449,6 +494,7 @@ } var doRequest; + if(useAjax) { doRequest = function() { if(luminateExtend.global.routingId && luminateExtend.global.routingId !== '') { @@ -471,10 +517,9 @@ contentType: settings.contentType, /* set dataType explicitly as API sends Content-Type: text/plain rather than application/json (E-62659) */ dataType: 'json', - type: 'POST', - success: function(data) { - apiCallbackHandler(settings, data); - } + type: 'POST', + }).always(function(xhr_or_data, status, xhr_error) { + apiCallbackHandler(settings, xhr_or_data, status); }); }; } @@ -568,7 +613,7 @@ if(!$.isArray(requests)) { sendRequest(requests); } - + else { requests.reverse(); @@ -619,6 +664,21 @@ }); } }; + + luminateExtend.api.error = function(message) { + function LuminateError(message) { + this.name = 'LuminateError'; + this.default_message = 'Error communicating with the Luminate API. Check your Luminate API settings'; + + this.message = message || this.default_message; + this.stack = (new Error()).stack; + } + + LuminateError.prototype = Object.create(Error.prototype); + LuminateError.prototype.constructor = LuminateError; + + return new LuminateError(message); + }; /* session variables */ luminateExtend.sessionVars = { @@ -1014,4 +1074,4 @@ return formattedDate; } }; -})(typeof jQuery === 'undefined' && typeof Zepto === 'function' ? Zepto : jQuery); \ No newline at end of file +})); \ No newline at end of file diff --git a/luminateExtend.min.js b/luminateExtend.min.js index 39cc399..26d5b92 100644 --- a/luminateExtend.min.js +++ b/luminateExtend.min.js @@ -1,2 +1,2 @@ -/* luminateExtend.js | Version: 1.8.1 (18-OCT-2016) */ -!function(a){var b=function(b){return b&&a.inArray(b,["es_US","en_CA","fr_CA","en_GB","en_AU"])<0&&(b="en_US"),b},c=function(a){return a&&(a=b(a),luminateExtend.sessionVars.set("locale",a)),a},d=function(a,b){return(a?luminateExtend.global.path.secure+"S":luminateExtend.global.path.nonsecure)+"PageServer"+(luminateExtend.global.routingId&&""!==luminateExtend.global.routingId?";"+luminateExtend.global.routingId:"")+"?pagename=luminateExtend_server&pgwrap=n"+(b?"&"+b:"")},e=function(b,c){if(b.responseFilter&&b.responseFilter.array&&b.responseFilter.filter&&luminateExtend.utils.stringToObj(b.responseFilter.array,c)){var e,f,d=b.responseFilter.filter.split("==")[0].split("!=")[0].replace(/^\s+|\s+$/g,"");if(b.responseFilter.filter.indexOf("!=")!==-1?(e="nequal",f=b.responseFilter.filter.split("!=")[1]):b.responseFilter.filter.indexOf("==")!==-1&&(e="equal",f=b.responseFilter.filter.split("==")[1]),e&&f){f=f.replace(/^\s+|\s+$/g,"");var g=[],h=!1;if(a.each(luminateExtend.utils.ensureArray(luminateExtend.utils.stringToObj(b.responseFilter.array,c)),function(){"nequal"===e&&this[d]===f||"equal"===e&&this[d]!==f?h=!0:g.push(this)}),h){var i=b.responseFilter.array.split(".");a.each(c,function(b,d){b===i[0]&&a.each(d,function(d,e){d===i[1]&&(2===i.length?c[b][d]=g:a.each(e,function(e,f){e===i[2]&&(3===i.length?c[b][d][e]=g:a.each(f,function(a,f){a===i[3]&&4===i.length&&(c[b][d][e][a]=g)}))}))})})}}}var j=a.noop;b.callback&&("function"==typeof b.callback?j=b.callback:b.callback.error&&c.errorResponse?j=b.callback.error:b.callback.success&&!c.errorResponse&&(j=b.callback.success));var k=b.data.indexOf("&method=login")!==-1&&b.data.indexOf("&method=loginTest")===-1,l=b.data.indexOf("&method=logout")!==-1;if(k||l){var m=function(){j(c)},n={callback:m,useCache:!1,useHTTPS:b.useHTTPS};k&&c.loginResponse&&c.loginResponse.nonce&&(n.nonce="NONCE_TOKEN="+c.loginResponse.nonce),luminateExtend.api.getAuth(n)}else j(c)};window.luminateExtend=function(a){luminateExtend.init(a||{})},luminateExtend.library={version:"1.7.1"},luminateExtend.global={update:function(b,d){b&&(b.length?d&&("locale"===b&&(d=c(d)),luminateExtend.global[b]=d):(b.locale&&(b.locale=c(b.locale)),luminateExtend.global=a.extend(luminateExtend.global,b)))}},luminateExtend.init=function(c){var d=a.extend({apiCommon:{},auth:{type:"auth"},path:{}},c||{});if(d.locale&&(d.locale=b(d.locale)),d.supportsCORS=!1,window.XMLHttpRequest){var e=new XMLHttpRequest;"withCredentials"in e&&(d.supportsCORS=!0)}return luminateExtend.global=a.extend(luminateExtend.global,d),luminateExtend},luminateExtend.api=function(a){luminateExtend.api.request(a||{})},luminateExtend.api.bind=function(b){return b=b||"form.luminateApi",a(b).length>0&&a(b).each(function(){"form"===this.nodeName.toLowerCase()&&a(this).bind("submit",function(b){b.cancelBubble=!0,b.returnValue=!1,b.stopPropagation&&(b.stopPropagation(),b.preventDefault()),a(this).attr("id")||a(this).attr("id","luminateApi-"+(new Date).getTime());var g,c=a(this).attr("action"),d=c.split("?"),e=a(this).data("luminateapi"),f=d[0].indexOf("/site/")!==-1?d[0].split("/site/")[1]:d[0],h=a(this).attr("enctype"),i=d.length>1?d[1]:"",j="#"+a(this).attr("id"),k=!1,l=!1;e&&(e.callback&&(g=luminateExtend.utils.stringToObj(e.callback)),e.requiresAuth&&"true"===e.requiresAuth&&(k=!0),(0===c.indexOf("https:")||"https:"===window.location.protocol&&c.indexOf("http")===-1)&&(l=!0)),luminateExtend.api.request({api:f,callback:g,contentType:h,data:i,form:j,requiresAuth:k,useHTTPS:l})})}),luminateExtend},luminateExtend.api.getAuth=function(b){var c=a.extend({useCache:!0,useHTTPS:!1},b||{});if(luminateExtend.api.getAuthLoad)if(luminateExtend.api.getAuthLoad=!1,c.useCache&&luminateExtend.global.auth.type&&luminateExtend.global.auth.token)luminateExtend.api.getAuthLoad=!0,c.callback&&c.callback();else{var e=function(a){luminateExtend.global.update(a),luminateExtend.api.getAuthLoad=!0,c.callback&&c.callback()};luminateExtend.global.supportsCORS?a.ajax({url:(c.useHTTPS?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"CRConsAPI",data:"luminateExtend="+luminateExtend.library.version+(c.nonce&&""!==c.nonce?"&"+c.nonce:"")+"&api_key="+luminateExtend.global.apiKey+"&method=getLoginUrl&response_format=json&v=1.0",xhrFields:{withCredentials:!0},dataType:"json",success:function(a){var b=a.getLoginUrlResponse,c=b.url,d=b.routing_id,f=b.JSESSIONID;d||c.indexOf("CRConsAPI;jsessionid=")===-1||(d=c.split("CRConsAPI;jsessionid=")[1].split("?")[0]),e({auth:{type:"auth",token:b.token},routingId:d?"jsessionid="+d:"",sessionCookie:f?"JSESSIONID="+f:""})}}):a.ajax({url:d(c.useHTTPS,"action=getAuth&callback=?"),dataType:"jsonp",success:e})}else{var f=function(){luminateExtend.api.getAuth(c)};setTimeout(f,1e3)}},luminateExtend.api.getAuthLoad=!0;var f=function(b){var c=a.extend({contentType:"application/x-www-form-urlencoded",data:"",requiresAuth:!1,useHTTPS:null},b||{}),f=["addressbook","advocacy","connect","cons","content","datasync","donation","email","group","orgevent","recurring","survey","teamraiser"];if(a.inArray(c.api.toLowerCase(),f)>=0&&(c.api="CR"+c.api.charAt(0).toUpperCase()+c.api.slice(1).toLowerCase()+"API",c.api=c.api.replace("Addressbook","AddressBook").replace("Datasync","DataSync").replace("Orgevent","OrgEvent")),luminateExtend.global.path.nonsecure&&luminateExtend.global.path.secure&&luminateExtend.global.apiKey&&c.api){"multipart/form-data"===c.contentType.split(";")[0]?c.contentType="multipart/form-data":c.contentType="application/x-www-form-urlencoded",c.contentType+="; charset=UTF-8",c.data="luminateExtend="+luminateExtend.library.version+(""===c.data?"":"&"+c.data),c.form&&a(c.form).length>0&&(c.data+="&"+a(c.form).eq(0).serialize()),c.data.indexOf("&api_key=")===-1&&(c.data+="&api_key="+luminateExtend.global.apiKey),luminateExtend.global.apiCommon.centerId&&c.data.indexOf("¢er_id=")===-1&&(c.data+="¢er_id="+luminateExtend.global.apiCommon.centerId),luminateExtend.global.apiCommon.categoryId&&c.data.indexOf("&list_category_id=")===-1&&(c.data+="&list_category_id="+luminateExtend.global.apiCommon.categoryId),c.data.indexOf("&response_format=xml")!==-1?c.data=c.data.replace(/&response_format=xml/g,"&response_format=json"):c.data.indexOf("&response_format=")===-1&&(c.data+="&response_format=json"),luminateExtend.global.apiCommon.source&&c.data.indexOf("&source=")===-1&&(c.data+="&source="+luminateExtend.global.apiCommon.source),luminateExtend.global.apiCommon.subSource&&c.data.indexOf("&sub_source=")===-1&&(c.data+="&sub_source="+luminateExtend.global.apiCommon.subSource),c.data.indexOf("&suppress_response_codes=")===-1&&(c.data+="&suppress_response_codes=true"),luminateExtend.global.locale&&c.data.indexOf("&s_locale=")===-1&&(c.data+="&s_locale="+luminateExtend.global.locale),c.data.indexOf("&v=")===-1&&(c.data+="&v=1.0");var g="http://",h=luminateExtend.global.path.nonsecure.split("http://")[1];"CRDonationAPI"===c.api||"CRTeamraiserAPI"===c.api||"CRConnectAPI"!==c.api&&("https:"===window.location.protocol&&null==c.useHTTPS||1==c.useHTTPS)?c.useHTTPS=!0:c.useHTTPS=!1,c.useHTTPS&&(g="https://",h=luminateExtend.global.path.secure.split("https://")[1]),g+=h+c.api;var i=!1,j=!1,k=!1;window.location.protocol===g.split("//")[0]&&document.domain===h.split("/")[0]?(i=!0,j=!0):luminateExtend.global.supportsCORS?j=!0:"postMessage"in window&&(k=!0);var l;j?l=function(){luminateExtend.global.routingId&&""!==luminateExtend.global.routingId&&(g+=";"+luminateExtend.global.routingId),c.requiresAuth&&c.data.indexOf("&"+luminateExtend.global.auth.type+"=")===-1&&(c.data+="&"+luminateExtend.global.auth.type+"="+luminateExtend.global.auth.token),luminateExtend.global.sessionCookie&&""!==luminateExtend.global.sessionCookie&&(c.data+="&"+luminateExtend.global.sessionCookie),c.data+="&ts="+(new Date).getTime(),a.ajax({url:g,data:c.data,xhrFields:{withCredentials:!0},contentType:c.contentType,dataType:"json",type:"POST",success:function(a){e(c,a)}})}:k&&(l=function(){var b=(new Date).getTime(),f="luminateApiPostMessage"+b,h=d(c.useHTTPS,"action=postMessage");luminateExtend.global.routingId&&""!==luminateExtend.global.routingId&&(g+=";"+luminateExtend.global.routingId),c.requiresAuth&&c.data.indexOf("&"+luminateExtend.global.auth.type+"=")===-1&&(c.data+="&"+luminateExtend.global.auth.type+"="+luminateExtend.global.auth.token),luminateExtend.global.sessionCookie&&""!==luminateExtend.global.sessionCookie&&(c.data+="&"+luminateExtend.global.sessionCookie),c.data+="&ts="+b,luminateExtend.api.request.postMessageEventHandler||(luminateExtend.api.request.postMessageEventHandler={},luminateExtend.api.request.postMessageEventHandler.handler=function(b){if(luminateExtend.global.path.nonsecure.indexOf(b.origin)!==-1||luminateExtend.global.path.secure.indexOf(b.origin)!==-1){var c=a.parseJSON(b.data),d=c.postMessageFrameId,e=a.parseJSON(decodeURIComponent(c.response));luminateExtend.api.request.postMessageEventHandler[d]&&luminateExtend.api.request.postMessageEventHandler[d](d,e)}},"undefined"!=typeof window.addEventListener?window.addEventListener("message",luminateExtend.api.request.postMessageEventHandler.handler,!1):"undefined"!=typeof window.attachEvent&&window.attachEvent("onmessage",luminateExtend.api.request.postMessageEventHandler.handler)),luminateExtend.api.request.postMessageEventHandler[f]=function(b,d){e(c,d),a("#"+b).remove(),delete luminateExtend.api.request.postMessageEventHandler[b]},a("body").append(''),a("#"+f).bind("load",function(){var b='{"postMessageFrameId": "'+a(this).attr("id")+'", "requestUrl": "'+g+'", "requestContentType": "'+c.contentType+'", "requestData": "'+c.data+'"}',d=g.split("/site/")[0].split("/admin/")[0];document.getElementById(a(this).attr("id")).contentWindow.postMessage(b,d)}),a("#"+f).attr("src",h)}),c.requiresAuth||!j&&!i&&!luminateExtend.global.sessionCookie?luminateExtend.api.getAuth({callback:l,useHTTPS:c.useHTTPS}):l()}};luminateExtend.api.request=function(b){if(a.isArray(b)){b.reverse();var c=[];a.each(b,function(d){var e=a.extend({async:!0},this);if(e.async||d===b.length-1)c.push(e);else{var g=b[d+1];if(g.callback&&"function"!=typeof g.callback){var h=g.callback.success||a.noop;g.callback.success=function(a){h(a),f(e)}}else{var g=b[d+1],i=g.callback||a.noop;g.callback={success:function(a){i(a),f(e)},error:function(a){i(a)}}}}}),c.reverse(),a.each(c,function(){f(this)})}else f(b)},luminateExtend.sessionVars={set:function(a,b,c){var d={};c&&(d.callback=c),a&&(d.data="s_"+a+"="+(b||""),luminateExtend.utils.ping(d))}},luminateExtend.tags=function(a,b){luminateExtend.tags.parse(a,b)},luminateExtend.tags.parse=function(b,c){luminateExtend.widgets?luminateExtend.widgets(b,c):(b=b&&"all"!==b?luminateExtend.utils.ensureArray(b):["cons"],c=c||"body",a.each(b,function(b,d){if("cons"===d){var e=a(c).find(document.getElementsByTagName("luminate:cons"));if(e.length>0){var f=function(b){e.each(function(){b.getConsResponse?a(this).replaceWith(luminateExtend.utils.stringToObj(a(this).attr("field"),b.getConsResponse)):a(this).remove()})};luminateExtend.api.request({api:"cons",callback:f,data:"method=getUser",requiresAuth:!0})}}}))},luminateExtend.utils={ensureArray:function(b){return a.isArray(b)?b:b?[b]:[]},stringToObj:function(a,b){var c=b||window;if(a)for(var d=a.split("."),e=0;e'),a("#"+d).bind("load",function(){a(this).remove(),c.callback&&c.callback()}),a("#"+d).attr("src",("https:"===window.location.protocol?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"EstablishSession"+(luminateExtend.global.routingId&&""!==luminateExtend.global.routingId?";"+luminateExtend.global.routingId:"")+"?"+(null==c.data?"":c.data+"&")+"NEXTURL="+encodeURIComponent(("https:"===window.location.protocol?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"PixelServer"))},simpleDateFormat:function(c,d,e){if(e=e||luminateExtend.global.locale,e=b(e),d=d||(a.inArray(e,["en_CA","fr_CA","en_GB","en_AU"])>=0?"d/M/yy":"M/d/yy"),c=c||new Date,!(c instanceof Date)){var f=c.split("T")[0].split("-"),g=c.split("T").length>1?c.split("T")[1].split(".")[0].split("Z")[0].split("-")[0].split(":"):["00","00","00"];c=new Date(f[0],f[1]-1,f[2],g[0],g[1],g[2])}var h=function(a){return a=""+a,0===a.indexOf("0")&&"0"!==a?a.substring(1):a},i=function(a){return a=Number(a),isNaN(a)?"00":(a<10?"0":"")+a},j={month:i(c.getMonth()+1),date:i(c.getDate()),year:i(c.getFullYear()),day:c.getDay(),hour24:c.getHours(),hour12:c.getHours(),minutes:i(c.getMinutes()),ampm:"AM"};j.hour24>11&&(j.ampm="PM"),j.hour24=i(j.hour24),0===j.hour12&&(j.hour12=12),j.hour12>12&&(j.hour12=j.hour12-12),j.hour12=i(j.hour12);var k,l=function(a){var b=a.replace(/yy+(?=y)/g,"yy").replace(/MMM+(?=M)/g,"MMM").replace(/d+(?=d)/g,"d").replace(/EEE+(?=E)/g,"EEE").replace(/a+(?=a)/g,"").replace(/k+(?=k)/g,"k").replace(/h+(?=h)/g,"h").replace(/m+(?=m)/g,"m"),c=b.replace(/yyy/g,j.year).replace(/yy/g,j.year.substring(2)).replace(/y/g,j.year).replace(/dd/g,j.date).replace(/d/g,h(j.date)),d=function(a,b,c){for(var d=1;d23&&(e=23);var f="+"===c?e:0-e;"kk"===b||"k"===b?(f=Number(j.hour24)+f,f>24?f-=24:f<0&&(f+=24)):(f=Number(j.hour12)+f,f>24?f-=24:f<0&&(f+=24),f>12&&(f-=12)),f=""+f,"kk"!==b&&"hh"!==b||(f=i(f)),("h"===b&&0===f||"hh"===b&&"00"===f)&&(f="12"),a[d]=f+a[d]}return a.join("")};c.indexOf("k+")!==-1&&(c=d(c.split("kk+"),"kk","+"),c=d(c.split("k+"),"k","+")),c.indexOf("k-")!==-1&&(c=d(c.split("kk-"),"kk","-"),c=d(c.split("k-"),"k","-")),c=c.replace(/kk/g,j.hour24).replace(/k/g,h(j.hour24)),c.indexOf("h+")!==-1&&(c=d(c.split("hh+"),"hh","+"),c=d(c.split("h+"),"h","+")),c.indexOf("h-")!==-1&&(c=d(c.split("hh-"),"hh","-"),c=d(c.split("h-"),"h","-")),c=c.replace(/hh/g,j.hour12<12&&j.hour12.indexOf&&0!==j.hour12.indexOf("0")?"0"+j.hour12:j.hour12).replace(/h/g,h(j.hour12)),c=c.replace(/mm/g,j.minutes).replace(/m/g,h(j.minutes)),c=c.replace(/a/g,"A");var f=["January","February","march","april","may","June","July","august","September","October","November","December"];"es_US"===e&&(f=["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]),"fr_CA"===e&&(f=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]),c=c.replace(/MMMM/g,f[Number(j.month)-1]).replace(/MMM/g,f[Number(j.month)-1].substring(0,3)).replace(/MM/g,j.month).replace(/M/g,h(j.month)).replace(/march/g,"March").replace(/may/g,"May").replace(/Mayo/g,"mayo");var g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];return"es_US"===e&&(g=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]),"fr_CA"===e&&(g=["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]),c=c.replace(/EEEE/g,g[j.day]).replace(/EEE/g,g[j.day].substring(0,3)).replace(/EE/g,g[j.day].substring(0,3)).replace(/E/g,g[j.day].substring(0,3)),c=c.replace(/A/g,j.ampm).replace(/april/g,"April").replace(/august/g,"August")};if(d.indexOf("'")!==-1){var m=d.replace(/\'+(?=\')/g,"''").split("''");if(1===m.length){m=d.split("'");for(var n=0;n0&&a(c).each(function(){"form"===this.nodeName.toLowerCase()&&a(this).bind("submit",function(c){c.cancelBubble=!0,c.returnValue=!1,c.stopPropagation&&(c.stopPropagation(),c.preventDefault()),a(this).attr("id")||a(this).attr("id","luminateApi-"+(new Date).getTime());var h,d=a(this).attr("action"),e=d.split("?"),f=a(this).data("luminateapi"),g=e[0].indexOf("/site/")!==-1?e[0].split("/site/")[1]:e[0],i=a(this).attr("enctype"),j=e.length>1?e[1]:"",k="#"+a(this).attr("id"),l=!1,m=!1;f&&(f.callback&&(h=luminateExtend.utils.stringToObj(f.callback)),f.requiresAuth&&"true"===f.requiresAuth&&(l=!0),(0===d.indexOf("https:")||"https:"===b.location.protocol&&d.indexOf("http")===-1)&&(m=!0)),luminateExtend.api.request({api:g,callback:h,contentType:i,data:j,form:k,requiresAuth:l,useHTTPS:m})})}),luminateExtend},luminateExtend.api.getAuth=function(b){var c=a.extend({useCache:!0,useHTTPS:!1},b||{});if(luminateExtend.api.getAuthLoad)if(luminateExtend.api.getAuthLoad=!1,c.useCache&&luminateExtend.global.auth.type&&luminateExtend.global.auth.token)luminateExtend.api.getAuthLoad=!0,c.callback&&c.callback();else{var d=function(a){luminateExtend.global.update(a),luminateExtend.api.getAuthLoad=!0,c.callback&&c.callback()};luminateExtend.global.supportsCORS?a.ajax({url:(c.useHTTPS?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"CRConsAPI",data:"luminateExtend="+luminateExtend.library.version+(c.nonce&&""!==c.nonce?"&"+c.nonce:"")+"&api_key="+luminateExtend.global.apiKey+"&method=getLoginUrl&response_format=json&v=1.0",xhrFields:{withCredentials:!0},dataType:"json",success:function(a){var b=a.getLoginUrlResponse,c=b.url,e=b.routing_id,f=b.JSESSIONID;e||c.indexOf("CRConsAPI;jsessionid=")===-1||(e=c.split("CRConsAPI;jsessionid=")[1].split("?")[0]),d({auth:{type:"auth",token:b.token},routingId:e?"jsessionid="+e:"",sessionCookie:f?"JSESSIONID="+f:""})}}):a.ajax({url:g(c.useHTTPS,"action=getAuth&callback=?"),dataType:"jsonp",success:d})}else{var e=function(){luminateExtend.api.getAuth(c)};setTimeout(e,1e3)}},luminateExtend.api.getAuthLoad=!0;var i=function(d){var e=a.extend({contentType:"application/x-www-form-urlencoded",data:"",requiresAuth:!1,useHTTPS:null},d||{}),f=["addressbook","advocacy","connect","cons","content","datasync","donation","email","group","orgevent","recurring","survey","teamraiser"];if(a.inArray(e.api.toLowerCase(),f)>=0&&(e.api="CR"+e.api.charAt(0).toUpperCase()+e.api.slice(1).toLowerCase()+"API",e.api=e.api.replace("Addressbook","AddressBook").replace("Datasync","DataSync").replace("Orgevent","OrgEvent")),luminateExtend.global.path.nonsecure&&luminateExtend.global.path.secure&&luminateExtend.global.apiKey&&e.api){"multipart/form-data"===e.contentType.split(";")[0]?e.contentType="multipart/form-data":e.contentType="application/x-www-form-urlencoded",e.contentType+="; charset=UTF-8",e.data="luminateExtend="+luminateExtend.library.version+(""===e.data?"":"&"+e.data),e.form&&a(e.form).length>0&&(e.data+="&"+a(e.form).eq(0).serialize()),e.data.indexOf("&api_key=")===-1&&(e.data+="&api_key="+luminateExtend.global.apiKey),luminateExtend.global.apiCommon.centerId&&e.data.indexOf("¢er_id=")===-1&&(e.data+="¢er_id="+luminateExtend.global.apiCommon.centerId),luminateExtend.global.apiCommon.categoryId&&e.data.indexOf("&list_category_id=")===-1&&(e.data+="&list_category_id="+luminateExtend.global.apiCommon.categoryId),e.data.indexOf("&response_format=xml")!==-1?e.data=e.data.replace(/&response_format=xml/g,"&response_format=json"):e.data.indexOf("&response_format=")===-1&&(e.data+="&response_format=json"),luminateExtend.global.apiCommon.source&&e.data.indexOf("&source=")===-1&&(e.data+="&source="+luminateExtend.global.apiCommon.source),luminateExtend.global.apiCommon.subSource&&e.data.indexOf("&sub_source=")===-1&&(e.data+="&sub_source="+luminateExtend.global.apiCommon.subSource),e.data.indexOf("&suppress_response_codes=")===-1&&(e.data+="&suppress_response_codes=true"),luminateExtend.global.locale&&e.data.indexOf("&s_locale=")===-1&&(e.data+="&s_locale="+luminateExtend.global.locale),e.data.indexOf("&v=")===-1&&(e.data+="&v=1.0");var i="http://",j=luminateExtend.global.path.nonsecure.split("http://")[1];"CRDonationAPI"===e.api||"CRTeamraiserAPI"===e.api||"CRConnectAPI"!==e.api&&("https:"===b.location.protocol&&null==e.useHTTPS||1==e.useHTTPS)?e.useHTTPS=!0:e.useHTTPS=!1,e.useHTTPS&&(i="https://",j=luminateExtend.global.path.secure.split("https://")[1]),i+=j+e.api;var k=!1,l=!1,m=!1;b.location.protocol===i.split("//")[0]&&c.domain===j.split("/")[0]?(k=!0,l=!0):luminateExtend.global.supportsCORS?l=!0:"postMessage"in b&&(m=!0);var n;l?n=function(){luminateExtend.global.routingId&&""!==luminateExtend.global.routingId&&(i+=";"+luminateExtend.global.routingId),e.requiresAuth&&e.data.indexOf("&"+luminateExtend.global.auth.type+"=")===-1&&(e.data+="&"+luminateExtend.global.auth.type+"="+luminateExtend.global.auth.token),luminateExtend.global.sessionCookie&&""!==luminateExtend.global.sessionCookie&&(e.data+="&"+luminateExtend.global.sessionCookie),e.data+="&ts="+(new Date).getTime(),a.ajax({url:i,data:e.data,xhrFields:{withCredentials:!0},contentType:e.contentType,dataType:"json",type:"POST"}).always(function(a,b,c){h(e,a,b)})}:m&&(n=function(){var d=(new Date).getTime(),f="luminateApiPostMessage"+d,j=g(e.useHTTPS,"action=postMessage");luminateExtend.global.routingId&&""!==luminateExtend.global.routingId&&(i+=";"+luminateExtend.global.routingId),e.requiresAuth&&e.data.indexOf("&"+luminateExtend.global.auth.type+"=")===-1&&(e.data+="&"+luminateExtend.global.auth.type+"="+luminateExtend.global.auth.token),luminateExtend.global.sessionCookie&&""!==luminateExtend.global.sessionCookie&&(e.data+="&"+luminateExtend.global.sessionCookie),e.data+="&ts="+d,luminateExtend.api.request.postMessageEventHandler||(luminateExtend.api.request.postMessageEventHandler={},luminateExtend.api.request.postMessageEventHandler.handler=function(b){if(luminateExtend.global.path.nonsecure.indexOf(b.origin)!==-1||luminateExtend.global.path.secure.indexOf(b.origin)!==-1){var c=a.parseJSON(b.data),d=c.postMessageFrameId,e=a.parseJSON(decodeURIComponent(c.response));luminateExtend.api.request.postMessageEventHandler[d]&&luminateExtend.api.request.postMessageEventHandler[d](d,e)}},"undefined"!=typeof b.addEventListener?b.addEventListener("message",luminateExtend.api.request.postMessageEventHandler.handler,!1):"undefined"!=typeof b.attachEvent&&b.attachEvent("onmessage",luminateExtend.api.request.postMessageEventHandler.handler)),luminateExtend.api.request.postMessageEventHandler[f]=function(b,c){h(e,c),a("#"+b).remove(),delete luminateExtend.api.request.postMessageEventHandler[b]},a("body").append(''),a("#"+f).bind("load",function(){var b='{"postMessageFrameId": "'+a(this).attr("id")+'", "requestUrl": "'+i+'", "requestContentType": "'+e.contentType+'", "requestData": "'+e.data+'"}',d=i.split("/site/")[0].split("/admin/")[0];c.getElementById(a(this).attr("id")).contentWindow.postMessage(b,d)}),a("#"+f).attr("src",j)}),e.requiresAuth||!l&&!k&&!luminateExtend.global.sessionCookie?luminateExtend.api.getAuth({callback:n,useHTTPS:e.useHTTPS}):n()}};luminateExtend.api.request=function(b){if(a.isArray(b)){b.reverse();var c=[];a.each(b,function(d){var e=a.extend({async:!0},this);if(e.async||d===b.length-1)c.push(e);else{var f=b[d+1];if(f.callback&&"function"!=typeof f.callback){var g=f.callback.success||a.noop;f.callback.success=function(a){g(a),i(e)}}else{var f=b[d+1],h=f.callback||a.noop;f.callback={success:function(a){h(a),i(e)},error:function(a){h(a)}}}}}),c.reverse(),a.each(c,function(){i(this)})}else i(b)},luminateExtend.api.error=function(a){function b(a){this.name="LuminateError",this.default_message="Error communicating with the Luminate API. Check your Luminate API settings",this.message=a||this.default_message,this.stack=(new Error).stack}return b.prototype=Object.create(Error.prototype),b.prototype.constructor=b,new b(a)},luminateExtend.sessionVars={set:function(a,b,c){var d={};c&&(d.callback=c),a&&(d.data="s_"+a+"="+(b||""),luminateExtend.utils.ping(d))}},luminateExtend.tags=function(a,b){luminateExtend.tags.parse(a,b)},luminateExtend.tags.parse=function(b,d){luminateExtend.widgets?luminateExtend.widgets(b,d):(b=b&&"all"!==b?luminateExtend.utils.ensureArray(b):["cons"],d=d||"body",a.each(b,function(b,e){if("cons"===e){var f=a(d).find(c.getElementsByTagName("luminate:cons"));if(f.length>0){var g=function(b){f.each(function(){b.getConsResponse?a(this).replaceWith(luminateExtend.utils.stringToObj(a(this).attr("field"),b.getConsResponse)):a(this).remove()})};luminateExtend.api.request({api:"cons",callback:g,data:"method=getUser",requiresAuth:!0})}}}))},luminateExtend.utils={ensureArray:function(b){return a.isArray(b)?b:b?[b]:[]},stringToObj:function(a,c){var d=c||b;if(a)for(var e=a.split("."),f=0;f'),a("#"+e).bind("load",function(){a(this).remove(),d.callback&&d.callback()}),a("#"+e).attr("src",("https:"===b.location.protocol?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"EstablishSession"+(luminateExtend.global.routingId&&""!==luminateExtend.global.routingId?";"+luminateExtend.global.routingId:"")+"?"+(null==d.data?"":d.data+"&")+"NEXTURL="+encodeURIComponent(("https:"===b.location.protocol?luminateExtend.global.path.secure:luminateExtend.global.path.nonsecure)+"PixelServer"))},simpleDateFormat:function(b,c,d){if(d=d||luminateExtend.global.locale,d=e(d),c=c||(a.inArray(d,["en_CA","fr_CA","en_GB","en_AU"])>=0?"d/M/yy":"M/d/yy"),b=b||new Date,!(b instanceof Date)){var f=b.split("T")[0].split("-"),g=b.split("T").length>1?b.split("T")[1].split(".")[0].split("Z")[0].split("-")[0].split(":"):["00","00","00"];b=new Date(f[0],f[1]-1,f[2],g[0],g[1],g[2])}var h=function(a){return a=""+a,0===a.indexOf("0")&&"0"!==a?a.substring(1):a},i=function(a){return a=Number(a),isNaN(a)?"00":(a<10?"0":"")+a},j={month:i(b.getMonth()+1),date:i(b.getDate()),year:i(b.getFullYear()),day:b.getDay(),hour24:b.getHours(),hour12:b.getHours(),minutes:i(b.getMinutes()),ampm:"AM"};j.hour24>11&&(j.ampm="PM"),j.hour24=i(j.hour24),0===j.hour12&&(j.hour12=12),j.hour12>12&&(j.hour12=j.hour12-12),j.hour12=i(j.hour12);var k,l=function(a){var b=a.replace(/yy+(?=y)/g,"yy").replace(/MMM+(?=M)/g,"MMM").replace(/d+(?=d)/g,"d").replace(/EEE+(?=E)/g,"EEE").replace(/a+(?=a)/g,"").replace(/k+(?=k)/g,"k").replace(/h+(?=h)/g,"h").replace(/m+(?=m)/g,"m"),c=b.replace(/yyy/g,j.year).replace(/yy/g,j.year.substring(2)).replace(/y/g,j.year).replace(/dd/g,j.date).replace(/d/g,h(j.date)),e=function(a,b,c){for(var d=1;d23&&(e=23);var f="+"===c?e:0-e;"kk"===b||"k"===b?(f=Number(j.hour24)+f,f>24?f-=24:f<0&&(f+=24)):(f=Number(j.hour12)+f,f>24?f-=24:f<0&&(f+=24),f>12&&(f-=12)),f=""+f,"kk"!==b&&"hh"!==b||(f=i(f)),("h"===b&&0===f||"hh"===b&&"00"===f)&&(f="12"),a[d]=f+a[d]}return a.join("")};c.indexOf("k+")!==-1&&(c=e(c.split("kk+"),"kk","+"),c=e(c.split("k+"),"k","+")),c.indexOf("k-")!==-1&&(c=e(c.split("kk-"),"kk","-"),c=e(c.split("k-"),"k","-")),c=c.replace(/kk/g,j.hour24).replace(/k/g,h(j.hour24)),c.indexOf("h+")!==-1&&(c=e(c.split("hh+"),"hh","+"),c=e(c.split("h+"),"h","+")),c.indexOf("h-")!==-1&&(c=e(c.split("hh-"),"hh","-"),c=e(c.split("h-"),"h","-")),c=c.replace(/hh/g,j.hour12<12&&j.hour12.indexOf&&0!==j.hour12.indexOf("0")?"0"+j.hour12:j.hour12).replace(/h/g,h(j.hour12)),c=c.replace(/mm/g,j.minutes).replace(/m/g,h(j.minutes)),c=c.replace(/a/g,"A");var f=["January","February","march","april","may","June","July","august","September","October","November","December"];"es_US"===d&&(f=["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"]),"fr_CA"===d&&(f=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]),c=c.replace(/MMMM/g,f[Number(j.month)-1]).replace(/MMM/g,f[Number(j.month)-1].substring(0,3)).replace(/MM/g,j.month).replace(/M/g,h(j.month)).replace(/march/g,"March").replace(/may/g,"May").replace(/Mayo/g,"mayo");var g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];return"es_US"===d&&(g=["domingo","lunes","martes","miércoles","jueves","viernes","sábado"]),"fr_CA"===d&&(g=["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]),c=c.replace(/EEEE/g,g[j.day]).replace(/EEE/g,g[j.day].substring(0,3)).replace(/EE/g,g[j.day].substring(0,3)).replace(/E/g,g[j.day].substring(0,3)),c=c.replace(/A/g,j.ampm).replace(/april/g,"April").replace(/august/g,"August")};if(c.indexOf("'")!==-1){var m=c.replace(/\'+(?=\')/g,"''").split("''");if(1===m.length){m=c.split("'");for(var n=0;n=1.5.1" + }, + "bugs": { + "web": "https://github.com/noahcooper/luminateExtend/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/noahcooper/luminateExtend.git" + }, + "keywords": [ + "luminate", + "blackbaud", + "teamraiser", + "team raiser", + "convio" + ], + "main": "luminateExtend.js", + "homepage": "https://github.com/noahcooper/luminateExtend" +} \ No newline at end of file diff --git a/src/luminateExtend.js b/src/luminateExtend.js index eef0f75..5d659fb 100644 --- a/src/luminateExtend.js +++ b/src/luminateExtend.js @@ -1,12 +1,31 @@ /* * luminateExtend.js - * Version: 1.8.1 (18-OCT-2016) + * Version: 1.8.1 (23-FEB-2017) * Requires: jQuery v1.5.1+ or Zepto v1.1+ * Includes: SimpleDateFormatJS v1.3 (https://github.com/noahcooper/SimpleDateFormatJS) */ -(function($) { - /* private helper functions */ + +(function (factory) { + // If there is a variable named module and it has an exports property, + // then we're working in a Node-like environment. Use require to load + // the jQuery object that the module system is using and pass it in. + if (typeof define === 'function' && define.amd) { + define(['jquery'], function(jquery){ + return factory(jquery, window, document); + }); + } else if(typeof module === "object" && typeof module.exports === "object") { + module.exports = factory(require('jquery'), window, document); + } + // Otherwise, we're working in a browser, so just pass in the global + // jQuery or Zepto object. + else { + factory(typeof jQuery === 'undefined' && typeof Zepto === 'function' ? Zepto : jQuery, window, document); + } +}(function($, window, document, undefined) { + // This code will receive whatever jQuery object was passed in from + // the function above and will attach the tipso plugin to it. + // var validateLocale = function(locale) { /* if a locale is provided that is not supported, default to "en_US" */ if(locale && $.inArray(locale, ['es_US', 'en_CA', 'fr_CA', 'en_GB', 'en_AU']) < 0) { @@ -33,10 +52,32 @@ (data ? ('&' + data) : ''); }, - apiCallbackHandler = function(requestSettings, responseData) { - if(requestSettings.responseFilter && + apiCallbackHandler = function(requestSettings, responseData, jqXHR_textStatus) { + // test if response data is a jqXHR object. This means, we have had a AJAX error for some reason + if (typeof responseData.getResponseHeader === 'function') { + // if the XML HTTP status is 0, it could be due to a Cross-site scripting issue related to CORS header. + // Normally we would use the error directly from the ajax request but a status of 0 has an empty response text + if (responseData.status == 0) { + var port = window.location.port; + var addendum = '. You need to whitelist the domain and port API requests are originating from'; + + if (port !== '') { + port = ':' + port; + } else { + addendum = ''; + } + + var message = 'Check your Luminate API settings to make sure ' + window.location.hostname + port + ' is whitelisted' + addendum; + + responseData = new luminateExtend.api.error(message); + } else { + responseData = new luminateExtend.api.error(jqXHR_textStatus); + } + + } else if(requestSettings.responseFilter && requestSettings.responseFilter.array && requestSettings.responseFilter.filter) { + if(luminateExtend.utils.stringToObj(requestSettings.responseFilter.array, responseData)) { var filterKey = requestSettings.responseFilter.filter.split('==')[0].split('!=')[0].replace(/^\s+|\s+$/g, ''), filterOperator, @@ -104,7 +145,7 @@ if(typeof requestSettings.callback === 'function') { callbackFn = requestSettings.callback; } - else if(requestSettings.callback.error && responseData.errorResponse) { + else if((requestSettings.callback.error && responseData.errorResponse) || responseData instanceof Error) { callbackFn = requestSettings.callback.error; } else if(requestSettings.callback.success && !responseData.errorResponse) { @@ -114,22 +155,21 @@ var isLoginRequest = requestSettings.data.indexOf('&method=login') !== -1 && requestSettings.data.indexOf('&method=loginTest') === -1, isLogoutRequest = requestSettings.data.indexOf('&method=logout') !== -1; - - if(!isLoginRequest && !isLogoutRequest) { + + if((!isLoginRequest && !isLogoutRequest) || responseData instanceof Error) { callbackFn(responseData); } - /* get a new auth token after login or logout */ else { var newAuthCallback = function() { callbackFn(responseData); - }, + }, getAuthOptions = { callback: newAuthCallback, useCache: false, useHTTPS: requestSettings.useHTTPS }; - + if(isLoginRequest && responseData.loginResponse && responseData.loginResponse.nonce) { getAuthOptions.nonce = 'NONCE_TOKEN=' + responseData.loginResponse.nonce; } @@ -146,7 +186,7 @@ /* library info */ luminateExtend.library = { - version: '1.7.1' + version: '1.8.1' }; /* global settings */ @@ -350,6 +390,7 @@ luminateExtend.api.getAuthLoad = true; var sendRequest = function(options) { + var settings = $.extend({ contentType: 'application/x-www-form-urlencoded', data: '', @@ -449,6 +490,7 @@ } var doRequest; + if(useAjax) { doRequest = function() { if(luminateExtend.global.routingId && luminateExtend.global.routingId !== '') { @@ -471,10 +513,9 @@ contentType: settings.contentType, /* set dataType explicitly as API sends Content-Type: text/plain rather than application/json (E-62659) */ dataType: 'json', - type: 'POST', - success: function(data) { - apiCallbackHandler(settings, data); - } + type: 'POST', + }).always(function(xhr_or_data, status, xhr_error) { + apiCallbackHandler(settings, xhr_or_data, status); }); }; } @@ -568,7 +609,7 @@ if(!$.isArray(requests)) { sendRequest(requests); } - + else { requests.reverse(); @@ -619,6 +660,21 @@ }); } }; + + luminateExtend.api.error = function(message) { + function LuminateError(message) { + this.name = 'LuminateError'; + this.default_message = 'Error communicating with the Luminate API. Check your Luminate API settings'; + + this.message = message || this.default_message; + this.stack = (new Error()).stack; + } + + LuminateError.prototype = Object.create(Error.prototype); + LuminateError.prototype.constructor = LuminateError; + + return new LuminateError(message); + }; /* session variables */ luminateExtend.sessionVars = { @@ -1014,4 +1070,4 @@ return formattedDate; } }; -})(typeof jQuery === 'undefined' && typeof Zepto === 'function' ? Zepto : jQuery); \ No newline at end of file +})); \ No newline at end of file