-
Notifications
You must be signed in to change notification settings - Fork 0
/
releasenotes.js
64 lines (50 loc) · 1.66 KB
/
releasenotes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;( function($, _, undefined){
"use strict";
ips.controller.register('pages.front.releaseNotes.main', {
_ajaxObj: null,
initialize: function () {
this.on( 'click', '[data-releaseID]', this.showRelease );
this.setup();
},
setup: function () {
// Find the current release if available
var showFirst = this.scope.find('[data-role="releases"] [data-currentRelease]');
if( !showFirst.length ) {
showFirst = this.scope.find('[data-role="releases"] [data-releaseID]').first();
}
if( showFirst.length ){
showFirst.click();
}
},
showRelease: function (e) {
e.preventDefault();
var self = this;
var link = $( e.currentTarget ).attr('href');
var infoPanel = this.scope.find('[data-role="releaseInfo"]');
// Cancel any current requests
if( this._ajaxObj && _.isFunction( this._ajaxObj.abort ) ){
this._ajaxObj.abort();
}
// Set panel to loading
infoPanel
.css({
height: infoPanel.height() + 'px'
})
.html( $('<div/>').addClass('ipsLoading').css({ height: '100px' }) );
// Unhighlight all others, then highlight this one
this.scope.find('[data-releaseID]').removeClass('cRelease_active');
$( e.currentTarget ).addClass('cRelease_active');
this._ajaxObj = ips.getAjax()( link, {
data: {
rating_submitted: 1
}
})
.done( function (response) {
var responseContent = $("<div>" + response + "</div>");
var content = responseContent.find('#elCmsPageWrap');
infoPanel.html( content ).css({ height: 'auto' });
$( document ).trigger( 'contentChange', [ infoPanel ] );
});
}
});
}(jQuery, _));