Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // Thinking Like AngularJS. For Fun and Learning.
  2.  
  3. /*
  4. isht.directive('name',function(){
  5. return function(node) {
  6. //Performing Function.
  7. }
  8. })
  9. */
  10. var isht = {};
  11. isht.store = [];
  12. isht.count = 0;
  13.  
  14. isht.directive = function(name,func) {
  15. // Adding Directive to the Store Array
  16. name = name.toUpperCase();
  17. this.store[name] = func();
  18. this.count++;
  19. }
  20.  
  21. // DOM Loop for Traversing
  22. isht.walkTheDom = function(node,func) {
  23. func(node);
  24. node = node.firstChild;
  25. while(node) {
  26. func(node);
  27. this.walkTheDom(node,func);
  28. node = node.nextSibling;
  29. }
  30. }
  31.  
  32. // Processing Directives
  33.  
  34. isht.bootstrap = function() {
  35. // Processing Each Node
  36. this.walkTheDom(document.body, function(node) {
  37. if(isht.store[node.tagName]) {
  38. var directive = isht.store[node.nodeName];
  39. directive(node);
  40.  
  41. }
  42. })
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement