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
912e012b
Commit
912e012b
authored
9 years ago
by
Syed Hassan Raza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Disabled class to Sign In button
parent
e908b569
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
3 deletions
+54
-3
cms/static/coffee/spec/main.coffee
+1
-0
cms/static/js/factories/login.js
+9
-3
cms/static/js/spec/views/login_studio_spec.js
+32
-0
cms/templates/js/mock/login.underscore
+12
-0
No files found.
cms/static/coffee/spec/main.coffee
View file @
912e012b
...
@@ -253,6 +253,7 @@ define([
...
@@ -253,6 +253,7 @@ define([
"js/spec/views/xblock_validation_spec"
,
"js/spec/views/xblock_validation_spec"
,
"js/spec/views/license_spec"
,
"js/spec/views/license_spec"
,
"js/spec/views/paging_spec"
,
"js/spec/views/paging_spec"
,
"js/spec/views/login_studio_spec"
,
"js/spec/views/pages/container_spec"
,
"js/spec/views/pages/container_spec"
,
"js/spec/views/pages/container_subviews_spec"
,
"js/spec/views/pages/container_subviews_spec"
,
...
...
This diff is collapsed.
Click to expand it.
cms/static/js/factories/login.js
View file @
912e012b
define
([
'jquery.cookie'
,
'utility'
],
function
(
)
{
define
([
'jquery.cookie'
,
'utility'
,
'common/js/components/utils/view_utils'
],
function
(
cookie
,
utility
,
ViewUtils
)
{
'use strict'
;
'use strict'
;
return
function
(
homepageURL
)
{
return
function
(
homepageURL
)
{
function
postJSON
(
url
,
data
,
callback
)
{
function
postJSON
(
url
,
data
,
callback
)
{
...
@@ -22,15 +22,19 @@ define(['jquery.cookie', 'utility'], function() {
...
@@ -22,15 +22,19 @@ define(['jquery.cookie', 'utility'], function() {
$
(
'form#login_form'
).
submit
(
function
(
event
)
{
$
(
'form#login_form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
event
.
preventDefault
();
var
submitButton
=
$
(
'#submit'
),
deferred
=
new
$
.
Deferred
(),
promise
=
deferred
.
promise
();
ViewUtils
.
disableElementWhileRunning
(
submitButton
,
function
()
{
return
promise
;
});
var
submit_data
=
$
(
'#login_form'
).
serialize
();
var
submit_data
=
$
(
'#login_form'
).
serialize
();
postJSON
(
'/login_post'
,
submit_data
,
function
(
json
)
{
postJSON
(
'/login_post'
,
submit_data
,
function
(
json
)
{
if
(
json
.
success
)
{
if
(
json
.
success
)
{
var
next
=
/next=
([^
&
]
*
)
/g
.
exec
(
decodeURIComponent
(
window
.
location
.
search
));
var
next
=
/next=
([^
&
]
*
)
/g
.
exec
(
decodeURIComponent
(
window
.
location
.
search
));
if
(
next
&&
next
.
length
>
1
&&
!
isExternal
(
next
[
1
]))
{
if
(
next
&&
next
.
length
>
1
&&
!
isExternal
(
next
[
1
]))
{
location
.
href
=
next
[
1
]
;
ViewUtils
.
redirect
(
next
[
1
])
;
}
else
{
}
else
{
location
.
href
=
homepageURL
;
ViewUtils
.
redirect
(
homepageURL
)
;
}
}
}
else
if
(
$
(
'#login_error'
).
length
===
0
)
{
}
else
if
(
$
(
'#login_error'
).
length
===
0
)
{
$
(
'#login_form'
).
prepend
(
$
(
'#login_form'
).
prepend
(
...
@@ -39,11 +43,13 @@ define(['jquery.cookie', 'utility'], function() {
...
@@ -39,11 +43,13 @@ define(['jquery.cookie', 'utility'], function() {
'</span></div>'
'</span></div>'
);
);
$
(
'#login_error'
).
addClass
(
'is-shown'
);
$
(
'#login_error'
).
addClass
(
'is-shown'
);
deferred
.
resolve
();
}
else
{
}
else
{
$
(
'#login_error'
)
$
(
'#login_error'
)
.
stop
()
.
stop
()
.
addClass
(
'is-shown'
)
.
addClass
(
'is-shown'
)
.
html
(
json
.
value
);
.
html
(
json
.
value
);
deferred
.
resolve
();
}
}
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
cms/static/js/spec/views/login_studio_spec.js
0 → 100644
View file @
912e012b
define
([
'jquery'
,
'js/factories/login'
,
'common/js/spec_helpers/ajax_helpers'
,
'common/js/components/utils/view_utils'
],
function
(
$
,
LoginFactory
,
AjaxHelpers
,
ViewUtils
)
{
'use strict'
;
describe
(
"Studio Login Page"
,
function
()
{
var
submitButton
;
beforeEach
(
function
()
{
loadFixtures
(
'mock/login.underscore'
);
/*jshint unused: false*/
var
login_factory
=
new
LoginFactory
(
"/home/"
);
submitButton
=
$
(
'#submit'
);
});
it
(
'disable the submit button once it is clicked'
,
function
()
{
spyOn
(
ViewUtils
,
'redirect'
).
andCallFake
(
function
(){});
var
requests
=
AjaxHelpers
.
requests
(
this
);
expect
(
submitButton
).
not
.
toHaveClass
(
'is-disabled'
);
submitButton
.
click
();
AjaxHelpers
.
respondWithJson
(
requests
,
{
'success'
:
true
});
expect
(
submitButton
).
toHaveClass
(
'is-disabled'
);
});
it
(
'It will not disable the submit button if there are errors in ajax request'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
);
expect
(
submitButton
).
not
.
toHaveClass
(
'is-disabled'
);
submitButton
.
click
();
expect
(
submitButton
).
toHaveClass
(
'is-disabled'
);
AjaxHelpers
.
respondWithError
(
requests
,
{});
expect
(
submitButton
).
not
.
toHaveClass
(
'is-disabled'
);
});
});
});
This diff is collapsed.
Click to expand it.
cms/templates/js/mock/login.underscore
0 → 100644
View file @
912e012b
<div class="wrapper-content wrapper">
<form id="login_form" method="post" action="login_post" onsubmit="return false;">
<input type="hidden" name="csrfmiddlewaretoken" value="csrf"/>
<input id="email" type="email" name="email" placeholder="'example: username@domain.com'"/>
<input id="password" type="password" name="password"/>
<div class="form-actions">
<button type="submit" id="submit" name="submit" class="action action-primary">Sign In</button>
</div>
<input name="honor_code" type="checkbox" value="true" checked="true" hidden="true">
</form>
</div>
This diff is collapsed.
Click to expand it.
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