Skip to content
Browse files

started on compose scene. fixed app menu from "About Phnx" to "About …

…Project Macaw"
  • Loading branch information...
1 parent 1b43944 commit 4b9aaf63f47846ac0b1e088a7c7abe01659015ad @pcamp123 pcamp123 committed Jan 5, 2012
View
15 app/assistants/app-assistant.js
@@ -28,15 +28,22 @@ AppAssistant.prototype = {
}
// code for x-launch-params still work-in-progress
else if (params.tweet) {
- launchParams.action = 'prepTweet';
- launchParams.msg = launchParams.tweet;
- }
+ params.action = 'prepTweet';
+ params.msg = params.tweet;
+ }
+ if(params.action == 'compose') {
+ var compose_parameters = {
+ todo: 'new_external',
+ tweet_text: params.body
+ };
+ this.toasters.add(new ComposeToaster(compose_parameters, this));
+ }
else {
Mojo.Log.info('params: ' + params);
// Launch the app normally, load the default user if it exists.
this.launchMain();
// this.checkNotifications(); // for debugging
- }
+ }
},
handleCommand: function(event) {
var stage = this.controller.getActiveStageController();
View
133 app/assistants/compose-tweet-assistant.js
@@ -0,0 +1,133 @@
+function ComposeTweetAssistant(opts) {
+ this.textarea = 'txtCompose';
+ stageController = this.controller.stageController;
+ this.count = 140;
+ this.sending = false;
+
+
+}
+
+ComposeTweetAssistant.prototype.setup = function() {
+ var prefs = new LocalStorage();
+ if (prefs.read('enterToSubmit')) {
+ get(this.textarea).observe('keydown', function(e){
+ if (e.keyCode === 13) {
+ this.submitTweet();
+ e.stop();
+ }
+ }.bind(this));
+ }
+ get(this.textarea).observe('change', function(e) {
+ this.updateCounter();
+ }.bind(this));
+
+ get(this.textarea).observe('keyup', function(e){
+ this.updateCounter();
+ this.autoComplete();
+ }.bind(this));
+
+ // Start with autocorrect disabled. Only turn it on when the cursor is
+ // in a word that does not start with @.
+ get(this.textarea).setAttribute("autocorrect", "off");
+
+ try {
+ this.controller.window.PalmSystem.setManualKeyboardEnabled(true);
+ } catch (e) {
+ // This is fine. This is only need for devices without a physical
+ // keyboard.
+ }
+
+ get(this.textarea).observe('focus', function(e){
+ this.showKeyboard();
+ }.bind(this));
+ get(this.textarea).observe('click', function(e){
+ this.showKeyboard();
+ }.bind(this));
+
+ get(this.textarea).observe('blur', function(e){
+ if (this.refocus) {
+ this.showKeyboard();
+ try {
+ get(this.textarea).focus();
+ } catch (e) {
+ }
+
+ // Reset each time
+ this.refocus = false;
+ }
+ }.bind(this));
+
+ Mojo.Event.listen(get('submit-' + this.id), Mojo.Event.tap, this.submitTweet.bind(this));
+};
+
+ComposeTweetAssistant.prototype.updateCounter = function() {
+ var count = this.availableChars - get(this.textarea).value.length;
+ get('count-' + this.id).update(count);
+};
+
+ComposeTweetAssistant.prototype.submitTweet = function(event) {
+ var txt = get(this.textarea).value;
+ var Twitter = new TwitterAPI(this.user);
+ var args;
+ var sendfunc = function()
+ {
+ var msg = messages.shift();
+
+ if (!msg) {
+ // We're all done!
+ var refresh = (new LocalStorage()).read('refreshOnSubmit');
+
+ if (refresh) {
+ this.assistant.refreshAll();
+ }
+
+ return;
+ }
+
+ args = { 'status': msg };
+
+ Twitter.postTweet(args, function(response, meta) {
+ // Make the next message a reply to this one
+ // this.reply = true;
+ // this.reply_id = response.responseJSON.id;
+
+ // Send the next part
+ sendfunc();
+ }.bind(this));
+ }.bind(this);
+
+ sendfunc();
+
+ this.sending = true;
+}
+ComposeTweetAssistant.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 */
+};
+
+ComposeTweetAssistant.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 */
+};
+
+ComposeTweetAssistant.prototype.cleanup = function(event) {
+ get(this.textarea).stopObserving('click');
+ get(this.textarea).stopObserving('focus');
+ get(this.textarea).stopObserving('blur');
+
+ get(this.textarea).stopObserving('keyup');
+ get(this.textarea).stopObserving('change');
+ var prefs = new LocalStorage();
+ if (prefs.read('enterToSubmit')) {
+ get(this.textarea).stopObserving('keydown');
+ }
+
+ this.hideKeyboard();
+
+ Mojo.Event.stopListening(get('submit-' + this.id), Mojo.Event.tap, this.submitTweet);
+ Mojo.Event.stopListening(get('photo-' + this.id), Mojo.Event.tap, this.photoTapped);
+ Mojo.Event.stopListening(get('geotag-' + this.id), Mojo.Event.tap, this.geotagTapped);
+ Mojo.Event.stopListening(get('link-' + this.id), Mojo.Event.tap, this.linkTapped);
+ Mojo.Event.stopListening(get('cancel-' + this.id), Mojo.Event.tap, this.cancelTapped);
+ Mojo.Event.stopListening(get('complete-bar-' + this.id), Mojo.Event.tap, this.addUser);
+ };
View
3 app/assistants/main-assistant.js
@@ -183,7 +183,7 @@ MainAssistant.prototype = {
label: 'About',
items: [
{
- label: 'About phnx',
+ label: 'About Project Macaw',
command: 'cmdAbout'
},
{
@@ -947,6 +947,7 @@ MainAssistant.prototype = {
if (this.toasters.items.length === 0) {
this.toggleCompose({});
}
+ //this.controller.stageController.pushScene("compose-tweet");
},
toggleCompose: function(opts) {
this.toasters.add(new ComposeToaster(opts, this));
View
18 app/views/compose-tweet/compose-tweet-scene.html
@@ -0,0 +1,18 @@
+ <div class="compose-wrapper">
+ <div id="dm" class="dm-title">Direct message to @#{-to}</div>
+ <div class="compose-txt">
+ <div id="count" class="counter">140</div>
+ <textarea id="txtCompose" spellcheck="true"></textarea>
+ </div>
+ </div>
+ <div class="compose-opts">
+ <div class="compose-opts-wrapper" align="center">
+ <div id="submit" class="compose-submit" x-mojo-tap-highlight="immediate">Post Tweet</div>
+ <div id="cancel" class="compose-cancel" x-mojo-tap-highlight="immediate">Cancel</div>
+ <div id="photo" class="compose-button photo" x-mojo-tap-highlight="immediate"></div>
+ <div id="geotag" class="compose-button geotag" x-mojo-tap-highlight="immediate"></div>
+ <div id="link" class="compose-button link" x-mojo-tap-highlight="immediate"></div>
+
+ <div style="clear:both"></div>
+ </div>
+ </div>
View
4 sources.json
@@ -88,5 +88,9 @@
{
"scenes": "help",
"source": "app/assistants/help-assistant.js"
+ },
+ {
+ "scenes": "compose-tweet",
+ "source": "app/assistants/compose-tweet-assistant.js"
}
]

0 comments on commit 4b9aaf6

Please sign in to comment.
Something went wrong with that request. Please try again.