Browse Source

Clean demo and test

pull/67/head
Artur Arseniev 9 years ago
parent
commit
59693874ab
  1. 2
      bower.json
  2. 2
      dist/css/grapes.min.css
  3. 30
      dist/grapes.min.js
  4. 1598
      index.html
  5. 2
      package.json
  6. 7
      src/code_manager/model/JsGenerator.js
  7. 85
      src/demo.js
  8. 3
      src/rich_text_editor/main.js
  9. 1
      styles/css/main.css
  10. 1
      styles/scss/main.scss
  11. 6
      test/specs/storage_manager/model/Models.js

2
bower.json

@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Open source Web Template Editor",
"version": "0.4.35",
"version": "0.4.38",
"author": "Artur Arseniev",
"homepage": "http://grapesjs.com",
"main": [

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

30
dist/grapes.min.js

File diff suppressed because one or more lines are too long

1598
index.html

File diff suppressed because it is too large

2
package.json

@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Open source Web Template Editor",
"version": "0.4.35",
"version": "0.4.38",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",

7
src/code_manager/model/JsGenerator.js

@ -7,8 +7,6 @@ define(['backbone'], function (Backbone) {
var script = model.get('script');
var type = model.get('type');
var comps = model.get('components');
// TODO
var id = model.cid;
if (script) {
@ -32,11 +30,6 @@ define(['backbone'], function (Backbone) {
this.mapJs[type] = {ids: [id], code: scrStr};
}
}
/*
code = 'var item = document.getElementById("'+id+'");'+
'(' + scrStr + '.bind(item))();';
*/
}
comps.each(function(model) {

85
src/demo.js

@ -366,7 +366,6 @@ require(['config/require-config'], function() {
);
window.editor = editor;
var pnm = editor.Panels;
@ -400,90 +399,6 @@ require(['config/require-config'], function() {
attributes: { title: 'Empty canvas' }
}]);
// Blocks
var bm = editor.BlockManager;
bm.add('timer', {
label: 'timer',
attributes: {class:'gjs-fonts gjs-f-text'},
content: {
type: 'timer',
startfrom: 'May 5, 2018 20:00:00',
activeOnRender: 1,
}
});
var domc = editor.DomComponents;
var defaultType = domc.getType('default');
var defaultModel = defaultType.model;
var defaultView = defaultType.view;
domc.addType('timer', {
model: defaultModel.extend({
defaults: _.extend({}, defaultModel.prototype.defaults, {
startfrom: 'Nov 25, 2018 15:00:00',
droppable: false,
traits: [{
label: 'Start',
name: 'startfrom',
changeProp: 1,
}],
}),
init: function () {
this.listenTo(this, 'change:startfrom', this.buildScript);
this.listenTo(this, 'active', this.activeScript);
this.get('components').add('<span id="timer-c"></span>');
},
activeScript: function () {
this.set({'script': this.getScript()}, {silent: 1});
this.view.updateScript();
},
buildScript: function() {
this.set('script', this.getScript());
},
getScript: function() {
var startfrom = this.get('startfrom');
var fn = function () {
var startfrom = $startfrom$;
var countDownDate = new Date(startfrom).getTime();
var el = this.querySelector('#timer-c');
var moveTimer = function() {
var now = new Date().getTime();
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
el.innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
el.innerHTML = "EXPIRED";
}
};
var x = setInterval(moveTimer, 1000);
moveTimer();
};
var fnStr = this.getScriptString(fn);
return fnStr.replace('$startfrom$', '"'+startfrom+'"');
}
}, {
isComponent: function(el) {
if(el.getAttribute &&
el.getAttribute('data-gjs-type') == 'timer') {
return {type: 'timer'};
}
},
}),
view: defaultView,
});
editor.render();
});
});

3
src/rich_text_editor/main.js

@ -189,7 +189,8 @@ define(function(require) {
focus: function(view, rte) {
var customRte = this.customRte;
if (customRte) {
customRte.focus(view.el, rte);
if(customRte.focus)
customRte.focus(view.el, rte);
} else {
this.attach(view);
}

1
styles/css/main.css

@ -4169,7 +4169,6 @@ ol.example li.placeholder:before {
border: 1px solid rgba(0, 0, 0, 0.3);
position: absolute;
border-radius: 3px;
overflow: hidden;
z-index: 10; }
#gjs-rte-toolbar .gjs-rte-btn {
display: inline-block;

1
styles/scss/main.scss

@ -1449,7 +1449,6 @@ $uploadPadding: 150px 10px;
border: 1px solid $mainDkColor;
position: absolute;
border-radius: 3px;
overflow: hidden;
z-index: 10;
.#{$rte-prefix}btn {

6
test/specs/storage_manager/model/Models.js

@ -78,7 +78,9 @@ define([path + 'LocalStorage',
delete obj;
});
it('Store data', function() {
// Stubbing will not return the original object so
// .always will not work
it.skip('Store data', function() {
sinon.stub($, "ajax");
for(var k in params)
@ -115,4 +117,4 @@ define([path + 'LocalStorage',
};
});
});

Loading…
Cancel
Save