Skip to content

Commit

Permalink
Updated distribution to version 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Semantic-Pusher-Robot committed Jul 20, 2015
1 parent 1417771 commit 9c1b639
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 27 deletions.
15 changes: 14 additions & 1 deletion definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ $.api = $.fn.api = function(parameters) {
}
else {
module.verbose('Found required variable', variable, value);
url = url.replace(templatedString, value);
url = url.replace(templatedString, module.get.urlEncodedValue(value));
}
});
}
Expand Down Expand Up @@ -686,6 +686,19 @@ $.api = $.fn.api = function(parameters) {
: settings
;
},
urlEncodedValue: function(value) {
var
decodedValue = window.decodeURIComponent(value),
encodedValue = window.encodeURIComponent(value),
alreadyEncoded = (decodedValue !== value)
;
if(alreadyEncoded) {
module.debug('URL value is already encoded, avoiding double encoding', value);
return value;
}
module.verbose('Encoding value for url', value, encodedValue);
return encodedValue;
},
defaultData: function() {
var
data = {}
Expand Down
2 changes: 1 addition & 1 deletion definitions/collections/message.less
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
}
.ui.icon.message > .icon:not(.close) {
display: block;
flex: 0 1 auto;
flex: 0 0 auto;
width: auto;
line-height: 1;
vertical-align: @iconVerticalAlign;
Expand Down
17 changes: 14 additions & 3 deletions definitions/modules/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ $.fn.checkbox = function(parameters) {
$label = $(this).children(selector.label),
$input = $(this).children(selector.input),

shortcutPressed = false,

instance = $module.data(moduleNamespace),

observer,
Expand Down Expand Up @@ -192,11 +194,19 @@ $.fn.checkbox = function(parameters) {
if(key == keyCode.escape) {
module.verbose('Escape key pressed blurring field');
$input.blur();
event.preventDefault();
shortcutPressed = true;
}
if(!event.ctrlKey && (key == keyCode.enter)) {
module.verbose('Enter key pressed, toggling checkbox');
else if(!event.ctrlKey && ( key == keyCode.space || key == keyCode.enter) ) {
module.verbose('Enter/space key pressed, toggling checkbox');
module.toggle();
shortcutPressed = true;
}
else {
shortcutPressed = false;
}
},
keyup: function(event) {
if(shortcutPressed) {
event.preventDefault();
}
}
Expand Down Expand Up @@ -455,6 +465,7 @@ $.fn.checkbox = function(parameters) {
$module
.on('click' + eventNamespace, module.event.click)
.on('keydown' + eventNamespace, selector.input, module.event.keydown)
.on('keyup' + eventNamespace, selector.input, module.event.keyup)
;
}
},
Expand Down
6 changes: 6 additions & 0 deletions definitions/modules/checkbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@
background-color: @radioFocusBulletColor;
}

/* Indeterminate */
.ui.radio.checkbox input:indeterminate ~ .box:after,
.ui.radio.checkbox input:indeterminate ~ label:after {
opacity: 0;
}

/* Active */
.ui.radio.checkbox input:checked ~ .box:before,
.ui.radio.checkbox input:checked ~ label:before {
Expand Down
81 changes: 61 additions & 20 deletions definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,19 @@ $.fn.dropdown = function(parameters) {
.html( templates.dropdown(selectValues) )
.insertBefore($input)
;
if($input.hasClass(className.multiple) && $input.prop('multiple') === false) {
module.error(error.missingMultiple);
$input.prop('multiple', true);
}
if($input.is('[multiple]')) {
module.set.multiple();
}
$input
.removeAttr('class')
.detach()
.prependTo($module)
;
}
if($input.is('[multiple]')) {
module.set.multiple();
}
module.refresh();
},
menu: function(values) {
Expand Down Expand Up @@ -1449,8 +1453,8 @@ $.fn.dropdown = function(parameters) {
if(value === '') {
return '';
}
return (!$input.is('select') && module.is.multiple())
? typeof value == 'string'
return ( !module.has.selectInput() && module.is.multiple() )
? (typeof value == 'string') // delimited string
? value.split(settings.delimiter)
: ''
: value
Expand Down Expand Up @@ -2091,8 +2095,8 @@ $.fn.dropdown = function(parameters) {
}
}

if( $input.is('select') && (settings.allowAdditions || settings.apiSettings) ) {
module.debug('Adding an option to the select before setting the value', value);
if( module.is.single() && module.has.selectInput() && module.can.extendSelect() ) {
module.debug('Adding user option', value);
module.add.optionValue(value);
}

Expand Down Expand Up @@ -2266,8 +2270,13 @@ $.fn.dropdown = function(parameters) {
selectObserver.disconnect();
module.verbose('Temporarily disconnecting mutation observer', value);
}
if( module.is.single() ) {
module.verbose('Removing previous user addition');
$input.find('option.' + className.addition).remove();
}
$('<option/>')
.prop('value', value)
.addClass(className.addition)
.html(value)
.appendTo($input)
;
Expand Down Expand Up @@ -2348,7 +2357,7 @@ $.fn.dropdown = function(parameters) {
module.debug('Cannot select blank values from multiselect');
return;
}
// extend currently array
// extend current array
if($.isArray(currentValue)) {
newValue = currentValue.concat([addedValue]);
newValue = module.get.uniqueArray(newValue);
Expand All @@ -2357,8 +2366,8 @@ $.fn.dropdown = function(parameters) {
newValue = [addedValue];
}
// add values
if($input.is('select')) {
if(settings.allowAdditions || settings.apiSettings) {
if( module.has.selectInput() ) {
if(module.can.extendSelect()) {
module.debug('Adding value to select', addedValue, newValue, $input);
module.add.optionValue(addedValue);
}
Expand Down Expand Up @@ -2413,6 +2422,28 @@ $.fn.dropdown = function(parameters) {
$item.removeClass(className.filtered);
}
},
optionValue: function(value) {
var
$option = $input.find('option[value="' + value + '"]'),
hasOption = ($option.length > 0)
;
if(!hasOption || !$option.hasClass(className.addition)) {
return;
}
// temporarily disconnect observer
if(selectObserver) {
selectObserver.disconnect();
module.verbose('Temporarily disconnecting mutation observer', value);
}
$option.remove();
module.verbose('Removing user addition as an <option>', value);
if(selectObserver) {
selectObserver.observe($input[0], {
childList : true,
subtree : true
});
}
},
message: function() {
$menu.children(selector.message).remove();
},
Expand Down Expand Up @@ -2466,16 +2497,16 @@ $.fn.dropdown = function(parameters) {
},
value: function(removedValue, removedText, $removedItem) {
var
values = $input.val(),
values = module.get.values(),
newValue
;
if( $input.is('select') ) {
if( module.has.selectInput() ) {
module.verbose('Input is <select> removing selected option', removedValue);
newValue = module.remove.arrayValue(removedValue, values);
module.remove.optionValue(removedValue);
}
else {
module.verbose('Removing from delimited values', removedValue);
values = values.split(settings.delimiter);
newValue = module.remove.arrayValue(removedValue, values);
newValue = newValue.join(settings.delimiter);
}
Expand All @@ -2489,6 +2520,9 @@ $.fn.dropdown = function(parameters) {
module.check.maxSelections();
},
arrayValue: function(removedValue, values) {
if( !$.isArray(values) ) {
values = [values];
}
values = $.grep(values, function(value){
return (removedValue != value);
});
Expand Down Expand Up @@ -2567,6 +2601,9 @@ $.fn.dropdown = function(parameters) {
search: function() {
return ($search.length > 0);
},
selectInput: function() {
return ( $input.is('select') );
},
firstLetter: function($item, letter) {
var
text,
Expand Down Expand Up @@ -2744,6 +2781,9 @@ $.fn.dropdown = function(parameters) {
click: function() {
return (hasTouch || settings.on == 'click');
},
extendSelect: function() {
return settings.allowAdditions || settings.apiSettings;
},
show: function() {
return !module.is.disabled() && (module.has.items() || module.has.message());
},
Expand Down Expand Up @@ -3147,13 +3187,14 @@ $.fn.dropdown.settings = {
},

error : {
action : 'You called a dropdown action that was not defined',
alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown',
labels : 'Allowing user additions currently requires the use of labels.',
method : 'The method you called is not defined.',
noAPI : 'The API module is required to load resources remotely',
noStorage : 'Saving remote data requires session storage',
noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>'
action : 'You called a dropdown action that was not defined',
alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown',
labels : 'Allowing user additions currently requires the use of labels.',
missingMultiple : '<select> requires multiple property to be set to correctly preserve multiple values',
method : 'The method you called is not defined.',
noAPI : 'The API module is required to load resources remotely',
noStorage : 'Saving remote data requires session storage',
noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>'
},

regExp : {
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var
Package.describe({
name : 'semantic:ui',
summary : 'Semantic UI - LESS Release of Semantic UI',
version : '2.0.4',
version : '2.0.5',
git : 'git://github.com/Semantic-Org/Semantic-UI-LESS.git',
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "semantic-ui-less",
"version": "2.0.4",
"version": "2.0.5",
"title": "Semantic UI",
"description": "LESS Only distribution of Semantic UI",
"homepage": "http://www.semantic-ui.com",
Expand Down

0 comments on commit 9c1b639

Please sign in to comment.