client/js/main.js
author rougeronj
Tue, 16 Jun 2015 11:36:09 +0200
changeset 482 a55c33989404
parent 472 6dcff4438175
child 499 7d374d366b28
permissions -rw-r--r--
add type selector in the node editor add node_editor_template options to add custom templates for the node editor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
67085e6281e5 Added basic node/edge editing
veltr
parents: 4
diff changeset
     1
/* Declaring the Renkan Namespace Rkns and Default values */
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
     2
195
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
     3
(function(root) {
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
     4
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
     5
    "use strict";
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
     6
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
     7
    if (typeof root.Rkns !== "object") {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
     8
        root.Rkns = {};
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
     9
    }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    10
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    11
    var Rkns = root.Rkns;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    12
    var $ = Rkns.$ = root.jQuery;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    13
    var _ = Rkns._ = root._;
195
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
    14
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    15
    Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    16
        "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    17
        "#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    18
        "#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    19
        "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    20
        "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    21
        "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    22
        "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    23
    ];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    24
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    25
    Rkns.__renkans = [];
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
    26
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    27
    var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    28
        if (typeof _renkan !== "undefined") {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    29
            this.renkan = _renkan;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    30
            this.renkan.$.find(".Rk-Bin-Main").hide();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    31
            this.$ = Rkns.$('<li>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    32
                .addClass("Rk-Bin")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    33
                .appendTo(_renkan.$.find(".Rk-Bin-List"));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    34
            this.title_icon_$ = Rkns.$('<span>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    35
                .addClass("Rk-Bin-Title-Icon")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    36
                .appendTo(this.$);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    37
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    38
            var _this = this;
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
    39
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    40
            Rkns.$('<a>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    41
                .attr({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    42
                    href: "#",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    43
                    title: _renkan.translate("Close bin")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    44
                })
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    45
                .addClass("Rk-Bin-Close")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    46
                .html('&times;')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    47
                .appendTo(this.$)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    48
                .click(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    49
                    _this.destroy();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    50
                    if (!_renkan.$.find(".Rk-Bin-Main:visible").length) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    51
                        _renkan.$.find(".Rk-Bin-Main:last").slideDown();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    52
                    }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    53
                    _renkan.resizeBins();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    54
                    return false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    55
                });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    56
            Rkns.$('<a>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    57
                .attr({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    58
                    href: "#",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    59
                    title: _renkan.translate("Refresh bin")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    60
                })
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    61
                .addClass("Rk-Bin-Refresh")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    62
                .appendTo(this.$)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    63
                .click(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    64
                    _this.refresh();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    65
                    return false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    66
                });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    67
            this.count_$ = Rkns.$('<div>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    68
                .addClass("Rk-Bin-Count")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    69
                .appendTo(this.$);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    70
            this.title_$ = Rkns.$('<h2>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    71
                .addClass("Rk-Bin-Title")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    72
                .appendTo(this.$);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    73
            this.main_$ = Rkns.$('<div>')
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    74
                .addClass("Rk-Bin-Main")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    75
                .appendTo(this.$)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    76
                .html('<h4 class="Rk-Bin-Loading">' + _renkan.translate("Loading, please wait") + '</h4>');
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    77
            this.title_$.html(_opts.title || '(new bin)');
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    78
            this.renkan.resizeBins();
195
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
    79
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    80
            if (_opts.auto_refresh) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    81
                window.setInterval(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    82
                    _this.refresh();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    83
                }, _opts.auto_refresh);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    84
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    85
        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    86
    };
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
    87
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    88
    _BaseBin.prototype.destroy = function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    89
        this.$.detach();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    90
        this.renkan.resizeBins();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    91
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    92
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    93
    /* Point of entry */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    94
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    95
    var Renkan = Rkns.Renkan = function(_opts) {
34
08a366a35143 First part of SH design integration
veltr
parents: 28
diff changeset
    96
        var _this = this;
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
    97
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
    98
        Rkns.__renkans.push(this);
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
    99
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   100
        this.options = _.defaults(_opts, Rkns.defaults, {
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   101
            templates: _.defaults(_opts.templates, renkanJST) || renkanJST,
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   102
            node_editor_templates: _.defaults(_opts.node_editor_templates, Rkns.defaults.node_editor_templates)
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   103
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   104
        this.template = renkanJST['templates/main.html'];
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   105
482
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   106
        var types_templates = {};
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   107
        _.each(this.options.node_editor_templates, function(value, key) {
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   108
            types_templates[key] = _this.options.templates[value];
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   109
            delete _this.options.templates[value];
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   110
        });
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   111
        this.options.node_editor_templates = types_templates;
a55c33989404 add type selector in the node editor
rougeronj
parents: 472
diff changeset
   112
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   113
        _.each(this.options.property_files, function(f) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   114
            Rkns.$.getJSON(f, function(data) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   115
                _this.options.properties = _this.options.properties.concat(data);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   116
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   117
        });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   118
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   119
        this.read_only = this.options.read_only || !this.options.editor_mode;
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents: 455
diff changeset
   120
        
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents: 455
diff changeset
   121
        this.router = new Rkns.Router();
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents: 455
diff changeset
   122
        
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   123
        this.project = new Rkns.Models.Project();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   124
        this.dataloader = new Rkns.DataLoader.Loader(this.project, this.options);
433
e457ec945e50 replace underscore par lodash
ymh <ymh.work@gmail.com>
parents: 430
diff changeset
   125
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   126
        this.setCurrentUser = function(user_id, user_name) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   127
            this.project.addUser({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   128
                _id: user_id,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   129
                title: user_name
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   130
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   131
            this.current_user = user_id;
195
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
   132
            this.renderer.redrawUsers();
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   133
        };
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   134
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   135
        if (typeof this.options.user_id !== "undefined") {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   136
            this.current_user = this.options.user_id;
160
408da84d4dc0 Convert tabs added by ide configuration mistake
veltr
parents: 159
diff changeset
   137
        }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   138
        this.$ = Rkns.$("#" + this.options.container);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   139
        this.$
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   140
            .addClass("Rk-Main")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   141
            .html(this.template(this));
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   142
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   143
        this.tabs = [];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   144
        this.search_engines = [];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   145
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   146
        this.current_user_list = new Rkns.Models.UsersList();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   147
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   148
        this.current_user_list.on("add remove", function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   149
            if (this.renderer) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   150
                this.renderer.redrawUsers();
21
b43dd87f7ffa Added Drag+Drop from a tweet list
veltr
parents: 20
diff changeset
   151
            }
188
50b3287d06dd Added a basic space editor
veltr
parents: 185
diff changeset
   152
        });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   153
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   154
        this.colorPicker = (function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   155
            var _tmpl = renkanJST['templates/colorpicker.html'];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   156
            return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   157
                return _tmpl({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   158
                    c: c
26
2fad193bae98 Added basic LDT project import
veltr
parents: 24
diff changeset
   159
                });
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   160
            }).join("") + '</ul>';
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   161
        })();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   162
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   163
        if (this.options.show_editor) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   164
            this.renderer = new Rkns.Renderer.Scene(this);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   165
        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   166
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   167
        if (!this.options.search.length) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   168
            this.$.find(".Rk-Web-Search-Form").detach();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   169
        } else {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   170
            var _tmpl = renkanJST['templates/search.html'],
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   171
                _select = this.$.find(".Rk-Search-List"),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   172
                _input = this.$.find(".Rk-Web-Search-Input"),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   173
                _form = this.$.find(".Rk-Web-Search-Form");
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   174
            _.each(this.options.search, function(_search, _key) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   175
                if (Rkns[_search.type] && Rkns[_search.type].Search) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   176
                    _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
160
408da84d4dc0 Convert tabs added by ide configuration mistake
veltr
parents: 159
diff changeset
   177
                }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   178
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   179
            _select.html(
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   180
                _(this.search_engines).map(function(_search, _key) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   181
                    return _tmpl({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   182
                        key: _key,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   183
                        title: _search.getSearchTitle(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   184
                        className: _search.getBgClass()
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   185
                    });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   186
                }).join("")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   187
            );
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   188
            _select.find("li").click(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   189
                var _el = Rkns.$(this);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   190
                _this.setSearchEngine(_el.attr("data-key"));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   191
                _form.submit();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   192
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   193
            _form.submit(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   194
                if (_input.val()) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   195
                    var _search = _this.search_engine;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   196
                    _search.search(_input.val());
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   197
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   198
                return false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   199
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   200
            this.$.find(".Rk-Search-Current").mouseenter(
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   201
                function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   202
                    _select.slideDown();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   203
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   204
            );
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   205
            this.$.find(".Rk-Search-Select").mouseleave(
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   206
                function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   207
                    _select.hide();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   208
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   209
            );
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   210
            this.setSearchEngine(0);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   211
        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   212
        _.each(this.options.bins, function(_bin) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   213
            if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   214
                _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
160
408da84d4dc0 Convert tabs added by ide configuration mistake
veltr
parents: 159
diff changeset
   215
            }
20
bd58970ffd16 Refactoring to better fit the MVVM pattern
veltr
parents: 18
diff changeset
   216
        });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   217
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   218
        var elementDropped = false;
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   219
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   220
        this.$.find(".Rk-Bins")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   221
            .on("click", ".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   222
                var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   223
                if (_mainDiv.is(":hidden")) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   224
                    _this.$.find(".Rk-Bin-Main").slideUp();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   225
                    _mainDiv.slideDown();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   226
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   227
            });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   228
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   229
        if (this.options.show_editor) {
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   230
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   231
            this.$.find(".Rk-Bins").on("mouseover", ".Rk-Bin-Item", function(_e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   232
                var _t = Rkns.$(this);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   233
                if (_t && $(_t).attr("data-uri")) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   234
                    var _models = _this.project.get("nodes").where({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   235
                        uri: $(_t).attr("data-uri")
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   236
                    });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   237
                    _.each(_models, function(_model) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   238
                        _this.renderer.highlightModel(_model);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   239
                    });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   240
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   241
            }).mouseout(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   242
                _this.renderer.unhighlightAll();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   243
            }).on("mousemove", ".Rk-Bin-Item", function(e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   244
                try {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   245
                    this.dragDrop();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   246
                } catch (err) {}
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   247
            }).on("touchstart", ".Rk-Bin-Item", function(e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   248
                elementDropped = false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   249
            }).on("touchmove", ".Rk-Bin-Item", function(e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   250
                e.preventDefault();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   251
                var touch = e.originalEvent.changedTouches[0],
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   252
                    off = _this.renderer.canvas_$.offset(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   253
                    w = _this.renderer.canvas_$.width(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   254
                    h = _this.renderer.canvas_$.height();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   255
                if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   256
                    if (elementDropped) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   257
                        _this.renderer.onMouseMove(touch, true);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   258
                    } else {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   259
                        elementDropped = true;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   260
                        var div = document.createElement('div');
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   261
                        div.appendChild(this.cloneNode(true));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   262
                        _this.renderer.dropData({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   263
                            "text/html": div.innerHTML
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   264
                        }, touch);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   265
                        _this.renderer.onMouseDown(touch, true);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   266
                    }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   267
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   268
            }).on("touchend", ".Rk-Bin-Item", function(e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   269
                if (elementDropped) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   270
                    _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   271
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   272
                elementDropped = false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   273
            }).on("dragstart", ".Rk-Bin-Item", function(e) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   274
                var div = document.createElement('div');
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   275
                div.appendChild(this.cloneNode(true));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   276
                try {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   277
                    e.originalEvent.dataTransfer.setData("text/html", div.innerHTML);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   278
                } catch (err) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   279
                    e.originalEvent.dataTransfer.setData("text", div.innerHTML);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   280
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   281
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   282
196
2a2fcec209d0 Added in-graph search
veltr
parents: 195
diff changeset
   283
        }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   284
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   285
        Rkns.$(window).resize(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   286
            _this.resizeBins();
196
2a2fcec209d0 Added in-graph search
veltr
parents: 195
diff changeset
   287
        });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   288
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   289
        var lastsearch = false,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   290
            lastval = '';
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
   291
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   292
        this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   293
            var val = Rkns.$(this).val();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   294
            if (val === lastval) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   295
                return;
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
   296
            }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   297
            var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val : null);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   298
            if (search.source === lastsearch) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   299
                return;
