Revision [15294]

Last edited on 2013-07-25 10:01:29 by AbydonianSoftware
Additions:
// instantiate the DataEditor object and run the init() function


Revision [15293]

Edited on 2013-07-25 10:00:56 by AbydonianSoftware
Additions:
Using these objects can be very clean and simple. Rather than peppering your HTML with ""JavaScript"" functions, you simply instantiate the object and call member methods where needed in your HTML. There are actually ways of using layout managers, such that you can mostly avoid HTML; but for this example, we'll show how you would use ""JavaScript"" in some basic HTML.
Deletions:
Using these objects can be very clean and simple. Rather than peppering your HTML with ""JavaScript"" functions, you simply instantiate the object and call member methods where needed in your HTML. There are actually ways of using layout managers, such that you can mostly avoid HTML; but for this example, we'll show how you would use JavaScript in some basic HTML.


Revision [15292]

Edited on 2013-07-25 10:00:39 by AbydonianSoftware
Additions:
Using these objects can be very clean and simple. Rather than peppering your HTML with ""JavaScript"" functions, you simply instantiate the object and call member methods where needed in your HTML. There are actually ways of using layout managers, such that you can mostly avoid HTML; but for this example, we'll show how you would use JavaScript in some basic HTML.
%%(html)
<!DOCTYPE html>
<html>
<head><title>example</title></head>
<body>
<form>
<input type="button" onclick="dataEditor.displayEditor()" value="Display Editor" />
</form>
<script type="text/javascript">
var dataEditor = new DataEditor();
dataEditor.init();
</script>
</body>
</html>
%%


Revision [15291]

Edited on 2013-07-25 09:56:53 by AbydonianSoftware
Additions:
In this example, we are going to show how to create a basic ""JavaScript"" module using prototypes. This is not meant to be an example that //does anything//; more it is meant to show how one would structure an object. We'll leave the function examples to other articles that document how to perform certain tasks.
Deletions:
In this example, we are going to show how to create a basic ""JavaScript"" module using prototypes.


Revision [15290]

Edited on 2013-07-25 09:52:56 by AbydonianSoftware
Additions:
==Using the Object In Your Code==


Revision [15289]

Edited on 2013-07-25 09:52:29 by AbydonianSoftware
Additions:
// run the editor code here


Revision [15288]

Edited on 2013-07-25 09:52:01 by AbydonianSoftware
Additions:
/**
* MODULE: DataEditor
* PURPOSE: PROVIDE A MEANS FOR EDITING THE DATA
*/
/**
* FUNCTION: init
* PURPOSE: INITIALIZE THE OBJECT
*/
// run any initialization code here
/**
* FUNCTION: display editor
* PURPOSE: DISPLAY THE EDITOR TO THE CLIENT
*/
DataEditor.prototype.displayEditor=function() {


Revision [15287]

Edited on 2013-07-25 09:49:23 by AbydonianSoftware
Additions:
Here is a simple example, where we define a function called //init//. Note that unlike typical ""JavaScript"" functions, we create a prototype attribute and then make that attribute equal to the function. Syntax errors in this very basic structure can be tricky to diagnose, if you're not accustomed to using this style of coding.
DataEditor.prototype.init=function() {
};
Deletions:
function DataEditor.prototype.init=function() {


Revision [15286]

Edited on 2013-07-25 09:46:48 by AbydonianSoftware
Additions:
==Member Functions==
Member functions provide all of the functionality and are encapsulated in the object, meaning that you must instantiate the object and reference all functions from an instance of the object, in order to use the member functions. These member functions will have access to all variables encapsulated in the object.
function DataEditor.prototype.init=function() {


Revision [15285]

Edited on 2013-07-25 09:44:36 by AbydonianSoftware
Additions:
%%(javascript)
Deletions:
%%(JavaScript)


Revision [15284]

Edited on 2013-07-25 09:44:19 by AbydonianSoftware
Additions:
//Object Oriented ""JavaScript""// is a great way to organize your JavaScript source code, so that it is portable, readable, maintainable and encapsulated. This method of ""JavaScript"" development is a sort of self-imposed discipline, that makes ""JavaScript"" far more organized than it often is in web applications.
===Object Oriented ""JavaScript"" Using Prototypes===
In this example, we are going to show how to create a basic ""JavaScript"" module using prototypes.
==The Constructor==
The Constructor looks just like a function call, in this method of ""JavaScript"" coding. In the constructor, we can save any parameters we want to pass in, into the object's local variables and possibly kick off any initialization processes.
%%(JavaScript)
function DataEditor(imagePath) {
this.imagePath = imagePath; // save imagePath to a local variable, inside of DataEditor
}
%%
Deletions:
//Object Oriented JavaScript// is a great way to organize your JavaScript source code, so that it is portable, readable, maintainable and encapsulated. This method of JavaScript development is a sort of self-imposed discipline, that makes JavaScript far more organized than it often is in web applications.


Revision [15283]

Edited on 2013-07-25 09:40:10 by AbydonianSoftware
Additions:
//Object Oriented JavaScript// is a great way to organize your JavaScript source code, so that it is portable, readable, maintainable and encapsulated. This method of JavaScript development is a sort of self-imposed discipline, that makes JavaScript far more organized than it often is in web applications.


Revision [15278]

Edited on 2013-07-25 09:36:19 by AbydonianSoftware
Additions:
----
[[JavaScript]]


Revision [15277]

The oldest known version of this page was created on 2013-07-25 09:36:05 by AbydonianSoftware
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki