web/data/cubicweb.htmlhelpers.js
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 18 Mar 2010 14:06:53 +0100
branchstable
changeset 4941 ec27aea9632b
parent 3781 c7ef58db0e4b
child 5477 f79c39be0b9b
permissions -rw-r--r--
[sql] fix FSPATH implementation plpy.execute() returns a list of dictionaries with column names as keys and corresponding values as values.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
CubicWeb.require('python.js');
2338
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
     2
CubicWeb.require('jquery.corner.js');
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     4
/* returns the document's baseURI. (baseuri() uses document.baseURI if
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
 * available and inspects the <base> tag manually otherwise.)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     6
*/
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
function baseuri() {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
    var uri = document.baseURI;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
    if (uri) { // some browsers don't define baseURI
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
	return uri;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    11
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    12
    var basetags = document.getElementsByTagName('base');
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    13
    if (basetags.length) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    14
	return getNodeAttribute(basetags[0], 'href');
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
    return '';
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
2357
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
    20
/* set body's cursor to 'progress' */
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
function setProgressCursor() {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
    var body = document.getElementsByTagName('body')[0];
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
    body.style.cursor = 'progress';
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
2357
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
    26
/* reset body's cursor to default (mouse cursor). The main
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
 * purpose of this function is to be used as a callback in the
2357
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
    28
 * deferreds' callbacks chain. */
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
function resetCursor(result) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    var body = document.getElementsByTagName('body')[0];
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
    body.style.cursor = 'default';
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    // pass result to next callback in the callback chain
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
    return result;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
function updateMessage(msg) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
    var msgdiv = DIV({'class':'message'});
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
    // don't pass msg to DIV() directly because DIV will html escape it
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
    // and msg should alreay be html escaped at this point.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
    msgdiv.innerHTML = msg;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
    jQuery('#appMsg').removeClass('hidden').empty().append(msgdiv);
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
/* builds an url from an object (used as a dictionnary)
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    45
 *
1419
7ff24154351d javascript + json refactoring
sylvain.thenault@logilab.fr
parents: 30
diff changeset
    46
 * >>> asURL({'rql' : "RQL", 'x': [1, 2], 'itemvid' : "oneline"})
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
 * rql=RQL&vid=list&itemvid=oneline&x=1&x=2
3781
c7ef58db0e4b [javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3494
diff changeset
    48
 * >>> asURL({'rql' : "a&b", 'x': [1, 2], 'itemvid' : "oneline"})
c7ef58db0e4b [javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3494
diff changeset
    49
 * rql=a%26b&x=1&x=2&itemvid=oneline
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
 */
1419
7ff24154351d javascript + json refactoring
sylvain.thenault@logilab.fr
parents: 30
diff changeset
    51
function asURL(props) {
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
    var chunks = [];
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    53
    for(key in props) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
	var value = props[key];
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
	// generate a list of couple key=value if key is multivalued
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
	if (isArrayLike(value)) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
	    for (var i=0; i<value.length;i++) {
3781
c7ef58db0e4b [javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3494
diff changeset
    58
		chunks.push(key + '=' + urlEncode(value[i]));
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
	    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
	} else {
3781
c7ef58db0e4b [javascript] asURL now escapes request arguments
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3494
diff changeset
    61
	    chunks.push(key + '=' + urlEncode(value));
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
	}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
    return chunks.join('&');
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    67
/* return selected value of a combo box if any
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
 */
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
function firstSelected(selectNode) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
    var selection = filter(attrgetter('selected'), selectNode.options);
2357
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
    71
    return (selection.length > 0) ? getNodeAttribute(selection[0], 'value'):null;
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
/* toggle visibility of an element by its id
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
 */
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
function toggleVisibility(elemId) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
    jqNode(elemId).toggleClass('hidden');
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    80
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    81
/* toggles visibility of login popup div */
2385
8fa16dc4b8c8 [js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2378
diff changeset
    82
// XXX used exactly ONCE in basecomponents
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    83
function popupLoginBox() {
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    84
    toggleVisibility('popupLoginBox');
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    85
    jQuery('#__login:visible').focus();
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    86
}
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    87
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    89
/* returns the list of elements in the document matching the tag name
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
 * and the properties provided
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    91
 *
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
 * @param tagName the tag's name
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
 * @param properties a js Object used as a dict
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
 * @return an iterator (if a *real* array is needed, you can use the
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
 *                      list() function)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
 */
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
function getElementsMatching(tagName, properties, /* optional */ parent) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    98
    parent = parent || document;
2357
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
    99
    return filter(function elementMatches(element) {
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
   100
                     for (prop in properties) {
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
   101
                       if (getNodeAttribute(element, prop) != properties[prop]) {
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
   102
	                 return false;}}
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
   103
                    return true;},
e65e352cfde3 [htmlhelpers] notes about seemingly unused functions (remove for cw 3.4 ?), cleanup a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2355
diff changeset
   104
                  parent.getElementsByTagName(tagName));
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
/*
29
7d14f1eadded fix focus problems on login inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
   108
 * sets checked/unchecked status of checkboxes
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
 */
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   110
function setCheckboxesState(nameprefix, checked){
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   111
    // XXX: this looks in *all* the document for inputs
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
    var elements = getElementsMatching('input', {'type': "checkbox"});
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   113
    filterfunc = function(cb) { return nameprefix && cb.name.startsWith(nameprefix); };
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
    forEach(filter(filterfunc, elements), function(cb) {cb.checked=checked;});
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   115
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   116
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   117
function setCheckboxesState2(nameprefix, value, checked){
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   118
    // XXX: this looks in *all* the document for inputs
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   119
    var elements = getElementsMatching('input', {'type': "checkbox"});
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   120
    filterfunc = function(cb) { return nameprefix && cb.name.startsWith(nameprefix) && cb.value == value; };
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   121
    forEach(filter(filterfunc, elements), function(cb) {cb.checked=checked;});
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   124
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   125
/* this function is a hack to build a dom node from html source */
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
function html2dom(source) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
    var tmpNode = SPAN();
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
    tmpNode.innerHTML = source;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
    if (tmpNode.childNodes.length == 1) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
	return tmpNode.firstChild;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   131
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
    else {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
	// we leave the span node when `source` has no root node
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   134
	// XXX This is cleary not the best solution, but css/html-wise,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
	///    a span not should not be too  much disturbing
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   136
	return tmpNode;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   137
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   138
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   139
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
// *** HELPERS **************************************************** //
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
function rql_for_eid(eid) { return 'Any X WHERE X eid ' + eid; }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
function isTextNode(domNode) { return domNode.nodeType == 3; }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   144
function isElementNode(domNode) { return domNode.nodeType == 1; }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
function autogrow(area) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
    if (area.scrollHeight > area.clientHeight && !window.opera) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
	if (area.rows < 20) {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
	    area.rows += 2;
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
	}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
    }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
//============= page loading events ==========================================//
2338
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   154
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   155
CubicWeb.rounded = [
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   156
		    ['div.sideBoxBody', 'bottom 6px'],
3494
ed9501fb1152 cleanup unused
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2385
diff changeset
   157
		    ['div.boxTitle, div.sideBoxTitle, th.month', 'top 6px']
2338
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   158
		    ];
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   159
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   160
function roundedCorners(node) {
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   161
    node = jQuery(node);
2355
359903ef980a for some reason, use of an anonymous function makes things more readable
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2338
diff changeset
   162
    for(var r=0; r < CubicWeb.rounded.length; r++) {
2338
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   163
       node.find(CubicWeb.rounded[r][0]).corner(CubicWeb.rounded[r][1]);
3f7c7fbae94e call postAjaxLoad in reloadComponent; add corners only on reloaded elements
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2232
diff changeset
   164
    }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
}
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
2385
8fa16dc4b8c8 [js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2378
diff changeset
   167
jQuery(document).ready(function () {roundedCorners(this.body);});
8fa16dc4b8c8 [js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2378
diff changeset
   168
8fa16dc4b8c8 [js] shrink htmlhelpers, extract massmailing functionality, jslint
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2378
diff changeset
   169
CubicWeb.provide('corners.js');
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
CubicWeb.provide('htmlhelpers.js');