knitkit 2.1.15 → 3.0.0

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 (209) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/knitkit/base_controller.rb +1 -1
  3. data/app/controllers/knitkit/comments_controller.rb +7 -2
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +78 -98
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +65 -45
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +22 -12
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -16
  9. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +15 -49
  10. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +4 -3
  11. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +69 -11
  12. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +63 -60
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +98 -82
  14. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +77 -0
  15. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +64 -44
  16. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +147 -0
  17. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +81 -45
  18. data/app/controllers/knitkit/mobile_controller.rb +15 -0
  19. data/app/controllers/knitkit/online_document_sections_controller.rb +2 -1
  20. data/app/controllers/knitkit/unauthorized_controller.rb +0 -1
  21. data/app/controllers/knitkit/website_sections_controller.rb +7 -4
  22. data/app/mailers/website_inquiry_mailer.rb +8 -7
  23. data/app/models/content.rb +11 -2
  24. data/app/models/document.rb +2 -17
  25. data/app/models/published_website.rb +96 -59
  26. data/app/models/theme.rb +100 -14
  27. data/app/models/website.rb +260 -28
  28. data/app/models/website_inquiry.rb +5 -12
  29. data/app/models/website_section.rb +9 -1
  30. data/app/views/knitkit/blogs/_add_comment.html.erb +44 -23
  31. data/app/views/knitkit/blogs/_comment.html.erb +4 -6
  32. data/app/views/knitkit/blogs/index.html.erb +63 -49
  33. data/app/views/knitkit/blogs/show.html.erb +17 -12
  34. data/app/views/knitkit/mobile/index.html.erb +162 -0
  35. data/app/views/knitkit/online_document_sections/index.html.erb +7 -5
  36. data/app/views/knitkit/unauthorized/index.html.erb +8 -4
  37. data/app/views/knitkit/website_sections/index.html.erb +8 -4
  38. data/app/views/layouts/knitkit/base.html.erb +79 -63
  39. data/app/views/layouts/knitkit/online_document_sections.html.erb +74 -52
  40. data/app/views/menus/knitkit/_default_menu.html.erb +4 -4
  41. data/app/views/menus/knitkit/_default_section_menu.html.erb +22 -23
  42. data/app/views/shared/knitkit/_bread_crumb.html.erb +10 -7
  43. data/app/views/shared/knitkit/_footer.html.erb +2 -2
  44. data/app/views/website_inquiry_mailer/inquiry.erb +23 -2
  45. data/app/widgets/contact_us/base.rb +25 -50
  46. data/app/widgets/contact_us/javascript/contact_us.js +7 -7
  47. data/app/widgets/contact_us/views/error.html.erb +6 -8
  48. data/app/widgets/contact_us/views/index.html.erb +28 -1
  49. data/app/widgets/contact_us/views/layouts/base.html.erb +9 -6
  50. data/app/widgets/contact_us/views/success.html.erb +3 -3
  51. data/app/widgets/google_map/views/index.html.erb +36 -36
  52. data/app/widgets/login/base.rb +1 -0
  53. data/app/widgets/login/javascript/login.js +3 -3
  54. data/app/widgets/login/views/index.html.erb +46 -26
  55. data/app/widgets/login/views/layouts/base.html.erb +15 -13
  56. data/app/widgets/login/views/login_header.html.erb +7 -9
  57. data/app/widgets/manage_profile/base.rb +116 -164
  58. data/app/widgets/manage_profile/views/_address.html.erb +184 -0
  59. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +23 -192
  60. data/app/widgets/manage_profile/views/_email_address.html.erb +163 -0
  61. data/app/widgets/manage_profile/views/_password_form.html.erb +23 -20
  62. data/app/widgets/manage_profile/views/_phone_number.html.erb +165 -0
  63. data/app/widgets/manage_profile/views/_user_information_form.html.erb +49 -33
  64. data/app/widgets/manage_profile/views/error.html.erb +6 -0
  65. data/app/widgets/manage_profile/views/index.html.erb +44 -46
  66. data/app/widgets/manage_profile/views/layouts/base.html.erb +3 -1
  67. data/app/widgets/manage_profile/views/success.html.erb +5 -0
  68. data/app/widgets/reset_password/views/index.html.erb +33 -28
  69. data/app/widgets/reset_password/views/layouts/base.html.erb +10 -1
  70. data/app/widgets/search/base.rb +37 -25
  71. data/app/widgets/search/views/_inline_search_form.html.erb +12 -0
  72. data/app/widgets/search/views/_search_form.html.erb +41 -0
  73. data/app/widgets/search/views/index.html.erb +5 -3
  74. data/app/widgets/search/views/layouts/base.html.erb +13 -23
  75. data/app/widgets/search/views/show.html.erb +32 -47
  76. data/app/widgets/signup/base.rb +1 -1
  77. data/app/widgets/signup/javascript/signup.js +7 -9
  78. data/app/widgets/signup/views/_signup_form.html.erb +34 -29
  79. data/app/widgets/signup/views/error.html.erb +11 -11
  80. data/app/widgets/signup/views/index.html.erb +3 -2
  81. data/app/widgets/signup/views/layouts/base.html.erb +8 -5
  82. data/app/widgets/signup/views/success.html.erb +5 -4
  83. data/config/routes.rb +39 -28
  84. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +3 -0
  85. data/db/migrate/20110211002317_setup_knitkit.rb +0 -1
  86. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +33 -0
  87. data/db/migrate/20140622212723_update_website_inquiries.rb +22 -0
  88. data/db/migrate/20140911185022_add_publishing_to_website.rb +5 -0
  89. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +12 -0
  90. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +13 -0
  91. data/lib/knitkit.rb +0 -1
  92. data/lib/knitkit/engine.rb +1 -0
  93. data/lib/knitkit/extensions.rb +4 -0
  94. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +33 -0
  95. data/lib/knitkit/extensions/active_record/acts_as_document.rb +0 -12
  96. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +7 -10
  97. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +2 -4
  98. data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +4 -1
  99. data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +16 -13
  100. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +10 -8
  101. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +123 -108
  102. data/lib/knitkit/extensions/will_paginate/link_renderer.rb +67 -0
  103. data/lib/knitkit/routing_filter/section_router.rb +10 -8
  104. data/lib/knitkit/syntax_validator.rb +2 -2
  105. data/lib/knitkit/version.rb +7 -3
  106. data/public/images/inline_edit/close.png +0 -0
  107. data/public/images/knitkit/close_window.png +0 -0
  108. data/public/images/knitkit/logo.png +0 -0
  109. data/public/images/knitkit/splash/images/add-site.png +0 -0
  110. data/public/images/knitkit/splash/images/adjust-site.png +0 -0
  111. data/public/images/knitkit/splash/images/browse-site.png +0 -0
  112. data/public/images/knitkit/splash/images/find-themes.png +0 -0
  113. data/public/images/knitkit/splash/images/settings.png +0 -0
  114. data/public/images/knitkit/splash/images/tutorials.png +0 -0
  115. data/public/images/knitkit/splash/splash.png +0 -0
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +656 -627
  117. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +444 -333
  118. data/public/javascripts/erp_app/desktop/applications/knitkit/{east_region.js → east_region/east_region.js} +33 -33
  119. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +332 -0
  120. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +144 -0
  121. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +335 -0
  122. data/public/javascripts/erp_app/desktop/applications/knitkit/{widgets_panel.js → east_region/widgets_panel.js} +55 -55
  123. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +150 -37
  124. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +228 -96
  125. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +89 -85
  126. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +238 -217
  127. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +59 -54
  128. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +170 -0
  129. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +1168 -0
  130. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +71 -0
  131. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +301 -306
  132. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +216 -0
  133. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +182 -153
  134. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +48 -65
  135. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +93 -94
  136. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +523 -197
  137. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +20 -34
  138. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +74 -0
  139. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +245 -0
  140. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +360 -0
  141. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +348 -0
  142. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +106 -1132
  143. data/public/javascripts/knitkit/bootstrap-datepicker.js +474 -0
  144. data/public/javascripts/knitkit/bootstrap.min.js +7 -0
  145. data/public/javascripts/knitkit/confirm-bootstrap.js +110 -0
  146. data/public/javascripts/knitkit/inline_editing.js +73 -50
  147. data/public/javascripts/knitkit/jquery.maskedinput.min.js +7 -0
  148. data/public/javascripts/knitkit/mobile/app/view/Main.js +108 -0
  149. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +734 -0
  150. data/public/javascripts/knitkit/theme.js +76 -0
  151. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +95 -35
  152. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +10 -0
  153. data/public/stylesheets/knitkit/bootstrap.min.css +7 -0
  154. data/public/stylesheets/knitkit/custom.css +122 -0
  155. data/public/stylesheets/knitkit/datepicker.css +182 -0
  156. data/public/stylesheets/knitkit/inline_editing.css +58 -58
  157. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +1 -1
  158. data/spec/dummy/config/application.rb +1 -1
  159. data/spec/models/article_spec.rb +3 -3
  160. data/spec/models/content_spec.rb +9 -9
  161. data/spec/models/website_spec.rb +1 -1
  162. metadata +100 -114
  163. data/app/helpers/application_helper.rb +0 -134
  164. data/app/views/knitkit/articles/index.html.erb +0 -3
  165. data/app/views/knitkit/articles/show.html.erb +0 -4
  166. data/app/views/menus/knitkit/_default_sub_menu.html.erb +0 -43
  167. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +0 -47
  168. data/app/widgets/contact_us/views/_contact_form.html.erb +0 -36
  169. data/app/widgets/dynamic_forms/base.rb +0 -139
  170. data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +0 -110
  171. data/app/widgets/dynamic_forms/views/error.html.erb +0 -5
  172. data/app/widgets/dynamic_forms/views/index.html.erb +0 -8
  173. data/app/widgets/dynamic_forms/views/success.html.erb +0 -4
  174. data/app/widgets/dynamic_grid/base.rb +0 -130
  175. data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +0 -3
  176. data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +0 -3
  177. data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +0 -177
  178. data/app/widgets/dynamic_grid/views/index.html.erb +0 -14
  179. data/app/widgets/login/views/reset_password.html.erb +0 -26
  180. data/app/widgets/manage_profile/views/default_type_error.html.erb +0 -5
  181. data/app/widgets/scaffold/base.rb +0 -87
  182. data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +0 -3
  183. data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +0 -3
  184. data/app/widgets/scaffold/javascript/scaffold.js +0 -337
  185. data/app/widgets/scaffold/views/index.html.erb +0 -15
  186. data/app/widgets/search/views/_search.html.erb +0 -39
  187. data/public/images/knitkit/bullet.png +0 -0
  188. data/public/images/knitkit/close.png +0 -0
  189. data/public/images/knitkit/content.png +0 -0
  190. data/public/images/knitkit/footer.png +0 -0
  191. data/public/images/knitkit/graphic.png +0 -0
  192. data/public/images/knitkit/greyFadeDown.png +0 -0
  193. data/public/images/knitkit/link.png +0 -0
  194. data/public/images/knitkit/menu.png +0 -0
  195. data/public/images/knitkit/menu_select.png +0 -0
  196. data/public/images/knitkit/search.png +0 -0
  197. data/public/images/knitkit/tooltip.gif +0 -0
  198. data/public/javascripts/ajax_pagination.js +0 -33
  199. data/public/javascripts/datepicker.js +0 -445
  200. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +0 -341
  201. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +0 -31
  202. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +0 -263
  203. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +0 -722
  204. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +0 -585
  205. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +0 -155
  206. data/public/javascripts/knitkit/helpers.js +0 -26
  207. data/public/stylesheets/datepicker.css +0 -121
  208. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +0 -233
  209. data/public/stylesheets/knitkit/style.css +0 -426
