ruboss4ruby 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/Generators +5 -0
  2. data/Manifest.txt +39 -41
  3. data/Rakefile +2 -1
  4. data/lib/ruboss4ruby.rb +16 -12
  5. data/lib/ruboss4ruby/active_foo.rb +39 -3
  6. data/lib/ruboss4ruby/recipes.rb +62 -0
  7. data/lib/ruboss4ruby/ruboss_helper.rb +54 -0
  8. data/lib/ruboss4ruby/ruboss_test_helpers.rb +31 -0
  9. data/lib/ruboss4ruby/tasks.rb +0 -2
  10. data/lib/ruboss4ruby/version.rb +2 -2
  11. data/merb_generators/ruboss_config.rb +19 -19
  12. data/merb_generators/ruboss_controller.rb +3 -3
  13. data/merb_generators/ruboss_flex_app.rb +3 -3
  14. data/merb_generators/ruboss_resource_controller.rb +3 -3
  15. data/merb_generators/ruboss_scaffold.rb +47 -47
  16. data/rails_generators/ruboss_config/ruboss_config_generator.rb +2 -2
  17. data/rails_generators/ruboss_config/templates/index.html.erb +2 -2
  18. data/rails_generators/ruboss_config/templates/mainapp-config.xml +21 -0
  19. data/rails_generators/ruboss_config/templates/mainapp.mxml +4 -7
  20. data/rails_generators/ruboss_config/templates/project-textmate.erb +52 -0
  21. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +0 -2
  22. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -2
  23. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +4 -3
  24. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -1
  25. data/test/controllers/application.rb +15 -0
  26. data/test/controllers/locations_controller.rb +93 -0
  27. data/test/controllers/notes_controller.rb +96 -0
  28. data/test/controllers/projects_controller.rb +93 -0
  29. data/test/controllers/tasks_controller.rb +93 -0
  30. data/test/controllers/users_controller.rb +93 -0
  31. data/test/database.yml +4 -0
  32. data/test/fixtures/locations.yml +8 -0
  33. data/test/fixtures/notes.yml +17 -0
  34. data/test/fixtures/projects.yml +25 -0
  35. data/test/fixtures/tasks.yml +46 -0
  36. data/test/fixtures/users.yml +13 -0
  37. data/test/helpers/controllers.log +8 -0
  38. data/test/helpers/functional_test_helper.rb +32 -0
  39. data/test/helpers/models.log +170 -0
  40. data/test/helpers/test_helper.rb +25 -0
  41. data/test/helpers/unit_test_helper.rb +23 -0
  42. data/test/model.yml +35 -0
  43. data/test/models/location.rb +4 -0
  44. data/test/models/note.rb +3 -0
  45. data/test/models/project.rb +6 -0
  46. data/test/models/task.rb +20 -0
  47. data/test/models/user.rb +23 -0
  48. data/test/playing_around_in_a_console.txt +71 -0
  49. data/test/schema.rb +63 -0
  50. data/test/test.sqlite3 +0 -0
  51. data/test/test.swf +1 -0
  52. data/test/test_active_foo.rb +79 -0
  53. data/test/test_ruboss_rails_integration_functional.rb +27 -0
  54. data/test/test_swfobject_helper.rb +63 -0
  55. data/test/to_fxml_test.rb +79 -0
  56. data/test/views/notes/empty_params_action.html.erb +1 -0
  57. data/test/views/notes/index.html.erb +1 -0
  58. metadata +57 -52
  59. data/merb_generators/ruboss_config/USAGE +0 -18
  60. data/merb_generators/ruboss_config/ruboss_config_generator.rb +0 -135
  61. data/merb_generators/ruboss_config/templates/actionscript.properties +0 -16
  62. data/merb_generators/ruboss_config/templates/actionscriptair.properties +0 -16
  63. data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
  64. data/merb_generators/ruboss_config/templates/flex.properties +0 -2
  65. data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +0 -276
  66. data/merb_generators/ruboss_config/templates/html-template/history/history.css +0 -6
  67. data/merb_generators/ruboss_config/templates/html-template/history/history.js +0 -645
  68. data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +0 -29
  69. data/merb_generators/ruboss_config/templates/html-template/index.template.html +0 -121
  70. data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  71. data/merb_generators/ruboss_config/templates/index.html.erb +0 -18
  72. data/merb_generators/ruboss_config/templates/mainair-app.xml +0 -134
  73. data/merb_generators/ruboss_config/templates/mainapp.mxml +0 -34
  74. data/merb_generators/ruboss_config/templates/project.properties +0 -18
  75. data/merb_generators/ruboss_config/templates/projectair.properties +0 -24
  76. data/merb_generators/ruboss_config/templates/swfobject.js +0 -5
  77. data/merb_generators/ruboss_controller/USAGE +0 -11
  78. data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +0 -32
  79. data/merb_generators/ruboss_resource_controller/USAGE +0 -5
  80. data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +0 -70
  81. data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -55
  82. data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
  83. data/merb_generators/ruboss_scaffold/USAGE +0 -5
  84. data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +0 -127
  85. data/merb_generators/ruboss_yaml_scaffold/USAGE +0 -5
  86. data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +0 -53
  87. data/merb_generators/templates/ruboss_scaffold/component.mxml.erb +0 -148
  88. data/merb_generators/templates/ruboss_scaffold/fixtures.yml.erb +0 -35
  89. data/merb_generators/templates/ruboss_scaffold/migration.rb.erb +0 -19
  90. data/merb_generators/templates/ruboss_scaffold/model.as.erb +0 -42
  91. data/merb_generators/templates/ruboss_scaffold/model.rb.erb +0 -11
  92. data/test/active_foo_test.rb +0 -16
  93. data/test/test_generator_helper.rb +0 -29
  94. data/test/test_helper.rb +0 -2
  95. data/test/test_ruboss_config_generator.rb +0 -45
  96. data/test/test_ruboss_controller_generator.rb +0 -45
  97. data/test/test_ruboss_on_ruby.rb +0 -11
  98. data/test/test_ruboss_scaffold_generator.rb +0 -45
  99. data/test/test_ruboss_yaml_scaffold_generator.rb +0 -46
