Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6ad466a3
Commit
6ad466a3
authored
Oct 13, 2017
by
Mike Greiling
Committed by
Phil Hughes
Oct 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor broadcast_message.js
parent
273b116c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
26 deletions
+29
-26
app/assets/javascripts/broadcast_message.js
app/assets/javascripts/broadcast_message.js
+20
-25
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+4
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
changelogs/unreleased/es-module-broadcast_message.yml
changelogs/unreleased/es-module-broadcast_message.yml
+5
-0
No files found.
app/assets/javascripts/broadcast_message.js
View file @
6ad466a3
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, no-else-return, object-shorthand, comma-dangle, max-len */
export
default
function
initBroadcastMessagesForm
()
{
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
onMessageColorInput
()
{
$
(
function
()
{
const
previewColor
=
$
(
this
).
val
();
var
previewPath
;
$
(
'
div.broadcast-message-preview
'
).
css
(
'
background-color
'
,
previewColor
);
$
(
'
input#broadcast_message_color
'
).
on
(
'
input
'
,
function
()
{
var
previewColor
;
previewColor
=
$
(
this
).
val
();
return
$
(
'
div.broadcast-message-preview
'
).
css
(
'
background-color
'
,
previewColor
);
});
});
$
(
'
input#broadcast_message_font
'
).
on
(
'
input
'
,
function
()
{
var
previewColor
;
$
(
'
input#broadcast_message_font
'
).
on
(
'
input
'
,
function
onMessageFontInput
()
{
previewColor
=
$
(
this
).
val
();
const
previewColor
=
$
(
this
).
val
();
return
$
(
'
div.broadcast-message-preview
'
).
css
(
'
color
'
,
previewColor
);
$
(
'
div.broadcast-message-preview
'
).
css
(
'
color
'
,
previewColor
);
});
});
previewPath
=
$
(
'
textarea#broadcast_message_message
'
).
data
(
'
preview-path
'
);
return
$
(
'
textarea#broadcast_message_message
'
).
on
(
'
input
'
,
function
()
{
const
previewPath
=
$
(
'
textarea#broadcast_message_message
'
).
data
(
'
preview-path
'
);
var
message
;
message
=
$
(
this
).
val
();
$
(
'
textarea#broadcast_message_message
'
).
on
(
'
input
'
,
_
.
debounce
(
function
onMessageInput
()
{
const
message
=
$
(
this
).
val
();
if
(
message
===
''
)
{
if
(
message
===
''
)
{
return
$
(
'
.js-broadcast-message-preview
'
).
text
(
"
Your message here
"
);
$
(
'
.js-broadcast-message-preview
'
).
text
(
'
Your message here
'
);
}
else
{
}
else
{
return
$
.
ajax
({
$
.
ajax
({
url
:
previewPath
,
url
:
previewPath
,
type
:
"
POST
"
,
type
:
'
POST
'
,
data
:
{
data
:
{
broadcast_message
:
{
broadcast_message
:
{
message
},
message
:
message
},
}
}
});
});
}
}
});
}
,
250
)
);
}
);
}
app/assets/javascripts/dispatcher.js
View file @
6ad466a3
...
@@ -70,6 +70,7 @@ import initSettingsPanels from './settings_panels';
...
@@ -70,6 +70,7 @@ import initSettingsPanels from './settings_panels';
import
initExperimentalFlags
from
'
./experimental_flags
'
;
import
initExperimentalFlags
from
'
./experimental_flags
'
;
import
OAuthRememberMe
from
'
./oauth_remember_me
'
;
import
OAuthRememberMe
from
'
./oauth_remember_me
'
;
import
PerformanceBar
from
'
./performance_bar
'
;
import
PerformanceBar
from
'
./performance_bar
'
;
import
initBroadcastMessagesForm
from
'
./broadcast_message
'
;
import
initNotes
from
'
./init_notes
'
;
import
initNotes
from
'
./init_notes
'
;
import
initLegacyFilters
from
'
./init_legacy_filters
'
;
import
initLegacyFilters
from
'
./init_legacy_filters
'
;
import
initIssuableSidebar
from
'
./init_issuable_sidebar
'
;
import
initIssuableSidebar
from
'
./init_issuable_sidebar
'
;
...
@@ -555,6 +556,9 @@ import memberExpirationDate from './member_expiration_date';
...
@@ -555,6 +556,9 @@ import memberExpirationDate from './member_expiration_date';
case
'
admin
'
:
case
'
admin
'
:
new
Admin
();
new
Admin
();
switch
(
path
[
1
])
{
switch
(
path
[
1
])
{
case
'
broadcast_messages
'
:
initBroadcastMessagesForm
();
break
;
case
'
cohorts
'
:
case
'
cohorts
'
:
new
UsagePing
();
new
UsagePing
();
break
;
break
;
...
...
app/assets/javascripts/main.js
View file @
6ad466a3
...
@@ -53,7 +53,6 @@ import './aside';
...
@@ -53,7 +53,6 @@ import './aside';
import
'
./autosave
'
;
import
'
./autosave
'
;
import
loadAwardsHandler
from
'
./awards_handler
'
;
import
loadAwardsHandler
from
'
./awards_handler
'
;
import
bp
from
'
./breakpoints
'
;
import
bp
from
'
./breakpoints
'
;
import
'
./broadcast_message
'
;
import
'
./commits
'
;
import
'
./commits
'
;
import
'
./compare
'
;
import
'
./compare
'
;
import
'
./compare_autocomplete
'
;
import
'
./compare_autocomplete
'
;
...
...
changelogs/unreleased/es-module-broadcast_message.yml
0 → 100644
View file @
6ad466a3
---
title
:
Fix unnecessary ajax requests in admin broadcast message form
merge_request
:
14853
author
:
type
:
fixed
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