summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAur??lio A. Heckert <aurium@gmail.com>2009-04-08 21:40:18 +0000
committeraurium <aurium@users.sourceforge.net>2009-04-08 21:40:18 +0000
commit20a5c24a8a36fbf303317ef337b023f395eaadf4 (patch)
tree4d993d0226010180a5b62818729c47513306bfc3
parentSome filters and extensions translation updates (diff)
downloadinkscape-20a5c24a8a36fbf303317ef337b023f395eaadf4.tar.gz
inkscape-20a5c24a8a36fbf303317ef337b023f395eaadf4.zip
group recognition to a more faster work with web-transmit-att extension.
(bzr r7669)
-rw-r--r--share/extensions/inkweb.js24
-rw-r--r--share/extensions/web-transmit-att.inx5
-rw-r--r--share/extensions/web-transmit-att.py35
3 files changed, 44 insertions, 20 deletions
diff --git a/share/extensions/inkweb.js b/share/extensions/inkweb.js
index 7b53153e7..10eaf9d01 100644
--- a/share/extensions/inkweb.js
+++ b/share/extensions/inkweb.js
@@ -67,18 +67,22 @@ InkWeb.setStyle = function (el, att, val) {
}
InkWeb.transmitAtt = function (conf) {
+ conf.att = conf.att.split( /\s+/ );
if ( typeof(conf.from) == "string" )
conf.from = document.getElementById( conf.from );
- if ( typeof(conf.to) == "string" )
- conf.to = document.getElementById( conf.to );
- conf.att = conf.att.split( /\s+/ );
- for ( var i=0; i<conf.att.length; i++ ) {
- var val = this.getStyle( conf.from, conf.att[i] );
- if ( val ) {
- this.setStyle( conf.to, conf.att[i], val );
- } else {
- val = conf.from.getAttribute(conf.att[i]);
- conf.to.setAttribute( conf.att[i], val );
+ if ( ! conf.to.join )
+ conf.to = [ conf.to ];
+ for ( var toEl,elN=0; toEl=conf.to[elN]; elN++ ) {
+ if ( typeof(toEl) == "string" )
+ toEl = document.getElementById( toEl );
+ for ( var i=0; i<conf.att.length; i++ ) {
+ var val = this.getStyle( conf.from, conf.att[i] );
+ if ( val ) {
+ this.setStyle( toEl, conf.att[i], val );
+ } else {
+ val = conf.from.getAttribute(conf.att[i]);
+ toEl.setAttribute( conf.att[i], val );
+ }
}
}
}
diff --git a/share/extensions/web-transmit-att.inx b/share/extensions/web-transmit-att.inx
index 0c0a4e0d1..205df8d81 100644
--- a/share/extensions/web-transmit-att.inx
+++ b/share/extensions/web-transmit-att.inx
@@ -27,6 +27,11 @@
<_item value="prepend">Run it before</_item>
<_item value="replace">Replace</_item>
</param>
+ <_param name="help" type="description">The next parameter is useful when you select more then two elements.</_param>
+ <param name="from-and-to" type="enum" _gui-text="Who transmit to Who?">
+ <_item value="g-to-one">All tramsmit to the last</_item>
+ <_item value="one-to-g">The first transmit to all</_item>
+ </param>
<effect>
<object-type>all</object-type>
<effects-menu>
diff --git a/share/extensions/web-transmit-att.py b/share/extensions/web-transmit-att.py
index 830085fab..9c7844dfc 100644
--- a/share/extensions/web-transmit-att.py
+++ b/share/extensions/web-transmit-att.py
@@ -36,6 +36,10 @@ class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
action="store", type="string",
dest="compatibility", default="append",
help="Compatibility with previews code to this event.")
+ self.OptionParser.add_option("-t", "--from-and-to",
+ action="store", type="string",
+ dest="from_and_to", default="g-to-one",
+ help='Who transmit to Who? "g-to-one" All tramsmit to the last. "one-to-g" The first transmit to all.')
def effect(self):
self.ensureInkWebSupport()
@@ -44,20 +48,31 @@ class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
inkwebeffect.inkex.errormsg(_("You must to select at least two elements."))
exit(1)
- elFrom = self.selected[ self.options.ids[0] ]
- idTo = self.options.ids[1]
+ elFrom = []
+ idTo = []
+ if self.options.from_and_to == "g-to-one":
+ # All tramsmit to the last
+ for selId in self.options.ids[:-1]:
+ elFrom.append( self.selected[selId] )
+ idTo.append( self.options.ids[-1] )
+ else:
+ # The first transmit to all
+ elFrom.append( self.selected[ self.options.ids[0] ] )
+ for selId in self.options.ids[1:]:
+ idTo.append( selId )
- prevEvCode = elFrom.get( self.options.when )
- if prevEvCode == None: prevEvCode = ""
+ evCode = "InkWeb.transmitAtt({from:this, to:['"+ "','".join(idTo) +"'], att:'"+self.options.att+"'})"
- evCode = "InkWeb.transmitAtt({from:this, to:'"+idTo+"', att:'"+self.options.att+"'})"
+ for el in elFrom:
+ prevEvCode = el.get( self.options.when )
+ if prevEvCode == None: prevEvCode = ""
- if self.options.compatibility == 'append':
- evCode = prevEvCode +";\n"+ evCode
- if self.options.compatibility == 'prepend':
- evCode = evCode +";\n"+ prevEvCode
+ if self.options.compatibility == 'append':
+ elEvCode = prevEvCode +";\n"+ evCode
+ if self.options.compatibility == 'prepend':
+ elEvCode = evCode +";\n"+ prevEvCode
- elFrom.set( self.options.when, evCode )
+ el.set( self.options.when, elEvCode )
if __name__ == '__main__':
e = InkWebTransmitAtt()