|
|
@ -10,7 +10,8 @@ define(['../app', 'angular', 'jquery', 'css!../css/multiLevelSelect'], function
|
|
|
|
multiLevelSelectPopup: '=',
|
|
|
|
multiLevelSelectPopup: '=',
|
|
|
|
childrenKey: '@',
|
|
|
|
childrenKey: '@',
|
|
|
|
labelKey: '@',
|
|
|
|
labelKey: '@',
|
|
|
|
onSelect: '&'
|
|
|
|
onSelect: '&',
|
|
|
|
|
|
|
|
choseOneLevel: '='
|
|
|
|
},
|
|
|
|
},
|
|
|
|
link: function (scope, element, attr) {
|
|
|
|
link: function (scope, element, attr) {
|
|
|
|
var selectBox,bg;
|
|
|
|
var selectBox,bg;
|
|
|
@ -27,8 +28,8 @@ define(['../app', 'angular', 'jquery', 'css!../css/multiLevelSelect'], function
|
|
|
|
top: (offset.top + $(this).outerHeight() + 3) + 'px',
|
|
|
|
top: (offset.top + $(this).outerHeight() + 3) + 'px',
|
|
|
|
left: offset.left + 'px'
|
|
|
|
left: offset.left + 'px'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
var container = $('<div></div>').appendTo(selectBox);
|
|
|
|
var container = $('<div style="border: 1px solid #bbb6b5;"></div>').appendTo(selectBox);
|
|
|
|
initSelectLevel(container, scope.multiLevelSelectPopup, 0);
|
|
|
|
initSelectLevel(container, scope.multiLevelSelectPopup, 0, scope.choseOneLevel);
|
|
|
|
var $body = $('body');
|
|
|
|
var $body = $('body');
|
|
|
|
selectBox.appendTo($body);
|
|
|
|
selectBox.appendTo($body);
|
|
|
|
bg = $('<div></div>').css({position:'fixed',top:0,left:0,right:0,bottom:0,zIndex:9998}).appendTo($body);
|
|
|
|
bg = $('<div></div>').css({position:'fixed',top:0,left:0,right:0,bottom:0,zIndex:9998}).appendTo($body);
|
|
|
@ -40,8 +41,7 @@ define(['../app', 'angular', 'jquery', 'css!../css/multiLevelSelect'], function
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initSelectLevel(container, list, groupIndex, choseOneLevel) {
|
|
|
|
function initSelectLevel(container, list, groupIndex) {
|
|
|
|
|
|
|
|
if (selectGroups[groupIndex]) {
|
|
|
|
if (selectGroups[groupIndex]) {
|
|
|
|
var groups = selectGroups.splice(groupIndex, 999);
|
|
|
|
var groups = selectGroups.splice(groupIndex, 999);
|
|
|
|
angular.forEach(groups, function (group) {
|
|
|
|
angular.forEach(groups, function (group) {
|
|
|
@ -61,7 +61,8 @@ define(['../app', 'angular', 'jquery', 'css!../css/multiLevelSelect'], function
|
|
|
|
scope.onSelect({$selected: item});
|
|
|
|
scope.onSelect({$selected: item});
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}catch(err){}
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
}
|
|
|
|
selectBox.remove();
|
|
|
|
selectBox.remove();
|
|
|
|
bg.remove();
|
|
|
|
bg.remove();
|
|
|
|
selectBox = null;
|
|
|
|
selectBox = null;
|
|
|
@ -74,10 +75,25 @@ define(['../app', 'angular', 'jquery', 'css!../css/multiLevelSelect'], function
|
|
|
|
li.addClass('active');
|
|
|
|
li.addClass('active');
|
|
|
|
initSelectLevel(container, item.children, groupIndex + 1);
|
|
|
|
initSelectLevel(container, item.children, groupIndex + 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (choseOneLevel) {
|
|
|
|
|
|
|
|
li.click(function () {
|
|
|
|
|
|
|
|
if (angular.isFunction(scope.onSelect)) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
scope.$apply(function () {
|
|
|
|
|
|
|
|
scope.onSelect({$selected: item});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}catch(err){}
|
|
|
|
|
|
|
|
selectBox.remove();
|
|
|
|
|
|
|
|
bg.remove();
|
|
|
|
|
|
|
|
selectBox = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}])
|
|
|
|
}])
|
|
|
|
});
|
|
|
|
});
|
|
|
|