Skip to content

Commit

Permalink
Merge pull request #1 from blubzel/master
Browse files Browse the repository at this point in the history
Fixed pickResizeHandler.
  • Loading branch information
delkant authored Aug 24, 2016
2 parents 772b77d + dd1f759 commit 8a3bc67
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions angular-areas.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
var getParameters = function(){
$scope.ngAreas_areas = $scope.$eval($attrs.ngAreas);
console.log(JSON.stringify($scope.ngAreas_areas));
return {
return {
width : (typeof $attrs.ngAreasWidth === 'undefined') ? 800 : $attrs.ngAreasWidth,
areas : (typeof $attrs.ngAreas ==='undefined') ? [] : $scope.ngAreas_areas,
onLoaded : (typeof $attrs.ngAreasOnLoad === 'undefined') ? null: $scope.$eval($attrs.ngAreasOnLoad),
Expand All @@ -25,33 +25,33 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
allowResize: (typeof allow.resize === 'undefined') ? true :allow.resize,
allowSelect: (typeof allow.select === 'undefined') ? true :allow.select,
allowDelete: (typeof allow.remove === 'undefined') ? true :allow.remove,
allowNudge: (typeof allow.nudge === 'undefined') ? true :allow.nudge
allowNudge: (typeof allow.nudge === 'undefined') ? true :allow.nudge
};
}
var destroy = function(){
console.log('ngAreas:destroy');
mainImageSelectAreas.destroy();
}

var reload = function(){
console.log('ngAreas:reload');
mainImageSelectAreas.init($element, getParameters());
console.log('global Areas: '+JSON.stringify(ngAreas._areas));
}

var renameByAreaId = function(event, args) {
var areaid = args.areaid;
var name = args.name;
mainImageSelectAreas.renameArea(areaid, name);
$(".name-area-id-"+areaid).html(name);
}

$scope.$on("ngAreas:reload", reload);

$scope.$on("ngAreas:destroy", destroy);

$scope.$on("ngAreas:renameByAreaId", renameByAreaId);

$element.css('display', 'none');
$element.bind('load', function() {
mainImageSelectAreas.init($element, getParameters());
Expand All @@ -61,7 +61,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
$element.bind('error', function(){
$.error( "Method " + customOptions + " on load error" );
});

$scope.imageArea = function(parent, areaid) {
var options = parent.options,
$image = parent.$image,
Expand Down Expand Up @@ -148,7 +148,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {

// Update the selection layer
$selection.addClass(area.cssClass);

$selection.css({
backgroundPosition : ( - area.x - 1) + "px " + ( - area.y - 1) + "px",
cursor : options.allowMove ? "move" : "default",
Expand Down Expand Up @@ -309,7 +309,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
cancelEvent(event);
focus();

var card = event.target.className.split(" ")[1];
var card = event.target.className.split(" ")[2];
if (card[card.length - 1] === "w") {
selectionOrigin[0] += area.width;
area.x = selectionOrigin[0] - area.width;
Expand Down Expand Up @@ -371,7 +371,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
if (resizeVertically) {
area.height = height;
}

if (area.width < 0) {
area.width = Math.abs(area.width);
area.x = selectionOrigin[0] - area.width;
Expand All @@ -384,7 +384,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
} else {
area.y = selectionOrigin[1];
}

fireEvent("changing");
refresh("resizeSelection");
},
Expand Down Expand Up @@ -439,15 +439,15 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
// Reset the resize constraints
resizeHorizontally = true;
resizeVertically = true;

if(typeof area.id === 'undefined' && area.newBox ){
area.newBox = false;
delete area.newBox;
fireEvent("onAdd");
}else{
fireEvent("changed");
}

refresh("releaseSelection");
},
deleteSelection = function (event) {
Expand Down Expand Up @@ -584,7 +584,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
};
};


imageSelectAreas.prototype.init = function (object, customOptions) {
var that = this,
defaultOptions = {
Expand Down Expand Up @@ -641,7 +641,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
if (this.options.onLoaded) {
this.$image.on("loaded", this.options.onLoaded);
}

// Initialize an image holder
this.$holder = $("<div class=\"ngAreas-element ngAreas-holder\"/>")
.css({
Expand Down Expand Up @@ -716,7 +716,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
});
}
};

imageSelectAreas.prototype.applyRatio = function (area) {
var that = this;
var apply = function (val){
Expand All @@ -728,7 +728,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
tmp.y = apply(tmp.y);
tmp.width = apply(tmp.width);
tmp.height = apply(tmp.height);

return tmp;
};

Expand All @@ -743,10 +743,10 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
tmp.y = removeIt(tmp.y);
tmp.width = removeIt(tmp.width);
tmp.height = removeIt(tmp.height);

return tmp;
};


imageSelectAreas.prototype._refresh = function () {
var nbAreas = this.areas().length;
Expand Down Expand Up @@ -865,7 +865,7 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
});
return ret;
};

imageSelectAreas.prototype.renameArea = function (areaid, name) {
this._eachArea(function (area) {
if(area.getData().areaid===areaid){
Expand All @@ -889,8 +889,8 @@ ngAreas.directive("ngAreas", ['$parse', function ($parse) {
});
return res;
};


var execCommand = function (currentObject, command){
if ( imageSelectAreas.prototype[command] ) { // Method call
var ret = imageSelectAreas.prototype[ command ].apply( $scope.selectAreas(currentObject), Array.prototype.slice.call( arguments, 1 ));
Expand Down

0 comments on commit 8a3bc67

Please sign in to comment.