X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ang%2FcrmUi.js;h=19672daed18b2fad3303850bac68e2a378e98790;hb=495f94fb2bc8777798085832c791794e5f3cffc4;hp=4e9afcfaada724dd47bd5c051f640bdd5720f3b2;hpb=ec36654545f74a355cf5453218e34eeb0d0df5c1;p=civicrm-core.git
diff --git a/ang/crmUi.js b/ang/crmUi.js
index 4e9afcfaad..19672daed1 100644
--- a/ang/crmUi.js
+++ b/ang/crmUi.js
@@ -1,7 +1,9 @@
/// crmUi: Sundry UI helpers
(function (angular, $, _) {
- var uidCount = 0;
+ var uidCount = 0,
+ pageTitle = 'CiviCRM',
+ documentTitle = 'CiviCRM';
angular.module('crmUi', [])
@@ -64,7 +66,7 @@
// Simple wrapper around $.crmDatepicker.
// example with no time input:
- // example with custom date format:
+ // example with custom date format:
.directive('crmUiDatepicker', function () {
return {
restrict: 'AE',
@@ -394,7 +396,9 @@
}
ngModel.$render = function(value) {
- CRM.wysiwyg.setVal(elm, ngModel.$viewValue);
+ editor.done(function() {
+ CRM.wysiwyg.setVal(elm, ngModel.$viewValue || '');
+ });
};
}
};
@@ -429,20 +433,20 @@
var titleLocked = parse(attrs.titleLocked, ts('Locked'));
var titleUnlocked = parse(attrs.titleUnlocked, ts('Unlocked'));
- $(element).addClass('ui-icon lock-button');
+ $(element).addClass('crm-i lock-button');
var refresh = function () {
var locked = binding(scope);
if (locked) {
$(element)
- .removeClass('ui-icon-unlocked')
- .addClass('ui-icon-locked')
+ .removeClass('fa-unlock')
+ .addClass('fa-lock')
.prop('title', titleLocked(scope))
;
}
else {
$(element)
- .removeClass('ui-icon-locked')
- .addClass('ui-icon-unlocked')
+ .removeClass('fa-lock')
+ .addClass('fa-unlock')
.prop('title', titleUnlocked(scope))
;
}
@@ -599,7 +603,7 @@
function init() {
// TODO watch select2-options
- element.select2(scope.crmUiSelect || {});
+ element.crmSelect2(scope.crmUiSelect || {});
if (ngModel) {
element.on('change', refreshModel);
$timeout(ngModel.$render);
@@ -651,7 +655,7 @@
};
})
- // example
...content...
+ // example ...content...
// WISHLIST: use a full Angular component instead of an incomplete jQuery wrapper
.directive('crmUiTab', function($parse) {
return {
@@ -659,6 +663,8 @@
restrict: 'EA',
scope: {
crmTitle: '@',
+ crmIcon: '@',
+ count: '@',
id: '@'
},
template: '',
@@ -837,13 +843,22 @@
};
})
- // Example:
+ // Example for Font Awesome:
+ // Example for jQuery UI (deprecated):
.directive('crmIcon', function() {
return {
restrict: 'EA',
- scope: {},
link: function (scope, element, attrs) {
- $(element).prepend(' ');
+ if (element.is('[crm-ui-tab]')) {
+ // handled in crmUiTab ctrl
+ return;
+ }
+ if (attrs.crmIcon.substring(0,3) == 'fa-') {
+ $(element).prepend(' ');
+ }
+ else {
+ $(element).prepend(' ');
+ }
if ($(element).is('button')) {
$(element).addClass('crm-button');
}
@@ -962,6 +977,39 @@
}
};
})
+
+ // Sets document title & page title; attempts to override CMS title markup for the latter
+ // WARNING: Use only once per route!
+ // Example (same title for both): {{ts('Hello')}}
+ // Example (separate document title): {{ts('Hello')}}
+ .directive('crmPageTitle', function($timeout) {
+ return {
+ scope: {
+ crmDocumentTitle: '='
+ },
+ link: function(scope, $el, attrs) {
+ function update() {
+ $timeout(function() {
+ var newPageTitle = _.trim($el.html()),
+ newDocumentTitle = scope.crmDocumentTitle || $el.text();
+ 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) {
+ $(this).html(newPageTitle);
+ $el.hide();
+ }
+ });
+ pageTitle = newPageTitle;
+ documentTitle = newDocumentTitle;
+ });
+ }
+
+ scope.$watch(function() {return scope.crmDocumentTitle + $el.html();}, update);
+ }
+ };
+ })
+
.run(function($rootScope, $location) {
/// Example:
$rootScope.goto = function(path) {