1
45cca39b00ac First rendering tests
veltr
parents:
diff changeset
   300
            }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   301
            lastsearch = search.source;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   302
            _.each(_this.tabs, function(tab) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   303
                tab.render(search);
196
2a2fcec209d0 Added in-graph search
veltr
parents: 195
diff changeset
   304
            });
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   305
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   306
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   307
        this.$.find(".Rk-Bins-Search-Form").submit(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   308
            return false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   309
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   310
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   311
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   312
    Renkan.prototype.translate = function(_text) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   313
        if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   314
            return Rkns.i18n[this.options.language][_text];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   315
        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   316
        if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0, 2)] && Rkns.i18n[this.options.language.substr(0, 2)][_text]) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   317
            return Rkns.i18n[this.options.language.substr(0, 2)][_text];
196
2a2fcec209d0 Added in-graph search
veltr
parents: 195
diff changeset
   318
        }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   319
        return _text;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   320
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   321
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   322
    Renkan.prototype.onStatusChange = function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   323
        this.renderer.onStatusChange();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   324
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   325
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   326
    Renkan.prototype.setSearchEngine = function(_key) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   327
        this.search_engine = this.search_engines[_key];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   328
        this.$.find(".Rk-Search-Current").attr("class", "Rk-Search-Current " + this.search_engine.getBgClass());
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   329
        var listClasses = this.search_engine.getBgClass().split(" ");
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   330
        var classes = "";
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   331
        for (var i = 0; i < listClasses.length; i++) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   332
            classes += "." + listClasses[i];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   333
        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   334
        this.$.find(".Rk-Web-Search-Input.Rk-Search-Input").attr("placeholder", this.translate("Search in ") + this.$.find(".Rk-Search-List " + classes).html());
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   335
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   336
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   337
    Renkan.prototype.resizeBins = function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   338
        var _d = +this.$.find(".Rk-Bins-Head").outerHeight();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   339
        this.$.find(".Rk-Bin-Title:visible").each(function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   340
            _d += Rkns.$(this).outerHeight();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   341
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   342
        this.$.find(".Rk-Bin-Main").css({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   343
            height: this.$.find(".Rk-Bins").height() - _d
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   344
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   345
    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   346
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   347
    /* Utility functions */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   348
    var getUUID4 = function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   349
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   350
            var r = Math.random() * 16 | 0,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   351
                v = c === 'x' ? r : (r & 0x3 | 0x8);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   352
            return v.toString(16);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   353
        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   354
    };
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   355
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   356
    Rkns.Utils = {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   357
        getUUID4: getUUID4,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   358
        getUID: (function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   359
            function pad(n) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   360
                return n < 10 ? '0' + n : n;
196
2a2fcec209d0 Added in-graph search
veltr
parents: 195
diff changeset
   361
            }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   362
            var _d = new Date(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   363
                ID_AUTO_INCREMENT = 0,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   364
                ID_BASE = _d.getUTCFullYear() + '-' +
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   365
                pad(_d.getUTCMonth() + 1) + '-' +
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   366
                pad(_d.getUTCDate()) + '-' +
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   367
                getUUID4();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   368
            return function(_base) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   369
                var _n = (++ID_AUTO_INCREMENT).toString(16),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   370
                    _uidbase = (typeof _base === "undefined" ? "" : _base + "-");
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   371
                while (_n.length < 4) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   372
                    _n = '0' + _n;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   373
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   374
                return _uidbase + ID_BASE + '-' + _n;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   375
            };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   376
        })(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   377
        getFullURL: function(url) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   378
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   379
            if (typeof(url) === 'undefined' || url == null) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   380
                return "";
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   381
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   382
            if (/https?:\/\//.test(url)) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   383
                return url;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   384
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   385
            var img = new Image();
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   386
            img.src = url;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   387
            var res = img.src;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   388
            img.src = null;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   389
            return res;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   390
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   391
        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   392
        inherit: function(_baseClass, _callbefore) {
293
fba23fde14ba Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents: 290
diff changeset
   393
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   394
            var _class = function(_arg) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   395
                if (typeof _callbefore === "function") {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   396
                    _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   397
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   398
                _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   399
                if (typeof this._init === "function" && !this._initialized) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   400
                    this._init.apply(this, Array.prototype.slice.call(arguments, 0));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   401
                    this._initialized = true;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   402
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   403
            };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   404
            _.extend(_class.prototype, _baseClass.prototype);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   405
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   406
            return _class;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   407
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   408
        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   409
        regexpFromTextOrArray: (function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   410
            var charsub = [
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   411
                    '[aáàâä]',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   412
                    '[cç]',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   413
                    '[eéèêë]',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   414
                    '[iíìîï]',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   415
                    '[oóòôö]',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   416
                    '[uùûü]'
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   417
                ],
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   418
                removeChars = [
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   419
                    String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   420
                    "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   421
                    ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   422
                ],
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   423
                remsrc = "[\\" + removeChars.join("\\") + "]",
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   424
                remrx = new RegExp(remsrc, "gm"),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   425
                charsrx = _.map(charsub, function(c) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   426
                    return new RegExp(c);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   427
                });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   428
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   429
            function replaceText(_text) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   430
                var txt = _text.toLowerCase().replace(remrx, ""),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   431
                    src = "";
284
fa8035885814 build renderer with require js
cavaliet
parents: 242
diff changeset
   432
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   433
                function makeReplaceFunc(l) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   434
                    return function(k, v) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   435
                        l = l.replace(charsrx[k], v);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   436
                    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   437
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   438
                for (var j = 0; j < txt.length; j++) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   439
                    if (j) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   440
                        src += remsrc + "*";
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   441
                    }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   442
                    var l = txt[j];
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   443
                    _.each(charsub, makeReplaceFunc(l));
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   444
                    src += l;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   445
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   446
                return src;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   447
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   448
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   449
            function getSource(inp) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   450
                switch (typeof inp) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   451
                    case "string":
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   452
                        return replaceText(inp);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   453
                    case "object":
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   454
                        var src = '';
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   455
                        _.each(inp, function(v) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   456
                            var res = getSource(v);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   457
                            if (res) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   458
                                if (src) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   459
                                    src += '|';
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   460
                                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   461
                                src += res;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   462
                            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   463
                        });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   464
                        return src;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   465
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   466
                return '';
284
fa8035885814 build renderer with require js
cavaliet
parents: 242
diff changeset
   467
            }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   468
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   469
            return function(_textOrArray) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   470
                var source = getSource(_textOrArray);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   471
                if (source) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   472
                    var testrx = new RegExp(source, "im"),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   473
                        replacerx = new RegExp('(' + source + ')', "igm");
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   474
                    return {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   475
                        isempty: false,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   476
                        source: source,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   477
                        test: function(_t) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   478
                            return testrx.test(_t);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   479
                        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   480
                        replace: function(_text, _replace) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   481
                            return _text.replace(replacerx, _replace);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   482
                        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   483
                    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   484
                } else {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   485
                    return {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   486
                        isempty: true,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   487
                        source: '',
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   488
                        test: function() {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   489
                            return true;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   490
                        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   491
                        replace: function(_text) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   492
                            return text;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   493
                        }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   494
                    };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   495
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   496
            };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   497
        })(),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   498
        /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   499
        _MIN_DRAG_DISTANCE: 2,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   500
        /* Distance between the inner and outer radius of buttons that appear when hovering on a node */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   501
        _NODE_BUTTON_WIDTH: 40,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   502
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   503
        _EDGE_BUTTON_INNER: 2,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   504
        _EDGE_BUTTON_OUTER: 40,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   505
        /* Constants used to know if a specific action is to be performed when clicking on the canvas */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   506
        _CLICKMODE_ADDNODE: 1,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   507
        _CLICKMODE_STARTEDGE: 2,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   508
        _CLICKMODE_ENDEDGE: 3,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   509
        /* Node size step: Used to calculate the size change when clicking the +/- buttons */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   510
        _NODE_SIZE_STEP: Math.LN2 / 4,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   511
        _MIN_SCALE: 1 / 20,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   512
        _MAX_SCALE: 20,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   513
        _MOUSEMOVE_RATE: 80,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   514
        _DOUBLETAP_DELAY: 800,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   515
        /* Maximum distance in pixels (squared, to reduce calculations)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   516
         * between two taps when double-tapping on a touch terminal */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   517
        _DOUBLETAP_DISTANCE: 20 * 20,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   518
        /* A placeholder so a default colour is displayed when a node has a null value for its user property */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   519
        _USER_PLACEHOLDER: function(_renkan) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   520
            return {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   521
                color: _renkan.options.default_user_color,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   522
                title: _renkan.translate("(unknown user)"),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   523
                get: function(attr) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   524
                    return this[attr] || false;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   525
                }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   526
            };
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   527
        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   528
        /* The code for the "Drag and Add Bookmarklet", slightly minified and with whitespaces removed, though
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   529
         * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   530
         */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   531
        _BOOKMARKLET_CODE: function(_renkan) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   532
            return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">" +
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   533
                _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g, "_") +
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   534
                "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   535
        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   536
        /* Shortens text to the required length then adds ellipsis */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   537
        shortenText: function(_text, _maxlength) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   538
            return (_text.length > _maxlength ? (_text.substr(0, _maxlength) + '…') : _text);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   539
        },
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   540
        /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   541
         * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   542
        drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   543
            _selector.css({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   544
                width: (_options.tooltip_width - 2 * _options.tooltip_padding)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   545
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   546
            var _height = _selector.outerHeight() + 2 * _options.tooltip_padding,
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   547
                _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   548
                _left = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   549
                _right = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length + _options.tooltip_width),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   550
                _top = _coords.y - _height / 2;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   551
            if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   552
                _top = Math.max(paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2) - _height;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   553
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   554
            if (_top < _options.tooltip_margin) {
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   555
                _top = Math.min(_options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   556
            }
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   557
            var _bottom = _top + _height;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   558
            /* jshint laxbreak:true */
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   559
            _path.segments[0].point = _path.segments[7].point = _coords.add([_isLeft * _xmargin, 0]);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   560
            _path.segments[1].point.x = _path.segments[2].point.x = _path.segments[5].point.x = _path.segments[6].point.x = _left;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   561
            _path.segments[3].point.x = _path.segments[4].point.x = _right;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   562
            _path.segments[2].point.y = _path.segments[3].point.y = _top;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   563
            _path.segments[4].point.y = _path.segments[5].point.y = _bottom;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   564
            _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   565
            _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   566
            _path.closed = true;
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   567
            _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0, _top], [0, _bottom]);
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   568
            _selector.css({
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   569
                left: (_options.tooltip_padding + Math.min(_left, _right)),
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   570
                top: (_options.tooltip_padding + _top)
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   571
            });
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   572
            return _path;
