Skip to content
/ drv.js Public

The Combined Type JavaScript MVVM / MVC / SPA Development Framework, Based on Director.js, Require.js and Vue.js.

License

Notifications You must be signed in to change notification settings

pandao/drv.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drv.js

The Combined Type JavaScript MVVM / MVC / SPA Development Framework, Based on Director.js, Require.js and Vue.js.

Install

bower install drv.js --save

Framework & Dependents

bower.json other dependencies vue-touch, vue-validator, jquery, requirejs-text, underscore, require-css, tiletemplate default no load . If you not need other dependencies, you can edit bower.json or execute command bower uninstall vue-touch vue-validator jquery requirejs-text underscore require-css tiletemplate.

Compatibility

  • Firefox 4.0+
  • Chrome 7+
  • IE 9+
  • Opera 11.60+
  • Safari 5.1.4+

Drv.js based on ES5 (ECMAScript 5), supported other ES5+ browsers . ECMAScript 5 compatibility table : http://kangax.github.io/compat-table/es5/.

Directory structure

you-app/
    bower_components/
    controllers/
    configs/
    images/
    views/
    css/
	lib/
    ...
    bower.json
    index.html
    main.js

Usage

index.html :

<div id="layout"></div>
<script src="./bower_components/requirejs/require.js"></script>
<script drv-main="./main" src="./bower_components/drv.js/dist/drv.min.js"></script>

main.js :

define(["./configs/routes"], function(routes) {
    var app = Drv.App(); // or Drv.App({your-configs ...});
    app.run(routes, function() {
        console.log(this);
    });
});

Configuration options reference => console.log(Drv.defaults); or console.log(app.settings);

routes.js :

define({
    "/"          : function() {},  // Director.js original way
    "/books"     : "book/index",   // Using Drv.App.Controller, autoload you-app/controllers/book/index.js
    "/books/:id" : "book/view",
    "/author"    : "author",
    "/about"     : "about"
});

Router (Director.js) API Documentation https://github.com/flatiron/director#api-documentation

Controller book/view.js :

// You can use Require.js css / text plugin for deps
define(["your-deps"], function() {
    var app    = Drv.getApp(); // Get app instance, On current page is singleton.
    var router = app.router;   // router.getRoute(), router.getPath()
    var params = router.$params;

    // Vue ViewModel Options
    var vmOptions = {
        el   : "#layout",
        data : {
            id : params[0],
            name : "Drv.js"
        },
        ready : function() {
            console.log("Vue.$http", this.$http);
        },
        methods : {
            clickDiv : function(e) {
                console.log(e.target);
            }
        }
    };

    // render you-app/views/index.html
    app.render("index", vmOptions);
});

ViewModel (Vue.js) Guide http://vuejs.org/guide/

View views/index.html :

<h1>View index.html {{name}} id={{id}}</h1>
<input v-model="name" />

<div style="width:100px;height:100px;background:green;color:#fff;" v-on="click:clickDiv">Drv.js</div>

ViewModel directives http://vuejs.org/api/directives.html

Documentations

Changes

Change logs

License

The MIT License.

Copyright (c) 2015 Pandao

About

The Combined Type JavaScript MVVM / MVC / SPA Development Framework, Based on Director.js, Require.js and Vue.js.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published