Not all browsers (ahem, IE) support the js console and will crash if it doesn't exist.
CRM.console adds a safe way to access console methods.
CRM.alert(msg.text, msg.title, msg.type, msg.options);
})
}
+ if (response.backtrace) {
+ CRM.console('log', response.backtrace);
+ }
}
}
// Suppress errors
result = sign + (j ? i.substr(0, j) + separator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + separator) + (2 ? decimal + Math.abs(value - i).toFixed(2).slice(2) : '');
return format.replace(/1.*234.*56/, result);
};
+
+ CRM.console = function(method, title, msg) {
+ if (window.console) {
+ method = $.isFunction(console[method]) ? method : 'log';
+ if (msg === undefined) {
+ return console[method](title);
+ } else {
+ return console[method](title, msg);
+ }
+ }
+ }
})(jQuery, _);
case 'sequence':
return 0 == _.where($scope.caseType.definition.activitySets, {sequence: '1'}).length;
default:
- if (console && console.log) console.log('Denied access to unrecognized workflow: (' + workflow + ')');
+ CRM.console('warn', 'Denied access to unrecognized workflow: (' + workflow + ')');
return false;
}
};
};
});
-})(angular, CRM.$, CRM._);
\ No newline at end of file
+})(angular, CRM.$, CRM._);
return tplURL = path;
}
if (!tplURL) {
- console && console.log && console.log('Warning: CRM.url called before initialization');
+ CRM.console('error', 'Error: CRM.url called before initialization');
}
if (!mode) {
mode = CRM.config && CRM.config.isFrontend ? 'front' : 'back';
return url;
};
- // Backwards compatible with jQuery fn
+ // @deprecated
$.extend ({'crmURL':
function (p, params) {
- console && console.log && console.log('Calling crmURL from jQuery is deprecated. Please use CRM.url() instead.');
+ CRM.console('warn', 'Calling crmURL from jQuery is deprecated. Please use CRM.url() instead.');
return CRM.url(p, params);
}
});
* @deprecated
*/
$.fn.crmAPI = function(entity, action, params, options) {
- console && console.log && console.log('Calling crmAPI from jQuery is deprecated. Please use CRM.api() instead.');
+ CRM.console('warn', 'Calling crmAPI from jQuery is deprecated. Please use CRM.api3() instead.');
return CRM.api.call(this, entity, action, params, options);
};