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
|
/**
* ownCloud - News app
*
* @author Bernhard Posselt
* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
var News = News || {};
$(document).ready(function(){
// config values
var menuUpdateIntervalMiliseconds = 200000;
// global object array for accessing instances
News.Objects = {};
News.Objects.Items = new News.Items('#feed_items');
News.Objects.Menu = new News.Menu(menuUpdateIntervalMiliseconds, News.Objects.Items);
News.Objects.Menu.bindOn('#feeds > ul');
/* first run script begins */
$('#browsebtn_firstrun, #cloudbtn_firstrun, #importbtn_firstrun').hide();
/* first run script ends */
$('#addfeed').click(function() {
$('#addfeed_dialog').dialog('open');
$('#feed_add_url').html('');
// populate folderlist
$('#addfeed_dialog .menu').empty();
// http://9gag.com/trending
var $rootFolder = $('<li>').addClass('menuItem').html($('<b>').html(t('News', 'None')));
$rootFolder.click(function(){
News.DropDownMenu.selectItem(this, 0);
});
$('#addfeed_dialog .menu').append($rootFolder);
$('#feeds .folder').each(function(){
var title = $(this).children('.title').html();
var id = parseInt($(this).data('id'));
var $folder = $('<li>').addClass('menuItem').html(title);
$folder.click(function(){
News.DropDownMenu.selectItem(this, id);
});
$('#addfeed_dialog .menu').append($folder);
});
});
$('#addfolder').click(function() {
$('#addfolder_dialog').dialog('open');
$('#folder_add_name').val('');
});
$('#addfeedbtn').click(function() {
$(this).hide();
$('#addfeed_dialog_firstrun').show();
});
$('#addfeedfolder').click(function(event) {
News.DropDownMenu.fade($(this).children('ul'));
event.stopPropagation();
});
$('#settingsbtn').on('click keydown', function() {
try {
OC.appSettings({appid:'news', loadJS:true, cache:false});
} catch(e) {
alert(e);
}
});
$('#addfolder_dialog,#addfeed_dialog,#changefolder_dialog').dialog({
dialogClass:'dialog',
minWidth: 600,
autoOpen: false
});
$('#changefolder_dialog input[type=submit]').click(function(){
News.Folder.changeName(this);
});
$('#folder_add_submit').click(function(){
News.Folder.submit(this);
});
$('.dropdownBtn').click(function(){
News.DropDownMenu.dropdown(this);
});
$('#feed_add_submit').click(function(){
News.Feed.submit(this);
});
$('#view').click(function(){
var data = {};
var showAll;
if($(this).hasClass('show_all')){
data.showAll = false;
$(this).addClass('show_unread').removeClass('show_all');
} else {
data.showAll = true;
$(this).addClass('show_all').removeClass('show_unread');
}
News.Objects.Menu.triggerHideRead();
$.post(OC.filePath('news', 'ajax', 'usersettings.php'), data, function(jsondata){
if(jsondata.status == 'success'){
News.Objects.Menu.setShowAll(data.showAll);
} else {
OC.dialogs.alert(jsonData.data.message, t('news', 'Error'));
}
});
});
$(document).click(function(event) {
$('#feedfoldermenu').hide();
});
$(document).keyup(function(e) {
if ((e.keyCode || e.which) == 74 || (e.keyCode || e.which) == 39) { // 'j' key shortcut
if(!$('.dialog').is(':visible')){
News.Objects.Items.jumpToNext();
}
}
if ((e.keyCode || e.which) == 75 || (e.keyCode || e.which) == 37) { // 'k' key shortcut
if(!$('.dialog').is(':visible')){
News.Objects.Items.jumpToPrevious();
}
}
});
});
|