You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
5.7 KiB
208 lines
5.7 KiB
13 years ago
|
var sankoreLang = {
|
||
12 years ago
|
view: "Display",
|
||
13 years ago
|
edit: "Edit",
|
||
|
example: "hello, this is the first sentence. hi, this is the second sentence. hello again, this is the third sentence. good morning, this is the fourth sentence. hi, sorry, i\'m late, i\'m the fifth sentence.",
|
||
|
wgt_name: "Split a text",
|
||
|
reload: "Reload",
|
||
12 years ago
|
slate: "slate",
|
||
|
pad: "pad",
|
||
|
none: "none",
|
||
13 years ago
|
help: "Help",
|
||
12 years ago
|
help_content:
|
||
|
"<p><h2>Split a text</h2></p>" +
|
||
|
"<p><h3>Separate sentences in a text</h3></p>" +
|
||
|
"<p>Text is written without the dots between sentences. The goal is to split the text correctly. If the result is correct, the area turns in green.</p>" +
|
||
|
"<p>To add points between sentences, move the cursor and click between two words.</p>" +
|
||
|
"<p>“Reload” button resets the exercise.</p>" +
|
||
|
"<p>Enter the “Edit” mode to :</p>" +
|
||
12 years ago
|
"<ul><li>choose the theme of the App : pad, slate, or none (by default : none),</li>" +
|
||
12 years ago
|
"<li>modify the text (write in the text field different phrases separated by dots.)</li></ul>" +
|
||
|
"<p>Do not use question and exclamation mark.</p>" +
|
||
|
"<p>“Display” button comes back to the activity.</p>",
|
||
12 years ago
|
theme: "Theme"
|
||
13 years ago
|
};
|
||
|
|
||
|
// if use the "view/edit" button or rely on the api instead
|
||
|
var isSankore = false;
|
||
|
// whether to do window.resize or not (window = widget area)
|
||
|
var isBrowser = ( typeof( widget ) == "undefined" );
|
||
|
|
||
|
function wcontainer( containerID )
|
||
|
{
|
||
|
// some protecred variables
|
||
|
var thisInstance = this;
|
||
|
this.editMode = false;
|
||
|
var data = {}; // see setData and getData
|
||
|
|
||
|
// widget size parameters
|
||
|
this.minHeight = 100;
|
||
|
this.minWidth = 400;
|
||
|
|
||
|
// set to 0 for no max width restriction
|
||
|
this.maxWidth = 0;
|
||
|
|
||
|
// links to the elements of the widget
|
||
|
this.elements = {};
|
||
|
|
||
|
/*
|
||
|
============
|
||
|
create
|
||
|
============
|
||
|
- creates html base, inits this.elements, assings events
|
||
|
*/
|
||
|
this.create = function( containerID )
|
||
|
{
|
||
|
var html =
|
||
|
'<div id="mp_content">' +
|
||
|
'<div class="viewmode" id="mp_view">' +
|
||
|
'</div>' +
|
||
|
'<div class="editmode" id="mp_edit">' +
|
||
|
'</div>' +
|
||
|
'</div>';
|
||
|
|
||
|
var container = $( containerID );
|
||
|
|
||
|
container.append( html );
|
||
|
this.elements.edit = container.find( ".editmode" );
|
||
|
this.elements.view = container.find( ".viewmode" );
|
||
|
this.elements.container = container;
|
||
|
this.elements.subcontainer = container.find( "#mp_content" );
|
||
|
this.elements.containerView = this.elements.subcontainer.find( ".viewmode" );
|
||
|
this.elements.containerEdit = this.elements.subcontainer.find( ".editmode" );
|
||
|
|
||
|
$("#wgt_edit").live("click", function(){
|
||
|
thisInstance.modeEdit();
|
||
|
} );
|
||
|
|
||
|
$("#wgt_display").live("click", function(){
|
||
|
thisInstance.modeView();
|
||
|
} );
|
||
|
};
|
||
|
|
||
|
|
||
|
/*
|
||
|
===============
|
||
|
setViewContent
|
||
|
===============
|
||
|
- assigns custom html to the viewmode container
|
||
|
*/
|
||
|
this.setViewContent = function( html )
|
||
|
{
|
||
|
this.elements.container.find( "#mp_content .viewmode" ).html( html );
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
===============
|
||
|
setEditContent
|
||
|
===============
|
||
|
- assigns custom html to the editmode container
|
||
|
*/
|
||
|
this.setEditContent = function( html )
|
||
|
{
|
||
|
this.elements.container.find( "#mp_content .editmode" ).html( html );
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
=========================
|
||
|
modeEdit and modeView
|
||
|
=========================
|
||
|
- switch the widget betweed modes
|
||
|
* for customization extend onEditMode and onViewMode
|
||
|
*/
|
||
|
this.modeEdit = function()
|
||
|
{
|
||
|
this.onEditMode();
|
||
|
this.editMode = true;
|
||
|
this.elements.edit.removeClass( "hide" );
|
||
|
this.elements.view.addClass( "hide" );
|
||
|
|
||
|
//this.adjustSize();
|
||
|
};
|
||
|
this.modeView = function()
|
||
|
{
|
||
|
this.onViewMode();
|
||
|
this.editMode = false;
|
||
|
this.elements.edit.addClass( "hide" );
|
||
|
this.elements.view.removeClass( "hide" );
|
||
|
|
||
|
//this.adjustSize();
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
======================
|
||
|
setData and getData
|
||
|
======================
|
||
|
- store some data inside
|
||
|
*/
|
||
|
this.setData = function( name, value ){
|
||
|
data[name] = value;
|
||
|
};
|
||
|
this.getData = function( name ){
|
||
|
if( typeof( data[name] ) == "undefined" ){
|
||
|
return null;
|
||
|
} else return data[name];
|
||
|
};
|
||
|
|
||
|
|
||
|
// redefinable methods
|
||
|
|
||
|
/*
|
||
|
==========================
|
||
|
onEditMode and onViewMode
|
||
|
==========================
|
||
|
- these are called when the mode is being changed
|
||
|
*/
|
||
|
this.onEditMode = function(){
|
||
|
//
|
||
|
};
|
||
|
this.onViewMode = function(){
|
||
|
//
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
======================
|
||
|
viewSize and editSize
|
||
|
======================
|
||
|
- calculate container size for the adjustSize method
|
||
|
* they are likely to be redefined for each particular widget
|
||
|
*/
|
||
|
this.viewSize = function(){
|
||
|
return {
|
||
|
w: this.elements.containerView.outerWidth(),
|
||
|
h: this.elements.containerView.outerHeight()
|
||
|
};
|
||
|
};
|
||
|
this.editSize = function(){
|
||
|
return {
|
||
|
w: this.elements.containerEdit.outerWidth(),
|
||
|
h: this.elements.containerEdit.outerHeight()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
=====================
|
||
|
checkAnswer
|
||
|
=====================
|
||
|
- check if the exercise in the view mode was done right
|
||
|
* redefine it for each particular widget
|
||
|
*/
|
||
|
this.checkAnswer = function()
|
||
|
{
|
||
|
//
|
||
|
};
|
||
|
|
||
|
|
||
|
// constructor end
|
||
|
|
||
|
// if the constructor was called with a parameter,
|
||
|
// call create() automatically
|
||
|
if( arguments.length > 0 ){
|
||
|
this.create( containerID );
|
||
|
}
|
||
|
this.setData( "dw", this.elements.container.outerWidth( true ) - this.elements.container.width() );
|
||
|
this.setData( "dh", this.elements.container.outerHeight( true ) - this.elements.container.height() );
|
||
|
window.winstance = thisInstance;
|
||
|
}
|