appcelerator 2.0.1.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. data/appcelerator/templates/appcelerator.xml +1 -0
  2. data/appcelerator/templates/application.rb +1 -2
  3. data/appcelerator/templates/index.html +1 -1
  4. data/appcelerator/templates/{js → javascripts}/appcelerator-debug.js +1110 -372
  5. data/appcelerator/templates/javascripts/appcelerator.js +20 -0
  6. data/appcelerator/templates/modules/app_box/app_box.js +1 -0
  7. data/appcelerator/templates/modules/app_button/app_button.js +1 -0
  8. data/appcelerator/templates/modules/app_button/css/button.css +1 -0
  9. data/appcelerator/templates/modules/app_button/images/dark_round_left.png +0 -0
  10. data/appcelerator/templates/modules/app_button/images/dark_round_left_disabled.png +0 -0
  11. data/appcelerator/templates/modules/app_button/images/dark_round_left_over.png +0 -0
  12. data/appcelerator/templates/modules/app_button/images/dark_round_left_press.png +0 -0
  13. data/appcelerator/templates/modules/app_button/images/dark_round_middle.png +0 -0
  14. data/appcelerator/templates/modules/app_button/images/dark_round_middle_disabled.png +0 -0
  15. data/appcelerator/templates/modules/app_button/images/dark_round_middle_over.png +0 -0
  16. data/appcelerator/templates/modules/app_button/images/dark_round_middle_press.png +0 -0
  17. data/appcelerator/templates/modules/app_button/images/dark_round_right.png +0 -0
  18. data/appcelerator/templates/modules/app_button/images/dark_round_right_disabled.png +0 -0
  19. data/appcelerator/templates/modules/app_button/images/dark_round_right_over.png +0 -0
  20. data/appcelerator/templates/modules/app_button/images/dark_round_right_press.png +0 -0
  21. data/appcelerator/templates/modules/app_button/images/dark_square_left.png +0 -0
  22. data/appcelerator/templates/modules/app_button/images/dark_square_left_disabled.png +0 -0
  23. data/appcelerator/templates/modules/app_button/images/dark_square_left_over.png +0 -0
  24. data/appcelerator/templates/modules/app_button/images/dark_square_left_press.png +0 -0
  25. data/appcelerator/templates/modules/app_button/images/dark_square_middle.png +0 -0
  26. data/appcelerator/templates/modules/app_button/images/dark_square_middle_disabled.png +0 -0
  27. data/appcelerator/templates/modules/app_button/images/dark_square_middle_over.png +0 -0
  28. data/appcelerator/templates/modules/app_button/images/dark_square_middle_press.png +0 -0
  29. data/appcelerator/templates/modules/app_button/images/dark_square_right.png +0 -0
  30. data/appcelerator/templates/modules/app_button/images/dark_square_right_disabled.png +0 -0
  31. data/appcelerator/templates/modules/app_button/images/dark_square_right_over.png +0 -0
  32. data/appcelerator/templates/modules/app_button/images/dark_square_right_press.png +0 -0
  33. data/appcelerator/templates/modules/app_button/images/icon_add_gray.png +0 -0
  34. data/appcelerator/templates/modules/app_button/images/icon_add_green.png +0 -0
  35. data/appcelerator/templates/modules/app_button/images/icon_delete_gray.png +0 -0
  36. data/appcelerator/templates/modules/app_button/images/icon_delete_red.png +0 -0
  37. data/appcelerator/templates/modules/app_button/images/icon_edit_gray.png +0 -0
  38. data/appcelerator/templates/modules/app_button/images/icon_edit_yellow.png +0 -0
  39. data/appcelerator/templates/modules/app_button/images/icon_save_blue.png +0 -0
  40. data/appcelerator/templates/modules/app_button/images/icon_save_gray.png +0 -0
  41. data/appcelerator/templates/modules/app_button/images/light_round_left.png +0 -0
  42. data/appcelerator/templates/modules/app_button/images/light_round_left_disabled.png +0 -0
  43. data/appcelerator/templates/modules/app_button/images/light_round_left_over.png +0 -0
  44. data/appcelerator/templates/modules/app_button/images/light_round_left_press.png +0 -0
  45. data/appcelerator/templates/modules/app_button/images/light_round_middle.png +0 -0
  46. data/appcelerator/templates/modules/app_button/images/light_round_middle_disabled.png +0 -0
  47. data/appcelerator/templates/modules/app_button/images/light_round_middle_over.png +0 -0
  48. data/appcelerator/templates/modules/app_button/images/light_round_middle_press.png +0 -0
  49. data/appcelerator/templates/modules/app_button/images/light_round_right.png +0 -0
  50. data/appcelerator/templates/modules/app_button/images/light_round_right_disabled.png +0 -0
  51. data/appcelerator/templates/modules/app_button/images/light_round_right_over.png +0 -0
  52. data/appcelerator/templates/modules/app_button/images/light_round_right_press.png +0 -0
  53. data/appcelerator/templates/modules/app_button/images/light_square_left.png +0 -0
  54. data/appcelerator/templates/modules/app_button/images/light_square_left_disabled.png +0 -0
  55. data/appcelerator/templates/modules/app_button/images/light_square_left_over.png +0 -0
  56. data/appcelerator/templates/modules/app_button/images/light_square_left_press.png +0 -0
  57. data/appcelerator/templates/modules/app_button/images/light_square_middle.png +0 -0
  58. data/appcelerator/templates/modules/app_button/images/light_square_middle_disabled.png +0 -0
  59. data/appcelerator/templates/modules/app_button/images/light_square_middle_over.png +0 -0
  60. data/appcelerator/templates/modules/app_button/images/light_square_middle_press.png +0 -0
  61. data/appcelerator/templates/modules/app_button/images/light_square_right.png +0 -0
  62. data/appcelerator/templates/modules/app_button/images/light_square_right_disabled.png +0 -0
  63. data/appcelerator/templates/modules/app_button/images/light_square_right_over.png +0 -0
  64. data/appcelerator/templates/modules/app_button/images/light_square_right_press.png +0 -0
  65. data/appcelerator/templates/modules/app_calendar/app_calendar.js +1 -1
  66. data/appcelerator/templates/modules/app_chart/app_chart.js +1 -1
  67. data/appcelerator/templates/modules/app_content/app_content.js +1 -1
  68. data/appcelerator/templates/modules/app_datatable/app_datatable.js +1 -1
  69. data/appcelerator/templates/modules/app_http/app_http.js +1 -0
  70. data/appcelerator/templates/modules/app_if/app_if.js +1 -0
  71. data/appcelerator/templates/modules/app_iterator/app_iterator.js +1 -1
  72. data/appcelerator/templates/modules/app_message/app_message.js +1 -1
  73. data/appcelerator/templates/modules/app_modaldialog/app_modaldialog.js +1 -1
  74. data/appcelerator/templates/modules/app_panel/app_panel.js +1 -0
  75. data/appcelerator/templates/modules/app_panel/app_panel_test.html +24 -0
  76. data/appcelerator/templates/modules/app_panel/css/panel.css +1 -0
  77. data/appcelerator/templates/modules/app_panel/css/panel_ie7.css +1 -0
  78. data/appcelerator/templates/modules/app_panel/images/close.png +0 -0
  79. data/appcelerator/templates/modules/app_panel/images/close_hover.png +0 -0
  80. data/appcelerator/templates/modules/app_panel/images/close_onclick.png +0 -0
  81. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_12.png +0 -0
  82. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_13.gif +0 -0
  83. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_15.png +0 -0
  84. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_17.png +0 -0
  85. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_19.png +0 -0
  86. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_62.png +0 -0
  87. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_63.gif +0 -0
  88. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_65.png +0 -0
  89. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_67.png +0 -0
  90. data/appcelerator/templates/modules/app_panel/images/collapsed_headers_69.png +0 -0
  91. data/appcelerator/templates/modules/app_panel/images/down.png +0 -0
  92. data/appcelerator/templates/modules/app_panel/images/down_hover.png +0 -0
  93. data/appcelerator/templates/modules/app_panel/images/down_onclick.png +0 -0
  94. data/appcelerator/templates/modules/app_panel/images/expanded_headers_12.png +0 -0
  95. data/appcelerator/templates/modules/app_panel/images/expanded_headers_13.gif +0 -0
  96. data/appcelerator/templates/modules/app_panel/images/expanded_headers_15.png +0 -0
  97. data/appcelerator/templates/modules/app_panel/images/expanded_headers_17.png +0 -0
  98. data/appcelerator/templates/modules/app_panel/images/expanded_headers_19.png +0 -0
  99. data/appcelerator/templates/modules/app_panel/images/expanded_headers_52.png +0 -0
  100. data/appcelerator/templates/modules/app_panel/images/expanded_headers_53.gif +0 -0
  101. data/appcelerator/templates/modules/app_panel/images/expanded_headers_55.png +0 -0
  102. data/appcelerator/templates/modules/app_panel/images/expanded_headers_57.png +0 -0
  103. data/appcelerator/templates/modules/app_panel/images/expanded_headers_59.png +0 -0
  104. data/appcelerator/templates/modules/app_panel/images/footer_30.png +0 -0
  105. data/appcelerator/templates/modules/app_panel/images/footer_32.png +0 -0
  106. data/appcelerator/templates/modules/app_panel/images/footer_37.png +0 -0
  107. data/appcelerator/templates/modules/app_panel/images/footer_39.png +0 -0
  108. data/appcelerator/templates/modules/app_panel/images/footer_43.gif +0 -0
  109. data/appcelerator/templates/modules/app_panel/images/footer_72.png +0 -0
  110. data/appcelerator/templates/modules/app_panel/images/footer_75.png +0 -0
  111. data/appcelerator/templates/modules/app_panel/images/footer_77.png +0 -0
  112. data/appcelerator/templates/modules/app_panel/images/footer_79.png +0 -0
  113. data/appcelerator/templates/modules/app_panel/images/footer_93.gif +0 -0
  114. data/appcelerator/templates/modules/app_panel/images/gray_left_tail.png +0 -0
  115. data/appcelerator/templates/modules/app_panel/images/gray_right_tail.png +0 -0
  116. data/appcelerator/templates/modules/app_panel/images/up.png +0 -0
  117. data/appcelerator/templates/modules/app_panel/images/up_hover.png +0 -0
  118. data/appcelerator/templates/modules/app_panel/images/up_onclick.png +0 -0
  119. data/appcelerator/templates/modules/app_panel/images/white_left_tail.png +0 -0
  120. data/appcelerator/templates/modules/app_panel/images/white_right_tail.png +0 -0
  121. data/appcelerator/templates/modules/app_progressbar/app_progressbar.js +1 -0
  122. data/appcelerator/templates/modules/app_progressbar/css/progressbar.css +1 -0
  123. data/appcelerator/templates/modules/app_script/app_script.js +1 -1
  124. data/appcelerator/templates/modules/app_search/app_search.js +1 -0
  125. data/appcelerator/templates/modules/app_search/css/search.css +1 -0
  126. data/appcelerator/templates/modules/app_security/app_security.js +1 -1
  127. data/appcelerator/templates/modules/app_upload/app_upload.js +1 -1
  128. data/appcelerator/templates/proxy_controller.rb +25 -0
  129. data/appcelerator/templates/routes.rb +2 -0
  130. data/appcelerator/templates/{service_broker.rb → service_broker_controller.rb} +0 -0
  131. data/appcelerator/templates/servicetester.html +208 -0
  132. data/appcelerator/templates/test_service.rb +3 -3
  133. data/appcelerator/templates/upload_controller.rb +55 -0
  134. data/bin/appcelerator +51 -30
  135. data/lib/appcelerator.rb +11 -5
  136. data/lib/appcelerator/dispatcher.rb +62 -62
  137. data/lib/appcelerator/service.rb +220 -222
  138. data/lib/appcelerator/service_broker_controller.rb +3 -11
  139. data/lib/appcelerator/servicebroker/inmemory_service_broker.rb +43 -37
  140. data/service/USAGE +1 -0
  141. data/service/templates/service.rb +3 -3
  142. metadata +164 -49
  143. data/appcelerator/appcelerator_generator.rb +0 -195
  144. data/appcelerator/templates/environment.rb +0 -65
  145. data/appcelerator/templates/js/appcelerator.js +0 -20
  146. data/appcelerator/templates/server +0 -4
  147. data/lib/appcelerator/model.rb +0 -94
