Changeset 274 for Dev/branches/rest-dojo-ui/client/rft
- Timestamp:
- 02/20/12 16:27:19 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 5 added
- 2 deleted
- 8 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/api.js
r256 r274 10 10 rawBody: json.toJson(args) 11 11 }); 12 },13 createObject: function(type, args) {14 var d = new Deferred();15 this.post("createObject",16 {17 type: type,18 values: args19 })20 .then(function(data) {21 d.resolve(data.uid);22 },function(){23 d.reject();24 });25 return d.promise;26 },27 getObject: function(type, uid) {28 var d = new Deferred();29 this.post("getObject",30 {31 type: type,32 uid: uid33 })34 .then(function(data) {35 d.resolve(data.object);36 },function(){37 d.reject();38 });39 return d.promise;40 },41 getObjects: function(type, predicates) {42 var d = new Deferred();43 this.post("getObjects",44 {45 type: type,46 predicates: predicates47 })48 .then(function(data) {49 d.resolve(data.objects);50 },function(){51 d.reject();52 });53 return d.promise;54 },55 deleteObject: function(type, uid) {56 var d = new Deferred();57 d.reject();58 return d.promise;59 12 } 60 } 13 }; 61 14 }); -
Dev/branches/rest-dojo-ui/client/rft/auth.js
r260 r274 20 20 post("/login", 21 21 { 22 username:username,22 email:username, 23 23 password:password 24 24 }) … … 49 49 post("/register", 50 50 { 51 username:username,51 email:username, 52 52 password:password 53 53 }) -
Dev/branches/rest-dojo-ui/client/rft/content.js
r264 r274 92 92 return dfd.promise; 93 93 } 94 currentPage = null; 94 95 } 95 96 … … 99 100 100 101 // load html 101 var pageUrl = ' pages'+hri.path()+'.html';102 var pageUrl = 'rft/pages'+hri.path()+'.html'; 102 103 xhr.get({ 103 104 url: pageUrl, … … 107 108 // initialize page or create error message 108 109 .then(function(html){ 109 currentPage = new _Page({ 110 templateString: html, 111 pageQuery: hri.args() 112 }); 113 contentPane.set('content',currentPage); 110 contentPane.set('content',html); 111 var rootNode = contentPane.containerNode.firstChild; 112 currentPage = dijit.byNode(rootNode); 113 if ( !currentPage ) { 114 currentPage = new _Page({},rootNode); 115 } 114 116 dfd.resolve(); 115 117 },function(){ 116 currentPage = new _Page({ 117 templateString: "<div>Page "+hri.path()+" not found.</div>" 118 }); 119 contentPane.set('content',currentPage); 118 contentPane.set('content',"<div>Page "+hri.path()+" not found.</div>"); 120 119 dfd.reject(); 121 120 }); -
Dev/branches/rest-dojo-ui/client/rft/css/main.css
r256 r274 5 5 } 6 6 7 .mainTitle {8 display: block;9 float: left;10 border-right: 1px solid;11 padding-right: 5px;12 margin-right: 5px;13 }14 15 7 .mainMenu { 16 display: block; 17 float: left; 18 } 19 20 .mainUserInfo { 21 display: block; 22 float: right; 23 border-left: 1px solid; 24 padding-left: 5px; 25 margin-left: 5px; 8 width: 100%; 26 9 } 27 10 -
Dev/branches/rest-dojo-ui/client/rft/run.js
r263 r274 1 1 require([ 2 2 'dijit/form/Form', 3 'dijit/form/TextBox', 4 'dijit/form/Button', 5 'dijit/form/Textarea', 3 6 'dojo/store/JsonRest', 4 7 'dojo/data/ObjectStore', … … 6 9 'dijit/layout/ContentPane', 7 10 'dijit/layout/TabContainer', 11 'dijit/layout/AccordionContainer', 8 12 'dijit/MenuBar', 9 13 'dijit/MenuBarItem', 14 'dijit/PopupMenuBarItem', 15 'dijit/DropDownMenu', 10 16 'rft/ui/MenuBarLink', 17 'rft/ui/MenuLink', 18 'rft/ui/QuestionWidget', 19 'rft/pages/questions' // could this be done dynamically? 11 20 ]); 12 21 13 22 require(['dojo/_base/window','dojo/parser', 'rft/ui/LoginDialog', 14 23 'dojo/dom', 'dojo/_base/connect', 'rft/auth', 'rft/content', 15 'dojo/domReady!' ,],24 'dojo/domReady!' ], 16 25 function(win,parser,LoginDialog,dom,connect,auth,content) { 17 26 parser.parse(); … … 27 36 }); 28 37 29 connect.connect(dom.byId(' userinfo'),'click',function(){38 connect.connect(dom.byId('loginMenu'),'click',function(){ 30 39 login.show(); 31 40 }); 41 32 42 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.html
r263 r274 9 9 <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="loginForm"> 10 10 <fieldset> 11 <label for=" username" class="loginLabel">Email</label>12 <input data-dojo-type="dijit.form.TextBox" name=" username" type="text" class="loginInput" />11 <label for="email" class="loginLabel">Email</label> 12 <input data-dojo-type="dijit.form.TextBox" name="email" type="text" class="loginInput" /> 13 13 <label for="password" class="loginLabel">Password</label> 14 14 <input data-dojo-type="dijit.form.TextBox" name="password" type="password" class="loginInput" /> 15 15 </fieldset> 16 <button type="submit" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onLogin">Login</button> 17 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onCancel">Cancel</button> 16 <div style="float: right;"> 17 <button type="button" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onRegister">Register</button> 18 <button type="submit" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onLogin">Login</button> 19 </div> 18 20 </form> 19 <div data-dojo-attach-point="loginErrors" ></div>21 <div data-dojo-attach-point="loginErrors" style="clear: both; color: red;"></div> 20 22 </div> 21 23 </div> -
Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.js
r263 r274 6 6 templateString: template, 7 7 widgetsInTemplate: true, 8 title: "Login ",8 title: "Login/Register", 9 9 baseClass: "rftLoginDialog", 10 10 startup: function() { … … 20 20 this.loginErrors.innerHTML = ''; 21 21 var data = this.loginForm.get('value'); 22 auth.login(data. username,data.password)22 auth.login(data.email,data.password) 23 23 .then(lang.hitch(this,function() { 24 24 this.hide(); … … 29 29 event.stop(evt); 30 30 return false; 31 }, 32 onRegister: function() { 33 this.loginErrors.innerHTML = ''; 34 var data = this.loginForm.get('value'); 35 auth.register(data.email,data.password) 36 .then(lang.hitch(this,function() { 37 this.hide(); 38 content.initial(); 39 }),lang.hitch(this,function() { 40 this.loginErrors.innerHTML = 'Register failed.'; 41 })); 31 42 } 32 43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/MenuLink.js
r270 r274 1 define(['dojo/_base/declare','dijit/Menu BarItem','../content'],2 function(declare,Menu BarItem,content){3 return declare('rft.ui.Menu BarLink',[MenuBarItem],{1 define(['dojo/_base/declare','dijit/MenuItem','../content'], 2 function(declare,MenuItem,content){ 3 return declare('rft.ui.MenuLink',[MenuItem],{ 4 4 options:{ 5 5 pageId: null -
Dev/branches/rest-dojo-ui/client/rft/ui/_Page.js
r263 r274 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser','dojo/query','dojo/_base/Deferred', 2 'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','rft/ui/_PageController'], 3 function(declare,lang,array,parser,query,Deferred,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_PageController){ 4 return declare('rft.ui._Page',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_PageController],{ 5 _controllerLoaded: false, 6 _hasStarted: false, 7 _triggeredOnVisit: false, 8 pageController: null, /* class derived from rft.ui._PageController, mixed in at creation */ 9 buildRendering: function() { 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser','dojo/query','dojo/dom-attr','dojo/_base/connect','dijit','dijit/_WidgetBase','dijit/_Container','dijit/_Contained'], 2 function(declare,lang,array,parser,query,attr,connect,dijit,_WidgetBase,_Container,_Contained){ 3 return declare('rft.ui._Page',[_WidgetBase],{ 4 startup: function() { 10 5 this.inherited(arguments); 11 var dfd = new Deferred(); 12 var mixinType = this.domNode.getAttribute("data-rft-mixin"); 13 if ( mixinType ) { 14 require([mixinType],lang.hitch(this,function(SomePageController){ 15 declare.safeMixin(this,new SomePageController()); 16 dfd.resolve(); 17 })); 18 } else { 19 dfd.resolve(); 20 } 21 dfd.then(lang.hitch(this,function(){ 22 var methods = query('> script[type^="rft/method"]',this.domNode).orphan(); 23 array.forEach(methods,lang.hitch(this,function(s){ 24 var method = s.getAttribute("data-rft-method"); 25 var func = parser._functionFromScript(s); 26 this[method] = func; 27 })); 28 this._controllerLoaded = true; 29 this._triggerOnVisit(); 6 this._attachPointsAndEvents(); 7 this.onVisit(); 8 }, 9 _attachPointsAndEvents: function() { 10 query('*[data-rft-attach-point]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){ 11 var point = attr.get(node,'data-rft-attach-point'); 12 var widget = dijit.byId(attr.get(node,'id')); 13 this[point] = widget || node; 14 })); 15 query('*[data-rft-attach-event]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){ 16 var event = attr.get(node,'data-rft-attach-event').split(':'); 17 var eventName = event[0]; 18 var eventHandler = event[1]; 19 var widget = dijit.byId(attr.get(node,'id')); 20 if ( widget ) { 21 this.connect(widget,eventName,lang.hitch(this,eventHandler)); 22 } else { 23 this.connect(node,eventName,lang.hitch(this,eventHandler)); 24 } 25 })); 26 query('> script[type^="rft/method"]',this.domNode) 27 .orphan().forEach(lang.hitch(this,function(s){ 28 var methodName = s.getAttribute("data-rft-method"); 29 var func = parser._functionFromScript(s); 30 this[methodName] = func; 30 31 })); 31 32 }, 32 startup: function() { 33 this.inherited(arguments); 34 this._hasStarted = true; 35 this._triggerOnVisit(); 36 }, 37 _triggerOnVisit: function() { 38 if ( this._controllerLoaded && this._hasStarted && !this._triggeredOnVisit ) { 39 this._triggeredOnVisit = false; 40 this.onVisit(); 41 } 42 } 33 /** Event fired after startup of all widgets is complete */ 34 onVisit: function(){}, 35 /** Event fired before leaving the page. Return false to prevent */ 36 onLeave: function(){} 43 37 }); 44 38 });
Note: See TracChangeset
for help on using the changeset viewer.