- Linting: ESLint (or ignore) JavaScript files; unfinished: editor/jgraduate and editor/extensions folders, editor/ (root), test/ (root) HTML
- Fix: An apparent bug in jquery.svgicons.js whereby a variable `holder` was declared in too nested of a scope - Fix: `addBezierCurve` in canvg.js had undeclared `i` - Fix: Undeclared variable in opera widget - Fix: Screencast `showNotes`
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
editor/jspdf/jspdf.min.js
|
editor/jspdf/jspdf.min.js
|
||||||
editor/jspdf/underscore-min.js
|
editor/jspdf/underscore-min.js
|
||||||
|
jgraduate/jpicker.min.js
|
||||||
|
jgraduate/jquery.jgraduate.js
|
||||||
|
jquery-ui
|
||||||
|
jquerybbq
|
||||||
|
js-hotkeys
|
||||||
|
spinbtn/JQuerySpinBtn.min.js
|
||||||
|
test/qunit
|
||||||
|
test/sinon
|
||||||
|
wave/json2.js
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,25 @@
|
|||||||
/*jslint vars: true*/
|
/* eslint-disable no-var */
|
||||||
/**
|
/**
|
||||||
* A class to parse color values
|
* A class to parse color values
|
||||||
* @author Stoyan Stefanov <sstoo@gmail.com>
|
* @author Stoyan Stefanov <sstoo@gmail.com>
|
||||||
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
||||||
* @license Use it if you like it
|
* @license Use it if you like it
|
||||||
*/
|
*/
|
||||||
function RGBColor(color_string) { 'use strict';
|
function RGBColor (colorString) { // eslint-disable-line no-unused-vars
|
||||||
|
'use strict';
|
||||||
this.ok = false;
|
this.ok = false;
|
||||||
|
|
||||||
// strip any leading #
|
// strip any leading #
|
||||||
if (color_string.charAt(0) === '#') { // remove # if any
|
if (colorString.charAt(0) === '#') { // remove # if any
|
||||||
color_string = color_string.substr(1,6);
|
colorString = colorString.substr(1, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_string = color_string.replace(/ /g,'');
|
colorString = colorString.replace(/ /g, '');
|
||||||
color_string = color_string.toLowerCase();
|
colorString = colorString.toLowerCase();
|
||||||
|
|
||||||
// before getting into regexps, try simple matches
|
// before getting into regexps, try simple matches
|
||||||
// and overwrite the input
|
// and overwrite the input
|
||||||
var simple_colors = {
|
var simpleColors = {
|
||||||
aliceblue: 'f0f8ff',
|
aliceblue: 'f0f8ff',
|
||||||
antiquewhite: 'faebd7',
|
antiquewhite: 'faebd7',
|
||||||
aqua: '00ffff',
|
aqua: '00ffff',
|
||||||
@@ -164,17 +165,17 @@ function RGBColor(color_string) { 'use strict';
|
|||||||
yellowgreen: '9acd32'
|
yellowgreen: '9acd32'
|
||||||
};
|
};
|
||||||
var key;
|
var key;
|
||||||
for (key in simple_colors) {
|
for (key in simpleColors) {
|
||||||
if (simple_colors.hasOwnProperty(key)) {
|
if (simpleColors.hasOwnProperty(key)) {
|
||||||
if (color_string == key) {
|
if (colorString === key) {
|
||||||
color_string = simple_colors[key];
|
colorString = simpleColors[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// emd of simple type-in colors
|
// emd of simple type-in colors
|
||||||
|
|
||||||
// array of color definition objects
|
// array of color definition objects
|
||||||
var color_defs = [
|
var colorDefs = [
|
||||||
{
|
{
|
||||||
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
|
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
|
||||||
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
|
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
|
||||||
@@ -212,10 +213,10 @@ function RGBColor(color_string) { 'use strict';
|
|||||||
|
|
||||||
var i;
|
var i;
|
||||||
// search through the definitions to find a match
|
// search through the definitions to find a match
|
||||||
for (i = 0; i < color_defs.length; i++) {
|
for (i = 0; i < colorDefs.length; i++) {
|
||||||
var re = color_defs[i].re;
|
var re = colorDefs[i].re;
|
||||||
var processor = color_defs[i].process;
|
var processor = colorDefs[i].process;
|
||||||
var bits = re.exec(color_string);
|
var bits = re.exec(colorString);
|
||||||
if (bits) {
|
if (bits) {
|
||||||
var channels = processor(bits);
|
var channels = processor(bits);
|
||||||
this.r = channels[0];
|
this.r = channels[0];
|
||||||
@@ -223,7 +224,6 @@ function RGBColor(color_string) { 'use strict';
|
|||||||
this.b = channels[2];
|
this.b = channels[2];
|
||||||
this.ok = true;
|
this.ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate/cleanup values
|
// validate/cleanup values
|
||||||
@@ -250,16 +250,16 @@ function RGBColor(color_string) { 'use strict';
|
|||||||
var i, j;
|
var i, j;
|
||||||
var examples = [];
|
var examples = [];
|
||||||
// add regexps
|
// add regexps
|
||||||
for (i = 0; i < color_defs.length; i++) {
|
for (i = 0; i < colorDefs.length; i++) {
|
||||||
var example = color_defs[i].example;
|
var example = colorDefs[i].example;
|
||||||
for (j = 0; j < example.length; j++) {
|
for (j = 0; j < example.length; j++) {
|
||||||
examples[examples.length] = example[j];
|
examples[examples.length] = example[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add type-in colors
|
// add type-in colors
|
||||||
var sc;
|
var sc;
|
||||||
for (sc in simple_colors) {
|
for (sc in simpleColors) {
|
||||||
if (simple_colors.hasOwnProperty(sc)) {
|
if (simpleColors.hasOwnProperty(sc)) {
|
||||||
examples[examples.length] = sc;
|
examples[examples.length] = sc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,27 +268,24 @@ function RGBColor(color_string) { 'use strict';
|
|||||||
xml.setAttribute('id', 'rgbcolor-examples');
|
xml.setAttribute('id', 'rgbcolor-examples');
|
||||||
for (i = 0; i < examples.length; i++) {
|
for (i = 0; i < examples.length; i++) {
|
||||||
try {
|
try {
|
||||||
var list_item = document.createElement('li');
|
var listItem = document.createElement('li');
|
||||||
var list_color = new RGBColor(examples[i]);
|
var listColor = new RGBColor(examples[i]);
|
||||||
var example_div = document.createElement('div');
|
var exampleDiv = document.createElement('div');
|
||||||
example_div.style.cssText =
|
exampleDiv.style.cssText =
|
||||||
'margin: 3px; '
|
'margin: 3px; ' +
|
||||||
+ 'border: 1px solid black; '
|
'border: 1px solid black; ' +
|
||||||
+ 'background:' + list_color.toHex() + '; '
|
'background:' + listColor.toHex() + '; ' +
|
||||||
+ 'color:' + list_color.toHex()
|
'color:' + listColor.toHex()
|
||||||
;
|
;
|
||||||
example_div.appendChild(document.createTextNode('test'));
|
exampleDiv.appendChild(document.createTextNode('test'));
|
||||||
var list_item_value = document.createTextNode(
|
var listItemValue = document.createTextNode(
|
||||||
' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
|
' ' + examples[i] + ' -> ' + listColor.toRGB() + ' -> ' + listColor.toHex()
|
||||||
);
|
);
|
||||||
list_item.appendChild(example_div);
|
listItem.appendChild(exampleDiv);
|
||||||
list_item.appendChild(list_item_value);
|
listItem.appendChild(listItemValue);
|
||||||
xml.appendChild(list_item);
|
xml.appendChild(listItem);
|
||||||
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
return xml;
|
return xml;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
|
/* globals jQuery, $, svgedit */
|
||||||
// jQuery Context Menu Plugin
|
// jQuery Context Menu Plugin
|
||||||
//
|
//
|
||||||
// Version 1.01
|
// Version 1.01
|
||||||
@@ -13,7 +15,8 @@
|
|||||||
// This plugin is dual-licensed under the GNU General Public License
|
// This plugin is dual-licensed under the GNU General Public License
|
||||||
// and the MIT License and is copyright A Beautiful Site, LLC.
|
// and the MIT License and is copyright A Beautiful Site, LLC.
|
||||||
//
|
//
|
||||||
if(jQuery)( function() {
|
if (jQuery) {
|
||||||
|
(function () {
|
||||||
var win = $(window);
|
var win = $(window);
|
||||||
var doc = $(document);
|
var doc = $(document);
|
||||||
|
|
||||||
@@ -21,12 +24,12 @@ if(jQuery)( function() {
|
|||||||
|
|
||||||
contextMenu: function (o, callback) {
|
contextMenu: function (o, callback) {
|
||||||
// Defaults
|
// Defaults
|
||||||
if( o.menu == undefined ) return false;
|
if (o.menu === undefined) return false;
|
||||||
if( o.inSpeed == undefined ) o.inSpeed = 150;
|
if (o.inSpeed === undefined) o.inSpeed = 150;
|
||||||
if( o.outSpeed == undefined ) o.outSpeed = 75;
|
if (o.outSpeed === undefined) o.outSpeed = 75;
|
||||||
// 0 needs to be -1 for expected results (no fade)
|
// 0 needs to be -1 for expected results (no fade)
|
||||||
if( o.inSpeed == 0 ) o.inSpeed = -1;
|
if (o.inSpeed === 0) o.inSpeed = -1;
|
||||||
if( o.outSpeed == 0 ) o.outSpeed = -1;
|
if (o.outSpeed === 0) o.outSpeed = -1;
|
||||||
// Loop each context menu
|
// Loop each context menu
|
||||||
$(this).each(function () {
|
$(this).each(function () {
|
||||||
var el = $(this);
|
var el = $(this);
|
||||||
@@ -37,27 +40,28 @@ if(jQuery)( function() {
|
|||||||
// Add contextMenu class
|
// Add contextMenu class
|
||||||
menu.addClass('contextMenu');
|
menu.addClass('contextMenu');
|
||||||
// Simulate a true right click
|
// Simulate a true right click
|
||||||
$(this).bind( "mousedown", function(e) {
|
$(this).bind('mousedown', function (e) {
|
||||||
var evt = e;
|
var evt = e;
|
||||||
$(this).mouseup(function (e) {
|
$(this).mouseup(function (e) {
|
||||||
var srcElement = $(this);
|
var srcElement = $(this);
|
||||||
srcElement.unbind('mouseup');
|
srcElement.unbind('mouseup');
|
||||||
if( evt.button === 2 || o.allowLeft || (evt.ctrlKey && svgedit.browser.isMac()) ) {
|
if (evt.button === 2 || o.allowLeft ||
|
||||||
|
(evt.ctrlKey && svgedit.browser.isMac())) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// Hide context menus that may be showing
|
// Hide context menus that may be showing
|
||||||
$(".contextMenu").hide();
|
$('.contextMenu').hide();
|
||||||
// Get this context menu
|
// Get this context menu
|
||||||
|
|
||||||
if (el.hasClass('disabled')) return false;
|
if (el.hasClass('disabled')) return false;
|
||||||
|
|
||||||
// Detect mouse position
|
// Detect mouse position
|
||||||
var d = {}, x = e.pageX, y = e.pageY;
|
var x = e.pageX, y = e.pageY;
|
||||||
|
|
||||||
var x_off = win.width() - menu.width(),
|
var xOff = win.width() - menu.width(),
|
||||||
y_off = win.height() - menu.height();
|
yOff = win.height() - menu.height();
|
||||||
|
|
||||||
if(x > x_off - 15) x = x_off-15;
|
if (x > xOff - 15) x = xOff - 15;
|
||||||
if(y > y_off - 30) y = y_off-30; // 30 is needed to prevent scrollbars in FF
|
if (y > yOff - 30) y = yOff - 30; // 30 is needed to prevent scrollbars in FF
|
||||||
|
|
||||||
// Show the menu
|
// Show the menu
|
||||||
doc.unbind('click');
|
doc.unbind('click');
|
||||||
@@ -82,7 +86,7 @@ if(jQuery)( function() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 40: // down
|
case 40: // down
|
||||||
if( menu.find('LI.hover').length == 0 ) {
|
if (menu.find('LI.hover').length === 0) {
|
||||||
menu.find('LI:first').addClass('hover');
|
menu.find('LI:first').addClass('hover');
|
||||||
} else {
|
} else {
|
||||||
menu.find('LI.hover').removeClass('hover').nextAll('LI:not(.disabled)').eq(0).addClass('hover');
|
menu.find('LI.hover').removeClass('hover').nextAll('LI:not(.disabled)').eq(0).addClass('hover');
|
||||||
@@ -94,7 +98,7 @@ if(jQuery)( function() {
|
|||||||
break;
|
break;
|
||||||
case 27: // esc
|
case 27: // esc
|
||||||
doc.trigger('click');
|
doc.trigger('click');
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -102,7 +106,7 @@ if(jQuery)( function() {
|
|||||||
menu.find('A').unbind('mouseup');
|
menu.find('A').unbind('mouseup');
|
||||||
menu.find('LI:not(.disabled) A').mouseup(function () {
|
menu.find('LI:not(.disabled) A').mouseup(function () {
|
||||||
doc.unbind('click').unbind('keypress');
|
doc.unbind('click').unbind('keypress');
|
||||||
$(".contextMenu").hide();
|
$('.contextMenu').hide();
|
||||||
// Callback
|
// Callback
|
||||||
if (callback) callback($(this).attr('href').substr(1), $(srcElement), {x: x - offset.left, y: y - offset.top, docX: x, docY: y});
|
if (callback) callback($(this).attr('href').substr(1), $(srcElement), {x: x - offset.left, y: y - offset.top, docX: x, docY: y});
|
||||||
return false;
|
return false;
|
||||||
@@ -130,47 +134,44 @@ if(jQuery)( function() {
|
|||||||
}
|
}
|
||||||
// Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
|
// Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
|
||||||
$(el).add($('UL.contextMenu')).bind('contextmenu', function () { return false; });
|
$(el).add($('UL.contextMenu')).bind('contextmenu', function () { return false; });
|
||||||
|
|
||||||
});
|
});
|
||||||
return $(this);
|
return $(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable context menu items on the fly
|
// Disable context menu items on the fly
|
||||||
disableContextMenuItems: function (o) {
|
disableContextMenuItems: function (o) {
|
||||||
if( o == undefined ) {
|
if (o === undefined) {
|
||||||
// Disable all
|
// Disable all
|
||||||
$(this).find('LI').addClass('disabled');
|
$(this).find('LI').addClass('disabled');
|
||||||
return( $(this) );
|
return $(this);
|
||||||
}
|
}
|
||||||
$(this).each(function () {
|
$(this).each(function () {
|
||||||
if( o != undefined ) {
|
if (o !== undefined) {
|
||||||
var d = o.split(',');
|
var d = o.split(',');
|
||||||
for (var i = 0; i < d.length; i++) {
|
for (var i = 0; i < d.length; i++) {
|
||||||
$(this).find('A[href="' + d[i] + '"]').parent().addClass('disabled');
|
$(this).find('A[href="' + d[i] + '"]').parent().addClass('disabled');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return( $(this) );
|
return $(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Enable context menu items on the fly
|
// Enable context menu items on the fly
|
||||||
enableContextMenuItems: function (o) {
|
enableContextMenuItems: function (o) {
|
||||||
if( o == undefined ) {
|
if (o === undefined) {
|
||||||
// Enable all
|
// Enable all
|
||||||
$(this).find('LI.disabled').removeClass('disabled');
|
$(this).find('LI.disabled').removeClass('disabled');
|
||||||
return( $(this) );
|
return $(this);
|
||||||
}
|
}
|
||||||
$(this).each(function () {
|
$(this).each(function () {
|
||||||
if( o != undefined ) {
|
if (o !== undefined) {
|
||||||
var d = o.split(',');
|
var d = o.split(',');
|
||||||
for (var i = 0; i < d.length; i++) {
|
for (var i = 0; i < d.length; i++) {
|
||||||
$(this).find('A[href="' + d[i] + '"]').parent().removeClass('disabled');
|
$(this).find('A[href="' + d[i] + '"]').parent().removeClass('disabled');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return( $(this) );
|
return $(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable context menu(s)
|
// Disable context menu(s)
|
||||||
@@ -178,7 +179,7 @@ if(jQuery)( function() {
|
|||||||
$(this).each(function () {
|
$(this).each(function () {
|
||||||
$(this).addClass('disabled');
|
$(this).addClass('disabled');
|
||||||
});
|
});
|
||||||
return( $(this) );
|
return $(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Enable context menu(s)
|
// Enable context menu(s)
|
||||||
@@ -186,7 +187,7 @@ if(jQuery)( function() {
|
|||||||
$(this).each(function () {
|
$(this).each(function () {
|
||||||
$(this).removeClass('disabled');
|
$(this).removeClass('disabled');
|
||||||
});
|
});
|
||||||
return( $(this) );
|
return $(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Destroy context menu(s)
|
// Destroy context menu(s)
|
||||||
@@ -196,8 +197,9 @@ if(jQuery)( function() {
|
|||||||
// Disable action
|
// Disable action
|
||||||
$(this).unbind('mousedown').unbind('mouseup');
|
$(this).unbind('mousedown').unbind('mouseup');
|
||||||
});
|
});
|
||||||
return( $(this) );
|
return $(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
|||||||
/*
|
/* eslint-disable no-var, no-redeclare */
|
||||||
|
/* globals $, jQuery */
|
||||||
|
/*
|
||||||
* jGraduate 0.4
|
* jGraduate 0.4
|
||||||
*
|
*
|
||||||
* jQuery Plugin for a gradient picker
|
* jQuery Plugin for a gradient picker
|
||||||
@@ -48,15 +50,13 @@ $.jGraduate.Paint({hex: "#rrggbb", linearGradient: o}) -> throws an exception?
|
|||||||
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
var ns = { svg: 'http://www.w3.org/2000/svg', xlink: 'http://www.w3.org/1999/xlink' };
|
var ns = { svg: 'http://www.w3.org/2000/svg', xlink: 'http://www.w3.org/1999/xlink' };
|
||||||
if (!window.console) {
|
if (!window.console) {
|
||||||
window.console = new function () {
|
window.console = new function () {
|
||||||
this.log = function (str) {};
|
this.log = function (str) {};
|
||||||
this.dir = function (str) {};
|
this.dir = function (str) {};
|
||||||
};
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.jGraduate = {
|
$.jGraduate = {
|
||||||
@@ -73,41 +73,37 @@ $.jGraduate = {
|
|||||||
this.radialGradient = null;
|
this.radialGradient = null;
|
||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case "none":
|
case 'none':
|
||||||
break;
|
break;
|
||||||
case "solidColor":
|
case 'solidColor':
|
||||||
this.solidColor = options.copy.solidColor;
|
this.solidColor = options.copy.solidColor;
|
||||||
break;
|
break;
|
||||||
case "linearGradient":
|
case 'linearGradient':
|
||||||
this.linearGradient = options.copy.linearGradient.cloneNode(true);
|
this.linearGradient = options.copy.linearGradient.cloneNode(true);
|
||||||
break;
|
break;
|
||||||
case "radialGradient":
|
case 'radialGradient':
|
||||||
this.radialGradient = options.copy.radialGradient.cloneNode(true);
|
this.radialGradient = options.copy.radialGradient.cloneNode(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// create linear gradient paint
|
// create linear gradient paint
|
||||||
else if (options.linearGradient) {
|
} else if (options.linearGradient) {
|
||||||
this.type = "linearGradient";
|
this.type = 'linearGradient';
|
||||||
this.solidColor = null;
|
this.solidColor = null;
|
||||||
this.radialGradient = null;
|
this.radialGradient = null;
|
||||||
this.linearGradient = options.linearGradient.cloneNode(true);
|
this.linearGradient = options.linearGradient.cloneNode(true);
|
||||||
}
|
|
||||||
// create linear gradient paint
|
// create linear gradient paint
|
||||||
else if (options.radialGradient) {
|
} else if (options.radialGradient) {
|
||||||
this.type = "radialGradient";
|
this.type = 'radialGradient';
|
||||||
this.solidColor = null;
|
this.solidColor = null;
|
||||||
this.linearGradient = null;
|
this.linearGradient = null;
|
||||||
this.radialGradient = options.radialGradient.cloneNode(true);
|
this.radialGradient = options.radialGradient.cloneNode(true);
|
||||||
}
|
|
||||||
// create solid color paint
|
// create solid color paint
|
||||||
else if (options.solidColor) {
|
} else if (options.solidColor) {
|
||||||
this.type = "solidColor";
|
this.type = 'solidColor';
|
||||||
this.solidColor = options.solidColor;
|
this.solidColor = options.solidColor;
|
||||||
}
|
|
||||||
// create empty paint
|
// create empty paint
|
||||||
else {
|
} else {
|
||||||
this.type = "none";
|
this.type = 'none';
|
||||||
this.solidColor = null;
|
this.solidColor = null;
|
||||||
this.linearGradient = null;
|
this.linearGradient = null;
|
||||||
this.radialGradient = null;
|
this.radialGradient = null;
|
||||||
@@ -118,10 +114,10 @@ $.jGraduate = {
|
|||||||
jQuery.fn.jGraduateDefaults = {
|
jQuery.fn.jGraduateDefaults = {
|
||||||
paint: new $.jGraduate.Paint(),
|
paint: new $.jGraduate.Paint(),
|
||||||
window: {
|
window: {
|
||||||
pickerTitle: "Drag markers to pick a paint"
|
pickerTitle: 'Drag markers to pick a paint'
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
clientPath: "images/"
|
clientPath: 'images/'
|
||||||
},
|
},
|
||||||
newstop: 'inverse' // same, inverse, black, white
|
newstop: 'inverse' // same, inverse, black, white
|
||||||
};
|
};
|
||||||
@@ -158,34 +154,32 @@ jQuery.fn.jGraduate =
|
|||||||
id = $this.attr('id'),
|
id = $this.attr('id'),
|
||||||
idref = '#' + $this.attr('id') + ' ';
|
idref = '#' + $this.attr('id') + ' ';
|
||||||
|
|
||||||
if (!idref)
|
if (!idref) {
|
||||||
{
|
|
||||||
alert('Container element must have an id attribute to maintain unique id strings for sub-elements.');
|
alert('Container element must have an id attribute to maintain unique id strings for sub-elements.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var okClicked = function () {
|
var okClicked = function () {
|
||||||
switch ($this.paint.type) {
|
switch ($this.paint.type) {
|
||||||
case "radialGradient":
|
case 'radialGradient':
|
||||||
$this.paint.linearGradient = null;
|
$this.paint.linearGradient = null;
|
||||||
break;
|
break;
|
||||||
case "linearGradient":
|
case 'linearGradient':
|
||||||
$this.paint.radialGradient = null;
|
$this.paint.radialGradient = null;
|
||||||
break;
|
break;
|
||||||
case "solidColor":
|
case 'solidColor':
|
||||||
$this.paint.radialGradient = $this.paint.linearGradient = null;
|
$this.paint.radialGradient = $this.paint.linearGradient = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$.isFunction($this.okCallback) && $this.okCallback($this.paint);
|
$.isFunction($this.okCallback) && $this.okCallback($this.paint);
|
||||||
$this.hide();
|
$this.hide();
|
||||||
},
|
};
|
||||||
cancelClicked = function() {
|
var cancelClicked = function () {
|
||||||
$.isFunction($this.cancelCallback) && $this.cancelCallback();
|
$.isFunction($this.cancelCallback) && $this.cancelCallback();
|
||||||
$this.hide();
|
$this.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
$.extend(true, $this, // public properties, methods, and callbacks
|
$.extend(true, $this, { // public properties, methods, and callbacks
|
||||||
{
|
|
||||||
// make a copy of the incoming paint
|
// make a copy of the incoming paint
|
||||||
paint: new $.jGraduate.Paint({copy: $settings.paint}),
|
paint: new $.jGraduate.Paint({copy: $settings.paint}),
|
||||||
okCallback: $.isFunction($arguments[1]) && $arguments[1] || null,
|
okCallback: $.isFunction($arguments[1]) && $arguments[1] || null,
|
||||||
@@ -196,7 +190,7 @@ jQuery.fn.jGraduate =
|
|||||||
color = null;
|
color = null;
|
||||||
var $win = $(window);
|
var $win = $(window);
|
||||||
|
|
||||||
if ($this.paint.type == "none") {
|
if ($this.paint.type === 'none') {
|
||||||
$this.paint = $.jGraduate.Paint({solidColor: 'ffffff'});
|
$this.paint = $.jGraduate.Paint({solidColor: 'ffffff'});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,8 +204,6 @@ jQuery.fn.jGraduate =
|
|||||||
'<div class="jGraduate_gradPick"></div>' +
|
'<div class="jGraduate_gradPick"></div>' +
|
||||||
'<div class="jGraduate_LightBox"></div>' +
|
'<div class="jGraduate_LightBox"></div>' +
|
||||||
'<div id="' + id + '_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>'
|
'<div id="' + id + '_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>'
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
var colPicker = $(idref + '> .jGraduate_colPick');
|
var colPicker = $(idref + '> .jGraduate_colPick');
|
||||||
var gradPicker = $(idref + '> .jGraduate_gradPick');
|
var gradPicker = $(idref + '> .jGraduate_gradPick');
|
||||||
@@ -310,7 +302,8 @@ jQuery.fn.jGraduate =
|
|||||||
|
|
||||||
// --------------
|
// --------------
|
||||||
// Set up all the SVG elements (the gradient, stops and rectangle)
|
// Set up all the SVG elements (the gradient, stops and rectangle)
|
||||||
var MAX = 256, MARGINX = 0, MARGINY = 0, STOP_RADIUS = 15/2,
|
var MAX = 256, MARGINX = 0, MARGINY = 0,
|
||||||
|
// STOP_RADIUS = 15 / 2,
|
||||||
SIZEX = MAX - 2 * MARGINX, SIZEY = MAX - 2 * MARGINY;
|
SIZEX = MAX - 2 * MARGINX, SIZEY = MAX - 2 * MARGINY;
|
||||||
|
|
||||||
var curType, curGradient, previewRect;
|
var curType, curGradient, previewRect;
|
||||||
@@ -341,9 +334,9 @@ jQuery.fn.jGraduate =
|
|||||||
|
|
||||||
// Make any missing gradients
|
// Make any missing gradients
|
||||||
switch (curType) {
|
switch (curType) {
|
||||||
case "solidColor":
|
case 'solidColor':
|
||||||
// fall through
|
// fall through
|
||||||
case "linearGradient":
|
case 'linearGradient':
|
||||||
if (!isSolid) {
|
if (!isSolid) {
|
||||||
curGradient.id = id + '_lg_jgraduate_grad';
|
curGradient.id = id + '_lg_jgraduate_grad';
|
||||||
grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));
|
grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));
|
||||||
@@ -351,8 +344,9 @@ jQuery.fn.jGraduate =
|
|||||||
mkElem('radialGradient', {
|
mkElem('radialGradient', {
|
||||||
id: id + '_rg_jgraduate_grad'
|
id: id + '_rg_jgraduate_grad'
|
||||||
}, svg);
|
}, svg);
|
||||||
if(curType === "linearGradient") break;
|
if (curType === 'linearGradient') break;
|
||||||
case "radialGradient":
|
// fall through
|
||||||
|
case 'radialGradient':
|
||||||
if (!isSolid) {
|
if (!isSolid) {
|
||||||
curGradient.id = id + '_rg_jgraduate_grad';
|
curGradient.id = id + '_rg_jgraduate_grad';
|
||||||
grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));
|
grad = curGradient = svg.appendChild(curGradient); // .cloneNode(true));
|
||||||
@@ -402,7 +396,6 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var x1 = parseFloat(grad.getAttribute('x1') || 0.0),
|
var x1 = parseFloat(grad.getAttribute('x1') || 0.0),
|
||||||
y1 = parseFloat(grad.getAttribute('y1') || 0.0),
|
y1 = parseFloat(grad.getAttribute('y1') || 0.0),
|
||||||
x2 = parseFloat(grad.getAttribute('x2') || 1.0),
|
x2 = parseFloat(grad.getAttribute('x2') || 1.0),
|
||||||
@@ -413,7 +406,6 @@ jQuery.fn.jGraduate =
|
|||||||
fx = parseFloat(grad.getAttribute('fx') || cx),
|
fx = parseFloat(grad.getAttribute('fx') || cx),
|
||||||
fy = parseFloat(grad.getAttribute('fy') || cy);
|
fy = parseFloat(grad.getAttribute('fy') || cy);
|
||||||
|
|
||||||
|
|
||||||
var previewRect = mkElem('rect', {
|
var previewRect = mkElem('rect', {
|
||||||
id: id + '_jgraduate_rect',
|
id: id + '_jgraduate_rect',
|
||||||
x: MARGINX,
|
x: MARGINX,
|
||||||
@@ -475,10 +467,10 @@ jQuery.fn.jGraduate =
|
|||||||
// Set defaults
|
// Set defaults
|
||||||
if (isRadial) {
|
if (isRadial) {
|
||||||
// For radial points
|
// For radial points
|
||||||
attrval = "0.5";
|
attrval = '0.5';
|
||||||
} else {
|
} else {
|
||||||
// Only x2 is 1
|
// Only x2 is 1
|
||||||
attrval = attr === 'x2' ? "1.0" : "0.0";
|
attrval = attr === 'x2' ? '1.0' : '0.0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,9 +491,9 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isRadial) {
|
if (isRadial) {
|
||||||
var $elem = attr[0] === "c" ? centerCoord : focusCoord;
|
var $elem = attr[0] === 'c' ? centerCoord : focusCoord;
|
||||||
} else {
|
} else {
|
||||||
var $elem = attr[1] === "1" ? beginCoord : endCoord;
|
var $elem = attr[1] === '1' ? beginCoord : endCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cssName = attr.indexOf('x') >= 0 ? 'left' : 'top';
|
var cssName = attr.indexOf('x') >= 0 ? 'left' : 'top';
|
||||||
@@ -510,8 +502,6 @@ jQuery.fn.jGraduate =
|
|||||||
}).change();
|
}).change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function mkStop (n, color, opac, sel, stop_elem) {
|
function mkStop (n, color, opac, sel, stop_elem) {
|
||||||
var stop = stop_elem || mkElem('stop', {'stop-color': color, 'stop-opacity': opac, offset: n}, curGradient);
|
var stop = stop_elem || mkElem('stop', {'stop-color': color, 'stop-opacity': opac, offset: n}, curGradient);
|
||||||
if (stop_elem) {
|
if (stop_elem) {
|
||||||
@@ -553,14 +543,14 @@ jQuery.fn.jGraduate =
|
|||||||
var stopOpacity = +stop.getAttribute('stop-opacity') || 1;
|
var stopOpacity = +stop.getAttribute('stop-opacity') || 1;
|
||||||
var stopColor = stop.getAttribute('stop-color') || 1;
|
var stopColor = stop.getAttribute('stop-color') || 1;
|
||||||
var thisAlpha = (parseFloat(stopOpacity) * 255).toString(16);
|
var thisAlpha = (parseFloat(stopOpacity) * 255).toString(16);
|
||||||
while (thisAlpha.length < 2) { thisAlpha = "0" + thisAlpha; }
|
while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }
|
||||||
color = stopColor.substr(1) + thisAlpha;
|
color = stopColor.substr(1) + thisAlpha;
|
||||||
$('#' + id + '_jGraduate_stopPicker').css({'left': 100, 'bottom': 15}).jPicker({
|
$('#' + id + '_jGraduate_stopPicker').css({'left': 100, 'bottom': 15}).jPicker({
|
||||||
window: { title: "Pick the start color and opacity for the gradient" },
|
window: { title: 'Pick the start color and opacity for the gradient' },
|
||||||
images: { clientPath: $settings.images.clientPath },
|
images: { clientPath: $settings.images.clientPath },
|
||||||
color: { active: color, alphaSupport: true }
|
color: { active: color, alphaSupport: true }
|
||||||
}, function (color, arg2) {
|
}, function (color, arg2) {
|
||||||
stopColor = color.val('hex') ? ('#'+color.val('hex')) : "none";
|
stopColor = color.val('hex') ? ('#' + color.val('hex')) : 'none';
|
||||||
stopOpacity = color.val('a') !== null ? color.val('a') / 256 : 1;
|
stopOpacity = color.val('a') !== null ? color.val('a') / 256 : 1;
|
||||||
colorhandle.setAttribute('fill', stopColor);
|
colorhandle.setAttribute('fill', stopColor);
|
||||||
colorhandle.setAttribute('fill-opacity', stopOpacity);
|
colorhandle.setAttribute('fill-opacity', stopOpacity);
|
||||||
@@ -601,7 +591,6 @@ jQuery.fn.jGraduate =
|
|||||||
$([cur_stop, stop, bg]).remove();
|
$([cur_stop, stop, bg]).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var stops, stopGroup;
|
var stops, stopGroup;
|
||||||
|
|
||||||
var stopMakerDiv = $('#' + id + '_jGraduate_StopSlider');
|
var stopMakerDiv = $('#' + id + '_jGraduate_StopSlider');
|
||||||
@@ -616,7 +605,6 @@ jQuery.fn.jGraduate =
|
|||||||
display: 'none'
|
display: 'none'
|
||||||
}, stopMakerSVG);
|
}, stopMakerSVG);
|
||||||
|
|
||||||
|
|
||||||
function selectStop (item) {
|
function selectStop (item) {
|
||||||
if (cur_stop) cur_stop.setAttribute('stroke', '#000');
|
if (cur_stop) cur_stop.setAttribute('stroke', '#000');
|
||||||
item.setAttribute('stroke', 'blue');
|
item.setAttribute('stroke', 'blue');
|
||||||
@@ -655,7 +643,6 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dragColor (evt) {
|
function dragColor (evt) {
|
||||||
|
|
||||||
var x = evt.pageX - stop_offset.left;
|
var x = evt.pageX - stop_offset.left;
|
||||||
var y = evt.pageY - stop_offset.top;
|
var y = evt.pageY - stop_offset.top;
|
||||||
x = x < 10 ? 10 : x > MAX + 10 ? MAX + 10 : x;
|
x = x < 10 ? 10 : x > MAX + 10 ? MAX + 10 : x;
|
||||||
@@ -685,7 +672,6 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
last = cur;
|
last = cur;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopMakerSVG = mkElem('svg', {
|
stopMakerSVG = mkElem('svg', {
|
||||||
@@ -734,12 +720,10 @@ jQuery.fn.jGraduate =
|
|||||||
stroke: '#000'
|
stroke: '#000'
|
||||||
}, stopMakerSVG);
|
}, stopMakerSVG);
|
||||||
|
|
||||||
|
|
||||||
var spreadMethodOpt = gradPicker.find('.jGraduate_spreadMethod').change(function () {
|
var spreadMethodOpt = gradPicker.find('.jGraduate_spreadMethod').change(function () {
|
||||||
curGradient.setAttribute('spreadMethod', $(this).val());
|
curGradient.setAttribute('spreadMethod', $(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// handle dragging the stop around the swatch
|
// handle dragging the stop around the swatch
|
||||||
var draggingCoord = null;
|
var draggingCoord = null;
|
||||||
|
|
||||||
@@ -791,17 +775,16 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
|
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
}
|
};
|
||||||
|
|
||||||
var onCoordUp = function () {
|
var onCoordUp = function () {
|
||||||
draggingCoord = null;
|
draggingCoord = null;
|
||||||
$win.unbind('mousemove', onCoordDrag).unbind('mouseup', onCoordUp);
|
$win.unbind('mousemove', onCoordDrag).unbind('mouseup', onCoordUp);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Linear gradient
|
// Linear gradient
|
||||||
// (function () {
|
// (function () {
|
||||||
|
|
||||||
|
|
||||||
stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');
|
stops = curGradient.getElementsByTagNameNS(ns.svg, 'stop');
|
||||||
|
|
||||||
// if there are not at least two stops, then
|
// if there are not at least two stops, then
|
||||||
@@ -827,11 +810,10 @@ jQuery.fn.jGraduate =
|
|||||||
|
|
||||||
previewRect.setAttribute('fill-opacity', gradalpha / 100);
|
previewRect.setAttribute('fill-opacity', gradalpha / 100);
|
||||||
|
|
||||||
|
|
||||||
$('#' + id + ' div.grad_coord').mousedown(function (evt) {
|
$('#' + id + ' div.grad_coord').mousedown(function (evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
draggingCoord = $(this);
|
draggingCoord = $(this);
|
||||||
var s_pos = draggingCoord.offset();
|
// var s_pos = draggingCoord.offset();
|
||||||
offset = draggingCoord.parent().offset();
|
offset = draggingCoord.parent().offset();
|
||||||
$win.mousemove(onCoordDrag).mouseup(onCoordUp);
|
$win.mousemove(onCoordDrag).mouseup(onCoordUp);
|
||||||
});
|
});
|
||||||
@@ -839,7 +821,7 @@ jQuery.fn.jGraduate =
|
|||||||
// bind GUI elements
|
// bind GUI elements
|
||||||
$('#' + id + '_jGraduate_Ok').bind('click', function () {
|
$('#' + id + '_jGraduate_Ok').bind('click', function () {
|
||||||
$this.paint.type = curType;
|
$this.paint.type = curType;
|
||||||
$this.paint[curType] = curGradient.cloneNode(true);;
|
$this.paint[curType] = curGradient.cloneNode(true);
|
||||||
$this.paint.solidColor = null;
|
$this.paint.solidColor = null;
|
||||||
okClicked();
|
okClicked();
|
||||||
});
|
});
|
||||||
@@ -852,16 +834,16 @@ jQuery.fn.jGraduate =
|
|||||||
focusCoord.show();
|
focusCoord.show();
|
||||||
} else {
|
} else {
|
||||||
focusCoord.hide();
|
focusCoord.hide();
|
||||||
attr_input.fx.val("");
|
attr_input.fx.val('');
|
||||||
attr_input.fy.val("");
|
attr_input.fy.val('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#" + id + "_jGraduate_match_ctr")[0].checked = !showFocus;
|
$('#' + id + '_jGraduate_match_ctr')[0].checked = !showFocus;
|
||||||
|
|
||||||
var lastfx, lastfy;
|
var lastfx, lastfy;
|
||||||
|
|
||||||
$("#" + id + "_jGraduate_match_ctr").change(function() {
|
$('#' + id + '_jGraduate_match_ctr').change(function () {
|
||||||
showFocus = !this.checked;
|
showFocus = !this.checked;
|
||||||
focusCoord.toggle(showFocus);
|
focusCoord.toggle(showFocus);
|
||||||
attr_input.fx.val('');
|
attr_input.fx.val('');
|
||||||
@@ -873,8 +855,8 @@ jQuery.fn.jGraduate =
|
|||||||
grad.removeAttribute('fx');
|
grad.removeAttribute('fx');
|
||||||
grad.removeAttribute('fy');
|
grad.removeAttribute('fy');
|
||||||
} else {
|
} else {
|
||||||
var fx = lastfx || .5;
|
var fx = lastfx || 0.5;
|
||||||
var fy = lastfy || .5;
|
var fy = lastfy || 0.5;
|
||||||
grad.setAttribute('fx', fx);
|
grad.setAttribute('fx', fx);
|
||||||
grad.setAttribute('fy', fy);
|
grad.setAttribute('fy', fy);
|
||||||
attr_input.fx.val(fx);
|
attr_input.fx.val(fx);
|
||||||
@@ -907,8 +889,8 @@ jQuery.fn.jGraduate =
|
|||||||
switch (slider.type) {
|
switch (slider.type) {
|
||||||
case 'radius':
|
case 'radius':
|
||||||
x = Math.pow(x * 2, 2.5);
|
x = Math.pow(x * 2, 2.5);
|
||||||
if(x > .98 && x < 1.02) x = 1;
|
if (x > 0.98 && x < 1.02) x = 1;
|
||||||
if (x <= .01) x = .01;
|
if (x <= 0.01) x = 0.01;
|
||||||
curGradient.setAttribute('r', x);
|
curGradient.setAttribute('r', x);
|
||||||
break;
|
break;
|
||||||
case 'opacity':
|
case 'opacity':
|
||||||
@@ -916,14 +898,15 @@ jQuery.fn.jGraduate =
|
|||||||
previewRect.setAttribute('fill-opacity', x);
|
previewRect.setAttribute('fill-opacity', x);
|
||||||
break;
|
break;
|
||||||
case 'ellip':
|
case 'ellip':
|
||||||
scale_x = 1, scale_y = 1;
|
scale_x = 1;
|
||||||
if(x < .5) {
|
scale_y = 1;
|
||||||
x /= .5; // 0.001
|
if (x < 0.5) {
|
||||||
scale_x = x <= 0 ? .01 : x;
|
x /= 0.5; // 0.001
|
||||||
} else if(x > .5) {
|
scale_x = x <= 0 ? 0.01 : x;
|
||||||
x /= .5; // 2
|
} else if (x > 0.5) {
|
||||||
|
x /= 0.5; // 2
|
||||||
x = 2 - x;
|
x = 2 - x;
|
||||||
scale_y = x <= 0 ? .01 : x;
|
scale_y = x <= 0 ? 0.01 : x;
|
||||||
}
|
}
|
||||||
xform();
|
xform();
|
||||||
x -= 1;
|
x -= 1;
|
||||||
@@ -932,7 +915,7 @@ jQuery.fn.jGraduate =
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'angle':
|
case 'angle':
|
||||||
x = x - .5;
|
x = x - 0.5;
|
||||||
angle = x *= 180;
|
angle = x *= 180;
|
||||||
xform();
|
xform();
|
||||||
x /= 100;
|
x /= 100;
|
||||||
@@ -964,10 +947,10 @@ jQuery.fn.jGraduate =
|
|||||||
var t = tlist.getItem(1);
|
var t = tlist.getItem(1);
|
||||||
var s = tlist.getItem(2);
|
var s = tlist.getItem(2);
|
||||||
|
|
||||||
if(r.type === 4
|
if (r.type === 4 &&
|
||||||
&& t.type === 2
|
t.type === 2 &&
|
||||||
&& s.type === 3) {
|
s.type === 3
|
||||||
|
) {
|
||||||
angle_val = Math.round(r.angle);
|
angle_val = Math.round(r.angle);
|
||||||
var m = s.matrix;
|
var m = s.matrix;
|
||||||
if (m.a !== 1) {
|
if (m.a !== 1) {
|
||||||
@@ -975,7 +958,6 @@ jQuery.fn.jGraduate =
|
|||||||
} else if(m.d !== 1) {
|
} else if(m.d !== 1) {
|
||||||
ellip_val = Math.round((1 - m.d) * 100);
|
ellip_val = Math.round((1 - m.d) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -984,7 +966,7 @@ jQuery.fn.jGraduate =
|
|||||||
radius: {
|
radius: {
|
||||||
handle: '#' + id + '_jGraduate_RadiusArrows',
|
handle: '#' + id + '_jGraduate_RadiusArrows',
|
||||||
input: '#' + id + '_jGraduate_RadiusInput',
|
input: '#' + id + '_jGraduate_RadiusInput',
|
||||||
val: (curGradient.getAttribute('r') || .5) * 100
|
val: (curGradient.getAttribute('r') || 0.5) * 100
|
||||||
},
|
},
|
||||||
opacity: {
|
opacity: {
|
||||||
handle: '#' + id + '_jGraduate_OpacArrows',
|
handle: '#' + id + '_jGraduate_OpacArrows',
|
||||||
@@ -1001,7 +983,7 @@ jQuery.fn.jGraduate =
|
|||||||
input: '#' + id + '_jGraduate_AngleInput',
|
input: '#' + id + '_jGraduate_AngleInput',
|
||||||
val: angle_val
|
val: angle_val
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$.each(sliders, function (type, data) {
|
$.each(sliders, function (type, data) {
|
||||||
var handle = $(data.handle);
|
var handle = $(data.handle);
|
||||||
@@ -1037,7 +1019,7 @@ jQuery.fn.jGraduate =
|
|||||||
case 'ellip':
|
case 'ellip':
|
||||||
scale_x = scale_y = 1;
|
scale_x = scale_y = 1;
|
||||||
if (val === 0) {
|
if (val === 0) {
|
||||||
xpos = SLIDERW * .5;
|
xpos = SLIDERW * 0.5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (val > 99.5) val = 99.5;
|
if (val > 99.5) val = 99.5;
|
||||||
@@ -1054,7 +1036,7 @@ jQuery.fn.jGraduate =
|
|||||||
case 'angle':
|
case 'angle':
|
||||||
angle = val;
|
angle = val;
|
||||||
xpos = angle / 180;
|
xpos = angle / 180;
|
||||||
xpos += .5;
|
xpos += 0.5;
|
||||||
xpos *= SLIDERW;
|
xpos *= SLIDERW;
|
||||||
if (isRad) xform();
|
if (isRad) xform();
|
||||||
}
|
}
|
||||||
@@ -1077,12 +1059,11 @@ jQuery.fn.jGraduate =
|
|||||||
slider = null;
|
slider = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// --------------
|
// --------------
|
||||||
var thisAlpha = ($this.paint.alpha * 255 / 100).toString(16);
|
var thisAlpha = ($this.paint.alpha * 255 / 100).toString(16);
|
||||||
while (thisAlpha.length < 2) { thisAlpha = "0" + thisAlpha; }
|
while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }
|
||||||
thisAlpha = thisAlpha.split(".")[0];
|
thisAlpha = thisAlpha.split('.')[0];
|
||||||
color = $this.paint.solidColor == "none" ? "" : $this.paint.solidColor + thisAlpha;
|
color = $this.paint.solidColor === 'none' ? '' : $this.paint.solidColor + thisAlpha;
|
||||||
|
|
||||||
if (!isSolid) {
|
if (!isSolid) {
|
||||||
color = stops[0].getAttribute('stop-color');
|
color = stops[0].getAttribute('stop-color');
|
||||||
@@ -1100,9 +1081,9 @@ jQuery.fn.jGraduate =
|
|||||||
color: { active: color, alphaSupport: true }
|
color: { active: color, alphaSupport: true }
|
||||||
},
|
},
|
||||||
function (color) {
|
function (color) {
|
||||||
$this.paint.type = "solidColor";
|
$this.paint.type = 'solidColor';
|
||||||
$this.paint.alpha = color.val('ahex') ? Math.round((color.val('a') / 255) * 100) : 100;
|
$this.paint.alpha = color.val('ahex') ? Math.round((color.val('a') / 255) * 100) : 100;
|
||||||
$this.paint.solidColor = color.val('hex') ? color.val('hex') : "none";
|
$this.paint.solidColor = color.val('hex') ? color.val('hex') : 'none';
|
||||||
$this.paint.radialGradient = null;
|
$this.paint.radialGradient = null;
|
||||||
okClicked();
|
okClicked();
|
||||||
},
|
},
|
||||||
@@ -1110,12 +1091,11 @@ jQuery.fn.jGraduate =
|
|||||||
function () { cancelClicked(); }
|
function () { cancelClicked(); }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
var tabs = $(idref + ' .jGraduate_tabs li');
|
var tabs = $(idref + ' .jGraduate_tabs li');
|
||||||
tabs.click(function () {
|
tabs.click(function () {
|
||||||
tabs.removeClass('jGraduate_tab_current');
|
tabs.removeClass('jGraduate_tab_current');
|
||||||
$(this).addClass('jGraduate_tab_current');
|
$(this).addClass('jGraduate_tab_current');
|
||||||
$(idref + " > div").hide();
|
$(idref + ' > div').hide();
|
||||||
var type = $(this).attr('data-type');
|
var type = $(this).attr('data-type');
|
||||||
var container = $(idref + ' .jGraduate_gradPick').show();
|
var container = $(idref + ' .jGraduate_gradPick').show();
|
||||||
if (type === 'rg' || type === 'lg') {
|
if (type === 'rg' || type === 'lg') {
|
||||||
@@ -1150,7 +1130,7 @@ jQuery.fn.jGraduate =
|
|||||||
$(idref + ' .jGraduate_colPick').show();
|
$(idref + ' .jGraduate_colPick').show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(idref + " > div").hide();
|
$(idref + ' > div').hide();
|
||||||
tabs.removeClass('jGraduate_tab_current');
|
tabs.removeClass('jGraduate_tab_current');
|
||||||
var tab;
|
var tab;
|
||||||
switch ($this.paint.type) {
|
switch ($this.paint.type) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*globals $, svgEditor*/
|
/* eslint-disable no-var */
|
||||||
/*jslint vars: true, eqeq: true*/
|
/* globals $, svgEditor */
|
||||||
/* SpinButton control
|
/* SpinButton control
|
||||||
*
|
*
|
||||||
* Adds bells and whistles to any ordinary textbox to
|
* Adds bells and whistles to any ordinary textbox to
|
||||||
@@ -65,11 +65,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
*/
|
*/
|
||||||
$.fn.SpinButton = function(cfg) { 'use strict';
|
$.fn.SpinButton = function (cfg) {
|
||||||
|
'use strict';
|
||||||
function coord (el, prop) {
|
function coord (el, prop) {
|
||||||
var c = el[prop], b = document.body;
|
var c = el[prop], b = document.body;
|
||||||
|
|
||||||
while ((el = el.offsetParent) && (el != b)) {
|
while ((el = el.offsetParent) && (el !== b)) {
|
||||||
if (!$.browser.msie || (el.currentStyle.position !== 'relative')) {
|
if (!$.browser.msie || (el.currentStyle.position !== 'relative')) {
|
||||||
c += el[prop];
|
c += el[prop];
|
||||||
}
|
}
|
||||||
@@ -79,7 +80,6 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
|
|
||||||
this.repeating = false;
|
this.repeating = false;
|
||||||
|
|
||||||
// Apply specified options or defaults:
|
// Apply specified options or defaults:
|
||||||
@@ -135,7 +135,8 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
var height = $(el).height() / 2;
|
var height = $(el).height() / 2;
|
||||||
|
|
||||||
var direction =
|
var direction =
|
||||||
(x > coord(el,'offsetLeft') + el.offsetWidth*scale - this.spinCfg._btn_width)
|
(x > coord(el, 'offsetLeft') +
|
||||||
|
el.offsetWidth * scale - this.spinCfg._btn_width)
|
||||||
? ((y < coord(el, 'offsetTop') + height * scale) ? 1 : -1) : 0;
|
? ((y < coord(el, 'offsetTop') + height * scale) ? 1 : -1) : 0;
|
||||||
|
|
||||||
if (direction !== this.spinCfg._direction) {
|
if (direction !== this.spinCfg._direction) {
|
||||||
@@ -165,7 +166,7 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
})
|
})
|
||||||
|
|
||||||
.mousedown(function (e) {
|
.mousedown(function (e) {
|
||||||
if (e.button === 0 && this.spinCfg._direction != 0) {
|
if (e.button === 0 && this.spinCfg._direction !== 0) {
|
||||||
// Respond to click on one of the buttons:
|
// Respond to click on one of the buttons:
|
||||||
var self = this;
|
var self = this;
|
||||||
var stepSize = e.shiftKey ? self.spinCfg.smallStep : self.spinCfg.step;
|
var stepSize = e.shiftKey ? self.spinCfg.smallStep : self.spinCfg.step;
|
||||||
@@ -222,9 +223,8 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
case 33: this.adjustValue(this.spinCfg.page); break; // PageUp
|
case 33: this.adjustValue(this.spinCfg.page); break; // PageUp
|
||||||
case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown
|
case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// we always ignore the first keypress event (use the keydown instead)
|
// we always ignore the first keypress event (use the keydown instead)
|
||||||
else {
|
} else {
|
||||||
this.repeating = true;
|
this.repeating = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -241,12 +241,11 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.bind("mousewheel", function(e){
|
.bind('mousewheel', function (e) {
|
||||||
// Respond to mouse wheel in IE. (It returns up/dn motion in multiples of 120)
|
// Respond to mouse wheel in IE. (It returns up/dn motion in multiples of 120)
|
||||||
if (e.wheelDelta >= 120) {
|
if (e.wheelDelta >= 120) {
|
||||||
this.adjustValue(this.spinCfg.step);
|
this.adjustValue(this.spinCfg.step);
|
||||||
}
|
} else if (e.wheelDelta <= -120) {
|
||||||
else if (e.wheelDelta <= -120) {
|
|
||||||
this.adjustValue(-this.spinCfg.step);
|
this.adjustValue(-this.spinCfg.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,8 +261,7 @@ $.fn.SpinButton = function(cfg) { 'use strict';
|
|||||||
this.addEventListener('DOMMouseScroll', function (e) {
|
this.addEventListener('DOMMouseScroll', function (e) {
|
||||||
if (e.detail > 0) {
|
if (e.detail > 0) {
|
||||||
this.adjustValue(-this.spinCfg.step);
|
this.adjustValue(-this.spinCfg.step);
|
||||||
}
|
} else if (e.detail < 0) {
|
||||||
else if (e.detail < 0) {
|
|
||||||
this.adjustValue(this.spinCfg.step);
|
this.adjustValue(this.spinCfg.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
/*
|
/* eslint-disable no-var */
|
||||||
|
/* globals jQuery */
|
||||||
|
/*
|
||||||
* SVG Icon Loader 2.0
|
* SVG Icon Loader 2.0
|
||||||
*
|
*
|
||||||
* jQuery Plugin for loading SVG icons from a single file
|
* jQuery Plugin for loading SVG icons from a single file
|
||||||
@@ -72,7 +74,6 @@ This will return the icon (as jQuery object) with a given ID.
|
|||||||
6. To resize icons at a later point without using the callback, use this:
|
6. To resize icons at a later point without using the callback, use this:
|
||||||
$.resizeSvgIcons(resizeOptions) (use the same way as the "resize" parameter)
|
$.resizeSvgIcons(resizeOptions) (use the same way as the "resize" parameter)
|
||||||
|
|
||||||
|
|
||||||
Example usage #1:
|
Example usage #1:
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
@@ -123,28 +124,28 @@ $(function() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
var svg_icons = {}, fixIDs;
|
var svgIcons = {}, fixIDs;
|
||||||
|
|
||||||
$.svgIcons = function (file, opts) {
|
$.svgIcons = function (file, opts) {
|
||||||
var svgns = "http://www.w3.org/2000/svg",
|
var svgns = 'http://www.w3.org/2000/svg',
|
||||||
xlinkns = "http://www.w3.org/1999/xlink",
|
xlinkns = 'http://www.w3.org/1999/xlink',
|
||||||
icon_w = opts.w?opts.w : 24,
|
iconW = opts.w || 24,
|
||||||
icon_h = opts.h?opts.h : 24,
|
iconH = opts.h || 24,
|
||||||
elems, svgdoc, testImg,
|
elems, svgdoc, testImg,
|
||||||
icons_made = false, data_loaded = false, load_attempts = 0,
|
iconsMade = false, dataLoaded = false, loadAttempts = 0,
|
||||||
ua = navigator.userAgent, isOpera = !!window.opera, isSafari = (ua.indexOf('Safari/') > -1 && ua.indexOf('Chrome/')==-1),
|
// ua = navigator.userAgent,
|
||||||
data_pre = 'data:image/svg+xml;charset=utf-8;base64,';
|
isOpera = !!window.opera,
|
||||||
|
// isSafari = (ua.indexOf('Safari/') > -1 && ua.indexOf('Chrome/') === -1),
|
||||||
|
dataPre = 'data:image/svg+xml;charset=utf-8;base64,';
|
||||||
|
|
||||||
if (opts.svgz) {
|
if (opts.svgz) {
|
||||||
var data_el = $('<object data="' + file + '" type=image/svg+xml>').appendTo('body').hide();
|
var dataEl = $('<object data="' + file + '" type=image/svg+xml>').appendTo('body').hide();
|
||||||
try {
|
try {
|
||||||
svgdoc = data_el[0].contentDocument;
|
svgdoc = dataEl[0].contentDocument;
|
||||||
data_el.load(getIcons);
|
dataEl.load(getIcons);
|
||||||
getIcons(0, true); // Opera will not run "load" event if file is already cached
|
getIcons(0, true); // Opera will not run "load" event if file is already cached
|
||||||
} catch (err1) {
|
} catch (err1) {
|
||||||
useFallback();
|
useFallback();
|
||||||
@@ -159,7 +160,7 @@ $(function() {
|
|||||||
$(useFallback);
|
$(useFallback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
svgdoc = parser.parseFromString(data, "text/xml");
|
svgdoc = parser.parseFromString(data, 'text/xml');
|
||||||
$(function () {
|
$(function () {
|
||||||
getIcons('ajax');
|
getIcons('ajax');
|
||||||
});
|
});
|
||||||
@@ -172,7 +173,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (err.responseText) {
|
if (err.responseText) {
|
||||||
svgdoc = parser.parseFromString(err.responseText, "text/xml");
|
svgdoc = parser.parseFromString(err.responseText, 'text/xml');
|
||||||
|
|
||||||
if (!svgdoc.childNodes.length) {
|
if (!svgdoc.childNodes.length) {
|
||||||
$(useFallback);
|
$(useFallback);
|
||||||
@@ -188,31 +189,31 @@ $(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIcons(evt, no_wait) {
|
function getIcons (evt, noWait) {
|
||||||
if (evt !== 'ajax') {
|
if (evt !== 'ajax') {
|
||||||
if(data_loaded) return;
|
if (dataLoaded) return;
|
||||||
// Webkit sometimes says svgdoc is undefined, other times
|
// Webkit sometimes says svgdoc is undefined, other times
|
||||||
// it fails to load all nodes. Thus we must make sure the "eof"
|
// it fails to load all nodes. Thus we must make sure the "eof"
|
||||||
// element is loaded.
|
// element is loaded.
|
||||||
svgdoc = data_el[0].contentDocument; // Needed again for Webkit
|
svgdoc = dataEl[0].contentDocument; // Needed again for Webkit
|
||||||
var isReady = (svgdoc && svgdoc.getElementById('svg_eof'));
|
var isReady = (svgdoc && svgdoc.getElementById('svg_eof'));
|
||||||
if(!isReady && !(no_wait && isReady)) {
|
if (!isReady && !(noWait && isReady)) {
|
||||||
load_attempts++;
|
loadAttempts++;
|
||||||
if(load_attempts < 50) {
|
if (loadAttempts < 50) {
|
||||||
setTimeout(getIcons, 20);
|
setTimeout(getIcons, 20);
|
||||||
} else {
|
} else {
|
||||||
useFallback();
|
useFallback();
|
||||||
data_loaded = true;
|
dataLoaded = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data_loaded = true;
|
dataLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
elems = $(svgdoc.firstChild).children(); // .getElementsByTagName('foreignContent');
|
elems = $(svgdoc.firstChild).children(); // .getElementsByTagName('foreignContent');
|
||||||
|
|
||||||
if (!opts.no_img) {
|
if (!opts.no_img) {
|
||||||
var testSrc = data_pre + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
|
var testSrc = dataPre + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
|
||||||
|
|
||||||
testImg = $(new Image()).attr({
|
testImg = $(new Image()).attr({
|
||||||
src: testSrc,
|
src: testSrc,
|
||||||
@@ -227,7 +228,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if(!icons_made) makeIcons();
|
if (!iconsMade) makeIcons();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +241,6 @@ $(function() {
|
|||||||
if (cl) icon.attr('class', 'svg_icon ' + cl);
|
if (cl) icon.attr('class', 'svg_icon ' + cl);
|
||||||
target.replaceWith(icon);
|
target.replaceWith(icon);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
target.append(icon);
|
target.append(icon);
|
||||||
}
|
}
|
||||||
if (isOpera) {
|
if (isOpera) {
|
||||||
@@ -250,32 +250,33 @@ $(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var holder;
|
||||||
var addIcon = function (icon, id) {
|
var addIcon = function (icon, id) {
|
||||||
if (opts.id_match === undefined || opts.id_match !== false) {
|
if (opts.id_match === undefined || opts.id_match !== false) {
|
||||||
setIcon(holder, icon, id, true);
|
setIcon(holder, icon, id, true);
|
||||||
}
|
}
|
||||||
svg_icons[id] = icon;
|
svgIcons[id] = icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeIcons (toImage, fallback) {
|
function makeIcons (toImage, fallback) {
|
||||||
if(icons_made) return;
|
if (iconsMade) return;
|
||||||
if (opts.no_img) toImage = false;
|
if (opts.no_img) toImage = false;
|
||||||
var holder, temp_holder;
|
var tempHolder;
|
||||||
|
|
||||||
if (toImage) {
|
if (toImage) {
|
||||||
temp_holder = $(document.createElement('div'));
|
tempHolder = $(document.createElement('div'));
|
||||||
temp_holder.hide().appendTo('body');
|
tempHolder.hide().appendTo('body');
|
||||||
}
|
}
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
var path = opts.fallback_path?opts.fallback_path:'';
|
var path = opts.fallback_path || '';
|
||||||
$.each(fallback, function (id, imgsrc) {
|
$.each(fallback, function (id, imgsrc) {
|
||||||
holder = $('#' + id);
|
holder = $('#' + id);
|
||||||
var icon = $(new Image())
|
var icon = $(new Image())
|
||||||
.attr({
|
.attr({
|
||||||
'class': 'svg_icon',
|
'class': 'svg_icon',
|
||||||
src: path + imgsrc,
|
src: path + imgsrc,
|
||||||
'width': icon_w,
|
'width': iconW,
|
||||||
'height': icon_h,
|
'height': iconH,
|
||||||
'alt': 'icon'
|
'alt': 'icon'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -289,10 +290,10 @@ $(function() {
|
|||||||
if (id === 'svg_eof') break;
|
if (id === 'svg_eof') break;
|
||||||
holder = $('#' + id);
|
holder = $('#' + id);
|
||||||
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];
|
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];
|
||||||
var svgroot = document.createElementNS(svgns, "svg");
|
var svgroot = document.createElementNS(svgns, 'svg');
|
||||||
// Per http://www.w3.org/TR/xml-names11/#defaulting, the namespace for
|
// Per http://www.w3.org/TR/xml-names11/#defaulting, the namespace for
|
||||||
// attributes should have no value.
|
// attributes should have no value.
|
||||||
svgroot.setAttributeNS(null, 'viewBox', [0,0,icon_w,icon_h].join(' '));
|
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' '));
|
||||||
|
|
||||||
// Make flexible by converting width/height to viewBox
|
// Make flexible by converting width/height to viewBox
|
||||||
var w = svg.getAttribute('width');
|
var w = svg.getAttribute('width');
|
||||||
@@ -307,10 +308,10 @@ $(function() {
|
|||||||
|
|
||||||
// Not using jQuery to be a bit faster
|
// Not using jQuery to be a bit faster
|
||||||
svgroot.setAttribute('xmlns', svgns);
|
svgroot.setAttribute('xmlns', svgns);
|
||||||
svgroot.setAttribute('width', icon_w);
|
svgroot.setAttribute('width', iconW);
|
||||||
svgroot.setAttribute('height', icon_h);
|
svgroot.setAttribute('height', iconH);
|
||||||
svgroot.setAttribute("xmlns:xlink", xlinkns);
|
svgroot.setAttribute('xmlns:xlink', xlinkns);
|
||||||
svgroot.setAttribute("class", 'svg_icon');
|
svgroot.setAttribute('class', 'svg_icon');
|
||||||
|
|
||||||
// Without cloning, Firefox will make another GET request.
|
// Without cloning, Firefox will make another GET request.
|
||||||
// With cloning, causes issue in Opera/Win/Non-EN
|
// With cloning, causes issue in Opera/Win/Non-EN
|
||||||
@@ -319,8 +320,8 @@ $(function() {
|
|||||||
svgroot.appendChild(svg);
|
svgroot.appendChild(svg);
|
||||||
var icon;
|
var icon;
|
||||||
if (toImage) {
|
if (toImage) {
|
||||||
temp_holder.empty().append(svgroot);
|
tempHolder.empty().append(svgroot);
|
||||||
var str = data_pre + encode64(unescape(encodeURIComponent(new XMLSerializer().serializeToString(svgroot))));
|
var str = dataPre + encode64(unescape(encodeURIComponent(new XMLSerializer().serializeToString(svgroot))));
|
||||||
icon = $(new Image())
|
icon = $(new Image())
|
||||||
.attr({'class': 'svg_icon', src: str});
|
.attr({'class': 'svg_icon', src: str});
|
||||||
} else {
|
} else {
|
||||||
@@ -328,91 +329,92 @@ $(function() {
|
|||||||
}
|
}
|
||||||
addIcon(icon, id);
|
addIcon(icon, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.placement) {
|
if (opts.placement) {
|
||||||
$.each(opts.placement, function (sel, id) {
|
$.each(opts.placement, function (sel, id) {
|
||||||
if(!svg_icons[id]) return;
|
if (!svgIcons[id]) return;
|
||||||
$(sel).each(function (i) {
|
$(sel).each(function (i) {
|
||||||
var copy = svg_icons[id].clone();
|
var copy = svgIcons[id].clone();
|
||||||
if (i > 0 && !toImage) copy = fixIDs(copy, i, true);
|
if (i > 0 && !toImage) copy = fixIDs(copy, i, true);
|
||||||
setIcon($(this), copy, id);
|
setIcon($(this), copy, id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!fallback) {
|
if (!fallback) {
|
||||||
if(toImage) temp_holder.remove();
|
if (toImage) tempHolder.remove();
|
||||||
if(data_el) data_el.remove();
|
if (dataEl) dataEl.remove();
|
||||||
if (testImg) testImg.remove();
|
if (testImg) testImg.remove();
|
||||||
}
|
}
|
||||||
if (opts.resize) $.resizeSvgIcons(opts.resize);
|
if (opts.resize) $.resizeSvgIcons(opts.resize);
|
||||||
icons_made = true;
|
iconsMade = true;
|
||||||
|
|
||||||
if(opts.callback) opts.callback(svg_icons);
|
if (opts.callback) opts.callback(svgIcons);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixIDs = function(svg_el, svg_num, force) {
|
fixIDs = function (svgEl, svgNum, force) {
|
||||||
var defs = svg_el.find('defs');
|
var defs = svgEl.find('defs');
|
||||||
if(!defs.length) return svg_el;
|
if (!defs.length) return svgEl;
|
||||||
var id_elems;
|
var idElems;
|
||||||
if (isOpera) {
|
if (isOpera) {
|
||||||
id_elems = defs.find('*').filter(function() {
|
idElems = defs.find('*').filter(function () {
|
||||||
return !!this.id;
|
return !!this.id;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
id_elems = defs.find('[id]');
|
idElems = defs.find('[id]');
|
||||||
}
|
}
|
||||||
|
|
||||||
var all_elems = svg_el[0].getElementsByTagName('*'), len = all_elems.length;
|
var allElems = svgEl[0].getElementsByTagName('*'), len = allElems.length;
|
||||||
|
|
||||||
id_elems.each(function(i) {
|
idElems.each(function (i) {
|
||||||
var id = this.id;
|
var id = this.id;
|
||||||
var no_dupes = ($(svgdoc).find('#' + id).length <= 1);
|
/*
|
||||||
if(isOpera) no_dupes = false; // Opera didn't clone svg_el, so not reliable
|
var noDupes = ($(svgdoc).find('#' + id).length <= 1);
|
||||||
// if(!force && no_dupes) return;
|
if (isOpera) noDupes = false; // Opera didn't clone svgEl, so not reliable
|
||||||
var new_id = 'x' + id + svg_num + i;
|
if(!force && noDupes) return;
|
||||||
this.id = new_id;
|
*/
|
||||||
|
var newId = 'x' + id + svgNum + i;
|
||||||
|
this.id = newId;
|
||||||
|
|
||||||
var old_val = 'url(#' + id + ')';
|
var oldVal = 'url(#' + id + ')';
|
||||||
var new_val = 'url(#' + new_id + ')';
|
var newVal = 'url(#' + newId + ')';
|
||||||
|
|
||||||
// Selector method, possibly faster but fails in Opera / jQuery 1.4.3
|
// Selector method, possibly faster but fails in Opera / jQuery 1.4.3
|
||||||
// svg_el.find('[fill="url(#' + id + ')"]').each(function() {
|
// svgEl.find('[fill="url(#' + id + ')"]').each(function() {
|
||||||
// this.setAttribute('fill', 'url(#' + new_id + ')');
|
// this.setAttribute('fill', 'url(#' + newId + ')');
|
||||||
// }).end().find('[stroke="url(#' + id + ')"]').each(function() {
|
// }).end().find('[stroke="url(#' + id + ')"]').each(function() {
|
||||||
// this.setAttribute('stroke', 'url(#' + new_id + ')');
|
// this.setAttribute('stroke', 'url(#' + newId + ')');
|
||||||
// }).end().find('use').each(function() {
|
// }).end().find('use').each(function() {
|
||||||
// if(this.getAttribute('xlink:href') == '#' + id) {
|
// if(this.getAttribute('xlink:href') == '#' + id) {
|
||||||
// this.setAttributeNS(xlinkns,'href','#' + new_id);
|
// this.setAttributeNS(xlinkns,'href','#' + newId);
|
||||||
// }
|
// }
|
||||||
// }).end().find('[filter="url(#' + id + ')"]').each(function() {
|
// }).end().find('[filter="url(#' + id + ')"]').each(function() {
|
||||||
// this.setAttribute('filter', 'url(#' + new_id + ')');
|
// this.setAttribute('filter', 'url(#' + newId + ')');
|
||||||
// });
|
// });
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
var elem = all_elems[i];
|
var elem = allElems[i];
|
||||||
if(elem.getAttribute('fill') === old_val) {
|
if (elem.getAttribute('fill') === oldVal) {
|
||||||
elem.setAttribute('fill', new_val);
|
elem.setAttribute('fill', newVal);
|
||||||
}
|
}
|
||||||
if(elem.getAttribute('stroke') === old_val) {
|
if (elem.getAttribute('stroke') === oldVal) {
|
||||||
elem.setAttribute('stroke', new_val);
|
elem.setAttribute('stroke', newVal);
|
||||||
}
|
}
|
||||||
if(elem.getAttribute('filter') === old_val) {
|
if (elem.getAttribute('filter') === oldVal) {
|
||||||
elem.setAttribute('filter', new_val);
|
elem.setAttribute('filter', newVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return svg_el;
|
return svgEl;
|
||||||
};
|
};
|
||||||
|
|
||||||
function useFallback () {
|
function useFallback () {
|
||||||
if(file.indexOf('.svgz') != -1) {
|
if (file.indexOf('.svgz') > -1) {
|
||||||
var reg_file = file.replace('.svgz','.svg');
|
var regFile = file.replace('.svgz', '.svg');
|
||||||
if (window.console) {
|
if (window.console) {
|
||||||
console.log('.svgz failed, trying with .svg');
|
console.log('.svgz failed, trying with .svg');
|
||||||
}
|
}
|
||||||
$.svgIcons(reg_file, opts);
|
$.svgIcons(regFile, opts);
|
||||||
} else if (opts.fallback) {
|
} else if (opts.fallback) {
|
||||||
makeIcons(false, opts.fallback);
|
makeIcons(false, opts.fallback);
|
||||||
}
|
}
|
||||||
@@ -421,7 +423,7 @@ $(function() {
|
|||||||
function encode64 (input) {
|
function encode64 (input) {
|
||||||
// base64 strings are 4/3 larger than the original string
|
// base64 strings are 4/3 larger than the original string
|
||||||
if (window.btoa) return window.btoa(input);
|
if (window.btoa) return window.btoa(input);
|
||||||
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||||
var output = new Array(Math.floor((input.length + 2) / 3) * 4);
|
var output = new Array(Math.floor((input.length + 2) / 3) * 4);
|
||||||
var chr1, chr2, chr3;
|
var chr1, chr2, chr3;
|
||||||
var enc1, enc2, enc3, enc4;
|
var enc1, enc2, enc3, enc4;
|
||||||
@@ -454,7 +456,7 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.getSvgIcon = function (id, uniqueClone) {
|
$.getSvgIcon = function (id, uniqueClone) {
|
||||||
var icon = svg_icons[id];
|
var icon = svgIcons[id];
|
||||||
if (uniqueClone && icon) {
|
if (uniqueClone && icon) {
|
||||||
icon = fixIDs(icon, 0, true).clone(true);
|
icon = fixIDs(icon, 0, true).clone(true);
|
||||||
}
|
}
|
||||||
@@ -463,12 +465,12 @@ $(function() {
|
|||||||
|
|
||||||
$.resizeSvgIcons = function (obj) {
|
$.resizeSvgIcons = function (obj) {
|
||||||
// FF2 and older don't detect .svg_icon, so we change it detect svg elems instead
|
// FF2 and older don't detect .svg_icon, so we change it detect svg elems instead
|
||||||
var change_sel = !$('.svg_icon:first').length;
|
var changeSel = !$('.svg_icon:first').length;
|
||||||
$.each(obj, function (sel, size) {
|
$.each(obj, function (sel, size) {
|
||||||
var arr = $.isArray(size);
|
var arr = $.isArray(size);
|
||||||
var w = arr ? size[0] : size,
|
var w = arr ? size[0] : size,
|
||||||
h = arr ? size[1] : size;
|
h = arr ? size[1] : size;
|
||||||
if(change_sel) {
|
if (changeSel) {
|
||||||
sel = sel.replace(/\.svg_icon/g, 'svg');
|
sel = sel.replace(/\.svg_icon/g, 'svg');
|
||||||
}
|
}
|
||||||
$(sel).each(function () {
|
$(sel).each(function () {
|
||||||
@@ -481,5 +483,4 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
function start_svg_edit() {
|
/* eslint-disable no-var */
|
||||||
var url = "chrome://svg-edit/content/editor/svg-editor.html";
|
function startSvgEdit () { // eslint-disable-line no-unused-vars
|
||||||
window.openDialog(url, "SVG Editor", "width=1024,height=700,menubar=no,toolbar=no");
|
var url = 'chrome://svg-edit/content/editor/svg-editor.html';
|
||||||
|
window.openDialog(url, 'SVG Editor', 'width=1024,height=700,menubar=no,toolbar=no');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
<menupopup id="menu_ToolsPopup">
|
<menupopup id="menu_ToolsPopup">
|
||||||
<menuitem insertafter="devToolsSeparator" label="SVG Editor"
|
<menuitem insertafter="devToolsSeparator" label="SVG Editor"
|
||||||
oncommand="start_svg_edit();" />
|
oncommand="startSvgEdit();" />
|
||||||
</menupopup>
|
</menupopup>
|
||||||
|
|
||||||
<!-- Firefox -->
|
<!-- Firefox -->
|
||||||
<statusbar id="status-bar">
|
<statusbar id="status-bar">
|
||||||
<statusbarpanel id="svg-edit-statusbar-button"
|
<statusbarpanel id="svg-edit-statusbar-button"
|
||||||
class="statusbarpanel-menu-iconic"
|
class="statusbarpanel-menu-iconic"
|
||||||
onclick="return start_svg_edit()"
|
onclick="return startSvgEdit()"
|
||||||
tooltip="SvgEdit">
|
tooltip="SvgEdit">
|
||||||
</statusbarpanel>
|
</statusbarpanel>
|
||||||
</statusbar>
|
</statusbar>
|
||||||
|
|||||||
@@ -1,49 +1,50 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
|
/* global $, Components, svgCanvas, netscape */
|
||||||
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/save handlers
|
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/save handlers
|
||||||
$(function () {
|
$(function () {
|
||||||
if (!window.Components) return;
|
if (!window.Components) return;
|
||||||
|
|
||||||
function moz_file_picker(readflag) {
|
function mozFilePicker (readflag) {
|
||||||
var fp = window.Components.classes["@mozilla.org/filepicker;1"].
|
var fp = window.Components.classes['@mozilla.org/filepicker;1']
|
||||||
createInstance(Components.interfaces.nsIFilePicker);
|
.createInstance(Components.interfaces.nsIFilePicker);
|
||||||
if(readflag)
|
if (readflag) fp.init(window, 'Pick a SVG file', fp.modeOpen);
|
||||||
fp.init(window, "Pick a SVG file", fp.modeOpen);
|
else fp.init(window, 'Pick a SVG file', fp.modeSave);
|
||||||
else
|
fp.defaultExtension = '*.svg';
|
||||||
fp.init(window, "Pick a SVG file", fp.modeSave);
|
|
||||||
fp.defaultExtension = "*.svg";
|
|
||||||
fp.show();
|
fp.show();
|
||||||
return fp.file;
|
return fp.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
svgCanvas.setCustomHandlers({
|
svgCanvas.setCustomHandlers({
|
||||||
'open':function() {
|
open: function () {
|
||||||
try {
|
try {
|
||||||
netscape.security.PrivilegeManager.
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||||
enablePrivilege("UniversalXPConnect");
|
var file = mozFilePicker(true);
|
||||||
var file = moz_file_picker(true);
|
if (!file) {
|
||||||
if(!file)
|
return null;
|
||||||
return(null);
|
}
|
||||||
|
|
||||||
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
|
var inputStream = Components.classes['@mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
inputStream.init(file, 0x01, 00004, null);
|
inputStream.init(file, 0x01, parseInt('00004', 8), null);
|
||||||
var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
|
var sInputStream = Components.classes['@mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptableInputStream);
|
||||||
sInputStream.init(inputStream);
|
sInputStream.init(inputStream);
|
||||||
svgCanvas.setSvgString(sInputStream.
|
svgCanvas.setSvgString(sInputStream.read(sInputStream.available()));
|
||||||
read(sInputStream.available()));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Exception while attempting to load" + e);
|
console.log('Exception while attempting to load' + e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'save':function(svg, str) {
|
save: function (svg, str) {
|
||||||
try {
|
try {
|
||||||
var file = moz_file_picker(false);
|
var file = mozFilePicker(false);
|
||||||
if(!file)
|
if (!file) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!file.exists())
|
if (!file.exists()) {
|
||||||
file.create(0, 0664);
|
file.create(0, parseInt('0664', 8));
|
||||||
|
}
|
||||||
|
|
||||||
var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
var out = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||||
out.init(file, 0x20 | 0x02, 00004,null);
|
out.init(file, 0x20 | 0x02, parseInt('00004', 8), null);
|
||||||
out.write(str, str.length);
|
out.write(str, str.length);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
|
|||||||
@@ -1,60 +1,57 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
|
/* globals $, svgCanvas */
|
||||||
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/save handlers
|
// Note: This JavaScript file must be included as the last script on the main HTML editor page to override the open/save handlers
|
||||||
$(function () {
|
$(function () {
|
||||||
if (window.opera && window.opera.io && window.opera.io.filesystem) {
|
if (window.opera && window.opera.io && window.opera.io.filesystem) {
|
||||||
svgCanvas.setCustomHandlers({
|
svgCanvas.setCustomHandlers({
|
||||||
'open':function() {
|
open: function () {
|
||||||
try {
|
try {
|
||||||
window.opera.io.filesystem.browseForFile(
|
window.opera.io.filesystem.browseForFile(
|
||||||
new Date().getTime(), /* mountpoint name */
|
new Date().getTime(), /* mountpoint name */
|
||||||
"", /* default location */
|
'', /* default location */
|
||||||
function (file) {
|
function (file) {
|
||||||
try {
|
try {
|
||||||
if (file) {
|
if (file) {
|
||||||
fstream = file.open(file, "r");
|
var fstream = file.open(file, 'r');
|
||||||
var output = "";
|
var output = '';
|
||||||
while (!fstream.eof) {
|
while (!fstream.eof) {
|
||||||
output += fstream.readLine();
|
output += fstream.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
svgCanvas.setSvgString(output); /* 'this' is bound to the filestream object here */
|
svgCanvas.setSvgString(output); /* 'this' is bound to the filestream object here */
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
console.log('Reading file failed.');
|
||||||
console.log("Reading file failed.");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false, /* not persistent */
|
false, /* not persistent */
|
||||||
false, /* no multiple selections */
|
false, /* no multiple selections */
|
||||||
"*.svg" /* file extension filter */
|
'*.svg' /* file extension filter */
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Open file failed.');
|
||||||
}
|
}
|
||||||
catch(e) {
|
|
||||||
console.log("Open file failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
'save':function(window, svg) {
|
save: function (window, svg) {
|
||||||
try {
|
try {
|
||||||
window.opera.io.filesystem.browseForSave(
|
window.opera.io.filesystem.browseForSave(
|
||||||
new Date().getTime(), /* mountpoint name */
|
new Date().getTime(), /* mountpoint name */
|
||||||
"", /* default location */
|
'', /* default location */
|
||||||
function (file) {
|
function (file) {
|
||||||
try {
|
try {
|
||||||
if (file) {
|
if (file) {
|
||||||
var fstream = file.open(file, "w");
|
var fstream = file.open(file, 'w');
|
||||||
fstream.write(svg, "UTF-8");
|
fstream.write(svg, 'UTF-8');
|
||||||
fstream.close();
|
fstream.close();
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
console.log('Write to file failed.');
|
||||||
console.log("Write to file failed.");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false /* not persistent */
|
false /* not persistent */
|
||||||
);
|
);
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
console.log('Save file failed.');
|
||||||
console.log("Save file failed.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,14 +6,12 @@
|
|||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<script>
|
<script>
|
||||||
/** this method adds the script that overrides the default open/save handlers */
|
/** this method adds the script that overrides the default open/save handlers */
|
||||||
function addHandlers()
|
function addHandlers () {
|
||||||
{
|
var cdoc = document.getElementById('container').contentDocument;
|
||||||
var cdoc = document.getElementById("container").contentDocument;
|
if (cdoc) {
|
||||||
if(cdoc)
|
var scriptelm = cdoc.createElement('script');
|
||||||
{
|
scriptelm.src = '../handlers.js';
|
||||||
var scriptelm = cdoc.createElement("script");
|
cdoc.getElementsByTagName('head')[0].appendChild(scriptelm);
|
||||||
scriptelm.src = "../handlers.js";
|
|
||||||
cdoc.getElementsByTagName("head")[0].appendChild(scriptelm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -209,7 +209,7 @@
|
|||||||
svgEditor.addExtension("Hello World", function () {
|
svgEditor.addExtension("Hello World", function () {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
svgicons: "extensions/helloworld-icon.xml",
|
svgicons: 'extensions/helloworld-icon.xml',
|
||||||
buttons: [{...}],
|
buttons: [{...}],
|
||||||
mouseDown: function() {
|
mouseDown: function() {
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
(function () {
|
(function () {
|
||||||
var doc = document;
|
var doc = document;
|
||||||
var disableBuilds = true;
|
var disableBuilds = true;
|
||||||
@@ -10,20 +11,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var byId = function (id) {
|
var byId = function (id) {
|
||||||
if (typeof id == 'string') { return doc.getElementById(id); }
|
if (typeof id === 'string') { return doc.getElementById(id); }
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
var query = function (query, root) {
|
var query = function (query, root) {
|
||||||
if (!query) { return []; }
|
if (!query) { return []; }
|
||||||
if (typeof query != 'string') { return toArray(query); }
|
if (typeof query !== 'string') { return toArray(query); }
|
||||||
if (typeof root == 'string') {
|
if (typeof root === 'string') {
|
||||||
root = byId(root);
|
root = byId(root);
|
||||||
if (!root) { return []; }
|
if (!root) { return []; }
|
||||||
}
|
}
|
||||||
|
|
||||||
root = root || document;
|
root = root || document;
|
||||||
var rootIsDoc = (root.nodeType == 9);
|
var rootIsDoc = (root.nodeType === 9);
|
||||||
var doc = rootIsDoc ? root : (root.ownerDocument || document);
|
var doc = rootIsDoc ? root : (root.ownerDocument || document);
|
||||||
|
|
||||||
// rewrite the query to be ID rooted
|
// rewrite the query to be ID rooted
|
||||||
@@ -38,13 +39,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var strToArray = function (s) {
|
var strToArray = function (s) {
|
||||||
if (typeof s == 'string' || s instanceof String) {
|
if (typeof s === 'string' || s instanceof String) {
|
||||||
if (s.indexOf(' ') < 0) {
|
if (s.indexOf(' ') < 0) {
|
||||||
a1[0] = s;
|
a1[0] = s;
|
||||||
return a1;
|
return a1;
|
||||||
} else {
|
|
||||||
return s.split(spaces);
|
|
||||||
}
|
}
|
||||||
|
return s.split(spaces);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
};
|
};
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
} else {
|
} else {
|
||||||
cls = '';
|
cls = '';
|
||||||
}
|
}
|
||||||
if (node.className != cls) {
|
if (node.className !== cls) {
|
||||||
node.className = cls;
|
node.className = cls;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
// test to determine if this browser can handle CSS transitions.
|
// test to determine if this browser can handle CSS transitions.
|
||||||
var cachedCanTransition =
|
var cachedCanTransition =
|
||||||
(isWK || (isFF && isFF > 3.6) || (isOpera && ver >= 10.5));
|
(isWK || (isFF && isFF > 3.6) || (isOpera && ver >= 10.5));
|
||||||
return function() { return cachedCanTransition; }
|
return function () { return cachedCanTransition; };
|
||||||
})();
|
})();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -125,10 +125,10 @@
|
|||||||
'past', 'current', 'future',
|
'past', 'current', 'future',
|
||||||
'far-future', 'distant-slide' ],
|
'far-future', 'distant-slide' ],
|
||||||
setState: function (state) {
|
setState: function (state) {
|
||||||
if (typeof state != 'string') {
|
if (typeof state !== 'string') {
|
||||||
state = this._states[state];
|
state = this._states[state];
|
||||||
}
|
}
|
||||||
if (state == 'current' && !this._visited) {
|
if (state === 'current' && !this._visited) {
|
||||||
this._visited = true;
|
this._visited = true;
|
||||||
this._makeBuildList();
|
this._makeBuildList();
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
_runAutos: function () {
|
_runAutos: function () {
|
||||||
if (this._currentState != 'current') {
|
if (this._currentState !== 'current') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// find the next auto, slice it out of the list, and run it
|
// find the next auto, slice it out of the list, and run it
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
}
|
}
|
||||||
removeClass(this._buildList.shift(), 'to-build');
|
removeClass(this._buildList.shift(), 'to-build');
|
||||||
return true;
|
return true;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
this._update();
|
this._update();
|
||||||
},
|
},
|
||||||
go: function (num) {
|
go: function (num) {
|
||||||
if (history.pushState && this.current != num) {
|
if (history.pushState && this.current !== num) {
|
||||||
history.replaceState(this.current, 'Slide ' + this.current, '#slide' + this.current);
|
history.replaceState(this.current, 'Slide ' + this.current, '#slide' + this.current);
|
||||||
}
|
}
|
||||||
this.current = num;
|
this.current = num;
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
|
|
||||||
_notesOn: false,
|
_notesOn: false,
|
||||||
showNotes: function () {
|
showNotes: function () {
|
||||||
var isOn = this._notesOn = !this._notesOn;
|
var notesOn = this._notesOn = !this._notesOn;
|
||||||
query('.notes').forEach(function (el) {
|
query('.notes').forEach(function (el) {
|
||||||
el.style.display = (notesOn) ? 'block' : 'none';
|
el.style.display = (notesOn) ? 'block' : 'none';
|
||||||
});
|
});
|
||||||
@@ -294,11 +294,9 @@
|
|||||||
}
|
}
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
this.next();
|
this.next();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleKeys: function (e) {
|
handleKeys: function (e) {
|
||||||
|
|
||||||
if (/^(input|textarea)$/i.test(e.target.nodeName)) return;
|
if (/^(input|textarea)$/i.test(e.target.nodeName)) return;
|
||||||
|
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
@@ -325,22 +323,17 @@
|
|||||||
} else if (delta < -SWIPE_SIZE) {
|
} else if (delta < -SWIPE_SIZE) {
|
||||||
this.prev();
|
this.prev();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
var slideshow = new SlideShow(query('.slide'));
|
var slideshow = new SlideShow(query('.slide')); // eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
document.querySelector('#toggle-counter').addEventListener('click', toggleCounter, false);
|
document.querySelector('#toggle-counter').addEventListener('click', toggleCounter, false);
|
||||||
document.querySelector('#toggle-size').addEventListener('click', toggleSize, false);
|
document.querySelector('#toggle-size').addEventListener('click', toggleSize, false);
|
||||||
document.querySelector('#toggle-transitions').addEventListener('click', toggleTransitions, false);
|
document.querySelector('#toggle-transitions').addEventListener('click', toggleTransitions, false);
|
||||||
document.querySelector('#toggle-gradients').addEventListener('click', toggleGradients, false);
|
document.querySelector('#toggle-gradients').addEventListener('click', toggleGradients, false);
|
||||||
|
|
||||||
|
|
||||||
var counters = document.querySelectorAll('.counter');
|
var counters = document.querySelectorAll('.counter');
|
||||||
var slides = document.querySelectorAll('.slide');
|
var slides = document.querySelectorAll('.slide');
|
||||||
|
|
||||||
@@ -354,8 +347,7 @@
|
|||||||
toArray(slides).forEach(function (el) {
|
toArray(slides).forEach(function (el) {
|
||||||
if (!/reduced/.test(el.className)) {
|
if (!/reduced/.test(el.className)) {
|
||||||
addClass(el, 'reduced');
|
addClass(el, 'reduced');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
removeClass(el, 'reduced');
|
removeClass(el, 'reduced');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -365,8 +357,7 @@
|
|||||||
toArray(slides).forEach(function (el) {
|
toArray(slides).forEach(function (el) {
|
||||||
if (!/no-transitions/.test(el.className)) {
|
if (!/no-transitions/.test(el.className)) {
|
||||||
addClass(el, 'no-transitions');
|
addClass(el, 'no-transitions');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
removeClass(el, 'no-transitions');
|
removeClass(el, 'no-transitions');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -376,15 +367,9 @@
|
|||||||
toArray(slides).forEach(function (el) {
|
toArray(slides).forEach(function (el) {
|
||||||
if (!/no-gradients/.test(el.className)) {
|
if (!/no-gradients/.test(el.className)) {
|
||||||
addClass(el, 'no-gradients');
|
addClass(el, 'no-gradients');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
removeClass(el, 'no-gradients');
|
removeClass(el, 'no-gradients');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
91
wave/wave.js
91
wave/wave.js
@@ -1,8 +1,9 @@
|
|||||||
|
/* eslint-disable no-var */
|
||||||
|
/* globals wave, $, svgCanvas */
|
||||||
var shapetime = {};
|
var shapetime = {};
|
||||||
var nodelete = false;
|
var nodelete = false;
|
||||||
|
|
||||||
function stateUpdated () {
|
function stateUpdated () {
|
||||||
|
|
||||||
// 'state' is an object of key-value pairs that map ids to JSON serialization of SVG elements
|
// 'state' is an object of key-value pairs that map ids to JSON serialization of SVG elements
|
||||||
// 'keys' is an array of all the keys in the state
|
// 'keys' is an array of all the keys in the state
|
||||||
var state = wave.getState();
|
var state = wave.getState();
|
||||||
@@ -12,7 +13,7 @@ function stateUpdated() {
|
|||||||
// 'e' is an integer describing the position within the document
|
// 'e' is an integer describing the position within the document
|
||||||
var k = this.id;
|
var k = this.id;
|
||||||
var v = state.get(k);
|
var v = state.get(k);
|
||||||
if(k == "selectorParentGroup" || k == "svgcontent"){
|
if (k === 'selectorParentGroup' || k === 'svgcontent') {
|
||||||
// meh
|
// meh
|
||||||
} else if (v) {
|
} else if (v) {
|
||||||
var ob = JSON.parse(v);
|
var ob = JSON.parse(v);
|
||||||
@@ -23,9 +24,7 @@ function stateUpdated() {
|
|||||||
// if (node) node.parentNode.removeChild(node);
|
// if (node) node.parentNode.removeChild(node);
|
||||||
}
|
}
|
||||||
// keys.remove(k);
|
// keys.remove(k);
|
||||||
|
|
||||||
} else if (!nodelete) {
|
} else if (!nodelete) {
|
||||||
|
|
||||||
this.parentNode.removeChild(this);
|
this.parentNode.removeChild(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -36,112 +35,104 @@ function stateUpdated() {
|
|||||||
var ob = JSON.parse(v);
|
var ob = JSON.parse(v);
|
||||||
if (ob) {
|
if (ob) {
|
||||||
if (!shapetime[k] || ob.time > shapetime[k]) {
|
if (!shapetime[k] || ob.time > shapetime[k]) {
|
||||||
var a;
|
var a = document.getElementById(k);
|
||||||
if(a = document.getElementById(k)){
|
if (a) {
|
||||||
var attrs = get_attrs(a);
|
var attrs = getAttrs(a);
|
||||||
if(JSON.stringify(attrs) != JSON.stringify(ob.attr)){
|
if (JSON.stringify(attrs) !== JSON.stringify(ob.attr)) {
|
||||||
shapetime[k] = ob.time
|
shapetime[k] = ob.time;
|
||||||
svgCanvas.updateElementFromJson(ob)
|
svgCanvas.updateElementFromJson(ob);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shapetime[k] = ob.time
|
shapetime[k] = ob.time;
|
||||||
svgCanvas.updateElementFromJson(ob)
|
svgCanvas.updateElementFromJson(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getId (canvas, objnum) {
|
function getId (canvas, objnum) {
|
||||||
var id = wave.getViewer().getId().split("@")[0];
|
var id = wave.getViewer().getId().split('@')[0];
|
||||||
var extra = SHA256(wave.getViewer().getId()); // in case the next step kills all the characters
|
var extra = SHA256(wave.getViewer().getId()); // in case the next step kills all the characters
|
||||||
for(var i = 0, l = id.length, n = ""; i < l; i++){
|
for (var i = 0, l = id.length, n = ''; i < l; i++) {
|
||||||
if("abcdefghijklmnopqrstuvwxyz0123456789".indexOf(id[i]) != -1){
|
if ('abcdefghijklmnopqrstuvwxyz0123456789'.indexOf(id[i]) > -1) {
|
||||||
n += id[i];
|
n += id[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "svg_"+n+"_"+extra.substr(0,5)+"_"+objnum;
|
return 'svg_' + n + '_' + extra.substr(0, 5) + '_' + objnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_attrs(a){
|
function getAttrs (a) {
|
||||||
var attrs = {};
|
var attrs = {};
|
||||||
for (var i = a.length; i--;) {
|
for (var i = a.length; i--;) {
|
||||||
var attr = a.item(i).nodeName;
|
var attr = a.item(i).nodeName;
|
||||||
if(",style,".indexOf(","+attr+",") == -1){
|
if (',style,'.indexOf(',' + attr + ',') === -1) {
|
||||||
attrs[attr] = a.item(i).nodeValue;
|
attrs[attr] = a.item(i).nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return attrs
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
if (wave && wave.isInWaveContainer()) {
|
if (wave && wave.isInWaveContainer()) {
|
||||||
wave.setStateCallback(function(){setTimeout(stateUpdated,10)});
|
wave.setStateCallback(function () {
|
||||||
|
setTimeout(stateUpdated, 10);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldchanged = svgCanvas.bind("changed", function(canvas, elem){
|
var oldchanged = svgCanvas.bind('changed', function (canvas, elem) {
|
||||||
if (oldchanged) oldchanged.apply(this, [canvas, elem]);
|
if (oldchanged) oldchanged.apply(this, [canvas, elem]);
|
||||||
|
|
||||||
var delta = {}
|
var delta = {};
|
||||||
$.each(elem, function () {
|
$.each(elem, function () {
|
||||||
|
|
||||||
var attrs = {};
|
|
||||||
var a = this.attributes;
|
var a = this.attributes;
|
||||||
if (a) {
|
if (a) {
|
||||||
var attrs = get_attrs(a)
|
var attrs = getAttrs(a);
|
||||||
var ob = {element: this.nodeName, attr: attrs};
|
var ob = {element: this.nodeName, attr: attrs};
|
||||||
|
|
||||||
ob.time = shapetime[this.id] = (new Date).getTime()
|
ob.time = shapetime[this.id] = new Date().getTime();
|
||||||
delta[this.id] = JSON.stringify(ob);
|
delta[this.id] = JSON.stringify(ob);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
wave.getState().submitDelta(delta)
|
wave.getState().submitDelta(delta);
|
||||||
// sendDelta(canvas, elem)
|
// sendDelta(canvas, elem)
|
||||||
|
|
||||||
});
|
});
|
||||||
// *
|
// *
|
||||||
|
var oldselected = svgCanvas.bind('selected', function (canvas, elem) {
|
||||||
var oldselected = svgCanvas.bind("selected", function(canvas, elem){
|
|
||||||
|
|
||||||
if (oldselected) oldselected.apply(this, [canvas, elem]);
|
if (oldselected) oldselected.apply(this, [canvas, elem]);
|
||||||
|
|
||||||
|
var delta = {};
|
||||||
var delta = {}
|
|
||||||
var deletions = 0;
|
var deletions = 0;
|
||||||
$.each(elem, function () {
|
$.each(elem, function () {
|
||||||
if(!this.parentNode && this != window){
|
if (!this.parentNode && this !== window) {
|
||||||
delta[this.id] = null;
|
delta[this.id] = null;
|
||||||
deletions ++
|
deletions++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (deletions > 0) {
|
if (deletions > 0) {
|
||||||
wave.getState().submitDelta(delta)
|
wave.getState().submitDelta(delta);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
///
|
//
|
||||||
svgCanvas.bind("cleared", function(){
|
svgCanvas.bind('cleared', function () {
|
||||||
// alert("cleared")
|
// alert("cleared")
|
||||||
var state = {}, keys = wave.getState().getKeys()
|
var state = {}, keys = wave.getState().getKeys();
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
state[keys[i]] = null;
|
state[keys[i]] = null;
|
||||||
}
|
}
|
||||||
wave.getState().submitDelta(state)
|
wave.getState().submitDelta(state);
|
||||||
});
|
});
|
||||||
// */
|
// */
|
||||||
svgCanvas.bind("getid", getId);
|
svgCanvas.bind('getid', getId);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window.gadgets) window.gadgets.util.registerOnLoadHandler(main);
|
||||||
|
|
||||||
if(window.gadgets) gadgets.util.registerOnLoadHandler(main);
|
|
||||||
|
|
||||||
// $(main)
|
// $(main)
|
||||||
|
|
||||||
|
/* eslint-disable */
|
||||||
// and why not use my stuff?
|
// and why not use my stuff?
|
||||||
function SHA256(b){function h(j,k){return(j>>e)+(k>>e)+((p=(j&o)+(k&o))>>e)<<e|p&o}function f(j,k){return j>>>k|j<<32-k}var g=[],d,c=3,l=[2],p,i,q,a,m=[],n=[];i=b.length*8;for(var e=16,o=65535,r="";c<312;c++){for(d=l.length;d--&&c%l[d]!=0;);d<0&&l.push(c)}b+="\u0080";for(c=0;c<=i;c+=8)n[c>>5]|=(b.charCodeAt(c/8)&255)<<24-c%32;n[(i+64>>9<<4)+15]=i;for(c=8;c--;)m[c]=parseInt(Math.pow(l[c],0.5).toString(e).substr(2,8),e);for(c=0;c<n.length;c+=e){a=m.slice(0);for(b=0;b<64;b++){g[b]=b<e?n[b+c]:h(h(h(f(g[b-2],17)^f(g[b-2],19)^g[b-2]>>>10,g[b-7]),f(g[b-15],7)^f(g[b-15],18)^g[b-15]>>>3),g[b-e]);i=h(h(h(h(a[7],f(a[4],6)^f(a[4],11)^f(a[4],25)),a[4]&a[5]^~a[4]&a[6]),parseInt(Math.pow(l[b],1/3).toString(e).substr(2,8),e)),g[b]);q=(f(a[0],2)^f(a[0],13)^f(a[0],22))+(a[0]&a[1]^a[0]&a[2]^a[1]&a[2]);for(d=8;--d;)a[d]=d==4?h(a[3],i):a[d-1];a[0]=h(i,q)}for(d=8;d--;)m[d]+=a[d]}for(c=0;c<8;c++)for(b=8;b--;)r+=(m[c]>>>b*4&15).toString(e);return r}
|
function SHA256(b){function h(j,k){return(j>>e)+(k>>e)+((p=(j&o)+(k&o))>>e)<<e|p&o}function f(j,k){return j>>>k|j<<32-k}var g=[],d,c=3,l=[2],p,i,q,a,m=[],n=[];i=b.length*8;for(var e=16,o=65535,r="";c<312;c++){for(d=l.length;d--&&c%l[d]!=0;);d<0&&l.push(c)}b+="\u0080";for(c=0;c<=i;c+=8)n[c>>5]|=(b.charCodeAt(c/8)&255)<<24-c%32;n[(i+64>>9<<4)+15]=i;for(c=8;c--;)m[c]=parseInt(Math.pow(l[c],0.5).toString(e).substr(2,8),e);for(c=0;c<n.length;c+=e){a=m.slice(0);for(b=0;b<64;b++){g[b]=b<e?n[b+c]:h(h(h(f(g[b-2],17)^f(g[b-2],19)^g[b-2]>>>10,g[b-7]),f(g[b-15],7)^f(g[b-15],18)^g[b-15]>>>3),g[b-e]);i=h(h(h(h(a[7],f(a[4],6)^f(a[4],11)^f(a[4],25)),a[4]&a[5]^~a[4]&a[6]),parseInt(Math.pow(l[b],1/3).toString(e).substr(2,8),e)),g[b]);q=(f(a[0],2)^f(a[0],13)^f(a[0],22))+(a[0]&a[1]^a[0]&a[2]^a[1]&a[2]);for(d=8;--d;)a[d]=d==4?h(a[3],i):a[d-1];a[0]=h(i,q)}for(d=8;d--;)m[d]+=a[d]}for(c=0;c<8;c++)for(b=8;b--;)r+=(m[c]>>>b*4&15).toString(e);return r}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user