Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-7196] Completed implementation of Ti.UI.EmailDialog. Fixed small ... #1387

Merged
merged 2 commits into from
Feb 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion apidoc/Titanium/UI/EmailDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name: Titanium.UI.EmailDialog
summary: The Email Dialog is created by <Titanium.UI.createEmailDialog> and allows you to send in
application emails on behalf of the application user.
description: On Mobile Web, the `to` addresses, `cc` addresses, `bcc` addresses, `subject`, and `body` are all appended together and formatted into a `mailto:` URL. This URL generally has a limit of around 2000 characters.
extends: Titanium.Proxy
since: "0.8"
platforms: [android, iphone, ipad]
platforms: [android, iphone, ipad, mobileweb]
methods:
- name: addAttachment
summary: |
Expand All @@ -13,6 +14,7 @@ methods:
- name: attachment
summary: attachment object as either a Blob or File object
type: Object
platforms: [android, iphone, ipad]
- name: isSupported
summary: return whether or not sending email is supported
- name: open
Expand All @@ -24,6 +26,7 @@ methods:
events:
- name: complete
summary: fired when the email dialog has completed sending the email
description: On Mobile Web, the platform cannot determine if the message was sent or not. The complete call fires immediately after calling open(), and always reports success.
properties:
- name: result
summary: |
Expand Down Expand Up @@ -52,6 +55,7 @@ properties:
- name: barColor
summary: the bar color of the email dialog window when opened
type: String
platforms: [android, iphone, ipad]
- name: bccRecipients
summary: |
array of email BCC: recipients
Expand All @@ -63,6 +67,8 @@ properties:
- name: html
summary: |
boolean to indicate whether the email messageBody should be sent as HTML content type. defaults to false. (Android note: you should not use html messages in 1.6: after that is okay.)
description: |
On Mobile Web, iPhone and iPad properly interpret HTML messages, however some e-mail clients, especially desktop clients, do not support HTML messages.
type: Boolean
- name: messageBody
summary: the email message body
Expand Down
1 change: 0 additions & 1 deletion mobileweb/titanium/Ti/Network/HTTPClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ define(["Ti/_", "Ti/_/declare", "Ti/_/lang", "Ti/_/Evented", "Ti/Network"],

var is = require.is,
on = require.on,
enc = encodeURIComponent,
undef;

return declare("Ti.Network.HTTPClient", Evented, {
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/titanium/Ti/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(
var body = document.body,
isDef = require.isDef,
isIOS = /(iPhone|iPad)/.test(navigator.userAgent),
modules = "2DMatrix,ActivityIndicator,AlertDialog,Animation,Button,ImageView,Label,OptionDialog,ScrollableView,ScrollView,Slider,Switch,Tab,TabGroup,TableView,TableViewRow,TableViewSection,TextArea,TextField,View,WebView,Window",
modules = "2DMatrix,ActivityIndicator,AlertDialog,Animation,Button,EmailDialog,ImageView,Label,OptionDialog,ScrollableView,ScrollView,Slider,Switch,Tab,TabGroup,TableView,TableViewRow,TableViewSection,TextArea,TextField,View,WebView,Window",
creators = {};

body.addEventListener('touchmove', function(e) {
Expand Down
56 changes: 56 additions & 0 deletions mobileweb/titanium/Ti/UI/EmailDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
define(["Ti/_", "Ti/_/declare", "Ti/_/Evented", "Ti/_/lang"],
function(_, declare, Evented, lang) {

var undef;

return declare("Ti.UI.EmailDialog", Evented, {

open: function() {
var r = this.toRecipients || [],
url = "mailto:" + r.join(","),
i, j,
fields = {
subject: "subject",
ccRecipients: "cc",
bccRecipients: "bcc",
messageBody: "body"
},
params = {};

for (i in fields) {
if (j = this[i]) {
require.is(j, "Array") && (j = j.join(","));
params[fields[i]] = j;
}
}

this.html || params.body && (params.body = _.escapeHtmlEntities(params.body));
params = lang.urlEncode(params);

location.href = url + (params ? "?" + params : "");

this.fireEvent("complete", {
result: this.SENT,
success: true
});
},

constants: {
CANCELLED: 0,
FAILED: 3,
SAVED: 1,
SENT: 2
},

properties: {
bccRecipients: undef,
ccRecipients: undef,
html: false,
messageBody: undef,
subject: undef,
toRecipients: undef
}

});

});
3 changes: 3 additions & 0 deletions mobileweb/titanium/Ti/_.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ define(["Ti/_/lang"], function(lang) {
}
},
dpi: dpi,
escapeHtmlEntities: function(html) {
return (""+html).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
},
getAbsolutePath: function(path) {
/^app\:\/\//.test(path) && (path = path.substring(6));
/^\//.test(path) && (path = path.substring(1));
Expand Down
3 changes: 2 additions & 1 deletion mobileweb/titanium/Ti/_/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ define(function() {
toArray: toArray,

urlEncode: function(obj) {
var pairs = [],
var enc = encodeURIComponent,
pairs = [],
prop,
value;

Expand Down
36 changes: 22 additions & 14 deletions support/mobileweb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Project Compiler
#

import os, sys, time, datetime, simplejson, codecs, shutil, subprocess, mako.template, re
import os, sys, time, datetime, simplejson, codecs, shutil, subprocess, mako.template, re, math
from tiapp import *

ignoreFiles = ['.gitignore', '.cvsignore', '.DS_Store'];
Expand All @@ -30,10 +30,11 @@ def __init__(self, project_path, deploytype):
self.minify = deploytype == "production"

self.packages = []
self.project_dependencies = [] # modules that the project uses
self.modules_map = {} # all modules including deps => individual module deps
self.modules_to_cache = [] # all modules to be baked into require.cache()
self.modules_to_load = [] # all modules to be required at load time
self.project_dependencies = [] # modules that the project uses
self.modules_map = {} # all modules including deps => individual module deps
self.modules_to_cache = [] # all modules to be baked into require.cache()
self.modules_to_load = [] # all modules to be required at load time
self.tiplus_modules_to_load = [] # all modules to be required at load time

# initialize paths
self.sdk_path = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
Expand Down Expand Up @@ -102,9 +103,7 @@ def __init__(self, project_path, deploytype):
if len(tiapp_xml.properties['modules']):
print '[INFO] Locating Ti+ modules…'
for module in tiapp_xml.properties['modules']:
# TODO: check if platform is even defined!

if module['platform'] == 'mobileweb':
if module['platform'] == '' or module['platform'] == 'mobileweb':
module_dir = os.path.join(self.modules_path, module['id'], module['version'])
if not os.path.exists(module_dir):
print '[ERROR] Unable to find Ti+ module "%s", v%s' % (module['id'], module['version'])
Expand All @@ -125,16 +124,18 @@ def __init__(self, project_path, deploytype):
print '[ERROR] Ti+ module "%s" is invalid: missing main "%s"' % (module['id'], main_file + '.js')
sys.exit(1)

print '[INFO] Bundling Ti+ module "%s"' % module['id']

self.project_dependencies.append(main_file)
self.modules_to_cache.append(main_file)
self.tiplus_modules_to_load.append(module['id'])

self.packages.append({
'name': module['id'],
'location': './modules/' + module['id'],
'main': main_file
})

print '[INFO] Bundling Ti+ module "%s"' % module['id']

# TODO: need to combine ALL Ti+ module .js files into the titanium.js, not just the main file

# TODO: need to combine ALL Ti+ module .css files into the titanium.css
Expand Down Expand Up @@ -236,6 +237,7 @@ def __init__(self, project_path, deploytype):

# 5) write require() to load all Ti modules
self.modules_to_load.sort()
self.modules_to_load += self.tiplus_modules_to_load
ti_js.write('require(%s);' % simplejson.dumps(self.modules_to_load))

# 6) close the titanium.js
Expand Down Expand Up @@ -299,10 +301,10 @@ def __init__(self, project_path, deploytype):
p = subprocess.Popen('java -jar "%s" --compilation_level SIMPLE_OPTIMIZATIONS --js "%s" --js_output_file "%s"' % (os.path.join(self.sdk_path, 'closureCompiler', 'compiler.jar'), source, dest), shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
print '[ERROR] Failed to minify "%s"' % dest
print '[WARN] Failed to minify "%s"' % dest
for line in stderr.split('\n'):
if len(line):
print '[ERROR] %s' % line
print '[WARN] %s' % line
print '[WARN] Leaving %s un-minified' % dest
os.remove(dest)
shutil.copy(source, dest)
Expand Down Expand Up @@ -346,8 +348,13 @@ def __init__(self, project_path, deploytype):
if os.path.exists(icon_file):
self.build_icons(icon_file)

total_time = int(round(time.time() - start_time))
print '[INFO] Finished in %s seconds' % total_time
total_time = round(time.time() - start_time)
total_minutes = math.floor(total_time / 60)
total_seconds = total_time % 60
if total_minutes > 0:
print '[INFO] Finished in %s minutes %s seconds' % (int(total_minutes), int(total_seconds))
else:
print '[INFO] Finished in %s seconds' % int(total_time)

def resolve(self, it):
parts = it.split('!')
Expand Down Expand Up @@ -446,6 +453,7 @@ def find_project_dependencies(self):
'Ti/UI/AlertDialog',
'Ti/UI/Animation',
'Ti/UI/Button',
'Ti/UI/EmailDialog',
'Ti/UI/ImageView',
'Ti/UI/Label',
'Ti/UI/OptionDialog',
Expand Down