Moved rico.js to minsrc and is now part of rico_min.js. Files are now sent to the...
[infodrom/rico3] / ricoClient / js / rico2jqu.js
index 07ea288..8d0447a 100644 (file)
@@ -1,5 +1,5 @@
 /**
-  *  Copyright (c) 2009 Matt Brown
+  *  Copyright (c) 2009-2011 Matt Brown
   *
   *  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
 
 if (typeof jQuery=='undefined') throw('This version of Rico requires the jQuery library');
 
+var Rico = {
+  Lib: 'jQuery',
+  LibVersion: jQuery().jquery,
+  extend: jQuery.extend,
+  trim: jQuery.trim,
+  tryFunctions: function() {
+    for (var i=0; i<arguments.length; i++) {
+      try {
+        return arguments[i]();
+      } catch(e){}
+    }
+    return null;
+  },
 
-Rico.Lib='jQuery';
-Rico.LibVersion=jQuery().jquery;
-Rico.extend=jQuery.extend;
-Rico.trim=jQuery.trim;
-Rico.tryFunctions = function() {
-  for (var i=0; i<arguments.length; i++) {
-    try {
-      return arguments[i]();
-    } catch(e){}
-  }
-  return null;
-};
+  _j: function(element) {
+    if (typeof element=='string')
+      element = document.getElementById(element);
+    return jQuery(element);
+  },
 
+  select: function(selector, element) {
+    return element ? this._j(element).find(selector) : jQuery(selector);
+  },
 
-Rico._j=function(element) {
-  if (typeof element=='string')
-    element = document.getElementById(element);
-  return jQuery(element);
-};
-  
-Rico.select=function(selector, element) {
-  return element ? this._j(element).find(selector) : jQuery(selector);
-};
-  
-Rico.eventBind=function(element, eventName, handler) {
-  this._j(element).bind(eventName, handler);
-};
+  eventBind: function(element, eventName, handler) {
+    this._j(element).bind(eventName, handler);
+  },
 
-Rico.eventUnbind=function(element, eventName, handler) {
-  this._j(element).unbind(eventName, handler);
-};
+  eventUnbind: function(element, eventName, handler) {
+    this._j(element).unbind(eventName, handler);
+  },
 
-Rico.eventHandle=function(object, method) {
-  return function(e) {
-    return object[method].call(object,e);
-  }
-};
+  eventHandle: function(object, method) {
+    return function(e) {
+      return object[method].call(object,e);
+    }
+  },
 
-Rico.eventElement=function(ev) {
-  return ev.target;
-};
+  eventElement: function(ev) {
+    return ev.target;
+  },
 
-Rico.eventClient=function(ev) {
-  return {x:ev.clientX, y:ev.clientY};
-};
+  eventClient: function(ev) {
+    return {x:ev.clientX, y:ev.clientY};
+  },
 
-Rico.eventStop=function(ev) {
-  ev.preventDefault();
-  ev.stopPropagation();
-};
-  
-Rico.addClass=function(element, className) {
-  return this._j(element).addClass(className);
-};
+  eventStop: function(ev) {
+    ev.preventDefault();
+    ev.stopPropagation();
+  },
 
-Rico.removeClass=function(element, className) {
-  return this._j(element).removeClass(className);
-};
+  addClass: function(element, className) {
+    var j=this._j(element);
+    if (!j.hasClass(className)) j.addClass(className);
+    return j;
+  },
 
-Rico.hasClass=function(element, className) {
-  return this._j(element).hasClass(className);
-};
-  
-Rico.getStyle=function(element, property) {
-  return this._j(element).css(property);
-};
-Rico.setStyle=function(element, properties) {
-  return this._j(element).css(properties);
-};
+  removeClass: function(element, className) {
+    return this._j(element).removeClass(className);
+  },
 
-/**
- * @returns available height, excluding scrollbar & margin
- */
-Rico.windowHeight=function() {
-  return jQuery(window).height();
-};
+  hasClass: function(element, className) {
+    return this._j(element).hasClass(className);
+  },
 
-/**
- * @returns available width, excluding scrollbar & margin
- */
-Rico.windowWidth=function() {
-  return jQuery(window).width();
-};
+  getStyle: function(element, property) {
+    return this._j(element).css(property);
+  },
+  setStyle: function(element, properties) {
+    return this._j(element).css(properties);
+  },
 
-Rico.positionedOffset=function(element) {
-  return this._j(element).position();
-};
+  /**
+   * @returns available height, excluding scrollbar & margin
+   */
+  windowHeight: function() {
+    return jQuery(window).height();
+  },
 
-Rico.cumulativeOffset=function(element) {
-  return this._j(element).offset();
-};
+  /**
+   * @returns available width, excluding scrollbar & margin
+   */
+  windowWidth: function() {
+    return jQuery(window).width();
+  },
 
-Rico.docScrollLeft=function() {
-  return jQuery('html').scrollLeft();
-};
+  positionedOffset: function(element) {
+    return this._j(element).position();
+  },
 
-Rico.docScrollTop=function() {
-  return jQuery('html').scrollTop();
-};
+  cumulativeOffset: function(element) {
+    return this._j(element).offset();
+  },
 
-Rico.getDirectChildrenByTag=function(element, tagName) {
-  return this._j(element).children(tagName);
-};
+  docScrollLeft: function() {
+    return jQuery('html').scrollLeft();
+  },
+
+  docScrollTop: function() {
+    return jQuery('html').scrollTop();
+  },
+
+  getDirectChildrenByTag: function(element, tagName) {
+    return this._j(element).children(tagName);
+  },
 
-Rico.ajaxRequest=function(url,options) {
-  this.jSend(url,options);
-}
+  toQueryString: jQuery.param,
+
+  // Animation
+
+  fadeIn: function(element,duration,onEnd) {
+    this._j(element).fadeIn(duration,onEnd);
+  },
+
+  fadeOut: function(element,duration,onEnd) {
+    this._j(element).fadeOut(duration,onEnd);
+  },
+
+  animate: function(element,options,properties) {
+    options.complete=options.onEnd;
+    this._j(element).animate(properties,options);
+  },
+
+  getJSON: jQuery.httpData ? function(xhr) { return jQuery.httpData(xhr,'json'); } : function(xhr) { return jQuery.parseJSON(xhr.responseText); },
+
+  ajaxRequest: function(url,options) {
+    this.jSend(url,options);
+  }
+};
 
 Rico.ajaxRequest.prototype = {
   jSend: function(url,options) {
@@ -137,35 +158,15 @@ Rico.ajaxRequest.prototype = {
     }
     this.xhr=jQuery.ajax(jOptions);
   },
-  
+
   jSuccess: function() {
     if (this.onSuccess) this.onSuccess(this.xhr);
   }
-}
-
-Rico.getJSON=function(xhr) { return jQuery.httpData(xhr,'json'); };
+};
 
 Rico.ajaxSubmit=function(form,url,options) {
   options.parameters=this._j(form).serialize();
   if (!options.method) options.method='post';
   url=url || form.action;
   new Rico.ajaxRequest(url,options);
-}
-Rico.toQueryString=jQuery.param;
-
-// Animation
-
-Rico.fadeIn=function(element,duration,onEnd) {
-  this._j(element).fadeIn(duration,onEnd);
-};
-
-Rico.fadeOut=function(element,duration,onEnd) {
-  this._j(element).fadeOut(duration,onEnd);
-};
-
-Rico.animate=function(element,options,properties) {
-  options.complete=options.onEnd;
-  this._j(element).animate(properties,options);
 };
-
-Rico._bindLoadEvent();