@@ -1,6 +0,0 @@
1
- /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */
2
-
3
- #ie_historyFrame { width: 0px; height: 0px; display:none }
4
- #firefox_anchorDiv { width: 0px; height: 0px; display:none }
5
- #safari_formDiv { width: 0px; height: 0px; display:none }
6
- #safari_rememberDiv { width: 0px; height: 0px; display:none }
@@ -1,645 +0,0 @@
1
- BrowserHistoryUtils = {
2
- addEvent: function(elm, evType, fn, useCapture) {
3
- useCapture = useCapture || false;
4
- if (elm.addEventListener) {
5
- elm.addEventListener(evType, fn, useCapture);
6
- return true;
7
- }
8
- else if (elm.attachEvent) {
9
- var r = elm.attachEvent('on' + evType, fn);
10
- return r;
11
- }
12
- else {
13
- elm['on' + evType] = fn;
14
- }
15
- }
16
- }
17
-
18
- BrowserHistory = (function() {
19
- // type of browser
20
- var browser = {
21
- ie: false,
22
- firefox: false,
23
- safari: false,
24
- opera: false,
25
- version: -1
26
- };
27
-
28
- // if setDefaultURL has been called, our first clue
29
- // that the SWF is ready and listening
30
- //var swfReady = false;
31
-
32
- // the URL we'll send to the SWF once it is ready
33
- //var pendingURL = '';
34
-
35
- // Default app state URL to use when no fragment ID present
36
- var defaultHash = '';
37
-
38
- // Last-known app state URL
39
- var currentHref = document.location.href;
40
-
41
- // Initial URL (used only by IE)
42
- var initialHref = document.location.href;
43
-
44
- // Initial URL (used only by IE)
45
- var initialHash = document.location.hash;
46
-
47
- // History frame source URL prefix (used only by IE)
48
- var historyFrameSourcePrefix = 'history/historyFrame.html?';
49
-
50
- // History maintenance (used only by Safari)
51
- var currentHistoryLength = -1;
52
-
53
- var historyHash = [];
54
-
55
- var initialState = createState(initialHref, initialHref + '#' + initialHash, initialHash);
56
-
57
- var backStack = [];
58
- var forwardStack = [];
59
-
60
- var currentObjectId = null;
61
-
62
- //UserAgent detection
63
- var useragent = navigator.userAgent.toLowerCase();
64
-
65
- if (useragent.indexOf("opera") != -1) {
66
- browser.opera = true;
67
- } else if (useragent.indexOf("msie") != -1) {
68
- browser.ie = true;
69
- browser.version = parseFloat(useragent.substring(useragent.indexOf('msie') + 4));
70
- } else if (useragent.indexOf("safari") != -1) {
71
- browser.safari = true;
72
- browser.version = parseFloat(useragent.substring(useragent.indexOf('safari') + 7));
73
- } else if (useragent.indexOf("gecko") != -1) {
74
- browser.firefox = true;
75
- }
76
-
77
- if (browser.ie == true && browser.version == 7) {
78
- window["_ie_firstload"] = false;
79
- }
80
-
81
- // Accessor functions for obtaining specific elements of the page.
82
- function getHistoryFrame()
83
- {
84
- return document.getElementById('ie_historyFrame');
85
- }
86
-
87
- function getAnchorElement()
88
- {
89
- return document.getElementById('firefox_anchorDiv');
90
- }
91
-
92
- function getFormElement()
93
- {
94
- return document.getElementById('safari_formDiv');
95
- }
96
-
97
- function getRememberElement()
98
- {
99
- return document.getElementById("safari_remember_field");
100
- }
101
-
102
- /* Get the Flash player object for performing ExternalInterface callbacks. */
103
- function getPlayer(objectId) {
104
- var objectId = objectId || null;
105
- var player = null; /* AJH, needed? = document.getElementById(getPlayerId()); */
106
- if (browser.ie && objectId != null) {
107
- player = document.getElementById(objectId);
108
- }
109
- if (player == null) {
110
- player = document.getElementsByTagName('object')[0];
111
- }
112
-
113
- if (player == null || player.object == null) {
114
- player = document.getElementsByTagName('embed')[0];
115
- }
116
-
117
- return player;
118
- }
119
-
120
- function getPlayers() {
121
- var players = [];
122
- if (players.length == 0) {
123
- var tmp = document.getElementsByTagName('object');
124
- players = tmp;
125
- }
126
-
127
- if (players.length == 0 || players[0].object == null) {
128
- var tmp = document.getElementsByTagName('embed');
129
- players = tmp;
130
- }
131
- return players;
132
- }
133
-
134
- function getIframeHash() {
135
- var doc = getHistoryFrame().contentWindow.document;
136
- var hash = String(doc.location.search);
137
- if (hash.length == 1 && hash.charAt(0) == "?") {
138
- hash = "";
139
- }
140
- else if (hash.length >= 2 && hash.charAt(0) == "?") {
141
- hash = hash.substring(1);
142
- }
143
- return hash;
144
- }
145
-
146
- /* Get the current location hash excluding the '#' symbol. */
147
- function getHash() {
148
- // It would be nice if we could use document.location.hash here,
149
- // but it's faulty sometimes.
150
- var idx = document.location.href.indexOf('#');
151
- return (idx >= 0) ? document.location.href.substr(idx+1) : '';
152
- }
153
-
154
- /* Get the current location hash excluding the '#' symbol. */
155
- function setHash(hash) {
156
- // It would be nice if we could use document.location.hash here,
157
- // but it's faulty sometimes.
158
- if (hash == '') hash = '#'
159
- document.location.hash = hash;
160
- }
161
-
162
- function createState(baseUrl, newUrl, flexAppUrl) {
163
- return { 'baseUrl': baseUrl, 'newUrl': newUrl, 'flexAppUrl': flexAppUrl, 'title': null };
164
- }
165
-
166
- /* Add a history entry to the browser.
167
- * baseUrl: the portion of the location prior to the '#'
168
- * newUrl: the entire new URL, including '#' and following fragment
169
- * flexAppUrl: the portion of the location following the '#' only
170
- */
171
- function addHistoryEntry(baseUrl, newUrl, flexAppUrl) {
172
-
173
- //delete all the history entries
174
- forwardStack = [];
175
-
176
- if (browser.ie) {
177
- //Check to see if we are being asked to do a navigate for the first
178
- //history entry, and if so ignore, because it's coming from the creation
179
- //of the history iframe
180
- if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) {
181
- currentHref = initialHref;
182
- return;
183
- }
184
- if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) {
185
- newUrl = baseUrl + '#' + defaultHash;
186
- flexAppUrl = defaultHash;
187
- } else {
188
- // for IE, tell the history frame to go somewhere without a '#'
189
- // in order to get this entry into the browser history.
190
- getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl;
191
- }
192
- setHash(flexAppUrl);
193
- } else {
194
-
195
- //ADR
196
- if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) {
197
- initialState = createState(baseUrl, newUrl, flexAppUrl);
198
- } else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) {
199
- backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl);
200
- }
201
-
202
- if (browser.safari) {
203
- // for Safari, submit a form whose action points to the desired URL
204
- if (browser.version <= 419.3) {
205
- var file = window.location.pathname.toString();
206
- file = file.substring(file.lastIndexOf("/")+1);
207
- getFormElement().innerHTML = '<form name="historyForm" action="'+file+'#' + flexAppUrl + '" method="GET"></form>';
208
- //get the current elements and add them to the form
209
- var qs = window.location.search.substring(1);
210
- var qs_arr = qs.split("&");
211
- for (var i = 0; i < qs_arr.length; i++) {
212
- var tmp = qs_arr[i].split("=");
213
- var elem = document.createElement("input");
214
- elem.type = "hidden";
215
- elem.name = tmp[0];
216
- elem.value = tmp[1];
217
- document.forms.historyForm.appendChild(elem);
218
- }
219
- document.forms.historyForm.submit();
220
- } else {
221
- top.location.hash = flexAppUrl;
222
- }
223
- // We also have to maintain the history by hand for Safari
224
- historyHash[history.length] = flexAppUrl;
225
- _storeStates();
226
- } else {
227
- // Otherwise, write an anchor into the page and tell the browser to go there
228
- addAnchor(flexAppUrl);
229
- setHash(flexAppUrl);
230
- }
231
- }
232
- backStack.push(createState(baseUrl, newUrl, flexAppUrl));
233
- }
234
-
235
- function _storeStates() {
236
- if (browser.safari) {
237
- getRememberElement().value = historyHash.join(",");
238
- }
239
- }
240
-
241
- function handleBackButton() {
242
- //The "current" page is always at the top of the history stack.
243
- var current = backStack.pop();
244
- if (!current) { return; }
245
- var last = backStack[backStack.length - 1];
246
- if (!last && backStack.length == 0){
247
- last = initialState;
248
- }
249
- forwardStack.push(current);
250
- }
251
-
252
- function handleForwardButton() {
253
- //summary: private method. Do not call this directly.
254
-
255
- var last = forwardStack.pop();
256
- if (!last) { return; }
257
- backStack.push(last);
258
- }
259
-
260
- function handleArbitraryUrl() {
261
- //delete all the history entries
262
- forwardStack = [];
263
- }
264
-
265
- /* Called periodically to poll to see if we need to detect navigation that has occurred */
266
- function checkForUrlChange() {
267
-
268
- if (browser.ie) {
269
- if (currentHref != document.location.href && currentHref + '#' != document.location.href) {
270
- //This occurs when the user has navigated to a specific URL
271
- //within the app, and didn't use browser back/forward
272
- //IE seems to have a bug where it stops updating the URL it
273
- //shows the end-user at this point, but programatically it
274
- //appears to be correct. Do a full app reload to get around
275
- //this issue.
276
- if (browser.version < 7) {
277
- currentHref = document.location.href;
278
- document.location.reload();
279
- } else {
280
- if (getHash() != getIframeHash()) {
281
- // this.iframe.src = this.blankURL + hash;
282
- var sourceToSet = historyFrameSourcePrefix + getHash();
283
- getHistoryFrame().src = sourceToSet;
284
- }
285
- }
286
- }
287
- }
288
-
289
- if (browser.safari) {
290
- // For Safari, we have to check to see if history.length changed.
291
- if (currentHistoryLength >= 0 && history.length != currentHistoryLength) {
292
- //alert("did change: " + history.length + ", " + historyHash.length + "|" + historyHash[history.length] + "|>" + historyHash.join("|"));
293
- // If it did change, then we have to look the old state up
294
- // in our hand-maintained array since document.location.hash
295
- // won't have changed, then call back into BrowserManager.
296
- currentHistoryLength = history.length;
297
- var flexAppUrl = historyHash[currentHistoryLength];
298
- if (flexAppUrl == '') {
299
- //flexAppUrl = defaultHash;
300
- }
301
- //ADR: to fix multiple
302
- if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
303
- var pl = getPlayers();
304
- for (var i = 0; i < pl.length; i++) {
305
- pl[i].browserURLChange(flexAppUrl);
306
- }
307
- } else {
308
- getPlayer().browserURLChange(flexAppUrl);
309
- }
310
- _storeStates();
311
- }
312
- }
313
- if (browser.firefox) {
314
- if (currentHref != document.location.href) {
315
- var bsl = backStack.length;
316
-
317
- var urlActions = {
318
- back: false,
319
- forward: false,
320
- set: false
321
- }
322
-
323
- if ((window.location.hash == initialHash || window.location.href == initialHref) && (bsl == 1)) {
324
- urlActions.back = true;
325
- // FIXME: could this ever be a forward button?
326
- // we can't clear it because we still need to check for forwards. Ugg.
327
- // clearInterval(this.locationTimer);
328
- handleBackButton();
329
- }
330
-
331
- // first check to see if we could have gone forward. We always halt on
332
- // a no-hash item.
333
- if (forwardStack.length > 0) {
334
- if (forwardStack[forwardStack.length-1].flexAppUrl == getHash()) {
335
- urlActions.forward = true;
336
- handleForwardButton();
337
- }
338
- }
339
-
340
- // ok, that didn't work, try someplace back in the history stack
341
- if ((bsl >= 2) && (backStack[bsl - 2])) {
342
- if (backStack[bsl - 2].flexAppUrl == getHash()) {
343
- urlActions.back = true;
344
- handleBackButton();
345
- }
346
- }
347
-
348
- if (!urlActions.back && !urlActions.forward) {
349
- var foundInStacks = {
350
- back: -1,
351
- forward: -1
352
- }
353
-
354
- for (var i = 0; i < backStack.length; i++) {
355
- if (backStack[i].flexAppUrl == getHash() && i != (bsl - 2)) {
356
- arbitraryUrl = true;
357
- foundInStacks.back = i;
358
- }
359
- }
360
- for (var i = 0; i < forwardStack.length; i++) {
361
- if (forwardStack[i].flexAppUrl == getHash() && i != (bsl - 2)) {
362
- arbitraryUrl = true;
363
- foundInStacks.forward = i;
364
- }
365
- }
366
- handleArbitraryUrl();
367
- }
368
-
369
- // Firefox changed; do a callback into BrowserManager to tell it.
370
- currentHref = document.location.href;
371
- var flexAppUrl = getHash();
372
- if (flexAppUrl == '') {
373
- //flexAppUrl = defaultHash;
374
- }
375
- //ADR: to fix multiple
376
- if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
377
- var pl = getPlayers();
378
- for (var i = 0; i < pl.length; i++) {
379
- pl[i].browserURLChange(flexAppUrl);
380
- }
381
- } else {
382
- getPlayer().browserURLChange(flexAppUrl);
383
- }
384
- }
385
- }
386
- //setTimeout(checkForUrlChange, 50);
387
- }
388
-
389
- /* Write an anchor into the page to legitimize it as a URL for Firefox et al. */
390
- function addAnchor(flexAppUrl)
391
- {
392
- if (document.getElementsByName(flexAppUrl).length == 0) {
393
- getAnchorElement().innerHTML += "<a name='" + flexAppUrl + "'>" + flexAppUrl + "</a>";
394
- }
395
- }
396
-
397
- var _initialize = function () {
398
- if (browser.ie)
399
- {
400
- var scripts = document.getElementsByTagName('script');
401
- for (var i = 0, s; s = scripts[i]; i++) {
402
- if (s.src.indexOf("history.js") > -1) {
403
- var iframe_location = (new String(s.src)).replace("history.js", "historyFrame.html");
404
- }
405
- }
406
- historyFrameSourcePrefix = iframe_location + "?";
407
- var src = historyFrameSourcePrefix;
408
-
409
- var iframe = document.createElement("iframe");
410
- iframe.id = 'ie_historyFrame';
411
- iframe.name = 'ie_historyFrame';
412
- //iframe.src = historyFrameSourcePrefix;
413
- try {
414
- document.body.appendChild(iframe);
415
- } catch(e) {
416
- setTimeout(function() {
417
- document.body.appendChild(iframe);
418
- }, 0);
419
- }
420
- }
421
-
422
- if (browser.safari)
423
- {
424
- var rememberDiv = document.createElement("div");
425
- rememberDiv.id = 'safari_rememberDiv';
426
- document.body.appendChild(rememberDiv);
427
- rememberDiv.innerHTML = '<input type="text" id="safari_remember_field" style="width: 500px;">';
428
-
429
- var formDiv = document.createElement("div");
430
- formDiv.id = 'safari_formDiv';
431
- document.body.appendChild(formDiv);
432
-
433
- var reloader_content = document.createElement('div');
434
- reloader_content.id = 'safarireloader';
435
- var scripts = document.getElementsByTagName('script');
436
- for (var i = 0, s; s = scripts[i]; i++) {
437
- if (s.src.indexOf("history.js") > -1) {
438
- html = (new String(s.src)).replace(".js", ".html");
439
- }
440
- }
441
- reloader_content.innerHTML = '<iframe id="safarireloader-iframe" src="about:blank" frameborder="no" scrolling="no"></iframe>';
442
- document.body.appendChild(reloader_content);
443
- reloader_content.style.position = 'absolute';
444
- reloader_content.style.left = reloader_content.style.top = '-9999px';
445
- iframe = reloader_content.getElementsByTagName('iframe')[0];
446
-
447
- if (document.getElementById("safari_remember_field").value != "" ) {
448
- historyHash = document.getElementById("safari_remember_field").value.split(",");
449
- }
450
-
451
- }
452
-
453
- if (browser.firefox)
454
- {
455
- var anchorDiv = document.createElement("div");
456
- anchorDiv.id = 'firefox_anchorDiv';
457
- document.body.appendChild(anchorDiv);
458
- }
459
-
460
- //setTimeout(checkForUrlChange, 50);
461
- }
462
-
463
- return {
464
- historyHash: historyHash,
465
- backStack: function() { return backStack; },
466
- forwardStack: function() { return forwardStack },
467
- getPlayer: getPlayer,
468
- initialize: function(src) {
469
- _initialize(src);
470
- },
471
- setURL: function(url) {
472
- document.location.href = url;
473
- },
474
- getURL: function() {
475
- return document.location.href;
476
- },
477
- getTitle: function() {
478
- return document.title;
479
- },
480
- setTitle: function(title) {
481
- try {
482
- backStack[backStack.length - 1].title = title;
483
- } catch(e) { }
484
- //if on safari, set the title to be the empty string.
485
- if (browser.safari) {
486
- if (title == "") {
487
- try {
488
- var tmp = window.location.href.toString();
489
- title = tmp.substring((tmp.lastIndexOf("/")+1), tmp.lastIndexOf("#"));
490
- } catch(e) {
491
- title = "";
492
- }
493
- }
494
- }
495
- document.title = title;
496
- },
497
- setDefaultURL: function(def)
498
- {
499
- defaultHash = def;
500
- def = getHash();
501
- //trailing ? is important else an extra frame gets added to the history
502
- //when navigating back to the first page. Alternatively could check
503
- //in history frame navigation to compare # and ?.
504
- if (browser.ie)
505
- {
506
- window['_ie_firstload'] = true;
507
- var sourceToSet = historyFrameSourcePrefix + def;
508
- var func = function() {
509
- getHistoryFrame().src = sourceToSet;
510
- window.location.replace("#" + def);
511
- setInterval(checkForUrlChange, 50);
512
- }
513
- try {
514
- func();
515
- } catch(e) {
516
- window.setTimeout(function() { func(); }, 0);
517
- }
518
- }
519
-
520
- if (browser.safari)
521
- {
522
- currentHistoryLength = history.length;
523
- if (historyHash.length == 0) {
524
- historyHash[currentHistoryLength] = def;
525
- var newloc = "#" + def;
526
- window.location.replace(newloc);
527
- } else {
528
- //alert(historyHash[historyHash.length-1]);
529
- }
530
- //setHash(def);
531
- setInterval(checkForUrlChange, 50);
532
- }
533
-
534
-
535
- if (browser.firefox || browser.opera)
536
- {
537
- var reg = new RegExp("#" + def + "$");
538
- if (window.location.toString().match(reg)) {
539
- } else {
540
- var newloc ="#" + def;
541
- window.location.replace(newloc);
542
- }
543
- setInterval(checkForUrlChange, 50);
544
- //setHash(def);
545
- }
546
-
547
- },
548
-
549
- /* Set the current browser URL; called from inside BrowserManager to propagate
550
- * the application state out to the container.
551
- */
552
- setBrowserURL: function(flexAppUrl, objectId) {
553
- if (browser.ie && typeof objectId != "undefined") {
554
- currentObjectId = objectId;
555
- }
556
- //fromIframe = fromIframe || false;
557
- //fromFlex = fromFlex || false;
558
- //alert("setBrowserURL: " + flexAppUrl);
559
- //flexAppUrl = (flexAppUrl == "") ? defaultHash : flexAppUrl ;
560
-
561
- var pos = document.location.href.indexOf('#');
562
- var baseUrl = pos != -1 ? document.location.href.substr(0, pos) : document.location.href;
563
- var newUrl = baseUrl + '#' + flexAppUrl;
564
-
565
- if (document.location.href != newUrl && document.location.href + '#' != newUrl) {
566
- currentHref = newUrl;
567
- addHistoryEntry(baseUrl, newUrl, flexAppUrl);
568
- currentHistoryLength = history.length;
569
- }
570
-
571
- return false;
572
- },
573
-
574
- browserURLChange: function(flexAppUrl) {
575
- var objectId = null;
576
- if (browser.ie && currentObjectId != null) {
577
- objectId = currentObjectId;
578
- }
579
- pendingURL = '';
580
-
581
- if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) {
582
- var pl = getPlayers();
583
- for (var i = 0; i < pl.length; i++) {
584
- try {
585
- pl[i].browserURLChange(flexAppUrl);
586
- } catch(e) { }
587
- }
588
- } else {
589
- try {
590
- getPlayer(objectId).browserURLChange(flexAppUrl);
591
- } catch(e) { }
592
- }
593
-
594
- currentObjectId = null;
595
- }
596
-
597
- }
598
-
599
- })();
600
-
601
- // Initialization
602
-
603
- // Automated unit testing and other diagnostics
604
-
605
- function setURL(url)
606
- {
607
- document.location.href = url;
608
- }
609
-
610
- function backButton()
611
- {
612
- history.back();
613
- }
614
-
615
- function forwardButton()
616
- {
617
- history.forward();
618
- }
619
-
620
- function goForwardOrBackInHistory(step)
621
- {
622
- history.go(step);
623
- }
624
-
625
- //BrowserHistoryUtils.addEvent(window, "load", function() { BrowserHistory.initialize(); });
626
- (function(i) {
627
- var u =navigator.userAgent;var e=/*@cc_on!@*/false;
628
- var st = setTimeout;
629
- if(/webkit/i.test(u)){
630
- st(function(){
631
- var dr=document.readyState;
632
- if(dr=="loaded"||dr=="complete"){i()}
633
- else{st(arguments.callee,10);}},10);
634
- } else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
635
- document.addEventListener("DOMContentLoaded",i,false);
636
- } else if(e){
637
- (function(){
638
- var t=document.createElement('doc:rdy');
639
- try{t.doScroll('left');
640
- i();t=null;
641
- }catch(e){st(arguments.callee,0);}})();
642
- } else{
643
- window.onload=i;
644
- }
645
- })( function() {BrowserHistory.initialize();} );