Initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('shopPackageSearchCtrl', ['$scope', shopPackageSearchCtrl])
|
||||
.directive('shopPackageSearch', [shopPackageSearchDirective]);
|
||||
|
||||
function shopPackageSearchDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'shop/html/shopPackageSearchTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function shopPackageSearchCtrl($scope) {
|
||||
$scope.searchString = global.getParameterByName('search') || '';
|
||||
$scope.searchInPage = searchInPage;
|
||||
$scope.clearSearch = clearSearch;
|
||||
$scope.updateUrl = updateUrl;
|
||||
|
||||
function updateUrl(){
|
||||
const url = $scope.searchString ? '?search=' + $scope.searchString : '?';
|
||||
history.pushState({
|
||||
search: $scope.searchString
|
||||
}, null, url);
|
||||
}
|
||||
|
||||
function searchInPage(event){
|
||||
|
||||
if((event.type && event.type === 'click') || (event.which && event.which === 13)){
|
||||
window.location = 'shop?search=' + $scope.searchString;
|
||||
}
|
||||
}
|
||||
|
||||
function clearSearch(){
|
||||
$scope.searchInPage = '';
|
||||
window.location = 'shop';
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user