Skip to content

Instantly share code, notes, and snippets.

@Ingelheim
Created May 15, 2014 13:07
Show Gist options
  • Save Ingelheim/d43d042909155c9c10dd to your computer and use it in GitHub Desktop.
Save Ingelheim/d43d042909155c9c10dd to your computer and use it in GitHub Desktop.
Refactoring of wysiwyg directive
/*global angular */
/*jshint globalstrict:true*/
'use strict';
angular.module('clientApp').directive('qenWysiwygTheOne', ['$timeout', 'qenWysiwygImage', 'imageTagService', function ($timeout, qenWysiwygImage, imageTagService) {
var QenWysiwyg = QEN.directives.QenWysiwyg($timeout, qenWysiwygImage, imageTagService);
var QenPrintWysiwyg = QEN.directives.QenPrintWysiwyg(imageTagService);
RedactorPlugins.qenImage = qenWysiwygImage;
return {
restrict: 'E',
require: 'ngModel',
scope: {
editorId: '@qenId',
placeholder: '@',
ngModel: '='
},
template: function(element, attrs) {
var inputEditable = attrs.inputeditable;
return inputEditable === 'false' ? QenPrintWysiwyg.template : QenWysiwyg.template;
},
replace: true,
compile: function (element, attrs, ngModel) {
var inputEditable = attrs.inputeditable;
return inputEditable === 'true' ? QenPrintWysiwyg.link : QenWysiwyg.link;
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment