Class Index | File Index

Classes


Class Cutter


Version 1.0.
Cutter
Defined in: Cutter.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Cutter()
Cutter is a class that allows HTML code to cut a number of words contained in the nodes, keeping intact the HTML markup.
Field Summary
Field Attributes Field Name and Description
 
bNeedViewMore is a property that will check it it's necessary to add the link to view more or not It checks if its necessary if for some reason the content is cutted.
 
bNotViewMore is a property that could be setted by the user to add or not the link to view more content if needed.
 
bTest is a property to now if you want to test the Cutter class This is used to change the type of id for each element.
 
nIdTest is the property for testing that will save the order for id.
 
nWords is the number of words to Cut
 
nWordsCounter is the counter of words when finding them in code
 
oApplyTo is the Dom object where we want to use the cutter.
 
oBackupApplyTo is the clone from Dom object to get it when showing the content.
 
oClasses is the config singleton for classes used in Cutter
 
oDocumentFragment is the DocumentFragment where the Dom elements are inserted before insert on Target
 
oSerialized is the JSON object where Cutter serializes all the DOM objects inside the oApplyTo Dom element
 
oTarget is the Dom object where to put the cutted code
 
oTexts is the config singleton for texts used in Cutter
 
oViewMore is a reference to the "see more" link.
Method Summary
Method Attributes Method Name and Description
<private>  
_countWords(sText)
_countWords is an utilities method used to count the words in a String
<private>  
_getFirstElementOfObject is an utilities method used to get the first element in a JSON object
<private>  
_getOnlyNumberOfWords(sString, nWords)
_getOnlyNumberOfWords is an utilities method used to get a number of words from the string
<private>  
_trim(sString)
_trim is an utilities method used to keep out all the spaces before or after the sentence
<private>  
addEvent(oElement, sType, fpCallback)
addEvent is the wrapper method to add a new event to the element
 
applyTo(oApplyTo)
applyTo is the method that sets the Dom object where to apply the cutter
<private>  
createViewMore is the method that creates the link to see all the content again
<private>  
deserializeObject(oSerialized, oParent)
deserializeObject is an utilities method used to deserialize a JSON object in a Dom element
<private>  
deserializeSerializedObject(oSerialized, oParent)
deserializeSerializedObject is an utilities method used to deserialize all the Dom elements that where serialized and is where the cut is applied.
 
init()
init is the method that makes all the work.
<private>  
loopOnDeserialize(oSerializedElements, oParent)
loopOnDeserialize is an utilities method used to loop over all the serialized elements
<static>  
Cutter.run(oApplyTo, oTarget, nWords, oTexts, oClasses)
run is the static method to make API simple.
<private>  
serializeDomObject(oDom, oSerializeObject)
serializeDomObject is an utilities method used to serialize all the Dom elements in a JSON object This method is the brain of the class.
<private>  
setBehaviour is the method that applies the behaviour to the "see more" link to get the full content again when makink click on it
 
setClasses(oClasses)
setClasses is the method that sets the config singleton of Classes used in Cutter
 
setTarget(oTarget)
setTarget is the method that sets the Dom object where to put the cutted code
 
setTexts(oTexts)
setTexts is the method that sets the config singleton of Texts used in Cutter
 
setWords(nWords)
setWords is the method used to set the max number of words before cut the code.
<private>  
showAll is the method that put the initial content to the target Dom element
Class Detail
Cutter()
Cutter is a class that allows HTML code to cut a number of words contained in the nodes, keeping intact the HTML markup.
Author: Tomas Corral Casas.
Field Detail
{Boolean} bNeedViewMore
bNeedViewMore is a property that will check it it's necessary to add the link to view more or not It checks if its necessary if for some reason the content is cutted. false by default.
Author: Tomas Corral Casas.

{Boolean} bNotViewMore
bNotViewMore is a property that could be setted by the user to add or not the link to view more content if needed. false by default.
Author: Tomas Corral Casas.

{Boolean} bTest
bTest is a property to now if you want to test the Cutter class This is used to change the type of id for each element. false by default.
Author: Tomas Corral Casas.

{Number} nIdTest
nIdTest is the property for testing that will save the order for id. 0 by default.
Author: Tomas Corral Casas.

{Number} nWords
nWords is the number of words to Cut
Author: Tomas Corral Casas.

{Number} nWordsCounter
nWordsCounter is the counter of words when finding them in code
Author: Tomas Corral Casas.

{Object} oApplyTo
oApplyTo is the Dom object where we want to use the cutter.
Author: Tomas Corral Casas.

{Object} oBackupApplyTo
oBackupApplyTo is the clone from Dom object to get it when showing the content.
Author: Tomas Corral Casas.

{Object} oClasses
oClasses is the config singleton for classes used in Cutter
Author: Tomas Corral Casas.

{Object} oDocumentFragment
oDocumentFragment is the DocumentFragment where the Dom elements are inserted before insert on Target
Author: Tomas Corral Casas.

{Object} oSerialized
oSerialized is the JSON object where Cutter serializes all the DOM objects inside the oApplyTo Dom element
Author: Tomas Corral Casas.

{Object} oTarget
oTarget is the Dom object where to put the cutted code
Author: Tomas Corral Casas.

