diff --git a/module/doc/control.php b/module/doc/control.php index 237498eb20..767dc9a469 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -485,7 +485,8 @@ class doc extends control if($objectType == 'module') $table = TABLE_MODULE; $collectors = $this->dao->select('collector')->from($table)->where('id')->eq($objectID)->fetch('collector'); - if(strpos($collectors, ",{$this->app->user->account},") !== false) + $hasCollect = strpos($collectors, ",{$this->app->user->account},") !== false; + if($hasCollect) { $collectors = str_replace(",{$this->app->user->account},", ',', $collectors); } @@ -500,7 +501,7 @@ class doc extends control $this->dao->update($table)->set('collector')->eq($collectors)->where('id')->eq($objectID)->exec(); - die(js::reload('parent')); + $this->send(array('status' => $hasCollect ? 'no' : 'yes')); } /** diff --git a/module/doc/js/common.js b/module/doc/js/common.js index 86ff939890..9c2ad11877 100644 --- a/module/doc/js/common.js +++ b/module/doc/js/common.js @@ -22,7 +22,7 @@ $(document).ready(function() { trigger: '.lib', selector: '.lib', - finish: function() + finish: function() { var orders = {}; var orderNext = 1; @@ -176,4 +176,24 @@ $(document).ready(function() $pageSetting.parent().removeClass('open'); }).on('click', function(e){e.stopPropagation()}); } + + $('.ajaxCollect').mousedown(function (event) { + var obj = $(this); + var url = obj.data('url'); + $.get(url, function(response) + { + if(response.status == 'yes') + { + obj.children('i').removeClass().addClass('icon icon-star text-yellow'); + obj.parent().prev().children('.file-name').children('i').remove('.icon'); + obj.parent().prev().children('.file-name').prepend(' '); + } + else + { + obj.children('i').removeClass().addClass('icon icon-star-empty'); + obj.parent().prev().children('.file-name').children('i').remove(".icon"); + } + }, 'json'); + return false; + }); }); diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index ba792bf159..d1327c1eec 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -90,7 +90,7 @@ var browseType = '';