caboose-cms 0.9.206 → 0.9.207
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.
- checksums.yaml +4 -4
- data/app/assets/images/caboose/loading2.gif +0 -0
- data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +4 -3
- data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +50 -46
- data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +52 -20
- data/app/assets/javascripts/caboose/block_modal_controllers/richtext_modal_controller.js +69 -2
- data/app/assets/javascripts/caboose/modal_controller.js +6 -54
- data/app/assets/javascripts/caboose/sidebar_controller.js +168 -0
- data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +4 -4
- data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +395 -44
- data/app/assets/stylesheets/caboose/login.scss +2 -2
- data/app/assets/stylesheets/caboose/modal_inline.css +6 -5
- data/app/assets/stylesheets/caboose/model_binder.css +1 -1
- data/app/controllers/caboose/sites_controller.rb +1 -1
- data/app/views/caboose/blocks/_image.html.erb +2 -0
- data/app/views/caboose/pages/_new_block_header.html.erb +1 -1
- data/app/views/caboose/pages/admin_edit_content.html.erb +1 -1
- data/app/views/caboose/posts/admin_edit_content.html.erb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 164718e4e30d7a328c496fc83ebff196f2d74afa53c0da98a43f536f84c2c603
         | 
| 4 | 
            +
              data.tar.gz: 9860eac7fd81fdbcd8b1b9712124878b31d304df77a8f0d5d4b0d85ea266b1dd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 007fa4d435cf6895275f1a4853f2572ec0e035e25f69721945707027cdf5c6df70ff77ed9920f2ea55d25b03b81549f704ba8179a775b4c4d4717423ad8b6aa1
         | 
| 7 | 
            +
              data.tar.gz: fe881dd9e3bba7240e926f5e3f9c80478fb40288b2b0ec3cbf49993186237a1b250869d4b853f5c16848b6aba7c69a6c3f548011be81bb791115fafbde6619e2
         | 
