Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cdn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vaclab
Cdn
Commits
f87a03a9
Commit
f87a03a9
authored
7 years ago
by
Rolf Niepraschk
Browse files
Options
Downloads
Patches
Plain Diff
"vl-jq-utils.js" nach "web-apps"
parent
37701101
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
_attachments/js/vl-jq-utils.js
+0
-87
0 additions, 87 deletions
_attachments/js/vl-jq-utils.js
with
0 additions
and
87 deletions
_attachments/js/vl-jq-utils.js
deleted
100644 → 0
+
0
−
87
View file @
37701101
/**
* @author Rolf Niepraschk (Rolf.Niepraschk@ptb.de)
* version: 2013-09-05
*/
// https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
/*
* Defines a jQuery plugin that works with AMD and browser globals.
* https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
*/
(
function
(
factory
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
// AMD. Register as an anonymous module.
requirejs
.
config
(
{
paths
:
{
'
jquery.rule
'
:
'
jquery.rule-1.0.2-min
'
},
shim
:
{
'
jquery.rule
'
:
[
'
jquery
'
]
}
});
define
([
'
jquery
'
,
'
jquery.rule
'
],
factory
);
}
else
{
// Browser globals
factory
(
jQuery
);
}
}(
function
(
$
)
{
/**
* Transformiert jedes selektierte Jquery-Objekt zu inline-SVG. Eine
* der folgenden Voraussetzungen muss erfüllt sein:
* 1. Die Funktion getSVGDocument ist existent (object- oder embed-Tag)
* 2. Es handelt sich um ein img-Tag, dessen src-Attribut SVG-Code adressiert.
* 3. Die css-Eigenschaft 'background-image' ist wirksam und adressiert
* SVG-Code.
* @param {function} ready Aufruf nach kompletter Abarbeitung (optional)
* @return {object} Jquery-Objekte
*/
function
toInlineSVG
(
ready
)
{
var
selector
=
this
.
selector
,
backgClasses
=
[],
length
=
this
.
length
;
function
makeSVG
(
$target
,
$s
,
id
,
cl
,
index
)
{
if
(
$s
.
length
)
{
// komplette Jquery-Struktur (SVG-Dokument)?
var
$svg
=
$s
.
find
(
'
svg
'
).
removeAttr
(
'
xmlns:a
'
).
attr
(
'
id
'
,
id
);
if
(
cl
)
$svg
.
attr
(
'
class
'
,
cl
);
$svg
.
replaceAll
(
$target
);
}
if
(
index
+
1
==
length
)
{
var
cl
=
'
.
'
+
backgClasses
.
join
(
'
'
).
split
(
/
\s
/
).
join
(
'
,.
'
);
$
.
rule
(
cl
).
append
(
'
background-image:none;
'
);
if
(
typeof
ready
==
'
function
'
)
ready
();
}
}
if
(
this
.
length
)
{
this
.
each
(
function
(
idx
,
el
){
var
$el
=
$
(
el
);
// Id und Klassen retten.
var
id
=
$el
.
attr
(
'
id
'
),
cl
=
$el
.
attr
(
'
class
'
);
if
(
el
.
getSVGDocument
)
{
// Funktion existent?
var
$svg
=
$
(
el
.
getSVGDocument
());
makeSVG
(
$el
,
$svg
,
id
,
cl
,
idx
);
}
else
if
(
el
.
tagName
==
'
IMG
'
)
{
var
url
=
$el
.
attr
(
'
src
'
);
$
.
get
(
url
,
function
(
data
)
{
makeSVG
(
$el
,
$
(
data
),
id
,
cl
,
idx
);
});
}
else
{
var
url
=
document
.
defaultView
.
getComputedStyle
(
el
,
null
).
getPropertyValue
(
'
background-image
'
).
replace
(
/^url
\([
"'
]?
/
,
''
).
replace
(
/
[
"'
]?\)
$/
,
''
);
if
(
url
.
length
)
{
// background-image?
backgClasses
.
push
(
cl
);
$
.
get
(
url
,
function
(
data
)
{
makeSVG
(
$el
,
$
(
data
),
id
,
cl
,
idx
);
});
}
}
});
}
else
{
if
(
typeof
ready
==
'
function
'
)
ready
();
}
//return this;
}
$
.
fn
.
toInlineSVG
=
toInlineSVG
;
}));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment