2016-01-26 05:28:36 +01:00
|
|
|
(function (global, factory) {
|
|
|
|
if (typeof define === "function" && define.amd) {
|
2016-01-31 21:39:10 +01:00
|
|
|
define('ss.CMSPageHistoryController', ['jQuery', 'i18n'], factory);
|
2016-01-26 05:28:36 +01:00
|
|
|
} else if (typeof exports !== "undefined") {
|
2016-01-31 21:39:10 +01:00
|
|
|
factory(require('jQuery'), require('i18n'));
|
2016-01-26 05:28:36 +01:00
|
|
|
} else {
|
|
|
|
var mod = {
|
|
|
|
exports: {}
|
|
|
|
};
|
|
|
|
factory(global.jQuery, global.i18n);
|
|
|
|
global.ssCMSPageHistoryController = mod.exports;
|
|
|
|
}
|
|
|
|
})(this, function (_jQuery, _i18n) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var _jQuery2 = _interopRequireDefault(_jQuery);
|
|
|
|
|
|
|
|
var _i18n2 = _interopRequireDefault(_i18n);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) {
|
|
|
|
return obj && obj.__esModule ? obj : {
|
|
|
|
default: obj
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_jQuery2.default.entwine('ss', function ($) {
|
|
|
|
$('#Form_VersionsForm').entwine({
|
|
|
|
onmatch: function onmatch() {
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
onunmatch: function onunmatch() {
|
|
|
|
this._super();
|
|
|
|
},
|
2016-02-11 20:33:04 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
onsubmit: function onsubmit(e, d) {
|
|
|
|
e.preventDefault();
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
var id,
|
|
|
|
self = this;
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
id = this.find(':input[name=ID]').val();
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
if (!id) return false;
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
var button, url, selected, to, from, compare, data;
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
compare = this.find(":input[name=CompareMode]").is(":checked");
|
|
|
|
selected = this.find("table input[type=checkbox]").filter(":checked");
|
|
|
|
|
|
|
|
if (compare) {
|
|
|
|
if (selected.length != 2) return false;
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
to = selected.eq(0).val();
|
|
|
|
from = selected.eq(1).val();
|
|
|
|
button = this.find(':submit[name=action_doCompare]');
|
|
|
|
url = _i18n2.default.sprintf(this.data('linkTmplCompare'), id, from, to);
|
|
|
|
} else {
|
|
|
|
to = selected.eq(0).val();
|
|
|
|
button = this.find(':submit[name=action_doShowVersion]');
|
|
|
|
url = _i18n2.default.sprintf(this.data('linkTmplShow'), id, to);
|
|
|
|
}
|
|
|
|
|
2016-03-04 02:58:17 +01:00
|
|
|
$('.cms-container').loadPanel(url, '', { pjax: 'CurrentForm' });
|
2016-01-26 05:28:36 +01:00
|
|
|
}
|
|
|
|
});
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
$('#Form_VersionsForm input[name=ShowUnpublished]').entwine({
|
|
|
|
onmatch: function onmatch() {
|
|
|
|
this.toggle();
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
onunmatch: function onunmatch() {
|
|
|
|
this._super();
|
|
|
|
},
|
2016-02-11 20:33:04 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
onchange: function onchange() {
|
|
|
|
this.toggle();
|
|
|
|
},
|
|
|
|
toggle: function toggle() {
|
|
|
|
var self = $(this);
|
|
|
|
var form = self.parents('form');
|
|
|
|
|
|
|
|
if (self.attr('checked')) {
|
|
|
|
form.find('tr[data-published=false]').show();
|
|
|
|
} else {
|
|
|
|
form.find("tr[data-published=false]").hide()._unselect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
$("#Form_VersionsForm tbody tr").entwine({
|
|
|
|
onclick: function onclick(e) {
|
|
|
|
var compare, selected;
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
compare = this.parents("form").find(':input[name=CompareMode]').attr("checked");
|
|
|
|
selected = this.siblings(".active");
|
|
|
|
|
|
|
|
if (compare && this.hasClass('active')) {
|
|
|
|
this._unselect();
|
|
|
|
|
|
|
|
return;
|
|
|
|
} else if (compare) {
|
|
|
|
if (selected.length > 1) {
|
|
|
|
return alert(_i18n2.default._t('ONLYSELECTTWO', 'You can only compare two versions at this time.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._select();
|
|
|
|
|
|
|
|
if (selected.length == 1) {
|
|
|
|
this.parents('form').submit();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
this._select();
|
|
|
|
selected._unselect();
|
|
|
|
|
|
|
|
this.parents("form").submit();
|
|
|
|
}
|
|
|
|
},
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
_unselect: function _unselect() {
|
|
|
|
this.removeClass('active');
|
|
|
|
this.find(":input[type=checkbox]").attr("checked", false);
|
|
|
|
},
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
_select: function _select() {
|
|
|
|
this.addClass('active');
|
|
|
|
this.find(":input[type=checkbox]").attr("checked", true);
|
|
|
|
}
|
2016-03-04 02:58:17 +01:00
|
|
|
|
2016-01-26 05:28:36 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|