511205219caf2e9cc28c5996b11ba86558b27e24
[src/app-framework-demo.git] / afb-client / app / Frontend / services / JQueryEmu.js
1 (function () {
2     'use strict';
3
4     // _all modules only reference dependencies
5     angular.module('JQueryEmu', [])
6
7             // Factory is a singleton and share its context within all instances.
8             .factory('JQemu', function () {
9
10                 // JQueryLight cannot search a tag within ancestrors
11                 var parent = function (element, selector) {
12                     var parent = element;
13                     var search = selector.toUpperCase();
14                     while (parent[0]) {
15                         if (search === parent[0].tagName) {
16                             return parent;
17                         }  // HTMLDivElement properties
18                         parent = parent.parent();
19                     }
20                 };
21                 
22                 // JQueryLight cannot search by type
23                 var  findByType= function (element, selector) {
24                     var search = selector.toLowerCase();
25                     var children = element.children();
26                     while (children[0]) {
27                         if (search === children[0].type) {
28                             return children;
29                         }  // HTMLDivElement properties
30                         children = children.next();
31                     }
32                 };
33
34                 var myMethods = {
35                     parent: parent,
36                     findByType: findByType
37                 };
38
39                 return myMethods;
40             });
41
42 })();