Skip to content

Commit

Permalink
Updates to 3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul-martinez committed Oct 22, 2014
1 parent ca391e6 commit 41d4f85
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CocoonJS Plugins

Ludei's plugins (also called extensions) are multiplatform Javascript APIs, that work in any of the three environments of CocoonJS: Canvas+, WebView+ and System webview.

Visit [http://doc.ludei.com/3.0.0/](http://doc.ludei.com/3.0.0/) where you'll find detailed documentation for all of the CocoonJS javascript plugins.
Visit [http://doc.ludei.com/latest/](http://doc.ludei.com/latest/) where you'll find detailed documentation for all of the CocoonJS javascript plugins.

You can find the final, minified files in the **"build/"** directory.

Expand Down Expand Up @@ -35,5 +35,5 @@ This command will create a folder called build/ that will contain cocoon.js and
Useful links
--------------------
How to use: https://www.ludei.com/cocoonjs/how-to-use/
Documentation: http://doc.ludei.com/3.0.0/
Documentation: http://doc.ludei.com/latest/
Cloud compiler: http://cloud.ludei.com
131 changes: 108 additions & 23 deletions build/cocoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<a href="http://support.ludei.com/hc"><img src="img/cocoon-tools-2.png" /></a>
<a href="https://cloud.ludei.com/"><img src="img/cocoon-tools-3.png" /></a>
<a href="https://www.ludei.com/cocoonjs/how-to-use/"><img src="img/cocoon-tools-4.png" /></a>
* @version 3.0.0
* @version 3.0.4
*/
(function () {

Expand Down Expand Up @@ -715,6 +715,8 @@ Cocoon.define("Cocoon.App" , function(extension){

extension.onSuspending = new Cocoon.EventHandler("IDTK_APP", "App", "onsuspending");

extension.onMemoryWarning = new Cocoon.EventHandler("IDTK_APP", "App", "onmemorywarning");

var signal = new Cocoon.Signal.createSignal();

/**
Expand Down Expand Up @@ -752,6 +754,19 @@ Cocoon.define("Cocoon.App" , function(extension){
*/
signal.register("suspending", extension.onSuspending);

/**
* Allows to listen to memory warning notifications from the system
* It is strongly recommended that you implement this method and free up as much memory as possible by disposing of cached data objects, images on canvases that can be recreated.
* @event On memory warning
* @memberof Cocoon.App
* @example
* Cocoon.App.on("memorywarning", function(){
* ...
* });
*/
signal.register("memorywarning", extension.onMemoryWarning);


extension.on = signal.expose();

return extension;
Expand Down Expand Up @@ -1067,28 +1082,6 @@ Cocoon.define("Cocoon.Utils" , function(extension){
}
};

/**
* Marks a audio file to be used as music by the system. Cocoon, internally, differentiates among music files and sound files.
* Music files are usually bigger in size and longer in duration that sound files. There can only be just one music file
* playing at a specific given time. The developer can mark as many files as he/she wants to be treated as music. When the corresponding
* HTML5 audio object is used, the system will automatically know how to treat the audio resource as music or as sound.
* Note that it is not mandatory to use this function. The system automatically tries to identify if a file is suitable to be treated as music
* or as sound by checking file size and duration thresholds. It is recommended, though, that the developer specifies him/herself what he/she considers
* to be music.
* @function markAsMusic
* @param {string} filePath File path to be marked as music
* @memberOf Cocoon.Utils
* @example
* Cocoon.Utils.markAsMusic("path/to/file.mp3");
*/
extension.markAsMusic = function(audioFilePath)
{
if (Cocoon.nativeAvailable)
{
return extension.callNative("IDTK_APP", "addForceMusic", arguments);
}
};

/**
* Captures a image of the screen synchronously and saves it to a file. Sync mode allows to capture the screen in the middle of a frame rendering.
* @function captureScreen
Expand Down Expand Up @@ -1142,6 +1135,39 @@ Cocoon.define("Cocoon.Utils" , function(extension){
}
};

/**
* Enables NPOT (not power of two) textures in Canvas+.
* Canvas+ uses POT (power of two) textures by default. Enabling NPOT improves memory usage but may affect performance on old GPUs.
* @function setNPOTEnabled
* @memberof Cocoon.Utils
* @param {boolean} enabled true to enable NPOT Textures
* @example
* Cocoon.Utils.setNPOTEnabled(true);
*/
extension.setNPOTEnabled = function (enabled) {
if (Cocoon.nativeAvailable) {
return window.ext.IDTK_APP.makeCall("setNPOTEnabled", enabled);
}
};

/**
* Sets a max memory threshold in Canvas+ for canvas2D contexts.
* If the maxMemory is enabled, CocoonJS checks the total amount of texture sizes (images and canvases).
* When the memory size reaches the max memory threshold CocoonJS disposes least recently used textures until the memory fits the threshold.
* It disposes textures used for JS Image objects (which can be reloaded later if needed).
* It doesn't dispose canvas objects because they cannot be reconstructed if they are used again in a render operation.
* @function setMaxMemory
* @memberof Cocoon.Utils
* @param {number} memoryInMBs max memory in megabytes
* @example
* Cocoon.Utils.setMaxMemory(75);
*/
extension.setMaxMemory = function (memoryInMBs) {
if (Cocoon.nativeAvailable) {
return window.ext.IDTK_APP.makeCall("setMaxMemory", memoryInMBs);
}
};

/**
*
* @memberof Cocoon.Utils
Expand Down Expand Up @@ -1371,6 +1397,65 @@ Cocoon.define("Cocoon.Dialog" , function(extension){
}
};

/**
* Shows a keyboard to receive user input. The developer has to process input events and render the resulting text.
* @param {object} param Object information.
* @param [param.type] {Cocoon.Dialog.keyboardType} Default value is Cocoon.Dialog.keyboardType.TEXT. The keyboard type to be used when the text has to be introduced.
* @param {callback} callbacks - <i>insertText</i>, <i>deleteBackward</i>, <i>done</i>, <i>cancel</i> callbacks called when the user clicks a key, confirms or cancels the keyboard session.
* @memberOf Cocoon.Dialog
* @function showKeyboard
* @example
* var text = "";
* Cocoon.Dialog.showKeyboard({
* type : Cocoon.Dialog.keyboardType.TEXT,
* },{
* insertText: function(inserted) { text+= inserted; console.log(text);}
* deleteBackward: function() {text = text.slice(0, text.length -1); console.log(text);}
* done : function(){ console.log("user clicked done key") },
* cancel : function(){ console.log("user dismissed keyboard") }
* });
*/
extension.showKeyboard = function(params, callbacks) {
params = params || {};
params.type = params.type || Cocoon.Dialog.keyboardType.TEXT;
var insertCallback = callbacks && callbacks.insertText;
var deleteCallback = callbacks && callbacks.deleteBackward;
var doneCallback = callbacks && callbacks.done;
var cancelCallback = callbacks && callbacks.cancel;

if (Cocoon.nativeAvailable) {
Cocoon.callNative("IDTK_APP", "showKeyboard",
[params, insertCallback, deleteBackward, doneCallback, cancelCallback], true);
}
};

/**
* Dimisses a keyboard which was previusly shown by {@link Cocoon.Dialog.showKeyboard}
*
* @memberOf Cocoon.Dialog
* @function dismissKeyboard
* @example
* var text = "";
* Cocoon.Dialog.showKeyboard({
* type : Cocoon.Dialog.keyboardType.TEXT,
* },{
* insertText: function(inserted) {
* if (inserted === "A") { //Custom keyboard hide
* Cocoon.Dialog.dimissKeyboard();
* }
* text+= inserted; console.log(text);
* }
* deleteBackward: function() {text = text.slice(0, text.length -1); console.log(text);}
* done : function(){ console.log("user clicked done key") },
* cancel : function(){ console.log("user dismissed keyboard") }
* });
*/
extension.dismissKeyboard = function() {
if (Cocoon.nativeAvailable) {
Cocoon.callNative("IDTK_APP", "dismissKeyboard", null, true);
}
}

/**
* Allows listening to events called when the text dialog is finished by accepting it's content.
* The callback function's documentation is represented by {@link Cocoon.Dialog.OnTextDialogFinishedListener}
Expand Down
8 changes: 4 additions & 4 deletions build/cocoon.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "cocoon",
"version": "0.0.0",
"description": "CocoonJS Extensions",
"version": "3.0.4",
"description": "CocoonJS Plugins",
"main": "index.js",
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "git://github.com/ludei/cocoonjs-plugins/"
},
"keywords": [
"cocoonjs",
"cocoon"
Expand Down
2 changes: 1 addition & 1 deletion src/cocoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<a href="http://support.ludei.com/hc"><img src="img/cocoon-tools-2.png" /></a>
<a href="https://cloud.ludei.com/"><img src="img/cocoon-tools-3.png" /></a>
<a href="https://www.ludei.com/cocoonjs/how-to-use/"><img src="img/cocoon-tools-4.png" /></a>
* @version 3.0.0
* @version 3.0.4
*/
(function () {

Expand Down

0 comments on commit 41d4f85

Please sign in to comment.