Created
June 25, 2012 22:40
-
-
Save basketofsoftkittens/2991905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proposed module structure | |
1. widgets are modules | |
2. widgets have resources(models/views/controllers) that are owned by the widget (other modules cant access because they are declared privately) | |
3. widgets can share resources when they are declared and registered via a "manager" (mint.widget,mint.model). shared resources are declared outside of the scope of the module | |
4. dependency management can include modules which include their resources and their resources dependencies | |
5. at the mint level, each store has a directory which holds widget overrides for a widget, or a widget resource. | |
proposed structure: | |
.. src | |
`-- models // shared resources | |
`-- store_widgets | |
| `-- homemint | |
| `--checkout_form | |
| `-- models | |
| `-- model.coupon.js | |
| | |
`-checkout_form | |
`--models | |
`--- model.coupon.js | |
`--views | |
`-- view.coupon.js | |
`--controllers | |
`forms.js | |
// src/widgets/checkout_form/models/model.coupon.js | |
exp.CouponModel = ready.model.Base.extend({ | |
initialize:function(){} | |
}); | |
// src/store_widgets/homemint/checkout_form/models/model.coupon.js | |
exp.CouponModel = CouponModel.extend({ | |
initialize:function(){ alert("hello world")} | |
}); | |
// src/widgets/checkout_form/model.coupon.js | |
mint.widget.register('checkout-form',{ | |
dependencies:{ | |
model:{ | |
Base:"model/model.Base.js" | |
} | |
}, | |
init:function(){ this.loadDependencies();} | |
ready:function(errors,data){ | |
var resources = populate(this,data); | |
this.CouponModel = new resources.CouponModel(); | |
} | |
}); | |
// js.php turns a modules directory into something like. | |
(function(){ | |
var populate = function(ready){ | |
var exp = {}; | |
exp.CouponModel = ready.model.Base.extend({ ... | |
.... | |
exp.CouponView = Backbone.View.extend({... | |
.... | |
// start store specific loading of resources | |
exp.CouponModel = CouponModel.extend({ ... | |
.... | |
return exp; | |
} | |
mint.widget.register('checkout-form',{ ..... | |
..... | |
ready:function(errors,data){ | |
var resources = populate(this,data); | |
// should alert "hello world" from mint specific overwritten resource | |
this.CouponModel = new rescources.CouponModel(); | |
} | |
..... | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment