# HG changeset patch # User ymh # Date 1366748110 -7200 # Node ID f978d70a9e639576a1e78ef8c3c5e9e00b335480 # Parent eb97351d5e9be0ec6d361143bacdb3c395502be4 Added tag V00.06.03 for changeset 5c34cc851c4b diff -r eb97351d5e9b -r f978d70a9e63 client/css/renkan.css --- a/client/css/renkan.css Tue Apr 23 22:14:59 2013 +0200 +++ b/client/css/renkan.css Tue Apr 23 22:15:10 2013 +0200 @@ -42,7 +42,7 @@ } html { - overflow: hidden; + overflow: hidden; } body { @@ -109,7 +109,7 @@ .Rk-UserList { box-shadow: 0 2px 2px #999999; - position: relative; z-index: 3; display: none; padding-top: 8px; + position: relative; z-index: 4; display: none; padding-top: 8px; } .Rk-User { @@ -131,7 +131,7 @@ } .Rk-TopBar-Tooltip { - position: absolute; top: 31px; left: 50%; margin-left: -60px; width: 120px; z-index: 3; display: none; + position: absolute; top: 31px; left: 50%; margin-left: -60px; width: 120px; z-index: 4; display: none; } .Rk-TopBar-Tooltip-Contents { @@ -185,11 +185,11 @@ } .Rk-Save-Button.Rk-Save-ReadOnly, .Rk-Save-Button.Rk-Save-ReadOnly:hover { - background-position: -172px -35px; + background-position: -172px -35px; } .Rk-Save-Button.Rk-Save-Online, .Rk-Save-Button.Rk-Save-Online:hover { - background-position: -172px 0; + background-position: -172px 0; } .Rk-Bookmarklet-Button { @@ -210,25 +210,41 @@ /* Canvas */ +.Rk-Editing-Space { + position: absolute; left: 0; top: 35px; right: 0; bottom: 0; overflow: hidden; + background: -moz-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); + background: -webkit-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); + background: -ms-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); +} + +.Rk-Editing-Space-Full { + top: 0; +} + .Rk-Canvas { - background: -moz-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); - background: -webkit-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); - background: -ms-radial-gradient( center, circle, #ffffff 40%, #e0e0e0 90%); - position: absolute; left: 0; top: 35px; right: 0; bottom: 0; z-index: 1; + position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 2; } -.Rk-Editing-Space-Full .Rk-Canvas { - top: 0; +/* Node Labels */ + +.Rk-Labels { + position: absolute; left: 0; top: 0; z-index: 1; + font-family: "Segoe UI", "Helvetica Neue", Arial, Helvetica, sans-serif; +} + +.Rk-Label { + position: absolute; width: 160px; margin-left: -80px; text-align: center; font-size: 13px; line-height: 13px; +} + +.Rk-Edge-Label { + font-size: 11px; transform-origin: 50% 0; -moz-transform-origin: 50% 0; + -webkit-transform-origin: 50% 0; -ms-transform-origin: 50% 0; } /* Editors */ .Rk-Editor { - position: absolute; left: 0; top: 35px; right: 0; z-index: 2; -} - -.Rk-Editing-Space-Full .Rk-Editor { - top: 0; + position: absolute; left: 0; top: 0; z-index: 3; } .Rk-Notifications { @@ -272,7 +288,7 @@ .Rk-Edit-ImgPreview { border: 1px solid #666; margin: 5px auto; display: block; - max-width: 253px !important; max-height: 100px !important; + max-width: 253px !important; max-height: 200px !important; } .Rk-Editor textarea { @@ -309,57 +325,61 @@ } .Rk-Edit-Size-Up, .Rk-Edit-Size-Down { - font-size: 13px; font-weight: bold; padding: 0 4px; background: #ffffff; color: #000000; border: 1px solid #cccccc; - text-decoration: none; + font-size: 13px; font-weight: bold; padding: 0 4px; background: #ffffff; color: #000000; border: 1px solid #cccccc; + text-decoration: none; } .Rk-Edit-Size-Up:hover, .Rk-Edit-Size-Down:hover { - background: #666666; + background: #666666; } .Rk-Edit-Size-Value { - display: inline-block; + display: inline-block; padding: 0 5px; text-align: center; width: 20px; } .Rk-Edit-Vocabulary-Class { - color: #999999; font-style: italic; font-weight: bold; + color: #999999; font-style: italic; font-weight: bold; } .Rk-Edit-Vocabulary-Property { - padding-left: 20px; + padding-left: 20px; } .Rk-Edit-Direction { - border: 1px solid #666; padding: 3px 5px; line-height: 20px; border-radius: 3px; background: #f0f0f0; cursor: pointer; + border: 1px solid #666; padding: 3px 5px; line-height: 20px; border-radius: 3px; background: #f0f0f0; cursor: pointer; } .Rk-Edit-Direction:hover { - background: #c0c0c0; + background: #c0c0c0; } .Rk-Display-Title a { - text-decoration: none; color: #000000; + text-decoration: none; color: #000000; } .Rk-Display-Title a:hover { - text-decoration: underline; + text-decoration: underline; } .Rk-Display-URI { - font-style: italic; + font-style: italic; +} + +.Rk-Display-ImgPreview { + margin: 5px auto; display: block; max-width: 255px !important; max-height: 260px !important; } .Rk-Fold-Bins { - position: absolute; top: 5px; width: 12px; text-align: center; font-size: 16px; cursor: pointer; - line-height: 16px; padding: 4px; color: #ffffff; background: #666666; border-radius: 0 6px 6px 0; - font-weight: bold; + position: absolute; top: 5px; width: 12px; text-align: center; font-size: 16px; cursor: pointer; + line-height: 16px; padding: 4px; color: #ffffff; background: #666666; border-radius: 0 6px 6px 0; + font-weight: bold; } .Rk-Fold-Bins:hover { - background: #333333; + background: #333333; } .Rk-ZoomButtons { @@ -522,7 +542,7 @@ cursor: move; } -.Rk-Bin-Item:hover { +.Rk-Bin-Item:hover, .Rk-Bin-Item.hover { background: -moz-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%); background: -webkit-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%); background: -ms-linear-gradient(top, rgba(0,0,0,.1) 20%, rgba(128,128,128,.1) 80%); @@ -551,7 +571,7 @@ } .Rk-Bin-Main h4 a { - color: #303080; + color: #303080; } .Rk-Twitter-Icon { @@ -615,7 +635,7 @@ } .Rk-ResourceList-Image { - float: left; max-width: 100px; max-height: 75px; margin-right: 2px; + float: left; max-width: 100px; max-height: 75px; margin-right: 2px; } .Rk-Ldt-Icon, .Rk-Ldt-Title-Icon { diff -r eb97351d5e9b -r f978d70a9e63 client/img/revert.png Binary file client/img/revert.png has changed diff -r eb97351d5e9b -r f978d70a9e63 client/js/defaults.js --- a/client/js/defaults.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/defaults.js Tue Apr 23 22:15:10 2013 +0200 @@ -1,33 +1,39 @@ Rkns.defaults = { - + language: (navigator.language || navigator.userLanguage || "en"), - /* GUI Language */ + /* GUI Language */ container: "renkan", - /* GUI Container DOM element ID */ + /* GUI Container DOM element ID */ search: [], - /* List of Search Engines */ - bins: [], - /* List of Bins */ - static_url: "", - /* URL for static resources */ - show_bins: true, - /* Show bins in left column */ - properties: [], - /* Semantic properties for edges */ - read_only: false, - /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */ - editor_mode: true, - /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */ + /* List of Search Engines */ + bins: [], + /* List of Bins */ + static_url: "", + /* URL for static resources */ + show_bins: true, + /* Show bins in left column */ + properties: [], + /* Semantic properties for edges */ + read_only: false, + /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */ + editor_mode: true, + /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */ snapshot_mode: false, - /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */ - show_top_bar: true, - /* Show the top bar, (title, buttons, users) */ - default_user_color: "#303030", - - /* MINI-MAP OPTIONS */ - + /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */ + show_top_bar: true, + /* Show the top bar, (title, buttons, users) */ + default_user_color: "#303030", + size_bug_fix: true, + /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */ + force_resize: false, + allow_double_click: true, + /* Allows Double Click to create a node on an empty background */ + element_delete_delay: 5000, + + /* MINI-MAP OPTIONS */ + show_minimap: true, - /* Show a small map at the bottom right */ + /* Show a small map at the bottom right */ minimap_width: 160, minimap_height: 120, minimap_background_color: "#ffffff", @@ -36,53 +42,50 @@ minimap_highlight_weight: 5, /* EDGE/NODE COMMON OPTIONS */ - - buttons_background: "#202020", - buttons_label_color: "#c000c0", - buttons_label_font_size: 9, - - /* NODE DISPLAY OPTIONS */ - + + buttons_background: "#202020", + buttons_label_color: "#c000c0", + buttons_label_font_size: 9, + + /* NODE DISPLAY OPTIONS */ + show_node_circles: true, - /* Show circles for nodes */ - clip_node_images: true, - /* Constraint node images to circles */ - node_size_base: 25, - node_stroke_width: 2, - selected_node_stroke_width: 4, - node_fill_color: "#ffffff", - highlighted_node_fill_color: "#ffff00", - node_label_color: "#000000", - node_label_font_size: 10, - node_label_font: 'Helvetica, Arial, sans-serif', - node_label_distance: 5, - /* Vertical distance between node and label */ - node_label_max_length: 40, - /* Maximum displayed text length */ - - /* EDGE DISPLAY OPTIONS */ - - edge_stroke_width: 2, - selected_edge_stroke_width: 4, - edge_label_color: "#000000", - edge_label_font_size: 9, - edge_label_font: 'Helvetica, Arial, sans-serif', - edge_label_distance: -3, - edge_label_max_length: 20, + /* Show circles for nodes */ + clip_node_images: true, + /* Constraint node images to circles */ + node_size_base: 25, + node_stroke_width: 2, + selected_node_stroke_width: 4, + node_fill_color: "#ffffff", + highlighted_node_fill_color: "#ffff00", + node_label_distance: 5, + /* Vertical distance between node and label */ + node_label_max_length: 60, + /* Maximum displayed text length */ + label_untitled_nodes: "(untitled)", + /* Label to display on untitled nodes */ + + /* EDGE DISPLAY OPTIONS */ + + edge_stroke_width: 2, + selected_edge_stroke_width: 4, + edge_label_distance: 0, + edge_label_max_length: 20, edge_arrow_length: 18, edge_arrow_width: 12, edge_gap_in_bundles: 12, + label_untitled_edges: "", /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */ - tooltip_width: 275, - tooltip_padding: 10, - tooltip_margin: 15, + tooltip_width: 275, + tooltip_padding: 10, + tooltip_margin: 15, tooltip_arrow_length : 20, tooltip_arrow_width : 40, - tooltip_top_color: "#f0f0f0", - tooltip_bottom_color: "#d0d0d0", - tooltip_border_color: "#808080", - tooltip_border_width: 1 - -} + tooltip_top_color: "#f0f0f0", + tooltip_bottom_color: "#d0d0d0", + tooltip_border_color: "#808080", + tooltip_border_width: 1 + +}; diff -r eb97351d5e9b -r f978d70a9e63 client/js/full-json.js --- a/client/js/full-json.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/full-json.js Tue Apr 23 22:15:10 2013 +0200 @@ -14,14 +14,14 @@ var _save = function() { var _data = _proj.toJSON(); if (!_renkan.read_only) { - Rkns.$.ajax({ - type: _opts.http_method, - url: _opts.url, - contentType: "application/json", - data: JSON.stringify(_data), - success: function(data, textStatus, jqXHR) { - } - }); + Rkns.$.ajax({ + type: _opts.http_method, + url: _opts.url, + contentType: "application/json", + data: JSON.stringify(_data), + success: function(data, textStatus, jqXHR) { + } + }); } } diff -r eb97351d5e9b -r f978d70a9e63 client/js/i18n.js --- a/client/js/i18n.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/i18n.js Tue Apr 23 22:15:10 2013 +0200 @@ -21,6 +21,7 @@ "Zoom Out": "Rapetisser l’échelle", "Edit": "Éditer", "Remove": "Supprimer", + "Cancel deletion": "Annuler la suppression", "Link to another node": "Créer un lien", "Enlarge": "Agrandir", "Shrink": "Rétrécir", diff -r eb97351d5e9b -r f978d70a9e63 client/js/ldtjson-bin.js --- a/client/js/ldtjson-bin.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/ldtjson-bin.js Tue Apr 23 22:15:10 2013 +0200 @@ -1,13 +1,13 @@ Rkns.Ldt = {} Rkns.Ldt.Bin = function(_renkan, _opts) { - if (_opts.ldt_type) { - var resclass = Rkns.Ldt[_opts.ldt_type+"Bin"]; - if (resclass) { - return new resclass(_renkan, _opts); - } - } - console.error("No such LDT Bin Type"); + if (_opts.ldt_type) { + var resclass = Rkns.Ldt[_opts.ldt_type+"Bin"]; + if (resclass) { + return new resclass(_renkan, _opts); + } + } + console.error("No such LDT Bin Type"); } Rkns.Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin); @@ -179,7 +179,7 @@ _rgxp = new RegExp('('+rxbase+')','gi'), rxtest = new RegExp(rxbase,'i') } else { - var rxbase = this.search.replace(/(\W)/g,'\\$1'), + var rxbase = this.search.replace(/(\W)/g,'\\$1'), _rgxp = new RegExp('('+rxbase+')','gi'); } function highlight(_text) { diff -r eb97351d5e9b -r f978d70a9e63 client/js/list-bin.js --- a/client/js/list-bin.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/list-bin.js Tue Apr 23 22:15:10 2013 +0200 @@ -12,53 +12,53 @@ ); Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) { - this.renkan = _renkan; + this.renkan = _renkan; this.title_$.html(_opts.title); if (_opts.list) { - this.data = _opts.list; + this.data = _opts.list; } this.refresh(); } Rkns.ResourceList.Bin.prototype.render = function(searchstr) { if (searchstr) { - var _rgxp = new RegExp('('+(searchstr).replace(/(\W)/g,'\\$1')+')','gi'), - rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i'); + var _rgxp = new RegExp('('+(searchstr).replace(/(\W)/g,'\\$1')+')','gi'), + rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i'); } function highlight(_text) { - if (searchstr) { - return _text.replace(_rgxp, "$1"); - } else { - return _text; - } + if (searchstr) { + return _text.replace(_rgxp, "$1"); + } else { + return _text; + } } var _html = "", _this = this, count = 0; Rkns._(this.data).each(function(_item) { - if (typeof _item === "string") { - if (/^(https?:\/\/|www)/.test(_item)) { - var _element = { url: _item } - } else { - var _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() }, - _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/); - if (_match) { - _element.url = _match[0]; - } - if (_element.title.length > 80) { - _element.description = _element.title; - _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…'); - } - } - } else { - var _element = _item; - } + if (typeof _item === "string") { + if (/^(https?:\/\/|www)/.test(_item)) { + var _element = { url: _item } + } else { + var _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() }, + _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/); + if (_match) { + _element.url = _match[0]; + } + if (_element.title.length > 80) { + _element.description = _element.title; + _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…'); + } + } + } else { + var _element = _item; + } var title = _element.title || (_element.url || "").replace(/^https?:\/\/(www\.)?/,'').replace(/^(.{40}).+$/,'$1…'), url = _element.url || "", description = _element.description || "", image = _element.image || ""; if (url && !/^https?:\/\//.test(url)) { - url = 'http://' + url; + url = 'http://' + url; } if (searchstr && !rxtest.test(title) && !rxtest.test(description)) { return; @@ -90,6 +90,6 @@ Rkns.ResourceList.Bin.prototype.refresh = function() { if (this.data) { - this.render(); + this.render(); } } \ No newline at end of file diff -r eb97351d5e9b -r f978d70a9e63 client/js/main.js --- a/client/js/main.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/main.js Tue Apr 23 22:15:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright 2012 Institut de recherche et d'innovation + * Copyright 2012-2013 Institut de recherche et d'innovation * contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron * * contact@iri.centrepompidou.fr @@ -52,25 +52,25 @@ Rkns.$('') .attr({ - href: "#", - title: _renkan.translate("Close bin") - }) + href: "#", + title: _renkan.translate("Close bin") + }) .addClass("Rk-Bin-Close") .html('×') .appendTo(this.$) .click(function() { _this.destroy(); if (!_renkan.$.find(".Rk-Bin-Main:visible").length) { - _renkan.$.find(".Rk-Bin-Main:last").slideDown(); + _renkan.$.find(".Rk-Bin-Main:last").slideDown(); } _renkan.resizeBins(); return false; }); Rkns.$('') .attr({ - href: "#", - title: _renkan.translate("Refresh bin") - }) + href: "#", + title: _renkan.translate("Refresh bin") + }) .addClass("Rk-Bin-Refresh") .appendTo(this.$) .click(function() { @@ -96,12 +96,12 @@ },_opts.auto_refresh) } } -} +}; Rkns._BaseBin.prototype.destroy = function() { this.$.detach(); this.renkan.resizeBins(); -} +}; /* Point of entry */ @@ -110,19 +110,16 @@ this.options = _.defaults(_opts, Rkns.defaults); - Rkns._(this.options.property_files).each(function(f) { - Rkns.$.getJSON(f, function(data) { - _this.options.properties = _this.options.properties.concat(data); - }); - }); + Rkns._(this.options.property_files).each(function(f) { + Rkns.$.getJSON(f, function(data) { + _this.options.properties = _this.options.properties.concat(data); + }); + }); this.read_only = this.options.read_only || !this.options.editor_mode; this.project = new Rkns.Models.Project(); - this.translate = function(_text) { - return (Rkns.i18n[_this.options.language] || Rkns.i18n[_this.options.language.substr(0,2)] || {})[_text] || _text; - } if (typeof this.options.user_id !== "undefined") { this.current_user = this.options.user_id; } @@ -144,9 +141,9 @@ _input = this.$.find(".Rk-Web-Search-Input") _form = this.$.find(".Rk-Web-Search-Form"); Rkns._(this.options.search).each(function(_search, _key) { - if (Rkns[_search.type] && Rkns[_search.type].Search) { - _this.search_engines.push(new Rkns[_search.type].Search(_this, _search)); - } + if (Rkns[_search.type] && Rkns[_search.type].Search) { + _this.search_engines.push(new Rkns[_search.type].Search(_this, _search)); + } }); _select.html( Rkns._(this.search_engines).map(function(_search, _key) { @@ -178,11 +175,13 @@ this.setSearchEngine(0); } Rkns._(this.options.bins).each(function(_bin) { - if (Rkns[_bin.type] && Rkns[_bin.type].Bin) { - _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin)); - } + if (Rkns[_bin.type] && Rkns[_bin.type].Bin) { + _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin)); + } }); + var elementDropped = false; + this.$.find(".Rk-Bins") .on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() { var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main"); @@ -203,19 +202,43 @@ }).mouseout(function() { _this.renderer.unhighlightAll(); }).on("mousemove", ".Rk-Bin-Item", function(e) { - try { - this.dragDrop(); - } - catch(err) {} + try { + this.dragDrop(); + } + catch(err) {} + }).on("touchstart", ".Rk-Bin-Item", function(e) { + elementDropped = false; + }).on("touchmove", ".Rk-Bin-Item", function(e) { + e.preventDefault(); + var touch = e.originalEvent.changedTouches[0], + off = _this.renderer.canvas_$.offset(), + w = _this.renderer.canvas_$.width(), + h = _this.renderer.canvas_$.height(); + if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) { + if (elementDropped) { + _this.renderer.onMouseMove(touch, true); + } else { + elementDropped = true; + var div = document.createElement('div'); + div.appendChild(this.cloneNode(true)); + _this.renderer.dropData({"text/html": div.innerHTML}, touch); + _this.renderer.onMouseDown(touch, true); + } + } + }).on("touchend", ".Rk-Bin-Item", function(e) { + if (elementDropped) { + _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true); + } + elementDropped = false; }).on("dragstart", ".Rk-Bin-Item", function(e) { - var div = document.createElement('div'); - div.appendChild(this.cloneNode(true)); - try { - e.originalEvent.dataTransfer.setData("text/html",div.innerHTML); - } - catch(err) { - e.originalEvent.dataTransfer.setData("text",div.innerHTML); - } + var div = document.createElement('div'); + div.appendChild(this.cloneNode(true)); + try { + e.originalEvent.dataTransfer.setData("text/html",div.innerHTML); + } + catch(err) { + e.originalEvent.dataTransfer.setData("text",div.innerHTML); + } }); Rkns.$(window).resize(function() { _this.resizeBins(); @@ -230,7 +253,7 @@ this.$.find(".Rk-Bins-Search-Form").submit(function() { return false }); -} +}; Rkns.Renkan.prototype.template = Rkns._.template( '<% if (options.show_bins) { %>

