zen 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. data/.gems +34 -0
  2. data/.travis.yml +7 -0
  3. data/AUTHORS +5 -0
  4. data/CHANGELOG +14 -0
  5. data/{license.txt → LICENSE} +0 -0
  6. data/MANIFEST +67 -51
  7. data/README.md +18 -25
  8. data/Rakefile +2 -3
  9. data/bin/zen +2 -2
  10. data/lib/zen.rb +93 -57
  11. data/lib/zen/asset.rb +7 -8
  12. data/lib/zen/bin/app.rb +0 -2
  13. data/lib/zen/controller/admin_controller.rb +4 -9
  14. data/lib/zen/controller/base_controller.rb +0 -25
  15. data/lib/zen/controller/main_controller.rb +5 -5
  16. data/lib/zen/controller/preview.rb +50 -0
  17. data/lib/zen/helper/common.rb +4 -68
  18. data/lib/zen/helper/message.rb +82 -0
  19. data/lib/zen/helper/theme.rb +2 -2
  20. data/lib/zen/language.rb +68 -38
  21. data/lib/zen/language/en/zen_general.yml +1 -4
  22. data/lib/zen/language/nl/zen_general.yml +28 -0
  23. data/lib/zen/language/nl/zen_models.yml +13 -0
  24. data/lib/zen/layout/admin.xhtml +1 -1
  25. data/lib/zen/layout/login.xhtml +1 -1
  26. data/lib/zen/model/settings.rb +2 -0
  27. data/lib/zen/package.rb +29 -25
  28. data/lib/zen/package/all.rb +1 -1
  29. data/lib/zen/package/categories/lib/categories/controller/categories.rb +51 -63
  30. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -52
  31. data/lib/zen/package/categories/lib/categories/language/en/categories.yml +2 -2
  32. data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +39 -0
  33. data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +33 -0
  34. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +2 -2
  35. data/lib/zen/package/comments/lib/comments.rb +31 -2
  36. data/lib/zen/package/comments/lib/comments/controller/comments.rb +42 -57
  37. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +36 -51
  38. data/lib/zen/package/comments/lib/comments/language/en/comments.yml +7 -3
  39. data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +48 -0
  40. data/lib/zen/package/comments/lib/comments/model/comment.rb +45 -4
  41. data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +152 -0
  42. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +5 -6
  43. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +2 -2
  44. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +43 -52
  45. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +68 -67
  46. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +1 -1
  47. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +32 -0
  48. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +52 -0
  49. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +3 -3
  50. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +4 -7
  51. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +3 -3
  52. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +37 -44
  53. data/lib/zen/package/menus/lib/menus/controller/menus.rb +33 -43
  54. data/lib/zen/package/menus/lib/menus/helper/menu_item.rb +5 -10
  55. data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +41 -0
  56. data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +39 -0
  57. data/lib/zen/package/menus/lib/menus/model/menu.rb +3 -3
  58. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +3 -3
  59. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +5 -6
  60. data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +1 -1
  61. data/lib/zen/package/sections/lib/sections.rb +20 -0
  62. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +85 -79
  63. data/lib/zen/package/sections/lib/sections/controller/sections.rb +58 -66
  64. data/lib/zen/package/sections/lib/sections/language/en/sections.yml +0 -1
  65. data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +43 -0
  66. data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +47 -0
  67. data/lib/zen/package/sections/lib/sections/model/section.rb +11 -15
  68. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +9 -5
  69. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +7 -8
  70. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +3 -4
  71. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +0 -4
  72. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +8 -2
  73. data/lib/zen/package/sections/migrations/1306772479_remove_unique_slug.rb +28 -0
  74. data/lib/zen/package/settings/lib/settings.rb +21 -34
  75. data/lib/zen/package/settings/lib/settings/controller/settings.rb +29 -22
  76. data/lib/zen/package/settings/lib/settings/language/en/settings.yml +7 -5
  77. data/lib/zen/package/settings/lib/settings/language/nl/settings.yml +39 -0
  78. data/lib/zen/package/settings/lib/settings/model/setting.rb +3 -5
  79. data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +3 -4
  80. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +3 -5
  81. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +11 -4
  82. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +5 -5
  83. data/lib/zen/package/settings/migrations/1299538742_add_language_key.rb +8 -8
  84. data/lib/zen/package/settings/migrations/1303196915_settings_plugin.rb +2 -5
  85. data/lib/zen/package/users/lib/users/controller/access_rules.rb +54 -61
  86. data/lib/zen/package/users/lib/users/controller/user_groups.rb +49 -57
  87. data/lib/zen/package/users/lib/users/controller/users.rb +58 -73
  88. data/lib/zen/package/users/lib/users/language/en/users.yml +6 -0
  89. data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +37 -0
  90. data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +31 -0
  91. data/lib/zen/package/users/lib/users/language/nl/users.yml +56 -0
  92. data/lib/zen/package/users/lib/users/model/user.rb +16 -1
  93. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +27 -2
  94. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +15 -3
  95. data/lib/zen/package/users/migrations/1304939855_user_settings.rb +15 -0
  96. data/lib/zen/plugin.rb +7 -9
  97. data/lib/zen/public/admin/css/{buttons.css → zen/buttons.css} +11 -7
  98. data/lib/zen/public/admin/css/{datepicker.css → zen/datepicker.css} +0 -0
  99. data/lib/zen/public/admin/css/{editor.css → zen/editor.css} +10 -5
  100. data/lib/zen/public/admin/css/{forms.css → zen/forms.css} +1 -1
  101. data/lib/zen/public/admin/css/{general.css → zen/general.css} +7 -7
  102. data/lib/zen/public/admin/css/{grid.css → zen/grid.css} +0 -0
  103. data/lib/zen/public/admin/css/{layout.css → zen/layout.css} +4 -5
  104. data/lib/zen/public/admin/css/zen/messages.css +61 -0
  105. data/lib/zen/public/admin/css/{notifications.css → zen/notifications.css} +4 -4
  106. data/lib/zen/public/admin/css/{reset.css → zen/reset.css} +0 -0
  107. data/lib/zen/public/admin/css/{tables.css → zen/tables.css} +3 -3
  108. data/lib/zen/public/admin/css/{tabs.css → zen/tabs.css} +5 -5
  109. data/lib/zen/public/admin/css/zen/window.css +79 -0
  110. data/lib/zen/public/admin/images/{icons → zen/icons}/accept.png +0 -0
  111. data/lib/zen/public/admin/images/{icons → zen/icons}/add.png +0 -0
  112. data/lib/zen/public/admin/images/{icons → zen/icons}/back.png +0 -0
  113. data/lib/zen/public/admin/images/{icons → zen/icons}/bold.png +0 -0
  114. data/lib/zen/public/admin/images/zen/icons/close.png +0 -0
  115. data/lib/zen/public/admin/images/{icons → zen/icons}/delete.png +0 -0
  116. data/lib/zen/public/admin/images/{icons → zen/icons}/edit.png +0 -0
  117. data/lib/zen/public/admin/images/{icons → zen/icons}/error.png +0 -0
  118. data/lib/zen/public/admin/images/{icons → zen/icons}/help.png +0 -0
  119. data/lib/zen/public/admin/images/{icons → zen/icons}/info.png +0 -0
  120. data/lib/zen/public/admin/images/{icons → zen/icons}/italic.png +0 -0
  121. data/lib/zen/public/admin/images/{icons → zen/icons}/large/error.png +0 -0
  122. data/lib/zen/public/admin/images/{icons → zen/icons}/large/notice.png +0 -0
  123. data/lib/zen/public/admin/images/{icons → zen/icons}/large/success.png +0 -0
  124. data/lib/zen/public/admin/images/{icons → zen/icons}/link.png +0 -0
  125. data/lib/zen/public/admin/images/{icons → zen/icons}/logout.png +0 -0
  126. data/lib/zen/public/admin/images/{icons → zen/icons}/ol.png +0 -0
  127. data/lib/zen/public/admin/images/{icons → zen/icons}/pdf.png +0 -0
  128. data/lib/zen/public/admin/images/zen/icons/preview.png +0 -0
  129. data/lib/zen/public/admin/images/{icons → zen/icons}/ul.png +0 -0
  130. data/lib/zen/public/admin/images/{icons → zen/icons}/user.png +0 -0
  131. data/lib/zen/public/admin/images/{icons → zen/icons}/view.png +0 -0
  132. data/lib/zen/public/admin/js/zen/core.js +73 -0
  133. data/lib/zen/public/admin/js/zen/editor.js +527 -0
  134. data/lib/zen/public/admin/js/zen/editor/markdown.js +84 -0
  135. data/lib/zen/public/admin/js/zen/editor/textile.js +84 -0
  136. data/lib/zen/public/admin/js/zen/init.js +12 -66
  137. data/lib/zen/public/admin/js/zen/tabs.js +5 -0
  138. data/lib/zen/public/admin/js/zen/window.js +206 -0
  139. data/lib/zen/task/build.rake +23 -6
  140. data/lib/zen/task/clean.rake +6 -7
  141. data/lib/zen/task/db.rake +7 -9
  142. data/lib/zen/task/package.rake +6 -6
  143. data/lib/zen/task/test.rake +6 -0
  144. data/lib/zen/task/theme.rake +3 -3
  145. data/lib/zen/theme.rb +3 -4
  146. data/lib/zen/validation.rb +7 -9
  147. data/lib/zen/version.rb +3 -4
  148. data/lib/zen/view/bottom.xhtml +0 -5
  149. data/lib/zen/view/main.xhtml +2 -0
  150. data/proto/app/app.rb +6 -4
  151. data/proto/app/config/config.rb +1 -7
  152. data/proto/app/config/database.rb +47 -43
  153. data/proto/app/config/middlewares.rb +0 -40
  154. data/proto/app/start.rb +1 -6
  155. data/proto/app/{vendor → theme}/.gitkeep +0 -0
  156. data/proto/migration.rb +3 -3
  157. data/proto/package/lib/package.rb +0 -1
  158. data/proto/package/lib/package/controller/controllers.rb +7 -40
  159. data/proto/package/lib/package/model/model.rb +3 -3
  160. metadata +106 -79
  161. data/CHANGELOG.md +0 -27
  162. data/ROADMAP.md +0 -53
  163. data/lib/zen/database.rb +0 -112
  164. data/lib/zen/logger.rb +0 -56
  165. data/lib/zen/public/admin/css/modals.css +0 -63
  166. data/lib/zen/public/admin/images/icons/close.png +0 -0
  167. data/lib/zen/public/admin/js/vendor/yepnope.js +0 -1
  168. data/lib/zen/public/admin/js/zen/editor/base.js +0 -262
  169. data/lib/zen/public/admin/js/zen/editor/drivers/html.js +0 -89
  170. data/lib/zen/public/admin/js/zen/editor/drivers/markdown.js +0 -87
  171. data/lib/zen/public/admin/js/zen/editor/drivers/textile.js +0 -87
  172. data/lib/zen/public/admin/js/zen/modal.js +0 -146
  173. data/lib/zen/public/admin/js/zen/notification.js +0 -211
  174. data/proto/app/config/requires.rb +0 -10
  175. data/proto/app/vendor/theme/.gitkeep +0 -0
  176. data/proto/package/lib/package/view/admin/package/edit.xhtml +0 -0
  177. data/proto/package/lib/package/view/admin/package/form.xhtml +0 -0
  178. data/proto/package/lib/package/view/admin/package/new.xhtml +0 -0
