ngDfp icon indicating copy to clipboard operation
ngDfp copied to clipboard

Support for callbacks?

Open aeldaly opened this issue 10 years ago • 0 comments

I'd like to be able to make css changes based on the existence of an ad. I already hide when empty, but I need to also change padding on the parent container. Currently, I had to modify the source of the js and check it into my own code base to achieve this. Here's what I had to do, for reference:

.directive('ngDfpAdContainer', function () {
    return {
      restrict: 'A',
      controller: ['$element', function ($element) {
        function hide(mode) {
          if (mode === 'visibility') {
            $element.css('visibility', 'hidden');
          }
          else {
            $element.hide();
            $element.parent().parent().css('width', '0px'); // I added this
            $element.parent().parent().css('padding', '0px'); // I added this
          }
        }

        function show(mode) {
          if (mode === 'visibility') {
            $element.css('visibility', 'visible');
          }
          else {
            $element.parent().parent().css('width', '100%'); // I added this
            $element.show();
          }
        }

        this.$$setVisible = function (visible, mode) {
          if (visible) {
            show(mode);
          }
          else {
            hide(mode);
          }
        };
      }]
    };

Is there a more elegant solution?

Thanks!

aeldaly avatar Dec 06 '15 21:12 aeldaly