public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $ajaxResponseObject->setStatus("ok"); $jswrapper = new \Widgets\JSWrapper(); $trashbinModel = new \Explorer\Model\Trashbin($this->trashbin); $js = "jQuery('#{$this->id}').addClass('justTrashed').removeClass('listviewer-item-selected').find('input:checkbox').attr('disabled', 'disabled');\n\t\t\t var checkbox = document.getElementById('{$this->id}_checkbox');\n\t\t\t if (!checkbox) {\n\t\t\t \t\tlocation.reload();\n\t\t\t } else {\n\t\t\t \tcheckbox.checked = false;\n\t\t\t \tdocument.getElementById('{$this->id}').onclick_restore = document.getElementById('{$this->id}').onclick;\n\t\t\t \tdocument.getElementById('{$this->id}').onclick = \"\";\n\t\t \tdocument.getElementById('trashbinIconbarWrapper').innerHTML = '" . $trashbinModel->getIconbarHtml() . "';\n\t\t\t }"; $jswrapper->setJs($js); $ajaxResponseObject->addWidget($jswrapper); return $ajaxResponseObject; }
public function getIconBarEntries() { $currentUser = $GLOBALS["STEAM"]->get_current_steam_user(); $trashbin = $currentUser->get_attribute(USER_TRASHBIN); $trashbinModel = new \Explorer\Model\Trashbin($trashbin); //$trashbinCount = count($trashbin->get_inventory()); $trashbinCount = 1; $clipboardModel = new \Explorer\Model\Clipboard($currentUser); //$clipboardCount = count($currentUser->get_inventory()); $clipboardCount = 1; return array(array("name" => "<div id=\"clipboardIconbarWrapper\">" . $clipboardModel->getIconbarHtml() . "</div>", "menu" => $clipboardCount > 0 ? array(array("name" => "Objekte hier einfügen", "onclick" => "sendRequest('Paste', {'env':jQuery('#environment').attr('value')}, '', 'popup', null, null, 'explorer');"), array("name" => "Zwischenablage leeren", "onclick" => "sendRequest('EmptyClipboard', {}, '', 'popup', null, null, 'explorer');")) : ""), array("name" => "<div id=\"trashbinIconbarWrapper\">" . $trashbinModel->getIconbarHtml() . "</div>", "menu" => $trashbinCount > 0 ? array(array("name" => "Papierkorb leeren", "onclick" => "sendRequest('EmptyTrashbin', {}, '', 'popup', null, null, 'explorer');"), array("name" => "Papierkorb öffnen")) : "")); }
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject) { $ajaxResponseObject->setStatus("ok"); if (isset($this->params["fromNameSpace"]) && $this->params["fromNameSpace"] === "Trashbin") { $reloadId = \lms_steam::get_current_user()->get_trashbin()->get_id(); $reload = new \Widgets\JSWrapper(); $reload->setPostJsCode(<<<END \t\tcloseDialog(); \t\tsendRequest("LoadContent", {"id":"{$reloadId}"}, "trashbinWrapper", "updater", null, null, "trashbin"); END ); $ajaxResponseObject->addWidget($reload); } if (!isset($this->id)) { $jswrapper = new \Widgets\JSWrapper(); $ids = ""; $elements = ""; foreach ($this->elements as $key => $element) { if (count($this->elements) > $key + 1) { $ids .= "{\"id\":\"" . $element->get_id() . "\"}, "; $elements .= "\"\", "; } else { $ids .= "{\"id\":\"" . $element->get_id() . "\"}"; $elements .= "\"\""; } } $js = "sendMultiRequest('EmptyTrashbin', jQuery.parseJSON('[{$ids}]'), jQuery.parseJSON('[{$elements}]'), 'updater', null, null, 'explorer', 'Leere Papierkorb ...', 0, " . count($this->elements) . ");"; $jswrapper->setJs($js); $ajaxResponseObject->addWidget($jswrapper); return $ajaxResponseObject; } else { $trashbinModel = new \Explorer\Model\Trashbin($this->trashbin); $jswrapper = new \Widgets\JSWrapper(); $js = "document.getElementById('trashbinIconbarWrapper').innerHTML = '" . $trashbinModel->getIconbarHtml() . "'; jQuery('.justTrashed').hide();"; $jswrapper->setJs($js); $ajaxResponseObject->addWidget($jswrapper); return $ajaxResponseObject; } }