Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
chore(build): Build v0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlee44 committed Jun 29, 2014
1 parent 44e3c47 commit 89ac649
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 87 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# v0.3.2 (2014/6/29)
## Bug Fixes
- **macAutocomplete:**
- Fixed not querying data correctly
([aaf8f7c9](https://github.com/StartTheShift/MacGyver/commit/aaf8f7c9fcadd6e06885853e4620f976475f3a89))
- Fixed not able to select item using mouse
([f644f3f5](https://github.com/StartTheShift/MacGyver/commit/f644f3f5c53ffecf70136ea713caf2cb912b3e09))
- Fixed scope not destroyed correctly
([5ea9ab0c](https://github.com/StartTheShift/MacGyver/commit/5ea9ab0cea6d1f96915b663fb1187b428fff6875))

## Optimizations
- **macAutocomplete:** Reduced parsing when update items
([29121368](https://github.com/StartTheShift/MacGyver/commit/29121368f5d574bb859e2dacaf8a0af23b0e6f25))


# v0.3.1 (2014/6/27)
## Bug Fixes
- **macAutocomplete:** Fixed not able to select item when clicking on dropdown
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MacGyver",
"version": "0.3.1",
"version": "0.3.2",
"main": [
"lib/img/ui-bg_flat_0_aaaaaa_40x100.png",
"lib/img/ui-bg_glass_75_ffffff_1x400.png",
Expand Down
93 changes: 53 additions & 40 deletions lib/macgyver-core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MacGyver v0.3.1
* MacGyver v0.3.2
* @link http://starttheshift.github.io/MacGyver
* @license MIT
*/
Expand Down Expand Up @@ -764,7 +764,7 @@ angular.module("Mac").directive("macAutocomplete", [
replace: true,
require: "ngModel",
link: function($scope, element, attrs, ctrl, transclude) {
var $menuScope, appendMenu, autocompleteUrl, clickHandler, currentAutocomplete, delay, disabled, getData, hide, inside, isMenuAppended, labelGetter, labelKey, menuEl, onError, onSelect, onSelectBool, onSuccess, positionMenu, queryData, queryKey, reset, source, timeoutId, updateItem;
var $menuScope, appendMenu, autocompleteUrl, blurHandler, currentAutocomplete, delay, disabled, getData, inside, isMenuAppended, labelGetter, labelKey, menuEl, onError, onSelect, onSuccess, positionMenu, preventBlur, preventParser, queryData, queryKey, reset, source, timeoutId, updateItem;
labelKey = attrs.macAutocompleteLabel || "name";
labelGetter = $parse(labelKey);
queryKey = attrs.macAutocompleteQuery || "q";
Expand All @@ -779,13 +779,36 @@ angular.module("Mac").directive("macAutocomplete", [
currentAutocomplete = [];
timeoutId = null;
isMenuAppended = false;
onSelectBool = false;
preventParser = false;
preventBlur = false;
$menuScope = $scope.$new();
$menuScope.items = [];
$menuScope.index = 0;
$menuScope.select = function(index) {
var label, selected;
selected = currentAutocomplete[index];
onSelect($scope, {
selected: selected
});
label = $menuScope.items[index].label || "";
preventParser = true;
if (attrs.ngModel != null) {
ctrl.$setViewValue(label);
ctrl.$render();
}
return reset();
};
$menuScope.onMousedown = function($event) {
$event.preventDefault();
preventBlur = true;
return $timeout(function() {
return preventBlur = false;
}, 0, false);
};
menuEl = angular.element(document.createElement("mac-menu"));
menuEl.attr({
"ng-class": attrs.macMenuClass || null,
"ng-mousedown": "onMousedown($event)",
"mac-menu-items": "items",
"mac-menu-select": "select(index)",
"mac-menu-index": "index"
Expand All @@ -795,7 +818,7 @@ angular.module("Mac").directive("macAutocomplete", [
});
$compile(menuEl)($menuScope);
ctrl.$parsers.push(function(value) {
if (value && !disabled($scope) && !onSelectBool) {
if (value && !disabled($scope) && !preventParser) {
if (timeoutId != null) {
$timeout.cancel(timeoutId);
}
Expand All @@ -806,22 +829,26 @@ angular.module("Mac").directive("macAutocomplete", [
} else {
queryData(value);
}
} else if (isMenuAppended) {
hide();
} else {
reset();
}
onSelectBool = false;
preventParser = false;
return value;
});

/*
@name clickHandler
@name blurHandler
@description
Create a click handler function to make sure directive is unbinding
Create a blur handler function to make sure directive is unbinding
the correct handler
*/
clickHandler = function() {
blurHandler = function() {
if (preventBlur) {
preventBlur = false;
return;
}
return $scope.$apply(function() {
return hide();
return reset();
});
};

Expand All @@ -834,7 +861,7 @@ angular.module("Mac").directive("macAutocomplete", [
*/
appendMenu = function(callback) {
if (!isMenuAppended) {
element.bind("blur", clickHandler);
element.bind("blur", blurHandler);
}
isMenuAppended = true;
if (inside) {
Expand All @@ -851,16 +878,13 @@ angular.module("Mac").directive("macAutocomplete", [
Resetting autocomplete
*/
reset = function() {
$menuScope.items.length = 0;
return hide();
};
hide = function() {
$animate.leave(menuEl, function() {
$menuScope.index = 0;
$menuScope.items.length = 0;
menuEl[0].style.top = "";
menuEl[0].style.left = "";
isMenuAppended = false;
return element.unbind("blur", clickHandler);
return element.unbind("blur", blurHandler);
});
};

Expand Down Expand Up @@ -897,20 +921,23 @@ angular.module("Mac").directive("macAutocomplete", [
if (data == null) {
data = [];
}
$menuScope.items.length = 0;
if (data.length > 0) {
currentAutocomplete = data;
$menuScope.items = data.map(function(item) {
var label;
if (angular.isObject(item)) {
label = labelGetter(item) || "";
if (item.value == null) {
item.value = labelGetter(item) || "";
}
if (item.label == null) {
item.label = labelGetter(item) || "";
}
return item;
} else {
label = item;
return {
label: item,
value: item
};
}
return {
label: label,
value: label
};
});
return appendMenu(positionMenu);
}
Expand Down Expand Up @@ -975,20 +1002,6 @@ angular.module("Mac").directive("macAutocomplete", [
}
}
};
$menuScope.select = function(index) {
var label, selected;
selected = currentAutocomplete[index];
onSelect($scope, {
selected: selected
});
label = $menuScope.items[index].label || "";
onSelectBool = true;
if (attrs.ngModel != null) {
ctrl.$setViewValue(label);
ctrl.$render();
}
return reset();
};
element.bind("keydown", function(event) {
if ($menuScope.items.length === 0) {
return true;
Expand All @@ -1014,7 +1027,7 @@ angular.module("Mac").directive("macAutocomplete", [
break;
case keys.ESCAPE:
$scope.$apply(function() {
hide();
reset();
return event.preventDefault();
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/macgyver-datepicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MacGyver v0.3.1
* MacGyver v0.3.2
* @link http://starttheshift.github.io/MacGyver
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/macgyver-filters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MacGyver v0.3.1
* MacGyver v0.3.2
* @link http://starttheshift.github.io/MacGyver
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/macgyver-string-filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MacGyver v0.3.1
* MacGyver v0.3.2
* @link http://starttheshift.github.io/MacGyver
* @license MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/macgyver-table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* MacGyver v0.3.1
* MacGyver v0.3.2
* @link http://starttheshift.github.io/MacGyver
* @license MIT
*/
Expand Down
Loading

0 comments on commit 89ac649

Please sign in to comment.