Added support for context panel dropdown icon lists in extensions
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1578 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -776,6 +776,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var btn_selects = [];
|
||||||
|
|
||||||
if(ext.context_tools) {
|
if(ext.context_tools) {
|
||||||
$.each(ext.context_tools, function(i, tool) {
|
$.each(ext.context_tools, function(i, tool) {
|
||||||
// Add select tool
|
// Add select tool
|
||||||
@@ -813,7 +815,23 @@
|
|||||||
$(sel).bind(evt, func);
|
$(sel).bind(evt, func);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'button-select':
|
||||||
|
var html = '<div id="' + tool.id + '" class="dropdown toolset">'
|
||||||
|
+ '<div id="cur_' + tool.id + '" class="icon_label"></div><button></button></div>';
|
||||||
|
|
||||||
|
var list = $('<ul id="' + tool.id + '_opts"></ul>').appendTo('#option_lists');
|
||||||
|
|
||||||
|
// Creates the tool, hides & adds it, returns the select element
|
||||||
|
var dropdown = $(html).appendTo(panel).children();
|
||||||
|
|
||||||
|
btn_selects.push({
|
||||||
|
elem: ('#' + tool.id),
|
||||||
|
list: ('#' + tool.id + '_opts'),
|
||||||
|
callback: tool.events.change,
|
||||||
|
cur: ('#cur_' + tool.id)
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
case 'input':
|
case 'input':
|
||||||
var html = '<label' + cont_id + '>'
|
var html = '<label' + cont_id + '>'
|
||||||
+ '<span id="' + tool.id + '_label">'
|
+ '<span id="' + tool.id + '_label">'
|
||||||
@@ -885,13 +903,21 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var button = $('<div/>')
|
var button = $(btn.list?'<li/>':'<div/>')
|
||||||
.attr("id", id)
|
.attr("id", id)
|
||||||
.attr("title", btn.title)
|
.attr("title", btn.title)
|
||||||
.addClass(cls);
|
.addClass(cls);
|
||||||
if(!btn.includeWith) {
|
if(!btn.includeWith && !btn.list) {
|
||||||
button.appendTo(parent);
|
button.appendTo(parent);
|
||||||
} else {
|
} else if(btn.list) {
|
||||||
|
// Add button to list
|
||||||
|
button.addClass('push_button');
|
||||||
|
$('#' + btn.list + '_opts').append(button);
|
||||||
|
if(btn.isDefault) {
|
||||||
|
$('#cur_' + btn.list).append(button.children().clone());
|
||||||
|
placement_obj['#cur_' + btn.list] = btn.id;
|
||||||
|
}
|
||||||
|
} else if(btn.includeWith) {
|
||||||
// Add to flyout menu / make flyout menu
|
// Add to flyout menu / make flyout menu
|
||||||
var opts = btn.includeWith;
|
var opts = btn.includeWith;
|
||||||
// opts.button, default, position
|
// opts.button, default, position
|
||||||
@@ -947,35 +973,42 @@
|
|||||||
if(!svgicons) {
|
if(!svgicons) {
|
||||||
button.append(icon);
|
button.append(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add given events to button
|
if(!btn.list) {
|
||||||
$.each(btn.events, function(name, func) {
|
// Add given events to button
|
||||||
if(name == "click") {
|
$.each(btn.events, function(name, func) {
|
||||||
if(btn.type == 'mode') {
|
if(name == "click") {
|
||||||
if(btn.includeWith) {
|
if(btn.type == 'mode') {
|
||||||
button.bind(name, func);
|
if(btn.includeWith) {
|
||||||
|
button.bind(name, func);
|
||||||
|
} else {
|
||||||
|
button.bind(name, function() {
|
||||||
|
if(toolButtonClick(button)) {
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(btn.key) {
|
||||||
|
$(document).bind('keydown', btn.key, func);
|
||||||
|
if(btn.title) button.attr("title", btn.title + ' ['+btn.key+']');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
button.bind(name, function() {
|
button.bind(name, func);
|
||||||
if(toolButtonClick(button)) {
|
|
||||||
func();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(btn.key) {
|
|
||||||
$(document).bind('keydown', btn.key, func);
|
|
||||||
if(btn.title) button.attr("title", btn.title + ' ['+btn.key+']');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
button.bind(name, func);
|
button.bind(name, func);
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
button.bind(name, func);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setupFlyouts(holders);
|
setupFlyouts(holders);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.each(btn_selects, function() {
|
||||||
|
addAltDropDown(this.elem, this.list, this.callback, {seticon: true});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$.svgIcons(svgicons, {
|
$.svgIcons(svgicons, {
|
||||||
w:24, h:24,
|
w:24, h:24,
|
||||||
id_match: false,
|
id_match: false,
|
||||||
@@ -1700,7 +1733,14 @@
|
|||||||
if(dropUp) {
|
if(dropUp) {
|
||||||
$(elem).addClass('dropup');
|
$(elem).addClass('dropup');
|
||||||
}
|
}
|
||||||
list.find('li').bind('mouseup', callback);
|
list.find('li').bind('mouseup', function() {
|
||||||
|
if(opts.seticon) {
|
||||||
|
setIcon('#cur_' + button[0].id , $(this).children());
|
||||||
|
$(this).addClass('current').siblings().removeClass('current');
|
||||||
|
}
|
||||||
|
callback.apply(this, arguments);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$(window).mouseup(function(evt) {
|
$(window).mouseup(function(evt) {
|
||||||
if(!on_button) {
|
if(!on_button) {
|
||||||
@@ -1712,7 +1752,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var height = list.height();
|
var height = list.height();
|
||||||
|
|
||||||
$(elem).bind('mousedown',function() {
|
$(elem).bind('mousedown',function() {
|
||||||
var off = $(elem).offset();
|
var off = $(elem).offset();
|
||||||
if(dropUp) {
|
if(dropUp) {
|
||||||
@@ -2295,7 +2334,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var setIcon = function(elem, icon_id, forcedSize) {
|
var setIcon = function(elem, icon_id, forcedSize) {
|
||||||
var icon = $.getSvgIcon(icon_id).clone();
|
var icon = (typeof icon_id == 'string') ? $.getSvgIcon(icon_id).clone() : icon_id.clone();
|
||||||
$(elem).empty().append(icon);
|
$(elem).empty().append(icon);
|
||||||
if(forcedSize) {
|
if(forcedSize) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user