Skip to content

Commit

Permalink
change namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
blackout314 committed Dec 10, 2014
1 parent be2c90a commit a9d2150
Show file tree
Hide file tree
Showing 3 changed files with 361 additions and 321 deletions.
85 changes: 47 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ pi('#id')
pii('.class')
```

### Class manipulation
```javascript
pi.classAdd('#try', 'newClass');
pii.classAdd('.class', 'newClass');
```

### jQuery style .ready
```javascript
pi.ready(function(){
});
```


### Listener
```javascript
var listener = function(e) { console.log(e); };
Expand All @@ -27,56 +40,62 @@ pii('.class').on('click',listener);
pii('#try .sub')[0].on('mouseover',listener);
```

### Class manipulation
#### Event Listeners Manager
```javascript
pi.classAdd('#try', 'newClass');
pii.classAdd('.class', 'newClass');
```
var a = function(){ console.log('a'); };
var b = function(){ console.log('b'); };

### jQuery style .ready
```javascript
pi.ready(function(){
});
pi.E.on( '#one', 'click', a );
pi.E.on( '#one', 'click', b );

// when click on #one -> print a \n b

// remove all click listeners

pi.E.purge( '#one', 'click' );
```

### Pub/Sub Notifier

### Topics Pub/Sub Notifier
```javascript
var callback = function(a){ console.log('LOG: '+a); };
pi.sub('NOTICE', callback);

pi.pub('NOTICE',['hello']);
pi.unsub({'topic':'NOTICE','callback':callback});
pi.pub('NOTICE',['hello']);
pi.T.sub('NOTICE', callback);
pi.T.pub('NOTICE',['hello']);
pi.T.unsub({'topic':'NOTICE','callback':callback});
pi.T.pub('NOTICE',['hello']);
```


### LocalStorage
```javascript
pi.storage.set('key','value');
pi.S.set('key','value');
```

### Namespace on LocalStorage
#### Namespace on LocalStorage
```javascript
var hello = pi.storage.namespace('hello');
var hello = pi.S.namespace('hello');
hello.set('key','value'); // set key
hello.get('key'); // get key
```


### AjaxCall
```javascript
var ok = function (data) { console.log(data); };
pi.ajax( {
pi.A({
type:'GET',
url:'example.json',
success:ok
} );
});
```


### Routes
```javascript
var ok = function (action,arg1,arg2) { console.log(arg1); };
pi.route.add('news', ok); -> hash -> #!/news/arg1/arg2
pi.R.add('news', ok); -> hash -> #!/news/arg1/arg2

pi.route.bundle( [
pi.R.bundle( [
{
route:'news',
callback:function(){ alert('news'); }
Expand All @@ -86,37 +105,27 @@ pi.route.bundle( [
callback:function(){ alert('defaultAction'); }
}
] );
pi.route.start('defaultAction');
pi.R.start('defaultAction');
```

### Event Listeners Manager
```javascript
var a = function(){ console.log('a'); };
var b = function(){ console.log('b'); };

pi.event.on( '#one', 'click', a );
pi.event.on( '#one', 'click', b );

// when click on #one -> print a \n b

pi.event.purge( '#one', 'click' ); // remove all click listeners
```
## Questions

##Why
###Why
In the amazing javascript world we'll found many great framework, but this is the _mine_.
I hate IE and i have no plans to support it.
IE is a ugly program (i call him virus/malware).

##Who
###Who
I'm a humble javascript coder

##What
###What
Make website smart and amazing

##Where
###Where
Github!

##Browser support:
###Browser support:
- Firefox 3.5+
- Opera 9+
- Safari 4+
Expand Down
Loading

0 comments on commit a9d2150

Please sign in to comment.