Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SondagesPro-LimeSurvey-plugin
recomputeExpression
Commits
30605fb4
Commit
30605fb4
authored
Apr 24, 2019
by
Denis Chenu
Browse files
[fix] 3.X compatibility
parent
d8a512b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
js/recompute.js
View file @
30605fb4
...
...
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
$
(
function
()
{
$
(
document
).
on
(
'
ready pjax:scriptcomplete
'
,
function
()
{
if
(
typeof
recomputeVar
!=
'
undefined
'
){
addUpdateResponse
();
}
...
...
@@ -31,13 +31,20 @@ function addUpdateResponse()
var
aUrl
=
docUrl
.
split
(
'
/
'
);
var
surveyid
=
recomputeVar
.
surveyId
;
var
responseId
=
recomputeVar
.
responseId
;
console
.
warn
([
surveyid
,
responseId
,
$
(
'
table.detailbrowsetable
'
).
length
]);
if
(
responseId
&&
$
(
'
table.detailbrowsetable
'
).
length
>
0
)
// Browse one response
{
// OR var responseId= aUrl.pop();
$
(
'
.menubar
'
).
eq
(
1
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
append
(
"
<a class='btn btn-small updateanswer' data-responseid='
"
+
responseId
+
"
'><i class='icon-refresh'></i>Update This Answer</a>
"
);
if
(
$
(
'
.menubar
'
).
eq
(
1
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
length
)
{
$
(
'
.menubar
'
).
eq
(
1
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
append
(
"
<a class='btn btn-small updateanswer' data-responseid='
"
+
responseId
+
"
'><i class='icon-refresh'></i>Update This Answer</a>
"
);
}
else
{
$
(
'
#browsermenubarid .container-fluid .text-right
'
).
append
(
"
<a class='btn btn-default btn-small updateanswer' data-responseid='
"
+
responseId
+
"
'><i class='icon-refresh'></i>Update This Answer</a>
"
);
}
$
(
'
.updateanswer
'
).
click
(
function
(){
$
(
"
#updatedsrid
"
).
remove
();
$
.
ajax
({
url
:
jsonUrl
,
...
...
@@ -76,11 +83,15 @@ function addUpdateResponse()
},
});
});
return
;
}
if
(
surveyid
){
$
(
'
.menubar
'
).
eq
(
0
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
append
(
"
<a class='btn btn-small updateanswers'><i class='icon-refresh'></i>Update all submitted answers</a>
"
);
$
(
"
.updateanswers
"
).
click
(
function
(){
var
jsonurl
=
$
(
this
).
attr
(
'
rel
'
);
if
(
$
(
'
.menubar
'
).
eq
(
1
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
length
)
{
$
(
'
.menubar
'
).
eq
(
1
).
find
(
'
.menubar-main
'
).
find
(
"
.menubar-left:last
"
).
append
(
"
<a class='btn btn-small updateanswer' data-recompute='1'><i class='icon-refresh'></i>Update This Answer</a>
"
);
}
else
{
$
(
'
#browsermenubarid .container-fluid .col-md-12
'
).
append
(
"
<a class='btn btn-small updateanswer' data-recompute='1'><i class='icon-refresh'></i>Update all submitted answers</a>
"
);
}
$
(
"
[data-recompute]
"
).
click
(
function
(){
$
(
"
#updatedsrid
"
).
remove
();
var
$dialog
=
$
(
'
<div id="updatedsrid" style="overflow-y:scroll"></div>
'
)
.
html
(
""
)
...
...
recomputeExpression.php
View file @
30605fb4
...
...
@@ -50,8 +50,7 @@ class recomputeExpression extends PluginBase
),
);
protected
$storage
=
'DbStorage'
;
public
function
__construct
(
PluginManager
$manager
,
$id
)
{
parent
::
__construct
(
$manager
,
$id
);
public
function
init
()
{
// Add the script (everywhere)
$this
->
subscribe
(
'afterPluginLoad'
);
//Can call plugin
...
...
@@ -70,7 +69,7 @@ class recomputeExpression extends PluginBase
'responseId'
=>
$responseid
,
);
Yii
::
app
()
->
getClientScript
()
->
registerScript
(
'aRecomputeVar'
,
'recomputeVar='
.
json_encode
(
$aRecomputeVar
),
CClientScript
::
POS_BEGIN
);
Yii
::
app
()
->
getClientScript
()
->
registerScriptFile
(
Yii
::
app
()
->
getConfig
(
'publicurl'
)
.
"plugins/recomputeExpression
/js/recompute.js
"
);
Yii
::
app
()
->
getClientScript
()
->
registerScriptFile
(
Yii
::
app
()
->
assetManager
->
publish
(
dirname
(
__FILE__
)
.
'
/js/recompute.js
'
)
);
}
}
public
function
newDirectRequest
()
...
...
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