This commit is contained in:
Connor Turland 2014-10-05 09:44:28 -04:00
commit ad2d79a7ea
4 changed files with 187 additions and 194 deletions

View file

@ -373,29 +373,7 @@ Metamaps.GlobalUI.Search = {
self.close(0, true);
}
break;
case 65:
case 97:
if (e.ctrlKey){
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
e.preventDefault();
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
Metamaps.Control.selectNode(n,e);
});
Metamaps.Visualize.mGraph.plot();
}
break;
case 69:
case 101:
if (e.ctrlKey){
e.preventDefault();
Metamaps.JIT.zoomExtents();
}
break;
default:
break; //console.log(e.which);
}

View file

@ -1654,6 +1654,11 @@ Metamaps.JIT = {
var ratioX = spanX / width;
var ratioY = spanY / height;
var cogX = (maxX + minX)/2;
var cogY = (maxY + minY)/2;
canvas.translate(-1* cogX, -1* cogY);
var newRatio = Math.max(ratioX,ratioY);
var scaleMultiplier = 1/newRatio*0.9;
@ -1669,43 +1674,6 @@ Metamaps.JIT = {
canvas.scale(scaleMultiplier,scaleMultiplier);
}
counter = 0;
nodes.forEach(function (n) {
var x = n.pos.x,
y = n.pos.y;
if (counter == 0){
maxX = x;
minX = x;
maxY = y;
minY = y;
}
var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'),
dim = n.getData('dim'),
ctx = canvas.getCtx();
var height = 25 * arrayOfLabelLines.length;
var index, lineWidths = [];
for (index = 0; index < arrayOfLabelLines.length; ++index) {
lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width)
}
var width = Math.max.apply(null, lineWidths) + 8;
maxX = Math.max(x + width /2,maxX);
maxY = Math.max(y + n.getData("height") + 5 + height,maxY);
minX = Math.min(x - width /2,minX);
minY = Math.min(y - dim,minY);
counter++;
});
var cogX = (maxX + minX)/2;
var cogY = (maxY + minY)/2;
canvas.translate(-1* cogX, -1* cogY);
$(document).trigger(Metamaps.JIT.events.zoom, [event]);
}
else if(nodes.length == 1){

View file

@ -2743,6 +2743,53 @@ Metamaps.Listeners = {
case 27:
if (Metamaps.Active.Map) Metamaps.JIT.escKeyHandler();
break;
case 65: //if a or A is pressed
case 97:
if (e.ctrlKey){
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
e.preventDefault();
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
Metamaps.Control.selectNode(n,e);
});
Metamaps.Visualize.mGraph.plot();
}
break;
case 69: //if e or E is pressed
case 101:
if (e.ctrlKey){
e.preventDefault();
Metamaps.JIT.zoomExtents();
}
break;
case 82: //if r or R is pressed
case 114:
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.removeSelectedNodes();
console.log('Once function works, selected nodes will be removed');
}
break;
case 68: //if d or D is pressed
case 100:
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.deleteSelectedNodes();
console.log('Once function works, selected nodes will be deleted');
}
break;
case 72: //if h or H is pressed
case 104:
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.hideSelectedNodes();
console.log('Once function works, selected nodes will be hidden');
}
break;
default:
break; //alert(e.which);
}

View file

@ -1,134 +1,134 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140930013020) do
create_table "in_metacode_sets", :force => true do |t|
t.integer "metacode_id"
t.integer "metacode_set_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
create_table "mappings", :force => true do |t|
t.text "category"
t.integer "xloc"
t.integer "yloc"
t.integer "topic_id"
t.integer "synapse_id"
t.integer "map_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "maps", :force => true do |t|
t.text "name"
t.boolean "arranged"
t.text "desc"
t.text "permission"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "featured"
t.string "screenshot_file_name"
t.string "screenshot_content_type"
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
end
create_table "metacode_sets", :force => true do |t|
t.string "name"
t.text "desc"
t.integer "user_id"
t.boolean "mapperContributed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
create_table "metacodes", :force => true do |t|
t.text "name"
t.string "icon"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "color"
end
create_table "synapses", :force => true do |t|
t.text "desc"
t.text "category"
t.text "weight"
t.text "permission"
t.integer "node1_id"
t.integer "node2_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "topics", :force => true do |t|
t.text "name"
t.text "desc"
t.text "link"
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.text "settings"
t.string "code", :limit => 8
t.string "joinedwithcode", :limit => 8
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "encrypted_password", :limit => 128, :default => ""
t.string "remember_token"
t.datetime "remember_created_at"
t.string "reset_password_token"
t.datetime "last_sign_in_at"
t.string "last_sign_in_ip"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140930013020) do
create_table "in_metacode_sets", :force => true do |t|
t.integer "metacode_id"
t.integer "metacode_set_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
create_table "mappings", :force => true do |t|
t.text "category"
t.integer "xloc"
t.integer "yloc"
t.integer "topic_id"
t.integer "synapse_id"
t.integer "map_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "maps", :force => true do |t|
t.text "name"
t.boolean "arranged"
t.text "desc"
t.text "permission"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "featured"
t.string "screenshot_file_name"
t.string "screenshot_content_type"
t.integer "screenshot_file_size"
t.datetime "screenshot_updated_at"
end
create_table "metacode_sets", :force => true do |t|
t.string "name"
t.text "desc"
t.integer "user_id"
t.boolean "mapperContributed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
create_table "metacodes", :force => true do |t|
t.text "name"
t.string "icon"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "color"
end
create_table "synapses", :force => true do |t|
t.text "desc"
t.text "category"
t.text "weight"
t.text "permission"
t.integer "node1_id"
t.integer "node2_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "topics", :force => true do |t|
t.text "name"
t.text "desc"
t.text "link"
t.text "permission"
t.integer "user_id"
t.integer "metacode_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "audio_file_name"
t.string "audio_content_type"
t.integer "audio_file_size"
t.datetime "audio_updated_at"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.text "settings"
t.string "code", :limit => 8
t.string "joinedwithcode", :limit => 8
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "encrypted_password", :limit => 128, :default => ""
t.string "remember_token"
t.datetime "remember_created_at"
t.string "reset_password_token"
t.datetime "last_sign_in_at"
t.string "last_sign_in_ip"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.string "current_sign_in_ip"
t.datetime "reset_password_sent_at"
t.boolean "admin"
t.string "image_file_name"
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
end
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
end