{Object} oTexts
oTexts is the config singleton for texts used in Cutter
Author: Tomas Corral Casas.

{Object} oViewMore
oViewMore is a reference to the "see more" link.
Author: Tomas Corral Casas.
Method Detail
<private> {Number} _countWords(sText)
_countWords is an utilities method used to count the words in a String
Author: Tomas Corral Casas.
Parameters:
{string} sText
The text where to know how many words are.
Returns:
the number of words in the string

<private> {Object} _getFirstElementOfObject(oObject)
_getFirstElementOfObject is an utilities method used to get the first element in a JSON object
Author: Tomas Corral Casas.
Parameters:
{object} oObject
The JSON object from which to obtain the first element
Returns:
the first element in the JSON object

<private> {Number} _getOnlyNumberOfWords(sString, nWords)
_getOnlyNumberOfWords is an utilities method used to get a number of words from the string
Author: Tomas Corral Casas.
Parameters:
{string} sString
The text from which to extract the words
{number} nWords
The number of words to get
Returns:
the number of words in the string

<private> {String} _trim(sString)
_trim is an utilities method used to keep out all the spaces before or after the sentence
Author: Tomas Corral Casas.
Parameters:
{string} sString
This is the text to be trimmed
Returns:
the trimmed string

<private> addEvent(oElement, sType, fpCallback)
addEvent is the wrapper method to add a new event to the element
Author: Tomas Corral Casas.
Parameters:
{DOM} oElement
{String} sType
{Function} fpCallback

{Object} applyTo(oApplyTo)
applyTo is the method that sets the Dom object where to apply the cutter
Author: Tomas Corral Casas.
Parameters:
{object} oApplyTo
This is the Dom element
Returns:
the instance of the Cutter

<private> createViewMore()
createViewMore is the method that creates the link to see all the content again
Author: Tomas Corral Casas.

<private> deserializeObject(oSerialized, oParent)
deserializeObject is an utilities method used to deserialize a JSON object in a Dom element
Author: Tomas Corral Casas.
Parameters:
{object} oSerialized
The JSON object from which to obtain the Dom element information
{object} oParent
The Dom element where to add the new Dom element

<private> deserializeSerializedObject(oSerialized, oParent)
deserializeSerializedObject is an utilities method used to deserialize all the Dom elements that where serialized and is where the cut is applied. This method is the core of the class.
Author: Tomas Corral Casas.
Parameters:
{object} oSerialized
The JSON object to deserialize
{object} oParent
The DOM object where to put the new finished code.

init()
init is the method that makes all the work. Serialize the Dom. Deserialize the JSON object to Dom elements only with the words that were wanted Remove the firstChild in oDocumentFragment because this node is the oApplyTo content. Clean the content on oTarget. Create the "see more" link Append the "see more" link to the oDocumentFragment. Insert the oDocumentFragment content in the oTarget element At least the behaviour is applied to the link to make possible to get the original content before the cut.
Author: Tomas Corral Casas.

<private> loopOnDeserialize(oSerializedElements, oParent)
loopOnDeserialize is an utilities method used to loop over all the serialized elements
Author: Tomas Corral Casas.
Parameters:
{object} oSerializedElements
The JSON object on which to run the loop
oParent

<static> Cutter.run(oApplyTo, oTarget, nWords, oTexts, oClasses)
run is the static method to make API simple.
Author: Tomas Corral Casas.
Parameters:
{DOM} oApplyTo
{DOM} oTarget
{Number} nWords
{Object} oTexts
{Object} oClasses

<private> serializeDomObject(oDom, oSerializeObject)
serializeDomObject is an utilities method used to serialize all the Dom elements in a JSON object This method is the brain of the class.
Author: Tomas Corral Casas.
Parameters:
{object} oDom
The Dom element to serialize
{object} oSerializeObject
The JSON object where to serialize the Dom element

<private> setBehaviour()
setBehaviour is the method that applies the behaviour to the "see more" link to get the full content again when makink click on it
Author: Tomas Corral Casas.

{Object} setClasses(oClasses)
setClasses is the method that sets the config singleton of Classes used in Cutter
Author: Tomas Corral Casas.
Parameters:
{object} oClasses
This is the singleton config
Returns:
the instance of the Cutter

{Object} setTarget(oTarget)
setTarget is the method that sets the Dom object where to put the cutted code
Author: Tomas Corral Casas.
Parameters:
{object} oTarget
This is the Dom element
Returns:
the instance of the Cutter

{Object} setTexts(oTexts)
setTexts is the method that sets the config singleton of Texts used in Cutter
Author: Tomas Corral Casas.
Parameters:
{object} oTexts
This is the singleton config
Returns:
the instance of the Cutter

{Object} setWords(nWords)
setWords is the method used to set the max number of words before cut the code.
Author: Tomas Corral Casas.
Parameters:
{number} nWords
This is the number of words to see.
Returns:
the instance of the Cutter

<private> showAll()
showAll is the method that put the initial content to the target Dom element
Author: Tomas Corral Casas.

©2011
Documentation generated by JsDoc Toolkit 2.4.0 on Sun Jul 31 2011 11:40:05 GMT+0200 (CEST)