mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 07:36:32 +02:00
Admin JS Helper - initial import
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
* Image Administration Area
|
* Image Administration Area
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $
|
||||||
* $Revision: 1.12 $
|
* $Revision: 1.13 $
|
||||||
* $Date: 2008-12-10 20:55:21 $
|
* $Date: 2008-12-10 23:46:47 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -653,67 +653,13 @@ if(!e_AJAX_REQUEST) require_once("footer.php");
|
|||||||
function headerjs()
|
function headerjs()
|
||||||
{
|
{
|
||||||
require_once(e_HANDLER.'js_helper.php');
|
require_once(e_HANDLER.'js_helper.php');
|
||||||
|
//FIXME - how exactly to call JS lan?
|
||||||
$ret = "
|
$ret = "
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
//add required core lan
|
//add required core lan
|
||||||
(".e_jshelper::toString(IMALAN_67).").addModLan('core', 'delete_confirm');
|
(".e_jshelper::toString(IMALAN_67).").addModLan('core', 'delete_confirm');
|
||||||
|
|
||||||
/**
|
|
||||||
* Admin Image JS Handler
|
|
||||||
*/
|
|
||||||
var eCoreImage = {
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this.tCheckEventHandler = this.tCheckHandler.bindAsEventListener(this);
|
|
||||||
this.allCheckEventHandler = this.allCheckHandler.bindAsEventListener(this);
|
|
||||||
this.allUnCheckEventHandler = this.allUnCheckHandler.bindAsEventListener(this);
|
|
||||||
|
|
||||||
\$\$('.options').invoke('observe', 'click', this.tCheckEventHandler);
|
|
||||||
\$\$('button.action[name=check_all]').invoke('observe', 'click', this.allCheckEventHandler);
|
|
||||||
\$\$('button.action[name=uncheck_all]').invoke('observe', 'click', this.allUnCheckHandler);
|
|
||||||
\$\$('button.delete').invoke('observe', 'click', function(e){ if( !e107Helper.confirm(e107.getModLan('delete_confirm')) ) e.stop(); });
|
|
||||||
},
|
|
||||||
|
|
||||||
tCheckHandler: function(event) {
|
|
||||||
//do nothing if checkbox or link is clicked
|
|
||||||
var tmp = event.element();
|
|
||||||
if(tmp.nodeName.toLowerCase() == 'input' || tmp.nodeName.toLowerCase() == 'a') return;
|
|
||||||
//stop event
|
|
||||||
event.stop();
|
|
||||||
|
|
||||||
//checkbox container element
|
|
||||||
var element = event.findElement('.options'), check = null;
|
|
||||||
if(element) {
|
|
||||||
check = element.select('input.checkbox'); //search for checkbox
|
|
||||||
}
|
|
||||||
//toggle checked property
|
|
||||||
if(check && check[0] && !(\$(check[0]).disabled)) {
|
|
||||||
\$(check[0]).checked = !(\$(check[0]).checked);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
allCheckHandler: function(event) {
|
|
||||||
event.stop();
|
|
||||||
var form = event.element().up('form');
|
|
||||||
if(form) {
|
|
||||||
form.toggleChecked(true, 'name^=multiaction');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
allUnCheckHandler: function(event) {
|
|
||||||
event.stop();
|
|
||||||
var form = event.element().up('form');
|
|
||||||
if(form) {
|
|
||||||
form.toggleChecked(false, 'name^=multiaction');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Observe e107:loaded event
|
|
||||||
*/
|
|
||||||
e107.runOnLoad(eCoreImage.init.bind(eCoreImage), document, true);
|
|
||||||
</script>
|
</script>
|
||||||
|
<script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script>
|
||||||
";
|
";
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
131
e107_files/jslib/core/admin.js
Normal file
131
e107_files/jslib/core/admin.js
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001-2008 e107 Developers (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://gnu.org).
|
||||||
|
*
|
||||||
|
* e107 Admin Helper
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_files/jslib/core/admin.js,v $
|
||||||
|
* $Revision: 1.1 $
|
||||||
|
* $Date: 2008-12-10 23:46:47 $
|
||||||
|
* $Author: secretr $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
e107Admin = {}
|
||||||
|
e107Admin.Helper = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto Initialize everything
|
||||||
|
*
|
||||||
|
* Use it with e107#runOnLoad
|
||||||
|
* Example: e107.runOnLoad(e107Admin.Helper.init.bind(e107Admin.Helper), document, true);
|
||||||
|
* Do it only ONCE per page!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
init: function() {
|
||||||
|
this.toggleCheckedHandler = this.toggleChecked.bindAsEventListener(this);
|
||||||
|
this.allCheckedEventHandler = this.allChecked.bindAsEventListener(this);
|
||||||
|
this.allUncheckedEventHandler = this.allUnchecked.bindAsEventListener(this);
|
||||||
|
|
||||||
|
$$('.options').invoke('observe', 'click', this.toggleCheckedHandler);
|
||||||
|
$$('button.action[name=check_all]').invoke('observe', 'click', this.allCheckedEventHandler);
|
||||||
|
$$('button.action[name=uncheck_all]').invoke('observe', 'click', this.allUncheckedEventHandler);
|
||||||
|
$$('button.delete').invoke('observe', 'click', function(e){ if( !e107Helper.confirm(e107.getModLan('delete_confirm')) ) e.stop(); });
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener: Auto-toggle single checkbox on click on its container element
|
||||||
|
* Usage: Just be sure to write down the proper CSS rules, no JS code required
|
||||||
|
* if e107Admin.Helper#init is executed
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* <div class='options'>
|
||||||
|
* <input type='checkbox' class='checkbox' />
|
||||||
|
* <div class='smalltext field-help'>Inline Help Text</div>
|
||||||
|
* </div>
|
||||||
|
* OR
|
||||||
|
* <td class='options control'>
|
||||||
|
* <input class='checkbox' type='checkbox' />
|
||||||
|
* <div class='smalltext field-help'>Inline Help Text</div>
|
||||||
|
* </td>
|
||||||
|
* Note: The important part are classes 'options' and 'checkbox'.
|
||||||
|
* Container tagName is not important (everything is valid)
|
||||||
|
*
|
||||||
|
* Demo: e107_admin/image.php
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
toggleChecked: function(event) {
|
||||||
|
//do nothing if checkbox/form element or link is clicked
|
||||||
|
var tmp = event.element().nodeName.toLowerCase();
|
||||||
|
if(tmp == 'input' || tmp == 'a' || tmp == 'select' || tmp == 'textarea' || tmp == 'radio') return;
|
||||||
|
//stop event
|
||||||
|
event.stop();
|
||||||
|
|
||||||
|
//checkbox container element
|
||||||
|
var element = event.findElement('.options'), check = null;
|
||||||
|
if(element) {
|
||||||
|
check = element.select('input.checkbox'); //search for checkbox
|
||||||
|
}
|
||||||
|
//toggle checked property
|
||||||
|
if(check && check[0] && !($(check[0]).disabled)) {
|
||||||
|
$(check[0]).checked = !($(check[0]).checked);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener
|
||||||
|
* Check all checkboxes in the current form, having
|
||||||
|
* name attribute value starting with 'multiaction'
|
||||||
|
* This method is auto-attached to every button having name=check_all
|
||||||
|
* if init() method is executed
|
||||||
|
*
|
||||||
|
* Examples of valid inputbox markup:
|
||||||
|
* <input type='checkbox' class='checkbox' name='multiaction[]'>
|
||||||
|
* OR
|
||||||
|
* <input type='checkbox' class='checkbox' name='multiaction_something_else[]'>
|
||||||
|
*
|
||||||
|
* Example of button being auto-observed (see e107Admin.Helper#init)
|
||||||
|
* <button class='action' type='button' name='check_all' value='Check All'><span>Check All</span></button>
|
||||||
|
*
|
||||||
|
* Demo: e107_admin/image.php
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
allChecked: function(event) {
|
||||||
|
event.stop();
|
||||||
|
var form = event.element().up('form');
|
||||||
|
if(form) {
|
||||||
|
form.toggleChecked(true, 'name^=multiaction');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener
|
||||||
|
* Uncheck all checkboxes in the current form, having
|
||||||
|
* name attribute value starting with 'multiaction'
|
||||||
|
* This method is auto-attached to every button having name=uncheck_all
|
||||||
|
* if init() method is executed
|
||||||
|
*
|
||||||
|
* Examples of valid inputbox markup:
|
||||||
|
* <input type='checkbox' class='checkbox' name='multiaction[]'>
|
||||||
|
* OR
|
||||||
|
* <input type='checkbox' class='checkbox' name='multiaction_something_else[]'>
|
||||||
|
*
|
||||||
|
* Example of button being auto-observed (see e107Admin.Helper#init)
|
||||||
|
* <button class='action' type='button' name='uncheck_all' value='Uncheck All'><span>Uncheck All</span></button>
|
||||||
|
*
|
||||||
|
* Demo: e107_admin/image.php
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
allUnchecked: function(event) {
|
||||||
|
event.stop();
|
||||||
|
var form = event.element().up('form');
|
||||||
|
if(form) {
|
||||||
|
form.toggleChecked(false, 'name^=multiaction');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e107.runOnLoad(e107Admin.Helper.init.bind(e107Admin.Helper), document, true);
|
Reference in New Issue
Block a user