Browse Source

Fix tests

pull/36/head
Artur Arseniev 10 years ago
parent
commit
dd67bdf788
  1. 5
      src/canvas/view/CanvasView.js
  2. 4
      src/class_manager/view/ClassTagsView.js
  3. 13
      src/commands/view/CommandAbstract.js
  4. 10
      src/panels/main.js
  5. 25
      src/panels/view/ButtonView.js
  6. 2
      test/specs/dom_components/view/ComponentImageView.js

5
src/canvas/view/CanvasView.js

@ -6,6 +6,7 @@ function(Backbone, FrameView) {
return Backbone.View.extend({
initialize: function(o) {
_.bindAll(this, 'renderBody', 'onFrameScroll');
this.config = o.config || {};
this.em = this.config.em || {};
this.ppfx = this.config.pStylePrefix || '';
@ -47,7 +48,7 @@ function(Backbone, FrameView) {
if(protCss)
body.append('<style>' + frameCss + protCss + '</style>');
this.config.em.trigger('loaded');
this.frame.el.contentWindow.onscroll = this.onFrameScroll.bind(this);
this.frame.el.contentWindow.onscroll = this.onFrameScroll;
// When the iframe is focused the event dispatcher is not the same so
// I need to delegate all events to the parent document
@ -105,7 +106,7 @@ function(Backbone, FrameView) {
this.model.get('frame').set('wrapper', this.wrapper);
this.$el.append(this.frame.render().el);
var frame = this.frame;
frame.el.onload = this.renderBody.bind(this);
frame.el.onload = this.renderBody;
}
this.toolsEl = $('<div>', { id: this.ppfx + 'tools' }).get(0);
this.hlEl = $('<div>', { class: this.ppfx + 'highlighter' }).get(0);

4
src/class_manager/view/ClassTagsView.js

@ -136,7 +136,9 @@ define(['backbone', 'text!./../template/classTags.html', './ClassTagView'],
});
var state = this.compTarget.get('state');
result = state ? result + ':' + state : result;
this.el.querySelector('#' + this.pfx + 'sel').innerHTML = result;
var el = this.el.querySelector('#' + this.pfx + 'sel');
if(el)
el.innerHTML = result;
},
/**

13
src/commands/view/CommandAbstract.js

@ -28,14 +28,15 @@ define(['backbone'],
if(this.editorModel.get)
this.setElement(this.getCanvas());
this.$canvas = this.$el;
this.$wrapper = $(this.getCanvasWrapper());
if(this.canvas){
this.$canvas = this.$el;
this.$wrapper = $(this.getCanvasWrapper());
this.frameEl = this.canvas.getFrameEl();
this.canvasTool = this.getCanvasTools();
this.bodyEl = this.getCanvasBody();
}
this.init(this.config);
this.frameEl = this.canvas.getFrameEl();
this.canvasTool = this.getCanvasTools();
this.bodyEl = this.getCanvasBody();
},
/**

10
src/panels/main.js

@ -100,7 +100,7 @@ define(function(require) {
* @example
* var myPanel = panelManager.getPanel('myNewPanel');
*/
getPanel : function(id){
getPanel: function(id){
var res = panels.where({id: id});
return res.length ? res[0] : null;
},
@ -119,7 +119,7 @@ define(function(require) {
* active: false,
* });
*/
addButton : function(panelId, button){
addButton: function(panelId, button){
var pn = this.getPanel(panelId);
return pn ? pn.get('buttons').add(button) : null;
},
@ -132,7 +132,7 @@ define(function(require) {
* @example
* var button = panelManager.getButton('myPanel','myButton');
*/
getButton : function(panelId, id){
getButton: function(panelId, id){
var pn = this.getPanel(panelId);
if(pn){
var res = pn.get('buttons').where({id: id});
@ -145,7 +145,7 @@ define(function(require) {
* Render panels and buttons
* @return {HTMLElement}
*/
render : function(){
render: function(){
return PanelsViewObj.render().el;
},
@ -153,7 +153,7 @@ define(function(require) {
* Active activable buttons
* @private
*/
active : function(){
active: function(){
this.getPanels().each(function(p){
p.get('buttons').each(function(btn){
if(btn.get('active'))

25
src/panels/view/ButtonView.js

@ -41,18 +41,19 @@ function(Backbone, require) {
this.events.click = 'clicked';
this.delegateEvents();
this.canvasEl = this.em.Canvas.CanvasView.$el.get(0);
this.sorter = new this.em.Utils.Sorter({
container: this.canvasEl,
containerSel: '*',
itemSel: '*',
pfx: this.ppfx,
onMove: this.onDrag,
onEndMove: this.onDrop,
direction: 'auto',
nested: 1,
});
if(this.em.Canvas){
this.canvasEl = this.em.Canvas.getElement();
this.sorter = new this.em.Utils.Sorter({
container: this.canvasEl,
containerSel: '*',
itemSel: '*',
pfx: this.ppfx,
onMove: this.onDrag,
onEndMove: this.onDrop,
direction: 'auto',
nested: 1,
});
}
},
/**

2
test/specs/dom_components/view/ComponentImageView.js

@ -35,7 +35,7 @@ define([path + 'ComponentImageView', 'DomComponents/model/Component'],
});
it('Component empty', function() {
$fixture.html().should.equal('<img class="image-placeholder">');
$fixture.html().should.equal('<img class="'+ view.classEmpty +'">');
});
it('TagName is <img>', function() {

Loading…
Cancel
Save