spiderfw 0.5.9 → 0.5.10

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 (98) hide show
  1. data/apps/app_server/_init.rb +8 -0
  2. data/apps/app_server/app_server.rb +60 -0
  3. data/apps/app_server/config/options.rb +2 -0
  4. data/apps/app_server/controllers/app_server_controller.rb +20 -0
  5. data/apps/app_server/lib/app.rb +21 -0
  6. data/apps/app_server/lib/git_app.rb +22 -0
  7. data/apps/app_server/views/app_list.shtml +8 -0
  8. data/apps/app_server/views/app_server.layout.shtml +14 -0
  9. data/apps/cas_server/_init.rb +1 -1
  10. data/apps/config_editor/_init.rb +14 -0
  11. data/apps/config_editor/config_editor.appspec +3 -0
  12. data/apps/config_editor/controllers/config_editor_controller.rb +88 -0
  13. data/apps/config_editor/views/config_editor.layout.shtml +20 -0
  14. data/apps/config_editor/views/index.shtml +23 -0
  15. data/apps/config_editor/widgets/edit/edit.rb +13 -0
  16. data/apps/config_editor/widgets/edit/edit.shtml +4 -0
  17. data/apps/core/auth/models/group.rb +2 -2
  18. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.js +187 -0
  19. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.1.0.min.js +1 -0
  20. data/apps/core/components/public/js/jquery/plugins/jtree/jquery.jtree.spider.1.0.js +193 -0
  21. data/apps/core/components/widgets/table/table.rb +19 -9
  22. data/apps/core/components/widgets/table/table.shtml +2 -2
  23. data/apps/core/forms/widgets/inputs/subform/subform.rb +10 -0
  24. data/apps/core/forms/widgets/inputs/subform/subform.shtml +5 -0
  25. data/apps/hippo/script/converti_strutture.rb +335 -0
  26. data/apps/master/_init.rb +12 -0
  27. data/apps/master/controllers/master_controller.rb +110 -0
  28. data/apps/master/master.appspec +5 -0
  29. data/apps/master/models/customer.rb +13 -0
  30. data/apps/master/models/installation.rb +10 -0
  31. data/apps/master/models/resource.rb +10 -0
  32. data/apps/master/models/servant.rb +25 -0
  33. data/apps/master/views/customer.shtml +20 -0
  34. data/apps/master/views/customers.shtml +10 -0
  35. data/apps/master/views/index.shtml +4 -0
  36. data/apps/master/views/installation.shtml +36 -0
  37. data/apps/master/views/master.layout.shtml +14 -0
  38. data/apps/master/views/servant.shtml +26 -0
  39. data/apps/master/views/servants.shtml +7 -0
  40. data/apps/servant/_init.rb +5 -0
  41. data/apps/servant/bin/spider-servant.rb +47 -0
  42. data/apps/servant/lib/resource.rb +11 -0
  43. data/apps/servant/lib/resources/db/mysql.rb +31 -0
  44. data/apps/servant/lib/resources/db.rb +54 -0
  45. data/apps/servant/lib/servant.rb +82 -0
  46. data/apps/servant/servant.appspec +4 -0
  47. data/apps/servant/var/log/error.log +1 -0
  48. data/apps/worker/worker.rb +1 -1
  49. data/blueprints/install/config.ru +12 -0
  50. data/lib/spiderfw/app.rb +8 -0
  51. data/lib/spiderfw/cmd/cmd.rb +4 -2
  52. data/lib/spiderfw/cmd/commands/content.rb +33 -0
  53. data/lib/spiderfw/cmd/commands/{init.rb → create.rb} +4 -4
  54. data/lib/spiderfw/config/options/spider.rb +4 -0
  55. data/lib/spiderfw/controller/controller.rb +11 -1
  56. data/lib/spiderfw/controller/dispatcher.rb +2 -0
  57. data/lib/spiderfw/controller/home_controller.rb +7 -1
  58. data/lib/spiderfw/controller/mixins/static_content.rb +17 -3
  59. data/lib/spiderfw/controller/mixins/visual.rb +2 -2
  60. data/lib/spiderfw/controller/session.rb +2 -0
  61. data/lib/spiderfw/create.rb +2 -2
  62. data/lib/spiderfw/model/base_model.rb +11 -0
  63. data/lib/spiderfw/model/condition.rb +37 -7
  64. data/lib/spiderfw/model/mappers/db_mapper.rb +67 -71
  65. data/lib/spiderfw/model/mappers/mapper.rb +92 -31
  66. data/lib/spiderfw/model/model.rb +1 -0
  67. data/lib/spiderfw/model/query.rb +1 -3
  68. data/lib/spiderfw/model/query_funcs.rb +51 -0
  69. data/lib/spiderfw/model/storage/db/adapters/oci8.rb +4 -1
  70. data/lib/spiderfw/model/storage/db/db_schema.rb +15 -1
  71. data/lib/spiderfw/model/storage/db/db_storage.rb +8 -2
  72. data/lib/spiderfw/static_content.rb +84 -0
  73. data/lib/spiderfw/utils/monkey/date_time.rb +4 -0
  74. data/lib/spiderfw/utils/monkey/hpricot_compat.rb +0 -0
  75. data/lib/spiderfw/utils/monkey/object.rb +25 -0
  76. data/lib/spiderfw/utils/test_case.rb +24 -0
  77. metadata +54 -24
  78. data/apps/cms/models/content.rb +0 -16
  79. data/apps/cms/models/news_item.rb +0 -7
  80. data/apps/cms/models/translation.rb +0 -14
  81. data/apps/cms/views/admin/admin.shtml +0 -16
  82. data/apps/cms/views/admin/content.shtml +0 -4
  83. data/apps/core/acl/_init.rb +0 -10
  84. data/apps/core/acl/controllers/acl_controller.rb +0 -14
  85. data/apps/core/acl/models/permission.rb +0 -11
  86. data/apps/core/acl/views/acl.layout.shtml +0 -8
  87. data/apps/core/acl/views/index.shtml +0 -3
  88. data/apps/git_model_versioning/models/mixins/git_versioned.rb +0 -91
  89. data/apps/master/controllers/git.rb +0 -32
  90. data/apps/saml/_init.rb +0 -13
  91. data/apps/saml/controllers/saml2idp.rb +0 -18
  92. data/apps/saml/lib/bindings/http_redirect_binding.rb +0 -14
  93. data/apps/saml/lib/messages/authn_request.rb +0 -52
  94. data/apps/saml/lib/saml.rb +0 -10
  95. data/apps/soap/soap.gemspec +0 -10
  96. data/blueprints/model.rb +0 -15
  97. /data/blueprints/{install → home}/config/config.yml +0 -0
  98. /data/blueprints/{install → home}/init.rb +0 -0
