{"version":3,"sources":["api.js"],"names":["$","window","document","undefined","Math","self","Function","api","fn","parameters","returnedValue","$allModules","isFunction","this","moduleSelector","selector","time","Date","getTime","performance","query","arguments","methodInvoked","queryArguments","slice","call","each","ajaxSettings","requestSettings","url","data","requestStartTime","module","settings","isPlainObject","extend","namespace","metadata","error","className","eventNamespace","moduleNamespace","$module","$form","closest","form","$context","stateContext","element","context","instance","initialize","bind","events","instantiate","verbose","destroy","removeData","off","triggerEvent","get","event","on","trigger","debug","decode","json","response","JSON","parse","e","read","cachedResponse","Storage","noStorage","sessionStorage","getItem","write","stringify","setItem","is","disabled","loading","interruptRequests","abort","defaultData","urlData","serializeForm","add","formData","cancelled","beforeSend","templatedURL","mocked","base","type","method","beforeXHR","success","failure","complete","cache","request","create","resolveWith","throttle","throttleFirstRequest","timer","clearTimeout","setTimeout","send","missingURL","should","removeError","hideError","filter","length","expectingJSON","dataType","mockResponse","mockResponseAsync","responseAsync","input","state","abortedRequest","xhr","readyState","validResponse","successTest","was","succesful","requiredVariables","optionalVariables","match","regExp","required","optional","index","templatedString","variable","indexOf","substr","value","requiredParameter","urlEncodedValue","replace","hasOtherData","canSerialize","serializeObject","serialize","missingSerialize","set","mockedXHR","onRequest","preventDefault","always","done","textStatus","elapsedTime","timeLeft","loadingDuration","translatedResponse","onResponse","rejectWith","fail","status","httpMessage","onSuccess","firstParameter","secondParameter","responseFromXHR","remove","onComplete","errorMessage","errorFromRequest","onAbort","statusMessage","onError","errorDuration","onFailure","Deferred","asyncCallback","responder","asyncResponder","responseText","ajax","addClass","removeClass","runSettings","legacyParameters","noReturnedValue","decodedValue","decodeURIComponent","encodedValue","encodeURIComponent","alreadyEncoded","isWindow","val","text","oninput","onpropertychange","action","missingAction","attr","reset","setting","name","internal","silent","log","prototype","console","info","apply","message","currentTime","executionTime","previousTime","push","Name","Arguments","Execution Time","display","title","totalTime","group","table","groupCollapsed","groupEnd","invoke","passedArguments","maxDepth","found","object","split","depth","camelCaseValue","charAt","toUpperCase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oB,GAGpBR,WAGAD,aAAuB,EAGvBE,eAAuB,EAGvBkB,SAAuB,EAGvBC,sBAAuB,EAGvBV,OAAoB,MACpBlE,QACAwF,SAAoB,OAGpBC,cAAoB,EACpBC,mBAAoB,EAGpBrD,UAAoB,EACpBsD,eAAoB,EAGpB9B,WAAc,SAAS1D,GAAY,MAAOA,IAC1CgE,UAAc,SAAS4B,KACvB4B,UAAc,SAASwF,EAASpH,KAGhCqC,YAAc,EAGdK,UAAc,SAASpG,EAAUzB,KAGjCkI,WAAc,SAASzG,EAAUzB,KAGjCyI,UAAc,SAAShH,EAAUzB,KAGjCuI,QAAc,SAASJ,EAAcnI,KAGrCqI,QAAc,SAASF,EAAcnI,KAErCsF,aAAc,EAGd1F,OACEqD,WAAoB,mDACpBrD,MAAoB,uCACpB4M,eAAoB,2CACpBC,UAAoB,iDACpBtD,iBAAoB,kDACpB7F,OAAoB,uCACpB0G,cAAoB,yCACpBpD,iBAAoB,kFACpBvC,WAAoB,iCACpB+E,gBAAoB,6EACpBpH,UAAoB,qDACpB0K,WAAoB,0CACpBrG,kBAAoB,qCACpBiC,cAAoB,yBACpBqE,QAAoB,0BAGtB/G,QACEC,SAAW,oBACXC,SAAW,uBAGbjG,WACE2C,QAAU,UACV5C,MAAU,SAGZvB,UACEkE,SAAW,YACXpC,KAAY,QAGdR,UACEoK,OAAU,SACV5K,IAAU,SAMVyN,OAAQrP,OAAQC","file":"api.min.js","sourcesContent":["/*!\n * # Semantic UI 2.2.6 - API\n * http://github.com/semantic-org/semantic-ui/\n *\n *\n * Released under the MIT license\n * http://opensource.org/licenses/MIT\n *\n */\n\n;(function ($, window, document, undefined) {\n\n\"use strict\";\n\nvar\n window = (typeof window != 'undefined' && window.Math == Math)\n ? window\n : (typeof self != 'undefined' && self.Math == Math)\n ? self\n : Function('return this')()\n;\n\n$.api = $.fn.api = function(parameters) {\n\n var\n // use window context if none specified\n $allModules = $.isFunction(this)\n ? $(window)\n : $(this),\n moduleSelector = $allModules.selector || '',\n time = new Date().getTime(),\n performance = [],\n\n query = arguments[0],\n methodInvoked = (typeof query == 'string'),\n queryArguments = [].slice.call(arguments, 1),\n\n returnedValue\n ;\n\n $allModules\n .each(function() {\n var\n settings = ( $.isPlainObject(parameters) )\n ? $.extend(true, {}, $.fn.api.settings, parameters)\n : $.extend({}, $.fn.api.settings),\n\n // internal aliases\n namespace = settings.namespace,\n metadata = settings.metadata,\n selector = settings.selector,\n error = settings.error,\n className = settings.className,\n\n // define namespaces for modules\n eventNamespace = '.' + namespace,\n moduleNamespace = 'module-' + namespace,\n\n // element that creates request\n $module = $(this),\n $form = $module.closest(selector.form),\n\n // context used for state\n $context = (settings.stateContext)\n ? $(settings.stateContext)\n : $module,\n\n // request details\n ajaxSettings,\n requestSettings,\n url,\n data,\n requestStartTime,\n\n // standard module\n element = this,\n context = $context[0],\n instance = $module.data(moduleNamespace),\n module\n ;\n\n module = {\n\n initialize: function() {\n if(!methodInvoked) {\n module.bind.events();\n }\n module.instantiate();\n },\n\n instantiate: function() {\n module.verbose('Storing instance of module', module);\n instance = module;\n $module\n .data(moduleNamespace, instance)\n ;\n },\n\n destroy: function() {\n module.verbose('Destroying previous module for', element);\n $module\n .removeData(moduleNamespace)\n .off(eventNamespace)\n ;\n },\n\n bind: {\n events: function() {\n var\n triggerEvent = module.get.event()\n ;\n if( triggerEvent ) {\n module.verbose('Attaching API events to element', triggerEvent);\n $module\n .on(triggerEvent + eventNamespace, module.event.trigger)\n ;\n }\n else if(settings.on == 'now') {\n module.debug('Querying API endpoint immediately');\n module.query();\n }\n }\n },\n\n decode: {\n json: function(response) {\n if(response !== undefined && typeof response == 'string') {\n try {\n response = JSON.parse(response);\n }\n catch(e) {\n // isnt json string\n }\n }\n return response;\n }\n },\n\n read: {\n cachedResponse: function(url) {\n var\n response\n ;\n if(window.Storage === undefined) {\n module.error(error.noStorage);\n return;\n }\n response = sessionStorage.getItem(url);\n module.debug('Using cached response', url, response);\n response = module.decode.json(response);\n return response;\n }\n },\n write: {\n cachedResponse: function(url, response) {\n if(response && response === '') {\n module.debug('Response empty, not caching', response);\n return;\n }\n if(window.Storage === undefined) {\n module.error(error.noStorage);\n return;\n }\n if( $.isPlainObject(response) ) {\n response = JSON.stringify(response);\n }\n sessionStorage.setItem(url, response);\n module.verbose('Storing cached response for url', url, response);\n }\n },\n\n query: function() {\n\n if(module.is.disabled()) {\n module.debug('Element is disabled API request aborted');\n return;\n }\n\n if(module.is.loading()) {\n if(settings.interruptRequests) {\n module.debug('Interrupting previous request');\n module.abort();\n }\n else {\n module.debug('Cancelling request, previous request is still pending');\n return;\n }\n }\n\n // pass element metadata to url (value, text)\n if(settings.defaultData) {\n $.extend(true, settings.urlData, module.get.defaultData());\n }\n\n // Add form content\n if(settings.serializeForm) {\n settings.data = module.add.formData(settings.data);\n }\n\n // call beforesend and get any settings changes\n requestSettings = module.get.settings();\n\n // check if before send cancelled request\n if(requestSettings === false) {\n module.cancelled = true;\n module.error(error.beforeSend);\n return;\n }\n else {\n module.cancelled = false;\n }\n\n // get url\n url = module.get.templatedURL();\n\n if(!url && !module.is.mocked()) {\n module.error(error.missingURL);\n return;\n }\n\n // replace variables\n url = module.add.urlData( url );\n // missing url parameters\n if( !url && !module.is.mocked()) {\n return;\n }\n\n requestSettings.url = settings.base + url;\n\n // look for jQuery ajax parameters in settings\n ajaxSettings = $.extend(true, {}, settings, {\n type : settings.method || settings.type,\n data : data,\n url : settings.base + url,\n beforeSend : settings.beforeXHR,\n success : function() {},\n failure : function() {},\n complete : function() {}\n });\n\n module.debug('Querying URL', ajaxSettings.url);\n module.verbose('Using AJAX settings', ajaxSettings);\n if(settings.cache === 'local' && module.read.cachedResponse(url)) {\n module.debug('Response returned from local cache');\n module.request = module.create.request();\n module.request.resolveWith(context, [ module.read.cachedResponse(url) ]);\n return;\n }\n\n if( !settings.throttle ) {\n module.debug('Sending request', data, ajaxSettings.method);\n module.send.request();\n }\n else {\n if(!settings.throttleFirstRequest && !module.timer) {\n module.debug('Sending request', data, ajaxSettings.method);\n module.send.request();\n module.timer = setTimeout(function(){}, settings.throttle);\n }\n else {\n module.debug('Throttling request', settings.throttle);\n clearTimeout(module.timer);\n module.timer = setTimeout(function() {\n if(module.timer) {\n delete module.timer;\n }\n module.debug('Sending throttled request', data, ajaxSettings.method);\n module.send.request();\n }, settings.throttle);\n }\n }\n\n },\n\n should: {\n removeError: function() {\n return ( settings.hideError === true || (settings.hideError === 'auto' && !module.is.form()) );\n }\n },\n\n is: {\n disabled: function() {\n return ($module.filter(selector.disabled).length > 0);\n },\n expectingJSON: function() {\n return settings.dataType === 'json' || settings.dataType === 'jsonp';\n },\n form: function() {\n return $module.is('form') || $context.is('form');\n },\n mocked: function() {\n return (settings.mockResponse || settings.mockResponseAsync || settings.response || settings.responseAsync);\n },\n input: function() {\n return $module.is('input');\n },\n loading: function() {\n return (module.request)\n ? (module.request.state() == 'pending')\n : false\n ;\n },\n abortedRequest: function(xhr) {\n if(xhr && xhr.readyState !== undefined && xhr.readyState === 0) {\n module.verbose('XHR request determined to be aborted');\n return true;\n }\n else {\n module.verbose('XHR request was not aborted');\n return false;\n }\n },\n validResponse: function(response) {\n if( (!module.is.expectingJSON()) || !$.isFunction(settings.successTest) ) {\n module.verbose('Response is not JSON, skipping validation', settings.successTest, response);\n return true;\n }\n module.debug('Checking JSON returned success', settings.successTest, response);\n if( settings.successTest(response) ) {\n module.debug('Response passed success test', response);\n return true;\n }\n else {\n module.debug('Response failed success test', response);\n return false;\n }\n }\n },\n\n was: {\n cancelled: function() {\n return (module.cancelled || false);\n },\n succesful: function() {\n return (module.request && module.request.state() == 'resolved');\n },\n failure: function() {\n return (module.request && module.request.state() == 'rejected');\n },\n complete: function() {\n return (module.request && (module.request.state() == 'resolved' || module.request.state() == 'rejected') );\n }\n },\n\n add: {\n urlData: function(url, urlData) {\n var\n requiredVariables,\n optionalVariables\n ;\n if(url) {\n requiredVariables = url.match(settings.regExp.required);\n optionalVariables = url.match(settings.regExp.optional);\n urlData = urlData || settings.urlData;\n if(requiredVariables) {\n module.debug('Looking for required URL variables', requiredVariables);\n $.each(requiredVariables, function(index, templatedString) {\n var\n // allow legacy {$var} style\n variable = (templatedString.indexOf('$') !== -1)\n ? templatedString.substr(2, templatedString.length - 3)\n : templatedString.substr(1, templatedString.length - 2),\n value = ($.isPlainObject(urlData) && urlData[variable] !== undefined)\n ? urlData[variable]\n : ($module.data(variable) !== undefined)\n ? $module.data(variable)\n : ($context.data(variable) !== undefined)\n ? $context.data(variable)\n : urlData[variable]\n ;\n // remove value\n if(value === undefined) {\n module.error(error.requiredParameter, variable, url);\n url = false;\n return false;\n }\n else {\n module.verbose('Found required variable', variable, value);\n value = (settings.encodeParameters)\n ? module.get.urlEncodedValue(value)\n : value\n ;\n url = url.replace(templatedString, value);\n }\n });\n }\n if(optionalVariables) {\n module.debug('Looking for optional URL variables', requiredVariables);\n $.each(optionalVariables, function(index, templatedString) {\n var\n // allow legacy {/$var} style\n variable = (templatedString.indexOf('$') !== -1)\n ? templatedString.substr(3, templatedString.length - 4)\n : templatedString.substr(2, templatedString.length - 3),\n value = ($.isPlainObject(urlData) && urlData[variable] !== undefined)\n ? urlData[variable]\n : ($module.data(variable) !== undefined)\n ? $module.data(variable)\n : ($context.data(variable) !== undefined)\n ? $context.data(variable)\n : urlData[variable]\n ;\n // optional replacement\n if(value !== undefined) {\n module.verbose('Optional variable Found', variable, value);\n url = url.replace(templatedString, value);\n }\n else {\n module.verbose('Optional variable not found', variable);\n // remove preceding slash if set\n if(url.indexOf('/' + templatedString) !== -1) {\n url = url.replace('/' + templatedString, '');\n }\n else {\n url = url.replace(templatedString, '');\n }\n }\n });\n }\n }\n return url;\n },\n formData: function(data) {\n var\n canSerialize = ($.fn.serializeObject !== undefined),\n formData = (canSerialize)\n ? $form.serializeObject()\n : $form.serialize(),\n hasOtherData\n ;\n data = data || settings.data;\n hasOtherData = $.isPlainObject(data);\n\n if(hasOtherData) {\n if(canSerialize) {\n module.debug('Extending existing data with form data', data, formData);\n data = $.extend(true, {}, data, formData);\n }\n else {\n module.error(error.missingSerialize);\n module.debug('Cant extend data. Replacing data with form data', data, formData);\n data = formData;\n }\n }\n else {\n module.debug('Adding form data', formData);\n data = formData;\n }\n return data;\n }\n },\n\n send: {\n request: function() {\n module.set.loading();\n module.request = module.create.request();\n if( module.is.mocked() ) {\n module.mockedXHR = module.create.mockedXHR();\n }\n else {\n module.xhr = module.create.xhr();\n }\n settings.onRequest.call(context, module.request, module.xhr);\n }\n },\n\n event: {\n trigger: function(event) {\n module.query();\n if(event.type == 'submit' || event.type == 'click') {\n event.preventDefault();\n }\n },\n xhr: {\n always: function() {\n // nothing special\n },\n done: function(response, textStatus, xhr) {\n var\n context = this,\n elapsedTime = (new Date().getTime() - requestStartTime),\n timeLeft = (settings.loadingDuration - elapsedTime),\n translatedResponse = ( $.isFunction(settings.onResponse) )\n ? module.is.expectingJSON()\n ? settings.onResponse.call(context, $.extend(true, {}, response))\n : settings.onResponse.call(context, response)\n : false\n ;\n timeLeft = (timeLeft > 0)\n ? timeLeft\n : 0\n ;\n if(translatedResponse) {\n module.debug('Modified API response in onResponse callback', settings.onResponse, translatedResponse, response);\n response = translatedResponse;\n }\n if(timeLeft > 0) {\n module.debug('Response completed early delaying state change by', timeLeft);\n }\n setTimeout(function() {\n if( module.is.validResponse(response) ) {\n module.request.resolveWith(context, [response, xhr]);\n }\n else {\n module.request.rejectWith(context, [xhr, 'invalid']);\n }\n }, timeLeft);\n },\n fail: function(xhr, status, httpMessage) {\n var\n context = this,\n elapsedTime = (new Date().getTime() - requestStartTime),\n timeLeft = (settings.loadingDuration - elapsedTime)\n ;\n timeLeft = (timeLeft > 0)\n ? timeLeft\n : 0\n ;\n if(timeLeft > 0) {\n module.debug('Response completed early delaying state change by', timeLeft);\n }\n setTimeout(function() {\n if( module.is.abortedRequest(xhr) ) {\n module.request.rejectWith(context, [xhr, 'aborted', httpMessage]);\n }\n else {\n module.request.rejectWith(context, [xhr, 'error', status, httpMessage]);\n }\n }, timeLeft);\n }\n },\n request: {\n done: function(response, xhr) {\n module.debug('Successful API Response', response);\n if(settings.cache === 'local' && url) {\n module.write.cachedResponse(url, response);\n module.debug('Saving server response locally', module.cache);\n }\n settings.onSuccess.call(context, response, $module, xhr);\n },\n complete: function(firstParameter, secondParameter) {\n var\n xhr,\n response\n ;\n // have to guess callback parameters based on request success\n if( module.was.succesful() ) {\n response = firstParameter;\n xhr = secondParameter;\n }\n else {\n xhr = firstParameter;\n response = module.get.responseFromXHR(xhr);\n }\n module.remove.loading();\n settings.onComplete.call(context, response, $module, xhr);\n },\n fail: function(xhr, status, httpMessage) {\n var\n // pull response from xhr if available\n response = module.get.responseFromXHR(xhr),\n errorMessage = module.get.errorFromRequest(response, status, httpMessage)\n ;\n if(status == 'aborted') {\n module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage);\n settings.onAbort.call(context, status, $module, xhr);\n return true;\n }\n else if(status == 'invalid') {\n module.debug('JSON did not pass success test. A server-side error has most likely occurred', response);\n }\n else if(status == 'error') {\n if(xhr !== undefined) {\n module.debug('XHR produced a server error', status, httpMessage);\n // make sure we have an error to display to console\n if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {\n module.error(error.statusMessage + httpMessage, ajaxSettings.url);\n }\n settings.onError.call(context, errorMessage, $module, xhr);\n }\n }\n\n if(settings.errorDuration && status !== 'aborted') {\n module.debug('Adding error state');\n module.set.error();\n if( module.should.removeError() ) {\n setTimeout(module.remove.error, settings.errorDuration);\n }\n }\n module.debug('API Request failed', errorMessage, xhr);\n settings.onFailure.call(context, response, $module, xhr);\n }\n }\n },\n\n create: {\n\n request: function() {\n // api request promise\n return $.Deferred()\n .always(module.event.request.complete)\n .done(module.event.request.done)\n .fail(module.event.request.fail)\n ;\n },\n\n mockedXHR: function () {\n var\n // xhr does not simulate these properties of xhr but must return them\n textStatus = false,\n status = false,\n httpMessage = false,\n responder = settings.mockResponse || settings.response,\n asyncResponder = settings.mockResponseAsync || settings.responseAsync,\n asyncCallback,\n response,\n mockedXHR\n ;\n\n mockedXHR = $.Deferred()\n .always(module.event.xhr.complete)\n .done(module.event.xhr.done)\n .fail(module.event.xhr.fail)\n ;\n\n if(responder) {\n if( $.isFunction(responder) ) {\n module.debug('Using specified synchronous callback', responder);\n response = responder.call(context, requestSettings);\n }\n else {\n module.debug('Using settings specified response', responder);\n response = responder;\n }\n // simulating response\n mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);\n }\n else if( $.isFunction(asyncResponder) ) {\n asyncCallback = function(response) {\n module.debug('Async callback returned response', response);\n\n if(response) {\n mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);\n }\n else {\n mockedXHR.rejectWith(context, [{ responseText: response }, status, httpMessage]);\n }\n };\n module.debug('Using specified async response callback', asyncResponder);\n asyncResponder.call(context, requestSettings, asyncCallback);\n }\n return mockedXHR;\n },\n\n xhr: function() {\n var\n xhr\n ;\n // ajax request promise\n xhr = $.ajax(ajaxSettings)\n .always(module.event.xhr.always)\n .done(module.event.xhr.done)\n .fail(module.event.xhr.fail)\n ;\n module.verbose('Created server request', xhr, ajaxSettings);\n return xhr;\n }\n },\n\n set: {\n error: function() {\n module.verbose('Adding error state to element', $context);\n $context.addClass(className.error);\n },\n loading: function() {\n module.verbose('Adding loading state to element', $context);\n $context.addClass(className.loading);\n requestStartTime = new Date().getTime();\n }\n },\n\n remove: {\n error: function() {\n module.verbose('Removing error state from element', $context);\n $context.removeClass(className.error);\n },\n loading: function() {\n module.verbose('Removing loading state from element', $context);\n $context.removeClass(className.loading);\n }\n },\n\n get: {\n responseFromXHR: function(xhr) {\n return $.isPlainObject(xhr)\n ? (module.is.expectingJSON())\n ? module.decode.json(xhr.responseText)\n : xhr.responseText\n : false\n ;\n },\n errorFromRequest: function(response, status, httpMessage) {\n return ($.isPlainObject(response) && response.error !== undefined)\n ? response.error // use json error message\n : (settings.error[status] !== undefined) // use server error message\n ? settings.error[status]\n : httpMessage\n ;\n },\n request: function() {\n return module.request || false;\n },\n xhr: function() {\n return module.xhr || false;\n },\n settings: function() {\n var\n runSettings\n ;\n runSettings = settings.beforeSend.call(context, settings);\n if(runSettings) {\n if(runSettings.success !== undefined) {\n module.debug('Legacy success callback detected', runSettings);\n module.error(error.legacyParameters, runSettings.success);\n runSettings.onSuccess = runSettings.success;\n }\n if(runSettings.failure !== undefined) {\n module.debug('Legacy failure callback detected', runSettings);\n module.error(error.legacyParameters, runSettings.failure);\n runSettings.onFailure = runSettings.failure;\n }\n if(runSettings.complete !== undefined) {\n module.debug('Legacy complete callback detected', runSettings);\n module.error(error.legacyParameters, runSettings.complete);\n runSettings.onComplete = runSettings.complete;\n }\n }\n if(runSettings === undefined) {\n module.error(error.noReturnedValue);\n }\n if(runSettings === false) {\n return runSettings;\n }\n return (runSettings !== undefined)\n ? $.extend(true, {}, runSettings)\n : $.extend(true, {}, settings)\n ;\n },\n urlEncodedValue: function(value) {\n var\n decodedValue = window.decodeURIComponent(value),\n encodedValue = window.encodeURIComponent(value),\n alreadyEncoded = (decodedValue !== value)\n ;\n if(alreadyEncoded) {\n module.debug('URL value is already encoded, avoiding double encoding', value);\n return value;\n }\n module.verbose('Encoding value using encodeURIComponent', value, encodedValue);\n return encodedValue;\n },\n defaultData: function() {\n var\n data = {}\n ;\n if( !$.isWindow(element) ) {\n if( module.is.input() ) {\n data.value = $module.val();\n }\n else if( module.is.form() ) {\n\n }\n else {\n data.text = $module.text();\n }\n }\n return data;\n },\n event: function() {\n if( $.isWindow(element) || settings.on == 'now' ) {\n module.debug('API called without element, no events attached');\n return false;\n }\n else if(settings.on == 'auto') {\n if( $module.is('input') ) {\n return (element.oninput !== undefined)\n ? 'input'\n : (element.onpropertychange !== undefined)\n ? 'propertychange'\n : 'keyup'\n ;\n }\n else if( $module.is('form') ) {\n return 'submit';\n }\n else {\n return 'click';\n }\n }\n else {\n return settings.on;\n }\n },\n templatedURL: function(action) {\n action = action || $module.data(metadata.action) || settings.action || false;\n url = $module.data(metadata.url) || settings.url || false;\n if(url) {\n module.debug('Using specified url', url);\n return url;\n }\n if(action) {\n module.debug('Looking up url for action', action, settings.api);\n if(settings.api[action] === undefined && !module.is.mocked()) {\n module.error(error.missingAction, settings.action, settings.api);\n return;\n }\n url = settings.api[action];\n }\n else if( module.is.form() ) {\n url = $module.attr('action') || $context.attr('action') || false;\n module.debug('No url or action specified, defaulting to form action', url);\n }\n return url;\n }\n },\n\n abort: function() {\n var\n xhr = module.get.xhr()\n ;\n if( xhr && xhr.state() !== 'resolved') {\n module.debug('Cancelling API request');\n xhr.abort();\n }\n },\n\n // reset state\n reset: function() {\n module.remove.error();\n module.remove.loading();\n },\n\n setting: function(name, value) {\n module.debug('Changing setting', name, value);\n if( $.isPlainObject(name) ) {\n $.extend(true, settings, name);\n }\n else if(value !== undefined) {\n if($.isPlainObject(settings[name])) {\n $.extend(true, settings[name], value);\n }\n else {\n settings[name] = value;\n }\n }\n else {\n return settings[name];\n }\n },\n internal: function(name, value) {\n if( $.isPlainObject(name) ) {\n $.extend(true, module, name);\n }\n else if(value !== undefined) {\n module[name] = value;\n }\n else {\n return module[name];\n }\n },\n debug: function() {\n if(!settings.silent && settings.debug) {\n if(settings.performance) {\n module.performance.log(arguments);\n }\n else {\n module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');\n module.debug.apply(console, arguments);\n }\n }\n },\n verbose: function() {\n if(!settings.silent && settings.verbose && settings.debug) {\n if(settings.performance) {\n module.performance.log(arguments);\n }\n else {\n module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');\n module.verbose.apply(console, arguments);\n }\n }\n },\n error: function() {\n if(!settings.silent) {\n module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');\n module.error.apply(console, arguments);\n }\n },\n performance: {\n log: function(message) {\n var\n currentTime,\n executionTime,\n previousTime\n ;\n if(settings.performance) {\n currentTime = new Date().getTime();\n previousTime = time || currentTime;\n executionTime = currentTime - previousTime;\n time = currentTime;\n performance.push({\n 'Name' : message[0],\n 'Arguments' : [].slice.call(message, 1) || '',\n //'Element' : element,\n 'Execution Time' : executionTime\n });\n }\n clearTimeout(module.performance.timer);\n module.performance.timer = setTimeout(module.performance.display, 500);\n },\n display: function() {\n var\n title = settings.name + ':',\n totalTime = 0\n ;\n time = false;\n clearTimeout(module.performance.timer);\n $.each(performance, function(index, data) {\n totalTime += data['Execution Time'];\n });\n title += ' ' + totalTime + 'ms';\n if(moduleSelector) {\n title += ' \\'' + moduleSelector + '\\'';\n }\n if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {\n console.groupCollapsed(title);\n if(console.table) {\n console.table(performance);\n }\n else {\n $.each(performance, function(index, data) {\n console.log(data['Name'] + ': ' + data['Execution Time']+'ms');\n });\n }\n console.groupEnd();\n }\n performance = [];\n }\n },\n invoke: function(query, passedArguments, context) {\n var\n object = instance,\n maxDepth,\n found,\n response\n ;\n passedArguments = passedArguments || queryArguments;\n context = element || context;\n if(typeof query == 'string' && object !== undefined) {\n query = query.split(/[\\. ]/);\n maxDepth = query.length - 1;\n $.each(query, function(depth, value) {\n var camelCaseValue = (depth != maxDepth)\n ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)\n : query\n ;\n if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {\n object = object[camelCaseValue];\n }\n else if( object[camelCaseValue] !== undefined ) {\n found = object[camelCaseValue];\n return false;\n }\n else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {\n object = object[value];\n }\n else if( object[value] !== undefined ) {\n found = object[value];\n return false;\n }\n else {\n module.error(error.method, query);\n return false;\n }\n });\n }\n if ( $.isFunction( found ) ) {\n response = found.apply(context, passedArguments);\n }\n else if(found !== undefined) {\n response = found;\n }\n if($.isArray(returnedValue)) {\n returnedValue.push(response);\n }\n else if(returnedValue !== undefined) {\n returnedValue = [returnedValue, response];\n }\n else if(response !== undefined) {\n returnedValue = response;\n }\n return found;\n }\n };\n\n if(methodInvoked) {\n if(instance === undefined) {\n module.initialize();\n }\n module.invoke(query);\n }\n else {\n if(instance !== undefined) {\n instance.invoke('destroy');\n }\n module.initialize();\n }\n })\n ;\n\n return (returnedValue !== undefined)\n ? returnedValue\n : this\n ;\n};\n\n$.api.settings = {\n\n name : 'API',\n namespace : 'api',\n\n debug : false,\n verbose : false,\n performance : true,\n\n // object containing all templates endpoints\n api : {},\n\n // whether to cache responses\n cache : true,\n\n // whether new requests should abort previous requests\n interruptRequests : true,\n\n // event binding\n on : 'auto',\n\n // context for applying state classes\n stateContext : false,\n\n // duration for loading state\n loadingDuration : 0,\n\n // whether to hide errors after a period of time\n hideError : 'auto',\n\n // duration for error state\n errorDuration : 2000,\n\n // whether parameters should be encoded with encodeURIComponent\n encodeParameters : true,\n\n // API action to use\n action : false,\n\n // templated URL to use\n url : false,\n\n // base URL to apply to all endpoints\n base : '',\n\n // data that will\n urlData : {},\n\n // whether to add default data to url data\n defaultData : true,\n\n // whether to serialize closest form\n serializeForm : false,\n\n // how long to wait before request should occur\n throttle : 0,\n\n // whether to throttle first request or only repeated\n throttleFirstRequest : true,\n\n // standard ajax settings\n method : 'get',\n data : {},\n dataType : 'json',\n\n // mock response\n mockResponse : false,\n mockResponseAsync : false,\n\n // aliases for mock\n response : false,\n responseAsync : false,\n\n // callbacks before request\n beforeSend : function(settings) { return settings; },\n beforeXHR : function(xhr) {},\n onRequest : function(promise, xhr) {},\n\n // after request\n onResponse : false, // function(response) { },\n\n // response was successful, if JSON passed validation\n onSuccess : function(response, $module) {},\n\n // request finished without aborting\n onComplete : function(response, $module) {},\n\n // failed JSON success test\n onFailure : function(response, $module) {},\n\n // server error\n onError : function(errorMessage, $module) {},\n\n // request aborted\n onAbort : function(errorMessage, $module) {},\n\n successTest : false,\n\n // errors\n error : {\n beforeSend : 'The before send function has aborted the request',\n error : 'There was an error with your request',\n exitConditions : 'API Request Aborted. Exit conditions met',\n JSONParse : 'JSON could not be parsed during error handling',\n legacyParameters : 'You are using legacy API success callback names',\n method : 'The method you called is not defined',\n missingAction : 'API action used but no url was defined',\n missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',\n missingURL : 'No URL specified for api event',\n noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',\n noStorage : 'Caching responses locally requires session storage',\n parseError : 'There was an error parsing your request',\n requiredParameter : 'Missing a required URL parameter: ',\n statusMessage : 'Server gave an error: ',\n timeout : 'Your request timed out'\n },\n\n regExp : {\n required : /\\{\\$*[A-z0-9]+\\}/g,\n optional : /\\{\\/\\$*[A-z0-9]+\\}/g,\n },\n\n className: {\n loading : 'loading',\n error : 'error'\n },\n\n selector: {\n disabled : '.disabled',\n form : 'form'\n },\n\n metadata: {\n action : 'action',\n url : 'url'\n }\n};\n\n\n\n})( jQuery, window, document );\n"]}