123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- define("dojox/mvc/Generate", [
- "dojo/_base/lang",
- "dojo/_base/declare",
- "./_Container",
- "./Group",
- "dijit/form/TextBox"
- ], function(lang, declare, Container){
-
- return declare("dojox.mvc.Generate", [Container], {
-
-
-
-
-
-
-
-
-
-
-
- _counter : 0,
-
-
-
-
- _defaultWidgetMapping: {"String" : "dijit.form.TextBox"},
-
-
-
-
- _defaultClassMapping: {"Label" : "generate-label-cell", "String" : "generate-dijit-cell", "Heading" : "generate-heading", "Row" : "row"},
-
-
-
-
-
- _defaultIdNameMapping: {"String" : "textbox_t"},
-
-
-
- _updateBinding: function(){
-
-
- this.inherited(arguments);
- this._buildContained();
- },
-
- _buildContained: function(){
-
-
-
-
-
- this._destroyBody();
-
- this._counter = 0;
- this.srcNodeRef.innerHTML = this._generateBody(this.get("binding"));
-
- this._createBody();
- },
-
- _generateBody: function(binding, hideHeading){
-
-
-
-
-
-
-
-
-
- var body = "";
- for(var prop in binding){
- if(binding[prop] && lang.isFunction(binding[prop].toPlainObject)){
- if(binding[prop].get(0)){
- body += this._generateRepeat(binding[prop], prop);
- }else if(binding[prop].value){
-
- body += this._generateTextBox(prop);
- }else{
- body += this._generateGroup(binding[prop], prop, hideHeading);
- }
- }
- }
- return body;
- },
-
- _generateRepeat: function(binding, repeatHeading){
-
-
-
-
-
-
-
-
-
- var headingClass = (this.classMapping && this.classMapping["Heading"]) ? this.classMapping["Heading"] : this._defaultClassMapping["Heading"];
- var repeat = '<div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: \'' + repeatHeading + '\'" + id="' + this.id + '_r' + this._counter++ + '">' +
- '<div class="' + headingClass + '\">' + repeatHeading + '</div>';
- repeat += this._generateBody(binding, true);
- repeat += '</div>';
- return repeat;
- },
-
- _generateGroup: function(binding, groupHeading, hideHeading){
-
-
-
-
-
-
-
-
-
-
-
- var group = '<div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: \'' + groupHeading + '\'" + id="' + this.id + '_g' + this._counter++ + '">';
- if(!hideHeading){
- var headingClass = (this.classMapping && this.classMapping["Heading"]) ? this.classMapping["Heading"] : this._defaultClassMapping["Heading"];
- group += '<div class="' + headingClass + '\">' + groupHeading + '</div>';
- }
- group += this._generateBody(binding);
- group += '</div>';
- return group;
- },
-
- _generateTextBox: function(prop){
-
-
-
-
-
-
-
- var idname = this.idNameMapping ? this.idNameMapping["String"] : this._defaultIdNameMapping["String"];
- idname = idname + this._counter++;
- var widClass = this.widgetMapping ? this.widgetMapping["String"] : this._defaultWidgetMapping["String"];
- var labelClass = (this.classMapping && this.classMapping["Label"]) ? this.classMapping["Label"] : this._defaultClassMapping["Label"];
- var stringClass = (this.classMapping && this.classMapping["String"]) ? this.classMapping["String"] : this._defaultClassMapping["String"];
- var rowClass = (this.classMapping && this.classMapping["Row"]) ? this.classMapping["Row"] : this._defaultClassMapping["Row"];
-
- return '<div class="' + rowClass + '\">' +
- '<label class="' + labelClass + '\">' + prop + ':</label>' +
- '<input class="' + stringClass + '\" data-dojo-type="' + widClass + '\" data-dojo-props="name: \'' + idname + "', ref: '" + prop + '\'" id="' +
- idname + '\"></input>' +
- '</div>';
- }
- });
- });
|