campbellhay-bureau 4.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/campbellhay-bureau.gemspec +14 -0
  4. data/gempush +8 -0
  5. data/lib/_static/_test.txt +1 -0
  6. data/lib/_static/css/main.css +586 -0
  7. data/lib/_static/css/plugin.asmselect.css +63 -0
  8. data/lib/_static/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
  9. data/lib/_static/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
  10. data/lib/_static/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png +0 -0
  11. data/lib/_static/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
  12. data/lib/_static/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
  13. data/lib/_static/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
  14. data/lib/_static/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
  15. data/lib/_static/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
  16. data/lib/_static/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
  17. data/lib/_static/css/ui-darkness/images/ui-icons_222222_256x240.png +0 -0
  18. data/lib/_static/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png +0 -0
  19. data/lib/_static/css/ui-darkness/images/ui-icons_a83300_256x240.png +0 -0
  20. data/lib/_static/css/ui-darkness/images/ui-icons_cccccc_256x240.png +0 -0
  21. data/lib/_static/css/ui-darkness/images/ui-icons_ffffff_256x240.png +0 -0
  22. data/lib/_static/css/ui-darkness/jquery-ui-1.9.1.custom.css +378 -0
  23. data/lib/_static/css/ui-darkness/jquery-ui-1.9.1.custom.min.css +5 -0
  24. data/lib/_static/img/backend_small_icons.png +0 -0
  25. data/lib/_static/img/btn.png +0 -0
  26. data/lib/_static/img/btn_old.png +0 -0
  27. data/lib/_static/img/file.png +0 -0
  28. data/lib/_static/img/handle.png +0 -0
  29. data/lib/_static/img/help/clone-button.png +0 -0
  30. data/lib/_static/img/help/create-button.png +0 -0
  31. data/lib/_static/img/help/delete-button.png +0 -0
  32. data/lib/_static/img/help/delete-warning.png +0 -0
  33. data/lib/_static/img/help/document.png +0 -0
  34. data/lib/_static/img/help/edit-button.png +0 -0
  35. data/lib/_static/img/help/form.png +0 -0
  36. data/lib/_static/img/help/image-dimensions.png +0 -0
  37. data/lib/_static/img/help/list.png +0 -0
  38. data/lib/_static/img/help/logout.png +0 -0
  39. data/lib/_static/img/help/move-button.png +0 -0
  40. data/lib/_static/img/help/overview.png +0 -0
  41. data/lib/_static/img/help/preview-button.png +0 -0
  42. data/lib/_static/img/help/relationships.png +0 -0
  43. data/lib/_static/img/help/reload-button.png +0 -0
  44. data/lib/_static/img/help/save-or-cancel.png +0 -0
  45. data/lib/_static/img/help/search.png +0 -0
  46. data/lib/_static/img/help/sub-section.png +0 -0
  47. data/lib/_static/img/help/x-list.png +0 -0
  48. data/lib/_static/img/placeholder.nutshell.jpg +0 -0
  49. data/lib/_static/img/placeholder.stash_thumb.gif +0 -0
  50. data/lib/_static/img/small-loader.gif +0 -0
  51. data/lib/_static/img/underwood_btn.png +0 -0
  52. data/lib/_static/js/addon.timepicker.js +20 -0
  53. data/lib/_static/js/jquery-ui-1.9.1.custom.js +8364 -0
  54. data/lib/_static/js/jquery-ui-1.9.1.custom.min.js +6 -0
  55. data/lib/_static/js/main.js +347 -0
  56. data/lib/_static/js/plugin.asmselect.js +407 -0
  57. data/lib/_static/js/plugin.form.js +23 -0
  58. data/lib/_static/js/plugin.mapolygon.js +3 -0
  59. data/lib/_static/js/plugin.quickmask.js +68 -0
  60. data/lib/_static/js/plugin.quicksearch.js +1 -0
  61. data/lib/_static/js/plugin.speechify.js +4 -0
  62. data/lib/_static/js/plugin.underwood.js +4 -0
  63. data/lib/_templates/_test.txt +1 -0
  64. data/lib/_templates/head.html +23 -0
  65. data/lib/_templates/help.html +104 -0
  66. data/lib/_templates/layout.html +13 -0
  67. data/lib/bureau/adapter.rb +114 -0
  68. data/lib/bureau.rb +122 -0
  69. data/lib/mongo_bureau.rb +214 -0
  70. data/lib/sequel_bureau_adapter.rb +188 -0
  71. data/test/spec_bureau.rb +123 -0
  72. data/test/spec_bureau_adapter.rb +71 -0
  73. metadata +126 -0
