Browse Source

Add noAssets config option to Asset Manager

pull/281/head
Artur Arseniev 9 years ago
parent
commit
3b23227a55
  1. 4
      dist/grapes.min.js
  2. 6
      index.html
  3. 2
      package.json
  4. 4
      src/asset_manager/config/config.js
  5. 8
      src/asset_manager/index.js
  6. 10
      src/asset_manager/view/AssetsView.js

4
dist/grapes.min.js

File diff suppressed because one or more lines are too long

6
index.html

@ -831,11 +831,6 @@
fromElement: true, fromElement: true,
clearOnRender: 0, clearOnRender: 0,
storageManager: {
autoload: 1,
storeComponents: 1,
storeStyles: 1,
},
commands: { commands: {
defaults: [{ defaults: [{
@ -1268,7 +1263,6 @@
command: function(editor, sender) { command: function(editor, sender) {
if(sender) sender.set('active', false); if(sender) sender.set('active', false);
if(confirm('Are you sure to clean the canvas?')) { if(confirm('Are you sure to clean the canvas?')) {
editor.CssComposer.getAll().reset();
editor.DomComponents.clear(); editor.DomComponents.clear();
setTimeout(function() { setTimeout(function() {
localStorage.clear(); localStorage.clear();

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Free and Open Source Web Builder Framework", "description": "Free and Open Source Web Builder Framework",
"version": "0.9.35", "version": "0.9.36",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",

4
src/asset_manager/config/config.js

@ -2,6 +2,10 @@ module.exports = {
// Default assets // Default assets
assets: [], assets: [],
// Content to add where there is no assets to show
// eg. 'No <b>assets</b> here, drag to upload'
noAssets: '',
// Style prefix // Style prefix
stylePrefix: 'am-', stylePrefix: 'am-',

8
src/asset_manager/index.js

@ -249,12 +249,12 @@ module.exports = () => {
/** /**
* Render assets * Render assets
* @param {Boolean} f Force to render, otherwise cached version will be returned * @param {array} assets Assets to render, without the argument will render
* all global assets
* @return {HTMLElement} * @return {HTMLElement}
* @private
*/ */
render(assets = []) { render(assets) {
const toRender = assets.length ? assets : this.getAll().models; const toRender = assets || this.getAll().models;
am.collection.reset(toRender); am.collection.reset(toRender);
return this.getContainer(); return this.getContainer();
}, },

10
src/asset_manager/view/AssetsView.js

@ -138,17 +138,15 @@ module.exports = Backbone.View.extend({
render() { render() {
const pfx = this.pfx; const pfx = this.pfx;
const ppfx = this.ppfx; const ppfx = this.ppfx;
const noAssets = this.config.noAssets;
const fuRendered = this.options.fu.render().el; const fuRendered = this.options.fu.render().el;
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
this.$el.empty(); this.$el.empty();
this.collection.each((model) => this.addAsset(model, fragment));
this.collection.each((model) => {
this.addAsset(model, fragment);
});
this.$el.append(fuRendered).append(this.template(this)); this.$el.append(fuRendered).append(this.template(this));
this.el.className = `${ppfx}asset-manager`; this.el.className = `${ppfx}asset-manager`;
this.$el.find(`.${pfx}assets`).append(fragment); const assetsEl = this.$el.find(`.${pfx}assets`);
assetsEl.append(fragment.childNodes.length ? fragment : noAssets);
return this; return this;
} }
}); });

Loading…
Cancel
Save