зеркало из https://github.com/nextcloud/news.git
reverted js back to old state
This commit is contained in:
Родитель
fea980d06e
Коммит
86f8d78584
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The cache is used to cache items and tell the program which items have been
|
||||
* loaded
|
||||
*/
|
||||
|
||||
(function(exports) {
|
||||
"use strict";
|
||||
|
||||
var Cache = function(){
|
||||
this.reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Cache.prototype.reset = function(){
|
||||
this.items = [];
|
||||
};
|
||||
|
||||
exports.Cache = Cache;
|
||||
|
||||
}(typeof exports === "undefined" ? (this.moduleName = {}): exports));
|
||||
|
||||
|
65
js/items.js
65
js/items.js
|
@ -70,7 +70,7 @@ var News = News || {};
|
|||
* @param item the dom item
|
||||
*/
|
||||
Items.prototype._markItemAsReadTimeout = function(item) {
|
||||
var itemId = parseInt($(item).data('id'), 10);
|
||||
var itemId = parseInt($(item).data('id'));
|
||||
var itemOffset = $(item).position().top;
|
||||
var cachedItem = this._itemCache.getItem(itemId);
|
||||
if(itemOffset < 0){
|
||||
|
@ -96,8 +96,7 @@ var News = News || {};
|
|||
var data = {
|
||||
id: id,
|
||||
type: type,
|
||||
mostRecentItemId: this._itemCache.getMostRecentItemId(),
|
||||
mostRecentItemTimestamp: this._itemCache.getMostRecentItemTimestamp()
|
||||
mostRecentItemId: this._itemCache.getMostRecentItemId(type, id)
|
||||
};
|
||||
|
||||
this._$articleList.addClass('loading');
|
||||
|
@ -134,7 +133,7 @@ var News = News || {};
|
|||
var notJumped = true;
|
||||
$('.feed_item').each(function(){
|
||||
if(notJumped && $(this).position().top > 1){
|
||||
var id = parseInt($(this).data('id'), 10);
|
||||
var id = parseInt($(this).data('id'));
|
||||
self._jumpToElemenId(id);
|
||||
notJumped = false;
|
||||
}
|
||||
|
@ -151,7 +150,7 @@ var News = News || {};
|
|||
if(notJumped && $(this).position().top >= 0){
|
||||
var previous = $(this).prev();
|
||||
if(previous.length > 0){
|
||||
var id = parseInt(previous.data('id'), 10);
|
||||
var id = parseInt(previous.data('id'));
|
||||
self._jumpToElemenId(id);
|
||||
}
|
||||
notJumped = false;
|
||||
|
@ -162,7 +161,7 @@ var News = News || {};
|
|||
if(notJumped){
|
||||
var $items = $('.feed_item');
|
||||
if($items.length > 0){
|
||||
var id = parseInt($items.last().data('id'), 10);
|
||||
var id = parseInt($items.last().data('id'));
|
||||
self._jumpToElemenId(id);
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +220,7 @@ var News = News || {};
|
|||
* @return the jquery node
|
||||
*/
|
||||
Items.prototype._findNodeById = function(id) {
|
||||
id = parseInt(id, 10);
|
||||
id = parseInt(id);
|
||||
return this._$articleList.find('.feed_item[data-id="' + id + '"]');
|
||||
};
|
||||
|
||||
|
@ -253,15 +252,13 @@ var News = News || {};
|
|||
var ItemCache = function() {
|
||||
this._items = {};
|
||||
this._feeds = {};
|
||||
this._itemIds = [];
|
||||
this._itemTimestamps = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an item from the cache
|
||||
*/
|
||||
ItemCache.prototype.getItem = function(itemId) {
|
||||
itemId = parseInt(itemId, 10);
|
||||
itemId = parseInt(itemId);
|
||||
return this._items[itemId];
|
||||
};
|
||||
|
||||
|
@ -292,8 +289,6 @@ var News = News || {};
|
|||
self._items[item.getId()] = item;
|
||||
self._feeds[item.getFeedId()] = self._feeds[item.getFeedId()] || {};
|
||||
self._feeds[item.getFeedId()][item.getId()] = item;
|
||||
self._itemIds.push(item.getId());
|
||||
self._itemTimestamps.push(item.getTimeStamp());
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -303,8 +298,6 @@ var News = News || {};
|
|||
ItemCache.prototype.empty = function() {
|
||||
this._items = {};
|
||||
this._feeds = {};
|
||||
this._itemIds = [];
|
||||
this._itemTimestamps = [];
|
||||
};
|
||||
|
||||
|
||||
|
@ -350,13 +343,12 @@ var News = News || {};
|
|||
return pairs;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns all the ids of feeds for a type sorted by timestamp ascending
|
||||
* @param type the type (MenuNodeType)
|
||||
* @param id the id
|
||||
* @return all the ids of feeds for a type sorted by timestamp ascending
|
||||
*/
|
||||
* Returns all the ids of feeds for a type sorted by timestamp ascending
|
||||
* @param type the type (MenuNodeType)
|
||||
* @param id the id
|
||||
* @return all the ids of feeds for a type sorted by timestamp ascending
|
||||
*/
|
||||
ItemCache.prototype._getSortedItemIds = function(type, id) {
|
||||
var pairs = this._getItemIdTimestampPairs(type, id);
|
||||
|
||||
|
@ -371,32 +363,21 @@ var News = News || {};
|
|||
return itemIds;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return the most recent id that is loaded on the page or 0 if no ids are there
|
||||
* Returns the most recent id of a feed
|
||||
* @param type the type (MenuNodeType)
|
||||
* @param id the id
|
||||
* @return the most recent id that is loaded on the page or 0
|
||||
*/
|
||||
ItemCache.prototype.getMostRecentItemId = function() {
|
||||
if(this._itemIds.length === 0){
|
||||
ItemCache.prototype.getMostRecentItemId = function(type, id) {
|
||||
var itemIds = this._getSortedItemIds(type, id);
|
||||
if(itemIds.length === 0){
|
||||
return 0;
|
||||
} else {
|
||||
this.itemIds = this._itemIds.sort();
|
||||
return this.itemIds[this.itemIds.length-1];
|
||||
return itemIds[itemIds.length-1];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the most recent timestamp that is loaded on the page or 0 if no ids are there
|
||||
*/
|
||||
ItemCache.prototype.getMostRecentItemTimestamp = function() {
|
||||
if(this._itemTimestamps.length === 0){
|
||||
return 0;
|
||||
} else {
|
||||
this._itemTimestamps = this._itemTimestamps.sort();
|
||||
return this._itemTimestamps[this._itemTimestamps.length-1];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the html for a specific feed
|
||||
* @param type the type (MenuNodeType)
|
||||
|
@ -431,14 +412,14 @@ var News = News || {};
|
|||
var Item = function(html){
|
||||
this._starred = false;
|
||||
this._$html = $(html);
|
||||
this._id = parseInt(this._$html.data('id'), 10);
|
||||
this._feedId = parseInt(this._$html.data('feedid'), 10);
|
||||
this._id = parseInt(this._$html.data('id'));
|
||||
this._feedId = parseInt(this._$html.data('feedid'));
|
||||
this._read = this._$html.hasClass('read');
|
||||
this._locked = false;
|
||||
this._important = this._$html.find('li.star').hasClass('important');
|
||||
// get timestamp for sorting
|
||||
var $stamp = this._$html.find('.timestamp');
|
||||
this._timestamp = parseInt($stamp.html(), 10);
|
||||
this._timestamp = parseInt($stamp.html());
|
||||
$stamp.remove();
|
||||
// open all links in new tabs
|
||||
this._$html.find('.body a').attr('target', '_blank');
|
||||
|
|
27
js/menu.js
27
js/menu.js
|
@ -135,7 +135,7 @@ var News = News || {};
|
|||
* @param html the html to add
|
||||
*/
|
||||
Menu.prototype.addNode = function(parentId, html){
|
||||
parentId = parseInt(parentId, 10);
|
||||
parentId = parseInt(parentId);
|
||||
var $parentNode;
|
||||
var $html = $(html);
|
||||
|
||||
|
@ -172,7 +172,7 @@ var News = News || {};
|
|||
*/
|
||||
Menu.prototype.updateNode = function(type, id, data){
|
||||
var $node = this._getNodeFromTypeAndId(type, id);
|
||||
id = parseInt(id, 10);
|
||||
id = parseInt(id);
|
||||
|
||||
if(data.title !== undefined){
|
||||
// prevent xss
|
||||
|
@ -188,10 +188,10 @@ var News = News || {};
|
|||
/**
|
||||
* Removes a node and its subnodes from the menu
|
||||
* @param type the type (MenuNodeType)
|
||||
* @param id the id
|
||||
* @param id the id
|
||||
*/
|
||||
Menu.prototype.removeNode = function(type, id){
|
||||
id = parseInt(id, 10);
|
||||
id = parseInt(id);
|
||||
var $node = this._getNodeFromTypeAndId(type, id);
|
||||
$node.remove();
|
||||
};
|
||||
|
@ -276,9 +276,9 @@ var News = News || {};
|
|||
*/
|
||||
Menu.prototype.getFeedIdsOfFolder = function(folderId) {
|
||||
$folder = this._getNodeFromTypeAndId(MenuNodeType.Folder, folderId);
|
||||
var ids = [];
|
||||
var ids = new Array();
|
||||
$folder.children('ul').children('li').each(function(){
|
||||
ids.push(parseInt($(this).data('id'), 10));
|
||||
ids.push(parseInt($(this).data('id')));
|
||||
});
|
||||
return ids;
|
||||
};
|
||||
|
@ -546,6 +546,7 @@ var News = News || {};
|
|||
Menu.prototype._edit = function(type, id){
|
||||
var $node = this._getNodeFromTypeAndId(type, id);
|
||||
var name = $node.children('.title').html();
|
||||
var id = $node.data('id');
|
||||
$('#changefolder_dialog').find('input[type=text]').val(name);
|
||||
$('#changefolder_dialog').find('input[type=hidden]').val(id);
|
||||
$('#changefolder_dialog').dialog('open');
|
||||
|
@ -589,7 +590,7 @@ var News = News || {};
|
|||
|
||||
$.post(OC.filePath('news', 'ajax', 'setallitemsread.php'), data, function(jsonData) {
|
||||
if(jsonData.status == 'success'){
|
||||
self._setUnreadCount(type, id, parseInt(jsonData.data.unreadCount, 10));
|
||||
self._setUnreadCount(type, id, parseInt(jsonData.data.unreadCount));
|
||||
} else {
|
||||
OC.dialogs.alert(jsonData.data.message, t('news', 'Error'));
|
||||
}
|
||||
|
@ -691,7 +692,7 @@ var News = News || {};
|
|||
*/
|
||||
Menu.prototype._getAndRemoveUnreadCount = function($listItem){
|
||||
var $unreadCounter = $listItem.children('.unread_items_counter');
|
||||
var unreadCount = parseInt($unreadCounter.html(), 10);
|
||||
var unreadCount = parseInt($unreadCounter.html());
|
||||
$unreadCounter.remove();
|
||||
return unreadCount;
|
||||
};
|
||||
|
@ -719,7 +720,7 @@ var News = News || {};
|
|||
*/
|
||||
Menu.prototype._getIdAndTypeFromNode = function($listItem) {
|
||||
return {
|
||||
id: parseInt($listItem.data('id'), 10),
|
||||
id: parseInt($listItem.data('id')),
|
||||
type: this._listItemToMenuNodeType($listItem)
|
||||
};
|
||||
};
|
||||
|
@ -781,7 +782,7 @@ var News = News || {};
|
|||
* @param unreadCount the count of unread items
|
||||
*/
|
||||
Menu.prototype._setUnreadCount = function(type, id, unreadCount){
|
||||
unreadCount = parseInt(unreadCount, 10);
|
||||
unreadCount = parseInt(unreadCount);
|
||||
if(unreadCount < 0){
|
||||
unreadCount = 0;
|
||||
}
|
||||
|
@ -864,9 +865,9 @@ var News = News || {};
|
|||
var $dropped = $(this);
|
||||
var $dragged = $(ui.draggable);
|
||||
|
||||
var feedId = parseInt($dragged.data('id'), 10);
|
||||
var folderId = parseInt($dropped.data('id'), 10);
|
||||
var fromFolderId = parseInt($dragged.parent().data('id'), 10);
|
||||
var feedId = parseInt($dragged.data('id'));
|
||||
var folderId = parseInt($dropped.data('id'));
|
||||
var fromFolderId = parseInt($dragged.parent().data('id'));
|
||||
|
||||
// ignore when dragged to the same folder
|
||||
if(folderId === fromFolderId){
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
alert('hi')
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div>hi</div>
|
Загрузка…
Ссылка в новой задаче