Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Widgets: begin updating to ui widgets for 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
arschmitz committed Sep 18, 2014
1 parent 32f471c commit 983e9d1
Show file tree
Hide file tree
Showing 39 changed files with 970 additions and 2,880 deletions.
11 changes: 7 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,10 +1014,13 @@ module.exports = function( grunt ) {
}
},
files: {
"jquery-ui/jquery.ui.core.js": "jquery-ui/ui/jquery.ui.core.js",
"jquery-ui/jquery.ui.widget.js": "jquery-ui/ui/jquery.ui.widget.js",
"jquery-ui/jquery.ui.tabs.js": "jquery-ui/ui/jquery.ui.tabs.js",
"jquery-ui/MIT-LICENSE.txt": "jquery-ui/MIT-LICENSE.txt"
"jquery-ui/core.js": "jquery-ui/ui/core.js",
"jquery-ui/widget.js": "jquery-ui/ui/widget.js",
"jquery-ui/tabs.js": "jquery-ui/ui/tabs.js",
"jquery-ui/button.js": "jquery-ui/ui/button.js",
"jquery-ui/checkboxradio.js": "jquery-ui/ui/checkboxradio.js",
"jquery-ui/controlgroup.js": "jquery-ui/ui/controlgroup.js",
"jquery-ui/LICENSE.txt": "jquery-ui/LICENSE.txt"
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"dependencies": {
"jquery": "1.11.1",
"jquery-ui": "jquery/jquery-ui#c0ab71056b936627e8a7821f03c044aec6280a40"
"jquery-ui": "jquery/jquery-ui#button"
},
"devDependencies": {
"requirejs": "2.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Copyright 2013 jQuery Foundation and other contributors,
http://jqueryui.com/
Copyright 2007, 2014 jQuery Foundation and other contributors,
https://jquery.org/

This software consists of voluntary contributions made by many
individuals (AUTHORS.txt, http://jqueryui.com/about) For exact
contribution history, see the revision history and logs, available
at http://jquery-ui.googlecode.com/svn/
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery-ui

The following license applies to all parts of this software except as
documented below:

====

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -24,3 +28,17 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

====

Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code contained within the demos directory.

CC0: http://creativecommons.org/publicdomain/zero/1.0/

====

All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.
209 changes: 209 additions & 0 deletions external/jquery-ui/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/*!
* jQuery UI Button button
* http://jqueryui.com
*
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/button/
*/
(function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define([
"jquery",
"./core",
"./widget"
], factory );
} else {

// Browser globals
factory( jQuery );
}
}(function( $ ) {

var baseClasses = "ui-widget ui-corner-all",
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons" +
" ui-button-text-only ui-icon-beginning ui-icon-end ui-icon-top ui-icon-bottom",
formResetHandler = function() {
var form = $( this );
setTimeout(function() {
form.find( ".ui-button" ).filter( ":ui-button" ).button( "refresh" );
});
};

$.widget( "ui.button", {
version: "button",
defaultElement: "<button>",
options: {
disabled: null,
showLabel: true,
label: null,
icon: null,
iconPosition: "beginning",
classes: {
"ui-button": "ui-corner-all",
"ui-button-icon-only": null,
"ui-button-icon": null
}
},

_getCreateOptions: function() {
var disabled,
options = {};

this.isInput = this.element.is( "input" );
this.originalLabel = this.isInput ? this.element.val() : this.element.html();

disabled = this.element.prop( "disabled" );
if ( disabled != null ) {
options.disabled = disabled;
}

if ( this.originalLabel ) {
options.label = this.originalLabel;
}

return options;
},

_create: function() {
var formElement = $( this.element[ 0 ].form );

// We don't use _on and _off here because we want all the checkboxes in the same form to use
// single handler which handles all the checkboxradio widgets in the form
formElement.off( "reset" + this.eventNamespace, formResetHandler );
formElement.on( "reset" + this.eventNamespace, formResetHandler );

if ( this.options.disabled == null ) {
this.options.disabled = this.element.prop( "disabled" ) || false;
}

this._enhance();

if ( this.element.is( "a" ) ) {
this._on({
"keyup": function( event ) {
if ( event.keyCode === $.ui.keyCode.SPACE ) {
this.element[0].click();
}
}
});
}
},

_enhance: function() {
this._setOption( "disabled", this.options.disabled );

this.element.addClass( this._classes( "ui-button" ) + " " + baseClasses ).attr( "role", "button" );

// Check to see if the label needs to be set or if its already correct
if ( this.options.label && this.options.label !== this.originalLabel ) {
if ( this.isInput ) {
this.element.val( this.options.label );
} else {
this.element.html( this.options.label );
}
}
if ( this.options.icon ) {
this._updateIcon( this.options.icon )._updateTooltip();
}
},

_updateTooltip: function() {
this.title = this.element.attr( "title" );
this.noTitle = !this.title;

if ( !this.options.showLabel && !this.noTitle ){
this.element.attr( "title", this.options.label );
}
},

_updateIcon: function( icon ) {
if ( !this.icon ) {
this.icon = $( "<span>" ).addClass( this._classes( "ui-button-icon" ) + " ui-icon" );
this.element.addClass( "ui-icon-" + this.options.iconPosition );

if ( !this.options.showLabel ){
this.element.addClass( this._classes( "ui-button-icon-only" ) );
}
} else {
this.icon.removeClass( this.options.icon );
}

this.icon.addClass( icon ).appendTo( this.element );
return this;
},

_destroy: function() {
this.element
.removeClass( this._classes( "ui-button ui-button-icon-only" ) + " " + baseClasses + " ui-state-active " + typeClasses )
.removeAttr( "role" );

if ( this.icon ) {
this.icon.remove();
}
if ( !this.hasTitle ) {
this.element.removeAttr( "title" );
}
},

_setOption: function( key, value ) {
if ( key === "icon" ) {
if ( value !== null ) {
this._updateIcon( value );
} else {
this.icon.remove();
this.element.removeClass( this._classes( "ui-button-icon" ) + " ui-icon-" + this.options.iconPosition );
}
}

// Make sure we cant end up with a button that has no text nor icon
if ( key === "showLabel" ) {
if ( ( !value && !this.options.icon ) || value ) {
this.element.toggleClass( this._classes( "ui-button-icon-only" ), !value )
.toggleClass( this.options.iconPosition, !!value );
this._updateTooltip();
} else {
value = true;
}
}
if ( key === "iconPosition" && this.options.icon ) {
this.element.addClass( value ).removeClass( this.options.iconPosition );
}
if ( key === "label" ) {
if ( this.isInput ) {
this.element.val( value );
} else {
// If there us an icon append it else nothing then append the value
// this avoids removal of the icon when setting label text
this.element.html( !!this.icon ? "" : this.icon ).append( value );
}
}
this._super( key, value );
if ( key === "disabled" ) {
this.element.toggleClass( "ui-state-disabled", value ).prop( "disabled", value ).blur();
}
},

refresh: function() {

// Make sure to only check disabled if its an element that supports this otherwise
// check for the disabled class to determine state
var isDisabled = this.element.is( "input, button" ) ?
this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );

if ( isDisabled !== this.options.disabled ) {
this._setOptions({ "disabled": isDisabled });
}

this._updateTooltip();
}

});

return $.ui.button;

}));
Loading

0 comments on commit 983e9d1

Please sign in to comment.