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