<%- translate("Select contents:")%>

' @@ -242,15 +265,24 @@ + '
    <% } %>
    ' ); +Rkns.Renkan.prototype.translate = function(_text) { + if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) { + return Rkns.i18n[this.options.language][_text]; + } + if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) { + return Rkns.i18n[this.options.language.substr(0,2)][_text]; + } + return _text; +}; + Rkns.Renkan.prototype.onStatusChange = function() { - this.renderer.onStatusChange(); -} - + this.renderer.onStatusChange(); +}; Rkns.Renkan.prototype.setSearchEngine = function(_key) { this.search_engine = this.search_engines[_key]; this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass()); -} +}; Rkns.Renkan.prototype.resizeBins = function() { var _d = + this.$.find(".Rk-Bins-Head").outerHeight(); @@ -260,13 +292,14 @@ this.$.find(".Rk-Bin-Main").css({ height: this.$.find(".Rk-Bins").height() - _d }); -} +}; /* Utility functions */ Rkns.Utils = { _ID_AUTO_INCREMENT : 0, _ID_BASE : (function(_d) { + function pad(n){return n<10 ? '0'+n : n} function fillrand(n) { var _res = '' @@ -279,40 +312,47 @@ + pad(_d.getUTCMonth()+1) + '-' + pad(_d.getUTCDate()) + '-' + fillrand(16); + })(new Date()), getUID : function(_base) { + var _n = (++this._ID_AUTO_INCREMENT).toString(16), _base = (typeof _base === "undefined" ? "" : _base + "-" ); while (_n.length < 4) { _n = '0' + _n } return _base + this._ID_BASE + '-' + _n; + }, getFullURL : function(url) { - - if(typeof(url) == 'undefined' || url == null ) { - return ""; - } - if(url.indexOf("http://")==0) { - return url; - } - var img = new Image(); - img.src = url; - var res = img.src; - img.src = null; - return res; + + if(typeof(url) == 'undefined' || url == null ) { + return ""; + } + if(/https?:\/\//.test(url)) { + return url; + } + var img = new Image(); + img.src = url; + var res = img.src; + img.src = null; + return res; + }, inherit : function(_baseClass, _callbefore) { - var _class = function() { + + var _class = function(_arg) { if (typeof _callbefore === "function") { _callbefore.apply(this, Array.prototype.slice.call(arguments, 0)); } _baseClass.apply(this, Array.prototype.slice.call(arguments, 0)); - if (typeof this._init == "function") { + if (typeof this._init == "function" && !this._initialized) { this._init.apply(this, Array.prototype.slice.call(arguments, 0)); + this._initialized = true; } } - _class.prototype = new _baseClass(); + Rkns._(_class.prototype).extend(_baseClass.prototype); return _class; + } -} \ No newline at end of file +}; diff -r eb97351d5e9b -r f978d70a9e63 client/js/models.js --- a/client/js/models.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/models.js Tue Apr 23 22:15:10 2013 +0200 @@ -263,7 +263,7 @@ }); var UsersList = Models.UsersList = Backbone.Collection.extend({ - model: RosterUser + model: RosterUser }); diff -r eb97351d5e9b -r f978d70a9e63 client/js/paper-renderer.js --- a/client/js/paper-renderer.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/paper-renderer.js Tue Apr 23 22:15:10 2013 +0200 @@ -12,28 +12,28 @@ _MIN_SCALE: 1/20, _MAX_SCALE: 20, _AUTOSCALE_MARGIN: 50, + _MOUSEMOVE_RATE: 80, + _DOUBLETAP_DELAY: 800, + _DOUBLETAP_DISTANCE: 20*20, _USER_PLACEHOLDER : function(_renkan) { - return { - color: _renkan.options.default_user_color, - title: _renkan.translate("(unknown user)"), - get: function(attr) { - return this[attr] || false; - } - } + return { + color: _renkan.options.default_user_color, + title: _renkan.translate("(unknown user)"), + get: function(attr) { + return this[attr] || false; + } + } }, _BOOKMARKLET_CODE: function(_renkan) { - 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='" - + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") - + "

    '.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);})();" - } -} - -Rkns.Renderer.Utils = { - shortenText : function(_text, _maxlength) { - return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text); - }, + 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='" + + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") + + "

    '.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);})();" + }, + shortenText : function(_text, _maxlength) { + return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text); + }, drawEditBox : function(_options, _coords, _path, _xmargin, _selector) { - _selector.css({ + _selector.css({ width: ( _options.tooltip_width - 2* _options.tooltip_padding ), }) var _height = _selector.outerHeight() + 2* _options.tooltip_padding, @@ -41,14 +41,13 @@ _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ), _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ), _top = _coords.y - _height / 2; + if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) { + _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height; + } if (_top < _options.tooltip_margin) { _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 ); } var _bottom = _top + _height; - if (_bottom > (paper.view.size.height - _options.tooltip_margin)) { - _bottom = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ); - _top = _bottom - _height; - } _path.segments[0].point = _path.segments[7].point = _coords.add([_isLeft * _xmargin, 0]); @@ -74,105 +73,7 @@ left: (_options.tooltip_padding + Math.min(_left, _right)), top: (_options.tooltip_padding + _top) }); - }, - sector : function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgsrc, _caption) { - var _options = _repr.renderer.renkan.options, - _startRads = _startAngle * Math.PI / 180, - _endRads = _endAngle * Math.PI / 180, - _img = new Image(), - _span = _endRads - _startRads, - _startdx = - Math.sin(_startRads), - _startdy = Math.cos(_startRads), - _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, - _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, - _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, - _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, - _enddx = - Math.sin(_endRads), - _enddy = Math.cos(_endRads), - _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, - _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, - _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, - _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, - _centerR = (_inR + _outR)/2, - _centerRads = (_startRads + _endRads) / 2, - _centerX = Math.cos(_centerRads) * _centerR, - _centerY = Math.sin(_centerRads) * _centerR, - _centerXIn = Math.cos(_centerRads) * _inR, - _centerXOut = Math.cos(_centerRads) * _outR, - _centerYIn = Math.sin(_centerRads) * _inR, - _centerYOut = Math.sin(_centerRads) * _outR, - _textX = Math.cos(_centerRads) * (_outR + 3), - _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2, - _segments = []; - _repr.renderer.buttons_layer.activate(); - var _path = new paper.Path(); - _path.add([_startXIn, _startYIn]); - _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); - _path.lineTo([_endXOut, _endYOut]); - _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]); - _path.fillColor = _options.buttons_background; - _path.opacity = .5; - _path.closed = true; - _path.__representation = _repr; - var _text = new paper.PointText(_textX,_textY); - _text.characterStyle = { - fontSize: _options.buttons_label_font_size, - fillColor: _options.buttons_label_color - }; - if (_textX > 2) { - _text.paragraphStyle.justification = 'left'; - } else if (_textX < -2) { - _text.paragraphStyle.justification = 'right'; - } else { - _text.paragraphStyle.justification = 'center'; - } - _text.visible = false; - var _visible = false, - _restPos = new paper.Point(-200, -200), - _grp = new paper.Group([_path, _text]), - _delta = _grp.position, - _imgdelta = new paper.Point([_centerX, _centerY]), - _currentPos = new paper.Point(0,0); - _text.content = _caption; - _grp.visible = false; - _grp.position = _restPos; - var _res = { - show: function() { - _visible = true; - _grp.position = _currentPos.add(_delta); - _grp.visible = true; - }, - moveTo: function(_point) { - _currentPos = _point; - if (_visible) { - _grp.position = _point.add(_delta); - } - }, - hide: function() { - _visible = false; - _grp.visible = false; - _grp.position = _restPos; - }, - select: function() { - _path.opacity = .8; - _text.visible = true; - }, - unselect: function() { - _path.opacity = .5; - _text.visible = false; - }, - destroy: function() { - _grp.remove(); - } - } - _img.onload = function() { - var _h = _img.height; - var _raster = new paper.Raster(_img); - _raster.position = _imgdelta.add(_grp.position).subtract(_delta); - _grp.addChild(_raster); - } - _img.src = _imgsrc; - return _res + return _path; } } @@ -191,11 +92,19 @@ this._removeBinding = function() { _renderer.removeRepresentation(_this); _(function() { - _renderer.redraw() - }).defer(); + _renderer.redraw() + }).defer(); + } + this._selectBinding = function() { + _this.select(); + } + this._unselectBinding = function() { + _this.unselect(); } this.model.on("change", this._changeBinding ); this.model.on("remove", this._removeBinding ); + this.model.on("select", this._selectBinding ); + this.model.on("unselect", this._unselectBinding ); } } } @@ -212,20 +121,36 @@ Rkns.Renderer._BaseRepresentation.prototype.hide = function() {} -Rkns.Renderer._BaseRepresentation.prototype.select = function() {} +Rkns.Renderer._BaseRepresentation.prototype.select = function() { + if (this.model) { + this.model.trigger("selected"); + } +} -Rkns.Renderer._BaseRepresentation.prototype.unselect = function() {} +Rkns.Renderer._BaseRepresentation.prototype.unselect = function() { + if (this.model) { + this.model.trigger("unselected"); + } +} Rkns.Renderer._BaseRepresentation.prototype.highlight = function() {} Rkns.Renderer._BaseRepresentation.prototype.unhighlight = function() {} -Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() {} +Rkns.Renderer._BaseRepresentation.prototype.mousedown = function() {} + +Rkns.Renderer._BaseRepresentation.prototype.mouseup = function() { + if (this.model) { + this.model.trigger("clicked"); + } +} Rkns.Renderer._BaseRepresentation.prototype.destroy = function() { if (this.model) { this.model.off("change", this._changeBinding ); this.model.off("remove", this._removeBinding ); + this.model.off("select", this._selectBinding ); + this.model.off("unselect", this._unselectBinding ); } } @@ -269,83 +194,113 @@ this.type = "Node"; this.circle = new paper.Path.Circle([0, 0], 1); this.circle.__representation = this; - this.circle.fillColor = this.options.node_fill_color; if (this.options.show_node_circles) { - this.circle.strokeWidth = this.options.node_stroke_width; - this.h_ratio = 1; + this.circle.strokeWidth = this.options.node_stroke_width; + this.h_ratio = 1; } else { - this.circle.opacity = .01; - this.h_ratio = 0; + this.h_ratio = 0; } - this.title = new paper.PointText([0,0]); - this.title.characterStyle = { - font: this.options.node_label_font, - fontSize: this.options.node_label_font_size, - fillColor: this.options.node_label_color - }; + this.title = Rkns.$('
    ').appendTo(this.renderer.labels_$); if (this.options.editor_mode) { - this.buttons = [ - new Rkns.Renderer.NodeEditButton(this.renderer, null), - new Rkns.Renderer.NodeRemoveButton(this.renderer, null), - new Rkns.Renderer.NodeLinkButton(this.renderer, null), - new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), - new Rkns.Renderer.NodeShrinkButton(this.renderer, null) - ]; - for (var i = 0; i < this.buttons.length; i++) { - this.buttons[i].source_representation = this; - } + this.normal_buttons = [ + new Rkns.Renderer.NodeEditButton(this.renderer, null), + new Rkns.Renderer.NodeRemoveButton(this.renderer, null), + new Rkns.Renderer.NodeLinkButton(this.renderer, null), + new Rkns.Renderer.NodeEnlargeButton(this.renderer, null), + new Rkns.Renderer.NodeShrinkButton(this.renderer, null) + ]; + this.pending_delete_buttons = [ + new Rkns.Renderer.NodeRevertButton(this.renderer, null) + ]; + this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons) + for (var i = 0; i < this.all_buttons.length; i++) { + this.all_buttons[i].source_representation = this; + } + this.active_buttons = []; } else { - this.buttons = []; + this.active_buttons = this.all_buttons = []; } this.last_circle_radius = 1; - this.title.paragraphStyle.justification = 'center'; if (this.renderer.minimap) { - this.renderer.minimap.node_layer.activate(); - this.minimap_circle = new paper.Path.Circle([0, 0], 1); - this.renderer.minimap.node_group.addChild(this.minimap_circle); + this.renderer.minimap.node_layer.activate(); + this.minimap_circle = new paper.Path.Circle([0, 0], 1); + this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation; + this.renderer.minimap.node_group.addChild(this.minimap_circle); } } Rkns.Renderer.Node.prototype.redraw = function(_dontRedrawEdges) { var _model_coords = new paper.Point(this.model.get("position")), - _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP); + _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Rkns.Renderer._NODE_SIZE_STEP); if (!this.is_dragging || !this.paper_coords) { this.paper_coords = this.renderer.toPaperCoords(_model_coords); } this.circle_radius = _baseRadius * this.renderer.scale; if (this.last_circle_radius !== this.circle_radius) { - this.buttons.forEach(function(b) { - b.setSectorSize(); - }); - var square = new paper.Size(this.circle_radius, this.circle_radius), - topleft = this.paper_coords.subtract(square), - bounds = new paper.Rectangle(topleft, square.multiply(2)); - this.circle.fitBounds(bounds); - if (this.node_image) { - this.node_image.fitBounds(bounds); - } + this.all_buttons.forEach(function(b) { + b.setSectorSize(); + }); + var square = new paper.Size(this.circle_radius, this.circle_radius), + topleft = this.paper_coords.subtract(square), + bounds = new paper.Rectangle(topleft, square.multiply(2)); + this.circle.fitBounds(bounds); + if (this.node_image) { + this.node_image.fitBounds(bounds); + } } else { - this.circle.position = this.paper_coords; - if (this.node_image) { + this.circle.position = this.paper_coords; + if (this.node_image) { this.node_image.position = this.paper_coords; } } this.last_circle_radius = this.circle_radius; - var _text = this.model.get("title") || this.renkan.translate("(untitled)"); - this.title.content = Rkns.Renderer.Utils.shortenText(_text, this.options.node_label_max_length); - - this.title.position = this.paper_coords.add([ - 0, - this.circle_radius * this.h_ratio + this.options.node_label_font_size + this.options.node_label_distance - ]); + var old_act_btn = this.active_buttons; + + if (this.model.get("delete_scheduled")) { + var opacity = .5; + this.active_buttons = this.pending_delete_buttons; + this.circle.dashArray = [2,2]; + } else { + var opacity = 1; + this.active_buttons = this.normal_buttons; + this.circle.dashArray = null; + } + + if (this.selected && this.renderer.isEditable()) { + if (old_act_btn !== this.active_buttons) { + old_act_btn.forEach(function(b) { + b.hide(); + }); + } + this.active_buttons.forEach(function(b) { + b.show(); + }); + } + + if (this.node_image) { + this.node_image.opacity = this.highlighted ? opacity * .5 : (opacity - .01); + } + + this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color; + + this.circle.opacity = this.options.show_node_circles ? opacity : .01; + + var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || ""; + _text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); + this.title.text(_text); + this.title.css({ + left: this.paper_coords.x, + top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance, + opacity: opacity + }) var _color = this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); this.circle.strokeColor = _color; var _pc = this.paper_coords; - this.buttons.forEach(function(b) { - b.moveTo(_pc); - }); + this.all_buttons.forEach(function(b) { + b.moveTo(_pc); + }); var _img = this.model.get("image"); if (_img && _img !== this.img) { var _image = new Image(), @@ -357,29 +312,29 @@ _this.renderer.node_layer.activate(); var _ratio = Math.min(2 / _image.width, 2 / _image.height ); if (!_this.options.show_node_circles) { - _this.h_ratio = Math.min(1, _image.height / _image.width); + _this.h_ratio = Math.min(1, _image.height / _image.width); } var _raster = new paper.Raster(_image); if (_this.options.clip_node_images) { - var _clip = new paper.Path.Circle([0, 0], 1); - _raster.scale(_ratio); - _this.node_image = new paper.Group(_clip, _raster); - _this.node_image.opacity = .99; - /* This is a workaround to allow clipping at group level - * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug). - */ - _this.node_image.clipped = true; - _clip.__representation = _this; + var _clip = new paper.Path.Circle([0, 0], 1); + _raster.scale(_ratio); + _this.node_image = new paper.Group(_clip, _raster); + _this.node_image.opacity = .99; + /* This is a workaround to allow clipping at group level + * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug). + */ + _this.node_image.clipped = true; + _clip.__representation = _this; } else { - _this.node_image = _raster; + _this.node_image = _raster; } _this.node_image.__representation = _this; - var square = new paper.Size(_this.circle_radius, _this.circle_radius), - topleft = _this.paper_coords.subtract(square), - bounds = new paper.Rectangle(topleft, square.multiply(2)); - _this.node_image.fitBounds(bounds); + var square = new paper.Size(_this.circle_radius, _this.circle_radius), + topleft = _this.paper_coords.subtract(square), + bounds = new paper.Rectangle(topleft, square.multiply(2)); + _this.node_image.fitBounds(bounds); _this.redraw(); - paper.view.draw(); + paper.view.draw(); } _image.src = _img; } @@ -390,34 +345,34 @@ } if (this.renderer.minimap) { - this.minimap_circle.fillColor = _color; - var minipos = this.renderer.toMinimapCoords(_model_coords), - miniradius = this.renderer.minimap.scale * _baseRadius, - minisize = new paper.Size([miniradius, miniradius]); - this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); + this.minimap_circle.fillColor = _color; + var minipos = this.renderer.toMinimapCoords(_model_coords), + miniradius = this.renderer.minimap.scale * _baseRadius, + minisize = new paper.Size([miniradius, miniradius]); + this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2)); } if (!_dontRedrawEdges) { - Rkns._.each(this.project.get("edges").filter(function (ed) { return ((ed.to === this.model) || (ed.from === this.model));}), function(edge, index, list){ - var repr = this.renderer.getRepresentationByModel(edge); - if(repr != null && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") { - repr.redraw(); - } - }, this); + Rkns._.each(this.project.get("edges").filter(function (ed) { return ((ed.to === this.model) || (ed.from === this.model));}), function(edge, index, list){ + var repr = this.renderer.getRepresentationByModel(edge); + if(repr != null && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") { + repr.redraw(); + } + }, this); } } Rkns.Renderer.Node.prototype.paperShift = function(_delta) { - if (this.options.editor_mode) { - if (!this.renkan.read_only) { - this.is_dragging = true; - this.paper_coords = this.paper_coords.add(_delta); - this.redraw(); - } - } else { - this.renderer.paperShift(_delta); - } + if (this.options.editor_mode) { + if (!this.renkan.read_only) { + this.is_dragging = true; + this.paper_coords = this.paper_coords.add(_delta); + this.redraw(); + } + } else { + this.renderer.paperShift(_delta); + } } Rkns.Renderer.Node.prototype.openEditor = function() { @@ -428,56 +383,64 @@ } Rkns.Renderer.Node.prototype.select = function() { + this.selected = true; this.circle.strokeWidth = this.options.selected_node_stroke_width; if (this.renderer.isEditable()) { - this.buttons.forEach(function(b) { - b.show(); - }); + this.active_buttons.forEach(function(b) { + b.show(); + }); } var _uri = this.model.get("uri"); if (_uri) { - Rkns.$('.Rk-Bin-Item').each(function() { - var _el = Rkns.$(this); - if (_el.attr("data-uri") == _uri) { - _el.addClass("selected"); - } - }); + Rkns.$('.Rk-Bin-Item').each(function() { + var _el = Rkns.$(this); + if (_el.attr("data-uri") == _uri) { + _el.addClass("selected"); + } + }); } if (!this.options.editor_mode) { this.openEditor(); } if (this.renderer.minimap) { - this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight; - this.minimap_circle.strokeColor = this.options.minimap_highlight_color; + this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight; + this.minimap_circle.strokeColor = this.options.minimap_highlight_color; } + this.super("select"); } Rkns.Renderer.Node.prototype.unselect = function(_newTarget) { if (!_newTarget || _newTarget.source_representation !== this) { - this.buttons.forEach(function(b) { - b.hide(); - }); - this.circle.strokeWidth = this.options.node_stroke_width; + this.selected = false; + this.all_buttons.forEach(function(b) { + b.hide(); + }); + this.circle.strokeWidth = this.options.node_stroke_width; Rkns.$('.Rk-Bin-Item').removeClass("selected"); - if (this.renderer.minimap) { - this.minimap_circle.strokeColor = undefined; - } + if (this.renderer.minimap) { + this.minimap_circle.strokeColor = undefined; + } + this.super("unselect"); } } + +Rkns.Renderer.Node.prototype.highlight = function() { + if (this.highlighted) { + return; + } + this.highlighted = true; + this.redraw(); + this.renderer.throttledPaperDraw(); +} -Rkns.Renderer.Node.prototype.highlight = function() { - this.circle.fillColor = this.options.highlighted_node_fill_color; - if (this.node_image) { - this.node_image.opacity = .5; +Rkns.Renderer.Node.prototype.unhighlight = function() { + if (!this.highlighted) { + return; } -} - -Rkns.Renderer.Node.prototype.unhighlight = function(_newTarget) { - this.circle.fillColor = this.options.node_fill_color; - if (this.node_image) { - this.node_image.opacity = .99; - } + this.highlighted = false; + this.redraw(); + this.renderer.throttledPaperDraw(); } Rkns.Renderer.Node.prototype.saveCoords = function() { @@ -489,16 +452,25 @@ } }; if (this.renderer.isEditable()) { - this.model.set(_data); + this.model.set(_data); } } -Rkns.Renderer.Node.prototype.mouseup = function(_event) { - if (this.renderer.isEditable() && this.renderer.is_dragging) { +Rkns.Renderer.Node.prototype.mousedown = function(_event, _isTouch) { + if (_isTouch) { + this.renderer.unselectAll(); + this.select(); + } +} + +Rkns.Renderer.Node.prototype.mouseup = function(_event, _isTouch) { + if (this.renderer.is_dragging && this.renderer.isEditable()) { this.saveCoords(); - } - else { - this.openEditor(); + } else { + if (!_isTouch && !this.model.get("delete_scheduled")) { + this.openEditor(); + } + this.model.trigger("clicked"); } this.renderer.click_target = null; this.renderer.is_dragging = false; @@ -507,13 +479,13 @@ Rkns.Renderer.Node.prototype.destroy = function(_event) { this.super("destroy"); - this.buttons.forEach(function(b) { - b.destroy(); - }); + this.all_buttons.forEach(function(b) { + b.destroy(); + }); this.circle.remove(); this.title.remove(); if (this.renderer.minimap) { - this.minimap_circle.remove(); + this.minimap_circle.remove(); } if (this.node_image) { this.node_image.remove(); @@ -536,32 +508,36 @@ this.line.strokeWidth = this.options.edge_stroke_width; this.arrow = new paper.Path(); this.arrow.add( - [ 0, 0 ], - [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], - [ 0, this.options.edge_arrow_width ] - ); + [ 0, 0 ], + [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], + [ 0, this.options.edge_arrow_width ] + ); this.arrow.__representation = this; - this.text = new paper.PointText(); - this.text.characterStyle = { - font: this.options.edge_label_font, - fontSize: this.options.edge_label_font_size, - fillColor: this.options.edge_label_color - }; - this.text.paragraphStyle.justification = 'center'; - this.text_angle = 0; + this.text = Rkns.$('
    ').appendTo(this.renderer.labels_$); this.arrow_angle = 0; if (this.options.editor_mode) { - this.edit_button = new Rkns.Renderer.EdgeEditButton(this.renderer, null); - this.edit_button.source_representation = this; - this.remove_button = new Rkns.Renderer.EdgeRemoveButton(this.renderer, null); - this.remove_button.source_representation = this; + this.normal_buttons = [ + new Rkns.Renderer.EdgeEditButton(this.renderer, null), + new Rkns.Renderer.EdgeRemoveButton(this.renderer, null), + ]; + this.pending_delete_buttons = [ + new Rkns.Renderer.EdgeRevertButton(this.renderer, null) + ]; + this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons) + for (var i = 0; i < this.all_buttons.length; i++) { + this.all_buttons[i].source_representation = this; + } + this.active_buttons = []; + } else { + this.active_buttons = this.all_buttons = []; } if (this.renderer.minimap) { - this.renderer.minimap.edge_layer.activate(); - this.minimap_line = new paper.Path(); - this.minimap_line.add([0,0],[0,0]); - this.minimap_line.strokeWidth = 1; + this.renderer.minimap.edge_layer.activate(); + this.minimap_line = new paper.Path(); + this.minimap_line.add([0,0],[0,0]); + this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation; + this.minimap_line.strokeWidth = 1; } } @@ -569,7 +545,7 @@ this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from")); this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to")); if (!this.from_representation || !this.to_representation) { - return; + return; } var _p0a = this.from_representation.paper_coords, _p1a = this.to_representation.paper_coords, @@ -585,8 +561,31 @@ _textdelta = _ortho.multiply(this.options.edge_label_distance), _handle = _v.divide(3), _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); + + if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) { + var opacity = .5; + this.line.dashArray = [2, 2]; + } else { + var opacity = 1; + this.line.dashArray = null; + } + + var old_act_btn = this.active_buttons; + + this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons; + + if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) { + old_act_btn.forEach(function(b) { + b.hide(); + }); + this.active_buttons.forEach(function(b) { + b.show(); + }); + } + this.paper_coords = _p0b.add(_p1b).divide(2); this.line.strokeColor = _color; + this.line.opacity = opacity; this.line.segments[0].point = _p0a; this.line.segments[1].point = this.paper_coords; this.line.segments[1].handleIn = _handle.multiply(-1); @@ -594,6 +593,7 @@ this.line.segments[2].point = _p1a; this.arrow.rotate(_a - this.arrow_angle); this.arrow.fillColor = _color; + this.arrow.opacity = opacity; this.arrow.position = this.paper_coords; this.arrow_angle = _a; if (_a > 90) { @@ -604,20 +604,29 @@ _a += 180; _textdelta = _textdelta.multiply(-1); } - this.text.rotate(_a - this.text_angle); - var _text = this.model.get("title"); - this.text.content = Rkns.Renderer.Utils.shortenText(_text, this.options.edge_label_max_length); - this.text.position = this.paper_coords.add(_textdelta); + var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || ""; + _text = Rkns.Renderer.shortenText(_text, this.options.node_label_max_length); + this.text.text(_text); + var _textpos = this.paper_coords.add(_textdelta); + this.text.css({ + left: _textpos.x, + top: _textpos.y, + transform: "rotate(" + _a + "deg)", + "-moz-transform": "rotate(" + _a + "deg)", + "-webkit-transform": "rotate(" + _a + "deg)", + opacity: opacity + }); this.text_angle = _a; - if (this.options.editor_mode) { - this.edit_button.moveTo(this.paper_coords); - this.remove_button.moveTo(this.paper_coords); - } + + var _pc = this.paper_coords; + this.all_buttons.forEach(function(b) { + b.moveTo(_pc); + }); if (this.renderer.minimap) { - this.minimap_line.strokeColor = _color; - this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))); - this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))); + this.minimap_line.strokeColor = _color; + this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))); + this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))); } } @@ -629,48 +638,64 @@ } Rkns.Renderer.Edge.prototype.select = function() { + this.selected = true; this.line.strokeWidth = this.options.selected_edge_stroke_width; if (this.renderer.isEditable()) { - this.edit_button.show(); - this.remove_button.show(); - } + this.active_buttons.forEach(function(b) { + b.show(); + }); + } if (!this.options.editor_mode) { this.openEditor(); } + this.super("select"); } Rkns.Renderer.Edge.prototype.unselect = function(_newTarget) { if (!_newTarget || _newTarget.source_representation !== this) { - if (this.options.editor_mode) { - this.edit_button.hide(); - this.remove_button.hide(); + this.selected = false; + if (this.options.editor_mode) { + this.all_buttons.forEach(function(b) { + b.hide(); + }); } this.line.strokeWidth = this.options.edge_stroke_width; + this.super("unselect"); } } -Rkns.Renderer.Edge.prototype.mouseup = function(_event) { - if (!this.renkan.read_only) { - if (this.renderer.is_dragging) { - this.from_representation.saveCoords(); - this.to_representation.saveCoords(); - } else { +Rkns.Renderer.Edge.prototype.mousedown = function(_event, _isTouch) { + if (_isTouch) { + this.renderer.unselectAll(); + this.select(); + } +} + +Rkns.Renderer.Edge.prototype.mouseup = function(_event, _isTouch) { + if (!this.renkan.read_only && this.renderer.is_dragging) { + this.from_representation.saveCoords(); + this.to_representation.saveCoords(); + this.from_representation.is_dragging = false; + this.to_representation.is_dragging = false; + } else { + if (!_isTouch) { this.openEditor(); } + this.model.trigger("clicked"); } this.renderer.click_target = null; this.renderer.is_dragging = false; } Rkns.Renderer.Edge.prototype.paperShift = function(_delta) { - if (this.options.editor_mode) { - if (!this.options.read_only) { - this.from_representation.paperShift(_delta); - this.to_representation.paperShift(_delta); - } - } else { - this.renderer.paperShift(_delta); - } + if (this.options.editor_mode) { + if (!this.options.read_only) { + this.from_representation.paperShift(_delta); + this.to_representation.paperShift(_delta); + } + } else { + this.renderer.paperShift(_delta); + } } Rkns.Renderer.Edge.prototype.destroy = function() { @@ -679,12 +704,11 @@ this.arrow.remove(); this.text.remove(); if (this.renderer.minimap) { - this.minimap_line.remove(); + this.minimap_line.remove(); } - if (this.options.editor_mode) { - this.edit_button.destroy(); - this.remove_button.destroy(); - } + this.all_buttons.forEach(function(b) { + b.destroy(); + }); var _this = this; this.bundle.edges = Rkns._(this.bundle.edges).reject(function(_edge) { return _edge === _this; @@ -697,20 +721,22 @@ Rkns.Renderer.TempEdge.prototype._init = function() { this.renderer.edge_layer.activate(); - this.type = "temp-edge"; + this.type = "Temp-edge"; var _color = (this.project.get("users").get(this.renkan.current_user) || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color"); this.line = new paper.Path(); this.line.strokeColor = _color; + this.line.dashArray = [4, 2]; + this.line.strokeWidth = this.options.selected_edge_stroke_width; this.line.add([0,0],[0,0]); this.line.__representation = this; this.arrow = new paper.Path(); this.arrow.fillColor = _color; this.arrow.add( - [ 0, 0 ], - [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], - [ 0, this.options.edge_arrow_width ] - ); + [ 0, 0 ], + [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ], + [ 0, this.options.edge_arrow_width ] + ); this.arrow.__representation = this; this.arrow_angle = 0; } @@ -728,34 +754,38 @@ } Rkns.Renderer.TempEdge.prototype.paperShift = function(_delta) { - if (!this.renderer.isEditable()) { - this.renderer.removeRepresentation(_this); - paper.view.draw(); - return; - } + if (!this.renderer.isEditable()) { + this.renderer.removeRepresentation(_this); + paper.view.draw(); + return; + } this.end_pos = this.end_pos.add(_delta); var _hitResult = paper.project.hitTest(this.end_pos); this.renderer.findTarget(_hitResult); this.redraw(); } -Rkns.Renderer.TempEdge.prototype.mouseup = function(_event) { +Rkns.Renderer.TempEdge.prototype.mouseup = function(_event, _isTouch) { var _hitResult = paper.project.hitTest(_event.point), _model = this.from_representation.model, _endDrag = true; if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { var _target = _hitResult.item.__representation; - if (_target.type === "Node" && _model !== _target.model) { - var _data = { - id: Rkns.Utils.getUID('edge'), - created_by: this.renkan.current_user, - from: _model.get("_id"), - to: _target.model.get("_id") - }; - if (this.renderer.isEditable()) { - this.project.addEdge(_data); + if (_target.type.substr(0,4) === "Node") { + var _destmodel = _target.model || _target.source_representation.model; + if (_model !== _destmodel) { + var _data = { + id: Rkns.Utils.getUID('edge'), + created_by: this.renkan.current_user, + from: _model, + to: _destmodel + }; + if (this.renderer.isEditable()) { + this.project.addEdge(_data); + } } } + if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) { _endDrag = false; this.renderer.is_dragging = true; @@ -776,184 +806,9 @@ /* */ -Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); - -Rkns.Renderer.NodeEditor.prototype._init = function() { - this.renderer.buttons_layer.activate(); - this.type = "editor"; - this.editor_block = new paper.Path(); - var _pts = Rkns._(Rkns._.range(8)).map(function() {return [0,0]}); - this.editor_block.add.apply(this.editor_block, _pts); - this.editor_block.strokeWidth = this.options.tooltip_border_width; - this.editor_block.strokeColor = this.options.tooltip_border_color; - this.editor_block.opacity = .8; - this.editor_$ = Rkns.$('
    ') - .appendTo(this.renderer.editor_$) - .css({ - position: "absolute", - opacity: .8 - }) - .hide(); -} - -Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( - '

    ×<%-translate("Edit Node")%>

    ' - + '

    ' - + '

    ' - + '

    ' - + '

    <%-translate("Size:")%>-<%-node.size%>+

    ' - + '
    <%-translate("Node color:")%>
      ' - + '<% _(Rkns.pickerColors).each(function(c) { %>
    • <% }); %>
    <%- translate("Choose color") %>
    ' - + '' - + '

    ' - + '

    ' - + '<% if (node.has_creator) { %>

    <%-translate("Created by:")%> <%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %>

    <% } %>' -); - -Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( - '

    ×' - + '<% if (node.uri) { %><% } %><%-node.title%><% if (node.uri) { %><% } %>

    ' - + '<% if (node.uri) { %>

    <%-node.short_uri%>

    <% } %>' - + '

    <%-node.description%>

    ' - + '<% if (node.has_creator) { %>

    <%-translate("Created by:")%><%- Rkns.Renderer.Utils.shortenText(node.created_by_title, 25) %>

    <% } %>' -); +Rkns.Renderer._BaseEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); -Rkns.Renderer.NodeEditor.prototype.draw = function() { - var _model = this.source_representation.model, - _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan), - _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), - _image_placeholder = this.options.static_url + "img/image-placeholder.png", - _size = (_model.get("size") || 0); - this.editor_$ - .html(_template({ - node: { - has_creator: !!_model.get("created_by"), - title: _model.get("title"), - uri: _model.get("uri"), - short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), - description: _model.get("description"), - image: _model.get("image") || "", - image_placeholder: _image_placeholder, - color: _model.get("color") || _created_by.get("color"), - created_by_color: _created_by.get("color"), - created_by_title: _created_by.get("title"), - size: (_size > 0 ? "+" : "") + _size - }, - translate: this.renkan.translate - })); - this.redraw(); - var _this = this, - closeEditor = function() { - _this.renderer.removeRepresentation(_this); - paper.view.draw(); - } - - this.editor_$.find(".Rk-CloseX").click(closeEditor); - - if (this.renderer.isEditable()) { - - var onFieldChange = Rkns._(function() { - Rkns._(function() { - if (_this.renderer.isEditable()) { - var _uri = _this.editor_$.find(".Rk-Edit-URI").val(), - _image = _this.editor_$.find(".Rk-Edit-Image").val(); - _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _image || _image_placeholder); - _this.editor_$.find(".Rk-Edit-Goto").attr("href",_uri); - var _data = { - title: _this.editor_$.find(".Rk-Edit-Title").val(), - description: _this.editor_$.find(".Rk-Edit-Description").val(), - uri: _uri, - image: _image - } - _model.set(_data); - _this.redraw(); - } else { - closeEditor(); - } - - }).defer(); - }).throttle(500); - - this.editor_$.find("input, textarea").bind("change keyup paste", onFieldChange); - - this.editor_$.find(".Rk-Edit-Image-File").bind("change", function() { - if (this.files.length) { - var f = this.files[0], - fr = new FileReader(); - if (f.type.substr(0,5) !== "image") { - alert(_this.renkan.translate("This file is not an image")); - return; - } - if (f.size > (Rkns.Renderer._IMAGE_MAX_KB * 1024)) { - alert(_this.renkan.translate("Image size must be under ")+Rkns.Renderer._IMAGE_MAX_KB+_this.renkan.translate("KB")); - return; - } - fr.onload = function(e) { - _this.editor_$.find(".Rk-Edit-Image").val(e.target.result); - onFieldChange(); - } - fr.readAsDataURL(f); - } - }); - this.editor_$.find(".Rk-Edit-Title")[0].focus(); - this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( - function() { _this.editor_$.find(".Rk-Edit-ColorPicker").show(); }, - function() { _this.editor_$.find(".Rk-Edit-ColorPicker").hide(); } - ); - this.editor_$.find(".Rk-Edit-ColorPicker li").hover( - function() { _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); }, - function() { _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color")) } - ).click(function() { - if (_this.renderer.isEditable()) { - _model.set("color", $(this).attr("data-color")); - paper.view.draw(); - } else { - closeEditor(); - } - }); - - function shiftSize(n) { - if (_this.renderer.isEditable()) { - var _newsize = n+(_model.get("size") || 0); - _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize); - _model.set("size", _newsize); - paper.view.draw(); - } else { - closeEditor(); - } - } - - this.editor_$.find(".Rk-Edit-Size-Down").click(function() { - shiftSize(-1); - return false; - }); - this.editor_$.find(".Rk-Edit-Size-Up").click(function() { - shiftSize(1); - return false; - }); - } - this.editor_$.find("img").load(function() { - _this.redraw(); - }); -} - -Rkns.Renderer.NodeEditor.prototype.redraw = function() { - var _coords = this.source_representation.paper_coords; - Rkns.Renderer.Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$); - this.editor_$.show(); - paper.view.draw(); -} - -Rkns.Renderer.NodeEditor.prototype.destroy = function() { - this.editor_block.remove(); - this.editor_$.detach(); -} - -/* */ - -Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); - -Rkns.Renderer.EdgeEditor.prototype._init = function() { +Rkns.Renderer._BaseEditor.prototype._init = function() { this.renderer.buttons_layer.activate(); this.type = "editor"; this.editor_block = new paper.Path(); @@ -971,21 +826,207 @@ .hide(); } +Rkns.Renderer._BaseEditor.prototype.destroy = function() { + this.editor_block.remove(); + this.editor_$.remove(); +} + +/* */ + +Rkns.Renderer.NodeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor); + +Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template( + '

    ×<%-renkan.translate("Edit Node")%>

    ' + + '

    ' + + '

    ' + + '

    ' + + '

    <%-renkan.translate("Size:")%>-<%-node.size%>+

    ' + + '
    <%-renkan.translate("Node color:")%>
      ' + + '<% _(Rkns.pickerColors).each(function(c) { %>
    • <% }); %>
    <%- renkan.translate("Choose color") %>
    ' + + '' + + '

    ' + + '

    ' + + '<% if (node.has_creator) { %>

    <%-renkan.translate("Created by:")%> <%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>

    <% } %>' +); + +Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template( + '

    ×' + + '<% if (node.uri) { %><% } %><%-node.title%><% if (node.uri) { %><% } %>

    ' + + '<% if (node.uri) { %>

    <%-node.short_uri%>

    <% } %>' + + '

    <%-node.description%>

    ' + + '<% if (node.image) { %><% } %>' + + '<% if (node.has_creator) { %>

    <%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %>

    <% } %>' +); + +Rkns.Renderer.NodeEditor.prototype.draw = function() { + var _model = this.source_representation.model, + _created_by = _model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan), + _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ), + _image_placeholder = this.options.static_url + "img/image-placeholder.png", + _size = (_model.get("size") || 0); + this.editor_$ + .html(_template({ + node: { + has_creator: !!_model.get("created_by"), + title: _model.get("title"), + uri: _model.get("uri"), + short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), + description: _model.get("description"), + image: _model.get("image") || "", + image_placeholder: _image_placeholder, + color: _model.get("color") || _created_by.get("color"), + created_by_color: _created_by.get("color"), + created_by_title: _created_by.get("title"), + size: (_size > 0 ? "+" : "") + _size + }, + renkan: this.renkan + })); + this.redraw(); + var _this = this, + closeEditor = function() { + _this.renderer.removeRepresentation(_this); + paper.view.draw(); + } + + this.editor_$.find(".Rk-CloseX").click(closeEditor); + + if (this.renderer.isEditable()) { + + var onFieldChange = Rkns._(function() { + Rkns._(function() { + if (_this.renderer.isEditable()) { + var _uri = _this.editor_$.find(".Rk-Edit-URI").val(), + _image = _this.editor_$.find(".Rk-Edit-Image").val(); + _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _image || _image_placeholder); + _this.editor_$.find(".Rk-Edit-Goto").attr("href",_uri); + var _data = { + title: _this.editor_$.find(".Rk-Edit-Title").val(), + description: _this.editor_$.find(".Rk-Edit-Description").val(), + uri: _uri, + image: _image + } + _model.set(_data); + _this.redraw(); + } else { + closeEditor(); + } + + }).defer(); + }).throttle(500); + + this.editor_$.on("keyup", function(_e) { + if (_e.keyCode === 27) { + closeEditor(); + } + }); + + this.editor_$.find("input, textarea").on("change keyup paste", onFieldChange); + + this.editor_$.find(".Rk-Edit-Image-File").change(function() { + if (this.files.length) { + var f = this.files[0], + fr = new FileReader(); + if (f.type.substr(0,5) !== "image") { + alert(_this.renkan.translate("This file is not an image")); + return; + } + if (f.size > (Rkns.Renderer._IMAGE_MAX_KB * 1024)) { + alert(_this.renkan.translate("Image size must be under ")+Rkns.Renderer._IMAGE_MAX_KB+_this.renkan.translate("KB")); + return; + } + fr.onload = function(e) { + _this.editor_$.find(".Rk-Edit-Image").val(e.target.result); + onFieldChange(); + } + fr.readAsDataURL(f); + } + }); + this.editor_$.find(".Rk-Edit-Title")[0].focus(); + + var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker"); + + this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( + function(_e) { + _e.preventDefault(); + _picker.show(); + }, + function(_e) { + _e.preventDefault(); + _picker.hide(); + } + ); + + _picker.find("li").hover( + function(_e) { + _e.preventDefault(); + _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); + }, + function(_e) { + _e.preventDefault(); + _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color")) + } + ).click(function(_e) { + _e.preventDefault(); + if (_this.renderer.isEditable()) { + _model.set("color", $(this).attr("data-color")); + _picker.hide(); + paper.view.draw(); + } else { + closeEditor(); + } + }); + + function shiftSize(n) { + if (_this.renderer.isEditable()) { + var _newsize = n+(_model.get("size") || 0); + _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize); + _model.set("size", _newsize); + paper.view.draw(); + } else { + closeEditor(); + } + } + + this.editor_$.find(".Rk-Edit-Size-Down").click(function() { + shiftSize(-1); + return false; + }); + this.editor_$.find(".Rk-Edit-Size-Up").click(function() { + shiftSize(1); + return false; + }); + } + this.editor_$.find("img").load(function() { + _this.redraw(); + }); +} + +Rkns.Renderer.NodeEditor.prototype.redraw = function() { + var _coords = this.source_representation.paper_coords; + Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * .75, this.editor_$); + this.editor_$.show(); + paper.view.draw(); +} + +/* */ + +Rkns.Renderer.EdgeEditor = Rkns.Utils.inherit(Rkns.Renderer._BaseEditor); + Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template( - '

    ×<%-translate("Edit Edge")%>

    ' - + '

    ' - + '

    ' - + '<% if (properties.length) { %>

    ' + + '

    ' + + '<% if (properties.length) { %>

    <% } %>' - + '
    <%-translate("Edge color:")%>
      ' - + '<% _(Rkns.pickerColors).each(function(c) { %>
    • <% }); %>
    <%- translate("Choose color") %>
    ' - + '

    <%- translate("Change edge direction") %>

    ' - + '

    <%-translate("From:")%><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %>

    ' - + '

    <%-translate("To:")%><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %>

    ' - + '<% if (edge.has_creator) { %>

    <%-translate("Created by:")%><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %>

    <% } %>' + + '
    <%-renkan.translate("Edge color:")%>
      ' + + '<% _(Rkns.pickerColors).each(function(c) { %>
    • <% }); %>
    <%- renkan.translate("Choose color") %>
    ' + + '

    <%- renkan.translate("Change edge direction") %>

    ' + + '

    <%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>

    ' + + '

    <%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>

    ' + + '<% if (edge.has_creator) { %>

    <%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>

    <% } %>' ); Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template( @@ -993,9 +1034,9 @@ + '<% if (edge.uri) { %><% } %><%-edge.title%><% if (edge.uri) { %><% } %>' + '<% if (edge.uri) { %>

    <%-edge.short_uri%>

    <% } %>' + '

    <%-edge.description%>

    ' - + '

    <%-translate("From:")%><%- Rkns.Renderer.Utils.shortenText(edge.from_title, 25) %>

    ' - + '

    <%-translate("To:")%><%- Rkns.Renderer.Utils.shortenText(edge.to_title, 25) %>

    ' - + '<% if (edge.has_creator) { %>

    <%-translate("Created by:")%><%- Rkns.Renderer.Utils.shortenText(edge.created_by_title, 25) %>

    <% } %>' + + '

    <%-renkan.translate("From:")%><%- Rkns.Renderer.shortenText(edge.from_title, 25) %>

    ' + + '

    <%-renkan.translate("To:")%><%- Rkns.Renderer.shortenText(edge.to_title, 25) %>

    ' + + '<% if (edge.has_creator) { %>

    <%-renkan.translate("Created by:")%><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %>

    <% } %>' ); Rkns.Renderer.EdgeEditor.prototype.draw = function() { @@ -1007,10 +1048,10 @@ this.editor_$ .html(_template({ edge: { - has_creator: !!_model.get("created_by"), + has_creator: !!_model.get("created_by"), title: _model.get("title"), uri: _model.get("uri"), - short_uri: Rkns.Renderer.Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), + short_uri: Rkns.Renderer.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), description: _model.get("description"), color: _model.get("color") || _created_by.get("color"), from_title: _from_model.get("title"), @@ -1020,107 +1061,127 @@ created_by_color: _created_by.get("color"), created_by_title: _created_by.get("title") }, - translate: this.renkan.translate, + renkan: this.renkan, properties: this.options.properties })); this.redraw(); var _this = this, - closeEditor = function() { - _this.renderer.removeRepresentation(_this); - paper.view.draw(); - } + closeEditor = function() { + _this.renderer.removeRepresentation(_this); + paper.view.draw(); + } this.editor_$.find(".Rk-CloseX").click(closeEditor); if (this.renderer.isEditable()) { - - var onFieldChange = Rkns._(function() { - Rkns._(function() { - if (_this.renderer.isEditable()) { - _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val()); - var _data = { - title: _this.editor_$.find(".Rk-Edit-Title").val(), - uri: _this.editor_$.find(".Rk-Edit-URI").val() - } - _model.set(_data); - paper.view.draw(); - } else { - closeEditor(); - } - }).defer(); - }).throttle(500); - - this.editor_$.find("input").bind("keyup change paste", onFieldChange); + + var onFieldChange = Rkns._(function() { + Rkns._(function() { + if (_this.renderer.isEditable()) { + _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val()); + var _data = { + title: _this.editor_$.find(".Rk-Edit-Title").val(), + uri: _this.editor_$.find(".Rk-Edit-URI").val() + } + _model.set(_data); + paper.view.draw(); + } else { + closeEditor(); + } + }).defer(); + }).throttle(500); + + this.editor_$.on("keyup", function(_e) { + if (_e.keyCode === 27) { + closeEditor(); + } + }); + + this.editor_$.find("input").on("keyup change paste", onFieldChange); + this.editor_$.find(".Rk-Edit-Vocabulary").change(function() { - var e = $(this), - v = e.val(); - if (v) { - _this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text()); - _this.editor_$.find(".Rk-Edit-URI").val(v); - onFieldChange(); - } + var e = $(this), + v = e.val(); + if (v) { + _this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text()); + _this.editor_$.find(".Rk-Edit-URI").val(v); + onFieldChange(); + } }); this.editor_$.find(".Rk-Edit-Direction").click(function() { - if (_this.renderer.isEditable()) { - _model.set({ - from: _model.get("to"), - to: _model.get("from") - }); - _this.draw(); - } else { - closeEditor(); - } + if (_this.renderer.isEditable()) { + _model.set({ + from: _model.get("to"), + to: _model.get("from") + }); + _this.draw(); + } else { + closeEditor(); + } }); + + var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker"); + this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover( - function() { _this.editor_$.find(".Rk-Edit-ColorPicker").show(); }, - function() { _this.editor_$.find(".Rk-Edit-ColorPicker").hide(); } + function(_e) { + _e.preventDefault(); + _picker.show(); + }, + function(_e) { + _e.preventDefault(); + _picker.hide(); + } ); - this.editor_$.find(".Rk-Edit-ColorPicker li").hover( - function() { _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); }, - function() { _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(this.renkan)).get("color")); } - ).click(function() { - if (_this.renderer.isEditable()) { - _model.set("color", $(this).attr("data-color")); - paper.view.draw(); + + _picker.find("li").hover( + function(_e) { + _e.preventDefault(); + _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color")); + }, + function(_e) { + _e.preventDefault(); + _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Rkns.Renderer._USER_PLACEHOLDER(_this.renkan)).get("color")) + } + ).click(function(_e) { + _e.preventDefault(); + if (_this.renderer.isEditable()) { + _model.set("color", $(this).attr("data-color")); + _picker.hide(); + paper.view.draw(); } else { - closeEditor(); - } + closeEditor(); + } }); } } Rkns.Renderer.EdgeEditor.prototype.redraw = function() { var _coords = this.source_representation.paper_coords; - Rkns.Renderer.Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); + Rkns.Renderer.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); this.editor_$.show(); paper.view.draw(); } -Rkns.Renderer.EdgeEditor.prototype.destroy = function() { - this.editor_block.remove(); - this.editor_$.detach(); -} - /* */ Rkns.Renderer._NodeButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); Rkns.Renderer._NodeButton.prototype.setSectorSize = function() { - var sectorInner = this.source_representation.circle_radius; - if (sectorInner !== this.lastSectorInner) { - if (this.sector) { - this.sector.destroy(); - } - this.sector = Rkns.Renderer.Utils.sector( - this, 1 + sectorInner, - Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, - this.startAngle, - this.endAngle, - 1, - this.options.static_url + this.imageFile, - this.renkan.translate(this.text) - ); - this.lastSectorInner = sectorInner; - } + var sectorInner = this.source_representation.circle_radius; + if (sectorInner !== this.lastSectorInner) { + if (this.sector) { + this.sector.destroy(); + } + this.sector = this.renderer.drawSector( + this, 1 + sectorInner, + Rkns.Renderer._NODE_BUTTON_WIDTH + sectorInner, + this.startAngle, + this.endAngle, + 1, + this.imageName, + this.renkan.translate(this.text) + ); + this.lastSectorInner = sectorInner; + } } /* */ @@ -1130,9 +1191,9 @@ Rkns.Renderer.NodeEditButton.prototype._init = function() { this.type = "Node-edit-button"; this.lastSectorInner = 0; - this.startAngle = -225; - this.endAngle = -135; - this.imageFile = 'img/edit.png'; + this.startAngle = -135; + this.endAngle = -45; + this.imageName = "edit"; this.text = "Edit"; } @@ -1149,16 +1210,44 @@ Rkns.Renderer.NodeRemoveButton.prototype._init = function() { this.type = "Node-remove-button"; this.lastSectorInner = 0; - this.startAngle = -45; - this.endAngle = 45; - this.imageFile = 'img/remove.png'; + this.startAngle = 0; + this.endAngle = 90; + this.imageName = "remove"; this.text = "Remove"; } Rkns.Renderer.NodeRemoveButton.prototype.mouseup = function() { + this.renderer.click_target = null; + this.renderer.is_dragging = false; this.renderer.removeRepresentationsOfType("editor"); - if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) { - this.project.removeNode(this.source_representation.model); + if (this.renderer.isEditable()) { + var delid = Rkns.Utils.getUID("delete"); + this.renderer.delete_list.push({ + id: delid, + time: new Date().valueOf() + this.options.element_delete_delay + }); + this.source_representation.model.set("delete_scheduled", delid); + } +} + +/* */ + +Rkns.Renderer.NodeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); + +Rkns.Renderer.NodeRevertButton.prototype._init = function() { + this.type = "Node-revert-button"; + this.lastSectorInner = 0; + this.startAngle = -135; + this.endAngle = 135; + this.imageName = "revert"; + this.text = "Cancel deletion"; +} + +Rkns.Renderer.NodeRevertButton.prototype.mouseup = function() { + this.renderer.click_target = null; + this.renderer.is_dragging = false; + if (this.renderer.isEditable()) { + this.source_representation.model.unset("delete_scheduled"); } } @@ -1169,12 +1258,25 @@ Rkns.Renderer.NodeLinkButton.prototype._init = function() { this.type = "Node-link-button"; this.lastSectorInner = 0; - this.startAngle = -135; - this.endAngle = -45; - this.imageFile = 'img/link.png'; + this.startAngle = 90; + this.endAngle = 180; + this.imageName = "link"; this.text = "Link to another node"; } +Rkns.Renderer.NodeLinkButton.prototype.mousedown = function(_event, _isTouch) { + if (this.renderer.isEditable()) { + var _off = this.renderer.canvas_$.offset(), + _point = new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]); + this.renderer.click_target = null; + this.renderer.removeRepresentationsOfType("editor"); + this.renderer.addTempEdge(this.source_representation, _point); + } +} + /* */ Rkns.Renderer.NodeEnlargeButton = Rkns.Utils.inherit(Rkns.Renderer._NodeButton); @@ -1182,18 +1284,18 @@ Rkns.Renderer.NodeEnlargeButton.prototype._init = function() { this.type = "Node-enlarge-button"; this.lastSectorInner = 0; - this.startAngle = 45; - this.endAngle = 90; - this.imageFile = 'img/enlarge.png'; + this.startAngle = -45; + this.endAngle = 0; + this.imageName = "enlarge"; this.text = "Enlarge"; } Rkns.Renderer.NodeEnlargeButton.prototype.mouseup = function() { - var _newsize = 1 + (this.source_representation.model.get("size") || 0); - this.source_representation.model.set("size", _newsize); - this.source_representation.select(); - this.select(); - paper.view.draw(); + var _newsize = 1 + (this.source_representation.model.get("size") || 0); + this.source_representation.model.set("size", _newsize); + this.source_representation.select(); + this.select(); + paper.view.draw(); } /* */ @@ -1203,18 +1305,18 @@ Rkns.Renderer.NodeShrinkButton.prototype._init = function() { this.type = "Node-shrink-button"; this.lastSectorInner = 0; - this.startAngle = 90; - this.endAngle = 135; - this.imageFile = 'img/shrink.png'; + this.startAngle = -180; + this.endAngle = -135; + this.imageName = "shrink"; this.text = "Shrink"; } Rkns.Renderer.NodeShrinkButton.prototype.mouseup = function() { - var _newsize = -1 + (this.source_representation.model.get("size") || 0); - this.source_representation.model.set("size", _newsize); - this.source_representation.select(); - this.select(); - paper.view.draw(); + var _newsize = -1 + (this.source_representation.model.get("size") || 0); + this.source_representation.model.set("size", _newsize); + this.source_representation.select(); + this.select(); + paper.view.draw(); } /* */ @@ -1223,7 +1325,7 @@ Rkns.Renderer.EdgeEditButton.prototype._init = function() { this.type = "Edge-edit-button"; - this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 90, 90, 1, this.options.static_url+'img/edit.png', this.renkan.translate("Edit")); + this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit")); } Rkns.Renderer.EdgeEditButton.prototype.mouseup = function() { @@ -1238,13 +1340,37 @@ Rkns.Renderer.EdgeRemoveButton.prototype._init = function() { this.type = "Edge-remove-button"; - this.sector = Rkns.Renderer.Utils.sector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, - 270, -90, 1, this.options.static_url+'img/remove.png', this.renkan.translate("Remove")); + this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove")); } Rkns.Renderer.EdgeRemoveButton.prototype.mouseup = function() { + this.renderer.click_target = null; + this.renderer.is_dragging = false; this.renderer.removeRepresentationsOfType("editor"); - if (this.renderer.isEditable() && confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) { - this.project.removeEdge(this.source_representation.model); + if (this.renderer.isEditable()) { + var delid = Rkns.Utils.getUID("delete"); + this.renderer.delete_list.push({ + id: delid, + time: new Date().valueOf() + this.options.element_delete_delay + }); + this.source_representation.model.set("delete_scheduled", delid); + } +} + +/* */ + +Rkns.Renderer.EdgeRevertButton = Rkns.Utils.inherit(Rkns.Renderer._BaseButton); + +Rkns.Renderer.EdgeRevertButton.prototype._init = function() { + this.type = "Edge-revert-button"; + this.sector = this.renderer.drawSector(this, Rkns.Renderer._EDGE_BUTTON_INNER, Rkns.Renderer._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion")); +} + +Rkns.Renderer.EdgeRevertButton.prototype.mouseup = function() { + this.renderer.click_target = null; + this.renderer.is_dragging = false; + if (this.renderer.isEditable()) { + this.source_representation.model.unset("delete_scheduled"); } } @@ -1253,12 +1379,12 @@ Rkns.Renderer.MiniFrame = Rkns.Utils.inherit(Rkns.Renderer._BaseRepresentation); Rkns.Renderer.MiniFrame.prototype.paperShift = function(_delta) { - this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)); + this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)); this.renderer.redraw(); } Rkns.Renderer.MiniFrame.prototype.mouseup = function(_delta) { - this.renderer.click_target = null; + this.renderer.click_target = null; this.renderer.is_dragging = false; } @@ -1271,235 +1397,224 @@ this.$.html(this.template(_renkan)); this.onStatusChange(); this.canvas_$ = this.$.find(".Rk-Canvas"); + this.labels_$ = this.$.find(".Rk-Labels"); this.editor_$ = this.$.find(".Rk-Editor"); this.notif_$ = this.$.find(".Rk-Notifications"); paper.setup(this.canvas_$[0]); this.scale = 1; this.offset = paper.view.center; this.totalScroll = 0; + this.mouse_down = false; this.click_target = null; this.selected_target = null; this.edge_layer = new paper.Layer(); this.node_layer = new paper.Layer(); this.buttons_layer = new paper.Layer(); + this.delete_list = []; if (_renkan.options.show_minimap) { - this.minimap = { - background_layer: new paper.Layer(), - edge_layer: new paper.Layer(), - node_layer: new paper.Layer(), - node_group: new paper.Group(), - size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height ) - } - - this.minimap.background_layer.activate(); - this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size); - this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4])); - this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color; - this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color; - this.minimap.rectangle.strokeWidth = 4; - this.minimap.offset = new paper.Point(this.minimap.size.divide(2)); - this.minimap.scale = .1; - - this.minimap.node_layer.activate(); - this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); - this.minimap.node_group.addChild(this.minimap.cliprectangle); - this.minimap.node_group.clipped = true; - this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); - this.minimap.node_group.addChild(this.minimap.miniframe); - this.minimap.miniframe.fillColor = '#c0c0ff'; - this.minimap.miniframe.opacity = .3; - this.minimap.miniframe.strokeColor = '#000080'; - this.minimap.miniframe.strokeWidth = 3; - this.minimap.miniframe.__representation = new Rkns.Renderer.MiniFrame(this, null); + this.minimap = { + background_layer: new paper.Layer(), + edge_layer: new paper.Layer(), + node_layer: new paper.Layer(), + node_group: new paper.Group(), + size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height ) + } + + this.minimap.background_layer.activate(); + this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size); + this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4])); + this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color; + this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color; + this.minimap.rectangle.strokeWidth = 4; + this.minimap.offset = new paper.Point(this.minimap.size.divide(2)); + this.minimap.scale = .1; + + this.minimap.node_layer.activate(); + this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); + this.minimap.node_group.addChild(this.minimap.cliprectangle); + this.minimap.node_group.clipped = true; + this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size); + this.minimap.node_group.addChild(this.minimap.miniframe); + this.minimap.miniframe.fillColor = '#c0c0ff'; + this.minimap.miniframe.opacity = .3; + this.minimap.miniframe.strokeColor = '#000080'; + this.minimap.miniframe.strokeWidth = 3; + this.minimap.miniframe.__representation = new Rkns.Renderer.MiniFrame(this, null); } + this.throttledPaperDraw = Rkns._(function() { + paper.view.draw(); + }).throttle(100); + this.bundles = []; this.click_mode = false; - var _tool = new paper.Tool(), - _this = this, - _allowScroll = true; + + var _this = this, + _allowScroll = true, + _originalScale, + _zooming = false, + _lastTapDate, + _lastTapX, + _lastTapY; + + this.imageCache = {}; + + ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) { + var img = new Image(); + img.src = _renkan.options.static_url + 'img/' + imgname + '.png'; + _this.imageCache[imgname] = img; + }); + + var throttledMouseMove = _.throttle(function(_event, _isTouch) { + _this.onMouseMove(_event, _isTouch); + }, Rkns.Renderer._MOUSEMOVE_RATE); - _tool.minDistance = Rkns.Renderer._MIN_DRAG_DISTANCE; - _tool.onMouseMove = function(_event) { - _this.onMouseMove(_event); - } - _tool.onMouseDown = function(_event) { - _this.onMouseDown(_event); - } - _tool.onMouseDrag = function(_event) { - _this.onMouseDrag(_event); - } - this.canvas_$.mouseup(function(_event) { - _this.onMouseUp(_event); - }); - this.canvas_$.mousewheel(function(_event, _delta) { - if (_allowScroll) { - _this.onScroll(_event, _delta); + this.canvas_$.on({ + mousedown: function(_event) { + _event.preventDefault(); + _this.onMouseDown(_event, false); + }, + mousemove: function(_event) { + _event.preventDefault(); + throttledMouseMove(_event, false); + }, + mouseup: function(_event) { + _event.preventDefault(); + _this.onMouseUp(_event, false); + }, + mousewheel: function(_event, _delta) { + _event.preventDefault(); + if (_allowScroll) { + _this.onScroll(_event, _delta); + } + }, + touchstart: function(_event) { + _event.preventDefault(); + var _touches = _event.originalEvent.touches[0]; + if ( + _renkan.options.allow_double_click + && new Date() - _lastTap < Rkns.Renderer._DOUBLETAP_DELAY + && ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Rkns.Renderer._DOUBLETAP_DISTANCE ) + ) { + _lastTap = 0; + _this.onDoubleClick(_touches); + } else { + _lastTap = new Date(); + _lastTapX = _touches.pageX; + _lastTapY = _touches.pageY; + _originalScale = _this.scale; + _zooming = false; + _this.onMouseDown(_touches, true); + } + }, + touchmove: function(_event) { + _event.preventDefault(); + _lastTap = 0; + if (_event.originalEvent.touches.length == 1) { + _this.onMouseMove(_event.originalEvent.touches[0], true); + } else { + if (!_zooming) { + _this.onMouseUp(_event.originalEvent.touches[0], true); + _this.click_target = null; + _this.is_dragging = false; + _zooming = true; + } + if (_event.originalEvent.scale === "undefined") { + return; + } + var _newScale = _event.originalEvent.scale * _originalScale, + _scaleRatio = _newScale / _this.scale, + _newOffset = new paper.Point([ + _this.canvas_$.width(), + _this.canvas_$.height() + ]).multiply( .5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio )); + _this.setScale(_newScale, _this.offset); + } + }, + touchend: function(_event) { + _event.preventDefault(); + _this.onMouseUp(_event.originalEvent.changedTouches[0], true); + }, + dblclick: function(_event) { + _event.preventDefault(); + if (_renkan.options.allow_double_click) { + _this.onDoubleClick(_event); + } + }, + mouseleave: function(_event) { + _event.preventDefault(); + _this.onMouseUp(_event, false); + _this.click_target = null; + _this.is_dragging = false; + }, + dragover: function(_event) { + _event.preventDefault(); + }, + dragenter: function(_event) { + _event.preventDefault(); + _allowScroll = false; + }, + dragleave: function(_event) { + _event.preventDefault(); + _allowScroll = true; + }, + drop: function(_event) { + _event.preventDefault(); + _allowScroll = true; + var res = {}; + Rkns._(_event.originalEvent.dataTransfer.types).each(function(t) { + try { + res[t] = _event.originalEvent.dataTransfer.getData(t); + } catch(e) {} + }); + var text = _event.originalEvent.dataTransfer.getData("Text"); + if (typeof text === "string") { + switch(text[0]) { + case "{": + case "[": + try { + var data = JSON.parse(text); + _(res).extend(data); + } + catch(e) { + if (!res["text/plain"]) { + res["text/plain"] = text; + } + } + break; + case "<": + if (!res["text/html"]) { + res["text/html"] = text; + } + break; + default: + if (!res["text/plain"]) { + res["text/plain"] = text; + } + } + } + var url = _event.originalEvent.dataTransfer.getData("URL"); + if (url && !res["text/uri-list"]) { + res["text/uri-list"] = url; + } + _this.dropData(res, _event.originalEvent); } }); - this.canvas_$.dblclick(function(_event) { - _this.onDoubleClick(_event); - }); - this.canvas_$.on("dragover", function(_event) { - _event.stopPropagation(); - _event.preventDefault(); - }); - this.canvas_$.on("dragenter", function(_event) { - _allowScroll = false; - _event.stopPropagation(); - _event.preventDefault(); - }); - this.canvas_$.on("dragleave", function(_event) { - _allowScroll = true; - _event.stopPropagation(); - _event.preventDefault(); - }); - this.canvas_$.on("drop", function(_event) { - _event.stopPropagation(); - _event.preventDefault(); - _allowScroll = true; - if (!_this.isEditable()) { - return; - } - var res = {}; - Rkns._(_event.originalEvent.dataTransfer.types).each(function(t) { - try { - res[t] = _event.originalEvent.dataTransfer.getData(t); - } catch(e) {} - }); - var text = _event.originalEvent.dataTransfer.getData("Text"); - if (typeof text === "string") { - switch(text[0]) { - case "{": - case "[": - try { - var data = JSON.parse(text); - _(res).extend(data); - } - catch(e) { - if (!res["text/plain"]) { - res["text/plain"] = text; - } - } - break; - case "<": - if (!res["text/html"]) { - res["text/html"] = text; - } - break; - default: - if (!res["text/plain"]) { - res["text/plain"] = text; - } - } - } - var url = _event.originalEvent.dataTransfer.getData("URL"); - if (url && !res["text/uri-list"]) { - res["text/uri-list"] = url; - } - if (res["text/json"] || res["application/json"]) { - try { - var data = JSON.parse(res["text/json"] || res["application/json"]); - _(res).extend(data); - } - catch(e) {} - } - var newNode = {}; - switch(res["text/x-iri-specific-site"]) { - case "twitter": - var snippet = Rkns.$('
    ').html(res["text/x-iri-selected-html"]), - tweetdiv = snippet.find(".tweet") - newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name"); - newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id"); - newNode.image = tweetdiv.find(".avatar").attr("src"); - newNode.description = tweetdiv.find(".js-tweet-text:first").text(); - break; - case "google": - var snippet = Rkns.$('
    ').html(res["text/x-iri-selected-html"]); - newNode.title = snippet.find("h3:first").text().trim(); - newNode.uri = snippet.find("h3 a").attr("href"); - newNode.description = snippet.find(".st:first").text().trim(); - break; - case undefined: - default: - if (res["text/x-iri-source-uri"]) { - newNode.uri = res["text/x-iri-source-uri"]; - } - if (res["text/plain"] || res["text/x-iri-selected-text"]) { - newNode.description = (res["text/plain"] || res["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim(); - } - if (res["text/html"] || res["text/x-iri-selected-html"]) { - var snippet = Rkns.$('
    ').html(res["text/html"] || res["text/x-iri-selected-html"]); - newNode.image = snippet.find("img").attr("src") || ''; - newNode.uri = snippet.find("a").attr("href") || newNode.uri; - newNode.title = snippet.find("[title]").attr("title"); - newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim(); - } - if (res["text/uri-list"]) { - newNode.uri = res["text/uri-list"]; - } - if (res["text/x-moz-url"] && !newNode.title) { - newNode.title = (res["text/x-moz-url"].split("\n")[1] || "").trim(); - if (newNode.title === newNode.uri) { - newNode.title = false; - } - } - if (res["text/x-iri-source-title"] && !newNode.title) { - newNode.title = res["text/x-iri-source-title"]; - } - if (res["text/html"] || res["text/x-iri-selected-html"]) { - newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image; - newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri; - newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title; - newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description; - } - } - var fields = ["title", "description", "uri", "image"]; - for (var i = 0; i < fields.length; i++) { - var f = fields[i]; - if (res["text/x-iri-" + f] || res[f]) { - newNode[f] = res["text/x-iri-" + f] || res[f]; - } - } - if (newNode.title || newNode.description || newNode.uri) { - var _off = _this.canvas_$.offset(), - _point = new paper.Point([ - _event.originalEvent.pageX - _off.left, - _event.originalEvent.pageY - _off.top - ]), - _coords = _this.toModelCoords(_point), - _data = { - id: Rkns.Utils.getUID('node'), - created_by: _this.renkan.current_user, - uri: newNode.uri || "", - title: newNode.title || _this.renkan.translate("Dragged resource"), - description: newNode.description || "", - image: newNode.image || "", - color: newNode.color || undefined, - position: { - x: _coords.x, - y: _coords.y - } - }; - var _node = _this.renkan.project.addNode(_data); - _this.getRepresentationByModel(_node).openEditor(); - } - }) this.editor_$.find(".Rk-ZoomOut").click(function() { - var _newScale = _this.scale * Math.SQRT1_2, - _offset = new paper.Point([ - _this.canvas_$.width(), - _this.canvas_$.height() - ]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(_this.offset.multiply( Math.SQRT1_2 )); + var _newScale = _this.scale * Math.SQRT1_2, + _offset = new paper.Point([ + _this.canvas_$.width(), + _this.canvas_$.height() + ]).multiply( .5 * ( 1 - Math.SQRT1_2 ) ).add(_this.offset.multiply( Math.SQRT1_2 )); _this.setScale( _newScale, _offset ); }); this.editor_$.find(".Rk-ZoomIn").click(function() { - var _newScale = _this.scale * Math.SQRT2, - _offset = new paper.Point([ - _this.canvas_$.width(), - _this.canvas_$.height() - ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 )); + var _newScale = _this.scale * Math.SQRT2, + _offset = new paper.Point([ + _this.canvas_$.width(), + _this.canvas_$.height() + ]).multiply( .5 * ( 1 - Math.SQRT2 ) ).add(_this.offset.multiply( Math.SQRT2 )); _this.setScale( _newScale, _offset ); }); this.$.find(".Rk-CurrentUser").mouseenter( @@ -1548,45 +1663,45 @@ } }); this.$.find(".Rk-Bookmarklet-Button") - .attr("href","javascript:" + Rkns.Renderer._BOOKMARKLET_CODE(_renkan)) - .click(function(){ - _this.notif_$ - .text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.")) - .fadeIn() - .delay(5000) - .fadeOut(); - return false; - }); + .attr("href","javascript:" + Rkns.Renderer._BOOKMARKLET_CODE(_renkan)) + .click(function(){ + _this.notif_$ + .text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.")) + .fadeIn() + .delay(5000) + .fadeOut(); + return false; + }); this.$.find(".Rk-TopBar-Button").mouseover(function() { Rkns.$(this).find(".Rk-TopBar-Tooltip").show(); }).mouseout(function() { Rkns.$(this).find(".Rk-TopBar-Tooltip").hide(); }); this.$.find(".Rk-Fold-Bins").click(function() { - var bins = _renkan.$.find(".Rk-Bins"); - if (bins.offset().left < 0) { - bins.animate({left: 0},250); - _this.$.animate({left: 300},250,function() { - var w = _this.$.width(); - paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); - }); - $(this).html("«"); - } else { - bins.animate({left: -300},250); - _this.$.animate({left: 0},250,function() { - var w = _this.$.width(); - paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); - }); - $(this).html("»"); - } + var bins = _renkan.$.find(".Rk-Bins"); + if (bins.offset().left < 0) { + bins.animate({left: 0},250); + _this.$.animate({left: 300},250,function() { + var w = _this.$.width(); + paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); + }); + $(this).html("«"); + } else { + bins.animate({left: -300},250); + _this.$.animate({left: 0},250,function() { + var w = _this.$.width(); + paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]); + }); + $(this).html("»"); + } }); paper.view.onResize = function(_event) { - _this.offset = _this.offset.add(_event.delta.divide(2)); - if (_this.minimap) { - _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size) - _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4])); - _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size); + _this.offset = _this.offset.add(_event.delta.divide(2)); + if (_this.minimap) { + _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size) + _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4])); + _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size); } _this.redraw(); } @@ -1621,7 +1736,7 @@ _thRedraw(); }); this.renkan.project.on("change:title", function(_model, _title) { - var el = $(".Rk-PadTitle"); + var el = _this.$.find(".Rk-PadTitle"); if (el.is("input")) { if (el.val() !== _title) { el.val(_title); @@ -1631,13 +1746,53 @@ } }); + if (_renkan.options.size_bug_fix) { + var _delay = ( + typeof _renkan.options.size_bug_fix === "number" + ? _renkan.options.size_bug_fix + : 500 + ); + window.setTimeout( + function() { + _this.fixSize(true); + }, + _delay + ); + } + + if (_renkan.options.force_resize) { + $(window).resize(function() { + _this.fixSize(false); + }); + } + this.redraw(); + window.setInterval(function() { + var _now = new Date().valueOf(); + _this.delete_list.forEach(function(d) { + if (_now >= d.time) { + var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}); + if (el) { + project.removeNode(el); + } + el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id}); + if (el) { + project.removeEdge(el); + } + } + }); + _this.delete_list = _this.delete_list.filter(function(d) { + return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id}) + }); + }, 500); + if (this.minimap) { - window.setInterval(function() { - _this.rescaleMinimap() - }, 2000); + window.setInterval(function() { + _this.rescaleMinimap() + }, 2000); } + } Rkns.Renderer.Scene.prototype.template = Rkns._.template( @@ -1651,14 +1806,137 @@ + '
    ' + '
    ' + '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%>
    ' - + '
    ' - + '<% } } %>' - + '
    ' + + '
    ' + + '<% } %>
    <% } %>' + + '
    ' + + '
    ' + '<% if (options.show_bins) { %>
    «
    <% } %>' + '
    ">
    ">
    ' + '
    ' ); +Rkns.Renderer.Scene.prototype.fixSize = function(_autoscale) { + var w = this.$.width(), + h = this.$.height(); + if (this.renkan.options.show_top_bar) { + h -= this.$.find(".Rk-TopBar").height(); + } + this.canvas_$.attr({ + width: w, + height: h + }); + + paper.view.viewSize = new paper.Size([w, h]); + + if (_autoscale) { + this.autoScale(); + } +} + +Rkns.Renderer.Scene.prototype.drawSector = function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) { + var _options = this.renkan.options, + _startRads = _startAngle * Math.PI / 180, + _endRads = _endAngle * Math.PI / 180, + _img = this.imageCache[_imgname], + _span = _endRads - _startRads, + _startdx = - Math.sin(_startRads), + _startdy = Math.cos(_startRads), + _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx, + _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy, + _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx, + _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy, + _enddx = - Math.sin(_endRads), + _enddy = Math.cos(_endRads), + _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx, + _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy, + _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx, + _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy, + _centerR = (_inR + _outR)/2, + _centerRads = (_startRads + _endRads) / 2, + _centerX = Math.cos(_centerRads) * _centerR, + _centerY = Math.sin(_centerRads) * _centerR, + _centerXIn = Math.cos(_centerRads) * _inR, + _centerXOut = Math.cos(_centerRads) * _outR, + _centerYIn = Math.sin(_centerRads) * _inR, + _centerYOut = Math.sin(_centerRads) * _outR, + _textX = Math.cos(_centerRads) * (_outR + 3), + _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2, + _segments = []; + this.buttons_layer.activate(); + var _path = new paper.Path(); + _path.add([_startXIn, _startYIn]); + _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]); + _path.lineTo([_endXOut, _endYOut]); + _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]); + _path.fillColor = _options.buttons_background; + _path.opacity = .5; + _path.closed = true; + _path.__representation = _repr; + var _text = new paper.PointText(_textX,_textY); + _text.characterStyle = { + fontSize: _options.buttons_label_font_size, + fillColor: _options.buttons_label_color + }; + if (_textX > 2) { + _text.paragraphStyle.justification = 'left'; + } else if (_textX < -2) { + _text.paragraphStyle.justification = 'right'; + } else { + _text.paragraphStyle.justification = 'center'; + } + _text.visible = false; + var _visible = false, + _restPos = new paper.Point(-200, -200), + _grp = new paper.Group([_path, _text]), + _delta = _grp.position, + _imgdelta = new paper.Point([_centerX, _centerY]), + _currentPos = new paper.Point(0,0); + _text.content = _caption; + _grp.visible = false; + _grp.position = _restPos; + var _res = { + show: function() { + _visible = true; + _grp.position = _currentPos.add(_delta); + _grp.visible = true; + }, + moveTo: function(_point) { + _currentPos = _point; + if (_visible) { + _grp.position = _point.add(_delta); + } + }, + hide: function() { + _visible = false; + _grp.visible = false; + _grp.position = _restPos; + }, + select: function() { + _path.opacity = .8; + _text.visible = true; + }, + unselect: function() { + _path.opacity = .5; + _text.visible = false; + }, + destroy: function() { + _grp.remove(); + } + } + function showImage() { + var _raster = new paper.Raster(_img); + _raster.position = _imgdelta.add(_grp.position).subtract(_delta); + _grp.addChild(_raster); + } + if (_img.width) { + showImage(); + } else { + Rkns.$(_img).on("load",showImage); + } + + return _res +} + Rkns.Renderer.Scene.prototype.addToBundles = function(_edgeRepr) { var _bundle = Rkns._(this.bundles).find(function(_bundle) { return ( @@ -1684,33 +1962,33 @@ } Rkns.Renderer.Scene.prototype.isEditable = function() { - return (this.renkan.options.editor_mode && !this.renkan.read_only) + return (this.renkan.options.editor_mode && !this.renkan.read_only) } Rkns.Renderer.Scene.prototype.onStatusChange = function() { - var savebtn = this.$.find(".Rk-Save-Button"), - tip = savebtn.find(".Rk-TopBar-Tooltip-Contents"); - if (this.renkan.read_only) { - savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly"); - tip.text(this.renkan.translate("Connection lost")); - } else { - if (this.renkan.options.snapshot_mode) { - savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online"); - tip.text(this.renkan.translate("Archive Project")); - } else { - savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online"); - tip.text(this.renkan.translate("Auto-save enabled")); - } - } + var savebtn = this.$.find(".Rk-Save-Button"), + tip = savebtn.find(".Rk-TopBar-Tooltip-Contents"); + if (this.renkan.read_only) { + savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly"); + tip.text(this.renkan.translate("Connection lost")); + } else { + if (this.renkan.options.snapshot_mode) { + savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online"); + tip.text(this.renkan.translate("Archive Project")); + } else { + savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online"); + tip.text(this.renkan.translate("Auto-save enabled")); + } + } } Rkns.Renderer.Scene.prototype.setScale = function(_newScale, _offset) { - if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) { - this.scale = _newScale; - if (_offset) { - this.offset = _offset - } - this.redraw(); + if (_newScale > Rkns.Renderer._MIN_SCALE && _newScale < Rkns.Renderer._MAX_SCALE) { + this.scale = _newScale; + if (_offset) { + this.offset = _offset + } + this.redraw(); } } @@ -1724,7 +2002,7 @@ _maxx = Math.max.apply(Math, _xx), _maxy = Math.max.apply(Math, _yy); var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxy - _miny))); - this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); + this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale))); } if (nodes.length === 1) { this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]))); @@ -1732,9 +2010,9 @@ } Rkns.Renderer.Scene.prototype.redrawMiniframe = function() { - var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))), - bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight)); - this.minimap.miniframe.fitBounds(topleft, bottomright); + var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))), + bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight)); + this.minimap.miniframe.fitBounds(topleft, bottomright); } Rkns.Renderer.Scene.prototype.rescaleMinimap = function() { @@ -1747,16 +2025,16 @@ _maxx = Math.max.apply(Math, _xx), _maxy = Math.max.apply(Math, _yy); var _scale = Math.min( - this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width, - this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height, - ( this.renkan.options.minimap_width - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxx - _minx), - ( this.renkan.options.minimap_height - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxy - _miny) - ); + this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width, + this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height, + ( this.renkan.options.minimap_width - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxx - _minx), + ( this.renkan.options.minimap_height - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxy - _miny) + ); this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)); this.minimap.scale = _scale; } if (nodes.length === 1) { - this.minimap.scale = .1; + this.minimap.scale = .1; this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale)); } this.redraw(); @@ -1845,12 +2123,18 @@ }); } +Rkns.Renderer.Scene.prototype.unselectAll = function(_model) { + Rkns._(this.representations).each(function(_repr) { + _repr.unselect(); + }); +} + Rkns.Renderer.Scene.prototype.redraw = function() { Rkns._(this.representations).each(function(_representation) { - _representation.redraw(true); + _representation.redraw(true); }); if (this.minimap) { - this.redrawMiniframe(); + this.redrawMiniframe(); } paper.view.draw(); } @@ -1875,45 +2159,60 @@ } } else { if (this.selected_target) { - this.selected_target.unselect(null); + this.selected_target.unselect(); } this.selected_target = null; } } Rkns.Renderer.Scene.prototype.paperShift = function(_delta) { - this.offset = this.offset.add(_delta); + this.offset = this.offset.add(_delta); this.redraw(); } Rkns.Renderer.Scene.prototype.onMouseMove = function(_event) { - var _hitResult = paper.project.hitTest(_event.point); + var _off = this.canvas_$.offset(), + _point = new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]), + _delta = _point.subtract(this.last_point); + this.last_point = _point; + if (!this.is_dragging && this.mouse_down && _delta.length > Rkns.Renderer._MIN_DRAG_DISTANCE) { + this.is_dragging = true; + } + var _hitResult = paper.project.hitTest(_point); if (this.is_dragging) { if (this.click_target && typeof this.click_target.paperShift === "function") { - this.click_target.paperShift(_event.delta); + this.click_target.paperShift(_delta); } else { - this.paperShift(_event.delta); + this.paperShift(_delta); } } else { this.findTarget(_hitResult); } + paper.view.draw(); } -Rkns.Renderer.Scene.prototype.onMouseDown = function(_event) { - if (!this.click_target || this.click_target.type !== "temp-edge") { +Rkns.Renderer.Scene.prototype.onMouseDown = function(_event, _isTouch) { + var _off = this.canvas_$.offset(), + _point = new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]); + this.last_point = _point; + this.mouse_down = true; + if (!this.click_target || this.click_target.type !== "Temp-edge") { this.removeRepresentationsOfType("editor"); this.is_dragging = false; - var _hitResult = paper.project.hitTest(_event.point); - if (this.isEditable() && _hitResult && typeof _hitResult.item.__representation !== "undefined") { + var _hitResult = paper.project.hitTest(_point); + if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { this.click_target = _hitResult.item.__representation; - if (this.click_target.type === "Node-link-button") { - this.removeRepresentationsOfType("editor"); - this.addTempEdge(this.click_target.source_representation, _event.point); - } + this.click_target.mousedown(_event, _isTouch); } else { this.click_target = null; if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_ADDNODE) { - var _coords = this.toModelCoords(_event.point), + var _coords = this.toModelCoords(_point), _data = { id: Rkns.Utils.getUID('node'), created_by: this.renkan.current_user, @@ -1930,7 +2229,7 @@ if (this.click_mode) { if (this.isEditable() && this.click_mode === Rkns.Renderer._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") { this.removeRepresentationsOfType("editor"); - this.addTempEdge(this.click_target, _event.point); + this.addTempEdge(this.click_target, _point); this.click_mode = Rkns.Renderer._CLICKMODE_ENDEDGE; this.notif_$.fadeOut(function() { Rkns.$(this).html(_renkan.translate("Click on a second node to complete the edge")).fadeIn(); @@ -1940,14 +2239,11 @@ this.click_mode = false; } } + paper.view.draw(); } -Rkns.Renderer.Scene.prototype.onMouseDrag = function(_event) { - this.is_dragging = true; - this.onMouseMove(_event); -} - -Rkns.Renderer.Scene.prototype.onMouseUp = function(_event) { +Rkns.Renderer.Scene.prototype.onMouseUp = function(_event, _isTouch) { + this.mouse_down = false; if (this.click_target) { var _off = this.canvas_$.offset(); this.click_target.mouseup( @@ -1956,12 +2252,17 @@ _event.pageX - _off.left, _event.pageY - _off.top ]) - } + }, + _isTouch ); } else { this.click_target = null; this.is_dragging = false; + if (_isTouch) { + this.unselectAll(); + } } + paper.view.draw(); } Rkns.Renderer.Scene.prototype.onScroll = function(_event, _scrolldelta) { @@ -1973,9 +2274,9 @@ _event.pageY - _off.top ]).subtract(this.offset).multiply( Math.SQRT2 - 1 ); if (this.totalScroll > 0) { - this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) ); + this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) ); } else { - this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2))); + this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2))); } this.totalScroll = 0; } @@ -2006,3 +2307,109 @@ } paper.view.draw(); } + +Rkns.Renderer.Scene.prototype.dropData = function(_data, _event) { + if (!this.isEditable()) { + return; + } + if (_data["text/json"] || _data["application/json"]) { + try { + var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]); + _(_data).extend(jsondata); + } + catch(e) {} + } + var newNode = {}; + switch(_data["text/x-iri-specific-site"]) { + case "twitter": + var snippet = Rkns.$('
    ').html(_data["text/x-iri-selected-html"]), + tweetdiv = snippet.find(".tweet") + newNode.title = _renkan.translate("Tweet by ") + tweetdiv.attr("data-name"); + newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id"); + newNode.image = tweetdiv.find(".avatar").attr("src"); + newNode.description = tweetdiv.find(".js-tweet-text:first").text(); + break; + case "google": + var snippet = Rkns.$('
    ').html(_data["text/x-iri-selected-html"]); + newNode.title = snippet.find("h3:first").text().trim(); + newNode.uri = snippet.find("h3 a").attr("href"); + newNode.description = snippet.find(".st:first").text().trim(); + break; + case undefined: + default: + if (_data["text/x-iri-source-uri"]) { + newNode.uri = _data["text/x-iri-source-uri"]; + } + if (_data["text/plain"] || _data["text/x-iri-selected-text"]) { + newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim(); + } + if (_data["text/html"] || _data["text/x-iri-selected-html"]) { + var snippet = Rkns.$('
    ').html(_data["text/html"] || _data["text/x-iri-selected-html"]); + var _imgs = snippet.find("img"); + if (_imgs.length) { + newNode.image = _imgs[0].src; + } + var _as = snippet.find("a"); + if (_as.length) { + newNode.uri = _as[0].href; + } + newNode.title = snippet.find("[title]").attr("title") || newNode.title; + newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim(); + } + if (_data["text/uri-list"]) { + newNode.uri = _data["text/uri-list"]; + } + if (_data["text/x-moz-url"] && !newNode.title) { + newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim(); + if (newNode.title === newNode.uri) { + newNode.title = false; + } + } + if (_data["text/x-iri-source-title"] && !newNode.title) { + newNode.title = _data["text/x-iri-source-title"]; + } + if (_data["text/html"] || _data["text/x-iri-selected-html"]) { + newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image; + newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri; + newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title; + newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description; + } + } + if (!newNode.title) { + newNode.title = this.renkan.translate("Dragged resource"); + } + var fields = ["title", "description", "uri", "image"]; + for (var i = 0; i < fields.length; i++) { + var f = fields[i]; + if (_data["text/x-iri-" + f] || _data[f]) { + newNode[f] = _data["text/x-iri-" + f] || _data[f]; + } + if (newNode[f] === "none" || newNode[f] === "null") { + newNode[f] = undefined; + } + } + var _off = this.canvas_$.offset(), + _point = new paper.Point([ + _event.pageX - _off.left, + _event.pageY - _off.top + ]), + _coords = this.toModelCoords(_point), + _nodedata = { + id: Rkns.Utils.getUID('node'), + created_by: this.renkan.current_user, + uri: newNode.uri || "", + title: newNode.title || "", + description: newNode.description || "", + image: newNode.image || "", + color: newNode.color || undefined, + position: { + x: _coords.x, + y: _coords.y + } + }; + var _node = this.renkan.project.addNode(_nodedata), + _repr = this.getRepresentationByModel(_node); + if (_event.type === "drop") { + _repr.openEditor(); + } +} diff -r eb97351d5e9b -r f978d70a9e63 client/js/twitter-bin.js --- a/client/js/twitter-bin.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/twitter-bin.js Tue Apr 23 22:15:10 2013 +0200 @@ -2,16 +2,16 @@ } Rkns.Twitter.Search = function(_renkan, _opts) { - this.renkan = _renkan; - this.opts = _opts; + this.renkan = _renkan; + this.opts = _opts; } Rkns.Twitter.Search.prototype.getBgClass = function() { - return "Rk-Twitter-Icon"; + return "Rk-Twitter-Icon"; } Rkns.Twitter.Search.prototype.getSearchTitle = function() { - return this.renkan.translate("Twitter"); + return this.renkan.translate("Twitter"); } Rkns.Twitter.Search.prototype.search = function(_q) { @@ -38,7 +38,7 @@ ); Rkns.Twitter.Bin.prototype._init = function(_renkan, _opts) { - this.renkan = _renkan; + this.renkan = _renkan; this.search = _opts.search; this.title_icon_$.addClass('Rk-Twitter-Title-Icon'); this.title_$.html(this.search).addClass("Rk-Twitter-Title"); diff -r eb97351d5e9b -r f978d70a9e63 client/js/wikipedia-bin.js --- a/client/js/wikipedia-bin.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/js/wikipedia-bin.js Tue Apr 23 22:15:10 2013 +0200 @@ -11,16 +11,16 @@ } Rkns.Wikipedia.Search.prototype.getSearchTitle = function() { - var langs = { - "fr": "French", - "en": "English", - "ja": "Japanese" - } - if (langs[this.lang]) { - return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]); - } else { - return this.renkan.translate("Wikipedia") + " [" + this.lang + "]"; - } + var langs = { + "fr": "French", + "en": "English", + "ja": "Japanese" + } + if (langs[this.lang]) { + return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]); + } else { + return this.renkan.translate("Wikipedia") + " [" + this.lang + "]"; + } } Rkns.Wikipedia.Search.prototype.search = function(_q) { @@ -42,7 +42,7 @@ ); Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) { - this.renkan = _renkan; + this.renkan = _renkan; this.search = _opts.search; this.lang = _opts.lang || "en"; this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang); diff -r eb97351d5e9b -r f978d70a9e63 client/lib/backbone-relational.js --- a/client/lib/backbone-relational.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/lib/backbone-relational.js Tue Apr 23 22:15:10 2013 +0200 @@ -1,6 +1,6 @@ /* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab: */ /** - * Backbone-relational.js 0.8.0+ + * Backbone-relational.js 0.8.5 * (c) 2011-2013 Paul Uithol and contributors (https://github.com/PaulUithol/Backbone-relational/graphs/contributors) * * Backbone-relational may be freely distributed under the MIT license; see the accompanying LICENSE.txt. @@ -1792,6 +1792,7 @@ */ var reset = Backbone.Collection.prototype.__reset = Backbone.Collection.prototype.reset; Backbone.Collection.prototype.reset = function( models, options ) { + options = _.extend( { merge: true }, options ); reset.call( this, models, options ); if ( this.model.prototype instanceof Backbone.RelationalModel ) { diff -r eb97351d5e9b -r f978d70a9e63 client/lib/jquery.min.js --- a/client/lib/jquery.min.js Tue Apr 23 22:14:59 2013 +0200 +++ b/client/lib/jquery.min.js Tue Apr 23 22:15:10 2013 +0200 @@ -1,5 +1,6 @@ -/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license +/*! jQuery v2.0.0 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license //@ sourceMappingURL=jquery.min.map -*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
    a",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="
    t
    ",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
    ",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj; -return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="
    ",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&>(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:b.support.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l) -}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("