@@ -0,0 +1,8 @@
1
+ module Spider
2
+ module AppServer
3
+ include Spider::App
4
+ @controller = :AppServerController
5
+ end
6
+ end
7
+
8
+ require 'apps/app_server/controllers/app_server_controller'
@@ -0,0 +1,60 @@
1
+ require 'find'
2
+ require 'apps/app_server/lib/app'
3
+ require 'apps/app_server/lib/git_app'
4
+
5
+ module Spider
6
+
7
+ module AppServer
8
+
9
+ def self.apps
10
+ @apps ||= scan
11
+ end
12
+
13
+ def self.rescan
14
+ @apps = scan
15
+ end
16
+
17
+ def self.scan
18
+ apps = []
19
+ self.paths.each do |path|
20
+ apps += scan_path(path)
21
+ end
22
+ apps
23
+ end
24
+
25
+ def self.scan_path(path)
26
+ apps = []
27
+ git_repos = search_git(path)
28
+ git_repos.each do |p|
29
+ app = GitApp.new(p)
30
+ apps << app if app.spec
31
+ end
32
+ apps
33
+ end
34
+
35
+ def self.search_git(path)
36
+ found = []
37
+ Find.find(path) do |p|
38
+ if File.directory?(p)
39
+ if File.directory?("#{p}/objects") && File.directory?("#{p}/info") && File.file?("#{p}/HEAD")
40
+ found << p
41
+ Find.prune
42
+ end
43
+ end
44
+ end
45
+ found
46
+ end
47
+
48
+ def self.search_dirs(path)
49
+ Dir.glob("#{path}/**/_init.rb").each do |f|
50
+ found << File.dirname(f)
51
+ end
52
+ end
53
+
54
+ def self.paths
55
+ Spider.conf.get('app_server.search_paths')
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,2 @@
1
+ Spider.config_option 'app_server.search_paths', _("Paths to search for apps"), :type => Array
2
+
@@ -0,0 +1,20 @@
1
+ module Spider; module AppServer
2
+
3
+ class AppServerController < Spider::PageController
4
+
5
+ layout 'app_server'
6
+
7
+ __.html :template => 'app_list'
8
+ __.json :call => :list_json
9
+ def list
10
+ @scene.apps = AppServer.apps
11
+ end
12
+
13
+ def list_json
14
+ $out << AppServer.apps.to_json
15
+ end
16
+
17
+ end
18
+
19
+
20
+ end; end
@@ -0,0 +1,21 @@
1
+ module Spider; module AppServer
2
+
3
+ class App
4
+ attr_accessor :spec
5
+ attr_reader :last_modified
6
+
7
+ def initialize
8
+ end
9
+
10
+ def method_missing(name, *args)
11
+ @spec.send(name, *args) if @spec.respond_to?(name)
12
+ end
13
+
14
+ def to_json
15
+ @spec.to_json
16
+ end
17
+
18
+
19
+ end
20
+
21
+ end; end
@@ -0,0 +1,22 @@
1
+ require 'grit'
2
+
3
+ module Spider; module AppServer
4
+
5
+ class GitApp < App
6
+
7
+ def initialize(path)
8
+ repo = Grit::Repo.new(path)
9
+ spec = nil
10
+ repo.tree.blobs.each do |blob|
11
+ next unless blob.basename =~ /\.appspec$/
12
+ spec = blob.data
13
+ @spec = Spider::App::AppSpec.eval(spec)
14
+ @last_modified = repo.commits.first.authored_date # FIXME
15
+ break
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end; end
@@ -0,0 +1,8 @@
1
+ <ul>
2
+ <li sp:each="@apps |app|">
3
+ <h5>{ app.name } ({ app.version })</h5>
4
+ <div class="description">
5
+ { app.description }
6
+ </div>
7
+ </li>
8
+ </ul>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Spider AppServer</title>
6
+ <script sp:each='@assets[:js] |script|' type="text/javascript" src="{ script }"></script>
7
+ <link sp:each='@assets[:css] |css_file|' rel='stylesheet' href='{ css_file }' />
8
+ </head>
9
+ <body>
10
+ <div id="content">
11
+ <sp:yield />
12
+ </div>
13
+ </body>
14
+ </html>
@@ -18,6 +18,6 @@ end
18
18
 
