X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2FCommon.js;h=e5d14fef7f37005db8ebaf423dc1a317059f2d91;hb=a5db8e6f23a5fe5a90dfade39766c5bf0f7f8d27;hp=e0b4d42c59ad114755816a637981cb942b80c3c5;hpb=873a6408b9461557400f5a23409ed5b047a22a74;p=civicrm-core.git diff --git a/js/Common.js b/js/Common.js index e0b4d42c59..e5d14fef7f 100644 --- a/js/Common.js +++ b/js/Common.js @@ -1,6 +1,6 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.3 | + | CiviCRM version 4.4 | +--------------------------------------------------------------------+ | Copyright CiviCRM LLC (c) 2004-2013 | +--------------------------------------------------------------------+ @@ -596,9 +596,9 @@ CRM.validate = CRM.validate || { }); $.fn.crmtooltip = function () { - $('a.crm-summary-link:not(.crm-processed)') - .addClass('crm-processed') - .on('mouseover', function (e) { + $(document) + .on('mouseover', 'a.crm-summary-link:not(.crm-processed)', function (e) { + $(this).addClass('crm-processed'); $(this).addClass('crm-tooltip-active'); var topDistance = e.pageY - $(window).scrollTop(); if (topDistance < 300 | topDistance < $(this).children('.crm-tooltip-wrapper').height()) { @@ -611,14 +611,15 @@ CRM.validate = CRM.validate || { .load(this.href); } }) - .on('mouseout', function () { + .on('mouseout', 'a.crm-summary-link', function () { + $(this).removeClass('crm-processed'); $(this).removeClass('crm-tooltip-active crm-tooltip-down'); }) - .on('click', false); + .on('click', 'a.crm-summary-link', false); }; var h; - CRM.help = function (title, params) { + CRM.help = function (title, params, url) { h && h.close && h.close(); var options = { expires: 0 @@ -626,7 +627,7 @@ CRM.validate = CRM.validate || { h = CRM.alert('...', title, 'crm-help crm-msg-loading', options); params.class_name = 'CRM_Core_Page_Inline_Help'; params.type = 'page'; - $.ajax(CRM.url('civicrm/ajax/inline'), + $.ajax(url || CRM.url('civicrm/ajax/inline'), { data: params, dataType: 'html', @@ -804,7 +805,12 @@ CRM.validate = CRM.validate || { CRM.alert(text, title, type, options); }); // Handle qf form errors - $('form :input.error', this).one('blur', function () { + $('form :input.error', this).one('blur', function() { + // ignore autocomplete fields + if ($(this).is('.ac_input')) { + return; + } + $('.ui-notify-message.error a.ui-notify-close').click(); $(this).removeClass('error'); $(this).next('span.crm-error').remove(); @@ -874,4 +880,33 @@ CRM.validate = CRM.validate || { $(this).toggleClass('collapsed'); }); }; + + /** + * Clientside currency formatting + * @param value + * @param format - currency representation of the number 1234.56 + * @return string + * @see CRM_Core_Resources::addCoreResources + */ + var currencyTemplate; + CRM.formatMoney = function(value, format) { + var decimal, separator, sign, i, j, result; + if (value === 'init' && format) { + currencyTemplate = format; + return; + } + format = format || currencyTemplate; + result = /1(.?)234(.?)56/.exec(format); + if (result === null) { + return 'Invalid format passed to CRM.formatMoney'; + } + separator = result[1]; + decimal = result[2]; + sign = (value < 0) ? '-' : ''; + //extracting the absolute value of the integer part of the number and converting to string + i = parseInt(value = Math.abs(value).toFixed(2)) + ''; + j = ((j = i.length) > 3) ? j % 3 : 0; + 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); + }; })(jQuery);