This repository was archived by the owner on Oct 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathext.ctrl_s.php
More file actions
105 lines (92 loc) · 2.75 KB
/
ext.ctrl_s.php
File metadata and controls
105 lines (92 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Ctrl+s
*
* @package Ctrl+s
* @author Scott-David Jones <enquiries@autumndev.co.uk>
* @copyright Copyright (c) 2012 AutumnDev
*/
class Ctrl_s_ext {
var $name = "Ctrl+S";
var $version = 1.0;
var $description = "Shortcut for 'Update' or 'Save' on any Control Panel Screen";
var $docs_url = 'www.autumndev.co.uk';
var $settings_exist = 'n';
var $globalVars;
/**
* Constructor
*/
function __construct()
{
// -------------------------------------------
// Make a local reference to the
// EE super object
// -------------------------------------------
$this->EE =& get_instance();
}
// --------------------------------------------------------------------
/**
* Activate Extension
*/
function activate_extension()
{
// -------------------------------------------
// Add the row to exp_extensions
// -------------------------------------------
$this->EE->db->insert('extensions', array(
'class' => __CLASS__,
'method' => 'addSave',
'hook' => 'cp_js_end',
'settings' => '',
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
));
}
/**
* Update Extension
*/
function update_extension($current = '')
{
if ($current == '' OR $current == $this->version)
{
return false;
}
$this->EE->db->where('class', __CLASS__);
$this->EE->db->update(
'extensions',
array('version' => $this->version)
);
}
/**
* Disable Extension
*/
function disable_extension()
{
// -------------------------------------------
// Remove the row from exp_extensions
// -------------------------------------------
$this->EE->db->where('class', __CLASS__)
->delete('extensions');
}
//input name="update"
//input name="submit" id="submit_button"
function addSave(){
$js = "
$.ctrl = function(key, callback, args) {
$(document).keydown(function(e) {
if(!args) args=[]; // IE cries without this
if(e.keyCode == key.charCodeAt(0) && (e.ctrlKey || e.metaKey)) {
callback.apply(this, args);
return false;
}
});
};
$.ctrl('S', function(s) {
//find any update/submit buttons
$('input[name=update], input[name=submit]').click();
});
";
return $this->EE->extensions->last_call . $js;
}
}