@@ -1,89 +0,0 @@
1
- /**
2
- * HTML driver for the visual editor. This driver supports the following elements:
3
- *
4
- * * bold tags
5
- * * italic tags
6
- * * link tags
7
- * * ol tags
8
- * * ul tags
9
- *
10
- * @author Yorick Peterse
11
- * @link http://yorickpeterse.com/ Yorick Peterse's Website
12
- * @link http://zen-cms.com/ Zen Website
13
- * @license http://code.yorickpeterse.com/license.txt The MIT license
14
- * @since 0.1
15
- */
16
- Zen.Editor.Html = new Class(
17
- {
18
- /**
19
- * Replaces the selected text or inserts a block
20
- * of <strong> tags.
21
- *
22
- * @author Yorick Peterse
23
- * @since 0.1
24
- * @param {object} editor instance of the editor to which this callback belongs.
25
- * @return {void}
26
- */
27
- bold: function(editor)
28
- {
29
- editor.insertAroundCursor({before: '<strong>', after: '</strong>'});
30
- },
31
-
32
- /**
33
- * Inserts a block of italic tags at the current cursor or
34
- * around the currently selected text.
35
- *
36
- * @author Yorick Peterse
37
- * @since 0.1
38
- * @param {object} editor instance of the editor to which this callback belongs.
39
- * @return {void}
40
- */
41
- italic: function(editor)
42
- {
43
- editor.insertAroundCursor({before: '<em>', after: '</em>'});
44
- },
45
-
46
- /**
47
- * Inserts an anchor tag.
48
- *
49
- * @author Yorick Peterse
50
- * @since 0.1
51
- * @param {object} editor instance of the editor to which this callback belongs.
52
- * @return {void}
53
- */
54
- link: function(editor)
55
- {
56
- var link = prompt("URL");
57
-
58
- if ( link != '' && link !== null )
59
- {
60
- editor.insertAroundCursor({before: '<a href="' + link + '">', after: '</a>'});
61
- }
62
- },
63
-
64
- /**
65
- * Inserts an ordered list into the current text field
66
- *
67
- * @author Yorick Peterse
68
- * @since 0.1
69
- * @param {object} editor instance of the editor to which this callback belongs.
70
- * @return {void}
71
- */
72
- ol: function(editor)
73
- {
74
- editor.insertAroundCursor({before: "<ol>\n", after: "\n</ol>"});
75
- },
76
-
77
- /**
78
- * Inserts an unordered list into the current text field
79
- *
80
- * @author Yorick Peterse
81
- * @since 0.1
82
- * @param {object} editor instance of the editor to which this callback belongs.
83
- * @return {void}
84
- */
85
- ul: function(editor)
86
- {
87
- editor.insertAroundCursor({before: "<ul>\n", after: "\n</ul>"});
88
- }
89
- });
@@ -1,87 +0,0 @@
1
- /**
2
- * Markdown driver for the visual editor. This driver supports the following elements:
3
- *
4
- * * bold tags
5
- * * italic tags
6
- * * link tags
7
- * * ol tags
8
- * * ul tags
9
- *
10
- * @author Yorick Peterse
11
- * @link http://yorickpeterse.com/ Yorick Peterse's Website
12
- * @link http://zen-cms.com/ Zen Website
13
- * @license http://code.yorickpeterse.com/license.txt The MIT license
14
- * @since 0.1
15
- */
16
- Zen.Editor.Markdown = new Class(
17
- {
18
- /**
19
- * Inserts bold tags (*text*)
20
- *
21
- * @author Yorick Peterse
22
- * @since 0.1
23
- * @param {object} editor instance of the editor to which this callback belongs.
24
- * @return {void}
25
- */
26
- bold: function(editor)
27
- {
28
- editor.insertAroundCursor({before: '**', after: '**'});
29
- },
30
-
31
- /**
32
- * Inserts italic tags (_text_)
33
- *
34
- * @author Yorick Peterse
35
- * @since 0.1
36
- * @param {object} editor instance of the editor to which this callback belongs.
37
- * @return {void}
38
- */
39
- italic: function(editor)
40
- {
41
- editor.insertAroundCursor({before: '_', after: '_'});
42
- },
43
-
44
- /**
45
- * Inserts an anchor tag ("text":"url").
46
- *
47
- * @author Yorick Peterse
48
- * @since 0.1
49
- * @param {object} editor instance of the editor to which this callback belongs.
50
- * @return {void}
51
- */
52
- link: function(editor)
53
- {
54
- var link = prompt("URL");
55
-
56
- if ( link !== '' && link != null )
57
- {
58
- editor.insertAroundCursor({before: '[', after: '](' + link + ')'});
59
- }
60
- },
61
-
62
- /**
63
- * Inserts an ordered list into the current text field
64
- *
65
- * @author Yorick Peterse
66
- * @since 0.1
67
- * @param {object} editor instance of the editor to which this callback belongs.
68
- * @return {void}
69
- */
70
- ol: function(editor)
71
- {
72
- editor.insertAroundCursor({before: "\n1. "});
73
- },
74
-
75
- /**
76
- * Inserts an unordered list into the current text field
77
- *
78
- * @author Yorick Peterse
79
- * @since 0.1
80
- * @param {object} editor instance of the editor to which this callback belongs.
81
- * @return {void}
82
- */
83
- ul: function(editor)
84
- {
85
- editor.insertAroundCursor({before: "\n* "});
86
- }
87
- });
@@ -1,87 +0,0 @@
1
- /**
2
- * Textile driver for the visual editor. This driver supports the following elements:
3
- *
4
- * * bold tags
5
- * * italic tags
6
- * * link tags
7
- * * ol tags
8
- * * ul tags
9
- *
10
- * @author Yorick Peterse
11
- * @link http://yorickpeterse.com/ Yorick Peterse's Website
12
- * @link http://zen-cms.com/ Zen Website
13
- * @license http://code.yorickpeterse.com/license.txt The MIT license
14
- * @since 0.1
15
- */
16
- Zen.Editor.Textile = new Class(
17
- {
18
- /**
19
- * Inserts bold tags (*text*)
20
- *
21
- * @author Yorick Peterse
22
- * @since 0.1
23
- * @param {object} editor instance of the editor to which this callback belongs.
24
- * @return {void}
25
- */
26
- bold: function(editor)
27
- {
28
- editor.insertAroundCursor({before: '*', after: '*'});
29
- },
30
-
31
- /**
32
- * Inserts italic tags (_text_)
33
- *
34
- * @author Yorick Peterse
35
- * @since 0.1
36
- * @param {object} editor instance of the editor to which this callback belongs.
37
- * @return {void}
38
- */
39
- italic: function(editor)
40
- {
41
- editor.insertAroundCursor({before: '_', after: '_'});
42
- },
43
-
44
- /**
45
- * Inserts an anchor tag ("text":"url").
46
- *
47
- * @author Yorick Peterse
48
- * @since 0.1
49
- * @param {object} editor instance of the editor to which this callback belongs.
50
- * @return {void}
51
- */
52
- link: function(editor)
53
- {
54
- var link = prompt("URL");
55
-
56
- if ( link !== '' && link != null )
57
- {
58
- editor.insertAroundCursor({before: '"', after: '":' + link});
59
- }
60
- },
61
-
62
- /**
63
- * Inserts an ordered list into the current text field
64
- *
65
- * @author Yorick Peterse
66
- * @since 0.1
67
- * @param {object} editor instance of the editor to which this callback belongs.
68
- * @return {void}
69
- */
70
- ol: function(editor)
71
- {
72
- editor.insertAroundCursor({before: "\n# "});
73
- },
74
-
75
- /**
76
- * Inserts an unordered list into the current text field
77
- *
78
- * @author Yorick Peterse
79
- * @since 0.1
80
- * @param {object} editor instance of the editor to which this callback belongs.
81
- * @return {void}
82
- */
83
- ul: function(editor)
84
- {
85
- editor.insertAroundCursor({before: "\n* "});
86
- }
87
- });
@@ -1,146 +0,0 @@
1
- /**
2
- * The Modal class is a very simple Mootools class that can be used to create
3
- * modal windows. The class itself does not apply any CSS styles, it only adds
4
- * a few IDs/classes. All styling should be done in separate CSS files.
5
- *
6
- * ## Basic Usage
7
- *
8
- * Using this class is super-duper simple:
9
- *
10
- * new Modal("Hello, world!");
11
- *
12
- * That creates a container, a background div and the actual modal window
13
- * along with the specified content. It doesn't matter what kind of content
14
- * you're trying to add as long as it's valid HTML you're good to go.
15
- * For example, an image could be shown as following:
16
- *
17
- * new Modal($('some_image_id'))
18
- *
19
- * Note that iFrames are not supported simply because I never had the need for them.
20
- * If you want to load remote data you'd have to do some processing before generating
21
- * the modal window:
22
- *
23
- * var iframe = new Element('iframe', {src: 'url/of/iframe'});
24
- * new Modal(iframe);
25
- *
26
- * This class also does not animate the modals, this should also be handled by CSS
27
- * and can be done quite easily using CSS3.
28
- *
29
- * ## Closing Modal Windows
30
- *
31
- * The Modal class will add a div element with an id of "modal_close" to the modal window.
32
- * Whenever this element is clicked the callback specified in options.callback will be triggered.
33
- *
34
- * ## HTML
35
- *
36
- * The Modal class generates the following HTML:
37
- *
38
- * <div id="modal_container">
39
- * <div id="modal_window">
40
- * <div id="modal_close"></div>
41
- * <!-- Content goes here -->
42
- * </div>
43
- * <div id="modal_background"></div>
44
- * </div>
45
- *
46
- * @author Yorick Peterse
47
- * @link http://yorickpeterse.com/ Yorick Peterse's Website
48
- * @link http://zen-cms.com/ Zen Website
49
- * @license http://code.yorickpeterse.com/license.txt The MIT license
50
- * @since 0.1
51
- */
52
- Zen.Modal = new Class(
53
- {
54
- Implements: Options,
55
-
56
- /**
57
- * Object containing all default options for each modal window.
58
- * The following options are available:
59
- *
60
- * * height: specifies the width of the window (pixels, em, etc)
61
- * * width: specifies the height of the modal window
62
- * * fullscreen: specifies if the modal window should have a class of "fullscreen".
63
- * * callback: an event that's triggered whenever the close element is clicked.
64
- *
65
- * @author Yorick Peterse
66
- * @since 0.1
67
- * @var {object}
68
- */
69
- options: {
70
- height: '200px',
71
- width: '200px',
72
- fullscreen: false,
73
- callback: function()
74
- {
75
- // Remove all elements
76
- $('modal_background').destroy();
77
- $('modal_container').destroy();
78
- }
79
- },
80
-
81
- /**
82
- * Creates a new instance of the modal window and shows it.
83
- * Basic usage is as following:
84
- *
85
- * modal = new Modal("Hello, world!");
86
- *
87
- * If you want to specify any additional options you can do so as following:
88
- *
89
- * modal = new Modal("Hello, world!", {fullscreen: true});
90
- *
91
- * Note that calling this method will also show the message rather than just
92
- * initializing the class.
93
- *
94
- * @author Yorick Peterse
95
- * @since 0.1
96
- * @param {string} content The content to display inside the modal window.
97
- * @param {object} options Object containing all custom options.
98
- * @return {void}
99
- */
100
- initialize: function(content, options)
101
- {
102
- this.setOptions(options);
103
-
104
- var modal_class = null;
105
-
106
- if ( this.options.fullscreen === true )
107
- {
108
- modal_class = "fullscreen";
109
- }
110
-
111
- var styles = {width: this.options.width, height: this.options.height};
112
-
113
- // Create our base elements
114
- var modal_container = new Element('div', {id: 'modal_container'});
115
- var modal_window = new Element('div',
116
- {
117
- id : 'modal_window',
118
- 'class': modal_class,
119
- styles : styles
120
- });
121
-
122
- var modal_close = new Element('div', {id: 'modal_close'});
123
- var modal_background = new Element('div', {id: 'modal_background'});
124
-
125
- // Strings will be inserted using the html() method. Other elements
126
- // will be injected into the modal window.
127
- if ( typeof content === "string" )
128
- {
129
- modal_window.set('html', content);
130
- }
131
- else
132
- {
133
- modal_window.adopt(content.clone());
134
- }
135
-
136
- // Inject the close button
137
- modal_close.inject(modal_window);
138
-
139
- // Bind the events
140
- modal_close.addEvent('click', this.options.callback);
141
-
142
- modal_window.inject(modal_container);
143
- modal_background.inject(document.body);
144
- modal_container.inject(document.body);
145
- }
146
- });
@@ -1,211 +0,0 @@
1
- /**
2
- * The Notification class can be used to display Growl like notifications to the user.
3
- * These notifications can be used to inform the user that an entry has been saved, a new comment
4
- * has been posted, etc. Note that this class only inserts/animates the HTML, you'll have to
5
- * style the notifications yourself (more on that later on).
6
- *
7
- * ## Basic Usage
8
- *
9
- * Creating a new notification is fairly easy. The most basic notification only requires some content
10
- * and a title.
11
- *
12
- * notification = new Zen.Notification(
13
- * {
14
- * title: 'My title',
15
- * content: 'Hello, world!'
16
- * });
17
- *
18
- * This will show a new notification without a title and an image, just the text "Hello, world!".
19
- * You're not limited to plain text so feel free to use Comic Sans MS, pink colors and other funky
20
- * elements.
21
- *
22
- * ## Configuring Notifications
23
- *
24
- * Obviously just a message isn't enough and you might want to add an image or a title. When creating
25
- * a new notification you can use the following configuration options:
26
- *
27
- * * title: the title for the notification
28
- * * content: the text or HTML to display in the message
29
- * * image: a custom image to show in the notification
30
- * * sticky: boolean that indicates that the message can't be hidden by clicking on it
31
- * * duration: the time (in miliseconds) after which the notification should be removed
32
- *
33
- * ## Styling Notifications
34
- *
35
- * The HTML generated by the Notification class is fairly straightforward. There
36
- * are 2 important elements. The notification container and the notification itself.
37
- * The container will, how unexpected it may sound, contain all notifications. It's
38
- * HTML looks like the following:
39
- *
40
- * <div id="notification_container">
41
- *
42
- * </div>
43
- *
44
- * The HTML for a notification is slightly more complicated and looks like the following:
45
- *
46
- * <div class="notification">
47
- * <div class="close"></div>
48
- * <div class="image">
49
- * <img src="..." />
50
- * </div>
51
- * <div class="title">
52
- * Notification Title
53
- * </div>
54
- * <div class="content">
55
- * Content goes here
56
- * </div>
57
- * </div>
58
- *
59
- * As you can see it uses quite a few div elements but it's nothing ground breaking.
60
- * The image and title div elements will only be displayed if a title and/or image has been
61
- * specified. The close and content div will always be displayed.
62
- *
63
- * @author Yorick Peterse
64
- * @link http://yorickpeterse.com/ Yorick Peterse's Website
65
- * @link http://zen-cms.com/ Zen Website
66
- * @license http://code.yorickpeterse.com/license.txt The MIT license
67
- * @since 0.1
68
- */
69
- Zen.Notification = new Class(
70
- {
71
- Implements: Options,
72
-
73
- /**
74
- * JSON object containing all default and user defined options.
75
- * The following options are available:
76
- *
77
- * * title: the title for the notification
78
- * * content: the text or HTML to display in the message
79
- * * image: a custom image to show in the notification
80
- * * sticky: boolean that indicates that the message can't be hidden by clicking on it
81
- * * duration: the time (in miliseconds) after which the notification should be removed
82
- *
83
- * @author Yorick Peterse
84
- * @since 0.1
85
- * @var {object}
86
- */
87
- options:
88
- {
89
- title: '',
90
- content: '',
91
- image: '',
92
- sticky: false,
93
- duration: 3000
94
- },
95
-
96
- /**
97
- * Creates a new instance of the notification class
98
- * and shows the notification based on the specified options.
99
- *
100
- * @author Yorick Peterse
101
- * @since 0.1
102
- * @param {object} options An object containing all custom configuration parameters.
103
- * @return {void}
104
- */
105
- initialize: function(options)
106
- {
107
- this.setOptions(options);
108
- this.generateContainer();
109
- this.generateNotification();
110
- },
111
-
112
- /**
113
- * Generates a new notification container in case it doesn't already exist.
114
- *
115
- * @author Yorick Peterse
116
- * @since 0.1
117
- * @return {void}
118
- */
119
- generateContainer: function()
120
- {
121
- // The container only has to be created once
122
- if ( $('notification_container') !== null )
123
- {
124
- return;
125
- }
126
-
127
- container = new Element('div', {id: 'notification_container'});
128
- container.inject(document.body);
129
- },
130
-
131
- /**
132
- * Generates a new notification and inserts it into the notification
133
- * container.
134
- *
135
- * @author Yorick Peterse
136
- * @since 0.1
137
- * @return {void}
138
- */
139
- generateNotification: function()
140
- {
141
- var self = this;
142
- var notification = new Element('div',
143
- {
144
- 'class': 'notification',
145
- styles : {
146
- visibility: 'hidden'
147
- }
148
- });
149
-
150
- notification.adopt(new Element('div', {'class': 'close'}));
151
-
152
- // We'll only add the title and the image if they've been set
153
- if ( this.options.image !== '' )
154
- {
155
- var image_div = new Element('div', {'class': 'image'});
156
- var image_tag = new Element('img', {src: this.options.image});
157
-
158
- notification.adopt(image_div.adopt(image_tag));
159
- }
160
-
161
- var title_div = new Element('div',
162
- {
163
- 'class': 'title',
164
- html : this.options.title
165
- });
166
-
167
- var content_div = new Element('div',
168
- {
169
- 'class' : 'content',
170
- html : this.options.content
171
- });
172
-
173
- notification.adopt(title_div, content_div).inject($('notification_container'));
174
-
175
- // Add a new event listener so we can close our event
176
- notification.addEvent('click', function()
177
- {
178
- self.removeNotification(notification);
179
- });
180
-
181
- notification.tween('opacity', 0, 1);
182
-
183
- // Automatically remove the notification after 3 seconds if "sticky" is set to false
184
- if ( this.options.sticky !== true )
185
- {
186
- this.removeNotification.delay(this.options.duration, this, [notification]);
187
- }
188
- },
189
-
190
- /**
191
- * Removes the specified notification by fading it out and them removing the DOM element.
192
- *
193
- * @author Yorick peterse
194
- * @since 0.1
195
- * @param {object} notification The notification to remove.
196
- * @return {void}
197
- */
198
- removeNotification: function(notification)
199
- {
200
- // Fade the notification along with a callback so we can remove the element
201
- // once the animation is finished
202
- effect = new Fx.Tween(notification);
203
-
204
- effect.addEvent('complete', function()
205
- {
206
- notification.destroy();
207
- });
208
-
209
- effect.start('opacity', 1, 0);
210
- }
211
- });