Enhancement

17 views
Skip to first unread message

66Ton99

unread,
Oct 20, 2010, 12:15:45 PM10/20/10
to sfJqueryReloadedPlugin
Index: plugins/sfJqueryReloadedPlugin/README
===================================================================
--- plugins/sfJqueryReloadedPlugin/README (revision 6224)
+++ plugins/sfJqueryReloadedPlugin/README (working copy)
@@ -62,15 +62,26 @@
{{{
all:
.settings:
- jquery_core: jquery-1.3.1.min.js
+ jquery_core: jquery-1.4.2.min.js
+ #or full path
+ jquery_path: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
}}}
- * Optional: specify different versions of the ui and autocomplete
plugins, which would be looked for in the /js/plugins/ subfolder of
your jquery_web_dir. Again, you can use relative paths relative to
that location in web space if they are in a different place.
+ * Optional: specify different versions of the ui and autocomplete
plugins,
+ which would be looked for in the /js/plugins/ subfolder of your
jquery_web_dir.
+ Again, you can use relative paths relative to that location in web
space if they are in a different place.
+ Or you can start path with slash "/" or full path with "http://..."
{{{
all:
.settings:
jquery_sortable: jquery-ui-1.7.2.custom.min.js
jquery_autocomplete: jquery.autocomplete.min.js
}}}
+ * Optional: On debug mode. It will remove ".min" form original
paths
+{{{
+ all:
+ .settings:
+ jquery_debug: true
+}}}

If you are running your websites under Microsoft Windows, you also
have to manually copy the {{{./web}}}
directory of the plugin in the {{{%SF_ROOT_DIR%/web}}} directory of
your project
Index: plugins/sfJqueryReloadedPlugin/lib/helper/jQueryHelper.php
===================================================================
--- plugins/sfJqueryReloadedPlugin/lib/helper/jQueryHelper.php
(revision 6224)
+++ plugins/sfJqueryReloadedPlugin/lib/helper/jQueryHelper.php
(working copy)
@@ -10,13 +10,16 @@
* t...@punkave.com 20090413: be consistent with the way global
* settings.yml files work, it should always be the webdir, not the /
js/
* subfolder of the webdir.
+ * 66T...@gmail.com 20101020: added debug mode
*/
-
if (!$jq_path = sfConfig::get('sf_jquery_path'))
{
$jq_path = sfConfig::get('sf_jquery_web_dir', '/
sfJqueryReloadedPlugin') .
'/js/' . sfConfig::get('sf_jquery_core', 'jquery-1.4.2.min.js');
}
+if (sfConfig::get('sf_jquery_debug')) {
+ $jq_path = str_replace('.min.js', '.js', $jq_path);
+}
sfContext::getInstance()->getResponse()->addJavascript($jq_path,
'first');

/**
@@ -34,15 +37,16 @@
*
* Example:
* <?php echo jq_add_plugins_by_name(array('sortable',
'autocomplete')) ?>
+ *
+ * 66T...@gmail.com 20101020: added possibility add additional
plugins
*
*/
-
function jq_add_plugins_by_name($args = array()) {
/*
- * When adding the capability to use a new plugin you must
- * extend this array, and keep it up to date when you update to
- * a new version. You must also update the plugin's
- * default config/settings.yml file
+ * When adding the capability to use a new plugin or other
+ * version you must update config/settings.yml file
+ * Example:
+ * jquery_newPlugin: Path
*/

$plugins = array(
@@ -52,19 +56,18 @@
'autocomplete' => 'jquery.autocomplete.min.js'
);

- $pluginPaths = sfConfig::get('sf_jquery_plugin_paths');
foreach ($args as $name)
{
- if (!isset($plugins[$name]))
+ if (!isset($plugins[$name]) && !sfConfig::has("sf_jquery_$name"))
{
throw new Exception("Unknown jQuery plugin name $name");
}
- if (!isset($pluginPaths[$name]))
- {
- $filename = sfConfig::get("sf_jquery_$name", $plugins[$name]);
+ $filename = sfConfig::get("sf_jquery_$name", @$plugins[$name]);
+ if ('/' != substr($filename, 0, 1) && false === strpos($filename,
'://')) {
$filename = sfConfig::get('sf_jquery_web_dir', '/
sfJqueryReloadedPlugin') . "/js/plugins/$filename";
- } else {
- $filename = $pluginPaths[$name];
+ }
+ if (sfConfig::get('sf_jquery_debug')) {
+ $filename = str_replace('.min.js', '.js', $filename);
}
sfContext::getInstance()->getResponse()-
>addJavascript($filename);
}
Reply all
Reply to author
Forward
0 new messages