X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ang%2FcrmUi.js;h=3f091914b2a88f6d874ba2faad6281b82b1b5ae0;hb=aa0c560270faef4aba459bda712f2f93f6e80256;hp=20ee8b1a8f10af7da538e118becc24499a43b7ee;hpb=9b7fe90f0cd3cd3109ffa1f824dbb60d6a664679;p=civicrm-core.git diff --git a/ang/crmUi.js b/ang/crmUi.js index 20ee8b1a8f..3f091914b2 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -633,6 +633,24 @@ }; }) + // Use a select2 widget as a pick-list. Instead of updating ngModel, the select2 widget will fire an event. + // This similar to ngModel+ngChange, except that value is never stored in a model. It is only fired in the event. + // usage: + .directive('onCrmUiSelect', function () { + return { + priority: 10, + link: function (scope, element, attrs) { + element.on('select2-selecting', function(e) { + e.preventDefault(); + element.select2('close').select2('val', ''); + scope.$apply(function() { + scope.$eval(attrs.onCrmUiSelect, {selection: e.val}); + }); + }); + } + }; + }) + // Render a crmEntityRef widget // usage: .directive('crmEntityref', function ($parse, $timeout) { @@ -927,7 +945,8 @@ else { $(element).prepend(' '); } - if ($(element).is('button')) { + // Add crm-* class to non-bootstrap buttons + if ($(element).is('button:not(.btn)')) { $(element).addClass('crm-button'); } } @@ -1064,15 +1083,20 @@ function update() { $timeout(function() { var newPageTitle = _.trim($el.html()), - newDocumentTitle = scope.crmDocumentTitle || $el.text(); + newDocumentTitle = scope.crmDocumentTitle || $el.text(), + h1Count = 0; document.title = $('title').text().replace(documentTitle, newDocumentTitle); // If the CMS has already added title markup to the page, use it $('h1').not('.crm-container h1').each(function() { - if (_.trim($(this).html()) === pageTitle) { + if ($(this).hasClass('crm-page-title') || _.trim($(this).html()) === pageTitle) { $(this).addClass('crm-page-title').html(newPageTitle); $el.hide(); + ++h1Count; } }); + if (!h1Count) { + $el.show(); + } pageTitle = newPageTitle; documentTitle = newDocumentTitle; });