knitkit 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/GPL-3-LICENSE +674 -0
  2. data/README.md +6 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/knitkit/application.js +9 -0
  5. data/app/assets/stylesheets/knitkit/application.css +7 -0
  6. data/app/controllers/knitkit/articles_controller.rb +7 -0
  7. data/app/controllers/knitkit/base_controller.rb +45 -0
  8. data/app/controllers/knitkit/blogs_controller.rb +27 -0
  9. data/app/controllers/knitkit/comments_controller.rb +18 -0
  10. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +135 -0
  11. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +144 -0
  12. data/app/controllers/knitkit/erp_app/desktop/comments_controller.rb +43 -0
  13. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +27 -0
  14. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +145 -0
  15. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -0
  16. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +68 -0
  17. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +20 -0
  18. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +272 -0
  19. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +135 -0
  20. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +177 -0
  21. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +143 -0
  22. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +116 -0
  23. data/app/controllers/knitkit/unauthorized_controller.rb +8 -0
  24. data/app/controllers/knitkit/website_sections_controller.rb +17 -0
  25. data/app/helpers/application_helper.rb +132 -0
  26. data/app/models/article.rb +14 -0
  27. data/app/models/blog.rb +21 -0
  28. data/app/models/comment.rb +24 -0
  29. data/app/models/content.rb +158 -0
  30. data/app/models/extensions/user.rb +5 -0
  31. data/app/models/published_element.rb +9 -0
  32. data/app/models/published_website.rb +118 -0
  33. data/app/models/theme.rb +239 -0
  34. data/app/models/website.rb +457 -0
  35. data/app/models/website_host.rb +3 -0
  36. data/app/models/website_inquiry.rb +11 -0
  37. data/app/models/website_inquiry_mailer.rb +12 -0
  38. data/app/models/website_nav.rb +17 -0
  39. data/app/models/website_nav_item.rb +21 -0
  40. data/app/models/website_section.rb +152 -0
  41. data/app/models/website_section_content.rb +4 -0
  42. data/app/views/knitkit/articles/index.html.erb +3 -0
  43. data/app/views/knitkit/articles/show.html.erb +4 -0
  44. data/app/views/knitkit/blogs/_add_comment.html.erb +28 -0
  45. data/app/views/knitkit/blogs/_comment.html.erb +8 -0
  46. data/app/views/knitkit/blogs/index.html.erb +51 -0
  47. data/app/views/knitkit/blogs/index.rss.builder +23 -0
  48. data/app/views/knitkit/blogs/show.html.erb +22 -0
  49. data/app/views/knitkit/unauthorized/index.html.erb +4 -0
  50. data/app/views/knitkit/website_sections/index.html.erb +6 -0
  51. data/app/views/layouts/knitkit/base.html.erb +59 -0
  52. data/app/views/menus/knitkit/_default_menu.html.erb +23 -0
  53. data/app/views/menus/knitkit/_default_section_menu.html.erb +27 -0
  54. data/app/views/menus/knitkit/_default_sub_menu.html.erb +45 -0
  55. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +49 -0
  56. data/app/views/shared/knitkit/_bread_crumb.html.erb +7 -0
  57. data/app/views/shared/knitkit/_footer.html.erb +3 -0
  58. data/app/views/website_inquiry_mailer/inquiry.erb +3 -0
  59. data/app/widgets/contact_us/base.rb +86 -0
  60. data/app/widgets/contact_us/javascript/contact_us.js +13 -0
  61. data/app/widgets/contact_us/views/_contact_form.html.erb +36 -0
  62. data/app/widgets/contact_us/views/error.html.erb +10 -0
  63. data/app/widgets/contact_us/views/index.html.erb +1 -0
  64. data/app/widgets/contact_us/views/layouts/base.html.erb +7 -0
  65. data/app/widgets/contact_us/views/success.html.erb +4 -0
  66. data/app/widgets/google_map/base.rb +48 -0
  67. data/app/widgets/google_map/javascript/google_map.js +174 -0
  68. data/app/widgets/google_map/views/index.html.erb +41 -0
  69. data/app/widgets/login/base.rb +61 -0
  70. data/app/widgets/login/javascript/login.js +162 -0
  71. data/app/widgets/login/views/index.html.erb +37 -0
  72. data/app/widgets/login/views/layouts/base.html.erb +14 -0
  73. data/app/widgets/login/views/login_header.html.erb +9 -0
  74. data/app/widgets/login/views/reset_password.html.erb +26 -0
  75. data/app/widgets/manage_profile/base.rb +327 -0
  76. data/app/widgets/manage_profile/javascript/manage_profile.js +11 -0
  77. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +180 -0
  78. data/app/widgets/manage_profile/views/_password_form.html.erb +20 -0
  79. data/app/widgets/manage_profile/views/_user_information_form.html.erb +30 -0
  80. data/app/widgets/manage_profile/views/contact_type_in_use.html.erb +4 -0
  81. data/app/widgets/manage_profile/views/default_type_error.html.erb +5 -0
  82. data/app/widgets/manage_profile/views/error.html.erb +3 -0
  83. data/app/widgets/manage_profile/views/index.html.erb +46 -0
  84. data/app/widgets/manage_profile/views/layouts/base.html.erb +1 -0
  85. data/app/widgets/manage_profile/views/password_blank.html.erb +4 -0
  86. data/app/widgets/manage_profile/views/password_invalid.html.erb +4 -0
  87. data/app/widgets/manage_profile/views/password_success.html.erb +3 -0
  88. data/app/widgets/manage_profile/views/success.html.erb +3 -0
  89. data/app/widgets/reset_password/base.rb +42 -0
  90. data/app/widgets/reset_password/javascript/reset_password.js +13 -0
  91. data/app/widgets/reset_password/views/index.html.erb +31 -0
  92. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -0
  93. data/app/widgets/search/base.rb +80 -0
  94. data/app/widgets/search/javascript/search.js +31 -0
  95. data/app/widgets/search/views/_search.html.erb +39 -0
  96. data/app/widgets/search/views/index.html.erb +3 -0
  97. data/app/widgets/search/views/layouts/base.html.erb +24 -0
  98. data/app/widgets/search/views/show.html.erb +48 -0
  99. data/app/widgets/signup/base.rb +72 -0
  100. data/app/widgets/signup/javascript/signup.js +13 -0
  101. data/app/widgets/signup/views/_signup_form.html.erb +36 -0
  102. data/app/widgets/signup/views/error.html.erb +11 -0
  103. data/app/widgets/signup/views/index.html.erb +1 -0
  104. data/app/widgets/signup/views/layouts/base.html.erb +7 -0
  105. data/app/widgets/signup/views/success.html.erb +4 -0
  106. data/config/environment.rb +0 -0
  107. data/config/routes.rb +41 -0
  108. data/db/data_migrations/20110509223702_add_publisher_role.rb +11 -0
  109. data/db/data_migrations/20110816153456_add_knitkit_application.rb +31 -0
  110. data/db/data_migrations/upgrade/20111011203718_create_paths_for_sections.rb +13 -0
  111. data/db/data_migrations/upgrade/20111216192114_add_secured_models_to_menu_items.rb +18 -0
  112. data/db/data_migrations/upgrade/20111216202819_set_contents_iid_to_permalink_where_null.rb +12 -0
  113. data/db/migrate/20110211002317_setup_knitkit.rb +259 -0
  114. data/db/migrate/upgrade/20111014190442_update_contents.rb +25 -0
  115. data/db/migrate/upgrade/20111014201502_add_published_by_to_published_elements.rb +22 -0
  116. data/db/migrate/upgrade/20111017133851_add_iid_to_section.rb +21 -0
  117. data/db/migrate/upgrade/20111027145006_add_in_menu_to_section.rb +19 -0
  118. data/lib/knitkit.rb +12 -0
  119. data/lib/knitkit/engine.rb +26 -0
  120. data/lib/knitkit/extensions.rb +18 -0
  121. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +88 -0
  122. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +28 -0
  123. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +38 -0
  124. data/lib/knitkit/extensions/active_record/theme_support/has_many_themes.rb +34 -0
  125. data/lib/knitkit/extensions/compass/widgets/base.rb +53 -0
  126. data/lib/knitkit/extensions/core/array.rb +5 -0
  127. data/lib/knitkit/extensions/railties/action_view.rb +187 -0
  128. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +198 -0
  129. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +44 -0
  130. data/lib/knitkit/routing_filter/section_router.rb +55 -0
  131. data/lib/knitkit/syntax_validator.rb +32 -0
  132. data/lib/knitkit/version.rb +3 -0
  133. data/lib/tasks/knitkit_tasks.rake +4 -0
  134. data/public/images/knitkit/bullet.png +0 -0
  135. data/public/images/knitkit/content.png +0 -0
  136. data/public/images/knitkit/footer.png +0 -0
  137. data/public/images/knitkit/graphic.png +0 -0
  138. data/public/images/knitkit/greyFadeDown.png +0 -0
  139. data/public/images/knitkit/link.png +0 -0
  140. data/public/images/knitkit/logo.png +0 -0
  141. data/public/images/knitkit/menu.png +0 -0
  142. data/public/images/knitkit/menu_select.png +0 -0
  143. data/public/images/knitkit/search.png +0 -0
  144. data/public/javascripts/datepicker.js +440 -0
  145. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +473 -0
  146. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +576 -0
  147. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +217 -0
  148. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +26 -0
  149. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +109 -0
  150. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +30 -0
  151. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +160 -0
  152. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +46 -0
  153. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +46 -0
  154. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +92 -0
  155. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +220 -0
  156. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +613 -0
  157. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +573 -0
  158. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +664 -0
  159. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +2161 -0
  160. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +52 -0
  161. data/public/stylesheets/datepicker.css +121 -0
  162. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +114 -0
  163. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +219 -0
  164. data/public/stylesheets/knitkit/style.css +394 -0
  165. metadata +289 -0
