Merge pull request #143 from maitai/master

Configurable trigger for opening the right sidebar (hover/click)
This commit is contained in:
Kent Safranski
2013-01-27 05:39:10 -08:00
5 changed files with 77 additions and 16 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@
config.php
data/
workspace/
.project

View File

@@ -164,6 +164,19 @@ switch($_GET['action']){
</td>
</tr>
<tr>
<td><?php i18n("Right Sidebar Trigger"); ?></td>
<td>
<select class="setting" data-setting="right-sidebar-trigger">
<option value="false"><?php i18n("Hover"); ?></option>
<option value="true"><?php i18n("Click"); ?></option>
</select>
</td>
</tr>
</table>
@@ -206,6 +219,9 @@ var editor_settings = {
case 'wrap-mode':
$(this).children('option[value="'+codiad.editor.settings.wrapMode+'"]').prop('selected',true);
break;
case 'right-sidebar-trigger':
$(this).children('option[value="'+codiad.editor.settings.rightSidebarTrigger+'"]').prop('selected',true);
break;
}
});
},
@@ -241,6 +257,10 @@ var editor_settings = {
var bool_val = (val == "true");
codiad.editor.setWrapMode(bool_val);
break;
case 'right-sidebar-trigger':
var bool_val = (val == "true");
codiad.editor.setRightSidebarTrigger(bool_val);
break;
}
}
});

View File

@@ -324,7 +324,7 @@
}
});
$.each(['printMargin', 'highlightLine', 'indentGuides', 'wrapMode'],
$.each(['printMargin', 'highlightLine', 'indentGuides', 'wrapMode', 'rightSidebarTrigger'],
function(idx, key) {
var localValue =
localStorage.getItem('codiad.editor.' + key);
@@ -937,6 +937,22 @@
localStorage.setItem('codiad.editor.wrapMode', w);
},
//////////////////////////////////////////////////////////////////
//
// Set trigger for opening the right sidebar
//
// Parameters:
// t - {Boolean} (false for Hover, true for Click)
// i - {Editor} (If omitted, Defaults to all editors)
//
//////////////////////////////////////////////////////////////////
setRightSidebarTrigger: function(t, i) {
this.settings.rightSidebarTrigger = t;
// LocalStorage
localStorage.setItem('codiad.editor.rightSidebarTrigger', t);
},
//////////////////////////////////////////////////////////////////
//
// Get content from editor

View File

@@ -87,22 +87,43 @@
// Right Column Slider
$("#sb-right")
.hoverIntent(function() {
var timeout_r = $(this)
.data("timeout_r");
if (timeout_r) {
clearTimeout(timeout_r);
.click(function() {
if (codiad.editor.settings.rightSidebarTrigger) { // if trigger set to Click
var timeout_r = $(this)
.data("timeout_r");
if (timeout_r) {
clearTimeout(timeout_r);
}
$('#editor-region')
.animate({
'margin-right': '200px'
}, 300, 'easeOutQuart', function(){
_this.isRigthSidebarOpen = true;
});
$(this)
.animate({
'right': '0px'
}, 300, 'easeOutQuart');
}
})
.hoverIntent(function() {
if (!codiad.editor.settings.rightSidebarTrigger) { // if trigger set to Hover
var timeout_r = $(this)
.data("timeout_r");
if (timeout_r) {
clearTimeout(timeout_r);
}
$('#editor-region')
.animate({
'margin-right': '200px'
}, 300, 'easeOutQuart', function(){
_this.isRigthSidebarOpen = true;
});
$(this)
.animate({
'right': '0px'
}, 300, 'easeOutQuart');
}
$('#editor-region')
.animate({
'margin-right': '200px'
}, 300, 'easeOutQuart', function(){
_this.isRigthSidebarOpen = true;
});
$(this)
.animate({
'right': '0px'
}, 300, 'easeOutQuart');
}, function() {
$(this)
.data("timeout_r", setTimeout($.proxy(function() {

View File

@@ -22,6 +22,9 @@ $lang = array(
"Wrap Lines" => "Wrap Lines",
"No wrap" => "No wrap",
"Wrap Lines" => "Wrap Lines",
"Right Sidebar Trigger" => "Right Sidebar Trigger",
"Hover" => "Hover",
"Click" => "Click",
"Close" => "Close",
"Yes" => "Yes",
"No" => "No",