@@ -4,5 +4,6 @@
4
4
  <servicebroker poll="false">@{rootPath}servicebroker</servicebroker>
5
5
  <upload>@{rootPath}upload</upload>
6
6
  <download>@{rootPath}download</download>
7
+ <proxy>@{rootPath}proxy</proxy>
7
8
  <sessionid>SESSIONID</sessionid>
8
9
  </appcelerator>
@@ -2,6 +2,5 @@
2
2
  # Likewise, all the methods added will be available for all controllers.
3
3
 
4
4
  class ApplicationController < ActionController::Base
5
- # Pick a unique cookie name to distinguish our session data from others'
6
- session :session_key => 'app_session_id'
5
+ helper :all # include all helpers, all the time
7
6
  end
@@ -5,7 +5,7 @@
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
6
6
  <noscript><meta http-equiv="refresh" content="0;upgrade_script.html"/></noscript>
7
7
  <title>Congratulations. Appcelerator is installed.</title>
8
- <script src="js/appcelerator.js" type="text/javascript"></script>
8
+ <script src="javascripts/appcelerator.js" type="text/javascript"></script>
9
9
  <link rel="shortcut icon" href="images/favicon.ico"/>
10
10
  </head>
11
11
  <body style="visibility:hidden" on="l:app.compiled then visible">
@@ -19,8 +19,7 @@
19
19
  */
20
20
 
21
21
  /* The following files are subject to license agreements by their respective license owners */
22
-
23
- /**
22
+ /**
24
23
  * this file is included *before* any other thirdparty libraries or
25
24
  * SDK files. you must assume that you have no external capabilities in this file
26
25
  */
@@ -6365,10 +6364,223 @@ Element.findChildren = function(element, only, recursive, tagName) {
6365
6364
  Element.offsetSize = function (element, type) {
6366
6365
  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
6367
6366
  }
6367
+ // Copyright (c) 2005 Thomas Fakes (http://craz8.com)
6368
+ //
6369
+ // This code is substantially based on code from script.aculo.us which has the
6370
+ // following copyright and permission notice
6371
+ //
6372
+ // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
6373
+ //
6374
+ // Permission is hereby granted, free of charge, to any person obtaining
6375
+ // a copy of this software and associated documentation files (the
6376
+ // "Software"), to deal in the Software without restriction, including
6377
+ // without limitation the rights to use, copy, modify, merge, publish,
6378
+ // distribute, sublicense, and/or sell copies of the Software, and to
6379
+ // permit persons to whom the Software is furnished to do so, subject to
6380
+ // the following conditions:
6381
+ //
6382
+ // The above copyright notice and this permission notice shall be
6383
+ // included in all copies or substantial portions of the Software.
6384
+ //
6385
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6386
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6387
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6388
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6389
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
6390
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
6391
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6392
+
6393
+ var Resizeable = Class.create();
6394
+ Resizeable.prototype = {
6395
+ initialize: function(element) {
6396
+ var options = Object.extend({
6397
+ top: 6,
6398
+ bottom: 6,
6399
+ left: 6,
6400
+ right: 6,
6401
+ minHeight: 0,
6402
+ minWidth: 0,
6403
+ zindex: 1000,
6404
+ resize: null
6405
+ }, arguments[1] || {});
6406
+
6407
+ this.element = $(element);
6408
+ this.handle = this.element;
6409
+
6410
+ Element.makePositioned(this.element); // fix IE
6411
+
6412
+ this.options = options;
6413
+
6414
+ this.active = false;
6415
+ this.resizing = false;
6416
+ this.currentDirection = '';
6417
+
6418
+ this.eventMouseDown = this.startResize.bindAsEventListener(this);
6419
+ this.eventMouseUp = this.endResize.bindAsEventListener(this);
6420
+ this.eventMouseMove = this.update.bindAsEventListener(this);
6421
+ this.eventCursorCheck = this.cursor.bindAsEventListener(this);
6422
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
6423
+
6424
+ this.registerEvents();
6425
+ },
6426
+ destroy: function() {
6427
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
6428
+ this.unregisterEvents();
6429
+ },
6430
+ registerEvents: function() {
6431
+ Event.observe(document, "mouseup", this.eventMouseUp);
6432
+ Event.observe(document, "mousemove", this.eventMouseMove);
6433
+ Event.observe(document, "keypress", this.eventKeypress);
6434
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
6435
+ Event.observe(this.element, "mousemove", this.eventCursorCheck);
6436
+ },
6437
+ unregisterEvents: function() {
6438
+ //if(!this.active) return;
6439
+ //Event.stopObserving(document, "mouseup", this.eventMouseUp);
6440
+ //Event.stopObserving(document, "mousemove", this.eventMouseMove);
6441
+ //Event.stopObserving(document, "mousemove", this.eventCursorCheck);
6442
+ //Event.stopObserving(document, "keypress", this.eventKeypress);
6443
+ },
6444
+ startResize: function(event) {
6445
+ if(Event.isLeftClick(event)) {
6446
+
6447
+ // abort on form elements, fixes a Firefox issue
6448
+ var src = Event.element(event);
6449
+ if(src.tagName && (
6450
+ src.tagName=='INPUT' ||
6451
+ src.tagName=='SELECT' ||
6452
+ src.tagName=='BUTTON' ||
6453
+ src.tagName=='TEXTAREA')) return;
6454
+
6455
+ var dir = this.directions(event);
6456
+ if (dir.length > 0) {
6457
+ this.active = true;
6458
+ var offsets = Position.cumulativeOffset(this.element);
6459
+ this.startTop = offsets[1];
6460
+ this.startLeft = offsets[0];
6461
+ this.startWidth = parseInt(Element.getStyle(this.element, 'width'));
6462
+ this.startHeight = parseInt(Element.getStyle(this.element, 'height'));
6463
+ this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
6464
+ this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
6465
+
6466
+ this.currentDirection = dir;
6467
+ Event.stop(event);
6468
+ }
6469
+ }
6470
+ },
6471
+ finishResize: function(event, success) {
6472
+ // this.unregisterEvents();
6473
+
6474
+ this.active = false;
6475
+ this.resizing = false;
6476
+
6477
+ if(this.options.zindex)
6478
+ this.element.style.zIndex = this.originalZ;
6479
+
6480
+ if (this.options.resize) {
6481
+ this.options.resize(this.element);
6482
+ }
6483
+ },
6484
+ keyPress: function(event) {
6485
+ if(this.active) {
6486
+ if(event.keyCode==Event.KEY_ESC) {
6487
+ this.finishResize(event, false);
6488
+ Event.stop(event);
6489
+ }
6490
+ }
6491
+ },
6492
+ endResize: function(event) {
6493
+ if(this.active && this.resizing) {
6494
+ this.finishResize(event, true);
6495
+ Event.stop(event);
6496
+ }
6497
+ this.active = false;
6498
+ this.resizing = false;
6499
+ },
6500
+ draw: function(event) {
6501
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
6502
+ var style = this.element.style;
6503
+ if (this.currentDirection.indexOf('n') != -1) {
6504
+ var pointerMoved = this.startY - pointer[1];
6505
+ var margin = Element.getStyle(this.element, 'margin-top') || "0";
6506
+ var newHeight = this.startHeight + pointerMoved;
6507
+ if (newHeight > this.options.minHeight) {
6508
+ style.height = newHeight + "px";
6509
+ style.top = (this.startTop - pointerMoved - parseInt(margin)) + "px";
6510
+ }
6511
+ }
6512
+ if (this.currentDirection.indexOf('w') != -1) {
6513
+ var pointerMoved = this.startX - pointer[0];
6514
+ var margin = Element.getStyle(this.element, 'margin-left') || "0";
6515
+ var newWidth = this.startWidth + pointerMoved;
6516
+ if (newWidth > this.options.minWidth) {
6517
+ style.left = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
6518
+ style.width = newWidth + "px";
6519
+ }
6520
+ }
6521
+ if (this.currentDirection.indexOf('s') != -1) {
6522
+ var newHeight = this.startHeight + pointer[1] - this.startY;
6523
+ if (newHeight > this.options.minHeight) {
6524
+ style.height = newHeight + "px";
6525
+ }
6526
+ }
6527
+ if (this.currentDirection.indexOf('e') != -1) {
6528
+ var newWidth = this.startWidth + pointer[0] - this.startX;
6529
+ if (newWidth > this.options.minWidth) {
6530
+ style.width = newWidth + "px";
6531
+ }
6532
+ }
6533
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
6534
+ },
6535
+ between: function(val, low, high) {
6536
+ return (val >= low && val < high);
6537
+ },
6538
+ directions: function(event) {
6539
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
6540
+ var offsets = Position.cumulativeOffset(this.element);
6541
+
6542
+ var cursor = '';
6543
+ if (this.between(pointer[1] - offsets[1], 0, this.options.top)) cursor += 'n';
6544
+ if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1], 0, this.options.bottom)) cursor += 's';
6545
+ if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
6546
+ if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
6547
+
6548
+ return cursor;
6549
+ },
6550
+ cursor: function(event) {
6551
+ var cursor = this.directions(event);
6552
+ if (cursor.length > 0) {
6553
+ cursor += '-resize';
6554
+ } else {
6555
+ cursor = '';
6556
+ }
6557
+ this.element.style.cursor = cursor;
6558
+ },
6559
+ update: function(event) {
6560
+ if(this.active) {
6561
+ if(!this.resizing) {
6562
+ var style = this.element.style;
6563
+ this.resizing = true;
6564
+
6565
+ if(Element.getStyle(this.element,'position')=='')
6566
+ style.position = "relative";
6567
+
6568
+ if(this.options.zindex) {
6569
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
6570
+ style.zIndex = this.options.zindex;
6571
+ }
6572
+ }
6573
+ this.draw(event);
6368
6574
 
6575
+ // fix AppleWebKit rendering
6576
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
6577
+ Event.stop(event);
6578
+ return false;
6579
+ }
6580
+ }
6581
+ }
6369
6582
  /* END THIRD PARTY SOURCE */
6370
6583
 
6371
-
6372
6584
  /**
6373
6585
  * Appcelerator bootstrap loader
6374
6586
  */
@@ -6388,7 +6600,7 @@ Appcelerator.Version =
6388
6600
  {
6389
6601
  major: parseInt('2'),
6390
6602
  minor: parseInt('0'),
6391
- revision: parseInt('1.1'),
6603
+ revision: parseInt('2'),
6392
6604
  toString:function()
6393
6605
  {
6394
6606
  return this.major + "." + this.minor + '.' + this.revision;
@@ -6680,7 +6892,7 @@ Appcelerator.Core.loadJS = function (path, onload)
6680
6892
  $E('Error loading '+path+'\n Exception: '+Object.getExceptionDetail(e));
6681
6893
  };
6682
6894
 
6683
- Appcelerator.Core.HeadElement.appendChild(script);
6895
+ Appcelerator.Core.HeadElement.appendChild(script);
6684
6896
  };
6685
6897
 
6686
6898
  Appcelerator.Core.widgets = {};
@@ -7187,6 +7399,21 @@ function $E()
7187
7399
  }
7188
7400
  }
7189
7401
 