@@ -1,7 +1,9 @@
1
1
  Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
2
- extend:"Ext.panel.Panel",
3
- alias:'widget.knitkit_centerregion',
4
- ckEditorToolbar:[
2
+ extend: "Ext.panel.Panel",
3
+ id: 'knitkitCenterRegion',
4
+ alias: 'widget.knitkit_centerregion',
5
+ ckEditorExtraPlugins: 'codemirror,syntaxhighlight',
6
+ ckEditorToolbar: [
5
7
  ['Source', '-', 'Preview', 'Print'],
6
8
  ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
7
9
  ['Undo', 'Redo'],
@@ -9,34 +11,35 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
9
11
  ['SpellChecker', '-', 'SelectAll'],
10
12
  ['TextColor', 'BGColor'],
11
13
  ['Bold', 'Italic', 'Underline', 'Strike'],
12
- ['Subscript', 'Superscript', '-', 'jwplayer'],
13
- ['Table', 'NumberedList', 'BulletedList'],
14
+ ['Subscript', 'Superscript', '-'],
15
+ ['Image', 'Table', 'NumberedList', 'BulletedList'],
14
16
  ['Outdent', 'Indent', 'Blockquote'],
15
17
  ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
16
18
  ['BidiLtr', 'BidiRtl'],
17
19
  ['Link', 'Unlink', 'Anchor'],
18
20
  ['HorizontalRule', 'SpecialChar', 'PageBreak'],
19
21
  ['ShowBlocks', 'RemoveFormat'],
20
- ['KnitkitThemes', 'Format', 'Font', 'FontSize' ],
21
- ['Maximize', '-', 'About']
22
+ ['Format', 'Font', 'FontSize'],
23
+ ['Maximize', '-', 'About'],
24
+ ['Syntaxhighlight']
22
25
  ],
23
26
 
24
- setWindowStatus:function (status) {
27
+ setWindowStatus: function (status) {
25
28
  this.findParentByType('statuswindow').setStatus(status);
26
29
  },
27
30
 
28
- clearWindowStatus:function () {
31
+ clearWindowStatus: function () {
29
32
  this.findParentByType('statuswindow').clearStatus();
30
33
  },
31
34
 
32
- viewSectionLayout:function (title, template) {
35
+ viewSectionLayout: function (title, template) {
33
36
  this.workArea.add({
34
- title:title + ' - Layout',
35
- disableToolbar:true,
36
- xtype:'codemirror',
37
- parser:'rhtml',
38
- sourceCode:template,
39
- closable:true
37
+ title: title + ' - Layout',
38
+ disableToolbar: true,
39
+ xtype: 'codemirror',
40
+ mode: 'rhtml',
41
+ sourceCode: template,
42
+ closable: true
40
43
  });
41
44
  this.workArea.setActiveTab(this.workArea.items.length - 1);
42
45
  return false;
@@ -44,17 +47,18 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
44
47
 
45
48
  /* sections */
46
49
 
47
- saveSectionLayout:function (sectionId, content) {
50
+ saveSectionLayout: function (id, comp, content) {
51
+ jcomp = comp;
48
52
  var self = this;
49
53
  this.setWindowStatus('Saving...');
50
54
  Ext.Ajax.request({
51
- url:'/knitkit/erp_app/desktop/section/save_layout',
52
- method:'POST',
53
- params:{
54
- id:sectionId,
55
- content:content
55
+ url: '/knitkit/erp_app/desktop/section/save_layout',
56
+ method: 'POST',
57
+ params: {
58
+ id: id,
59
+ content: content
56
60
  },
57
- success:function (response) {
61
+ success: function (response) {
58
62
  self.clearWindowStatus();
59
63
  var obj = Ext.decode(response.responseText);
60
64
  if (obj.success) {
@@ -67,59 +71,55 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
67
71
  else {
68
72
  Ext.Msg.alert('Error', obj.message);
69
73
  }
74
+ comp.codeMirrorInstance.focus();
70
75
  },
71
- failure:function (response) {
76
+ failure: function (response) {
72
77
  self.clearWindowStatus();
73
78
  Ext.Msg.alert('Error', 'Error saving layout');
74
79
  }
75
80
  });
76
81
  },
77
82
 
78
- editSectionLayout:function (sectionName, websiteId, websiteSectionId, content, tbarItems) {
83
+ editSectionLayout: function (sectionName, websiteId, websiteSectionId, content, tbarItems) {
79
84
  var self = this;
80
85
  var itemId = 'section-' + websiteSectionId;
81
86
  var item = this.workArea.query('#' + itemId).first();
82
87
 
83
88
  if (Compass.ErpApp.Utility.isBlank(item)) {
84
89
  item = Ext.create("Ext.panel.Panel", {
85
- layout:'border',
86
- title:sectionName,
87
- save:function (comp) {
90
+ layout: 'border',
91
+ title: sectionName,
92
+ save: function (comp) {
88
93
  var content = comp.down('codemirror').getValue();
89
- self.saveSectionLayout(websiteSectionId, content);
94
+ self.saveSectionLayout(websiteSectionId, comp, content);
90
95
  },
91
- closable:true,
92
- itemId:itemId,
93
- items:[
96
+ closable: true,
97
+ itemId: itemId,
98
+ items: [
94
99
  {
95
- title:sectionName + ' - Layout',
96
- tbarItems:tbarItems,
97
- disableSave:true,
98
- listeners:{
99
- save:function (comp, content) {
100
- self.saveSectionLayout(websiteSectionId, content);
100
+ title: sectionName + ' - Layout',
101
+ tbarItems: tbarItems,
102
+ disableSave: true,
103
+ listeners: {
104
+ save: function (comp, content) {
105
+ self.saveSectionLayout(websiteSectionId, comp, content);
101
106
  }
102
107
  },
103
- xtype:'codemirror',
104
- parser:'erb',
105
- region:'center',
106
- sourceCode:content
108
+ xtype: 'codemirror',
109
+ mode: 'rhtml',
110
+ region: 'center',
111
+ sourceCode: content
107
112
  },
108
113
  {
109
- xtype:'knitkit_versionswebsitesectiongridpanel',
110
- websiteSectionId:websiteSectionId,
111
- region:'south',
112
- height:150,
113
- collapsible:true,
114
- centerRegion:self,
115
- siteId:websiteId
114
+ xtype: 'knitkit_versionswebsitesectiongridpanel',
115
+ websiteSectionId: websiteSectionId,
116
+ region: 'south',
117
+ height: 150,
118
+ collapsible: true,
119
+ centerRegion: self,
120
+ siteId: websiteId
116
121
  }
117
- ],
118
- listeners:{
119
- 'show':function (panel) {
120
- Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
121
- }
122
- }
122
+ ]
123
123
  });
124
124
 
125
125
  this.workArea.add(item);
@@ -131,22 +131,21 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
131
131
 
132
132
  /* documentation using markdown */
133
133
 
134
- saveDocumentationMarkdown:function (id, siteId, content) {
134
+ saveDocumentationMarkdown: function (id, comp, content, siteId) {
135
135
  var self = this;
136
136
  this.setWindowStatus('Saving...');
137
137
  Ext.Ajax.request({
138
- url:'/knitkit/erp_app/desktop/content/update',
139
- method:'POST',
140
- params:{
141
- id:id,
142
- html:content,
143
- site_id:siteId
138
+ url: '/knitkit/erp_app/desktop/content/update',
139
+ method: 'POST',
140
+ params: {
141
+ id: id,
142
+ html: content,
143
+ site_id: siteId
144
144
  },
145
- success:function (response) {
145
+ success: function (response) {
146
146
  var obj = Ext.decode(response.responseText);
147
147
  if (obj.success) {
148
148
  self.clearWindowStatus();
149
- Ext.getStore('knitkit_articlesgridpanelStore').load();
150
149
  var activeTab = self.workArea.getActiveTab();
151
150
  var versionsGrid = activeTab.down('knitkit_versionsarticlegridpanel');
152
151
  versionsGrid.getStore().load();
@@ -155,59 +154,55 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
155
154
  Ext.Msg.alert('Error', 'Error saving contents');
156
155
  self.clearWindowStatus();
157
156
  }
157
+ comp.ckEditorInstance.focus();
158
158
  },
159
- failure:function (response) {
159
+ failure: function (response) {
160
160
  self.clearWindowStatus();
161
161
  Ext.Msg.alert('Error', 'Error saving contents');
162
162
  }
163
163
  });
164
164
  },
165
165
 
166
- editDocumentationMarkdown:function (sectionName, websiteId, contentId, content, tbarItems) {
166
+ editDocumentationMarkdown: function (sectionName, websiteId, contentId, content, tbarItems) {
167
167
  var self = this;
168
168
  var itemId = 'markdown-' + contentId;
169
169
  var item = this.workArea.query('#' + itemId).first();
170
170
 
171
171
  if (Compass.ErpApp.Utility.isBlank(item)) {
172
172
  item = Ext.create("Ext.panel.Panel", {
173
- layout:'border',
174
- title:sectionName,
175
- save:function (comp) {
173
+ layout: 'border',
174
+ title: sectionName,
175
+ save: function (comp) {
176
176
  var content = comp.down('codemirror').getValue();
177
- self.saveDocumentationMarkdown(contentId, websiteId, content);
177
+ self.saveDocumentationMarkdown(contentId, comp, content, websiteId);
178
178
  },
179
- closable:true,
180
- itemId:itemId,
181
- items:[
179
+ closable: true,
180
+ itemId: itemId,
181
+ items: [
182
182
  {
183
- title:sectionName + ' - Markdown',
184
- tbarItems:tbarItems,
185
- disableSave:true,
186
- listeners:{
187
- save:function (comp, content) {
188
- self.saveDocumentationMarkdown(contentId, websiteId, content);
183
+ title: sectionName + ' - Markdown',
184
+ tbarItems: tbarItems,
185
+ disableSave: true,
186
+ listeners: {
187
+ save: function (comp, content) {
188
+ self.saveDocumentationMarkdown(contentId, comp, content, websiteId);
189
189
  }
190
190
  },
191
- xtype:'codemirror',
192
- parser:'erb',
193
- region:'center',
194
- sourceCode:content
191
+ xtype: 'codemirror',
192
+ mode: 'rhtml',
193
+ region: 'center',
194
+ sourceCode: content
195
195
  },
196
196
  {
197
- xtype:'knitkit_versionsarticlegridpanel',
198
- contentId:contentId,
199
- region:'south',
200
- height:150,
201
- collapsible:true,
202
- centerRegion:self,
203
- siteId:websiteId
204
- }
205
- ],
206
- listeners:{
207
- 'show':function (panel) {
208
- Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
197
+ xtype: 'knitkit_versionsarticlegridpanel',
198
+ contentId: contentId,
199
+ region: 'south',
200
+ height: 150,
201
+ collapsible: true,
202
+ centerRegion: self,
203
+ siteId: websiteId
209
204
  }
210
- }
205
+ ]
211
206
  });
212
207
 
213
208
  this.workArea.add(item);
@@ -219,77 +214,80 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
219
214
 
220
215
  /* templates */
221
216
 
222
- saveTemplateFile:function (path, content) {
217
+ saveTemplateFile: function (path, comp, content) {
223
218
  var self = this;
224
219
  this.setWindowStatus('Saving...');
225
220
  Ext.Ajax.request({
226
- url:'/knitkit/erp_app/desktop/theme/update_file',
227
- method:'POST',
228
- params:{
229
- node:path,
230
- content:content
221
+ url: '/knitkit/erp_app/desktop/theme/update_file',
222
+ method: 'POST',
223
+ params: {
224
+ node: path,
225
+ content: content
231
226
  },
232
- success:function (response) {
227
+ success: function (response) {
233
228
  var obj = Ext.decode(response.responseText);
234
229
  self.clearWindowStatus();
235
230
  if (!obj.success) {
236
231
  Ext.Msg.alert('Error', obj.message);
237
232
  }
233
+ comp.codeMirrorInstance.focus();
238
234
  },
239
- failure:function (response) {
235
+ failure: function (response) {
240
236
  self.clearWindowStatus();
241
237
  Ext.Msg.alert('Error', 'Error saving contents');
242
238
  }
243
239
  });
244
240
  },
245
241
 
246
- editTemplateFile:function (node, content, tbarItems, themeId) {
242
+ editTemplateFile: function (node, content, tbarItems, themeId) {
247
243
  var self = this,
248
244
  pathArr = node.data.id.split('/'),
249
- containerDir = pathArr[pathArr.length-2],
245
+ containerDir = pathArr[pathArr.length - 2],
250
246
  fileName = pathArr.pop(),
251
247
  baseName = fileName.split('.')[0],
252
248
  fileType = node.data.id.split('.').pop(),
253
249
  filePathHash = Compass.ErpApp.Utility.Encryption.MD5(node.data.id),
254
- templatePath = node.data.id.replace(new RegExp("/public/sites/.+/themes/"), ""),
255
-
250
+ templatePath = node.data.id.replace(new RegExp("/public/sites/.+/themes/"), ""),
251
+
256
252
  itemId = baseName + "_" + filePathHash, // Using a hash will allow files with same name to be opened concurrently
257
253
  item = this.workArea.query('#' + itemId).first();
258
254
 
255
+ mode = Compass.ErpApp.Shared.CodeMirror.determineCodeMirrorMode(node.data.id);
256
+
259
257
  // If this file isn't already an existing tab, let's open it
260
258
  if (Compass.ErpApp.Utility.isBlank(item)) {
261
- item = Ext.create('Ext.panel.Panel', {
262
- closable:true,
259
+ item = Ext.create('Ext.panel.Panel', {
260
+ closable: true,
263
261
  title: baseName,
264
262
  baseName: baseName,
265
263
  fileName: fileName,
266
264
  containerDir: containerDir,
267
265
  filePathHash: filePathHash,
268
- itemId:itemId,
269
- layout:'fit',
270
- save:function (comp) {
266
+ itemId: itemId,
267
+ layout: 'fit',
268
+ save: function (comp) {
271
269
  var content = comp.down('codemirror').getValue();
272
- self.saveTemplateFile(node.data.id, content);
270
+ self.saveTemplateFile(node.data.id, comp, content);
273
271
  },
274
- items:[
272
+ items: [
275
273
  {
276
- tbarItems:tbarItems,
277
- disableSave:true,
278
- xtype:'codemirror',
279
- listeners:{
280
- save:function (comp, content) {
281
- self.saveTemplateFile(node.data.id, content);
274
+ tbarItems: tbarItems,
275
+ disableSave: true,
276
+ xtype: 'codemirror',
277
+ listeners: {
278
+ save: function (comp, content) {
279
+ self.saveTemplateFile(node.data.id, comp, content);
282
280
  }
283
281
  },
284
- parser:fileType,
285
- sourceCode:content
282
+ mode: mode,
283
+ sourceCode: content
286
284
  }
287
285
  ],
288
- bbar:{
289
- items:[
290
- templatePath
291
- ]
292
- }
286
+ bbar: {
287
+ items: [
288
+ templatePath
289
+ ]
290
+ }
293
291
  });
294
292
 
295
293
  this.workArea.add(item);
@@ -301,117 +299,169 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
301
299
 
302
300
  /* excerpts */
303
301
 
304
- saveExcerpt:function (id, content, siteId) {
302
+ saveExcerpt: function (id, comp, content, siteId) {
305
303
  var self = this;
306
304
  this.setWindowStatus('Saving...');
307
305
  Ext.Ajax.request({
308
- url:'/knitkit/erp_app/desktop/content/save_excerpt',
309
- method:'POST',
310
- params:{
311
- id:id,
312
- html:content,
313
- site_id:siteId
306
+ url: '/knitkit/erp_app/desktop/content/save_excerpt',
307
+ method: 'POST',
308
+ params: {
309
+ id: id,
310
+ html: content,
311
+ site_id: siteId
314
312
  },
315
- success:function (response) {
313
+ success: function (response) {
316
314
  var obj = Ext.decode(response.responseText);
317
315
  if (obj.success) {
318
316
  self.clearWindowStatus();
319
- Ext.getStore('knitkit_articlesgridpanelStore').load();
320
317
  var activeTab = self.workArea.getActiveTab();
321
318
  var panel = activeTab.query('knitkit_versionsbloggridpanel');
322
319
  if (panel.length === 0) {
323
320
  panel = activeTab.query('knitkit_nonpublishedversionswebsitesectiongridpanel');
324
321
  }
325
322
  panel[0].getStore().load();
323
+ comp.ckEditorInstance.focus();
326
324
  }
327
325
  else {
328
326
  Ext.Msg.alert('Error', 'Error saving excerpt');
329
327
  self.clearWindowStatus();
330
328
  }
331
329
  },
332
- failure:function (response) {
330
+ failure: function (response) {
333
331
  self.clearWindowStatus();
334
332
  Ext.Msg.alert('Error', 'Error saving excerpt');
335
333
  }
336
334
  });
337
335
  },
338
336
 
339
- editExcerpt:function (title, id, content, siteId, contentGridStore) {
337
+ editExcerpt: function (title, id, content, siteId, contentGridStore) {
340
338
  var self = this;
341
339
  var itemId = 'editExcerpt-' + id;
342
340
  var item = this.workArea.query('#' + itemId).first();
343
341
 
344
342
  if (Compass.ErpApp.Utility.isBlank(item)) {
345
343
  var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor", {
346
- autoHeight:true,
347
- value:content,
348
- ckEditorConfig:{
349
- extraPlugins:'jwplayer,knitkitthemes',
350
- toolbar:self.ckEditorToolbar
344
+ autoHeight: true,
345
+ //value:content,
346
+ ckEditorConfig: {
347
+ extraPlugins: self.ckEditorExtraPlugins,
348
+ toolbar: self.ckEditorToolbar
351
349
  },
352
- listeners:{
353
- save:function (comp, content) {
354
- self.saveExcerpt(id, content, siteId);
350
+ listeners: {
351
+ save: function (comp, content) {
352
+ self.saveExcerpt(id, comp, content, siteId);
355
353
  if (!Ext.isEmpty(contentGridStore)) contentGridStore.load();
354
+ },
355
+ ckeditordrop: function (ckeditorPanel, dropEvent) {
356
+ var dataTransfer = dropEvent.dataTransfer;
357
+ var files = dataTransfer.files;
358
+ for (var i = 0; i < files.length; i++) {
359
+ var loadMask = new Ext.LoadMask(ckeditorPanel, {msg:"Please wait..."});
360
+ loadMask.show();
361
+
362
+ var file = files[i];
363
+ var reader = new FileReader();
364
+
365
+ Compass.ErpApp.Utility.addEventHandler(reader, 'loadend', function (e, file) {
366
+ var bin = this.result;
367
+
368
+ Ext.Ajax.request({
369
+ headers: {'Content-Type': file.type},
370
+ url: '/knitkit/erp_app/desktop/image_assets/shared/upload_file',
371
+ jsonData: bin,
372
+ params:{
373
+ name: file.name,
374
+ directory: 'root_node',
375
+ is_drag_drop: true
376
+ },
377
+ success: function(result){
378
+ loadMask.hide();
379
+ resultObj = Ext.JSON.decode(result.responseText);
380
+ if(resultObj.success){
381
+ ckeditorPanel.insertHtml('<img src='+resultObj.url+' height="200" width="200" />');
382
+ var sharedImageAssetsDataView = self.up('#knitkit').down('knitkit_ImageAssetsPanel').sharedImageAssetsDataView,
383
+ sharedImageAssetsTreePanel = self.up('#knitkit').down('knitkit_ImageAssetsPanel').sharedImageAssetsTreePanel;
384
+
385
+ sharedImageAssetsDataView.getStore().load({
386
+ params:{
387
+ directory: sharedImageAssetsDataView.directory
388
+ }
389
+ });
390
+ sharedImageAssetsTreePanel.getStore().load({
391
+ callback:function(){
392
+ sharedImageAssetsTreePanel.getView().refresh();
393
+ }
394
+ });
395
+ }
396
+ else{
397
+ Ext.Msg.alert('Error', 'Could not upload image');
398
+ }
399
+ },
400
+ failure: function(result){
401
+ loadMask.hide();
402
+ Ext.Msg.alert('Error', 'Could not upload image');
403
+ }
404
+ });
405
+ }.bindToEventHandler(file));
406
+
407
+ reader.readAsDataURL(file);
408
+ }
356
409
  }
357
410
  }
358
411
  });
359
412
 
413
+ ckEditor.setValue(content);
414
+
360
415
  var items = [
361
416
  {
362
- xtype:'panel',
363
- layout:'fit',
364
- split:true,
365
- region:'center',
366
- items:ckEditor,
367
- autoDestroy:true
417
+ xtype: 'panel',
418
+ layout: 'fit',
419
+ split: true,
420
+ region: 'center',
421
+ items: ckEditor,
422
+ autoDestroy: true
368
423
  }
369
424
  ];
370
425
 
371
426
  if (!Compass.ErpApp.Utility.isBlank(siteId)) {
372
427
  items.push({
373
- xtype:'knitkit_versionsbloggridpanel',
374
- contentId:id,
375
- region:'south',
376
- height:150,
377
- collapsible:true,
378
- centerRegion:self,
379
- siteId:siteId
428
+ xtype: 'knitkit_versionsbloggridpanel',
429
+ contentId: id,
430
+ region: 'south',
431
+ height: 150,
432
+ collapsible: true,
433
+ collapsed: true,
434
+ centerRegion: self,
435
+ siteId: siteId
380
436
  });
381
437
  }
382
438
  else {
383
439
  items.push({
384
- xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
385
- contentId:id,
386
- region:'south',
387
- height:150,
388
- collapsible:true,
389
- centerRegion:self
440
+ xtype: 'knitkit_nonpublishedversionswebsitesectiongridpanel',
441
+ contentId: id,
442
+ region: 'south',
443
+ height: 150,
444
+ collapsible: true,
445
+ collapsed: true,
446
+ centerRegion: self
390
447
  });
391
448
  }
392
449
 
393
450
  item = Ext.create("Ext.panel.Panel", {
394
- layout:'border',
395
- title:title,
396
- closable:true,
397
- items:items,
398
- save:function (comp) {
451
+ layout: 'border',
452
+ title: title,
453
+ closable: true,
454
+ items: items,
455
+ save: function (comp) {
399
456
  if (currentUser.hasCapability('edit_html', 'Content')) {
400
457
  var content = comp.down('ckeditor').getValue();
401
- self.saveExcerpt(id, content, siteId);
458
+ self.saveExcerpt(id, comp, content, siteId);
402
459
  if (!Ext.isEmpty(contentGridStore)) contentGridStore.load();
403
460
  } else {
404
461
  currentUser.showInvalidAccess();
405
462
  }
406
463
  },
407
- itemId:itemId,
408
- listeners:{
409
- 'show':function (panel) {
410
- if (!Compass.ErpApp.Utility.isBlank(siteId)) {
411
- Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
412
- }
413
- }
414
- }
464
+ itemId: itemId
415
465
  });
416
466
 
417
467
  this.workArea.add(item);
@@ -422,7 +472,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
422
472
 
423
473
  /* image */
424
474
 
425
- showImage:function (node, themeId) {
475
+ showImage: function (node, themeId) {
426
476
  var self = this;
427
477
  var fileName = node.data.id.split('/').pop().split('.')[0];
428
478
  var fileType = node.data.id.split('.').pop();
@@ -431,11 +481,11 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
431
481
 
432
482
  if (Compass.ErpApp.Utility.isBlank(item)) {
433
483
  item = Ext.create('Ext.panel.Panel', {
434
- closable:true,
435
- title:fileName + '.' + fileType,
436
- itemId:itemId,
437
- layout:'fit',
438
- html:'<img src="' + node.data.url + '" />'
484
+ closable: true,
485
+ title: fileName + '.' + fileType,
486
+ itemId: itemId,
487
+ layout: 'fit',
488
+ html: '<img src="' + node.data.url + '" />'
439
489
  });
440
490
 
441
491
  this.workArea.add(item);
@@ -447,22 +497,21 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
447
497
 
448
498
  /* content */
449
499
 
450
- saveContent:function (id, content, contentType, siteId) {
500
+ saveContent: function (id, comp, content, contentType, siteId) {
451
501
  var self = this;
452
502
  this.setWindowStatus('Saving...');
453
503
  Ext.Ajax.request({
454
- url:'/knitkit/erp_app/desktop/content/update',
455
- method:'POST',
456
- params:{
457
- id:id,
458
- html:content,
459
- site_id:siteId
504
+ url: '/knitkit/erp_app/desktop/content/update',
505
+ method: 'POST',
506
+ params: {
507
+ id: id,
508
+ html: content,
509
+ site_id: siteId
460
510
  },
461
- success:function (response) {
511
+ success: function (response) {
462
512
  var obj = Ext.decode(response.responseText);
463
513
  if (obj.success) {
464
514
  self.clearWindowStatus();
465
- Ext.getStore('knitkit_articlesgridpanelStore').load();
466
515
  if (!Compass.ErpApp.Utility.isBlank(contentType)) {
467
516
  var activeTab = self.workArea.getActiveTab();
468
517
  var versionsGrid = activeTab.down('knitkit_versions' + contentType + 'gridpanel');
@@ -473,62 +522,131 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
473
522
  if (!Ext.isEmpty(versionsGrid)) {
474
523
  versionsGrid.getStore().load();
475
524
  }
476
-
477
525
  }
526
+ //comp.ckEditorInstance.focus();
478
527
  }
479
528
  else {
480
529
  Ext.Msg.alert('Error', 'Error saving contents');
481
530
  self.clearWindowStatus();
482
531
  }
483
532
  },
484
- failure:function (response) {
533
+ failure: function (response) {
485
534
  self.clearWindowStatus();
486
535
  Ext.Msg.alert('Error', 'Error saving contents');
487
536
  }
488
537
  });
489
538
  },
490
539
 
491
- viewContent:function (title, content) {
540
+ viewContent: function (title, content) {
492
541
  var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor", {
493
- autoHeight:true,
494
- value:content,
495
- ckEditorConfig:{
496
- toolbar:[
542
+ autoHeight: true,
543
+ value: content,
544
+ ckEditorConfig: {
545
+ toolbar: [
497
546
  ['Preview']
498
547
  ]
499
548
  }
500
549
  });
501
550
 
502
551
  var item = Ext.create('Ext.panel.Panel', {
503
- closable:true,
504
- layout:'fit',
505
- title:title,
506
- split:true,
507
- items:ckEditor,
508
- autoDestroy:true
552
+ closable: true,
553
+ layout: 'fit',
554
+ title: title,
555
+ split: true,
556
+ items: ckEditor,
557
+ autoDestroy: true
558
+ });
559
+
560
+ this.workArea.add(item);
561
+ this.workArea.setActiveTab(item);
562
+ },
563
+
564
+ openIframeInTab : function( title, url ) {
565
+
566
+ var item = Ext.create('Ext.panel.Panel', {
567
+ iframeId:'themes_iframe',
568
+ closable: true,
569
+ layout: 'fit',
570
+ title: title,
571
+ html:'<iframe height="100%" width="100%" frameBorder="0" src="'+url+'"></iframe>'
509
572
  });
510
573
 
511
574
  this.workArea.add(item);
512
575
  this.workArea.setActiveTab(item);
513
576
  },
514
577
 
515
- editContent:function (title, id, content, siteId, contentType, contentGridStore) {
578
+ editContent: function (title, id, content, siteId, contentType, contentGridStore) {
516
579
  var self = this;
517
580
  var itemId = 'editContent-' + id;
518
581
  var item = this.workArea.query('#' + itemId).first();
519
582
 
520
583
  if (Compass.ErpApp.Utility.isBlank(item)) {
521
584
  var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor", {
522
- autoHeight:true,
585
+ autoHeight: true,
523
586
  //value:content,
524
- ckEditorConfig:{
525
- extraPlugins:'jwplayer,knitkitthemes',
526
- toolbar:self.ckEditorToolbar
587
+ ckEditorConfig: {
588
+ extraPlugins: self.ckEditorExtraPlugins,
589
+ toolbar: self.ckEditorToolbar
527
590
  },
528
- listeners:{
529
- save:function (comp, content) {
530
- self.saveContent(id, content, contentType, siteId);
591
+ listeners: {
592
+ save: function (comp, content) {
593
+ self.saveContent(id, comp, content, contentType, siteId);
531
594
  if (!Ext.isEmpty(contentGridStore)) contentGridStore.load();
595
+ },
596
+ ckeditordrop: function (ckeditorPanel, dropEvent) {
597
+ var dataTransfer = dropEvent.dataTransfer;
598
+ var files = dataTransfer.files;
599
+ for (var i = 0; i < files.length; i++) {
600
+ var loadMask = new Ext.LoadMask(ckeditorPanel, {msg:"Please wait..."});
601
+ loadMask.show();
602
+
603
+ var file = files[i];
604
+ var reader = new FileReader();
605
+
606
+ Compass.ErpApp.Utility.addEventHandler(reader, 'loadend', function (e, file) {
607
+ var bin = this.result;
608
+
609
+ Ext.Ajax.request({
610
+ headers: {'Content-Type': file.type},
611
+ url: '/knitkit/erp_app/desktop/image_assets/shared/upload_file',
612
+ jsonData: bin,
613
+ params:{
614
+ name: file.name,
615
+ directory: 'root_node',
616
+ is_drag_drop: true
617
+ },
618
+ success: function(result){
619
+ loadMask.hide();
620
+ resultObj = Ext.JSON.decode(result.responseText);
621
+ if(resultObj.success){
622
+ ckeditorPanel.insertHtml('<img src='+resultObj.url+' height="200" width="200" />');
623
+ var sharedImageAssetsDataView = self.up('#knitkit').down('knitkit_ImageAssetsPanel').sharedImageAssetsDataView,
624
+ sharedImageAssetsTreePanel = self.up('#knitkit').down('knitkit_ImageAssetsPanel').sharedImageAssetsTreePanel;
625
+
626
+ sharedImageAssetsDataView.getStore().load({
627
+ params:{
628
+ directory: sharedImageAssetsDataView.directory
629
+ }
630
+ });
631
+ sharedImageAssetsTreePanel.getStore().load({
632
+ callback:function(){
633
+ sharedImageAssetsTreePanel.getView().refresh();
634
+ }
635
+ });
636
+ }
637
+ else{
638
+ Ext.Msg.alert('Error', 'Could not upload image');
639
+ }
640
+ },
641
+ failure: function(result){
642
+ loadMask.hide();
643
+ Ext.Msg.alert('Error', 'Could not upload image');
644
+ }
645
+ });
646
+ }.bindToEventHandler(file));
647
+
648
+ reader.readAsDataURL(file);
649
+ }
532
650
  }
533
651
  }
534
652
  });
@@ -537,48 +655,50 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
537
655
 
538
656
  var items = [
539
657
  {
540
- xtype:'panel',
541
- layout:'fit',
542
- split:true,
543
- region:'center',
544
- items:ckEditor,
545
- autoDestroy:true
658
+ xtype: 'panel',
659
+ layout: 'fit',
660
+ split: true,
661
+ region: 'center',
662
+ items: ckEditor,
663
+ autoDestroy: true
546
664
  }
547
665
  ];
548
666
 
549
667
  if (!Compass.ErpApp.Utility.isBlank(siteId)) {
550
668
  items.push({
551
- xtype:'knitkit_versions' + contentType + 'gridpanel',
552
- contentId:id,
553
- region:'south',
554
- height:150,
555
- collapsible:true,
556
- centerRegion:self,
557
- siteId:siteId
669
+ xtype: 'knitkit_versions' + contentType + 'gridpanel',
670
+ contentId: id,
671
+ region: 'south',
672
+ height: 200,
673
+ collapsible: true,
674
+ collapsed: true,
675
+ centerRegion: self,
676
+ siteId: siteId
558
677
  });
559
678
  }
560
679
  else {
561
680
  items.push({
562
- xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
563
- contentId:id,
564
- region:'south',
565
- height:150,
566
- collapsible:true,
567
- centerRegion:self
681
+ xtype: 'knitkit_nonpublishedversionswebsitesectiongridpanel',
682
+ contentId: id,
683
+ region: 'south',
684
+ height: 200,
685
+ collapsible: true,
686
+ collapsed: true,
687
+ centerRegion: self
568
688
  });
569
689
  }
570
690
 
571
691
  item = Ext.create('Ext.panel.Panel', {
572
- xtype:'panel',
573
- layout:'border',
574
- title:title,
575
- itemId:itemId,
576
- closable:true,
577
- items:items,
578
- save:function (comp) {
692
+ xtype: 'panel',
693
+ layout: 'border',
694
+ title: title,
695
+ itemId: itemId,
696
+ closable: true,
697
+ items: items,
698
+ save: function (comp) {
579
699
  if (currentUser.hasCapability('edit_html', 'Content')) {
580
700
  var content = comp.down('ckeditor').getValue();
581
- self.saveContent(id, content, contentType, siteId);
701
+ self.saveContent(id, comp, content, contentType, siteId);
582
702
  if (contentGridStore) {
583
703
  contentGridStore.load();
584
704
  }
@@ -586,62 +706,51 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
586
706
  } else {
587
707
  currentUser.showInvalidAccess();
588
708
  }
589
- },
590
- listeners:{
591
- 'show':function (panel) {
592
- if (!Compass.ErpApp.Utility.isBlank(siteId)) {
593
- Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
594
- }
595
- }
596
709
  }
597
710
  });
598
-
599
711
  this.workArea.add(item);
600
712
  }
601
-
602
713
  this.workArea.setActiveTab(item);
603
714
  },
604
715
 
605
- /* comment */
606
-
607
- showComment:function (comment) {
716
+ showComment: function (comment) {
608
717
  var activeTab = this.workArea.getActiveTab();
609
718
  var cardPanel = activeTab.query('panel')[0];
610
719
  cardPanel.removeAll(true);
611
720
  cardPanel.add({
612
- xtype:'panel',
613
- html:comment
721
+ xtype: 'panel',
722
+ html: comment
614
723
  });
615
724
  cardPanel.getLayout().setActiveItem(0);
616
725
  },
617
726
 
618
- viewContentComments:function (contentId, title) {
727
+ viewContentComments: function (contentId, title) {
619
728
  var self = this;
620
729
  var itemId = 'contentComments-' + contentId;
621
730
  var item = this.workArea.query('#' + itemId).first();
622
731
 
623
732
  if (Compass.ErpApp.Utility.isBlank(item)) {
624
733
  item = Ext.create("Ext.panel.Panel", {
625
- layout:'border',
626
- itemId:itemId,
627
- title:title,
628
- closable:true,
629
- items:[
734
+ layout: 'border',
735
+ itemId: itemId,
736
+ title: title,
737
+ closable: true,
738
+ items: [
630
739
  {
631
- xtype:'panel',
632
- layout:'card',
633
- split:true,
634
- region:'center',
635
- items:[],
636
- autoDestroy:true
740
+ xtype: 'panel',
741
+ layout: 'card',
742
+ split: true,
743
+ region: 'center',
744
+ items: [],
745
+ autoDestroy: true
637
746
  },
638
747
  {
639
- xtype:'knitkit_commentsgridpanel',
640
- contentId:contentId,
641
- region:'south',
642
- height:300,
643
- collapsible:true,
644
- centerRegion:self
748
+ xtype: 'knitkit_commentsgridpanel',
749
+ contentId: contentId,
750
+ region: 'south',
751
+ height: 300,
752
+ collapsible: true,
753
+ centerRegion: self
645
754
  }
646
755
  ]
647
756
  });
@@ -651,40 +760,35 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
651
760
  this.workArea.setActiveTab(item);
652
761
  },
653
762
 
654
- viewWebsiteInquiries:function (websiteId, title) {
763
+ viewWebsiteInquiries: function (websiteId, title) {
655
764
  var self = this;
656
765
  var itemId = 'websiteInqueries-' + websiteId;
657
766
  var item = this.workArea.query('#' + itemId).first();
658
767
 
659
768
  if (Compass.ErpApp.Utility.isBlank(item)) {
660
769
  item = Ext.create("Ext.panel.Panel", {
661
- layout:'border',
662
- title:title + " Inquiries",
663
- itemId:itemId,
664
- closable:true,
665
- items:[
770
+ layout: 'border',
771
+ title: title + " Inquiries",
772
+ itemId: itemId,
773
+ closable: true,
774
+ items: [
666
775
  {
667
- xtype:'panel',
668
- layout:'card',
669
- split:true,
670
- region:'center',
671
- items:[],
672
- autoDestroy:true
776
+ xtype: 'panel',
777
+ layout: 'card',
778
+ split: true,
779
+ region: 'center',
780
+ items: [],
781
+ autoDestroy: true
673
782
  },
674
783
  {
675
- xtype:'knitkit_inquiriesgridpanel',
676
- websiteId:websiteId,
677
- region:'south',
678
- height:300,
679
- collapsible:true,
680
- centerRegion:self
681
- }
682
- ],
683
- listeners:{
684
- 'show':function (panel) {
685
- Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
784
+ xtype: 'knitkit_inquiriesgridpanel',
785
+ websiteId: websiteId,
786
+ region: 'south',
787
+ height: 300,
788
+ collapsible: true,
789
+ centerRegion: self
686
790
  }
687
- }
791
+ ]
688
792
  });
689
793
 
690
794
  this.workArea.add(item);
@@ -693,7 +797,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
693
797
  this.workArea.setActiveTab(item);
694
798
  },
695
799
 
696
- insertHtmlIntoActiveCkEditor:function (html) {
800
+ insertHtmlIntoActiveCkEditor: function (html) {
697
801
  var activeTab = this.workArea.getActiveTab();
698
802
  if (Compass.ErpApp.Utility.isBlank(activeTab)) {
699
803
  Ext.Msg.alert('Error', 'No editor');
@@ -709,7 +813,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
709
813
  return false;
710
814
  },
711
815
 
712
- replaceHtmlInActiveCkEditor:function (html) {
816
+ replaceHtmlInActiveCkEditor: function (html) {
713
817
  var activeTab = this.workArea.getActiveTab();
714
818
  if (Compass.ErpApp.Utility.isBlank(activeTab)) {
715
819
  Ext.Msg.alert('Error', 'No editor');
@@ -725,7 +829,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
725
829
  return false;
726
830
  },
727
831
 
728
- replaceContentInActiveCodeMirror:function (content) {
832
+ replaceContentInActiveCodeMirror: function (content) {
729
833
  var activeTab = this.workArea.getActiveTab();
730
834
  if (Compass.ErpApp.Utility.isBlank(activeTab)) {
731
835
  Ext.Msg.alert('Error', 'No editor');
@@ -741,7 +845,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
741
845
  return false;
742
846
  },
743
847
 
744
- addContentToActiveCodeMirror:function (content) {
848
+ addContentToActiveCodeMirror: function (content) {
745
849
  var activeTab = this.workArea.getActiveTab();
746
850
  if (Compass.ErpApp.Utility.isBlank(activeTab)) {
747
851
  Ext.Msg.alert('Error', 'No editor');
@@ -760,17 +864,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
760
864
  this.workArea.setActiveTab(item);
761
865
  },
762
866
 
763
- insertHtmlIntoActiveCkEditorOrCodemirror:function (html) {
867
+ insertHtmlIntoActiveCkEditorOrCodemirror: function (html) {
764
868
  var activeTab = this.workArea.getActiveTab();
765
869
  if (Compass.ErpApp.Utility.isBlank(activeTab)) {
766
870
  Ext.Msg.alert('Error', 'No editor');
767
871
  }
768
872
  else {
769
- if (activeTab.query('ckeditor').length > 0) {
770
- activeTab.query('ckeditor')[0].insertHtml(html);
873
+ if (activeTab.down('ckeditor')) {
874
+ activeTab.down('ckeditor').insertHtml(html);
771
875
  }
772
- else if (activeTab.query('codemirror').length > 0) {
773
- activeTab.query('codemirror')[0].insertContent(html);
876
+ else if (activeTab.down('codemirror')) {
877
+ activeTab.down('codemirror').insertContent(html);
774
878
  }
775
879
  else {
776
880
  Ext.Msg.alert('Error', 'No ckeditor or codemirror found');
@@ -779,14 +883,14 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
779
883
  return false;
780
884
  },
781
885
 
782
- saveCurrent:function () {
886
+ saveCurrent: function () {
783
887
  var activeTab = this.workArea.getActiveTab();
784
888
  if (!Ext.isEmpty(activeTab) && !Ext.isEmpty(activeTab.initialConfig.save)) {
785
889
  activeTab.initialConfig.save(activeTab);
786
890
  }
787
891
  },
788
892
 
789
- saveAll:function () {
893
+ saveAll: function () {
790
894
  this.workArea.items.each(function (comp) {
791
895
  if (!Ext.isEmpty(comp) && !Ext.isEmpty(comp.initialConfig.save)) {
792
896
  comp.initialConfig.save(comp);
@@ -794,28 +898,28 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
794
898
  });
795
899
  },
796
900
 
797
- constructor:function (config) {
901
+ constructor: function (config) {
798
902
  region = this;
799
903
  this.workArea = Ext.createWidget('tabpanel', {
800
- autoDestroy:true,
801
- region:'center',
802
- plugins:Ext.create('Ext.ux.TabCloseMenu', {
803
- extraItemsTail:[
904
+ autoDestroy: true,
905
+ region: 'center',
906
+ plugins: Ext.create('Ext.ux.TabCloseMenu', {
907
+ extraItemsTail: [
804
908
  '-',
805
909
  {
806
- text:'Closable',
807
- checked:true,
808
- hideOnClick:true,
809
- handler:function (item) {
910
+ text: 'Closable',
911
+ checked: true,
912
+ hideOnClick: true,
913
+ handler: function (item) {
810
914
  currentItem.tab.setClosable(item.checked);
811
915
  }
812
916
  }
813
917
  ],
814
- listeners:{
815
- aftermenu:function () {
918
+ listeners: {
919
+ aftermenu: function () {
816
920
  currentItem = null;
817
921
  },
818
- beforemenu:function (menu, item) {
922
+ beforemenu: function (menu, item) {
819
923
  var menuitem = menu.child('*[text="Closable"]');
820
924
  currentItem = item;
821
925
  menuitem.setChecked(item.closable);
@@ -823,16 +927,16 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
823
927
  }
824
928
  }),
825
929
  listeners: {
826
- add:function() {
930
+ add: function () {
827
931
  this.smartRenameTabs();
828
932
  },
829
- remove:function() {
933
+ remove: function () {
830
934
  this.smartRenameTabs();
831
935
  }
832
936
  },
833
937
 
834
938
  smartRenameTabs: function () {
835
- var tabs = this.queryBy(function(record) {
939
+ var tabs = this.queryBy(function (record) {
836
940
  // If no filePathHash is found, this item is not an actual tab element, don't collect it into tabs array
837
941
  if (record.filePathHash != undefined) {
838
942
  return true;
@@ -844,7 +948,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
844
948
  fileNames = {};
845
949
 
846
950
  // Collect counts for each unique baseName and fileName
847
- Ext.each(tabs, function(tab) {
951
+ Ext.each(tabs, function (tab) {
848
952
  if (!baseNames[tab.baseName]) {
849
953
  baseNames[tab.baseName] = 1;
850
954
  } else {
@@ -859,11 +963,11 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
859
963
  });
860
964
 
861
965
  // Rename each tab as needed
862
- Ext.each(tabs, function(tab) {
966
+ Ext.each(tabs, function (tab) {
863
967
  if (baseNames[tab.baseName] > 1) {
864
968
  // Duplicate fileName, use fileName + container directory in title
865
969
  if (fileNames[tab.fileName] > 1) {
866
- tab.setTitle(tab.fileName+" ("+tab.containerDir+")");
970
+ tab.setTitle(tab.fileName + " (" + tab.containerDir + ")");
867
971
  } else { // Duplicate baseName but unique fileName, use fileName for title
868
972
  tab.setTitle(tab.fileName);
869
973
  }
@@ -874,13 +978,20 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion", {
874
978
  }
875
979
  });
876
980
 
981
+ startupPanel = Ext.createWidget('knitkit_splash_screen', {
982
+ closable: true,
983
+ centerRegion: region
984
+ });
985
+ this.workArea.add(startupPanel);
986
+ this.workArea.setActiveTab(startupPanel);
987
+
877
988
  config = Ext.apply({
878
- id:'knitkitCenterRegion',
879
- autoDestroy:true,
880
- layout:'border',
881
- region:'center',
989
+ id: 'knitkitCenterRegion',
990
+ autoDestroy: true,
991
+ layout: 'border',
992
+ region: 'center',
882
993
  //split:true,
883
- items:[this.workArea]
994
+ items: [this.workArea]
884
995
  }, config);
885
996
 
886
997
  this.callParent([config]);