19
19
  ['mixins/consumable', 'ticket', 'login_ticket',
20
20
  'ticket_granting_ticket', 'proxy_granting_ticket', 'proxy_ticket'].each do |mod|
21
- require Spider::CASServer.path+'/models/'+mod
21
+ require 'apps/cas_server/models/'+mod
22
22
  end
23
23
  require 'apps/cas_server/controllers/mixins/cas_login_mixin'
@@ -0,0 +1,14 @@
1
+ module Spider
2
+
3
+ module ConfigEditor
4
+ include Spider::App
5
+ @controller = :ConfigEditorController
6
+ end
7
+
8
+ end
9
+
10
+ Spider::Template.register_namespace('config_editor', Spider::ConfigEditor)
11
+
12
+
13
+ require 'apps/config_editor/controllers/config_editor_controller'
14
+ require 'apps/config_editor/widgets/edit/edit'
@@ -0,0 +1,3 @@
1
+ name 'Configuration Editor'
2
+ version '0.1'
3
+ author 'Ivan Pirlik'
@@ -0,0 +1,88 @@
1
+ module Spider; module ConfigEditor
2
+
3
+ class ConfigEditorController < Spider::PageController
4
+
5
+ layout 'config_editor'
6
+
7
+ def conf
8
+ Spider.conf
9
+ end
10
+
11
+ def index
12
+ redirect 'options'
13
+ end
14
+
15
+ def before(action='', *arguments)
16
+ super
17
+ @scene.required = []
18
+ self.conf.each do |key, val|
19
+ if !val && self.conf.option(key)[:params][:required]
20
+ @scene.required << key
21
+ end
22
+ end
23
+ end
24
+
25
+ __.html :template => 'index'
26
+ def options(action='')
27
+ @scene.prefix = action
28
+ @scene.prefix += '/' unless @scene.prefix.empty?
29
+ @scene.parts = []
30
+ conf = self.conf.options
31
+ unless action.empty?
32
+ parts = action.split('/')
33
+ tmp_cur_part = ''
34
+ @scene.parts = parts.map{ |p| tmp_cur_part = "#{tmp_cur_part}/#{p}"}
35
+ @scene.parts.pop
36
+ parts.each do |part|
37
+ conf = conf[part]
38
+ end
39
+ end
40
+ @scene.subconfs = []
41
+ @scene.options = {}
42
+ @scene.edit_widgets = {}
43
+ if conf[:params] && conf[:params][:type] == :conf
44
+ @scene.multiple = true
45
+ conf = conf['x']
46
+ end
47
+
48
+ conf.each do |key, val|
49
+ if val.key?(:description) && val.key?(:params) && val[:params][:type] != :conf
50
+ next if val[:description] == "__auto__"
51
+ @scene.options[key] = val
52
+ w = create_edit_widget(key, val)
53
+ @scene.edit_widgets[key] = w
54
+ else
55
+ @scene.subconfs << key
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ __.html :template => 'index'
62
+ def required
63
+ @scene.parts = []
64
+ @scene.subconfs = []
65
+ @scene.options = {}
66
+ @scene.edit_widgets = {}
67
+ self.conf.each do |key, val|
68
+ next unless self.conf.option(key)
69
+ if self.conf.option(key)[:params][:required]
70
+ @scene.options[req] = self.conf.option(key)
71
+ w = create_edit_widget(req, self.conf.option(key))
72
+ @scene.edit_widgets[key] = w
73
+ end
74
+ end
75
+ end
76
+
77
+ def create_edit_widget(key, option)
78
+ w = Edit.new(@request, @response, @scene)
79
+ w.attributes[:name] = key
80
+ w.attributes[:option] = option
81
+ w.widget_init
82
+ w.prepare
83
+ w
84
+ end
85
+
86
+ end
87
+
88
+ end; end
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>_(Spider Configuration Editor)</title>
6
+ <script sp:each='@assets[:js] |script|' type="text/javascript" src="{ script }"></script>
7
+ <link sp:each='@assets[:css] |css_file|' rel='stylesheet' href='{ css_file }' />
8
+ </head>
9
+ <body>
10
+ <div id="content">
11
+ <div id="menu">
12
+ <a href="{ ConfigEditor.url }/options">_(Configuration options)</a>
13
+ <a href="{ ConfigEditor.url }/required">
14
+ _(Required)<span sp:if="!@required.empty?">!</span>
15
+ </a>
16
+ </div>
17
+ <sp:yield />
18
+ </div>
19
+ </body>
20
+ </html>
@@ -0,0 +1,23 @@
1
+ <div>
2
+ <div>
3
+ <a sp:if="!@parts.empty?" href="{ ConfigEditor.url }/options">_(Start)</a>
4
+ <tpl:pass sp:each="@parts |part|">
5
+ <a href="{ ConfigEditor.url }/options{ part }">{ part.split('/').last }</a>
6
+ </tpl:pass>
7
+ </div>
8
+ <form action='' method="post">
9
+ <div sp:if="@multiple">
10
+ Multiple (fixme)
11
+ </div>
12
+ <ul>
13
+ <li sp:each="@subconfs |key|">
14
+ <a href="{ ConfigEditor.url }/options/{ @prefix }{ key }">{ key }</a>
15
+ </li>
16
+ </ul>
17
+ <ul>
18
+ <li sp:each="@options |key, option|">
19
+ <sp:run obj="@edit_widgets[key]" />
20
+ </li>
21
+ </ul>
22
+ </form>
23
+ </div>
@@ -0,0 +1,13 @@
1
+ module Spider; module ConfigEditor
2
+
3
+ class Edit < Spider::Widget
4
+ tag 'edit'
5
+
6
+ is_attribute :name, :type => String
7
+ is_attribute :option
8
+
9
+
10
+
11
+ end
12
+
13
+ end; end
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <label>{ @name }</label>
3
+ <input type="text" name="options[{ @name }]">
4
+ </div>
@@ -1,6 +1,6 @@
1
1
  require 'spiderfw/model/mixins/tree'
