Guest User

Untitled

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1.  
  2. if(typeof EADIS == "undefined" || !EADIS) {
  3. var EADIS = {};
  4. }
  5.  
  6. EADIS.namespace = function() {
  7. var a = arguments, o = null, d;
  8. for(var i = 0 ; i < a.length ; i++) {
  9. d = (""+a[i]).split(".");
  10. for(var j = (d[0] == "EADIS" ? 1 : 0) ; j < d.length ; j++) {
  11.  
  12. }
  13. }
  14. return o;
  15. }
  16.  
  17. (function() {
  18. EADIS.namespace("EADIS.util");
  19.  
  20. var Merge = function() {
  21. obj = {};
  22. for(var i in arguments) {
  23. var from = arguments[i];
  24. for(var j in form) {
  25. obj[j] = from[j];
  26. }
  27. }
  28. return obj;
  29. }
  30. EADIS.util.Merge = Merge;
  31.  
  32. var Trim = function() {
  33. this = this.replace(/^\s+/, '');
  34. for (var i = this.length - 1; i >= 0; i--) {
  35. if (/\S/.test(this.charAt(i))) {
  36. this = this.substring(0, i + 1);
  37. break;
  38. }
  39. }
  40. return this;
  41. }
  42. String.prototype.trim = Trim;
  43. /**
  44. * Add Trim() to the String prototype. This will make trim available globally to all Strings
  45. * var str = " String Test ".trim();
  46. * var str = ValidString.trim();
  47. */
  48.  
  49. var toString = Object.prototype.toString;
  50. var isFunction = function(obj) {
  51. return toString.call(obj) == '[object Function]';
  52. }
  53. EADIS.util.isFunction = isFunction;
  54.  
  55. })();
  56.  
  57. (function() {
  58. EADIS.namespace("EADIS.dom");
  59.  
  60. var Group = function() {
  61. var a = arguments;
  62. if(typeof a.count == 'undefined') {
  63. a = [a];
  64. }
  65. this.init.apply(this, a);
  66. }
  67.  
  68. Group.prototype = {
  69. init: function(group) {
  70. this._group = group;
  71. },
  72.  
  73. indexOf: function(obj) {
  74. for(var i in this._group) {
  75. if(this._group[i] == obj) {
  76. return i;
  77. }
  78. }
  79. },
  80.  
  81. get: function(index) {
  82. return this._group[index];
  83. },
  84.  
  85. execute: function(fun) {
  86. if(typeof fun == 'string') {
  87. fun = this._group[0][fun];
  88. }
  89.  
  90. for(var i in this._group) {
  91. var el = this._group[i];
  92. fun.call(this, el);
  93. }
  94. }
  95. };
  96.  
  97. var GroupActions = {};
  98.  
  99. GroupActions.prototype = {
  100. disable: function() {
  101. this.execute(function(el) { el.disabled = true;});
  102. },
  103.  
  104. enabled: function() {
  105. this.execute(function(el) { el.disabled = false;});
  106. },
  107.  
  108. hasClass: function(class) {
  109. return new RegExp('\\b' + class + '\\b').test(this._element.className);
  110. }
  111.  
  112. addClass: function() {
  113. var a = arguments;
  114. if(typeof a.count == 'undefined') {
  115. a = a.split(" ");
  116. }
  117.  
  118. for each(var value in a) {
  119. if(!this.hasClass(value)){
  120. this._element.className += this._element.className + ' ' + value;
  121. }
  122. }
  123. },
  124.  
  125. removeClass: function() {
  126. var a = arguments;
  127. if(typeof a.count == 'undefined') {
  128. a = a.split(" ");
  129. }
  130.  
  131. for each(var value in a) {
  132. this._element.className = this._element.className.replace(value, '');
  133. }
  134. }
  135.  
  136. };
  137.  
  138. EADIS.dom.Group = Util.Merge(GroupActions, Group);
  139. })();
  140.  
  141. (function() {
  142.  
  143. /**
  144. * EventListener
  145. */
  146.  
  147. var EventListener = function(obj, type) {
  148.  
  149. }
  150.  
  151. EventListener.prototype = {
  152. init: function(obj, type) {
  153. if(obj typeof String) {
  154. this._obj = document.findElementById(obj);
  155. this._type = type;
  156. }
  157.  
  158. this._obj
  159. },
  160.  
  161. subscribe: function(fn, scope) {
  162.  
  163. },
  164.  
  165. fireQueue: function() {
  166.  
  167. }
  168. }
  169.  
  170. DOM.EventListener = EventListener;
  171.  
  172. /**
  173. * ElementGroup
  174. */
  175.  
  176. var ElementGroup = function() {
  177. var args = arguments;
  178. if(args.length == 1) {
  179. if(args typeof String) {
  180. var tokens = args.split(',');
  181. for(var i = 0 ; i < tokens.length ; i++) {
  182. args[i] = new DOM.Element(Util.trim(tokens[i]));
  183. }
  184. } else if (args typeof Array) {
  185. for(var i = 0 ; i < args.length ; i++) {
  186. args[i] = new DOM.Element(args[i]);
  187. }
  188. }
  189. }
  190.  
  191. var group = {};
  192. for(element in args) {
  193. group[element.id] = element;
  194. }
  195.  
  196. this.init(group)
  197. }
  198.  
  199. ElementGroup.prototype = {
  200. init: function(group) {
  201. this._group = group;
  202. },
  203.  
  204. add: function(obj) {
  205. if(obj typeof String) {
  206. obj = new DOM.Element(obj);
  207. }
  208. this._group[obj.id] = obj;
  209. },
  210.  
  211. remove: function(obj) {
  212. if(!(obj typeof String)) {
  213. obj = obj.id;
  214. }
  215. delete this._group[obj];
  216. },
  217.  
  218. apply: function(fn) {
  219. for each(var element in this._group) {
  220. fn.call(this, element)
  221. }
  222. }
  223. }
  224.  
  225. /**
  226. * ElementController
  227. */
  228. var ElementController = function() {
  229.  
  230. }
  231.  
  232. ElementController.prototype = {
  233.  
  234. }
  235.  
  236. /**
  237. * Element
  238. */
  239.  
  240. var Element = function(obj) {
  241. if(obj typeof String) {
  242. obj = document.findElementById(obj);
  243. }
  244.  
  245. this.init(obj);
  246. }
  247.  
  248. Element.prototype = {
  249. init: function(obj) {
  250. this._element = obj;
  251. this._events = {};
  252. this.id = obj.getAttribute('id');
  253. },
  254.  
  255. on: function(type, fn, scope) {
  256. if(!this._events[type]) {
  257. this._events[type] = new Event(this._elemet, type);
  258. }
  259. this._events[types].subscribe(fn, scope);
  260. },
  261.  
  262. when: function(e) {
  263.  
  264. },
  265.  
  266. disable: function() {
  267. this._element.disabled = true;
  268. },
  269.  
  270. enable: function() {
  271. this._element.disabled = false;
  272. },
  273.  
  274. addClass: function(class) {
  275. if(!this.hasClass(class)){
  276. this._element.className += (' ' + class);
  277. }
  278. },
  279.  
  280. removeClass: function(class) {
  281. this._element.className.replace(class, '');
  282. },
  283.  
  284. hasClass: function(class) {
  285. return new RegExp('\\b' + class + '\\b').test(this._element.className);
  286. }
  287.  
  288.  
  289. }
  290.  
  291. })()
Add Comment
Please, Sign In to add comment