Changeset 407 for Dev/branches/rest-dojo-ui/client/rft/pages/question.js
- Timestamp:
- 09/05/12 14:41:13 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui
- Property svn:ignore
-
old new 1 1 nbproject 2 2 .project 3 release
-
- Property svn:ignore
-
Dev/branches/rest-dojo-ui/client
- Property svn:externals
-
old new 1 dojotoolkit http://svn.dojotoolkit.org/src/tags/release-1.8.0 1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojo 2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8.0/dijit 3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojox 4 util http://svn.dojotoolkit.org/src/tags/release-1.8.0/util
-
- Property svn:externals
-
Dev/branches/rest-dojo-ui/client/rft/pages/question.js
r390 r407 4 4 'dojo/_base/event', 5 5 'dojo/_base/lang', 6 'rft/store', 7 'rft/content', 8 'rft/ui/_Page', 9 'rft/ui/QuestionEditorPreview', 10 'rft/ui/QuestionEditorToolkit' 11 ],function(declare, Deferred, event, lang, store, content, _Page, QuestionEditorPreview, QuestionEditorToolkit){ 12 return declare('rft.pages.question', [_Page], { 13 question: null, 14 _toolkit: null, 15 _preview: null, 16 17 onVisit: function() { 18 if (this.pageArgs.uid) { 19 Deferred.when(store.get(this.pageArgs.uid)) 20 .then(lang.hitch(this, function(obj) { 21 this.question = obj; 22 this._refresh(); 23 })); 24 } else { 25 throw new Error("Error: no reference to object set!"); 26 } 27 this._setupEditor(); 28 }, 29 onLeave: function() { 30 this.inherited(arguments); 31 }, 32 _refresh: function () { 33 this._toolkit.set('value',this.question); 34 this._preview.appendItems(this.question.content || []); 35 }, 36 _onSave: function(evt) { 37 lang.mixin(this.question, this._toolkit.get('value')); 38 this.question.content = this._preview.getItems(); 39 store.put(this.question) 40 .then(function() { 41 content.goTo('questions'); 42 }); 43 evt && event.stop( evt ); 44 return false; 45 }, 46 _onDiscard: function() { 47 content.goTo('questions'); 48 return true; 49 }, 50 _setupEditor: function() { 51 this._toolkit = new QuestionEditorToolkit({ 52 },this.QuestionEditorToolkitNode); 53 this._toolkit.on('submit',lang.hitch(this,"_onSave")); 54 this._toolkit.startup(); 6 '../store', 7 '../app/Controller', 8 '../app/Page', 9 '../ui/QuestionEditorPreview', 10 '../ui/QuestionEditorToolkit', 11 'dojo/text!./question.html' 12 ],function(declare, Deferred, event, lang, store, Controller, Page, QuestionEditorPreview, QuestionEditorToolkit, template){ 13 return declare([Page], { 14 templateString: template, 15 question: null, 16 _toolkit: null, 17 _preview: null, 18 19 startup: function() { 20 if ( this._started ) { return; } 21 this.inherited(arguments); 22 if (this.questionId) { 23 Deferred.when(store.get(this.questionId)) 24 .then(lang.hitch(this, function(obj) { 25 this.question = obj; 26 this._refresh(); 27 })); 28 } else { 29 throw new Error("Error: no reference to object set!"); 30 } 31 this._setupEditor(); 32 }, 33 onLeave: function() { 34 this.inherited(arguments); 35 }, 36 _refresh: function () { 37 this._toolkit.set('value',this.question); 38 this._preview.appendItems(this.question.content || []); 39 }, 40 _onSave: function(evt) { 41 lang.mixin(this.question, this._toolkit.get('value')); 42 this.question.content = this._preview.getItems(); 43 store.put(this.question) 44 .then(function() { 45 Controller.go('/questions'); 46 }); 47 evt && event.stop( evt ); 48 return false; 49 }, 50 _onDiscard: function() { 51 Controller.go('/questions'); 52 return true; 53 }, 54 _setupEditor: function() { 55 this._toolkit = new QuestionEditorToolkit({ 56 },this.QuestionEditorToolkitNode); 57 this._toolkit.on('submit',lang.hitch(this,"_onSave")); 58 this._toolkit.startup(); 55 59 56 this._preview = new QuestionEditorPreview({ 57 region: 'center' 58 },this.QuestionEditorPreviewNode); 59 this._preview.startup(); 60 this._supportingWidgets.push(this._toolkit, this._preview); 61 } 62 }); 60 this._preview = new QuestionEditorPreview({ 61 },this.QuestionEditorPreviewNode); 62 this._preview.startup(); 63 this._supportingWidgets.push(this._toolkit, this._preview); 64 } 65 }); 63 66 }); 64
Note: See TracChangeset
for help on using the changeset viewer.