Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/v0.4'

  • Loading branch information...
commit dc52b62f634c36f96cb1845ba565a2625f2da653 2 parents e4b47b7 + 8c2f925
@sergi sergi authored
Showing with 65,524 additions and 113,702 deletions.
  1. +3 −3 .gitmodules
  2. +1 −1  README.md
  3. +1 −1  bin/cloud9.js
  4. +12 −0 client/core/util.js
  5. +123 −0 client/ext/beautify/beautify.js
  6. +1,146 −0 client/ext/beautify/res/jsbeautify/jsbeautify.js
  7. +19 −0 client/ext/beautify/settings.xml
  8. +4 −0 client/ext/code/proxydocument.js
  9. +1 −1  client/ext/code/settings.xml
  10. +1 −0  client/ext/console/console.js
  11. +2 −0  client/ext/debugger/debugger.js
  12. +79 −0 client/ext/dockpanel/dock.html
  13. +1,353 −0 client/ext/dockpanel/dock.js
  14. +14 −2 client/ext/dockpanel/dockpanel.js
  15. +35 −0 client/ext/dockpanel/docktest.html
  16. +80 −0 client/ext/dockpanel/docktest.js
  17. +1,295 −0 client/ext/dockpanel/libdock.js
  18. +5 −4 client/ext/editors/editors.js
  19. +1 −1  client/ext/extension_template/extension_template_stripped.js
  20. +75 −53 client/ext/filesystem/filesystem.js
  21. +1 −1  client/ext/gotofile/gotofile.js
  22. +3 −4 client/ext/gotofile/gotofile.xml
  23. +1 −1  client/ext/gotoline/skin.xml
  24. +3 −0  client/ext/keybindings_default/default_mac.js
  25. +3 −0  client/ext/keybindings_default/default_win.js
  26. +27 −1 client/ext/newresource/newresource.js
  27. +2 −2 client/ext/noderunner/noderunner.js
  28. +23 −11 client/ext/openfiles/openfiles.xml
  29. BIN  client/ext/quicksearch/icons/rounded_close.png
  30. +4 −0 client/ext/quicksearch/quicksearch.js
  31. +2 −2 client/ext/quicksearch/quicksearch.xml
  32. +1 −1  client/ext/quicksearch/skin.xml
  33. +65 −0 client/ext/save/save.css
  34. +66 −13 client/ext/save/save.js
  35. +111 −63 client/ext/save/save.xml
  36. +33 −9 client/ext/searchinfiles/searchinfiles.js
  37. +23 −13 client/ext/searchinfiles/searchinfiles.xml
  38. +2 −4 client/ext/searchinfiles/skin.xml
  39. +18 −7 client/ext/settings/settings.xml
  40. +3 −3 client/ext/settings/skin.xml
  41. +6 −0 client/ext/settings/template.xml
  42. +95 −11 client/ext/tree/tree.js
  43. +20 −4 client/ext/tree/tree.xml
  44. +6 −2 client/ext/undo/undo.js
  45. +51,862 −112,844 client/js/apf_debug.js
  46. +8,117 −339 client/js/apf_release.js
  47. +7 −3 client/js/modules.js
  48. +1 −1  client/style/error.css
  49. BIN  client/style/images/checkbox-blue.png
  50. BIN  client/style/images/signin_bitbucket.png
  51. BIN  client/style/images/signin_facebook.png
  52. BIN  client/style/images/signin_github.png
  53. BIN  client/style/images/signin_google.png
  54. BIN  client/style/images/signin_twitter.png
  55. +451 −203 client/style/skins.xml
  56. +1 −1  client/style/skins/bar.xml
  57. +3 −3 client/style/skins/button.xml
  58. +1 −1  client/style/skins/checkbox.xml
  59. +3 −3 client/style/skins/datagrid.xml
  60. +3 −3 client/style/skins/dropdown.xml
  61. +1 −1  client/style/skins/frame.xml
  62. +1 −1  client/style/skins/label.xml
  63. +3 −3 client/style/skins/list.xml
  64. +2 −2 client/style/skins/menu.xml
  65. +7 −7 client/style/skins/modalwindow.xml
  66. +1 −1  client/style/skins/radiobutton.xml
  67. +1 −1  client/style/skins/slider.xml
  68. +1 −1  client/style/skins/spinner.xml
  69. +1 −1  client/style/skins/statusbar.xml
  70. +7 −7 client/style/skins/tab.xml
  71. +5 −5 client/style/skins/textbox.xml
  72. +2 −2 client/style/skins/toolbar.xml
  73. +5 −5 client/style/skins/tree.xml
  74. +5 −5 client/style/skins/unused/accordion.xml
  75. +3 −3 client/style/skins/unused/caldropdown.xml
  76. +1 −1  client/style/skins/unused/calendar.xml
  77. +2 −2 client/style/skins/unused/editor.xml
  78. +1 −1  client/style/skins/unused/errorbox.xml
  79. +2 −2 client/style/skins/unused/fastlist.xml
  80. +3 −3 client/style/skins/unused/flowchart.xml
  81. +3 −3 client/style/skins/unused/notifier.xml
  82. +1 −1  client/style/skins/unused/portal.xml
  83. +1 −1  client/style/skins/unused/progressbar.xml
  84. +2 −2 client/style/skins/unused/propedit.xml
  85. +3 −3 client/style/skins/unused/slideshow.xml
  86. +3 −3 client/style/skins/unused/toolwindow.xml
  87. +2 −2 client/style/skins/unused/tslider.xml
  88. +1 −1  client/style/skins/unused/upload.xml
  89. +1 −1  client/style/skins/unused/video.xml
  90. +94 −2 client/style/style.css
  91. +1 −1  package.json
  92. +117 −0 server/cloud9/ext/hg/index.js
  93. +6 −0 server/cloud9/ext/hg/package.json
  94. +11 −3 server/cloud9/ide.js
  95. +1 −1  server/cloud9/view/error.tmpl.html
  96. +1 −1  support/ace
  97. +1 −1  support/apf
  98. +0 −1  support/async
  99. +1 −0  support/asyncjs
  100. +1 −1  support/jsdav
  101. +2 −1  support/paths.js