| Binary file | 
| @@ -144,14 +144,14 @@ BlockContentController.prototype = { | |
| 144 144 |  | 
| 145 145 | 
             
              render_block: function(block_id) {
         | 
| 146 146 | 
             
                var that = this;
         | 
| 147 | 
            -
              //  console.log("rendering block " + block_id + "...");
         | 
| 147 | 
            +
              //  console.log("rendering block " + block_id + "..."); 
         | 
| 148 148 | 
             
                var url = that.base_url() + '/' + block_id + '/render';
         | 
| 149 149 | 
             
                that.is_modified();
         | 
| 150 150 | 
             
                $.ajax({
         | 
| 151 151 | 
             
                  url: url,
         | 
| 152 152 | 
             
                  type: 'get',
         | 
| 153 153 | 
             
                  success: function(html) {
         | 
| 154 | 
            -
                    $('#block_' + block_id).replaceWith(html);
         | 
| 154 | 
            +
                    $('body .container #block_' + block_id).replaceWith(html);
         | 
| 155 155 | 
             
                    that.is_loading(false, 'Loading...');
         | 
| 156 156 | 
             
                    that.add_dropzones();
         | 
| 157 157 | 
             
                    that.init_inline_editor();
         | 
| @@ -299,6 +299,7 @@ BlockContentController.prototype = { | |
| 299 299 | 
             
                  that.selected_block_ids = [];
         | 
| 300 300 | 
             
                  that.add_dropzones();
         | 
| 301 301 | 
             
                  that.is_modified();
         | 
| 302 | 
            +
                  that.mc.close();
         | 
| 302 303 | 
             
                }
         | 
| 303 304 | 
             
              },
         | 
| 304 305 |  | 
| @@ -436,7 +437,7 @@ BlockContentController.prototype = { | |
| 436 437 | 
             
                    }
         | 
| 437 438 | 
             
                  }
         | 
| 438 439 |  | 
| 439 | 
            -
                  if ( !$(v).hasClass('header') && !$(v).hasClass('content_wrapper') && !$(v).hasClass('footer') && !$(v).hasClass('header-wrapper') && !$(v).hasClass('footer-wrapper') ) {
         | 
| 440 | 
            +
                  if ( !$(v).hasClass('header') && !$(v).parent().hasClass('header-wrapper') && $(v).closest("#modal_content").length == 0 && !$(v).hasClass('content_wrapper') && !$(v).hasClass('footer') && !$(v).hasClass('header-wrapper') && !$(v).hasClass('footer-wrapper') ) {
         | 
| 440 441 | 
             
                    $(v).draggable( {
         | 
| 441 442 | 
             
                      handle: ".drag_handle",
         | 
| 442 443 | 
             
                      revert: "invalid",
         | 
| @@ -92,7 +92,7 @@ var BlockModalController = ModalController.extend({ | |
| 92 92 | 
             
                    $.each(that.block.children, function(i, b) {
         | 
| 93 93 | 
             
                      if (separate_children && b.block_type.id == separate_child_id) return;                    
         | 
| 94 94 | 
             
                      var div_id = 'block_' + b.id + (that.complex_field_types.indexOf(b.block_type.field_type) == -1 ? '_value' : '');
         | 
| 95 | 
            -
                      div.append($('<div/>'). | 
| 95 | 
            +
                      div.append($('<div/>').append($('<div/>').attr('id', div_id)));                                
         | 
| 96 96 | 
             
                    });
         | 
| 97 97 | 
             
                    if (separate_children)
         | 
| 98 98 | 
             
                    {
         | 
| @@ -101,7 +101,7 @@ var BlockModalController = ModalController.extend({ | |
| 101 101 | 
             
                        if (b.block_type.id == separate_child_id)
         | 
| 102 102 | 
             
                        {
         | 
| 103 103 | 
             
                          var div_id = 'block_' + b.id + (that.complex_field_types.indexOf(b.block_type.field_type) == -1 ? '_value' : '');
         | 
| 104 | 
            -
                          div.append($('<div/>'). | 
| 104 | 
            +
                          div.append($('<div/>').append($('<div/>').attr('id', div_id)));
         | 
| 105 105 | 
             
                        }             
         | 
| 106 106 | 
             
                      });
         | 
| 107 107 | 
             
                    }    
         | 
| @@ -110,7 +110,7 @@ var BlockModalController = ModalController.extend({ | |
| 110 110 | 
             
                  {
         | 
| 111 111 | 
             
                    div.append($('<p/>').append("This block doesn't have any content yet."));
         | 
| 112 112 | 
             
                  }
         | 
| 113 | 
            -
                  if (that.block.block_type.allow_child_blocks)
         | 
| 113 | 
            +
                  if (that.block.block_type.allow_child_blocks && that.block.block_type.default_child_block_type_id)
         | 
| 114 114 | 
             
                  {        
         | 
| 115 115 | 
             
                    div.append($('<p/>').css('clear', 'both').append($('<a/>').addClass('caboose-btn').attr('href', '#').html(that.add_child_link_text ? that.add_child_link_text : "Add a child block!").click(function(e) {
         | 
| 116 116 | 
             
                      e.preventDefault();
         | 
| @@ -120,7 +120,7 @@ var BlockModalController = ModalController.extend({ | |
| 120 120 | 
             
                }
         | 
| 121 121 | 
             
                $('#modal_content').replaceWith(div);
         | 
| 122 122 | 
             
                that.render_child_blocks();
         | 
| 123 | 
            -
                that.autosize();
         | 
| 123 | 
            +
                //that.autosize();
         | 
| 124 124 | 
             
              },
         | 
| 125 125 |  | 
| 126 126 | 
             
              print_controls: function()
         | 
| @@ -135,7 +135,7 @@ var BlockModalController = ModalController.extend({ | |
| 135 135 | 
             
                }
         | 
| 136 136 | 
             
                p.append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Move Up'   ).click(function() { that.move_up();         })).append(' ');
         | 
| 137 137 | 
             
                p.append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Move Down' ).click(function() { that.move_down();       })).append(' ');    
         | 
| 138 | 
            -
                p.append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Advanced'  ).attr('id', 'btn_advanced').click(function() { that.print_advanced();  }));
         | 
| 138 | 
            +
                //p.append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Advanced'  ).attr('id', 'btn_advanced').click(function() { that.print_advanced();  }));
         | 
| 139 139 | 
             
                $('#modal_controls').empty().append(p);    
         | 
| 140 140 | 
             
              },
         | 
| 141 141 |  | 
| @@ -163,40 +163,40 @@ var BlockModalController = ModalController.extend({ | |
| 163 163 | 
             
              before_print_advanced: false,
         | 
| 164 164 | 
             
              print_advanced: function()
         | 
| 165 165 | 
             
              {
         | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 166 | 
            +
            //     var that = this;        
         | 
| 167 | 
            +
            //     if (that.before_print_advanced) that.before_print_advanced();
         | 
| 168 168 |  | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 169 | 
            +
            //     var b = that.block;    
         | 
| 170 | 
            +
            //     $('#modal_content').empty()      
         | 
| 171 | 
            +
            //  //     .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_block_type_id' )))
         | 
| 172 | 
            +
            //  //     .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_parent_id'     )))
         | 
| 173 | 
            +
            //       .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_constrain'     )))
         | 
| 174 | 
            +
            //       .append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_full_width'    )))      
         | 
| 175 | 
            +
            //     $('#modal_controls').empty()
         | 
| 176 | 
            +
            //       .append($('<p/>')
         | 
| 177 | 
            +
            //         .append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() { 
         | 
| 178 | 
            +
            //           that.close();
         | 
| 179 | 
            +
            //           that.parent_controller.render_blocks(); 
         | 
| 180 | 
            +
            //         })).append(' ')                              
         | 
| 181 | 
            +
            //         .append($('<input/>').attr('type', 'button').addClass('btn').val('Back' ).click(function() { 
         | 
| 182 | 
            +
            //           that.print_content();
         | 
| 183 | 
            +
            //           that.print_controls();          
         | 
| 184 | 
            +
            //         }))
         | 
| 185 | 
            +
            //       );
         | 
| 186 186 |  | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
            //        { name: 'block_type_id' , nice_name: 'Block type' , type: 'select'   , value: b.block_type.id         , text: b.block_type.name              , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.block_type.id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }, options_url: '/admin/block-types/options' },
         | 
| 194 | 
            -
            //        { name: 'parent_id'     , nice_name: 'Parent ID'  , type: 'select'   , value: b.parent_id             , text: b.parent ? b.parent.title : '' , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.parent_id     = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }, options_url: '/admin/' + (that.page_id ? 'pages/' + that.page_id : 'posts/' + that.post_id) + '/parentblock-options?block_id=' + b.id },
         | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 187 | 
            +
            //     var m = new ModelBinder({
         | 
| 188 | 
            +
            //       name: 'Block',
         | 
| 189 | 
            +
            //       id: b.id,
         | 
| 190 | 
            +
            //       update_url: that.block_url(b),      
         | 
| 191 | 
            +
            //       authenticity_token: that.authenticity_token,
         | 
| 192 | 
            +
            //       attributes: [
         | 
| 193 | 
            +
            // //        { name: 'block_type_id' , nice_name: 'Block type' , type: 'select'   , value: b.block_type.id         , text: b.block_type.name              , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.block_type.id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }, options_url: '/admin/block-types/options' },
         | 
| 194 | 
            +
            // //        { name: 'parent_id'     , nice_name: 'Parent ID'  , type: 'select'   , value: b.parent_id             , text: b.parent ? b.parent.title : '' , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.parent_id     = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }, options_url: '/admin/' + (that.page_id ? 'pages/' + that.page_id : 'posts/' + that.post_id) + '/parentblock-options?block_id=' + b.id },
         | 
| 195 | 
            +
            //         { name: 'constrain'     , nice_name: 'Constrain'  , type: 'checkbox' , value: b.constrain     ? 1 : 0 ,                                        width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.constrain     = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
         | 
| 196 | 
            +
            //         { name: 'full_width'    , nice_name: 'Full Width' , type: 'checkbox' , value: b.full_width    ? 1 : 0 ,                                        width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.full_width    = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }}
         | 
| 197 | 
            +
            //       ]
         | 
| 198 | 
            +
            //     });
         | 
| 199 | 
            +
            //     that.autosize();
         | 
| 200 200 | 
             
              },
         | 
| 201 201 |  | 
| 202 202 | 
             
              /*****************************************************************************
         | 
| @@ -214,7 +214,13 @@ var BlockModalController = ModalController.extend({ | |
| 214 214 | 
             
              render_child_block: function(b)
         | 
| 215 215 | 
             
              {
         | 
| 216 216 | 
             
                var that = this;
         | 
| 217 | 
            -
                if ( | 
| 217 | 
            +
                if ( b.block_type.field_type == 'richtext' ) {
         | 
| 218 | 
            +
                  var html = "<span id='block_" + b.id + "' class='caboose-btn'>Edit " + b.block_type.description + "</span>";
         | 
| 219 | 
            +
                  $('#the_modal #block_' + b.id).replaceWith(html);
         | 
| 220 | 
            +
                  var b2 = that.block_with_id(b.id);
         | 
| 221 | 
            +
                  that.set_clickable(b2);
         | 
| 222 | 
            +
                }
         | 
| 223 | 
            +
                else if (that.complex_field_types.indexOf(b.block_type.field_type) > -1)
         | 
| 218 224 | 
             
                {
         | 
| 219 225 | 
             
                  if (!b.rendered_value)
         | 
| 220 226 | 
             
                  {
         | 
| @@ -226,7 +232,7 @@ var BlockModalController = ModalController.extend({ | |
| 226 232 | 
             
                        var b2 = that.block_with_id(b.id);            
         | 
| 227 233 | 
             
                        b2.rendered_value = html;
         | 
| 228 234 | 
             
                        that.set_clickable(b2);                            
         | 
| 229 | 
            -
                        that.autosize();
         | 
| 235 | 
            +
                        //that.autosize();
         | 
| 230 236 | 
             
                      },            
         | 
| 231 237 | 
             
                    });
         | 
| 232 238 | 
             
                  }
         | 
| @@ -280,7 +286,6 @@ var BlockModalController = ModalController.extend({ | |
| 280 286 |  | 
| 281 287 | 
             
              remove_media: function(block) {
         | 
| 282 288 | 
             
                var that = this;
         | 
| 283 | 
            -
             | 
| 284 289 | 
             
                $.ajax({          
         | 
| 285 290 | 
             
                  url: that.block_url(block) + '/remove-media',
         | 
| 286 291 | 
             
                  type: 'put',
         | 
| @@ -292,7 +297,6 @@ var BlockModalController = ModalController.extend({ | |
| 292 297 | 
             
                    that.autosize();
         | 
| 293 298 | 
             
                  },            
         | 
| 294 299 | 
             
                });
         | 
| 295 | 
            -
             | 
| 296 300 | 
             
              },
         | 
| 297 301 |  | 
| 298 302 | 
             
              set_clickable: function(b)
         | 
| @@ -307,14 +311,14 @@ var BlockModalController = ModalController.extend({ | |
| 307 311 | 
             
                }
         | 
| 308 312 |  | 
| 309 313 | 
             
                $('#the_modal #block_' + b.id).attr('onclick','').unbind('click');
         | 
| 310 | 
            -
                $('#the_modal #block_' + b.id).click(function(e) { | 
| 314 | 
            +
                $('#the_modal #block_' + b.id).click(function(e) {    
         | 
| 311 315 | 
             
                  e.stopPropagation();
         | 
| 312 316 | 
             
                  that.parent_controller.edit_block(b.id); 
         | 
| 313 317 | 
             
                });
         | 
| 314 318 |  | 
| 315 319 | 
             
                if ( b.block_type && b.block_type.field_type == 'image' && b.rendered_value.indexOf('select_image.png') < 0 ) {
         | 
| 316 | 
            -
                  btn = $('<a href="#" class="caboose-btn">Remove</a>');
         | 
| 317 | 
            -
                  btn.css('position','absolute').css('left','100%').css('left','calc(100% + 10px)').css('bottom','0').css('font-size','13px');
         | 
| 320 | 
            +
                  btn = $('<a href="#" class="caboose-btn remove">Remove Image</a>');
         | 
| 321 | 
            +
                  //btn.css('position','absolute').css('left','100%').css('left','calc(100% + 10px)').css('bottom','0').css('font-size','13px');
         | 
| 318 322 | 
             
                  btn.on('click', function(e) {
         | 
| 319 323 | 
             
                    e.preventDefault();
         | 
| 320 324 | 
             
                    that.remove_media(b);
         | 
| @@ -323,8 +327,8 @@ var BlockModalController = ModalController.extend({ | |
| 323 327 | 
             
                }
         | 
| 324 328 |  | 
| 325 329 | 
             
                if ( b.block_type && b.block_type.field_type == 'file' && b.rendered_value.indexOf('Click to select a file') < 0 ) {
         | 
| 326 | 
            -
                  btn = $('<a href="#" class="caboose-btn">Remove</a>');
         | 
| 327 | 
            -
                  btn.css('margin-bottom','10px').css('font-size','13px');
         | 
| 330 | 
            +
                  btn = $('<a href="#" class="caboose-btn remove">Remove File</a>');
         | 
| 331 | 
            +
                  //btn.css('margin-bottom','10px').css('font-size','13px');
         | 
| 328 332 | 
             
                  btn.on('click', function(e) {
         | 
| 329 333 | 
             
                    e.preventDefault();
         | 
| 330 334 | 
             
                    that.remove_media(b);
         | 
| @@ -10,12 +10,15 @@ var MediaModalController = BlockModalController.extend({ | |
| 10 10 | 
             
            	aws_access_key_id: false,		
         | 
| 11 11 | 
             
            	policy: false,
         | 
| 12 12 | 
             
            	signature: false,
         | 
| 13 | 
            -
            	refresh_unprocessed_images: false, | 
| 13 | 
            +
            	refresh_unprocessed_images: false,
         | 
| 14 | 
            +
              last_upload_processed: false,       
         | 
| 14 15 | 
             
            	selected_media: false,
         | 
| 15 16 | 
             
            	uploader: false,  
         | 
| 16 17 | 
             
              assets_path: false,
         | 
| 17 18 | 
             
              upload_extensions: "jpg,jpeg,png,gif,tif,tiff,pdf,doc,docx,odt,odp,ods,ppt,pptx,xls,xlsx,zip,tgz,csv,txt",
         | 
| 18 19 | 
             
              file_view: 'thumbnail',
         | 
| 20 | 
            +
              ajax_count: 0,
         | 
| 21 | 
            +
              ajax_limit: 20,
         | 
| 19 22 |  | 
| 20 23 | 
             
              assets_to_include: function()
         | 
| 21 24 | 
             
              {
         | 
| @@ -127,10 +130,10 @@ var MediaModalController = BlockModalController.extend({ | |
| 127 130 | 
             
                var div = $('<div/>').attr('id', 'top_controls')
         | 
| 128 131 | 
             
                  .append($('<p/>')
         | 
| 129 132 | 
             
                    //.append(select).append(' | ')
         | 
| 130 | 
            -
                    .append($('<select/>').attr('id', 'categories')) | 
| 131 | 
            -
                     | 
| 132 | 
            -
                    .append($('<a/>').attr('href', '#').html('Upload | 
| 133 | 
            -
                    .append($('<a/>').attr('href', '#').html(that.file_view == 'list' ? ' | 
| 133 | 
            +
                    .append($('<select/>').attr('id', 'categories'))//.append(' | ')        
         | 
| 134 | 
            +
                    //.append($('<a/>').attr('href', '#').html('New Category'                                                 ).click(function(e) { e.preventDefault(); that.add_category();     }))// .append(' | ')              
         | 
| 135 | 
            +
                    .append($('<a/>').attr('href', '#').html('Upload'                                      ).click(function(e) { e.preventDefault(); that.toggle_uploader();  }))// .append(' | ')
         | 
| 136 | 
            +
                    .append($('<a/>').attr('href', '#').html(that.file_view == 'list' ? 'Thumbnails' : 'List' ).click(function(e) { e.preventDefault(); that.toggle_file_view(); $(this).html( that.file_view == 'thumbnail' ? 'List' : 'Thumbnails'  ); }))// .append(' | ')
         | 
| 134 137 | 
             
                    .append($('<a/>').attr('href', '#').html('Alphabetize'                                      ).click(function(e) { e.preventDefault(); that.alphabetize_media();  }))
         | 
| 135 138 | 
             
                  )
         | 
| 136 139 | 
             
                  .append($('<div/>').attr('id', 'new_cat_message'))              
         | 
| @@ -200,7 +203,7 @@ var MediaModalController = BlockModalController.extend({ | |
| 200 203 | 
             
                      li.addClass("png");
         | 
| 201 204 | 
             
                    }
         | 
| 202 205 | 
             
                    if (m.image_urls && m.image_urls != undefined)
         | 
| 203 | 
            -
                      li.append($( | 
| 206 | 
            +
                      li.append($('<img/>').attr('src', m.image_urls.tiny_url + '?' + d).attr("id","image-" + m.id));
         | 
| 204 207 | 
             
                    else if (m.original_name) {
         | 
| 205 208 | 
             
                      var ext = m.original_name.match(/\.[0-9a-z]+$/i);
         | 
| 206 209 | 
             
                      li.addClass('empty');
         | 
| @@ -218,17 +221,46 @@ var MediaModalController = BlockModalController.extend({ | |
| 218 221 | 
             
                else
         | 
| 219 222 | 
             
                  ul = $('<p/>').html("This category is empty.");
         | 
| 220 223 | 
             
                $('#the_modal #media').empty().append(ul);
         | 
| 221 | 
            -
                if (that.refresh_unprocessed_images == true && processing)
         | 
| 222 | 
            -
                  setTimeout(function() { that.refresh(); }, 2000);
         | 
| 224 | 
            +
                if (that.refresh_unprocessed_images == true && processing) {
         | 
| 225 | 
            +
                  // setTimeout(function() { that.refresh(); }, 2000);
         | 
| 226 | 
            +
                  setTimeout(function() { that.check_processing_status(); }, 3000);
         | 
| 227 | 
            +
                }
         | 
| 223 228 | 
             
                that.autosize();
         | 
| 224 229 |  | 
| 225 | 
            -
                $.each(that.media, function(i, m) {
         | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            +
                // $.each(that.media, function(i, m) {
         | 
| 231 | 
            +
                //   $('li.media').draggable({
         | 
| 232 | 
            +
                //     multiple: true,
         | 
| 233 | 
            +
                //     revert: 'invalid',
         | 
| 234 | 
            +
                //     start: function() { $(this).data("origPosition", $(this).position()); }
         | 
| 235 | 
            +
                //   });
         | 
| 236 | 
            +
                // });
         | 
| 237 | 
            +
              },
         | 
| 238 | 
            +
             | 
| 239 | 
            +
              check_processing_status: function() 
         | 
| 240 | 
            +
              {     
         | 
| 241 | 
            +
                console.log("checking processing status");
         | 
| 242 | 
            +
                var that = this;
         | 
| 243 | 
            +
                if (!that.last_upload_processed)
         | 
| 244 | 
            +
                  that.last_upload_processed = new Date();
         | 
| 245 | 
            +
                if ( that.ajax_count < that.ajax_limit ) {
         | 
| 246 | 
            +
                  $.ajax({
         | 
| 247 | 
            +
                    url: '/admin/media/last-upload-processed',
         | 
| 248 | 
            +
                    type: 'get',            
         | 
| 249 | 
            +
                    success: function(resp) {
         | 
| 250 | 
            +
                      that.ajax_count += 1;
         | 
| 251 | 
            +
                      var d = Date.parse(resp['last_upload_processed']);        
         | 
| 252 | 
            +
                      if (d > that.last_upload_processed) {
         | 
| 253 | 
            +
                        console.log("new processed image, refreshing");
         | 
| 254 | 
            +
                        that.refresh_media();      
         | 
| 255 | 
            +
                      }      
         | 
| 256 | 
            +
                      else {
         | 
| 257 | 
            +
                        console.log("no new processed images, waiting");
         | 
| 258 | 
            +
                        setTimeout(function() { that.check_processing_status(); }, 3000);          
         | 
| 259 | 
            +
                      }
         | 
| 260 | 
            +
                      that.last_upload_processed = d;                                                        
         | 
| 261 | 
            +
                    }
         | 
| 230 262 | 
             
                  });
         | 
| 231 | 
            -
                } | 
| 263 | 
            +
                }
         | 
| 232 264 | 
             
              },
         | 
| 233 265 |  | 
| 234 266 | 
             
              print_media_detail: function(media_id)
         | 
| @@ -264,12 +296,12 @@ var MediaModalController = BlockModalController.extend({ | |
| 264 296 | 
             
                var select_text = m.media_type == 'image' ? 'Select this Image' : 'Select this File';
         | 
| 265 297 | 
             
                $('#modal_controls').empty()
         | 
| 266 298 | 
             
                  .append($('<p/>').css('clear', 'both')
         | 
| 267 | 
            -
                    .append($('<input/>').attr('type', 'button').addClass('caboose-btn').val( | 
| 299 | 
            +
                    .append($('<input/>').attr('type', 'button').addClass('caboose-btn').val(select_text ).click(function(e) { that.select_media(media_id)                           }))     
         | 
| 300 | 
            +
                    .append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Back'            ).click(function(e) { 
         | 
| 268 301 | 
             
                      that.print_top_controls();
         | 
| 269 302 | 
             
                      that.print_media();
         | 
| 270 303 | 
             
                      that.print_controls();
         | 
| 271 | 
            -
                    }))
         | 
| 272 | 
            -
                    .append($('<input/>').attr('type', 'button').addClass('caboose-btn').val(select_text ).click(function(e) { that.select_media(media_id)                           }))        
         | 
| 304 | 
            +
                    }))   
         | 
| 273 305 | 
             
                    .append($('<input/>').attr('type', 'button').addClass('caboose-btn').val('Close'             ).click(function(e) { that.parent_controller.render_blocks(); that.close(); }))
         | 
| 274 306 | 
             
                  );
         | 
| 275 307 |  | 
| @@ -355,11 +387,11 @@ var MediaModalController = BlockModalController.extend({ | |
| 355 387 | 
             
                          success: function(resp) {},
         | 
| 356 388 | 
             
                          async: false          
         | 
| 357 389 | 
             
                        });
         | 
| 358 | 
            -
                        that.refresh_media(function() { that.refresh_categories(function() { that.print_categories(); that.print_media(); }); });
         | 
| 390 | 
            +
                        //that.refresh_media(function() { that.refresh_categories(function() { that.print_categories(); that.print_media(); }); });
         | 
| 359 391 | 
             
                      },   
         | 
| 360 392 | 
             
                      FileUploaded: function(ip, file)
         | 
| 361 393 | 
             
                      {
         | 
| 362 | 
            -
                        that.refresh_media(function() { that.print_media(); });            
         | 
| 394 | 
            +
                        //that.refresh_media(function() { that.print_media(); });            
         | 
| 363 395 | 
             
                      },          
         | 
| 364 396 | 
             
                      UploadComplete: function(up, files) {            
         | 
| 365 397 | 
             
                        if (that.uploader)
         | 
| @@ -369,6 +401,7 @@ var MediaModalController = BlockModalController.extend({ | |
| 369 401 | 
             
                            that.uploader = false;                
         | 
| 370 402 | 
             
                          });
         | 
| 371 403 | 
             
                        }
         | 
| 404 | 
            +
                        that.refresh_unprocessed_images = true;
         | 
| 372 405 | 
             
                        that.refresh_media(function() { that.print_media(); });            
         | 
| 373 406 | 
             
                      }
         | 
| 374 407 | 
             
                    }
         | 
| @@ -451,7 +484,6 @@ var MediaModalController = BlockModalController.extend({ | |
| 451 484 | 
             
              {
         | 
| 452 485 | 
             
                var that = this;
         | 
| 453 486 | 
             
                that.file_view = (that.file_view == 'thumbnail' ? 'list' : 'thumbnail');
         | 
| 454 | 
            -
             | 
| 455 487 | 
             
                that.print_media();
         | 
| 456 488 | 
             
              },  
         | 
| 457 489 |  | 
| @@ -6,12 +6,59 @@ var RichtextModalController = BlockModalController.extend({ | |
| 6 6 | 
             
              modal_height: 500,
         | 
| 7 7 | 
             
              trapFocus: false,
         | 
| 8 8 |  | 
| 9 | 
            +
              modal: function(el, width, height, callback)
         | 
| 10 | 
            +
              {
         | 
| 11 | 
            +
                var that = this;
         | 
| 12 | 
            +
                if (!width) width = that.modal_width ? that.modal_width : 400;
         | 
| 13 | 
            +
                if (!height) height = that.modal_height ? that.modal_height : $(el).outerHeight(true);
         | 
| 14 | 
            +
                that.modal_element = el;    
         | 
| 15 | 
            +
                el.attr('id', 'the_modal').addClass('modal').addClass('colorbox').css('width', '' + width + 'px');
         | 
| 16 | 
            +
                var options = {
         | 
| 17 | 
            +
                  html: el,           
         | 
| 18 | 
            +
                  initialWidth: width, 
         | 
| 19 | 
            +
                  innerWidth: width, 
         | 
| 20 | 
            +
                  scrolling: false,        
         | 
| 21 | 
            +
                  closeButton: false,
         | 
| 22 | 
            +
                  opacity: 0.50,
         | 
| 23 | 
            +
                  onComplete: function() {                
         | 
| 24 | 
            +
                    $("#cboxClose").hide();
         | 
| 25 | 
            +
                    if (callback) callback();        
         | 
| 26 | 
            +
                  }
         | 
| 27 | 
            +
                };
         | 
| 28 | 
            +
                if (that.trapFocus === false)
         | 
| 29 | 
            +
                  options['trapFocus'] = false;    
         | 
| 30 | 
            +
                $.colorbox(options);
         | 
| 31 | 
            +
              },
         | 
| 32 | 
            +
              
         | 
| 33 | 
            +
              last_size: 0,
         | 
| 34 | 
            +
              autosize: function(msg, msg_container, flag)
         | 
| 35 | 
            +
              {    
         | 
| 36 | 
            +
                var that = this;
         | 
| 37 | 
            +
                if (!flag)
         | 
| 38 | 
            +
                  that.last_size = 0;
         | 
| 39 | 
            +
                if (!that.modal_element) return;
         | 
| 40 | 
            +
                if (msg) $('#' + (msg_container ? msg_container : 'modal_message')).html(msg);    
         | 
| 41 | 
            +
                var h = that.modal_height ? that.modal_height : $(that.modal_element).outerHeight(true) + 20;    
         | 
| 42 | 
            +
                if (h > 0 && h > that.last_size)    
         | 
| 43 | 
            +
                  $.colorbox.resize({ innerHeight: '' + h + 'px' });
         | 
| 44 | 
            +
                that.last_size = h;
         | 
| 45 | 
            +
                
         | 
| 46 | 
            +
                if (!flag || flag < 2)
         | 
| 47 | 
            +
                  setTimeout(function() { that.autosize(false, false, flag ? flag + 1 : 1); }, 200);
         | 
| 48 | 
            +
              },
         | 
| 49 | 
            +
              
         | 
| 50 | 
            +
              before_close: false,
         | 
| 51 | 
            +
              close: function()
         | 
| 52 | 
            +
              {
         | 
| 53 | 
            +
                var that = this;
         | 
| 54 | 
            +
                if (that.before_close) that.before_close();
         | 
| 55 | 
            +
                $.colorbox.close();    
         | 
| 56 | 
            +
              },
         | 
| 57 | 
            +
             | 
| 9 58 | 
             
              assets_to_include: function()
         | 
| 10 59 | 
             
              {
         | 
| 11 60 | 
             
                return [
         | 
| 12 61 | 
             
                  '//cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.13/tinymce.min.js'
         | 
| 13 | 
            -
                  //'//tinymce.cachefly.net/4.0/tinymce.min.js',
         | 
| 14 | 
            -
                  //'caboose/tinymce_init.js'
         | 
| 15 62 | 
             
                ]
         | 
| 16 63 | 
             
              },
         | 
| 17 64 |  | 
| @@ -62,6 +109,26 @@ var RichtextModalController = BlockModalController.extend({ | |
| 62 109 | 
             
                });
         | 
| 63 110 | 
             
                that.autosize();        
         | 
| 64 111 | 
             
              },
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              print_crumbtrail: function()
         | 
| 114 | 
            +
              {    
         | 
| 115 | 
            +
                // var that = this;
         | 
| 116 | 
            +
                // var crumbs = $('<h2/>').css('margin-top', '0').css('padding-top', '0');
         | 
| 117 | 
            +
                // $.each(that.block.crumbtrail, function(i, h) {
         | 
| 118 | 
            +
                //   if (i > 0) crumbs.append(' > ');
         | 
| 119 | 
            +
                //   if ( i == 0 || (i == 1 && h['text'] == "Content" )) {
         | 
| 120 | 
            +
                //     crumbs.append($('<span/>').html(h['text']).data('block_id', h['block_id']));
         | 
| 121 | 
            +
                //   }
         | 
| 122 | 
            +
                //   else {
         | 
| 123 | 
            +
                //     crumbs.append($('<a/>').attr('href', '#').html(h['text']).data('block_id', h['block_id']).click(function(e) { 
         | 
| 124 | 
            +
                //       e.preventDefault();
         | 
| 125 | 
            +
                //       if (that.before_crumbtrail_click) that.before_crumbtrail_click();
         | 
| 126 | 
            +
                //       that.parent_controller.edit_block(parseInt($(this).data('block_id')));
         | 
| 127 | 
            +
                //     }));
         | 
| 128 | 
            +
                //   }
         | 
| 129 | 
            +
                // }); 
         | 
| 130 | 
            +
                $('#modal_crumbtrail').empty()     
         | 
| 131 | 
            +
              },
         | 
| 65 132 |  | 
| 66 133 | 
             
              before_crumbtrail_click: function() { var that = this; tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value'); },  
         | 
| 67 134 | 
             
              before_close:            function() { var that = this; tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value'); },  
         |