@@ -0,0 +1,347 @@
1
+ // What to do when a new nutshell is created
2
+ var new_nutshell_callback = function(s) {
3
+ // Hide delete/clone forms
4
+ $('.btn-delete, .btn-clone', s).prev().hide().find('input[name=_destination]').remove();
5
+ // Hide delete attachment forms
6
+ $('.deletable-image form', s).hide().after("<div class='btn-delete-attachment' title='Delete Attachment'></div>").find('input[name=_destination]').remove();
7
+ // Quick updates from nutshell
8
+ $('.nutshell *[name^=model]', s).change(function() {
9
+ var arr = $(this).attr('id').split('-');
10
+ var update_url = cms_path+'/'+arr[1]+'/'+arr[0]
11
+ $.ajax({
12
+ url: update_url,
13
+ data: $(this).parents('form').serialize(),
14
+ type: 'PUT'
15
+ });
16
+ });
17
+ // Scene selector
18
+ var selectable_scene = $('.mapolygon-me');
19
+ $('.nutshell', s).hover(function() {
20
+ var $this = $(this);
21
+ if ($this.data().sceneSelectorCoordinates!='' && selectable_scene.data().dots=='') selectable_scene.trigger('show.mapolygon', [$this.data().sceneSelectorCoordinates.split(',')]);
22
+ }, function() {
23
+ var $this = $(this);
24
+ if ($(this).data().sceneSelectorCoordinates!='' && selectable_scene.data().dots=='') selectable_scene.trigger('reset.mapolygon');
25
+ });
26
+ };
27
+
28
+ var new_nut_tree_callback = function(s) {
29
+ var $$ = $(s);
30
+
31
+ var search_opts = {
32
+ onAfter: function() {
33
+ if ($('.search input[type=search]', s).val()=='') {
34
+ $('.sortable-handle', s).show();
35
+ } else {
36
+ $('.sortable-handle', s).hide();
37
+ }
38
+ }
39
+ }
40
+ var qs = $('.search input[type=search]', s).quicksearch($$.find(".nutshell"), search_opts);
41
+ $$.data('quicksearch', qs);
42
+
43
+ // Drop from minilist
44
+ var tree = $('.nut-tree', s);
45
+ tree.droppable({
46
+ accept: '.minilist li',
47
+ drop: function( e, ui ) {
48
+ var id = ui.draggable.attr('id').substring(5);
49
+ var params_sample = ui.draggable.parents('.many-to-many-picker').attr('rel');
50
+ var params = params_sample + id;
51
+ var path = cms_path + '/' + this.id;
52
+ $.post(path, params, function() {
53
+ $$.trigger('reload_nut_tree.cms');
54
+ ui.draggable.css({opacity: 0.5});
55
+ //ui.draggable.addClass('selected');
56
+ });
57
+ }
58
+ });
59
+
60
+ // Sortable
61
+ $('.sortable', s).sortable({
62
+ stop: function() { $.ajax({
63
+ url: $(this).attr('rel'),
64
+ data: $(this).sortable('serialize'),
65
+ type: 'PUT'
66
+ });
67
+ },
68
+ items: '.nutshell',
69
+ handle:'.sortable-handle'
70
+ });
71
+
72
+ new_nutshell_callback(s);
73
+ };
74
+
75
+ // What to do when a new slide is pushed on the stack
76
+ var pushstack_callback = function(s, reloading) {
77
+ var $$ = $(s);
78
+
79
+ // Bind Return callbacks
80
+ // unless it's a reload
81
+ if (!reloading) {
82
+ $$
83
+ .bind('reload.cms', function() {
84
+ $$.find('.slide-inner').load($$.data('reload_path'), function() {
85
+ pushstack_callback(s,true);
86
+ $$.scrollTop($$.data('scrolltop'));
87
+ });
88
+ })
89
+ .bind('reload_nut_tree.cms', function() {
90
+ $.get($$.data('reload_path'), function(data) {
91
+ $$.find('.nut-tree').html($("<div>"+data+"</div>").find('.nut-tree').html());
92
+ new_nut_tree_callback(s);
93
+ $$.scrollTop($$.data('scrolltop'));
94
+ });
95
+ })
96
+ .bind('register_return.cms', function(e,launcher,cb) {
97
+ $$.data('cb',cb).data('cb_launcher',launcher).data('scrolltop', $$.scrollTop());
98
+ })
99
+ .bind('clean_return.cms', function() {
100
+ $$.removeData('cb').removeData('cb_launcher');
101
+ })
102
+ .bind('return.cms', function(e,data) {
103
+ $$.scrollTop($$.data('scrolltop'));
104
+ var cb = $$.data('cb');
105
+ var cb_launcher = $$.data('cb_launcher');
106
+ if (cb) cb($$,cb_launcher,data);
107
+ $$.trigger('clean_return.cms');
108
+ $$.removeData('scrolltop'); // Seperated because the cancel button should trigger the scrolltop
109
+ $$.data('quicksearch').cache();
110
+ });
111
+ }
112
+
113
+ // HTML EDITOR
114
+ // textarea tag needs to be specified because the iframe copy the class, so we need to avoid endless nesting
115
+ $('textarea.underwood_editor', s).underwood({sanitize: false}).hide();
116
+ $('textarea.underwood_editor_full', s).underwood({toolbar: 'title paragraph bold italic link mailto unlink image source', sanitize: false}).hide();
117
+ $('textarea.underwood_editor_no_title', s).underwood({toolbar: 'bold italic link mailto unlink source', sanitize: false}).hide();
118
+
119
+ // Permalink dropdowns
120
+ $('.permalink-dropdown', s).change(function() {
121
+ var $select = $(this);
122
+ $select.parent().find('input').val($select.val());
123
+ });
124
+
125
+ // Date/Time pickers
126
+ $('.datepicker', s).datepicker({dateFormat: 'yy-mm-dd'});
127
+ $('.timepicker', s).timepicker({showSecond: true,timeFormat: 'hh:mm:ss'});
128
+ $('.datetimepicker', s).datetimepicker({showSecond: true,dateFormat: 'yy-mm-dd',timeFormat: 'hh:mm:ss'});
129
+
130
+ // Multiple select with asmSelect
131
+ $(".asm-select", s).asmSelect({ sortable: true });
132
+
133
+ // Back btn
134
+ if ($$.is('.inserted-slide')) {
135
+ // var commands = $$.find('.nut-tree-commands');
136
+ // if (commands.size()>0) {
137
+ // commands.prepend("<a class='pop-stack btn btn-back' href='javascript:;' title='Back'></a>");
138
+ // } else {
139
+ // $$.find('.slide-inner').prepend("<div class='nut-tree-commands'><a class='pop-stack btn btn-back cancel' href='javascript:;' title='Back'></a></div>");
140
+ // }
141
+ $$.find('.slide-inner').prepend("<a class='pop-stack top-pop-stack' href='javascript:;'>"+ $$.prev().find('.slide-title > span').text() +"<span>go back up<span class='btn btn-back'></span></span></a>");
142
+ }
143
+
144
+ // Reload btn
145
+ $('.btn-reload', s).click(function() {
146
+ $$.trigger('reload.cms');
147
+ return false;
148
+ });
149
+
150
+ // JS Search
151
+ $('.search :submit', s).hide();
152
+ $('.search', s).submit(function() { return false; });
153
+
154
+ // Minilist
155
+ $('.many-to-many-picker .minilist-wrapper', s).frise()
156
+ .bind('fix_width.cms', function() {
157
+ var $this = $(this);
158
+ var ul = $this.children(':first');
159
+ var elts = $this.find('li:visible');
160
+ var elt = ul.children(':first');
161
+ var gutter = parseInt(elt.css('margin-right'));
162
+ var w = elts.size() * elt.width() + elts.size() * gutter;
163
+ ul.width(w);
164
+ })
165
+ .trigger('fix_width.cms');
166
+ $('.many-to-many-picker .minilist-wrapper li', s).draggable({
167
+ appendTo: 'body',
168
+ //axis: "y",
169
+ revert: 'invalid', // when not dropped, the item will revert back to its initial position
170
+ helper: function(e) { return $("<div class='minilist-dragged'>"+$(this).html()+"</div>") },
171
+ cursor: "move"
172
+ });
173
+
174
+ //Minilist quicksearch
175
+ search_opts = {
176
+ onAfter: function() {
177
+ $('.many-to-many-picker .minilist-wrapper', s).trigger('fix_width.cms');
178
+ }
179
+ }
180
+ $('.minisearch', s).quicksearch($$.find(".minilist li"), search_opts);
181
+
182
+ // Scene selector
183
+ var selectable_scene = $('.mapolygon-me', s);
184
+ selectable_scene.mapolygon(function(data,img) {
185
+ if (data.length>0) $('.scene-selector-toolbar',s).fadeIn();
186
+ });
187
+ $('.reset-mapolygon', s).click(function() {
188
+ selectable_scene.trigger('reset.mapolygon');
189
+ $('.scene-selector-toolbar',s).fadeOut();
190
+ });
191
+ $('.save-mapolygon', s).click(function() {
192
+ this.href = this.href+selectable_scene.data().dots.join(',');
193
+ });
194
+
195
+ // Ajaxify forms
196
+ if ($$.is('.inserted-slide')) {
197
+ $$.find('input[name=_destination]').remove();
198
+ $f = $$.find(':submit').parents('form').not('.search');
199
+ $f.filter('.backend-form').has(':submit[value=SAVE]').append(" or <a href='javascript:;' class='pop-stack cancel'>CANCEL</a>");
200
+ $f.submit(function() { // Model form or search
201
+ var $form = $(this);
202
+ $form.find(':submit').prop('disabled',true).after("<img src='"+cms_path+"/_static/img/small-loader.gif' />");
203
+ $form.ajaxSubmit({
204
+ success: function(data) {
205
+ if (data=='OK' || !!data.match(/\bOK\b/i)) { // Success
206
+ console.log('data ok');
207
+ $slides.trigger('pop.cms', [data]);
208
+ } else {
209
+ console.log('data not ok');
210
+ $$.children().html(data);
211
+ // if ($form.is('.search')) {
212
+ // var url = $form.attr('action') + ($form.attr('action').indexOf('?')+1 ? '&' : '?') + $form.serialize();
213
+ // $$.data('reload_path', url);
214
+ // }
215
+ pushstack_callback($$);
216
+ }
217
+ }
218
+ });
219
+ return false;
220
+ });
221
+ }
222
+
223
+ new_nut_tree_callback(s);
224
+
225
+ // Custom
226
+ if (typeof custom_pushstack_callback == 'function') custom_pushstack_callback(s); // Write this method in order to add some custom editors
227
+ };
228
+
229
+ // Return callbacks
230
+ var form_callback = function(slide,launcher,data) {
231
+ var $slide = $(slide);
232
+ var $launcher = $(launcher);
233
+ var $data = $(data);
234
+ if ($launcher.is('.btn-edit')) {
235
+ $launcher.parents('.nutshell').before($data).remove();
236
+ } else {
237
+ $('.nut-tree', slide).prepend($data);
238
+ }
239
+ new_nutshell_callback($data);
240
+ //$data.hide().fadeIn('slow'); // Fucks the fact that scroll is getting to its prev position
241
+ };
242
+
243
+ var default_callback = function(slide,launcher,data) {
244
+ // Just reload the slide until a better callback is created
245
+ $(slide).trigger('reload.cms');
246
+ };
247
+
248
+ $(function() {
249
+
250
+ // Stack
251
+ $slides = $('#slides');
252
+ $slides
253
+ .bind('push.cms', function(e, data, url) {
254
+ var last = $("<div class='slide inserted-slide'><div class='slide-inner'>"+data+"</div></div>").appendTo($(this));
255
+ last.data('reload_path', url);
256
+ var previous = last.prev();
257
+ $slides.animate({top: -$(window).height()+'px'}, function() {
258
+ previous.hide();
259
+ $slides.css({top: '0px'});
260
+ pushstack_callback(last);
261
+ });
262
+ })
263
+ .bind('pop.cms', function(e, data) {
264
+ var last = $('.inserted-slide:last');
265
+ last.fadeOut('fast', function() {
266
+ var called = last.prev().show();
267
+ last.remove();
268
+ $slides.css({top: -$(window).height()+'px'});
269
+ $slides.animate({top: '0px'}, function() {
270
+ called.trigger('return.cms', [data]);
271
+ });
272
+ });
273
+ });
274
+
275
+ // Links pushing stack
276
+ $('a.push-stack').live('click', function(e) {
277
+ var cb = $(this).is('.sublist-link') ? default_callback : default_callback; // will change in time
278
+ $(this).parents('.slide').trigger('register_return.cms', [this,cb]);
279
+ var url = this.href.replace(/(_no_wrap=true|_destination=[^&]*)/g, '');
280
+ $.get(url, function(data) {
281
+ $slides.trigger('push.cms', [data, url]);
282
+ });
283
+ return false;
284
+ });
285
+
286
+ // Links Pop Stack without callback
287
+ $('.pop-stack').live('click', function() {
288
+ if ($(this).is('.cancel')) $(this).parents('.slide').prev().trigger('clean_return.cms');;
289
+ $slides.trigger('pop.cms');
290
+ return false;
291
+ });
292
+
293
+ // Ajax delete
294
+ $('.btn-delete').live('click', function() {
295
+ if (confirm('This action is irreversible. Are you sure you want to delete this entry ?')) {
296
+ var $btn = $(this);
297
+ var $form = $btn.prev();
298
+ $.ajax({
299
+ url: $form.attr('action'),
300
+ data: $form.serialize(),
301
+ type: 'DELETE',
302
+ success: function() { $btn.parents('.nutshell').fadeOut(function() { $(this).remove(); }); }
303
+ });
304
+ }
305
+ });
306
+
307
+ // Ajax delete attachment
308
+ $('.btn-delete-attachment').live('click', function() {
309
+ if (confirm('This action is irreversible. Are you sure you want to delete this attachment ?')) {
310
+ var $btn = $(this);
311
+ var $form = $btn.prev();
312
+ $.ajax({
313
+ url: $form.attr('action'),
314
+ data: $form.serialize(),
315
+ type: 'PUT',
316
+ success: function() { $btn.parents('.deletable-image').fadeOut(); }
317
+ });
318
+ }
319
+ });
320
+
321
+ // Ajax clone
322
+ $('.btn-clone').live('click', function() {
323
+ if (confirm('This will create a new entry with similar values. Do you want to proceed ?')) {
324
+ var $btn = $(this);
325
+ var $form = $btn.prev();
326
+ var $slide = $btn.parents('.slide')
327
+ $.post($form.attr('action'), $form.serialize(), function(data) {
328
+ if (data=='OK') {
329
+ $slide.trigger('reload.cms');
330
+ if ($btn.parents('.sortable').size()==0) $slide.animate({ scrollTop: $slide.height() });
331
+ }
332
+ });
333
+ }
334
+ });
335
+
336
+ pushstack_callback($('#content').data('reload_path', document.location.href));
337
+
338
+ // Tooltips
339
+ $.speechify({
340
+ backgroundColor: '#00ABC4',
341
+ color: 'black',
342
+ 'border-radius': '0px',
343
+ '-moz-border-radius': '0px',
344
+ '-webkit-border-radius': '0px',
345
+ '-webkit-box-shadow': '0px 0px 5px rgba(0,0,0,0.5)'
346
+ });
347
+ });