From: Chuck Scott Date: Tue, 29 Dec 2015 21:36:08 +0000 (-0500) Subject: Image gallery fixes and add-on specific js and css files X-Git-Tag: v1.0.52^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7246171a3a50d45583059c73d08d3bffb40c0ef8;p=WP-Plugins%2Fglm-member-db.git Image gallery fixes and add-on specific js and css files --- diff --git a/controllers/admin.php b/controllers/admin.php index e9091401..451d3b4c 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -275,19 +275,33 @@ class glmMembersAdmin extends GlmPluginSupport wp_enqueue_media(); - // Scripts included with this plugin - wp_register_script('glm-members-admin-js', - GLM_MEMBERS_PLUGIN_URL . 'js/admin.js', - array( - 'jquery' - )); - wp_enqueue_script('glm-members-admin-js'); + // Register any admin.js files in the js directory of any glm members plugin + reset($this->config['addOns']); + foreach ($this->config['addOns'] as $a) { + $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/js/admin.js'; + if (is_file($jsFile)) { + $jsName = $a['slug'].'-admin-js'; + wp_register_script( + $jsName, + GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/js/admin.js' + ); + wp_enqueue_script($jsName); + } + } - // A simple set of styles for things I haven't found as a WordPress - // default yet - wp_register_style('glmMembersAdminStyle', - GLM_MEMBERS_PLUGIN_URL . 'css/admin.css'); - wp_enqueue_style('glmMembersAdminStyle'); + // Register any admin.css files in the css directory of any glm members plugin + reset($this->config['addOns']); + foreach ($this->config['addOns'] as $a) { + $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/css/admin.css'; + if (is_file($cssFile)) { + $cssName = $a['slug'].'-admin-css'; + wp_register_style( + $cssName, + GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/css/admin.css' + ); + wp_enqueue_style($cssName); + } + } // Image Upload scripts and css for Member DB and perhaps other wp_register_script('glm-members-admin-image-upload', diff --git a/controllers/front.php b/controllers/front.php index a863b577..5c8986a3 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -143,22 +143,32 @@ class glmMembersFront extends GlmPluginSupport wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_style("wp-jquery-ui-dialog"); - // Front end script - wp_register_script( - 'glm-members-front-js', - GLM_MEMBERS_PLUGIN_URL . 'js/front.js', - array( - 'jquery' - ) - ); - wp_enqueue_script('glm-members-front-js'); + // Register any front.js files in the js directory of any glm members plugin + reset($this->config['addOns']); + foreach ($this->config['addOns'] as $a) { + $jsFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/js/front.js'; + if (is_file($jsFile)) { + $jsName = $a['slug'].'-front-js'; + wp_register_script( + $jsName, + GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/js/front.js' + ); + wp_enqueue_script($jsName); + } + } - // A simple set of styles for things I haven't found as a WordPress - wp_register_style( - 'glmMembersFrontStyle', - GLM_MEMBERS_PLUGIN_URL . 'css/front.css' - ); - wp_enqueue_style('glmMembersFrontStyle'); + // Register any front.css files in the css directory of any glm members plugin + foreach ($this->config['addOns'] as $a) { + $cssFile = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.$a['slug'].'/css/front.css'; + if (is_file($cssFile)) { + $cssName = $a['slug'].'-front-css'; + wp_register_style( + $cssName, + GLM_MEMBERS_WORDPRESS_PLUGIN_URL.'/'.$a['slug'].'/css/front.css' + ); + wp_enqueue_style($cssName); + } + } } diff --git a/css/admin.css b/css/admin.css index c38319ed..c468fdba 100644 --- a/css/admin.css +++ b/css/admin.css @@ -71,7 +71,7 @@ padding: 0px 8px 4px 8px !important; } .nav-tab-active { - font-weight: bold; var_dump($memberData); + font-weight: bold; font-size: 1.1vw !important; text-decoration: none; border: 2px #ccc solid; @@ -265,7 +265,6 @@ td.glm-nowrap { .glm-imageGalleryContainer { border: 1px #ddd solid !important; - draggable } .glm-galleryImage { diff --git a/defines.php b/defines.php index bd024157..de451292 100644 --- a/defines.php +++ b/defines.php @@ -54,6 +54,7 @@ define('GLM_MEMBERS_PLUGIN_CONFIG_PATH', GLM_MEMBERS_PLUGIN_PATH.'/config'); $pluginsPath = str_replace(GLM_MEMBERS_PLUGIN_SLUG, '', GLM_MEMBERS_PLUGIN_PATH); define('GLM_MEMBERS_WORDPRESS_PLUGIN_PATH', $pluginsPath); +define('GLM_MEMBERS_WORDPRESS_PLUGIN_URL', WP_PLUGIN_URL); // Database defines global $wpdb; diff --git a/js/admin.js b/js/admin.js index 17d8de5c..cf967274 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1,44 +1,5 @@ - -// Other needed JS code - -jQuery(document).ready(function($){ - - /* - * Use media uploaded for all file/image uploads - */ - - var custom_uploader; - - $('.glm-protp-upload-button').click(function(e) { - - e.preventDefault(); - - var id = $(this).attr('data-id'); - - //If the uploader object has already been created, reopen the dialog - if (custom_uploader) { - custom_uploader.open(); - return; - } - - //Extend the wp.media object - var custom_uploader = wp.media.frames.file_frame = wp.media({ - title: 'Choose the desired image below or select "Upload Files" to select a new image.', - button: { - text: 'Choose Image' - }, - multiple: false - }); - - //When a file is selected, grab the URL and set it as the text field's value - custom_uploader.on('select', function() { - attachment = custom_uploader.state().get('selection').first().toJSON(); - $('#' + id).val(attachment.url); - }); - - //Open the uploader dialog - custom_uploader.open(); - - }); - -}); \ No newline at end of file +/* + * + * Other needed Admin JS code + * + */ diff --git a/js/imageUpload/imageUpload.js b/js/imageUpload/imageUpload.js index 8a17cf2f..e32a4fb1 100644 --- a/js/imageUpload/imageUpload.js +++ b/js/imageUpload/imageUpload.js @@ -75,8 +75,8 @@ jQuery(document).ready(function($) { allowedTypes = drop.attr("data-allowedTypes"); uploadStatusTemplate = drop.children('.glm-imageUploadStatusTemplate').html(); - imageDataTemplate = drop.children('.glm-galleryDataTemplate').html(); - galleryImages = drop.parent().parent().children('.glm-galleryItems'); + imageDataTemplate = drop.children('.glm-galleryImageDataTemplate').html(); + galleryImages = drop.parent().parent().children('.glm-galleryImages'); // Change drop destination appearance only when dragging over a file. drop.on('dragenter', function(e){ @@ -182,8 +182,10 @@ jQuery(document).ready(function($) { processFile(); } else { + // When status has faded in, Send the files sendFileToServer(fd, status); + } }); @@ -228,6 +230,7 @@ jQuery(document).ready(function($) { // Using a copy of the supplied template, add file information // to statusbar statusbar = uploadStatusTemplate; + statusbar = statusbar.replace('bust-stupid-ngg-image-selection', 'img'); statusbar = statusbar.replace('{ thisFile }', curFile); statusbar = statusbar.replace('{ numbFiles }', lastFile); statusbar = statusbar.replace('{ fileImage }', e.target.result); @@ -249,7 +252,7 @@ jQuery(document).ready(function($) { // If a large file, notify user it will take time. if (file.size > 100000 && file.type == 'image/png') { - sizeStr += ' -- NOTE: Processing for this image may be slow!'; + sizeStr += ' -- NOTE: Processing for this image may be slow!'; } statusbar = statusbar.replace('{ fileSize }', sizeStr); @@ -277,7 +280,7 @@ jQuery(document).ready(function($) { } /* - * Sends file to image plugin via AJAX submission targeting WordPress AJAX + * Uploads the image via AJAX submission targeting WordPress AJAX * handler. */ function sendFileToServer(fd, status) @@ -321,6 +324,7 @@ jQuery(document).ready(function($) { // Using a copy of the supplied template, add image information imageData = imageDataTemplate; + imageData = imageData.replace(/bust-stupid-ngg-image-selection/g, 'img'); imageData = imageData.replace(/{ id }/g, fileData.files[i].id); imageData = imageData.replace(/\{ filename \}/g, fileData.files[i].newFileName); galleryImages.prepend(imageData); @@ -335,10 +339,10 @@ jQuery(document).ready(function($) { } else { alert("Upload Failed\nReason: " + fileData.message); - } + } - }, - complete: function() { + }, + complete: function() { // When status area has faded statusArea.fadeOut( function() { diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index 86f002db..1255ba85 100644 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -460,11 +460,17 @@
- Uploading Image [thisFile] of [numbFiles] + Uploading Image { thisFile } of { numbFiles } - -
Cancel Upload
+ + + + @@ -491,7 +497,7 @@
+
+ +
+
Cancel Upload
Name: { fileName }
Type: { fileType }
- + @@ -505,10 +511,12 @@
Delete:
Delete:
Selected Image:
Featured Image:
New Upload
- +
-
+
+ +