459
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   573
        },
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   574
        // from http://stackoverflow.com/a/6444043
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   575
        increaseBrightness: function (hex, percent){
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   576
            // strip the leading # if it's there
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   577
            hex = hex.replace(/^\s*#|\s*$/g, '');
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   578
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   579
            // convert 3 char codes --> 6, e.g. `E0F` --> `EE00FF`
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   580
            if(hex.length === 3){
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   581
                hex = hex.replace(/(.)/g, '$1$1');
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   582
            }
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   583
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   584
            var r = parseInt(hex.substr(0, 2), 16),
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   585
                g = parseInt(hex.substr(2, 2), 16),
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   586
                b = parseInt(hex.substr(4, 2), 16);
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   587
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   588
            return '#' +
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   589
               ((0|(1<<8) + r + (256 - r) * percent / 100).toString(16)).substr(1) +
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   590
               ((0|(1<<8) + g + (256 - g) * percent / 100).toString(16)).substr(1) +
98cae534083d add node and edge stroke width + adjust text + arrow placement + conrol arrow visibility
ymh <ymh.work@gmail.com>
parents: 444
diff changeset
   591
               ((0|(1<<8) + b + (256 - b) * percent / 100).toString(16)).substr(1);
284
fa8035885814 build renderer with require js
cavaliet
parents: 242
diff changeset
   592
        }
444
19f0b7803aed add schema version + dataloaders to ensure data migrations + small correction for php server exmple + a readme for the php server example
ymh <ymh.work@gmail.com>
parents: 433
diff changeset
   593
    };
195
15e048e00002 Better User List Management
veltr
parents: 188
diff changeset
   594
})(window);
188
50b3287d06dd Added a basic space editor
veltr
parents: 185
diff changeset
   595
50b3287d06dd Added a basic space editor
veltr
parents: 185
diff changeset
   596
/* END main.js */