Skip to content

Commit

Permalink
Make blocks use the new block syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbell committed Aug 20, 2012
1 parent 5382bbb commit 752f07a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 114 deletions.
19 changes: 8 additions & 11 deletions src/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
var template = '<p>Drop gist link here</p><div class="input text"><label>or paste URL:</label><input type="text" class="paste-block"></div>';
var gist_template = '<div class="gist"><%= div %></div>';

var Gist = SirTrevor.BlockType.extend({
SirTrevor.Blocks.Gist = SirTrevor.Block.extend({

title: "Gist",
className: "gist-block",
Expand All @@ -16,8 +16,7 @@ var Gist = SirTrevor.BlockType.extend({
dropzoneHTML: template,

loadData: function(data){
this.loading();
this._super("loadGist", data.id);
this.loadGist(data.id);
},

loadGist: function(gist_id) {
Expand All @@ -33,9 +32,9 @@ var Gist = SirTrevor.BlockType.extend({

$('head').append('<link rel="stylesheet" href="'+data.stylesheet+'" type="text/css">');

this.$el.html(data.div);
this.$editor.html(data.div);
this.$dropzone.fadeOut(250);
this.$el.show();
this.$editor.show();
this.ready();
};

Expand All @@ -56,7 +55,7 @@ var Gist = SirTrevor.BlockType.extend({
// Content pasted. Delegate to the drop parse method
var input = $(event.target),
val = input.val();
this._super("handleDropPaste", val);
this.handleDropPaste(val);
},

handleDropPaste: function(url) {
Expand All @@ -70,16 +69,14 @@ var Gist = SirTrevor.BlockType.extend({
this.loading();

ID = ID[0];
this._super("loadGist", ID);
this.loadGist(ID);
}
}
}
},

onDrop: function(transferData){
var url = transferData.getData('text/plain');
this._super("handleDropPaste", url);
this.handleDropPaste(url);
}
});

SirTrevor.BlockTypes.Gist = new Gist();
});
15 changes: 6 additions & 9 deletions src/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var md_template = '<div class="expanding-textarea"><pre><span></span><br></pre><textarea class="required <%= className %>"></textarea></div>';

var Markdown = SirTrevor.BlockType.extend({
SirTrevor.Blocks.Markdown = SirTrevor.Block.extend({

title: "Markdown",
className: "markdown",
Expand All @@ -14,13 +14,13 @@ var Markdown = SirTrevor.BlockType.extend({
},

loadData: function(data){
this.$('.markdown').html(data.text);
this.$$('.markdown').html(data.text);
},

onBlockRender: function(){
/* Make our expanding text area */

var cont = this.$('.expanding-textarea'),
var cont = this.$$('.expanding-textarea'),
area = cont.find('textarea'),
span = cont.find('span');

Expand All @@ -33,11 +33,8 @@ var Markdown = SirTrevor.BlockType.extend({

toData: function() {
var bl = this.$el,
dataStruct = bl.data('block'),
content;
dataStruct = bl.data('block');

dataStruct.data.text = this.$('.markdown').val();
dataStruct.data.text = this.$$('.markdown').val();
}
});

SirTrevor.BlockTypes.Markdown = new Markdown();
});
12 changes: 5 additions & 7 deletions src/ordered-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var od_template = '<div class="text-block <%= className %>" contenteditable="true"></div>';

var OrderedList = SirTrevor.BlockType.extend({
SirTrevor.Blocks.Ol = SirTrevor.Block.extend({

title: "List",
className: "ordered-list",
Expand All @@ -15,20 +15,20 @@ var OrderedList = SirTrevor.BlockType.extend({

onBlockRender: function(){

this.$('.text-block').bind('click', function(){
this.$$('.text-block').bind('click', function(){
if($(this).html().length === 0){
document.execCommand("insertOrderedList",false,false);
}
});

// Put in a list
if (_.isEmpty(this.data)) {
this.$('.text-block').focus().click();
this.$$('.text-block').focus().click();
}
},

loadData: function(data){
this.$('.text-block').html("<ol>" + this.instance._toHTML(data.text, this.type) + "</ol>");
this.$$('.text-block').html("<ol>" + this.instance._toHTML(data.text, this.type) + "</ol>");
},

toMarkdown: function(markdown){
Expand All @@ -40,6 +40,4 @@ var OrderedList = SirTrevor.BlockType.extend({
toHTML: function(html) {
return html.replace(/^ 1. (.+)$/mg,"<li>$1</li>");
}
});

SirTrevor.BlockTypes.OrderedList = new OrderedList();
});
87 changes: 0 additions & 87 deletions src/tweet.js

This file was deleted.

0 comments on commit 752f07a

Please sign in to comment.