Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cathsm-server-bc2conf2021
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bienchen
cathsm-server-bc2conf2021
Commits
67a2fd65
Commit
67a2fd65
authored
5 years ago
by
Ian Sillitoe
Browse files
Options
Downloads
Patches
Plain Diff
whitespace
parent
4fb57a3b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/admin/js/actions.js
+59
-59
59 additions, 59 deletions
static/admin/js/actions.js
with
59 additions
and
59 deletions
static/admin/js/actions.js
+
59
−
59
View file @
67a2fd65
/*global gettext, interpolate, ngettext*/
(
function
(
$
)
{
(
function
(
$
)
{
'
use strict
'
;
var
lastChecked
;
$
.
fn
.
actions
=
function
(
opts
)
{
$
.
fn
.
actions
=
function
(
opts
)
{
var
options
=
$
.
extend
({},
$
.
fn
.
actions
.
defaults
,
opts
);
var
actionCheckboxes
=
$
(
this
);
var
list_editable_changed
=
false
;
var
showQuestion
=
function
()
{
var
showQuestion
=
function
()
{
$
(
options
.
acrossClears
).
hide
();
$
(
options
.
acrossQuestions
).
show
();
$
(
options
.
allContainer
).
hide
();
},
showClear
=
function
()
{
$
(
options
.
acrossClears
).
show
();
$
(
options
.
acrossQuestions
).
hide
();
$
(
options
.
actionContainer
).
toggleClass
(
options
.
selectedClass
);
$
(
options
.
allContainer
).
show
();
$
(
options
.
counterContainer
).
hide
();
},
reset
=
function
()
{
$
(
options
.
acrossClears
).
hide
();
$
(
options
.
acrossQuestions
).
hide
();
$
(
options
.
allContainer
).
hide
();
$
(
options
.
counterContainer
).
show
();
},
clearAcross
=
function
()
{
reset
();
$
(
options
.
acrossInput
).
val
(
0
);
$
(
options
.
actionContainer
).
removeClass
(
options
.
selectedClass
);
},
checker
=
function
(
checked
)
{
if
(
checked
)
{
showQuestion
();
}
else
{
showClear
=
function
()
{
$
(
options
.
acrossClears
).
show
();
$
(
options
.
acrossQuestions
).
hide
();
$
(
options
.
actionContainer
).
toggleClass
(
options
.
selectedClass
);
$
(
options
.
allContainer
).
show
();
$
(
options
.
counterContainer
).
hide
();
},
reset
=
function
()
{
$
(
options
.
acrossClears
).
hide
();
$
(
options
.
acrossQuestions
).
hide
();
$
(
options
.
allContainer
).
hide
();
$
(
options
.
counterContainer
).
show
();
},
clearAcross
=
function
()
{
reset
();
}
$
(
actionCheckboxes
).
prop
(
"
checked
"
,
checked
)
.
parent
().
parent
().
toggleClass
(
options
.
selectedClass
,
checked
);
},
updateCounter
=
function
()
{
var
sel
=
$
(
actionCheckboxes
).
filter
(
"
:checked
"
).
length
;
// data-actions-icnt is defined in the generated HTML
// and contains the total amount of objects in the queryset
var
actions_icnt
=
$
(
'
.action-counter
'
).
data
(
'
actionsIcnt
'
);
$
(
options
.
counterContainer
).
html
(
interpolate
(
ngettext
(
'
%(sel)s of %(cnt)s selected
'
,
'
%(sel)s of %(cnt)s selected
'
,
sel
),
{
sel
:
sel
,
cnt
:
actions_icnt
},
true
));
$
(
options
.
allToggle
).
prop
(
"
checked
"
,
function
()
{
var
value
;
if
(
sel
===
actionCheckboxes
.
length
)
{
value
=
true
;
$
(
options
.
acrossInput
).
val
(
0
);
$
(
options
.
actionContainer
).
removeClass
(
options
.
selectedClass
);
},
checker
=
function
(
checked
)
{
if
(
checked
)
{
showQuestion
();
}
else
{
value
=
false
;
clearAcross
();
reset
();
}
return
value
;
});
};
$
(
actionCheckboxes
).
prop
(
"
checked
"
,
checked
)
.
parent
().
parent
().
toggleClass
(
options
.
selectedClass
,
checked
);
},
updateCounter
=
function
()
{
var
sel
=
$
(
actionCheckboxes
).
filter
(
"
:checked
"
).
length
;
// data-actions-icnt is defined in the generated HTML
// and contains the total amount of objects in the queryset
var
actions_icnt
=
$
(
'
.action-counter
'
).
data
(
'
actionsIcnt
'
);
$
(
options
.
counterContainer
).
html
(
interpolate
(
ngettext
(
'
%(sel)s of %(cnt)s selected
'
,
'
%(sel)s of %(cnt)s selected
'
,
sel
),
{
sel
:
sel
,
cnt
:
actions_icnt
},
true
));
$
(
options
.
allToggle
).
prop
(
"
checked
"
,
function
()
{
var
value
;
if
(
sel
===
actionCheckboxes
.
length
)
{
value
=
true
;
showQuestion
();
}
else
{
value
=
false
;
clearAcross
();
}
return
value
;
});
};
// Show counter by default
$
(
options
.
counterContainer
).
show
();
// Check state of checkboxes and reinit state if needed
$
(
this
).
filter
(
"
:checked
"
).
each
(
function
(
i
)
{
$
(
this
).
filter
(
"
:checked
"
).
each
(
function
(
i
)
{
$
(
this
).
parent
().
parent
().
toggleClass
(
options
.
selectedClass
);
updateCounter
();
if
(
$
(
options
.
acrossInput
).
val
()
===
1
)
{
showClear
();
}
});
$
(
options
.
allToggle
).
show
().
on
(
'
click
'
,
function
()
{
$
(
options
.
allToggle
).
show
().
on
(
'
click
'
,
function
()
{
checker
(
$
(
this
).
prop
(
"
checked
"
));
updateCounter
();
});
$
(
"
a
"
,
options
.
acrossQuestions
).
on
(
'
click
'
,
function
(
event
)
{
$
(
"
a
"
,
options
.
acrossQuestions
).
on
(
'
click
'
,
function
(
event
)
{
event
.
preventDefault
();
$
(
options
.
acrossInput
).
val
(
1
);
showClear
();
});
$
(
"
a
"
,
options
.
acrossClears
).
on
(
'
click
'
,
function
(
event
)
{
$
(
"
a
"
,
options
.
acrossClears
).
on
(
'
click
'
,
function
(
event
)
{
event
.
preventDefault
();
$
(
options
.
allToggle
).
prop
(
"
checked
"
,
false
);
clearAcross
();
...
...
@@ -88,14 +88,14 @@
updateCounter
();
});
lastChecked
=
null
;
$
(
actionCheckboxes
).
on
(
'
click
'
,
function
(
event
)
{
$
(
actionCheckboxes
).
on
(
'
click
'
,
function
(
event
)
{
if
(
!
event
)
{
event
=
window
.
event
;
}
var
target
=
event
.
target
?
event
.
target
:
event
.
srcElement
;
if
(
lastChecked
&&
$
.
data
(
lastChecked
)
!==
$
.
data
(
target
)
&&
event
.
shiftKey
===
true
)
{
var
inrange
=
false
;
$
(
lastChecked
).
prop
(
"
checked
"
,
target
.
checked
)
.
parent
().
parent
().
toggleClass
(
options
.
selectedClass
,
target
.
checked
);
$
(
actionCheckboxes
).
each
(
function
()
{
$
(
actionCheckboxes
).
each
(
function
()
{
if
(
$
.
data
(
this
)
===
$
.
data
(
lastChecked
)
||
$
.
data
(
this
)
===
$
.
data
(
target
))
{
inrange
=
(
inrange
)
?
false
:
true
;
}
...
...
@@ -109,17 +109,17 @@
lastChecked
=
target
;
updateCounter
();
});
$
(
'
form#changelist-form table#result_list tr
'
).
on
(
'
change
'
,
'
td:gt(0) :input
'
,
function
()
{
$
(
'
form#changelist-form table#result_list tr
'
).
on
(
'
change
'
,
'
td:gt(0) :input
'
,
function
()
{
list_editable_changed
=
true
;
});
$
(
'
form#changelist-form button[name="index"]
'
).
on
(
'
click
'
,
function
(
event
)
{
$
(
'
form#changelist-form button[name="index"]
'
).
on
(
'
click
'
,
function
(
event
)
{
if
(
list_editable_changed
)
{
return
confirm
(
gettext
(
"
You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost.
"
));
}
});
$
(
'
form#changelist-form input[name="_save"]
'
).
on
(
'
click
'
,
function
(
event
)
{
$
(
'
form#changelist-form input[name="_save"]
'
).
on
(
'
click
'
,
function
(
event
)
{
var
action_changed
=
false
;
$
(
'
select option:selected
'
,
options
.
actionContainer
).
each
(
function
()
{
$
(
'
select option:selected
'
,
options
.
actionContainer
).
each
(
function
()
{
if
(
$
(
this
).
val
())
{
action_changed
=
true
;
}
...
...
@@ -144,7 +144,7 @@
allToggle
:
"
#action-toggle
"
,
selectedClass
:
"
selected
"
};
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
var
$actionsEls
=
$
(
'
tr input.action-select
'
);
if
(
$actionsEls
.
length
>
0
)
{
$actionsEls
.
actions
();
...
...
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