use new form element syntax

This commit is contained in:
rolux 2011-12-21 21:04:28 +05:30
parent 6321b4e2a9
commit e965ae21c2
15 changed files with 123 additions and 126 deletions

View File

@ -284,11 +284,10 @@ pandora.ui.accountForm = function(action, value) {
})
.bindEvent({
change: function(data) {
var selected = data.selected[0].id;
pandora.$ui.usernameOrEmailInput.options({
autovalidate: selected == 'username'
autovalidate: data.value == 'username'
? pandora.autovalidateUsername : pandora.autovalidateEmail,
validate: pandora.validateUser(selected, true),
validate: pandora.validateUser(data.value, true),
value: ''
}).focusInput(true);
that.$element.find('.OxFormMessage:visible').html('').hide();

View File

@ -83,7 +83,7 @@ pandora.ui.contactForm = function() {
.bindEvent({
change: function(data) {
$receiptCheckbox.options({
title: data.checked
title: data.value
? 'Send a receipt to ' + pandora.user.email
: 'Don\'t send me a receipt'
});

View File

@ -271,7 +271,7 @@ pandora.ui.filesView = function(options, self) {
conditions = [{key: 'id', value: data.value, operator: '=='}]
} else {
conditions = Ox.map(['title', 'director', 'year'], function(key) {
var value = self['$' + key + 'Input'].options('value')
var value = self['$' + key + 'Input'].value()
return value.length ? {key: key, value: value, operator: '='} : null;
});
}
@ -286,7 +286,7 @@ pandora.ui.filesView = function(options, self) {
*/
conditions = {};
Ox.map(['id', 'title', 'director', 'year'], function(key) {
var value = self['$' + key + 'Input'].options('value');
var value = self['$' + key + 'Input'].value();
if(value.length) {
conditions[key] = key == 'director' ? value.split(', ') : value;
}
@ -295,18 +295,18 @@ pandora.ui.filesView = function(options, self) {
var length = result.data.items.length;
if (length == 0) {
if (key != 'id') {
self.$idInput.options({value: ''});
self.$idInput.value('');
}
} else if (result.data.items.length == 1) {
['title', 'director', 'year', 'id'].forEach(function(key) {
self['$' + key + 'Input'].options({
value: key == 'director'
self['$' + key + 'Input'].value(
key == 'director'
? result.data.items[0][key].join(', ')
: result.data.items[0][key]
});
);
});
} else {
self.$idInput.options({value: ''});
self.$idInput.value('');
}
});
}
@ -343,7 +343,7 @@ pandora.ui.filesView = function(options, self) {
.bindEvent({
click: function() {
['title', 'director', 'year', 'id'].forEach(function(key) {
self['$' + key + 'Input'].options({value: ''})
self['$' + key + 'Input'].value('');
});
}
});
@ -421,11 +421,11 @@ pandora.ui.filesView = function(options, self) {
}, function(result) {
['title', 'director', 'year'].forEach(function(key) {
if (result.data[key]) {
self['$' + key + 'Input'].options({
value: key == 'director'
self['$' + key + 'Input'].value(
key == 'director'
? result.data[key].join(', ')
: result.data[key]
});
);
}
});
updateForm();

View File

@ -171,7 +171,7 @@ pandora.ui.filter = function(id) {
.bindEvent('change', function(data) {
var filters = Ox.clone(pandora.user.ui.filters),
find,
id_ = data.selected[0].id,
id_ = data.value,
i_ = Ox.getPositionById(pandora.user.ui.filters, id_);
if (i_ == -1) {
// new filter was not part of old filter set

View File

@ -16,7 +16,6 @@ pandora.ui.findElement = function() {
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id;
pandora.$ui.findInput.options({
autocomplete: autocompleteFunction()
}).focusInput(true);
@ -46,8 +45,7 @@ pandora.ui.findElement = function() {
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id;
if (key == 'advanced') {
if (data.value == 'advanced') {
that.update();
pandora.$ui.filterDialog = pandora.ui.filterDialog().open();
} else {

View File

@ -7,36 +7,36 @@ pandora.ui.folderBrowserBar = function(id) {
pandora.$ui.findListElement[id] = Ox.FormElementGroup({
elements: [
pandora.$ui.findListSelect[id] = Ox.Select({
items: [
{id: 'user', title: 'Find: User', checked: true},
{id: 'list', title: 'Find: List'}
],
overlap: 'right',
type: 'image'
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id == 'user' ? 'user' : 'name',
value = pandora.$ui.findListInput[id].value();
value && updateList(key, value);
pandora.$ui.findListInput[id].options({
placeholder: data.selected[0].title
});
}
}),
items: [
{id: 'user', title: 'Find: User', checked: true},
{id: 'list', title: 'Find: List'}
],
overlap: 'right',
type: 'image'
})
.bindEvent({
change: function(data) {
var key = data.value == 'user' ? 'user' : 'name',
value = pandora.$ui.findListInput[id].value();
value && updateList(key, value);
pandora.$ui.findListInput[id].options({
placeholder: data.title
});
}
}),
pandora.$ui.findListInput[id] = Ox.Input({
changeOnKeypress: true,
clear: true,
placeholder: 'Find: User',
width: pandora.getFoldersWidth() - 24
})
.bindEvent({
change: function(data) {
var key = pandora.$ui.findListSelect[id].value() == 'user' ? 'user' : 'name',
value = data.value;
updateList(key, value);
}
})
changeOnKeypress: true,
clear: true,
placeholder: 'Find: User',
width: pandora.getFoldersWidth() - 24
})
.bindEvent({
change: function(data) {
var key = pandora.$ui.findListSelect[id].value() == 'user' ? 'user' : 'name',
value = data.value;
updateList(key, value);
}
})
],
})
.css({

View File

@ -107,8 +107,8 @@ pandora.ui.home = function() {
var folder = pandora.getListData().folder,
value = $findInput.value();
folder && pandora.$ui.folderList[folder].options({selected: []});
pandora.$ui.findSelect.options({value: '*'});
pandora.$ui.findInput.options({value: value});
pandora.$ui.findSelect.value('*');
pandora.$ui.findInput.value(value);
that.fadeOutScreen();
pandora.UI.set('find', {
conditions: value === ''

View File

@ -55,7 +55,7 @@ pandora.ui.listDialog = function(section) {
.bindEvent({
change: function(data) {
pandora.$ui.findIconItemInput.options({
placeholder: data.selected[0].title
placeholder: data.title
});
// fixme: this is a bit weird
setTimeout(function() {
@ -247,13 +247,13 @@ pandora.ui.listGeneralPanel = function(listData) {
}
}
function editStatus(data) {
var status = data.selected[0].id;
var status = data.value;
$statusSelect.value(status == 'private' ? 'public' : 'private');
pandora.changeListStatus(listData.id, status, function(result) {
listData.status = result.data.status;
if (result.data.status == 'private') {
subscribers = 0;
$subscribersInput.options({value: 0});
$subscribersInput.value(0);
}
$statusSelect.value(result.data.status);
$subscribersInput[getSubscribersAction()]();

View File

@ -19,11 +19,11 @@ pandora.ui.logsDialog = function() {
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id,
var key = data.value,
value = $findInput.value();
value && updateList(key, value);
$findInput.options({
placeholder: data.selected[0].title
placeholder: data.title
});
}
}),

View File

@ -162,7 +162,7 @@ pandora.ui.mainMenu = function() {
that.checkItem('allitems');
}
} else if (data.id == 'find') {
pandora.$ui.findSelect.options({value: value});
pandora.$ui.findSelect.value(value);
} else if (data.id == 'itemview') {
pandora.UI.set({itemView: value});
} else if (Ox.startsWith(data.id, 'orderfilter')) {

View File

@ -97,7 +97,7 @@ pandora.ui.preferencesDialog = function() {
this.options({
title: this.options('title') == 'Subscribed' ? 'Unsubscribed' : 'Subscribed'
});
pandora.user.newsletter = data.checked;
pandora.user.newsletter = data.value;
pandora.api.editPreferences({
newsletter: pandora.user.newsletter
});

View File

@ -15,7 +15,7 @@ pandora.ui.sectionButtons = function() {
})
.bindEvent({
change: function(data) {
var section = data.selected[0];
var section = data.value;
if (section == 'items') {
pandora.URL.set(pandora.Query.toString());
} else if (section == 'clips') {

View File

@ -28,29 +28,29 @@ pandora.ui.sortSelect = function(isNavigationView) {
}));
}
that = Ox.Select({
id: 'sortSelect',
items: items,
width: isNavigationView ? 128 : 144
})
.css({
float: isNavigationView ? 'right' : 'left',
margin: isNavigationView ? '4px 4px 0 0' : '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
var key = data.selected[0].id;
pandora.UI.set(sortKey, [{
key: key,
operator: pandora.getSortOperator(key)
}]);
},
pandora_listsort: function(data) {
that.selectItem(data.value[0].key);
},
pandora_itemsort: function(data) {
that.selectItem(data.value[0].key);
}
});
id: 'sortSelect',
items: items,
width: isNavigationView ? 128 : 144
})
.css({
float: isNavigationView ? 'right' : 'left',
margin: isNavigationView ? '4px 4px 0 0' : '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
var key = data.value;
pandora.UI.set(sortKey, [{
key: key,
operator: pandora.getSortOperator(key)
}]);
},
pandora_listsort: function(data) {
that.selectItem(data.value[0].key);
},
pandora_itemsort: function(data) {
that.selectItem(data.value[0].key);
}
});
return that;
};

View File

@ -31,7 +31,7 @@ pandora.ui.usersDialog = function() {
change: function(data) {
$findInput.value() && updateList();
$findInput.options({
placeholder: data.selected[0].title
placeholder: data.title
});
}
}),
@ -537,11 +537,11 @@ pandora.ui.usersDialog = function() {
change: function(event) {
var data = {id: user.id}, key, value;
if (event.id == 'status') {
data.disabled = !event.data.checked;
data.disabled = !event.data.value;
} else if (event.id == 'level') {
data.level = event.data.selected[0].id;
data.level = event.data.value;
} else if (event.id == 'newsletter') {
data.newsletter = event.data.checked;
data.newsletter = event.data.value;
} else {
data[event.id] = event.data.value;
}
@ -622,12 +622,12 @@ pandora.ui.usersDialog = function() {
click: function(data) {
var $input = getFormItemById('message'),
textarea = $input.find('textarea')[0],
value = $input.options('value');
$input.options({
value: value.substr(0, textarea.selectionStart)
+ '{' + data.id + '}'
+ value.substr(textarea.selectionEnd)
})
value = $input.value();
$input.value(
value.substr(0, textarea.selectionStart)
+ '{' + data.id + '}'
+ value.substr(textarea.selectionEnd)
)
.focusInput(textarea.selectionStart + data.id.length + 2);
}
}),
@ -654,7 +654,7 @@ pandora.ui.usersDialog = function() {
function selectForm(data) {
var selected;
if (data.selected[0] == 'edit') {
if (data.value == 'edit') {
$mailForm.detach();
selected = $list.options('selected');
if (selected.length == 1 && selected[0].level != 'guest') {
@ -690,8 +690,8 @@ pandora.ui.usersDialog = function() {
function sendMail() {
pandora.api.mail({
to: getTo(),
subject: getFormItemById('subject').options('value'),
message: getFormItemById('message').options('value'),
subject: getFormItemById('subject').value(),
message: getFormItemById('message').value(),
receipt: getFormItemById('receipt').value()
}, function(result) {
var title = result.status.code == 200
@ -734,7 +734,7 @@ pandora.ui.usersDialog = function() {
}
function setHeight(data) {
var form = $formButton.options('value'),
var form = $formButton.value(),
$item = getFormItemById(form == 'edit' ? 'notes' : 'message');
Ox.print('$ITEM', $item)
dialogHeight = data.height;
@ -759,9 +759,9 @@ pandora.ui.usersDialog = function() {
function setSend() {
getFormItemById('send').options({
disabled: getFormItemById('to').options('value') == 'No recipients'
|| getFormItemById('subject').options('value') === ''
|| getFormItemById('message').options('value') === ''
disabled: getFormItemById('to').value() == 'No recipients'
|| getFormItemById('subject').value() === ''
|| getFormItemById('message').value() === ''
});
}

View File

@ -7,34 +7,34 @@ pandora.ui.viewSelect = function() {
sortKey = !ui.item ? 'listSort' : 'itemSort',
viewKey = !ui.item ? 'listView' : 'itemView',
that = Ox.Select({
id: 'viewSelect',
items: Ox.map(pandora.site[viewKey + 's'], function(view) {
return viewKey == 'listView'
|| ['data', 'files'].indexOf(view.id) == -1
|| pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
? Ox.extend(Ox.clone(view), {
checked: view.id == ui[viewKey],
title: 'View ' + view.title
})
: null;
}),
width: !ui.item ? 144 : 128
})
.css({
float: 'left',
margin: '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
pandora.UI.set(viewKey, data.selected[0].id);
},
pandora_listview: function(data) {
that.selectItem(data.value);
},
pandora_itemview: function(data) {
that.selectItem(data.value);
}
});
id: 'viewSelect',
items: Ox.map(pandora.site[viewKey + 's'], function(view) {
return viewKey == 'listView'
|| ['data', 'files'].indexOf(view.id) == -1
|| pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level]
? Ox.extend(Ox.clone(view), {
checked: view.id == ui[viewKey],
title: 'View ' + view.title
})
: null;
}),
width: !ui.item ? 144 : 128
})
.css({
float: 'left',
margin: '4px 0 0 4px'
})
.bindEvent({
change: function(data) {
pandora.UI.set(viewKey, data.value);
},
pandora_listview: function(data) {
that.selectItem(data.value);
},
pandora_itemview: function(data) {
that.selectItem(data.value);
}
});
return that;
};