Skip to content

Instantly share code, notes, and snippets.

@brendanjerwin
Created June 5, 2013 14:06
Show Gist options
  • Save brendanjerwin/5714126 to your computer and use it in GitHub Desktop.
Save brendanjerwin/5714126 to your computer and use it in GitHub Desktop.
(function(){
var cors_supported = XMLHttpRequest && 'withCredentials' in (new XMLHttpRequest()),
dependencies = ['lib/window', './modernizr','./html5_shiv', './es5-shim', './date', './awesome_buttons', './string_split', './jquery-enable-disable', './jquery-domain-type', './jquery-konami',
'./jquery.autogrow-textarea', './jquery-save-restore', './jquery-ajax-isolated-script', 'require', 'lib/jquery','./browser_selector', './inflection'];
if(!cors_supported){
dependencies.push('./flensed/jquery.flXHRproxy', './throttle_ajax');
}
define(dependencies, function(win, mod, html5_shiv, es5_shim, date, awesome_buttons, string_split, jqEnableDisable, jQueryDomainType, jqKonami,
jqAutogrowTextarea, jqSaveRestore, jqIsolatedScript, require, $, browserSelector){
if(!cors_supported){
var domainSplit, tenant_name_from_url;
var ajaxSettings = {
transport:'flXHRproxy',
flXHR: true};
domainSplit = win.location != null ? win.location.hostname != null ? win.location.hostname.split('.') : void 0 : void 0;
tenant_name_from_url = domainSplit[0];
if(tenant_name_from_url == 'cm') {
flensed.flXHR({instancePooling: false});
}
$.ajaxSetup(ajaxSettings);
}
if(string_split.fillNeeded()) string_split.fill();
Date.prototype.displayDate = function(appendUTCString){
return new Date(+this + this.getTimezoneOffset() * 60 * 1000).toString('MM/dd/yyyy') + (appendUTCString === false ? '' : ' UTC') ;
}
Date.prototype.toUTC = function(){
var dt = this;
return new Date(dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate(), dt.getUTCHours(), dt.getUTCMinutes(), dt.getUTCSeconds(), dt.getUTCMilliseconds());
}
var nativeDateToJSON = Date.prototype.toJSON;
Date.prototype.toJSON = function(){
return nativeDateToJSON.apply(this.clone().clearTime());
}
String.prototype.truncate = function(to) {
if (this.length <= to) return this;
return this.substr(0, to - 3) + '...'
}
document.createElement('field');
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment