Skip to content

Commit

Permalink
docs(api): remove some setters in example code blocks (#12694)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Apr 7, 2021
1 parent 311da8f commit 6c7db5f
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 86 deletions.
8 changes: 4 additions & 4 deletions apidoc/Titanium/Android/Menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ examples:
activity.onCreateOptionsMenu = function(e){
var menu = e.menu;
var login = menu.add({ title: "Login", itemId: LOGIN });
login.setIcon("login.png");
login.icon = 'login.png';
login.addEventListener("click", function(e) {
loggedIn = true;
// In Android 3.0 and above we need to call invalidateOptionsMenu() for menu changes at runtime
win.activity.invalidateOptionsMenu();
});
var logout = menu.add({ title: "Logout", itemId: LOGOUT });
logout.setIcon("logout.png");
logout.icon = 'logout.png';
logout.addEventListener("click", function(e) {
loggedIn = false;
// In Android 3.0 and above we need to call invalidateOptionsMenu() for menu changes at runtime
Expand All @@ -268,8 +268,8 @@ examples:
activity.onPrepareOptionsMenu = function(e) {
var menu = e.menu;
menu.findItem(LOGIN).setVisible(!loggedIn);
menu.findItem(LOGOUT).setVisible(loggedIn);
menu.findItem(LOGIN).visible = !loggedIn;
menu.findItem(LOGOUT).visible = loggedIn;
};
win.open();
```
Expand Down
8 changes: 4 additions & 4 deletions apidoc/Titanium/Android/Service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ description: |
}
// Insert location data.
section.setItems([
section.items = [
{ properties: { title: 'LOCATION:\n' + e.latitude + ', ' + e.longitude, color: 'green' } },
{ properties: { title: 'ALTITUDE:\n' + e.altitude, color: 'green' } },
{ properties: { title: 'ACCURACY:\n' + e.accuracy, color: 'green' } }
]);
])
} else {
// Oops! Something bad happened.
section.setItems([
section.items = [
{ properties: { title: 'ERROR:\n' + e.error, color: 'red' } }
]);
];
}
// Add section to listView
Expand Down
4 changes: 2 additions & 2 deletions apidoc/Titanium/Media/AudioRecorder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ examples:
recordPause.addEventListener('click', function(e) {
if (audioRecorder.getPaused()) {
recordPause.setTitle('Pause');
recordPause.title = 'Pause';
audioRecorder.resume()
} else {
recordPause.setTitle('Resume');
recordPause.title = 'Resume';
audioRecorder.pause();
}
});
Expand Down
4 changes: 1 addition & 3 deletions apidoc/Titanium/Media/VideoPlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ examples:
control would not be required.
``` js
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({
title: 'Test',
backgroundColor: '#fff',
exitOnClose: true
backgroundColor: '#fff'
});
// Change to a valid URL
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/Network/Cookie.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ description: |
}
listViewData.push(obj);
}
listSection.setItems(listViewData);
listSection.items = listViewData;
});
listView.addEventListener('itemclick', function(e) {
var item = e.section.getItemAt(e.itemIndex);
Expand Down
16 changes: 3 additions & 13 deletions apidoc/Titanium/UI/AlertDialog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,9 @@ examples:
Create a single-button alert dialog using the global `alert()` alias.
``` js
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test',
backgroundColor: 'white',
exitOnClose: true,
fullscreen: false
backgroundColor: 'white'
});
win.addEventListener('click', function(e) {
Expand All @@ -529,12 +526,9 @@ examples:
property, which is invoked when the app window is clicked.
``` js
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test',
backgroundColor: 'white',
exitOnClose: true,
fullscreen: false
backgroundColor: 'white'
});
win.addEventListener('click', function(e) {
Expand All @@ -554,12 +548,9 @@ examples:
Output a message to the log when the cancel button is clicked.
``` js
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test',
backgroundColor: 'white',
exitOnClose: true,
fullscreen: false
backgroundColor: 'white'
});
win.addEventListener('click', function(e) {
var dialog = Ti.UI.createAlertDialog({
Expand Down Expand Up @@ -588,7 +579,6 @@ examples:
Output entered text value to the log when the OK button is clicked.
``` js
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test'
});
Expand Down
4 changes: 2 additions & 2 deletions apidoc/Titanium/UI/ListItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ examples:
}
var section = Ti.UI.createListSection();
section.setItems(data);
section.items = data;
listView.sections = [section];
listView.addEventListener('itemclick', function(e) {
var item = section.getItemAt(e.itemIndex);
Expand Down Expand Up @@ -535,7 +535,7 @@ examples:
}
var section = Ti.UI.createListSection();
section.setItems(data);
section.items = data;
listView.sections = [section];
// Modified version of the `itemclick` event listener
Expand Down
26 changes: 13 additions & 13 deletions apidoc/Titanium/UI/ListView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1014,10 +1014,10 @@ properties:
For example:
``` js
listView.setTableSeparatorInsets({
left:10,
right:10
});
listView.tableSeparatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: "5.2.0"
Expand All @@ -1043,10 +1043,10 @@ properties:
For example:
``` js
listView.setListSeparatorInsets({
left:10,
right:10
});
listView.listSeparatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: "5.4.0"
Expand All @@ -1062,10 +1062,10 @@ properties:
For example:
``` js
listView.setRowSeparatorInsets({
left:10,
right:10
});
listView.rowSeparatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: "5.2.0"
Expand Down Expand Up @@ -1439,7 +1439,7 @@ examples:
var grainSection = Ti.UI.createListSection({ headerTitle: 'Grains / Granos', items: grainDataSet});
sections.push(grainSection);
listView.setSections(sections);
listView.sections = sections;
win.add(listView);
win.open();
```
Expand Down
38 changes: 17 additions & 21 deletions apidoc/Titanium/UI/RefreshControl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,33 @@ examples:
A basic sample showing the usage of refreshstart event with endRefreshing functionality.
``` js
var win = Ti.UI.createWindow({
fullscreen:true
});
var counter = 0;
function genData()
{
var data = [];
var i=1;
for (i=1;i<=3;i++) {
data.push({properties:{title:'ROW '+(counter+i)}})
const win = Ti.UI.createWindow();
let counter = 0;
function genData() {
const data = [];
for (let i = 1; i <= 3; i++) {
data.push({ properties:{ title: `ROW ${counter + i}` } });
}
counter += 3;
return data;
}
var section = Ti.UI.createListSection();
section.setItems(genData());
var control = Ti.UI.createRefreshControl({
tintColor:'red'
})
var listView = Ti.UI.createListView({
sections:[section],
refreshControl:control
const section = Ti.UI.createListSection();
section.items = genData();
const control = Ti.UI.createRefreshControl({
tintColor: 'red'
});
const listView = Ti.UI.createListView({
sections: [section],
refreshControl: control
});
control.addEventListener('refreshstart',function(e){
control.addEventListener('refreshstart', () => {
Ti.API.info('refreshstart');
setTimeout(function(){
setTimeout(() => {
Ti.API.debug('Timeout');
section.appendItems(genData());
control.endRefreshing();
}, 2000);
})
});
win.add(listView);
win.open();
```
31 changes: 14 additions & 17 deletions apidoc/Titanium/UI/TableView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1481,10 +1481,10 @@ properties:
For example:
``` js
tableView1.setSeparatorInsets({
left:10,
right:10
});
tableView1.separatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: 3.2.0
Expand All @@ -1504,16 +1504,16 @@ properties:
- name: tableSeparatorInsets
summary: The insets for the table view header and footer.
description: |
Cell separators do not extend all the way to the edge of the table view.Set this to a
Cell separators do not extend all the way to the edge of the table view. Set this to a
dictionary with two keys, `left` specifying inset from left edge and `right` specifying the inset from the
right edge. If the rowSeparatorInsets is not set, the tableSeparatorInsets will also set the cell insets.
For example:
``` js
tableView1.setTableSeparatorInsets({
left:10,
right:10
});
tableView1.tableSeparatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: "5.2.0"
Expand All @@ -1523,16 +1523,16 @@ properties:
- name: rowSeparatorInsets
summary: The insets for table view cells (applies to all cells).
description: |
Cell separators do not extend all the way to the edge of the table view.Set this to a
Cell separators do not extend all the way to the edge of the table view. Set this to a
dictionary with two keys, `left` specifying inset from left edge and `right` specifying the inset from the
right edge. This property is only available upon creation of the cells.
For example:
``` js
tableView1.setRowSeparatorInsets({
left:10,
right:10
});
tableView1.rowSeparatorInsets = {
left: 10,
right: 10
};
```
type: HorizontalInsets
since: "5.2.0"
Expand Down Expand Up @@ -1667,11 +1667,8 @@ examples:
Create a table of rows that contain a custom child-view layout.
``` js
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
backgroundColor: 'black',
exitOnClose: true,
fullscreen: false,
title: 'TableView Demo'
});
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/TableViewRow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ examples:
tableData.push(row);
}
table.setData(tableData);
table.data = tableData;
table.addEventListener('swipe', function(e){
if (e.source && e.source.objName !== 'table'){
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/iOS/BlurView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ examples:
];
tabs.addEventListener("click", function(e) {
blur.setEffect(effects[e.index]);
blur.effect = effects[e.index];
});
win.add(tabs);
Expand Down
6 changes: 3 additions & 3 deletions apidoc/Titanium/UI/iOS/PreviewContext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ examples:
});
}
section1.setItems(items);
section2.setItems(items);
listView.setSections([section1, section2]);
section1.items = items;
section2.items = items;
listView.sections = [section1, section2];
win.add(listView);
win.open();
Expand Down
2 changes: 1 addition & 1 deletion apidoc/Titanium/WatchSession/WatchSession.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ examples:
var cacheFile = e.data.getFile();
var downloadedFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, cacheFile.getName());
downloadedFile.write(e.data);
imageView.setImage(downloadedFile);
imageView.image = downloadedFile;
});
Ti.WatchSession.addEventListener('receiveapplicationcontext', function(e) {
Expand Down

0 comments on commit 6c7db5f

Please sign in to comment.