@@ -0,0 +1,576 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.knitkit_centerregion',
4
+ ckEditorToolbar:[
5
+ ['Source','-','CompassSave','Preview','Print'],
6
+ ['Cut','Copy','Paste','PasteText','PasteFromWord'],
7
+ ['Undo','Redo'],
8
+ ['Find','Replace'],
9
+ ['SpellChecker','-','SelectAll'],
10
+ ['TextColor','BGColor'],
11
+ ['Bold','Italic','Underline','Strike'],
12
+ ['Subscript','Superscript','-','RemoveFormat'],
13
+ ['NumberedList','BulletedList'],
14
+ ['Outdent','Indent','Blockquote','CreateDiv'],
15
+ ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
16
+ ['BidiLtr','BidiRtl'],
17
+ ['Link','Unlink','Anchor'],
18
+ ['jwplayer','Flash','Table'],
19
+ ['HorizontalRule','SpecialChar','PageBreak'],
20
+ ['Styles','Format','Font','FontSize' ],
21
+ ['Maximize','ShowBlocks','-','About']
22
+ ],
23
+
24
+ setWindowStatus : function(status){
25
+ this.findParentByType('statuswindow').setStatus(status);
26
+ },
27
+
28
+ clearWindowStatus : function(){
29
+ this.findParentByType('statuswindow').clearStatus();
30
+ },
31
+
32
+ viewSectionLayout : function(title, template){
33
+ this.workArea.add({
34
+ title:title + ' - Layout',
35
+ disableToolbar:true,
36
+ xtype:'codemirror',
37
+ parser:'rhtml',
38
+ sourceCode:template,
39
+ closable:true
40
+ });
41
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
42
+ return false;
43
+ },
44
+
45
+ saveSectionLayout : function(sectionId, content){
46
+ var self = this;
47
+ this.setWindowStatus('Saving...');
48
+ var conn = new Ext.data.Connection();
49
+ conn.request({
50
+ url: '/knitkit/erp_app/desktop/section/save_layout',
51
+ method: 'POST',
52
+ params:{
53
+ id:sectionId,
54
+ content:content
55
+ },
56
+ success: function(response) {
57
+ self.clearWindowStatus();
58
+ var obj = Ext.decode(response.responseText);
59
+ if(obj.success){
60
+ var activeTab = self.workArea.getActiveTab();
61
+ activeTab.query('knitkit_versionswebsitesectiongridpanel')[0].store.load();
62
+ }
63
+ else{
64
+ Ext.Msg.alert('Error', obj.message);
65
+ }
66
+ },
67
+ failure: function(response) {
68
+ self.clearWindowStatus();
69
+ Ext.Msg.alert('Error', 'Error saving layout');
70
+ }
71
+ });
72
+ },
73
+
74
+ editSectionLayout : function(sectionName, websiteId, websiteSectionId, content, tbarItems){
75
+ var self = this;
76
+ var centerRegionLayout = Ext.create("Ext.panel.Panel",{
77
+ layout:'border',
78
+ title:sectionName,
79
+ closable:true,
80
+ items:[
81
+ {
82
+ title:sectionName + ' - Layout',
83
+ tbarItems:tbarItems,
84
+ xtype:'codemirror',
85
+ parser:'erb',
86
+ region:'center',
87
+ sourceCode:content,
88
+ closable:true,
89
+ listeners:{
90
+ 'save':function(codeMirror, content){
91
+ self.saveSectionLayout(websiteSectionId, content);
92
+ }
93
+ }
94
+ },
95
+ {
96
+ xtype:'knitkit_versionswebsitesectiongridpanel',
97
+ websiteSectionId:websiteSectionId,
98
+ region:'south',
99
+ height:300,
100
+ collapsible:true,
101
+ centerRegion:self,
102
+ siteId:websiteId
103
+ }
104
+ ],
105
+ listeners:{
106
+ 'show':function(panel){
107
+ Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
108
+ }
109
+ }
110
+ });
111
+
112
+ this.workArea.add(centerRegionLayout);
113
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
114
+ return false;
115
+ },
116
+
117
+ saveTemplateFile : function(path, content){
118
+ var self = this;
119
+ this.setWindowStatus('Saving...');
120
+ var conn = new Ext.data.Connection();
121
+ conn.request({
122
+ url: '/knitkit/erp_app/desktop/theme/update_file',
123
+ method: 'POST',
124
+ params:{
125
+ node:path,
126
+ content:content
127
+ },
128
+ success: function(response) {
129
+ var obj = Ext.decode(response.responseText);
130
+ self.clearWindowStatus();
131
+ if(!obj.success){
132
+ Ext.Msg.alert('Error', obj.message);
133
+ }
134
+ },
135
+ failure: function(response) {
136
+ self.clearWindowStatus();
137
+ Ext.Msg.alert('Error', 'Error saving contents');
138
+ }
139
+ });
140
+ },
141
+
142
+ editTemplateFile : function(node, content, tbarItems){
143
+ var self = this;
144
+ var file_name = node.data.id.split('/').pop().split('.')[0];
145
+ var fileType = node.data.id.split('.').pop();
146
+ this.workArea.add(
147
+ {
148
+ closable:true,
149
+ title:file_name,
150
+ xtype:'panel',
151
+ layout:'fit',
152
+ items:[{
153
+ tbarItems:tbarItems,
154
+ xtype:'codemirror',
155
+ parser:fileType,
156
+ sourceCode:content,
157
+ closable:true,
158
+ listeners:{
159
+ 'save':function(codeMirror, content){
160
+ self.saveTemplateFile(node.data.id, content);
161
+ }
162
+ }
163
+ }]
164
+ });
165
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
166
+ return false;
167
+ },
168
+
169
+ saveExcerpt : function(id, content){
170
+ var self = this;
171
+ this.setWindowStatus('Saving...');
172
+ var conn = new Ext.data.Connection();
173
+ conn.request({
174
+ url: '/knitkit/erp_app/desktop/content/save_excerpt',
175
+ method: 'POST',
176
+ params:{
177
+ id:id,
178
+ html:content
179
+ },
180
+ success: function(response) {
181
+ var obj = Ext.decode(response.responseText);
182
+ if(obj.success){
183
+ self.clearWindowStatus();
184
+ var activeTab = self.workArea.getActiveTab();
185
+ var panel = activeTab.query('knitkit_versionsbloggridpanel');
186
+ if(panel.length == 0){
187
+ panel = activeTab.query('knitkit_nonpublishedversionswebsitesectiongridpanel');
188
+ }
189
+ panel[0].getStore().load();
190
+ }
191
+ else{
192
+ Ext.Msg.alert('Error', 'Error saving excerpt');
193
+ self.clearWindowStatus();
194
+ }
195
+ },
196
+ failure: function(response) {
197
+ self.clearWindowStatus();
198
+ Ext.Msg.alert('Error', 'Error saving excerpt');
199
+ }
200
+ });
201
+ },
202
+
203
+ editExcerpt : function(title, id, content, siteId, contentGridStore){
204
+ var self = this;
205
+ var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
206
+ autoHeight:true,
207
+ value:content,
208
+ ckEditorConfig:{
209
+ extraPlugins:'compasssave,codemirror,jwplayer',
210
+ toolbar:self.ckEditorToolbar
211
+ },
212
+ listeners:{
213
+ 'save':function(ckEditor, content){
214
+ self.saveExcerpt(id, content);
215
+ contentGridStore.load();
216
+ }
217
+ }
218
+ });
219
+
220
+ var items = [ {
221
+ xtype:'panel',
222
+ layout:'fit',
223
+ split:true,
224
+ region:'center',
225
+ items:ckEditor,
226
+ autoDestroy:true
227
+ }];
228
+
229
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
230
+ items.push( {
231
+ xtype:'knitkit_versionsbloggridpanel',
232
+ contentId:id,
233
+ region:'south',
234
+ height:300,
235
+ collapsible:true,
236
+ centerRegion:self,
237
+ siteId:siteId
238
+ });
239
+ }
240
+ else{
241
+ items.push({
242
+ xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
243
+ contentId:id,
244
+ region:'south',
245
+ height:300,
246
+ collapsible:true,
247
+ centerRegion:self
248
+ });
249
+ }
250
+
251
+ var centerRegionLayout = Ext.create("Ext.panel.Panel",{
252
+ layout:'border',
253
+ title:title,
254
+ closable:true,
255
+ items:items,
256
+ listeners:{
257
+ 'show':function(panel){
258
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
259
+ Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
260
+ }
261
+ }
262
+ }
263
+ })
264
+
265
+ this.workArea.add(centerRegionLayout);
266
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
267
+ },
268
+
269
+ saveContent : function(id, content, contentType){
270
+ var self = this;
271
+ this.setWindowStatus('Saving...');
272
+ var conn = new Ext.data.Connection();
273
+ conn.request({
274
+ url: '/knitkit/erp_app/desktop/content/update',
275
+ method: 'POST',
276
+ params:{
277
+ id:id,
278
+ html:content
279
+ },
280
+ success: function(response) {
281
+ var obj = Ext.decode(response.responseText);
282
+ if(obj.success){
283
+ self.clearWindowStatus();
284
+ if(!Compass.ErpApp.Utility.isBlank(contentType)){
285
+ var activeTab = self.workArea.getActiveTab();
286
+ var panel = activeTab.query('knitkit_versions'+contentType+'gridpanel');
287
+ if(panel.length == 0){
288
+ panel = activeTab.query('knitkit_nonpublishedversionswebsitesectiongridpanel');
289
+ }
290
+ panel[0].getStore().load();
291
+ }
292
+ }
293
+ else{
294
+ Ext.Msg.alert('Error', 'Error saving contents');
295
+ self.clearWindowStatus();
296
+ }
297
+ },
298
+ failure: function(response) {
299
+ self.clearWindowStatus();
300
+ Ext.Msg.alert('Error', 'Error saving contents');
301
+ }
302
+ });
303
+ },
304
+
305
+ viewContent : function(title, content){
306
+ var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
307
+ autoHeight:true,
308
+ value:content,
309
+ ckEditorConfig:{
310
+ toolbar:[['Preview']]
311
+ }
312
+ });
313
+
314
+ this.workArea.add({
315
+ xtype:'panel',
316
+ closable:true,
317
+ layout:'fit',
318
+ title:title,
319
+ split:true,
320
+ items:ckEditor,
321
+ autoDestroy:true
322
+ });
323
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
324
+ },
325
+
326
+ editContent : function(title, id, content, siteId, contentType, contentGridStore){
327
+ var self = this;
328
+ var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
329
+ autoHeight:true,
330
+ //value:content,
331
+ ckEditorConfig:{
332
+ extraPlugins:'compasssave,codemirror,jwplayer',
333
+ toolbar:self.ckEditorToolbar
334
+ },
335
+ listeners:{
336
+ 'save':function(ckEditor, content){
337
+ self.saveContent(id, content, contentType);
338
+ contentGridStore.load();
339
+ }
340
+ }
341
+ });
342
+
343
+ ckEditor.setValue(content);
344
+
345
+ var items = [
346
+ {
347
+ xtype:'panel',
348
+ layout:'fit',
349
+ split:true,
350
+ region:'center',
351
+ items:ckEditor,
352
+ autoDestroy:true
353
+ }
354
+ ];
355
+
356
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
357
+ items.push({
358
+ xtype:'knitkit_versions'+contentType+'gridpanel',
359
+ contentId:id,
360
+ region:'south',
361
+ height:300,
362
+ collapsible:true,
363
+ centerRegion:self,
364
+ siteId:siteId
365
+ });
366
+ }
367
+ else{
368
+ items.push({
369
+ xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
370
+ contentId:id,
371
+ region:'south',
372
+ height:300,
373
+ collapsible:true,
374
+ centerRegion:self
375
+ });
376
+ }
377
+
378
+ var centerRegionLayout = Ext.create("Ext.panel.Panel",{
379
+ layout:'border',
380
+ title:title,
381
+ closable:true,
382
+ items:items,
383
+ listeners:{
384
+ 'show':function(panel){
385
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
386
+ Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
387
+ }
388
+ }
389
+ }
390
+ });
391
+
392
+ this.workArea.add(centerRegionLayout);
393
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
394
+ },
395
+
396
+ showComment : function(comment){
397
+ var activeTab = this.workArea.getActiveTab();
398
+ var cardPanel = activeTab.query('panel')[0];
399
+ cardPanel.removeAll(true);
400
+ cardPanel.add({
401
+ xtype:'panel',
402
+ html:comment
403
+ });
404
+ cardPanel.getLayout().setActiveItem(0);
405
+ },
406
+
407
+ viewContentComments : function(contentId, title){
408
+ var self = this;
409
+ var centerRegionLayout = Ext.create("Ext.panel.Panel",{
410
+ layout:'border',
411
+ title:title,
412
+ closable:true,
413
+ items:[
414
+ {
415
+ xtype:'panel',
416
+ layout:'card',
417
+ split:true,
418
+ region:'center',
419
+ items:[],
420
+ autoDestroy:true
421
+ },
422
+ {
423
+ xtype:'knitkit_commentsgridpanel',
424
+ contentId:contentId,
425
+ region:'south',
426
+ height:300,
427
+ collapsible:true,
428
+ centerRegion:self
429
+ }
430
+ ]
431
+ });
432
+
433
+ this.workArea.add(centerRegionLayout);
434
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
435
+ },
436
+
437
+ viewWebsiteInquiries : function(websiteId, title){
438
+ var self = this;
439
+ var centerRegionLayout = Ext.create("Ext.panel.Panel",{
440
+ layout:'border',
441
+ title:title + " Inquiries",
442
+ closable:true,
443
+ items:[
444
+ {
445
+ xtype:'panel',
446
+ layout:'card',
447
+ split:true,
448
+ region:'center',
449
+ items:[],
450
+ autoDestroy:true
451
+ },
452
+ {
453
+ xtype:'knitkit_inquiriesgridpanel',
454
+ websiteId:websiteId,
455
+ region:'south',
456
+ height:300,
457
+ collapsible:true,
458
+ centerRegion:self
459
+ }
460
+ ],
461
+ listeners:{
462
+ 'show':function(panel){
463
+ Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
464
+ }
465
+ }
466
+ });
467
+
468
+ this.workArea.add(centerRegionLayout);
469
+ this.workArea.setActiveTab(this.workArea.items.length - 1);
470
+ },
471
+
472
+ insertHtmlIntoActiveCkEditor : function(html){
473
+ var activeTab = this.workArea.getActiveTab();
474
+ if(Compass.ErpApp.Utility.isBlank(activeTab)){
475
+ Ext.Msg.alert('Error', 'No editor');
476
+ }
477
+ else{
478
+ if(activeTab.query('ckeditor').length == 0){
479
+ Ext.Msg.alert('Error', 'No ckeditor found');
480
+ }
481
+ else{
482
+ activeTab.query('ckeditor')[0].insertHtml(html);
483
+ }
484
+ }
485
+ return false;
486
+ },
487
+
488
+ replaceHtmlInActiveCkEditor : function(html){
489
+ var activeTab = this.workArea.getActiveTab();
490
+ if(Compass.ErpApp.Utility.isBlank(activeTab)){
491
+ Ext.Msg.alert('Error', 'No editor');
492
+ }
493
+ else{
494
+ if(activeTab.query('ckeditor').length == 0){
495
+ Ext.Msg.alert('Error', 'No ckeditor found');
496
+ }
497
+ else{
498
+ activeTab.query('ckeditor')[0].setValue(html);
499
+ }
500
+ }
501
+ return false;
502
+ },
503
+
504
+ replaceContentInActiveCodeMirror : function(content){
505
+ var activeTab = this.workArea.getActiveTab();
506
+ if(Compass.ErpApp.Utility.isBlank(activeTab)){
507
+ Ext.Msg.alert('Error', 'No editor');
508
+ }
509
+ else{
510
+ if(activeTab.query('codemirror').length == 0){
511
+ Ext.Msg.alert('Error', 'No codemirror found.');
512
+ }
513
+ else{
514
+ activeTab.query('codemirror')[0].setValue(content);
515
+ }
516
+ }
517
+ return false;
518
+ },
519
+
520
+ addContentToActiveCodeMirror : function(content){
521
+ var activeTab = this.workArea.getActiveTab();
522
+ if(Compass.ErpApp.Utility.isBlank(activeTab)){
523
+ Ext.Msg.alert('Error', 'No editor');
524
+ }
525
+ else{
526
+ if(activeTab.query('codemirror').length == 0){
527
+ Ext.Msg.alert('Error', 'No codemirror found. Note that a widget can only be added to a Layout.');
528
+ }
529
+ else{
530
+ activeTab.query('codemirror')[0].insertContent(content);
531
+ }
532
+ }
533
+ return false;
534
+ },
535
+
536
+ constructor : function(config) {
537
+ this.workArea = Ext.createWidget('tabpanel', {
538
+ autoDestroy:true,
539
+ region:'center',
540
+ plugins: Ext.create('Ext.ux.TabCloseMenu', {
541
+ extraItemsTail: [
542
+ '-',
543
+ {
544
+ text: 'Closable',
545
+ checked: true,
546
+ hideOnClick: true,
547
+ handler: function (item) {
548
+ currentItem.tab.setClosable(item.checked);
549
+ }
550
+ }
551
+ ],
552
+ listeners: {
553
+ aftermenu: function () {
554
+ currentItem = null;
555
+ },
556
+ beforemenu: function (menu, item) {
557
+ var menuitem = menu.child('*[text="Closable"]');
558
+ currentItem = item;
559
+ menuitem.setChecked(item.closable);
560
+ }
561
+ }
562
+ })
563
+ });
564
+
565
+ config = Ext.apply({
566
+ id:'knitkitCenterRegion',
567
+ autoDestroy:true,
568
+ layout:'border',
569
+ region:'center',
570
+ split:true,
571
+ items:[this.workArea]
572
+ }, config);
573
+
574
+ this.callParent([config]);
575
+ }
576
+ });