public
Created — forked from balupton/README.md

  • Download Gist
aloha-ui-abstraction.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
// http://svn.ckeditor.com/CKEditor/trunk/_source/plugins/basicstyles/plugin.js
 
Aloha.ui.store = function(ID,properties){
Aloha.ui.objects[ID] = {
config: config,
element: $button
};
}
 
Aloha.ui.createButton = function( ID, config ){
var $button = $( "<button>"
+ Aloha.API.translate( config.text || ID )
+ "</button>" ).button();
Aloha.ui.store(ID, {
config: config,
element: $button
});
return $button;
};
 
// jQuery UI Implementation - included in jQuery UI Adapter
 
Aloha.ui.addWrapButton = function( ID, config ){
var $button = Aloha.ui.createButton(ID, config);
var $selection = Aloha.API.getSelection();
// Apply Style
if ( config.style ) {
$selection.css( options.style );
}
// Wrap
if ( config.element ) {
$selection.wrap( options.element );
}
});
 
Aloha.ui.addInsertButton = function ( id, config ) {
var $button = Aloha.ui.createButton ( ID, config );
var
onClick /*alias*/
= Aloha.ui.events[id].click // makes overrides possible
= function(){
var $selection = Aloha.getSelection();
$(config.element).after($selection);
}
;
$button.click(onClick);
};
 
Aloha.ui.addCustomButton( "Increase Image Size", {
context: "img",
click: function(event){
var $img = Aloha.API.getSelection().find( "img" );
$img = $img.height( $img.height() * 1.5 );
}
});
 
 
Aloha.ui.addInsertButton( "Image", {
element: "img"
});
 
 
 
Aloha.cron.addTask(function() {
// ...
});
Aloha.cron.addTransform( "b", "strong" );
 
Aloha.ui.addStyleButton( "Bold", {
element: "strong",
});
 
Aloha.ui.addStyleButton( "Red", {
// enabled when, and applies
element: "p",
style: {
color: "red",
fontSize: "30px"
}
});
 
 
$( element ).aloha({
toolbar: Aloha.toolbars.full
});
 
 
// Defined in Implementors Configuration
$( element ).aloha({
toolbar: {
Format: [
["Bold", "Italic", "Underline", "Formatting"],
"headers", // regard as widget
{
type: "multiSplitArea",
items: // ...
},
// Putting plugin code in configuration - not good
new Aloha.ui.multiSplitArea({
items: [
new Aloha.ui.imageButton( "h1", {
image: "h1".gif"
});
]
});
],
"Image Styles": [ "Bold", "Save" ]
},
headers: [ "h1", "h2", "h3", "normal", "blockquote" ]
});
// ^ triggers aloha.configured
 
 
Aloha.listen("aloha.configured", function(editor){
// ^ required for access to editor.config
 
/// Defined in Image Plugin
Aloha.ui.addImageButton( "h1", {
image: "h1.gif"
});
 
Aloha.ui.addMultiSplitArea( "headers", { // 52
items: editor.config.headers // [ "headers.h1" ] // 76
});
});
 
 
// Events
aloha.configured
aloha.toolbar.ready
 
 
 
 
 
$( element ).aloha({
toolbar: [
{
label: "Format",
controls: [ "Bold", "Italic", "Underline" ]
}
]
});
 
 
 
$( element ).aloha({
toolbar: {
Format: [
[ "Bold", "Italic", "Underline", "Formatting" ],
[ "H1", "H2", "H3" ]
]
}
});
gistfile2.txt
1 2 3 4 5 6 7 8
Related to Wiki Article:
http://aloha-editor.org/wiki/Migration_to_jQuery_UI
 
And Aloha Editor DevCon Talk:
http://www.livestream.com/alohaeditor/video?clipId=pla_7219285e-1723-430b-84ae-5190e3d3004f&utm_source=lslibrary&utm_medium=ui-thumb
 
Copyright Aloha Editor Team.
Romain and Benjamin

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.