7402
+
7403
+ if(typeof err == 'undefined') {
7404
+ var err = {
7405
+ println: function(msg) {
7406
+ console.log(msg); // TODO: switch to Logger
7407
+ }
7408
+ };
7409
+ }
7410
+ if(typeof out == 'undefined') {
7411
+ var out = {
7412
+ println: function(msg) {
7413
+ console.log(msg); // TODO: switch to Logger
7414
+ }
7415
+ };
7416
+ }
7190
7417
  Object.extend(String.prototype,
7191
7418
  {
7192
7419
  /**
@@ -8221,6 +8448,8 @@ Appcelerator.Compiler.isCompiledMode = false;
8221
8448
  Appcelerator.Compiler.compiledCode = '';
8222
8449
  Appcelerator.Compiler.compiledDocument = null;
8223
8450
  Appcelerator.Compiler.compiledJS = null;
8451
+ // list of strings of code that forwards to attribute listeners handlers (in compiled mode)
8452
+ Appcelerator.Compiler.compiledAttributeListeners = [];
8224
8453
 
8225
8454
  //
8226
8455
  // delay before showing loading message in number of milliseconds
@@ -8333,16 +8562,26 @@ Appcelerator.Compiler.registerAttributeProcessor = function(name,attribute,liste
8333
8562
  }
8334
8563
  };
8335
8564
 
8336
- Appcelerator.Compiler.forwardToAttributeListener = function(element,array)
8565
+ Appcelerator.Compiler.forwardToAttributeListener = function(element,array,tagname)
8337
8566
  {
8338
- for (var c=0;c<array.length;c++)
8567
+ for (var i=0;i<array.length;i++)
8339
8568
  {
8340
- var entry = array[c];
8341
- var attribute = entry[0];
8569
+ var entry = array[i];
8570
+ var attributeName = entry[0];
8342
8571
  var listener = entry[1];
8343
- var value = element.getAttribute(attribute);
8344
- listener.handle(element,attribute,value);
8345
- }
8572
+ var value = element.getAttribute(attributeName);
8573
+ if (value) // optimization to avoid adding listeners if the attribute isn't present
8574
+ {
8575
+ if (Appcelerator.Compiler.isCompiledMode)
8576
+ {
8577
+ Appcelerator.Compiler.compiledAttributeListeners.push([element.id,attributeName,tagname,i]);
8578
+ }
8579
+ else
8580
+ {
8581
+ listener.handle(element,attributeName,value);
8582
+ }
8583
+ }
8584
+ }
8346
8585
  };
8347
8586
 
8348
8587
  //
@@ -8355,16 +8594,12 @@ Appcelerator.Compiler.delegateToAttributeListeners = function(element)
8355
8594
  var p = Appcelerator.Compiler.attributeProcessors[tagname];
8356
8595
  if (p && p.length > 0)
8357
8596
  {
8358
- Appcelerator.Compiler.forwardToAttributeListener(element,p);
8597
+ Appcelerator.Compiler.forwardToAttributeListener(element,p,tagname);
8359
8598
  }
8360
8599
  p = Appcelerator.Compiler.attributeProcessors['*'];
8361
8600
  if (p && p.length > 0)
8362
8601
  {
8363
- Appcelerator.Compiler.forwardToAttributeListener(element,p);
8364
- }
8365
- if (Appcelerator.Compiler.isCompiledMode)
8366
- {
8367
- element.removeAttribute('on');
8602
+ Appcelerator.Compiler.forwardToAttributeListener(element,p,'*');
8368
8603
  }
8369
8604
  };
8370
8605
 
@@ -8462,7 +8697,7 @@ Appcelerator.Compiler.compileDocument = function(onFinishCompiled)
8462
8697
  }
8463
8698
  delete Appcelerator.Compiler.onbeforecompileListeners;
8464
8699
  }
8465
-
8700
+
8466
8701
  var container = document.body;
8467
8702
  var originalVisibility = container.style.visibility || 'visible';
8468
8703
 
@@ -8477,7 +8712,7 @@ Appcelerator.Compiler.compileDocument = function(onFinishCompiled)
8477
8712
  }
8478
8713
 
8479
8714
  var state = Appcelerator.Compiler.createCompilerState();
8480
-
8715
+
8481
8716
  // start scanning at the body
8482
8717
  Appcelerator.Compiler.compileElement(container,state);
8483
8718
 
@@ -8487,25 +8722,30 @@ Appcelerator.Compiler.compileDocument = function(onFinishCompiled)
8487
8722
  {
8488
8723
  setTimeout(function()
8489
8724
  {
8490
- if (Appcelerator.Compiler.oncompileListeners)
8491
- {
8492
- for (var c=0;c<Appcelerator.Compiler.oncompileListeners.length;c++)
8493
- {
8494
- Appcelerator.Compiler.oncompileListeners[c]();
8495
- }
8496
- delete Appcelerator.Compiler.oncompileListeners;
8497
- }
8498
- if (typeof(onFinishCompiled)=='function') onFinishCompiled();
8499
- if (originalVisibility!=container.style.visibility)
8500
- {
8501
- container.style.visibility = originalVisibility;
8502
- }
8503
- $MQ('l:app.compiled');
8725
+ if (typeof(onFinishCompiled)=='function') onFinishCompiled();
8726
+ if (originalVisibility!=container.style.visibility)
8727
+ {
8728
+ container.style.visibility = originalVisibility;
8729
+ }
8730
+ Appcelerator.Compiler.compileDocumentOnFinish();
8504
8731
  },0);
8505
8732
  };
8506
8733
  Appcelerator.Compiler.checkLoadState(state);
8507
8734
  };
8508
8735
 
8736
+ Appcelerator.Compiler.compileDocumentOnFinish = function ()
8737
+ {
8738
+ if (Appcelerator.Compiler.oncompileListeners)
8739
+ {
8740
+ for (var c=0;c<Appcelerator.Compiler.oncompileListeners.length;c++)
8741
+ {
8742
+ Appcelerator.Compiler.oncompileListeners[c]();
8743
+ }
8744
+ delete Appcelerator.Compiler.oncompileListeners;
8745
+ }
8746
+ $MQ('l:app.compiled');
8747
+ }
8748
+
8509
8749
  Appcelerator.Compiler.compileInterceptors=[];
8510
8750
 
8511
8751
  Appcelerator.Compiler.addCompilationInterceptor = function(interceptor)
@@ -8566,7 +8806,13 @@ Appcelerator.Compiler.compileElement = function(element,state)
8566
8806
  element.style.originalDisplay = element.style.display || 'block';
8567
8807
  if (Appcelerator.Compiler.isCompiledMode)
8568
8808
  {
8569
- Appcelerator.Compiler.compileWidget(element,state);
8809
+ var widgetJS = Appcelerator.Compiler.compileWidget(element,state);
8810
+ var code = '(function()';
8811
+ code += '{';
8812
+ code += 'Appcelerator.Core.require("'+name+'",function()'
8813
+ code += '{' + widgetJS + '});';
8814
+ code += '})();';
8815
+ Appcelerator.Compiler.compiledCode += code;
8570
8816
  }
8571
8817
  else
8572
8818
  {
@@ -8661,6 +8907,16 @@ Appcelerator.Compiler.addTrash = function(element,trash)
8661
8907
  element.trashcan.push(trash);
8662
8908
  };
8663
8909
 
8910
+ Appcelerator.Compiler.getJsonTemplateVar = function(values,var_name,template_var) {
8911
+ var o = Object.getNestedProperty(values,var_name,template_var);
8912
+ if (typeof(o) == 'object')
8913
+ {
8914
+ o = Object.toJSON(o);
8915
+ o = o.replace(/"/g,'&quot;');
8916
+ }
8917
+ return o;
8918
+ }
8919
+
8664
8920
  Appcelerator.Compiler.templateRE = /#\{(.*?)\}/g;
8665
8921
  Appcelerator.Compiler.compileTemplate = function(html,htmlonly,varname)
8666
8922
  {
@@ -8668,11 +8924,11 @@ Appcelerator.Compiler.compileTemplate = function(html,htmlonly,varname)
8668
8924
 
8669
8925
  var fn = function(m, name, format, args)
8670
8926
  {
8671
- return "'; o = Object.getNestedProperty(values,'"+name+"','#{"+name+"}'); o = (typeof(o)=='object') ? o.toJSON() : o; str+=o; str+='";
8927
+ return "', jtv(values,'"+name+"','#{"+name+"}'),'";
8672
8928
  };
8673
- var body = "var "+varname+" = function(values){ var o; var str = '" +
8929
+ var body = "var "+varname+" = function(values){ var jtv = Appcelerator.Compiler.getJsonTemplateVar; return ['" +
8674
8930
  html.replace(/(\r\n|\n)/g, '').replace(/\t/g,' ').replace(/'/g, "\\'").replace(Appcelerator.Compiler.templateRE, fn) +
8675
- "'; return str; };" + (htmlonly?'':varname);
8931
+ "'].join('');};" + (htmlonly?'':varname);
8676
8932
 
8677
8933
  var result = htmlonly ? body : eval(body);
8678
8934
  return result;
@@ -8788,6 +9044,11 @@ Appcelerator.Compiler.getHtml = function (element,convertHtmlPrefix)
8788
9044
 
8789
9045
  var html = element.innerHTML || Appcelerator.Util.Dom.getText(element);
8790
9046
 
9047
+ return Appcelerator.Compiler.convertHtml(html, convertHtmlPrefix);
9048
+ };
9049
+
9050
+ Appcelerator.Compiler.convertHtml = function (html, convertHtmlPrefix)
9051
+ {
8791
9052
  // convert funky url-encoded parameters escaped
8792
9053
  if (html.indexOf('#%7B')!=-1)
8793
9054
  {
@@ -9027,6 +9288,7 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9027
9288
  {
9028
9289
  var name = Appcelerator.Compiler.getTagname(element);
9029
9290
  var module = Appcelerator.Core.widgets[name];
9291
+ var compiledCode = '';
9030
9292
 
9031
9293
  if (module)
9032
9294
  {
@@ -9078,10 +9340,36 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9078
9340
  }
9079
9341
  widgetParameters['id'] = id;
9080
9342
 
9343
+ //
9344
+ // building custom functions
9345
+ //
9346
+ var functions = null;
9347
+ if (module.getActions)
9348
+ {
9349
+ functions = module.getActions();
9350
+ for (var c=0;c<functions.length;c++)
9351
+ {
9352
+ Appcelerator.Compiler.buildCustomAction(functions[c]);
9353
+ }
9354
+ }
9355
+
9081
9356
  //
9082
9357
  // parse on attribute
9083
9358
  //
9084
- Appcelerator.Compiler.parseOnAttribute(element);
9359
+ if (!Appcelerator.Compiler.isCompiledMode)
9360
+ {
9361
+ if (module.dontParseOnAttributes)
9362
+ {
9363
+ if (!module.dontParseOnAttributes())
9364
+ {
9365
+ Appcelerator.Compiler.parseOnAttribute(element);
9366
+ }
9367
+ }
9368
+ else
9369
+ {
9370
+ Appcelerator.Compiler.parseOnAttribute(element);
9371
+ }
9372
+ }
9085
9373
 
9086
9374
  //
9087
9375
  // hande off widget for building
@@ -9125,6 +9413,11 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9125
9413
  //TODO: look to see how we can deal with this without adding DIV so we
9126
9414
  //can support things like TR inside an iterator
9127
9415
  html = '<div id="'+id+'_temp" style="margin:0;padding:0;display:none">'+html+'</div>';
9416
+
9417
+ if (Appcelerator.Browser.isIE)
9418
+ {
9419
+ html = '<?xml:namespace prefix = app ns = "http://www.appcelerator.org" /> ' + html;
9420
+ }
9128
9421
  added = true;
9129
9422
  switch(position)
9130
9423
  {
@@ -9193,8 +9486,17 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9193
9486
  //
9194
9487
  // remove element
9195
9488
  //
9489
+ var removeId = id;
9196
9490
  if (removeElement)
9197
9491
  {
9492
+ if (Appcelerator.Compiler.isCompiledMode)
9493
+ {
9494
+ // add an empty div to handle attribute processors
9495
+ removeId = Appcelerator.Compiler.generateId();
9496
+ var replaceHtml = '<div id="'+removeId+'" '+Appcelerator.Util.Dom.getAttributesString(element,['style','id'])+' style="margin:0;padding:0;display:none"/>';
9497
+ new Insertion.Before(element,replaceHtml);
9498
+ compiledCode += 'Appcelerator.Compiler.parseOnAttribute($("'+removeId+'"));';
9499
+ }
9198
9500
  Appcelerator.Compiler.removeElementId(id);
9199
9501
  Element.remove(element);
9200
9502
  }
@@ -9207,39 +9509,82 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9207
9509
 
9208
9510
  //
9209
9511
  // attach any special widget functions
9210
- //
9211
- var functions = instructions.functions;
9512
+ //
9212
9513
  if (functions)
9213
9514
  {
9214
9515
  for (var c=0;c<functions.length;c++)
9215
9516
  {
9216
- var name = functions[c];
9217
- var method = module[name];
9218
- if (!method) throw "couldn't find method named: "+name+" for module = "+module;
9219
- var f = function(id,m,data,scope)
9517
+ var methodname = functions[c];
9518
+ var method = module[methodname];
9519
+ if (!method) throw "couldn't find method named: "+methodname+" for module = "+module;
9520
+
9521
+ if (Appcelerator.Compiler.isCompiledMode)
9220
9522
  {
9221
- try
9222
- {
9223
- method(id,widgetParameters,data,scope);
9224
- }
9225
- catch (e)
9523
+ var paramsJSON = Object.toJSON(widgetParameters).gsub('\\\\\\\"','\\\\\\\"').gsub('\\\'','\\\'');
9524
+ compiledCode += '(function(){ var f = function(id,m,data,scope)';
9525
+ compiledCode += '{';
9526
+ compiledCode += 'try';
9527
+ compiledCode += '{';
9528
+ compiledCode += 'var module = Appcelerator.Core.widgets["'+name+'"];';
9529
+ compiledCode += 'var method = module["'+methodname+'"];';
9530
+ compiledCode += 'method("'+id+'",\''+paramsJSON+'\'.evalJSON(),data,scope);';
9531
+ compiledCode += '}';
9532
+ compiledCode += 'catch (e) {';
9533
+ compiledCode += '$E("Error executing '+methodname+' in module '+module.toString()+'. Error "+Object.getExceptionDetail(e)+", stack="+e.stack);';
9534
+ compiledCode += '}';
9535
+ compiledCode += '};';
9536
+ compiledCode += 'Appcelerator.Compiler.attachFunction("'+removeId+'","'+methodname+'",f);})();';
9537
+ }
9538
+ else
9539
+ {
9540
+ (function()
9226
9541
  {
9227
- $E('Error executing '+name+' in module '+module.toString()+'. Error '+Object.getExceptionDetail(e)+', stack='+e.stack);
9228
- }
9229
- };
9230
- Appcelerator.Compiler.attachFunction(id,name,f);
9542
+ var attachMethodName = functions[c];
9543
+ var attachMethod = module[methodname];
9544
+ var f = function(id,m,data,scope)
9545
+ {
9546
+ try
9547
+ {
9548
+ attachMethod(id,widgetParameters,data,scope);
9549
+ }
9550
+ catch (e)
9551
+ {
9552
+ $E('Error executing '+attachMethodName+' in module '+module.toString()+'. Error '+Object.getExceptionDetail(e)+', stack='+e.stack);
9553
+ }
9554
+ };
9555
+ Appcelerator.Compiler.attachFunction(id,attachMethodName,f);
9556
+ })();
9557
+ }
9231
9558
  }
9232
9559
  }
9233
9560
 
9234
- // run the rest of the compiler for the widget
9235
- // after re-queuing so that we can prevent the UI thread from freezing
9236
- //setTimeout(function()
9237
- // {
9238
- //
9239
- // run initialization
9240
- //
9241
- if (instructions.compile)
9242
- {
9561
+ //
9562
+ // run initialization
9563
+ //
9564
+ if (instructions.compile)
9565
+ {
9566
+ if (Appcelerator.Compiler.isCompiledMode)
9567
+ {
9568
+ var paramsJSON = Object.toJSON(widgetParameters).gsub('\\\\\\\"','\\\\\\\"').gsub('\\\'','\\\'');
9569
+ compiledCode += '(function(){try';
9570
+ compiledCode += '{';
9571
+ compiledCode += 'var module = Appcelerator.Core.widgets["'+name+'"];';
9572
+ if (outer)
9573
+ {
9574
+ compiledCode += 'module.compileWidget(\''+paramsJSON+'\'.evalJSON(),$("'+outer.id+'"));';
9575
+ }
9576
+ else
9577
+ {
9578
+ compiledCode += 'module.compileWidget(\''+paramsJSON+'\'.evalJSON(),null);';
9579
+ }
9580
+ compiledCode += '}';
9581
+ compiledCode += 'catch (exxx) {';
9582
+ compiledCode += 'Appcelerator.Compiler.handleElementException($("'+id+'"), exxx, "compiling widget '+id+', type '+element.nodeName+'");';
9583
+ compiledCode += 'return;';
9584
+ compiledCode += '}})();';
9585
+ }
9586
+ else
9587
+ {
9243
9588
  try
9244
9589
  {
9245
9590
  module.compileWidget(widgetParameters,outer);
@@ -9249,22 +9594,36 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9249
9594
  Appcelerator.Compiler.handleElementException($(id), exxx, 'compiling widget ' + id + ', type ' + element.nodeName);
9250
9595
  return;
9251
9596
  }
9252
- }
9253
-
9254
- if (added && instructions.wire && outer)
9255
- {
9256
- Appcelerator.Compiler.compileElement(outer, state);
9257
- }
9258
-
9259
- // fix any issues from the new HTML (only matters in IE6 otherwise no-op)
9260
- Appcelerator.Browser.fixImageIssues();
9261
-
9262
- // reset the display for the widget
9263
- if (outer)
9597
+ }
9598
+ }
9599
+
9600
+ if (added && instructions.wire && outer)
9601
+ {
9602
+ if (Appcelerator.Compiler.isCompiledMode)
9603
+ {
9604
+ compiledCode += 'Appcelerator.Compiler.dynamicCompile($("'+outer+'"));'; // is dynamic ok?
9605
+ }
9606
+ else
9264
9607
  {
9265
- outer.style.display='';
9608
+ Appcelerator.Compiler.compileElement(outer, state);
9266
9609
  }
9267
- ///},0);
9610
+ }
9611
+
9612
+ // fix any issues from the new HTML (only matters in IE6 otherwise no-op)
9613
+ if (Appcelerator.Compiler.isCompiledMode)
9614
+ {
9615
+ compiledCode += 'Appcelerator.Browser.fixImageIssues();';
9616
+ }
9617
+ else
9618
+ {
9619
+ Appcelerator.Browser.fixImageIssues();
9620
+ }
9621
+
9622
+ // reset the display for the widget
9623
+ if (outer)
9624
+ {
9625
+ outer.style.display='';
9626
+ }
9268
9627
  }
9269
9628
  }
9270
9629
  else
@@ -9275,7 +9634,9 @@ Appcelerator.Compiler.compileWidget = function(element,state)
9275
9634
  element.style.display = element.style.originalDisplay;
9276
9635
  }
9277
9636
  }
9278
- };
9637
+
9638
+ return compiledCode;
9639
+ };
9279
9640
 
9280
9641
  Appcelerator.Compiler.determineScope = function(element)
9281
9642
  {
@@ -9312,13 +9673,14 @@ Appcelerator.Compiler.parseOnAttribute = function(element)
9312
9673
  return false;
9313
9674
  };
9314
9675
 
9315
- Appcelerator.Compiler.compileExpression = function (element,value,notfunction)
9676
+ Appcelerator.Compiler.parseExpression = function(value)
9316
9677
  {
9317
9678
  value = value.gsub('\n',' ');
9318
9679
  value = value.gsub('\r',' ');
9319
9680
  value = value.gsub('\t',' ');
9320
9681
  value = value.trim();
9321
9682
 
9683
+ var thens = [];
9322
9684
  var ors = Appcelerator.Compiler.smartSplit(value,' or ');
9323
9685
 
9324
9686
  for (var c=0,len=ors.length;c<len;c++)
@@ -9408,14 +9770,26 @@ Appcelerator.Compiler.compileExpression = function (element,value,notfunction)
9408
9770
  }
9409
9771
  }
9410
9772
 
9411
- $D('compiling condition=['+condition+'], action=['+action+'], elseAction=['+elseAction+'], delay=['+delay+'], ifCond=['+ifCond+']');
9412
-
9413
- var handled = Appcelerator.Compiler.handleCondition(element,condition,action,elseAction,delay,ifCond);
9773
+ thens.push([null,condition,action,elseAction,delay,ifCond]);
9774
+ }
9775
+ return thens;
9776
+ };
9777
+
9778
+
9779
+ Appcelerator.Compiler.compileExpression = function (element,value,notfunction)
9780
+ {
9781
+ var clauses = Appcelerator.Compiler.parseExpression(value);
9782
+ for(var i = 0; i < clauses.length; i++) {
9783
+ var clause = clauses[i];
9784
+ $D('compiling condition=['+clause[1]+'], action=['+clause[2]+'], elseAction=['+clause[3]+'], delay=['+clause[4]+'], ifCond=['+clause[5]+']');
9785
+
9786
+ clause[0] = element;
9787
+ var handled = Appcelerator.Compiler.handleCondition.apply(this, clause);
9414
9788
 
9415
- if (!handled)
9416
- {
9417
- throw "syntax error: unknown condition type: "+condition+" for "+value;
9418
- }
9789
+ if (!handled)
9790
+ {
9791
+ throw "syntax error: unknown condition type: "+clause[1]+" for "+value;
9792
+ }
9419
9793
  }
9420
9794
  };
9421
9795
 
@@ -9460,7 +9834,7 @@ Appcelerator.Compiler.registerCustomAction = function(name,callback)
9460
9834
  code+='Appcelerator.Compiler.publishEvent("'+id+'","'+action+'");'; // TODO: is this needed?
9461
9835
  code+='}';
9462
9836
  code+='catch(exxx){';
9463
- code+=' Appcelerator.Compiler.handleElementException($("'+id+'"),exxx,"Executing:'+action+'");';
9837
+ code+='Appcelerator.Compiler.handleElementException($("'+id+'"),exxx,"Executing:'+action+'");';
9464
9838
  code+='}';
9465
9839
  return code;
9466
9840
  }
@@ -10377,10 +10751,31 @@ Appcelerator.Compiler.isCSSAttribute = function (name)
10377
10751
  {
10378
10752
  return true;
10379
10753
  }
10754
+
10755
+ var css = Appcelerator.Compiler.CSSAttributes[c];
10756
+ var index = css.indexOf('-');
10757
+ if (index > 0)
10758
+ {
10759
+ var converted = css.substring(0,index) + css.substring(index+1).capitalize();
10760
+ if (converted == name)
10761
+ {
10762
+ return true;
10763
+ }
10764
+ }
10380
10765
  }
10381
10766
  return false;
10382
10767
  };
10383
10768
 
10769
+ Appcelerator.Compiler.convertCSSAttribute = function (css)
10770
+ {
10771
+ var index = css.indexOf('-');
10772
+ if (index > 0)
10773
+ {
10774
+ var converted = css.substring(0,index) + css.substring(index+1).capitalize();
10775
+ return converted;
10776
+ }
10777
+ return css;
10778
+ }
10384
10779
 
10385
10780
  //
10386
10781
  // start the compile once the document is loaded - we need to run this each
@@ -10389,126 +10784,150 @@ Appcelerator.Compiler.isCSSAttribute = function (name)
10389
10784
  //
10390
10785
  Appcelerator.Util.ServerConfig.addConfigListener(function()
10391
10786
  {
10392
- if (Appcelerator.Compiler.compileOnLoad)
10787
+ if (Appcelerator.Compiler.compileOnLoad)
10393
10788
  {
10394
- if (Appcelerator.Compiler.isCompiledMode)
10789
+ // prototype/rhino problem
10790
+ for (var name in Event.Methods)
10791
+ {
10792
+ delete Object.prototype[name];
10793
+ }
10794
+
10795
+ var outputHandler;
10796
+ if(Appcelerator.Compiler.isCompiledMode)
10395
10797
  {
10396
- Appcelerator.Compiler.compileDocument(function()
10397
- {
10398
- if (Appcelerator.Compiler.isCompiledMode)
10399
- {
10400
- var html='';
10401
-
10402
- // add the version metadata
10403
- var meta=window.document.createElement('meta');
10404
- meta.setAttribute('name','generator');
10405
- meta.setAttribute('content','Appcelerator '+Appcelerator.Version);
10406
- Appcelerator.Core.HeadElement.appendChild(meta);
10407
-
10408
- // add the license metadata
10409
- meta=window.document.createElement('meta');
10410
- meta.setAttribute('name','license');
10411
- meta.setAttribute('content',Appcelerator.LicenseMessage);
10412
- Appcelerator.Core.HeadElement.appendChild(meta);
10413
-
10414
- var script=window.document.createElement('script');
10415
- script.setAttribute('src','js/'+appcelerator_app_js);
10416
- script.setAttribute('type','text/javascript');
10417
- Appcelerator.Core.HeadElement.appendChild(script);
10418
- var code = 'Appcelerator.Compiler.compileOnLoad=false;';
10419
-
10420
-
10421
- if (Appcelerator.Compiler.compiledCode && Appcelerator.Compiler.compiledCode.length > 0)
10422
- {
10423
- code+='Appcelerator.Core.onload(function(){';
10424
-
10425
- // set scopes for all our elements
10426
- var jscode = 'function setScope(id,scope){var e = $(id); if (e) e.scope = scope;}';
10427
-
10428
- for (var i in Appcelerator.Compiler.scopeMap)
10429
- {
10430
- var scope = Appcelerator.Compiler.scopeMap[i];
10431
- if (typeof(scope)=='string')
10432
- {
10433
- jscode+='setScope("'+i+'","'+scope+'");';
10434
- }
10435
- }
10436
-
10437
- jscode+=Appcelerator.Compiler.compiledCode;
10438
-
10439
- if (Appcelerator.Compiler.compressor)
10440
- {
10441
- // run the JS compressor
10442
- code+=Appcelerator.Compiler.compressor.compress(jscode);
10443
- }
10444
- else
10445
- {
10446
- code+=jscode;
10447
- }
10448
- code+='});';
10449
- }
10450
-
10451
- // remove unnecessary ids from <head>
10452
- Appcelerator.Core.HeadElement.getElementsByTagName('*').each(function(n)
10453
- {
10454
- if (n.nodeType == 1 && Appcelerator.Compiler.automatedIDRegex.test(n.id))
10455
- {
10456
- n.removeAttribute('id');
10457
- }
10458
- });
10459
- if (Appcelerator.Compiler.automatedIDRegex.test(Appcelerator.Core.HeadElement.id))
10460
- {
10461
- Appcelerator.Core.HeadElement.removeAttribute('id');
10462
- }
10463
- if (Appcelerator.Compiler.automatedIDRegex.test(Appcelerator.Core.HeadElement.parentNode.id))
10464
- {
10465
- Appcelerator.Core.HeadElement.parentNode.removeAttribute('id');
10466
- }
10467
-
10468
- //
10469
- // sweep through and figure out which CSS links are not really
10470
- // used by the app (since we import all on compile)
10471
- //
10472
- var css = {};
10473
- document.getElementsByTagName('link').each(function(link)
10474
- {
10475
- if (link.id)
10476
- {
10477
- css[link.id] = link;
10478
- }
10479
- });
10480
-
10481
- for (var path in Appcelerator.Core.widgets_css)
10482
- {
10483
- var module = Appcelerator.Core.widgets_css[path];
10484
- if (typeof module == 'string' && Appcelerator.Core.usedModules[module])
10485
- {
10486
- delete css['css_'+module];
10487
- }
10488
- }
10489
-
10490
- for (var name in css)
10491
- {
10492
- if (name && typeof(name)=='string' && name.indexOf('css_')!=-1)
10493
- {
10494
- var link = css[name];
10495
- link.parentNode.removeChild(link);
10496
- }
10497
- }
10498
-
10499
- html+=Appcelerator.Util.Dom.getText(window.document.documentElement,false,null,true,true);
10500
- Appcelerator.Compiler.compiledJS = code;
10501
- Appcelerator.Compiler.compiledDocument = html;
10502
- }
10503
- });
10504
- }
10505
- else
10506
- {
10507
- Appcelerator.Compiler.compileDocument();
10508
- }
10798
+ outputHandler = Appcelerator.Util.ServerConfig.outputCompiledDocument;
10799
+ }
10800
+ else
10801
+ {
10802
+ outputHandler = Prototype.K;
10803
+ }
10804
+ Appcelerator.Compiler.compileDocument(outputHandler);
10509
10805
  }
10510
10806
  });
10511
10807
 
10808
+ Appcelerator.Util.ServerConfig.outputCompiledDocument = function()
10809
+ {
10810
+ if (Appcelerator.Compiler.isCompiledMode)
10811
+ {
10812
+ var html='';
10813
+
10814
+ // add the version metadata
10815
+ var meta=window.document.createElement('meta');
10816
+ meta.setAttribute('name','generator');
10817
+ meta.setAttribute('content','Appcelerator '+Appcelerator.Version);
10818
+ Appcelerator.Core.HeadElement.appendChild(meta);
10819
+
10820
+ // add the license metadata
10821
+ meta=window.document.createElement('meta');
10822
+ meta.setAttribute('name','license');
10823
+ meta.setAttribute('content',Appcelerator.LicenseMessage);
10824
+ Appcelerator.Core.HeadElement.appendChild(meta);
10825
+
10826
+ var script=window.document.createElement('script');
10827
+ script.setAttribute('src','js/'+appcelerator_app_js);
10828
+ script.setAttribute('type','text/javascript');
10829
+ Appcelerator.Core.HeadElement.appendChild(script);
10830
+
10831
+ var code = null;
10832
+
10833
+ // set scopes for all our elements
10834
+ var codeArray = [
10835
+ 'Appcelerator.Compiler.compileOnLoad=false;',
10836
+ 'Appcelerator.Core.onload(function(){',
10837
+ 'function setScope(id,scope){var e = $(id); if (e) e.scope = scope;}'
10838
+ ];
10839
+
10840
+ for (var i in Appcelerator.Compiler.scopeMap)
10841
+ {
10842
+ var scope = Appcelerator.Compiler.scopeMap[i];
10843
+ if (typeof(scope)=='string')
10844
+ {
10845
+ codeArray.push('setScope("'+i+'","'+scope+'");');
10846
+ }
10847
+ }
10848
+
10849
+ if (Appcelerator.Compiler.compiledCode)
10850
+ {
10851
+ codeArray.push(Appcelerator.Compiler.compiledCode);
10852
+ }
10853
+
10854
+ codeArray.push("var attributeProcessors = Appcelerator.Compiler.attributeProcessors;");
10855
+ codeArray.push("function handleListener(elementId, attributeName, tagname, handlerIndex) {");
10856
+ codeArray.push("var element = $(elementId); var value = element.getAttribute(attributeName);");
10857
+ codeArray.push("attributeProcessors[tagname][handlerIndex][1].handle(element,attributeName,value);}");
10858
+
10859
+ var listeners = Appcelerator.Compiler.compiledAttributeListeners;
10860
+ for(i = 0; i < listeners.length; i++) {
10861
+ codeArray.push('handleListener("'+listeners[i].join('","')+'");');
10862
+ }
10863
+
10864
+ codeArray.push('Appcelerator.Compiler.compileDocumentOnFinish();');
10865
+ // close the entire onload handler
10866
+ codeArray.push('});');
10867
+
10868
+ code = codeArray.join('');
10869
+
10870
+ if (Appcelerator.Compiler.compressor)
10871
+ {
10872
+ // run the JS compressor (a java class)
10873
+ code = Appcelerator.Compiler.compressor.compress(code);
10874
+ }
10875
+
10876
+ // remove unnecessary ids from <head>
10877
+ Appcelerator.Core.HeadElement.getElementsByTagName('*').each(function(n)
10878
+ {
10879
+ if (n.nodeType == 1 && Appcelerator.Compiler.automatedIDRegex.test(n.id))
10880
+ {
10881
+ n.removeAttribute('id');
10882
+ }
10883
+ });
10884
+ if (Appcelerator.Compiler.automatedIDRegex.test(Appcelerator.Core.HeadElement.id))
10885
+ {
10886
+ Appcelerator.Core.HeadElement.removeAttribute('id');
10887
+ }
10888
+ if (Appcelerator.Compiler.automatedIDRegex.test(Appcelerator.Core.HeadElement.parentNode.id))
10889
+ {
10890
+ Appcelerator.Core.HeadElement.parentNode.removeAttribute('id');
10891
+ }
10892
+
10893
+ //
10894
+ // sweep through and figure out which CSS links are not really
10895
+ // used by the app (since we import all on compile)
10896
+ //
10897
+ var css = {};
10898
+ document.getElementsByTagName('link').each(function(link)
10899
+ {
10900
+ if (link.id)
10901
+ {
10902
+ css[link.id] = link;
10903
+ }
10904
+ });
10905
+
10906
+ for (var path in Appcelerator.Core.widgets_css)
10907
+ {
10908
+ var module = Appcelerator.Core.widgets_css[path];
10909
+ if (typeof module == 'string' && Appcelerator.Core.usedModules[module])
10910
+ {
10911
+ delete css['css_'+module];
10912
+ }
10913
+ }
10914
+
10915
+ for (var name in css)
10916
+ {
10917
+ if (name && typeof(name)=='string' && name.indexOf('css_')!=-1)
10918
+ {
10919
+ var link = css[name];
10920
+ link.parentNode.removeChild(link);
10921
+ }
10922
+ }
10923
+
10924
+ html+=Appcelerator.Util.Dom.getText(window.document.documentElement,false,null,true,true);
10925
+
10926
+ Appcelerator.Compiler.compiledJS = code;
10927
+ Appcelerator.Compiler.compiledDocument = html;
10928
+ }
10929
+ };
10930
+
10512
10931
 
10513
10932
  Appcelerator.Compiler.setHTML = function(element,html)
10514
10933
  {
@@ -10823,9 +11242,9 @@ Appcelerator.Util.Dom =
10823
11242
  var html = '';
10824
11243
  this.eachAttribute(element, function(name, value)
10825
11244
  {
10826
- if (!excludes || !excludes.exists(name))
11245
+ if (false == (excludes && excludes.indexOf(name) > -1))
10827
11246
  {
10828
- html += name + '="' + String.escapeXML(value||'') + '" ';
11247
+ html += name + '="' + String.escapeXML(value||'') + '" ';
10829
11248
  }
10830
11249
  }, null, true);
10831
11250
  return html;
@@ -11073,7 +11492,6 @@ Appcelerator.Util.ServiceBroker =
11073
11492
  initQueue:[],
11074
11493
  timer: null,
11075
11494
  time: null,
11076
- currentRequestId:1,
11077
11495
  serverDown: false,
11078
11496
  poll: false,
11079
11497
  fetching: false,
@@ -11082,8 +11500,11 @@ Appcelerator.Util.ServiceBroker =
11082
11500
  localPatternListeners: [],
11083
11501
  remotePatternListeners: [],
11084
11502
  devmode: (window.location.href.indexOf('devmode=1') > 0),
11085
- disabled: this.devmode || (window.location.href.indexOf('file:/') == 0) || Appcelerator.Parameters['mbDisabled']=='1',
11086
- remoteDisabled: this.disabled || Appcelerator.Parameters['remoteDisabled']=='1',
11503
+ disabled: this.devmode || (window.location.href.indexOf('file:/') == 0) || Appcelerator.Parameters.get('mbDisabled')=='1',
11504
+ remoteDisabled: this.disabled || Appcelerator.Parameters.get('remoteDisabled')=='1',
11505
+ marshaller:'xml/json',
11506
+ transport:'appcelerator',
11507
+ multiplex:true,
11087
11508
 
11088
11509
  toString: function ()
11089
11510
  {
@@ -11392,61 +11813,13 @@ Appcelerator.Util.ServiceBroker =
11392
11813
  }
11393
11814
  this.localMessageQueue.push([name,data,dest,scope,version]);
11394
11815
  },
11395
-
11396
- processIncoming: function (xml)
11397
- {
11398
- if (xml)
11399
- {
11400
- var children = xml.documentElement.childNodes;
11401
- if (children && children.length > 0)
11402
- {
11403
- for (var c = 0; c < children.length; c++)
11404
- {
11405
- var child = children.item(c);
11406
- if (child.nodeType == Appcelerator.Util.Dom.ELEMENT_NODE)
11407
- {
11408
- var requestid = child.getAttribute("requestid");
11409
- try
11410
- {
11411
- this.dispatch(requestid, child);
11412
- }
11413
- catch (e)
11414
- {
11415
- $E(this + ' - Error in dispatch of message. ' + Object.getExceptionDetail(e));
11416
- }
11417
- }
11418
- }
11419
- }
11420
- }
11421
- },
11422
-
11423
- dispatch: function (requestid, msg)
11816
+ dispatch: function (msg)
11424
11817
  {
11425
- var type = msg.getAttribute("type");
11426
- var datatype = msg.getAttribute("datatype");
11427
- var scope = msg.getAttribute("scope") || 'appcelerator';
11428
-
11429
- var data = msg;
11430
-
11431
- if (datatype == 'JSON')
11432
- {
11433
- var text;
11434
- try
11435
- {
11436
- text = Appcelerator.Util.Dom.getText(msg);
11437
- data = text.evalJSON();
11438
- data.toString = function ()
11439
- {
11440
- return Object.toJSON(this);
11441
- };
11442
- $D(this.toString() + ' received remote message, type:' + type + ',data:' + data);
11443
- }
11444
- catch (e)
11445
- {
11446
- $E('Error received evaluating: ' + text + ' for ' + msg + ', type:' + type + ", " + Object.getExceptionDetail(e));
11447
- return;
11448
- }
11449
- }
11818
+ var requestid = msg.requestid;
11819
+ var type = msg.type;
11820
+ var datatype = msg.datatype;
11821
+ var scope = msg.scope;
11822
+ var data = msg.data;
11450
11823
 
11451
11824
  // let the interceptors have at it
11452
11825
  if (this.interceptors.length > 0)
@@ -11458,7 +11831,7 @@ Appcelerator.Util.ServiceBroker =
11458
11831
  var func = interceptor['interceptDispatch'];
11459
11832
  if (func)
11460
11833
  {
11461
- var result = func.apply(interceptor, [requestid,type,data,datatype,scope]);
11834
+ var result = func.apply(interceptor, [requestid,type,msg,datatype,scope]);
11462
11835
  if (result != null && !result)
11463
11836
  {
11464
11837
  send = false;
@@ -11552,8 +11925,6 @@ Appcelerator.Util.ServiceBroker =
11552
11925
 
11553
11926
  deliver: function (initialrequest)
11554
11927
  {
11555
- var xml = null;
11556
-
11557
11928
  if (this.messageQueue == null)
11558
11929
  {
11559
11930
  // we're dead and destroyed, cool, just
@@ -11566,94 +11937,89 @@ Appcelerator.Util.ServiceBroker =
11566
11937
  // remote disabled
11567
11938
  return;
11568
11939
  }
11940
+
11941
+ // get the marshaller to use
11942
+ var marshaller = Appcelerator.Util.ServiceBrokerMarshaller[this.marshaller];
11943
+ if (!marshaller)
11944
+ {
11945
+ $E(this+' - no marshaller defined, will not send message to remote endpoint');
11946
+ this.remoteDisabled = true;
11947
+ return;
11948
+ }
11949
+ var transportHandler = Appcelerator.Util.ServiceBrokerTransportHandler[this.transport];
11950
+ if (!transportHandler)
11951
+ {
11952
+ $E(this+' - no transport handler defined, will not send message to remote endpoint');
11953
+ this.remoteDisabled = true;
11954
+ return;
11955
+ }
11569
11956
 
11570
- // send if we have stuff
11571
- var time = new Date();
11572
- var timestamp = time.getTime();
11573
- if (this.messageQueue.length > 0)
11574
- {
11575
- xml = "<?xml version='1.0'?>\n";
11576
- var tz = time.getTimezoneOffset()/60;
11577
- var idleMs = Appcelerator.Util.IdleManager.getIdleTimeInMS();
11578
- xml += "<request version='1.0' idle='" + idleMs + "' timestamp='"+timestamp+"' tz='"+tz+"'>\n";
11579
- for (var c = 0,len = this.messageQueue.length; c < len; c++)
11580
- {
11581
- var msg = this.messageQueue[c];
11582
- var requestid = this.currentRequestId++;
11583
- var scope = msg[2];
11584
- var version = msg[3];
11585
- var datatype = 'JSON';
11586
- var data = msg[0]['data'];
11587
- xml += "<message requestid='" + requestid + "' type='" + msg[0]['type'] + "' datatype='" + datatype + "' scope='"+scope+"' version='"+version+"'>";
11588
- xml += '<![CDATA[' + Object.toJSON(data) + ']]>';
11589
- xml += "</message>";
11590
- }
11591
- this.messageQueue.clear();
11592
- xml += "</request>";
11593
- }
11594
- // get the auth token
11595
- var cookieName = Appcelerator.ServerConfig['sessionid'].value||'JSESSIONID';
11596
- var authToken = Appcelerator.Util.Cookie.GetCookie(cookieName);
11597
- // calculate the token we send back to the server
11598
- var token = (authToken) ? Appcelerator.Util.MD5.hex_md5(authToken+this.instanceid) : '';
11599
- var _method = (xml == null) ? 'get' : 'post';
11600
- var p = (initialrequest && xml == null) ? "?maxwait=1&initial=1&instanceid="+this.instanceid : "?maxwait=" + ((!initialrequest && xml) ? this.maxWaitPollTime : this.maxWaitPollTimeWhenSending)+"&instanceid="+this.instanceid+'&auth='+token+'&ts='+timestamp;
11957
+ this.fetching = true;
11958
+
11959
+ var payloadObj = marshaller.serialize(this.messageQueue,this.multiplex);
11960
+ var payload = payloadObj.postBody;
11961
+ var contentType = payloadObj.contentType;
11962
+
11963
+ var instructions = transportHandler.prepare(this,initialrequest,payload,contentType);
11964
+
11965
+ if (this.multiplex)
11966
+ {
11967
+ this.messageQueue.clear();
11968
+ }
11969
+ else
11970
+ {
11971
+ if (this.messageQueue.length > 0)
11972
+ {
11973
+ this.messageQueue.removeAt(0);
11974
+ }
11975
+ }
11601
11976
 
11602
- Logger.trace(this.toString() + ' Sending (poll=' + (this.poll) + '): ' + (xml || '<empty>'));
11977
+ var url = instructions.url;
11978
+ var method = instructions.method;
11979
+ var postBody = instructions.postBody;
11980
+ var contentType = instructions.contentType;
11603
11981
 
11604
- this.fetching = true;
11605
- this.sendRequest(p,_method,xml,0)
11982
+ this.sendRequest(url,method,postBody,contentType,marshaller,0);
11983
+
11984
+ if (!this.multiplex && this.messageQueue.length > 0)
11985
+ {
11986
+ this.deliver.defer();
11987
+ }
11606
11988
  },
11607
- sendRequest: function(p,_method,xml,count)
11989
+ sendRequest: function(url,method,body,contentType,marshaller,count)
11608
11990
  {
11609
- count = count++;
11991
+ count = count+1;
11610
11992
 
11611
11993
  if (count > 3)
11612
11994
  {
11995
+ self.fetching = false;
11613
11996
  $E('too many attempts sending a re-authorization request.');
11614
11997
  return;
11615
11998
  }
11616
11999
 
11617
12000
  var self = this;
11618
12001
 
11619
- new Ajax.Request(this.serverPath + p,
12002
+ new Ajax.Request(url,
11620
12003
  {
11621
12004
  asynchronous: true,
11622
- method: _method,
11623
- postBody: xml || "",
11624
- contentType: 'text/xml',
12005
+ method: method,
12006
+ postBody: body,
12007
+ contentType: contentType,
12008
+ evalJSON:false,
12009
+ evalJS:false,
11625
12010
  onComplete: function()
11626
12011
  {
11627
12012
  self.fetching = false;
11628
12013
  },
11629
12014
  onSuccess: function (result)
11630
12015
  {
11631
- setTimeout(function()
12016
+ (function()
11632
12017
  {
11633
12018
  self.fetching = false;
11634
12019
  self.startTimer(false);
11635
12020
 
11636
- if (result && result.status)
11637
- {
11638
- if (result.status == 401)
11639
- {
11640
- self.onServiceBrokerInvalidLogin();
11641
- return;
11642
- }
11643
- // 204 is no content, in which case the content-type is text/plain
11644
- if (result.status != 204 && result.status != 202)
11645
- {
11646
- var contentType = result.getResponseHeader('Content-type');
11647
- // do indexOf instead of equals since we sometime tack on the character encoding
11648
- if (!contentType || contentType.indexOf('text/xml') == -1)
11649
- {
11650
- // this most likely means we've been redirected on the
11651
- // server to another page or something, in which case
11652
- // we (default) will just go to the landing page
11653
- self.onServiceBrokerInvalidContentType(contentType);
11654
- return;
11655
- }
11656
- }
12021
+ if (result && result.status && result.status >= 200 && result.status < 300)
12022
+ {
11657
12023
  if (self.serverDown)
11658
12024
  {
11659
12025
  self.serverDown = false;
@@ -11661,33 +12027,23 @@ Appcelerator.Util.ServiceBroker =
11661
12027
  if (Logger.infoEnabled) Logger.info('[' + Appcelerator.Util.DateTime.get12HourTime(new Date(), true, true) + '] ' + self.toString() + ' Server is UP at ' + self.serverPath);
11662
12028
  self.queue({type:'local:appcelerator.servicebroker.server.up',data:{path:this.serverPath,downtime:downtime}});
11663
12029
  }
11664
- if (result.status == 200)
11665
- {
11666
- var skip = false;
11667
- var cl = result.getResponseHeader("Content-Length");
11668
- if (cl && cl == "0")
11669
- {
11670
- // this is OK, just means no messages from the other side
11671
- skip = true;
11672
- $D(self.toString() + ' Receiving no messages on response');
11673
- }
11674
- if (!skip)
11675
- {
11676
- // now process them
11677
- $D('[' + Appcelerator.Util.DateTime.get12HourTime(new Date(), true, true) + '] ' + self.toString() + ' Receiving: ' + result.responseText);
11678
- self.processIncoming(result.responseXML);
11679
- }
11680
- }
11681
- }
11682
-
11683
- // 204 is no content, which is OK
11684
- // 503 is service unavailable, which we handle already
11685
- if (result && result.status && result.status != 200 && result.status != 503 && result.status != 204 && result.status != 202)
11686
- {
11687
- $E(self.toString() + ' Response Failure: ' + result.status + ' ' + result.statusText);
11688
- }
11689
-
11690
- },0);
12030
+
12031
+ var cl = parseInt(result.getResponseHeader("Content-Length") || '1');
12032
+ var contentType = result.getResponseHeader('Content-Type') || 'unknown';
12033
+
12034
+ if (cl > 0)
12035
+ {
12036
+ var msgs = marshaller.deserialize(result,parseInt(cl),contentType);
12037
+ if (msgs && msgs.length > 0)
12038
+ {
12039
+ for (var c=0;c<msgs.length;c++)
12040
+ {
12041
+ self.dispatch(msgs[c]);
12042
+ }
12043
+ }
12044
+ }
12045
+ }
12046
+ }).defer();
11691
12047
  },
11692
12048
  onFailure: function (transport, json)
11693
12049
  {
@@ -11697,13 +12053,13 @@ Appcelerator.Util.ServiceBroker =
11697
12053
  if (!cl)
11698
12054
  {
11699
12055
  Logger.warn("Failed authentication, will retry 1 more time");
11700
- self.sendRequest(p+"&retry=1",_method,xml,count);
12056
+ self.sendRequest(url,method,body,contentType,marshaller,count);
11701
12057
  return;
11702
12058
  }
11703
12059
  }
11704
12060
  if (transport.status == 406)
11705
12061
  {
11706
- self.sendRequest(p,_method,xml,count);
12062
+ self.sendRequest(url,method,body,contentType,marshaller,count);
11707
12063
  return;
11708
12064
  }
11709
12065
  self.fetching = false;
@@ -11769,7 +12125,7 @@ Appcelerator.Util.ServiceBroker =
11769
12125
  for (var p in this.localDirectListeners)
11770
12126
  {
11771
12127
  var a = this.localDirectListeners[p];
11772
- if (typeof(a) == 'array')
12128
+ if (Object.isArray(a))
11773
12129
  {
11774
12130
  a.clear();
11775
12131
  }
@@ -11781,7 +12137,7 @@ Appcelerator.Util.ServiceBroker =
11781
12137
  for (var p in this.remoteDirectListeners)
11782
12138
  {
11783
12139
  var a = this.remoteDirectListeners[p];
11784
- if (typeof(a) == 'array')
12140
+ if (Object.isArray(a))
11785
12141
  {
11786
12142
  a.clear();
11787
12143
  }
@@ -12020,7 +12376,7 @@ function $MQL (type,f,myscope,element)
12020
12376
  {
12021
12377
  accept: function ()
12022
12378
  {
12023
- if (typeof(type)=='array')
12379
+ if (Object.isArray(type))
12024
12380
  {
12025
12381
  return type;
12026
12382
  }
@@ -12053,6 +12409,301 @@ function $MQL (type,f,myscope,element)
12053
12409
  return listener;
12054
12410
  }
12055
12411
 
12412
+
12413
+ Appcelerator.Util.ServiceBrokerMarshaller={};
12414
+ Appcelerator.Util.ServiceBrokerMarshaller['xml/json'] =
12415
+ {
12416
+ currentRequestId:1,
12417
+ jsonify:function(msg)
12418
+ {
12419
+ var requestid = this.currentRequestId++;
12420
+ var scope = msg[2];
12421
+ var version = msg[3];
12422
+ var datatype = 'JSON';
12423
+ var data = msg[0]['data'];
12424
+ var xml = "<message requestid='" + requestid + "' type='" + msg[0]['type'] + "' datatype='" + datatype + "' scope='"+scope+"' version='"+version+"'>";
12425
+ xml += '<![CDATA[' + Object.toJSON(data) + ']]>';
12426
+ xml += "</message>";
12427
+ return xml;
12428
+ },
12429
+ serialize: function(messageQueue,multiplex)
12430
+ {
12431
+ var xml = null;
12432
+ if (messageQueue.length > 0)
12433
+ {
12434
+ xml = '';
12435
+ var time = new Date();
12436
+ var timestamp = time.getTime();
12437
+ xml = "<?xml version='1.0'?>\n";
12438
+ var tz = time.getTimezoneOffset()/60;
12439
+ var idleMs = Appcelerator.Util.IdleManager.getIdleTimeInMS();
12440
+ xml += "<request version='1.0' idle='" + idleMs + "' timestamp='"+timestamp+"' tz='"+tz+"'>\n";
12441
+ if (multiplex)
12442
+ {
12443
+ for (var c = 0,len = messageQueue.length; c < len; c++)
12444
+ {
12445
+ xml+=this.jsonify(messageQueue[c]);
12446
+ }
12447
+ }
12448
+ else
12449
+ {
12450
+ xml+=this.jsonify(messageQueue[0]);
12451
+ }
12452
+ xml += "</request>";
12453
+ }
12454
+ return {
12455
+ 'postBody': xml,
12456
+ 'contentType':'text/xml'
12457
+ };
12458
+ },
12459
+ deserialize: function(response,length,contentType)
12460
+ {
12461
+ if (response.status == 202)
12462
+ {
12463
+ return null;
12464
+ }
12465
+ if (contentType.indexOf('text/xml')==-1)
12466
+ {
12467
+ $E(this+', invalid content type: '+contentType+', excepted: text/xml');
12468
+ return null;
12469
+ }
12470
+ var xml = response.responseXML;
12471
+ if (!xml)
12472
+ {
12473
+ return null;
12474
+ }
12475
+ var children = xml.documentElement.childNodes;
12476
+ var msgs = null;
12477
+ if (children && children.length > 0)
12478
+ {
12479
+ msgs = [];
12480
+ for (var c = 0; c < children.length; c++)
12481
+ {
12482
+ var child = children.item(c);
12483
+ if (child.nodeType == Appcelerator.Util.Dom.ELEMENT_NODE)
12484
+ {
12485
+ var requestid = child.getAttribute("requestid");
12486
+ try
12487
+ {
12488
+ var type = child.getAttribute("type");
12489
+ var datatype = child.getAttribute("datatype");
12490
+ var scope = child.getAttribute("scope") || 'appcelerator';
12491
+ var data, text;
12492
+ try
12493
+ {
12494
+ text = Appcelerator.Util.Dom.getText(child);
12495
+ data = text.evalJSON();
12496
+ data.toString = function () { return Object.toJSON(this); };
12497
+ }
12498
+ catch (e)
12499
+ {
12500
+ $E('Error received evaluating: ' + text + ' for type: ' + type + ", error: " + Object.getExceptionDetail(e));
12501
+ return;
12502
+ }
12503
+ $D(this.toString() + ' received remote message, type:' + type + ',data:' + data);
12504
+ msgs.push({type:type,data:data,datatype:datatype,scope:scope,requestid:requestid});
12505
+ }
12506
+ catch (e)
12507
+ {
12508
+ $E(this + ' - Error in dispatch of message. ' + Object.getExceptionDetail(e));
12509
+ }
12510
+ }
12511
+ }
12512
+ }
12513
+ return msgs;
12514
+ }
12515
+ };
12516
+
12517
+
12518
+ function jsonParameterEncode (key, value, array)
12519
+ {
12520
+ switch(typeof(value))
12521
+ {
12522
+ case 'string':
12523
+ case 'number':
12524
+ case 'boolean':
12525
+ {
12526
+ array.push(key+'='+encodeURIComponent(value));
12527
+ break;
12528
+ }
12529
+ case 'array':
12530
+ case 'object':
12531
+ {
12532
+ // check to see if the object is an array
12533
+ if (Object.isArray(value))
12534
+ {
12535
+ for (var c=0;c<value.length;c++)
12536
+ {
12537
+ jsonParameterEncode(key+'.'+c,value[c],array);
12538
+ }
12539
+ }
12540
+ else
12541
+ {
12542
+ for (var p in value)
12543
+ {
12544
+ jsonParameterEncode(key+'.'+p,value[p],array);
12545
+ }
12546
+ }
12547
+ break;
12548
+ }
12549
+ case 'function':
12550
+ {
12551
+ break;
12552
+ }
12553
+ default:
12554
+ {
12555
+ array.push(encodeURIComponent(key)+'=');
12556
+ break;
12557
+ }
12558
+ }
12559
+ }
12560
+
12561
+ function jsonToQueryParams(json)
12562
+ {
12563
+ var parameters = [];
12564
+
12565
+ for (var key in json)
12566
+ {
12567
+ var value = json[key];
12568
+ jsonParameterEncode(key,value,parameters);
12569
+ }
12570
+
12571
+ return parameters.join('&');
12572
+ };
12573
+
12574
+ /**
12575
+ * given an element will encode the element and it's children to
12576
+ * json
12577
+ */
12578
+ function json_encode_xml (node,json)
12579
+ {
12580
+ var obj = {};
12581
+ var found = json[node.nodeName];
12582
+ if (found)
12583
+ {
12584
+ if (Object.isArray(found))
12585
+ {
12586
+ found.push(obj);
12587
+ }
12588
+ else
12589
+ {
12590
+ json[node.nodeName] = [found,obj];
12591
+ }
12592
+ }
12593
+ else
12594
+ {
12595
+ json[node.nodeName] = obj;
12596
+ }
12597
+
12598
+ Appcelerator.Util.Dom.eachAttribute(node,function(name,value)
12599
+ {
12600
+ obj[name]=value;
12601
+ });
12602
+ var added = false;
12603
+ Appcelerator.Util.Dom.each(node.childNodes,Appcelerator.Util.Dom.ELEMENT_NODE,function(child)
12604
+ {
12605
+ json_encode_xml(child,obj);
12606
+ added = true;
12607
+ });
12608
+ if (!added)
12609
+ {
12610
+ var text = Appcelerator.Util.Dom.getText(node);
12611
+ json[node.nodeName] = text;
12612
+ }
12613
+ }
12614
+
12615
+
12616
+ /**
12617
+ * Form URL encoded service marshaller
12618
+ */
12619
+ Appcelerator.Util.ServiceBrokerMarshaller['application/x-www-form-urlencoded'] =
12620
+ {
12621
+ currentRequestId:1,
12622
+ parameterize: function(msg)
12623
+ {
12624
+ var requestid = this.currentRequestId++;
12625
+ var scope = msg[2];
12626
+ var version = msg[3];
12627
+ var datatype = 'JSON';
12628
+ var data = msg[0]['data'];
12629
+
12630
+ var str = '$messagetype='+msg[0]['type']+'&$requestid='+requestid+'&$datatype='+datatype+'&$scope='+scope+'&$version='+version;
12631
+
12632
+ if (data)
12633
+ {
12634
+ str+='&' + jsonToQueryParams(data);
12635
+ }
12636
+ return str;
12637
+ },
12638
+ serialize: function(messageQueue,multiplex)
12639
+ {
12640
+ var xml = null;
12641
+ if (messageQueue.length > 0)
12642
+ {
12643
+ xml = '';
12644
+ if (multiplex)
12645
+ {
12646
+ for (var c = 0,len = messageQueue.length; c < len; c++)
12647
+ {
12648
+ xml+=this.parameterize(messageQueue[c]);
12649
+ }
12650
+ }
12651
+ else
12652
+ {
12653
+ xml+=this.parameterize(messageQueue[0]);
12654
+ }
12655
+ }
12656
+ return {
12657
+ 'postBody': xml,
12658
+ 'contentType':'application/x-www-form-urlencoded'
12659
+ };
12660
+ },
12661
+ deserialize: function(response,length,contentType)
12662
+ {
12663
+ if (response.status == 202)
12664
+ {
12665
+ return null;
12666
+ }
12667
+ if (contentType.indexOf('/json')==-1)
12668
+ {
12669
+ $E(this+', invalid content type: '+contentType+', excepted json mimetype');
12670
+ return null;
12671
+ }
12672
+ return [response.responseText.evalJSON(true)];
12673
+ }
12674
+ };
12675
+
12676
+ Appcelerator.Util.ServiceBrokerTransportHandler = {};
12677
+
12678
+ /**
12679
+ * Appcelerator based protocol transport handler
12680
+ */
12681
+ Appcelerator.Util.ServiceBrokerTransportHandler['appcelerator'] =
12682
+ {
12683
+ prepare: function(serviceBroker,initialrequest,payload,contentType)
12684
+ {
12685
+ // get the auth token
12686
+ var cookieName = Appcelerator.ServerConfig['sessionid'].value||'JSESSIONID';
12687
+ var authToken = Appcelerator.Util.Cookie.GetCookie(cookieName);
12688
+
12689
+ // calculate the token we send back to the server
12690
+ var token = (authToken) ? Appcelerator.Util.MD5.hex_md5(authToken+serviceBroker.instanceid) : '';
12691
+
12692
+ // create parameters for URL
12693
+ var parameters = "?maxwait=" + ((!initialrequest && payload) ? serviceBroker.maxWaitPollTime : serviceBroker.maxWaitPollTimeWhenSending)+"&instanceid="+serviceBroker.instanceid+'&auth='+token+'&ts='+new Date().getTime();
12694
+ var url = serviceBroker.serverPath + parameters;
12695
+ var method = payload ? 'post' : 'get';
12696
+
12697
+ return {
12698
+ 'url':url,
12699
+ 'method': method,
12700
+ 'postBody': payload||'',
12701
+ 'contentType':contentType
12702
+ };
12703
+ }
12704
+ };
12705
+
12706
+
12056
12707
  Appcelerator.Util.ServiceBrokerInterceptor = Class.create();
12057
12708
  /**
12058
12709
  * ServiceBrokerInterceptor interceptor prototype class
@@ -12104,6 +12755,9 @@ else
12104
12755
  }
12105
12756
  Appcelerator.Util.ServiceBroker.serverPath = config.value;
12106
12757
  Appcelerator.Util.ServiceBroker.poll = (config.poll == 'true');
12758
+ Appcelerator.Util.ServiceBroker.multiplex = config.multiplex ? (config.multiplex == 'true') : true;
12759
+ Appcelerator.Util.ServiceBroker.transport = config.transport || Appcelerator.Util.ServiceBroker.transport;
12760
+ Appcelerator.Util.ServiceBroker.marshaller = config.marshaller || Appcelerator.Util.ServiceBroker.marshaller;
12107
12761
  Appcelerator.Util.ServiceBroker.triggerConfig();
12108
12762
  Appcelerator.Util.ServiceBroker.startTimer();
12109
12763
  Logger.info('ServiceBroker ready');
@@ -12148,12 +12802,15 @@ else
12148
12802
  }
12149
12803
  }
12150
12804
 
12805
+
12151
12806
  Appcelerator.Core.onunload(Appcelerator.Util.ServiceBroker.destroy.bind(Appcelerator.Util.ServiceBroker));
12152
12807
  Appcelerator.Compiler.afterDocumentCompile(function()
12153
12808
  {
12154
12809
  Appcelerator.Util.ServiceBroker.triggerComplete();
12155
12810
  });
12156
12811
 
12812
+
12813
+
12157
12814
  Appcelerator.Compiler.registerCustomAction('show',
12158
12815
  {
12159
12816
  build: function(id,action,params)
@@ -12268,6 +12925,7 @@ Appcelerator.Compiler.registerCustomAction('toggle',
12268
12925
  {
12269
12926
  if (Appcelerator.Compiler.isCSSAttribute(key))
12270
12927
  {
12928
+ key = Appcelerator.Compiler.convertCSSAttribute(key);
12271
12929
  switch (key)
12272
12930
  {
12273
12931
  case 'display':
@@ -12330,6 +12988,7 @@ var addsetBuilder =
12330
12988
  var value = obj.value;
12331
12989
  if (Appcelerator.Compiler.isCSSAttribute(key))
12332
12990
  {
12991
+ key = Appcelerator.Compiler.convertCSSAttribute(key);
12333
12992
  return "Element.setStyle('" + id + "',{'" + key + "':" + Appcelerator.Compiler.generateSetter(value) + "})";
12334
12993
  }
12335
12994
  else if (key == 'class')
@@ -12477,14 +13136,6 @@ Appcelerator.Compiler.buildActionFunction = function(id,method,params,checkenabl
12477
13136
  return prefix + 'Appcelerator.Compiler.executeFunction("'+target+'","'+method+'",["'+target+'","'+method+'",this.data,this.scope])' + suffix;
12478
13137
  };
12479
13138
 
12480
- Appcelerator.Compiler.registerCustomAction('execute',
12481
- {
12482
- build: function(id,action,params)
12483
- {
12484
- return Appcelerator.Compiler.buildActionFunction(id,'execute',params);
12485
- }
12486
- });
12487
-
12488
13139
  Appcelerator.Compiler.registerCustomAction('selectOption',
12489
13140
  {
12490
13141
  build: function(id,action,params)
@@ -12971,7 +13622,17 @@ for (var c=0,len=Appcelerator.Compiler.GenericFunctions.length;c<len;c++)
12971
13622
  var f = new GenericActionFunction(gf[1]);
12972
13623
  Appcelerator.Compiler.registerCustomAction(gf[0],f);
12973
13624
  }
12974
- Appcelerator.Compiler.registerCustomAction('history',
13625
+
13626
+ Appcelerator.Compiler.buildCustomAction = function (name)
13627
+ {
13628
+ var action = Appcelerator.Compiler.customActions[name];
13629
+
13630
+ if (!action)
13631
+ {
13632
+ var f = new GenericActionFunction(false);
13633
+ Appcelerator.Compiler.registerCustomAction(name,f);
13634
+ }
13635
+ };Appcelerator.Compiler.registerCustomAction('history',
12975
13636
  {
12976
13637
  build: function(id,action,params)
12977
13638
  {
@@ -13140,7 +13801,6 @@ Appcelerator.Compiler.registerCustomCondition(function(element,condition,action,
13140
13801
  'blur',
13141
13802
  'dblclick',
13142
13803
  'mousedown',
13143
- 'resize',
13144
13804
  'mouseout',
13145
13805
  'mouseover',
13146
13806
  'mousemove',
@@ -13485,7 +14145,33 @@ Appcelerator.Compiler.MessageAction.makeMBListener = function(element,type,actio
13485
14145
 
13486
14146
  return true;
13487
14147
  };
13488
-
14148
+ Appcelerator.Compiler.registerCustomCondition(function(element,condition,action,elseAction,delay,ifCond)
14149
+ {
14150
+ if (condition == 'resize')
14151
+ {
14152
+ if (!element.getAttribute('resizable'))
14153
+ {
14154
+ throw "resize condition only applies to elements that have resizable attribute";
14155
+ }
14156
+
14157
+ if (!element.resizeListeners)
14158
+ {
14159
+ element.resizeListeners = [];
14160
+ }
14161
+
14162
+ var actionFunc = Appcelerator.Compiler.makeConditionalAction(element.id,action,ifCond);
14163
+ element.resizeListeners.push(
14164
+ {
14165
+ onResize: function(e)
14166
+ {
14167
+ Appcelerator.Compiler.executeAfter(actionFunc,delay,{id:element.id});
14168
+ }
14169
+ });
14170
+ return true;
14171
+ }
14172
+
14173
+ return false;
14174
+ });
13489
14175
  Appcelerator.Compiler.Selected = {};
13490
14176
  Appcelerator.Compiler.Selected.makeSelectedListener = function(element,condition,action,elseAction,delay,ifCond)
13491
14177
  {
@@ -14664,6 +15350,11 @@ Appcelerator.Compiler.afterDocumentCompile(function()
14664
15350
  {
14665
15351
  Appcelerator.History.loadIE();
14666
15352
  }
15353
+ else if (Appcelerator.Compiler.isCompiledMode)
15354
+ {
15355
+ // init.js does not define history, maybe it should
15356
+ return;
15357
+ }
14667
15358
  else
14668
15359
  {
14669
15360
  // THIS TRICK CAME FROM YUI's HISTORY COMPONENT
@@ -14897,6 +15588,11 @@ if (Appcelerator.Browser.isIE6)
14897
15588
 
14898
15589
  Appcelerator.Browser.fixBackgroundPNG = function(obj)
14899
15590
  {
15591
+ if (obj.style.backgroundImage.indexOf('blank_1x1.gif') > 0)
15592
+ {
15593
+ obj.style.backgroundImage = '';
15594
+ }
15595
+ obj.style.filter = '';
14900
15596
  var bg = obj.currentStyle.backgroundImage;
14901
15597
  var src = bg.substring(5,bg.length-2);
14902
15598
  var scale = obj.currentStyle.backgroundRepeat == 'no-repeat' ? 'image' : 'scale';
@@ -14958,7 +15654,7 @@ Appcelerator.Browser.fixImageIssues = function()
14958
15654
 
14959
15655
  for (var i = document.all.length - 1, obj = null; (obj = document.all[i]); i--)
14960
15656
  {
14961
- if (obj.currentStyle.backgroundImage.match(/\.png/i) != null)
15657
+ if (obj.currentStyle.backgroundImage.match(/(\.png)|(blank_1x1\.gif)/i) != null)
14962
15658
  {
14963
15659
  Appcelerator.Browser.fixBackgroundPNG(obj);
14964
15660
  //obj.attachEvent("onpropertychange", fnPropertyChanged);
@@ -15800,11 +16496,11 @@ Appcelerator.Util.MD5 =
15800
16496
  // register our input button listener for handling
15801
16497
  // activators
15802
16498
  //
15803
- Appcelerator.Compiler.registerAttributeProcessor('input','activators',
16499
+ Appcelerator.Compiler.registerAttributeProcessor(['div','input','button'],'activators',
15804
16500
  {
15805
16501
  handle: function(element,attribute,value)
15806
16502
  {
15807
- if (value && element.getAttribute('type') == 'button')
16503
+ if (value && (element.nodeName == 'DIV' || element.getAttribute('type') == 'button' || element.nodeName == 'BUTTON'))
15808
16504
  {
15809
16505
  // see if we're part of a field set and if so, add
15810
16506
  // our reference
@@ -15826,7 +16522,17 @@ Appcelerator.Compiler.registerAttributeProcessor('input','activators',
15826
16522
  break;
15827
16523
  }
15828
16524
  }
16525
+ element.setAttribute('disabled',!valid);
15829
16526
  element.disabled = !valid;
16527
+
16528
+ if (element.disabled && element.onActivatorsDisable)
16529
+ {
16530
+ element.onActivatorsDisable();
16531
+ }
16532
+ if (!element.disabled && element.onActivatorsEnable)
16533
+ {
16534
+ element.onActivatorsEnable();
16535
+ }
15830
16536
  };
15831
16537
  for (var c=0,len=fields.length;c<len;c++)
15832
16538
  {
@@ -16045,6 +16751,38 @@ Appcelerator.Compiler.registerAttributeProcessor('*','on',
16045
16751
  }
16046
16752
  }
16047
16753
  });//
16754
+ // register our resizable attribute listener
16755
+ //
16756
+ Appcelerator.Compiler.registerAttributeProcessor(['div','img', 'table'],'resizable',
16757
+ {
16758
+ handle: function(element,attribute,value)
16759
+ {
16760
+ if (value && value!='false')
16761
+ {
16762
+ var options = value == "true" ? {} : value.evalJSON();
16763
+ options.resize = function(e)
16764
+ {
16765
+ var listeners = element.resizeListeners;
16766
+ if (listeners && listeners.length > 0)
16767
+ {
16768
+ for (var c=0;c<listeners.length;c++)
16769
+ {
16770
+ var cb = listeners[c];
16771
+ cb.onResize(e);
16772
+ }
16773
+ }
16774
+ };
16775
+
16776
+ element.resizable = new Resizeable(element.id, options);
16777
+
16778
+ Appcelerator.Compiler.addTrash(element, function()
16779
+ {
16780
+ element.resizable.destroy();
16781
+ });
16782
+ }
16783
+ }
16784
+ });
16785
+ //
16048
16786
  // add a selectable attribute which implements a single state selection
16049
16787
  // for all children of element passed in
16050
16788
  //