summaryrefslogtreecommitdiffstats
path: root/afb-client/app/Frontend/services/JQueryEmu.js
blob: 511205219caf2e9cc28c5996b11ba86558b27e24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function () {
    'use strict';

    // _all modules only reference dependencies
    angular.module('JQueryEmu', [])

            // Factory is a singleton and share its context within all instances.
            .factory('JQemu', function () {

                // JQueryLight cannot search a tag within ancestrors
                var parent = function (element, selector) {
                    var parent = element;
                    var search = selector.toUpperCase();
                    while (parent[0]) {
                        if (search === parent[0].tagName) {
                            return parent;
                        }  // HTMLDivElement properties
                        parent = parent.parent();
                    }
                };
                
                // JQueryLight cannot search by type
                var  findByType= function (element, selector) {
                    var search = selector.toLowerCase();
                    var children = element.children();
                    while (children[0]) {
                        if (search === children[0].type) {
                            return children;
                        }  // HTMLDivElement properties
                        children = children.next();
                    }
                };

                var myMethods = {
                    parent: parent,
                    findByType: findByType
                };

                return myMethods;
            });

})();