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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
News={
DropDownMenu: {
fade:function(button){
var list = $(button).parent().find('ul#fademenu').toggle();
return false;
},
dropdown:function(button){
var list = $(button).parent().find('ul#dropdownmenu');
if (list.css('display') == 'none')
list.slideDown('fast').show();
else
list.slideUp('fast');
return false;
},
selectItem:function(item, folderid){
var parent = $(item).parent().parent();
parent.find('#dropdownBtn').text($(item).text());
parent.find(':input[name="folderid"]').val(folderid);
parent.find('ul#dropdownmenu').slideUp('fast');
}
},
UI: {
overview:function(dialogtype, dialogfile){
if($(dialogtype).dialog('isOpen') == true){
$(dialogtype).dialog('moveToTop');
}else{
$('#dialog_holder').load(OC.filePath('news', 'ajax', dialogfile), function(jsondata){
if(jsondata.status != 'error'){
$(dialogtype).dialog({
dialogClass:'dialog',
minWidth: 600,
close: function(event, ui) {
$(this).dialog('destroy').remove();
}
}).css('overflow','visible');
} else {
alert(jsondata.data.message);
}
});
}
return false;
}
},
Folder: {
submit:function(button){
var displayname = $("#folder_add_name").val().trim();
if(displayname.length == 0) {
OC.dialogs.alert(t('news', 'Displayname cannot be empty.'), t('news', 'Error'));
return false;
}
$(button).attr("disabled", true);
//translation here!!!
$(button).prop('value', 'Adding...');
var folderid = $('#inputfolderid:input[name="folderid"]').val();
var url;
url = OC.filePath('news', 'ajax', 'createfolder.php');
$.post(url, { name: displayname, parentid: folderid },
function(jsondata){
if(jsondata.status == 'success'){
//$(button).closest('tr').prev().html(jsondata.page).show().next().remove();
OC.dialogs.alert(jsondata.data.message, t('news', 'Success!'));
} else {
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
$("#folder_add_name").val('');
$(button).attr("disabled", false);
//translation here!!!
$(button).prop('value', 'Add folder');
});
},
delete:function(folderid) {
$('#feeds_delete').tipsy('hide');
OC.dialogs.confirm(t('news', 'Are you sure you want to delete this folder and all its feeds?'), t('news', 'Warning'), function(answer) {
if(answer == true) {
$.post(OC.filePath('news', 'ajax', 'deletefolder.php'),{'folderid':folderid},function(jsondata){
if(jsondata.status == 'success'){
alert('removed!');
}
else{
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
});
}
});
return false;
}
},
Feed: {
id:'',
submit:function(button){
var feedurl = $("#feed_add_url").val().trim();
if(feedurl.length == 0) {
OC.dialogs.alert(t('news', 'URL cannot be empty.'), t('news', 'Error'));
return false;
}
$(button).attr("disabled", true);
//translation here!!!
$(button).prop('value', 'Adding...');
var folderid = $('#inputfolderid:input[name="folderid"]').val();
var url;
url = OC.filePath('news', 'ajax', 'createfeed.php');
$.post(url, { feedurl: feedurl, folderid: folderid },
function(jsondata){
if(jsondata.status == 'success'){
OC.dialogs.alert(jsondata.data.message, t('news', 'Success!'));
} else {
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
$("#feed_add_url").val('');
$(button).attr("disabled", false);
//translation here!!!
$(button).prop('value', 'Add feed');
});
},
delete:function(feedid) {
$('#feeds_delete').tipsy('hide');
OC.dialogs.confirm(t('news', 'Are you sure you want to delete this feed?'), t('news', 'Warning'), function(answer) {
if(answer == true) {
$.post(OC.filePath('news', 'ajax', 'deletefeed.php'),{'feedid':feedid},function(jsondata){
if(jsondata.status == 'success'){
$('#leftcontent [data-id="'+jsondata.data.feedid+'"]').remove();
//change the right view too (maybe a message to subscribe, like in Google Reader?)
}
else{
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
});
}
});
return false;
},
markItem:function(itemid) {
$.post(OC.filePath('news', 'ajax', 'markitem.php'),{'itemid':itemid},function(jsondata){
if(jsondata.status == 'success'){
var $currentitem = $('#rightcontent [data-id="'+jsondata.data.itemid+'"]');
$currentitem.removeClass('title_unread');
$currentitem.addClass('title_read');
//set a timeout for this
}
else{
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
}
});
}
}
}
$(document).ready(function(){
$('#addfeed').click(function() {
News.UI.overview('#addfeed_dialog','feeddialog.php');
$(this).parent().toggle();
});
$('#addfolder').click(function() {
News.UI.overview('#addfolder_dialog','folderdialog.php');
$(this).parent().toggle();
});
$('.collapsable').click(function(){
$(this).parent().children().toggle();
$(this).toggle();
});
$('.accordion .title_unread').click(function() {
$(this).next().toggle();
return false;
}).next().hide();
$('.accordion .title_read').click(function() {
$(this).next().toggle();
return false;
}).next().hide();
var list = $('.collapsable,.feeds_list').hover(function() {
var elem = $(this).find('#feeds_delete,#feeds_edit');
if(elem.css('display') == 'none')
elem.css('display', 'inline');
else
elem.css('display', 'none');
return false;
});
list.find('#feeds_delete').hide();
list.find('#feeds_edit').hide();
});
|