zen 0.2.4.1 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/MANIFEST +42 -33
  2. data/README.md +14 -27
  3. data/ROADMAP.md +20 -2
  4. data/{Thorfile → Rakefile} +2 -3
  5. data/bin/zen +27 -5
  6. data/lib/zen.rb +70 -52
  7. data/lib/zen/asset.rb +258 -0
  8. data/lib/zen/bin/app.rb +42 -0
  9. data/lib/zen/controller/admin_controller.rb +53 -36
  10. data/lib/zen/controller/base_controller.rb +13 -8
  11. data/lib/zen/controller/frontend_controller.rb +4 -3
  12. data/lib/zen/controller/main_controller.rb +17 -33
  13. data/lib/zen/error/validation_error.rb +10 -0
  14. data/lib/zen/ext/string.rb +185 -0
  15. data/lib/zen/helper/acl.rb +120 -92
  16. data/lib/zen/helper/common.rb +1 -3
  17. data/lib/zen/helper/theme.rb +73 -0
  18. data/lib/zen/language.rb +66 -57
  19. data/lib/zen/layout/admin.xhtml +5 -48
  20. data/lib/zen/layout/login.xhtml +4 -44
  21. data/lib/zen/model/methods.rb +1 -1
  22. data/lib/zen/model/settings.rb +0 -3
  23. data/lib/zen/package.rb +101 -83
  24. data/lib/zen/package/base.rb +62 -0
  25. data/lib/zen/package/categories/lib/categories.rb +29 -10
  26. data/lib/zen/package/categories/lib/categories/controller/categories.rb +4 -5
  27. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +4 -5
  28. data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +4 -3
  29. data/lib/zen/package/categories/lib/categories/model/category.rb +2 -2
  30. data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
  31. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +130 -0
  32. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +1 -1
  33. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +2 -2
  34. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +11 -6
  35. data/lib/zen/package/comments/lib/comments.rb +23 -13
  36. data/lib/zen/package/comments/lib/comments/controller/comments.rb +4 -5
  37. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +7 -8
  38. data/lib/zen/package/comments/lib/comments/model/comment.rb +4 -4
  39. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +111 -0
  40. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +2 -2
  41. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +3 -3
  42. data/lib/zen/package/custom_fields/lib/custom_fields.rb +18 -11
  43. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +4 -5
  44. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +4 -5
  45. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +2 -2
  46. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +3 -3
  47. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +3 -3
  48. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +9 -5
  49. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +1 -1
  50. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +3 -3
  51. data/lib/zen/package/menus/lib/menus.rb +25 -43
  52. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +5 -6
  53. data/lib/zen/package/menus/lib/menus/controller/menus.rb +9 -5
  54. data/lib/zen/package/menus/lib/menus/helper/menu_item.rb +4 -4
  55. data/lib/zen/package/menus/lib/menus/model/menu.rb +2 -2
  56. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +4 -1
  57. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +152 -0
  58. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +1 -1
  59. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +3 -3
  60. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +7 -7
  61. data/lib/zen/package/sections/lib/sections.rb +32 -16
  62. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +9 -18
  63. data/lib/zen/package/sections/lib/sections/controller/sections.rb +8 -9
  64. data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +1 -1
  65. data/lib/zen/package/sections/lib/sections/model/section.rb +4 -4
  66. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +9 -10
  67. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +224 -0
  68. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +85 -0
  69. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +1 -1
  70. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +9 -5
  71. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +2 -2
  72. data/lib/zen/package/settings/lib/settings.rb +145 -10
  73. data/lib/zen/package/settings/lib/settings/controller/settings.rb +28 -24
  74. data/lib/zen/package/settings/lib/settings/language/en/settings.yml +10 -0
  75. data/lib/zen/package/settings/lib/settings/model/setting.rb +3 -64
  76. data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +40 -0
  77. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +76 -0
  78. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +236 -0
  79. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +20 -49
  80. data/lib/zen/package/settings/migrations/1295597111_create_schema.rb +0 -12
  81. data/lib/zen/package/settings/migrations/1303196915_settings_plugin.rb +31 -0
  82. data/lib/zen/package/users/lib/users.rb +18 -15
  83. data/lib/zen/package/users/lib/users/controller/access_rules.rb +44 -8
  84. data/lib/zen/package/users/lib/users/controller/user_groups.rb +4 -5
  85. data/lib/zen/package/users/lib/users/controller/users.rb +5 -6
  86. data/lib/zen/package/users/lib/users/language/en/access_rules.yml +11 -9
  87. data/lib/zen/package/users/lib/users/model/access_rule.rb +7 -6
  88. data/lib/zen/package/users/lib/users/model/user.rb +4 -4
  89. data/lib/zen/package/users/lib/users/model/user_group.rb +3 -3
  90. data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +50 -0
  91. data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +32 -29
  92. data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +8 -6
  93. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +3 -3
  94. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +2 -2
  95. data/lib/zen/package/users/migrations/1303510943_class_rules.rb +13 -0
  96. data/lib/zen/plugin.rb +110 -104
  97. data/lib/zen/plugin/base.rb +46 -0
  98. data/lib/zen/{liquid/controller_behavior.rb → plugin/controller.rb} +9 -7
  99. data/lib/zen/plugin/helper.rb +47 -0
  100. data/lib/zen/plugin/markup/lib/markup.rb +14 -0
  101. data/lib/zen/plugin/markup/lib/markup/language/en/markup.yml +6 -0
  102. data/lib/zen/plugin/markup/lib/markup/markup.rb +154 -0
  103. data/lib/zen/public/admin/css/forms.css +4 -0
  104. data/lib/zen/public/admin/css/general.css +15 -15
  105. data/lib/zen/public/admin/css/layout.css +10 -10
  106. data/lib/zen/public/admin/css/reset.css +123 -0
  107. data/lib/zen/public/admin/images/icons/accept.png +0 -0
  108. data/lib/zen/public/admin/images/icons/add.png +0 -0
  109. data/lib/zen/public/admin/images/icons/back.png +0 -0
  110. data/lib/zen/public/admin/images/icons/bold.png +0 -0
  111. data/lib/zen/public/admin/images/icons/close.png +0 -0
  112. data/lib/zen/public/admin/images/icons/delete.png +0 -0
  113. data/lib/zen/public/admin/images/icons/edit.png +0 -0
  114. data/lib/zen/public/admin/images/icons/error.png +0 -0
  115. data/lib/zen/public/admin/images/icons/help.png +0 -0
  116. data/lib/zen/public/admin/images/icons/info.png +0 -0
  117. data/lib/zen/public/admin/images/icons/italic.png +0 -0
  118. data/lib/zen/public/admin/images/icons/large/error.png +0 -0
  119. data/lib/zen/public/admin/images/icons/large/notice.png +0 -0
  120. data/lib/zen/public/admin/images/icons/large/success.png +0 -0
  121. data/lib/zen/public/admin/images/icons/link.png +0 -0
  122. data/lib/zen/public/admin/images/icons/logout.png +0 -0
  123. data/lib/zen/public/admin/images/icons/ol.png +0 -0
  124. data/lib/zen/public/admin/images/icons/pdf.png +0 -0
  125. data/lib/zen/public/admin/images/icons/ul.png +0 -0
  126. data/lib/zen/public/admin/images/icons/user.png +0 -0
  127. data/lib/zen/public/admin/images/icons/view.png +0 -0
  128. data/lib/zen/public/admin/js/mootools/core.js +384 -333
  129. data/lib/zen/public/admin/js/mootools/more.js +256 -231
  130. data/lib/zen/public/admin/js/vendor/{datepicker/Picker.Date.js → datepicker.js} +447 -0
  131. data/lib/zen/public/admin/js/vendor/yepnope.js +1 -0
  132. data/lib/zen/public/admin/js/zen/editor/base.js +8 -1
  133. data/lib/zen/public/admin/js/zen/init.js +89 -26
  134. data/lib/zen/public/favicon.ico +0 -0
  135. data/lib/zen/task.rb +7 -0
  136. data/lib/zen/task/build.rake +60 -0
  137. data/lib/zen/task/clean.rake +27 -0
  138. data/lib/zen/task/db.rake +111 -0
  139. data/lib/zen/task/package.rake +67 -0
  140. data/lib/zen/task/plugin.rake +24 -0
  141. data/lib/zen/task/proto.rake +95 -0
  142. data/lib/zen/task/theme.rake +68 -0
  143. data/lib/zen/theme.rb +28 -55
  144. data/lib/zen/theme/base.rb +64 -0
  145. data/lib/zen/validation.rb +149 -0
  146. data/lib/zen/version.rb +1 -1
  147. data/lib/zen/view/bottom.xhtml +6 -0
  148. data/lib/zen/view/main.xhtml +32 -0
  149. data/proto/app/Rakefile +12 -0
  150. data/proto/app/app.rb +6 -6
  151. data/proto/app/config/config.rb +7 -14
  152. data/proto/app/config/database.rb +0 -20
  153. data/proto/app/start.rb +0 -1
  154. data/proto/app/{vendor/themes → task}/.gitkeep +0 -0
  155. data/proto/app/vendor/theme/.gitkeep +0 -0
  156. data/proto/package/lib/package.rb +8 -17
  157. data/proto/package/lib/package/controller/controllers.rb +4 -4
  158. data/proto/package/lib/package/language/en/languages.yml +3 -3
  159. data/proto/package/lib/package/model/model.rb +1 -1
  160. metadata +73 -73
  161. data/lib/zen/bin/base.rb +0 -109
  162. data/lib/zen/helper/asset.rb +0 -106
  163. data/lib/zen/liquid/general.rb +0 -94
  164. data/lib/zen/liquid/redirect.rb +0 -70
  165. data/lib/zen/liquid/strip.rb +0 -60
  166. data/lib/zen/package/categories/lib/categories/liquid/categories.rb +0 -16
  167. data/lib/zen/package/comments/lib/comments/liquid/comment_form.rb +0 -127
  168. data/lib/zen/package/comments/lib/comments/liquid/comments.rb +0 -115
  169. data/lib/zen/package/menus/lib/menus/liquid/menus.rb +0 -152
  170. data/lib/zen/package/sections/lib/sections/liquid/section_entries.rb +0 -228
  171. data/lib/zen/package/sections/lib/sections/liquid/sections.rb +0 -77
  172. data/lib/zen/package/settings/lib/settings/liquid/setting.rb +0 -58
  173. data/lib/zen/package/users/lib/users/liquid/user.rb +0 -77
  174. data/lib/zen/package/users/lib/users/liquid/users.rb +0 -82
  175. data/lib/zen/plugin/markup.rb +0 -30
  176. data/lib/zen/public/admin/css/boilerplate.css +0 -176
  177. data/lib/zen/public/admin/images/general/noise.jpg +0 -0
  178. data/lib/zen/public/admin/js/vendor/datepicker/Picker.Attach.js +0 -137
  179. data/lib/zen/public/admin/js/vendor/datepicker/Picker.js +0 -291
  180. data/lib/zen/public/admin/js/vendor/datepicker/README.md +0 -325
  181. data/lib/zen/public/admin/js/vendor/datepicker/locale.js +0 -16
  182. data/lib/zen/strict_struct.rb +0 -36
  183. data/lib/zen/task/build.rb +0 -123
  184. data/lib/zen/task/clean.rb +0 -46
  185. data/lib/zen/task/db.rb +0 -130
  186. data/lib/zen/task/package.rb +0 -87
  187. data/lib/zen/task/proto.rb +0 -116
  188. data/lib/zen/task/theme.rb +0 -88
  189. data/proto/app/Thorfile +0 -4
