Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(typeof EADIS == "undefined" || !EADIS) {
- var EADIS = {};
- }
- EADIS.namespace = function() {
- var a = arguments, o = null, d;
- for(var i = 0 ; i < a.length ; i++) {
- d = (""+a[i]).split(".");
- for(var j = (d[0] == "EADIS" ? 1 : 0) ; j < d.length ; j++) {
- }
- }
- return o;
- }
- (function() {
- EADIS.namespace("EADIS.util");
- var Merge = function() {
- obj = {};
- for(var i in arguments) {
- var from = arguments[i];
- for(var j in form) {
- obj[j] = from[j];
- }
- }
- return obj;
- }
- EADIS.util.Merge = Merge;
- var Trim = function() {
- this = this.replace(/^\s+/, '');
- for (var i = this.length - 1; i >= 0; i--) {
- if (/\S/.test(this.charAt(i))) {
- this = this.substring(0, i + 1);
- break;
- }
- }
- return this;
- }
- String.prototype.trim = Trim;
- /**
- * Add Trim() to the String prototype. This will make trim available globally to all Strings
- * var str = " String Test ".trim();
- * var str = ValidString.trim();
- */
- var toString = Object.prototype.toString;
- var isFunction = function(obj) {
- return toString.call(obj) == '[object Function]';
- }
- EADIS.util.isFunction = isFunction;
- })();
- (function() {
- EADIS.namespace("EADIS.dom");
- var Group = function() {
- var a = arguments;
- if(typeof a.count == 'undefined') {
- a = [a];
- }
- this.init.apply(this, a);
- }
- Group.prototype = {
- init: function(group) {
- this._group = group;
- },
- indexOf: function(obj) {
- for(var i in this._group) {
- if(this._group[i] == obj) {
- return i;
- }
- }
- },
- get: function(index) {
- return this._group[index];
- },
- execute: function(fun) {
- if(typeof fun == 'string') {
- fun = this._group[0][fun];
- }
- for(var i in this._group) {
- var el = this._group[i];
- fun.call(this, el);
- }
- }
- };
- var GroupActions = {};
- GroupActions.prototype = {
- disable: function() {
- this.execute(function(el) { el.disabled = true;});
- },
- enabled: function() {
- this.execute(function(el) { el.disabled = false;});
- },
- hasClass: function(class) {
- return new RegExp('\\b' + class + '\\b').test(this._element.className);
- }
- addClass: function() {
- var a = arguments;
- if(typeof a.count == 'undefined') {
- a = a.split(" ");
- }
- for each(var value in a) {
- if(!this.hasClass(value)){
- this._element.className += this._element.className + ' ' + value;
- }
- }
- },
- removeClass: function() {
- var a = arguments;
- if(typeof a.count == 'undefined') {
- a = a.split(" ");
- }
- for each(var value in a) {
- this._element.className = this._element.className.replace(value, '');
- }
- }
- };
- EADIS.dom.Group = Util.Merge(GroupActions, Group);
- })();
- (function() {
- /**
- * EventListener
- */
- var EventListener = function(obj, type) {
- }
- EventListener.prototype = {
- init: function(obj, type) {
- if(obj typeof String) {
- this._obj = document.findElementById(obj);
- this._type = type;
- }
- this._obj
- },
- subscribe: function(fn, scope) {
- },
- fireQueue: function() {
- }
- }
- DOM.EventListener = EventListener;
- /**
- * ElementGroup
- */
- var ElementGroup = function() {
- var args = arguments;
- if(args.length == 1) {
- if(args typeof String) {
- var tokens = args.split(',');
- for(var i = 0 ; i < tokens.length ; i++) {
- args[i] = new DOM.Element(Util.trim(tokens[i]));
- }
- } else if (args typeof Array) {
- for(var i = 0 ; i < args.length ; i++) {
- args[i] = new DOM.Element(args[i]);
- }
- }
- }
- var group = {};
- for(element in args) {
- group[element.id] = element;
- }
- this.init(group)
- }
- ElementGroup.prototype = {
- init: function(group) {
- this._group = group;
- },
- add: function(obj) {
- if(obj typeof String) {
- obj = new DOM.Element(obj);
- }
- this._group[obj.id] = obj;
- },
- remove: function(obj) {
- if(!(obj typeof String)) {
- obj = obj.id;
- }
- delete this._group[obj];
- },
- apply: function(fn) {
- for each(var element in this._group) {
- fn.call(this, element)
- }
- }
- }
- /**
- * ElementController
- */
- var ElementController = function() {
- }
- ElementController.prototype = {
- }
- /**
- * Element
- */
- var Element = function(obj) {
- if(obj typeof String) {
- obj = document.findElementById(obj);
- }
- this.init(obj);
- }
- Element.prototype = {
- init: function(obj) {
- this._element = obj;
- this._events = {};
- this.id = obj.getAttribute('id');
- },
- on: function(type, fn, scope) {
- if(!this._events[type]) {
- this._events[type] = new Event(this._elemet, type);
- }
- this._events[types].subscribe(fn, scope);
- },
- when: function(e) {
- },
- disable: function() {
- this._element.disabled = true;
- },
- enable: function() {
- this._element.disabled = false;
- },
- addClass: function(class) {
- if(!this.hasClass(class)){
- this._element.className += (' ' + class);
- }
- },
- removeClass: function(class) {
- this._element.className.replace(class, '');
- },
- hasClass: function(class) {
- return new RegExp('\\b' + class + '\\b').test(this._element.className);
- }
- }
- })()
Add Comment
Please, Sign In to add comment