X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ang%2FcrmUi.js;h=4ea687c32964e87a5d0dad35ac30c3bcb92e454f;hb=2c0f8c6797d810bc6a3202b7d0c18e762f5f22ec;hp=5efa2a48019b71be756951693e9d2a2e7b8d2ca2;hpb=3c42b8da2517a5178d9fda9daf54f006446be4f7;p=civicrm-core.git diff --git a/ang/crmUi.js b/ang/crmUi.js index 5efa2a4801..4ea687c329 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -1,12 +1,14 @@ /// crmUi: Sundry UI helpers (function (angular, $, _) { - var uidCount = 0; + var uidCount = 0, + pageTitle = 'CiviCRM', + documentTitle = 'CiviCRM'; - angular.module('crmUi', []) + angular.module('crmUi', CRM.angRequires('crmUi')) // example
...content...
- // WISHLIST: crmCollapsed should support two-way/continous binding + // WISHLIST: crmCollapsed should support two-way/continuous binding .directive('crmUiAccordion', function() { return { scope: { @@ -361,31 +363,13 @@ // Example: // ...content... + // example
...content...
// WISHLIST: use a full Angular component instead of an incomplete jQuery wrapper .directive('crmUiTab', function($parse) { return { @@ -705,6 +673,8 @@ restrict: 'EA', scope: { crmTitle: '@', + crmIcon: '@', + count: '@', id: '@' }, template: '
', @@ -720,7 +690,8 @@ return { restrict: 'EA', scope: { - crmUiTabSet: '@' + crmUiTabSet: '@', + tabSetOptions: '@' }, templateUrl: '~/crmUi/tabset.html', transclude: true, @@ -772,6 +743,7 @@ }) // example:
...
...
+ // example with custom nav classes:
...
// Note: "myWizardCtrl" has various actions/properties like next() and $first(). // WISHLIST: Allow each step to determine if it is "complete" / "valid" / "selectable" // WISHLIST: Allow each step to enable/disable (show/hide) itself @@ -779,7 +751,8 @@ return { restrict: 'EA', scope: { - crmUiWizard: '@' + crmUiWizard: '@', + crmUiWizardNavClass: '@' // string, A list of classes that will be added to the nav items }, templateUrl: '~/crmUi/wizard.html', transclude: true, @@ -883,13 +856,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'); } @@ -900,6 +882,7 @@ // example:
...content...
// If there are any conditional steps, then be sure to set a weight explicitly on *all* steps to maintain ordering. // example:
...content...
+ // example with custom classes:
...content...
.directive('crmUiWizardStep', function() { var nextWeight = 1; return { @@ -907,9 +890,10 @@ restrict: 'EA', scope: { crmTitle: '@', // expression, evaluates to a printable string - crmUiWizardStep: '@' // int, a weight which determines the ordering of the steps + crmUiWizardStep: '@', // int, a weight which determines the ordering of the steps + crmUiWizardStepClass: '@' // string, A list of classes that will be added to the template }, - template: '
', + template: '
', transclude: true, link: function (scope, element, attrs, ctrls) { var crmUiWizardCtrl = ctrls[0], form = ctrls[1]; @@ -922,7 +906,7 @@ return form.$valid; }; crmUiWizardCtrl.add(scope); - element.on('$destroy', function(){ + scope.$on('$destroy', function(){ crmUiWizardCtrl.remove(scope); }); } @@ -1008,6 +992,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) {