Skip to content

Support for callbacks? #39

@aeldaly

Description

@aeldaly

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions