Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
20b472f6
Commit
20b472f6
authored
Jul 05, 2016
by
Matthew Taylor
Committed by
GitHub
Jul 05, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #668 from mewtaylor/issue/gh-666-all
Fix GH-666: Make category options into key/value
parents
11155c42
aa3cbe55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
src/views/explore/explore.jsx
src/views/explore/explore.jsx
+32
-32
No files found.
src/views/explore/explore.jsx
View file @
20b472f6
var
classNames
=
require
(
'
classnames
'
);
var
injectIntl
=
require
(
'
react-intl
'
).
injectIntl
;
var
FormattedMessage
=
require
(
'
react-intl
'
).
FormattedMessage
;
var
React
=
require
(
'
react
'
);
...
...
@@ -17,7 +18,14 @@ require('./explore.scss');
var
Explore
=
injectIntl
(
React
.
createClass
({
type
:
'
Explore
'
,
getDefaultProps
:
function
()
{
var
categoryOptions
=
[
'
all
'
,
'
animations
'
,
'
art
'
,
'
games
'
,
'
music
'
,
'
stories
'
];
var
categoryOptions
=
{
all
:
'
*
'
,
animations
:
'
animations
'
,
art
:
'
art
'
,
games
:
'
games
'
,
music
:
'
music
'
,
stories
:
'
stories
'
};
var
typeOptions
=
[
'
projects
'
,
'
studios
'
];
var
pathname
=
window
.
location
.
pathname
.
toLowerCase
();
...
...
@@ -28,7 +36,7 @@ var Explore = injectIntl(React.createClass({
var
currentCategory
=
pathname
.
substring
(
slash
+
1
,
pathname
.
length
);
var
typeStart
=
pathname
.
indexOf
(
'
explore/
'
);
var
type
=
pathname
.
substring
(
typeStart
+
8
,
slash
);
if
(
categoryOptions
.
indexOf
(
currentCategory
)
===
-
1
||
typeOptions
.
indexOf
(
type
)
===
-
1
)
{
if
(
Object
.
keys
(
categoryOptions
)
.
indexOf
(
currentCategory
)
===
-
1
||
typeOptions
.
indexOf
(
type
)
===
-
1
)
{
window
.
location
=
window
.
location
.
origin
+
'
/explore/projects/all/
'
;
}
...
...
@@ -50,10 +58,8 @@ var Explore = injectIntl(React.createClass({
this
.
getExploreMore
();
},
getExploreMore
:
function
()
{
var
qText
=
''
;
if
(
this
.
props
.
tab
!=
'
all
'
)
{
qText
=
'
&q=
'
+
this
.
props
.
category
;
}
var
qText
=
'
&q=
'
+
this
.
props
.
acceptableTabs
[
this
.
props
.
category
]
||
'
*
'
;
api
({
uri
:
'
/search/
'
+
this
.
props
.
itemType
+
'
?limit=
'
+
this
.
props
.
loadNumber
+
...
...
@@ -80,34 +86,28 @@ var Explore = injectIntl(React.createClass({
window
.
location
=
window
.
location
.
origin
+
'
/explore/
'
+
newType
+
'
/
'
+
this
.
props
.
tab
;
},
getBubble
:
function
(
type
)
{
var
allBubble
=
<
a
href=
{
'
/explore/
'
+
this
.
props
.
itemType
+
'
/
'
+
type
+
'
/
'
}
>
<
li
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>;
if
(
this
.
props
.
category
===
type
)
{
allBubble
=
<
a
href=
{
'
/explore/
'
+
this
.
props
.
itemType
+
'
/
'
+
type
+
'
/
'
}
>
<
li
className=
'active'
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>;
}
return
allBubble
;
let
classes
=
classNames
({
active
:
(
this
.
props
.
category
===
type
)
});
return
(
<
a
href=
{
'
/explore/
'
+
this
.
props
.
itemType
+
'
/
'
+
type
+
'
/
'
}
>
<
li
className=
{
classes
}
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>
);
},
getTab
:
function
(
type
)
{
var
allTab
=
<
a
href=
{
'
/explore/
'
+
type
+
'
/
'
+
this
.
props
.
category
+
'
/
'
}
>
<
li
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>;
if
(
this
.
props
.
itemType
===
type
)
{
allTab
=
<
a
href=
{
'
/explore/
'
+
type
+
'
/
'
+
this
.
props
.
category
+
'
/
'
}
>
<
li
className=
'active'
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>;
}
return
allTab
;
let
classes
=
classNames
({
active
:
(
this
.
props
.
itemType
===
type
)
});
return
(
<
a
href=
{
'
/explore/
'
+
type
+
'
/
'
+
this
.
props
.
category
+
'
/
'
}
>
<
li
className=
{
classes
}
>
<
FormattedMessage
id=
{
'
general.
'
+
type
}
/>
</
li
>
</
a
>
);
},
render
:
function
()
{
return
(
...
...
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