Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed jQuery dependency #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Removed jQuery dependency #83

wants to merge 3 commits into from

Conversation

augnustin
Copy link

I can see there is another pull request on the same topic: #21

Changes here are really small:

  • Changed the element.find(className) to findDivByClassName = function(element, className)
  • Changed angular.element('body') to angular.element($document).find('body')
  • Changed $slider.width() to $slider[0].offsetWidth (and same with height)

I tested it in Chrome and FF and it works. I can't test it under IE because I'm using Linux. But offsetWidth is IE compatible.

Regarding findDivByClassName, I first used getElementsByClassName but it appeard not to be IE8 compatible so I went for a custom method, that only uses angular.find(tagName) which must be based on getElementsByTagName which is IE8 compatible.

Here it is:

            var filter = function(array, method) {
                var filteredArray = [];
                for (var i=0; i<array.length; i++) {
                    if (method(array[i])) {
                        filteredArray.push(array[i])
                    }
                }
                return filteredArray;
            };

            var findDivByClassName = function(element, className) {
                return angular.element(filter(element.find('div'), function(el){
                    return angular.element(el).hasClass(className);
                }));
            };

Hope this gets merged soon! 😄

Awesome directive by the way!

@danielcrisp
Copy link
Owner

Amazing - thank you, will take a look soon

@augnustin
Copy link
Author

I forgot a $document.find('body') in the $destroy.

Done. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants