first files (test)
This commit is contained in:
parent
c31b852b2a
commit
4a96564ef9
|
@ -0,0 +1,12 @@
|
||||||
|
You must identify the modifications in this text file.
|
||||||
|
These modifications are licensed under the TAPR Open Hardware License.
|
||||||
|
|
||||||
|
-----BEGINING OF THE MODIFICATIONS-----
|
||||||
|
|
||||||
|
-2017/04/07 - andreika
|
||||||
|
First Revision 0.010
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
|
-----END OF THE MODIFICATIONS-----
|
|
@ -0,0 +1,13 @@
|
||||||
|
You must attempt to send the modified documentation by email to any of the developers who have provided their email address in the list below.
|
||||||
|
This is a good faith obligation - if the email fails, you need do nothing more and may go on with your distribution.
|
||||||
|
|
||||||
|
If you wish to be notified of modifications that others may make, include your email address in this file.
|
||||||
|
|
||||||
|
|
||||||
|
-----BEGINING OF THE MAILING LIST-----
|
||||||
|
|
||||||
|
Name - email
|
||||||
|
------------
|
||||||
|
andreika - prometheus.pcb@gmail.com
|
||||||
|
|
||||||
|
-----END OF THE MAILING LIST-----
|
|
@ -0,0 +1,266 @@
|
||||||
|
The TAPR Open Hardware License
|
||||||
|
Version 1.0 (May 25, 2007)
|
||||||
|
Copyright 2007 TAPR - http://www.tapr.org/OHL
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
|
||||||
|
Open Hardware is a thing - a physical artifact, either electrical or
|
||||||
|
mechanical - whose design information is available to, and usable by,
|
||||||
|
the public in a way that allows anyone to make, modify, distribute, and
|
||||||
|
use that thing. In this preface, design information is called
|
||||||
|
"documentation" and things created from it are called "products."
|
||||||
|
|
||||||
|
The TAPR Open Hardware License ("OHL") agreement provides a legal
|
||||||
|
framework for Open Hardware projects. It may be used for any kind of
|
||||||
|
product, be it a hammer or a computer motherboard, and is TAPR's
|
||||||
|
contribution to the community; anyone may use the OHL for their Open
|
||||||
|
Hardware project.
|
||||||
|
|
||||||
|
Like the GNU General Public License, the OHL is designed to guarantee
|
||||||
|
your freedom to share and to create. It forbids anyone who receives
|
||||||
|
rights under the OHL to deny any other licensee those same rights to
|
||||||
|
copy, modify, and distribute documentation, and to make, use and
|
||||||
|
distribute products based on that documentation.
|
||||||
|
|
||||||
|
Unlike the GPL, the OHL is not primarily a copyright license. While
|
||||||
|
copyright protects documentation from unauthorized copying, modification,
|
||||||
|
and distribution, it has little to do with your right to make, distribute,
|
||||||
|
or use a product based on that documentation. For better or worse, patents
|
||||||
|
play a significant role in those activities. Although it does not prohibit
|
||||||
|
anyone from patenting inventions embodied in an Open Hardware design, and
|
||||||
|
of course cannot prevent a third party from enforcing their patent rights,
|
||||||
|
those who benefit from an OHL design may not bring lawsuits claiming that
|
||||||
|
design infringes their patents or other intellectual property.
|
||||||
|
|
||||||
|
The OHL addresses unique issues involved in the creation of tangible,
|
||||||
|
physical things, but does not cover software, firmware, or code loaded
|
||||||
|
into programmable devices. A copyright-oriented license such as the GPL
|
||||||
|
better suits these creations.
|
||||||
|
|
||||||
|
How can you use the OHL, or a design based upon it? While the terms and
|
||||||
|
conditions below take precedence over this preamble, here is a summary:
|
||||||
|
|
||||||
|
* You may modify the documentation and make products based upon it.
|
||||||
|
|
||||||
|
* You may use products for any legal purpose without limitation.
|
||||||
|
|
||||||
|
* You may distribute unmodified documentation, but you must include the
|
||||||
|
complete package as you received it.
|
||||||
|
|
||||||
|
* You may distribute products you make to third parties, if you either
|
||||||
|
include the documentation on which the product is based, or make it
|
||||||
|
available without charge for at least three years to anyone who requests
|
||||||
|
it.
|
||||||
|
|
||||||
|
* You may distribute modified documentation or products based on it, if
|
||||||
|
you:
|
||||||
|
* License your modifications under the OHL.
|
||||||
|
* Include those modifications, following the requirements stated
|
||||||
|
below.
|
||||||
|
* Attempt to send the modified documentation by email to any of the
|
||||||
|
developers who have provided their email address. This is a good
|
||||||
|
faith obligation - if the email fails, you need do nothing more
|
||||||
|
and may go on with your distribution.
|
||||||
|
|
||||||
|
* If you create a design that you want to license under the OHL, you
|
||||||
|
should:
|
||||||
|
* Include this document in a file named LICENSE (with the appropriate
|
||||||
|
extension) that is included in the documentation package.
|
||||||
|
* If the file format allows, include a notice like "Licensed under
|
||||||
|
the TAPR Open Hardware License (www.tapr.org/OHL)" in each
|
||||||
|
documentation file. While not required, you should also include
|
||||||
|
this notice on printed circuit board artwork and the product
|
||||||
|
itself; if space is limited the notice can be shortened or
|
||||||
|
abbreviated.
|
||||||
|
* Include a copyright notice in each file and on printed circuit
|
||||||
|
board artwork.
|
||||||
|
* If you wish to be notified of modifications that others may make,
|
||||||
|
include your email address in a file named "CONTRIB.TXT" or
|
||||||
|
something similar.
|
||||||
|
|
||||||
|
* Any time the OHL requires you to make documentation available to
|
||||||
|
others, you must include all the materials you received from the
|
||||||
|
upstream licensors. In addition, if you have modified the
|
||||||
|
documentation:
|
||||||
|
* You must identify the modifications in a text file (preferably
|
||||||
|
named "CHANGES.TXT") that you include with the documentation.
|
||||||
|
That file must also include a statement like "These modifications
|
||||||
|
are licensed under the TAPR Open Hardware License."
|
||||||
|
* You must include any new files you created, including any
|
||||||
|
manufacturing files (such as Gerber files) you create in the
|
||||||
|
course of making products.
|
||||||
|
* You must include both "before" and "after" versions of all files
|
||||||
|
you modified.
|
||||||
|
* You may include files in proprietary formats, but you must also
|
||||||
|
include open format versions (such as Gerber, ASCII, Postscript,
|
||||||
|
or PDF) if your tools can create them.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
1. Introduction
|
||||||
|
1.1 This Agreement governs how you may use, copy, modify, and
|
||||||
|
distribute Documentation, and how you may make, have made, and
|
||||||
|
distribute Products based on that Documentation. As used in this
|
||||||
|
Agreement, to "distribute" Documentation means to directly or indirectly
|
||||||
|
make copies available to a third party, and to "distribute" Products
|
||||||
|
means to directly or indirectly give, loan, sell or otherwise transfer
|
||||||
|
them to a third party.
|
||||||
|
|
||||||
|
1.2 "Documentation" includes:
|
||||||
|
(a) schematic diagrams;
|
||||||
|
(b) circuit or circuit board layouts, including Gerber and other
|
||||||
|
data files used for manufacture;
|
||||||
|
(c) mechanical drawings, including CAD, CAM, and other data files
|
||||||
|
used for manufacture;
|
||||||
|
(d) flow charts and descriptive text; and
|
||||||
|
(e) other explanatory material.
|
||||||
|
Documentation may be in any tangible or intangible form of expression,
|
||||||
|
including but not limited to computer files in open or proprietary
|
||||||
|
formats and representations on paper, film, or other media.
|
||||||
|
|
||||||
|
1.3 "Products" include:
|
||||||
|
(a) circuit boards, mechanical assemblies, and other physical parts
|
||||||
|
and components;
|
||||||
|
(b) assembled or partially assembled units (including components
|
||||||
|
and subassemblies); and
|
||||||
|
(c) parts and components combined into kits intended for assembly
|
||||||
|
by others;
|
||||||
|
which are based in whole or in part on the Documentation.
|
||||||
|
|
||||||
|
1.4 This Agreement applies to any Documentation which contains a
|
||||||
|
notice stating it is subject to the TAPR Open Hardware License, and to
|
||||||
|
all Products based in whole or in part on that Documentation. If
|
||||||
|
Documentation is distributed in an archive (such as a "zip" file) which
|
||||||
|
includes this document, all files in that archive are subject to this
|
||||||
|
Agreement unless they are specifically excluded. Each person who
|
||||||
|
contributes content to the Documentation is referred to in this
|
||||||
|
Agreement as a "Licensor."
|
||||||
|
|
||||||
|
1.5 By (a) using, copying, modifying, or distributing the
|
||||||
|
Documentation, or (b) making or having Products made or distributing
|
||||||
|
them, you accept this Agreement, agree to comply with its terms, and
|
||||||
|
become a "Licensee." Any activity inconsistent with this Agreement will
|
||||||
|
automatically terminate your rights under it (including the immunities
|
||||||
|
from suit granted in Section 2), but the rights of others who have
|
||||||
|
received Documentation, or have obtained Products, directly or
|
||||||
|
indirectly from you will not be affected so long as they fully comply
|
||||||
|
with it themselves.
|
||||||
|
|
||||||
|
1.6 This Agreement does not apply to software, firmware, or code
|
||||||
|
loaded into programmable devices which may be used in conjunction with
|
||||||
|
Documentation or Products. Such software is subject to the license
|
||||||
|
terms established by its copyright holder(s).
|
||||||
|
|
||||||
|
2. Patents
|
||||||
|
2.1 Each Licensor grants you, every other Licensee, and every
|
||||||
|
possessor or user of Products a perpetual, worldwide, and royalty-free
|
||||||
|
immunity from suit under any patent, patent application, or other
|
||||||
|
intellectual property right which he or she controls, to the extent
|
||||||
|
necessary to make, have made, possess, use, and distribute Products.
|
||||||
|
This immunity does not extend to infringement arising from modifications
|
||||||
|
subsequently made by others.
|
||||||
|
|
||||||
|
2.2 If you make or have Products made, or distribute Documentation
|
||||||
|
that you have modified, you grant every Licensor, every other Licensee,
|
||||||
|
and every possessor or user of Products a perpetual, worldwide, and
|
||||||
|
royalty-free immunity from suit under any patent, patent application, or
|
||||||
|
other intellectual property right which you control, to the extent
|
||||||
|
necessary to make, have made, possess, use, and distribute Products.
|
||||||
|
This immunity does not extend to infringement arising from modifications
|
||||||
|
subsequently made by others.
|
||||||
|
|
||||||
|
2.3 To avoid doubt, providing Documentation to a third party for the
|
||||||
|
sole purpose of having that party make Products on your behalf is not
|
||||||
|
considered "distribution", and a third party's act of making Products
|
||||||
|
solely on your behalf does not cause that party to grant the immunity
|
||||||
|
described in the preceding paragraph.
|
||||||
|
|
||||||
|
2.4 These grants of immunity are a material part of this Agreement,
|
||||||
|
and form a portion of the consideration given by each party to the
|
||||||
|
other. If any court judgment or legal agreement prevents you from
|
||||||
|
granting the immunity required by this Section, your rights under this
|
||||||
|
Agreement will terminate and you may no longer use, copy, modify or
|
||||||
|
distribute the Documentation, or make, have made, or distribute
|
||||||
|
Products.
|
||||||
|
|
||||||
|
3. Modifications
|
||||||
|
You may modify the Documentation, and those modifications will become
|
||||||
|
part of the Documentation. They are subject to this Agreement, as are
|
||||||
|
Products based in whole or in part on them. If you distribute the
|
||||||
|
modified Documentation, or Products based in whole or in part upon it,
|
||||||
|
you must email the modified Documentation in a form compliant with
|
||||||
|
Section 4 to each Licensor who has provided an email address with the
|
||||||
|
Documentation. Attempting to send the email completes your obligations
|
||||||
|
under this Section and you need take no further action if any address
|
||||||
|
fails.
|
||||||
|
|
||||||
|
4. Distributing Documentation
|
||||||
|
4.1 You may distribute unmodified copies of the Documentation in its
|
||||||
|
entirety in any medium, provided that you retain all copyright and other
|
||||||
|
notices (including references to this Agreement) included by each
|
||||||
|
Licensor, and include an unaltered copy of this Agreement.
|
||||||
|
4.2 You may distribute modified copies of the Documentation if you
|
||||||
|
comply with all the requirements of the preceding paragraph and:
|
||||||
|
(a) include a prominent notice in an ASCII or other open format
|
||||||
|
file identifying those elements of the Documentation that you
|
||||||
|
changed, and stating that the modifications are licensed under
|
||||||
|
the terms of this Agreement;
|
||||||
|
(b) include all new documentation files that you create, as well as
|
||||||
|
both the original and modified versions of each file you change
|
||||||
|
(files may be in your development tool's native file format,
|
||||||
|
but if reasonably possible, you must also include open format,
|
||||||
|
such as Gerber, ASCII, Postscript, or PDF, versions);
|
||||||
|
(c) do not change the terms of this Agreement with respect to
|
||||||
|
subsequent licensees; and
|
||||||
|
(d) if you make or have Products made, include in the Documentation
|
||||||
|
all elements reasonably required to permit others to make
|
||||||
|
Products, including Gerber, CAD/CAM and other files used for
|
||||||
|
manufacture.
|
||||||
|
|
||||||
|
5. Making Products
|
||||||
|
5.1 You may use the Documentation to make or have Products made,
|
||||||
|
provided that each Product retains any notices included by the Licensor
|
||||||
|
(including, but not limited to, copyright notices on circuit boards).
|
||||||
|
5.2 You may distribute Products you make or have made, provided that
|
||||||
|
you include with each unit a copy of the Documentation in a form
|
||||||
|
consistent with Section 4. Alternatively, you may include either (i) an
|
||||||
|
offer valid for at least three years to provide that Documentation, at
|
||||||
|
no charge other than the reasonable cost of media and postage, to any
|
||||||
|
person who requests it; or (ii) a URL where that Documentation may be
|
||||||
|
downloaded, available for at least three years after you last distribute
|
||||||
|
the Product.
|
||||||
|
|
||||||
|
6. NEW LICENSE VERSIONS
|
||||||
|
TAPR may publish updated versions of the OHL which retain the same
|
||||||
|
general provisions as the present version, but differ in detail to
|
||||||
|
address new problems or concerns, and carry a distinguishing version
|
||||||
|
number. If the Documentation specifies a version number which applies
|
||||||
|
to it and "any later version", you may choose either that version or any
|
||||||
|
later version published by TAPR. If the Documentation does not specify
|
||||||
|
a version number, you may choose any version ever published by TAPR.
|
||||||
|
TAPR owns the copyright to the OHL, but grants permission to any person
|
||||||
|
to copy, distribute, and use it in unmodified form.
|
||||||
|
|
||||||
|
7. WARRANTY AND LIABILITY LIMITATIONS
|
||||||
|
7.1 THE DOCUMENTATION IS PROVIDED ON AN "AS-IS" BASIS WITHOUT
|
||||||
|
WARRANTY OF ANY KIND, TO THE EXTENT PERMITTED BY APPLICABLE LAW. ALL
|
||||||
|
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
|
||||||
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||||
|
TITLE, ARE HEREBY EXPRESSLY DISCLAIMED.
|
||||||
|
7.2 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL ANY LICENSOR
|
||||||
|
BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, OR EXEMPLARY DAMAGES ARISING OUT OF
|
||||||
|
THE USE OF, OR INABILITY TO USE, THE DOCUMENTATION OR PRODUCTS,
|
||||||
|
INCLUDING BUT NOT LIMITED TO CLAIMS OF INTELLECTUAL PROPERTY
|
||||||
|
INFRINGEMENT OR LOSS OF DATA, EVEN IF THAT PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
7.3 You agree that the foregoing limitations are reasonable due to
|
||||||
|
the non-financial nature of the transaction represented by this
|
||||||
|
Agreement, and acknowledge that were it not for these limitations, the
|
||||||
|
Licensor(s) would not be willing to make the Documentation available to
|
||||||
|
you.
|
||||||
|
7.4 You agree to defend, indemnify, and hold each Licensor harmless
|
||||||
|
from any claim brought by a third party alleging any defect in the
|
||||||
|
design, manufacture, or operation of any Product which you make, have
|
||||||
|
made, or distribute pursuant to this Agreement.
|
||||||
|
####
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,360 @@
|
||||||
|
(function($) {
|
||||||
|
var has_VML, has_canvas, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,
|
||||||
|
canvas_style, hex_to_decimal, css3color, is_image_loaded, options_from_area;
|
||||||
|
|
||||||
|
has_canvas = !!document.createElement('canvas').getContext;
|
||||||
|
|
||||||
|
// VML: more complex
|
||||||
|
has_VML = (function() {
|
||||||
|
var a = document.createElement('div');
|
||||||
|
a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
|
||||||
|
var b = a.firstChild;
|
||||||
|
b.style.behavior = "url(#default#VML)";
|
||||||
|
return b ? typeof b.adj == "object": true;
|
||||||
|
})();
|
||||||
|
|
||||||
|
if(!(has_canvas || has_VML)) {
|
||||||
|
$.fn.maphilight = function() { return this; };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(has_canvas) {
|
||||||
|
hex_to_decimal = function(hex) {
|
||||||
|
return Math.max(0, Math.min(parseInt(hex, 16), 255));
|
||||||
|
};
|
||||||
|
css3color = function(color, opacity) {
|
||||||
|
return 'rgba('+hex_to_decimal(color.substr(0,2))+','+hex_to_decimal(color.substr(2,2))+','+hex_to_decimal(color.substr(4,2))+','+opacity+')';
|
||||||
|
};
|
||||||
|
create_canvas_for = function(img) {
|
||||||
|
var c = $('<canvas style="width:'+$(img).width()+'px;height:'+$(img).height()+'px;"></canvas>').get(0);
|
||||||
|
c.getContext("2d").clearRect(0, 0, $(img).width(), $(img).height());
|
||||||
|
return c;
|
||||||
|
};
|
||||||
|
var draw_shape = function(context, shape, coords, x_shift, y_shift) {
|
||||||
|
x_shift = x_shift || 0;
|
||||||
|
y_shift = y_shift || 0;
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
if(shape == 'rect') {
|
||||||
|
// x, y, width, height
|
||||||
|
context.rect(coords[0] + x_shift, coords[1] + y_shift, coords[2] - coords[0], coords[3] - coords[1]);
|
||||||
|
} else if(shape == 'poly') {
|
||||||
|
context.moveTo(coords[0] + x_shift, coords[1] + y_shift);
|
||||||
|
for(i=2; i < coords.length; i+=2) {
|
||||||
|
context.lineTo(coords[i] + x_shift, coords[i+1] + y_shift);
|
||||||
|
}
|
||||||
|
} else if(shape == 'circ') {
|
||||||
|
// x, y, radius, startAngle, endAngle, anticlockwise
|
||||||
|
context.arc(coords[0] + x_shift, coords[1] + y_shift, coords[2], 0, Math.PI * 2, false);
|
||||||
|
}
|
||||||
|
context.closePath();
|
||||||
|
};
|
||||||
|
add_shape_to = function(canvas, shape, coords, options, name) {
|
||||||
|
var i, context = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// Because I don't want to worry about setting things back to a base state
|
||||||
|
|
||||||
|
// Shadow has to happen first, since it's on the bottom, and it does some clip /
|
||||||
|
// fill operations which would interfere with what comes next.
|
||||||
|
if(options.shadow) {
|
||||||
|
context.save();
|
||||||
|
if(options.shadowPosition == "inside") {
|
||||||
|
// Cause the following stroke to only apply to the inside of the path
|
||||||
|
draw_shape(context, shape, coords);
|
||||||
|
context.clip();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redraw the shape shifted off the canvas massively so we can cast a shadow
|
||||||
|
// onto the canvas without having to worry about the stroke or fill (which
|
||||||
|
// cannot have 0 opacity or width, since they're what cast the shadow).
|
||||||
|
var x_shift = canvas.width * 100;
|
||||||
|
var y_shift = canvas.height * 100;
|
||||||
|
draw_shape(context, shape, coords, x_shift, y_shift);
|
||||||
|
|
||||||
|
context.shadowOffsetX = options.shadowX - x_shift;
|
||||||
|
context.shadowOffsetY = options.shadowY - y_shift;
|
||||||
|
context.shadowBlur = options.shadowRadius;
|
||||||
|
context.shadowColor = css3color(options.shadowColor, options.shadowOpacity);
|
||||||
|
|
||||||
|
// Now, work out where to cast the shadow from! It looks better if it's cast
|
||||||
|
// from a fill when it's an outside shadow or a stroke when it's an interior
|
||||||
|
// shadow. Allow the user to override this if they need to.
|
||||||
|
var shadowFrom = options.shadowFrom;
|
||||||
|
if (!shadowFrom) {
|
||||||
|
if (options.shadowPosition == 'outside') {
|
||||||
|
shadowFrom = 'fill';
|
||||||
|
} else {
|
||||||
|
shadowFrom = 'stroke';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shadowFrom == 'stroke') {
|
||||||
|
context.strokeStyle = "rgba(0,0,0,1)";
|
||||||
|
context.stroke();
|
||||||
|
} else if (shadowFrom == 'fill') {
|
||||||
|
context.fillStyle = "rgba(0,0,0,1)";
|
||||||
|
context.fill();
|
||||||
|
}
|
||||||
|
context.restore();
|
||||||
|
|
||||||
|
// and now we clean up
|
||||||
|
if(options.shadowPosition == "outside") {
|
||||||
|
context.save();
|
||||||
|
// Clear out the center
|
||||||
|
draw_shape(context, shape, coords);
|
||||||
|
context.globalCompositeOperation = "destination-out";
|
||||||
|
context.fillStyle = "rgba(0,0,0,1);";
|
||||||
|
context.fill();
|
||||||
|
context.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.save();
|
||||||
|
|
||||||
|
draw_shape(context, shape, coords);
|
||||||
|
|
||||||
|
// fill has to come after shadow, otherwise the shadow will be drawn over the fill,
|
||||||
|
// which mostly looks weird when the shadow has a high opacity
|
||||||
|
if(options.fill) {
|
||||||
|
context.fillStyle = css3color(options.fillColor, options.fillOpacity);
|
||||||
|
context.fill();
|
||||||
|
}
|
||||||
|
// Likewise, stroke has to come at the very end, or it'll wind up under bits of the
|
||||||
|
// shadow or the shadow-background if it's present.
|
||||||
|
if(options.stroke) {
|
||||||
|
context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
|
||||||
|
context.lineWidth = options.strokeWidth;
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
context.restore();
|
||||||
|
|
||||||
|
if(options.fade) {
|
||||||
|
$(canvas).css('opacity', 0).animate({opacity: 1}, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
clear_canvas = function(canvas) {
|
||||||
|
canvas.getContext('2d').clearRect(0, 0, canvas.width,canvas.height);
|
||||||
|
};
|
||||||
|
} else { // ie executes this code
|
||||||
|
create_canvas_for = function(img) {
|
||||||
|
return $('<var style="zoom:1;overflow:hidden;display:block;width:'+img.width+'px;height:'+img.height+'px;"></var>').get(0);
|
||||||
|
};
|
||||||
|
add_shape_to = function(canvas, shape, coords, options, name) {
|
||||||
|
var fill, stroke, opacity, e;
|
||||||
|
for (var i in coords) { coords[i] = parseInt(coords[i], 10); }
|
||||||
|
fill = '<v:fill color="#'+options.fillColor+'" opacity="'+(options.fill ? options.fillOpacity : 0)+'" />';
|
||||||
|
stroke = (options.stroke ? 'strokeweight="'+options.strokeWidth+'" stroked="t" strokecolor="#'+options.strokeColor+'"' : 'stroked="f"');
|
||||||
|
opacity = '<v:stroke opacity="'+options.strokeOpacity+'"/>';
|
||||||
|
if(shape == 'rect') {
|
||||||
|
e = $('<v:rect name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+coords[0]+'px;top:'+coords[1]+'px;width:'+(coords[2] - coords[0])+'px;height:'+(coords[3] - coords[1])+'px;"></v:rect>');
|
||||||
|
} else if(shape == 'poly') {
|
||||||
|
e = $('<v:shape name="'+name+'" filled="t" '+stroke+' coordorigin="0,0" coordsize="'+canvas.width+','+canvas.height+'" path="m '+coords[0]+','+coords[1]+' l '+coords.join(',')+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+canvas.width+'px;height:'+canvas.height+'px;"></v:shape>');
|
||||||
|
} else if(shape == 'circ') {
|
||||||
|
e = $('<v:oval name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(coords[0] - coords[2])+'px;top:'+(coords[1] - coords[2])+'px;width:'+(coords[2]*2)+'px;height:'+(coords[2]*2)+'px;"></v:oval>');
|
||||||
|
}
|
||||||
|
e.get(0).innerHTML = fill+opacity;
|
||||||
|
$(canvas).append(e);
|
||||||
|
};
|
||||||
|
clear_canvas = function(canvas) {
|
||||||
|
// jquery1.8 + ie7
|
||||||
|
var $html = $("<div>" + canvas.innerHTML + "</div>");
|
||||||
|
$html.children('[name=highlighted]').remove();
|
||||||
|
canvas.innerHTML = $html.html();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
shape_from_area = function(area) {
|
||||||
|
var i, coords = area.getAttribute('coords').split(',');
|
||||||
|
for (i=0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); }
|
||||||
|
return [area.getAttribute('shape').toLowerCase().substr(0,4), coords];
|
||||||
|
};
|
||||||
|
|
||||||
|
options_from_area = function(area, options) {
|
||||||
|
var $area = $(area);
|
||||||
|
return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight'));
|
||||||
|
};
|
||||||
|
|
||||||
|
is_image_loaded = function(img) {
|
||||||
|
if(!img.complete) { return false; } // IE
|
||||||
|
if(typeof img.naturalWidth != "undefined" && img.naturalWidth === 0) { return false; } // Others
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
canvas_style = {
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
padding: 0,
|
||||||
|
border: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
var ie_hax_done = false;
|
||||||
|
$.fn.maphilight = function(opts) {
|
||||||
|
opts = $.extend({}, $.fn.maphilight.defaults, opts);
|
||||||
|
|
||||||
|
if(!has_canvas && !ie_hax_done) {
|
||||||
|
$(window).ready(function() {
|
||||||
|
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
|
||||||
|
var style = document.createStyleSheet();
|
||||||
|
var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox'];
|
||||||
|
$.each(shapes,
|
||||||
|
function() {
|
||||||
|
style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ie_hax_done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.each(function() {
|
||||||
|
var img, wrap, options, map, canvas, canvas_always, highlighted_shape, usemap;
|
||||||
|
img = $(this);
|
||||||
|
|
||||||
|
if(!is_image_loaded(this)) {
|
||||||
|
// If the image isn't fully loaded, this won't work right. Try again later.
|
||||||
|
return window.setTimeout(function() {
|
||||||
|
img.maphilight(opts);
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight'));
|
||||||
|
|
||||||
|
// jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
|
||||||
|
// So use raw getAttribute instead.
|
||||||
|
usemap = img.get(0).getAttribute('usemap');
|
||||||
|
|
||||||
|
if (!usemap) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
map = $('map[name="'+usemap.substr(1)+'"]');
|
||||||
|
|
||||||
|
if(!(img.is('img,input[type="image"]') && usemap && map.size() > 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(img.hasClass('maphilighted')) {
|
||||||
|
// We're redrawing an old map, probably to pick up changes to the options.
|
||||||
|
// Just clear out all the old stuff.
|
||||||
|
var wrapper = img.parent();
|
||||||
|
img.insertBefore(wrapper);
|
||||||
|
wrapper.remove();
|
||||||
|
$(map).unbind('.maphilight');
|
||||||
|
}
|
||||||
|
|
||||||
|
wrap = $('<div></div>').css({
|
||||||
|
display:'block',
|
||||||
|
backgroundImage:'url("'+this.src+'")',
|
||||||
|
backgroundSize:'contain',
|
||||||
|
position:'relative',
|
||||||
|
padding:0,
|
||||||
|
width:this.width,
|
||||||
|
height:this.height
|
||||||
|
});
|
||||||
|
if(options.wrapClass) {
|
||||||
|
if(options.wrapClass === true) {
|
||||||
|
wrap.addClass($(this).attr('class'));
|
||||||
|
} else {
|
||||||
|
wrap.addClass(options.wrapClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img.before(wrap).css('opacity', 0).css(canvas_style).remove();
|
||||||
|
if(has_VML) { img.css('filter', 'Alpha(opacity=0)'); }
|
||||||
|
wrap.append(img);
|
||||||
|
|
||||||
|
canvas = create_canvas_for(this);
|
||||||
|
$(canvas).css(canvas_style);
|
||||||
|
canvas.height = this.height;
|
||||||
|
canvas.width = this.width;
|
||||||
|
|
||||||
|
$(map).bind('alwaysOn.maphilight', function() {
|
||||||
|
// Check for areas with alwaysOn set. These are added to a *second* canvas,
|
||||||
|
// which will get around flickering during fading.
|
||||||
|
if(canvas_always) {
|
||||||
|
clear_canvas(canvas_always);
|
||||||
|
}
|
||||||
|
if(!has_canvas) {
|
||||||
|
$(canvas).empty();
|
||||||
|
}
|
||||||
|
$(map).find('area[coords]').each(function() {
|
||||||
|
var shape, area_options;
|
||||||
|
area_options = options_from_area(this, options);
|
||||||
|
if(area_options.alwaysOn) {
|
||||||
|
if(!canvas_always && has_canvas) {
|
||||||
|
canvas_always = create_canvas_for(img[0]);
|
||||||
|
$(canvas_always).css(canvas_style);
|
||||||
|
canvas_always.width = img[0].width;
|
||||||
|
canvas_always.height = img[0].height;
|
||||||
|
img.before(canvas_always);
|
||||||
|
}
|
||||||
|
area_options.fade = area_options.alwaysOnFade; // alwaysOn shouldn't fade in initially
|
||||||
|
shape = shape_from_area(this);
|
||||||
|
if (has_canvas) {
|
||||||
|
add_shape_to(canvas_always, shape[0], shape[1], area_options, "");
|
||||||
|
} else {
|
||||||
|
add_shape_to(canvas, shape[0], shape[1], area_options, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).trigger('alwaysOn.maphilight')
|
||||||
|
.bind('mouseover.maphilight, focus.maphilight', function(e) {
|
||||||
|
var shape, area_options, area = e.target;
|
||||||
|
area_options = options_from_area(area, options);
|
||||||
|
if(!area_options.neverOn && !area_options.alwaysOn) {
|
||||||
|
shape = shape_from_area(area);
|
||||||
|
add_shape_to(canvas, shape[0], shape[1], area_options, "highlighted");
|
||||||
|
if(area_options.groupBy) {
|
||||||
|
var areas;
|
||||||
|
// two ways groupBy might work; attribute and selector
|
||||||
|
if(/^[a-zA-Z][\-a-zA-Z]+$/.test(area_options.groupBy)) {
|
||||||
|
areas = map.find('area['+area_options.groupBy+'="'+$(area).attr(area_options.groupBy)+'"]');
|
||||||
|
} else {
|
||||||
|
areas = map.find(area_options.groupBy);
|
||||||
|
}
|
||||||
|
var first = area;
|
||||||
|
areas.each(function() {
|
||||||
|
if(this != first) {
|
||||||
|
var subarea_options = options_from_area(this, options);
|
||||||
|
if(!subarea_options.neverOn && !subarea_options.alwaysOn) {
|
||||||
|
var shape = shape_from_area(this);
|
||||||
|
add_shape_to(canvas, shape[0], shape[1], subarea_options, "highlighted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// workaround for IE7, IE8 not rendering the final rectangle in a group
|
||||||
|
if(!has_canvas) {
|
||||||
|
$(canvas).append('<v:rect></v:rect>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).bind('mouseout.maphilight, blur.maphilight', function(e) { clear_canvas(canvas); });
|
||||||
|
|
||||||
|
img.before(canvas); // if we put this after, the mouseover events wouldn't fire.
|
||||||
|
|
||||||
|
img.addClass('maphilighted');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
$.fn.maphilight.defaults = {
|
||||||
|
fill: true,
|
||||||
|
fillColor: 'ff0000',
|
||||||
|
fillOpacity: 0.3,
|
||||||
|
stroke: true,
|
||||||
|
strokeColor: 'ff0000',
|
||||||
|
strokeOpacity: 1,
|
||||||
|
strokeWidth: 1,
|
||||||
|
fade: true,
|
||||||
|
alwaysOn: false,
|
||||||
|
neverOn: false,
|
||||||
|
groupBy: false,
|
||||||
|
wrapClass: true,
|
||||||
|
// plenty of shadow:
|
||||||
|
shadow: false,
|
||||||
|
shadowX: 0,
|
||||||
|
shadowY: 0,
|
||||||
|
shadowRadius: 6,
|
||||||
|
shadowColor: '000000',
|
||||||
|
shadowOpacity: 0.8,
|
||||||
|
shadowPosition: 'outside',
|
||||||
|
shadowFrom: false
|
||||||
|
};
|
||||||
|
})(jQuery);
|
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue