fix some bugs in news

This commit is contained in:
rolux 2012-02-18 16:58:53 +00:00
parent 5599b933d8
commit 14fb823468

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
pandora.ui.news = function(width) { pandora.ui.news = function(width, height) {
var that = Ox.Element(), var that = Ox.Element(),
$left = $('<div>') $left = $('<div>')
@ -26,7 +26,7 @@ pandora.ui.news = function(width) {
pandora.api.addNews({ pandora.api.addNews({
title: 'Untitled', title: 'Untitled',
date: Ox.formatDate(new Date(), '%Y-%m-%d'), date: Ox.formatDate(new Date(), '%Y-%m-%d'),
text: 'Text' text: ''
}, function(result) { }, function(result) {
items.splice(0, 0, result.data); items.splice(0, 0, result.data);
selected = result.data.id; selected = result.data.id;
@ -50,12 +50,12 @@ pandora.ui.news = function(width) {
function removeItem() { function removeItem() {
var index = Ox.getIndexById(items, selected); var index = Ox.getIndexById(items, selected);
items.splice(index, 1); items.splice(index, 1);
selected = items[0].id;
renderItem();
renderList();
pandora.api.removeNews({id: selected}, function(result) { pandora.api.removeNews({id: selected}, function(result) {
// ... // ...
}); });
selected = items[0].id;
renderItem();
renderList();
} }
function renderItem() { function renderItem() {
@ -91,7 +91,9 @@ pandora.ui.news = function(width) {
}) })
.css({ .css({
display: 'inline-block', display: 'inline-block',
fontSize: '9px' fontSize: '9px',
MozUserSelect: 'text',
WebkitUserSelect: 'text'
}) })
.bindEvent({ .bindEvent({
submit: function(data) { submit: function(data) {
@ -103,10 +105,16 @@ pandora.ui.news = function(width) {
$text = Ox.Editable({ $text = Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: isEditable, editable: isEditable,
maxHeight: height - 96,
placeholder: 'No text',
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea', type: 'textarea',
value: items[index].text, value: items[index].text,
width: width - 512 width: width - 512,
})
.css({
MozUserSelect: 'text',
WebkitUserSelect: 'text'
}) })
.bindEvent({ .bindEvent({
submit: function(data) { submit: function(data) {
@ -149,10 +157,10 @@ pandora.ui.news = function(width) {
Ox.Element() Ox.Element()
.addClass('item') .addClass('item')
.css({ .css({
width: '176px', width: '172px',
padding: '4px 8px 5px 8px', padding: '4px 8px 5px 8px',
borderRadius: '8px', borderRadius: '8px',
marginBottom: '2px', margin: '2px',
boxShadow: item.id == selected ? '0 0 2px ' + color : '', boxShadow: item.id == selected ? '0 0 2px ' + color : '',
cursor: 'pointer' cursor: 'pointer'
}) })