-
-
Save mecachisenros/834e8a38cf4204a5e4d554b471f1f2cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular, $, _) { | |
// Declare Angular module | |
var crmMailSubjectReview = angular.module( 'crmMailSubjectReview', [] ); | |
// Hook into crmMailing module and append directive into crmMailingBlockReview directive | |
angular.module( 'crmMailing' ).config( function( $provide ){ | |
$provide.decorator( 'crmMailingBlockReviewDirective', function( $delegate ){ | |
var directive = $delegate[0]; | |
var link = directive.link; | |
directive.compile = function( Element, Attrs ){ | |
Element.children( ":first" ).children( ":first" ).children( ":first" ).children( ":nth-child(2)" ).after( '<div crm-subject-review></div>' ); | |
return function( scope, elem, attr ){ | |
link.apply( this, arguments ); | |
}; | |
}; | |
return $delegate; | |
}); | |
}); | |
// crmSubjectReview directive | |
angular.module( 'crmMailing' ).directive( 'crmSubjectReview', function(){ | |
return { templateUrl: CRM.resourceUrls['uk.menas.subcustom'] + '/js/crmSubjectReview.html', | |
controller: 'crmSubjectReviewCtrl', | |
}; | |
}); | |
// crmSubjectReview factory | |
angular.module('crmMailing').factory('crmSubjectReviewFactory', function(){ | |
return { | |
editEnabled: false, | |
enableEdit: function() { | |
this.editEnabled = true; | |
}, | |
disableEdit: function() { | |
this.editEnabled = false; | |
} | |
} | |
}); | |
// crmSubjectReview controller | |
angular.module( 'crmMailing' ).controller( 'crmSubjectReviewCtrl', function( $scope, crmSubjectReviewFactory ){ | |
$scope.crmSubjectReview = crmSubjectReviewFactory; | |
}); | |
})(angular, CRM.$, CRM._); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here's the directive