@@ -1,3 +1,450 @@
1
+ /*
2
+ ---
3
+ name: Picker
4
+ description: Creates a Picker, which can be used for anything
5
+ authors: Arian Stolwijk
6
+ requires: [Core/Element.Dimensions, Core/Fx.Tween, Core/Fx.Transitions]
7
+ provides: Picker
8
+ ...
9
+ */
10
+
11
+
12
+ var Picker = new Class({
13
+
14
+ Implements: [Options, Events],
15
+
16
+ options: {/*
17
+ onShow: function(){},
18
+ onOpen: function(){},
19
+ onHide: function(){},
20
+ onClose: function(){},*/
21
+
22
+ pickerClass: 'datepicker',
23
+ inject: null,
24
+ animationDuration: 400,
25
+ useFadeInOut: true,
26
+ positionOffset: {x: 0, y: 0},
27
+ pickerPosition: 'bottom',
28
+ draggable: true,
29
+ showOnInit: true
30
+ },
31
+
32
+ initialize: function(options){
33
+ this.setOptions(options);
34
+ this.constructPicker();
35
+ if (this.options.showOnInit) this.show();
36
+ },
37
+
38
+ constructPicker: function(){
39
+ var options = this.options;
40
+
41
+ var picker = this.picker = new Element('div', {
42
+ 'class': options.pickerClass,
43
+ styles: {
44
+ left: 0,
45
+ top: 0,
46
+ display: 'none',
47
+ opacity: 0
48
+ }
49
+ }).inject(options.inject || document.body);
50
+
51
+ if (options.useFadeInOut){
52
+ picker.set('tween', {
53
+ duration: options.animationDuration,
54
+ link: 'cancel'
55
+ });
56
+ }
57
+
58
+ // Build the header
59
+ var header = this.header = new Element('div.header').inject(picker);
60
+
61
+ this.closeButton = new Element('div.closeButton[text=x]')
62
+ .addEvent('click', this.close.pass(false, this))
63
+ .inject(header);
64
+
65
+ var title = this.title = new Element('div.title').inject(header);
66
+ this.titleText = new Element('div.titleText').inject(title);
67
+
68
+ // Build the body of the picker
69
+ var body = this.body = new Element('div.body').inject(picker);
70
+
71
+ // oldContents and newContents are used to slide from the old content to a new one.
72
+ var slider = this.slider = new Element('div.slider', {
73
+ styles: {
74
+ position: 'absolute',
75
+ top: 0,
76
+ left: 0
77
+ }
78
+ }).set('tween', {
79
+ duration: options.animationDuration,
80
+ transition: Fx.Transitions.Quad.easeInOut
81
+ }).inject(body);
82
+
83
+ this.oldContents = new Element('div', {
84
+ styles: {
85
+ position: 'absolute',
86
+ top: 0
87
+ }
88
+ }).inject(slider);
89
+
90
+ this.newContents = new Element('div', {
91
+ styles: {
92
+ position: 'absolute',
93
+ top: 0,
94
+ left: 0
95
+ }
96
+ }).inject(slider);
97
+
98
+ // IFrameShim for select fields in IE
99
+ var shim = this.shim = window['IframeShim'] ? new IframeShim(picker) : null;
100
+
101
+ // Dragging
102
+ if (options.draggable && typeOf(picker.makeDraggable) == 'function'){
103
+ this.dragger = picker.makeDraggable(shim ? {
104
+ onDrag: shim.position.bind(shim)
105
+ } : null);
106
+ picker.setStyle('cursor', 'move');
107
+ }
108
+
109
+ this.addEvent('open', function(){
110
+ picker.setStyle('display', 'block');
111
+ if (shim) shim.show();
112
+ }, true);
113
+
114
+ this.addEvent('hide', function(){
115
+ picker.setStyle('display', 'none');
116
+ if (shim) shim.hide();
117
+ }, true);
118
+
119
+ },
120
+
121
+ open: function(noFx){
122
+ if (this.opened == true) return this;
123
+ this.opened = true;
124
+ this.fireEvent('open');
125
+ if (this.options.useFadeInOut && !noFx){
126
+ this.picker.fade('in').get('tween').chain(function(){
127
+ this.fireEvent('show');
128
+ }.bind(this));
129
+ } else {
130
+ this.picker.setStyle('opacity', 1);
131
+ this.fireEvent('show');
132
+ }
133
+ return this;
134
+ },
135
+
136
+ show: function(){
137
+ return this.open(true);
138
+ },
139
+
140
+ close: function(noFx){
141
+ if (this.opened == false) return this;
142
+ this.opened = false;
143
+ this.fireEvent('close');
144
+ if (this.options.useFadeInOut && !noFx){
145
+ this.picker.fade('out').get('tween').chain(function(){
146
+ this.fireEvent('hide');
147
+ }.bind(this));
148
+ } else {
149
+ this.picker.setStyle('opacity', 0);
150
+ this.fireEvent('hide');
151
+ }
152
+ return this;
153
+ },
154
+
155
+ hide: function(){
156
+ return this.close(true);
157
+ },
158
+
159
+ toggle: function(){
160
+ return this[this.opened == true ? 'close' : 'open']();
161
+ },
162
+
163
+ destroy: function(){
164
+ this.picker.destroy();
165
+ if (this.shim) this.shim.destroy();
166
+ },
167
+
168
+ position: function(x, y){
169
+ var offset = this.options.positionOffset,
170
+ scroll = document.getScroll(),
171
+ size = document.getSize(),
172
+ pickersize = this.picker.getSize();
173
+
174
+ if (typeOf(x) == 'element'){
175
+ var element = x,
176
+ where = y || this.options.pickerPosition;
177
+
178
+ var elementCoords = element.getCoordinates();
179
+
180
+ x = (where == 'left') ? elementCoords.left - pickersize.x
181
+ : (where == 'bottom' || where == 'top') ? elementCoords.left
182
+ : elementCoords.right
183
+ y = (where == 'bottom') ? elementCoords.bottom
184
+ : (where == 'top') ? elementCoords.top - pickersize.y
185
+ : elementCoords.top;
186
+ }
187
+
188
+ x += offset.x * ((where && where == 'left') ? -1 : 1);
189
+ y += offset.y * ((where && where == 'top') ? -1: 1);
190
+
191
+ if ((x + pickersize.x) > (size.x + scroll.x)) x = (size.x + scroll.x) - pickersize.x;
192
+ if ((y + pickersize.y) > (size.y + scroll.y)) y = (size.y + scroll.y) - pickersize.y;
193
+ if (x < 0) x = 0;
194
+ if (y < 0) y = 0;
195
+
196
+ this.picker.setStyles({
197
+ left: x,
198
+ top: y
199
+ });
200
+ if (this.shim) this.shim.position();
201
+ return this;
202
+ },
203
+
204
+ setBodySize: function(){
205
+ var bodysize = this.bodysize = this.body.getSize();
206
+ this.slider.setStyles({
207
+ width: 2 * bodysize.x,
208
+ height: bodysize.y
209
+ });
210
+ this.oldContents.setStyles({
211
+ left: bodysize.x,
212
+ width: bodysize.x,
213
+ height: bodysize.y
214
+ });
215
+ this.newContents.setStyles({
216
+ width: bodysize.x,
217
+ height: bodysize.y
218
+ });
219
+ },
220
+
221
+ setContent: function(){
222
+ var content = Array.from(arguments), fx;
223
+
224
+ if (['right', 'left', 'fade'].contains(content[1])) fx = content[1];
225
+ if (content.length == 1 || fx) content = content[0];
226
+
227
+ // swap contents so we can fill the newContents again and animate
228
+ var old = this.oldContents;
229
+ this.oldContents = this.newContents;
230
+ this.newContents = old;
231
+ this.newContents.empty();
232
+
233
+ var type = typeOf(content);
234
+ if (['string', 'number'].contains(type)) this.newContents.set('text', content);
235
+ else this.newContents.adopt(content);
236
+
237
+ this.setBodySize();
238
+
239
+ if (fx){
240
+ this.fx(fx);
241
+ } else {
242
+ this.slider.setStyle('left', 0);
243
+ this.oldContents.setStyles({left: 0, opacity: 0});
244
+ this.newContents.setStyles({left: 0, opacity: 1});
245
+ }
246
+ return this;
247
+ },
248
+
249
+ fx: function(fx){
250
+ var oldContents = this.oldContents,
251
+ newContents = this.newContents,
252
+ slider = this.slider,
253
+ bodysize = this.bodysize;
254
+ if (fx == 'right'){
255
+ oldContents.setStyles({left: 0, opacity: 1});
256
+ newContents.setStyles({left: bodysize.x, opacity: 1});
257
+ slider.setStyle('left', 0).tween('left', 0, -bodysize.x);
258
+ } else if (fx == 'left'){
259
+ oldContents.setStyles({left: bodysize.x, opacity: 1});
260
+ newContents.setStyles({left: 0, opacity: 1});
261
+ slider.setStyle('left', -bodysize.x).tween('left', -bodysize.x, 0);
262
+ } else if (fx == 'fade'){
263
+ slider.setStyle('left', 0);
264
+ oldContents.setStyle('left', 0).set('tween', {
265
+ duration: this.options.animationDuration / 2
266
+ }).tween('opacity', 1, 0).get('tween').chain(function(){
267
+ oldContents.setStyle('left', bodysize.x);
268
+ });
269
+ newContents.setStyles({opacity: 0, left: 0}).set('tween', {
270
+ duration: this.options.animationDuration
271
+ }).tween('opacity', 0, 1);
272
+ }
273
+ },
274
+
275
+ toElement: function(){
276
+ return this.picker;
277
+ },
278
+
279
+ setTitle: function(text){
280
+ this.titleText.set('text', text);
281
+ return this;
282
+ },
283
+
284
+ setTitleEvent: function(fn){
285
+ this.titleText.removeEvents('click');
286
+ if (fn) this.titleText.addEvent('click', fn);
287
+ this.titleText.setStyle('cursor', fn ? 'pointer' : '');
288
+ return this;
289
+ }
290
+
291
+ });
292
+
293
+ /*
294
+ ---
295
+ name: Picker.Attach
296
+ description: Adds attach and detach methods to the Picker, to attach it to element events
297
+ authors: Arian Stolwijk
298
+ requires: [Picker, Core/Element.Event]
299
+ provides: Picker.Attach
300
+ ...
301
+ */
302
+
303
+
304
+ Picker.Attach = new Class({
305
+
306
+ Extends: Picker,
307
+
308
+ options: {/*
309
+ onAttachedEvent: function(event){},
310
+
311
+ toggleElements: null, // deprecated
312
+ toggle: null, // When set it deactivate toggling by clicking on the input */
313
+ showOnInit: false
314
+ },
315
+
316
+ initialize: function(attachTo, options){
317
+ this.parent(options);
318
+
319
+ this.attachedEvents = [];
320
+ this.attachedElements = [];
321
+ this.toggles = [];
322
+ this.inputs = [];
323
+
324
+ var documentEvent = function(event){
325
+ if (this.attachedElements.contains(event.target)) return null;
326
+ this.close();
327
+ }.bind(this);
328
+ var document = this.picker.getDocument().addEvent('click', documentEvent);
329
+
330
+ var preventPickerClick = function(event){
331
+ event.stopPropagation();
332
+ return false;
333
+ };
334
+ this.picker.addEvent('click', preventPickerClick);
335
+
336
+ // Support for deprecated toggleElements
337
+ if (this.options.toggleElements) this.options.toggle = document.getElements(this.options.toggleElements);
338
+
339
+ this.attach(attachTo, this.options.toggle);
340
+ },
341
+
342
+ attach: function(attachTo, toggle){
343
+ if (typeOf(attachTo) == 'string') attachTo = document.id(attachTo);
344
+ if (typeOf(toggle) == 'string') toggle = document.id(toggle);
345
+
346
+ var elements = Array.from(attachTo),
347
+ toggles = Array.from(toggle),
348
+ allElements = [].append(elements).combine(toggles),
349
+ self = this;
350
+
351
+ var eventWrapper = function(fn, element){
352
+ return function(event){
353
+ if (event.type == 'keydown' && ['tab', 'esc'].contains(event.key) == false) return false;
354
+ if (event.target.get('tag') == 'a') event.stop();
355
+ self.fireEvent('attachedEvent', [event, element]);
356
+ self.position(element);
357
+ fn();
358
+ };
359
+ };
360
+
361
+ allElements.each(function(element, i){
362
+
363
+ // The events are already attached!
364
+ if (self.attachedElements.contains(element)) return null;
365
+
366
+ var tag = element.get('tag');
367
+
368
+ var events = {};
369
+ if (tag == 'input'){
370
+ // Fix in order to use togglers only
371
+ if (!toggles.length){
372
+ events = {
373
+ focus: eventWrapper(self.open.bind(self), element),
374
+ keydown: eventWrapper(self.close.bind(self), element),
375
+ click: eventWrapper(self.open.bind(self), element)
376
+ };
377
+ }
378
+ self.inputs.push(element);
379
+ } else {
380
+ if (toggles.contains(element)){
381
+ self.toggles.push(element);
382
+ events.click = eventWrapper(self.toggle.bind(self), element);
383
+ } else {
384
+ events.click = eventWrapper(self.open.bind(self), element);
385
+ }
386
+ }
387
+ element.addEvents(events);
388
+ self.attachedElements.push(element);
389
+ self.attachedEvents.push(events);
390
+ });
391
+ return this;
392
+ },
393
+
394
+ detach: function(attachTo, toggle){
395
+ if (typeOf(attachTo) == 'string') attachTo = document.id(attachTo);
396
+ if (typeOf(toggle) == 'string') toggle = document.id(toggle);
397
+
398
+ var elements = Array.from(attachTo),
399
+ toggles = Array.from(toggle),
400
+ allElements = [].append(elements).combine(toggles),
401
+ self = this;
402
+
403
+ if (!allElements.length) allElements = self.attachedElements;
404
+
405
+ allElements.each(function(element){
406
+ var i = self.attachedElements.indexOf(element);
407
+ if (i < 0) return null;
408
+
409
+ var events = self.attachedEvents[i];
410
+ element.removeEvents(events);
411
+ delete self.attachedEvents[i];
412
+ delete self.attachedElements[i];
413
+
414
+ var toggleIndex = self.toggles.indexOf(element);
415
+ if (toggleIndex != -1) delete self.toggles[toggleIndex];
416
+
417
+ var inputIndex = self.inputs.indexOf(element);
418
+ if (toggleIndex != -1) delete self.inputs[inputIndex];
419
+
420
+ });
421
+ return this;
422
+ },
423
+
424
+ destroy: function(){
425
+ this.detach();
426
+ this.parent();
427
+ }
428
+
429
+ });
430
+
431
+ /*
432
+ ---
433
+ name: Locale.en-US.DatePicker
434
+ description: English Language File for DatePicker
435
+ authors: Arian Stolwijk
436
+ requires: [More/Locale]
437
+ provides: Locale.en-US.DatePicker
438
+ ...
439
+ */
440
+
441
+
442
+ Locale.define('en-US', 'DatePicker', {
443
+ select_a_time: 'Select a time',
444
+ use_mouse_wheel: 'Use the mouse wheel to quickly change value',
445
+ time_confirm_button: 'OK'
446
+ });
447
+
1
448
  /*
2
449
  ---
3
450
  name: Picker.Date
@@ -0,0 +1 @@
1
+ /*yepnope1.0.1|WTFPL*/(function(a,b,c){function H(){var a=z;a.loader={load:G,i:0};return a}function G(a,b,c){var e=b=="c"?r:q;i=0,b=b||"j",u(a)?F(e,a,b,this.i++,d,c):(h.splice(this.i++,0,a),h.length==1&&E());return this}function F(a,c,d,g,j,l){function q(){!o&&A(n.readyState)&&(p.r=o=1,!i&&B(),n.onload=n.onreadystatechange=null,e(function(){m.removeChild(n)},0))}var n=b.createElement(a),o=0,p={t:d,s:c,e:l};n.src=n.data=c,!k&&(n.style.display="none"),n.width=n.height="0",a!="object"&&(n.type=d),n.onload=n.onreadystatechange=q,a=="img"?n.onerror=q:a=="script"&&(n.onerror=function(){p.e=p.r=1,E()}),h.splice(g,0,p),m.insertBefore(n,k?null:f),e(function(){o||(m.removeChild(n),p.r=p.e=o=1,B())},z.errorTimeout)}function E(){var a=h.shift();i=1,a?a.t?e(function(){a.t=="c"?D(a):C(a)},0):(a(),B()):i=0}function D(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css",!a.e&&(o||j)?function g(a){e(function(){if(!d)try{a.sheet.cssRules.length?(d=1,B()):g(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,e(function(){B()},0)):g(a)}},0)}(c):(c.onload=function(){d||(d=1,e(function(){B()},0))},a.e&&c.onload()),e(function(){d||(d=1,B())},z.errorTimeout),!a.e&&f.parentNode.insertBefore(c,f)}function C(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&A(c.readyState)&&(d=1,B(),c.onload=c.onreadystatechange=null)},e(function(){d||(d=1,B())},z.errorTimeout),a.e?c.onload():f.parentNode.insertBefore(c,f)}function B(){var a=1,b=-1;while(h.length- ++b)if(h[b].s&&!(a=h[b].r))break;a&&E()}function A(a){return!a||a=="loaded"||a=="complete"}var d=b.documentElement,e=a.setTimeout,f=b.getElementsByTagName("script")[0],g=({}).toString,h=[],i=0,j="MozAppearance"in d.style,k=j&&!!b.createRange().compareNode,l=j&&!k,m=k?d:f.parentNode,n=a.opera&&g.call(a.opera)=="[object Opera]",o="webkitAppearance"in d.style,p=o&&"async"in b.createElement("script"),q=j?"object":n||p?"img":"script",r=o?"img":q,s=Array.isArray||function(a){return g.call(a)=="[object Array]"},t=function(a){return typeof a=="object"},u=function(a){return typeof a=="string"},v=function(a){return g.call(a)=="[object Function]"},w=[],x={},y,z;z=function(a){function h(a,b){function i(a){if(u(a))g(a,f,b,0,c);else if(t(a))for(h in a)a.hasOwnProperty(h)&&g(a[h],f,b,h,c)}var c=!!a.test,d=c?a.yep:a.nope,e=a.load||a.both,f=a.callback,h;i(d),i(e),a.complete&&b.load(a.complete)}function g(a,b,d,e,g){var h=f(a),i=h.autoCallback;if(!h.bypass){b&&(b=v(b)?b:b[a]||b[e]||b[a.split("/").pop().split("?")[0]]);if(h.instead)return h.instead(a,b,d,e,g);d.load(h.url,h.forceCSS||!h.forceJS&&/css$/.test(h.url)?"c":c,h.noexec),(v(b)||v(i))&&d.load(function(){H(),b&&b(h.origUrl,g,e),i&&i(h.origUrl,g,e)})}}function f(a){var b=a.split("!"),c=w.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=x[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=w[h](f);return f}var b,d,e=this.yepnope.loader;if(u(a))g(a,0,e,0);else if(s(a))for(b=0;b<a.length;b++)d=a[b],u(d)?g(d,0,e,0):s(d)?z(d):t(d)&&h(d,e);else t(a)&&h(a,e)},z.addPrefix=function(a,b){x[a]=b},z.addFilter=function(a){w.push(a)},z.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",y=function(){b.removeEventListener("DOMContentLoaded",y,0),b.readyState="complete"},0)),a.yepnope=H()})(this,this.document)