Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
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
django-rest-framework
Commits
1fa2d823
Commit
1fa2d823
authored
Aug 29, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve tab preference in cookies.
parent
c7f3b8be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
rest_framework/static/rest_framework/js/default.js
+44
-1
rest_framework/templates/rest_framework/base.html
+2
-2
No files found.
rest_framework/static/rest_framework/js/default.js
View file @
1fa2d823
function
getCookie
(
c_name
)
{
// From http://www.w3schools.com/js/js_cookies.asp
var
c_value
=
document
.
cookie
;
var
c_start
=
c_value
.
indexOf
(
" "
+
c_name
+
"="
);
if
(
c_start
==
-
1
)
{
c_start
=
c_value
.
indexOf
(
c_name
+
"="
);
}
if
(
c_start
==
-
1
)
{
c_value
=
null
;
}
else
{
c_start
=
c_value
.
indexOf
(
"="
,
c_start
)
+
1
;
var
c_end
=
c_value
.
indexOf
(
";"
,
c_start
);
if
(
c_end
==
-
1
)
{
c_end
=
c_value
.
length
;
}
c_value
=
unescape
(
c_value
.
substring
(
c_start
,
c_end
));
}
return
c_value
;
}
// JSON highlighting.
prettyPrint
();
// Bootstrap tooltips.
$
(
'.js-tooltip'
).
tooltip
({
delay
:
1000
});
// Deal with rounded tab styling after tab clicks.
$
(
'a[data-toggle="tab"]:first'
).
on
(
'shown'
,
function
(
e
)
{
$
(
e
.
target
).
parents
(
'.tabbable'
).
addClass
(
'first-tab-active'
);
});
$
(
'a[data-toggle="tab"]:not(:first)'
).
on
(
'shown'
,
function
(
e
)
{
$
(
e
.
target
).
parents
(
'.tabbable'
).
removeClass
(
'first-tab-active'
);
});
$
(
'.form-switcher a:first'
).
tab
(
'show'
);
$
(
'a[data-toggle="tab"]'
).
click
(
function
(){
document
.
cookie
=
"tab="
+
this
.
name
;
});
// Store tab preference in cookies & display appropriate tab on load.
var
selectedTab
=
null
;
var
selectedTabName
=
getCookie
(
'tab'
);
if
(
selectedTabName
)
{
selectedTab
=
$
(
'.form-switcher a[name='
+
selectedTabName
+
']'
);
}
if
(
selectedTab
&&
selectedTab
.
length
>
0
)
{
// Display whichever tab is selected.
selectedTab
.
tab
(
'show'
);
}
else
{
// If no tab selected, display rightmost tab.
$
(
'.form-switcher a:first'
).
tab
(
'show'
);
}
rest_framework/templates/rest_framework/base.html
View file @
1fa2d823
...
...
@@ -128,8 +128,8 @@
<div
{%
if
post_form
%}
class=
"tabbable"
{%
endif
%}
>
{% if post_form %}
<ul
class=
"nav nav-tabs form-switcher"
>
<li><a
href=
"#object-form"
data-toggle=
"tab"
>
HTML form
</a></li>
<li><a
href=
"#generic-content-form"
data-toggle=
"tab"
>
Raw data
</a></li>
<li><a
name=
'html-tab'
href=
"#object-form"
data-toggle=
"tab"
>
HTML form
</a></li>
<li><a
name=
'raw-tab'
href=
"#generic-content-form"
data-toggle=
"tab"
>
Raw data
</a></li>
</ul>
{% endif %}
<div
class=
"well tab-content"
>
...
...
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