Permalink
Browse files

Started work on moving to pin auth, attempting to authenticate twitte…

…r opens new scene with webview widget
  • Loading branch information...
dcousineau committed May 31, 2011
1 parent 8805eae commit cb6c2575f21d1a4eaabe22d365d0fc90e9b3d1b0
@@ -0,0 +1,76 @@
+function GetTwitterPinAssistant(args) {
+ /* this is the creator function for your scene assistant object. It will be passed all the
+ additional parameters (after the scene name) that were passed to pushScene. The reference
+ to the scene controller (this.controller) has not be established yet, so any initialization
+ that needs the scene controller should be done in the setup function below. */
+ scene_helpers.addCommonSceneMethods(this);
+
+ /*
+ this connects App to this property of the appAssistant
+ */
+ App = Spaz.getAppObj();
+
+ // default next scene is my-timeline
+ this.nextscene = 'my-timeline';
+ this.nextsceneargs = {};
+
+ if (args) {
+
+ if (args.nextscene) {
+ this.nextscene = args.nextscene;
+ }
+
+ if (args.nextsceneargs) {
+ this.nextsceneargs = args.nextsceneargs;
+ }
+
+ }
+}
+
+GetTwitterPinAssistant.prototype.setup = function() {
+ /* this function is for setup tasks that have to happen when the scene is first created */
+
+ /* use Mojo.View.render to render view templates and add them to the scene, if needed */
+
+ /* setup widgets here */
+ this.controller.setupWidget('pinWebView', {
+ url: "http://m.twitter.com/",
+ });
+
+ /* add event handlers to listen to events from widgets */
+};
+
+GetTwitterPinAssistant.prototype.activate = function(event) {
+ /* put in event handlers here that should only be in effect when this scene is active. For
+ example, key handlers that are observing the document */
+ this.gotoNewPinUrl();
+};
+
+GetTwitterPinAssistant.prototype.deactivate = function(event) {
+ /* remove any event handlers you added in activate and do any other cleanup that should happen before
+ this scene is popped or another scene is pushed on top */
+};
+
+GetTwitterPinAssistant.prototype.cleanup = function(event) {
+ /* this function should do any cleanup needed before the scene is destroyed as
+ a result of being popped off the scene stack */
+};
+
+GetTwitterPinAssistant.prototype.gotoNewPinUrl = function() {
+ this.oauth = OAuth({
+ 'consumerKey':SPAZCORE_CONSUMERKEY_TWITTER,
+ 'consumerSecret':SPAZCORE_CONSUMERSECRET_TWITTER,
+ 'requestTokenUrl':'https://twitter.com/oauth/request_token',
+ 'authorizationUrl':'https://twitter.com/oauth/authorize',
+ 'accessTokenUrl':'https://twitter.com/oauth/access_token',
+ });
+
+ this.oauth.fetchRequestToken(function(url) {
+ //sch.openInBrowser(url, 'authorize');
+ this.controller.get('pinWebView').mojo.openURL(url);
+ }.bind(this),
+ function(data) {
+ //AppUtils.showBanner($L('Problem getting Request Token from Twitter'));
+ }.bind(this)
+ );
+}
@@ -135,11 +135,13 @@ StartloginAssistant.prototype.setup = function() {
Mojo.Event.listen(jQuery('#accountList')[0], Mojo.Event.listAdd, function(e) {
// alert("This would show a popup for input of a username and password. When submitted, the popup would verify the credentials. If successful, it would be added to the list");
- thisA.controller.showDialog({
- template: 'startlogin/new-account-dialog',
- assistant: new NewAccountDialogAssistant(thisA),
- preventCancel:false
- });
+ thisA.controller.showDialog({
+ template: 'startlogin/new-account-dialog',
+ assistant: new NewAccountDialogAssistant(thisA),
+ preventCancel:false
+ });
+
+ //Mojo.Controller.stageController.pushScene('new-account', {});
});
@@ -264,9 +266,13 @@ var NewAccountDialogAssistant = Class.create({
this.widget = widget;
jQuery('#saveAccountButton')[0].addEventListener(
- Mojo.Event.tap,
- this.handleVerifyPassword.bindAsEventListener(this)
- );
+ Mojo.Event.tap,
+ this.handleVerifyPassword.bindAsEventListener(this)
+ );
+ jQuery('#getPin')[0].addEventListener(
+ Mojo.Event.tap,
+ this.handleTwitterPin.bindAsEventListener(this)
+ );
this.newAccountModel = {
'username':false,
@@ -352,6 +358,13 @@ var NewAccountDialogAssistant = Class.create({
},
this.newAccountModel
);
+
+ this.controller.setupWidget('getPin', this.getPinAttributes = {
+
+ }, this.getPinModel = {
+ buttonLabel: "Log In and Get Pin",
+ buttonClass: "Primary"
+ });
this.controller.setupWidget('saveAccountButton', this.verifyButtonAttributes, this.verifyButtonModel);
@@ -416,6 +429,13 @@ var NewAccountDialogAssistant = Class.create({
true
);
+ Mojo.Event.listen(this.controller.get('getPin'),
+ Mojo.Event.tap,
+ this.handleTwitterPin.bindAsEventListener(this),
+ true
+ );
+
+ this.typePropertyChangeListener();
},
@@ -432,7 +452,11 @@ var NewAccountDialogAssistant = Class.create({
this.typePropertyChangeListener,
true
);
-
+ Mojo.Event.stopListening(this.controller.get('getPin'),
+ Mojo.Event.tap,
+ this.handleTwitterPin,
+ true
+ );
},
@@ -468,6 +492,16 @@ var NewAccountDialogAssistant = Class.create({
jQuery('#twitter-api-base-url-row').hide();
jQuery('#type-row').addClass('last');
}
+
+ if (this.newAccountModel.type === SPAZCORE_SERVICE_TWITTER) {
+ jQuery('#twitter-get-pin-row').show();
+ jQuery('#user-row').hide();
+ jQuery('#password-row').hide();
+ } else {
+ jQuery('#twitter-get-pin-row').hide();
+ jQuery('#user-row').show();
+ jQuery('#password-row').show();
+ }
},
@@ -545,6 +579,11 @@ var NewAccountDialogAssistant = Class.create({
}
},
+ handleTwitterPin: function() {
+ Mojo.Log.info("handling twitter pin");
+ Mojo.Controller.stageController.pushScene('get-twitter-pin', {});
+ },
+
activateSpinner: function() {
this.buttonWidget = this.controller.get('saveAccountButton');
this.buttonWidget.mojo.activate();
@@ -0,0 +1,4 @@
+<!-- TODO: replace the contents of this file with your own html -->
+
+
+<div id="pinWebView" x-mojo-element="WebView"></div>
@@ -9,7 +9,14 @@
<div class="palm-group palm-group-spaz unlabeled">
<div class="palm-list">
- <div class="palm-row first">
+ <div class="palm-row first" id="twitter-get-pin-row">
+ <div class="palm-row-wrapper">
+ <div class="textfield-group" x-mojo-focus-highlight="true">
+ <div id="getPin" x-mojo-element="Button"></div>
+ </div>
+ </div>
+ </div>
+ <div class="palm-row first" id="user-row">
<div class="palm-row-wrapper">
<div class="textfield-group" x-mojo-focus-highlight="true">
<div class="title">
@@ -21,7 +28,7 @@
</div>
</div>
</div>
- <div class="palm-row">
+ <div class="palm-row" id="password-row">
<div class="palm-row-wrapper">
<div class="textfield-group" x-mojo-focus-highlight="true">
<div class="title">
View
@@ -1,26 +1,25 @@
[
- {"source": "app/auth_config.js"},
- {"source": "app/views/themes.js"},
+ {"source": "app/auth_config.js"},
+ {"source": "app/views/themes.js"},
{"source": "vendors/jquery.tinysort.js"},
- {"source": "vendors/jquery.embedly.js"},
- {"source": "vendors/tools.tabs-1.0.1.js"},
- {"source": "spazcore/spazcore-webos.js"},
- {"source": "vendors/jquery-ui-justfx-1.6rc6.js"},
- {"source": "libs/view_methods.js"},
- {"source": "vendors/jquery.scrollTo.js"},
- {"source": "vendors/Lawnchair.js"},
- {"source": "vendors/adaptors/LawnchairAdaptorHelpers.js"},
- {"source": "vendors/adaptors/WebkitSQLiteAdaptor.js"},
- {"source": "app/helpers/spaz.js"},
- {"source": "app/helpers/depot.js"},
- {"source": "app/helpers/scene.js"},
- {"source": "app/models/tempcache.js"},
- {"source": "app/models/users.js"},
- {"source": "app/models/tweets.js"},
- {"source": "app/models/versioncookie.js"},
- {"source": "libs/BackgroundNotifier.js"},
-
-
+ {"source": "vendors/jquery.embedly.js"},
+ {"source": "vendors/tools.tabs-1.0.1.js"},
+ {"source": "spazcore/spazcore-webos.js"},
+ {"source": "vendors/jsOAuth-1.1.js"},
+ {"source": "vendors/jquery-ui-justfx-1.6rc6.js"},
+ {"source": "libs/view_methods.js"},
+ {"source": "vendors/jquery.scrollTo.js"},
+ {"source": "vendors/Lawnchair.js"},
+ {"source": "vendors/adaptors/LawnchairAdaptorHelpers.js"},
+ {"source": "vendors/adaptors/WebkitSQLiteAdaptor.js"},
+ {"source": "app/helpers/spaz.js"},
+ {"source": "app/helpers/depot.js"},
+ {"source": "app/helpers/scene.js"},
+ {"source": "app/models/tempcache.js"},
+ {"source": "app/models/users.js"},
+ {"source": "app/models/tweets.js"},
+ {"source": "app/models/versioncookie.js"},
+ {"source": "libs/BackgroundNotifier.js"},
{"source": "app/assistants/app-assistant.js"},
{"source": "app/assistants/stage-assistant.js"},
{
@@ -86,5 +85,13 @@
{
"scenes": "view-image",
"source": "app/assistants/view-image-assistant.js"
+ },
+ {
+ "scenes": "new-account",
+ "source": "app/assistants/new-account-assistant.js"
+ },
+ {
+ "scenes": "get-twitter-pin",
+ "source": "app/assistants/get-twitter-pin-assistant.js"
}
]
Oops, something went wrong.

0 comments on commit cb6c257

Please sign in to comment.