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
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
Paul Graydon
erp5
Commits
db585eae
Commit
db585eae
authored
May 10, 2012
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixscript to be more jslint compliant (and random usage of global variable).
parent
acd28780
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
116 deletions
+141
-116
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
+140
-115
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 @
db585eae
...
@@ -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>
ts36
567155.8
</string>
</value>
<value>
<string>
ts36
652259.54
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
__name__
</string>
</key>
<key>
<string>
__name__
</string>
</key>
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
<key>
<string>
data
</string>
</key>
<key>
<string>
data
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<value>
<string
encoding=
"cdata"
>
<![CDATA[
var DEFAULT_GADGET_DOM_READY_TIMEOUT;\n
DEFAULT_GADGET_DOM_READY_TIMEOUT = 1000;\n
DEFAULT_GADGET_DOM_READY_TIMEOUT = 1000;\n
\n
\n
/*\n
/*\n
...
@@ -38,21 +39,19 @@ var NameSpaceStorageCachePlugin = {\n
...
@@ -38,21 +39,19 @@ var NameSpaceStorageCachePlugin = {\n
* This plugin saves within current page namespace.\n
* This plugin saves within current page namespace.\n
*/\n
*/\n
\n
\n
_
namespace: {},\n
namespace: {},\n
\n
\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
//console.log(\'get namespace\');\n
return NameSpaceStorageCachePlugin.namespace[cache_id];\n
return NameSpaceStorageCachePlugin._namespace[cache_id];\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
//console.log(\'get namespace\');\n
NameSpaceStorageCachePlugin.namespace[cache_id] = data;\n
NameSpaceStorageCachePlugin._namespace[cache_id] = data;\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
\n
\n
var LocalStorageCachePlugin = {\n
var LocalStorageCachePlugin = {\n
...
@@ -60,55 +59,57 @@ var LocalStorageCachePlugin = {\n
...
@@ -60,55 +59,57 @@ var LocalStorageCachePlugin = {\n
* This plugin saves using HTML5 localStorage.\n
* This plugin saves using HTML5 localStorage.\n
*/\n
*/\n
\n
\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
//console.log(\'get local\');\n
return $.jStorage.get(cache_id, default_value);\n
return $.jStorage.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
//console.log(\'set local\');\n
$.jStorage.set(cache_id, data);\n
$.jStorage.set(cache_id, data)\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
var Cache = {\n
var Cache = {\n
\n
\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
/* We should have a way to \'purge\' localStorage by setting a ROOT_CACHE_ID in all browser\n
* instances\n
* instances\n
*/\n
*/\n
return Cache.ROOT_CACHE_ID + cache_id; \n
return Cache.ROOT_CACHE_ID + cache_id;\n
\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
mod = \'localstorage_test_12345678\';\n
var mod;\n
try {\n
mod = \'localstorage_test_12345678\';\n
try {\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
catch(e) {\n
}\n
return false;}\n
catch (e) {\n
},\n
return false;\n
}\n
},\n
\n
\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
cache_id = Cache.getCacheId(cache_id);\n
cache_id = Cache.getCacheId(cache_id);\n
if (Cache.hasLocalStorage()){\n
if (Cache.hasLocalStorage()) {\n
return LocalStorageCachePlugin.get(cache_id, default_value);}\n
return LocalStorageCachePlugin.get(cache_id, default_value);\n
else{\n
}\n
return NameSpaceStorageCachePlugin.get(cache_id, default_value);}\n
else {\n
return NameSpaceStorageCachePlugin.get(cache_id, 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
cache_id = Cache.getCacheId(cache_id);\n
cache_id = Cache.getCacheId(cache_id);\n
if (Cache.hasLocalStorage()){\n
if (Cache.hasLocalStorage()){\n
...
@@ -117,14 +118,14 @@ var Cache = {\n
...
@@ -117,14 +118,14 @@ var Cache = {\n
NameSpaceStorageCachePlugin.set(cache_id, data);}\n
NameSpaceStorageCachePlugin.set(cache_id, data);}\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
/*\n
/*\n
* Generic tabular gadget\n
* Generic tabular gadget\n
*/\n
*/\n
var TabbularGadget = {\n
var TabbularGadget = {\n
\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
...
@@ -133,8 +134,9 @@ var TabbularGadget = {\n
...
@@ -133,8 +134,9 @@ var TabbularGadget = {\n
visible_dom.removeClass("not_selected");\n
visible_dom.removeClass("not_selected");\n
},\n
},\n
\n
\n
addNewTabGadget: function(form_id, dom_id, gadget_data_handler){\n
addNewTabGadget: function(form_id, dom_id, gadget_data_handler)
{\n
// add new gadget and render it\n
// add new gadget and render it\n
var html_string;\n
tab_container=$(\'#\'+dom_id);\n
tab_container=$(\'#\'+dom_id);\n
tab_container.empty();\n
tab_container.empty();\n
// XXX: allow add any gadget,gadget:source items within API\n
// XXX: allow add any gadget,gadget:source items within API\n
...
@@ -154,7 +156,7 @@ var TabbularGadget = {\n
...
@@ -154,7 +156,7 @@ var TabbularGadget = {\n
window.setTimeout("RenderJs.updateGadgetData(tab_gadget)", DEFAULT_GADGET_DOM_READY_TIMEOUT);\n
window.setTimeout("RenderJs.updateGadgetData(tab_gadget)", DEFAULT_GADGET_DOM_READY_TIMEOUT);\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
/*\n
/*\n
Form field renderer\n
Form field renderer\n
...
@@ -166,163 +168,172 @@ var Form = {\n
...
@@ -166,163 +168,172 @@ var Form = {\n
\n
\n
CURRENT_FORM_ID: "",\n
CURRENT_FORM_ID: "",\n
\n
\n
getCurrentFormId: function (){\n
getCurrentFormId: function ()
{\n
/* Get current form ID (return hard coded one for now) */\n
/* Get current form ID (return hard coded one for now) */\n
return Form.CURRENT_FORM_ID;\n
return Form.CURRENT_FORM_ID;\n
},\n
},\n
\n
\n
setCurrentFormId: function (form_id){\n
setCurrentFormId: function (form_id)
{\n
/* Set current form ID (return hard coded one for now) */\n
/* Set current form ID (return hard coded one for now) */\n
Form.CURRENT_FORM_ID = form_id;\n
Form.CURRENT_FORM_ID = form_id;\n
},\n
},\n
\n
\n
\n
\n
getFieldId: function(field_id){\n
getFieldId: function(field_id)
{\n
/* Generate local form field id */\n
/* Generate local form field id */\n
return "field_" + field_id;\n
return "field_" + field_id;\n
},\n
},\n
\n
\n
updateField: function (dom, field_dict){\n
updateField: function (dom, field_dict)
{\n
/* General purpose field updater */\n
/* General purpose field updater */\n
editable = Boolean(field_dict[\'editable\']);\n
var editable;\n
editable = Boolean(field_dict.editable);\n
if (editable){\n
if (editable){\n
dom.val(field_dict
["value"]
);}\n
dom.val(field_dict
.value
);}\n
else{\n
else{\n
// if field is not editable just show its value\n
// if field is not editable just show its value\n
dom.replaceWith(field_dict
["value"]
);\n
dom.replaceWith(field_dict
.value
);\n
}\n
}\n
},\n
},\n
\n
\n
addOptionTagList: function (index, value){\n
addOptionTagList: function (index, value)
{\n
if(value[1]==field_value){\n
if(value[1]==
=
field_value){\n
select_dom.append(\'
<option
selected
value=
"\' + value[1] + \'"
>
\' + value[0] + \'
</option>
\');}\n
select_dom.append(\'
<option
selected
value=
"\' + value[1] + \'"
>
\' + value[0] + \'
</option>
\');}\n
else{\n
else{\n
select_dom.append(\'
<option
value=
"\' + value[1] + \'"
>
\' + value[0] + \'
</option>
\'); }\n
select_dom.append(\'
<option
value=
"\' + value[1] + \'"
>
\' + value[0] + \'
</option>
\'); }\n
},\n
},\n
\n
\n
BaseInputField: function (field_id, field_dict){\n
BaseInputField: function (field_id, field_dict)
{\n
/* HTML based input field */\n
/* HTML based input field */\n
var dom, display_width;\n
dom = $("[name=" + Form.getFieldId(field_id) + "]");\n
dom = $("[name=" + Form.getFieldId(field_id) + "]");\n
Form.updateField(dom, field_dict);\n
Form.updateField(dom, field_dict);\n
display_width = field_dict
["display_width"]
;\n
display_width = field_dict
.display_width
;\n
if (display_width){\n
if (display_width){\n
dom.attr("size", display_width);}\n
dom.attr("size", display_width);}\n
return dom;\n
return dom;\n
},\n
},\n
EditorField: function (field_id, field_dict){\n
\n
EditorField: function (field_id, field_dict) {\n
/* HTML based input field */\n
/* HTML based input field */\n
dom = $("#" + Form.getFieldId(field_id));\n
dom = $("#" + Form.getFieldId(field_id));\n
Form.updateField(dom, field_dict);\n
Form.updateField(dom, field_dict);\n
return dom;\n
return dom;\n
},\n
},\n
\n
\n
ListField: function (field_id, field_dict){\n
ListField: function (field_id, field_dict)
{\n
/* Select field */\n
/* Select field */\n
field_value = field_dict["value"]\n
//var field_value; // uncommenting makes a local variable and affects other parts of code!!!\n
field_value = field_dict.value;\n
select_dom = $("select[name=" + Form.getFieldId(field_id) + "]");\n
select_dom = $("select[name=" + Form.getFieldId(field_id) + "]");\n
$.each(field_dict
["items"]
, Form.addOptionTagList);\n
$.each(field_dict
.items
, Form.addOptionTagList);\n
return select_dom; \n
return select_dom; \n
},\n
},\n
\n
\n
ParallelListField: function (field_id, field_dict){\n
ParallelListField: function (field_id, field_dict)
{\n
/* mutiple select fields */\n
/* mutiple select fields */\n
// XXX: we render only first value but it can be many how to get them ?\n
// XXX: we render only first value but it can be many how to get them ?\n
field_value = field_dict
["value"][0]
\n
field_value = field_dict
.value[0];
\n
select_dom = $("select[name=subfield_field_" + field_id + "]");\n
select_dom = $("select[name=subfield_field_" + field_id + "]");\n
$.each(field_dict
["items"]
, Form.addOptionTagList);\n
$.each(field_dict
.items
, Form.addOptionTagList);\n
return select_dom;\n
return select_dom;\n
},\n
},\n
\n
\n
CheckBoxField: function (field_id, field_dict){\n
CheckBoxField: function (field_id, field_dict)
{\n
/* CheckBoxField field */\n
/* CheckBoxField field */\n
checked = Boolean(field_dict["value"])\n
var checked, checkbox_dom;\n
checked = Boolean(field_dict.value);\n
checkbox_dom = $("input[name=" + Form.getFieldId(field_id) + "]");\n
checkbox_dom = $("input[name=" + Form.getFieldId(field_id) + "]");\n
if (checked){\n
if (checked) {\n
checkbox_dom.attr(\'checked\', true)}\n
checkbox_dom.attr(\'checked\', true);\n
}\n
return checkbox_dom;\n
return checkbox_dom;\n
},\n
},\n
\n
\n
TextAreaField: function (field_id, field_dict){\n
TextAreaField: function (field_id, field_dict)
{\n
/* TextArea field */\n
/* TextArea field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
StringField: function (field_id, field_dict){\n
StringField: function (field_id, field_dict)
{\n
/* String field */\n
/* String field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
IntegerField: function (field_id, field_dict){\n
IntegerField: function (field_id, field_dict)
{\n
/* Int field */\n
/* Int field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
PasswordField: function (field_id, field_dict){\n
PasswordField: function (field_id, field_dict)
{\n
/* PasswordField field */\n
/* PasswordField field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
DateTimeField: function (field_id, field_dict){\n
DateTimeField: function (field_id, field_dict)
{\n
/* DateTimeField field */\n
/* DateTimeField field */\n
var date;\n
dom = $("[name=" + Form.getFieldId(field_id) + "]");\n
dom = $("[name=" + Form.getFieldId(field_id) + "]");\n
date = field_dict
["value"]
;\n
date = field_dict
.value
;\n
date = new Date(date);\n
date = new Date(date);\n
dom.datepicker({ dateFormat: \'dd/mm/yy\' }); // XXX: get format from server!\n
dom.datepicker({ dateFormat: \'dd/mm/yy\' }); // XXX: get format from server!\n
dom.datepicker(\'setDate\', date);\n
dom.datepicker(\'setDate\', date);\n
return dom;\n
return dom;\n
},\n
},\n
\n
\n
EmailField: function (field_id, field_dict){\n
EmailField: function (field_id, field_dict)
{\n
/* Email field */\n
/* Email field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
FormBox: function (field_id, field_dict){\n
FormBox: function (field_id, field_dict)
{\n
/* Email field */\n
/* Email field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
RelationStringField: function (field_id, field_dict){\n
RelationStringField: function (field_id, field_dict)
{\n
/* Relation field */\n
/* Relation field */\n
return Form.BaseInputField(field_id, field_dict);\n
return Form.BaseInputField(field_id, field_dict);\n
},\n
},\n
\n
\n
ImageField: function (field_id, field_dict){\n
ImageField: function (field_id, field_dict)
{\n
/* Image field */\n
/* Image field */\n
var dom;\n
dom = $("img[name=" + Form.getFieldId(field_id) + "]");\n
dom = $("img[name=" + Form.getFieldId(field_id) + "]");\n
// XXX: image field should return details like quality, etc ...\n
// XXX: image field should return details like quality, etc ...\n
dom.attr("src", field_dict
["value"]
+ "?quality=75.0
&display=thumbnail&format=png");
\n
dom.attr("src", field_dict
.value
+ "?quality=75.0
&display=thumbnail&format=png");
\n
},\n
},\n
\n
\n
ListBox: function (field_id, field_dict){\n
ListBox: function (field_id, field_dict)
{\n
/* Listbox field */\n
/* Listbox field */\n
var listbox_id, navigation_id, listbox_table, current_form_id, listbox_dict, listbox_data_url, colModel, column_title_list;\n
listbox_id = "field_" + field_id;\n
listbox_id = "field_" + field_id;\n
navigation_id = listbox_id + "_pager"; \n
navigation_id = listbox_id + "_pager"; \n
listbox_table =
jQuery
("#"+listbox_id);\n
listbox_table =
$
("#"+listbox_id);\n
current_form_id = Form.getCurrentFormId();\n
current_form_id = Form.getCurrentFormId();\n
\n
\n
listbox_dict = field_dict
[\'listbox\']
\n
listbox_dict = field_dict
.listbox;
\n
listbox_data_url = listbox_dict
["listbox_data_url"]
\n
listbox_data_url = listbox_dict
.listbox_data_url;
\n
colModel = []\n
colModel = []
;
\n
column_title_list = [];\n
column_title_list = [];\n
$.each(listbox_dict
[\'columns\']
,\n
$.each(listbox_dict
.columns
,\n
function(i, value){\n
function(i, value){\n
var index, title, column;\n
index = value[0];\n
index = value[0];\n
title = value[1];\n
title = value[1];\n
column_title_list.push(title);\n
column_title_list.push(title);\n
column = {\'name\': index,\n
column = {\'name\': index,\n
\'index\': index,\n
\'index\': index,\n
\'width\': 185,\n
\'width\': 185,\n
\'align\': \'left\'\n
\'align\': \'left\'};\n
}\n
colModel.push(column);\n
colModel.push(column);\n
});\n
});\n
\n
\n
listbox_table.jqGrid(
{url:listbox_data_url + \'?form_id=\' + current_form_id + \'
&s;
listbox_id=\' + field_id,\n
listbox_table.jqGrid({url:listbox_data_url + \'?form_id=\' + current_form_id + \'
&s;
listbox_id=\' + field_id,\n
datatype: "json",\n
datatype: "json",\n
colNames: column_title_list,\n
colNames: column_title_list,\n
colModel: colModel,\n
colModel: colModel,\n
rowNum:
listbox_dict[\'lines\']
,\n
rowNum:
listbox_dict.lines
,\n
pager: \'#\'+navigation_id,\n
pager: \'#\'+navigation_id,\n
sortname: \'id\',\n
sortname: \'id\',\n
viewrecords: true,\n
viewrecords: true,\n
...
@@ -332,22 +343,23 @@ var Form = {\n
...
@@ -332,22 +343,23 @@ var Form = {\n
alert("Error occurred during getting data from server.");\n
alert("Error occurred during getting data from server.");\n
},\n
},\n
cmTemplate: {sortable:false}, // XXX: until we get list of sortable columns from server\n
cmTemplate: {sortable:false}, // XXX: until we get list of sortable columns from server\n
caption: field_dict
["title"]
});\n
caption: field_dict
.title
});\n
listbox_table.jqGrid(\'navGrid\', \'#\'+navigation_id, {edit:false,add:false,del:false});\n
listbox_table.jqGrid(\'navGrid\', \'#\'+navigation_id, {edit:false,add:false,del:false});\n
return listbox_table;\n
return listbox_table;\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
/* Generic form updater */\n
/* Generic form updater */\n
var FormUpdater = {\n
var FormUpdater = {\n
\n
\n
\n
\n
update: function(data){\n
update: function(data)
{\n
/* Update form values */\n
/* Update form values */\n
$.each(data
[\'form_data\']
,\n
$.each(data
.form_data
,\n
function(field_id, field_dict){\n
function(field_id, field_dict){\n
type = field_dict["type"];\n
var type, dom;\n
type = field_dict.type;\n
dom = undefined;\n
dom = undefined;\n
if(Form.hasOwnProperty(type)){\n
if(Form.hasOwnProperty(type)){\n
dom = Form[type](field_id, field_dict);\n
dom = Form[type](field_id, field_dict);\n
...
@@ -355,12 +367,12 @@ var FormUpdater = {\n
...
@@ -355,12 +367,12 @@ var FormUpdater = {\n
\n
\n
// add a class that these fields are editable so asJSON\n
// add a class that these fields are editable so asJSON\n
// can serialize for for sending to server\n
// can serialize for for sending to server\n
if (dom!=
undefined
&&
dom!=null
&&
field_dict["editable"]
){\n
if (dom!=
=undefined
&&
dom!==null
&&
field_dict.editable
){\n
dom.addClass(Form.SERIALIZE_ABLE_CLASS_NAME);\n
dom.addClass(Form.SERIALIZE_ABLE_CLASS_NAME);\n
}\n
}\n
\n
\n
// mark required fields visually\n
// mark required fields visually\n
if (field_dict
["required"]
){\n
if (field_dict
.required
){\n
dom.parent().parent().children("label").css("font-weight", "bold");}\n
dom.parent().parent().children("label").css("font-weight", "bold");}\n
\n
\n
});\n
});\n
...
@@ -368,18 +380,23 @@ var FormUpdater = {\n
...
@@ -368,18 +380,23 @@ var FormUpdater = {\n
\n
\n
save: function(){\n
save: function(){\n
/* save form to server*/\n
/* save form to server*/\n
form_value_dict = {}\n
var form_value_dict, converted_value;\n
form_value_dict = {};\n
$("." + Form.SERIALIZE_ABLE_CLASS_NAME).each(function(index){\n
$("." + Form.SERIALIZE_ABLE_CLASS_NAME).each(function(index){\n
// DOM can change values, i.e. alter checkbox (on / off)\n
// DOM can change values, i.e. alter checkbox (on / off)\n
var element,name, value, type; \n
element = $(this); \n
element = $(this); \n
name = element.attr("name");\n
name = element.attr("name");\n
value = element.val();\n
value = element.val();\n
type = element.attr("type");\n
type = element.attr("type");\n
if (type==
"checkbox")
{\n
if (type==
="checkbox")
{\n
value = element.is(":checked");\n
value = element.is(":checked");\n
if(value==true){converted_value=1;}\n
if (value===true) {\n
if(value==false){converted_value=0;}\n
converted_value=1;\n
//value = {true:1, false:0}[value];\n
}\n
if(value===false) {\n
converted_value=0;\n
}\n
value = converted_value; \n
value = converted_value; \n
}\n
}\n
// XXX: how to handle file uploads ?\n
// XXX: how to handle file uploads ?\n
...
@@ -388,17 +405,19 @@ var FormUpdater = {\n
...
@@ -388,17 +405,19 @@ var FormUpdater = {\n
//console.log(form_value_dict);\n
//console.log(form_value_dict);\n
\n
\n
// add form_id as we need to know structure we\'re saving at server side\n
// add form_id as we need to know structure we\'re saving at server side\n
form_value_dict
["form_id"]
= Form.getCurrentFormId();\n
form_value_dict
.form_id
= Form.getCurrentFormId();\n
\n
\n
// validation happens at server side\n
// validation happens at server side\n
$.ajax({url:\'Form_save\',\n
$.ajax({url:\'Form_save\',\n
data: form_value_dict,\n
data: form_value_dict,\n
dataType: "json",\n
dataType: "json",\n
success: function (data) {\n
success: function (data) {\n
var field_errors;\n
field_errors = data.field_errors;\n
field_errors = data.field_errors;\n
if (field_errors!=undefined){\n
if (field_errors!=
=
undefined){\n
//console.log(field_errors);\n
//console.log(field_errors);\n
$.each(field_errors, function(index, value){\n
$.each(field_errors, function(index, value){\n
var dom, field;\n
dom = $("[name=" + Form.getFieldId(index) + "]");\n
dom = $("[name=" + Form.getFieldId(index) + "]");\n
dom.css("border", "1px solid red"); // XXX: use class / css\n
dom.css("border", "1px solid red"); // XXX: use class / css\n
field = dom.parent().parent();\n
field = dom.parent().parent();\n
...
@@ -414,6 +433,7 @@ var FormUpdater = {\n
...
@@ -414,6 +433,7 @@ var FormUpdater = {\n
// validation OK at server side\n
// validation OK at server side\n
$("span.error").each(function(index) {\n
$("span.error").each(function(index) {\n
// delete validation messages\n
// delete validation messages\n
var element;\n
element = $(this);\n
element = $(this);\n
element.parent().children("div.input").children("." +Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.parent().children("div.input").children("." +Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.remove();\n
element.remove();\n
...
@@ -425,16 +445,16 @@ var FormUpdater = {\n
...
@@ -425,16 +445,16 @@ var FormUpdater = {\n
}\n
}\n
}});\n
}});\n
}\n
}\n
}\n
}
;
\n
\n
\n
/*\n
/*\n
* Javascript Gadget representation\n
* Javascript Gadget representation\n
*/\n
*/\n
\n
\n
function Gadget(id, dom){\n
function Gadget(id, dom)
{\n
this.id = id;\n
this.id = id;\n
this.dom = dom;\n
this.dom = dom;\n
}
;
\n
}\n
\n
\n
/*\n
/*\n
* Generic gadget index placeholder\n
* Generic gadget index placeholder\n
...
@@ -457,17 +477,17 @@ var GadgetIndex = {\n
...
@@ -457,17 +477,17 @@ var GadgetIndex = {\n
/*\n
/*\n
* Get gadget javascript representation by its Id\n
* Get gadget javascript representation by its Id\n
*/\n
*/\n
var gadget;\n
gadget = undefined;\n
gadget = undefined;\n
$(GadgetIndex.gadget_list).each(\n
$(GadgetIndex.gadget_list).each(\n
function (index, value){\n
function (index, value)
{\n
if (value.id==
gadget_id)
{\n
if (value.id==
=gadget_id)
{\n
gadget = value;\n
gadget = value;\n
};\n
}});\n
})\n
return gadget;\n
return gadget;\n
}\n
}\n
\n
\n
}\n
}
;
\n
\n
\n
/*\n
/*\n
* Generic Gadget library renderer\n
* Generic Gadget library renderer\n
...
@@ -484,6 +504,7 @@ var RenderJs = {\n
...
@@ -484,6 +504,7 @@ var RenderJs = {\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
gadget_list = root.find("[gadget]");\n
gadget_list = root.find("[gadget]");\n
// Load chilren\n
// Load chilren\n
gadget_list.each(function(i,v){RenderJs.loadGadgetFromUrl($(this));});\n
gadget_list.each(function(i,v){RenderJs.loadGadgetFromUrl($(this));});\n
...
@@ -498,6 +519,7 @@ var RenderJs = {\n
...
@@ -498,6 +519,7 @@ var RenderJs = {\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;\n
url = gadget.attr("gadget");\n
url = gadget.attr("gadget");\n
gadget_id = gadget.attr("id");\n
gadget_id = gadget.attr("id");\n
\n
\n
...
@@ -506,7 +528,7 @@ var RenderJs = {\n
...
@@ -506,7 +528,7 @@ var RenderJs = {\n
\n
\n
// register gadgdet in javascript namespace\n
// register gadgdet in javascript namespace\n
GadgetIndex.registerGadget(new Gadget(gadget_id, gadget));\n
GadgetIndex.registerGadget(new Gadget(gadget_id, gadget));\n
if (url==
undefined || url
==""){\n
if (url==
=undefined || url=
==""){\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
return;\n
return;\n
}\n
}\n
...
@@ -515,16 +537,16 @@ var RenderJs = {\n
...
@@ -515,16 +537,16 @@ var RenderJs = {\n
gadget_property = gadget.attr("gadget:property");\n
gadget_property = gadget.attr("gadget:property");\n
\n
\n
cacheable = false;\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
cacheable = Boolean(gadget_property.cacheable);\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 cache_key\n
cache_id = gadget_property.cache_id\n
cache_id = gadget_property.cache_id
;
\n
app_cache = Cache.get(cache_id, undefined);\n
app_cache = Cache.get(cache_id, undefined);\n
\n
if(app_cache===undefined || app_cache===null){\n
if(app_cache==undefined){\n
// not in cache so we pull from network and cache\n
// not in cache so we pull from network and cache\n
//console.log("not in cache: " + cache_id + " " + url);\n
//console.log("not in cache: " + cache_id + " " + url);\n
$.ajax({url:url,\n
$.ajax({url:url,\n
...
@@ -558,13 +580,14 @@ var RenderJs = {\n
...
@@ -558,13 +580,14 @@ var RenderJs = {\n
\n
\n
traverse: function (method_name){\n
traverse: function (method_name){\n
// not working with ie7\n
// not working with ie7\n
var method, parent;\n
method = undefined;\n
method = undefined;\n
parent = window;\n
parent = window;\n
$.each(method_name.split(\'.\'),\n
$.each(method_name.split(\'.\'),\n
function(index,value){\n
function(index,value){\n
method = parent[value];\n
method = parent[value];\n
//console.log(value + obj);\n
//console.log(value + obj);\n
if (method!=undefined){\n
if (method!=
=
undefined){\n
parent=method;}\n
parent=method;}\n
else{\n
else{\n
return undefined;}});\n
return undefined;}});\n
...
@@ -572,25 +595,27 @@ var RenderJs = {\n
...
@@ -572,25 +595,27 @@ var RenderJs = {\n
},\n
},\n
\n
\n
updateGadgetWithDataHandler: function (result) {\n
updateGadgetWithDataHandler: function (result) {\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
data_source = gadget.attr("gadget:data-source");\n
data_source = gadget.attr("gadget:data-source");\n
data_handler = gadget.attr("gadget:data-handler");\n
data_handler = gadget.attr("gadget:data-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){\n
$.ajax({url:data_source,\n
$.ajax({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
]]>
</string>
</value>
]]>
</string>
</value>
...
@@ -601,7 +626,7 @@ var RenderJs = {\n
...
@@ -601,7 +626,7 @@ var RenderJs = {\n
</item>
</item>
<item>
<item>
<key>
<string>
size
</string>
</key>
<key>
<string>
size
</string>
</key>
<value>
<int>
2
027
7
</int>
</value>
<value>
<int>
2
122
7
</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 @
db585eae
6
7
\ 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