Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
722f6154
Commit
722f6154
authored
12 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1684906
by nod_: Drupal.progressBar is a constructor, rename it Drupal.ProgressBar.
parent
deec4d05
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/misc/ajax.js
+1
-1
1 addition, 1 deletion
core/misc/ajax.js
core/misc/batch.js
+1
-1
1 addition, 1 deletion
core/misc/batch.js
core/misc/progress.js
+75
-72
75 additions, 72 deletions
core/misc/progress.js
with
77 additions
and
74 deletions
core/misc/ajax.js
+
1
−
1
View file @
722f6154
...
...
@@ -353,7 +353,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
// Insert progressbar or throbber.
if
(
this
.
progress
.
type
===
'
bar
'
)
{
var
progressBar
=
new
Drupal
.
p
rogressBar
(
'
ajax-progress-
'
+
this
.
element
.
id
,
$
.
noop
,
this
.
progress
.
method
,
$
.
noop
);
var
progressBar
=
new
Drupal
.
P
rogressBar
(
'
ajax-progress-
'
+
this
.
element
.
id
,
$
.
noop
,
this
.
progress
.
method
,
$
.
noop
);
if
(
this
.
progress
.
message
)
{
progressBar
.
setProgress
(
-
1
,
this
.
progress
.
message
);
}
...
...
This diff is collapsed.
Click to expand it.
core/misc/batch.js
+
1
−
1
View file @
722f6154
...
...
@@ -23,7 +23,7 @@ Drupal.behaviors.batch = {
$
(
'
#wait
'
).
hide
();
};
var
progress
=
new
Drupal
.
p
rogressBar
(
'
updateprogress
'
,
updateCallback
,
'
POST
'
,
errorCallback
);
var
progress
=
new
Drupal
.
P
rogressBar
(
'
updateprogress
'
,
updateCallback
,
'
POST
'
,
errorCallback
);
progress
.
setProgress
(
-
1
,
settings
.
batch
.
initMessage
);
holder
.
append
(
progress
.
element
);
progress
.
startMonitoring
(
settings
.
batch
.
uri
+
'
&op=do
'
,
10
);
...
...
This diff is collapsed.
Click to expand it.
core/misc/progress.js
+
75
−
72
View file @
722f6154
...
...
@@ -9,10 +9,10 @@
* method is the function which will perform the HTTP request to get the
* progress bar state. Either "GET" or "POST".
*
* e.g. pb = new
p
rogressBar('myProgressBar');
* e.g. pb = new
Drupal.P
rogressBar('myProgressBar');
* some_element.appendChild(pb.element);
*/
Drupal
.
p
rogressBar
=
function
(
id
,
updateCallback
,
method
,
errorCallback
)
{
Drupal
.
P
rogressBar
=
function
(
id
,
updateCallback
,
method
,
errorCallback
)
{
var
pb
=
this
;
this
.
id
=
id
;
this
.
method
=
method
||
'
GET
'
;
...
...
@@ -27,82 +27,85 @@ Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
'
<div class="message"> </div>
'
);
};
/**
* Set the percentage and status message for the progressbar.
*/
Drupal
.
progressBar
.
prototype
.
setProgress
=
function
(
percentage
,
message
)
{
if
(
percentage
>=
0
&&
percentage
<=
100
)
{
$
(
this
.
element
).
find
(
'
div.filled
'
).
css
(
'
width
'
,
percentage
+
'
%
'
);
$
(
this
.
element
).
find
(
'
div.percentage
'
).
html
(
percentage
+
'
%
'
);
}
$
(
'
div.message
'
,
this
.
element
).
html
(
message
);
if
(
this
.
updateCallback
)
{
this
.
updateCallback
(
percentage
,
message
,
this
);
}
};
$
.
extend
(
Drupal
.
ProgressBar
.
prototype
,
{
/**
* Set the percentage and status message for the progressbar.
*/
setProgress
:
function
(
percentage
,
message
)
{
if
(
percentage
>=
0
&&
percentage
<=
100
)
{
$
(
this
.
element
).
find
(
'
div.filled
'
).
css
(
'
width
'
,
percentage
+
'
%
'
);
$
(
this
.
element
).
find
(
'
div.percentage
'
).
html
(
percentage
+
'
%
'
);
}
$
(
'
div.message
'
,
this
.
element
).
html
(
message
);
if
(
this
.
updateCallback
)
{
this
.
updateCallback
(
percentage
,
message
,
this
);
}
},
/**
* Start monitoring progress via Ajax.
*/
Drupal
.
progressBar
.
prototype
.
startMonitoring
=
function
(
uri
,
delay
)
{
this
.
delay
=
delay
;
this
.
uri
=
uri
;
this
.
sendPing
();
};
/**
* Stop monitoring progress via Ajax.
*/
Drupal
.
progressBar
.
prototype
.
stopMonitoring
=
function
()
{
clearTimeout
(
this
.
timer
);
// This allows monitoring to be stopped from within the callback.
this
.
uri
=
null
;
};
/**
* Start monitoring progress via Ajax.
*/
startMonitoring
:
function
(
uri
,
delay
)
{
this
.
delay
=
delay
;
this
.
uri
=
uri
;
this
.
sendPing
();
},
/**
* Request progress data from server.
*/
Drupal
.
progressBar
.
prototype
.
sendPing
=
function
()
{
if
(
this
.
timer
)
{
/**
* Stop monitoring progress via Ajax.
*/
stopMonitoring
:
function
()
{
clearTimeout
(
this
.
timer
);
}
if
(
this
.
uri
)
{
var
pb
=
this
;
// When doing a post request, you need non-null data. Otherwise a
// HTTP 411 or HTTP 406 (with Apache mod_security) error may result.
$
.
ajax
({
type
:
this
.
method
,
url
:
this
.
uri
,
data
:
''
,
dataType
:
'
json
'
,
success
:
function
(
progress
)
{
// Display errors.
if
(
progress
.
status
===
0
)
{
pb
.
displayError
(
progress
.
data
);
return
;
// This allows monitoring to be stopped from within the callback.
this
.
uri
=
null
;
},
/**
* Request progress data from server.
*/
sendPing
:
function
()
{
if
(
this
.
timer
)
{
clearTimeout
(
this
.
timer
);
}
if
(
this
.
uri
)
{
var
pb
=
this
;
// When doing a post request, you need non-null data. Otherwise a
// HTTP 411 or HTTP 406 (with Apache mod_security) error may result.
$
.
ajax
({
type
:
this
.
method
,
url
:
this
.
uri
,
data
:
''
,
dataType
:
'
json
'
,
success
:
function
(
progress
)
{
// Display errors.
if
(
progress
.
status
===
0
)
{
pb
.
displayError
(
progress
.
data
);
return
;
}
// Update display.
pb
.
setProgress
(
progress
.
percentage
,
progress
.
message
);
// Schedule next timer.
pb
.
timer
=
setTimeout
(
function
()
{
pb
.
sendPing
();
},
pb
.
delay
);
},
error
:
function
(
xmlhttp
)
{
pb
.
displayError
(
Drupal
.
ajaxError
(
xmlhttp
,
pb
.
uri
));
}
// Update display.
pb
.
setProgress
(
progress
.
percentage
,
progress
.
message
);
// Schedule next timer.
pb
.
timer
=
setTimeout
(
function
()
{
pb
.
sendPing
();
},
pb
.
delay
);
},
error
:
function
(
xmlhttp
)
{
pb
.
displayError
(
Drupal
.
ajaxError
(
xmlhttp
,
pb
.
uri
));
}
});
}
};
});
}
},
/**
* Display errors on the page.
*/
Drupal
.
progressBar
.
prototype
.
displayError
=
function
(
string
)
{
var
error
=
$
(
'
<div class="messages error"></div>
'
).
html
(
string
);
$
(
this
.
element
).
before
(
error
).
hide
();
/**
* Display errors on the page.
*/
displayError
:
function
(
string
)
{
var
error
=
$
(
'
<div class="messages error"></div>
'
).
html
(
string
);
$
(
this
.
element
).
before
(
error
).
hide
();
if
(
this
.
errorCallback
)
{
this
.
errorCallback
(
this
);
if
(
this
.
errorCallback
)
{
this
.
errorCallback
(
this
);
}
}
};
});
})(
jQuery
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment