Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
francois
erp5
Commits
bc44610f
Commit
bc44610f
authored
Oct 04, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to latest renderjs
parent
648eaee9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
552 additions
and
410 deletions
+552
-410
bt5/erp5_jquery_plugin_renderjs/PathTemplateItem/portal_skins/erp5_jquery/jquery/plugin/renderjs/renderjs.js.xml
..._skins/erp5_jquery/jquery/plugin/renderjs/renderjs.js.xml
+551
-409
bt5/erp5_jquery_plugin_renderjs/bt/revision
bt5/erp5_jquery_plugin_renderjs/bt/revision
+1
-1
No files found.
bt5/erp5_jquery_plugin_renderjs/PathTemplateItem/portal_skins/erp5_jquery/jquery/plugin/renderjs/renderjs.js.xml
View file @
bc44610f
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_EtagSupport__etag
</string>
</key>
<key>
<string>
_EtagSupport__etag
</string>
</key>
<value>
<string>
ts4
6068994.72
</string>
</value>
<value>
<string>
ts4
9355317.03
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
__name__
</string>
</key>
<key>
<string>
__name__
</string>
</key>
...
@@ -26,103 +26,150 @@
...
@@ -26,103 +26,150 @@
<key>
<string>
data
</string>
</key>
<key>
<string>
data
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<value>
<string
encoding=
"cdata"
>
<![CDATA[
/*global console, require, $, localStorage, document */\n
"use strict";\n
\n
/*\n
* RenderJs - Generic Gadget library renderer.\n
* http://www.renderjs.org/documentation\n
*/\n
\n
// by default RenderJs will render all gadgets when page is loaded\n
// still it\'s possible to override this and use explicit gadget rendering\n
var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true;\n
\n
// by default RenderJs will examin and bind all interaction gadgets\n
// available\n
var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true;\n
\n
if (typeof require !== \'undefined\') {\n
// example of how we can use requirejs to load external libraries\n
//require(["../../../../lib/jstorage/jstorage.js"], function (util) {\n
//});\n
}\n
\n
// fallback for IE\n
// fallback for IE\n
if (typeof console === "undefined" || typeof console.log === "undefined") {\n
if (typeof console === "undefined" || typeof console.log === "undefined") {\n
console = {};\n
console = {};\n
console.log = function() {};\n
console.log = function
() {};\n
}\n
}\n
\n
\n
\n
/*\n
* Generic Gadget library renderer\n
*/\n
\n
var RenderJs = (function () {\n
var RenderJs = (function () {\n
\n
// a variable indicating if current gadget loading is over or not\n
// a variable indicating if current gadget loading is over or not\n
var is_ready = false;\n
var is_ready = false;\n
\n
\n
return {\n
return {\n
\n
bootstrap: function (root) {\n
bootstrap: function (root){\n
/* initial load application gadget */\n
/* initial load application gadget */\n
var gadget_id;\n
gadget_id = root.attr("id");\n
if (gadget_id!==undefined) {\n
// bootstart root gadget only if it is indeed a gadget\n
RenderJs.loadGadgetFromUrl(root);\n
RenderJs.loadGadgetFromUrl(root);\n
}\n
RenderJs.load(root);\n
RenderJs.load(root);\n
},\n
},\n
\n
\n
load: function (root) {\n
load: function (root) {\n
/* Load gadget layout by traversing DOM */\n
/* Load gadget layout by traversing DOM */\n
var gadget_list
;\n
var gadget_list, gadget, gadget_id, gadget_js
;\n
gadget_list = root.find("[data-gadget]");\n
gadget_list = root.find("[data-gadget]");\n
\n
// register all gadget in advance so checkAndTriggerReady\n
// can have accurate information for list of all gadgets\n
gadget_list.each(function () {\n
gadget = $(this);\n
gadget_id = gadget.attr("id");\n
gadget_js = new RenderJs.Gadget(gadget_id, gadget);\n
RenderJs.GadgetIndex.registerGadget(gadget_js);\n
});\n
\n
// Load chilren\n
// Load chilren\n
gadget_list.each(function
() {\n
gadget_list.each(function
() {\n
RenderJs.loadGadgetFromUrl($(this));\n
RenderJs.loadGadgetFromUrl($(this));\n
});\n
});\n
},\n
},\n
\n
\n
updateAndRecurse: function(gadget, data)
{\n
updateAndRecurse: function (gadget, data)
{\n
/* Update current gadget and recurse down */\n
/* Update current gadget and recurse down */\n
gadget.append(data);\n
gadget.append(data);\n
// a gadget may contain sub gadgets\n
// a gadget may contain sub gadgets\n
this.load(gadget);\n
this.load(gadget);\n
},\n
},\n
\n
\n
loadGadgetFromUrl: function
(gadget) {\n
loadGadgetFromUrl: function
(gadget) {\n
/* Load gadget\'s SPECs from URL */\n
/* Load gadget\'s SPECs from URL */\n
var url, gadget_id, gadget_property, cacheable, cache_id, app_cache, data, gadget_js;\n
var url, gadget_id, gadget_property, cacheable, cache_id,\n
app_cache, data, gadget_js;\n
url = gadget.attr("data-gadget");\n
url = gadget.attr("data-gadget");\n
gadget_id = gadget.attr("id");\n
gadget_id = gadget.attr("id");\n
\n
gadget_js = RenderJs.GadgetIndex.getGadgetById(gadget_id);\n
// register gadget in javascript namespace\n
if (gadget_js===undefined) {\n
// register gadget in javascript namespace if not already registered\n
gadget_js = new RenderJs.Gadget(gadget_id, gadget);\n
gadget_js = new RenderJs.Gadget(gadget_id, gadget);\n
RenderJs.GadgetIndex.registerGadget(gadget_js);\n
RenderJs.GadgetIndex.registerGadget(gadget_js);\n
}\n
\n
\n
if (url!==undefined && url!==""){\n
// update Gadget\'s instance with contents of "data-gadget-property"\n
gadget_property = gadget.attr("data-gadget:property");\n
gadget_property = gadget.attr("data-gadget-property");\n
cacheable = false;\n
if (gadget_property !== undefined) {\n
if (gadget_property!==undefined) {\n
gadget_property = $.parseJSON(gadget_property);\n
gadget_property = $.parseJSON(gadget_property);\n
cacheable = Boolean(gadget_property.cacheable);\n
$.each(gadget_property, function (key, value) {\n
gadget_js[key] = value;\n
});\n
}\n
\n
if (url !== undefined && url !== "") {\n
cacheable = gadget.attr("data-gadget-cacheable");\n
cache_id = gadget.attr("data-gadget-cache-id");\n
if (cacheable !== undefined && cache_id !== undefined) {\n
cacheable = Boolean(parseInt(cacheable, 10));\n
}\n
}\n
//cacheable = false ; // to develop faster\n
//cacheable = false ; // to develop faster\n
if (cacheable) {\n
if (cacheable) {\n
// get from cache if possible, use last part from URL as cache_key
\n
// get from cache if possible, use last part from URL as
\n
cache_id = gadget_property.cache_id;
\n
// cache_key
\n
app_cache = RenderJs.Cache.get(cache_id, undefined);\n
app_cache = RenderJs.Cache.get(cache_id, undefined);\n
if(app_cache===undefined || app_cache===null)
{\n
if (app_cache === undefined || app_cache === null)
{\n
// not in cache so we pull from network and cache\n
// not in cache so we pull from network and cache\n
$.ajax({url:url,\n
$.ajax({\n
yourCustomData: {"gadget_id": gadget_id, "cache_id": cache_id},\n
url: url,\n
yourCustomData: {\n
"gadget_id": gadget_id,\n
"cache_id": cache_id\n
},\n
success: function (data) {\n
success: function (data) {\n
cache_id = this.yourCustomData.cache_id;\n
cache_id = this.yourCustomData.cache_id;\n
gadget_id = this.yourCustomData.gadget_id;\n
gadget_id = this.yourCustomData.gadget_id;\n
RenderJs.Cache.set(cache_id, data);\n
RenderJs.Cache.set(cache_id, data);\n
RenderJs.GadgetIndex.getGadgetById(gadget_id).setReady();\n
RenderJs.GadgetIndex.getGadgetById(gadget_id).\n
setReady();\n
RenderJs.updateAndRecurse(gadget, data);\n
RenderJs.updateAndRecurse(gadget, data);\n
RenderJs.checkAndTriggerReady();\n
RenderJs.checkAndTriggerReady();\n
}});\n
}\n
}\n
else {\n
});\n
} else {\n
// get from cache\n
// get from cache\n
data = app_cache;\n
data = app_cache;\n
gadget_js.setReady();\n
gadget_js.setReady();\n
this.updateAndRecurse(gadget, data);\n
this.updateAndRecurse(gadget, data);\n
this.checkAndTriggerReady();\n
this.checkAndTriggerReady();\n
}\n
}\n
}\n
} else {\n
else {\n
// not to be cached\n
// not to be cached\n
$.ajax({url:url,\n
$.ajax({\n
url: url,\n
yourCustomData: {"gadget_id": gadget_id},\n
yourCustomData: {"gadget_id": gadget_id},\n
success: function (data) {\n
success: function (data) {\n
gadget_id = this.yourCustomData.gadget_id;\n
gadget_id = this.yourCustomData.gadget_id;\n
RenderJs.GadgetIndex.getGadgetById(gadget_id).setReady();\n
RenderJs.GadgetIndex.getGadgetById(gadget_id).\n
setReady();\n
RenderJs.updateAndRecurse(gadget, data);\n
RenderJs.updateAndRecurse(gadget, data);\n
RenderJs.checkAndTriggerReady();\n
RenderJs.checkAndTriggerReady();\n
}});\n
}\n
}\n
});\n
}\n
}\n
else {\n
}
else {\n
// gadget is an inline one so no need to load it from network\n
// gadget is an inline one so no need to load it from network\n
gadget_js.setReady();\n
gadget_js.setReady();\n
RenderJs.checkAndTriggerReady();\n
RenderJs.checkAndTriggerReady();\n
...
@@ -135,74 +182,122 @@ var RenderJs = (function () {\n
...
@@ -135,74 +182,122 @@ var RenderJs = (function () {\n
*/\n
*/\n
return is_ready;\n
return is_ready;\n
},\n
},\n
\n
\n
setReady: function (value) {\n
setReady: function (value) {\n
/*\n
/*\n
* Update rendering status\n
* Update rendering status\n
*/\n
*/\n
is_ready = value; \n
is_ready = value;\n
},\n
\n
bindReady: function (ready_function) {\n
/*\n
* Bind a function on ready gadget loading.\n
*/\n
$("body").one("ready", ready_function);\n
},\n
},\n
\n
\n
checkAndTriggerReady: function
() {\n
checkAndTriggerReady: function
() {\n
/*\n
/*\n
* Trigger "ready" event only if all gadgets were marked as "ready"\n
* Trigger "ready" event only if all gadgets were marked as "ready"\n
*/\n
*/\n
var is_gadget_list_loaded;\n
var is_gadget_list_loaded;\n
is_gadget_list_loaded = RenderJs.GadgetIndex.isGadgetListLoaded();\n
is_gadget_list_loaded = RenderJs.GadgetIndex.isGadgetListLoaded();\n
if (is_gadget_list_loaded){\n
if (is_gadget_list_loaded)
{\n
if (!RenderJs.isReady()) {\n
if (!RenderJs.isReady()) {\n
RenderJs.GadgetIndex.getRootGadget().getDom().trigger("ready");\n
// backwards compatability with already written code\n
RenderJs.GadgetIndex.getRootGadget().getDom().\n
trigger("ready");\n
// trigger ready on root body element\n
$("body").trigger("ready");\n
RenderJs.setReady(true);\n
RenderJs.setReady(true);\n
}\n
}\n
//is_ready = true;\n
}\n
}\n
return is_gadget_list_loaded;\n
return is_gadget_list_loaded;\n
},\n
},\n
\n
\n
update: function (root) {\n
update: function (root) {\n
/* update gadget with data from remote source */\n
/* update gadget with data from remote source */\n
root.find("[gadget]").each(function(i,v){RenderJs.updateGadgetData($(this));});\n
root.find("[gadget]").each(function (i, v) {\n
RenderJs.updateGadgetData($(this));\n
});\n
},\n
},\n
\n
\n
updateGadgetWithDataHandler: function (result) {\n
updateGadgetWithDataHandler: function (result) {\n
var data_handler;\n
var data_handler;\n
data_handler = this.yourCustomData.data_handler;\n
data_handler = this.yourCustomData.data_handler;\n
if (data_handler!==undefined)
{\n
if (data_handler !== undefined)
{\n
eval(data_handler
+ "(result)");\n
eval(data_handler
+ "(result)");\n
}\n
}\n
},\n
},\n
\n
\n
updateGadgetData: function
(gadget) {\n
updateGadgetData: function
(gadget) {\n
/* Do real gagdet update here */\n
/* Do real gagdet update here */\n
var data_source, data_handler;\n
var data_source, data_handler;\n
data_source = gadget.attr("data-gadget:data
-source");\n
data_source = gadget.attr("data-gadget
-source");\n
data_handler = gadget.attr("data-gadget:data
-handler");\n
data_handler = gadget.attr("data-gadget
-handler");\n
// acquire data and pass it to method handler\n
// acquire data and pass it to method handler\n
if (data_source!==undefined){\n
if (data_source !== undefined && data_source !== "") {\n
$.ajax({url:data_source,\n
$.ajax({\n
url: data_source,\n
dataType: "json",\n
dataType: "json",\n
yourCustomData: {"data_handler": data_handler},\n
yourCustomData: {"data_handler": data_handler},\n
success: RenderJs.updateGadgetWithDataHandler});}\n
success: RenderJs.updateGadgetWithDataHandler\n
});\n
}\n
},\n
},\n
\n
\n
Cache : (function() {\n
addGadget: function (dom_id, gadget, gadget_data_handler,\n
gadget_data_source) {\n
/*\n
/*\n
* Generic cache implementation that can fall back to local namespace storage\n
* add new gadget and render it\n
* if no "modern" storage like localStorage is available\n
*/\n
*/\n
var html_string, tab_container, tab_gadget;\n
tab_container = $(\'#\' + dom_id);\n
tab_container.empty();\n
html_string = [\n
\'<div class="gadget" \',\n
\'data-gadget="\' + gadget + \'"\',\n
\'data-gadget-handler="\' + gadget_data_handler + \'" \',\n
\'data-gadget-source="\' + gadget_data_source + \'">
</div>
\'\n
].join(\'\\n\');\n
\n
\n
return {\n
tab_container.append(html_string);\n
tab_gadget = tab_container.find(".gadget");\n
// render new gadget\n
RenderJs.setReady(false);\n
RenderJs.loadGadgetFromUrl(tab_gadget);\n
// clear previous events\n
RenderJs.GadgetIndex.getRootGadget().getDom().bind(\n
"ready",\n
function () {\n
if (!is_ready) {\n
RenderJs.updateGadgetData(tab_gadget);\n
is_ready = true;\n
}\n
}\n
);\n
return tab_gadget;\n
},\n
\n
\n
Cache: (function () {\n
/*\n
* Generic cache implementation that can fall back to local\n
* namespace storage if no "modern" storage like localStorage\n
* is available\n
*/\n
return {\n
ROOT_CACHE_ID: \'APP_CACHE\',\n
ROOT_CACHE_ID: \'APP_CACHE\',\n
\n
\n
getCacheId: function (cache_id) {\n
getCacheId: function (cache_id) {\n
/* We should have a way to \'purge\' localStorage by setting a ROOT_CACHE_ID in all browser\n
/*\n
* instances\n
* We should have a way to \'purge\' localStorage by setting a\n
* ROOT_CACHE_ID in all browser instances\n
*/\n
*/\n
return this.ROOT_CACHE_ID + cache_id;\n
return this.ROOT_CACHE_ID + cache_id;\n
},\n
},\n
\n
\n
hasLocalStorage: function
() {\n
hasLocalStorage: function
() {\n
/*\n
/*\n
* Feature test if localStorage is supported\n
* Feature test if localStorage is supported\n
*/\n
*/\n
...
@@ -212,8 +307,7 @@ var RenderJs = (function () {\n
...
@@ -212,8 +307,7 @@ var RenderJs = (function () {\n
localStorage.setItem(mod, mod);\n
localStorage.setItem(mod, mod);\n
localStorage.removeItem(mod);\n
localStorage.removeItem(mod);\n
return true;\n
return true;\n
}\n
} catch (e) {\n
catch (e) {\n
return false;\n
return false;\n
}\n
}\n
},\n
},\n
...
@@ -222,42 +316,50 @@ var RenderJs = (function () {\n
...
@@ -222,42 +316,50 @@ var RenderJs = (function () {\n
/* Get cache key value */\n
/* Get cache key value */\n
cache_id = this.getCacheId(cache_id);\n
cache_id = this.getCacheId(cache_id);\n
if (this.hasLocalStorage()) {\n
if (this.hasLocalStorage()) {\n
return this.LocalStorageCachePlugin.get(cache_id, default_value);\n
return this.LocalStorageCachePlugin.\n
get(cache_id, default_value);\n
}\n
}\n
//fallback to javscript namespace cache\n
//fallback to javscript namespace cache\n
return this.NameSpaceStorageCachePlugin.get(cache_id, default_value);\n
return this.NameSpaceStorageCachePlugin.\n
get(cache_id, default_value);\n
},\n
},\n
\n
\n
set: function (cache_id, data) {\n
set: function (cache_id, data) {\n
/* Set cache key value */\n
/* Set cache key value */\n
cache_id = this.getCacheId(cache_id);\n
cache_id = this.getCacheId(cache_id);\n
if (this.hasLocalStorage()){\n
if (this.hasLocalStorage()) {\n
this.LocalStorageCachePlugin.set(cache_id, data);}\n
this.LocalStorageCachePlugin.set(cache_id, data);\n
else{\n
} else {\n
this.NameSpaceStorageCachePlugin.set(cache_id, data);}\n
this.NameSpaceStorageCachePlugin.set(cache_id, data);\n
}\n
},\n
},\n
\n
\n
LocalStorageCachePlugin : (function
() {\n
LocalStorageCachePlugin: (function
() {\n
/*\n
/*\n
* This plugin saves using HTML5 localStorage.\n
* This plugin saves using HTML5 localStorage.\n
*/\n
*/\n
return {\n
return {\n
get: function (cache_id, default_value) {\n
get: function (cache_id, default_value) {\n
/* Get cache key value */\n
/* Get cache key value */\n
return $.jStorage.get(cache_id, default_value);\n
if (cache_id in localStorage) {\n
return JSON.parse(localStorage.getItem(cache_id));\n
}\n
else {\n
return default_value;\n
}\n
},\n
},\n
\n
\n
set: function (cache_id, data) {\n
set: function (cache_id, data) {\n
/* Set cache key value */\n
/* Set cache key value */\n
$.jStorage.set(cache_id, data
);\n
localStorage.setItem(cache_id, JSON.stringify(data)
);\n
}\n
}\n
}}()),\n
};\n
}()),\n
\n
\n
NameSpaceStorageCachePlugin: (function
() {\n
NameSpaceStorageCachePlugin: (function
() {\n
/*\n
/*\n
* This plugin saves within current page namespace.\n
* This plugin saves within current page namespace.\n
*/\n
*/\n
\n
var namespace = {};\n
var namespace = {};\n
\n
\n
return {\n
return {\n
...
@@ -270,117 +372,98 @@ var RenderJs = (function () {\n
...
@@ -270,117 +372,98 @@ var RenderJs = (function () {\n
/* Set cache key value */\n
/* Set cache key value */\n
namespace[cache_id] = data;\n
namespace[cache_id] = data;\n
}\n
}\n
};\n
}())\n
};\n
}()),\n
\n
\n
}}())\n
Gadget: (function (gadget_id, dom) {\n
\n
}}()),\n
\n
Gadget: ( function (id, dom) {\n
/*\n
/*\n
* Javascript Gadget representation\n
* Javascript Gadget representation\n
*/\n
*/\n
this.id =
id;\n
this.id = gadget_
id;\n
this.dom = dom;\n
this.dom = dom;\n
this.is_ready = false;\n
this.is_ready = false;\n
\n
\n
this.getId = function
() {\n
this.getId = function
() {\n
return this.id;\n
return this.id;\n
};\n
};\n
\n
\n
this.getDom = function
() {\n
this.getDom = function
() {\n
return this.dom;\n
return this.dom;\n
};\n
};\n
\n
\n
this.isReady = function
() {\n
this.isReady = function
() {\n
/*\n
/*\n
* Return True if remote gadget is loaded into DOM.\n
* Return True if remote gadget is loaded into DOM.\n
*/\n
*/\n
return this.is_ready;\n
return this.is_ready;\n
};\n
};\n
\n
\n
this.setReady = function
() {\n
this.setReady = function
() {\n
/*\n
/*\n
* Return True if remote gadget is loaded into DOM.\n
* Return True if remote gadget is loaded into DOM.\n
*/\n
*/\n
this.is_ready = true;\n
this.is_ready = true;\n
};\n
};\n
}),\n
}),\n
\n
\n
TabbularGadget
: (function () {\n
TabbularGadget
: (function () {\n
/*\n
/*\n
* Generic tabular gadget\n
* Generic tabular gadget\n
*/\n
*/\n
return {\n
return {\n
\n
toggleVisibility: function (visible_dom) {\n
toggleVisibility: function(visible_dom) {\n
/*\n
/*\n
* Set tab as active visually and mark as not active rest.\n
* Set tab as active visually and mark as not active rest.\n
*/\n
*/\n
$(".selected").addClass("not_selected"); $(".selected").removeClass("selected");\n
$(".selected").addClass("not_selected");\n
$(".selected").removeClass("selected");\n
visible_dom.addClass("selected");\n
visible_dom.addClass("selected");\n
visible_dom.removeClass("not_selected");\n
visible_dom.removeClass("not_selected");\n
},\n
},\n
\n
\n
addNewTabGadget: function(dom_id, gadget, gadget_data_handler, gadget_data_source) {\n
addNewTabGadget: function (dom_id, gadget, gadget_data_handler,\n
gadget_data_source) {\n
/*\n
/*\n
* add new gadget and render it\n
* add new gadget and render it\n
*/\n
*/\n
var html_string;\n
var tab_gadget;\n
tab_container=$(\'#\'+dom_id);\n
tab_gadget = RenderJs.addGadget(\n
tab_container.empty();\n
dom_id, gadget, gadget_data_handler, gadget_data_source\n
html_string =[\'<div class="gadget" \',\n
);\n
\'data-gadget="\' + gadget + \'"\',\n
\'data-gadget:data-handler="\' + gadget_data_handler + \'" \',\n
\'data-gadget:data-source="\' + gadget_data_source +\'">
</div>
\'].join(\'\\n\');\n
\n
tab_container.append(html_string);\n
tab_gadget = tab_container.find(".gadget");\n
\n
// XXX: we should unregister all gadgets (if any we replace now in DOM)\n
// XXX: we should unregister all gadgets (if any we replace now in DOM)\n
\n
// render new gadget\n
RenderJs.setReady(false);\n
RenderJs.loadGadgetFromUrl(tab_gadget);\n
// clear previous events\n
RenderJs.GadgetIndex.getRootGadget().getDom().bind("ready", function (){\n
if (!is_ready){\n
RenderJs.updateGadgetData(tab_gadget);\n
is_ready = true;\n
}\n
}\n
});\n
};\n
}\n
}()),\n
\n
}}()),\n
\n
\n
\n
GadgetIndex
: (function () {\n
GadgetIndex
: (function () {\n
/*\n
/*\n
* Generic gadget index placeholder\n
* Generic gadget index placeholder\n
*/\n
*/\n
var gadget_list = [];\n
var gadget_list = [];\n
\n
\n
return {\n
return {\n
\n
getGadgetList: function () {\n
getGadgetList: function() {\n
/*\n
/*\n
* Return list of registered gadgets\n
* Return list of registered gadgets\n
*/\n
*/\n
return gadget_list;\n
return gadget_list;\n
},\n
},\n
\n
\n
registerGadget: function
(gadget) {\n
registerGadget: function
(gadget) {\n
/*\n
/*\n
* Register gadget\n
* Register gadget\n
*/\n
*/\n
gadget_list.push(gadget);\n
gadget_list.push(gadget);\n
},\n
},\n
\n
\n
unregisterGadget: function
(gadget) {\n
unregisterGadget: function
(gadget) {\n
/*\n
/*\n
* Unregister gadget\n
* Unregister gadget\n
*/\n
*/\n
var index = $.inArray(gadget, gadget_list);\n
var index = $.inArray(gadget, gadget_list);\n
if (index!==
-1) {\n
if (index !==
-1) {\n
gadget_list.splice(index, 1);\n
gadget_list.splice(index, 1);\n
}\n
}\n
},\n
},\n
...
@@ -393,9 +476,11 @@ var RenderJs = (function () {\n
...
@@ -393,9 +476,11 @@ var RenderJs = (function () {\n
gadget = undefined;\n
gadget = undefined;\n
$(RenderJs.GadgetIndex.getGadgetList()).each(\n
$(RenderJs.GadgetIndex.getGadgetList()).each(\n
function (index, value) {\n
function (index, value) {\n
if (value.getId()===
gadget_id) {\n
if (value.getId() ===
gadget_id) {\n
gadget = value;\n
gadget = value;\n
}});\n
}\n
}\n
);\n
return gadget;\n
return gadget;\n
},\n
},\n
\n
\n
...
@@ -408,72 +493,129 @@ var RenderJs = (function () {\n
...
@@ -408,72 +493,129 @@ var RenderJs = (function () {\n
\n
\n
isGadgetListLoaded: function () {\n
isGadgetListLoaded: function () {\n
/*\n
/*\n
* Return True if all gadgets were loaded from network or cache\n
* Return True if all gadgets were loaded from network or\n
* cache\n
*/\n
*/\n
var result;\n
var result;\n
result = true;\n
result = true;\n
$(this.getGadgetList()).each(\n
$(this.getGadgetList()).each(\n
function (index, value) {\n
function (index, value) {\n
if (value.isReady()===
false) {\n
if (value.isReady() ===
false) {\n
result = false;\n
result = false;\n
}\n
}\n
});\n
}\n
);\n
return result;\n
return result;\n
},\n
\n
getSelf: function (){\n
/*\n
* Return Gadget\'s Javascript representation\n
*/\n
// XXX:\n
}\n
}\n
\n
};
\n
}
}()),\n
}()),\n
\n
\n
InteractionGadget : (function () {\n
InteractionGadget : (function () {\n
/*\n
/*\n
* Basic gadget interaction gadget implementation.\n
* Basic gadget interaction gadget implementation.\n
*/\n
*/\n
return {\n
return {\n
\n
bind: function (gadget_dom) {\n
bind: function (gadget_dom){\n
/*\n
/*\n
* Bind event between gadgets.\n
* Bind event between gadgets.\n
*/\n
*/\n
var gadget_id, gadget_connection_list,\n
createMethodInteraction = function (\n
original_source_method_id, source_gadget_id,\n
source_method_id, destination_gadget_id,\n
destination_method_id) {\n
var interaction = function () {\n
RenderJs.GadgetIndex.getGadgetById(\n
source_gadget_id)[original_source_method_id].\n
apply(null, arguments);\n
RenderJs.GadgetIndex.getGadgetById(\n
destination_gadget_id)[destination_method_id].\n
apply(null, arguments);\n
};\n
return interaction;\n
},\n
createTriggerInteraction = function (\n
destination_gadget_id, destination_method_id) {\n
var interaction = function () {\n
RenderJs.GadgetIndex.getGadgetById(\n
destination_gadget_id)[destination_method_id].\n
apply(null, arguments);\n
};\n
return interaction;\n
};\n
gadget_id = gadget_dom.attr("id");\n
gadget_id = gadget_dom.attr("id");\n
gadget_dom.find("connect").each(function (key, value){\n
gadget_connection_list = gadget_dom.attr("data-gadget-connection");\n
var source, source_gadget_id, source_method_id, source_gadget, destination, destination_gadget_id,\n
gadget_connection_list = $.parseJSON(gadget_connection_list);\n
destination_method_id, destination_gadget, func_body, func;\n
$.each(gadget_connection_list, function (key, value) {\n
source = $(value).attr("source").split(".");\n
var source, source_gadget_id, source_method_id,\n
source_gadget, destination, destination_gadget_id,\n
destination_method_id, destination_gadget,\n
original_source_method_id;\n
source = value.source.split(".");\n
source_gadget_id = source[0];\n
source_gadget_id = source[0];\n
source_method_id = source[1];\n
source_method_id = source[1];\n
source_gadget = RenderJs.GadgetIndex.getGadgetById(source_gadget_id);\n
source_gadget = RenderJs.GadgetIndex.\n
getGadgetById(source_gadget_id);\n
\n
\n
destination = $(value).attr("destination")
.split(".");\n
destination = value.destination
.split(".");\n
destination_gadget_id = destination[0];\n
destination_gadget_id = destination[0];\n
destination_method_id = destination[1];\n
destination_method_id = destination[1];\n
destination_gadget = RenderJs.GadgetIndex.getGadgetById(destination_gadget_id);\n
destination_gadget = RenderJs.GadgetIndex.\n
getGadgetById(destination_gadget_id);\n
\n
\n
if (source_gadget.hasOwnProperty(source_method_id))
{\n
if (source_gadget.hasOwnProperty(source_method_id))
{\n
// direct javascript use case\n
// direct javascript use case\n
func_body = \'RenderJs.GadgetIndex.getGadgetById("\' + source_gadget_id + \'")["original_\' + source_method_id + \'"]();\';
\n
original_source_method_id = "original_" +
\n
func_body = func_body + \'\\nRenderJs.GadgetIndex.getGadgetById("\' + destination_gadget_id + \'")["\' + destination_method_id + \'"]();\'
;\n
source_method_id
;\n
func = new Function(func_body);
\n
source_gadget[original_source_method_id] =
\n
source_gadget["original_" + source_method_id] =
source_gadget[source_method_id];\n
source_gadget[source_method_id];\n
source_gadget[source_method_id] =
func;
\n
source_gadget[source_method_id] =\n
}
\n
createMethodInteraction(
\n
else{
\n
original_source_method_id,
\n
// this is a custom event attached to HTML gadget representation
\n
source_gadget_id,
\n
func_body = \'RenderJs.GadgetIndex.getGadgetById("\' + destination_gadget_id + \'")["\' + destination_method_id + \'"]();\';
\n
source_method_id,
\n
func = new Function(func_body);
\n
destination_gadget_id,
\n
source_gadget.dom.bind(source_method_id, func);
\n
destination_method_id
\n
}
\n
);
\n
}\n
}\n
else {\n
// this is a custom event attached to HTML gadget\n
// representation\n
source_gadget.dom.bind(\n
source_method_id,\n
createTriggerInteraction(\n
destination_gadget_id, destination_method_id\n
)\n
);\n
);\n
}\n
}\n
}}())\n
});\n
}\n
};\n
}())\n
};\n
}());\n
\n
\n
}}());
// impliticly call RenderJs bootstrap\n
$(document).ready(function () {\n
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {\n
RenderJs.bootstrap($(\'body\'));\n
}\n
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {\n
var root_gadget = RenderJs.GadgetIndex.getRootGadget();\n
// We might have a page without gadgets.\n
// Be careful, right now we can be in this case because\n
// asynchronous gadget loading is not finished\n
if (root_gadget !== undefined) {\n
RenderJs.bindReady(\n
function () {\n
// examine all Intaction Gadgets and bind accordingly\n
$("div[data-gadget-connection]").each( function(index, element) {\n
RenderJs.InteractionGadget.bind($(element));\n
})\n
});\n
}\n
}\n
});
]]>
</string>
</value>
]]>
</string>
</value>
</item>
</item>
...
@@ -483,7 +625,7 @@ var RenderJs = (function () {\n
...
@@ -483,7 +625,7 @@ var RenderJs = (function () {\n
</item>
</item>
<item>
<item>
<key>
<string>
size
</string>
</key>
<key>
<string>
size
</string>
</key>
<value>
<int>
18997
</int>
</value>
<value>
<int>
22925
</int>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
title
</string>
</key>
<key>
<string>
title
</string>
</key>
...
...
bt5/erp5_jquery_plugin_renderjs/bt/revision
View file @
bc44610f
20
21
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment