if ($prevID != 0) {
$alt = ts('Move to top');
- $links[] = "<a href=\"{$url}&dst={$firstID}&dir=first\"><img src=\"{$imageURL}/first.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
+ $links[] = "<a class=\"crm-weight-arrow\" href=\"{$url}&dst={$firstID}&dir=first\"><img src=\"{$imageURL}/first.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
$alt = ts('Move up one row');
- $links[] = "<a href=\"{$url}&dst={$prevID}&dir=swap\"><img src=\"{$imageURL}/up.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
+ $links[] = "<a class=\"crm-weight-arrow\" href=\"{$url}&dst={$prevID}&dir=swap\"><img src=\"{$imageURL}/up.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
}
else {
$links[] = "<img src=\"{$imageURL}/spacer.gif\" class=\"order-icon\">";
if ($nextID != 0) {
$alt = ts('Move down one row');
- $links[] = "<a href=\"{$url}&dst={$nextID}&dir=swap\"><img src=\"{$imageURL}/down.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
+ $links[] = "<a class=\"crm-weight-arrow\" href=\"{$url}&dst={$nextID}&dir=swap\"><img src=\"{$imageURL}/down.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
$alt = ts('Move to bottom');
- $links[] = "<a href=\"{$url}&dst={$lastID}&dir=last\"><img src=\"{$imageURL}/last.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
+ $links[] = "<a class=\"crm-weight-arrow\" href=\"{$url}&dst={$lastID}&dir=last\"><img src=\"{$imageURL}/last.gif\" title=\"$alt\" alt=\"$alt\" class=\"order-icon\"></a>";
}
else {
$links[] = "<img src=\"{$imageURL}/spacer.gif\" class=\"order-icon\">";
$srcWeight = CRM_Core_DAO::getFieldValue($daoName, $src, 'weight', $idName);
$dstWeight = CRM_Core_DAO::getFieldValue($daoName, $dst, 'weight', $idName);
if ($srcWeight == $dstWeight) {
- CRM_Utils_System::redirect($url);
+ self::fixOrderOutput($url);
}
$tableName = $object->tableName();
CRM_Core_DAO::executeQuery($query, $params);
}
- CRM_Utils_System::redirect($url);
+ self::fixOrderOutput($url);
+ }
+
+ static function fixOrderOutput($url) {
+ if (empty($_GET['snippet']) || $_GET['snippet'] !== 'json') {
+ CRM_Utils_System::redirect($url);
+ }
+
+ CRM_Core_Page_AJAX::returnJsonResponse(array(
+ 'userContext' => $url,
+ ));
}
}
if (!this.element.is('.crm-container *')) {
this.element.addClass('crm-container');
}
+ this._handleOrderLinks();
this.options.url ? this.refresh() : this.options.url = document.location.href;
this._originalUrl = this.options.url;
},
}
return url;
},
+ _handleOrderLinks: function() {
+ var that = this;
+ $('a.crm-weight-arrow', that.element).click(function(e) {
+ that.options.block && that.element.block();
+ $.getJSON(that._formatUrl(this.href)).done(function() {
+ that.refresh();
+ });
+ e.stopImmediatePropagation();
+ return false;
+ });
+ },
refresh: function() {
var that = this;
var url = this._formatUrl(this.options.url);
- this.options.block && this.element.block();
+ this.options.block && $('.blockOverlay', this.element).length < 1 && this.element.block();
$.getJSON(url, function(data) {
if (typeof(data) != 'object' || typeof(data.content) != 'string') {
that._onFailure(data);
return;
}
data.url = url;
- that.element.html(data.content).trigger('crmLoad', data);
+ that.element.html(data.content);
+ that._handleOrderLinks();
+ that.element.trigger('crmLoad', data);
that.options.crmForm && that.element.trigger('crmFormLoad', data);
}).fail(function() {
that._onFailure();