From e9f6febe028a078b04bc2ce61886a860ce2c851b Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Wed, 16 May 2012 03:10:56 +0000 Subject: [PATCH] More JS work --- e107_admin/footer.php | 13 ++-- e107_admin/header.php | 13 +++- e107_admin/image.php | 7 ++- e107_admin/includes/tabbed.php | 2 +- e107_admin/newspost.php | 2 +- e107_admin/prefs.php | 29 +++++++-- e107_handlers/form_handler.php | 28 ++++++++- e107_handlers/js_manager.php | 99 ++++++++++++++++++++++++------- e107_themes/jayya/admin_theme.php | 60 +++++++++++++++++++ e107_themes/jayya/style.css | 9 --- 10 files changed, 214 insertions(+), 48 deletions(-) diff --git a/e107_admin/footer.php b/e107_admin/footer.php index dfa3029e4..c473f1fd7 100644 --- a/e107_admin/footer.php +++ b/e107_admin/footer.php @@ -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 "\n"; + // echo "\n"; } +e107::getJs()->renderJs('footer_inline', true); + // // H Final HTML // diff --git a/e107_admin/header.php b/e107_admin/header.php index ea699e5af..3d8b6b19c 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -103,8 +103,9 @@ if(!defined('XHTML_FORCE')) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; } -else +else // XHTML { echo(defined("STANDARDS_MODE") ? "" : "\n")."\n"; echo "\n"; @@ -112,8 +113,9 @@ else \n"; echo(defined("CORE_LC")) ? "\n" : ""; + echo "\n"; } -echo "\n"; + echo "".(defined("e_PAGETITLE") ? e_PAGETITLE." - " : (defined("PAGE_NAME") ? PAGE_NAME." - " : "")).LAN_head_4." :: ".SITENAME."\n"; @@ -369,14 +371,19 @@ $body_onload = ""; * TODO - remove it from here */ require_once (e_HANDLER.'js_helper.php'); - +/* echo " "; +*/ +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 diff --git a/e107_admin/image.php b/e107_admin/image.php index 2a2f432a1..8b22ccddd 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -418,9 +418,12 @@ class media_admin_ui extends e_admin_ui $frm = e107::getForm(); $bbcodeMode = ($this->getQuery('bbcode')==1) ? 'bbcode=1' : FALSE; + + + $text = "
-
    +
    • Choose from Library
    • Upload a File
    • "; @@ -862,7 +865,7 @@ class media_admin_ui extends e_admin_ui
      ".DBLAN_20." - + diff --git a/e107_admin/includes/tabbed.php b/e107_admin/includes/tabbed.php index c9e57d327..ea0625d9c 100644 --- a/e107_admin/includes/tabbed.php +++ b/e107_admin/includes/tabbed.php @@ -21,7 +21,7 @@ $emessage = &eMessage::getInstance(); $text = "
      -
        "; +
          "; foreach ($admin_cat['id'] as $cat_key => $cat_id) { diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 65c49ebf5..95accca21 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -1377,7 +1377,7 @@ class admin_newspost $text .= "
          -
            +
            • ".LAN_NEWS_52."
            • SEO
            • ".LAN_NEWS_53."
            • diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index b6f616ee3..ba7670b99 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -1114,7 +1114,13 @@ $text .= "
      "; - $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 .= " @@ -1154,7 +1173,7 @@ $text .= "
      ".$name."
      - + diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index eb5fdd4fb..39938032b 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -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 ' - + '.$text.' '; @@ -2123,7 +2145,9 @@ class e_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) { diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 477648d24..41277d38f 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -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 "

      ".$this->_dependence." :: ".$status."

      "; + 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 != '' && $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', ''); + } + else + { + $this->addJs('core', $inc, 'all', ''); + } } } @@ -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
      "; } + else + { + // echo $this->_dependence."::".$file_path." : ENABLED
      "; + } + $tp = e107::getParser(); diff --git a/e107_themes/jayya/admin_theme.php b/e107_themes/jayya/admin_theme.php index 4e5a266fc..5f9d93c25 100644 --- a/e107_themes/jayya/admin_theme.php +++ b/e107_themes/jayya/admin_theme.php @@ -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'); + + +/* +
      + +*/ // // e107::getJs()->requireCoreLib(array( // 'core/decorate.js' => 2, diff --git a/e107_themes/jayya/style.css b/e107_themes/jayya/style.css index 554e5e16c..ea8d971d7 100644 --- a/e107_themes/jayya/style.css +++ b/e107_themes/jayya/style.css @@ -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 */