var AssetsController = Class.extend({ manifest: false, editable_extensions: ['css', 'js', 'scss'], init: function(params) { var that = this; for (var i in params) that[i] = params[i]; that.refresh_manifest(function() { that.print(); }); var h = $(window).outerHeight() - 52; $('#manifest').css('height', '' + h + 'px').css('max-height', '' + h + 'px'); }, refresh_manifest: function(after) { var that = this; $.ajax({ url: '/admin/assets/manifest', type: 'get', success: function(resp) { that.manifest = resp; if (after) after(); } }); }, print: function() { var that = this; that.print_manifest(); }, print_manifest: function() { var that = this; var ul = $('
That type of file is not editable.
"); return; } $('#editor').html("Getting file...
"); var str = false; var error = false; $.ajax({ url: that.assets_path + path, type: 'get', success: function(resp) { str = resp; }, error: function(e) { error = "Error retrieving file." }, async: false }); if (error) { $('#editor').empty().html("" + error + "
"); return; } var w = $(window).outerWidth() - 380; var h = $(window).outerHeight() - 200; $('#editor').empty() .append($('') .append($('').attr('type', 'button').val('Save' ).click(function(e) { that.save_file(); })).append(' ') .append($('').attr('type', 'button').val('Cancel' ).click(function(e) { $('#editor').empty(); })) ) .append($('').attr('id', 'the_editor') .css('width', '' + w + 'px') .css('height', '' + h + 'px') .append(str) ); } }); function sort_by_name(a, b){ var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0)); } function sorted_hash(h) { var keys = []; for (var k in h) if (h.hasOwnProperty(k)) keys.push(k); keys.sort(); var h2 = {}; for (i in keys) { var k = keys[i]; h2[k] = h[k]; } return h2; }