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,137 +0,0 @@
1
- /*
2
- ---
3
- name: Picker.Attach
4
- description: Adds attach and detach methods to the Picker, to attach it to element events
5
- authors: Arian Stolwijk
6
- requires: [Picker, Core/Element.Event]
7
- provides: Picker.Attach
8
- ...
9
- */
10
-
11
-
12
- Picker.Attach = new Class({
13
-
14
- Extends: Picker,
15
-
16
- options: {/*
17
- onAttachedEvent: function(event){},
18
-
19
- toggleElements: null, // deprecated
20
- toggle: null, // When set it deactivate toggling by clicking on the input */
21
- showOnInit: false
22
- },
23
-
24
- initialize: function(attachTo, options){
25
- this.parent(options);
26
-
27
- this.attachedEvents = [];
28
- this.attachedElements = [];
29
- this.toggles = [];
30
- this.inputs = [];
31
-
32
- var documentEvent = function(event){
33
- if (this.attachedElements.contains(event.target)) return null;
34
- this.close();
35
- }.bind(this);
36
- var document = this.picker.getDocument().addEvent('click', documentEvent);
37
-
38
- var preventPickerClick = function(event){
39
- event.stopPropagation();
40
- return false;
41
- };
42
- this.picker.addEvent('click', preventPickerClick);
43
-
44
- // Support for deprecated toggleElements
45
- if (this.options.toggleElements) this.options.toggle = document.getElements(this.options.toggleElements);
46
-
47
- this.attach(attachTo, this.options.toggle);
48
- },
49
-
50
- attach: function(attachTo, toggle){
51
- if (typeOf(attachTo) == 'string') attachTo = document.id(attachTo);
52
- if (typeOf(toggle) == 'string') toggle = document.id(toggle);
53
-
54
- var elements = Array.from(attachTo),
55
- toggles = Array.from(toggle),
56
- allElements = [].append(elements).combine(toggles),
57
- self = this;
58
-
59
- var eventWrapper = function(fn, element){
60
- return function(event){
61
- if (event.type == 'keydown' && ['tab', 'esc'].contains(event.key) == false) return false;
62
- if (event.target.get('tag') == 'a') event.stop();
63
- self.fireEvent('attachedEvent', [event, element]);
64
- self.position(element);
65
- fn();
66
- };
67
- };
68
-
69
- allElements.each(function(element, i){
70
-
71
- // The events are already attached!
72
- if (self.attachedElements.contains(element)) return null;
73
-
74
- var tag = element.get('tag');
75
-
76
- var events = {};
77
- if (tag == 'input'){
78
- // Fix in order to use togglers only
79
- if (!toggles.length){
80
- events = {
81
- focus: eventWrapper(self.open.bind(self), element),
82
- keydown: eventWrapper(self.close.bind(self), element),
83
- click: eventWrapper(self.open.bind(self), element)
84
- };
85
- }
86
- self.inputs.push(element);
87
- } else {
88
- if (toggles.contains(element)){
89
- self.toggles.push(element);
90
- events.click = eventWrapper(self.toggle.bind(self), element);
91
- } else {
92
- events.click = eventWrapper(self.open.bind(self), element);
93
- }
94
- }
95
- element.addEvents(events);
96
- self.attachedElements.push(element);
97
- self.attachedEvents.push(events);
98
- });
99
- return this;
100
- },
101
-
102
- detach: function(attachTo, toggle){
103
- if (typeOf(attachTo) == 'string') attachTo = document.id(attachTo);
104
- if (typeOf(toggle) == 'string') toggle = document.id(toggle);
105
-
106
- var elements = Array.from(attachTo),
107
- toggles = Array.from(toggle),
108
- allElements = [].append(elements).combine(toggles),
109
- self = this;
110
-
111
- if (!allElements.length) allElements = self.attachedElements;
112
-
113
- allElements.each(function(element){
114
- var i = self.attachedElements.indexOf(element);
115
- if (i < 0) return null;
116
-
117
- var events = self.attachedEvents[i];
118
- element.removeEvents(events);
119
- delete self.attachedEvents[i];
120
- delete self.attachedElements[i];
121
-
122
- var toggleIndex = self.toggles.indexOf(element);
123
- if (toggleIndex != -1) delete self.toggles[toggleIndex];
124
-
125
- var inputIndex = self.inputs.indexOf(element);
126
- if (toggleIndex != -1) delete self.inputs[inputIndex];
127
-
128
- });
129
- return this;
130
- },
131
-
132
- destroy: function(){
133
- this.detach();
134
- this.parent();
135
- }
136
-
137
- });
@@ -1,291 +0,0 @@
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
- });
@@ -1,325 +0,0 @@
1
- MooTools-DatePicker
2
- ===================
3
-
4
- MooTools DatePicker is a nice modular and themable DatePicker. It has many features and options, such as
5
- year, month, day or timepicker only modes, min and max dates, Localization and a lot more.
6
-
7
- This Plugin makes use of MooTools' Locale and Date plugins in MooTools More, to provide a localized
8
- datepicker, as well as easy formatting and parsing Dates.
9
-
10
- This DatePicker is a fork of the original [MonkeyPhysics DatePicker](http://www.monkeyphysics.com/mootools/script/2/datepicker),
11
- and has improved a lot since then. Though it should be (almost) backward compatible.
12
-
13
- ![Screenshot](https://github.com/arian/mootools-datepicker/raw/master/screenshot.png)
14
-
15
- As of version 1.60 the datepicker will only work with MooTools 1.3.
16
-
17
- How to use
18
- ----------
19
-
20
- Below you will find a description and some docs how you can use the datepicker.
21
- If you find any weird things, please create a ticket at github or fork and fix it!
22
-
23
- The DatePicker consists out of three layers, a Picker class, which can be used to create any form of Picker, a Picker.Attach class,
24
- which handles stuff like attaching the Picker to a input or anchor element. Finally there is the DatePicker class, which you'll probably
25
- use. Every option of the Picker or Picker.Attach classes can be used in the DatePicker class.
26
-
27
- Basic Example
28
- -------------
29
-
30
- First you need to include the following html tags:
31
-
32
- #HTML
33
- <script src="../Source/Locale.en-US.DatePicker.js" type="text/javascript"></script>
34
- <script src="../Source/Picker.js" type="text/javascript"></script>
35
- <script src="../Source/Picker.Attach.js" type="text/javascript"></script>
36
- <script src="../Source/Picker.Date.js" type="text/javascript"></script>
37
-
38
- <link href="../Source/datepicker_dashboard/datepicker_dashboard.css" rel="stylesheet">
39
-
40
- Then you can simply use, for example:
41
-
42
- #JS
43
- new Picker.Date($$('input'), {
44
- timePicker: true,
45
- positionOffset: {x: 5, y: 0},
46
- pickerClass: 'datepicker_dashboard',
47
- useFadeInOut: !Browser.ie
48
- });
49
-
50
-
51
- ### Theming:
52
-
53
- Theming is done with CSS files, there are four themes available, which you can find in the Source folder.
54
-
55
- Just include the CSS file and set the `pickerClass` option.
56
-
57
-
58
- ### Localization
59
-
60
- The DatePicker uses the MooTools More Date Class, which already includes many localized strings.
61
- For some specific strings DatePicker has its own localizations, which you can find in the Locale.__-__.DatePicker.js files.
62
- Just include the file in your page with a script tag to use the translations.
63
-
64
- Currently the following languages are supported
65
-
66
- - en-US
67
- - de-DE
68
- - fr-FR
69
- - it-IT
70
- - nl-NL
71
- - cs-CZ
72
- - ru-RU
73
-
74
- You can set the current language with:
75
-
76
- #JS
77
- Locale.use('nl-NL');
78
-
79
-
80
- Class: DatePicker
81
- -----------------
82
-
83
- ### Syntax
84
-
85
- #JS
86
- var dp = new DatePicker([element, options]);
87
-
88
- ### Arguments
89
-
90
- 1. element: (*element*, *string*, *array*) The element(s) to attach the datepicker to
91
- 2. options: (*object*, optional) The options object
92
-
93
- ### Options:
94
-
95
- All the options of the Picker and Picker.Attach classes, and:
96
-
97
- - minDate: (*Date instance*, *string*, defaults to `null`) Minimum date allowed to pick. Blocks anything before.
98
- - maxDate: (*Date instance*, *string*, defaults to `null`) Maximum date allowed to pick. Blocks anything after.
99
- - availableDates: (*object*, defaults to `null`) When only a few dates should be selectable. An object like `{2011: {1: [19, 29, 31], 3: [5, 19, 24]}}` with all the dates (year -> months -> days).
100
- - format: (*string*, defaults to the default localized format) The format to output into the input field. Uses [Date.format](http://mootools.net/docs/more/Types/Date#Date:format)
101
- - timePicker: (*boolean*, defaults to 1 `false`) Enable/disable timepicker functionality. Hours/Minutes values can be changed using the scrollwheel.
102
- - timeWheelStep: (*number*, defaults to `1`) The number of minutes the minutes field will change in the timepicker when using the scrollwheel, for example 5, 10, 15. The value will always be k * timeWheelStep.
103
- - yearPicker: (*boolean*, defaults to `true`) Enable/disable yearpicker functionality. Makes it much easier to change years.
104
- - yearPerPage: (*number*, defaults to `20`) Amount of years to show in the year-picking view. Be aware that this may affect your layout.
105
- - startView: (*string*, defaults to `days`) The view that will be showed when the picker opens. The options are `time`, `days`, `months` and `years`
106
- - pickOnly: (*string*, defaults to `false`) If you just want to pick a year, month, day or time. The options are `time`, `days`, `months` and `years`
107
- - canAlwaysGoUp: (*array*, defaults to `['months', 'days']`) The views where you can click the title to go up. The options are `time`, `days`, `months` and `years`
108
- - months_abbr: (*array*) An array with the month name abbreviations. If nothing is set, it will automatically use MooTools Locale to get the abbreviations
109
- - days_abbr: (*array*) An array with the day name abbreviations. If nothing is set, it will automatically use MooTools Locale to get the abbreviations
110
- - years_title: (*function*, defaults to a function which returns `year + '-' + (year + options.yearsPerPage - 1)`) A function that returns the title for the yearpicker with as arguments the date object and the options object.
111
- - months_title: (*function*, defaults to a function which returns `date.format('%b %Y')`) A function that returns the title for the monthpicker with as arguments the date object and the options object.
112
- - days_title: (*function*, defaults to a function which returns `date.format('%b %Y')`) A function that returns the title for the daypicker with as arguments the date object and the options object.
113
- - time_title: (*function*, defaults to a function which returns `(options.pickOnly == 'time') ? Locale.get('DatePicker.select_a_time') : date.format('%d %B, %Y')`) A function that returns the title for the timepicker with as arguments the date object and the options object.
114
-
115
-
116
-
117
- ### Events:
118
-
119
- - onSelect: Will fire when the user has selected a date
120
-
121
- #### signature
122
-
123
- #JS
124
- onSelect(date)
125
-
126
- #### arguments
127
-
128
- 1. date - A Date object. You could use [Date.format](http://mootools.net/docs/more/Types/Date#Date:format) to format it into a string. For example to set it into a hidden field which will be sent to the server.
129
-
130
-
131
- ### Examples
132
-
133
- #JS
134
- new DatePicker('inputField', {
135
- timePicker: true,
136
- pickerClass: 'datepicker_jqui',
137
- onSelect: function(date){
138
- myHiddenField.set('value', date.format('%s');
139
- }
140
- });
141
-
142
-
143
- Class: Picker.Attach
144
- --------------------
145
-
146
- Picker.Attach handles all the links from elements to the Picker. It handles the onfocus events of input elements etc.
147
- The Class itself is not very useful on its own, but it is useful to extend this Class.
148
- This class adds a outerclick as well to close the Picker if you click outside the picker.
149
-
150
- #### Syntax:
151
-
152
- #JS
153
- new Picker.Attach(attachTo, options);
154
-
155
- #### Options:
156
-
157
- - toggle: (*element*, *string*, *array*) A collection of elements which will toggle the picker when such a link is clicked.
158
-
159
-
160
- ### Picker.Attach Method: attach
161
-
162
- This will attach links and input elements to the picker
163
-
164
- #### Syntax
165
-
166
- #JS
167
- myPicker.attach(attachTo);
168
-
169
- #### Arguments
170
-
171
- 1. attachTo: (*element*, *string*, *array*) The elements or element to attach to the Picker. Can be a input element for onfocus events or other elements for click events.
172
-
173
-
174
- ### Picker.Attach Method: detach
175
-
176
- This will detach links and input elements from the picker
177
-
178
- #### Syntax
179
-
180
- #JS
181
- myPicker.detach(detach);
182
-
183
- #### Arguments
184
-
185
- 1. detach: (*element*, *string*, *array*) The elements or element to detach from the Picker. Can be a input element for onfocus events or other elements for click events.
186
-
187
-
188
- Class: Picker
189
- -------------
190
-
191
- This is a generic Picker Class, which is used for the basic things, like positioning, Fx, open, close, stuff like that.
192
-
193
- #### Syntax:
194
-
195
- #JS
196
- new Picker(options);
197
-
198
- #### Options:
199
-
200
- - pickerClass: (*string*, defaults to `datepicker`) CSS class for the main datepicker container element. You can use multiple classes by separating them by a space, e.g. `class1 class2 class3`
201
- - inject: (*element*, defaults to `document.body`) This is where the Picker element will be injected to.
202
- - anitmationDuration: (*number*, defaults to `400`) Duration of the slide/fade animations in milliseconds.
203
- - useFadeInOut: (*boolean*, defaults to `true`) Whether to fade-in/out the datepicker popup. You might want to set this to `false` in IE.
204
- - positionOffset: (*object*, defaults to `{x: 0, y: 0}`) Allows you to tweak the position at which the datepicker appears, relative to the input element. Formatted as an object with x and y properties. Values can be negative.
205
- - pickerPosition: (*string*, defaults to `bottom`) If the picker is positioned relative to an element, you can choose to position it top, bottom, left or right.
206
- - draggable: (*boolean*, defaults to `true`) Will make the picker draggable, if Drag from MooTools More is included.
207
-
208
- #### Events:
209
-
210
- - open - triggered when the Picker will open (before the fx)
211
- - close - triggered after the Picker is will get closed (before the fx)
212
- - show - triggered when the Picker is shown
213
- - hide - triggered when the Picker is hidden
214
-
215
-
216
-
217
- ### Picker Method: show
218
-
219
- A method to show the Picker manually, with a Fx.
220
-
221
- #### Syntax
222
-
223
- #JS
224
- dp.show()
225
-
226
- ### Picker Method: close
227
-
228
- Closes the Picker with a Fx.
229
-
230
- #### Syntax
231
-
232
- #JS
233
- dp.close();
234
-
235
-
236
- ### Picker Method: toggle
237
-
238
- Toggles the Picker with a Fx.
239
-
240
- #### Syntax
241
-
242
- #JS
243
- picker.toggle();
244
-
245
- ### Picker Method: show
246
-
247
- Opens the Picker directly.
248
-
249
- #### Syntax
250
-
251
- #JS
252
- dp.show();
253
-
254
-
255
- ### Picker Method: hide
256
-
257
- Hides the Picker directly.
258
-
259
- #### Syntax
260
-
261
- #JS
262
- dp.hide();
263
-
264
-
265
- ### Picker Method: destroy
266
-
267
- Destroys the Picker
268
-
269
- #JS
270
- picker.destroy();
271
-
272
-
273
- ### Picker Method: position
274
-
275
- Positions the Picker.
276
-
277
- #### Syntax:
278
-
279
- #JS
280
- picker.position(x, y);
281
- // or
282
- picker.position(myElement, where);
283
-
284
- #### Arguments
285
-
286
- 1. x: (*number*) Number of pixels from the left
287
- 2. y: (*number*) Number of pixels from the top
288
-
289
- Or
290
-
291
- 1. myElement - (*element*) A element the Picker should be positioned relative to.
292
- 2. where - (*string*, optional) Position the Picker `left` or `right` to the element.
293
-
294
-
295
- ### Picker Method: setContent
296
-
297
- Set the content of the Picker, either elements or text.
298
-
299
- #### Syntax:
300
-
301
- #JS
302
- picker.setContent(element, fx);
303
-
304
- #### Arguments:
305
-
306
- 1. element: (*element*, *string*) Set the content of the Picker with this value
307
- 2. fx: (*string*, optional) Set the content of the picker, and apply it with this Fx. Options: 'fade', 'right', 'left'
308
-
309
-
310
- ### Picker Method: setTitle
311
-
312
- Sets the Picker title text.
313
-
314
- #JS
315
- picker.setTitle(text);
316
-
317
- #### Arguments:
318
-
319
- 1. text: (*string*) The text which will be set into the title.
320
-
321
-
322
- License
323
- -------
324
-
325
- - [MIT License](http://www.opensource.org/licenses/mit-license.php)