mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-12 05:49:42 +00:00
Monotone-Parent: 2e4c1f0cd08151845778a2d833dd35169090f1c1
Monotone-Revision: 8986a763513aaa0555e00724715459d7295739d9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-11-01T20:31:48 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2006-11-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* UI/WebServerResources/generic.js: moved extensions methods to
|
||||
DOM elements to separate files for better clarity.
|
||||
|
||||
* UI/Common/UIxPageFrame.m ([UIxPageFrame -pageContentClasses]):
|
||||
new method that returns "pageContent" as class, but also "popup"
|
||||
for the DIV where the page content lies, so that we can manipulate
|
||||
|
||||
@@ -1038,236 +1038,6 @@ function disableAnchor(anchor) {
|
||||
}
|
||||
}
|
||||
|
||||
/* custom extensions to the DOM api */
|
||||
HTMLElement.prototype.childNodesWithTag = function(tagName) {
|
||||
var matchingNodes = new Array();
|
||||
var tagName = tagName.toUpperCase();
|
||||
|
||||
for (var i = 0; i < this.childNodes.length; i++) {
|
||||
// log("(" + tagName + ") childNodes " + i + " = " + this.childNodes[i]);
|
||||
if (typeof(this.childNodes[i]) == "object"
|
||||
&& this.childNodes[i].tagName
|
||||
&& this.childNodes[i].tagName.toUpperCase() == tagName)
|
||||
matchingNodes.push(this.childNodes[i]);
|
||||
}
|
||||
|
||||
// log ("matching: " + matchingNodes.length);
|
||||
|
||||
return matchingNodes;
|
||||
}
|
||||
|
||||
HTMLElement.prototype.addClassName = function(className) {
|
||||
var classStr = '' + this.getAttribute("class");
|
||||
|
||||
position = classStr.indexOf(className, 0);
|
||||
if (position < 0) {
|
||||
classStr = classStr + ' ' + className;
|
||||
this.setAttribute('class', classStr);
|
||||
}
|
||||
}
|
||||
|
||||
HTMLElement.prototype.removeClassName = function(className) {
|
||||
var classStr = '' + this.getAttribute('class');
|
||||
|
||||
position = classStr.indexOf(className, 0);
|
||||
while (position > -1) {
|
||||
classStr1 = classStr.substring(0, position);
|
||||
classStr2 = classStr.substring(position + 10, classStr.length);
|
||||
classStr = classStr1 + classStr2;
|
||||
position = classStr.indexOf(className, 0);
|
||||
}
|
||||
|
||||
this.setAttribute('class', classStr);
|
||||
}
|
||||
|
||||
HTMLElement.prototype.hasClassName = function(className) {
|
||||
var classStr = '' + this.getAttribute('class');
|
||||
position = classStr.indexOf(className, 0);
|
||||
return (position > -1);
|
||||
}
|
||||
|
||||
HTMLElement.prototype.getParentWithTagName = function(tagName) {
|
||||
var currentElement = this;
|
||||
tagName = tagName.toUpperCase();
|
||||
|
||||
currentElement = currentElement.parentNode;
|
||||
while (currentElement
|
||||
&& currentElement.tagName != tagName) {
|
||||
currentElement = currentElement.parentNode;
|
||||
}
|
||||
|
||||
return currentElement;
|
||||
}
|
||||
|
||||
HTMLElement.prototype.cascadeLeftOffset = function() {
|
||||
var currentElement = this;
|
||||
|
||||
var offset = 0;
|
||||
while (currentElement) {
|
||||
offset += currentElement.offsetLeft;
|
||||
currentElement = currentElement.getParentWithTagName("div");
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
HTMLElement.prototype.cascadeTopOffset = function() {
|
||||
var currentElement = this;
|
||||
var offset = 0;
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (currentElement
|
||||
&& currentElement instanceof HTMLElement) {
|
||||
offset += currentElement.offsetTop;
|
||||
currentElement = currentElement.parentNode;
|
||||
i++;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
HTMLElement.prototype.dump = function(additionalInfo, additionalKeys) {
|
||||
var id = this.getAttribute("id");
|
||||
var nclass = this.getAttribute("class");
|
||||
|
||||
var str = this.tagName;
|
||||
if (id)
|
||||
str += "; id = " + id;
|
||||
if (nclass)
|
||||
str += "; class = " + nclass;
|
||||
|
||||
if (additionalInfo)
|
||||
str += "; " + additionalInfo;
|
||||
|
||||
if (additionalKeys)
|
||||
for (var i = 0; i < additionalKeys.length; i++) {
|
||||
var value = this.getAttribute(additionalKeys[i]);
|
||||
if (value)
|
||||
str += "; " + additionalKeys[i] + " = " + value;
|
||||
}
|
||||
|
||||
log (str);
|
||||
}
|
||||
|
||||
HTMLElement.prototype.getSelectedNodes = function() {
|
||||
var selArray = new Array();
|
||||
|
||||
for (var i = 0; i < this.childNodes.length; i++) {
|
||||
node = this.childNodes.item(i);
|
||||
if (node.nodeType == 1
|
||||
&& isNodeSelected(node))
|
||||
selArray.push(node);
|
||||
}
|
||||
|
||||
return selArray;
|
||||
}
|
||||
|
||||
HTMLElement.prototype.getSelectedNodesId = function() {
|
||||
var selArray = new Array();
|
||||
|
||||
for (var i = 0; i < this.childNodes.length; i++) {
|
||||
node = this.childNodes.item(i);
|
||||
if (node.nodeType == 1
|
||||
&& isNodeSelected(node))
|
||||
selArray.push(node.getAttribute("id"));
|
||||
}
|
||||
|
||||
return selArray;
|
||||
}
|
||||
|
||||
HTMLTableElement.prototype.getSelectedRows = function() {
|
||||
var tbody = (this.getElementsByTagName('tbody'))[0];
|
||||
|
||||
return tbody.getSelectedNodes();
|
||||
}
|
||||
|
||||
HTMLTableElement.prototype.getSelectedRowsId = function() {
|
||||
var tbody = (this.getElementsByTagName('tbody'))[0];
|
||||
|
||||
return tbody.getSelectedNodesId();
|
||||
}
|
||||
|
||||
HTMLTableElement.prototype.selectRowsMatchingClass = function(className) {
|
||||
var tbody = (this.getElementsByTagName('tbody'))[0];
|
||||
var nodes = tbody.childNodes;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes.item(i);
|
||||
if (node instanceof HTMLElement) {
|
||||
var classStr = '' + node.getAttribute("class");
|
||||
if (classStr.indexOf(className, 0) >= 0)
|
||||
selectNode(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HTMLTableElement.prototype.deselectAll = function() {
|
||||
var nodes = this.getSelectedRows();
|
||||
for (var i = 0; i < nodes.length; i++)
|
||||
deselectNode(nodes[i]);
|
||||
}
|
||||
|
||||
HTMLUListElement.prototype.getSelectedRows = function() {
|
||||
return this.getSelectedNodes();
|
||||
}
|
||||
|
||||
HTMLUListElement.prototype.getSelectedRowsId = function() {
|
||||
return this.getSelectedNodesId();
|
||||
}
|
||||
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/(^\s+|\s+$)/g, '');
|
||||
}
|
||||
|
||||
String.prototype.capitalize = function() {
|
||||
return this.replace(/\w+/g,
|
||||
function(a) {
|
||||
return ( a.charAt(0).toUpperCase()
|
||||
+ a.substr(1).toLowerCase() );
|
||||
});
|
||||
}
|
||||
|
||||
String.prototype.decodeEntities = function() {
|
||||
return this.replace(/&#(\d+);/g,
|
||||
function(wholematch, parenmatch1) {
|
||||
return String.fromCharCode(+parenmatch1);
|
||||
});
|
||||
}
|
||||
|
||||
HTMLInputElement.prototype._replicate = function() {
|
||||
if (this.replica) {
|
||||
this.replica.value = this.value;
|
||||
var onReplicaChangeEvent = document.createEvent("Event");
|
||||
onReplicaChangeEvent.initEvent("change", true, true);
|
||||
this.replica.dispatchEvent(onReplicaChangeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
HTMLInputElement.prototype.assignReplica = function(otherInput) {
|
||||
if (!this._onChangeBound) {
|
||||
this.addEventListener("change", this._replicate, false);
|
||||
this._onChangeBound = true;
|
||||
}
|
||||
this.replica = otherInput;
|
||||
}
|
||||
|
||||
HTMLSelectElement.prototype._replicate = function() {
|
||||
if (this.replica) {
|
||||
this.replica.value = this.value;
|
||||
var onReplicaChangeEvent = document.createEvent("Event");
|
||||
onReplicaChangeEvent.initEvent("change", true, true);
|
||||
this.replica.dispatchEvent(onReplicaChangeEvent);
|
||||
}
|
||||
}
|
||||
|
||||
HTMLSelectElement.prototype.assignReplica = function(otherSelect) {
|
||||
if (!this._onChangeBound) {
|
||||
this.addEventListener("change", this._replicate, false);
|
||||
this._onChangeBound = true;
|
||||
}
|
||||
this.replica = otherSelect;
|
||||
}
|
||||
|
||||
function d2h(d) {
|
||||
var hD = "0123456789abcdef";
|
||||
var h = hD.substr(d&15,1);
|
||||
@@ -1298,44 +1068,3 @@ function indexColor(number) {
|
||||
+ d2h((256 / colorTable[1]) - 1)
|
||||
+ d2h((256 / colorTable[0]) - 1));
|
||||
}
|
||||
|
||||
// function BatchAjaxRequest()
|
||||
// {
|
||||
// this.init();
|
||||
|
||||
// return this;
|
||||
// }
|
||||
|
||||
// BatchAjaxRequest.prototype.init = function() {
|
||||
// this.urls = null;
|
||||
// this.currentUrl = 0;
|
||||
// this.requestsLeft = 0;
|
||||
// this.returnCodes = new Array();
|
||||
// this.state = "waiting";
|
||||
// this.callback = null;
|
||||
// this.callbackData = null;
|
||||
// }
|
||||
|
||||
// BatchAjaxRequest.prototype.setUrls = function(urls) {
|
||||
// this.urls = urls;
|
||||
// }
|
||||
|
||||
// BatchAjaxRequest.prototype.setCallback = function(callback, callbackData) {
|
||||
// this.callback = callback;
|
||||
// this.callbackData = callbackData;
|
||||
// }
|
||||
|
||||
// BatchAjaxRequest.prototype._handler = function(http) {
|
||||
// if (
|
||||
// this.requestsLeft--;
|
||||
// if (this.requestsLeft == 0
|
||||
// && this.callback)
|
||||
// this.callback(this, callbackData);
|
||||
// }
|
||||
|
||||
// BatchAjaxRequest.prototype.run = function() {
|
||||
// this.requestsLeft = this.urls.length;
|
||||
// this.currentUrl = 0;
|
||||
// }
|
||||
|
||||
// test = new BatchAjaxRequest();
|
||||
|
||||
Reference in New Issue
Block a user