Permalink
Browse files

initial commit but old project :)

  • Loading branch information...
0 parents commit 54eb1626e5ad13734b139a6b67a49610e2689d1c @rgaidot committed Dec 12, 2010
16 LICENSE
@@ -0,0 +1,16 @@
+Copyright (c) 2007 Exalead
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
@@ -0,0 +1,9 @@
+# Minidom
+
+Minidom is a javascript framework built on top of prototypejs (http://www.prototypejs.org/). It is designed to create complex web applications using the HMVC (Hierarchical-Model-View-Controller) pattern.
+
+# CREDITS
+
+R. Gaidot, S. Jaïs, G. Esquevin, V. Jauneau, E.Albert
+
+Copyright (c) 2007 Exalead
@@ -0,0 +1,8 @@
+var Browser =
+{
+ userAgent: function() {
+ return navigator.userAgent;
+ }
+};
+
+
@@ -0,0 +1,42 @@
+var BrowserClasses = Class.create();
+Object.extend(BrowserClasses, {
+ userAgents: $H({
+ "ie6": /MSIE 6/i,
+ "ie7": /MSIE 7/i,
+ "ie": /MSIE/i,
+ "nopng": /MSIE 6/i,
+ "safari": /safari/i,
+ "opera": /opera/i,
+ "firefox": /firefox/i,
+ "windows": /windows/i,
+ "macintosh": /macintosh/i
+ }),
+ _userAgentCache: undefined,
+ _languageCache: undefined,
+ getLanguageClasses: function() {
+ return [Locale.current.language, Locale.current.country, Locale.current.code];
+ },
+ getUserAgentClasses: function() {
+ if (!BrowserClasses._cache) {
+ var ua = Browser.userAgent();
+ var result = $A();
+ BrowserClasses.userAgents.each(function(pair){
+ if (pair.value.test(ua,"i")) {
+ result.push(pair.key);
+ }
+ });
+ BrowserClasses._cache = result;
+ }
+ return BrowserClasses._cache;
+ },
+ setLanguageClasses: function(element) {
+ BrowserClasses.getLanguageClasses().each(function(cls) {
+ Element.addClassName(element,cls);
+ });
+ },
+ setUserAgentClasses: function(element) {
+ BrowserClasses.getUserAgentClasses().each(function(cls) {
+ Element.addClassName(element,cls);
+ });
+ }
+});
@@ -0,0 +1,70 @@
+var Component = {};
+Component.create = function(prototype) {
+ var cls;
+ cls = function() {
+ var self = $E("div");
+ var _debugKey;
+ try {
+ for (var key in this) {
+ _debugKey = key;
+ self[key] = this[key];
+ }
+ } catch(e) {
+ console.log("Key '"+_debugKey+"' is already a reserved DOM keyword");
+ }
+ Object.extend(self, CallbackManager);
+ self.initialize.apply(self, arguments);
+ Element.addClassName(self,Component.getClassName(cls));
+ return self;
+ }
+ if (prototype) {
+ Object.extend(cls.prototype,prototype);
+ }
+ return cls;
+}
+
+Component.getClassName = function(cls) {
+ if (!cls.className) {
+ for (var key in window) {
+
+ if (window[key] == cls) {
+ cls.className = key;
+ break;
+ }
+ }
+ }
+ return cls.className;
+}
+
+var CallbackManager = {
+ _listen: function(name, callback, clean){
+ if (!this._callbacks)
+ this._callbacks = $H();
+ if(!this._callbacks[name] || clean){
+ this._callbacks[name] = new Array();
+ }
+ this._callbacks[name].push(callback);
+ },
+ listen: function(){
+ if(typeof(arguments[0]) == typeof("")){
+ this._listen(arguments[0], arguments[1], arguments[2]);
+ }else{
+ $H(arguments[0]).each(function(pair){
+ if (/^on/.test(pair.key))
+ this._listen(pair.key, pair.value);
+ }.bind(this));
+ }
+ },
+ fire: function(name){
+ if(this._callbacks && this._callbacks[name]){
+ for(var i = 0; i < this._callbacks[name].length; i++){
+ // passing trigger + arguments to callback function
+ var args = $A(arguments);
+ args[0] = this; // replacing event name by trigger object
+ if(this._callbacks[name][i].apply(this, args) == false) return false;
+ }
+ }
+ return true;
+ }
+};
+
@@ -0,0 +1,8 @@
+TestSuite.add("ExampleTest", {
+ testFoo: function() {
+ with(this) {
+ assertEqual("foo", "foo");
+ }
+ }
+});
+
@@ -0,0 +1,11 @@
+window.MinidomException = Class.create();
+
+/**
+ * instance methods
+ */
+Object.extend(window.MinidomException.prototype, {
+ initialize: function(name, message) {
+ this.name = name;
+ this.message = message;
+ }
+});
@@ -0,0 +1,13 @@
+Object.impl = function(cls, interf) {
+ var interfaceMembers = $H(interf).keys();
+ var classMembers = $A();
+ for (var m in cls.prototype) {
+ classMembers.push(m);
+ }
+ interfaceMembers.each(function(member){
+ if (-1 == classMembers.indexOf(member)) {
+ throw "Class [" + classMembers.inspect() + "] does not implement "+member;
+ }
+ });
+
+}
@@ -0,0 +1,18 @@
+var Locale = Class.create();
+Object.extend(Locale.prototype, {
+ initialize: function(language, country) {
+ var toks = $A(language.split(/[-_]+/));
+ if (toks.length > 1) {
+ this.language = toks[0];
+ this.country = toks[1];
+ } else {
+ this.language = language;
+ this.country = country;
+ }
+ this.code = this.language + (this.country?"_"+this.country:"");
+ }
+});
+
+Locale.setCurrent = function(language, country) {
+ Locale.current = new Locale(language, country);
+}
@@ -0,0 +1,14 @@
+TestSuite.add("LocaleTest", {
+ testCreateLocale: function() {
+ with(this) {
+ var l = new Locale("en_US");
+ assertEqual("en", l.language);
+ assertEqual("US", l.country);
+
+ l = new Locale("en","US");
+ assertEqual("en", l.language);
+ assertEqual("US", l.country);
+ }
+ }
+});
+
Oops, something went wrong.

0 comments on commit 54eb162

Please sign in to comment.