FINAL suepr merge step : added all modules to this super repos
339
sites/all/modules/contrib/admin/cobalt/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
16
sites/all/modules/contrib/admin/cobalt/README.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
h1. COBALT
|
||||
|
||||
Thank you for downloading Cobalt. Cobalt is a way to control Drupal 6 made in the image of "Quicksilver":http://docs.blacktree.com/quicksilver/what_is_quicksilver for Mac. So far it's confirmed to work in Safari/Webkit and Firefox 3. In Firefox, and other potentially compatible browsers, Google Gears have to be installed for quicksilver to work. This is due to Cobalt's need to store data locally for fast access.
|
||||
|
||||
h2. INSTRUCTIONS
|
||||
|
||||
Cobalt is invoked through pressing [Alt+space] or [Ctrl+space]. Then you only have to start typing to quickly get what you want. Use the arrow up/down to select one of the suggestions and [Alt+left/right] to switch between the the pages. Cobalt will learn from your choices so the amount of selecting and paging will decrease over time. If you are satisfied with the default action (Go to for menu items) you can just press enter to execute it. If you want to do something else (maybe you would like to assign a shortcut) just press [tab] and select one of the actions using the arrow keys or typing part of the action name. The press enter to execute the selected action.
|
||||
|
||||
The Cobalt Nodes module also provides convenient context entries like "Edit current node", that, just like any other entry, you can assign shortcuts to. Then you can assign shortcuts like [Ctrl+e], [Ctrl+v] and [Ctrl+Shift+d] to edit, view or delete the node whose page you're currently on.
|
||||
|
||||
h2. INSTALLATION
|
||||
|
||||
Cobalt consists of four modules. The Cobalt module contains Cobalt itself and access to the menu system, including the devel modules menu items (do you use clear cache often? Assign it a shortcut like [Ctrl+Shift+c] and life *will* get easier.). The three other modules: Cobalt Nodes, Cobalt Taxonomy and Cobalt Users provides access to exactly the stuff their names imply with sensible actions like view, edit and delete.
|
||||
|
||||
We now have modules in place that supports lookup for menus, nodes, users and taxonomy. Nodes and users have view, edit and delete actions that can be accessed by tabbing to the right cell and pressing the up and down arrow keys.
|
16
sites/all/modules/contrib/admin/cobalt/cobalt.info
Normal file
@@ -0,0 +1,16 @@
|
||||
name = Cobalt
|
||||
description = Cobalt is a javascript implementation of Quicksilver for Drupal
|
||||
package = Cobalt
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = menu
|
||||
|
||||
files[] = cobalt.module
|
||||
files[] = cobalt_admin.inc.php
|
||||
files[] = cobalt_update.inc.php
|
||||
; Information added by drupal.org packaging script on 2012-05-18
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "cobalt"
|
||||
datestamp = "1337350855"
|
||||
|
212
sites/all/modules/contrib/admin/cobalt/cobalt.module
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_init().
|
||||
*/
|
||||
function cobalt_init() {
|
||||
if (user_access('use cobalt')) {
|
||||
global $user;
|
||||
|
||||
if (variable_get('cobalt_jquery_hotkeys', 1)) {
|
||||
drupal_add_library('cobalt', 'jquery.hotkeys');
|
||||
}
|
||||
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.js');
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.menu.js');
|
||||
|
||||
$settings = array(
|
||||
'state' => $user->uid,
|
||||
'path' => $_GET['q'],
|
||||
'bindings' => preg_split('/,\s*/', variable_get('cobalt_shortcuts', 'Alt+space, Ctrl+space')),
|
||||
);
|
||||
drupal_add_js(array('cobalt' => $settings), 'setting');
|
||||
|
||||
$themes = cobalt_themes();
|
||||
$theme_key = variable_get('cobalt_theme', '');
|
||||
foreach ($themes as $key => $info) {
|
||||
if ($key==$theme_key) {
|
||||
$theme = $info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($theme) || !isset($theme['css']) || !isset($theme['replace']) || !$theme['replace']) {
|
||||
drupal_add_css(drupal_get_path('module', 'cobalt') . '/css/cobalt.css');
|
||||
}
|
||||
if (isset($theme) && isset($theme['css'])) {
|
||||
if (is_array($theme['css'])) {
|
||||
foreach ($theme['css'] as $css) {
|
||||
drupal_add_css($css);
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_add_css($theme['css']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_library().
|
||||
*/
|
||||
function cobalt_library() {
|
||||
// Use the original version by John Resig since the latest version at
|
||||
// https://github.com/tzuryby/jquery.hotkeys doesn't work, probably due
|
||||
// to incompatibility with jQuery 1.4.4.
|
||||
$libraries['jquery.hotkeys'] = array(
|
||||
'title' => 'jQuery Hotkeys',
|
||||
'website' => 'https://github.com/jeresig/jquery.hotkeys',
|
||||
'version' => '0.8',
|
||||
'js' => array(
|
||||
drupal_get_path('module', 'cobalt') . '/js/jquery.hotkeys.js' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
return $libraries;
|
||||
}
|
||||
|
||||
function cobalt_themes() {
|
||||
static $themes;
|
||||
|
||||
if (!$themes) {
|
||||
$themes = array(
|
||||
'' => array(
|
||||
'name' => t('Default theme'),
|
||||
),
|
||||
);
|
||||
drupal_alter('cobalt_themes', $themes);
|
||||
}
|
||||
|
||||
return $themes;
|
||||
}
|
||||
|
||||
function cobalt_cobalt_themes_alter(&$themes) {
|
||||
$themes['cobalt_blue'] = array(
|
||||
'name' => t('Cobalt blue'),
|
||||
'css' => drupal_get_path('module', 'cobalt') . '/css/cobalt_blue.css',
|
||||
'replace' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_perm().
|
||||
*/
|
||||
function cobalt_permissions() {
|
||||
return array(
|
||||
'use cobalt' => array(
|
||||
'title' => t('Enables Cobalt for the user'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function cobalt_menu() {
|
||||
$items = array();
|
||||
$items['cobalt/alias'] = array(
|
||||
'title' => 'Forward to the correct alias',
|
||||
'page callback' => 'cobalt_forward_to_alias',
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['cobalt/data/menu_json'] = array(
|
||||
'title' => 'Serialized menu',
|
||||
'page callback' => 'cobalt_menu_json',
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['admin/config/system/cobalt'] = array(
|
||||
'title' => 'Cobalt',
|
||||
'description' => 'Configure Cobalt appearance and behaviour.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('cobalt_settings'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'file' => 'cobalt_admin.inc.php',
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'weight' => 0,
|
||||
);
|
||||
$items['cobalt/update'] = array(
|
||||
'title' => 'Cobalt update',
|
||||
'page callback' => 'cobalt_js_update',
|
||||
'page arguments' => array('cobalt_settings'),
|
||||
'access arguments' => array('use cobalt'),
|
||||
'file' => 'cobalt_update.inc.php',
|
||||
'type' => MENU_CALLBACK,
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
// Menu callback for clearing the cache even when the devel module
|
||||
// isn't installed.
|
||||
$items['cobalt/clear-cache'] = array(
|
||||
'title' => t('Clear cache'),
|
||||
'page callback' => '_cobalt_clear_cache',
|
||||
'file' => 'cobalt_admin.inc.php',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
// Menuitem for rebuilding content permissions.
|
||||
$items['cobalt/rebuild-permissions'] = array(
|
||||
'title' => t('Rebuild permissions'),
|
||||
'page callback' => '_cobalt_rebuild_permissions',
|
||||
'file' => 'cobalt_admin.inc.php',
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function cobalt_forward_to_alias() {
|
||||
$url_parts = array();
|
||||
$i = 2;
|
||||
while (arg($i)) {
|
||||
$url_parts[] = arg($i);
|
||||
$i++;
|
||||
}
|
||||
$path = join('/', $url_parts);
|
||||
drupal_goto($path);
|
||||
}
|
||||
|
||||
function cobalt_menu_json() {
|
||||
$menu_names = array_keys(menu_get_menus());
|
||||
|
||||
$tree = array();
|
||||
foreach ($menu_names as $name) {
|
||||
$tree += menu_tree_all_data($name);
|
||||
}
|
||||
|
||||
$data = array();
|
||||
_cobalt_menu_data_recursive($tree, $data);
|
||||
|
||||
drupal_alter('cobalt_menu', $data);
|
||||
|
||||
print drupal_json_output($data);
|
||||
exit;
|
||||
}
|
||||
|
||||
function _cobalt_menu_data_recursive($tree, &$data) {
|
||||
foreach ($tree as $key => $item) {
|
||||
$link = $item['link'];
|
||||
if ($link['hidden'] !== 1 && $link['access'] && !($link['type'] & MENU_LINKS_TO_PARENT) && $link['type'] !== MENU_VISIBLE_IN_BREADCRUMB) {
|
||||
$data[$link['mlid']] = array($link['href'], $link['title']);
|
||||
if ($item['below']) {
|
||||
_cobalt_menu_data_recursive($item['below'], $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_cobalt_menu_alter().
|
||||
*/
|
||||
function cobalt_cobalt_menu_alter(&$menuitems) {
|
||||
if (!module_exists('devel') && user_access('administer site configuration')) {
|
||||
$menuitems['cobalt-clear-cache'] = array('cobalt/clear-cache', t('Clear cache'));
|
||||
}
|
||||
|
||||
if (user_access('administer site configuration')) {
|
||||
$menuitems['cobalt-rebuild-permissions'] = array('cobalt/rebuild-permissions', t('Rebuild permissions'));
|
||||
}
|
||||
}
|
50
sites/all/modules/contrib/admin/cobalt/cobalt_admin.inc.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
function cobalt_settings() {
|
||||
$form = array();
|
||||
|
||||
$themes = cobalt_themes();
|
||||
$theme_options = array();
|
||||
foreach ($themes as $key => $info) {
|
||||
$theme_options[$key] = $info['name'];
|
||||
}
|
||||
|
||||
$form['cobalt_theme'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $theme_options,
|
||||
'#default_value' => variable_get('cobalt_theme', ''),
|
||||
'#title' => t('Select a theme for Cobalt'),
|
||||
);
|
||||
|
||||
$form['cobalt_shortcuts'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => variable_get('cobalt_shortcuts', 'Alt+space, Ctrl+space'),
|
||||
'#title' => t('Shortcuts for activating cobalt'),
|
||||
'#description' => t('The shortcuts that can be used to activate Cobalt should be separated by a comma, like this: "Alt+space, Ctrl+space".') . ' ' . l(t('See the live demo for jshotkeys to get some help'), 'http://jshotkeys.googlepages.com/test-static-01.html'),
|
||||
);
|
||||
|
||||
$form['javascript_includes'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Javascript includes'),
|
||||
'#description' => t('All the following libraries are needed for Cobalt to function properly. These options are here if you need Cobalt to play nice with any other modules or themes that use the same javascript libraries.'),
|
||||
);
|
||||
|
||||
$form['javascript_includes']['cobalt_jquery_hotkeys'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => variable_get('cobalt_jquery_hotkeys', 1),
|
||||
'#title' => t('Include the jQuery Hotkeys plugin'),
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
function _cobalt_clear_cache() {
|
||||
drupal_flush_all_caches();
|
||||
drupal_set_message(t('Cache cleared.'));
|
||||
drupal_goto();
|
||||
}
|
||||
|
||||
function _cobalt_rebuild_permissions() {
|
||||
node_access_rebuild();
|
||||
drupal_goto();
|
||||
}
|
33
sites/all/modules/contrib/admin/cobalt/cobalt_update.inc.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
function cobalt_js_update() {
|
||||
$settings = array();
|
||||
$out = 'Updating the following: <ul>';
|
||||
for ($i=2; arg($i); $i+=3) {
|
||||
$module = arg($i);
|
||||
$from = arg($i+1);
|
||||
$to = arg($i+2);
|
||||
|
||||
$settings[$module] = array($from, $to);
|
||||
|
||||
$up_file = drupal_get_path('module', $module) . '/' . $module . '_update.inc.php';
|
||||
if (file_exists($up_file)) {
|
||||
require_once($up_file);
|
||||
}
|
||||
|
||||
$up_function = $module . '_cobalt_js_update';
|
||||
if (is_callable($up_function)) {
|
||||
call_user_func($up_function, $from, $to);
|
||||
}
|
||||
|
||||
$out .= "<li>{$module} from {$from} to {$to}</li>";
|
||||
}
|
||||
$out .= '</ul>';
|
||||
|
||||
drupal_add_js(array('cobalt' => array('update' => $settings)), 'setting');
|
||||
return $out;
|
||||
}
|
||||
|
||||
function cobalt_cobalt_js_update($from, $to) {
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.update.js');
|
||||
}
|
15
sites/all/modules/contrib/admin/cobalt/cobaltnodes.info
Normal file
@@ -0,0 +1,15 @@
|
||||
name = Cobalt Nodes
|
||||
description = Provides access to nodes through cobalt
|
||||
dependencies[] = cobalt
|
||||
package = "Cobalt"
|
||||
core = "7.x"
|
||||
|
||||
files[] = cobaltnodes.install
|
||||
files[] = cobaltnodes.module
|
||||
files[] = cobaltnodes_update.inc.php
|
||||
; Information added by drupal.org packaging script on 2012-05-18
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "cobalt"
|
||||
datestamp = "1337350855"
|
||||
|
41
sites/all/modules/contrib/admin/cobalt/cobaltnodes.install
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
function cobaltnodes_install() {
|
||||
drupal_install_schema('cobaltnodes');
|
||||
}
|
||||
|
||||
function cobaltnodes_uninstall() {
|
||||
drupal_uninstall_schema('cobaltnodes');
|
||||
}
|
||||
|
||||
function cobaltnodes_schema() {
|
||||
$schema = array();
|
||||
|
||||
$schema['cobalt_node_deletion'] = array(
|
||||
'description' => t('Registers node deletions so that deleted nodes can be removed from the index.'),
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => t('Node id'),
|
||||
),
|
||||
'deleted' => array(
|
||||
'description' => t('The Unix timestamp when the node was deleted.'),
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0),
|
||||
),
|
||||
'primary key' => array('nid'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
function cobaltnodes_update_7000() {
|
||||
$ret = array();
|
||||
|
||||
db_rename_table($ret, 'cobalt_nodes_deletions', 'cobalt_node_deletion');
|
||||
|
||||
return $ret;
|
||||
}
|
103
sites/all/modules/contrib/admin/cobalt/cobaltnodes.module
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
function cobaltnodes_init() {
|
||||
if (user_access('use cobalt')) {
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.nodes.js');
|
||||
|
||||
// Add the current node nid as a javascript setting
|
||||
if (arg(0)=='node' && is_numeric(arg(1))) {
|
||||
drupal_add_js(array('cobalt' => array('nodes_current' => arg(1))), 'setting');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cobaltnodes_menu() {
|
||||
$items = array();
|
||||
$items['cobalt/data/nodes_update/%'] = array(
|
||||
'title' => 'Serialized nodes',
|
||||
'page callback' => 'cobaltnodes_json',
|
||||
'page arguments' => array('update', 3),
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['cobalt/data/nodes_single/%'] = array(
|
||||
'title' => 'Serialized node',
|
||||
'page callback' => 'cobaltnodes_json',
|
||||
'page arguments' => array('single', 3),
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
function cobaltnodes_cron() {
|
||||
// Delete logged deletions older than two weeks
|
||||
db_query("DELETE FROM {cobalt_node_deletion} WHERE deleted<:time_ago", array(
|
||||
':time_ago' => time() - 86400*14,
|
||||
));
|
||||
}
|
||||
|
||||
function cobaltnodes_node_delete($node) {
|
||||
db_query("INSERT INTO {cobalt_node_deletion}(nid, deleted) VALUES(:nid, :deleted)", array(
|
||||
':nid' => $node->nid,
|
||||
':deleted' => time()+60*1, // Add a minute for margin
|
||||
));
|
||||
}
|
||||
|
||||
function cobaltnodes_json($op, $value) {
|
||||
$result = array();
|
||||
|
||||
// We're skipping the status check on purpose. As we check with the node_access
|
||||
// function later this allows administrators to access unpublished nodes.
|
||||
if ($op=='update') {
|
||||
$res = db_query("SELECT n.nid, n.title, n.type, n.uid, n.status
|
||||
FROM {node} n
|
||||
WHERE created > :since OR changed > :since
|
||||
ORDER BY created DESC
|
||||
LIMIT 100", array(
|
||||
':since' => $value,
|
||||
));
|
||||
}
|
||||
else if ($op=='single') {
|
||||
$res = db_query("SELECT nid, title, type, uid, status FROM {node}
|
||||
WHERE nid = :nid", array(
|
||||
':nid' => $value,
|
||||
));
|
||||
}
|
||||
|
||||
$nodes = array();
|
||||
$access_types = array(
|
||||
'r' => 'view',
|
||||
'w' => 'update',
|
||||
'd' => 'delete',
|
||||
);
|
||||
|
||||
foreach ($res as $node) {
|
||||
$access = '';
|
||||
foreach ($access_types as $key => $permission) {
|
||||
if (node_access($permission, $node)) {
|
||||
$access .= $key;
|
||||
}
|
||||
}
|
||||
if (!empty($access)) {
|
||||
$nodes[] = array($node->nid, $node->title, $access);
|
||||
}
|
||||
}
|
||||
|
||||
$result['nodes'] = $nodes;
|
||||
|
||||
if ($op=='update') {
|
||||
$deleted = array();
|
||||
// Get deletions
|
||||
$res = db_query("SELECT nid FROM {cobalt_node_deletion} WHERE deleted>:since", array(
|
||||
':since' => $value,
|
||||
));
|
||||
foreach ($res as $node) {
|
||||
$deleted[] = $node->nid;
|
||||
}
|
||||
$result['deleted'] = $deleted;
|
||||
}
|
||||
|
||||
print drupal_json_output($result);
|
||||
exit;
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
/* Remove this line if you want to try out the updating mechanism
|
||||
function cobaltnodes_cobalt_js_update($from, $to) {
|
||||
drupal_add_js(drupal_get_path('module', 'cobaltnodes') . '/js/cobalt.nodes.update.js');
|
||||
}
|
||||
//*/
|
14
sites/all/modules/contrib/admin/cobalt/cobalttaxonomy.info
Normal file
@@ -0,0 +1,14 @@
|
||||
name = Cobalt Taxonomy
|
||||
description = Provides access to taxonomies through cobalt
|
||||
dependencies[] = cobalt
|
||||
dependencies[] = taxonomy
|
||||
package = "Cobalt"
|
||||
core = "7.x"
|
||||
|
||||
files[] = cobalttaxonomy.module
|
||||
; Information added by drupal.org packaging script on 2012-05-18
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "cobalt"
|
||||
datestamp = "1337350855"
|
||||
|
48
sites/all/modules/contrib/admin/cobalt/cobalttaxonomy.module
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
function cobalttaxonomy_init() {
|
||||
if (user_access('use cobalt')) {
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.taxonomy.js');
|
||||
}
|
||||
}
|
||||
|
||||
function cobalttaxonomy_menu() {
|
||||
$items = array();
|
||||
$items['cobalt/data/taxonomy_json'] = array(
|
||||
'title' => 'Serialized taxonomies',
|
||||
'page callback' => 'cobalttaxonomy_json',
|
||||
'page arguments' => array('update', 3),
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
function cobalttaxonomy_json($op, $value) {
|
||||
global $user;
|
||||
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
|
||||
$voc_data = array();
|
||||
foreach ($vocabularies as $vocabulary) {
|
||||
$voc_data[$vocabulary->vid] = $vocabulary->name;
|
||||
}
|
||||
|
||||
$term_tree = array();
|
||||
foreach ($vocabularies as $vocabulary) {
|
||||
$term_tree += taxonomy_get_tree($vocabulary->vid);
|
||||
}
|
||||
|
||||
$term_data = array();
|
||||
|
||||
foreach ($term_tree as $term) {
|
||||
$term_data[$term->tid] = array($term->name, $term->vid);
|
||||
}
|
||||
|
||||
$data = array('vocabularies' => $voc_data, 'terms' => $term_data, 'access' => user_access('administer taxonomy'));
|
||||
|
||||
print drupal_json_output($data);
|
||||
exit;
|
||||
}
|
||||
|
13
sites/all/modules/contrib/admin/cobalt/cobaltusers.info
Normal file
@@ -0,0 +1,13 @@
|
||||
name = Cobalt Users
|
||||
description = Provides access to users through cobalt
|
||||
dependencies[] = cobalt
|
||||
package = Cobalt
|
||||
core = 7.x
|
||||
|
||||
files[] = cobaltusers.module
|
||||
; Information added by drupal.org packaging script on 2012-05-18
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "cobalt"
|
||||
datestamp = "1337350855"
|
||||
|
47
sites/all/modules/contrib/admin/cobalt/cobaltusers.module
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
function cobaltusers_init() {
|
||||
if (user_access('use cobalt')) {
|
||||
drupal_add_js(drupal_get_path('module', 'cobalt') . '/js/cobalt.users.js');
|
||||
}
|
||||
}
|
||||
|
||||
function cobaltusers_menu() {
|
||||
$items = array();
|
||||
$items['cobalt/data/users_json/%'] = array(
|
||||
'title' => 'Serialized users',
|
||||
'page callback' => 'cobaltusers_json',
|
||||
'page arguments' => array(2),
|
||||
'access arguments' => array('use cobalt'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
function cobaltusers_json($last_update) {
|
||||
// We're just fetching the bare minimum of what we need for the
|
||||
// user_*_access methods and display.
|
||||
$res = db_query("SELECT uid, name, access, status FROM {users}
|
||||
WHERE created > :last_update
|
||||
ORDER BY uid DESC
|
||||
LIMIT 100", array(
|
||||
':last_update' => $last_update,
|
||||
));
|
||||
|
||||
$users = array();
|
||||
foreach ($res as $account) {
|
||||
if (user_access('administer users')) {
|
||||
$access = 'rwd';
|
||||
}
|
||||
else {
|
||||
$access = (user_view_access($account)?'r':'') . (user_edit_access($account)?'w':'');
|
||||
}
|
||||
|
||||
if (!empty($access)) {
|
||||
$users[] = array($account->uid, $account->name, $access);
|
||||
}
|
||||
}
|
||||
|
||||
print drupal_json_output($users);
|
||||
exit;
|
||||
}
|
BIN
sites/all/modules/contrib/admin/cobalt/css/bookmark.png
Normal file
After Width: | Height: | Size: 21 KiB |
161
sites/all/modules/contrib/admin/cobalt/css/cobalt.css
Normal file
@@ -0,0 +1,161 @@
|
||||
#cobalt * {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#cobalt, #cobalt-out {
|
||||
background-color: #000;
|
||||
background-color: rgba(0,0,0,0.7);
|
||||
border-radius: 20px;
|
||||
box-shadow: rgba(255, 255, 255, 0.5) 1px 1px 5px;
|
||||
-moz-border-radius: 20px;
|
||||
-webkit-border-radius: 20px;
|
||||
-webkit-box-shadow: rgba(255, 255, 255, 0.5) 1px 1px 5px;
|
||||
|
||||
position: fixed;
|
||||
top: 38%;
|
||||
left: 50%;
|
||||
margin: -85px 0 0 -165px;
|
||||
width: 330px;
|
||||
padding: 5px 0;
|
||||
|
||||
font-size: 12px;
|
||||
font-family: 'Lucida Grande', sans-serif;
|
||||
line-height: 16px;
|
||||
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#cobalt-out {
|
||||
background-color: rgba(0,0,0,0.8);
|
||||
padding: 10px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#cobalt .cell {
|
||||
position: relative;
|
||||
background-color: #FFF;
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
border-radius: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
float: left;
|
||||
margin: 5px 0 5px 10px;
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
font-family: 'Lucida Grande', sans-serif;
|
||||
}
|
||||
|
||||
#cobalt .cell input {
|
||||
text-shadow: 1px 1px 5px #FFF;
|
||||
margin: -4px 0 0 -4px;
|
||||
padding: 4px;
|
||||
width: 134px;
|
||||
height: 134px;
|
||||
border: 0;
|
||||
color: #000;
|
||||
color: rgba(0,0,0,0.8);
|
||||
background-color: transparent;
|
||||
background-color: rgba(0,0,0,0);
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
#cobalt .inner {
|
||||
overflow: hidden;
|
||||
width: 130px;
|
||||
height: 130px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#cobalt .cell label {
|
||||
display: none;
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
width: 120px;
|
||||
padding: 3px;
|
||||
text-align: center;
|
||||
color: #FFF;
|
||||
background-color: #000;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
|
||||
#cobalt .cell .cobalt-item-url_data {
|
||||
background: url(bookmark.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#cobalt .cell .cobalt-item-node {
|
||||
background: url(node.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#cobalt .cell .cobalt-item-user {
|
||||
background: url(user.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#cobalt .cell .cobalt-item-vocabulary, #cobalt .cell .cobalt-item-term {
|
||||
background: url(voc.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-paging {
|
||||
display: none;
|
||||
margin: 0;
|
||||
padding: 0 20px;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-paging li {
|
||||
display: inline-block;
|
||||
list-style: none;
|
||||
margin: 6px 0 0;
|
||||
padding: 0;
|
||||
opacity: .5;
|
||||
background: url(whitedot.png) top left no-repeat;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-paging li.current {
|
||||
opacity: 1.0;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete, #cobalt .cobalt-actions {
|
||||
display: none;
|
||||
clear: both;
|
||||
margin: 0 10px;
|
||||
padding: 10px 0 5px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete li, #cobalt .cobalt-actions li {
|
||||
display: block;
|
||||
list-style: none;
|
||||
padding: 5px 10px;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete li small {
|
||||
color: #333;
|
||||
color: rgba(256,256,256,0.8);
|
||||
}
|
||||
|
||||
#cobalt .right .cobalt-action-default {
|
||||
background: url(default_action.png) center center no-repeat;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete li.active, #cobalt .cobalt-actions li.active {
|
||||
background-color: #FFF;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
border-radius: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
}
|
||||
|
||||
#cobalt-out .cobalt-update-link {
|
||||
text-transform: uppercase;
|
||||
color: #FFF;
|
||||
}
|
46
sites/all/modules/contrib/admin/cobalt/css/cobalt_blue.css
Normal file
@@ -0,0 +1,46 @@
|
||||
#cobalt, #cobalt-out {
|
||||
background-color: #000;
|
||||
background-color: rgba(0,0,100,0.7);
|
||||
}
|
||||
|
||||
#cobalt-out {
|
||||
background-color: rgba(0,0,100,0.8);
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#cobalt .cell {
|
||||
background-color: #FFF;
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
#cobalt .cell input {
|
||||
text-shadow: 1px 1px 5px #FFF;
|
||||
color: #000;
|
||||
color: rgba(0,0,100,0.8);
|
||||
background-color: transparent;
|
||||
background-color: rgba(0,0,100,0);
|
||||
}
|
||||
|
||||
#cobalt .cell label {
|
||||
color: #FFF;
|
||||
background-color: #000;
|
||||
background-color: rgba(0,0,100,0.5);
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete, #cobalt .cobalt-actions {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete li small {
|
||||
color: #333;
|
||||
color: rgba(256,256,256,0.8);
|
||||
}
|
||||
|
||||
#cobalt .cobalt-autocomplete li.active, #cobalt .cobalt-actions li.active {
|
||||
background-color: #FFF;
|
||||
background-color: rgba(0,0,100,0.5);
|
||||
}
|
||||
|
||||
#cobalt-out .cobalt-update-link {
|
||||
color: #FFF;
|
||||
}
|
BIN
sites/all/modules/contrib/admin/cobalt/css/default_action.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/drupal.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/dummy.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/node.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/user.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/voc.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sites/all/modules/contrib/admin/cobalt/css/whitedot.png
Normal file
After Width: | Height: | Size: 215 B |
26
sites/all/modules/contrib/admin/cobalt/index.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="js/gears_init.js"></script>
|
||||
<script src="js/minimal-gears-wrapper.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="js/jquery-1.2.6.min.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="js/jquery.hotkeys.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="js/cobalt.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="js/cobalt.dummy.js" type="text/javascript" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="css/cobalt.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<link rel="stylesheet" href="css/cobalt.dummy.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
Drupal = {
|
||||
'settings': {
|
||||
'cobalt': {
|
||||
'state': 0
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="css/spiderweb.jpg" width="1024" height="682" alt="Spiderweb">
|
||||
</body>
|
||||
</html>
|
793
sites/all/modules/contrib/admin/cobalt/js/cobalt.js
Normal file
@@ -0,0 +1,793 @@
|
||||
(function($) {
|
||||
$(document).ready(function(){
|
||||
var match_count = 0, match_page_size=5, match_offset = 0,
|
||||
cobalt_visible = false, cobalt_out_visible = false,
|
||||
matches = [], match_idx = 0, handler_idx = 0,
|
||||
current_text, current_action_text='', handler, item, actions, match_count=0,
|
||||
plugins = {}, plugin_names=[], catalogs = {}, global_handlers = [], handlers = {},
|
||||
update_queue = [], required_updates = [];
|
||||
|
||||
var log_error = function(message, err) {
|
||||
if (typeof(window.console) != 'undefined') {
|
||||
console.error(message);
|
||||
if(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var log_msg = function(message) {
|
||||
if (typeof(window.console) != 'undefined') {
|
||||
console.log(message);
|
||||
}
|
||||
};
|
||||
|
||||
var db = null;
|
||||
// Initialize database
|
||||
if (!db && typeof(openDatabase)=='function') {
|
||||
try {
|
||||
db = openDatabase('cobalt', '1.0', 'Cobalt Database', 204800);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.name === 'SECURITY_ERR') {
|
||||
log_msg(Drupal.t('Failed to open database using the Web SQL Database API due to a security-related error.'));
|
||||
}
|
||||
else {
|
||||
log_msg(Drupal.t('Failed to open database using the Web SQL Database API.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!db) {
|
||||
log_error(Drupal.t('Could not open a client-side database. Cobalt requires a browser that implements the Web SQL Database API.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var nullDataHandler = function(transaction, results) { };
|
||||
|
||||
var current_state = function() {
|
||||
if (typeof(Drupal.settings.cobalt) != 'undefined' &&
|
||||
typeof(Drupal.settings.cobalt.state) != 'undefined') {
|
||||
return Drupal.settings.cobalt.state;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize Cobalt
|
||||
var cobalt = {
|
||||
'dbErrorHandler': function(transaction, error)
|
||||
{
|
||||
$(document).trigger('cobalt-db-error');
|
||||
if (window.console) {
|
||||
console.error(error.message+' (Code: '+error.code+')');
|
||||
}
|
||||
return false;
|
||||
},
|
||||
'registerPlugin': function(name, plugin) {
|
||||
plugin_names.push(name);
|
||||
plugins[name] = plugin;
|
||||
|
||||
if(typeof(plugin['catalogs'])!='undefined') {
|
||||
for(var c_name in plugin.catalogs) {
|
||||
catalogs[c_name] = plugin.catalogs[c_name];
|
||||
}
|
||||
}
|
||||
|
||||
if(typeof(plugin['handlers'])!='undefined') {
|
||||
var h_len = plugin.handlers.length;
|
||||
for(var i=0; i<h_len; i++) {
|
||||
register_handler(plugin.handlers[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
'catalogUpdated': function(catalog, updated) {
|
||||
if (typeof(updated)=='undefined') {
|
||||
updated = new Date().getTime();
|
||||
}
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("UPDATE catalogs SET updated=?, state=? WHERE name = ?;", [ updated, Drupal.settings.cobalt.state, catalog ], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'emptyCatalog': function(name) {
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("DELETE FROM entries WHERE catalog=?;", [ name ], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'addKeyBinding': function(binding, catalog, id, handler, active, state) {
|
||||
if (typeof(state)=='undefined') {
|
||||
state = current_state();
|
||||
}
|
||||
if (typeof(active)=='undefined') {
|
||||
active = 1;
|
||||
}
|
||||
bind_key(binding, catalog, id, handler);
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("INSERT OR REPLACE INTO key_bindings(binding, catalog, id, handler, active, state) VALUES(?,?,?,?,?,?);", [ binding, catalog, id, handler, active, state ], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'loadEntry': function(catalog, id, callback) {
|
||||
var state = current_state();
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT * FROM entries WHERE catalog=? AND id=? AND state=?;", [ catalog, id, state ], function(transaction, results) {
|
||||
var item = null;
|
||||
if (results.rows.length) {
|
||||
item = results.rows.item(0);
|
||||
item.information = JSON.parse(item.data);
|
||||
}
|
||||
callback(item);
|
||||
},cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'deleteEntry': function(catalog, id) {
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("DELETE FROM entries WHERE catalog=? AND id=?;", [ catalog, id ], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'addTemporaryEntry': function(id, name, information, classname) {
|
||||
cobalt.addEntry({id:id, name:name, information:information, catalog:'*temporary*', classname:classname, active:1, state:current_state()});
|
||||
},
|
||||
'addEntry': function(data) {
|
||||
if (typeof(data.state)=='undefined') {
|
||||
data.state = current_state();
|
||||
}
|
||||
if (typeof(data.active)=='undefined') {
|
||||
data.active = 1;
|
||||
}
|
||||
if (typeof(data.extra)=='undefined') {
|
||||
data.extra = '';
|
||||
}
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("INSERT OR REPLACE INTO entries(id, name, extra, data, catalog, data_class, state, active) VALUES(?,?,?,?,?,?,?,?);", [data['id'], data['name'], data.extra, JSON.stringify(data.information), data.catalog, data.classname, data.state, data.active], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
},
|
||||
'actionCandidates': function(item, callback) {
|
||||
action_candidates(item, callback);
|
||||
},
|
||||
'showHtml': function(html) {
|
||||
if (typeof(html) == 'string') {
|
||||
cobalt_output.html(html);
|
||||
}
|
||||
else {
|
||||
cobalt_output.empty().append(html);
|
||||
}
|
||||
|
||||
if (!cobalt_out_visible) {
|
||||
toggle_output();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof(Drupal.settings.cobalt) != 'undefined' && typeof(Drupal.settings.cobalt.update) != 'undefined') {
|
||||
cobalt.updateVersion = function(transaction, name, version) {
|
||||
transaction.executeSql('UPDATE versions SET version=? WHERE name=?', [version, name], nullDataHandler,cobalt.dbErrorHandler);
|
||||
};
|
||||
$(document).trigger('cobalt-update', [cobalt, db, Drupal.settings.cobalt.update]);
|
||||
return;
|
||||
}
|
||||
|
||||
var register_handler_use = function(handler, item, transaction) {
|
||||
transaction.executeSql("INSERT OR IGNORE INTO handler_usage_data(catalog, id, handler, weight) VALUES(?,?,?,?)",
|
||||
[item.catalog, item.id, handler.id, 0], nullDataHandler, cobalt.dbErrorHandler);
|
||||
transaction.executeSql("UPDATE handler_usage_data SET weight=weight+1 WHERE catalog=? AND id=? AND handler=?",
|
||||
[item.catalog, item.id, handler.id], nullDataHandler, cobalt.dbErrorHandler);
|
||||
if (item.id) {
|
||||
handler.weight++;
|
||||
register_handler_use(handler, {id:0, catalog: ''}, transaction);
|
||||
}
|
||||
};
|
||||
|
||||
var register_use = function(text, item, handler) {
|
||||
db.transaction(function (transaction) {
|
||||
register_handler_use(handler, item, transaction);
|
||||
transaction.executeSql("UPDATE usage_data SET last=null WHERE last = 1", [], nullDataHandler, cobalt.dbErrorHandler);
|
||||
if (item.weight == null) {
|
||||
// IGNORE in the rare event a handler that don't refresh the page
|
||||
// (e.g "show") is used multiple times and the weight initially was null.
|
||||
transaction.executeSql("INSERT OR IGNORE INTO usage_data(catalog, id, weight, abbreviation, last) VALUES(?,?,?,?,?)",
|
||||
[item.catalog, item.id, 1, text, 1], nullDataHandler,cobalt.dbErrorHandler);
|
||||
}
|
||||
else {
|
||||
transaction.executeSql("UPDATE usage_data SET weight=weight+1, abbreviation=?, last=1 WHERE catalog=? AND id=?",
|
||||
[text, item.catalog, item.id], nullDataHandler,cobalt.dbErrorHandler);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var register_handler = function(handler) {
|
||||
if (typeof(handler['data_class'])=='undefined') {
|
||||
handler['data_class'] = null;
|
||||
}
|
||||
|
||||
handler.weight = 0;
|
||||
handler.context_weight = 0;
|
||||
|
||||
// Get the weight of the handler
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT weight FROM handler_usage_data WHERE catalog='' AND handler=?",
|
||||
[handler.id], function(transaction, results) {
|
||||
if (results.rows.length) {
|
||||
handler.weight = results.rows.item(0).weight;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (!handler['data_class']) {
|
||||
global_handlers.push(handler);
|
||||
}
|
||||
else {
|
||||
if (!handlers[handler.data_class]) {
|
||||
handlers[handler.data_class] = [];
|
||||
}
|
||||
handlers[handler.data_class].push(handler);
|
||||
}
|
||||
};
|
||||
|
||||
$(document).trigger('cobalt-load', cobalt);
|
||||
|
||||
cobalt.registerPlugin('cobalt', {
|
||||
'version': 1,
|
||||
'handlers': [
|
||||
{
|
||||
'id': 'cobalt_show',
|
||||
'name': Drupal.t('Show'),
|
||||
'handler': function(text, item) {
|
||||
cobalt.showHtml('<h2>' + item.name + '</h2>' +
|
||||
Drupal.t('text') + ': <i>' + text + '</i><br/>' +
|
||||
Drupal.t('id') + ': ' + item.id + '<br/>' +
|
||||
Drupal.t('catalog') + ': ' + item.catalog + '<br/>' +
|
||||
Drupal.t('class') + ': ' + item.data_class + '<br/>' +
|
||||
Drupal.t('data') + ': ' + item.data + '<br/>' +
|
||||
Drupal.t('weight') + ': ' + item.weight);
|
||||
}
|
||||
},
|
||||
{
|
||||
'id': 'cobalt_abbrev',
|
||||
'name': Drupal.t('Assign shortcut'),
|
||||
'handler': function(text, item) {
|
||||
cobalt.actionCandidates(item, function(cand) {
|
||||
var out = $('<div class="shortcut-add"><h2>' + item.name + '</h2>' +
|
||||
Drupal.t('The keys !input should trigger the action:', {'!input': '<input class="key-combo" type="text" value="Ctrl+"/>'}) +
|
||||
'<br/> <select class="action-select"></select>' +
|
||||
'<p><button class="ok">' + Drupal.t('Ok') + '</button></p></div>');
|
||||
var actions = $(out).find('.action-select');
|
||||
var key_combo = $(out).find('.key-combo').css('width',50);
|
||||
var cand_count = cand.length;
|
||||
for(var i=0; i<cand_count; i++) {
|
||||
actions.append('<option value="' + cand[i].id + '">' + cand[i].name + '</option>');
|
||||
}
|
||||
|
||||
$(out).find('button.ok').bind('click',function(){
|
||||
toggle_output('hide');
|
||||
cobalt.addKeyBinding(key_combo.val(), item.catalog, item.id, actions.val());
|
||||
});
|
||||
|
||||
cobalt.showHtml(out);
|
||||
key_combo.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS versions(' +
|
||||
'name TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0, ' +
|
||||
'CONSTRAINT pk_versions PRIMARY KEY(name));', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS entries(' +
|
||||
'catalog TEXT NOT NULL, id TEXT NOT NULL, name TEXT NOT NULL, extra TEXT DEFAULT "", data TEXT NOT NULL DEFAULT "", data_class TEXT NOT NULL, ' +
|
||||
'state INTEGER NOT NULL DEFAULT 0, active INTEGER NOT NULL DEFAULT 1, ' +
|
||||
'CONSTRAINT pk_entries PRIMARY KEY(catalog, id));', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('DELETE FROM entries WHERE catalog=?', ['*temporary*'], nullDataHandler, cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS key_bindings(' +
|
||||
'binding TEXT NOT NULL, catalog TEXT NOT NULL, id TEXT NOT NULL, handler TEXT NOT NULL, ' +
|
||||
'state INTEGER NOT NULL DEFAULT 0, active INTEGER NOT NULL DEFAULT 1, ' +
|
||||
'CONSTRAINT pk_bindings PRIMARY KEY(binding, state));', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS usage_data(catalog TEXT NOT NULL, id TEXT NOT NULL, ' +
|
||||
'weight INTEGER NOT NULL DEFAULT 0, abbreviation TEXT NOT NULL DEFAULT "", last INTEGER, ' +
|
||||
'CONSTRAINT pk_usage_data PRIMARY KEY(catalog, id));', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS handler_usage_data(catalog TEXT NOT NULL, id TEXT NOT NULL, ' +
|
||||
'handler TEXT NOT NULL, weight INTEGER NOT NULL DEFAULT 0,' +
|
||||
'CONSTRAINT pk_handler_usage_data PRIMARY KEY(catalog, id, handler));', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_entries_catalog ON entries(catalog);', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_entries_abbreviation ON usage_data(abbreviation);', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_entries_active ON entries(active DESC);', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_entries_weight ON usage_data(weight DESC);', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
transaction.executeSql('CREATE TABLE IF NOT EXISTS catalogs(' +
|
||||
'name TEXT NOT NULL PRIMARY KEY, updated INTEGER NOT NULL DEFAULT 0, state INTEGER NOT NULL DEFAULT 0, active INTEGER NOT NULL DEFAULT 1, uninstall INTEGER NOT NULL DEFAULT 0);', [], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
|
||||
var cobalt_output = $('<div id="cobalt-out"></div>').appendTo('body').hide();
|
||||
|
||||
var bind_key = function (binding, catalog, id, handler) {
|
||||
$(document).bind('keydown', binding, function(){
|
||||
cobalt.loadEntry(catalog, id, function(item) {
|
||||
if (item) {
|
||||
cobalt.actionCandidates(item, function(cand){
|
||||
var cand_count = cand.length;
|
||||
for(var i=0; i<cand_count; i++) {
|
||||
if (cand[i].id == handler) {
|
||||
cand[i].handler(item.name, item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var toggle_output = function(arg) {
|
||||
if (cobalt_out_visible) {
|
||||
cobalt_output.hide();
|
||||
cobalt_out_visible = false;
|
||||
}
|
||||
else if (arg!='hide') {
|
||||
cobalt_output.show();
|
||||
cobalt_out_visible = true;
|
||||
}
|
||||
};
|
||||
|
||||
var keypress_reaction = function() {
|
||||
if(cobalt_input.val()==current_text) {
|
||||
return;
|
||||
}
|
||||
current_text = cobalt_input.val();
|
||||
|
||||
if($.trim(current_text)!='') {
|
||||
lookup();
|
||||
}
|
||||
};
|
||||
|
||||
var action_keypress_reaction = function() {
|
||||
if(cobalt_h_input.val()==current_action_text) {
|
||||
return;
|
||||
}
|
||||
current_action_text = cobalt_h_input.val();
|
||||
|
||||
action_candidates(item, function(candidates) {
|
||||
actions = candidates;
|
||||
set_handler(0, true);
|
||||
});
|
||||
};
|
||||
|
||||
var clear_ac = function() {
|
||||
match_idx = 0;
|
||||
matches = null;
|
||||
item = 0;
|
||||
$('#cobalt .inner').attr('class','inner');
|
||||
$('#cobalt .inner label').hide();
|
||||
cobalt_ac.hide().empty();
|
||||
cobalt_paging.hide().empty();
|
||||
};
|
||||
|
||||
var lookup = function(preserve_offset) {
|
||||
if (!preserve_offset) {
|
||||
match_offset = 0;
|
||||
}
|
||||
var like_expr = '%' + current_text + '%';
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT e.*, u.weight FROM entries AS e " +
|
||||
"LEFT OUTER JOIN usage_data AS u ON (e.catalog=u.catalog AND e.id=u.id) " +
|
||||
"WHERE e.active=1 AND (u.abbreviation = ? OR e.name LIKE ? OR e.extra LIKE ?) " +
|
||||
"ORDER BY nullif(?,u.abbreviation), nullif(?,e.name), u.weight DESC LIMIT ?,?;", [
|
||||
current_text, like_expr, like_expr, current_text, current_text, match_offset, match_page_size ], lookup_finished,cobalt.dbErrorHandler);
|
||||
});
|
||||
};
|
||||
|
||||
var lookup_finished = function(transaction, results) {
|
||||
if (results.rows.length) {
|
||||
match_idx = 0;
|
||||
$('#cobalt .left label').hide();
|
||||
cobalt_ac.empty().hide();
|
||||
for (var i=0; i<results.rows.length; i++) {
|
||||
var item = results.rows.item(i);
|
||||
item.information = JSON.parse(item.data);
|
||||
if (typeof(catalogs[item.catalog]) !='undefined' && typeof(catalogs[item.catalog].item_formatter) == 'function'){
|
||||
var title = catalogs[item.catalog].item_formatter(item);
|
||||
}
|
||||
else {
|
||||
var title = item.name;
|
||||
}
|
||||
$('<li class="ac-opt-' + i + '"></li>').html(title).appendTo(cobalt_ac);
|
||||
}
|
||||
matches = results.rows;
|
||||
|
||||
//Only count for paging when we're not already offsetting the result and
|
||||
//have a match count equal to the page size
|
||||
if (match_offset) {
|
||||
update_pager(match_count);
|
||||
}
|
||||
else if (matches.length==match_page_size) {
|
||||
var like_expr = '%' + current_text + '%';
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT COUNT(*) as match_count FROM entries AS e " +
|
||||
"LEFT OUTER JOIN usage_data AS u ON (e.catalog=u.catalog AND e.id=u.id) " +
|
||||
"WHERE e.active=1 AND (u.abbreviation = ? OR e.name LIKE ? OR e.extra LIKE ?);", [
|
||||
current_text, like_expr, like_expr], function(transaction, results) {
|
||||
if (results.rows.length) {
|
||||
match_count = results.rows.item(0).match_count;
|
||||
update_pager(match_count);
|
||||
}
|
||||
},cobalt.dbErrorHandler);
|
||||
});
|
||||
}
|
||||
else {
|
||||
update_pager(matches.length);
|
||||
}
|
||||
cobalt_ac.show();
|
||||
}
|
||||
|
||||
ac_select(0);
|
||||
};
|
||||
|
||||
var update_pager = function(new_match_count) {
|
||||
match_count = new_match_count;
|
||||
cobalt_paging.hide().empty();
|
||||
|
||||
var page_count = Math.min(Math.ceil(match_count/match_page_size),25);
|
||||
for (var i=0; i<page_count; i++ ) {
|
||||
var p = $('<li> </li>').appendTo(cobalt_paging);
|
||||
if (i==match_offset/match_page_size) {
|
||||
p.attr('class','current');
|
||||
}
|
||||
}
|
||||
|
||||
cobalt_paging.show();
|
||||
};
|
||||
|
||||
var ac_page = function(new_offset) {
|
||||
if (new_offset>=match_count || new_offset<0) {
|
||||
return;
|
||||
}
|
||||
match_offset = new_offset;
|
||||
lookup(true);
|
||||
};
|
||||
|
||||
var ac_select = function(idx) {
|
||||
if (idx<0 || idx >= matches.length) {
|
||||
item = null;
|
||||
return;
|
||||
}
|
||||
|
||||
item = matches.item(idx);
|
||||
item.information = JSON.parse(item.data);
|
||||
var old_item = matches.item(match_idx);
|
||||
|
||||
$('#cobalt .ac-opt-' + match_idx).removeClass('active');
|
||||
match_idx = idx;
|
||||
// Generate path specific classes that can be used for icons.
|
||||
// Matches the classes used in the Rubik admin theme.
|
||||
var classes = '';
|
||||
if (item.data_class === 'url_data') {
|
||||
var path = JSON.parse(item.data);
|
||||
if (typeof(path) == 'object') {
|
||||
path = path.path;
|
||||
}
|
||||
classes = [];
|
||||
var args = path.split('/');
|
||||
while(args.length) {
|
||||
classes[args.length - 1] = 'path-' + args.join('-');
|
||||
args.pop();
|
||||
}
|
||||
classes = classes.join(' ');
|
||||
};
|
||||
$('#cobalt .left .inner').attr('class','inner cobalt-item-' + item.data_class + ' ' + classes);
|
||||
$('#cobalt .left label').text(item.name).show();
|
||||
$('#cobalt .ac-opt-' + match_idx).addClass('active');
|
||||
|
||||
action_candidates(item, function(candidates){
|
||||
actions = candidates;
|
||||
set_handler(0, true);
|
||||
});
|
||||
};
|
||||
|
||||
var action_candidates = function(item, callback) {
|
||||
var candidates = [], gcount, i, j, cls_count, rc, cc, item,
|
||||
add_applicable = function(handler) {
|
||||
// Check if the handler matches the current_action_text (from closure),
|
||||
// or run the handlers own applicability check if it has one.
|
||||
if ((current_action_text=='' || handler['name'].toLowerCase().indexOf(current_action_text)!=-1) &&
|
||||
(!handler['applicable'] || handler.applicable(current_text, item))) {
|
||||
candidates.push(handler);
|
||||
}
|
||||
};
|
||||
|
||||
// Add handlers for the items data class that match the current_action_text
|
||||
if (typeof(handlers[item.data_class])!='undefined') {
|
||||
cls_count = handlers[item.data_class].length;
|
||||
for (i=0; i<cls_count; i++) {
|
||||
add_applicable(handlers[item.data_class][i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add global handlers that match the current_action_text
|
||||
g_count = global_handlers.length;
|
||||
for (i=0; i<g_count; i++) {
|
||||
add_applicable(global_handlers[i]);
|
||||
}
|
||||
|
||||
// Load the usage data for the candidates so that we may sort them
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT handler, weight FROM handler_usage_data WHERE catalog=? AND id=?",
|
||||
[item.catalog, item.id], function(transaction, results) {
|
||||
rc = results.rows.length;
|
||||
cc = candidates.length;
|
||||
for (j=0; j<cc; j++) {
|
||||
candidates[j].context_weight = 0;
|
||||
for (i=0; i<rc; i++) {
|
||||
r = results.rows.item(i);
|
||||
if (r.handler == candidates[j].id) {
|
||||
candidates[j].context_weight = r.weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort the candidates after context_weight and weight
|
||||
candidates.sort(function(a, b){
|
||||
var cwd = b.context_weight-a.context_weight;
|
||||
if (cwd==0) {
|
||||
return b.weight-a.weight;
|
||||
}
|
||||
return cwd;
|
||||
});
|
||||
callback(candidates);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var handler_class = function() {
|
||||
if (handler) {
|
||||
return handler['class'] ? handler['class'] : 'default';
|
||||
}
|
||||
};
|
||||
|
||||
var set_handler = function(idx, update) {
|
||||
if (update) {
|
||||
cobalt_actions.empty();
|
||||
var a_count = actions.length;
|
||||
for(var i=0; i<a_count; i++) {
|
||||
$('<li class="action-opt-' + i + '"></l i>').html(actions[i]['name']).appendTo(cobalt_actions);
|
||||
}
|
||||
}
|
||||
|
||||
if (idx<0 || idx >= actions.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#cobalt .action-opt-' + handler_idx).removeClass('active');
|
||||
$('#cobalt .action-opt-' + idx).addClass('active');
|
||||
handler_idx = idx;
|
||||
var new_handler = actions[idx];
|
||||
|
||||
handler = new_handler;
|
||||
if (handler) {
|
||||
var newClass = handler_class();
|
||||
$('#cobalt .right .inner').attr('class','inner cobalt-action-' + newClass);
|
||||
$('#cobalt .right label').text(handler.name).show();
|
||||
}
|
||||
};
|
||||
|
||||
var run_handler = function() {
|
||||
if (item && typeof(handler['handler']) == 'function') {
|
||||
var text = $.trim(cobalt_input.val());
|
||||
register_use(text, item, handler);
|
||||
try {
|
||||
handler.handler(text, item);
|
||||
}
|
||||
catch(err) {
|
||||
log_error(Drupal.t("The handler threw a exception"), err);
|
||||
}
|
||||
}
|
||||
hide();
|
||||
};
|
||||
|
||||
var get_last_entry = function() {
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT e.*, u.weight FROM entries AS e INNER JOIN usage_data AS u ON u.catalog = e.catalog AND u.id = e.id WHERE last = 1;", [], function(transaction, results) {
|
||||
lookup_finished(transaction, results);
|
||||
}, cobalt.dbErrorHandler);
|
||||
});
|
||||
};
|
||||
|
||||
var toggle = function(arg) {
|
||||
if (cobalt_visible) {
|
||||
cb.hide();
|
||||
cobalt_visible = false;
|
||||
}
|
||||
else if (arg!='hide') {
|
||||
toggle_output('hide');
|
||||
cobalt_input.val($.trim(cobalt_input.val()));
|
||||
cb.show();
|
||||
cobalt_visible = true;
|
||||
setTimeout(function(){ cobalt_input.focus(); cobalt_input.select(); }, 100);
|
||||
}
|
||||
};
|
||||
|
||||
var hide = function() {
|
||||
toggle('hide');
|
||||
};
|
||||
|
||||
var init = function() {
|
||||
$(document).trigger('cobalt-init', cobalt);
|
||||
|
||||
// Load key bindings
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql('SELECT binding, catalog, id, handler FROM key_bindings', [], function(transaction, results) {
|
||||
for (var i=0; i<results.rows.length; i++) {
|
||||
var b = results.rows.item(i);
|
||||
bind_key(b.binding, b.catalog, b.id, b.handler);
|
||||
}
|
||||
},cobalt.dbErrorHandler);
|
||||
});
|
||||
|
||||
get_last_entry();
|
||||
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("SELECT * FROM catalogs ORDER BY updated;", [ ], function(transaction, results) {
|
||||
var info = {};
|
||||
var state = current_state();
|
||||
|
||||
// Queue catalogs for update
|
||||
for (var i = 0; i < results.rows.length; i++) {
|
||||
var item = results.rows.item(i);
|
||||
info[item.name] = item;
|
||||
update_queue.push({'name': item.name, 'updated': (item.state==state?item.updated:0) });
|
||||
}
|
||||
|
||||
// Install new catalogs and queue them for updates
|
||||
for (var key in catalogs) {
|
||||
(function(key) {
|
||||
if (!info[key]) {
|
||||
if (catalogs[key]['install']) {
|
||||
catalogs[key].install();
|
||||
}
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql("INSERT INTO catalogs(name) VALUES(?)", [key], nullDataHandler,cobalt.dbErrorHandler);
|
||||
});
|
||||
update_queue.unshift({'name': key, 'updated': 0 });
|
||||
}
|
||||
})(key);
|
||||
}
|
||||
|
||||
// Update loop
|
||||
var update_counter = 0;
|
||||
var update_loop = function() {
|
||||
setTimeout(function() {
|
||||
if(update_queue.length) {
|
||||
var inf = update_queue.shift();
|
||||
var now = new Date().getTime();
|
||||
var catalog = catalogs[inf.name];
|
||||
|
||||
if (typeof(catalog['update_rate'])!='undefined' && inf.updated + catalog.update_rate > now) {
|
||||
update_queue.push(inf);
|
||||
update_loop();
|
||||
}
|
||||
else {
|
||||
if (catalog['update']) {
|
||||
catalog.update(inf.updated, function(enqueue){
|
||||
var now = new Date().getTime();
|
||||
cobalt.catalogUpdated(inf.name);
|
||||
|
||||
if (enqueue) {
|
||||
update_queue.push({'name': inf.name, 'updated': now });
|
||||
}
|
||||
|
||||
update_counter++;
|
||||
update_loop();
|
||||
});
|
||||
}
|
||||
else {
|
||||
update_loop();
|
||||
}
|
||||
}
|
||||
}
|
||||
},update_counter?1000:100);
|
||||
};
|
||||
update_loop();
|
||||
},cobalt.dbErrorHandler);
|
||||
});
|
||||
|
||||
$(document).trigger('cobalt-post-init', cobalt);
|
||||
|
||||
cb.bind('click', function(e){ return false; });
|
||||
$([cobalt_input[0], cobalt_h_input[0]]).bind('keydown', 'esc', function(){ toggle('hide'); toggle_output('hide'); return false; }).
|
||||
bind('keydown', 'return', function(){ run_handler(); return false; });
|
||||
cobalt_input.bind('keydown', 'up', function(){ ac_select(match_idx-1); return false; }).
|
||||
bind('keydown', 'down', function(){ ac_select(match_idx+1); return false; }).
|
||||
bind('keydown', 'Alt+left', function(){ ac_page(match_offset-match_page_size); return false; }).
|
||||
bind('keydown', 'Alt+right', function(){ ac_page(match_offset+match_page_size); return false; }).
|
||||
bind('keyup', function(){ keypress_reaction(); return false; }).
|
||||
bind('focus', function() {
|
||||
if (matches && matches.length) {
|
||||
cobalt_ac.show();
|
||||
cobalt_paging.show();
|
||||
}
|
||||
cobalt_actions.hide();
|
||||
});
|
||||
cobalt_h_input.bind('keydown', 'up', function(){ set_handler(handler_idx-1); return false; }).
|
||||
bind('keydown', 'down', function(){ set_handler(handler_idx+1); return false; }).
|
||||
bind('keyup', function(){ action_keypress_reaction(); return false; }).
|
||||
bind('focus', function(){ cobalt_paging.hide(); cobalt_ac.hide(); cobalt_actions.show(); });
|
||||
cobalt_output.bind('click', function(e){ return false; });
|
||||
$('.cell.left', cb).bind('click', function(){ cobalt_input[0].focus(); });
|
||||
$('.cell.right', cb).bind('click', function(){ cobalt_h_input[0].focus(); });
|
||||
$(document).bind('click', function(){ toggle('hide'); toggle_output('hide'); });
|
||||
|
||||
if (Drupal && Drupal.settings && Drupal.settings.cobalt) {
|
||||
var bindings = Drupal.settings.cobalt.bindings,
|
||||
bind_count = bindings.length, i;
|
||||
for (i=0; i<bind_count; i++) {
|
||||
$(document).bind('keydown', bindings[i], toggle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(document).bind('keydown', 'Alt+space', toggle)
|
||||
.bind('keydown', 'Ctrl+space', toggle);
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize GUI
|
||||
var cb = $('<div id="cobalt">'+
|
||||
'<div class ="cells"><div class="cell left"><div class="inner"><span class="icon"></span><input type="text" id="cobalt-input" /><label></label></div></div>'+
|
||||
'<div class="cell right"><div class="inner"><input type="text" id="cobalt-handler-input" /><label></label></div></div></div>'+
|
||||
'<ol class="cobalt-paging"></ol><ul class="cobalt-autocomplete"></ul><ul class="cobalt-actions"></ul></div>').appendTo('body').hide();
|
||||
var cobalt_input = $('#cobalt-input');
|
||||
var cobalt_h_input = $('#cobalt-handler-input');
|
||||
var cobalt_ac = $('#cobalt .cobalt-autocomplete');
|
||||
var cobalt_actions = $('#cobalt .cobalt-actions');
|
||||
var cobalt_paging = $('#cobalt .cobalt-paging');
|
||||
$('#cobalt .right label').hide();
|
||||
|
||||
// Check if we need to update anything before initializing
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql('SELECT name, version FROM versions', [], function(transaction, results) {
|
||||
var v = {};
|
||||
for (var i=0; i<results.rows.length; i++) {
|
||||
var vi = results.rows.item(i);
|
||||
v[vi.name] = vi.version;
|
||||
}
|
||||
|
||||
db.transaction(function (transaction) {
|
||||
var plugin_count = plugin_names.length;
|
||||
for (var i=0; i<plugin_count; i++) {
|
||||
var n=plugin_names[i];
|
||||
if (typeof(v[n])=='undefined') {
|
||||
transaction.executeSql('INSERT INTO versions(name, version) VALUES(?,?)', [ n, plugins[n].version ], nullDataHandler,cobalt.dbErrorHandler);
|
||||
}
|
||||
else if (v[n]<plugins[n].version) {
|
||||
required_updates.push([n, v[n], plugins[n].version]);
|
||||
}
|
||||
}
|
||||
|
||||
if (required_updates.length) {
|
||||
var update_notice = function () {
|
||||
var update_url = Drupal.settings.basePath + 'cobalt/update';
|
||||
for (var i=0; i<required_updates.length; i++) {
|
||||
var u = required_updates[i];
|
||||
update_url += '/' + u[0] + '/' + u[1] + '/' + u[2];
|
||||
}
|
||||
cobalt.showHtml('<h1>' + Drupal.t('Update required') + '</h1>' +
|
||||
'<p>' + Drupal.t('Cobalt must be updated before it can be used') + '</p>' +
|
||||
'<p><a class="cobalt-update-link" href="' + update_url + '">' + Drupal.t('Click here to update') + '</a></p>');
|
||||
};
|
||||
$(document).bind('click', function(){ toggle_output('hide'); });
|
||||
if (Drupal && Drupal.settings && Drupal.settings.cobalt) {
|
||||
var bindings = Drupal.settings.cobalt.bindings,
|
||||
bind_count = bindings.length, i;
|
||||
for (i=0; i<bind_count; i++) {
|
||||
$(document).bind('keydown', bindings[i], update_notice);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(document).bind('keydown', 'Alt+space', update_notice)
|
||||
.bind('keydown', 'Ctrl+space', update_notice);
|
||||
}
|
||||
}
|
||||
else {
|
||||
init();
|
||||
}
|
||||
});
|
||||
},cobalt.dbErrorHandler);
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
94
sites/all/modules/contrib/admin/cobalt/js/cobalt.menu.js
Normal file
@@ -0,0 +1,94 @@
|
||||
(function($) {
|
||||
$(document).bind('cobalt-load', function(evt, cobalt) {
|
||||
var plugin = {
|
||||
'version': 0,
|
||||
'catalogs': {},
|
||||
'handlers': []
|
||||
};
|
||||
|
||||
plugin['catalogs']['menu'] = {
|
||||
'update': function(last_update, callback) {
|
||||
$.getJSON(Drupal.settings.basePath + 'cobalt/data/menu_json', {}, function (data) {
|
||||
cobalt.emptyCatalog('menu');
|
||||
for (var id in data) {
|
||||
cobalt.addEntry({id:id, name:data[id][1], extra:data[id][0], information: data[id][0], catalog:'menu', classname:'url_data'});
|
||||
}
|
||||
callback(false);
|
||||
});
|
||||
},
|
||||
'install': function() {
|
||||
},
|
||||
'uninstall': function() {
|
||||
},
|
||||
'item_formatter': function(item) {
|
||||
return item.name + ' <small>' + item.information + '</small>';
|
||||
},
|
||||
'update_rate': 60000
|
||||
};
|
||||
|
||||
var uri_from_item = function(item, omitDestination) {
|
||||
var path = item.information;
|
||||
var destination = Drupal.settings.cobalt.path;
|
||||
if (typeof(path) == 'object') {
|
||||
destination = path.destination;
|
||||
path = path.path;
|
||||
}
|
||||
|
||||
if (path=='<front>') {
|
||||
path = '';
|
||||
}
|
||||
|
||||
if (destination && !omitDestination) {
|
||||
path = path + '?destination=' + destination;
|
||||
}
|
||||
|
||||
return Drupal.settings.basePath + path;
|
||||
};
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'menu_goto',
|
||||
'name': Drupal.t('Go to and return'),
|
||||
'data_class': 'url_data',
|
||||
'handler': function(text, item) {
|
||||
window.location.href = uri_from_item(item);
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'menu_goto_stay',
|
||||
'name': Drupal.t('Go to'),
|
||||
'data_class': 'url_data',
|
||||
'handler': function(text, item) {
|
||||
window.location.href = uri_from_item(item, true);
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'menu_open_in_new_window',
|
||||
'name': Drupal.t('Open in new window'),
|
||||
'data_class': 'url_data',
|
||||
'handler': function(text, item) {
|
||||
var form = document.createElement("form");
|
||||
$(form).attr({
|
||||
'method': 'GET',
|
||||
'action': uri_from_item(item),
|
||||
'target': '_blank'
|
||||
}).appendTo('body');
|
||||
|
||||
try {
|
||||
form.submit();
|
||||
}
|
||||
catch(e) {
|
||||
var message = $('<div></div>');
|
||||
message.append('<h1>' + Drupal.t('Could not open window') + '</h1>');
|
||||
message.append('<p>' + Drupal.t('You might be using a popup blocker, which stopped Cobalt from opening a new window.') + '</p>');
|
||||
cobalt.showHtml(message);
|
||||
}
|
||||
|
||||
$(form).remove();
|
||||
}
|
||||
});
|
||||
|
||||
cobalt.registerPlugin('cobalt_menu', plugin);
|
||||
});
|
||||
})(jQuery);
|
124
sites/all/modules/contrib/admin/cobalt/js/cobalt.nodes.js
Normal file
@@ -0,0 +1,124 @@
|
||||
(function($) {
|
||||
$(document).bind('cobalt-load', function(evt, cobalt) {
|
||||
var plugin = {
|
||||
'version': 0,
|
||||
'catalogs': {},
|
||||
'handlers': []
|
||||
};
|
||||
|
||||
// Utility function for fetching data from the server
|
||||
// Used by the updater and the current node check
|
||||
var get_node_data = function (op, value, callback) {
|
||||
$.getJSON(Drupal.settings.basePath + 'cobalt/data/nodes_' + op + '/' + value, {}, function (data) {
|
||||
|
||||
if (typeof(data.nodes)!='undefined') {
|
||||
var num_nodes = data.nodes.length;
|
||||
for (var i=0; i<num_nodes; i++) {
|
||||
cobalt.addEntry({id:data.nodes[i][0], name:data.nodes[i][1], information:{'perm': data.nodes[i][2]}, catalog:'nodes', classname:'node'});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(data.deleted)!='undefined') {
|
||||
var num_deletes = data.deleted.length;
|
||||
for (var i=0; i<num_deletes; i++) {
|
||||
cobalt.deleteEntry('nodes', data.deleted[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(callback)=='function') {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
plugin['catalogs']['nodes'] = {
|
||||
'update': function(last_update, callback) {
|
||||
get_node_data('update', Math.round((last_update/1000)), function(){ callback(true); });
|
||||
},
|
||||
'install': function() {
|
||||
},
|
||||
'uninstall': function() {
|
||||
},
|
||||
'item_formatter': function(item) {
|
||||
return item.name + ' <small>node/' + item.id + '</small>';
|
||||
},
|
||||
'update_rate': 60000
|
||||
};
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'node_view',
|
||||
'name': Drupal.t('View'),
|
||||
'data_class': 'node',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('r') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'cobalt/alias/node/' + item.id;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'node_edit',
|
||||
'name': Drupal.t('Edit'),
|
||||
'data_class': 'node',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('w') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'node/' + item.id + '/edit?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'node_delete',
|
||||
'name': Drupal.t('Delete'),
|
||||
'data_class': 'node',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('d') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'node/' + item.id + '/delete?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
cobalt.registerPlugin('cobaltnodes', plugin);
|
||||
|
||||
var add_temporary_entries = function(nid, perm) {
|
||||
var rp = 'node/' + nid;
|
||||
var ep = 'node/' + nid + '/edit';
|
||||
var dp = 'node/' + nid + '/delete';
|
||||
|
||||
if (perm.indexOf('r') >= 0 && Drupal.settings.cobalt.path != rp) {
|
||||
cobalt.addTemporaryEntry('node_context_view', Drupal.t('View current node'), rp, 'url_data');
|
||||
}
|
||||
if (perm.indexOf('w') >= 0 && Drupal.settings.cobalt.path != ep) {
|
||||
cobalt.addTemporaryEntry('node_context_edit', Drupal.t('Edit current node'), ep, 'url_data');
|
||||
}
|
||||
if (perm.indexOf('d') >= 0 && Drupal.settings.cobalt.path != dp) {
|
||||
cobalt.addTemporaryEntry('node_context_delete', Drupal.t('Delete current node'), {'path': dp, 'destination': false}, 'url_data');
|
||||
}
|
||||
};
|
||||
|
||||
//Run the current-node-check on init
|
||||
$(document).bind('cobalt-init', function(evt, cobalt) {
|
||||
// Make sure that we have the current node among our entries, this is a easy
|
||||
// way to make sure that we have the nodes the user expects.
|
||||
if (typeof(Drupal.settings.cobalt.nodes_current) != 'undefined') {
|
||||
var nid = Drupal.settings.cobalt.nodes_current;
|
||||
cobalt.loadEntry('nodes', nid, function(item) {
|
||||
// Make sure that context sensitive items are added
|
||||
if (!item) {
|
||||
get_node_data('single', nid, function(data){
|
||||
if (typeof(data['nodes'])!='undefined' && data.nodes.length) {
|
||||
add_temporary_entries(data.nodes[0][0], data.nodes[0][2]);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
add_temporary_entries(item.id, item.information.perm);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
@@ -0,0 +1,23 @@
|
||||
/* Remove this line if you want to try out the updating mechanism
|
||||
//Sample update script that covers the scenario of a plugin that previously
|
||||
//have been updated to v.1 but currently is v.2
|
||||
$(document).bind('cobalt-update', function(evt, cobalt, db, updates) {
|
||||
if (typeof(updates['cobaltnodes'])!='undefined') {
|
||||
var update = updates.cobaltnodes;
|
||||
switch (parseInt(update[0], 10)) {
|
||||
case 0:
|
||||
db.transaction(function (transaction) {
|
||||
//Do some changes needed to upgrade to rev 1
|
||||
console.log('Updating to v.1');
|
||||
cobalt.updateVersion(transaction, 'cobaltnodes', 1);
|
||||
});
|
||||
case 1:
|
||||
db.transaction(function (transaction) {
|
||||
//Do some changes needed to upgrade to rev 2
|
||||
console.log('Updating to v.2');
|
||||
cobalt.updateVersion(transaction, 'cobaltnodes', 2);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
//*/
|
96
sites/all/modules/contrib/admin/cobalt/js/cobalt.taxonomy.js
Normal file
@@ -0,0 +1,96 @@
|
||||
(function($) {
|
||||
$(document).bind('cobalt-load', function(evt, cobalt) {
|
||||
var plugin = {
|
||||
'version': 0,
|
||||
'catalogs': {},
|
||||
'handlers': []
|
||||
};
|
||||
|
||||
plugin['catalogs']['vocabularies'] = {
|
||||
'update': function(last_update, callback) {
|
||||
$.getJSON(Drupal.settings.basePath + 'cobalt/data/taxonomy_json', {}, function (data) {
|
||||
cobalt.emptyCatalog('vocabularies');
|
||||
var access = data.access ? 'w' : '';
|
||||
for (var id in data.vocabularies) {
|
||||
cobalt.addEntry({id:id, name:data.vocabularies[id], information:access, catalog:'vocabularies', classname:'vocabulary'});
|
||||
}
|
||||
cobalt.emptyCatalog('terms');
|
||||
for (var id in data.terms) {
|
||||
cobalt.addEntry({id:id, name:data.terms[id][0], information:{'perm': access, 'vid': data.terms[id][1]}, catalog:'terms', classname:'term'});
|
||||
}
|
||||
callback(false);
|
||||
});
|
||||
},
|
||||
'install': function() {
|
||||
},
|
||||
'uninstall': function() {
|
||||
},
|
||||
'update_rate': 60000
|
||||
};
|
||||
|
||||
// Insert empty catalog, the update function is handled for both catalogs in
|
||||
// the vocabularies catalog.
|
||||
plugin['catalogs']['terms'] = {};
|
||||
|
||||
|
||||
// Register handlers
|
||||
plugin['handlers'].push({
|
||||
'id': 'vocabulary_list',
|
||||
'name': Drupal.t('List terms'),
|
||||
'data_class': 'vocabulary',
|
||||
'applicable': function(text, item) {
|
||||
return item.information == 'w';
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/' + item.id + '/list';
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'vocabulary_edit',
|
||||
'name': Drupal.t('Edit'),
|
||||
'data_class': 'vocabulary',
|
||||
'applicable': function(text, item) {
|
||||
return item.information == 'w';
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/edit/vocabulary/' + item.id + '?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'vocabulary_add',
|
||||
'name': Drupal.t('Add terms'),
|
||||
'data_class': 'vocabulary',
|
||||
'applicable': function(text, item) {
|
||||
return item.information == 'w';
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/' + item.id + '/list/add';
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'term_view',
|
||||
'name': Drupal.t('View'),
|
||||
'data_class': 'term',
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'taxonomy/term/' + item.id;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'term_edit',
|
||||
'name': Drupal.t('Edit'),
|
||||
'data_class': 'term',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm == 'w';
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'taxonomy/term/' + item.id + '/edit?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
cobalt.registerPlugin('cobalttaxonomy', plugin);
|
||||
});
|
||||
})(jQuery);
|
16
sites/all/modules/contrib/admin/cobalt/js/cobalt.update.js
Normal file
@@ -0,0 +1,16 @@
|
||||
(function($) {
|
||||
$(document).bind('cobalt-update', function(evt, cobalt, db, updates) {
|
||||
if (typeof(updates['cobalt'])!='undefined') {
|
||||
var update = updates.cobalt;
|
||||
switch (parseInt(update[0], 10)) {
|
||||
case 0:
|
||||
// Update to version 1.
|
||||
db.transaction(function (transaction) {
|
||||
transaction.executeSql('ALTER TABLE entries ADD COLUMN extra TEXT DEFAULT ""', [], function(){}, cobalt.dbErrorHandler);
|
||||
transaction.executeSql('ALTER TABLE usage_data ADD COLUMN last INTEGER', [], function(){}, cobalt.dbErrorHandler);
|
||||
cobalt.updateVersion(transaction, 'cobalt', 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
65
sites/all/modules/contrib/admin/cobalt/js/cobalt.users.js
Normal file
@@ -0,0 +1,65 @@
|
||||
(function($) {
|
||||
$(document).bind('cobalt-load', function(evt, cobalt) {
|
||||
var plugin = {
|
||||
'version': 0,
|
||||
'catalogs': {},
|
||||
'handlers': []
|
||||
};
|
||||
|
||||
plugin['catalogs']['users'] = {
|
||||
'update': function(last_update, callback) {
|
||||
$.getJSON(Drupal.settings.basePath + 'cobalt/data/users_json/' + Math.round((last_update/1000)), {}, function (data) {
|
||||
var num_nodes = data.length;
|
||||
for (var i=0; i<num_nodes; i++) {
|
||||
cobalt.addEntry({id:data[i][0], name:data[i][1], information:{'perm': data[i][2]}, catalog:'users', classname:'user'});
|
||||
}
|
||||
callback(true);
|
||||
});
|
||||
},
|
||||
'install': function() {
|
||||
},
|
||||
'uninstall': function() {
|
||||
},
|
||||
'update_rate': 300000
|
||||
};
|
||||
|
||||
// Add handlers
|
||||
plugin['handlers'].push({
|
||||
'id': 'user_view',
|
||||
'name': Drupal.t('View'),
|
||||
'data_class': 'user',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('r') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'user/' + item.id;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'user_edit',
|
||||
'name': Drupal.t('Edit'),
|
||||
'data_class': 'user',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('w') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'user/' + item.id + '/edit?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
plugin['handlers'].push({
|
||||
'id': 'user_delete',
|
||||
'name': Drupal.t('Cancel account'),
|
||||
'data_class': 'user',
|
||||
'applicable': function(text, item) {
|
||||
return item.information.perm.indexOf('d') >= 0;
|
||||
},
|
||||
'handler': function(text, item) {
|
||||
window.location.href = Drupal.settings.basePath + 'user/' + item.id + '/cancel?destination=' + Drupal.settings.cobalt.path;
|
||||
}
|
||||
});
|
||||
|
||||
cobalt.registerPlugin('cobaltusers', plugin);
|
||||
});
|
||||
})(jQuery);
|
12
sites/all/modules/contrib/admin/cobalt/js/jquery.hotkeys.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* jQuery Hotkeys Plugin
|
||||
* Copyright 2010, John Resig
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Based upon the plugin by Tzury Bar Yochay:
|
||||
* http://github.com/tzuryby/hotkeys
|
||||
*
|
||||
* Original idea by:
|
||||
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||
*/
|
||||
(function(b){b.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};function a(d){if(typeof d.data!=="string"){return;}var c=d.handler,e=d.data.toLowerCase().split(" ");d.handler=function(n){if(this!==n.target&&(/textarea|select/i.test(n.target.nodeName)||n.target.type==="text")){return;}var h=n.type!=="keypress"&&b.hotkeys.specialKeys[n.which],o=String.fromCharCode(n.which).toLowerCase(),k,m="",g={};if(n.altKey&&h!=="alt"){m+="alt+";}if(n.ctrlKey&&h!=="ctrl"){m+="ctrl+";}if(n.metaKey&&!n.ctrlKey&&h!=="meta"){m+="meta+";}if(n.shiftKey&&h!=="shift"){m+="shift+";}if(h){g[m+h]=true;}else{g[m+o]=true;g[m+b.hotkeys.shiftNums[o]]=true;if(m==="shift+"){g[b.hotkeys.shiftNums[o]]=true;}}for(var j=0,f=e.length;j<f;j++){if(g[e[j]]){return c.apply(this,arguments);}}};}b.each(["keydown","keyup","keypress"],function(){b.event.special[this]={add:a};});})(jQuery);
|