window_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/CHANGELOG.rdoc +0 -0
  2. data/LICENSE +44 -0
  3. data/README.rdoc +68 -0
  4. data/app/controllers/window_rails_controller.rb +32 -0
  5. data/files/javascripts/debug.js +137 -0
  6. data/files/javascripts/extended_debug.js +113 -0
  7. data/files/javascripts/tooltip.js +241 -0
  8. data/files/javascripts/window.js +1872 -0
  9. data/files/javascripts/window_effects.js +157 -0
  10. data/files/javascripts/window_ext.js +115 -0
  11. data/files/themes/alert.css +119 -0
  12. data/files/themes/alert/bottom.gif +0 -0
  13. data/files/themes/alert/bottom_left.gif +0 -0
  14. data/files/themes/alert/bottom_right.gif +0 -0
  15. data/files/themes/alert/left.gif +0 -0
  16. data/files/themes/alert/overlay.png +0 -0
  17. data/files/themes/alert/progress.gif +0 -0
  18. data/files/themes/alert/right.gif +0 -0
  19. data/files/themes/alert/top.gif +0 -0
  20. data/files/themes/alert/top_left.gif +0 -0
  21. data/files/themes/alert/top_right.gif +0 -0
  22. data/files/themes/alert_lite.css +88 -0
  23. data/files/themes/alphacube.css +150 -0
  24. data/files/themes/alphacube/bottom-left-c.gif +0 -0
  25. data/files/themes/alphacube/bottom-middle.gif +0 -0
  26. data/files/themes/alphacube/bottom-right-c.gif +0 -0
  27. data/files/themes/alphacube/button-close-focus.gif +0 -0
  28. data/files/themes/alphacube/button-max-focus.gif +0 -0
  29. data/files/themes/alphacube/button-min-focus.gif +0 -0
  30. data/files/themes/alphacube/frame-left.gif +0 -0
  31. data/files/themes/alphacube/frame-right.gif +0 -0
  32. data/files/themes/alphacube/left-top.gif +0 -0
  33. data/files/themes/alphacube/right-top.gif +0 -0
  34. data/files/themes/alphacube/top-middle.gif +0 -0
  35. data/files/themes/behavior.htc +51 -0
  36. data/files/themes/darkX.css +121 -0
  37. data/files/themes/darkX/button-close-focused.png +0 -0
  38. data/files/themes/darkX/button-maximize-focused.png +0 -0
  39. data/files/themes/darkX/button-minimize-focused.png +0 -0
  40. data/files/themes/darkX/frame-bottom-left-focused.png +0 -0
  41. data/files/themes/darkX/frame-bottom-mid-focused.png +0 -0
  42. data/files/themes/darkX/frame-bottom-right-focused.png +0 -0
  43. data/files/themes/darkX/frame-left-focused.png +0 -0
  44. data/files/themes/darkX/frame-right-focused.png +0 -0
  45. data/files/themes/darkX/titlebar-left-focused.png +0 -0
  46. data/files/themes/darkX/titlebar-mid-focused.png +0 -0
  47. data/files/themes/darkX/titlebar-right-focused.png +0 -0
  48. data/files/themes/debug.css +25 -0
  49. data/files/themes/default.css +155 -0
  50. data/files/themes/default/bottom_left.gif +0 -0
  51. data/files/themes/default/bottom_mid.gif +0 -0
  52. data/files/themes/default/bottom_right.gif +0 -0
  53. data/files/themes/default/bottom_right_resize.gif +0 -0
  54. data/files/themes/default/center_left.gif +0 -0
  55. data/files/themes/default/center_right.gif +0 -0
  56. data/files/themes/default/clear.gif +0 -0
  57. data/files/themes/default/close.gif +0 -0
  58. data/files/themes/default/inspect.gif +0 -0
  59. data/files/themes/default/maximize.gif +0 -0
  60. data/files/themes/default/minimize.gif +0 -0
  61. data/files/themes/default/overlay.png +0 -0
  62. data/files/themes/default/resize.gif +0 -0
  63. data/files/themes/default/sizer.gif +0 -0
  64. data/files/themes/default/top_left.gif +0 -0
  65. data/files/themes/default/top_mid.gif +0 -0
  66. data/files/themes/default/top_right.gif +0 -0
  67. data/files/themes/iefix/blank.gif +0 -0
  68. data/files/themes/iefix/iepngfix.css +3 -0
  69. data/files/themes/iefix/iepngfix.htc +54 -0
  70. data/files/themes/lighting.css +960 -0
  71. data/files/themes/lighting/background_buttons.gif +0 -0
  72. data/files/themes/lighting/bottom-left-blue.png +0 -0
  73. data/files/themes/lighting/bottom-left-darkblue.png +0 -0
  74. data/files/themes/lighting/bottom-left-green.png +0 -0
  75. data/files/themes/lighting/bottom-left-grey.png +0 -0
  76. data/files/themes/lighting/bottom-middle-blue.png +0 -0
  77. data/files/themes/lighting/bottom-middle-darkblue.png +0 -0
  78. data/files/themes/lighting/bottom-middle-green.png +0 -0
  79. data/files/themes/lighting/bottom-middle-grey.png +0 -0
  80. data/files/themes/lighting/bottom-right-blue.png +0 -0
  81. data/files/themes/lighting/bottom-right-darkblue.png +0 -0
  82. data/files/themes/lighting/bottom-right-green.png +0 -0
  83. data/files/themes/lighting/bottom-right-grey.png +0 -0
  84. data/files/themes/lighting/button-close-blue.png +0 -0
  85. data/files/themes/lighting/button-close-darkblue.png +0 -0
  86. data/files/themes/lighting/button-close-green.png +0 -0
  87. data/files/themes/lighting/button-close-grey.png +0 -0
  88. data/files/themes/lighting/button-maximize-blue.png +0 -0
  89. data/files/themes/lighting/button-maximize-darkblue.png +0 -0
  90. data/files/themes/lighting/button-maximize-green.png +0 -0
  91. data/files/themes/lighting/button-maximize-grey.png +0 -0
  92. data/files/themes/lighting/button-minimize-blue.png +0 -0
  93. data/files/themes/lighting/button-minimize-darkblue.png +0 -0
  94. data/files/themes/lighting/button-minimize-green.png +0 -0
  95. data/files/themes/lighting/button-minimize-grey.png +0 -0
  96. data/files/themes/lighting/left-blue.png +0 -0
  97. data/files/themes/lighting/left-darkblue.png +0 -0
  98. data/files/themes/lighting/left-green.png +0 -0
  99. data/files/themes/lighting/left-grey.png +0 -0
  100. data/files/themes/lighting/pngbehavior.htc +67 -0
  101. data/files/themes/lighting/right-blue.png +0 -0
  102. data/files/themes/lighting/right-darkblue.png +0 -0
  103. data/files/themes/lighting/right-green.png +0 -0
  104. data/files/themes/lighting/right-grey.png +0 -0
  105. data/files/themes/lighting/spinner.gif +0 -0
  106. data/files/themes/lighting/top-left-blue.png +0 -0
  107. data/files/themes/lighting/top-left-darkblue.png +0 -0
  108. data/files/themes/lighting/top-left-green.png +0 -0
  109. data/files/themes/lighting/top-left-grey.png +0 -0
  110. data/files/themes/lighting/top-middle-blue.png +0 -0
  111. data/files/themes/lighting/top-middle-darkblue.png +0 -0
  112. data/files/themes/lighting/top-middle-green.png +0 -0
  113. data/files/themes/lighting/top-middle-grey.png +0 -0
  114. data/files/themes/lighting/top-right-blue.png +0 -0
  115. data/files/themes/lighting/top-right-darkblue.png +0 -0
  116. data/files/themes/lighting/top-right-green.png +0 -0
  117. data/files/themes/lighting/top-right-grey.png +0 -0
  118. data/files/themes/mac_os_x.css +333 -0
  119. data/files/themes/mac_os_x/B.png +0 -0
  120. data/files/themes/mac_os_x/BL.png +0 -0
  121. data/files/themes/mac_os_x/BL_Main.png +0 -0
  122. data/files/themes/mac_os_x/BR.png +0 -0
  123. data/files/themes/mac_os_x/BR_Main.png +0 -0
  124. data/files/themes/mac_os_x/B_Main.png +0 -0
  125. data/files/themes/mac_os_x/L.png +0 -0
  126. data/files/themes/mac_os_x/L_Main.png +0 -0
  127. data/files/themes/mac_os_x/R.png +0 -0
  128. data/files/themes/mac_os_x/R_Main.png +0 -0
  129. data/files/themes/mac_os_x/T.png +0 -0
  130. data/files/themes/mac_os_x/TL.png +0 -0
  131. data/files/themes/mac_os_x/TL_Main.png +0 -0
  132. data/files/themes/mac_os_x/TR.png +0 -0
  133. data/files/themes/mac_os_x/TR_Main.png +0 -0
  134. data/files/themes/mac_os_x/T_Main.png +0 -0
  135. data/files/themes/mac_os_x/close.gif +0 -0
  136. data/files/themes/mac_os_x/maximize.gif +0 -0
  137. data/files/themes/mac_os_x/minimize.gif +0 -0
  138. data/files/themes/mac_os_x_dialog.css +160 -0
  139. data/files/themes/mac_os_x_dialog/B.png +0 -0
  140. data/files/themes/mac_os_x_dialog/BL.png +0 -0
  141. data/files/themes/mac_os_x_dialog/BR.png +0 -0
  142. data/files/themes/mac_os_x_dialog/L.png +0 -0
  143. data/files/themes/mac_os_x_dialog/R.png +0 -0
  144. data/files/themes/mac_os_x_dialog/T.png +0 -0
  145. data/files/themes/mac_os_x_dialog/TL.png +0 -0
  146. data/files/themes/mac_os_x_dialog/TR.png +0 -0
  147. data/files/themes/mac_os_x_dialog/bg.gif +0 -0
  148. data/files/themes/mac_os_x_dialog/close.gif +0 -0
  149. data/files/themes/mac_os_x_dialog/maximize.gif +0 -0
  150. data/files/themes/mac_os_x_dialog/minimize.gif +0 -0
  151. data/files/themes/nuncio.css +164 -0
  152. data/files/themes/nuncio/bottom_left.png +0 -0
  153. data/files/themes/nuncio/bottom_mid.png +0 -0
  154. data/files/themes/nuncio/bottom_right.png +0 -0
  155. data/files/themes/nuncio/center_left.png +0 -0
  156. data/files/themes/nuncio/center_right.png +0 -0
  157. data/files/themes/nuncio/close.png +0 -0
  158. data/files/themes/nuncio/minimize.png +0 -0
  159. data/files/themes/nuncio/overlay.png +0 -0
  160. data/files/themes/nuncio/top_left.png +0 -0
  161. data/files/themes/nuncio/top_mid.png +0 -0
  162. data/files/themes/nuncio/top_right.png +0 -0
  163. data/files/themes/spread.css +108 -0
  164. data/files/themes/spread/bottom-left-c.gif +0 -0
  165. data/files/themes/spread/bottom-middle.gif +0 -0
  166. data/files/themes/spread/bottom-right-c.gif +0 -0
  167. data/files/themes/spread/button-close-focus.gif +0 -0
  168. data/files/themes/spread/button-max-focus.gif +0 -0
  169. data/files/themes/spread/button-min-focus.gif +0 -0
  170. data/files/themes/spread/frame-left.gif +0 -0
  171. data/files/themes/spread/frame-right.gif +0 -0
  172. data/files/themes/spread/left-top.gif +0 -0
  173. data/files/themes/spread/right-top.gif +0 -0
  174. data/files/themes/spread/top-middle.gif +0 -0
  175. data/init.rb +1 -0
  176. data/install.rb +32 -0
  177. data/lib/window_rails.rb +164 -0
  178. data/lib/window_rails/version.rb +3 -0
  179. data/uninstall.rb +9 -0
  180. metadata +260 -0
