Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1778c157
Commit
1778c157
authored
Aug 19, 2014
by
Ben McMorran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor dismissNotification uses into shared logic in view_utils
parent
d1ffecf3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
46 deletions
+33
-46
cms/static/js/index.js
+6
-14
cms/static/js/views/overview.js
+5
-14
cms/static/js/views/pages/course_outline.js
+5
-17
cms/static/js/views/utils/view_utils.js
+17
-1
No files found.
cms/static/js/index.js
View file @
1778c157
define
([
"domReady"
,
"jquery"
,
"underscore"
,
"js/utils/cancel_on_escape"
,
"js/views/utils/create_course_utils"
],
function
(
domReady
,
$
,
_
,
CancelOnEscape
,
CreateCourseUtilsFactory
)
{
define
([
"domReady"
,
"jquery"
,
"underscore"
,
"js/utils/cancel_on_escape"
,
"js/views/utils/create_course_utils"
,
"js/views/utils/view_utils"
],
function
(
domReady
,
$
,
_
,
CancelOnEscape
,
CreateCourseUtilsFactory
,
ViewUtils
)
{
var
CreateCourseUtils
=
CreateCourseUtilsFactory
({
name
:
'.new-course-name'
,
org
:
'.new-course-org'
,
...
...
@@ -19,16 +20,6 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
error
:
'error'
});
var
dismissNotification
=
function
(
e
)
{
e
.
preventDefault
();
$
.
ajax
({
url
:
$
(
this
).
data
(
'dismiss-link'
),
type
:
'DELETE'
,
success
:
function
(
result
)
{
window
.
location
.
reload
();
}
});
};
var
saveNewCourse
=
function
(
e
)
{
e
.
preventDefault
();
...
...
@@ -90,13 +81,14 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape", "js/vie
var
onReady
=
function
()
{
$
(
'.new-course-button'
).
bind
(
'click'
,
addNewCourse
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
dismissNotification
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
ViewUtils
.
deleteNotificationHandler
(
function
()
{
window
.
location
.
reload
();
}));
};
domReady
(
onReady
);
return
{
dismissNotification
:
dismissNotification
,
onReady
:
onReady
};
});
cms/static/js/views/overview.js
View file @
1778c157
define
([
"domReady"
,
"jquery"
,
"jquery.ui"
,
"underscore"
,
"gettext"
,
"js/views/feedback_notification"
,
"js/utils/cancel_on_escape"
,
"js/utils/date_utils"
,
"js/utils/module"
],
"js/utils/cancel_on_escape"
,
"js/utils/date_utils"
,
"js/utils/module"
,
"js/views/utils/view_utils"
],
function
(
domReady
,
$
,
ui
,
_
,
gettext
,
NotificationView
,
CancelOnEscape
,
DateUtils
,
ModuleUtils
)
{
DateUtils
,
ModuleUtils
,
ViewUtils
)
{
var
modalSelector
=
'.edit-section-publish-settings'
;
var
dismissNotification
=
function
(
e
)
{
e
.
preventDefault
();
$
.
ajax
({
url
:
$
(
'.dismiss-button'
).
data
(
'dismiss-link'
),
type
:
'GET'
,
success
:
function
(
result
)
{
$
(
'.wrapper-alert-announcement'
).
remove
()
}
});
};
var
toggleSections
=
function
(
e
)
{
e
.
preventDefault
();
...
...
@@ -233,7 +222,9 @@ define(["domReady", "jquery", "jquery.ui", "underscore", "gettext", "js/views/fe
$
(
'.toggle-button-sections'
).
bind
(
'click'
,
toggleSections
);
$
(
'.expand-collapse'
).
bind
(
'click'
,
toggleSubmodules
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
dismissNotification
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
ViewUtils
.
deleteNotificationHandler
(
function
()
{
$
(
'.wrapper-alert-announcement'
).
remove
();
}));
var
$body
=
$
(
'body'
);
$body
.
on
(
'click'
,
'.section-published-date .edit-release-date'
,
editSectionPublishDate
);
...
...
cms/static/js/views/pages/course_outline.js
View file @
1778c157
...
...
@@ -2,8 +2,8 @@
* This page is used to show the user an outline of the course.
*/
define
([
"jquery"
,
"underscore"
,
"gettext"
,
"js/views/pages/base_page"
,
"js/views/utils/xblock_utils"
,
"js/views/course_outline"
],
function
(
$
,
_
,
gettext
,
BasePage
,
XBlockViewUtils
,
CourseOutlineView
)
{
"js/views/course_outline"
,
"js/views/utils/view_utils"
],
function
(
$
,
_
,
gettext
,
BasePage
,
XBlockViewUtils
,
CourseOutlineView
,
ViewUtils
)
{
var
expandedLocators
,
CourseOutlinePage
;
CourseOutlinePage
=
BasePage
.
extend
({
...
...
@@ -25,7 +25,9 @@ define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views
self
.
outlineView
.
handleAddEvent
(
event
);
});
this
.
model
.
on
(
'change'
,
this
.
setCollapseExpandVisibility
,
this
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
this
.
dismissNotification
);
$
(
'.dismiss-button'
).
bind
(
'click'
,
ViewUtils
.
deleteNotificationHandler
(
function
()
{
$
(
'.wrapper-alert-announcement'
).
removeClass
(
'is-shown'
).
addClass
(
'is-hidden'
)
}));
},
setCollapseExpandVisibility
:
function
()
{
...
...
@@ -98,20 +100,6 @@ define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views
}
},
this
);
}
},
/**
* Dismiss the course rerun notification.
*/
dismissNotification
:
function
(
e
)
{
e
.
preventDefault
();
$
.
ajax
({
url
:
$
(
'.dismiss-button'
).
data
(
'dismiss-link'
),
type
:
'DELETE'
,
success
:
function
(
result
)
{
$
(
'.wrapper-alert-announcement'
).
removeClass
(
'is-shown'
).
addClass
(
'is-hidden'
)
}
});
}
});
...
...
cms/static/js/views/utils/view_utils.js
View file @
1778c157
...
...
@@ -5,7 +5,7 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js
function
(
$
,
_
,
gettext
,
NotificationView
,
PromptView
)
{
var
toggleExpandCollapse
,
showLoadingIndicator
,
hideLoadingIndicator
,
confirmThenRunOperation
,
runOperationShowingMessage
,
disableElementWhileRunning
,
getScrollOffset
,
setScrollOffset
,
setScrollTop
,
redirect
,
hasChangedAttributes
;
setScrollTop
,
redirect
,
hasChangedAttributes
,
deleteNotificationHandler
;
/**
* Toggles the expanded state of the current element.
...
...
@@ -95,6 +95,21 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js
};
/**
* Returns a handler that removes a notification, both dismissing it and deleting it from the database.
* @param callback function to call when deletion succeeds
*/
deleteNotificationHandler
=
function
(
callback
)
{
return
function
(
event
)
{
event
.
preventDefault
();
$
.
ajax
({
url
:
$
(
this
).
data
(
'dismiss-link'
),
type
:
'DELETE'
,
success
:
callback
});
};
};
/**
* Performs an animated scroll so that the window has the specified scroll top.
* @param scrollTop The desired scroll top for the window.
*/
...
...
@@ -158,6 +173,7 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js
'confirmThenRunOperation'
:
confirmThenRunOperation
,
'runOperationShowingMessage'
:
runOperationShowingMessage
,
'disableElementWhileRunning'
:
disableElementWhileRunning
,
'deleteNotificationHandler'
:
deleteNotificationHandler
,
'setScrollTop'
:
setScrollTop
,
'getScrollOffset'
:
getScrollOffset
,
'setScrollOffset'
:
setScrollOffset
,
...
...
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