1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 03:10:50 +02:00

More JS work

This commit is contained in:
CaMer0n
2012-05-16 03:10:56 +00:00
parent 7f25438201
commit e9f6febe02
10 changed files with 214 additions and 48 deletions

View File

@@ -280,7 +280,7 @@ if (isset($footer_js) && is_array($footer_js))
e107::getJs()->renderJs('footer', true);
// [JSManager] Load JS Footer inline code by priority
e107::getJs()->renderJs('footer_inline', true);
//
// G final JS script keeps user and server time in sync.
@@ -298,11 +298,16 @@ if (abs($_serverTime - $lastSet) > 120)
* Benefit: account for user time corrections and changes in internet delays
* Drawback: each update may cause all server times to display a bit different
*/
echo "<script type='text/javascript'>\n";
echo "SyncWithServerTime('{$_serverTime}', '{$_serverPath}', '{$_serverDomain}');
</script>\n";
// echo "<script type='text/javascript'>\n";
e107::js('footer-inline',"SyncWithServerTime('{$_serverTime}', '{$_serverPath}', '{$_serverDomain}');",'prototype');
//echo "SyncWithServerTime('{$_serverTime}', '{$_serverPath}', '{$_serverDomain}');
// </script>\n";
}
e107::getJs()->renderJs('footer_inline', true);
//
// H Final HTML
//

View File