data/CHANGELOG.rdoc ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Current WindowRails License:
2
+
3
+ Copyright (c) 2010 Chris Roberts <chrisroberts.code@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
24
+ Original Prototype Window License:
25
+
26
+ Copyright (c) 2006 Sébastien Gruhier (http://xilinus.com, http://itseb.com)
27
+
28
+ Permission is hereby granted, free of charge, to any person obtaining
29
+ a copy of this software and associated documentation files (the
30
+ "Software"), to deal in the Software without restriction, including
31
+ without limitation the rights to use, copy, modify, merge, publish,
32
+ distribute, sublicense, and/or sell copies of the Software, and to
33
+ permit persons to whom the Software is furnished to do so, subject to
34
+ the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be
37
+ included in all copies or substantial portions of the Software.
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
41
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
42
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
43
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
44
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,68 @@
1
+ ++ Important note ++
2
+
3
+ This is still in its infancy and is pretty unstable. This will be removed once it's ready
4
+ for initial release.
5
+
6
+ == WindowRails
7
+
8
+ WindowRails is a plugin for Rails that provides easy to use AJAXy windows. It is based
9
+ completely on {Prototype Window}[http://prototype-window.xilinus.com/] with helpers for
10
+ Rails to make it easy to use from a Rails app.
11
+
12
+ === Basic examples to get you started
13
+
14
+ ==== Linking to a window
15
+ <%= link_to_window('Link', :url => {:controller => :my_controller, :action => :my_action}, :modal => true, :className => 'alphacube', :window => 'some_name') %>
16
+
17
+ ==== Opening a window via AJAX
18
+ def open_my_window
19
+ respond_to do |format|
20
+ format.html
21
+ format.js do
22
+ render :update do |page|
23
+ page.open_window({:partial => 'my_partial'}, :modal => true, :width => 400, :height => 200, :window => 'my_window')
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ ==== Updating a window via AJAX
30
+ def update_my_window
31
+ respond_to do |format|
32
+ format.html
33
+ format.js do
34
+ render :update do |page|
35
+ page.update_window({:partial => 'new_partial'}, :window => 'my_window')
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ ==== Closing a window via AJAX
42
+ def close_my_window
43
+ respond_to do |format|
44
+ format.html
45
+ format.js do
46
+ render :update do |page|
47
+ page.close_window(:window => 'my_window')
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ == Documentation
54
+
55
+ [WindowRails documentation]{http://chrisroberts.github.com/window_rails}
56
+
57
+ == Bugs/Features
58
+
59
+ [Issues]{http://github.com/chrisroberts/window_rails/issues}
60
+
61
+ == Thanks
62
+
63
+ * Many thanks to Sébastien Gruhier (creator of {Prototype Window}[http://prototype-window.xilinus.com/])
64
+
65
+ == License
66
+
67
+ * Prototype Window was released under the MIT license
68
+ * WindowRails continues on under the MIT license
@@ -0,0 +1,32 @@
1
+ class WindowRailsController < ActionController::Base
2
+
3
+ # Make sure we kick any thing out that is making a request other
4
+ # than openning a new window
5
+ before_filter :redirect_out, :except => :open_window
6
+ def redirect_out
7
+ respond_to do |format|
8
+ format.html do
9
+ redirect_to '/'
10
+ end
11
+ format.js do
12
+ render :update do |page|
13
+ page.redirect_to '/'
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ # Opens a new window
20
+ def open_window
21
+ respond_to do |format|
22
+ format.html do
23
+ redirect_to '/'
24
+ end
25
+ format.js do
26
+ render :update do |page|
27
+ page.activate_window({:url => params[:window_url]}, params[:window_options])
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,137 @@
1
+ var debugWindow = null;
2
+ function debug(text, reverse) {
3
+ if (debugWindow == null)
4
+ return;
5
+
6
+ time = "-"; //new Date();
7
+ if (reverse) {
8
+ $('debug').innerHTML = time + " " + text + "<br>"+ $('debug').innerHTML;
9
+ debugWindow.getContent().scrollTop=0;
10
+ }
11
+ else {
12
+ $('debug').innerHTML += time + " " + text + "<br>";
13
+ debugWindow.getContent().scrollTop=10000; // Far away
14
+ }
15
+ }
16
+
17
+ function hideDebug() {
18
+ if (debugWindow) {
19
+ debugWindow.destroy();
20
+ debugWindow = null;
21
+ }
22
+ }
23
+
24
+ function showDebug(bShow) {
25
+ if (debugWindow == null) {
26
+ debugWindow = new Window('debug_window', {className: 'dialog',width:250, height:100, right:4, bottom:42, zIndex:1000, opacity:1, showEffect: Element.show, resizable: true, title: "Debug"})
27
+ debugWindow.getContent().innerHTML = "<style>#debug_window .dialog_content {background:#000;}</style> <div id='debug'></div>";
28
+ date=new Date;
29
+ date.setMonth(date.getMonth()+3);
30
+
31
+ //debugWindow.setCookie(null, date);
32
+ }
33
+ if( typeof bShow == 'undefined' || bShow)debugWindow.show()
34
+ }
35
+
36
+
37
+ function clearDebug() {
38
+ if (debugWindow == null)
39
+ return;
40
+ $('debug').innerHTML = "";
41
+ }
42
+
43
+ /**
44
+ * document.createElement convenience wrapper
45
+ *
46
+ * The data parameter is an object that must have the "tag" key, containing
47
+ * a string with the tagname of the element to create. It can optionally have
48
+ * a "children" key which can be: a string, "data" object, or an array of "data"
49
+ * objects to append to this element as children. Any other key is taken as an
50
+ * attribute to be applied to this tag.
51
+ *
52
+ * Available under an MIT license:
53
+ * http://www.opensource.org/licenses/mit-license.php
54
+ *
55
+ * @param {Object} data The data representing the element to create
56
+ * @return {Element} The element created.
57
+ */
58
+ function $E(data) {
59
+ var el;
60
+ if ('string'==typeof data) {
61
+ el=document.createTextNode(data);
62
+ } else {
63
+ //create the element
64
+ el=document.createElement(data.tag);
65
+ delete(data.tag);
66
+
67
+ //append the children
68
+ if ('undefined'!=typeof data.children) {
69
+ if ('string'==typeof data.children ||'undefined'==typeof data.children.length) {
70
+ //strings and single elements
71
+ el.appendChild($E(data.children));
72
+ } else {
73
+ //arrays of elements
74
+ for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) {
75
+ el.appendChild($E(child));
76
+ }
77
+ }
78
+ delete(data.children);
79
+ }
80
+
81
+ //any other data is attributes
82
+ for (attr in data) {
83
+ el[attr]=data[attr];
84
+ }
85
+ }
86
+
87
+ return el;
88
+ }
89
+
90
+ // FROM Nick Hemsley
91
+ var Debug = {
92
+ inspectOutput: function (container, within) {
93
+ within = within || debugWindow.getContent()
94
+
95
+ if (debugWindow == null)
96
+ return;
97
+
98
+ within.appendChild(container)
99
+ },
100
+
101
+ inspect: function(object) {
102
+ var cont = $E({tag: "div", className: "inspector"})
103
+ Debug.inspectObj(object, cont)
104
+ debugWindow.getContent().appendChild(cont)
105
+ },
106
+
107
+ inspectObj: function (object, container) {
108
+ for (prop in object) {
109
+ Debug.inspectOutput(Debug.inspectable(object, prop), container)
110
+ }
111
+ },
112
+
113
+ inspectable: function(object, prop) {
114
+ cont = $E({tag: 'div', className: 'inspectable', children: [prop + " value: " + object[prop] ]})
115
+ cont.toInspect = object[prop]
116
+ Event.observe(cont, 'click', Debug.inspectClicked, false)
117
+ return cont
118
+ },
119
+
120
+ inspectClicked: function(e) {
121
+ Debug.inspectContained(Event.element(e))
122
+ Event.stop(e)
123
+ },
124
+
125
+ inspectContained: function(container) {
126
+ if (container.opened) {
127
+ container.parentNode.removeChild(container.opened)
128
+ delete(container.opened)
129
+ } else {
130
+ sibling = container.parentNode.insertBefore($E({tag: "div", className: "child"}), container.nextSibling)
131
+ if (container.toInspect)
132
+ Debug.inspectObj(container.toInspect, sibling)
133
+ container.opened = sibling
134
+ }
135
+ }
136
+ }
137
+ var inspect = Debug.inspect;
@@ -0,0 +1,113 @@
1
+ var commandHistory;
2
+ var historyIndex;
3
+
4
+ function showExtendedDebug() {
5
+ if (debugWindow != null) {
6
+ hideDebug();
7
+ }
8
+
9
+ if (debugWindow == null) {
10
+ commandHistory = new Array();
11
+ historyIndex = 0;
12
+
13
+ debugWindow = new Window('debug_window', {className: 'dialog',width:250, height:100, right:4, minWidth:250, bottom:42, zIndex:1000, opacity:1, showEffect: Element.show, resizable: true, title: "Debug"})
14
+ debugWindow.getContent().innerHTML = "<style>#debug_window .dialog_content {background:#000;}</style> <div font='monaco' id='debug' style='padding:3px;color:#0F0;font-family:monaco'></div>";
15
+
16
+ //create hourglass icon and attach events to it.
17
+ var cont = "<div id=\"debug_window_inspect\" style=\"width: 15px; height: 15px; background: transparent url(themes/default/inspect.gif) no-repeat 0 0; position:absolute; top:5px; left:70px; cursor:pointer; z-index:3000;\"></div>";
18
+
19
+ new Insertion.After('debug_window_maximize', cont);
20
+ Event.observe('debug_window_inspect', 'click', enterInspectionMode, false);
21
+
22
+ //create command text box
23
+ cont = "Eval:<input id=\"debug_window_command\" type=\"textbox\" style=\"width:150px; height: 12px; color: black;\">"
24
+ debugWindow.setStatusBar(cont);
25
+
26
+ Event.observe('debug_window_command', 'mousedown', donothing);
27
+ Event.observe('debug_window_command', 'keypress', evalJS, false);
28
+ }
29
+ debugWindow.show();
30
+ }
31
+
32
+ function donothing(evt){
33
+ Field.activate('debug_window_command');
34
+ return false;
35
+ }
36
+
37
+ function evalJS(evt){
38
+ if(evt.keyCode == Event.KEY_RETURN){
39
+ var js = $F('debug_window_command');
40
+ try{
41
+ var ret = eval(js);
42
+ if(ret != null)
43
+ debug(ret);
44
+ }catch(e){
45
+ debug(e);
46
+ }
47
+ $('debug_window_command').value = '';
48
+
49
+ Field.activate('debug_window_command');
50
+ commandHistory.push(js);
51
+ historyIndex = 0;
52
+ }
53
+
54
+ if(evt.keyCode == Event.KEY_UP){
55
+ if(commandHistory.length > historyIndex){
56
+ historyIndex++;
57
+ var js = commandHistory[commandHistory.length-historyIndex];
58
+ $('debug_window_command').value = js;
59
+ Event.stop(evt);
60
+ Field.activate('debug_window_command');
61
+ }
62
+ }
63
+
64
+ if(evt.keyCode == Event.KEY_DOWN){
65
+ if(commandHistory.length >= historyIndex && historyIndex > 1){
66
+ historyIndex--;
67
+ var js = commandHistory[commandHistory.length-historyIndex];
68
+ $('debug_window_command').value = js;
69
+ Event.stop(evt);
70
+ Field.activate('debug_window_command');
71
+ }
72
+ }
73
+ }
74
+
75
+ function enterInspectionMode(evt){
76
+ //stop observing magnifying glass
77
+ Event.stopObserving('debug_window_inspect', 'click', enterInspectionMode, false);
78
+ //change pointer
79
+ document.body.style.cursor='help';
80
+ //start observing mouse clicks
81
+ Event.observe(window, 'click', inspectItem, false);
82
+ }
83
+
84
+ function inspectItem(evt){
85
+ // the element that triggered the event
86
+ var element = Event.element(evt);
87
+ if(element.id!="debug_window_inspect"){
88
+ clearDebug()
89
+ //change pointer
90
+ document.body.style.cursor='default';
91
+ debug(element.id);
92
+ inspect(element);
93
+ //stop observing mouse clicks
94
+ Event.stopObserving(window, 'click', inspectItem, false);
95
+ //alert('doing something');
96
+ //start observing mag
97
+ Event.observe('debug_window_inspect', 'click', enterInspectionMode, false);
98
+ }
99
+ }
100
+
101
+ function clearDebug() {
102
+ var win = $('debug');
103
+ if (win == null)
104
+ return;
105
+
106
+ win.innerHTML=" ";
107
+ //clear inspections too
108
+ var divs = document.getElementsByClassName('inspector');
109
+ divs.each(function(div){
110
+ Element.remove(div);
111
+ });
112
+ }
113
+
@@ -0,0 +1,241 @@
1
+ // Singleton class TooltipWindow
2
+ // This class works with special className. The tooltip content could be in your HTML page as an hidden element or
3
+ // can be retreive by an AJAX call.
4
+ //
5
+ // To work, You just need to set two class name on elements that should show tooltips
6
+ // - One to say to TooltipManager that this element must have a tooltip ('tooltip' by default)
7
+ // - Another to indicate how to find the tooltip content
8
+ // It could be html_XXXX if tootltip content is somewhere hidden in your page, XXX must be DOM ID of this hidden element
9
+ // It could be ajax_XXXX if tootltip content must be find by an ajax request, XXX will be the string send as id parameter to your server.
10
+ // Check samples/tooltips/tooltip.html to see how it works
11
+ //
12
+ TooltipManager = {
13
+ options: {cssClassName: 'tooltip', delayOver: 200, delayOut: 1000, shiftX: 10, shiftY: 10,
14
+ className: 'alphacube', width: 200, height: null,
15
+ draggable: false, minimizable: false, maximizable: false, showEffect: Element.show, hideEffect: Element.hide},
16
+ ajaxInfo: null,
17
+ elements: null,
18
+ showTimer: null,
19
+ hideTimer: null,
20
+
21
+ // Init tooltip manager
22
+ // parameters:
23
+ // - cssClassName (string) : CSS class name where tooltip should be shown.
24
+ // - ajaxOptions (hash) : Ajax options for ajax tooltip.
25
+ // For examples {url: "/tooltip/get.php", options: {method: 'get'}}
26
+ // see Ajax.Request documentation for details
27
+ //- tooltipOptions (hash) : available keys
28
+ // - delayOver: int in ms (default 10) delay before showing tooltip
29
+ // - delayOut: int in ms (default 1000) delay before hidding tooltip
30
+ // - shiftX: int in pixels (default 10) left shift of the tooltip window
31
+ // - shiftY: int in pixels (default 10) top shift of the tooltip window
32
+ // and All window options like showEffect: Element.show, hideEffect: Element.hide to remove animation
33
+ // default: {className: 'alphacube', width: 200, height: null, draggable: false, minimizable: false, maximizable: false}
34
+
35
+ init: function(cssClassName, ajaxInfo, tooltipOptions) {
36
+ TooltipManager.options = Object.extend(TooltipManager.options, tooltipOptions || {});
37
+
38
+ cssClassName = TooltipManager.options.cssClassName || "tooltip";
39
+ TooltipManager.ajaxInfo = ajaxInfo;
40
+ TooltipManager.elements = $$("." + cssClassName);
41
+ TooltipManager.elements.each(function(element) {
42
+ element = $(element)
43
+ var info = TooltipManager._getInfo(element);
44
+ if (info.ajax) {
45
+ element.ajaxId = info.id;
46
+ element.ajaxInfo = ajaxInfo;
47
+ }
48
+ else {
49
+ element.tooltipElement = $(info.id);
50
+ }
51
+ element.observe("mouseover", TooltipManager._mouseOver);
52
+ element.observe("mouseout", TooltipManager._mouseOut);
53
+ });
54
+ Windows.addObserver(this);
55
+ },
56
+
57
+ addHTML: function(element, tooltipElement) {
58
+ element = $(element);
59
+ tooltipElement = $(tooltipElement);
60
+ element.tooltipElement = tooltipElement;
61
+
62
+ element.observe("mouseover", TooltipManager._mouseOver);
63
+ element.observe("mouseout", TooltipManager._mouseOut);
64
+ },
65
+
66
+ addAjax: function(element, ajaxInfo) {
67
+ element = $(element);
68
+ element.ajaxInfo = ajaxInfo;
69
+ element.observe("mouseover", TooltipManager._mouseOver);
70
+ element.observe("mouseout", TooltipManager._mouseOut);
71
+ },
72
+
73
+ addURL: function(element, url, width, height) {
74
+ element = $(element);
75
+ element.url = url;
76
+ element.frameWidth = width;
77
+ element.frameHeight = height;
78
+ element.observe("mouseover", TooltipManager._mouseOver);
79
+ element.observe("mouseout", TooltipManager._mouseOut);
80
+ },
81
+
82
+ close: function() {
83
+ if (TooltipManager.tooltipWindow)
84
+ TooltipManager.tooltipWindow.hide();
85
+ },
86
+
87
+ preloadImages: function(path, images, extension) {
88
+ if (!extension)
89
+ extension = ".gif";
90
+
91
+ //preload images
92
+ $A(images).each(function(i) {
93
+ var image = new Image();
94
+ image.src= path + "/" + i + extension;
95
+ });
96
+ },
97
+
98
+ _showTooltip: function(element) {
99
+ if (this.element == element)
100
+ return;
101
+ // Get original element
102
+ while (element && (!element.tooltipElement && !element.ajaxInfo && !element.url))
103
+ element = element.parentNode;
104
+ this.element = element;
105
+
106
+ TooltipManager.showTimer = null;
107
+ if (TooltipManager.hideTimer)
108
+ clearTimeout(TooltipManager.hideTimer);
109
+
110
+ var position = Position.cumulativeOffset(element);
111
+ var dimension = element.getDimensions();
112
+
113
+ if (! this.tooltipWindow)
114
+ this.tooltipWindow = new Window("__tooltip__", TooltipManager.options);
115
+
116
+ this.tooltipWindow.hide();
117
+ this.tooltipWindow.setLocation(position[1] + dimension.height + TooltipManager.options.shiftY, position[0] + TooltipManager.options.shiftX);
118
+
119
+ Event.observe(this.tooltipWindow.element, "mouseover", function(event) {TooltipManager._tooltipOver(event, element)});
120
+ Event.observe(this.tooltipWindow.element, "mouseout", function(event) {TooltipManager._tooltipOut(event, element)});
121
+
122
+ // Reset width/height for computation
123
+ this.tooltipWindow.height = TooltipManager.options.height;
124
+ this.tooltipWindow.width = TooltipManager.options.width;
125
+
126
+ // Ajax content
127
+ if (element.ajaxInfo) {
128
+ var p = element.ajaxInfo.options.parameters;
129
+ var saveParam = p;
130
+
131
+ // Set by CSS
132
+ if (element.ajaxId) {
133
+ if (p)
134
+ p += "&id=" + element.ajaxId;
135
+ else
136
+ p = "id=" + element.ajaxId;
137
+ }
138
+ element.ajaxInfo.options.parameters = p || "";
139
+ this.tooltipWindow.setHTMLContent("");
140
+ this.tooltipWindow.setAjaxContent(element.ajaxInfo.url, element.ajaxInfo.options);
141
+ element.ajaxInfo.options.parameters = saveParam;
142
+ }
143
+ // URL content
144
+ else if (element.url) {
145
+ this.tooltipWindow.setURL(element.url);
146
+ this.tooltipWindow.setSize(element.frameWidth, element.frameHeight);
147
+
148
+ // Set tooltip size
149
+ this.tooltipWindow.height = element.frameHeight;
150
+ this.tooltipWindow.width = element.frameWidth;
151
+ }
152
+ // HTML content
153
+ else
154
+ this.tooltipWindow.setHTMLContent(element.tooltipElement.innerHTML);
155
+
156
+ if (!element.ajaxInfo) {
157
+ this.tooltipWindow.show();
158
+ this.tooltipWindow.toFront();
159
+ }
160
+ },
161
+
162
+ _hideTooltip: function(element) {
163
+ if (this.tooltipWindow) {
164
+ this.tooltipWindow.hide();
165
+ this.element = null;
166
+ }
167
+ },
168
+
169
+ _mouseOver: function (event) {
170
+ var element = Event.element(event);
171
+ if (TooltipManager.showTimer)
172
+ clearTimeout(TooltipManager.showTimer);
173
+
174
+ TooltipManager.showTimer = setTimeout(function() {TooltipManager._showTooltip(element)}, TooltipManager.options.delayOver)
175
+ },
176
+
177
+ _mouseOut: function(event) {
178
+ var element = Event.element(event);
179
+ if (TooltipManager.showTimer) {
180
+ clearTimeout(TooltipManager.showTimer);
181
+ TooltipManager.showTimer = null;
182
+ return;
183
+ }
184
+ if (TooltipManager.tooltipWindow)
185
+ TooltipManager.hideTimer = setTimeout(function() {TooltipManager._hideTooltip(element)}, TooltipManager.options.delayOut)
186
+ },
187
+
188
+ _tooltipOver: function(event, element) {
189
+ if (TooltipManager.hideTimer) {
190
+ clearTimeout(TooltipManager.hideTimer);
191
+ TooltipManager.hideTimer = null;
192
+ }
193
+ },
194
+
195
+ _tooltipOut: function(event, element) {
196
+ if (TooltipManager.hideTimer == null)
197
+ TooltipManager.hideTimer = setTimeout(function() {TooltipManager._hideTooltip(element)}, TooltipManager.options.delayOut)
198
+ },
199
+
200
+ _getInfo: function(element) {
201
+ // Find html_ for static content
202
+ var id = element.className.split(' ').detect(function(name) {return name.indexOf("html_") == 0});
203
+ var ajax = true;
204
+ if (id)
205
+ ajax = false;
206
+ else
207
+ // Find ajax_ for ajax content
208
+ id = element.className.split(' ').detect(function(name) {return name.indexOf("ajax_") == 0});
209
+
210
+ id = id.substr(id.indexOf('_')+1, id.length)
211
+ return id ? {ajax: ajax, id: id} : null;
212
+ },
213
+
214
+ onBeforeShow: function(eventName, win) {
215
+ var top = parseFloat(win.getLocation().top);
216
+ var dim = win.element.getDimensions();
217
+
218
+ if (top + dim.height > TooltipManager._getScrollTop() + TooltipManager._getPageHeight()) {
219
+ var position = Position.cumulativeOffset(this.element);
220
+
221
+ var top = position[1] - TooltipManager.options.shiftY - dim.height;
222
+ win.setLocation(top, position[0] + TooltipManager.options.shiftX)
223
+ }
224
+ },
225
+
226
+ _getPageWidth: function(){
227
+ return window.innerWidth || document.documentElement.clientWidth || 0;
228
+ },
229
+
230
+ _getPageHeight: function(){
231
+ return window.innerHeight || document.documentElement.clientHeight || 0;
232
+ },
233
+
234
+ _getScrollTop: function(){
235
+ return document.documentElement.scrollTop || window.pageYOffset || 0;
236
+ },
237
+
238
+ _getScrollLeft: function(){
239
+ return document.documentElement.scrollLeft || window.pageXOffset || 0;
240
+ }
241
+ };