Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
e6cfbba9
Commit
e6cfbba9
authored
Aug 23, 2012
by
webchick
Browse files
Issue
#1574490
by frega, nod_: Clean-up: batch.js.
parent
be8126ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/misc/batch.js
View file @
e6cfbba9
(
function
(
$
)
{
(
function
(
$
,
Drupal
)
{
"
use strict
"
;
...
...
@@ -7,31 +7,33 @@
*/
Drupal
.
behaviors
.
batch
=
{
attach
:
function
(
context
,
settings
)
{
$
(
context
).
find
(
'
#progress
'
).
once
(
'
batch
'
,
function
()
{
var
holder
=
$
(
this
);
// Remove HTML from no-js progress bar. The JS progress bar is created
// later on.
holder
.
empty
();
var
batch
=
settings
.
batch
;
var
$progress
=
$
(
'
#progress
'
).
once
(
'
batch
'
);
var
progressBar
;
// Success: redirect to the summary.
var
updateCallback
=
function
(
progress
,
status
,
pb
)
{
if
(
progress
===
'
100
'
)
{
pb
.
stopMonitoring
();
window
.
location
=
settings
.
batch
.
uri
+
'
&op=finished
'
;
}
};
// Success: redirect to the summary.
function
updateCallback
(
progress
,
status
,
pb
)
{
if
(
progress
===
'
100
'
)
{
pb
.
stopMonitoring
();
window
.
location
=
batch
.
uri
+
'
&op=finished
'
;
}
}
var
errorCallback
=
function
(
pb
)
{
holder
.
prepend
(
$
(
'
<p class="error"></p>
'
).
html
(
settings
.
batch
.
errorMessage
));
$
(
'
#wait
'
).
hide
();
};
function
errorCallback
(
pb
)
{
$progress
.
prepend
(
$
(
'
<p class="error"></p>
'
).
html
(
batch
.
errorMessage
));
$
(
'
#wait
'
).
hide
();
}
var
progress
=
new
Drupal
.
ProgressBar
(
'
updateprogress
'
,
updateCallback
,
'
POST
'
,
errorCallback
);
progress
.
setProgress
(
-
1
,
settings
.
batch
.
initMessage
);
holder
.
append
(
progress
.
element
);
progress
.
startMonitoring
(
settings
.
batch
.
uri
+
'
&op=do
'
,
10
);
});
if
(
$progress
.
length
)
{
progressBar
=
new
Drupal
.
ProgressBar
(
'
updateprogress
'
,
updateCallback
,
'
POST
'
,
errorCallback
);
progressBar
.
setProgress
(
-
1
,
batch
.
initMessage
);
progressBar
.
startMonitoring
(
batch
.
uri
+
'
&op=do
'
,
10
);
// Remove HTML from no-js progress bar.
$progress
.
empty
();
// Append the JS progressbar element.
$progress
.
append
(
progressBar
.
element
);
}
}
};
})(
jQuery
);
})(
jQuery
,
Drupal
);
Write
Preview
Supports
Markdown
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