In this quick start, you'll learn how to add the Ribbon widget to an HTML project using HTML markup and jQuery script.
- To create a new HTML page in your favorite text editor, add the following code and save the document with an .html extension.
Drop down and copy markup
Paste in Notepad. |
Copy Code
|
<!DOCTYPE HTML>
<HTML>
<head>
</head>
<body>
</body>
</HTML>
|
- Add links to the dependencies to your HTML page within the <head> tags. Find the latest dependencies in the content delivery network (CDN) file at wijmo cdn.
Drop down and copy references to paste inside the head tags
References |
Copy Code
|
<!--jQuery References-->
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js" type="text/javascript"></script>
<!--Theme-->
<link href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" />
<!--Wijmo Widgets CSS-->
<link href="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20133.19.min.css" rel="stylesheet" type="text/css" />
<!--Wijmo Widgets JavaScript-->
<script src="http://cdn.wijmo.com/jquery.wijmo-open.all.3.20133.19.min.js" type="text/javascript"></script>
<script src="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20133.19.min.js" type="text/javascript"></script> |
- Add the following markup within the <body> tags to create the widget. The main <div> element creates the Ribbon widget, and we call its id attribute in jQuery to initialize it. The nested elements create the individual tools within the ribbon.
Drop down and copy markup to paste inside the body tags
Markup |
Copy Code
|
<div id="ribbon">
<ul>
<li><a href="#FormatTab">Format Tab</a></li>
<li><a href="#CustomizeTab">Customize Tab</a></li>
</ul>
<div id="FormatTab">
<ul>
<li id="actiongroup">
<button title="Save" class="wijmo-wijribbon-bigbutton" name="save">
<div class="wijmo-wijribbon-save"></div>
<span>Save</span>
</button>
<span class="wijmo-wijribbon-list">
<button title="Undo" class="wijmo-wijribbon-undo" name="undo"></button>
<button title="Redo" class="wijmo-wijribbon-redo" name="redo"></button>
</span>
<span class="wijmo-wijribbon-list">
<button title="Preview" class="wijmo-wijribbon-preview" name="preview"></button>
<button title="Clean up" class="wijmo-wijribbon-cleanup" name="cleanup"></button>
</span>
<span class="wijmo-wijribbon-list">
<button title="Cut" class="wijmo-wijribbon-cut" name="cut"></button>
<button title="Copy" class="wijmo-wijribbon-copy" name="copy"></button>
<button title="Paste" class="wijmo-wijribbon-paste" name="paste"></button>
<button title="Select All" class="wijmo-wijribbon-selectall" name="selectall"></button>
</span>
<div>Actions</div>
</li>
<li id="fontgroup">
<div title="Font Name" class="wijmo-wijribbon-dropdownbutton">
<button title="Font Name" name="fontname">Font Name</button>
<ul>
<li>
<input type="radio" id="fontNameArial" name="fontname"/>
<label for="fontNameArial" id="fn1" title="Arial">Arial</label>
</li>
<li>
<input type="radio" id="fontNameCourier" name="fontname"/>
<label for="fontNameCourier" id="fn2" title="Courier New">Courier New</label>
</li>
<li>
<input type="radio" id="fontNameTimes" name="fontname"/>
<label for="fontNameTimes" id="fn3" title="Times New Roman">Times New Roman</label>
</li>
</ul>
</div>
<div title="Font Size" class="wijmo-wijribbon-dropdownbutton">
<button title="Font Size" name="fontsize">Font Size</button>
<ul>
<li>
<input type="radio" id="fontSizeSmall" name="fontsize"/>
<label for="fontSizeSmall" id="small" title="Small">Small</label>
</li>
<li>
<input type="radio" id="fontSizeMedium" name="fontsize"/>
<label for="fontSizeMedium" id="medium" title="Medium">Medium</label>
</li>
<li>
<input type="radio" id="fontSizeLarge" name="fontsize"/>
<label for="fontSizeLarge" id="large" title="Large">Large</label>
</li>
</ul>
</div>
<span class="wijmo-wijribbon-list">
<button title="Background Color" class="wijmo-wijribbon-bgcolor" name="backcolor"></button>
<button title="Font Color" class="wijmo-wijribbon-color" name="fontcolor"></button>
</span>
<span class="wijmo-wijribbon-list">
<input type="checkbox" id="fontStyleBold"/>
<label for="fontStyleBold" id="bold" title="Bold" class="wijmo-wijribbon-bold"></label>
<input type="checkbox" id="fontStyleItalic"/>
<label for="fontStyleItalic" id="italic" title="Italic" class="wijmo-wijribbon-italic"></label>
<input type="checkbox" id="fontStyleUnderline"/>
<label for="fontStyleUnderline" id="underline" title="Underline" class="wijmo-wijribbon-underline"></label>
<input type="checkbox" id="fontStyleStrikeThrough"/>
<label for="fontStyleStrikeThrough" id="strike" title="Strikethrough" class="wijmo-wijribbon-strike"></label>
<input type="checkbox" id="fontStyleSubscript"/>
<label for="fontStyleSubscript" id="subscript" title="Subscript" class="wijmo-wijribbon-sub"></label>
<input type="checkbox" id="fontStyleSuperscript"/>
<label for="fontStyleSuperscript" id="superscript" title="Superscript" class="wijmo-wijribbon-sup"></label>
</span>
<span class="wijmo-wijribbon-list">
<button title="Template" class="wijmo-wijribbon-template" name="template"></button>
</span>
<span class="wijmo-wijribbon-list">
<button title="RemoveFormat" class="wijmo-wijribbon-removeformat" name="removeformat"></button>
</span>
<div>Font</div>
</li>
</ul>
</div>
<div id="CustomizeTab">
<ul>
<li>
<div title="Table" class="wijmo-wijribbon-splitbutton">
<button title="customize button" name="customcommand">Click Me</button>
</div>
<div>Customize</div>
</li>
</ul>
</div>
</div>
|
- Within the <head> tags, below the references, add the following script to initialize the widget.
Drop down and copy script to paste inside the head tags
Script |
Copy Code
|
<script id="scriptInit" type="text/javascript">
$(document).ready(function () {
$("#ribbon").wijribbon({
click: function (e, cmd) {
alert(cmd.commandName);
}
})
});
</script> |
- Also within the <head> tags, below the script, add the following CSS styles to set the size of the widget.
Drop down and copy styles to paste inside the head tags
Style |
Copy Code
|
<style type="text/css">
#ribbon
{
width: 500px;
}
#actiongroup
{
width: 200px;
}
#fontgroup
{
width: 250px;
}
</style> |
- Save your HTML file and open it in a browser. The ribbon appears like the following live widget.
See Also
Concepts