2014 lines
56 KiB
XML
2014 lines
56 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<root>
|
|
<!--
|
|
Microsoft ResX Schema
|
|
|
|
Version 2.0
|
|
|
|
The primary goals of this format is to allow a simple XML format
|
|
that is mostly human readable. The generation and parsing of the
|
|
various data types are done through the TypeConverter classes
|
|
associated with the data types.
|
|
|
|
Example:
|
|
|
|
... ado.net/XML headers & schema ...
|
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
<resheader name="version">2.0</resheader>
|
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
</data>
|
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
<comment>This is a comment</comment>
|
|
</data>
|
|
|
|
There are any number of "resheader" rows that contain simple
|
|
name/value pairs.
|
|
|
|
Each data row contains a name, and value. The row also contains a
|
|
type or mimetype. Type corresponds to a .NET class that support
|
|
text/value conversion through the TypeConverter architecture.
|
|
Classes that don't support this are serialized and stored with the
|
|
mimetype set.
|
|
|
|
The mimetype is used for serialized objects, and tells the
|
|
ResXResourceReader how to depersist the object. This is currently not
|
|
extensible. For a given mimetype the value must be set accordingly:
|
|
|
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
that the ResXResourceWriter will generate, however the reader can
|
|
read any of the formats listed below.
|
|
|
|
mimetype: application/x-microsoft.net.object.binary.base64
|
|
value : The object must be serialized with
|
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
: and then encoded with base64 encoding.
|
|
|
|
mimetype: application/x-microsoft.net.object.soap.base64
|
|
value : The object must be serialized with
|
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
: and then encoded with base64 encoding.
|
|
|
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
value : The object must be serialized into a byte array
|
|
: using a System.ComponentModel.TypeConverter
|
|
: and then encoded with base64 encoding.
|
|
-->
|
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
<xsd:element name="root" msdata:IsDataSet="true">
|
|
<xsd:complexType>
|
|
<xsd:choice maxOccurs="unbounded">
|
|
<xsd:element name="metadata">
|
|
<xsd:complexType>
|
|
<xsd:sequence>
|
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
</xsd:sequence>
|
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
<xsd:attribute name="type" type="xsd:string" />
|
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
<xsd:attribute ref="xml:space" />
|
|
</xsd:complexType>
|
|
</xsd:element>
|
|
<xsd:element name="assembly">
|
|
<xsd:complexType>
|
|
<xsd:attribute name="alias" type="xsd:string" />
|
|
<xsd:attribute name="name" type="xsd:string" />
|
|
</xsd:complexType>
|
|
</xsd:element>
|
|
<xsd:element name="data">
|
|
<xsd:complexType>
|
|
<xsd:sequence>
|
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
</xsd:sequence>
|
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
<xsd:attribute ref="xml:space" />
|
|
</xsd:complexType>
|
|
</xsd:element>
|
|
<xsd:element name="resheader">
|
|
<xsd:complexType>
|
|
<xsd:sequence>
|
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
</xsd:sequence>
|
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
</xsd:complexType>
|
|
</xsd:element>
|
|
</xsd:choice>
|
|
</xsd:complexType>
|
|
</xsd:element>
|
|
</xsd:schema>
|
|
<resheader name="resmimetype">
|
|
<value>text/microsoft-resx</value>
|
|
</resheader>
|
|
<resheader name="version">
|
|
<value>2.0</value>
|
|
</resheader>
|
|
<resheader name="reader">
|
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
</resheader>
|
|
<resheader name="writer">
|
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
</resheader>
|
|
<data name="imageCropperScript" xml:space="preserve">
|
|
<value>function initImageCropper(imageId, jsonId, rawId) {
|
|
$(function() {
|
|
$('.header a').click(function() {
|
|
initJcrop(imageId, jsonId, rawId); // if other tab
|
|
});
|
|
$('#' + imageId).ready(function() {
|
|
setTimeout('initJcrop("' + imageId + '","' + jsonId + '","' + rawId + '")',100);
|
|
//initJcrop(imageId, jsonId, rawId); // if first tab
|
|
});
|
|
});
|
|
}
|
|
|
|
function initJcrop(imageId, jsonId, rawId) {
|
|
|
|
if ($('#' + imageId).height() > 0) {
|
|
if ($('.img' + imageId + '.ic-crop').size() == 0) {
|
|
|
|
// json object
|
|
var json = eval('(' + $('#' + jsonId).val() + ')');
|
|
|
|
// store json object to hidden element
|
|
$('#' + jsonId).data('json', json);
|
|
|
|
// create jcrop
|
|
var API = $.Jcrop('#' + imageId);
|
|
|
|
// add current height and width spans
|
|
var coords_id = 'img' + imageId + '_coords';
|
|
$('#' + jsonId).after('<div style="float:left;color:#777;padding: 7px 0 0 0" id="' + coords_id + '"></div>');
|
|
$('#' + coords_id).append('<span class="img' + imageId + ' ic-width"></span>');
|
|
$('#' + coords_id).append('<span class="img' + imageId + ' ic-height"></span>');
|
|
|
|
// generate crop links (rel = index)
|
|
for (var i = json.crops.length - 1; i >= 0; i--) {
|
|
$('#' + jsonId).after('<a href="#" class="img' + imageId + ' ic-crop" rel="' + i + '"><b>Name:</b> ' + json.crops[i].name + '<br/><b>Target:</b> ' + json.crops[i].config.targetWidth + 'x' + json.crops[i].config.targetHeight + '<br/><b>Aspect:</b> ' + (json.crops[i].config.keepAspect ? 'yes' : 'no') + '</a>');
|
|
}
|
|
|
|
icValidateHealth(imageId, jsonId);
|
|
|
|
// set current class
|
|
$('.img' + imageId + '.ic-crop').click(function() {
|
|
$('.img' + imageId + '.ic-crop').removeClass('current');
|
|
$(this).addClass('current');
|
|
});
|
|
|
|
$('.img' + imageId + '.ic-crop').each(function(i) {
|
|
$(this).click(function() {
|
|
|
|
var json = eval('(' + $('#' + jsonId).val() + ')');
|
|
var btn = this;
|
|
var index = this.rel;
|
|
var crop = json.crops[index];
|
|
|
|
// keep aspect?
|
|
API.setOptions({
|
|
aspectRatio: (crop.config.keepAspect ? crop.config.targetWidth / crop.config.targetHeight : 0)
|
|
});
|
|
|
|
// only change presets
|
|
API.setOptions({ allowSelect: false });
|
|
|
|
// events
|
|
API.setOptions({
|
|
|
|
onChange: function(c) {
|
|
$('.img' + imageId + '.ic-width').html(c.w);
|
|
$('.img' + imageId + '.ic-height').html('x' + c.h);
|
|
},
|
|
|
|
onSelect: function(c) {
|
|
|
|
crop.value.x = c.x;
|
|
crop.value.y = c.y;
|
|
crop.value.x2 = c.x2;
|
|
crop.value.y2 = c.y2;
|
|
json.current = index;
|
|
|
|
$('#' + jsonId).val(JSON.stringify(json));
|
|
|
|
var raw = '';
|
|
for (var i = 0; i < json.crops.length; i++) {
|
|
raw += json.crops[i].value.x + ',' +
|
|
json.crops[i].value.y + ',' +
|
|
json.crops[i].value.x2 + ',' +
|
|
json.crops[i].value.y2;
|
|
if (i < json.crops.length - 1) raw += ';';
|
|
}
|
|
$('#' + rawId).val(raw);
|
|
icValidateHealth(imageId, jsonId);
|
|
}
|
|
});
|
|
|
|
var x = crop.value.x;
|
|
var y = crop.value.y;
|
|
var x2 = crop.value.x2;
|
|
var y2 = crop.value.y2;
|
|
|
|
if (x2 == 0) x2 = x + crop.config.targetWidth;
|
|
if (y2 == 0) y2 = y + crop.config.targetHeight;
|
|
|
|
API.setSelect([x, y, x2, y2]);
|
|
|
|
return false;
|
|
|
|
});
|
|
});
|
|
|
|
$(".img" + imageId + ".ic-crop[rel='" + json.current + "']").click();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
function icValidateHealth(imageId, jsonId) {
|
|
var json = eval('(' + $('#' + jsonId).val() + ')');
|
|
|
|
$('.img' + imageId + '.ic-crop').each(function(i) {
|
|
|
|
var crop = json.crops[i];
|
|
|
|
if (crop.value.x2 - crop.value.x < crop.config.targetWidth ||
|
|
crop.value.y2 - crop.value.y < crop.config.targetHeight) {
|
|
$(this).removeClass('healthy');
|
|
$(this).addClass('unhealthy');
|
|
} else {
|
|
$(this).removeClass('unhealthy');
|
|
$(this).addClass('healthy');
|
|
}
|
|
|
|
});
|
|
}</value>
|
|
</data>
|
|
<data name="jCropCSS" xml:space="preserve">
|
|
<value><style type="text/css">
|
|
/* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
|
|
.jcrop-holder { text-align: left; }
|
|
|
|
.jcrop-vline, .jcrop-hline
|
|
{
|
|
font-size: 0;
|
|
position: absolute;
|
|
background: white url('/umbraco_client/imagecropper/Jcrop.gif') top left repeat;
|
|
}
|
|
.jcrop-vline { height: 100%; width: 1px !important; }
|
|
.jcrop-hline { width: 100%; height: 1px !important; }
|
|
.jcrop-handle {
|
|
font-size: 1px;
|
|
width: 7px !important;
|
|
height: 7px !important;
|
|
border: 1px #eee solid;
|
|
background-color: #333;
|
|
*width: 9px;
|
|
*height: 9px;
|
|
}
|
|
|
|
.jcrop-tracker { width: 100%; height: 100%; }
|
|
|
|
.custom .jcrop-vline,
|
|
.custom .jcrop-hline
|
|
{
|
|
background: yellow;
|
|
}
|
|
.custom .jcrop-handle
|
|
{
|
|
border-color: black;
|
|
background-color: #C7BB00;
|
|
-moz-border-radius: 3px;
|
|
-webkit-border-radius: 3px;
|
|
}
|
|
|
|
.ic-crop
|
|
{
|
|
display: block;
|
|
float: left;
|
|
text-decoration: none;
|
|
padding: 10px 5px;
|
|
background: #ddd;
|
|
border: 4px solid #fff;
|
|
|
|
margin: 5px 5px 0 0;
|
|
}
|
|
|
|
.ic-crop:hover { text-decoration: none; }
|
|
|
|
.ic-crop.current
|
|
{
|
|
/* text-decoration: underline; */
|
|
|
|
|
|
}
|
|
|
|
.ic-crop.healthy
|
|
{
|
|
background: #E6EFC2;
|
|
color: #264409;
|
|
}
|
|
|
|
.ic-crop.current.healthy
|
|
{
|
|
border-color: #C6D880;
|
|
}
|
|
|
|
.ic-crop.unhealthy
|
|
{
|
|
background: #FBE3E4;
|
|
color: #8A1F11;
|
|
}
|
|
|
|
.ic-crop.current.unhealthy
|
|
{
|
|
border-color: #FBC2C4;
|
|
}
|
|
</style></value>
|
|
</data>
|
|
<data name="jCropScript" xml:space="preserve">
|
|
<value>/**
|
|
* jquery.Jcrop.js v0.9.8
|
|
* jQuery Image Cropping Plugin
|
|
* @author Kelly Hallman <khallman@gmail.com>
|
|
* Copyright (c) 2008-2009 Kelly Hallman - released under MIT License {{{
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
* }}}
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
$.Jcrop = function(obj,opt)
|
|
{
|
|
// Initialization {{{
|
|
|
|
// Sanitize some options {{{
|
|
var obj = obj, opt = opt;
|
|
|
|
if (typeof(obj) !== 'object') obj = $(obj)[0];
|
|
if (typeof(opt) !== 'object') opt = { };
|
|
|
|
// Some on-the-fly fixes for MSIE...sigh
|
|
if (!('trackDocument' in opt))
|
|
{
|
|
opt.trackDocument = $.browser.msie ? false : true;
|
|
if ($.browser.msie && $.browser.version.split('.')[0] == '8')
|
|
opt.trackDocument = true;
|
|
}
|
|
|
|
if (!('keySupport' in opt))
|
|
opt.keySupport = $.browser.msie ? false : true;
|
|
|
|
// }}}
|
|
// Extend the default options {{{
|
|
var defaults = {
|
|
|
|
// Basic Settings
|
|
trackDocument: false,
|
|
baseClass: 'jcrop',
|
|
addClass: null,
|
|
|
|
// Styling Options
|
|
bgColor: 'black',
|
|
bgOpacity: .6,
|
|
borderOpacity: .4,
|
|
handleOpacity: .5,
|
|
|
|
handlePad: 5,
|
|
handleSize: 9,
|
|
handleOffset: 5,
|
|
edgeMargin: 14,
|
|
|
|
aspectRatio: 0,
|
|
keySupport: true,
|
|
cornerHandles: true,
|
|
sideHandles: true,
|
|
drawBorders: true,
|
|
dragEdges: true,
|
|
|
|
boxWidth: 0,
|
|
boxHeight: 0,
|
|
|
|
boundary: 8,
|
|
animationDelay: 20,
|
|
swingSpeed: 3,
|
|
|
|
allowSelect: true,
|
|
allowMove: true,
|
|
allowResize: true,
|
|
|
|
minSelect: [ 0, 0 ],
|
|
maxSize: [ 0, 0 ],
|
|
minSize: [ 0, 0 ],
|
|
|
|
// Callbacks / Event Handlers
|
|
onChange: function() { },
|
|
onSelect: function() { }
|
|
|
|
};
|
|
var options = defaults;
|
|
setOptions(opt);
|
|
|
|
// }}}
|
|
// Initialize some jQuery objects {{{
|
|
|
|
var $origimg = $(obj);
|
|
var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' });
|
|
|
|
$img.width($origimg.width());
|
|
$img.height($origimg.height());
|
|
$origimg.after($img).hide();
|
|
|
|
presize($img,options.boxWidth,options.boxHeight);
|
|
|
|
var boundx = $img.width(),
|
|
boundy = $img.height(),
|
|
|
|
$div = $('<div />')
|
|
.width(boundx).height(boundy)
|
|
.addClass(cssClass('holder'))
|
|
.css({
|
|
position: 'relative',
|
|
backgroundColor: options.bgColor
|
|
}).insertAfter($origimg).append($img);
|
|
;
|
|
|
|
if (options.addClass) $div.addClass(options.addClass);
|
|
//$img.wrap($div);
|
|
|
|
var $img2 = $('<img />')/*{{{*/
|
|
.attr('src',$img.attr('src'))
|
|
.css('position','absolute')
|
|
.width(boundx).height(boundy)
|
|
;/*}}}*/
|
|
var $img_holder = $('<div />')/*{{{*/
|
|
.width(pct(100)).height(pct(100))
|
|
.css({
|
|
zIndex: 310,
|
|
position: 'absolute',
|
|
overflow: 'hidden'
|
|
})
|
|
.append($img2)
|
|
;/*}}}*/
|
|
var $hdl_holder = $('<div />')/*{{{*/
|
|
.width(pct(100)).height(pct(100))
|
|
.css('zIndex',320);
|
|
/*}}}*/
|
|
var $sel = $('<div />')/*{{{*/
|
|
.css({
|
|
position: 'absolute',
|
|
zIndex: 300
|
|
})
|
|
.insertBefore($img)
|
|
.append($img_holder,$hdl_holder)
|
|
;/*}}}*/
|
|
|
|
var bound = options.boundary;
|
|
var $trk = newTracker().width(boundx+(bound*2)).height(boundy+(bound*2))
|
|
.css({ position: 'absolute', top: px(-bound), left: px(-bound), zIndex: 290 })
|
|
.mousedown(newSelection);
|
|
|
|
/* }}} */
|
|
// Set more variables {{{
|
|
|
|
var xlimit, ylimit, xmin, ymin;
|
|
var xscale, yscale, enabled = true;
|
|
var docOffset = getPos($img),
|
|
// Internal states
|
|
btndown, lastcurs, dimmed, animating,
|
|
shift_down;
|
|
|
|
// }}}
|
|
|
|
|
|
// }}}
|
|
// Internal Modules {{{
|
|
|
|
var Coords = function()/*{{{*/
|
|
{
|
|
var x1 = 0, y1 = 0, x2 = 0, y2 = 0, ox, oy;
|
|
|
|
function setPressed(pos)/*{{{*/
|
|
{
|
|
var pos = rebound(pos);
|
|
x2 = x1 = pos[0];
|
|
y2 = y1 = pos[1];
|
|
};
|
|
/*}}}*/
|
|
function setCurrent(pos)/*{{{*/
|
|
{
|
|
var pos = rebound(pos);
|
|
ox = pos[0] - x2;
|
|
oy = pos[1] - y2;
|
|
x2 = pos[0];
|
|
y2 = pos[1];
|
|
};
|
|
/*}}}*/
|
|
function getOffset()/*{{{*/
|
|
{
|
|
return [ ox, oy ];
|
|
};
|
|
/*}}}*/
|
|
function moveOffset(offset)/*{{{*/
|
|
{
|
|
var ox = offset[0], oy = offset[1];
|
|
|
|
if (0 > x1 + ox) ox -= ox + x1;
|
|
if (0 > y1 + oy) oy -= oy + y1;
|
|
|
|
if (boundy < y2 + oy) oy += boundy - (y2 + oy);
|
|
if (boundx < x2 + ox) ox += boundx - (x2 + ox);
|
|
|
|
x1 += ox;
|
|
x2 += ox;
|
|
y1 += oy;
|
|
y2 += oy;
|
|
};
|
|
/*}}}*/
|
|
function getCorner(ord)/*{{{*/
|
|
{
|
|
var c = getFixed();
|
|
switch(ord)
|
|
{
|
|
case 'ne': return [ c.x2, c.y ];
|
|
case 'nw': return [ c.x, c.y ];
|
|
case 'se': return [ c.x2, c.y2 ];
|
|
case 'sw': return [ c.x, c.y2 ];
|
|
}
|
|
};
|
|
/*}}}*/
|
|
function getFixed()/*{{{*/
|
|
{
|
|
if (!options.aspectRatio) return getRect();
|
|
// This function could use some optimization I think...
|
|
var aspect = options.aspectRatio,
|
|
min_x = options.minSize[0]/xscale,
|
|
min_y = options.minSize[1]/yscale,
|
|
max_x = options.maxSize[0]/xscale,
|
|
max_y = options.maxSize[1]/yscale,
|
|
rw = x2 - x1,
|
|
rh = y2 - y1,
|
|
rwa = Math.abs(rw),
|
|
rha = Math.abs(rh),
|
|
real_ratio = rwa / rha,
|
|
xx, yy
|
|
;
|
|
if (max_x == 0) { max_x = boundx * 10 }
|
|
if (max_y == 0) { max_y = boundy * 10 }
|
|
if (real_ratio < aspect)
|
|
{
|
|
yy = y2;
|
|
w = rha * aspect;
|
|
xx = rw < 0 ? x1 - w : w + x1;
|
|
|
|
if (xx < 0)
|
|
{
|
|
xx = 0;
|
|
h = Math.abs((xx - x1) / aspect);
|
|
yy = rh < 0 ? y1 - h: h + y1;
|
|
}
|
|
else if (xx > boundx)
|
|
{
|
|
xx = boundx;
|
|
h = Math.abs((xx - x1) / aspect);
|
|
yy = rh < 0 ? y1 - h : h + y1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
xx = x2;
|
|
h = rwa / aspect;
|
|
yy = rh < 0 ? y1 - h : y1 + h;
|
|
if (yy < 0)
|
|
{
|
|
yy = 0;
|
|
w = Math.abs((yy - y1) * aspect);
|
|
xx = rw < 0 ? x1 - w : w + x1;
|
|
}
|
|
else if (yy > boundy)
|
|
{
|
|
yy = boundy;
|
|
w = Math.abs(yy - y1) * aspect;
|
|
xx = rw < 0 ? x1 - w : w + x1;
|
|
}
|
|
}
|
|
|
|
// Magic %-)
|
|
if(xx > x1) { // right side
|
|
if(xx - x1 < min_x) {
|
|
xx = x1 + min_x;
|
|
} else if (xx - x1 > max_x) {
|
|
xx = x1 + max_x;
|
|
}
|
|
if(yy > y1) {
|
|
yy = y1 + (xx - x1)/aspect;
|
|
} else {
|
|
yy = y1 - (xx - x1)/aspect;
|
|
}
|
|
} else if (xx < x1) { // left side
|
|
if(x1 - xx < min_x) {
|
|
xx = x1 - min_x
|
|
} else if (x1 - xx > max_x) {
|
|
xx = x1 - max_x;
|
|
}
|
|
if(yy > y1) {
|
|
yy = y1 + (x1 - xx)/aspect;
|
|
} else {
|
|
yy = y1 - (x1 - xx)/aspect;
|
|
}
|
|
}
|
|
|
|
if(xx < 0) {
|
|
x1 -= xx;
|
|
xx = 0;
|
|
} else if (xx > boundx) {
|
|
x1 -= xx - boundx;
|
|
xx = boundx;
|
|
}
|
|
|
|
if(yy < 0) {
|
|
y1 -= yy;
|
|
yy = 0;
|
|
} else if (yy > boundy) {
|
|
y1 -= yy - boundy;
|
|
yy = boundy;
|
|
}
|
|
|
|
return last = makeObj(flipCoords(x1,y1,xx,yy));
|
|
};
|
|
/*}}}*/
|
|
function rebound(p)/*{{{*/
|
|
{
|
|
if (p[0] < 0) p[0] = 0;
|
|
if (p[1] < 0) p[1] = 0;
|
|
|
|
if (p[0] > boundx) p[0] = boundx;
|
|
if (p[1] > boundy) p[1] = boundy;
|
|
|
|
return [ p[0], p[1] ];
|
|
};
|
|
/*}}}*/
|
|
function flipCoords(x1,y1,x2,y2)/*{{{*/
|
|
{
|
|
var xa = x1, xb = x2, ya = y1, yb = y2;
|
|
if (x2 < x1)
|
|
{
|
|
xa = x2;
|
|
xb = x1;
|
|
}
|
|
if (y2 < y1)
|
|
{
|
|
ya = y2;
|
|
yb = y1;
|
|
}
|
|
return [ Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb) ];
|
|
};
|
|
/*}}}*/
|
|
function getRect()/*{{{*/
|
|
{
|
|
var xsize = x2 - x1;
|
|
var ysize = y2 - y1;
|
|
|
|
if (xlimit && (Math.abs(xsize) > xlimit))
|
|
x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
|
|
if (ylimit && (Math.abs(ysize) > ylimit))
|
|
y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
|
|
|
|
if (ymin && (Math.abs(ysize) < ymin))
|
|
y2 = (ysize > 0) ? (y1 + ymin) : (y1 - ymin);
|
|
if (xmin && (Math.abs(xsize) < xmin))
|
|
x2 = (xsize > 0) ? (x1 + xmin) : (x1 - xmin);
|
|
|
|
if (x1 < 0) { x2 -= x1; x1 -= x1; }
|
|
if (y1 < 0) { y2 -= y1; y1 -= y1; }
|
|
if (x2 < 0) { x1 -= x2; x2 -= x2; }
|
|
if (y2 < 0) { y1 -= y2; y2 -= y2; }
|
|
if (x2 > boundx) { var delta = x2 - boundx; x1 -= delta; x2 -= delta; }
|
|
if (y2 > boundy) { var delta = y2 - boundy; y1 -= delta; y2 -= delta; }
|
|
if (x1 > boundx) { var delta = x1 - boundy; y2 -= delta; y1 -= delta; }
|
|
if (y1 > boundy) { var delta = y1 - boundy; y2 -= delta; y1 -= delta; }
|
|
|
|
return makeObj(flipCoords(x1,y1,x2,y2));
|
|
};
|
|
/*}}}*/
|
|
function makeObj(a)/*{{{*/
|
|
{
|
|
return { x: a[0], y: a[1], x2: a[2], y2: a[3],
|
|
w: a[2] - a[0], h: a[3] - a[1] };
|
|
};
|
|
/*}}}*/
|
|
|
|
return {
|
|
flipCoords: flipCoords,
|
|
setPressed: setPressed,
|
|
setCurrent: setCurrent,
|
|
getOffset: getOffset,
|
|
moveOffset: moveOffset,
|
|
getCorner: getCorner,
|
|
getFixed: getFixed
|
|
};
|
|
}();
|
|
|
|
/*}}}*/
|
|
var Selection = function()/*{{{*/
|
|
{
|
|
var start, end, dragmode, awake, hdep = 370;
|
|
var borders = { };
|
|
var handle = { };
|
|
var seehandles = false;
|
|
var hhs = options.handleOffset;
|
|
|
|
/* Insert draggable elements {{{*/
|
|
|
|
// Insert border divs for outline
|
|
if (options.drawBorders) {
|
|
borders = {
|
|
top: insertBorder('hline')
|
|
.css('top',$.browser.msie?px(-1):px(0)),
|
|
bottom: insertBorder('hline'),
|
|
left: insertBorder('vline'),
|
|
right: insertBorder('vline')
|
|
};
|
|
}
|
|
|
|
// Insert handles on edges
|
|
if (options.dragEdges) {
|
|
handle.t = insertDragbar('n');
|
|
handle.b = insertDragbar('s');
|
|
handle.r = insertDragbar('e');
|
|
handle.l = insertDragbar('w');
|
|
}
|
|
|
|
// Insert side handles
|
|
options.sideHandles &&
|
|
createHandles(['n','s','e','w']);
|
|
|
|
// Insert corner handles
|
|
options.cornerHandles &&
|
|
createHandles(['sw','nw','ne','se']);
|
|
|
|
/*}}}*/
|
|
// Private Methods
|
|
function insertBorder(type)/*{{{*/
|
|
{
|
|
var jq = $('<div />')
|
|
.css({position: 'absolute', opacity: options.borderOpacity })
|
|
.addClass(cssClass(type));
|
|
$img_holder.append(jq);
|
|
return jq;
|
|
};
|
|
/*}}}*/
|
|
function dragDiv(ord,zi)/*{{{*/
|
|
{
|
|
var jq = $('<div />')
|
|
.mousedown(createDragger(ord))
|
|
.css({
|
|
cursor: ord+'-resize',
|
|
position: 'absolute',
|
|
zIndex: zi
|
|
})
|
|
;
|
|
$hdl_holder.append(jq);
|
|
return jq;
|
|
};
|
|
/*}}}*/
|
|
function insertHandle(ord)/*{{{*/
|
|
{
|
|
return dragDiv(ord,hdep++)
|
|
.css({ top: px(-hhs+1), left: px(-hhs+1), opacity: options.handleOpacity })
|
|
.addClass(cssClass('handle'));
|
|
};
|
|
/*}}}*/
|
|
function insertDragbar(ord)/*{{{*/
|
|
{
|
|
var s = options.handleSize,
|
|
o = hhs,
|
|
h = s, w = s,
|
|
t = o, l = o;
|
|
|
|
switch(ord)
|
|
{
|
|
case 'n': case 's': w = pct(100); break;
|
|
case 'e': case 'w': h = pct(100); break;
|
|
}
|
|
|
|
return dragDiv(ord,hdep++).width(w).height(h)
|
|
.css({ top: px(-t+1), left: px(-l+1)});
|
|
};
|
|
/*}}}*/
|
|
function createHandles(li)/*{{{*/
|
|
{
|
|
for(i in li) handle[li[i]] = insertHandle(li[i]);
|
|
};
|
|
/*}}}*/
|
|
function moveHandles(c)/*{{{*/
|
|
{
|
|
var midvert = Math.round((c.h / 2) - hhs),
|
|
midhoriz = Math.round((c.w / 2) - hhs),
|
|
north = west = -hhs+1,
|
|
east = c.w - hhs,
|
|
south = c.h - hhs,
|
|
x, y;
|
|
|
|
'e' in handle &&
|
|
handle.e.css({ top: px(midvert), left: px(east) }) &&
|
|
handle.w.css({ top: px(midvert) }) &&
|
|
handle.s.css({ top: px(south), left: px(midhoriz) }) &&
|
|
handle.n.css({ left: px(midhoriz) });
|
|
|
|
'ne' in handle &&
|
|
handle.ne.css({ left: px(east) }) &&
|
|
handle.se.css({ top: px(south), left: px(east) }) &&
|
|
handle.sw.css({ top: px(south) });
|
|
|
|
'b' in handle &&
|
|
handle.b.css({ top: px(south) }) &&
|
|
handle.r.css({ left: px(east) });
|
|
};
|
|
/*}}}*/
|
|
function moveto(x,y)/*{{{*/
|
|
{
|
|
$img2.css({ top: px(-y), left: px(-x) });
|
|
$sel.css({ top: px(y), left: px(x) });
|
|
};
|
|
/*}}}*/
|
|
function resize(w,h)/*{{{*/
|
|
{
|
|
$sel.width(w).height(h);
|
|
};
|
|
/*}}}*/
|
|
function refresh()/*{{{*/
|
|
{
|
|
var c = Coords.getFixed();
|
|
|
|
Coords.setPressed([c.x,c.y]);
|
|
Coords.setCurrent([c.x2,c.y2]);
|
|
|
|
updateVisible();
|
|
};
|
|
/*}}}*/
|
|
|
|
// Internal Methods
|
|
function updateVisible()/*{{{*/
|
|
{ if (awake) return update(); };
|
|
/*}}}*/
|
|
function update()/*{{{*/
|
|
{
|
|
var c = Coords.getFixed();
|
|
|
|
resize(c.w,c.h);
|
|
moveto(c.x,c.y);
|
|
|
|
options.drawBorders &&
|
|
borders['right'].css({ left: px(c.w-1) }) &&
|
|
borders['bottom'].css({ top: px(c.h-1) });
|
|
|
|
seehandles && moveHandles(c);
|
|
awake || show();
|
|
|
|
options.onChange(unscale(c));
|
|
};
|
|
/*}}}*/
|
|
function show()/*{{{*/
|
|
{
|
|
$sel.show();
|
|
$img.css('opacity',options.bgOpacity);
|
|
awake = true;
|
|
};
|
|
/*}}}*/
|
|
function release()/*{{{*/
|
|
{
|
|
disableHandles();
|
|
$sel.hide();
|
|
$img.css('opacity',1);
|
|
awake = false;
|
|
};
|
|
/*}}}*/
|
|
function showHandles()//{{{
|
|
{
|
|
if (seehandles)
|
|
{
|
|
moveHandles(Coords.getFixed());
|
|
$hdl_holder.show();
|
|
}
|
|
};
|
|
//}}}
|
|
function enableHandles()/*{{{*/
|
|
{
|
|
seehandles = true;
|
|
if (options.allowResize)
|
|
{
|
|
moveHandles(Coords.getFixed());
|
|
$hdl_holder.show();
|
|
return true;
|
|
}
|
|
};
|
|
/*}}}*/
|
|
function disableHandles()/*{{{*/
|
|
{
|
|
seehandles = false;
|
|
$hdl_holder.hide();
|
|
};
|
|
/*}}}*/
|
|
function animMode(v)/*{{{*/
|
|
{
|
|
(animating = v) ? disableHandles(): enableHandles();
|
|
};
|
|
/*}}}*/
|
|
function done()/*{{{*/
|
|
{
|
|
animMode(false);
|
|
refresh();
|
|
};
|
|
/*}}}*/
|
|
|
|
var $track = newTracker().mousedown(createDragger('move'))
|
|
.css({ cursor: 'move', position: 'absolute', zIndex: 360 })
|
|
|
|
$img_holder.append($track);
|
|
disableHandles();
|
|
|
|
return {
|
|
updateVisible: updateVisible,
|
|
update: update,
|
|
release: release,
|
|
refresh: refresh,
|
|
setCursor: function (cursor) { $track.css('cursor',cursor); },
|
|
enableHandles: enableHandles,
|
|
enableOnly: function() { seehandles = true; },
|
|
showHandles: showHandles,
|
|
disableHandles: disableHandles,
|
|
animMode: animMode,
|
|
done: done
|
|
};
|
|
}();
|
|
/*}}}*/
|
|
var Tracker = function()/*{{{*/
|
|
{
|
|
var onMove = function() { },
|
|
onDone = function() { },
|
|
trackDoc = options.trackDocument;
|
|
|
|
if (!trackDoc)
|
|
{
|
|
$trk
|
|
.mousemove(trackMove)
|
|
.mouseup(trackUp)
|
|
.mouseout(trackUp)
|
|
;
|
|
}
|
|
|
|
function toFront()/*{{{*/
|
|
{
|
|
$trk.css({zIndex:450});
|
|
if (trackDoc)
|
|
{
|
|
$(document)
|
|
.mousemove(trackMove)
|
|
.mouseup(trackUp)
|
|
;
|
|
}
|
|
}
|
|
/*}}}*/
|
|
function toBack()/*{{{*/
|
|
{
|
|
$trk.css({zIndex:290});
|
|
if (trackDoc)
|
|
{
|
|
$(document)
|
|
.unbind('mousemove',trackMove)
|
|
.unbind('mouseup',trackUp)
|
|
;
|
|
}
|
|
}
|
|
/*}}}*/
|
|
function trackMove(e)/*{{{*/
|
|
{
|
|
onMove(mouseAbs(e));
|
|
};
|
|
/*}}}*/
|
|
function trackUp(e)/*{{{*/
|
|
{
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
|
|
if (btndown)
|
|
{
|
|
btndown = false;
|
|
|
|
onDone(mouseAbs(e));
|
|
options.onSelect(unscale(Coords.getFixed()));
|
|
toBack();
|
|
onMove = function() { };
|
|
onDone = function() { };
|
|
}
|
|
|
|
return false;
|
|
};
|
|
/*}}}*/
|
|
|
|
function activateHandlers(move,done)/* {{{ */
|
|
{
|
|
btndown = true;
|
|
onMove = move;
|
|
onDone = done;
|
|
toFront();
|
|
return false;
|
|
};
|
|
/* }}} */
|
|
|
|
function setCursor(t) { $trk.css('cursor',t); };
|
|
|
|
$img.before($trk);
|
|
return {
|
|
activateHandlers: activateHandlers,
|
|
setCursor: setCursor
|
|
};
|
|
}();
|
|
/*}}}*/
|
|
var KeyManager = function()/*{{{*/
|
|
{
|
|
var $keymgr = $('<input type="radio" />')
|
|
.css({ position: 'absolute', left: '-30px' })
|
|
.keypress(parseKey)
|
|
.blur(onBlur),
|
|
|
|
$keywrap = $('<div />')
|
|
.css({
|
|
position: 'absolute',
|
|
overflow: 'hidden'
|
|
})
|
|
.append($keymgr)
|
|
;
|
|
|
|
function watchKeys()/*{{{*/
|
|
{
|
|
if (options.keySupport)
|
|
{
|
|
$keymgr.show();
|
|
$keymgr.focus();
|
|
}
|
|
};
|
|
/*}}}*/
|
|
function onBlur(e)/*{{{*/
|
|
{
|
|
$keymgr.hide();
|
|
};
|
|
/*}}}*/
|
|
function doNudge(e,x,y)/*{{{*/
|
|
{
|
|
if (options.allowMove) {
|
|
Coords.moveOffset([x,y]);
|
|
Selection.updateVisible();
|
|
};
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
};
|
|
/*}}}*/
|
|
function parseKey(e)/*{{{*/
|
|
{
|
|
if (e.ctrlKey) return true;
|
|
shift_down = e.shiftKey ? true : false;
|
|
var nudge = shift_down ? 10 : 1;
|
|
switch(e.keyCode)
|
|
{
|
|
case 37: doNudge(e,-nudge,0); break;
|
|
case 39: doNudge(e,nudge,0); break;
|
|
case 38: doNudge(e,0,-nudge); break;
|
|
case 40: doNudge(e,0,nudge); break;
|
|
|
|
case 27: Selection.release(); break;
|
|
|
|
case 9: return true;
|
|
}
|
|
|
|
return nothing(e);
|
|
};
|
|
/*}}}*/
|
|
|
|
if (options.keySupport) $keywrap.insertBefore($img);
|
|
return {
|
|
watchKeys: watchKeys
|
|
};
|
|
}();
|
|
/*}}}*/
|
|
|
|
// }}}
|
|
// Internal Methods {{{
|
|
|
|
function px(n) { return '' + parseInt(n) + 'px'; };
|
|
function pct(n) { return '' + parseInt(n) + '%'; };
|
|
function cssClass(cl) { return options.baseClass + '-' + cl; };
|
|
function getPos(obj)/*{{{*/
|
|
{
|
|
// Updated in v0.9.4 to use built-in dimensions plugin
|
|
var pos = $(obj).offset();
|
|
return [ pos.left, pos.top ];
|
|
};
|
|
/*}}}*/
|
|
function mouseAbs(e)/*{{{*/
|
|
{
|
|
return [ (e.pageX - docOffset[0]), (e.pageY - docOffset[1]) ];
|
|
};
|
|
/*}}}*/
|
|
function myCursor(type)/*{{{*/
|
|
{
|
|
if (type != lastcurs)
|
|
{
|
|
Tracker.setCursor(type);
|
|
//Handles.xsetCursor(type);
|
|
lastcurs = type;
|
|
}
|
|
};
|
|
/*}}}*/
|
|
function startDragMode(mode,pos)/*{{{*/
|
|
{
|
|
docOffset = getPos($img);
|
|
Tracker.setCursor(mode=='move'?mode:mode+'-resize');
|
|
|
|
if (mode == 'move')
|
|
return Tracker.activateHandlers(createMover(pos), doneSelect);
|
|
|
|
var fc = Coords.getFixed();
|
|
var opp = oppLockCorner(mode);
|
|
var opc = Coords.getCorner(oppLockCorner(opp));
|
|
|
|
Coords.setPressed(Coords.getCorner(opp));
|
|
Coords.setCurrent(opc);
|
|
|
|
Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);
|
|
};
|
|
/*}}}*/
|
|
function dragmodeHandler(mode,f)/*{{{*/
|
|
{
|
|
return function(pos) {
|
|
if (!options.aspectRatio) switch(mode)
|
|
{
|
|
case 'e': pos[1] = f.y2; break;
|
|
case 'w': pos[1] = f.y2; break;
|
|
case 'n': pos[0] = f.x2; break;
|
|
case 's': pos[0] = f.x2; break;
|
|
}
|
|
else switch(mode)
|
|
{
|
|
case 'e': pos[1] = f.y+1; break;
|
|
case 'w': pos[1] = f.y+1; break;
|
|
case 'n': pos[0] = f.x+1; break;
|
|
case 's': pos[0] = f.x+1; break;
|
|
}
|
|
Coords.setCurrent(pos);
|
|
Selection.update();
|
|
};
|
|
};
|
|
/*}}}*/
|
|
function createMover(pos)/*{{{*/
|
|
{
|
|
var lloc = pos;
|
|
KeyManager.watchKeys();
|
|
|
|
return function(pos)
|
|
{
|
|
Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
|
|
lloc = pos;
|
|
|
|
Selection.update();
|
|
};
|
|
};
|
|
/*}}}*/
|
|
function oppLockCorner(ord)/*{{{*/
|
|
{
|
|
switch(ord)
|
|
{
|
|
case 'n': return 'sw';
|
|
case 's': return 'nw';
|
|
case 'e': return 'nw';
|
|
case 'w': return 'ne';
|
|
case 'ne': return 'sw';
|
|
case 'nw': return 'se';
|
|
case 'se': return 'nw';
|
|
case 'sw': return 'ne';
|
|
};
|
|
};
|
|
/*}}}*/
|
|
function createDragger(ord)/*{{{*/
|
|
{
|
|
return function(e) {
|
|
if (options.disabled) return false;
|
|
if ((ord == 'move') && !options.allowMove) return false;
|
|
btndown = true;
|
|
startDragMode(ord,mouseAbs(e));
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
return false;
|
|
};
|
|
};
|
|
/*}}}*/
|
|
function presize($obj,w,h)/*{{{*/
|
|
{
|
|
var nw = $obj.width(), nh = $obj.height();
|
|
if ((nw > w) && w > 0)
|
|
{
|
|
nw = w;
|
|
nh = (w/$obj.width()) * $obj.height();
|
|
}
|
|
if ((nh > h) && h > 0)
|
|
{
|
|
nh = h;
|
|
nw = (h/$obj.height()) * $obj.width();
|
|
}
|
|
xscale = $obj.width() / nw;
|
|
yscale = $obj.height() / nh;
|
|
$obj.width(nw).height(nh);
|
|
};
|
|
/*}}}*/
|
|
function unscale(c)/*{{{*/
|
|
{
|
|
return {
|
|
x: parseInt(c.x * xscale), y: parseInt(c.y * yscale),
|
|
x2: parseInt(c.x2 * xscale), y2: parseInt(c.y2 * yscale),
|
|
w: parseInt(c.w * xscale), h: parseInt(c.h * yscale)
|
|
};
|
|
};
|
|
/*}}}*/
|
|
function doneSelect(pos)/*{{{*/
|
|
{
|
|
var c = Coords.getFixed();
|
|
if (c.w > options.minSelect[0] && c.h > options.minSelect[1])
|
|
{
|
|
Selection.enableHandles();
|
|
Selection.done();
|
|
}
|
|
else
|
|
{
|
|
Selection.release();
|
|
}
|
|
Tracker.setCursor( options.allowSelect?'crosshair':'default' );
|
|
};
|
|
/*}}}*/
|
|
function newSelection(e)/*{{{*/
|
|
{
|
|
if (options.disabled) return false;
|
|
if (!options.allowSelect) return false;
|
|
btndown = true;
|
|
docOffset = getPos($img);
|
|
Selection.disableHandles();
|
|
myCursor('crosshair');
|
|
var pos = mouseAbs(e);
|
|
Coords.setPressed(pos);
|
|
Tracker.activateHandlers(selectDrag,doneSelect);
|
|
KeyManager.watchKeys();
|
|
Selection.update();
|
|
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
return false;
|
|
};
|
|
/*}}}*/
|
|
function selectDrag(pos)/*{{{*/
|
|
{
|
|
Coords.setCurrent(pos);
|
|
Selection.update();
|
|
};
|
|
/*}}}*/
|
|
function newTracker()
|
|
{
|
|
var trk = $('<div></div>').addClass(cssClass('tracker'));
|
|
$.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' });
|
|
return trk;
|
|
};
|
|
|
|
// }}}
|
|
// API methods {{{
|
|
|
|
function animateTo(a)/*{{{*/
|
|
{
|
|
var x1 = a[0] / xscale,
|
|
y1 = a[1] / yscale,
|
|
x2 = a[2] / xscale,
|
|
y2 = a[3] / yscale;
|
|
|
|
if (animating) return;
|
|
|
|
var animto = Coords.flipCoords(x1,y1,x2,y2);
|
|
var c = Coords.getFixed();
|
|
var animat = initcr = [ c.x, c.y, c.x2, c.y2 ];
|
|
var interv = options.animationDelay;
|
|
|
|
var x = animat[0];
|
|
var y = animat[1];
|
|
var x2 = animat[2];
|
|
var y2 = animat[3];
|
|
var ix1 = animto[0] - initcr[0];
|
|
var iy1 = animto[1] - initcr[1];
|
|
var ix2 = animto[2] - initcr[2];
|
|
var iy2 = animto[3] - initcr[3];
|
|
var pcent = 0;
|
|
var velocity = options.swingSpeed;
|
|
|
|
Selection.animMode(true);
|
|
|
|
var animator = function()
|
|
{
|
|
return function()
|
|
{
|
|
pcent += (100 - pcent) / velocity;
|
|
|
|
animat[0] = x + ((pcent / 100) * ix1);
|
|
animat[1] = y + ((pcent / 100) * iy1);
|
|
animat[2] = x2 + ((pcent / 100) * ix2);
|
|
animat[3] = y2 + ((pcent / 100) * iy2);
|
|
|
|
if (pcent < 100) animateStart();
|
|
else Selection.done();
|
|
|
|
if (pcent >= 99.8) pcent = 100;
|
|
|
|
setSelectRaw(animat);
|
|
};
|
|
}();
|
|
|
|
function animateStart()
|
|
{ window.setTimeout(animator,interv); };
|
|
|
|
animateStart();
|
|
};
|
|
/*}}}*/
|
|
function setSelect(rect)//{{{
|
|
{
|
|
setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);
|
|
};
|
|
//}}}
|
|
function setSelectRaw(l) /*{{{*/
|
|
{
|
|
Coords.setPressed([l[0],l[1]]);
|
|
Coords.setCurrent([l[2],l[3]]);
|
|
Selection.update();
|
|
};
|
|
/*}}}*/
|
|
function setOptions(opt)/*{{{*/
|
|
{
|
|
if (typeof(opt) != 'object') opt = { };
|
|
options = $.extend(options,opt);
|
|
|
|
if (typeof(options.onChange)!=='function')
|
|
options.onChange = function() { };
|
|
|
|
if (typeof(options.onSelect)!=='function')
|
|
options.onSelect = function() { };
|
|
|
|
};
|
|
/*}}}*/
|
|
function tellSelect()/*{{{*/
|
|
{
|
|
return unscale(Coords.getFixed());
|
|
};
|
|
/*}}}*/
|
|
function tellScaled()/*{{{*/
|
|
{
|
|
return Coords.getFixed();
|
|
};
|
|
/*}}}*/
|
|
function setOptionsNew(opt)/*{{{*/
|
|
{
|
|
setOptions(opt);
|
|
interfaceUpdate();
|
|
};
|
|
/*}}}*/
|
|
function disableCrop()//{{{
|
|
{
|
|
options.disabled = true;
|
|
Selection.disableHandles();
|
|
Selection.setCursor('default');
|
|
Tracker.setCursor('default');
|
|
};
|
|
//}}}
|
|
function enableCrop()//{{{
|
|
{
|
|
options.disabled = false;
|
|
interfaceUpdate();
|
|
};
|
|
//}}}
|
|
function cancelCrop()//{{{
|
|
{
|
|
Selection.done();
|
|
Tracker.activateHandlers(null,null);
|
|
};
|
|
//}}}
|
|
function destroy()//{{{
|
|
{
|
|
$div.remove();
|
|
$origimg.show();
|
|
};
|
|
//}}}
|
|
|
|
function interfaceUpdate(alt)//{{{
|
|
// This method tweaks the interface based on options object.
|
|
// Called when options are changed and at end of initialization.
|
|
{
|
|
options.allowResize ?
|
|
alt?Selection.enableOnly():Selection.enableHandles():
|
|
Selection.disableHandles();
|
|
|
|
Tracker.setCursor( options.allowSelect? 'crosshair': 'default' );
|
|
Selection.setCursor( options.allowMove? 'move': 'default' );
|
|
|
|
$div.css('backgroundColor',options.bgColor);
|
|
|
|
if ('setSelect' in options) {
|
|
setSelect(opt.setSelect);
|
|
Selection.done();
|
|
delete(options.setSelect);
|
|
}
|
|
|
|
if ('trueSize' in options) {
|
|
xscale = options.trueSize[0] / boundx;
|
|
yscale = options.trueSize[1] / boundy;
|
|
}
|
|
|
|
xlimit = options.maxSize[0] || 0;
|
|
ylimit = options.maxSize[1] || 0;
|
|
xmin = options.minSize[0] || 0;
|
|
ymin = options.minSize[1] || 0;
|
|
|
|
if ('outerImage' in options)
|
|
{
|
|
$img.attr('src',options.outerImage);
|
|
delete(options.outerImage);
|
|
}
|
|
|
|
Selection.refresh();
|
|
};
|
|
//}}}
|
|
|
|
// }}}
|
|
|
|
$hdl_holder.hide();
|
|
interfaceUpdate(true);
|
|
|
|
var api = {
|
|
animateTo: animateTo,
|
|
setSelect: setSelect,
|
|
setOptions: setOptionsNew,
|
|
tellSelect: tellSelect,
|
|
tellScaled: tellScaled,
|
|
|
|
disable: disableCrop,
|
|
enable: enableCrop,
|
|
cancel: cancelCrop,
|
|
|
|
focus: KeyManager.watchKeys,
|
|
|
|
getBounds: function() { return [ boundx * xscale, boundy * yscale ]; },
|
|
getWidgetSize: function() { return [ boundx, boundy ]; },
|
|
|
|
release: Selection.release,
|
|
destroy: destroy
|
|
|
|
};
|
|
|
|
$origimg.data('Jcrop',api);
|
|
return api;
|
|
};
|
|
|
|
$.fn.Jcrop = function(options)/*{{{*/
|
|
{
|
|
function attachWhenDone(from)/*{{{*/
|
|
{
|
|
var loadsrc = options.useImg || from.src;
|
|
var img = new Image();
|
|
img.onload = function() { $.Jcrop(from,options); };
|
|
img.src = loadsrc;
|
|
};
|
|
/*}}}*/
|
|
if (typeof(options) !== 'object') options = { };
|
|
|
|
// Iterate over each object, attach Jcrop
|
|
this.each(function()
|
|
{
|
|
// If we've already attached to this object
|
|
if ($(this).data('Jcrop'))
|
|
{
|
|
// The API can be requested this way (undocumented)
|
|
if (options == 'api') return $(this).data('Jcrop');
|
|
// Otherwise, we just reset the options...
|
|
else $(this).data('Jcrop').setOptions(options);
|
|
}
|
|
// If we haven't been attached, preload and attach
|
|
else attachWhenDone(this);
|
|
});
|
|
|
|
// Return "this" so we're chainable a la jQuery plugin-style!
|
|
return this;
|
|
};
|
|
/*}}}*/
|
|
|
|
})(jQuery);</value>
|
|
</data>
|
|
<data name="json2Script" xml:space="preserve">
|
|
<value>/*
|
|
http://www.JSON.org/json2.js
|
|
2008-11-19
|
|
|
|
Public Domain.
|
|
|
|
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
|
|
|
See http://www.JSON.org/js.html
|
|
|
|
This file creates a global JSON object containing two methods: stringify
|
|
and parse.
|
|
|
|
JSON.stringify(value, replacer, space)
|
|
value any JavaScript value, usually an object or array.
|
|
|
|
replacer an optional parameter that determines how object
|
|
values are stringified for objects. It can be a
|
|
function or an array of strings.
|
|
|
|
space an optional parameter that specifies the indentation
|
|
of nested structures. If it is omitted, the text will
|
|
be packed without extra whitespace. If it is a number,
|
|
it will specify the number of spaces to indent at each
|
|
level. If it is a string (such as '\t' or '&nbsp;'),
|
|
it contains the characters used to indent at each level.
|
|
|
|
This method produces a JSON text from a JavaScript value.
|
|
|
|
When an object value is found, if the object contains a toJSON
|
|
method, its toJSON method will be called and the result will be
|
|
stringified. A toJSON method does not serialize: it returns the
|
|
value represented by the name/value pair that should be serialized,
|
|
or undefined if nothing should be serialized. The toJSON method
|
|
will be passed the key associated with the value, and this will be
|
|
bound to the object holding the key.
|
|
|
|
For example, this would serialize Dates as ISO strings.
|
|
|
|
Date.prototype.toJSON = function (key) {
|
|
function f(n) {
|
|
// Format integers to have at least two digits.
|
|
return n < 10 ? '0' + n : n;
|
|
}
|
|
|
|
return this.getUTCFullYear() + '-' +
|
|
f(this.getUTCMonth() + 1) + '-' +
|
|
f(this.getUTCDate()) + 'T' +
|
|
f(this.getUTCHours()) + ':' +
|
|
f(this.getUTCMinutes()) + ':' +
|
|
f(this.getUTCSeconds()) + 'Z';
|
|
};
|
|
|
|
You can provide an optional replacer method. It will be passed the
|
|
key and value of each member, with this bound to the containing
|
|
object. The value that is returned from your method will be
|
|
serialized. If your method returns undefined, then the member will
|
|
be excluded from the serialization.
|
|
|
|
If the replacer parameter is an array of strings, then it will be
|
|
used to select the members to be serialized. It filters the results
|
|
such that only members with keys listed in the replacer array are
|
|
stringified.
|
|
|
|
Values that do not have JSON representations, such as undefined or
|
|
functions, will not be serialized. Such values in objects will be
|
|
dropped; in arrays they will be replaced with null. You can use
|
|
a replacer function to replace those with JSON values.
|
|
JSON.stringify(undefined) returns undefined.
|
|
|
|
The optional space parameter produces a stringification of the
|
|
value that is filled with line breaks and indentation to make it
|
|
easier to read.
|
|
|
|
If the space parameter is a non-empty string, then that string will
|
|
be used for indentation. If the space parameter is a number, then
|
|
the indentation will be that many spaces.
|
|
|
|
Example:
|
|
|
|
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
|
// text is '["e",{"pluribus":"unum"}]'
|
|
|
|
|
|
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
|
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
|
|
|
text = JSON.stringify([new Date()], function (key, value) {
|
|
return this[key] instanceof Date ?
|
|
'Date(' + this[key] + ')' : value;
|
|
});
|
|
// text is '["Date(---current time---)"]'
|
|
|
|
|
|
JSON.parse(text, reviver)
|
|
This method parses a JSON text to produce an object or array.
|
|
It can throw a SyntaxError exception.
|
|
|
|
The optional reviver parameter is a function that can filter and
|
|
transform the results. It receives each of the keys and values,
|
|
and its return value is used instead of the original value.
|
|
If it returns what it received, then the structure is not modified.
|
|
If it returns undefined then the member is deleted.
|
|
|
|
Example:
|
|
|
|
// Parse the text. Values that look like ISO date strings will
|
|
// be converted to Date objects.
|
|
|
|
myData = JSON.parse(text, function (key, value) {
|
|
var a;
|
|
if (typeof value === 'string') {
|
|
a =
|
|
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
|
if (a) {
|
|
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
|
+a[5], +a[6]));
|
|
}
|
|
}
|
|
return value;
|
|
});
|
|
|
|
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
|
var d;
|
|
if (typeof value === 'string' &&
|
|
value.slice(0, 5) === 'Date(' &&
|
|
value.slice(-1) === ')') {
|
|
d = new Date(value.slice(5, -1));
|
|
if (d) {
|
|
return d;
|
|
}
|
|
}
|
|
return value;
|
|
});
|
|
|
|
|
|
This is a reference implementation. You are free to copy, modify, or
|
|
redistribute.
|
|
|
|
This code should be minified before deployment.
|
|
See http://javascript.crockford.com/jsmin.html
|
|
|
|
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
|
NOT CONTROL.
|
|
*/
|
|
|
|
/*jslint evil: true */
|
|
|
|
/*global JSON */
|
|
|
|
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
|
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
|
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
|
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
|
test, toJSON, toString, valueOf
|
|
*/
|
|
|
|
// Create a JSON object only if one does not already exist. We create the
|
|
// methods in a closure to avoid creating global variables.
|
|
|
|
if (!this.JSON) {
|
|
JSON = {};
|
|
}
|
|
(function () {
|
|
|
|
function f(n) {
|
|
// Format integers to have at least two digits.
|
|
return n < 10 ? '0' + n : n;
|
|
}
|
|
|
|
if (typeof Date.prototype.toJSON !== 'function') {
|
|
|
|
Date.prototype.toJSON = function (key) {
|
|
|
|
return this.getUTCFullYear() + '-' +
|
|
f(this.getUTCMonth() + 1) + '-' +
|
|
f(this.getUTCDate()) + 'T' +
|
|
f(this.getUTCHours()) + ':' +
|
|
f(this.getUTCMinutes()) + ':' +
|
|
f(this.getUTCSeconds()) + 'Z';
|
|
};
|
|
|
|
String.prototype.toJSON =
|
|
Number.prototype.toJSON =
|
|
Boolean.prototype.toJSON = function (key) {
|
|
return this.valueOf();
|
|
};
|
|
}
|
|
|
|
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
|
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
|
gap,
|
|
indent,
|
|
meta = { // table of character substitutions
|
|
'\b': '\\b',
|
|
'\t': '\\t',
|
|
'\n': '\\n',
|
|
'\f': '\\f',
|
|
'\r': '\\r',
|
|
'"' : '\\"',
|
|
'\\': '\\\\'
|
|
},
|
|
rep;
|
|
|
|
|
|
function quote(string) {
|
|
|
|
// If the string contains no control characters, no quote characters, and no
|
|
// backslash characters, then we can safely slap some quotes around it.
|
|
// Otherwise we must also replace the offending characters with safe escape
|
|
// sequences.
|
|
|
|
escapable.lastIndex = 0;
|
|
return escapable.test(string) ?
|
|
'"' + string.replace(escapable, function (a) {
|
|
var c = meta[a];
|
|
return typeof c === 'string' ? c :
|
|
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
|
}) + '"' :
|
|
'"' + string + '"';
|
|
}
|
|
|
|
|
|
function str(key, holder) {
|
|
|
|
// Produce a string from holder[key].
|
|
|
|
var i, // The loop counter.
|
|
k, // The member key.
|
|
v, // The member value.
|
|
length,
|
|
mind = gap,
|
|
partial,
|
|
value = holder[key];
|
|
|
|
// If the value has a toJSON method, call it to obtain a replacement value.
|
|
|
|
if (value && typeof value === 'object' &&
|
|
typeof value.toJSON === 'function') {
|
|
value = value.toJSON(key);
|
|
}
|
|
|
|
// If we were called with a replacer function, then call the replacer to
|
|
// obtain a replacement value.
|
|
|
|
if (typeof rep === 'function') {
|
|
value = rep.call(holder, key, value);
|
|
}
|
|
|
|
// What happens next depends on the value's type.
|
|
|
|
switch (typeof value) {
|
|
case 'string':
|
|
return quote(value);
|
|
|
|
case 'number':
|
|
|
|
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
|
|
return isFinite(value) ? String(value) : 'null';
|
|
|
|
case 'boolean':
|
|
case 'null':
|
|
|
|
// If the value is a boolean or null, convert it to a string. Note:
|
|
// typeof null does not produce 'null'. The case is included here in
|
|
// the remote chance that this gets fixed someday.
|
|
|
|
return String(value);
|
|
|
|
// If the type is 'object', we might be dealing with an object or an array or
|
|
// null.
|
|
|
|
case 'object':
|
|
|
|
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
|
// so watch out for that case.
|
|
|
|
if (!value) {
|
|
return 'null';
|
|
}
|
|
|
|
// Make an array to hold the partial results of stringifying this object value.
|
|
|
|
gap += indent;
|
|
partial = [];
|
|
|
|
// Is the value an array?
|
|
|
|
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
|
|
|
// The value is an array. Stringify every element. Use null as a placeholder
|
|
// for non-JSON values.
|
|
|
|
length = value.length;
|
|
for (i = 0; i < length; i += 1) {
|
|
partial[i] = str(i, value) || 'null';
|
|
}
|
|
|
|
// Join all of the elements together, separated with commas, and wrap them in
|
|
// brackets.
|
|
|
|
v = partial.length === 0 ? '[]' :
|
|
gap ? '[\n' + gap +
|
|
partial.join(',\n' + gap) + '\n' +
|
|
mind + ']' :
|
|
'[' + partial.join(',') + ']';
|
|
gap = mind;
|
|
return v;
|
|
}
|
|
|
|
// If the replacer is an array, use it to select the members to be stringified.
|
|
|
|
if (rep && typeof rep === 'object') {
|
|
length = rep.length;
|
|
for (i = 0; i < length; i += 1) {
|
|
k = rep[i];
|
|
if (typeof k === 'string') {
|
|
v = str(k, value);
|
|
if (v) {
|
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
|
|
// Otherwise, iterate through all of the keys in the object.
|
|
|
|
for (k in value) {
|
|
if (Object.hasOwnProperty.call(value, k)) {
|
|
v = str(k, value);
|
|
if (v) {
|
|
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Join all of the member texts together, separated with commas,
|
|
// and wrap them in braces.
|
|
|
|
v = partial.length === 0 ? '{}' :
|
|
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
|
|
mind + '}' : '{' + partial.join(',') + '}';
|
|
gap = mind;
|
|
return v;
|
|
}
|
|
}
|
|
|
|
// If the JSON object does not yet have a stringify method, give it one.
|
|
|
|
if (typeof JSON.stringify !== 'function') {
|
|
JSON.stringify = function (value, replacer, space) {
|
|
|
|
// The stringify method takes a value and an optional replacer, and an optional
|
|
// space parameter, and returns a JSON text. The replacer can be a function
|
|
// that can replace values, or an array of strings that will select the keys.
|
|
// A default replacer method can be provided. Use of the space parameter can
|
|
// produce text that is more easily readable.
|
|
|
|
var i;
|
|
gap = '';
|
|
indent = '';
|
|
|
|
// If the space parameter is a number, make an indent string containing that
|
|
// many spaces.
|
|
|
|
if (typeof space === 'number') {
|
|
for (i = 0; i < space; i += 1) {
|
|
indent += ' ';
|
|
}
|
|
|
|
// If the space parameter is a string, it will be used as the indent string.
|
|
|
|
} else if (typeof space === 'string') {
|
|
indent = space;
|
|
}
|
|
|
|
// If there is a replacer, it must be a function or an array.
|
|
// Otherwise, throw an error.
|
|
|
|
rep = replacer;
|
|
if (replacer && typeof replacer !== 'function' &&
|
|
(typeof replacer !== 'object' ||
|
|
typeof replacer.length !== 'number')) {
|
|
throw new Error('JSON.stringify');
|
|
}
|
|
|
|
// Make a fake root object containing our value under the key of ''.
|
|
// Return the result of stringifying the value.
|
|
|
|
return str('', {'': value});
|
|
};
|
|
}
|
|
|
|
|
|
// If the JSON object does not yet have a parse method, give it one.
|
|
|
|
if (typeof JSON.parse !== 'function') {
|
|
JSON.parse = function (text, reviver) {
|
|
|
|
// The parse method takes a text and an optional reviver function, and returns
|
|
// a JavaScript value if the text is a valid JSON text.
|
|
|
|
var j;
|
|
|
|
function walk(holder, key) {
|
|
|
|
// The walk method is used to recursively walk the resulting structure so
|
|
// that modifications can be made.
|
|
|
|
var k, v, value = holder[key];
|
|
if (value && typeof value === 'object') {
|
|
for (k in value) {
|
|
if (Object.hasOwnProperty.call(value, k)) {
|
|
v = walk(value, k);
|
|
if (v !== undefined) {
|
|
value[k] = v;
|
|
} else {
|
|
delete value[k];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return reviver.call(holder, key, value);
|
|
}
|
|
|
|
|
|
// Parsing happens in four stages. In the first stage, we replace certain
|
|
// Unicode characters with escape sequences. JavaScript handles many characters
|
|
// incorrectly, either silently deleting them, or treating them as line endings.
|
|
|
|
cx.lastIndex = 0;
|
|
if (cx.test(text)) {
|
|
text = text.replace(cx, function (a) {
|
|
return '\\u' +
|
|
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
|
});
|
|
}
|
|
|
|
// In the second stage, we run the text against regular expressions that look
|
|
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
|
// because they can cause invocation, and '=' because it can cause mutation.
|
|
// But just to be safe, we want to reject all unexpected forms.
|
|
|
|
// We split the second stage into 4 regexp operations in order to work around
|
|
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
|
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
|
// replace all simple value tokens with ']' characters. Third, we delete all
|
|
// open brackets that follow a colon or comma or that begin the text. Finally,
|
|
// we look to see that the remaining characters are only whitespace or ']' or
|
|
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
|
|
|
if (/^[\],:{}\s]*$/.
|
|
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
|
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
|
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
|
|
|
// In the third stage we use the eval function to compile the text into a
|
|
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
|
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
|
// in parens to eliminate the ambiguity.
|
|
|
|
j = eval('(' + text + ')');
|
|
|
|
// In the optional fourth stage, we recursively walk the new structure, passing
|
|
// each name/value pair to a reviver function for possible transformation.
|
|
|
|
return typeof reviver === 'function' ?
|
|
walk({'': j}, '') : j;
|
|
}
|
|
|
|
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
|
|
|
throw new SyntaxError('JSON.parse');
|
|
};
|
|
}
|
|
})();</value>
|
|
</data>
|
|
</root> |