diff options
author | wei <> | 2006-01-16 02:59:04 +0000 |
---|---|---|
committer | wei <> | 2006-01-16 02:59:04 +0000 |
commit | ce2b2803b78379a2bfca2849a5d5f8933a1634ea (patch) | |
tree | cc79e490dcdec6bc14e5c703f273f299fcfc2982 /framework/Web/Javascripts/extended/dom.js | |
parent | ca47a8c7fd5eb9f34ac00a2f1a843859d6123dd8 (diff) |
Diffstat (limited to 'framework/Web/Javascripts/extended/dom.js')
-rw-r--r-- | framework/Web/Javascripts/extended/dom.js | 232 |
1 files changed, 0 insertions, 232 deletions
diff --git a/framework/Web/Javascripts/extended/dom.js b/framework/Web/Javascripts/extended/dom.js index f29cf37d..21016b03 100644 --- a/framework/Web/Javascripts/extended/dom.js +++ b/framework/Web/Javascripts/extended/dom.js @@ -5,235 +5,3 @@ Object.extend(Element, { }
});
-Prado.Element =
-{
- /**
- * Set the value of a particular element.
- * @param string element id
- * @param string new element value.
- */
- setValue : function(element, value)
- {
- var el = $(element);
- if(el && typeof(el.value) != "undefined")
- el.value = value;
- },
-
- select : function(element, method, value)
- {
- var el = $(element);
- var isList = element.indexOf('[]') > -1;
- if(!el && !isList) return;
- method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
- var selection = Prado.Element.Selection;
- if(isFunction(selection[method]))
- selection[method](isList ? element : el,value);
- },
-
- click : function(element)
- {
- var el = $(element);
- //Logger.info(el);
- if(!el) return;
- if(document.createEvent)
- {
- var evt = document.createEvent('HTMLEvents');
- evt.initEvent('click', true, true);
- el.dispatchEvent(evt);
- //Logger.warn("dispatching click for "+el.id);
- }
- else if(el.fireEvent)
- {
- el.fireEvent('onclick');
- if(isFunction(el.onclick))
- el.onclick();
- }
- },
-
- setAttribute : function(element, attribute, value)
- {
- var el = $(element);
- if(attribute == "disabled" && value==false)
- el.removeAttribute(attribute);
- else
- el.setAttribute(attribute, value);
- },
-
- setOptions : function(element, options)
- {
- var el = $(element);
- if(el && el.tagName.toLowerCase() == "select")
- {
- while(el.length > 0)
- el.remove(0);
- for(var i = 0; i<options.length; i++)
- el.options[el.options.length] = new Option(options[i][0],options[i][1]);
- }
- },
-/**
- * A delayed focus on a particular element
- * @param {element} element to apply focus()
- */
- focus : function(element)
- {
- var obj = $(element);
- if(isObject(obj) && isdef(obj.focus))
- setTimeout(function(){ obj.focus(); }, 100);
- return false;
- }
-}
-
-Prado.Element.Selection =
-{
- inputValue : function(el, value)
- {
- switch(el.type.toLowerCase())
- {
- case 'checkbox':
- case 'radio':
- return el.checked = value;
- }
- },
-
- selectValue : function(el, value)
- {
- $A(el.options).each(function(option)
- {
- option.selected = option.value == value;
- });
- },
-
- selectIndex : function(el, index)
- {
- if(el.type == 'select-one')
- el.selectedIndex = index;
- else
- {
- for(var i = 0; i<el.length; i++)
- {
- if(i == index)
- el.options[i].selected = true;
- }
- }
- },
-
- selectClear : function(el)
- {
- el.selectedIndex = -1;
- },
-
- selectAll : function(el)
- {
- $A(el.options).each(function(option)
- {
- option.selected = true;
- Logger.warn(option.value);
- });
- },
-
- selectInvert : function(el)
- {
- $A(el.options).each(function(option)
- {
- option.selected = !option.selected;
- });
- },
-
- checkValue : function(name, value)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = el.value == value
- });
- },
-
- checkIndex : function(name, index)
- {
- var elements = $A(document.getElementsByName(name));
- for(var i = 0; i<elements.length; i++)
- {
- if(i == index)
- elements[i].checked = true;
- }
- },
-
- checkClear : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = false;
- });
- },
-
- checkAll : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = true;
- });
- },
- checkInvert : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = !el.checked;
- });
- }
-};
-
-
-/**
- * Alias some of the prototype functions.
- * Insert a html fragment relative to an element.
- */
-Object.extend(Prado.Element,
-{
- /**
- *
- */
- Insert :
- {
- /**
- * Insert directly after the element.
- */
- After : function(element, innerHTML)
- {
- new Insertion.After(element, innerHTML);
- },
-
- /**
- * Insert directly after the element
- */
- Before : function(element, innerHTML)
- {
- new Insertion.Before(element. innerHTML);
- },
-
- /**
- * Insert below the element container.
- */
- Below : function(element, innerHTML)
- {
- new Insertion.Bottom(element, innerHTML);
- },
-
- /**
- * Insert above the element container.
- */
- Above : function(element, innerHTML)
- {
- new Insertion.Top(element, innerHTML);
- }
- },
- CssClass :
- {
- /**
- * Set the css class name of an element.
- */
- set : function(element, cssClass)
- {
- element = new Element.ClassNames(element);
- element.set(cssClass);
- }
- }
-});
\ No newline at end of file |