mu(inheritance) : smal(lest?) inheritance javascript framework

µ(inheritance) allows :

  • inheritance between function (class)
  • multi-inheritance (but not recommended ;-))
  • to declare and use a constructor otherwise, you have an abstract class (unable to instantiate)
  • calling parent constructor (constructor name = function (class) name)
  • to test type of an object
  • using private variables without side effects with inheritance

This source code (<30 lines of code) is largely inspired by those books :

  • Javascript patterns - Stoyan Stefanov
  • JavaScript : the Good Parts - Douglas Crockford
  • Javascript cookbook - Shelley Powers
  • Pragmatic Guide to JavaScript - Christophe Porteneuve

I was guided by three rules :

  • module pattern
  • functional inheritance pattern
  • no prototype

and a "desire" : each class has a constructor (and be able to call her parent's constructor).

Explanation :

µ(inheritance) source code :

JoApp StarterKit (II) : Split view version

A little add-on to JoApp starterkit : "splitview version of joapp starterkit for ipad"
... for iOS lovers :-)


Code here :

JoApp StarterKit

I started a Starterkit for JoApp for beginners. It is a set of simple "stack cards" easily reusable. For now, you will find the cards using the following components:

Two columns iPad layout template for SenchaTouch

Hi, this is a little piece of javascript code for Sencha. The aim is to have a two columns layered screen like that :

.
Main screen structure is like that :

And now ... javascript code :

Html code :

Nice and very simple, isn't it ? ;-)

Have a nice day.
@+P.

Two columns iPad layout template for JoApp

This morning i've played again with Jo. The result is a "Two columns iPad layout template" for JoApp.
You can download it here : https://gist.github.com/718801.
If you want an "iPad look", i've modified my previous css sheet (cf. post : Ipad css sheet for JoApp ) (little update about stack transitions), you can download it here : https://gist.github.com/718804.

It looks like that with standard Jo css sheet :

and with ipad css sheet :

Prototype = evil ? (javascript)

When i want create a "pseudo" class with javascript from scratch (ie without any framework like mootools), i use this :

	function animal(){
		var name = "?";
		this.getName=function(){return name;}
		this.setName=function(value){name=value;}

	}

	var a1 = new animal();
	var a2 = new animal();
	
	a1.setName("Aglaë");
	a2.setName("Sidonie");
	
	console.log(a1.getName()+' and '+a2.getName());

and the result is :

Aglaë and Sidonie

Ok, fine, it's normal.

Update of last article about OOJS

I've updated my last article about javascript.

To instantiate objects, instead of use this very bad code :

	var s_arguments="";
	//get arguments
	for(var i=0; i<arguments.length;i++){s_arguments=s_arguments+"arguments["+i+"]"+",";}
	//put arguments in a string
	s_arguments = s_arguments.substring(0,s_arguments.length-1);
	
	//Call "constructor" with parameters
	eval("myObject."+constructor_name+"("+s_arguments+");");
	//I know, eval is evil ;-)
	
	//return instance
	return myObject;

use this :

Thanks to the "future" really good book of John Resig "Secrets of the JavaScript Ninja" (http://www.manning.com/resig/) i've found the "true way" : .apply()

			if(constructor_name!=null){ 	
				myObject[constructor_name].apply(myObject,arguments);
            }

No more eval() ;-), more beautiful code

Ugly but useful object oriented javascript notation

Hello, first of all, two things/points(?) :

  • on the right hand : i try to improve my english, so sorry for the readers (and Google Translate is my friend)
  • on the other hand : i'm not a javascript ninja

We are going to create a framework "à la MooTools".
how to have an almost "real" object-oriented notation in javascript ?
Be careful : The objective of this paper is primarily to "play" with javascript. I'm not sure my code is very clean ;-)

Simple JSON Object : create instance :

Ipad css sheet for JoApp

Yesterday, i've played with Jo, css and iPad. I need Jo css for iPad. Then this is my work (i'm not a css ninja but it seems working) :

You can test it here : http://www.k33g.org/m/test.html
An download it here : http://www.k33g.org/m/ipad4jo.css
You need also this png file : http://www.k33g.org/m/ipad_expando.png

SenchaTouch en ... 10 minutes, 1/4 d'heure

Dans la lignée des mini-tutos javascript dédiés "webapps mobiles", aujourd'hui, nous allons parler de SenchaTouch. SenchaTouch est un framework javascript destiné à créer des webapps mobiles pour les types majeures de terminaux.
SenchaTouch n'est pas open-source, il y a une licence à payer, mais quand on voit la qualité du rendu final (difficile de faire la distinction avec une application native), l'ensemble des composants, le comportement de l'ihm, etc. …, cela est compréhensible (le prix).


Warning: INSERT command denied to user 'kgkyojmt001'@'10.0.75.16' for table 'drp_watchdog' query: INSERT INTO drp_watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";s:12:\"user warning\";s:8:\"%message\";s:349:\"INSERT command denied to user &#039;kgkyojmt001&#039;@&#039;10.0.75.16&#039; for table &#039;drp_accesslog&#039;\nquery: INSERT INTO drp_accesslog (title, path, url, hostname, uid, sid, timer, timestamp) values(&#039;&#039;, &#039;node&#039;, &#039;&#039;, &#039;23.22.212.158&#039;, 0, &#039;9165f55f7c8a2061a16fb6542bf1fa4a&#039;, 1393, 1368915988)\";s:5:\"%file\";s:60:\"/homez.312/kgkyojmt/www/modules/statistics/statistics.module\";s:5:\"%line\";i:64;}', 3, '', 'http://www. in /homez.312/kgkyojmt/www/includes/database.mysql.inc on line 128

Warning: INSERT command denied to user 'kgkyojmt001'@'10.0.75.16' for table 'drp_watchdog' query: INSERT INTO drp_watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";s:12:\"user warning\";s:8:\"%message\";s:878:\"UPDATE command denied to user &#039;kgkyojmt001&#039;@&#039;10.0.75.16&#039; for table &#039;drp_sessions&#039;\nquery: UPDATE drp_sessions SET uid = 0, cache = 0, hostname = &#039;23.22.212.158&#039;, session = &#039;messages|a:1:{s:5:\\&quot;error\\&quot;;a:1:{i:0;s:439:\\&quot;user warning: INSERT command denied to user &amp;#039;kgkyojmt001&amp;#039;@&amp;#039;10.0.75.16&amp;#039; for table &amp;#039;drp_accesslog&amp;#039;\\nquery: INSERT INTO drp_accesslog (title, path, url, hostname, uid, sid, timer, timestamp) va in /homez.312/kgkyojmt/www/includes/database.mysql.inc on line 128