js/core/elem/elem.js in rsence-pre-2.1.0.21 vs js/core/elem/elem.js in rsence-pre-2.1.8.0
- old
+ new
@@ -10,10 +10,16 @@
* An object that contains the browser types detected as booleans.
**/
var//RSence.Core
BROWSER_TYPE = {
+/* Any browser on Mac OS X */
+ mac: false,
+
+/* Any browser on Windows */
+ win: false,
+
/* Any version of Microsoft Internet Explorer */
ie: false,
/* Microsoft Internet Explorer version 6 */
ie6: false,
@@ -772,11 +778,10 @@
_currTodo = _attrTodo.splice(0, _iMax);
for (i = 0; i !== _iMax; i++) {
_key = _currTodo.pop();
_val = _attrCache[_key];
_elem.setAttribute(_key, _val);
- //_elem[_key]=_val;
}
},
/** = Description
* Gets a named element attribute.
@@ -825,11 +830,11 @@
setAttr: function(_id, _key, _value, _bypass) {
var _this = ELEM,
_attrTodo = _this._attrTodo[_id],
_attrCache = _this._attrCache[_id],
_differs = _value !== _this.getAttr(_id, _key);
- if (_differs) {
+ if (_differs || _bypass) {
_attrCache[_key] = _value;
if (_bypass) {
_this._elements[_id].setAttribute(_key, _value);
}
else {
@@ -1041,15 +1046,19 @@
* (Optional, default: 0; the document body)
*
* +_tagName+:: The tag name of the element.
* (Optional, default: 'DIV')
*
+ * +_options+:: Options to set before appending child to parent.
+ * Supported option attrs: [[key,value],[key,value]]
+ * (Optional, rarely necessary except when creating IMG tags)
+ *
* = Returns
* The new ELEM ID.
*
**/
- make: function(_targetId, _tagName) {
+ make: function(_targetId, _tagName, _options) {
if (_targetId === undefined) {
_targetId = 0;
}
if (_tagName === undefined) {
_tagName = 'DIV';
@@ -1082,13 +1091,26 @@
return _id;
}
}
}
_elem = document.createElement(_tagName);
- _this._elements[_targetId].appendChild(_elem);
_id = _this._add(_elem);
_this._initCache(_id);
+ if(_options!==undefined){
+ if(_options.attrs){
+ var
+ i = 0,
+ _key, _value;
+ for( ; i<_options.attrs.length; i++ ){
+ _key = _options.attrs[i][0];
+ _value = _options.attrs[i][1];
+ _elem[_key] = _value;
+ _this.setAttr( _id, _key, _value );
+ }
+ }
+ }
+ _this._elements[_targetId].appendChild(_elem);
return _id;
},
/** = Description
* Returns the inner size of the browser window.
@@ -1256,24 +1278,28 @@
}
},
/* Checks browser versions and starts the document load check */
_warmup: function() {
- var _this = ELEM,
- _ua = navigator.userAgent,
- _isIE = (document.all && (_ua.indexOf("Opera") === -1)),
- _browserType = BROWSER_TYPE;
+ var
+ _this = ELEM,
+ _ua = navigator.userAgent,
+ _isIE = (document.all && (_ua.indexOf("Opera") === -1)),
+ _browserType = BROWSER_TYPE;
_browserType.opera = _ua.indexOf("Opera") !== -1;
_browserType.safari = _ua.indexOf("KHTML") !== -1;
_browserType.symbian = _ua.indexOf("SymbianOS") !== -1;
_browserType.chrome = _ua.indexOf("Chrome") !== -1;
_browserType.ie = _isIE;
_browserType.ie6 = _isIE && (_ua.indexOf("MSIE 6") !== -1);
_browserType.ie7 = _isIE && (_ua.indexOf("MSIE 7") !== -1);
_browserType.ie8 = _isIE && (_ua.indexOf("MSIE 8") !== -1);
_browserType.ie9 = _isIE && (_ua.indexOf("MSIE 9") !== -1);
+ _browserType.mac = (_ua.indexOf("Macintosh") !== -1);
+ _browserType.win = (_ua.indexOf("Windows") !== -1);
+
// Experimental; don't treat IE9 as an IE at all.
// NOTE: IE9 Beta does still not behave like a standard web browser.
// It will probably require as much tuning as earlier IE versions.
if(_browserType.ie9){
_browserType.ie = false;
@@ -1314,13 +1340,13 @@
}
document.write("<scr" + "ipt id=__ie_onload defer src=" + _ie_proto + "></scr" + "ipt>");
var _ie_script = document.getElementById("__ie_onload");
_ie_script.onreadystatechange = function() {
if ((this.readyState === "complete") && true) {
- clearTimeout(ELEM._domLoadTimer);
- ELEM._domLoadStatus = true;
- ELEM._init();
+ clearTimeout(_this._domLoadTimer);
+ _this._domLoadStatus = true;
+ _this._init();
}
};
// the event will trigger on ie, so we don't have to keep on polling:
return;
}
@@ -1351,10 +1377,10 @@
BROWSER_TYPE.symbian = document.body.innerHTML === "fastinnerhtml!";
}
_this._init();
}
else {
- _this._domLoadTimer = setTimeout('ELEM._domWaiter()', _this.ELEMTickerInterval * 10);
+ _this._domLoadTimer = setTimeout(_this._domWaiter, 10 ); // (_this.ELEMTickerInterval * 10));
}
}
};
ELEM._constructor();