Commit 2a1fe6f4 authored by Krzysztof Kutt's avatar Krzysztof Kutt
Browse files

Initial version (by Urszula Ciaputa)

parent 02b2c8a0
simplebpmn Plugin for DokuWiki
Simple plugin that allows rendering of the diagrams specified in SimpleBPMN notation
All documentation for this plugin can be found at
http://example.com
If you install this plugin manually, make sure it is installed in
lib/plugins/simplebpmn/ - if the folder is called different it
will not work!
Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.
----
Copyright (C) Urszula Ciaputa <u.ciaputa@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See the COPYING file in your DokuWiki folder for details
<?php
/**
* DokuWiki Plugin simplebpmn (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Urszula Ciaputa <u.ciaputa@gmail.com>
*/
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'action.php');
class action_plugin_simplebpmn extends DokuWiki_Action_Plugin {
/**
* Register the eventhandlers
*/
function register(&$controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'bpmn_button', array ());
}
/**
* Inserts the toolbar button
*/
function bpmn_button(&$event, $param) {
$event->data[] = array (
'type' => 'format',
'title' => 'SimpleBPMN Notation',
'icon' => '../../plugins/simplebpmn/img/bpmn_button.png',
'open' => '<bpmn subprocesses=collapse diagram=before>',
'close' => '</bpmn>',
);
}
}
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/
(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},
unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});
function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";
// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
// New school multidimensional scroll (touchpads) deltas
deltaY = delta;
// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
})(jQuery);
/*
Base.js, version 1.1a
Copyright 2006-2010, Dean Edwards
License: http://www.opensource.org/licenses/mit-license.php
*/
var Base = function() {
// dummy
};
Base.extend = function(_instance, _static) { // subclass
var extend = Base.prototype.extend;
// build the prototype
Base._prototyping = true;
var proto = new this;
extend.call(proto, _instance);
proto.base = function() {
// call this method from any other method to invoke that method's ancestor
};
delete Base._prototyping;
// create the wrapper for the constructor function
//var constructor = proto.constructor.valueOf(); //-dean
var constructor = proto.constructor;
var klass = proto.constructor = function() {
if (!Base._prototyping) {
if (this._constructing || this.constructor == klass) { // instantiation
this._constructing = true;
constructor.apply(this, arguments);
delete this._constructing;
} else if (arguments[0] != null) { // casting
return (arguments[0].extend || extend).call(arguments[0], proto);
}
}
};
// build the class interface
klass.ancestor = this;
klass.extend = this.extend;
klass.forEach = this.forEach;
klass.implement = this.implement;
klass.prototype = proto;
klass.toString = this.toString;
klass.valueOf = function(type) {
//return (type == "object") ? klass : constructor; //-dean
return (type == "object") ? klass : constructor.valueOf();
};
extend.call(klass, _static);
// class initialisation
if (typeof klass.init == "function") klass.init();
return klass;
};
Base.prototype = {
extend: function(source, value) {
if (arguments.length > 1) { // extending with a name/value pair
var ancestor = this[source];
if (ancestor && (typeof value == "function") && // overriding a method?
// the valueOf() comparison is to avoid circular references
(!ancestor.valueOf || ancestor.valueOf() != value.valueOf()) &&
/\bbase\b/.test(value)) {
// get the underlying method
var method = value.valueOf();
// override
value = function() {
var previous = this.base || Base.prototype.base;
this.base = ancestor;
var returnValue = method.apply(this, arguments);
this.base = previous;
return returnValue;
};
// point to the underlying method
value.valueOf = function(type) {
return (type == "object") ? value : method;
};
value.toString = Base.toString;
}
this[source] = value;
} else if (source) { // extending with an object literal
var extend = Base.prototype.extend;
// if this object has a customised extend method then use it
if (!Base._prototyping && typeof this != "function") {
extend = this.extend || extend;
}
var proto = {toSource: null};
// do the "toString" and other methods manually
var hidden = ["constructor", "toString", "valueOf"];
// if we are prototyping then include the constructor
var i = Base._prototyping ? 0 : 1;
while (key = hidden[i++]) {
if (source[key] != proto[key]) {
extend.call(this, key, source[key]);
}
}
// copy each of the source object's properties to this object
for (var key in source) {
if (!proto[key]) extend.call(this, key, source[key]);
}
}
return this;
}
};
// initialise
Base = Base.extend({
constructor: function() {
this.extend(arguments[0]);
}
}, {
ancestor: Object,
version: "1.1",
forEach: function(object, block, context) {
for (var key in object) {
if (this.prototype[key] === undefined) {
block.call(context, object[key], key, object);
}
}
},
implement: function() {
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] == "function") {
// if it's a function, call it
arguments[i](this.prototype);
} else {
// add the interface using the extend method
this.prototype.extend(arguments[i]);
}
}
return this;
},
toString: function() {
return String(this.valueOf());
}
});
;(function ($) {
/* Adds few useful things to canvas */
CanvasRenderingContext2D.prototype.canvasPlus = {};
CanvasRenderingContext2D.prototype.getDottedPattern = function(refresh) {
if( !this.canvasPlus.dottedPattern || refresh){
var w = 3*this.lineWidth;
var dp = document.createElement('canvas');
dp.width=w;
dp.height=w;
var context = dp.getContext("2d");
context.fillStyle = this.strokeStyle;
context.fillRect(0,0,2,2);
this.canvasPlus.dottedPattern = this.createPattern(dp,'repeat');
}
return this.canvasPlus.dottedPattern;
};
CanvasRenderingContext2D.prototype.getLineHeight = function (refresh){
if( !this.canvasPlus.lineHeight || refresh ) {
var $d = $('<div></div>').css({
'font': this.font,
'visibility': 'hidden',
'position': 'absolute',
'top': 0,
'left': 0
}).text('`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?').appendTo('body');
this.canvasPlus.lineHeight = $d.height();
$d.remove();
}
return this.canvasPlus.lineHeight;
};
CanvasRenderingContext2D.prototype.getTextLines = function (text, maxWidth) {
var lines = [];
var words = text.split(" ");
var line = "";
for (var n = 0; n < words.length; n++) {
var testLine = line + words[n] + " ";
var metrics = this.measureText(testLine);
var testWidth = metrics.width;
if (testWidth > maxWidth) {
lines.push(line);
line = words[n] + " ";
}
else {
line = testLine;
}
}
if( $.trim(line).length ) {
lines.push(line);
}
return lines;
};
CanvasRenderingContext2D.prototype.getTextHeight = function (text, maxWidth) {
var lines = this.getTextLines(text,maxWidth);
return this.getLineHeight(true)*lines.length;
};
CanvasRenderingContext2D.prototype.fillWrapText = function (text, x, y, maxWidth){
var lines = this.getTextLines(text,maxWidth);
for (var n = 0; n < lines.length; n++) {
this.fillText(lines[n], x, y);
y += this.getLineHeight();
}
};
CanvasRenderingContext2D.prototype.strokeRoundedRect = function (x,y,w,h,r){
this.beginPath();
this.moveTo(x+r,y);
this.lineTo(x+w-r, y);
this.arcTo(x+w, y, x+w, y+r, r);
this.lineTo(x+w, y+h-r);
this.arcTo(x+w, y+h, x+w-r, y+h, r);
this.lineTo(x+r, y+h);
this.arcTo(x, y+h, x, y+h-r, r);
this.lineTo(x, y+r);
this.arcTo(x, y, x+15, y, r);
this.stroke();
};
})(jQuery);
var Geometry = {
/**
* Return distance between two points
*/
distance: function(start,end) {
return Math.sqrt( Math.pow( start[0] - end[0], 2 ) + Math.pow( start[1] - end[1], 2 ) );
},
/**
* Is point inside the box?
*/
inside: function(box,point) {
return point[0] > box[0] && point[0] < box[0] + box[2] && point[1] > box[1] && point[1] < box[1] + box[3];
},
/**
* Does ab line cross cd line?
*/
cross: function(a,b,c,d) {
var detA = Geometry.det(c,d,a);
var detB = Geometry.det(c,d,b);
var detC = Geometry.det(a,b,c);
var detD = Geometry.det(a,b,d);
if( !detA || !detB || !detC || !detD ) {
return (!detA && Geometry.in_range(c,d,a)) || (!detB && Geometry.in_range(c,d,b)) || (!detC && Geometry.in_range(a,b,c)) || (!detD && Geometry.in_range(a,b,d));
} else {
return Geometry.sign(detA) != Geometry.sign(detB) && Geometry.sign(detC) != Geometry.sign(detD);
}
},
det: function(a,b,c){
return a[0]*b[1] + b[0]*c[1] + c[0]*a[1] - c[0]*b[1] - a[0]*c[1] - b[0]*a[1]
},
in_range: function(a,b,c) {
return Math.min(a[0], b[0]) <= c[0] && c[0] <= Math.max(a[0], b[0]) && Math.min(a[1], b[1]) <= c[1] && c[1] <= Math.max(a[1], b[1]);
},
sign: function(a) {
return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
};
This diff is collapsed.
/*! JSON.minify()
v0.1 (c) Kyle Simpson
MIT License
*/
;(function(global){
if (typeof global.JSON == "undefined" || !global.JSON) {
global.JSON = {};
}
global.JSON.minify = function(json) {
var tokenizer = /"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,
in_string = false,
in_multiline_comment = false,
in_singleline_comment = false,
tmp, tmp2, new_str = [], ns = 0, from = 0, lc, rc
;
tokenizer.lastIndex = 0;
while (tmp = tokenizer.exec(json)) {
lc = RegExp.leftContext;
rc = RegExp.rightContext;
if (!in_multiline_comment && !in_singleline_comment) {
tmp2 = lc.substring(from);
if (!in_string) {
tmp2 = tmp2.replace(/(\n|\r|\s)*/g,"");
}
new_str[ns++] = tmp2;
}
from = tokenizer.lastIndex;
if (tmp[0] == "\"" && !in_multiline_comment && !in_singleline_comment) {
tmp2 = lc.match(/(\\)*$/);
if (!in_string || !tmp2 || (tmp2[0].length % 2) == 0) { // start of string with ", or unescaped " character found to end string
in_string = !in_string;
}
from--; // include " character in next catch
rc = json.substring(from);
}
else if (tmp[0] == "/*" && !in_string && !in_multiline_comment && !in_singleline_comment) {
in_multiline_comment = true;
}
else if (tmp[0] == "*/" && !in_string && in_multiline_comment && !in_singleline_comment) {
in_multiline_comment = false;
}
else if (tmp[0] == "//" && !in_string && !in_multiline_comment && !in_singleline_comment) {
in_singleline_comment = true;
}
else if ((tmp[0] == "\n" || tmp[0] == "\r") && !in_string && !in_multiline_comment && in_singleline_comment) {
in_singleline_comment = false;
}
else if (!in_multiline_comment && !in_singleline_comment && !(/\n|\r|\s/.test(tmp[0]))) {
new_str[ns++] = tmp[0];
}
}
new_str[ns++] = rc;
return new_str.join("");
};
})(this);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment