diff --git a/.gitignore b/.gitignore index b084abea3..e9ebfeac1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ grapes.sublime-workspace img/ private/ +docs/ vendor/ coverage/ node_modules/ diff --git a/src/panels/main.js b/src/panels/main.js index da4a67f52..d808fa6d1 100644 --- a/src/panels/main.js +++ b/src/panels/main.js @@ -1,11 +1,29 @@ +/** + * This module manages panels and buttons inside the editor. + * You can init the editor with all panels and buttons necessary via configuration + * + * ```js + * var editor = new GrapesJS({ + * ... + * panels: {...} // Check below for the possible properties + * ... + * }); + * ``` + * + * + * Before using methods you should get first the module from the GrapesJs instance, in this way: + * + * ```js + * var panelService = editor.get('Panels'); + * ``` + * + * @module Panels + * @param {Object} config Configurations + */ define(function(require) { - /** - * @class Panel - * @param {Object} Configurations - * - * @return {Object} - * */ - function Panel(config){ + + var Panels = function(config){ + var c = config || {}, defaults = require('./config/config'), Panels = require('./model/Panels'), @@ -120,7 +138,7 @@ define(function(require) { }, }; - } + }; - return Panel; + return Panels; }); \ No newline at end of file diff --git a/src/panels/model/Panels.js b/src/panels/model/Panels.js index d1ad4933e..da177628a 100644 --- a/src/panels/model/Panels.js +++ b/src/panels/model/Panels.js @@ -1,11 +1,9 @@ -define([ 'backbone','./Panel'], +define([ 'backbone','./Panel'], function (Backbone, Panel) { - /** - * @class Panels - * */ + return Backbone.Collection.extend({ - + model: Panel, - + }); }); diff --git a/src/panels/view/PanelsView.js b/src/panels/view/PanelsView.js index b72c961bd..258eb1d52 100644 --- a/src/panels/view/PanelsView.js +++ b/src/panels/view/PanelsView.js @@ -1,10 +1,11 @@ -define(['backbone','./PanelView'], +define(['backbone','./PanelView'], function (Backbone, PanelView) { - /** + /** * @class ItemsView + * @private * */ return Backbone.View.extend({ - + initialize: function(o) { this.opt = o; this.config = o.config; @@ -13,52 +14,54 @@ define(['backbone','./PanelView'], this.listenTo( this.collection, 'reset', this.render ); this.className = this.pfx + 'panels'; }, - + /** * Add to collection * @param Object Model - * + * * @return Object + * @private * */ addTo: function(model){ this.addToCollection(model); }, - + /** * Add new object to collection * @param Object Model * @param Object Fragment collection * @param integer Index of append - * + * * @return Object Object created + * @private * */ addToCollection: function(model, fragmentEl){ var fragment = fragmentEl || null; var viewObject = PanelView; - - var view = new viewObject({ - model : model, + + var view = new viewObject({ + model : model, config : this.config, }); var rendered = view.render().el; - + if(fragment){ fragment.appendChild(rendered); }else{ this.$el.append(rendered); } - + return rendered; }, - + render: function() { var fragment = document.createDocumentFragment(); this.$el.empty(); - + this.collection.each(function(model){ this.addToCollection(model, fragment); }, this); - + this.$el.append(fragment); this.$el.attr('class', _.result(this, 'className')); return this;