123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- /* ------------------------------------------------------------------------------
- *
- * # jQuery UI Widgets
- *
- * Demo JS code for jqueryui_components.html page
- *
- * ---------------------------------------------------------------------------- */
- // Setup module
- // ------------------------------
- var JqueryUiComponents = function() {
- //
- // Setup module components
- //
- // Button
- var _componentUiButton = function() {
- if (!$().button) {
- console.warn('Warning - jQuery UI components are not loaded.');
- return;
- }
- // Basic button
- $('.jui-button').button();
- //
- // With icons
- //
- // Left icon
- $('.jui-button-icon-left').button({
- icon: 'icon-twitter'
- });
- // Right icon
- $('.jui-button-icon-right').button({
- icon: 'icon-dribbble3',
- iconPosition: 'end'
- });
- // Single icon only
- $('.jui-button-icon-only').button({
- icon: 'icon-vimeo',
- showLabel: false
- });
- };
- // Button set
- var _componentUiButtonset = function() {
- if (!$().buttonset) {
- console.warn('Warning - jQuery UI components are not loaded.');
- return;
- }
- // Basic button set
- $('.jui-button-set').buttonset();
- };
- // Control group
- var _componentUiControlgroup = function() {
- if (!$().controlgroup || !$().selectmenu) {
- console.warn('Warning - jQuery UI components are not loaded.');
- return;
- }
- // Basic example
- $('.jui-controlgroup').controlgroup();
- // Split button
- $('.jui-combo').selectmenu({
- classes: {
- 'ui-selectmenu-button': 'ui-button-icon-only'
- },
- position: {
- my: 'right top',
- at: 'right bottom',
- collision: 'none'
- }
- });
- };
- // Progress bar
- var _componentUiProgress = function() {
- if (!$().progressbar) {
- console.warn('Warning - jQuery UI components are not loaded.');
- return;
- }
- // Basic example
- $('.jui-progressbar').progressbar({
- value: 60
- });
- // Maximum value
- $('.jui-progressbar-max').progressbar({
- max: 1000,
- value: 400
- });
- // Indeterminate progress bar
- $('.jui-progressbar-indeterminate').progressbar({
- value: false
- }).on('create', function (event) {
- var target = $(event.target),
- progressbar = $('.jui-progressbar-indeterminate'),
- progressbarValue = progressbar.find('.ui-progressbar-value');
- progressbar.progressbar('option', 'value', false);
- });
- //
- // Custom label
- //
- // Define elements
- var progressbar = $( '.jui-progressbar-custom' ),
- progressLabel = $('.ui-progress-label');
- // Initialize progress bar
- progressbar.progressbar({
- value: false,
- change: function() {
- progressLabel.text(progressbar.progressbar('value') + '%');
- },
- complete: function() {
- progressLabel.text('Complete!');
- }
- });
- // Custom progress function
- function progress() {
- var val = progressbar.progressbar('value') || 0;
- progressbar.progressbar('value', val + 2);
- if (val < 99) {
- setTimeout(progress, 80);
- }
- }
- // Update progress after 2000ms
- setTimeout(progress, 2000);
- };
- // Dialog
- var _componentUiDialog = function() {
- if (!$().dialog) {
- console.warn('Warning - jQuery UI components are not loaded.');
- return;
- }
- // Basic example
- $('#jui-dialog-basic').dialog({
- autoOpen: false,
- width: 400
- });
- // With overlay
- $('#jui-dialog-overlay').dialog({
- autoOpen: false,
- modal: true,
- width: 400
- });
- // Animated
- $('#jui-dialog-animated').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- show: {
- effect: 'fade',
- duration: 500
- },
- hide: {
- effect: 'fade',
- duration: 500
- }
- });
- // With buttons
- $('#jui-dialog-buttons').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- buttons: {
- Save: function() {
- $(this).dialog('close');
- },
- Cancel: function() {
- $(this).dialog('close');
- }
- }
- });
- // Buttons with icons
- $('#jui-dialog-buttons-icons').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- buttons: [
- {
- text: 'Submit',
- icons: {
- primary: 'icon-checkmark5'
- },
- click: function() {
- $(this).dialog('close');
- }
- },
- {
- text: 'Cancel',
- icons: {
- primary: 'icon-cross3'
- },
- click: function() {
- $(this).dialog('close');
- }
- }
- ]
- });
- // Disable resize
- $('#jui-dialog-resize').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- resizable: false
- });
- // Disable close on escape
- $('#jui-dialog-close-escape').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- closeOnEscape: false
- });
- // Disable drag
- $('#jui-dialog-drag-disabled').dialog({
- autoOpen: false,
- modal: true,
- width: 400,
- draggable: false
- });
- // Append to element
- $('#jui-dialog-append').dialog({
- appendTo: '#modal-append-target',
- autoOpen: false,
- modal: true,
- width: 400
- });
- //
- // With forms
- //
- // Vertical form dialog
- $('#jui-dialog-form-vertical').dialog({
- autoOpen: false,
- modal: true,
- width: 500,
- buttons: {
- Submit: function() {
- $(this).dialog('close');
- },
- Cancel: function() {
- $(this).dialog('close');
- }
- }
- });
- // Horizontal form dialog
- $('#jui-dialog-form-horizontal').dialog({
- autoOpen: false,
- modal: true,
- width: 500,
- buttons: {
- Submit: function() {
- $(this).dialog('close');
- },
- Cancel: function() {
- $(this).dialog('close');
- }
- }
- });
- // Inline form dialog
- $('#jui-dialog-form-inline').dialog({
- autoOpen: false,
- modal: true,
- width: 555,
- buttons: {
- Submit: function() {
- $(this).dialog('close');
- },
- Cancel: function() {
- $(this).dialog('close');
- }
- }
- });
- //
- // Optional widths
- //
- // Default width
- $('#jui-dialog-width-default').dialog({
- autoOpen: false,
- modal: true
- });
- // Pixel width
- $('#jui-dialog-width-pixel').dialog({
- autoOpen: false,
- modal: true,
- width: 400
- });
- // Percentage width
- $('#jui-dialog-width-percentage').dialog({
- autoOpen: false,
- modal: true,
- width: '50%'
- });
- // Full width
- $('#jui-dialog-width-full').dialog({
- autoOpen: false,
- modal: true,
- width: '96%'
- });
- //
- // Dialog openers
- //
- $('#jui-dialog-basic-opener').on('click', function() {
- $('#jui-dialog-basic').dialog('open');
- });
- $('#jui-dialog-overlay-opener').on('click', function() {
- $('#jui-dialog-overlay').dialog('open');
- });
- $('#jui-dialog-animated-opener').on('click', function() {
- $('#jui-dialog-animated').dialog('open');
- });
- $('#jui-dialog-buttons-opener').on('click', function() {
- $('#jui-dialog-buttons').dialog('open');
- });
- $('#jui-dialog-buttons-icons-opener').on('click', function() {
- $('#jui-dialog-buttons-icons').dialog('open');
- });
- $('#jui-dialog-resize-opener').on('click', function() {
- $('#jui-dialog-resize').dialog('open');
- });
- $('#jui-dialog-close-escape-opener').on('click', function() {
- $('#jui-dialog-close-escape').dialog('open');
- });
- $('#jui-dialog-drag-disabled-opener').on('click', function() {
- $('#jui-dialog-drag-disabled').dialog('open');
- });
- $('#jui-dialog-append-opener').on('click', function() {
- $('#jui-dialog-append').dialog('open');
- });
- $('#jui-dialog-form-vertical-opener').on('click', function() {
- $('#jui-dialog-form-vertical').dialog('open');
- });
- $('#jui-dialog-form-horizontal-opener').on('click', function() {
- $('#jui-dialog-form-horizontal').dialog('open');
- });
- $('#jui-dialog-form-inline-opener').on('click', function() {
- $('#jui-dialog-form-inline').dialog('open');
- });
- $('#jui-dialog-width-default-opener').on('click', function() {
- $('#jui-dialog-width-default').dialog('open');
- });
- $('#jui-dialog-width-pixel-opener').on('click', function() {
- $('#jui-dialog-width-pixel').dialog('open');
- });
- $('#jui-dialog-width-percentage-opener').on('click', function() {
- $('#jui-dialog-width-percentage').dialog('open');
- });
- $('#jui-dialog-width-full-opener').on('click', function() {
- $('#jui-dialog-width-full').dialog('open');
- });
- };
- //
- // Return objects assigned to module
- //
- return {
- init: function() {
- _componentUiButton();
- _componentUiButtonset();
- _componentUiControlgroup();
- _componentUiProgress();
- _componentUiDialog();
- }
- }
- }();
- // Initialize module
- // ------------------------------
- document.addEventListener('DOMContentLoaded', function() {
- JqueryUiComponents.init();
- });
|