Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hamza
erp5-Boxiang
Commits
1accdd93
Commit
1accdd93
authored
Feb 28, 2013
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to recent RenderJs.
parent
327f785b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
284 additions
and
40 deletions
+284
-40
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
+280
-36
bt5/erp5_jquery_plugin_renderjs/PathTemplateItem/portal_skins/erp5_jquery/jquery/plugin/renderjs/renderjs.min.js.xml
...ns/erp5_jquery/jquery/plugin/renderjs/renderjs.min.js.xml
+3
-3
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 @
1accdd93
...
@@ -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>
ts
58177410.64
</string>
</value>
<value>
<string>
ts
62057361.38
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
__name__
</string>
</key>
<key>
<string>
__name__
</string>
</key>
...
@@ -26,9 +26,10 @@
...
@@ -26,9 +26,10 @@
<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
/*! RenderJs v0.2 */\n
/*global console, require, $, localStorage, document, jIO */\n
/*jslint evil: true, white: true */\n
"use strict";\n
"use strict";\n
\n
/*\n
/*\n
* RenderJs - Generic Gadget library renderer.\n
* RenderJs - Generic Gadget library renderer.\n
* http://www.renderjs.org/documentation\n
* http://www.renderjs.org/documentation\n
...
@@ -39,18 +40,28 @@
...
@@ -39,18 +40,28 @@
var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true;\n
var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING = true;\n
\n
\n
// by default RenderJs will examine and bind all interaction gadgets\n
// by default RenderJs will examine and bind all interaction gadgets\n
// available
\n
// available\n
var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true;\n
var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND = true;\n
\n
\n
// by default RenderJs will examine and create all routes\n
var RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE = true;\n
\n
// fallback for IE\n
// fallback for IE\n
if (
typeof console === "undefined" || typeof console.log === "undefined"
) {\n
if (
console === undefined || console.log === undefined
) {\n
console = {};\n
var
console = {};\n
console.log = function () {};\n
console.log = function () {};\n
}\n
}\n
\n
\n
var RenderJs = (function () {\n
var RenderJs = (function () {\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, current_gadget;\n
\n
function setSelfGadget (gadget) {\n
/*\n
* Only used internally to set current gadget being executed.\n
*/\n
current_gadget = gadget;\n
}\n
\n
\n
return {\n
return {\n
\n
\n
...
@@ -61,21 +72,25 @@ var RenderJs = (function () {\n
...
@@ -61,21 +72,25 @@ var RenderJs = (function () {\n
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {\n
if (RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING) {\n
RenderJs.bootstrap($(\'body\'));\n
RenderJs.bootstrap($(\'body\'));\n
}\n
}\n
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {
\n
var root_gadget = RenderJs.GadgetIndex.getRootGadget();
\n
var root_gadget = RenderJs.GadgetIndex.getRootGadget();
\n
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND||RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE) {
\n
// We might have a page without gadgets.\n
// We might have a page without gadgets.\n
// Be careful, right now we can be in this case because\n
// Be careful, right now we can be in this case because\n
// asynchronous gadget loading is not finished\n
// asynchronous gadget loading is not finished\n
if (root_gadget !== undefined) {\n
if (root_gadget !== undefined) {\n
RenderJs.bindReady(\n
RenderJs.bindReady(\n
function () {\n
function () {\n
// examine all Intaction Gadgets and bind accordingly\n
if (RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND) {\n
$("div[data-gadget-connection]").each( function (index, element) {\n
// examine all Intaction Gadgets and bind accordingly\n
RenderJs.InteractionGadget.bind($(element));\n
RenderJs.InteractionGadget.init();\n
})\n
}\n
if (RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE) {\n
// create all routes between gadgets\n
RenderJs.RouteGadget.init();\n
}\n
});\n
});\n
}\n
}\n
}
;
\n
}\n
},\n
},\n
\n
\n
bootstrap: function (root) {\n
bootstrap: function (root) {\n
...
@@ -122,25 +137,51 @@ var RenderJs = (function () {\n
...
@@ -122,25 +137,51 @@ var RenderJs = (function () {\n
* Set gadget data and recursively load it in case it holds another\n
* Set gadget data and recursively load it in case it holds another\n
* gadgets.\n
* gadgets.\n
*/\n
*/\n
// set current gadget as being loaded so gadget instance itself knows which gadget it is\n
setSelfGadget(RenderJs.GadgetIndex.getGadgetById(gadget.attr("id")));\n
gadget.append(data);\n
gadget.append(data);\n
// reset as no longer current gadget\n
setSelfGadget(undefined);\n
// a gadget may contain sub gadgets\n
// a gadget may contain sub gadgets\n
RenderJs.loadRecursiveGadget(gadget);\n
RenderJs.loadRecursiveGadget(gadget);\n
},\n
},\n
\n
getSelfGadget: function () {\n
/*\n
* Get current gadget being loaded\n
* This function must be used with care as it relies on Javascript nature of being a single\n
* threaded application. Currently current gadget is set in a global RenderJs variable\n
* before its HTML is inserted into DOM and if multiple threads were running (which is not the case currently)\n
* this could lead to reace conditions and unreliable getSelfGadget results.\n
* Additionally this function is available only at gadget\'s script load time - i.e.\n
* it can\'t be used in after that calls. In this case gagdget can save this value internally.\n
*/\n
return current_gadget;\n
},\n
\n
\n
loadGadget: function (gadget) {\n
loadGadget: function (gadget) {\n
/*\n
/*\n
* Load gadget\'s SPECs from URL\n
* Load gadget\'s SPECs from URL\n
*/\n
*/\n
var url, gadget_id, gadget_property, cacheable, cache_id,\n
var url, gadget_id, gadget_property, cacheable, cache_id,\n
i, gadget_index, gadget_index_id,\n
app_cache, data, gadget_js, is_update_gadget_data_running;\n
app_cache, data, gadget_js, is_update_gadget_data_running;\n
\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
gadget_js = RenderJs.GadgetIndex.getGadgetById(gadget_id);\n
gadget_js = RenderJs.GadgetIndex.getGadgetById(gadget_id);\n
gadget_index = RenderJs.GadgetIndex.getGadgetList();\n
\n
if (gadget_js === undefined) {\n
if (gadget_js === undefined) {\n
// register gadget in javascript namespace if not already registered\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 (gadget_js.isReady()) {\n
// avoid loading again gadget which was loaded before in same page\n
return ;\n
}\n
\n
\n
// update Gadget\'s instance with contents of "data-gadget-property"\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
...
@@ -263,7 +304,7 @@ var RenderJs = (function () {\n
...
@@ -263,7 +304,7 @@ var RenderJs = (function () {\n
updateGadgetData: function (gadget) {\n
updateGadgetData: function (gadget) {\n
/*\n
/*\n
* Gadget can be updated from "data-gadget-source" (i.e. a json)\n
* Gadget can be updated from "data-gadget-source" (i.e. a json)\n
* and "data-gadget-handler" attributes (i.e. a namespace Javascript)
\n
* and "data-gadget-handler" attributes (i.e. a namespace Javascript)\n
*/\n
*/\n
var data_source, data_handler;\n
var data_source, data_handler;\n
data_source = gadget.attr("data-gadget-source");\n
data_source = gadget.attr("data-gadget-source");\n
...
@@ -312,7 +353,7 @@ var RenderJs = (function () {\n
...
@@ -312,7 +353,7 @@ var RenderJs = (function () {\n
].join(\'\\n\');\n
].join(\'\\n\');\n
\n
\n
tab_container.append(html_string);\n
tab_container.append(html_string);\n
tab_gadget = tab_container.find(
".gadget"
);\n
tab_gadget = tab_container.find(
\'#\' + gadget_id
);\n
\n
\n
// render new gadget\n
// render new gadget\n
RenderJs.bootstrap(tab_container);\n
RenderJs.bootstrap(tab_container);\n
...
@@ -381,12 +422,10 @@ var RenderJs = (function () {\n
...
@@ -381,12 +422,10 @@ var RenderJs = (function () {\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
if (
cache_id in localStorage
) {\n
if (
localStorage.getItem(cache_id) !== null
) {\n
return JSON.parse(localStorage.getItem(cache_id));\n
return JSON.parse(localStorage.getItem(cache_id));\n
}\n
}\n
else {\n
return default_value;\n
return default_value;\n
}\n
},\n
},\n
\n
\n
set: function (cache_id, data) {\n
set: function (cache_id, data) {\n
...
@@ -417,7 +456,7 @@ var RenderJs = (function () {\n
...
@@ -417,7 +456,7 @@ var RenderJs = (function () {\n
};\n
};\n
}()),\n
}()),\n
\n
\n
Gadget:
(
function (gadget_id, dom) {\n
Gadget: function (gadget_id, dom) {\n
/*\n
/*\n
* Javascript Gadget representation\n
* Javascript Gadget representation\n
*/\n
*/\n
...
@@ -451,17 +490,25 @@ var RenderJs = (function () {\n
...
@@ -451,17 +490,25 @@ var RenderJs = (function () {\n
/*\n
/*\n
* Remove gadget (including its DOM element).\n
* Remove gadget (including its DOM element).\n
*/\n
*/\n
// unregister from GadgetIndex\n
var gadget;\n
// unregister root from GadgetIndex\n
RenderJs.GadgetIndex.unregisterGadget(this);\n
RenderJs.GadgetIndex.unregisterGadget(this);\n
// remove its DOM element\n
// gadget might contain sub gadgets so before remove entire\n
// DOM we must unregister them from GadgetIndex\n
this.getDom().find("[data-gadget]").each( function () {\n
gadget = RenderJs.GadgetIndex.getGadgetById($(this).attr("id"));\n
RenderJs.GadgetIndex.unregisterGadget(gadget);\n
});\n
// remove root\'s entire DOM element\n
$(this.getDom()).remove();\n
$(this.getDom()).remove();\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
var gadget_list = [];\n
return {\n
return {\n
toggleVisibility: function (visible_dom) {\n
toggleVisibility: function (visible_dom) {\n
/*\n
/*\n
...
@@ -482,7 +529,18 @@ var RenderJs = (function () {\n
...
@@ -482,7 +529,18 @@ var RenderJs = (function () {\n
tab_gadget = RenderJs.addGadget(\n
tab_gadget = RenderJs.addGadget(\n
dom_id, gadget_id, gadget, gadget_data_handler, gadget_data_source\n
dom_id, gadget_id, gadget, gadget_data_handler, gadget_data_source\n
);\n
);\n
// XXX: we should unregister all gadgets (if any we replace now in DOM)\n
\n
// we should unregister all gadgets part of this TabbularGadget\n
$.each(gadget_list,\n
function (index, gadget_id) {\n
var gadget = RenderJs.GadgetIndex.getGadgetById(gadget_id);\n
gadget.remove();\n
// update list of root gadgets inside TabbularGadget\n
gadget_list.splice($.inArray(gadget_id, gadget_list), 1);\n
}\n
);\n
// add it as root gadget\n
gadget_list.push(tab_gadget.attr("id"));\n
}\n
}\n
};\n
};\n
}()),\n
}()),\n
...
@@ -525,7 +583,10 @@ var RenderJs = (function () {\n
...
@@ -525,7 +583,10 @@ var RenderJs = (function () {\n
/*\n
/*\n
* Register gadget\n
* Register gadget\n
*/\n
*/\n
gadget_list.push(gadget);\n
if (RenderJs.GadgetIndex.getGadgetById(gadget.id) === undefined) {\n
// register only if not already added\n
gadget_list.push(gadget);\n
}\n
},\n
},\n
\n
\n
unregisterGadget: function (gadget) {\n
unregisterGadget: function (gadget) {\n
...
@@ -579,17 +640,120 @@ var RenderJs = (function () {\n
...
@@ -579,17 +640,120 @@ var RenderJs = (function () {\n
}\n
}\n
};\n
};\n
}()),\n
}()),\n
\n
GadgetCatalog : (function () {\n
/*\n
* Gadget catalog provides API to get list of gadgets from a repository\n
*/\n
var cache_id = "setGadgetIndexUrlList";\n
\n
function updateGadgetIndexFromURL(url) {\n
// split to base and document url\n
var url_list = url.split(\'/\'),\n
document_url = url_list[url_list.length-1],\n
d = url_list.splice($.inArray(document_url, url_list), 1),\n
base_url = url_list.join(\'/\'),\n
web_dav = jIO.newJio({\n
"type": "dav",\n
"username": "",\n
"password": "",\n
"url": base_url});\n
web_dav.get(document_url,\n
function (err, response) {\n
RenderJs.Cache.set(url, response);\n
});\n
}\n
\n
return {\n
updateGadgetIndex: function () {\n
/*\n
* Update gadget index from all configured remote repositories.\n
*/\n
$.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),\n
function(index, value) {\n
updateGadgetIndexFromURL(value);\n
});\n
},\n
\n
setGadgetIndexUrlList: function (url_list) {\n
/*\n
* Set list of Gadget Index repositories.\n
*/\n
// store in Cache (html5 storage)\n
RenderJs.Cache.set(cache_id, url_list);\n
},\n
\n
getGadgetIndexUrlList: function () {\n
/*\n
* Get list of Gadget Index repositories.\n
*/\n
// get from Cache (html5 storage)\n
return RenderJs.Cache.get(cache_id, undefined);\n
},\n
\n
getGadgetListThatProvide: function (service) {\n
/*\n
* Return list of all gadgets that providen a given service.\n
* Read this list from data structure created in HTML5 local\n
* storage by updateGadgetIndexFromURL\n
*/\n
// get from Cache stored index and itterate over it\n
// to find matching ones\n
var gadget_list = [];\n
$.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),\n
function(index, url) {\n
// get repos from cache\n
var cached_repo = RenderJs.Cache.get(url);\n
$.each(cached_repo.gadget_list,\n
function(index, gadget) {\n
if ($.inArray(service, gadget.service_list) > -1) {\n
// gadget provides a service, add to list\n
gadget_list.push(gadget);\n
}\n
}\n
);\n
});\n
return gadget_list;\n
},\n
\n
registerServiceList: function (gadget, service_list) {\n
/*\n
* Register a service provided by a gadget.\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
init: function (force) {\n
/*\n
* Inspect DOM and initialize this gadget\n
*/\n
var dom_list, gadget_id;\n
if (force===1) {\n
// we explicitly want to re-init elements even if already this is done before\n
dom_list = $("div[data-gadget-connection]");\n
}\n
else {\n
// XXX: improve and save \'bound\' on javascript representation of a gadget not DOM\n
dom_list = $("div[data-gadget-connection]")\n
.filter(function() { return $(this).data("bound") !== true; })\n
.data(\'bound\', true );\n
}\n
dom_list.each(function (index, element) {\n
RenderJs.InteractionGadget.bind($(element));});\n
},\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
var gadget_id, gadget_connection_list,\n
createMethodInteraction = function (\n
createMethodInteraction = function (\n
original_source_method_id, source_gadget_id,\n
original_source_method_id, source_gadget_id,\n
source_method_id, destination_gadget_id,\n
source_method_id, destination_gadget_id,\n
...
@@ -670,15 +834,95 @@ var RenderJs = (function () {\n
...
@@ -670,15 +834,95 @@ var RenderJs = (function () {\n
});\n
});\n
}\n
}\n
};\n
};\n
}()),\n
\n
RouteGadget : (function () {\n
/*\n
* A gadget that defines possible routes (i.e. URL changes) between gadgets.\n
*/\n
var route_list = [];\n
return {\n
\n
init: function () {\n
/*\n
* Inspect DOM and initialize this gadget\n
*/\n
$("div[data-gadget-route]").each(function (index, element) {\n
RenderJs.RouteGadget.route($(element));\n
});\n
},\n
\n
route: function (gadget_dom) {\n
/*\n
* Create routes between gadgets.\n
*/\n
var body = $("body"),\n
handler_func, priority,\n
gadget_route_list = gadget_dom.attr("data-gadget-route");\n
gadget_route_list = $.parseJSON(gadget_route_list);\n
$.each(gadget_route_list, function (key, gadget_route) {\n
handler_func = function () {\n
var gadget_id = gadget_route.destination.split(\'.\')[0],\n
method_id = gadget_route.destination.split(\'.\')[1],\n
gadget = RenderJs.GadgetIndex.getGadgetById(gadget_id);\n
// set gadget value so getSelfGadget can work\n
setSelfGadget(gadget);\n
gadget[method_id].apply(null, arguments);\n
// reset as no longer needed\n
setSelfGadget(undefined);\n
};\n
// add route itself\n
priority = gadget_route.priority;\n
if (priority === undefined) {\n
// default is 1 -i.e.first level\n
priority = 1;\n
}\n
RenderJs.RouteGadget.add(gadget_route.source, handler_func, priority);\n
});\n
},\n
\n
add: function (path, handler_func, priority) {\n
/*\n
* Add a route between path (hashable) and a handler function (part of Gadget\'s API).\n
*/\n
var body = $("body");\n
body\n
.route("add", path, 1)\n
.done(handler_func);\n
// save locally\n
route_list.push({"path": path,\n
"handler_func": handler_func,\n
"priority": priority});\n
},\n
\n
go: function (path, handler_func, priority) {\n
/*\n
* Go a route.\n
*/\n
var body = $("body");\n
body\n
.route("go", path, priority)\n
.fail(handler_func);\n
},\n
\n
remove: function (path) {\n
/*\n
* Remove a route.\n
*/\n
\n
// XXX: implement remove a route when route.js supports it\n
},\n
\n
getRouteList: function () {\n
/*\n
* Get list of all router\n
*/\n
return route_list;\n
}\n
};\n
}())\n
}())\n
};\n
};\n
}());\n
}());
\n
// impliticly call RenderJs bootstrap\n
// $(document).ready(function () {\n
// RenderJs.init();\n
// });\n
]]>
</string>
</value>
]]>
</string>
</value>
</item>
</item>
...
@@ -688,7 +932,7 @@ var RenderJs = (function () {\n
...
@@ -688,7 +932,7 @@ var RenderJs = (function () {\n
</item>
</item>
<item>
<item>
<key>
<string>
size
</string>
</key>
<key>
<string>
size
</string>
</key>
<value>
<int>
26111
</int>
</value>
<value>
<int>
36763
</int>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
title
</string>
</key>
<key>
<string>
title
</string>
</key>
...
...
bt5/erp5_jquery_plugin_renderjs/PathTemplateItem/portal_skins/erp5_jquery/jquery/plugin/renderjs/renderjs.min.js.xml
View file @
1accdd93
...
@@ -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>
ts
58177449.44
</string>
</value>
<value>
<string>
ts
62057392.7
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
__name__
</string>
</key>
<key>
<string>
__name__
</string>
</key>
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
<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 */"use strict";var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING=!0,RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND=!0;if(typeof console=="undefined"||typeof console.log=="undefined")console={},console.log=function(){};var RenderJs=function(){var is_ready=!1;return{init:function(){RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING&&RenderJs.bootstrap($("body"));if(RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND){var a=RenderJs.GadgetIndex.getRootGadget();a!==undefined&&RenderJs.bindReady(function(){$("div[data-gadget-connection]").each(function(a,b){RenderJs.InteractionGadget.bind($(b))})})}},bootstrap:function(a){var b,c;b=a.attr("id"),c=a.attr("data-gadget")!==undefined,RenderJs.setReady(!1),c&&b!==undefined&&RenderJs.loadGadget(a),RenderJs.loadRecursiveGadget(a)},loadRecursiveGadget:function(a){var b,c,d,e;b=a.find("[data-gadget]"),b.each(function(){c=$(this),d=c.attr("id"),e=new RenderJs.Gadget(d,c),RenderJs.GadgetIndex.registerGadget(e)}),b.each(function(){RenderJs.loadGadget($(this))})},setGadgetAndRecurse:function(a,b){a.append(b),RenderJs.loadRecursiveGadget(a)},loadGadget:function(a){var b,c,d,e,f,g,h,i,j;b=a.attr("data-gadget"),c=a.attr("id"),i=RenderJs.GadgetIndex.getGadgetById(c),i===undefined&&(i=new RenderJs.Gadget(c,a),RenderJs.GadgetIndex.registerGadget(i)),d=a.attr("data-gadget-property"),d!==undefined&&(d=$.parseJSON(d),$.each(d,function(a,b){i[a]=b})),b!==undefined&&b!==""?(e=a.attr("data-gadget-cacheable"),f=a.attr("data-gadget-cache-id"),e!==undefined&&f!==undefined&&(e=Boolean(parseInt(e,10))),e?(g=RenderJs.Cache.get(f,undefined),g===undefined||g===null?$.ajax({url:b,yourCustomData:{gadget_id:c,cache_id:f},success:function(b){f=this.yourCustomData.cache_id,c=this.yourCustomData.gadget_id,RenderJs.Cache.set(f,b),RenderJs.GadgetIndex.getGadgetById(c).setReady(),RenderJs.setGadgetAndRecurse(a,b),RenderJs.checkAndTriggerReady(),RenderJs.updateGadgetData(a)}}):(h=g,i.setReady(),this.setGadgetAndRecurse(a,h),this.checkAndTriggerReady(),RenderJs.updateGadgetData(a))):$.ajax({url:b,yourCustomData:{gadget_id:c},success:function(b){c=this.yourCustomData.gadget_id,RenderJs.GadgetIndex.getGadgetById(c).setReady(),RenderJs.setGadgetAndRecurse(a,b),RenderJs.checkAndTriggerReady(),RenderJs.updateGadgetData(a)}})):(j=RenderJs.updateGadgetData(a),j||i.setReady(),RenderJs.checkAndTriggerReady())},isReady:function(){return is_ready},setReady:function(a){is_ready=a},bindReady:function(a){$("body").one("ready",a)},checkAndTriggerReady:function(){var a;return a=RenderJs.GadgetIndex.isGadgetListLoaded(),a&&(RenderJs.isReady()||(RenderJs.GadgetIndex.getRootGadget().getDom().trigger("ready"),$("body").trigger("ready"),RenderJs.setReady(!0))),a},updateGadgetData:function(gadget){var data_source,data_handler;return data_source=gadget.attr("data-gadget-source"),data_handler=gadget.attr("data-gadget-handler"),data_source!==undefined&&data_source!==""?($.ajax({url:data_source,dataType:"json",yourCustomData:{data_handler:data_handler,gadget_id:gadget.attr("id")},success:function(result){var data_handler,gadget_id;data_handler=this.yourCustomData.data_handler,gadget_id=this.yourCustomData.gadget_id,data_handler!==undefined&&(eval(data_handler+"(result)"),gadget=RenderJs.GadgetIndex.getGadgetById(gadget_id),gadget.setReady(),RenderJs.checkAndTriggerReady())}}),!0):!1},addGadget:function(a,b,c,d,e){var f,g,h;return g=$("#"+a),g.empty(),f=[\'<div id="\'+b+\'"\',\'data-gadget="\'+c+\'"\',\'data-gadget-handler="\'+d+\'" \',\'data-gadget-source="\'+e+\'">
</div>
\'].join("\\n"),g.append(f),h=g.find(".gadget"),RenderJs.bootstrap(g),h},Cache:function(){return{ROOT_CACHE_ID:"APP_CACHE",getCacheId:function(a){return this.ROOT_CACHE_ID+a},hasLocalStorage:function(){var a;a="localstorage_test_12345678";try{return localStorage.setItem(a,a),localStorage.removeItem(a),!0}catch(b){return!1}},get:function(a,b){return a=this.getCacheId(a),this.hasLocalStorage()?this.LocalStorageCachePlugin.get(a,b):this.NameSpaceStorageCachePlugin.get(a,b)},set:function(a,b){a=this.getCacheId(a),this.hasLocalStorage()?this.LocalStorageCachePlugin.set(a,b):this.NameSpaceStorageCachePlugin.set(a,b)},LocalStorageCachePlugin:function(){return{get:function(a,b){return a in localStorage?JSON.parse(localStorage.getItem(a)):b},set:function(a,b){localStorage.setItem(a,JSON.stringify(b))}}}(),NameSpaceStorageCachePlugin:function(){var a={};return{get:function(b,c){return a[b]},set:function(b,c){a[b]=c}}}()}}(),Gadget:function(a,b){this.id=a,this.dom=b,this.is_ready=!1,this.getId=function(){return this.id},this.getDom=function(){return this.dom},this.isReady=function(){return this.is_ready},this.setReady=function(){this.is_ready=!0},this.remove=function(){RenderJs.GadgetIndex.unregisterGadget(this),$(this.getDom()).remove()}},TabbularGadget:function(){return{toggleVisibility:function(a){$(".selected").addClass("not_selected"),$(".selected").removeClass("selected"),a.addClass("selected"),a.removeClass("not_selected")},addNewTabGadget:function(a,b,c,d,e){var f;f=RenderJs.addGadget(a,b,c,d,e)}}}(),GadgetIndex:function(){var a=[];return{getGadgetIdListFromDom:function(a){var b=[];return $.each(a.find("[data-gadget]"),function(a,c){b.push($(c).attr("id"))}),b},setGadgetList:function(b){a=b},getGadgetList:function(){return a},registerGadget:function(b){a.push(b)},unregisterGadget:function(b){var c=$.inArray(b,a);c!==-1
&&
a.splice(c,1)},getGadgetById:function(a){var b;return b=undefined,$(RenderJs.GadgetIndex.getGadgetList()).each(function(c,d){d.getId()===a
&&
(b=d)}),b},getRootGadget:function(){return this.getGadgetList()[0]},isGadgetListLoaded:function(){var a;return a=!0,$(this.getGadgetList()).each(function(b,c){c.isReady()===!1
&&
(a=!1)}),a}}}(),InteractionGadget:function(){return{bind:function(a){var b,c,d=function(a,b,c,d,e){var f=function(){RenderJs.GadgetIndex.getGadgetById(b)[a].apply(null,arguments),RenderJs.GadgetIndex.getGadgetById(d).dom.trigger(c)};return f},e=function(a,b){var c=function(){RenderJs.GadgetIndex.getGadgetById(a)[b].apply(null,arguments)};return c};b=a.attr("id"),c=a.attr("data-gadget-connection"),c=$.parseJSON(c),$.each(c,function(a,b){var c,f,g,h,i,j,k,l,m;c=b.source.split("."),f=c[0],g=c[1],h=RenderJs.GadgetIndex.getGadgetById(f),i=b.destination.split("."),j=i[0],k=i[1],l=RenderJs.GadgetIndex.getGadgetById(j),h.hasOwnProperty(g)?(m="original_"+g,h[m]=h[g],h[g]=d(m,f,g,j,k),l.dom.bind(g,e(j,k))):h.dom.bind(g,e(j,k))})
}}}()}}();
"use strict";var RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING=true;var RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND=true;var RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE=true;if(console===undefined||console.log===undefined){var console={};console.log=function(){}}var RenderJs=function(){var is_ready=false,current_gadget;function setSelfGadget(gadget){current_gadget=gadget}return{init:function(){if(RENDERJS_ENABLE_IMPLICIT_GADGET_RENDERING){RenderJs.bootstrap($("body"))}var root_gadget=RenderJs.GadgetIndex.getRootGadget();if(RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND||RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE){if(root_gadget!==undefined){RenderJs.bindReady(function(){if(RENDERJS_ENABLE_IMPLICIT_INTERACTION_BIND){RenderJs.InteractionGadget.init()}if(RENDERJS_ENABLE_IMPLICIT_ROUTE_CREATE){RenderJs.RouteGadget.init()}})}}},bootstrap:function(root){var gadget_id,is_gadget;gadget_id=root.attr("id");is_gadget=root.attr("data-gadget")!==undefined;RenderJs.setReady(false);if(is_gadget&&gadget_id!==undefined){RenderJs.loadGadget(root)}RenderJs.loadRecursiveGadget(root)},loadRecursiveGadget:function(root){var gadget_list,gadget,gadget_id,gadget_js;gadget_list=root.find("[data-gadget]");gadget_list.each(function(){gadget=$(this);gadget_id=gadget.attr("id");gadget_js=new RenderJs.Gadget(gadget_id,gadget);RenderJs.GadgetIndex.registerGadget(gadget_js)});gadget_list.each(function(){RenderJs.loadGadget($(this))})},setGadgetAndRecurse:function(gadget,data){setSelfGadget(RenderJs.GadgetIndex.getGadgetById(gadget.attr("id")));gadget.append(data);setSelfGadget(undefined);RenderJs.loadRecursiveGadget(gadget)},getSelfGadget:function(){return current_gadget},loadGadget:function(gadget){var url,gadget_id,gadget_property,cacheable,cache_id,i,gadget_index,gadget_index_id,app_cache,data,gadget_js,is_update_gadget_data_running;url=gadget.attr("data-gadget");gadget_id=gadget.attr("id");gadget_js=RenderJs.GadgetIndex.getGadgetById(gadget_id);gadget_index=RenderJs.GadgetIndex.getGadgetList();if(gadget_js===undefined){gadget_js=new RenderJs.Gadget(gadget_id,gadget);RenderJs.GadgetIndex.registerGadget(gadget_js)}if(gadget_js.isReady()){return}gadget_property=gadget.attr("data-gadget-property");if(gadget_property!==undefined){gadget_property=$.parseJSON(gadget_property);$.each(gadget_property,function(key,value){gadget_js[key]=value})}if(url!==undefined&&url!==""){cacheable=gadget.attr("data-gadget-cacheable");cache_id=gadget.attr("data-gadget-cache-id");if(cacheable!==undefined&&cache_id!==undefined){cacheable=Boolean(parseInt(cacheable,10))}if(cacheable){app_cache=RenderJs.Cache.get(cache_id,undefined);if(app_cache===undefined||app_cache===null){$.ajax({url:url,yourCustomData:{gadget_id:gadget_id,cache_id:cache_id},success:function(data){cache_id=this.yourCustomData.cache_id;gadget_id=this.yourCustomData.gadget_id;RenderJs.Cache.set(cache_id,data);RenderJs.GadgetIndex.getGadgetById(gadget_id).setReady();RenderJs.setGadgetAndRecurse(gadget,data);RenderJs.checkAndTriggerReady();RenderJs.updateGadgetData(gadget)}})}else{data=app_cache;gadget_js.setReady();this.setGadgetAndRecurse(gadget,data);this.checkAndTriggerReady();RenderJs.updateGadgetData(gadget)}}else{$.ajax({url:url,yourCustomData:{gadget_id:gadget_id},success:function(data){gadget_id=this.yourCustomData.gadget_id;RenderJs.GadgetIndex.getGadgetById(gadget_id).setReady();RenderJs.setGadgetAndRecurse(gadget,data);RenderJs.checkAndTriggerReady();RenderJs.updateGadgetData(gadget)}})}}else{is_update_gadget_data_running=RenderJs.updateGadgetData(gadget);if(!is_update_gadget_data_running){gadget_js.setReady()}RenderJs.checkAndTriggerReady()}},isReady:function(){return is_ready},setReady:function(value){is_ready=value},bindReady:function(ready_function){$("body").one("ready",ready_function)},checkAndTriggerReady:function(){var is_gadget_list_loaded;is_gadget_list_loaded=RenderJs.GadgetIndex.isGadgetListLoaded();if(is_gadget_list_loaded){if(!RenderJs.isReady()){RenderJs.GadgetIndex.getRootGadget().getDom().trigger("ready");$("body").trigger("ready");RenderJs.setReady(true)}}return is_gadget_list_loaded},updateGadgetData:function(gadget){var data_source,data_handler;data_source=gadget.attr("data-gadget-source");data_handler=gadget.attr("data-gadget-handler");if(data_source!==undefined&&data_source!==""){$.ajax({url:data_source,dataType:"json",yourCustomData:{data_handler:data_handler,gadget_id:gadget.attr("id")},success:function(result){var data_handler,gadget_id;data_handler=this.yourCustomData.data_handler;gadget_id=this.yourCustomData.gadget_id;if(data_handler!==undefined){eval(data_handler+"(result)");gadget=RenderJs.GadgetIndex.getGadgetById(gadget_id);gadget.setReady();RenderJs.checkAndTriggerReady()}}});return true}return false},addGadget:function(dom_id,gadget_id,gadget,gadget_data_handler,gadget_data_source){var html_string,tab_container,tab_gadget;tab_container=$("#"+dom_id);tab_container.empty();html_string=[\'<div id="\'+gadget_id+\'"\',\'data-gadget="\'+gadget+\'"\',\'data-gadget-handler="\'+gadget_data_handler+\'" \',\'data-gadget-source="\'+gadget_data_source+\'">
</div>
\'].join("\\n");tab_container.append(html_string);tab_gadget=tab_container.find("#"+gadget_id);RenderJs.bootstrap(tab_container);return tab_gadget},Cache:function(){return{ROOT_CACHE_ID:"APP_CACHE",getCacheId:function(cache_id){return this.ROOT_CACHE_ID+cache_id},hasLocalStorage:function(){var mod;mod="localstorage_test_12345678";try{localStorage.setItem(mod,mod);localStorage.removeItem(mod);return true}catch(e){return false}},get:function(cache_id,default_value){cache_id=this.getCacheId(cache_id);if(this.hasLocalStorage()){return this.LocalStorageCachePlugin.get(cache_id,default_value)}return this.NameSpaceStorageCachePlugin.get(cache_id,default_value)},set:function(cache_id,data){cache_id=this.getCacheId(cache_id);if(this.hasLocalStorage()){this.LocalStorageCachePlugin.set(cache_id,data)}else{this.NameSpaceStorageCachePlugin.set(cache_id,data)}},LocalStorageCachePlugin:function(){return{get:function(cache_id,default_value){if(localStorage.getItem(cache_id)!==null){return JSON.parse(localStorage.getItem(cache_id))}return default_value},set:function(cache_id,data){localStorage.setItem(cache_id,JSON.stringify(data))}}}(),NameSpaceStorageCachePlugin:function(){var namespace={};return{get:function(cache_id,default_value){return namespace[cache_id]},set:function(cache_id,data){namespace[cache_id]=data}}}()}}(),Gadget:function(gadget_id,dom){this.id=gadget_id;this.dom=dom;this.is_ready=false;this.getId=function(){return this.id};this.getDom=function(){return this.dom};this.isReady=function(){return this.is_ready};this.setReady=function(){this.is_ready=true};this.remove=function(){var gadget;RenderJs.GadgetIndex.unregisterGadget(this);this.getDom().find("[data-gadget]").each(function(){gadget=RenderJs.GadgetIndex.getGadgetById($(this).attr("id"));RenderJs.GadgetIndex.unregisterGadget(gadget)});$(this.getDom()).remove()}},TabbularGadget:function(){var gadget_list=[];return{toggleVisibility:function(visible_dom){$(".selected").addClass("not_selected");$(".selected").removeClass("selected");visible_dom.addClass("selected");visible_dom.removeClass("not_selected")},addNewTabGadget:function(dom_id,gadget_id,gadget,gadget_data_handler,gadget_data_source){var tab_gadget;tab_gadget=RenderJs.addGadget(dom_id,gadget_id,gadget,gadget_data_handler,gadget_data_source);$.each(gadget_list,function(index,gadget_id){var gadget=RenderJs.GadgetIndex.getGadgetById(gadget_id);gadget.remove();gadget_list.splice($.inArray(gadget_id,gadget_list),1)});gadget_list.push(tab_gadget.attr("id"))}}}(),GadgetIndex:function(){var gadget_list=[];return{getGadgetIdListFromDom:function(dom){var gadget_id_list=[];$.each(dom.find("[data-gadget]"),function(index,value){gadget_id_list.push($(value).attr("id"))});return gadget_id_list},setGadgetList:function(gadget_list_value){gadget_list=gadget_list_value},getGadgetList:function(){return gadget_list},registerGadget:function(gadget){if(RenderJs.GadgetIndex.getGadgetById(gadget.id)===undefined){gadget_list.push(gadget)}},unregisterGadget:function(gadget){var index=$.inArray(gadget,gadget_list);if(index!==-1){gadget_list.splice(index,1)}},getGadgetById:function(gadget_id){var gadget;gadget=undefined;$(RenderJs.GadgetIndex.getGadgetList()).each(function(index,value){if(value.getId()===gadget_id){gadget=value}});return gadget},getRootGadget:function(){return this.getGadgetList()[0]},isGadgetListLoaded:function(){var result;result=true;$(this.getGadgetList()).each(function(index,value){if(value.isReady()===false){result=false}});return result}}}(),GadgetCatalog:function(){var cache_id="setGadgetIndexUrlList";function updateGadgetIndexFromURL(url){var url_list=url.split("/"),document_url=url_list[url_list.length-1],d=url_list.splice($.inArray(document_url,url_list),1),base_url=url_list.join("/"),web_dav=jIO.newJio({type:"dav",username:"",password:"",url:base_url});web_dav.get(document_url,function(err,response){RenderJs.Cache.set(url,response)})}return{updateGadgetIndex:function(){$.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),function(index,value){updateGadgetIndexFromURL(value)})},setGadgetIndexUrlList:function(url_list){RenderJs.Cache.set(cache_id,url_list)},getGadgetIndexUrlList:function(){return RenderJs.Cache.get(cache_id,undefined)},getGadgetListThatProvide:function(service){var gadget_list=[];$.each(RenderJs.GadgetCatalog.getGadgetIndexUrlList(),function(index,url){var cached_repo=RenderJs.Cache.get(url);$.each(cached_repo.gadget_list,function(index,gadget){if($.inArray(service,gadget.service_list)>-1){gadget_list.push(gadget)}})});return gadget_list},registerServiceList:function(gadget,service_list){}}}(),InteractionGadget:function(){return{init:function(force){var dom_list,gadget_id;if(force===1){dom_list=$("div[data-gadget-connection]")}else{dom_list=$("div[data-gadget-connection]").filter(function(){return $(this).data("bound")!==true}).data("bound",true)}dom_list.each(function(index,element){RenderJs.InteractionGadget.bind($(element))})},bind:function(gadget_dom){var gadget_id,gadget_connection_list,createMethodInteraction=function(original_source_method_id,source_gadget_id,source_method_id,destination_gadget_id,destination_method_id){var interaction=function(){RenderJs.GadgetIndex.getGadgetById(source_gadget_id)[original_source_method_id].apply(null,arguments);RenderJs.GadgetIndex.getGadgetById(destination_gadget_id).dom.trigger(source_method_id)};return interaction},createTriggerInteraction=function(destination_gadget_id,destination_method_id){var interaction=function(){RenderJs.GadgetIndex.getGadgetById(destination_gadget_id)[destination_method_id].apply(null,arguments)};return interaction};gadget_id=gadget_dom.attr("id");gadget_connection_list=gadget_dom.attr("data-gadget-connection");gadget_connection_list=$.parseJSON(gadget_connection_list);$.each(gadget_connection_list,function(key,value){var source,source_gadget_id,source_method_id,source_gadget,destination,destination_gadget_id,destination_method_id,destination_gadget,original_source_method_id;source=value.source.split(".");source_gadget_id=source[0];source_method_id=source[1];source_gadget=RenderJs.GadgetIndex.getGadgetById(source_gadget_id);destination=value.destination.split(".");destination_gadget_id=destination[0];destination_method_id=destination[1];destination_gadget=RenderJs.GadgetIndex.getGadgetById(destination_gadget_id);if(source_gadget.hasOwnProperty(source_method_id)){original_source_method_id="original_"+source_method_id;source_gadget[original_source_method_id]=source_gadget[source_method_id];source_gadget[source_method_id]=createMethodInteraction(original_source_method_id,source_gadget_id,source_method_id,destination_gadget_id,destination_method_id);destination_gadget.dom.bind(source_method_id,createTriggerInteraction(destination_gadget_id,destination_method_id))}else{source_gadget.dom.bind(source_method_id,createTriggerInteraction(destination_gadget_id,destination_method_id))}})}}}(),RouteGadget:function(){var route_list=[];return{init:function(){$("div[data-gadget-route]").each(function(index,element){RenderJs.RouteGadget.route($(element))})},route:function(gadget_dom){var body=$("body"),handler_func,priority,gadget_route_list=gadget_dom.attr("data-gadget-route");gadget_route_list=$.parseJSON(gadget_route_list);$.each(gadget_route_list,function(key,gadget_route){handler_func=function(){var gadget_id=gadget_route.destination.split(".")[0],method_id=gadget_route.destination.split(".")[1],gadget=RenderJs.GadgetIndex.getGadgetById(gadget_id);setSelfGadget(gadget);gadget[method_id].apply(null,arguments);setSelfGadget(undefined)};priority=gadget_route.priority;if(priority===undefined){priority=1}RenderJs.RouteGadget.add(gadget_route.source,handler_func,priority)})},add:function(path,handler_func,priority){var body=$("body");body.route("add",path,1).done(handler_func);route_list.push({path:path,handler_func:handler_func,priority:priority})},go:function(path,handler_func,priority){var body=$("body");body.route("go",path,priority).fail(handler_func)},remove:function(path){},getRouteList:function(){return route_list
}}}()}}();
]]>
</string>
</value>
]]>
</string>
</value>
</item>
</item>
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
size
</string>
</key>
<key>
<string>
size
</string>
</key>
<value>
<int>
6425
</int>
</value>
<value>
<int>
13121
</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 @
1accdd93
22
23
\ 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