2
2
  require 'apps/core/auth/models/mixins/access_control'
3
- require 'uuid'
3
+ require 'uuidtools'
4
4
 
5
5
  module Spider; module Auth
6
6
 
@@ -13,7 +13,7 @@ module Spider; module Auth
13
13
 
14
14
  with_mapper_subclasses do
15
15
  def assign_primary_keys(obj)
16
- obj.set(:gid, UUID.new.generate)
16
+ obj.set(:gid, UUIDTools::UUID.random_create.to_s)
17
17
  end
18
18
  end
19
19
 
@@ -0,0 +1,187 @@
1
+ // JavaScript Document
2
+ (function($) {
3
+
4
+ $.fn.jTree = function(options) {
5
+ var opts = $.extend({}, $.fn.jTree.defaults, options);
6
+ var cur = 0, curOff = 0, off =0, h =0, w=0, hover = 0;
7
+ var str='<li class="jTreePlacement" style="background:'+opts.pBg+';border:'+opts.pBorder+';color:'+opts.pColor+';height:'+opts.pHeight+'"></li>';
8
+ var container = this;
9
+ //events are written here
10
+ $(this).find("li").mousedown(function(e){
11
+ if ($("#jTreeHelper").is(":not(:animated)") && e.button !=2) {
12
+ // append jTreePlacement to body and hides
13
+ $("body").append(str);
14
+ $(".jTreePlacement").hide();
15
+ //get the current li and append to helper
16
+ $(this).clone().appendTo("#jTreeHelper");
17
+
18
+ // get initial state, cur and offset
19
+ cur = this;
20
+ curOff = $(cur).offset();
21
+ $(cur).hide();
22
+ // show initial helper
23
+ $("#jTreeHelper").css ({
24
+ position: "absolute",
25
+ top: e.pageY + 5,
26
+ left: e.pageX + 5,
27
+ background: opts.hBg,
28
+ opacity: opts.hOpacity
29
+ }).show();
30
+ $("#jTreeHelper *").css ({
31
+ color: opts.hColor,
32
+ background: opts.hBg,
33
+ });
34
+ // start binding events to use
35
+ // prevent text selection
36
+ $(document).bind("selectstart", doNothing);
37
+
38
+ // doubleclick is destructive, better disable
39
+ $(container).find("li").bind("dblclick", doNothing);
40
+
41
+ // in single li calculate the offset, width height of hovered block
42
+ $(container).find("li").bind("mouseover", getInitial);
43
+
44
+ // in single li put placement in correct places, also move the helper around
45
+ $(container).find("li").bind("mousemove", putPlacement);
46
+
47
+ // handle mouse movement outside our container
48
+ $(document).bind("mousemove", helperPosition);
49
+ }
50
+ //prevent bubbling of mousedown
51
+ return false;
52
+ });
53
+
54
+ // in single li or in container, snap into placement if present then destroy placement
55
+ // and helper then show snapped in object/li
56
+ // also destroys events
57
+ $(this).find("li").andSelf().mouseup(function(e){
58
+ // if placementBox is detected
59
+ if ($(".jTreePlacement").is(":visible")) {
60
+ $(cur).insertBefore(".jTreePlacement").show();
61
+ }
62
+ $(cur).show();
63
+ // remove helper and placement box
64
+ $(container).find("ul:empty").remove();
65
+ $("#jTreeHelper").empty().hide();
66
+ $(".jTreePlacement").remove();
67
+
68
+ // remove bindings
69
+ destroyBindings();
70
+
71
+ return false;
72
+ });
73
+
74
+ $(document).mouseup(function(e){
75
+ if (cur!=0) {
76
+ $("#jTreeHelper").animate({
77
+ top: curOff.top,
78
+ left: curOff.left
79
+ }, opts.snapBack, function(){
80
+ $("#jTreeHelper").empty().hide();
81
+ $(".jTreePlacement").remove();
82
+ $(cur).show();
83
+ }
84
+ );
85
+ destroyBindings();
86
+ }
87
+ cur = 0;
88
+ return false;
89
+ });
90
+ //functions are written here
91
+ var doNothing = function(){
92
+ return false;
93
+ };
94
+
95
+ var destroyBindings = function(){
96
+ $(document).unbind("selectstart", doNothing);
97
+ $(container).find("li").unbind("dblclick", doNothing);
98
+ $(container).find("li").unbind("mouseover", getInitial);
99
+ $(container).find("li").unbind("mousemove", putPlacement);
100
+ $(document).unbind("mousemove", helperPosition);
101
+ };
102
+
103
+ var helperPosition = function(e) {
104
+ $("#jTreeHelper").css ({
105
+ top: e.pageY + 5,
106
+ left: e.pageX + 5
107
+ });
108
+
109
+ $(".jTreePlacement").remove();
110
+ };
111
+
112
+ var getInitial = function(e){
113
+ off = $(this).offset();
114
+ h = $(this).height();
115
+ w = $(this).width();
116
+ hover = this;
117
+ return false;
118
+ };
119
+
120
+ var putPlacement = function(e){
121
+ $(cur).hide();
122
+ $("#jTreeHelper").css ({
123
+ top: e.pageY + 5,
124
+ left: e.pageX + 5
125
+ });
126
+
127
+ //inserting before
128
+ if ( e.pageY >= off.top && e.pageY < (off.top + h/2 - 1) ) {
129
+ if (!$(this).prev().hasClass("jTreePlacement")) {
130
+ $(".jTreePlacement").remove();
131
+ $(this).before(str);
132
+ }
133
+ }
134
+ //inserting after
135
+ else if (e.pageY >(off.top + h/2) && e.pageY <= (off.top + h) ) {
136
+ // as a sibling
137
+ if (e.pageY > off.left && e.pageX < off.left + opts.childOff) {
138
+ if (!$(this).next().hasClass("jTreePlacement")) {
139
+ $(".jTreePlacement").remove();
140
+ $(this).after(str);
141
+ }
142
+ }
143
+ // as a child
144
+ else if (e.pageX > off.left + opts.childOff) {
145
+
146
+ $(".jTreePlacement").remove();
147
+ if ($(this).find("ul").length == 0)
148
+ $(this).append('<ul>'+str+'</ul>');
149
+ else
150
+ $(this).find("ul").prepend(str);
151
+ }
152
+ }
153
+ return false;
154
+ }
155
+
156
+ var lockIn = function(e) {
157
+ // if placement box is present, insert before placement box
158
+ if ($(".jTreePlacement").length==1) {
159
+ $(cur).insertBefore(".jTreePlacement");
160
+ }
161
+ $(cur).show();
162
+
163
+ // remove helper and placement box
164
+ $("#jTreeHelper").empty().hide();
165
+
166
+ $(".jTreePlacement").remove();;
167
+ }
168
+
169
+ }; // end jTree
170
+
171
+
172
+ $.fn.jTree.defaults = {
173
+ showHelper: false,
174
+ hOpacity: 0.5,
175
+ hBg: "#FCC",
176
+ hColor: "#222",
177
+ pBorder: "1px dashed #CCC",
178
+ pBg: "#EEE",
179
+ pColor: "#222",
180
+ pHeight: "20px",
181
+ childOff: 20,
182
+ snapBack: 1000
183
+ };
184
+
185
+ })(jQuery);
186
+
187
+
@@ -0,0 +1 @@
1
+ (function(A){A.fn.jTree=function(Q){var C=A.extend({},A.fn.jTree.defaults,Q);var O=0,M=0,E=0,F=0,N=0,I=0;var K='<li class="jTreePlacement" style="background:'+C.pBg+";border:"+C.pBorder+";color:"+C.pColor+";height:"+C.pHeight+'"></li>';var D=this;A(this).find("li").mousedown(function(R){if(A("#jTreeHelper").is(":not(:animated)")&&R.button!=2){A("body").append(K);A(".jTreePlacement").hide();A(this).clone().appendTo("#jTreeHelper");O=this;M=A(O).offset();A(O).hide();A("#jTreeHelper").css({position:"absolute",top:R.pageY+5,left:R.pageX+5,background:C.hBg,opacity:C.hOpacity}).show();A("#jTreeHelper *").css({color:C.hColor,background:C.hBg,});A(document).bind("selectstart",G);A(D).find("li").bind("dblclick",G);A(D).find("li").bind("mouseover",H);A(D).find("li").bind("mousemove",J);A(document).bind("mousemove",P)}return false});A(this).find("li").andSelf().mouseup(function(R){if(A(".jTreePlacement").is(":visible")){A(O).insertBefore(".jTreePlacement").show()}A(O).show();A(D).find("ul:empty").remove();A("#jTreeHelper").empty().hide();A(".jTreePlacement").remove();B();return false});A(document).mouseup(function(R){if(O!=0){A("#jTreeHelper").animate({top:M.top,left:M.left},C.snapBack,function(){A("#jTreeHelper").empty().hide();A(".jTreePlacement").remove();A(O).show()});B()}O=0;return false});var G=function(){return false};var B=function(){A(document).unbind("selectstart",G);A(D).find("li").unbind("dblclick",G);A(D).find("li").unbind("mouseover",H);A(D).find("li").unbind("mousemove",J);A(document).unbind("mousemove",P)};var P=function(R){A("#jTreeHelper").css({top:R.pageY+5,left:R.pageX+5});A(".jTreePlacement").remove()};var H=function(R){E=A(this).offset();F=A(this).height();N=A(this).width();I=this;return false};var J=function(R){A(O).hide();A("#jTreeHelper").css({top:R.pageY+5,left:R.pageX+5});if(R.pageY>=E.top&&R.pageY<(E.top+F/2-1)){if(!A(this).prev().hasClass("jTreePlacement")){A(".jTreePlacement").remove();A(this).before(K)}}else{if(R.pageY>(E.top+F/2)&&R.pageY<=(E.top+F)){if(R.pageY>E.left&&R.pageX<E.left+C.childOff){if(!A(this).next().hasClass("jTreePlacement")){A(".jTreePlacement").remove();A(this).after(K)}}else{if(R.pageX>E.left+C.childOff){A(".jTreePlacement").remove();if(A(this).find("ul").length==0){A(this).append("<ul>"+K+"</ul>")}else{A(this).find("ul").prepend(K)}}}}}return false};var L=function(R){if(A(".jTreePlacement").length==1){A(O).insertBefore(".jTreePlacement")}A(O).show();A("#jTreeHelper").empty().hide();A(".jTreePlacement").remove()}};A.fn.jTree.defaults={showHelper:false,hOpacity:0.5,hBg:"#FCC",hColor:"#222",pBorder:"1px dashed #CCC",pBg:"#EEE",pColor:"#222",pHeight:"20px",childOff:20,snapBack:1000}})(jQuery);