-
-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
261 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Template plugin | Trumbowyg by Alex-D</title> | ||
<link rel="stylesheet" href="../css/main.css"> | ||
<link rel="stylesheet" href="../../dist/ui/trumbowyg.css"> | ||
</head> | ||
<body> | ||
<div id="main" role="main"> | ||
<header> | ||
<h1>Template plugin for Trumbowyg</h1> | ||
|
||
<p> | ||
This plugin allows you to add a template-dropdown. | ||
</p> | ||
</header> | ||
|
||
<div id="editor"> | ||
<h2>Lorem ipsum dolor sit amet</h2> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam! | ||
</p> | ||
<p> | ||
The text is derived from Cicero's De Finibus Bonorum et Malorum (On the Ends of Goods and Evils, or alternatively [About] The Purposes of Good and Evil ). The original passage began: Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit (Translation: "Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it"). | ||
</p> | ||
</div> | ||
|
||
<h2>The code</h2> | ||
<code> | ||
<pre> | ||
$('#editor') | ||
.trumbowyg({ | ||
btns: ['template'], | ||
plugins: { | ||
templates: [ | ||
{ | ||
name: 'Template 1', | ||
html: '<p>I am a template!</p>' | ||
}, | ||
{ | ||
name: 'Template 2', | ||
html: '<p>I am a different template!</p>' | ||
} | ||
] | ||
} | ||
}); | ||
</pre> | ||
</code> | ||
</div> | ||
<script src="../../bower_components/jquery/dist/jquery.min.js"></script> | ||
<script src="../../dist/trumbowyg.js"></script> | ||
<script src="../../dist/plugins/template/trumbowyg.template.js"></script> | ||
<script> | ||
$('#editor') | ||
.trumbowyg({ | ||
btns: ['template'], | ||
plugins: { | ||
templates: [ | ||
{ | ||
name: 'Template 1', | ||
html: '<p>I am a template!</p>' | ||
}, | ||
{ | ||
name: 'Template 2', | ||
html: '<p>I am a different template!</p>' | ||
} | ||
] | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(function($) { | ||
'use strict'; | ||
|
||
// Adds the language variables | ||
$.extend(true, $.trumbowyg, { | ||
langs: { | ||
en: { | ||
template: 'Template' | ||
}, | ||
nl: { | ||
template: 'Sjabloon' | ||
} | ||
} | ||
}); | ||
|
||
// Adds the extra button definition | ||
$.extend(true, $.trumbowyg, { | ||
plugins: { | ||
template: { | ||
shouldInit: function(trumbowyg) { | ||
return trumbowyg.o.plugins.hasOwnProperty('templates'); | ||
}, | ||
init: function(trumbowyg) { | ||
trumbowyg.addBtnDef('template', { | ||
dropdown: templateSelector(trumbowyg), | ||
hasIcon: false, | ||
text: trumbowyg.lang.template | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// Creates the template-selector dropdown. | ||
function templateSelector(trumbowyg) { | ||
var available = trumbowyg.o.plugins.templates; | ||
var templates = []; | ||
|
||
$.each(available, function(index, template) { | ||
trumbowyg.addBtnDef('template_' + index, { | ||
fn: function(){ | ||
trumbowyg.html(template.html); | ||
}, | ||
hasIcon: false, | ||
title: template.name | ||
}); | ||
templates.push('template_' + index); | ||
}); | ||
|
||
return templates; | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.