mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
418 lines
15 KiB
JavaScript
418 lines
15 KiB
JavaScript
$(document).ready( function() {
|
|
window.wikiDom = {
|
|
'type': 'document',
|
|
'children': [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Barack Hussein Obama II (born August 4 1961) is the 44th and current president of the United States of America. Obama won the 2008 United States presidential election on November 4. He became the first African-American president when he was inaugurated on January 20, 2009.' }
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 2 },
|
|
'content': { 'text': 'Before becoming president' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama was born in Honolulu, Hawaii. His father was a black foreign student from Kenya and his mother was a white woman from Kansas. He spent most of his childhood there, although he lived in Indonesia with his mother and stepfather from age 6 to age 10. He moved back to Hawaii after that to live with his grandparents. He started college at Occidental College in Los Angeles, and graduated from Columbia University in New York City. After taking time off to community organize, Obama went to law school at Harvard University. After law school, Obama worked for a law firm. The law firm sued companies who fired people, and sued the government claiming that some black people were prevented from voting.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Later, Obama worked for Alice Palmer, an Illinois state senator. She ran for U.S. Congress. While doing so, Obama became interested in her Illinois state senate seat. Later, Alice Palmer tried to run for that state senate seat, but Obama got her name taken off the ballot because she had not met the rules for the election. Because of this, he ran unopposed (without anybody else running against him) in the election. He ran for election and became an Illinois state senator. He was state senator from 1997 to 2004.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'While he was Illinois state senator, he was known for writing a law that required police to keep records on the race of people they stopped. The law that he wrote also forced police to videotape when they talked to people they suspect of murder. He also taught law part time at the University of Chicago Law School.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama later ran for the U.S. Senate. While running for Senate, John Kerry asked him to speak at the Democratic National Convention. Most people had never heard of Obama, but many people saw him speak on television and he became well known after that.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama won the presidential election of 2008. He was a U.S. Senator from 2005 to 2008.' }
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 2 },
|
|
'content': { 'text': 'Presidential campaign' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Barack Obama\'s presidential campaign for the White House started in early June 2008 when he defeated Hillary Clinton in the 2008 Democratic primaries. Hillary Clinton was favored to win but Obama won many smaller state caucuses (local party elections) by having a lot of volunteers. He decided not to accept government money for his campaign so that he could accept more money from people. He raised the most amount of money ever for a presidential campaign.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama\'s campaign theme was that he was a man of hope and change. He was also against the war in Iraq. He was in favor of giving money to American car companies. He was in favor of sending more troops to Afghanistan.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'During the campaign, some people said that Obama\'s friends included a Tony Rezko, a landlord, and former member of the Weather Underground, Bill Ayers but Obama said that they were not his friends. Obama also had trouble when his minister at church, Jeremiah Wright, was videotaped criticizing America. During the campaign, Obama said that his opponent, Republican candidate John McCain, was just like George W. Bush, something that John McCain said was not true.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'He defeated McCain in the election on November 4 by a wide electoral majority of 365 to 173, meaning that he won the most votes in enough states to send 365 people to officially elect him. The popular vote (based on the total number of votes across the country) was closer, with Obama winning 53%, McCain 46%.' }
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 2 },
|
|
'content': { 'text': 'Family' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama has been married to Michelle Obama since 1992. She has a Bachelor of Arts degree from Princeton University and also a Juris Doctor degree from Harvard Law School. She worked as a lawyer. They have two daughters, Malia Ann who was born in 1998 and Natasha ("Sasha"), born in 2001. They lived in Chicago, but moved into the White House on January 20, 2009.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama promised his daughters that the family would get a dog if he was elected President. In April 2009, Senator Ted Kennedy, who once tried to run for President, gave Obama one of his dogs, a Portuguese water dog named Bo.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama has a half sister who is a teacher in Hawaii. His father died from a car accident in Africa. His mother died of cancer. His grandmother died just before Obama won the election to become President.' }
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 2 },
|
|
'content': { 'text': 'Presidency' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama became President of the United States on January 20, 2009.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'When Obama became President, the United States was battling a tough recession. He asked Congress to spend an extra $787 billion ($787,000,000,000) to try to end the recession. He called the plan the stimulus bill. The stimulus bill funded many road projects, gave money to schools, gave tax credits to many Americans, and funded many science and research projects.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama continued the financial bailout that George W. Bush started, giving billions of dollars to car companies and banks so that they will not go bankrupt. He signed an act written by Barney Frank and Chris Dodd which would regulate Wall Street (the financial industry) to try to prevent another recession like this from happening again.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama signed the Patient Protection and Affordable Care Act which would bring health care reform to the United States, which he said would change the system so that more people can afford health care.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'In foreign policy, Obama made a plan to slowly withdraw troops from Iraq, ending the War In Iraq by the end of 2011, while adding more troops to Afghanistan to help the United States win the War In Afghanistan. He also decided that the USA should help in the war against Libya. He has said several times that he wants to improve U.S. relations with the Muslim world.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Obama received the 2009 Nobel Peace Prize on October 9, 2009. He noted that his efforts were humble, but he donated the prize money to several charities.' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Although his popularity was very high (around 70% approval) when he entered office, his approval ratings fell to 45% percent during the year of 2010. He has received a lot of criticism from Republicans, conservatives, libertarians, and members of the Tea Party because they believe that, under the Obama Administration, the federal government is becoming too big and spending too much money and that his programs are not the best for the country.' }
|
|
},
|
|
{
|
|
'type': 'pre',
|
|
'content': { 'text': 'A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps..' }
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 1 },
|
|
'content': {
|
|
'text': 'This is a heading (level 1)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 2 },
|
|
'content': {
|
|
'text': 'This is a heading (level 2)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 3 },
|
|
'content': {
|
|
'text': 'This is a heading (level 3)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 4 },
|
|
'content': {
|
|
'text': 'This is a heading (level 4)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 5 },
|
|
'content': {
|
|
'text': 'This is a heading (level 5)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'heading',
|
|
'attributes': { 'level': 6 },
|
|
'content': {
|
|
'text': 'This is a heading (level 6)',
|
|
'annotations': [
|
|
{
|
|
'type': 'textStyle/italic',
|
|
'range': {
|
|
'start': 10,
|
|
'end': 17
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': {
|
|
'text': 'In text display, line wrap is the feature of continuing on a new line when a line is full, such that each line fits in the viewable window, allowing text to be read from top to bottom without any horizontal scrolling.\nWord wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between and not within words, except when a single word is longer than a line.',
|
|
'annotations': [
|
|
// 'In text display' should be bold
|
|
{ 'type': 'textStyle/bold', 'range': { 'start': 0, 'end': 15 } },
|
|
// 'line wrap' should be italic
|
|
{ 'type': 'textStyle/italic', 'range': { 'start': 17, 'end': 26 } },
|
|
// 'wrap is' should be a link to '#'
|
|
{
|
|
'type': 'link/external',
|
|
'data': { 'href': '#' },
|
|
'range': { 'start': 22, 'end': 29 }
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 22' }
|
|
},
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 333' }
|
|
},
|
|
{
|
|
'type': 'list',
|
|
'children': [
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['bullet']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 4444' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['bullet', 'bullet']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 55555' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['bullet', 'bullet', 'bullet']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 666666' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['number']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 7777777' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['number', 'number']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 88888888' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['term']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 999999999' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['definition']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 0000000000' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'table',
|
|
'attributes': { 'html/style': 'width: 600px; border: solid 1px;' },
|
|
'children': [
|
|
{
|
|
'type': 'tableRow',
|
|
'children': [
|
|
{
|
|
'type': 'tableCell',
|
|
'attributes': { 'html/style': 'border: solid 1px;' },
|
|
'children': [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'row 1 & cell 1' }
|
|
},
|
|
{
|
|
'type': 'list',
|
|
'children': [
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['bullet']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 4444' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['bullet', 'bullet']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 55555' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'listItem',
|
|
'attributes': {
|
|
'styles': ['number']
|
|
},
|
|
'children' : [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'Test 666666' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
'type': 'tableCell',
|
|
'attributes': { 'html/style': 'border: solid 1px;' },
|
|
'children': [
|
|
{
|
|
'type': 'paragraph',
|
|
'content': { 'text': 'row 1 & cell 2' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|
|
window.doc = es.DocumentModel.newFromPlainObject( window.wikiDom );
|
|
window.surfaceModel = new es.SurfaceModel( window.doc );
|
|
window.surfaceView = new es.SurfaceView( $( '#es-editor' ), window.surfaceModel );
|
|
|
|
var tools = {
|
|
'textStyle/bold': $( '#es-toolbar-bold' ),
|
|
'textStyle/italic': $( '#es-toolbar-italic' )
|
|
};
|
|
surfaceView.on( 'select', function( range ) {
|
|
for ( var key in tools ) {
|
|
tools[key].removeClass( 'es-toolbarTool-down' );
|
|
}
|
|
if ( range.start == range.end ) {
|
|
var annotations = doc.getAnnotationsFromOffset( range.start );
|
|
if ( annotations.length ) {
|
|
for ( var i = 0; i < annotations.length; i++ ) {
|
|
if ( annotations[i].type in tools ) {
|
|
tools[annotations[i].type].addClass( 'es-toolbarTool-down' );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} );
|
|
} );
|