View
6 .gitmodules
@@ -4,9 +4,9 @@
[submodule "support/connect"]
path = support/connect
url = http://github.com/senchalabs/connect.git
-[submodule "support/async"]
- path = support/async
- url = http://github.com/ajaxorg/async.js.git
+[submodule "support/asyncjs"]
+ path = support/asyncjs
+ url = git://github.com/ajaxorg/async.js.git
[submodule "support/jsdav"]
path = support/jsdav
url = http://github.com/ajaxorg/jsDAV.git
View
2  README.md
@@ -1,5 +1,5 @@
# Cloud9 IDE
-
+test
The Cloud9 IDE is an open source project started by [ajax.org], built on top of [Node.JS].
This Integrated Development Environment aims to bring all great features from other existing IDE's and source code editors like Eclipse, Netbeans, Textmate, and many others together, bundled as plugins.
View
2  bin/cloud9.js
@@ -75,5 +75,5 @@ if (options.action) {
require("child_process").spawn(options.action[0], options.action.slice(1));
}
else {
- Sys.puts("Point you browser to " + url);
+ Sys.puts("Point your browser to " + url);
}
View
12 client/core/util.js
@@ -135,4 +135,16 @@ exports.getContentType = function(filename) {
return contentTypes[type] || "text/plain";
};
+/*
+ * JavaScript Linkify - v0.3 - 6/27/2009
+ * http://benalman.com/projects/javascript-linkify/
+ *
+ * Copyright (c) 2009 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ *
+ * Some regexps adapted from http://userscripts.org/scripts/review/7122
+ */
+exports.linkify=function(){var k="[a-z\\d.-]+://",h="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",c="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",n="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",f="(?:"+c+n+"|"+h+")",o="(?:[;/][^#?<>\\s]*)?",e="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",d="\\b"+k+"[^<>\\s]+",a="\\b"+f+o+e+"(?!\\w)",m="mailto:",j="(?:"+m+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+f+e+"(?!\\w)",l=new RegExp("(?:"+d+"|"+a+"|"+j+")","ig"),g=new RegExp("^"+k,"i"),b={"'":"`",">":"<",")":"(","]":"[","}":"{","B;":"B+","b:":"b9"},i={callback:function(q,p){return p?'<a href="'+p+'" title="'+p+'">'+q+"</a>":q},punct_regexp:/(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(u,z){z=z||{};var w,v,A,p,x="",t=[],s,E,C,y,q,D,B,r;for(v in i){if(z[v]===undefined){z[v]=i[v]}}while(w=l.exec(u)){A=w[0];E=l.lastIndex;C=E-A.length;if(/[\/:]/.test(u.charAt(C-1))){continue}do{y=A;r=A.substr(-1);B=b[r];if(B){q=A.match(new RegExp("\\"+B+"(?!$)","g"));D=A.match(new RegExp("\\"+r,"g"));if((q?q.length:0)<(D?D.length:0)){A=A.substr(0,A.length-1);E--}}if(z.punct_regexp){A=A.replace(z.punct_regexp,function(F){E-=F.length;return""})}}while(A.length&&A!==y);p=A;if(!g.test(p)){p=(p.indexOf("@")!==-1?(!p.indexOf(m)?"":m):!p.indexOf("irc.")?"irc://":!p.indexOf("ftp.")?"ftp://":"http://")+p}if(s!=C){t.push([u.slice(s,C)]);s=E}t.push([A,p])}t.push([u.substr(s)]);for(v=0;v<t.length;v++){x+=z.callback.apply(window,t[v])}return x||u}}();
+
});
View
123 client/ext/beautify/beautify.js
@@ -0,0 +1,123 @@
+/**
+ * Beautify extension for the Cloud9 IDE client
+ *
+ * Reformats the selected code in the current document
+ *
+ * Processing/formatting code from https://github.com/einars/js-beautify
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+
+define(function(require, exports, module) {
+
+ var ext = require("core/ext");
+ var ide = require("core/ide");
+ var util = require("core/util");
+ var canon = require("pilot/canon");
+ var editors = require("ext/editors/editors");
+ var Range = require("ace/range").Range;
+ var jsbeautify = require("ext/beautify/res/jsbeautify/jsbeautify");
+ var settings = require("text!ext/beautify/settings.xml");
+ var extSettings = require("ext/settings/settings");
+
+ return ext.register("ext/beautify/beautify", {
+ name: "JS Beautify",
+ dev: "Ajax.org",
+ alone: true,
+ type: ext.GENERAL,
+
+ commands: {
+ "beautify": {
+ hint: "reformat selected JavaScript code in the editor"
+ }
+ },
+
+ nodes: [],
+ hotitems: {},
+
+ beautify: function() {
+ var editor = editors.currentEditor;
+
+ var sel = editor.getSelection();
+ var doc = editor.getDocument();
+ var range = sel.getRange();
+ var value = doc.getTextRange(range);
+
+ // Load up current settings data
+ var preserveEmpty = extSettings.model.queryValue("beautify/jsbeautify/@preserveempty") == "true" ? true : false;
+ var keepIndentation = extSettings.model.queryValue("beautify/jsbeautify/@keeparrayindentation") == "true" ? true : false;
+ var braces = extSettings.model.queryValue("beautify/jsbeautify/@braces") || "end-expand";
+ var indentSize = extSettings.model.queryValue("editors/code/@tabsize") || "4";
+ var indentTab = extSettings.model.queryValue("editors/code/@softtabs") == "true" ? " " : "\t";
+
+ if (indentTab == "\t") indentSize = 1;
+
+ try {
+ value = jsbeautify.js_beautify(value, {
+ indent_size: indentSize,
+ indent_char: indentTab,
+ preserve_newlines: preserveEmpty,
+ keep_array_indentation: keepIndentation,
+ brace_style: braces
+ });
+ }
+ catch (e) {
+ util.alert("Error", "This code could not be beautified", "Please correct any JavaScript errors and try again");
+ return;
+ }
+
+ var end = doc.replace(range, value);
+ sel.setSelectionRange(Range.fromPoints(range.start, end));
+ },
+
+ init: function() {
+
+ },
+
+ hook: function() {
+ var _self = this;
+ this.nodes.push(
+ ide.mnuEdit.appendChild(new apf.divider()), ide.mnuEdit.appendChild(new apf.item({
+ caption: "Beautify Selection",
+ onclick: function() {
+ ext.initExtension(_self);
+ _self.beautify();
+ }
+ })));
+
+ this.hotitems["beautify"] = [this.nodes[1]];
+ canon.addCommand({
+ name: "beautify",
+ exec: function(env, args, request) {
+ _self.beautify();
+ }
+ });
+
+ ide.addEventListener("init.ext/settings/settings", function(e) {
+ e.ext.addSection("jsbeautify", _self.name, "beautify", function() {});
+ barSettings.insertMarkup(settings);
+ });
+ },
+
+ enable: function() {
+ this.nodes.each(function(item) {
+ item.enable();
+ });
+ },
+
+ disable: function() {
+ this.nodes.each(function(item) {
+ item.disable();
+ });
+ },
+
+ destroy: function() {
+ this.nodes.each(function(item) {
+ item.destroy(true, true);
+ });
+ this.nodes = [];
+ }
+ });
+
+});
View
1,146 client/ext/beautify/res/jsbeautify/jsbeautify.js
@@ -0,0 +1,1146 @@
+define(function(require, exports, module) {
+
+/*jslint onevar: false, plusplus: false */
+/*
+
+ JS Beautifier
+---------------
+
+
+ Written by Einar Lielmanis, <einar@jsbeautifier.org>
+ http://jsbeautifier.org/
+
+ Originally converted to javascript by Vital, <vital76@gmail.com>
+ "End braces on own line" added by Chris J. Shull, <chrisjshull@gmail.com>
+
+ You are free to use this in any way you want, in case you find this useful or working for you.
+
+ Usage:
+ js_beautify(js_source_text);
+ js_beautify(js_source_text, options);
+
+ The options are:
+ indent_size (default 4) — indentation size,
+ indent_char (default space) — character to indent with,
+ preserve_newlines (default true) — whether existing line breaks should be preserved,
+ preserve_max_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk,
+ indent_level (default 0) — initial indentation level, you probably won't need this ever,
+
+ jslint_happy (default false) — if true, then jslint-stricter mode is enforced.
+
+ jslint_happy !jslint_happy
+ ---------------------------------
+ function () function()
+
+ brace_style (default "collapse") - "collapse" | "expand" | "end-expand"
+ put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
+
+ e.g
+
+ js_beautify(js_source_text, {indent_size: 1, indent_char: '\t'});
+
+
+*/
+
+
+
+exports.js_beautify = function(js_source_text, options) {
+
+ var input, output, token_text, last_type, last_text, last_last_text, last_word, flags, flag_store, indent_string;
+ var whitespace, wordchar, punct, parser_pos, line_starters, digits;
+ var prefix, token_type, do_block_just_closed;
+ var wanted_newline, just_added_newline, n_newlines;
+
+
+ // Some interpreters have unexpected results with foo = baz || bar;
+ options = options ? options : {};
+
+ var opt_brace_style;
+
+ // compatibility
+ if (options.space_after_anon_function !== undefined && options.jslint_happy === undefined) {
+ options.jslint_happy = options.space_after_anon_function;
+ }
+ if (options.braces_on_own_line !== undefined) { //graceful handling of depricated option
+ opt_brace_style = options.braces_on_own_line ? "expand" : "collapse";
+ }
+ opt_brace_style = options.brace_style ? options.brace_style : (opt_brace_style ? opt_brace_style : "collapse");
+
+
+ var opt_indent_size = options.indent_size ? options.indent_size : 4;
+ var opt_indent_char = options.indent_char ? options.indent_char : ' ';
+ var opt_preserve_newlines = typeof options.preserve_newlines === 'undefined' ? true : options.preserve_newlines;
+ var opt_max_preserve_newlines = typeof options.max_preserve_newlines === 'undefined' ? false : options.max_preserve_newlines;
+ var opt_indent_level = options.indent_level ? options.indent_level : 0; // starting indentation
+ var opt_jslint_happy = options.jslint_happy === 'undefined' ? false : options.jslint_happy;
+ var opt_keep_array_indentation = typeof options.keep_array_indentation === 'undefined' ? false : options.keep_array_indentation;
+
+ just_added_newline = false;
+
+ // cache the source's length.
+ var input_length = js_source_text.length;
+
+ function trim_output(eat_newlines) {
+ eat_newlines = typeof eat_newlines === 'undefined' ? false : eat_newlines;
+ while (output.length && (output[output.length - 1] === ' '
+ || output[output.length - 1] === indent_string
+ || (eat_newlines && (output[output.length - 1] === '\n' || output[output.length - 1] === '\r')))) {
+ output.pop();
+ }
+ }
+
+ function trim(s) {
+ return s.replace(/^\s\s*|\s\s*$/, '');
+ }
+
+ function print_newline(ignore_repeated) {
+
+ flags.eat_next_space = false;
+ if (opt_keep_array_indentation && is_array(flags.mode)) {
+ return;
+ }
+
+ ignore_repeated = typeof ignore_repeated === 'undefined' ? true : ignore_repeated;
+
+ flags.if_line = false;
+ trim_output();
+
+ if (!output.length) {
+ return; // no newline on start of file
+ }
+
+ if (output[output.length - 1] !== "\n" || !ignore_repeated) {
+ just_added_newline = true;
+ output.push("\n");
+ }
+ for (var i = 0; i < flags.indentation_level; i += 1) {
+ output.push(indent_string);
+ }
+ if (flags.var_line && flags.var_line_reindented) {
+ if (opt_indent_char === ' ') {
+ output.push(' '); // var_line always pushes 4 spaces, so that the variables would be one under another
+ } else {
+ output.push(indent_string); // skip space-stuffing, if indenting with a tab
+ }
+ }
+ }
+
+
+
+ function print_single_space() {
+ if (flags.eat_next_space) {
+ flags.eat_next_space = false;
+ return;
+ }
+ var last_output = ' ';
+ if (output.length) {
+ last_output = output[output.length - 1];
+ }
+ if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space
+ output.push(' ');
+ }
+ }
+
+
+ function print_token() {
+ just_added_newline = false;
+ flags.eat_next_space = false;
+ output.push(token_text);
+ }
+
+ function indent() {
+ flags.indentation_level += 1;
+ }
+
+
+ function remove_indent() {
+ if (output.length && output[output.length - 1] === indent_string) {
+ output.pop();
+ }
+ }
+
+ function set_mode(mode) {
+ if (flags) {
+ flag_store.push(flags);
+ }
+ flags = {
+ previous_mode: flags ? flags.mode : 'BLOCK',
+ mode: mode,
+ var_line: false,
+ var_line_tainted: false,
+ var_line_reindented: false,
+ in_html_comment: false,
+ if_line: false,
+ in_case: false,
+ eat_next_space: false,
+ indentation_baseline: -1,
+ indentation_level: (flags ? flags.indentation_level + ((flags.var_line && flags.var_line_reindented) ? 1 : 0) : opt_indent_level),
+ ternary_depth: 0
+ };
+ }
+
+ function is_array(mode) {
+ return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]';
+ }
+
+ function is_expression(mode) {
+ return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]' || mode === '(EXPRESSION)';
+ }
+
+ function restore_mode() {
+ do_block_just_closed = flags.mode === 'DO_BLOCK';
+ if (flag_store.length > 0) {
+ flags = flag_store.pop();
+ }
+ }
+
+
+ function in_array(what, arr) {
+ for (var i = 0; i < arr.length; i += 1) {
+ if (arr[i] === what) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function get_next_token() {
+ n_newlines = 0;
+
+ if (parser_pos >= input_length) {
+ return ['', 'TK_EOF'];
+ }
+
+ wanted_newline = false;
+
+ var c = input.charAt(parser_pos);
+ parser_pos += 1;
+
+
+ var keep_whitespace = opt_keep_array_indentation && is_array(flags.mode);
+
+ if (keep_whitespace) {
+
+ //
+ // slight mess to allow nice preservation of array indentation and reindent that correctly
+ // first time when we get to the arrays:
+ // var a = [
+ // ....'something'
+ // we make note of whitespace_count = 4 into flags.indentation_baseline
+ // so we know that 4 whitespaces in original source match indent_level of reindented source
+ //
+ // and afterwards, when we get to
+ // 'something,
+ // .......'something else'
+ // we know that this should be indented to indent_level + (7 - indentation_baseline) spaces
+ //
+ var whitespace_count = 0;
+
+ while (in_array(c, whitespace)) {
+
+ if (c === "\n") {
+ trim_output();
+ output.push("\n");
+ just_added_newline = true;
+ whitespace_count = 0;
+ } else {
+ if (c === '\t') {
+ whitespace_count += 4;
+ } else if (c === '\r') {
+ // nothing
+ } else {
+ whitespace_count += 1;
+ }
+ }
+
+ if (parser_pos >= input_length) {
+ return ['', 'TK_EOF'];
+ }
+
+ c = input.charAt(parser_pos);
+ parser_pos += 1;
+
+ }
+ if (flags.indentation_baseline === -1) {
+ flags.indentation_baseline = whitespace_count;
+ }
+
+ if (just_added_newline) {
+ var i;
+ for (i = 0; i < flags.indentation_level + 1; i += 1) {
+ output.push(indent_string);
+ }
+ if (flags.indentation_baseline !== -1) {
+ for (i = 0; i < whitespace_count - flags.indentation_baseline; i++) {
+ output.push(' ');
+ }
+ }
+ }
+
+ } else {
+ while (in_array(c, whitespace)) {
+
+ if (c === "\n") {
+ n_newlines += ( (opt_max_preserve_newlines) ? (n_newlines <= opt_max_preserve_newlines) ? 1: 0: 1 );
+ }
+
+
+ if (parser_pos >= input_length) {
+ return ['', 'TK_EOF'];
+ }
+
+ c = input.charAt(parser_pos);
+ parser_pos += 1;
+
+ }
+
+ if (opt_preserve_newlines) {
+ if (n_newlines > 1) {
+ for (i = 0; i < n_newlines; i += 1) {
+ print_newline(i === 0);
+ just_added_newline = true;
+ }
+ }
+ }
+ wanted_newline = n_newlines > 0;
+ }
+
+
+ if (in_array(c, wordchar)) {
+ if (parser_pos < input_length) {
+ while (in_array(input.charAt(parser_pos), wordchar)) {
+ c += input.charAt(parser_pos);
+ parser_pos += 1;
+ if (parser_pos === input_length) {
+ break;
+ }
+ }
+ }
+
+ // small and surprisingly unugly hack for 1E-10 representation
+ if (parser_pos !== input_length && c.match(/^[0-9]+[Ee]$/) && (input.charAt(parser_pos) === '-' || input.charAt(parser_pos) === '+')) {
+
+ var sign = input.charAt(parser_pos);
+ parser_pos += 1;
+
+ var t = get_next_token(parser_pos);
+ c += sign + t[0];
+ return [c, 'TK_WORD'];
+ }
+
+ if (c === 'in') { // hack for 'in' operator
+ return [c, 'TK_OPERATOR'];
+ }
+ if (wanted_newline && last_type !== 'TK_OPERATOR'
+ && last_type !== 'TK_EQUALS'
+ && !flags.if_line && (opt_preserve_newlines || last_text !== 'var')) {
+ print_newline();
+ }
+ return [c, 'TK_WORD'];
+ }
+
+ if (c === '(' || c === '[') {
+ return [c, 'TK_START_EXPR'];
+ }
+
+ if (c === ')' || c === ']') {
+ return [c, 'TK_END_EXPR'];
+ }
+
+ if (c === '{') {
+ return [c, 'TK_START_BLOCK'];
+ }
+
+ if (c === '}') {
+ return [c, 'TK_END_BLOCK'];
+ }
+
+ if (c === ';') {
+ return [c, 'TK_SEMICOLON'];
+ }
+
+ if (c === '/') {
+ var comment = '';
+ // peek for comment /* ... */
+ var inline_comment = true;
+ if (input.charAt(parser_pos) === '*') {
+ parser_pos += 1;
+ if (parser_pos < input_length) {
+ while (! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/') && parser_pos < input_length) {
+ c = input.charAt(parser_pos);
+ comment += c;
+ if (c === '\x0d' || c === '\x0a') {
+ inline_comment = false;
+ }
+ parser_pos += 1;
+ if (parser_pos >= input_length) {
+ break;
+ }
+ }
+ }
+ parser_pos += 2;
+ if (inline_comment) {
+ return ['/*' + comment + '*/', 'TK_INLINE_COMMENT'];
+ } else {
+ return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT'];
+ }
+ }
+ // peek for comment // ...
+ if (input.charAt(parser_pos) === '/') {
+ comment = c;
+ while (input.charAt(parser_pos) !== '\r' && input.charAt(parser_pos) !== '\n') {
+ comment += input.charAt(parser_pos);
+ parser_pos += 1;
+ if (parser_pos >= input_length) {
+ break;
+ }
+ }
+ parser_pos += 1;
+ if (wanted_newline) {
+ print_newline();
+ }
+ return [comment, 'TK_COMMENT'];
+ }
+
+ }
+
+ if (c === "'" || // string
+ c === '"' || // string
+ (c === '/' &&
+ ((last_type === 'TK_WORD' && in_array(last_text, ['return', 'do'])) ||
+ (last_type === 'TK_COMMENT' || last_type === 'TK_START_EXPR' || last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EQUALS' || last_type === 'TK_EOF' || last_type === 'TK_SEMICOLON')))) { // regexp
+ var sep = c;
+ var esc = false;
+ var resulting_string = c;
+
+ if (parser_pos < input_length) {
+ if (sep === '/') {
+ //
+ // handle regexp separately...
+ //
+ var in_char_class = false;
+ while (esc || in_char_class || input.charAt(parser_pos) !== sep) {
+ resulting_string += input.charAt(parser_pos);
+ if (!esc) {
+ esc = input.charAt(parser_pos) === '\\';
+ if (input.charAt(parser_pos) === '[') {
+ in_char_class = true;
+ } else if (input.charAt(parser_pos) === ']') {
+ in_char_class = false;
+ }
+ } else {
+ esc = false;
+ }
+ parser_pos += 1;
+ if (parser_pos >= input_length) {
+ // incomplete string/rexp when end-of-file reached.
+ // bail out with what had been received so far.
+ return [resulting_string, 'TK_STRING'];
+ }
+ }
+
+ } else {
+ //
+ // and handle string also separately
+ //
+ while (esc || input.charAt(parser_pos) !== sep) {
+ resulting_string += input.charAt(parser_pos);
+ if (!esc) {
+ esc = input.charAt(parser_pos) === '\\';
+ } else {
+ esc = false;
+ }
+ parser_pos += 1;
+ if (parser_pos >= input_length) {
+ // incomplete string/rexp when end-of-file reached.
+ // bail out with what had been received so far.
+ return [resulting_string, 'TK_STRING'];
+ }
+ }
+ }
+
+
+
+ }
+
+ parser_pos += 1;
+
+ resulting_string += sep;
+
+ if (sep === '/') {
+ // regexps may have modifiers /regexp/MOD , so fetch those, too
+ while (parser_pos < input_length && in_array(input.charAt(parser_pos), wordchar)) {
+ resulting_string += input.charAt(parser_pos);
+ parser_pos += 1;
+ }
+ }
+ return [resulting_string, 'TK_STRING'];
+ }
+
+ if (c === '#') {
+
+
+ if (output.length === 0 && input.charAt(parser_pos) === '!') {
+ // shebang
+ resulting_string = c;
+ while (parser_pos < input_length && c != '\n') {
+ c = input.charAt(parser_pos);
+ resulting_string += c;
+ parser_pos += 1;
+ }
+ output.push(trim(resulting_string) + '\n');
+ print_newline();
+ return get_next_token();
+ }
+
+
+
+ // Spidermonkey-specific sharp variables for circular references
+ // https://developer.mozilla.org/En/Sharp_variables_in_JavaScript
+ // http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935
+ var sharp = '#';
+ if (parser_pos < input_length && in_array(input.charAt(parser_pos), digits)) {
+ do {
+ c = input.charAt(parser_pos);
+ sharp += c;
+ parser_pos += 1;
+ } while (parser_pos < input_length && c !== '#' && c !== '=');
+ if (c === '#') {
+ //
+ } else if (input.charAt(parser_pos) === '[' && input.charAt(parser_pos + 1) === ']') {
+ sharp += '[]';
+ parser_pos += 2;
+ } else if (input.charAt(parser_pos) === '{' && input.charAt(parser_pos + 1) === '}') {
+ sharp += '{}';
+ parser_pos += 2;
+ }
+ return [sharp, 'TK_WORD'];
+ }
+ }
+
+ if (c === '<' && input.substring(parser_pos - 1, parser_pos + 3) === '<!--') {
+ parser_pos += 3;
+ flags.in_html_comment = true;
+ return ['<!--', 'TK_COMMENT'];
+ }
+
+ if (c === '-' && flags.in_html_comment && input.substring(parser_pos - 1, parser_pos + 2) === '-->') {
+ flags.in_html_comment = false;
+ parser_pos += 2;
+ if (wanted_newline) {
+ print_newline();
+ }
+ return ['-->', 'TK_COMMENT'];
+ }
+
+ if (in_array(c, punct)) {
+ while (parser_pos < input_length && in_array(c + input.charAt(parser_pos), punct)) {
+ c += input.charAt(parser_pos);
+ parser_pos += 1;
+ if (parser_pos >= input_length) {
+ break;
+ }
+ }
+
+ if (c === '=') {
+ return [c, 'TK_EQUALS'];
+ } else {
+ return [c, 'TK_OPERATOR'];
+ }
+ }
+
+ return [c, 'TK_UNKNOWN'];
+ }
+
+ //----------------------------------
+ indent_string = '';
+ while (opt_indent_size > 0) {
+ indent_string += opt_indent_char;
+ opt_indent_size -= 1;
+ }
+
+ input = js_source_text;
+
+ last_word = ''; // last 'TK_WORD' passed
+ last_type = 'TK_START_EXPR'; // last token type
+ last_text = ''; // last token text
+ last_last_text = ''; // pre-last token text
+ output = [];
+
+ do_block_just_closed = false;
+
+ whitespace = "\n\r\t ".split('');
+ wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');
+ digits = '0123456789'.split('');
+
+ punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'.split(' ');
+
+ // words which should always start on new line.
+ line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');
+
+ // states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'.
+ // some formatting depends on that.
+ flag_store = [];
+ set_mode('BLOCK');
+
+ parser_pos = 0;
+ while (true) {
+ var t = get_next_token(parser_pos);
+ token_text = t[0];
+ token_type = t[1];
+ if (token_type === 'TK_EOF') {
+ break;
+ }
+
+ switch (token_type) {
+
+ case 'TK_START_EXPR':
+
+ if (token_text === '[') {
+
+ if (last_type === 'TK_WORD' || last_text === ')') {
+ // this is array index specifier, break immediately
+ // a[x], fn()[x]
+ if (in_array(last_text, line_starters)) {
+ print_single_space();
+ }
+ set_mode('(EXPRESSION)');
+ print_token();
+ break;
+ }
+
+ if (flags.mode === '[EXPRESSION]' || flags.mode === '[INDENTED-EXPRESSION]') {
+ if (last_last_text === ']' && last_text === ',') {
+ // ], [ goes to new line
+ if (flags.mode === '[EXPRESSION]') {
+ flags.mode = '[INDENTED-EXPRESSION]';
+ if (!opt_keep_array_indentation) {
+ indent();
+ }
+ }
+ set_mode('[EXPRESSION]');
+ if (!opt_keep_array_indentation) {
+ print_newline();
+ }
+ } else if (last_text === '[') {
+ if (flags.mode === '[EXPRESSION]') {
+ flags.mode = '[INDENTED-EXPRESSION]';
+ if (!opt_keep_array_indentation) {
+ indent();
+ }
+ }
+ set_mode('[EXPRESSION]');
+
+ if (!opt_keep_array_indentation) {
+ print_newline();
+ }
+ } else {
+ set_mode('[EXPRESSION]');
+ }
+ } else {
+ set_mode('[EXPRESSION]');
+ }
+
+
+
+ } else {
+ set_mode('(EXPRESSION)');
+ }
+
+ if (last_text === ';' || last_type === 'TK_START_BLOCK') {
+ print_newline();
+ } else if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_text === '.') {
+ // do nothing on (( and )( and ][ and ]( and .(
+ } else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') {
+ print_single_space();
+ } else if (last_word === 'function' || last_word === 'typeof') {
+ // function() vs function ()
+ if (opt_jslint_happy) {
+ print_single_space();
+ }
+ } else if (in_array(last_text, line_starters) || last_text === 'catch') {
+ print_single_space();
+ }
+ print_token();
+
+ break;
+
+ case 'TK_END_EXPR':
+ if (token_text === ']') {
+ if (opt_keep_array_indentation) {
+ if (last_text === '}') {
+ // trim_output();
+ // print_newline(true);
+ remove_indent();
+ print_token();
+ restore_mode();
+ break;
+ }
+ } else {
+ if (flags.mode === '[INDENTED-EXPRESSION]') {
+ if (last_text === ']') {
+ restore_mode();
+ print_newline();
+ print_token();
+ break;
+ }
+ }
+ }
+ }
+ restore_mode();
+ print_token();
+ break;
+
+ case 'TK_START_BLOCK':
+
+ if (last_word === 'do') {
+ set_mode('DO_BLOCK');
+ } else {
+ set_mode('BLOCK');
+ }
+ if (opt_brace_style=="expand") {
+ if (last_type !== 'TK_OPERATOR') {
+ if (last_text === 'return' || last_text === '=') {
+ print_single_space();
+ } else {
+ print_newline(true);
+ }
+ }
+ print_token();
+ indent();
+ } else {
+ if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') {
+ if (last_type === 'TK_START_BLOCK') {
+ print_newline();
+ } else {
+ print_single_space();
+ }
+ } else {
+ // if TK_OPERATOR or TK_START_EXPR
+ if (is_array(flags.previous_mode) && last_text === ',') {
+ if (last_last_text === '}') {
+ // }, { in array context
+ print_single_space();
+ } else {
+ print_newline(); // [a, b, c, {
+ }
+ }
+ }
+ indent();
+ print_token();
+ }
+
+ break;
+
+ case 'TK_END_BLOCK':
+ restore_mode();
+ if (opt_brace_style=="expand") {
+ if (last_text !== '{') {
+ print_newline();
+ }
+ print_token();
+ } else {
+ if (last_type === 'TK_START_BLOCK') {
+ // nothing
+ if (just_added_newline) {
+ remove_indent();
+ } else {
+ // {}
+ trim_output();
+ }
+ } else {
+ if (is_array(flags.mode) && opt_keep_array_indentation) {
+ // we REALLY need a newline here, but newliner would skip that
+ opt_keep_array_indentation = false;
+ print_newline();
+ opt_keep_array_indentation = true;
+
+ } else {
+ print_newline();
+ }
+ }
+ print_token();
+ }
+ break;
+
+ case 'TK_WORD':
+
+ // no, it's not you. even I have problems understanding how this works
+ // and what does what.
+ if (do_block_just_closed) {
+ // do {} ## while ()
+ print_single_space();
+ print_token();
+ print_single_space();
+ do_block_just_closed = false;
+ break;
+ }
+
+ if (token_text === 'function') {
+ if (flags.var_line) {
+ flags.var_line_reindented = true;
+ }
+ if ((just_added_newline || last_text === ';') && last_text !== '{') {
+ // make sure there is a nice clean space of at least one blank line
+ // before a new function definition
+ n_newlines = just_added_newline ? n_newlines : 0;
+ if ( ! opt_preserve_newlines) {
+ n_newlines = 1;
+ }
+
+ for (var i = 0; i < 2 - n_newlines; i++) {
+ print_newline(false);
+ }
+ }
+ }
+
+ if (token_text === 'case' || token_text === 'default') {
+ if (last_text === ':') {
+ // switch cases following one another
+ remove_indent();
+ } else {
+ // case statement starts in the same line where switch
+ flags.indentation_level--;
+ print_newline();
+ flags.indentation_level++;
+ }
+ print_token();
+ flags.in_case = true;
+ break;
+ }
+
+ prefix = 'NONE';
+
+ if (last_type === 'TK_END_BLOCK') {
+
+ if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
+ prefix = 'NEWLINE';
+ } else {
+ if (opt_brace_style=="expand" || opt_brace_style=="end-expand") {
+ prefix = 'NEWLINE';
+ } else {
+ prefix = 'SPACE';
+ print_single_space();
+ }
+ }
+ } else if (last_type === 'TK_SEMICOLON' && (flags.mode === 'BLOCK' || flags.mode === 'DO_BLOCK')) {
+ prefix = 'NEWLINE';
+ } else if (last_type === 'TK_SEMICOLON' && is_expression(flags.mode)) {
+ prefix = 'SPACE';
+ } else if (last_type === 'TK_STRING') {
+ prefix = 'NEWLINE';
+ } else if (last_type === 'TK_WORD') {
+ if (last_text === 'else') {
+ // eat newlines between ...else *** some_op...
+ // won't preserve extra newlines in this place (if any), but don't care that much
+ trim_output(true);
+ }
+ prefix = 'SPACE';
+ } else if (last_type === 'TK_START_BLOCK') {
+ prefix = 'NEWLINE';
+ } else if (last_type === 'TK_END_EXPR') {
+ print_single_space();
+ prefix = 'NEWLINE';
+ }
+
+ if (in_array(token_text, line_starters) && last_text !== ')') {
+ if (last_text == 'else') {
+ prefix = 'SPACE';
+ } else {
+ prefix = 'NEWLINE';
+ }
+ }
+
+ if (flags.if_line && last_type === 'TK_END_EXPR') {
+ flags.if_line = false;
+ }
+ if (in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
+ if (last_type !== 'TK_END_BLOCK' || opt_brace_style=="expand" || opt_brace_style=="end-expand") {
+ print_newline();
+ } else {
+ trim_output(true);
+ print_single_space();
+ }
+ } else if (prefix === 'NEWLINE') {
+ if ((last_type === 'TK_START_EXPR' || last_text === '=' || last_text === ',') && token_text === 'function') {
+ // no need to force newline on 'function': (function
+ // DONOTHING
+ } else if (token_text === 'function' && last_text == 'new') {
+ print_single_space();
+ } else if (last_text === 'return' || last_text === 'throw') {
+ // no newline between 'return nnn'
+ print_single_space();
+ } else if (last_type !== 'TK_END_EXPR') {
+ if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') {
+ // no need to force newline on 'var': for (var x = 0...)
+ if (token_text === 'if' && last_word === 'else' && last_text !== '{') {
+ // no newline for } else if {
+ print_single_space();
+ } else {
+ flags.var_line = false;
+ flags.var_line_reindented = false;
+ print_newline();
+ }
+ }
+ } else if (in_array(token_text, line_starters) && last_text != ')') {
+ flags.var_line = false;
+ flags.var_line_reindented = false;
+ print_newline();
+ }
+ } else if (is_array(flags.mode) && last_text === ',' && last_last_text === '}') {
+ print_newline(); // }, in lists get a newline treatment
+ } else if (prefix === 'SPACE') {
+ print_single_space();
+ }
+ print_token();
+ last_word = token_text;
+
+ if (token_text === 'var') {
+ flags.var_line = true;
+ flags.var_line_reindented = false;
+ flags.var_line_tainted = false;
+ }
+
+ if (token_text === 'if') {
+ flags.if_line = true;
+ }
+ if (token_text === 'else') {
+ flags.if_line = false;
+ }
+
+ break;
+
+ case 'TK_SEMICOLON':
+
+ print_token();
+ flags.var_line = false;
+ flags.var_line_reindented = false;
+ if (flags.mode == 'OBJECT') {
+ // OBJECT mode is weird and doesn't get reset too well.
+ flags.mode = 'BLOCK';
+ }
+ break;
+
+ case 'TK_STRING':
+
+ if (last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_SEMICOLON') {
+ print_newline();
+ } else if (last_type === 'TK_WORD') {
+ print_single_space();
+ }
+ print_token();
+ break;
+
+ case 'TK_EQUALS':
+ if (flags.var_line) {
+ // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
+ flags.var_line_tainted = true;
+ }
+ print_single_space();
+ print_token();
+ print_single_space();
+ break;
+
+ case 'TK_OPERATOR':
+
+ var space_before = true;
+ var space_after = true;
+
+ if (flags.var_line && token_text === ',' && (is_expression(flags.mode))) {
+ // do not break on comma, for(var a = 1, b = 2)
+ flags.var_line_tainted = false;
+ }
+
+ if (flags.var_line) {
+ if (token_text === ',') {
+ if (flags.var_line_tainted) {
+ print_token();
+ flags.var_line_reindented = true;
+ flags.var_line_tainted = false;
+ print_newline();
+ break;
+ } else {
+ flags.var_line_tainted = false;
+ }
+ // } else if (token_text === ':') {
+ // hmm, when does this happen? tests don't catch this
+ // flags.var_line = false;
+ }
+ }
+
+ if (last_text === 'return' || last_text === 'throw') {
+ // "return" had a special handling in TK_WORD. Now we need to return the favor
+ print_single_space();
+ print_token();
+ break;
+ }
+
+ if (token_text === ':' && flags.in_case) {
+ print_token(); // colon really asks for separate treatment
+ print_newline();
+ flags.in_case = false;
+ break;
+ }
+
+ if (token_text === '::') {
+ // no spaces around exotic namespacing syntax operator
+ print_token();
+ break;
+ }
+
+ if (token_text === ',') {
+ if (flags.var_line) {
+ if (flags.var_line_tainted) {
+ print_token();
+ print_newline();
+ flags.var_line_tainted = false;
+ } else {
+ print_token();
+ print_single_space();
+ }
+ } else if (last_type === 'TK_END_BLOCK' && flags.mode !== "(EXPRESSION)") {
+ print_token();
+ if (flags.mode === 'OBJECT' && last_text === '}') {
+ print_newline();
+ } else {
+ print_single_space();
+ }
+ } else {
+ if (flags.mode === 'OBJECT') {
+ print_token();
+ print_newline();
+ } else {
+ // EXPR or DO_BLOCK
+ print_token();
+ print_single_space();
+ }
+ }
+ break;
+ // } else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS']) || in_array(last_text, line_starters) || in_array(last_text, ['==', '!=', '+=', '-=', '*=', '/=', '+', '-'])))) {
+ } else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) || in_array(last_text, line_starters)))) {
+ // unary operators (and binary +/- pretending to be unary) special cases
+
+ space_before = false;
+ space_after = false;
+
+ if (last_text === ';' && is_expression(flags.mode)) {
+ // for (;; ++i)
+ // ^^^
+ space_before = true;
+ }
+ if (last_type === 'TK_WORD' && in_array(last_text, line_starters)) {
+ space_before = true;
+ }
+
+ if (flags.mode === 'BLOCK' && (last_text === '{' || last_text === ';')) {
+ // { foo; --i }
+ // foo(); --bar;
+ print_newline();
+ }
+ } else if (token_text === '.') {
+ // decimal digits or object.property
+ space_before = false;
+
+ } else if (token_text === ':') {
+ if (flags.ternary_depth == 0) {
+ flags.mode = 'OBJECT';
+ space_before = false;
+ } else {
+ flags.ternary_depth -= 1;
+ }
+ } else if (token_text === '?') {
+ flags.ternary_depth += 1;
+ }
+ if (space_before) {
+ print_single_space();
+ }
+
+ print_token();
+
+ if (space_after) {
+ print_single_space();
+ }
+
+ if (token_text === '!') {
+ // flags.eat_next_space = true;
+ }
+
+ break;
+
+ case 'TK_BLOCK_COMMENT':
+
+ var lines = token_text.split(/\x0a|\x0d\x0a/);
+
+ if (/^\/\*\*/.test(token_text)) {
+ // javadoc: reformat and reindent
+ print_newline();
+ output.push(lines[0]);
+ for (i = 1; i < lines.length; i++) {
+ print_newline();
+ output.push(' ');
+ output.push(trim(lines[i]));
+ }
+
+ } else {
+
+ // simple block comment: leave intact
+ if (lines.length > 1) {
+ // multiline comment block starts with a new line
+ print_newline();
+ trim_output();
+ } else {
+ // single-line /* comment */ stays where it is
+ print_single_space();
+
+ }
+
+ for (i = 0; i < lines.length; i++) {
+ output.push(lines[i]);
+ output.push('\n');
+ }
+
+ }
+ print_newline();
+ break;
+
+ case 'TK_INLINE_COMMENT':
+
+ print_single_space();
+ print_token();
+ if (is_expression(flags.mode)) {
+ print_single_space();
+ } else {
+ print_newline();
+ }
+ break;
+
+ case 'TK_COMMENT':
+
+ // print_newline();
+ if (wanted_newline) {
+ print_newline();
+ } else {
+ print_single_space();
+ }
+ print_token();
+ print_newline();
+ break;
+
+ case 'TK_UNKNOWN':
+ if (last_text === 'return' || last_text === 'throw') {
+ print_single_space();
+ }
+ print_token();
+ break;
+ }
+
+ last_last_text = last_text;
+ last_type = token_type;
+ last_text = token_text;
+ }
+
+ return output.join('').replace(/[\n ]+$/, '');
+
+}
+
+});
View
19 client/ext/beautify/settings.xml
@@ -0,0 +1,19 @@
+<a:application xmlns:a="http://ajax.org/2005/aml">
+ <div class="header">
+ <span></span><div>JS Beautify</div>
+ </div>
+ <a:checkbox class="underlined" label="Preserve empty lines"
+ checked="{[beautify/jsbeautify/@preserveempty] != '' ? [beautify/jsbeautify/@preserveempty] : 'true'}"
+ value="[beautify/jsbeautify/@preserveempty]" />
+ <a:checkbox class="underlined" label="Keep array indentation"
+ checked="{[beautify/jsbeautify/@keeparrayindentation] != '' ? [beautify/jsbeautify/@keeparrayindentation] : 'true'}"
+ value="[beautify/jsbeautify/@keeparrayindentation]" />
+ <a:vbox edge="5 5 2 5" align="left">
+ <a:label>Braces</a:label>
+ <a:dropdown default="end-expand" value="[{require('ext/settings/settings').model}::beautify/jsbeautify/@braces]" width="185" height="21">
+ <a:item value="collapse">Braces with control statement</a:item>
+ <a:item value="expand">Braces on own line</a:item>
+ <a:item value="end-expand">End braces on own line</a:item>
+ </a:dropdown>
+ </a:vbox>
+</a:application>
View
4 client/ext/code/proxydocument.js
@@ -41,6 +41,10 @@ oop.inherits(ProxyDocument, Document);
return this.doc.getLength();
};
+ this.getLine = function (row) {
+ return this.doc.getLine(row);
+ };
+
this.getLines = function (startRow, endRow) {
return this.doc.getLines(startRow, endRow);
};
View
2  client/ext/code/settings.xml
@@ -27,7 +27,7 @@
<a:checkbox label="Soft tabs" value="[editors/code/@softtabs]" flex="1" />
<a:spinner value="[editors/code/@tabsize]" realtime="true" min="1" max="64" width="50" />
</a:hbox>
- <a:hbox edge="0 5 2 0" align="center" class="underlined">
+ <a:hbox edge="5 5 2 5" align="center">
<a:label flex="1">Mouse Scroll speed</a:label>
<a:spinner value="[editors/code/@scrollspeed]" realtime="true" min="1" max="8" width="50" />
</a:hbox>
View
1  client/ext/console/console.js
@@ -480,6 +480,7 @@ return ext.register("ext/console/console", {
case "git":
case "npm":
case "pwd":
+ case "hg":
case "ls":
res = message.body;
//this.getPrompt() + " " + res.argv.join(" ") + "\n" +
View
2  client/ext/debugger/debugger.js
@@ -58,6 +58,8 @@ return ext.register("ext/debugger/debugger", {
ide.addEventListener("afteropenfile", function(e) {
var doc = e.doc;
var node = e.node;
+ if(!node)
+ return;
var path = node.getAttribute("path");
node.setAttribute("scriptname", ide.workspaceDir + path.slice(ide.davPrefix.length));
View
79 client/ext/dockpanel/dock.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:a="http://ajax.org/2005/aml" >
+ <head profile="http://www.w3.org/2005/10/profile">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="description" content=""/>
+ <meta name="keywords" content=""/>
+ <style>
+ HTML{overflow:hidden}
+ </style>
+ <script type="text/javascript" src="js/apf_debug.js"></script>
+ </head>
+ <body>
+ <a:skin
+ src = "style/skins.xml"
+ media-path = "style/images/"
+ icon-path = "style/icons/" />
+
+ <a:appsettings name="ide" debug="false"
+ disable-space = "true"
+ auto-hide-loading = "true"
+ allow-select = "false"
+ allow-blur = "true"
+ initdelay = "false"
+ storage = "cookie"
+ baseurl = "{apf.host ? apf.host : ''}" />
+
+ <a:hbox id="hboxMain" padding="0" anchors="0 0 0 0">
+ <a:bar skin="basic" flex="1">
+ </a:bar>
+ <!--a:bar id="dockPanelRight" skin="debug-panel">
+ <a:button skin="dockheader" onclick="require('ext/dockpanel/dockpanel').expand()" />
+ <a:vbox id="section" padding="0" edge="0 0 3 0" class="docksection">
+ <a:divider id="div1" skin="divider-debugpanel" margin="3 5 2 5" draggable="true" />
+ <a:button id="btn1" class="dockButtonID" skin="dockButton" submenu="submenu1" draggable="true" />
+ <a:button id="btn2" class="dockButtonID" skin="dockButton" submenu="submenu1" draggable="true" />
+ </a:vbox>
+ </a:bar-->
+ </a:hbox>
+
+ <!--a:menu id="submenu1" width="200" height="200"
+ ref = "{section}"
+ pinned = "true"
+ animate = "false"
+ skin = "dockwindowbasic">
+ <a:tab anchors="0 0 0 0" skin="docktab" buttons="scale">
+ <a:page id="page1" caption="Test">
+ <a:button margin="10" onclick="addBar()">Test</a:button>
+ </a:page>
+ <a:page id="page2" caption="Test Again">
+ <a:button right="10" bottom="10" width="50">Test</a:button>
+ </a:page>
+ </a:tab>
+ </a:menu-->
+
+ <!--a:menu id="submenu2" width="200" height="200"
+ ref = "{section}"
+ pinned = "true"
+ animate = "false"
+ skin = "dockwindowbasic">
+ <a:tab anchors="0 0 0 0" skin="docktab" buttons="scale">
+ <a:page caption="Test" />
+ </a:tab>
+ </a:menu>
+
+ <a:menu id="submenu3" width="200" height="200"
+ ref = "{section}"
+ pinned = "true"
+ animate = "false"
+ skin = "dockwindowbasic">
+ <a:tab anchors="0 0 0 0" skin="docktab" buttons="scale">
+ <a:page caption="Test 1" />
+ <a:page caption="Test 2" />
+ <a:page caption="Test 3" />
+ </a:tab>
+ </a:menu-->
+
+ <a:script src="dock.js" />
+ </body>
+</html>
View
1,353 client/ext/dockpanel/dock.js
@@ -0,0 +1,1353 @@
+/*
+ TODO:
+ - expanded state tab dragging
+ - insertbefore tab reorder doesnt create a new splitter bar
+ - multiple columns: splitter bars don't function as expected: should be non-symmetrical
+ - dragging forelasttab out of expanded column leaves splitter
+ - after_tab/before_tab lacks splitter and tab page doesnt animate
+
+ - single page should drag whole tab like button to section does
+ - anim should wait x00ms before playing
+
+ - tweak tab animations
+ - menu should appear onmouseup not down
+ - floating sections or menus
+
+ INTEGRATION
+ - refactor into seperate class
+ - closing a window should set the state in the windows menu
+ - debugger plugin doesnt need to be visible at the start anymore
+ - add right click menu to buttons/sections
+ - maintain state of sections/buttons even when closed
+ - save serialized state in settings.xml
+
+ - page closing should call cbStorePage
+*/
+
+var testState = {
+ bars : [
+ {
+ expanded : false,
+ width : 300,
+ sections : [
+ {
+ flex : 1,
+ width : 300,
+ height : 200,
+ buttons : [
+ {
+ caption: "Test4",
+ ext : ""
+ },
+ {
+ caption: "Test3",
+ ext : ""
+ }
+ ]
+ },
+ {
+ flex : 1,
+ width : 200,
+ height : 300,
+ buttons : [
+ {
+ caption: "Test2",
+ ext : ""
+ }
+ ]
+ },
+ {
+ flex : 1,
+ width : 200,
+ height : 200,
+ buttons : [
+ {
+ caption: "Test1",
+ ext : ""
+ }
+ ]
+ }
+ ]
+ },
+ {
+ expanded : true,
+ width : 200,
+ sections : [
+ {
+ flex : 1,
+ width : 200,
+ height : 200,
+ buttons : [
+ {
+ caption: "Test2",
+ ext : ""
+ }
+ ]
+ },
+ {
+ flex : 1,
+ width : 200,
+ height : 200,
+ buttons : [
+ {
+ caption: "Test1",
+ ext : ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+};
+
+function DockableLayout(parentHBox, cbFindPage, cbStorePage) {
+ this.columnCounter = 0;
+ this.$parentHBox = parentHBox;
+ this.$cbStorePage = cbStorePage;
+ this.$cbFindPage = cbFindPage;
+
+ var indicator = this.indicator = document.body.appendChild(document.createElement("div"));
+ indicator.style.position = "absolute";
+ indicator.style.display = "none";
+ indicator.style.border = "3px solid #7ac7f4";
+ indicator.style.zIndex = 1000000;
+};
+
+(function(){
+ var whiledrag, lastInfo, diffPixel = 3;
+ var menuCounter = 100;
+
+ /**
+ * Retrieve the current state of the layout as a JSON object
+ *
+ */
+ this.getState = function(){
+ var state = {bars: []};
+
+ var bar = this.$parentHBox.lastChild;
+ while (bar) {
+ if (bar.localName == "bar") {
+ var barInfo = {sections: []};
+ barInfo.expanded = bar.vbox && bar.vbox.visible;
+ barInfo.width = bar.vbox && bar.vbox.width
+ || bar.$dockData && bar.$dockData.width
+ || 200;
+
+ var sections = bar.selectNodes("vbox");
+ for (var i = 0; i < sections.length; i++) {
+ var sectionInfo = {buttons: []};
+ var buttons = sections[i].selectNodes("button");
+ sectionInfo.flex = buttons[0].$dockpage.parentNode.flex || 1;
+
+ var menu = self[buttons[0].submenu];
+ sectionInfo.width = menu.width;
+ sectionInfo.height = menu.height;
+
+ for (var j = 0; j < buttons.length; j++) {
+ var buttonInfo = {};
+ buttonInfo.ext = buttons[j].$dockpage.extension;
+ buttonInfo.caption = buttons[j].$dockpage.caption;
+
+ sectionInfo.buttons.push(buttonInfo);
+ }
+ barInfo.sections.push(sectionInfo);
+ }
+
+ state.bars.unshift(barInfo);
+ }
+ else if (!bar.bar) {
+ break;
+ }
+
+ bar = bar.previousSibling;
+ }
+
+ return state;
+ }
+
+ /**
+ * Set the current layout via a JSON object
+ * @param {Object} obj JSON object with the following structure:
+ * {
+ * bars : [
+ * {
+ * expanded : false,
+ * width : 300,
+ * sections : [
+ * {
+ * flex : 1,
+ * width : 200,
+ * height : 200,
+ * buttons : [
+ * {
+ *
+ * }
+ * ]
+ * }
+ * ]
+ * }
+ * ]
+ * }
+ *
+ */
+ this.loadState = function(obj){
+ this.$cleanup();
+
+ var bars = obj.bars;
+ for (var i = 0; i < bars.length; i++) {
+ var bar = this.$addBar();
+ bar.$dockData = bars[i];
+
+ var sections = bars[i].sections;
+ for (var j = 0; j < sections.length; j++) {
+ var section = this.$addSection(bar);
+ var menu = this.$addMenu(section);
+ var info = section.$dockData = sections[j];
+
+ menu.firstChild.setAttribute("flex", info.flex);
+ menu.setAttribute("width", info.width);
+ menu.setAttribute("height", info.height);
+
+ var buttons = sections[j].buttons
+ for (var k = 0; k < buttons.length; k++) {
+ var button = this.$addButton(section, menu,
+ this.$addPage(
+ this.$cbFindPage(buttons[k].ext),
+ menu,
+ buttons[k].caption,
+ buttons[k].caption.toLowerCase()
+ )
+ );
+ button.$dockData = buttons[k];
+ }
+ }
+
+ if (bars[i].expanded)
+ this.expandBar(bar);
+ }
+ }
+
+ /**
+ * Expand a bar
+ */
+ this.expandBar = function (bar){
+ if (!bar.vbox) {
+ var _self = this;
+ bar.vbox = bar.parentNode.insertBefore(new apf.vbox({
+ padding : 3,
+ width : bar.$dockData && bar.$dockData.width || 260,
+ splitters : true,
+ vdock : 1,
+ "class" : "dockcol unselectable",
+ childNodes : [
+ new apf.button({
+ dock : 1,
+ skin : "dockheader",
+ "class" : "expanded",
+ nosplitter : true,
+ height : 11,
+ margin : "0 0 -3 0",
+ onclick : function(){
+ _self.collapseBar(bar);
+ }
+ })
+ ]
+ }), bar);
+
+ //style hack
+ bar.vbox.$ext.style.borderLeft = "1px solid #333";
+
+ bar.splitter = bar.parentNode.insertBefore(new apf.splitter({
+ width : "0"
+ }), bar.vbox);
+
+ bar.splitter.bar =
+ bar.vbox.bar = bar;
+ }
+ else {
+ bar.parentNode.insertBefore(bar.vbox, bar);
+ bar.parentNode.insertBefore(bar.splitter, bar.vbox);
+ }
+
+ var vbox = bar.selectNodes("vbox");
+ for (var i = 0; i < vbox.length; i++) {
+ var menu = self[vbox[i].selectSingleNode("button").submenu]
+ menu.hide();
+ var tab = menu.firstChild;
+ bar.vbox.appendChild(tab);
+ if (!tab.flex)
+ tab.setAttribute("flex", 1);
+ }
+
+ bar.hide();
+ bar.vbox.show();
+ bar.splitter.show();
+
+ //Hack for button
+ bar.vbox.firstChild.$ext.onmousemove({});
+ }
+
+ /**
+ * Collapse a bar
+ */
+ this.collapseBar = function(bar){
+ var vbox = bar.selectNodes("vbox");
+ var tabs = bar.vbox.selectNodes("tab");
+ for (var i = 0; i < vbox.length; i++) {
+ var menu = self[vbox[i].selectSingleNode("button").submenu];
+ menu.appendChild(tabs[i]);
+ }
+
+ bar.show();
+ bar.vbox.hide();
+ bar.splitter.hide();
+
+ bar.parentNode.removeChild(bar.vbox);
+ bar.parentNode.removeChild(bar.splitter);
+
+ //Hack for button
+ bar.firstChild.$ext.onmousemove({});
+ }
+
+ /**
+ * Destroy full state
+ */
+ this.$cleanup = function(){
+ var bar = this.$parentHBox.lastChild;
+ while (bar) {
+ if (bar.localName == "bar") {
+ var sections = bar.selectNodes("vbox");
+ for (var i = 0; i < sections.length; i++) {
+ var buttons = sections[i].selectNodes("button");
+ var menu = self[buttons[0].submenu];
+
+ for (var j = 0; j < buttons.length; j++) {
+ //Store pages
+ this.$cbStorePage(buttons[j].$dockpage);
+ }
+
+ menu.destroy(true, true);
+ }
+ }
+ else if (!bar.bar) {
+ break;
+ }
+
+ var next = bar.previousSibling;
+ bar.destroy(true, true);
+ bar = next;
+ }
+ }
+
+ this.$isLastBar = function(aml) {
+ var last = this.$parentHBox.lastChild;
+ while (last && !last.visible)
+ last = last.previousSibling;
+
+ return aml == last || aml == last.vbox;
+ }
+
+ /**
+ * Starts the docking detection during drag&drop
+ */
+ this.$startDrag = function (dragged, original){
+ var last, state = 0, _self = this;
+
+ apf.setOpacity(dragged.$ext, 0.3);
+
+ function getLastBar(){
+ var lastBar = _self.$parentHBox.lastChild;
+ while (lastBar && lastBar.previousSibling
+ && (lastBar.previousSibling.localName == "bar"
+ || lastBar.previousSibling.bar))
+ lastBar = lastBar.previousSibling;
+ if (lastBar.localName != "bar")
+ lastBar = lastBar.bar;
+
+ return lastBar;
+ }
+
+ var lastBar = getLastBar();
+ var leftEdge = apf.getAbsolutePosition(lastBar.$ext)[0];
+ var indicator = this.indicator;
+
+ apf.addListener(document, "mousemove", whiledrag = function(e){
+ if (last) {
+ last.$ext.style.borderBottom = "";
+ delete last;
+ }
+
+ if (!e) return;
+
+ var indicatorTop = indicator.style.top;
+ dragged.$ext.style.top = "-2000px";
+ indicator.style.top = "-2000px";
+ apf.plane.hide();
+
+ //Adding a column
+ if (e.clientX > leftEdge - 40 && e.clientX < leftEdge) {
+ var isSameColumn = dragged.localName == "vbox"
+ && dragged.$dockbar == lastBar
+ && !dragged.$dockbar.selectNodes("vbox").length;
+
+ info = {
+ position : isSameColumn ? "none" : "left_of_column",
+ aml : aml = last = lastBar
+ }
+ }
+ //Rest
+ else {
+ var info = _self.$calcAction(e, original);
+ var aml = last = info.aml;
+ }
+
+ if (lastInfo && lastInfo.position == info.position && lastInfo.aml == aml) {
+ indicator.style.top = indicatorTop;
+ return;
+ }
+
+ lastInfo = info;
+
+ if (!aml || !aml.dock && !aml.bar) {
+ if (!state) {
+ state = 1;
+ apf.tween.single(dragged.$ext, {
+ type: "fade",
+ from: 0.3,
+ to : 1,
+ steps : 20,
+ onfinish : function(){
+ state = 1;
+ }
+ });
+ }
+ return;
+ }
+
+ var pos = apf.getAbsolutePosition(aml.$ext);
+ indicator.style.left = pos[0] + "px";
+ indicator.style.top = pos[1] + "px";
+ indicator.style.display = "block";
+ indicator.style.backgroundColor = "";
+ indicator.style.marginLeft = "0";
+ indicator.innerHTML = "";
+
+ if (state) {
+ state = 0;
+ apf.tween.single(dragged.$ext, {
+ type: "fade",
+ from: 1,
+ to : 0.3,
+ steps : 20,
+ onfinish : function(){
+ state = 0;
+ }
+ });
+ }
+
+ var width = aml.$ext.offsetWidth;
+ var height = aml.$ext.offsetHeight;
+
+ switch(info.position) {
+ case "before_button":
+ case "after_button":
+ indicator.innerHTML = "<div style='position:absolute'></div>";
+ indicator.style.borderWidth = "6px 1px 3px 1px";
+
+ var pos2 = apf.getAbsolutePosition(aml.parentNode.$ext);
+ indicator.style.left = pos2[0] + "px";
+ indicator.style.top = pos2[1] + "px";
+ width = aml.parentNode.$ext.offsetWidth;
+ height = aml.parentNode.$ext.offsetHeight;
+
+ var div = indicator.firstChild;
+ if (aml == getOriginal("button", original)) { //@todo Checks needs to include different representations
+ div.style.top = (pos[1] - pos2[1] - 2) + "px";
+ div.style.left = "2px";
+ div.style.right = "3px";
+ div.style.height = (aml.$ext.offsetHeight - 9) + "px";
+ div.style.border = "2px solid #7ac7f4";
+ div.style.webkitBorderRadius = "6px";
+ }
+ else {
+ div.style.top = (pos[1] - pos2[1]
+ + (info.position == "before_button" ? 0 : aml.$ext.offsetHeight)
+ - 8) + "px";
+ div.style.width = "100%";
+ div.style.borderBottom = "3px solid #7ac7f4";
+ }
+
+ break;
+ case "in_section":
+ if (getOriginal("section", original) == aml.$dockfor) {//@todo move this
+ indicator.style.borderWidth = "1px 1px 1px 1px";
+ height--;
+ }
+ break;
+ case "after_page":
+ case "before_page":
+ var pNode = aml.parentNode;
+ var pos2 = apf.getAbsolutePosition(pNode.$ext);
+ indicator.style.left = pos2[0] + "px";
+ indicator.style.top = pos2[1] + "px";
+ width = pNode.$ext.offsetWidth;
+ height = pNode.$ext.offsetHeight;
+
+ indicator.style.borderWidth = "3px 3px 3px 3px";
+
+ var compareAml = info.position == "before_page"
+ ? aml.previousSibling
+ : aml.nextSibling;
+ var originalAml = getOriginal("page", original);
+ var matchAml = originalAml == aml
+ ? aml
+ : (originalAml == compareAml ? compareAml : false);
+ var diff = apf.getAbsolutePosition((matchAml || aml).$button, pNode.$ext);
+ if (matchAml) {
+ indicator.innerHTML = "<div style='position:absolute;'></div><div style='position:absolute;'></div><div style='position:absolute;'></div>";
+ var div1 = indicator.firstChild;
+ var div2 = indicator.childNodes[1];
+ var div3 = indicator.childNodes[2];
+ div1.style.left = diff[0] + "px";
+ div1.style.width = (matchAml.$button.offsetWidth - 5) + "px";
+ div1.style.height = "18px";
+ div1.style.margin = "-18px 0 0 -3px";
+ div1.style.border = "3px solid #7ac7f4";
+ div1.style.borderWidth = "3px 3px 0 3px";
+
+ div2.style.left = (diff[0] + matchAml.$button.offsetWidth - 3) + "px";
+ div2.style.right = "0px";
+ div3.style.borderBottom =
+ div2.style.borderBottom = "3px solid #7ac7f4";
+
+ div3.style.left = "0px";
+ div3.style.right = (width - diff[0] - 3) + "px";
+
+ indicator.style.borderTop = "0px solid #7ac7f4";
+ indicator.style.top = (pos2[1] + 18) + "px";
+ height -= 18;
+ }
+ else {
+ indicator.innerHTML = "<div style='position:absolute;'><div></div></div>";
+ indicator.firstChild.style.height = "16px";
+ indicator.firstChild.style.width = "5px";
+ indicator.firstChild.style.background = "rgba(122,199,244,0.5)";
+ indicator.firstChild.style.top = "0px";
+ indicator.firstChild.firstChild.style.background = "#7ac7f4";
+ indicator.firstChild.firstChild.style.height = "100%";
+ indicator.firstChild.firstChild.style.margin="0 2px 0 2px";
+
+ var left = (diff[0] +
+ (info.position == "before_page" ? 0 : aml.$button.offsetWidth));
+ if (left)
+ left -= 5;
+ else {
+ indicator.firstChild.style.width = "2px";
+ indicator.firstChild.firstChild.style.marginLeft = "0px";
+ }
+ indicator.firstChild.style.left = left + "px";
+ }
+ break;
+ case "before_tab":
+ height = 0;
+ case "after_tab":
+ indicator.style.left = pos[0] + "px";
+ indicator.style.top = (pos[1] + height - (!aml.nextSibling ? 3 : 0)) + "px";
+ indicator.style.height = "3px";
+ indicator.style.width = width + "px";
+ indicator.style.borderWidth = "0 0 0 0";
+ indicator.style.backgroundColor = "rgba(122,199,244,"
+ + (!aml.nextSibling ? 1 : 0.8) + ")";
+ return;
+ case "before_section":
+ height = 0;
+ case "after_section":
+ indicator.style.left = pos[0] + "px";
+ indicator.style.top = (pos[1] + height - 3) + "px";
+ indicator.style.height = "5px";
+ indicator.style.width = aml.$ext.offsetWidth + "px";
+ indicator.style.borderWidth = "0 0 0 0";
+ indicator.innerHTML = "<div style='margin:2px 0 2px 0'></div>";
+ indicator.firstChild.style.backgroundColor = "#7ac7f4";
+ indicator.firstChild.style.height = "1px";
+ indicator.style.backgroundColor = "rgba(122,199,244,0.5)";
+ return;
+ case "in_column":
+ indicator.innerHTML = "<div style='position:absolute'></div>";
+ indicator.style.borderWidth = "0 0 0 0";
+
+ var div = indicator.firstChild;
+ div.style.top = "100%";
+ div.style.borderTop = "3px solid #7ac7f4"
+ div.style.height = (dragged.localName == "vbox" ? dragged.$ext.offsetHeight : 50) + "px";
+ div.style.background = "rgba(172,172,172,0.5)";
+ div.style.width = "100%";
+ div.style.webkitBorderRadius = "0 0 4px 4px";
+
+ /*apf.tween.single(div, {
+ type: "height",
+ from: 0,
+ to : dragged.localName == "vbox" ? dragged.$ext.offsetHeight : 50,
+ anim : apf.tween.EASEOUT,
+ steps : 20
+ });*/
+
+ break;
+ case "left_of_column":
+ if (aml != getLastBar()) {
+ indicator.style.borderWidth = "0 0 0 3px";
+ indicator.style.marginLeft = "-1px";
+ }
+ else {
+ indicator.innerHTML = "<div style='position:absolute'></div>";
+ indicator.style.borderWidth = "0 0 0 0";
+
+ var div = indicator.firstChild;
+ div.style.right = "100%";
+ div.style.width = 0;
+ div.style.height = "100%";
+ div.style.borderRight = "3px solid #7ac7f4"
+ div.style.background = "rgba(172,172,172,0.5)";
+ div.style.webkitBorderRadius = "4px 0 0 4px";
+
+ apf.tween.single(div, {
+ type: "width",
+ from: 0,
+ to : 40,
+ anim : apf.tween.EASEOUT,
+ steps : 20
+ });
+ }
+ break;
+ case "right_of_column":
+ indicator.style.borderWidth = "0 3px 0 0";
+ if (!_self.$isLastBar(aml))
+ indicator.style.marginLeft = "2px";
+ break;
+ default:
+ indicator.style.display = "none";
+ apf.setOpacity(dragged.$ext, 1);
+ break;
+ }
+
+ var diff = apf.getDiff(indicator);
+ indicator.style.width = (width - diff[0]) + "px";
+ indicator.style.height = (height - diff[1]) + "px";
+ });
+
+ whiledrag.dragged = dragged;
+ whiledrag.original = original;
+ }
+
+ /**
+ * Normalize types by converting them to the requested widget type of the
+ * conceptual single object
+ */
+ function getOriginal(type, aml) {
+ if (type == "button") {
+ if (aml.localName == "page")
+ return aml.$dockbutton;
+ if (aml.localName == "divider") {
+ var buttons = aml.parentNode.selectNodes("button");
+ if (buttons.length == 1)
+ return buttons[0];
+ }
+ return aml;
+ }
+ else if (type == "page") {
+ if (aml.localName == "button")
+ return aml.$dockpage;
+ if (aml.localName == "divider") {
+ var buttons = aml.parentNode.selectNodes("button");
+ if (buttons.length == 1)
+ return buttons[0].$dockpage;
+ }
+ return aml;
+ }
+ else if (type == "section") {
+ if (aml.localName == "page" && aml.parentNode.getPages().length == 1)
+ return aml.$dockbutton.parentNode;
+ if (aml.localName == "divider")
+ return aml.parentNode;
+ return aml;
+ }
+ }
+
+ function matchTab(pos, y) {
+ return y > pos - diffPixel && y < pos + diffPixel;
+ }
+
+ /**