@@ -103,8 +103,9 @@ if(!defined('XHTML_FORCE'))
echo "<!doctype html>\n";
echo "<html".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("CORE_LC") ? " lang=\"".CORE_LC."\"" : "").">\n";
echo "<head>\n";
echo "<meta charset='utf-8' />\n";
}
else
else // XHTML
{
echo(defined("STANDARDS_MODE") ? "" : "<?xml version='1.0' encoding='utf-8' "."?".">\n")."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
echo "<html xmlns='http://www.w3.org/1999/xhtml'".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("CORE_LC") ? " xml:lang=\"".CORE_LC."\"" : "").">\n";
@@ -112,8 +113,9 @@ else
<head>
<meta http-equiv='content-style-type' content='text/css' />\n";
echo(defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : "";
echo "<meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
}
echo "<meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
echo "<title>".(defined("e_PAGETITLE") ? e_PAGETITLE." - " : (defined("PAGE_NAME") ? PAGE_NAME." - " : "")).LAN_head_4." :: ".SITENAME."</title>\n";
@@ -369,14 +371,19 @@ $body_onload = "";
* TODO - remove it from here
*/
require_once (e_HANDLER.'js_helper.php');
/*
echo "
<script type='text/javascript'>
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
(".e_jshelper::toString(LAN_DELETE).").addModLan('core', 'delete');
</script>
";
*/
e107::js('inline',"
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
(".e_jshelper::toString(LAN_DELETE).").addModLan('core', 'delete');
",'prototype',5);
// [JSManager] Load JS Includes - Zone 5 - After theme_head, before e107:loaded trigger

View File

@@ -418,9 +418,12 @@ class media_admin_ui extends e_admin_ui
$frm = e107::getForm();
$bbcodeMode = ($this->getQuery('bbcode')==1) ? 'bbcode=1' : FALSE;
$text = "
<div class='admintabs' id='tab-container'>
<ul class='e-tabs e-hideme' id='core-emote-tabs'>
<ul class='e-tabs' id='core-emote-tabs'>
<li id='tab-select'><a href='#core-media-select'>Choose from Library</a></li>
<li id='tab-upload'><a href='#core-media-upload'>Upload a File</a></li>";
@@ -862,7 +865,7 @@ class media_admin_ui extends e_admin_ui
<fieldset id='core-mediamanager-batch'>
<legend class='e-hideme'>".DBLAN_20."</legend>
<table class='adminlist'>
<colgroup span='4'>
<colgroup>
<col style='width: 5%' />
<col />
<col />

View File

@@ -21,7 +21,7 @@ $emessage = &eMessage::getInstance();
$text = "<div style='text-align:center'>
<div class='admintabs' id='tab-container'>
<ul class='e-tabs e-hideme' id='core-emote-tabs'>";
<ul class='e-tabs' id='core-emote-tabs'>";
foreach ($admin_cat['id'] as $cat_key => $cat_id)
{

View File

@@ -1377,7 +1377,7 @@ class admin_newspost
$text .= "
<div class='admintabs' id='tab-container'>
<ul class='e-tabs e-hideme' id='core-emote-tabs'>
<ul class='e-tabs' id='core-emote-tabs'>
<li id='tab-general'><a href='#core-newspost-create'>".LAN_NEWS_52."</a></li>
<li id='tab-seo'><a href='#core-newspost-seo'>SEO</a></li>
<li id='tab-advanced'><a href='#core-newspost-edit-options'>".LAN_NEWS_53."</a></li>

View File

@@ -1114,7 +1114,13 @@ $text .= "
</colgroup>
<tbody>";
$js_options = array('admin'=>'Admin Area','front'=>'Front-End','all'=>"Both", 'none'=> 'Disabled');
$js_options = array(
'auto' => 'Auto (on-demand)', // load based on dependency
'admin' => 'Admin Area', // Always load in admin
'front' => 'Front-End', // Always load in front-end
'all' => "Both", // Always load in admin and front-end
'none' => 'Disabled' // disabled
);
//TODO FIXME - remove JS framework dependency from front-end and backend.
@@ -1125,7 +1131,7 @@ $text .= "
// with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc.
//TODO Move paths into js_manager and store only keys like 'prototype-local', 'core-minimum' in prefs.
/*
$js_types = array(
array('name'=> 'Prototype (local)', 'path'=> 'prototype/prototype.js') ,
array('name'=> 'Scriptaculous (local)', 'path'=> 'scriptaculous/scriptaculous.js'),
@@ -1137,12 +1143,25 @@ $text .= "
array('name'=> 'e107 Core Minimum', 'path'=> 'e107.js'),
array('name'=> 'e107 Plugin Scripts (TO-DO)', 'path'=> ''), // all js that has been added by Plugins.
array('name'=> 'e107 Theme Scripts (TO-DO)', 'path'=> ''), // all js that has been added by Themes.
);
);
*/
// e107 minimum loaded by default once dependency is removed.
$js_types = array(
array('id' => 'prototype', 'name'=> 'Prototype (local)'),
array('id' => 'prototype-cdn', 'name'=> 'Prototype (CDN)'),
array('id' => 'jquery', 'name'=> 'jQuery (CDN)')
);
foreach($js_types as $arr)
{
$k = $arr['path'];
// $k = $arr['path'];
$k = $arr['id'];
$name = $arr['name'];
$text .= "<tr>
<td>".$name."</td>
@@ -1154,7 +1173,7 @@ $text .= "
</tbody>
</table>
<table cellpadding='0' cellspacing='0' class='adminform' style='margin-top: 20px'>
<colgroup span='2'>
<colgroup>
<col class='col-label' />
<col class='col-control' />
</colgroup>

View File

@@ -163,6 +163,27 @@ class e_form
$footer = '';
if(!e107::getRegistry('core/form/mediaurl'))
{
e107::js('core','core/admin.js','prototype');
e107::js('core','core/dialog.js','prototype');
e107::js('core','core/draggable.js','prototype');
e107::css('core','core/dialog/dialog.css','prototype');
e107::css('core','core/dialog/e107/e107.css','prototype');
e107::js('footer-inline','
$$("a.e-dialog").invoke("observe", "click", function(ev) {
var element = ev.findElement("a");
ev.stop();
new e107Widgets.URLDialog(element.href + "&iframe=1", {
id: element["id"] || "e-dialog",
width: 830,
height: 650
}).center().setHeader("Media Manager : '.$category.'").setFooter('.$footer.').activate().show();
});
','prototype');
/*
e107::getJs()->requireCoreLib('core/admin.js')
->requireCoreLib('core/dialog.js')
->requireCoreLib('core/draggable.js')
@@ -180,6 +201,7 @@ class e_form
}).center().setHeader("Media Manager : '.$category.'").setFooter('.$footer.').activate().show();
});
');
*/
e107::setRegistry('core/form/mediaurl', true);
}
return $ret;
@@ -1104,7 +1126,7 @@ class e_form
}
return '
<colgroup span="'.$count.'">
<colgroup>
'.$text.'
</colgroup>
';
@@ -2123,7 +2145,9 @@ class e_form
</div>
</form>
";
e107::getJs()->footerInline("Form.focusFirstElement('{$form['id']}-form');");
e107::js('footer-inline',"Form.focusFirstElement('{$form['id']}-form');",'prototype');
// e107::getJs()->footerInline("Form.focusFirstElement('{$form['id']}-form');");
}
if(!$nocontainer)
{

View File

@@ -19,16 +19,21 @@ class e_jsmanager
*/
protected $_libraries = array(
'prototype' => array(
'prototype/prototype.js' ,
'scriptaculous/scriptaculous.js',
'scriptaculous/effects.js',
'e107.js'),
'prototype/prototype.js' ,
'scriptaculous/scriptaculous.js',
'scriptaculous/effects.js',
'e107.js'),
'jquery' => array(
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js")
"http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js",
"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css"
)
);
protected $_core_prefs = array();
/**
* Core JS library files, loaded via e_jslib.php
*
@@ -199,15 +204,23 @@ class e_jsmanager
// Load stored in preferences core lib paths ASAP - FIXME - find better way to store libs - array structure and separate table row
$core_libs = e107::getPref('e_jslib_core');
// $core_libs = e107::getPref('e_jslib_core');
$this->_core_prefs = e107::getPref('e_jslib_core');
$core = array();
if(!$core_libs)
foreach($this->_core_prefs as $id=>$vis)
{
$core_libs = array();
if($vis != 'none' && $vis != 'auto')
{
foreach($this->_libraries[$id] as $path)
{
$core[$path] = $vis;
}
}
}
$this->coreLib($core_libs);
$this->coreLib($core);
// Load stored in preferences plugin lib paths ASAP
$plug_libs = e107::getPref('e_jslib_plugin');
@@ -542,6 +555,41 @@ class e_jsmanager
{
$this->_dependence = null;
}
/**
* Return TRUE if the library is disabled. ie. prototype or jquery.
*/
public function libDisabled($type, $loc)
{
if($type == 'core' && ($loc == 'none'))
{
return TRUE;
}
if($this->_dependence != null && isset($this->_libraries[$this->_dependence]))
{
$status = $this->_core_prefs[$this->_dependence];
if($status == 'auto')
{
// echo "<h2>".$this->_dependence." :: ".$status."</h2>";
return FALSE;
}
if($this->isInAdmin() && $status !='admin' && $status !='all')
{
return TRUE;
}
elseif($status == 'none')
{
return TRUE;
}
}
return FALSE;
}
/**
* Require JS file(s). Used by corresponding public proxy methods.
@@ -567,24 +615,27 @@ class e_jsmanager
// ie. e107 Core Minimum: JS similar to e107 v1.0 should be loaded "e_js.php" (no framwork dependency)
// with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc.
if(empty($file_path))
{
return $this;
}
if($type == 'core' && ($runtime_location == 'none')) // disabled core js library
{
return $this;
}
// Load Required Library (prototype | jquery)
if($pre != 'noloop' && $this->_dependence != null && isset($this->_libraries[$this->_dependence])) // load framework
if($pre != '<!-- AutoLoad -->' && $this->_dependence != null && isset($this->_libraries[$this->_dependence])) // load framework
{
foreach($this->_libraries[$this->_dependence] as $inc)
{
$this->addJs('core', $inc, 'all', 'noloop');
if(strpos($inc,".css"))
{
$this->addJs('other_css', $inc, 'all', '<!-- AutoLoad -->');
}
else
{
$this->addJs('core', $inc, 'all', '<!-- AutoLoad -->');
}
}
}
@@ -609,10 +660,16 @@ class e_jsmanager
return $this;
}
if($runtime_location == 'front' && $this->isInAdmin())
if($this->libDisabled($type,$runtime_location))
{
return $this;
return $this;
//echo $this->_dependence."::".$file_path." : DISABLED<br />";
}
else
{
// echo $this->_dependence."::".$file_path." : ENABLED<br />";
}
$tp = e107::getParser();

View File

@@ -72,7 +72,67 @@ e107::js('inline',"
"
,'prototype');
//TODO - Move to external files.
e107::css('inline',"/******** Tabs JS */
.admintabs ul.e-tabs { border-bottom: 1px solid #DDDDDD; height: 31px; }
.admintabs ul.e-tabs li { border: 1px solid #DDDDDD; display: block; float: left; line-height: 30px; padding: 0px 7px; margin-right: 3px; background-color: #F9F9F9 }
.admintabs fieldset { clear: both ; border: 1px solid #DDDDDD; padding: 10px; border-top: 0px none; }
.admintabs fieldset legend { border: 1px solid #DDDDDD; }
.admintabs ul.e-tabs li.active { border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF}
a.e-tabs {
text-decoration: none;
}
",'prototype');
e107::js('inline','
$(document).ready(function()
{
$(".e-expandit").click(function () {
$(".e-hideme").toggle("slow");
});
$(function() {
$( "#datepicker" ).datepicker();
});
$(function() {
$( "#tab-container" ).tabs();
});
$(".adminlist tr:even").addClass("even");
$(".adminlist tr:odd").addClass("odd");
$(".e-dialog").click(function () {
var link = $(this).attr("href");
$("").load(link).dialog({
modal:true
});
return false;
});
});
','jquery');
e107::css('inline',"
.e-hideme { display:none; }
",'jquery');
/*
<div class="admintabs" id="tab-container">
<ul class="e-tabs e-hideme" id="core-emote-tabs">
<li id="tab-general"><a href="#core-newspost-create">General Information</a></li>
<li id="tab-seo"><a href="#core-newspost-seo">SEO</a></li>
<li id="tab-advanced"><a href="#core-newspost-edit-options">Advanced Options</a></li>
</ul>
*/
//
// e107::getJs()->requireCoreLib(array(
// 'core/decorate.js' => 2,

View File

@@ -550,15 +550,6 @@ div.bbarea.small, .tbox.small, .helpbox.small { width: 250px !important; }
/******** Prepare for Image Preview JS */
.image-preview {}
/******** Tabs JS */
.admintabs ul.e-tabs { border-bottom: 1px solid #DDDDDD; height: 31px; }
.admintabs ul.e-tabs li { border: 1px solid #DDDDDD; display: block; float: left; line-height: 30px; padding: 0px 7px; margin-right: 3px; background-color: #F9F9F9 }
.admintabs fieldset { clear: both ; border: 1px solid #DDDDDD; padding: 10px; border-top: 0px none; }
.admintabs fieldset legend { border: 1px solid #DDDDDD; }
.admintabs ul.e-tabs li.active { border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF}
a.e-tabs {
text-decoration: none;
}
/******** SyS Messages / Message text formatting */
/* message boxes */