Special XML conversion code for Firefox >= 20.0
[infodrom/rico3] / minsrc / rico.js
index 73ecc75..9c8e0ef 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  (c) 2005-2011 Richard Cowin (http://openrico.org)
- *  (c) 2005-2011 Matt Brown (http://dowdybrown.com)
+ *  (c) 2005-2012 Richard Cowin (http://openrico.org)
+ *  (c) 2005-2012 Matt Brown (http://dowdybrown.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  *  file except in compliance with the License. You may obtain a copy of the License at
@@ -13,7 +13,7 @@
  *  and limitations under the License.
  */
 
-Rico.Version='3.0b2';
+Rico.Version='3.0';
 Rico.theme={};
 Rico.onLoadCallbacks=[];
 Rico.windowIsLoaded=false;
@@ -23,25 +23,6 @@ Rico.inputtypes={search: 0, number: 0, range: 0, color: 0, tel: 0, url: 0, email
 Rico.windowLoaded=function() {
   this.windowIsLoaded=true;
   if (typeof Rico_CONFIG == 'object') {
-    var el = document.createElement('style');
-    document.getElementsByTagName('head')[0].appendChild(el);
-    if (!window.createPopup) { /* For Safari */
-      el.appendChild(document.createTextNode(''));
-    }
-    var s = document.styleSheets[document.styleSheets.length - 1];
-    this.addCssBackgroundRule(s,'.rico-icon',Rico_CONFIG.imgIcons,'no-repeat');
-    this.addCssBackgroundRule(s,'.ricoLG_Resize',Rico_CONFIG.imgResize,'repeat');
-    if (Rico_CONFIG.imgHeading) {
-      var repeat='repeat-x';
-      var pos='left center';
-      this.addCssBackgroundRule(s,'tr.ricoLG_hdg th',Rico_CONFIG.imgHeading,repeat,pos);
-      this.addCssBackgroundRule(s,'tr.ricoLG_hdg td',Rico_CONFIG.imgHeading,repeat,pos);
-      this.addCssBackgroundRule(s,'table.ricoLiveGrid thead td',Rico_CONFIG.imgHeading,repeat,pos);
-      this.addCssBackgroundRule(s,'table.ricoLiveGrid thead th',Rico_CONFIG.imgHeading,repeat,pos);
-      this.addCssBackgroundRule(s,'.ricoTitle',Rico_CONFIG.imgHeading,repeat,pos);
-      this.addCssBackgroundRule(s,'.Rico_accTitle',Rico_CONFIG.imgHeading,repeat,pos);
-    }
-
     if (Rico_CONFIG.enableLogging) this.enableLogging();
     if (Rico_CONFIG.enableHTML5) this._CheckInputTypes();
   }
@@ -53,23 +34,6 @@ Rico.windowLoaded=function() {
   }
 };
 
-Rico.addCssBackgroundRule=function(sheet,selector,imageUrl,repeat,position) {
-  if (!imageUrl) return;
-  this.addCssRule(sheet,selector,"background-image:url('"+imageUrl+"')");
-  this.addCssRule(sheet,selector,"background-repeat:"+repeat);
-  if (position) this.addCssRule(sheet,selector,"background-position:"+position);
-};
-
-Rico.addCssRule=function(sheet,selector,rule) {
-  if (sheet.addRule) {
-    sheet.addRule(selector, rule);
-  } else if (sheet.insertRule) {
-    sheet.insertRule (selector+" { "+rule+" }", 0);
-  } else {
-    alert('unable to add rule: '+rule);
-  }
-};
-
 // check for availability of HTML5 input types
 Rico._CheckInputTypes=function() {
   var i = document.createElement("input");
@@ -220,7 +184,13 @@ Rico.getContentAsString=function( parentNode, isEncoded ) {
 };
 
 Rico._getEncodedContent=function(parentNode) {
-  if (parentNode.innerHTML) return parentNode.innerHTML;
+  if (parentNode.innerHTML) {
+    if (Rico.isGecko && navigator.productSub >= "20100101")
+      parentNode.innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
+    else
+      return parentNode.innerHTML;
+  }
+
   switch (parentNode.childNodes.length) {
     case 0:  return "";
     case 1:  return parentNode.firstChild.nodeValue;
@@ -278,7 +248,7 @@ Rico.zFill=function(n,slen, radix) {
 Rico.keys=function(obj) {
   var objkeys=[];
   for(var k in obj)
-    objkeys.push[k];
+    objkeys.push(k);
   return objkeys;
 };
 
@@ -364,12 +334,17 @@ Rico.positionCtlOverIcon=function(ctl,icon) {
   icon=this.$(icon);
   var offsets=this.cumulativeOffset(icon);
   var scrTop=this.docScrollTop();
+  var scrLeft=this.docScrollLeft();
   var winHt=this.windowHeight();
   if (ctl.style.display=='none') ctl.style.display='block';
-  //var correction=this.isIE ? 1 : 2;  // based on a 1px border
   var correction=2;  // based on a 1px border
-  var lpad=this.nan2zero(this.getStyle(icon,'paddingLeft'));
-  ctl.style.left = (offsets.left+lpad+correction)+'px';
+  if (Rico.direction(icon) == 'rtl') {
+    //var margin=this.nan2zero(this.getStyle(icon,'marginRight'));
+    ctl.style.left = (offsets.left + icon.offsetWidth - ctl.offsetWidth)+'px';
+  } else {
+    var margin=this.nan2zero(this.getStyle(icon,'marginLeft'));
+    ctl.style.left = (offsets.left+margin+correction+scrLeft)+'px';
+  }
   var newTop=offsets.top + correction;// + scrTop;
   var ctlht=ctl.offsetHeight;
   var iconht=icon.offsetHeight;
@@ -573,7 +548,7 @@ Rico.formatNumber=function(n,fmt) {
   if (isNaN(n)) return 'NaN';
   if (typeof fmt.multiplier=='number') n*=fmt.multiplier;
   var decPlaces=typeof fmt.decPlaces=='number' ? fmt.decPlaces : 0;
-  var thouSep=typeof fmt.thouSep=='undefined' ? true : this.thouSep;
+  var thouSep=typeof fmt.thouSep=='undefined' ? true : fmt.thouSep;
   var prefix=fmt.prefix || "";
   var suffix=fmt.suffix || "";
   var negSign=typeof fmt.negSign=='string' ? fmt.negSign : "L";
@@ -600,11 +575,11 @@ Rico.formatNumber=function(n,fmt) {
  * @param fmt string specifying the output format, may be one of the following:<dl>
  * <dt>locale or localeDateTime</dt>
  *   <dd>use javascript's built-in toLocaleString() function</dd>
- * <dt>localeDate</dt>
+ * <dt>localeDate or 'Long Date'</dt>
  *   <dd>use javascript's built-in toLocaleDateString() function</dd>
  * <dt>translate or translateDateTime</dt>
  *   <dd>use the formats specified in the Rico.dateFmt and Rico.timeFmt properties</dd>
- * <dt>translateDate</dt>
+ * <dt>translateDate or 'Short Date'</dt>
  *   <dd>use the date format specified in the Rico.dateFmt property</dd>
  * <dt>Otherwise</dt>
  *   <dd>Any combination of: yyyy, yy, mmmm, mmm, mm, m, dddd, ddd, dd, d, hh, h, HH, H, nn, ss, a/p</dd>
@@ -616,12 +591,14 @@ Rico.formatDate=function(d,fmt) {
     case 'locale':
     case 'localeDateTime':
       return d.toLocaleString();
+    case 'Long Date':
     case 'localeDate':
       return d.toLocaleDateString();
     case 'translate':
     case 'translateDateTime':
       datefmt=this.dateFmt+' '+this.timeFmt;
       break;
+    case 'Short Date':
     case 'translateDate':
       datefmt=this.dateFmt;
       break;