Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100973273
jss-plugin-global.esm.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 4, 10:47
Size
4 KB
Mime Type
text/x-java
Expires
Thu, Feb 6, 10:47 (2 d)
Engine
blob
Format
Raw Data
Handle
24065111
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
jss-plugin-global.esm.js
View Options
import
_extends
from
'@babel/runtime/helpers/esm/extends'
;
import
{
RuleList
}
from
'jss'
;
var
at
=
'@global'
;
var
atPrefix
=
'@global '
;
var
GlobalContainerRule
=
/*#__PURE__*/
function
()
{
function
GlobalContainerRule
(
key
,
styles
,
options
)
{
this
.
type
=
'global'
;
this
.
at
=
at
;
this
.
isProcessed
=
false
;
this
.
key
=
key
;
this
.
options
=
options
;
this
.
rules
=
new
RuleList
(
_extends
({},
options
,
{
parent
:
this
}));
for
(
var
selector
in
styles
)
{
this
.
rules
.
add
(
selector
,
styles
[
selector
]);
}
this
.
rules
.
process
();
}
/**
* Get a rule.
*/
var
_proto
=
GlobalContainerRule
.
prototype
;
_proto
.
getRule
=
function
getRule
(
name
)
{
return
this
.
rules
.
get
(
name
);
}
/**
* Create and register rule, run plugins.
*/
;
_proto
.
addRule
=
function
addRule
(
name
,
style
,
options
)
{
var
rule
=
this
.
rules
.
add
(
name
,
style
,
options
);
if
(
rule
)
this
.
options
.
jss
.
plugins
.
onProcessRule
(
rule
);
return
rule
;
}
/**
* Replace rule, run plugins.
*/
;
_proto
.
replaceRule
=
function
replaceRule
(
name
,
style
,
options
)
{
var
newRule
=
this
.
rules
.
replace
(
name
,
style
,
options
);
if
(
newRule
)
this
.
options
.
jss
.
plugins
.
onProcessRule
(
newRule
);
return
newRule
;
}
/**
* Get index of a rule.
*/
;
_proto
.
indexOf
=
function
indexOf
(
rule
)
{
return
this
.
rules
.
indexOf
(
rule
);
}
/**
* Generates a CSS string.
*/
;
_proto
.
toString
=
function
toString
(
options
)
{
return
this
.
rules
.
toString
(
options
);
};
return
GlobalContainerRule
;
}();
var
GlobalPrefixedRule
=
/*#__PURE__*/
function
()
{
function
GlobalPrefixedRule
(
key
,
style
,
options
)
{
this
.
type
=
'global'
;
this
.
at
=
at
;
this
.
isProcessed
=
false
;
this
.
key
=
key
;
this
.
options
=
options
;
var
selector
=
key
.
substr
(
atPrefix
.
length
);
this
.
rule
=
options
.
jss
.
createRule
(
selector
,
style
,
_extends
({},
options
,
{
parent
:
this
}));
}
var
_proto2
=
GlobalPrefixedRule
.
prototype
;
_proto2
.
toString
=
function
toString
(
options
)
{
return
this
.
rule
?
this
.
rule
.
toString
(
options
)
:
''
;
};
return
GlobalPrefixedRule
;
}();
var
separatorRegExp
=
/\s*,\s*/g
;
function
addScope
(
selector
,
scope
)
{
var
parts
=
selector
.
split
(
separatorRegExp
);
var
scoped
=
''
;
for
(
var
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
scoped
+=
scope
+
" "
+
parts
[
i
].
trim
();
if
(
parts
[
i
+
1
])
scoped
+=
', '
;
}
return
scoped
;
}
function
handleNestedGlobalContainerRule
(
rule
,
sheet
)
{
var
options
=
rule
.
options
,
style
=
rule
.
style
;
var
rules
=
style
?
style
[
at
]
:
null
;
if
(
!
rules
)
return
;
for
(
var
name
in
rules
)
{
sheet
.
addRule
(
name
,
rules
[
name
],
_extends
({},
options
,
{
selector
:
addScope
(
name
,
rule
.
selector
)
}));
}
delete
style
[
at
];
}
function
handlePrefixedGlobalRule
(
rule
,
sheet
)
{
var
options
=
rule
.
options
,
style
=
rule
.
style
;
for
(
var
prop
in
style
)
{
if
(
prop
[
0
]
!==
'@'
||
prop
.
substr
(
0
,
at
.
length
)
!==
at
)
continue
;
var
selector
=
addScope
(
prop
.
substr
(
at
.
length
),
rule
.
selector
);
sheet
.
addRule
(
selector
,
style
[
prop
],
_extends
({},
options
,
{
selector
:
selector
}));
delete
style
[
prop
];
}
}
/**
* Convert nested rules to separate, remove them from original styles.
*/
function
jssGlobal
()
{
function
onCreateRule
(
name
,
styles
,
options
)
{
if
(
!
name
)
return
null
;
if
(
name
===
at
)
{
return
new
GlobalContainerRule
(
name
,
styles
,
options
);
}
if
(
name
[
0
]
===
'@'
&&
name
.
substr
(
0
,
atPrefix
.
length
)
===
atPrefix
)
{
return
new
GlobalPrefixedRule
(
name
,
styles
,
options
);
}
var
parent
=
options
.
parent
;
if
(
parent
)
{
if
(
parent
.
type
===
'global'
||
parent
.
options
.
parent
&&
parent
.
options
.
parent
.
type
===
'global'
)
{
options
.
scoped
=
false
;
}
}
if
(
!
options
.
selector
&&
options
.
scoped
===
false
)
{
options
.
selector
=
name
;
}
return
null
;
}
function
onProcessRule
(
rule
,
sheet
)
{
if
(
rule
.
type
!==
'style'
||
!
sheet
)
return
;
handleNestedGlobalContainerRule
(
rule
,
sheet
);
handlePrefixedGlobalRule
(
rule
,
sheet
);
}
return
{
onCreateRule
:
onCreateRule
,
onProcessRule
:
onProcessRule
};
}
export
default
jssGlobal
;
Event Timeline
Log In to Comment