From d3bdce14914f4658b9083187e460e063d7403d15 Mon Sep 17 00:00:00 2001 From: dziudek Date: Mon, 8 Jul 2013 10:31:37 +0200 Subject: [PATCH 01/25] Added option to define the custom RSS URLs --- MeetGavernWP/gavern/hooks.php | 36 +++++++++++++++++++ .../options/en_US/options.advanced.json | 7 ++++ 2 files changed, 43 insertions(+) diff --git a/MeetGavernWP/gavern/hooks.php b/MeetGavernWP/gavern/hooks.php index 6943677..0d29eff 100644 --- a/MeetGavernWP/gavern/hooks.php +++ b/MeetGavernWP/gavern/hooks.php @@ -231,4 +231,40 @@ function gavernwp_ga_code_hook() { add_action('gavernwp_ga_code', 'gavernwp_ga_code_hook'); +/** + * + * + * + * + * WP Core actions + * + * + * + * + **/ + +/** + * + * Function used to generate the custom RSS feed link + * + **/ + +function gavernwp_custom_rss_feed_url( $output, $feed ) { + global $tpl; + // get the new RSS URL + $feed_link = get_option($tpl->name . '_custom_rss_feed', ''); + // check the URL + if(trim($feed_link) !== '') { + if (strpos($output, 'comments')) { + return $output; + } + + return esc_url($feed_link); + } else { + return $output; + } +} + +add_action( 'feed_link', 'gavernwp_custom_rss_feed_url', 10, 2 ); + // EOF \ No newline at end of file diff --git a/MeetGavernWP/gavern/options/en_US/options.advanced.json b/MeetGavernWP/gavern/options/en_US/options.advanced.json index 56f46d7..83d4d93 100644 --- a/MeetGavernWP/gavern/options/en_US/options.advanced.json +++ b/MeetGavernWP/gavern/options/en_US/options.advanced.json @@ -81,6 +81,13 @@ "tooltip": "Enable inclusion of the override.css file in the section. The override.css file is the best way to add modifications and new CSS code without changing the original theme files.", "default": "Y" }, + { + "name": "custom_rss_feed", + "type": "Text", + "label": "Custom RSS feed URL", + "tooltip": "Specify the custom RSS feed URL if you're using services like Feedburner", + "default": "" + }, { "name": "comments_explained", "type": "TextBlock", From 0feac9a6cccbd52fd4d3475164f44c447dbb76b1 Mon Sep 17 00:00:00 2001 From: dziudek Date: Mon, 8 Jul 2013 11:57:47 +0200 Subject: [PATCH 02/25] Added submenu indicators --- MeetGavernWP/css/wp.css | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MeetGavernWP/css/wp.css b/MeetGavernWP/css/wp.css index 71f9af1..d301dab 100644 --- a/MeetGavernWP/css/wp.css +++ b/MeetGavernWP/css/wp.css @@ -46,6 +46,29 @@ margin: 0; } +#main-menu > li.haschild:after { + content: "\f078"; + font-family: FontAwesome; + font-size: 10px; + margin: 0 0 0 -5px; + position: relative; + top: -2px; +} + +#main-menu > li li.haschild { + position: relative; +} + +#main-menu > li li.haschild:after { + content: "\f054"; + font-family: FontAwesome; + font-size: 10px; + margin: 0; + position: absolute; + right: 10px; + top: 7px; +} + #main-menu > li > a { color: #777; margin: 0; From 37873c8c807c743ac6b8288f2431270ab32be873 Mon Sep 17 00:00:00 2001 From: dziudek Date: Tue, 9 Jul 2013 11:50:02 +0200 Subject: [PATCH 03/25] Fixed a notice in the GK Comments widget. --- MeetGavernWP/gavern/widgets.comments.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MeetGavernWP/gavern/widgets.comments.php b/MeetGavernWP/gavern/widgets.comments.php index 95e322d..b536812 100644 --- a/MeetGavernWP/gavern/widgets.comments.php +++ b/MeetGavernWP/gavern/widgets.comments.php @@ -136,7 +136,12 @@ function update( $new_instance, $old_instance ) { **/ function refresh_cache() { - $ids = array_keys(get_option('widget_widget_gk_comments')); + if(is_array(get_option('widget_widget_gk_comments'))) { + $ids = array_keys(get_option('widget_widget_gk_comments')); + } else { + $ids = array(); + } + for($i = 0; $i < count($ids); $i++) { if(is_numeric($ids[$i])) { delete_transient(md5('widget_gk_comments-' . $ids[$i])); From bf1649a459c9c01a884d68efc004be17a6ce41a5 Mon Sep 17 00:00:00 2001 From: dziudek Date: Tue, 9 Jul 2013 13:30:13 +0200 Subject: [PATCH 04/25] Added the priority parameter in the Customizer controls declaration. --- .../gavern/helpers/helpers.customizer.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/MeetGavernWP/gavern/helpers/helpers.customizer.php b/MeetGavernWP/gavern/helpers/helpers.customizer.php index 1fb83bc..f9a32e3 100644 --- a/MeetGavernWP/gavern/helpers/helpers.customizer.php +++ b/MeetGavernWP/gavern/helpers/helpers.customizer.php @@ -30,7 +30,8 @@ function gavern_init_customizer() { array( 'default' => $template_style, 'type' => 'option', - 'capability' => 'edit_theme_options' + 'capability' => 'edit_theme_options', + 'priority' => 1 ) ); // create control @@ -40,7 +41,8 @@ function gavern_init_customizer() { 'label' => $styles->family_desc, 'section' => 'colors', 'type' => 'select', - 'choices' => $styles_array + 'choices' => $styles_array, + 'priority' => 2 ) ); } @@ -108,7 +110,8 @@ function gavern_init_customizer() { "left" => __("Sidebar on the left", GKTPLNAME), "right"=> __("Sidebar on the right", GKTPLNAME), "none" => __("Sidebar disabled", GKTPLNAME) - ) + ), + 'priority' => 1 ) ); @@ -117,34 +120,38 @@ function gavern_init_customizer() { array( 'label' => __('Theme width', GKTPLNAME), 'section' => $tpl->name . '_layout', - 'type' => 'text' + 'type' => 'text', + 'priority' => 2 ) ); $wp_customize->add_control( - $tpl->name . '_sidebar_width', + $tpl->name . '_tablet_width', array( - 'label' => __('Sidebar % width', GKTPLNAME), + 'label' => __('Tablet width', GKTPLNAME), 'section' => $tpl->name . '_layout', - 'type' => 'text' + 'type' => 'text', + 'priority' => 3 ) ); $wp_customize->add_control( - $tpl->name . '_tablet_width', + $tpl->name . '_mobile_width', array( - 'label' => __('Tablet width', GKTPLNAME), + 'label' => __('Mobile width', GKTPLNAME), 'section' => $tpl->name . '_layout', - 'type' => 'text' + 'type' => 'text', + 'priority' => 4 ) ); $wp_customize->add_control( - $tpl->name . '_mobile_width', + $tpl->name . '_sidebar_width', array( - 'label' => __('Mobile width', GKTPLNAME), + 'label' => __('Sidebar % width', GKTPLNAME), 'section' => $tpl->name . '_layout', - 'type' => 'text' + 'type' => 'text', + 'priority' => 5 ) ); } From 0dc31104f86a674a275abd87935bdcb5fa5a74c6 Mon Sep 17 00:00:00 2001 From: dziudek Date: Sat, 13 Jul 2013 11:02:31 +0200 Subject: [PATCH 05/25] Back-end code optimized with JSHint + small fix for the update version comparision --- MeetGavernWP/js/back-end/gavern.metabox.js | 90 +- .../js/back-end/gavern.shortcode.button.js | 168 ++-- MeetGavernWP/js/back-end/template.options.js | 745 +++++++++-------- MeetGavernWP/js/back-end/updates.options.js | 96 ++- MeetGavernWP/js/back-end/widget.rules.js | 791 ++++++++++-------- 5 files changed, 975 insertions(+), 915 deletions(-) diff --git a/MeetGavernWP/js/back-end/gavern.metabox.js b/MeetGavernWP/js/back-end/gavern.metabox.js index 7683b52..35b9c75 100644 --- a/MeetGavernWP/js/back-end/gavern.metabox.js +++ b/MeetGavernWP/js/back-end/gavern.metabox.js @@ -5,49 +5,51 @@ * ------------------------------------------- * **/ - -// Open Graph metatags -jQuery(function(jQuery) { - jQuery('.gavern_opengraph_upload_image_button').click(function() { - formfield = jQuery(this).siblings('.gavern_opengraph_upload_image'); - preview = jQuery(this).siblings('.gavern_opengraph_preview_image'); - tb_show('', 'media-upload.php?type=image&TB_iframe=true'); - window.send_to_editor = function(html) { - imgurl = jQuery('img',html).attr('src'); - classes = jQuery('img', html).attr('class'); - id = classes.replace(/(.*?)wp-image-/, ''); - formfield.val(id); - preview.attr('src', imgurl); - tb_remove(); - } - return false; - }); +(function () { + "use strict"; + // Open Graph metatags + jQuery(function (jQuery) { + jQuery('.gavern_opengraph_upload_image_button').click(function () { + var formfield = jQuery(this).siblings('.gavern_opengraph_upload_image'); + var preview = jQuery(this).siblings('.gavern_opengraph_preview_image'); + tb_show('', 'media-upload.php?type=image&TB_iframe=true'); + window.send_to_editor = function (html) { + var imgurl = jQuery('img', html).attr('src'); + var classes = jQuery('img', html).attr('class'); + var id = classes.replace(/(.*?)wp-image-/, ''); + formfield.val(id); + preview.attr('src', imgurl); + tb_remove(); + }; + return false; + }); - jQuery('.gavern_opengraph_clear_image').click(function() { - var defaultImage = jQuery(this).parent().siblings('.gavern_opengraph_default_image').text(); - jQuery(this).parent().siblings('.gavern_opengraph_upload_image').val(''); - jQuery(this).parent().siblings('.gavern_opengraph_preview_image').attr('src', defaultImage); - return false; - }); -}); + jQuery('.gavern_opengraph_clear_image').click(function () { + var defaultImage = jQuery(this).parent().siblings('.gavern_opengraph_default_image').text(); + jQuery(this).parent().siblings('.gavern_opengraph_upload_image').val(''); + jQuery(this).parent().siblings('.gavern_opengraph_preview_image').attr('src', defaultImage); + return false; + }); + }); -// Page additional params -jQuery(document).ready(function() { - var templateSelect = jQuery('#page_template'); - var template = templateSelect.find('option:selected').val(); - - jQuery(document).find('p[data-template]').removeClass('active'); - jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); - - templateSelect.change(function() { - var template = templateSelect.find('option:selected').val(); - jQuery(document).find('p[data-template]').removeClass('active'); - jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); - }); - - templateSelect.blur(function() { - var template = templateSelect.find('option:selected').val(); - jQuery(document).find('p[data-template]').removeClass('active'); - jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); - }); -}); \ No newline at end of file + // Page additional params + jQuery(document).ready(function () { + var templateSelect = jQuery('#page_template'); + var template = templateSelect.find('option:selected').val(); + + jQuery(document).find('p[data-template]').removeClass('active'); + jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); + + templateSelect.change(function () { + var template = templateSelect.find('option:selected').val(); + jQuery(document).find('p[data-template]').removeClass('active'); + jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); + }); + + templateSelect.blur(function () { + var template = templateSelect.find('option:selected').val(); + jQuery(document).find('p[data-template]').removeClass('active'); + jQuery(document).find('p[data-template="' + template + '"]').addClass('active'); + }); + }); +}()); \ No newline at end of file diff --git a/MeetGavernWP/js/back-end/gavern.shortcode.button.js b/MeetGavernWP/js/back-end/gavern.shortcode.button.js index acce8a1..d9277ee 100644 --- a/MeetGavernWP/js/back-end/gavern.shortcode.button.js +++ b/MeetGavernWP/js/back-end/gavern.shortcode.button.js @@ -5,96 +5,88 @@ * ------------------------------------------- * **/ - -( - function(){ - var icon_url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEhJREFUeNpi/P//PwM1ARMDlQELjNG26z66UxmhNFFeqHJTZKSJCwe/gSxYwowBR1gOvAspimWY+tFYHo3lYRnLjIO+xAYIMABySA8v3JaU8wAAAABJRU5ErkJggg=='; +(function () { + "use strict"; - tinymce.create( - "tinymce.plugins.GavernWPShortcodes", - { - init: function(editor, pluginUrl) { - // initial code if necessary - }, - createControl:function(controlName, controlManager){ - if(controlName == "gavern_shortcode_button"){ - controlName = controlManager.createMenuButton( "gavern_shortcode_button", { - title:"Insert Gavern Shortcode", - image:icon_url, - icons:false - }); - - var $this = this; - - controlName.onRenderMenu.add(function(menu, button){ - for(var i = 0; i < $GAVERNWP_SHORTCODES.length; i++) { - // - if($GAVERNWP_SHORTCODES[i]['submenu'] != null) { - menu = button.addMenu({ - title: $GAVERNWP_SHORTCODES[i]['title'], - onclick : function() { - if($GAVERNWP_SHORTCODES[num]['code'] !== '') { - tinyMCE.activeEditor.execCommand( - "mceInsertContent", - false, - $GAVERNWP_SHORTCODES[num]['code'] + ' ' - ); - } - } - }); - - for(var j = 0; j < $GAVERNWP_SHORTCODES[i]['submenu'].length; j++) { - $this.addSubmenu( - menu, - $GAVERNWP_SHORTCODES[i]['submenu'][j]['title'], - $GAVERNWP_SHORTCODES[i]['submenu'][j]['code'] + ' ' - ); - } - } else { - var num = i; - button.add({ - title : $GAVERNWP_SHORTCODES[i]['title'], - onclick : function() { - if($GAVERNWP_SHORTCODES[num]['code'] !== '') { - tinyMCE.activeEditor.execCommand( - "mceInsertContent", - false, - $GAVERNWP_SHORTCODES[num]['code'] + ' ' - ); - } - } - }); - } + var icon_url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEhJREFUeNpi/P//PwM1ARMDlQELjNG26z66UxmhNFFeqHJTZKSJCwe/gSxYwowBR1gOvAspimWY+tFYHo3lYRnLjIO+xAYIMABySA8v3JaU8wAAAABJRU5ErkJggg=='; + + tinymce.create( + "tinymce.plugins.GavernWPShortcodes", { + init: function () { + // initial code if necessary + }, + createControl: function (controlName, controlManager) { + if (controlName === "gavern_shortcode_button") { + controlName = controlManager.createMenuButton("gavern_shortcode_button", { + title: "Insert Gavern Shortcode", + image: icon_url, + icons: false + }); + + var $this = this; + + controlName.onRenderMenu.add(function (menu, button) { + for (var i = 0; i < $GAVERNWP_SHORTCODES.length; i++) { + // + if ($GAVERNWP_SHORTCODES[i].submenu !== null) { + menu = button.addMenu({ + title: $GAVERNWP_SHORTCODES[i].title, + onclick: gkClickEvent($GAVERNWP_SHORTCODES, num) + }); + + for (var j = 0; j < $GAVERNWP_SHORTCODES[i].submenu.length; j++) { + $this.addSubmenu( + menu, + $GAVERNWP_SHORTCODES[i].submenu[j].title, + $GAVERNWP_SHORTCODES[i].submenu[j].code + ' ' + ); + } + } else { + var num = i; + button.add({ + title: $GAVERNWP_SHORTCODES[i].title, + onclick: gkClickEvent($GAVERNWP_SHORTCODES, num) + }); } - }); - - return controlName; - } - - return null - }, - - addSubmenu:function(menu, label, code){ - menu.add({ - title: label, - onclick:function(){ - tinyMCE.activeEditor.execCommand("mceInsertContent", false, code); - } - }) - }, - - getInfo:function() { - return { - longname:"GavernWP Shortcodes", - author:"GavickPro", - authorurl:"http://www.gavick.com", - infourl:"http://www.gavick.com", - version:"1.0" - } + } + }); + + return controlName; } + + return null; + }, + + addSubmenu: function (menu, label, code) { + menu.add({ + title: label, + onclick: function () { + tinyMCE.activeEditor.execCommand("mceInsertContent", false, code); + } + }); + }, + + getInfo: function () { + return { + longname: "GavernWP Shortcodes", + author: "GavickPro", + authorurl: "http://www.gavick.com", + infourl: "http://www.gavick.com", + version: "1.0" + }; } - ); - - tinymce.PluginManager.add( "GavernWPShortcodes", tinymce.plugins.GavernWPShortcodes ); + } + ); + + function gkClickEvent(shortcodes, num) { + if (shortcodes[num] && shortcodes[num].code !== '') { + tinyMCE.activeEditor.execCommand( + "mceInsertContent", + false, + shortcodes[num].code + ' ' + ); + } } -)(); \ No newline at end of file + + tinymce.PluginManager.add("GavernWPShortcodes", tinymce.plugins.GavernWPShortcodes); +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/back-end/template.options.js b/MeetGavernWP/js/back-end/template.options.js index f3501a9..907d749 100644 --- a/MeetGavernWP/js/back-end/template.options.js +++ b/MeetGavernWP/js/back-end/template.options.js @@ -5,381 +5,390 @@ * ------------------------------------------- * **/ +(function () { + "use strict"; -/** - * jQuery Cookie plugin - * - * Copyright (c) 2010 Klaus Hartl (stilbuero.de) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - */ -jQuery.cookie = function (key, value, options) { + /** + * jQuery Cookie plugin + * + * Copyright (c) 2010 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + jQuery.cookie = function (key, value, options) { + + // key and at least value given, set cookie... + if (arguments.length > 1 && String(value) !== "[object Object]") { + options = jQuery.extend({}, options); + + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, + t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', + options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); + } + + // key and possibly options given, get cookie... + options = value || {}; + var result, decode = options.raw ? function (s) { + return s; + } : decodeURIComponent; + return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; + }; + + // ID of the upload field + var uploadID = ''; + // common functions and objects + // + var gkValidation = []; + var gkValidationResults = []; + var gkValidationResultsTabs = []; + var gkVisibility = {}; + var gkVisibilityDependicies = {}; + // + jQuery(document).ready(function () { + // tabs + jQuery('#gkTabs li').each(function (i, el) { + var item = jQuery(el); + item.click(function () { + jQuery('#gkTabs li').removeClass('active'); + jQuery('#gkTabsContent > div').removeClass('active'); + + item.addClass('active'); + jQuery(jQuery('#gkTabsContent > div')[i]).addClass('active'); + // save the cookie with the active tab + jQuery.cookie(jQuery('#gkMainWrap').attr('data-theme') + '_active_tab', i, { + expires: 365, + path: '/' + }); + }); + }); + // initialize Media uploaders + gkMediaInit(); + // initialize validation + gkValidateInit(); + // initialize visualisation + gkVisibilityInit(); + // add mini tips + var fields = jQuery('#gkTabsContent').find('.gkInput'); + + fields.each(function (i, field) { + field = jQuery(field); + field.prev('label').miniTip(); + }); + // saving the settings + jQuery('.gkSave').each(function (i, button) { + jQuery(button).click(function (event) { + event.preventDefault(); + + if (gkValidate()) { + // save the settings + var data = { + action: 'template_save', + security: $gk_ajax_nonce + }; + + var fields = jQuery('#gkTabsContent').find('.gkInput'); + + fields.each(function (i, field) { + field = jQuery(field); + if (field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) { + data[field.attr('id')] = field.find('option:selected').val(); + } else { + data[field.attr('id')] = field.val(); + } + }); + // make an effect ;) + jQuery('#gkTabsContent').find('.active').find('.gkAjaxLoading').css('opacity', 1); + jQuery(event.target).html(jQuery(event.target).attr('data-loading')); + // make a request + jQuery.post(ajaxurl, data, function (response) { + if (response === '0') { + jQuery(event.target).html('You\'re not logged in. Settings wasn\'t saved'); + } else { + jQuery(event.target).html(response); + } + jQuery('#gkTabsContent').find('.active').find('.gkAjaxLoading').css('opacity', 0); + setTimeout(function () { + jQuery(event.target).html(jQuery(event.target).attr('data-loaded')); + }, 2500); + }); + } else { + jQuery(event.target).html(jQuery(event.target).attr('data-wrong')); + setTimeout(function () { + jQuery(event.target).html(jQuery(event.target).attr('data-loaded')); + }, 2500); + } + }); + }); + + if (jQuery('#gk-load-settings').length) { + jQuery('#gk-load-settings').click(function () { + window.location.href += '&task=load_widgets'; + }); + + jQuery('#gk-cancel-settings').click(function () { + window.location.href += '&task=notload_widgets'; + }); + } + }); + // function to init the validation rules + + function gkValidateInit() { + jQuery('#gkTabsContent > div').each(function (i, tab) { + gkValidation[i] = []; + gkValidationResults[i] = []; + gkValidationResultsTabs[i] = true; + + var fields = jQuery(tab).find('.gkInput'); + + fields.each(function (j, field) { + var data = { + 'type': 'text', + 'format': '', + 'required': '' + }; + field = jQuery(field); + + if (field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) { + data.type = 'select'; + field.blur(function () { + gkValidateField(field, 'select'); + gkVisibilityField(field, 'select'); + }); + field.change(function () { + gkValidateField(field, 'select'); + gkVisibilityField(field, 'select'); + }); + } else { + field.blur(function () { + gkValidateField(field, 'text'); + gkVisibilityField(field, 'text'); + }); + } + data.format = (field.attr('data-format') !== '') ? new RegExp(field.attr('data-format')) : ''; + data.required = field.attr('data-required'); + gkValidation[i][j] = data; + gkValidationResults[i][j] = []; + }); + }); + } + // function to validate + + function gkValidate() { + // validate + jQuery(gkValidation).each(function (i, fields) { + var allFields = jQuery(jQuery('#gkTabsContent > div')[i]).find('.gkInput'); + gkValidationResultsTabs[i] = true; + + jQuery(fields).each(function (j, field) { + var value = field.type === 'select' ? jQuery(allFields[j]).find('option:selected').val() : jQuery(allFields[j]).val(); + var data = gkValidation[i][j]; + gkValidationResults[i][j] = []; - // key and at least value given, set cookie... - if (arguments.length > 1 && String(value) !== "[object Object]") { - options = jQuery.extend({}, options); + if (data.required === 'true' && jQuery(allFields[j]).get('data-visible') === 'true' && !value) { + gkValidationResults[i][j].push('required'); + gkValidationResultsTabs[i] = false; + } - if (value === null || value === undefined) { - options.expires = -1; + if (data.format !== '' && jQuery(allFields[j]).attr('data-visible') === 'true' && !value.match(data.format)) { + gkValidationResults[i][j].push('format'); + gkValidationResultsTabs[i] = false; + } + }); + }); + // change elements basic on the results + var result = true; + + jQuery(gkValidationResultsTabs).each(function (i, tabCorrect) { + if (tabCorrect) { + jQuery(jQuery('#gkTabs li')[i]).removeClass('wrong'); + } else { + jQuery(jQuery('#gkTabs li')[i]).addClass('wrong'); + result = false; + } + }); + // validate all fields + var fields = jQuery('#gkTabsContent').find('.gkInput'); + + fields.each(function (i, field) { + field = jQuery(field); + gkValidateField(field, (field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) ? 'select' : 'text'); + }); + + // return the result + return result; + } + // function to validate one field + + function gkValidateField(field, type) { + var value = (type === 'select') ? field.find('option:selected').val() : field.val(); + var format = (field.attr('data-format') !== '') ? new RegExp(field.attr('data-format')) : ''; + var required = field.attr('data-required'); + var visibility = field.attr('data-visible'); + + field.removeClass('wrong-format'); + field.removeClass('wrong-required'); + + if (required === 'true' && visibility === 'true' && !value) { + field.addClass('wrong-required'); } - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); + if (format !== '' && visibility === 'true' && !value.match(format)) { + field.addClass('wrong-format'); } + // check the tabs + jQuery('#gkTabsContent > div').each(function (i, tab) { + var wrongFormat = jQuery(tab).find('.wrong-format'); + var wrongRequired = jQuery(tab).find('.wrong-required'); + + if (wrongFormat.length === 0 && wrongRequired.length === 0) { + if (jQuery(jQuery('#gkTabs li')[i]).hasClass('wrong')) { + jQuery(jQuery('#gkTabs li')[i]).removeClass('wrong'); + } + } else { + if (!jQuery(jQuery('#gkTabs li')[i]).hasClass('wrong')) { + jQuery(jQuery('#gkTabs li')[i]).addClass('wrong'); + } + } + }); + } + // + + function gkVisibilityInit() { + var allFields = jQuery('#gkTabsContent').find('.gkInput'); + // + allFields.each(function (i, field) { + var visibility = jQuery(field).attr('data-visibility'); + + if (visibility !== '') { + var tempVisibilityRules = visibility.split(','); + + for (var j = 0; j < tempVisibilityRules.length; j++) { + tempVisibilityRules[j] = tempVisibilityRules[j].split('='); + + tempVisibilityRules[j] = { + "field": tempVisibilityRules[j][0], + "value": tempVisibilityRules[j][1] + }; - value = String(value); + var visible = jQuery(field).attr('id'); - return (document.cookie = [ - encodeURIComponent(key), '=', - options.raw ? value : encodeURIComponent(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); + if (typeof gkVisibilityDependicies[visible] !== "object") { + gkVisibilityDependicies[visible] = [tempVisibilityRules[j]]; + } else { + gkVisibilityDependicies[visible].push(tempVisibilityRules[j]); + } + } + + var visibilityRules = jQuery(field).attr('data-visibility').split(','); + + for (var k = 0; k < visibilityRules.length; k++) { + visibilityRules[k] = visibilityRules[k].split('='); + var usedField = visibilityRules[k][0]; + var tempField = jQuery('*[data-name=' + usedField + ']'); + var type = (tempField.hasClass('gkSwitcher') || tempField.hasClass('gkSelect')) ? 'select' : 'text'; + + visibilityRules[k] = { + "type": type, + "visible": jQuery(field).attr('id') + }; + + if (typeof gkVisibility[usedField] !== "object") { + gkVisibility[usedField] = [visibilityRules[k]]; + } else { + gkVisibility[usedField].push(visibilityRules[k]); + } + } + } + }); + // + allFields.each(function (i, field) { + gkVisibilityField(jQuery(field)); + }); } + // + function gkVisibilityField(field) { + // + if (gkVisibility[field.attr('data-name')]) { + // + var dependencies = gkVisibility[field.attr('data-name')]; + // + for (var i = 0; i < dependencies.length; i++) { + var dependsFrom = gkVisibilityDependicies[dependencies[i].visible]; + var flag = 'true'; - // key and possibly options given, get cookie... - options = value || {}; - var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; - return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; -}; - -// ID of the upload field -var uploadID = ''; -// common functions and objects -function isNumber(n) { - return !isNaN(parseFloat(n)) && isFinite(n); -} -// -gkValidation = []; -gkValidationResults = []; -gkValidationResultsTabs = []; -gkVisibility = {}; -gkVisibilityDependicies = {}; -// -jQuery(document).ready(function() { - // tabs - jQuery('#gkTabs li').each(function(i,el){ - var item = jQuery(el); - item.click(function() { - jQuery('#gkTabs li').removeClass('active'); - jQuery('#gkTabsContent > div').removeClass('active'); - - item.addClass('active'); - jQuery(jQuery('#gkTabsContent > div')[i]).addClass('active'); - // save the cookie with the active tab - jQuery.cookie(jQuery('#gkMainWrap').attr('data-theme')+'_active_tab', i, { expires: 365, path: '/' }); - }); - }); - // initialize Media uploaders - gkMediaInit(); - // initialize validation - gkValidateInit(); - // initialize visualisation - gkVisibilityInit(); - // add mini tips - var fields = jQuery('#gkTabsContent').find('.gkInput'); - - fields.each(function(i, field) { - var field = jQuery(field); - field.prev('label').miniTip(); - }); - // saving the settings - jQuery('.gkSave').each(function(i, button) { - jQuery(button).click(function(event) { - event.preventDefault(); - - if(gkValidate()) { - // save the settings - var data = { - action: 'template_save', - security: $gk_ajax_nonce - }; - - var fields = jQuery('#gkTabsContent').find('.gkInput'); - - fields.each(function(i, field) { - var field = jQuery(field); - if(field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) { - data[field.attr('id')] = field.find('option:selected').val(); - } else { - data[field.attr('id')] = field.val(); - } - }); - // make an effect ;) - jQuery('#gkTabsContent').find('.active').find('.gkAjaxLoading').css('opacity', 1); - jQuery(event.target).html(jQuery(event.target).attr('data-loading')); - // make a request - jQuery.post(ajaxurl, data, function(response) { - if(response == '0') { - jQuery(event.target).html('You\'re not logged in. Settings wasn\'t saved'); - } else { - jQuery(event.target).html(response); - } - jQuery('#gkTabsContent').find('.active').find('.gkAjaxLoading').css('opacity', 0); - setTimeout(function() { - jQuery(event.target).html(jQuery(event.target).attr('data-loaded')); - }, 2500); - }); - } else { - jQuery(event.target).html(jQuery(event.target).attr('data-wrong')); - setTimeout(function() { - jQuery(event.target).html(jQuery(event.target).attr('data-loaded')); - }, 2500); - } - }); - }); - - if(jQuery('#gk-load-settings').length) { - jQuery('#gk-load-settings').click(function() { - window.location.href += '&task=load_widgets'; - }); - - jQuery('#gk-cancel-settings').click(function() { - window.location.href += '&task=notload_widgets'; - }); - } -}); -// function to init the validation rules -function gkValidateInit() { - jQuery('#gkTabsContent > div').each(function(i, tab) { - gkValidation[i] = []; - gkValidationResults[i] = []; - gkValidationResultsTabs[i] = true; - - var fields = jQuery(tab).find('.gkInput'); - - fields.each(function(j, field) { - var data = { - 'type': 'text', - 'format': '', - 'required': '' - }; - var field = jQuery(field); - - if(field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) { - data.type = 'select'; - field.blur(function() { - gkValidateField(field, 'select'); - gkVisibilityField(field, 'select'); - }); - field.change(function() { - gkValidateField(field, 'select'); - gkVisibilityField(field, 'select'); - }); - } else { - field.blur(function() { - gkValidateField(field, 'text'); - gkVisibilityField(field, 'text'); - }); - } - data.format = (field.attr('data-format') != '') ? new RegExp(field.attr('data-format')) : ''; - data.required = field.attr('data-required'); - gkValidation[i][j] = data; - gkValidationResults[i][j] = []; - }); - }); -} -// function to validate -function gkValidate() { - // validate - jQuery(gkValidation).each(function(i, fields) { - var allFields = jQuery(jQuery('#gkTabsContent > div')[i]).find('.gkInput'); - gkValidationResultsTabs[i] = true; - - jQuery(fields).each(function(j, field) { - var value = field.type == 'select' ? jQuery(allFields[j]).find('option:selected').val() : jQuery(allFields[j]).val(); - var data = gkValidation[i][j]; - gkValidationResults[i][j] = []; - - if(data.required == 'true' && jQuery(allFields[j]).get('data-visible') == 'true' && !value) { - gkValidationResults[i][j].push('required'); - gkValidationResultsTabs[i] = false; - } - - if(data.format != '' && jQuery(allFields[j]).attr('data-visible') == 'true' && !value.match(data.format)) { - gkValidationResults[i][j].push('format'); - gkValidationResultsTabs[i] = false; - } - }); - }); - // change elements basic on the results - var result = true; - - jQuery(gkValidationResultsTabs).each(function(i, tabCorrect) { - if(tabCorrect) { - jQuery(jQuery('#gkTabs li')[i]).removeClass('wrong'); - } else { - jQuery(jQuery('#gkTabs li')[i]).addClass('wrong'); - result = false; - } - }); - // validate all fields - var fields = jQuery('#gkTabsContent').find('.gkInput'); - - fields.each(function(i, field) { - var field = jQuery(field); - gkValidateField(field, (field.hasClass('gkSwitcher') || field.hasClass('gkSelect')) ? 'select' : 'text'); - }); - - // return the result - return result; -} -// function to validate one field -function gkValidateField(field, type) { - var value = (type == 'select') ? field.find('option:selected').val() : field.val(); - var format = (field.attr('data-format') != '') ? new RegExp(field.attr('data-format')) : ''; - var required = field.attr('data-required'); - var visibility = field.attr('data-visible'); - - field.removeClass('wrong-format'); - field.removeClass('wrong-required'); - - if(required == 'true' && visibility == 'true' && !value) { - field.addClass('wrong-required'); - } - - if(format != '' && visibility == 'true' && !value.match(format)) { - field.addClass('wrong-format'); - } - // check the tabs - jQuery('#gkTabsContent > div').each(function(i, tab) { - var wrongFormat = jQuery(tab).find('.wrong-format'); - var wrongRequired = jQuery(tab).find('.wrong-required'); - - if(wrongFormat.length == 0 && wrongRequired.length == 0) { - if(jQuery(jQuery('#gkTabs li')[i]).hasClass('wrong')) { - jQuery(jQuery('#gkTabs li')[i]).removeClass('wrong'); - } - } else { - if(!jQuery(jQuery('#gkTabs li')[i]).hasClass('wrong')) { - jQuery(jQuery('#gkTabs li')[i]).addClass('wrong'); - } - } - }); -} -// -function gkVisibilityInit() { - var allFields = jQuery('#gkTabsContent').find('.gkInput'); - // - allFields.each(function(i, field) { - var visibility = jQuery(field).attr('data-visibility'); - - if(visibility != '') { - var tempVisibilityRules = visibility.split(','); - - for(var j = 0; j < tempVisibilityRules.length; j++) { - tempVisibilityRules[j] = tempVisibilityRules[j].split('='); - - tempVisibilityRules[j] = { - "field": tempVisibilityRules[j][0], - "value": tempVisibilityRules[j][1] - }; - - var visible = jQuery(field).attr('id'); - - if(typeof gkVisibilityDependicies[visible] !== "object") { - gkVisibilityDependicies[visible] = [tempVisibilityRules[j]]; - } else { - gkVisibilityDependicies[visible].push(tempVisibilityRules[j]); - } - } - - var visibilityRules = jQuery(field).attr('data-visibility').split(','); - - for(var j = 0; j < visibilityRules.length; j++) { - visibilityRules[j] = visibilityRules[j].split('='); - var usedField = visibilityRules[j][0]; - var tempField = jQuery('*[data-name='+usedField+']'); - var type = (tempField.hasClass('gkSwitcher') || tempField.hasClass('gkSelect')) ? 'select' : 'text'; - - visibilityRules[j] = { - "type": type, - "visible": jQuery(field).attr('id') - }; - - if(typeof gkVisibility[usedField] !== "object") { - gkVisibility[usedField] = [visibilityRules[j]]; - } else { - gkVisibility[usedField].push(visibilityRules[j]); - } - } - } - }); - // - allFields.each(function(i, field) { - gkVisibilityField(jQuery(field)); - }); -} -// -function gkVisibilityField(field) { - // - if(gkVisibility[field.attr('data-name')]) { - // - var dependencies = gkVisibility[field.attr('data-name')]; - // - for(var i = 0; i < dependencies.length; i++) { - var dependsFrom = gkVisibilityDependicies[dependencies[i].visible]; - var flag = 'true'; - - for(var j = 0; j < dependsFrom.length; j++) { - var type = gkVisibility[dependsFrom[j].field].type; - var field = jQuery('*[data-name='+dependsFrom[j].field+']'); - var value = (type == 'select') ? field.find('option:selected').val() : field.val(); - - if(value != dependsFrom[j].value) { - flag = 'false'; - } - } - - jQuery('#' + dependencies[i].visible).parent('p').attr('data-visible', flag); - } - } -} -// -function gkMediaInit() { - // image uploaders - jQuery('.gkMediaInput').each( - function(i, el) { - el = jQuery(el); - var btnid = el.attr('id') + '_button'; - - jQuery('#'+btnid).click(function() { - uploadID = jQuery(this).prev('input'); - formfield = jQuery(this).prev('input').attr('name'); - tb_show('', 'media-upload.php?type=image&TB_iframe=true'); - - return false; - }); - - el.change(function() { - if(el.val() == '') { - var span = el.parent().find('.gkMediaPreview'); - span.html(span.attr('data-text')); - } else { - el.parent().find('.gkMediaPreview').html('Preview'); - } - }); - - el.blur(function() { - if(el.val() == '') { - var span = el.parent().find('.gkMediaPreview'); - span.html(span.attr('data-text')); - } else { - el.parent().find('.gkMediaPreview').html('Preview'); - } - }); - } - ); -} -// -window.send_to_editor = function(html) { - imgurl = jQuery('img', html).attr('src'); - uploadID.val(imgurl); - uploadID.parent().find('.gkMediaPreview').html('Preview'); - tb_remove(); -} \ No newline at end of file + for (var j = 0; j < dependsFrom.length; j++) { + var type = gkVisibility[dependsFrom[j].field].type; + field = jQuery('*[data-name=' + dependsFrom[j].field + ']'); + var value = (type === 'select') ? field.find('option:selected').val() : field.val(); + + if (value !== dependsFrom[j].value) { + flag = 'false'; + } + } + + jQuery('#' + dependencies[i].visible).parent('p').attr('data-visible', flag); + } + } + } + // + function gkMediaInit() { + // image uploaders + jQuery('.gkMediaInput').each( + function (i, el) { + el = jQuery(el); + var btnid = el.attr('id') + '_button'; + + jQuery('#' + btnid).click(function () { + uploadID = jQuery(this).prev('input'); + tb_show('', 'media-upload.php?type=image&TB_iframe=true'); + + return false; + }); + + el.change(function () { + if (el.val() === '') { + var span = el.parent().find('.gkMediaPreview'); + span.html(span.attr('data-text')); + } else { + el.parent().find('.gkMediaPreview').html('Preview'); + } + }); + + el.blur(function () { + if (el.val() === '') { + var span = el.parent().find('.gkMediaPreview'); + span.html(span.attr('data-text')); + } else { + el.parent().find('.gkMediaPreview').html('Preview'); + } + }); + } + ); + } + // + window.send_to_editor = function (html) { + var imgurl = jQuery('img', html).attr('src'); + uploadID.val(imgurl); + uploadID.parent().find('.gkMediaPreview').html('Preview'); + tb_remove(); + }; +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/back-end/updates.options.js b/MeetGavernWP/js/back-end/updates.options.js index 2ef5555..9321773 100644 --- a/MeetGavernWP/js/back-end/updates.options.js +++ b/MeetGavernWP/js/back-end/updates.options.js @@ -5,48 +5,56 @@ * ------------------------------------------- * **/ - +(function () { + "use strict"; -jQuery(document).ready(function() { - var update_url = 'https://www.gavick.com/updates/json/tmpl,component/query,product/product,' + $GK_TEMPLATE_UPDATE_NAME; - var update_div = jQuery('#gkTemplateUpdates'); - update_div.html('
Loading update data from GavicPro Update service...
'); - - jQuery.getScript(update_url, function(data, textStatus, jqxhr) { - var content = ''; - - var templateVersion = $GK_TEMPLATE_UPDATE_VERSION.split('.'); - jQuery.map(templateVersion, function(version, i) { return parseInt(version); }); - - jQuery($GK_UPDATE).each(function(i, el){ - - var updateVersion = el.version.split('.'); - jQuery.map(updateVersion, function(version, i) { return parseInt(version); }); - var isNewer = false; - - if(updateVersion[0] > templateVersion[0]) { - isNewer = true; - } else if(updateVersion[0] >= templateVersion[0] && updateVersion[1] > templateVersion[1]) { - isNewer = true; - } else if(updateVersion.length > 2) { - if(templateVersion.length > 2) { - if(updateVersion[0] >= templateVersion[0] && updateVersion[1] >= templateVersion[1] && updateVersion[2] > templateVersion[2]) { - isNewer = true; - } - } else { - isNewer = true; - } - } - // - if(isNewer) { - content += '
  • Version: ' + el.version + ' Date: ' + el.date + ' Download
  • '; - } - }); - - update_div.html('
      ' + content + '
    '); - - if(update_div.html() == '
      ') { - update_div.html('

      Your template is up to date

      '); - } - }); -}); \ No newline at end of file + jQuery(document).ready(function () { + var update_url = 'https://www.gavick.com/updates/json/tmpl,component/query,product/product,' + $GK_TEMPLATE_UPDATE_NAME; + var update_div = jQuery('#gkTemplateUpdates'); + update_div.html('
      Loading update data from GavicPro Update service...
      '); + + jQuery.getScript(update_url, function () { + var content = ''; + + var templateVersion = $GK_TEMPLATE_UPDATE_VERSION.split('.'); + + jQuery.map(templateVersion, function (version) { + return parseInt(version, 10); + }); + + jQuery($GK_UPDATE).each(function (i, el) { + var updateVersion = el.version.split('.'); + jQuery.map(updateVersion, function (version) { + return parseInt(version, 10); + }); + var isNewer = false; + + if (updateVersion[0] > templateVersion[0]) { + isNewer = true; + } else if (updateVersion[0] >= templateVersion[0] && updateVersion[1] > templateVersion[1]) { + isNewer = true; + } else if (updateVersion.length > 2) { + if (templateVersion.length > 2) { + if (updateVersion[0] >= templateVersion[0] && updateVersion[1] >= templateVersion[1] && updateVersion[2] > templateVersion[2]) { + isNewer = true; + } + } else { + if (updateVersion[0] >= templateVersion[0] && updateVersion[1] >= templateVersion[1] && updateVersion[2] > 0) { + isNewer = true; + } + } + } + // + if (isNewer) { + content += '
    • Version: ' + el.version + ' Date: ' + el.date + ' Download
    • '; + } + }); + + update_div.html('
        ' + content + '
      '); + + if (update_div.html() === '
        ') { + update_div.html('

        Your template is up to date

        '); + } + }); + }); +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/back-end/widget.rules.js b/MeetGavernWP/js/back-end/widget.rules.js index 459e147..1889231 100644 --- a/MeetGavernWP/js/back-end/widget.rules.js +++ b/MeetGavernWP/js/back-end/widget.rules.js @@ -5,6 +5,8 @@ * ------------------------------------------- * **/ + +"use strict"; /** * jQuery Cookie plugin @@ -17,241 +19,256 @@ */ jQuery.cookie = function (key, value, options) { -    // key and at least value given, set cookie... -    if (arguments.length > 1 && String(value) !== "[object Object]") { -        options = jQuery.extend({}, options); - -        if (value === null || value === undefined) { -            options.expires = -1; -        } - -        if (typeof options.expires === 'number') { -            var days = options.expires, t = options.expires = new Date(); -            t.setDate(t.getDate() + days); -        } - -        value = String(value); - -        return (document.cookie = [ -            encodeURIComponent(key), '=', -            options.raw ? value : encodeURIComponent(value), -            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE -            options.path ? '; path=' + options.path : '', -            options.domain ? '; domain=' + options.domain : '', -            options.secure ? '; secure' : '' -        ].join('')); -    } - -    // key and possibly options given, get cookie... -    options = value || {}; -    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; -    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; +      // key and at least value given, set cookie... +      + if (arguments.length > 1 && String(value) !== "[object Object]") {         + options = jQuery.extend({}, options); + +          + if (value === null || value === undefined) {             + options.expires = -1;         + } + +          + if (typeof options.expires === 'number') {             + var days = options.expires, + t = options.expires = new Date();             + t.setDate(t.getDate() + days);         + } + +          + value = String(value); + +          + return (document.cookie = [            encodeURIComponent(key), '=',             options.raw ? value : encodeURIComponent(value),             options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE +             options.path ? '; path=' + options.path : '',             options.domain ? '; domain=' + options.domain : '',             options.secure ? '; secure' : ''         + ].join(''));     + } + +      // key and possibly options given, get cookie... +      + options = value || {};     + var result, decode = options.raw ? function (s) { + return s; + } : decodeURIComponent;     + return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; }; // remove active state from any widget rules wrapper on the start to avoid // the situation when some wrapper is opened earlier due saved data in the cookie file. -jQuery(window).on('beforeunload', function() { - jQuery.cookie('gk_last_opened_widget_rules_wrap', 0, { expires: 365, path: '/' }); +jQuery(window).on('beforeunload', function () { + jQuery.cookie('gk_last_opened_widget_rules_wrap', 0, { + expires: 365, + path: '/' + }); }); // added event to open the widget rules wrapper (uses id from the back-end wihout the random ID at end). -jQuery(document).click(function(e) { - if(jQuery(e.target).hasClass('gk_widget_rules_btn')) { - var wrap = jQuery(e.target).next('.gk_widget_rules_wrapper'); - - if(wrap.hasClass('active')) { - wrap.removeClass('active'); - jQuery.cookie('gk_last_opened_widget_rules_wrap', 0, { expires: 365, path: '/' }); - } else { - wrap.addClass('active'); - jQuery.cookie('gk_last_opened_widget_rules_wrap', wrap.attr('data-id'), { expires: 365, path: '/' }); - } - } +jQuery(document).click(function (e) { + if (jQuery(e.target).hasClass('gk_widget_rules_btn')) { + var wrap = jQuery(e.target).next('.gk_widget_rules_wrapper'); + + if (wrap.hasClass('active')) { + wrap.removeClass('active'); + jQuery.cookie('gk_last_opened_widget_rules_wrap', 0, { + expires: 365, + path: '/' + }); + } else { + wrap.addClass('active'); + jQuery.cookie('gk_last_opened_widget_rules_wrap', wrap.attr('data-id'), { + expires: 365, + path: '/' + }); + } + } }); function gk_widget_control_init(id, inner) { - // check if the widget isn't a new widget - var allForms = jQuery('.gk_widget_rules_form'); - var newest = null; - var flag = 0; - - if(!inner) { - for(var i = 0; i < allForms.length; i++) { - if('#' + jQuery(allForms[i]).attr('id') == id) { - newest = jQuery(allForms[i]); - flag += 1; - } - } - - if(flag > 1) { - newest.attr('id', newest.attr('id') + '-' + Math.floor((Math.random() * 10000 + 1))); - newest.attr('data-state', 'uninitialized'); - gk_widget_control_init('#' + newest.attr('id'), true); - return; - } - } - // if it is a new widget - if(inner) { - var mouseUpEvent = function() { - setTimeout(function() { - gk_widget_control_init_events(id, inner); - jQuery(document).unbind('mouseup', mouseUpEvent); - }, 250); - }; - - jQuery(document).bind('mouseup', mouseUpEvent); - } else { - gk_widget_control_init_events(id, inner); - } + // check if the widget isn't a new widget + var allForms = jQuery('.gk_widget_rules_form'); + var newest = null; + var flag = 0; + + if (!inner) { + for (var i = 0; i < allForms.length; i++) { + if ('#' + jQuery(allForms[i]).attr('id') === id) { + newest = jQuery(allForms[i]); + flag += 1; + } + } + + if (flag > 1) { + newest.attr('id', newest.attr('id') + '-' + Math.floor((Math.random() * 10000 + 1))); + newest.attr('data-state', 'uninitialized'); + gk_widget_control_init('#' + newest.attr('id'), true); + return; + } + } + // if it is a new widget + if (inner) { + var mouseUpEvent = function () { + setTimeout(function () { + gk_widget_control_init_events(id, inner); + jQuery(document).unbind('mouseup', mouseUpEvent); + }, 250); + }; + + jQuery(document).bind('mouseup', mouseUpEvent); + } else { + gk_widget_control_init_events(id, inner); + } } // function to init form event + function gk_widget_control_init_events(id, inner) { - var form = jQuery(id); - - if(inner) { - form.parent().find('select:last-child').css('opacity', '0.5'); - - setTimeout(function() { - var btn = form.parent().parent().parent().find('*[name="savewidget"]'); - btn.click(); - }, 1000); - } - - if(form.attr('data-state') !== 'initialized') { - form.attr('data-state', 'initialized'); - var firstSelect = form.parent().find('.gk_widget_rules_select'); - var select = form.children('.gk_widget_rules_form_select'); - var page = form.find('.gk_widget_rules_form_input_page').parent(); - var post = form.find('.gk_widget_rules_form_input_post').parent(); - var category = form.find('.gk_widget_rules_form_input_category').parent(); - var tag = form.find('.gk_widget_rules_form_input_tag').parent(); - var template = form.find('.gk_widget_rules_form_input_template').parent(); - var taxonomy = form.find('.gk_widget_rules_form_input_taxonomy').parent(); - var taxonomy_term = form.find('.gk_widget_rules_form_input_taxonomy_term').parent(); - var posttype = form.find('.gk_widget_rules_form_input_posttype').parent(); - //var format = form.find('.gk_widget_rules_form_input_format').parent(); - var author = form.find('.gk_widget_rules_form_input_author').parent(); - var btn = form.find('.gk_widget_rules_btn'); - // hide unnecesary form - if(firstSelect.children('option:selected').val() == 'all') { - form.css('display', 'none'); - } - // change event - firstSelect.change(function() { - var value = firstSelect.children('option:selected').val(); - - if(value == 'all') { - form.css('display', 'none'); - } else { - form.css('display', 'block'); - } - }); - // refresh the list - gk_widget_control_refresh(form); - // add onChange event to the selectbox - select.change(function() { - var value = select.children('option:selected').val() - - if(value == 'homepage' || value == 'page404' || value == 'search' || value == 'archive') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'page:') { - page.css('display', 'block'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'post:') { - page.css('display', 'none'); - post.css('display', 'block'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'category:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'block'); - tag.css('display', 'none'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'tag:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'block'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'author:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'block'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - posttype.css('display', 'none'); - } else if(value == 'template:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'block'); - posttype.css('display', 'none'); - } else if(value == 'taxonomy:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - taxonomy.css('display', 'block'); - taxonomy_term.css('display', 'block'); - posttype.css('display', 'none'); - } else if(value == 'posttype:') { - page.css('display', 'none'); - post.css('display', 'none'); - category.css('display', 'none'); - tag.css('display', 'none'); - author.css('display', 'none'); - //format.css('display', 'none'); - template.css('display', 'none'); - taxonomy.css('display', 'none'); - taxonomy_term.css('display', 'none'); - posttype.css('display', 'block'); - }/*else if(value == 'format:') { + var form = jQuery(id); + + if (inner) { + form.parent().find('select:last-child').css('opacity', '0.5'); + + setTimeout(function () { + var btn = form.parent().parent().parent().find('*[name="savewidget"]'); + btn.click(); + }, 1000); + } + + if (form.attr('data-state') !== 'initialized') { + form.attr('data-state', 'initialized'); + var firstSelect = form.parent().find('.gk_widget_rules_select'); + var select = form.children('.gk_widget_rules_form_select'); + var page = form.find('.gk_widget_rules_form_input_page').parent(); + var post = form.find('.gk_widget_rules_form_input_post').parent(); + var category = form.find('.gk_widget_rules_form_input_category').parent(); + var tag = form.find('.gk_widget_rules_form_input_tag').parent(); + var template = form.find('.gk_widget_rules_form_input_template').parent(); + var taxonomy = form.find('.gk_widget_rules_form_input_taxonomy').parent(); + var taxonomy_term = form.find('.gk_widget_rules_form_input_taxonomy_term').parent(); + var posttype = form.find('.gk_widget_rules_form_input_posttype').parent(); + //var format = form.find('.gk_widget_rules_form_input_format').parent(); + var author = form.find('.gk_widget_rules_form_input_author').parent(); + var btn = form.find('.gk_widget_rules_btn'); + // hide unnecesary form + if (firstSelect.children('option:selected').val() === 'all') { + form.css('display', 'none'); + } + // change event + firstSelect.change(function () { + var value = firstSelect.children('option:selected').val(); + + if (value === 'all') { + form.css('display', 'none'); + } else { + form.css('display', 'block'); + } + }); + // refresh the list + gk_widget_control_refresh(form); + // add onChange event to the selectbox + select.change(function () { + var value = select.children('option:selected').val(); + + if (value === 'homepage' || value === 'page404' || value === 'search' || value === 'archive') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'page:') { + page.css('display', 'block'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'post:') { + page.css('display', 'none'); + post.css('display', 'block'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'category:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'block'); + tag.css('display', 'none'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'tag:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'block'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'author:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'block'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + posttype.css('display', 'none'); + } else if (value === 'template:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'block'); + posttype.css('display', 'none'); + } else if (value === 'taxonomy:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + taxonomy.css('display', 'block'); + taxonomy_term.css('display', 'block'); + posttype.css('display', 'none'); + } else if (value === 'posttype:') { + page.css('display', 'none'); + post.css('display', 'none'); + category.css('display', 'none'); + tag.css('display', 'none'); + author.css('display', 'none'); + //format.css('display', 'none'); + template.css('display', 'none'); + taxonomy.css('display', 'none'); + taxonomy_term.css('display', 'none'); + posttype.css('display', 'block'); + } + /*else if(value === 'format:') { page.css('display', 'none'); post.css('display', 'none'); category.css('display', 'none'); @@ -260,156 +277,188 @@ function gk_widget_control_init_events(id, inner) { format.css('display', 'block'); template.css('display', 'none'); }*/ - }); - // add the onClick event to the button - btn.click(function(event) { - event.preventDefault(); - - var output = form.find('.gk_widget_rules_output'); - var value = select.children('option:selected').val() - - if(value == 'homepage') { - output.val(output.val() + ',homepage'); - } else if(value == 'search') { - output.val(output.val() + ',search'); - } else if(value == 'archive') { - output.val(output.val() + ',archive'); - } else if(value == 'page404') { - output.val(output.val() + ',page404'); - } else if(value == 'page:') { - output.val(output.val() + ',page:' + form.find('.gk_widget_rules_form_input_page').val()); - } else if(value == 'post:') { - output.val(output.val() + ',post:' + form.find('.gk_widget_rules_form_input_post').val()); - } else if(value == 'format:') { - output.val(output.val() + ',format:' + form.find('.gk_widget_rules_form_input_format').val()); - } else if(value == 'template:') { - output.val(output.val() + ',template:' + form.find('.gk_widget_rules_form_input_template').val()); - } else if(value == 'category:') { - output.val(output.val() + ',category:' + form.find('.gk_widget_rules_form_input_category').val()); - } else if(value == 'tag:') { - output.val(output.val() + ',tag:' + form.find('.gk_widget_rules_form_input_tag').val()); - } else if(value == 'taxonomy:') { - var tax = form.find('.gk_widget_rules_form_input_taxonomy').val(); - var term = form.find('.gk_widget_rules_form_input_taxonomy_term').val(); - // - if(term != '') { - output.val(output.val() + ',taxonomy:' + tax + ';' + term); - } else { - output.val(output.val() + ',taxonomy:' + tax); - } - } else if(value == 'posttype:') { - var type = form.find('.gk_widget_rules_form_input_posttype').val(); - // - if(type != '') { - output.val(output.val() + ',posttype:' + type); - } - } else if(value == 'author:') { - output.val(output.val() + ',author:' + form.find('.gk_widget_rules_form_input_author').val()); - } - - gk_widget_control_refresh(form); - }); - // event to remove the page tags - form.find('.gk_widget_rules_pages div').click(function(event) { - if(event.target.nodeName.toLowerCase() == 'strong') { - var output = form.find('.gk_widget_rules_output'); - var parent = jQuery(event.target).parent(); - parent.find('strong').remove(); - var text = parent.text(); - // - if(text == 'All pages') text = 'page:'; - else if(text == 'All posts pages') text = 'post:'; - else if(text== 'All category pages') text = 'category:'; - else if(text == 'All tag pages') text = 'tag:'; - else if(text == 'All author pages') text = 'author:'; - else if(text == 'All taxonomy pages') text = 'taxonomy:'; - else if(text == 'All post format pages') text = 'format:'; - else if(text == 'All page template pages') text = 'template:'; - // - if(text.indexOf(':') == text.length - 1) { - var startlen = output.val().length; - output.val(output.val().replace("," + text + ",", "")); - // if previous regexp didn't changed the value - if(startlen === output.val().length) { - var regex = new RegExp(',' + text + '$', 'gmi'); - output.val(output.val().replace(regex, "")); - } - } else { - output.val(output.val().replace("," + text, "")); - } - // - gk_widget_control_refresh(form); - } - }); - // event to display the custom CSS class field - var selectStyles = jQuery(document).find('.gk_widget_rules_select_styles'); - selectStyles.each(function(i, select) { - select = jQuery(select); - - if(!select.hasClass('initialized')) { - select.change(function() { - var value = select.children('option:selected').val(); - var field = select.parent().parent().next('p'); - - if(value != 'gkcustom') { - if(!field.hasClass('gk-unvisible')) { - field.addClass('gk-unvisible'); - } - } else { - if(field.hasClass('gk-unvisible')) { - field.removeClass('gk-unvisible'); - } - } - }); - - select.addClass('initialized'); - } - }); - } + }); + // add the onClick event to the button + btn.click(function (event) { + event.preventDefault(); + + var output = form.find('.gk_widget_rules_output'); + var value = select.children('option:selected').val(); + + if (value === 'homepage') { + output.val(output.val() + ',homepage'); + } else if (value === 'search') { + output.val(output.val() + ',search'); + } else if (value === 'archive') { + output.val(output.val() + ',archive'); + } else if (value === 'page404') { + output.val(output.val() + ',page404'); + } else if (value === 'page:') { + output.val(output.val() + ',page:' + form.find('.gk_widget_rules_form_input_page').val()); + } else if (value === 'post:') { + output.val(output.val() + ',post:' + form.find('.gk_widget_rules_form_input_post').val()); + } else if (value === 'format:') { + output.val(output.val() + ',format:' + form.find('.gk_widget_rules_form_input_format').val()); + } else if (value === 'template:') { + output.val(output.val() + ',template:' + form.find('.gk_widget_rules_form_input_template').val()); + } else if (value === 'category:') { + output.val(output.val() + ',category:' + form.find('.gk_widget_rules_form_input_category').val()); + } else if (value === 'tag:') { + output.val(output.val() + ',tag:' + form.find('.gk_widget_rules_form_input_tag').val()); + } else if (value === 'taxonomy:') { + var tax = form.find('.gk_widget_rules_form_input_taxonomy').val(); + var term = form.find('.gk_widget_rules_form_input_taxonomy_term').val(); + // + if (term !== '') { + output.val(output.val() + ',taxonomy:' + tax + ';' + term); + } else { + output.val(output.val() + ',taxonomy:' + tax); + } + } else if (value === 'posttype:') { + var type = form.find('.gk_widget_rules_form_input_posttype').val(); + // + if (type !== '') { + output.val(output.val() + ',posttype:' + type); + } + } else if (value === 'author:') { + output.val(output.val() + ',author:' + form.find('.gk_widget_rules_form_input_author').val()); + } + + gk_widget_control_refresh(form); + }); + // event to remove the page tags + form.find('.gk_widget_rules_pages div').click(function (event) { + if (event.target.nodeName.toLowerCase() === 'strong') { + var output = form.find('.gk_widget_rules_output'); + var parent = jQuery(event.target).parent(); + parent.find('strong').remove(); + var text = parent.text(); + // + if (text === 'All pages') { + text = 'page:'; + } else if (text === 'All posts pages') { + text = 'post:'; + } else if (text === 'All category pages') { + text = 'category:'; + } else if (text === 'All tag pages') { + text = 'tag:'; + } else if (text === 'All author pages') { + text = 'author:'; + } else if (text === 'All taxonomy pages') { + text = 'taxonomy:'; + } else if (text === 'All post format pages') { + text = 'format:'; + } else if (text === 'All page template pages') { + text = 'template:'; + } + // + if (text.indexOf(':') === text.length - 1) { + var startlen = output.val().length; + output.val(output.val().replace("," + text + ",", "")); + // if previous regexp didn't changed the value + if (startlen === output.val().length) { + var regex = new RegExp(',' + text + '$', 'gmi'); + output.val(output.val().replace(regex, "")); + } + } else { + output.val(output.val().replace("," + text, "")); + } + // + gk_widget_control_refresh(form); + } + }); + // event to display the custom CSS class field + var selectStyles = jQuery(document).find('.gk_widget_rules_select_styles'); + selectStyles.each(function (i, select) { + select = jQuery(select); + + if (!select.hasClass('initialized')) { + select.change(function () { + var value = select.children('option:selected').val(); + var field = select.parent().parent().next('p'); + + if (value !== 'gkcustom') { + if (!field.hasClass('gk-unvisible')) { + field.addClass('gk-unvisible'); + } + } else { + if (field.hasClass('gk-unvisible')) { + field.removeClass('gk-unvisible'); + } + } + }); + + select.addClass('initialized'); + } + }); + } } // function to refresh the list of pages + function gk_widget_control_refresh(form) { - var output = form.find('.gk_widget_rules_output'); - if(output.length > 0) { - var list = form.find('.gk_widget_rules_pages div'); - list.html(''); - var pages = output.val().split(','); - var pages_exist = false; - - for(var i = 0; i < pages.length; i++) { - if(pages[i] != '') { - pages_exist = true; - var type = 'homepage'; - - if(pages[i].substr(0,5) == 'page:') type = 'page'; - else if(pages[i].substr(0,5) == 'post:') type = 'post'; - else if(pages[i].substr(0,9) == 'category:') type = 'category'; - else if(pages[i].substr(0,4) == 'tag:') type = 'tag'; - else if(pages[i].substr(0,7) == 'archive') type = 'archive'; - else if(pages[i].substr(0,7) == 'author:') type = 'author'; - //else if(pages[i].substr(0,7) == 'format:') type = 'format'; - else if(pages[i].substr(0,9) == 'template:') type = 'template'; - else if(pages[i].substr(0,9) == 'taxonomy:') type = 'taxonomy'; - else if(pages[i].substr(0,9) == 'posttype:') type = 'posttype'; - else if(pages[i].substr(0,7) == 'page404') type = 'page404'; - else if(pages[i].substr(0,6) == 'search') type = 'search'; - - var out = pages[i]; - - if(out == 'page:') out = 'All pages'; - else if(out == 'post:') out = 'All posts pages'; - else if(out == 'category:') out = 'All category pages'; - else if(out == 'tag:') out = 'All tag pages'; - else if(out == 'author:') out = 'All author pages'; - else if(out == 'taxonomy:') out = 'All taxonomy pages'; - else if(out == 'format:') out = 'All post format pages'; - else if(out == 'template:') out = 'All page template pages'; - - list.html(list.html() + ""+out+"×"); - } - } - - form.find('.gk_widget_rules_nopages').css('display', pages_exist ? 'none' : 'block'); - } -} + var output = form.find('.gk_widget_rules_output'); + if (output.length > 0) { + var list = form.find('.gk_widget_rules_pages div'); + list.html(''); + var pages = output.val().split(','); + var pages_exist = false; + + for (var i = 0; i < pages.length; i++) { + if (pages[i] !== '') { + pages_exist = true; + var type = 'homepage'; + + if (pages[i].substr(0, 5) === 'page:') { + type = 'page'; + } else if (pages[i].substr(0, 5) === 'post:') { + type = 'post'; + } else if (pages[i].substr(0, 9) === 'category:') { + type = 'category'; + } else if (pages[i].substr(0, 4) === 'tag:') { + type = 'tag'; + } else if (pages[i].substr(0, 7) === 'archive') { + type = 'archive'; + } else if (pages[i].substr(0, 7) === 'author:') { + type = 'author'; + } + //else if(pages[i].substr(0,7) === 'format:') { type = 'format'; } + else if (pages[i].substr(0, 9) === 'template:') { + type = 'template'; + } else if (pages[i].substr(0, 9) === 'taxonomy:') { + type = 'taxonomy'; + } else if (pages[i].substr(0, 9) === 'posttype:') { + type = 'posttype'; + } else if (pages[i].substr(0, 7) === 'page404') { + type = 'page404'; + } else if (pages[i].substr(0, 6) === 'search') { + type = 'search'; + } + + var out = pages[i]; + + if (out === 'page:') { + out = 'All pages'; + } else if (out === 'post:') { + out = 'All posts pages'; + } else if (out === 'category:') { + out = 'All category pages'; + } else if (out === 'tag:') { + out = 'All tag pages'; + } else if (out === 'author:') { + out = 'All author pages'; + } else if (out === 'taxonomy:') { + out = 'All taxonomy pages'; + } else if (out === 'format:') { + out = 'All post format pages'; + } else if (out === 'template:') { + out = 'All page template pages'; + } + + list.html(list.html() + "" + out + "×"); + } + } + + form.find('.gk_widget_rules_nopages').css('display', pages_exist ? 'none' : 'block'); + } +} \ No newline at end of file From 684a05e50ab6a56bee8eded6c7d8a58fe7e9e7a0 Mon Sep 17 00:00:00 2001 From: dziudek Date: Sat, 13 Jul 2013 11:39:02 +0200 Subject: [PATCH 06/25] JSHint and JSprettifier used in the other JS files --- MeetGavernWP/js/gk.menu.js | 383 +++++++------- MeetGavernWP/js/gk.scripts.js | 243 ++++----- MeetGavernWP/js/shortcodes.elements.js | 31 +- MeetGavernWP/js/shortcodes.template.js | 7 +- MeetGavernWP/js/templates/gallery.js | 116 ++--- MeetGavernWP/js/widgets/nsp.js | 659 +++++++++++++------------ MeetGavernWP/js/widgets/tabs.js | 209 ++++---- 7 files changed, 848 insertions(+), 800 deletions(-) diff --git a/MeetGavernWP/js/gk.menu.js b/MeetGavernWP/js/gk.menu.js index c28d8c8..00be943 100644 --- a/MeetGavernWP/js/gk.menu.js +++ b/MeetGavernWP/js/gk.menu.js @@ -5,190 +5,199 @@ * ------------------------------------------- * **/ - - -jQuery(document).ready(function() { - if(jQuery(window).width() > jQuery(document.body).attr('data-tablet-width')) { - if(jQuery('#main-menu')) { - // fix for the iOS devices - jQuery('#main-menu li').each(function(i, el) { - - if(jQuery(el).children('.sub-menu').length > 0) { - jQuery(el).addClass('haschild') - } - }); - // main element for the iOS fix - adding the onmouseover attribute - // and binding with the data-dblclick property to emulate dblclick event on - // the mobile devices - jQuery('#main-menu li a').each(function(i, el) { - el = jQuery(el); - - el.attr('onmouseover', ''); - - if(el.parent().hasClass('haschild') && jQuery(document.body).attr('data-tablet') != null) { - el.click(function(e) { - if(el.attr("data-dblclick") == undefined) { - e.stop(); - el.attr("data-dblclick", new Date().getTime()); - } else { - var now = new Date().getTime(); - if(now - el.attr("data-dblclick") < 500) { - window.location = el.attr('href'); - } else { - e.stop(); - el.attr("data-dblclick", new Date().getTime()); - } - } - }); - } - }); - // main menu element handler - var base = jQuery('#main-menu'); - // if the main menu exists - if(base.length > 0) { - // get the menu name... - var menuName = base.attr('id').replace('-', ''); - // ... used to get the menu params - if( - $GK_MENU[menuName] && - ( - $GK_MENU[menuName]['animation'].indexOf('height') != -1 || - $GK_MENU[menuName]['animation'].indexOf('width') != -1 || - $GK_MENU[menuName]['animation'].indexOf('opacity') != -1 - ) - ) { - base.find('li.haschild').each(function(i, el){ - el = jQuery(el); - - if(el.children('.sub-menu').length > 0) { - var content = jQuery(el.children('.sub-menu').first()); - var prevh = content.height(); - var prevw = content.width(); - var heightAnim = $GK_MENU[menuName]['animation'].indexOf('height') != -1; - var widthAnim = $GK_MENU[menuName]['animation'].indexOf('width') != -1; - var duration = $GK_MENU[menuName]['animation_speed']; - - if(duration == 'normal') { - duration = 500; - } else if(duration == 'fast') { - duration = 250; - } else { - duration = 1000; - } - - var fxStart = { - 'height' : heightAnim ? 0 : prevh, - 'width' : widthAnim ? 0 : prevw, - 'opacity' : 0 - }; - var fxEnd = { - 'height' : prevh, - 'width' : prevw, - 'opacity' : 1 - }; - - content.css(fxStart); - content.css({'left' : 'auto', 'overflow' : 'hidden' }); - - el.mouseenter(function(){ - content.css('display', 'block'); - - if(content.attr('data-base-margin') != null) { - content.css({ - 'margin-left': content.attr('data-base-margin') + "px" - }); - } - - var pos = content.offset(); - var winWidth = jQuery(window).outerWidth(); - var winScroll = jQuery(window).scrollLeft(); - - if(pos.left + prevw > (winWidth + winScroll)) { - var diff = (winWidth + winScroll) - (pos.left + prevw) - 5; - var base = parseInt(content.css('margin-left')); - var margin = base + diff; - - if(base > 0) { - margin = -prevw + 10; - } - content.css('margin-left', margin + "px"); - - if(content.attr('data-base-margin') == null) { - content.attr('data-base-margin', base); - } - } - // - content.stop(false, false, false); - - content.animate( - fxEnd, - duration, - function() { - if(content.outerHeight() == 0){ - content.css('overflow', 'hidden'); - } else if( - content.outerHeight() - prevh < 30 && - content.outerHeight() - prevh >= 0 - ) { - content.css('overflow', 'visible'); - } - } - ); - }); - el.mouseleave(function(){ - content.css({ - 'overflow': 'hidden' - }); - // - content.animate( - fxStart, - duration, - function() { - if(content.outerHeight() == 0){ - content.css('overflow', 'hidden'); - } else if( - content.outerHeight() - prevh < 30 && - content.outerHeight() - prevh >= 0 - ) { - content.css('overflow', 'visible'); - } - - content.css('display', 'none'); - } - ); - }); - } - }); - - base.find('li.haschild').each(function(i, el) { - el = jQuery(el); - content = jQuery(el.children('.sub-menu').first()); - content.css({ 'display': 'none' }); - }); - } - } - } - } - // toggler - var menuwrap = jQuery('[data-btn="gk-mainmenu-toggle"]'); - - jQuery('#gk-mainmenu-toggle').click(function(e) { - e.preventDefault() - - if(menuwrap.hasClass('menu-hidden') || menuwrap.hasClass('menu-hide')) { - menuwrap.removeClass('menu-hidden'); - menuwrap.removeClass('menu-hide'); - menuwrap.addClass('menu-visible'); - menuwrap.css('height', '0px'); - menuwrap.animate({ - 'height': (jQuery(menuwrap.find('ul').get(0)).height() + 2) + "px" - }, 350); - } else { - menuwrap.removeClass('menu-visible'); - menuwrap.addClass('menu-hide'); - menuwrap.animate({ - 'height': 0 - }, 350); - } - }); -}); \ No newline at end of file +(function () { + "use strict"; + + jQuery(document).ready(function () { + if (jQuery(window).width() > jQuery(document.body).attr('data-tablet-width')) { + if (jQuery('#main-menu')) { + // fix for the iOS devices + jQuery('#main-menu li').each(function (i, el) { + + if (jQuery(el).children('.sub-menu').length > 0) { + jQuery(el).addClass('haschild'); + } + }); + // main element for the iOS fix - adding the onmouseover attribute + // and binding with the data-dblclick property to emulate dblclick event on + // the mobile devices + jQuery('#main-menu li a').each(function (i, el) { + el = jQuery(el); + + el.attr('onmouseover', ''); + + if (el.parent().hasClass('haschild') && jQuery(document.body).attr('data-tablet') !== null) { + el.click(function (e) { + if (el.attr("data-dblclick") === undefined) { + e.stop(); + el.attr("data-dblclick", new Date().getTime()); + } else { + var now = new Date().getTime(); + if (now - el.attr("data-dblclick") < 500) { + window.location = el.attr('href'); + } else { + e.stop(); + el.attr("data-dblclick", new Date().getTime()); + } + } + }); + } + }); + // main menu element handler + var base = jQuery('#main-menu'); + // if the main menu exists + if (base.length > 0) { + // get the menu name... + var menuName = base.attr('id').replace('-', ''); + // ... used to get the menu params + if ( + $GK_MENU[menuName] && + ( + $GK_MENU[menuName].animation.indexOf('height') !== -1 || + $GK_MENU[menuName].animation.indexOf('width') !== -1 || + $GK_MENU[menuName].animation.indexOf('opacity') !== -1 + ) + ) { + var content = false; + + base.find('li.haschild').each(function (i, el) { + el = jQuery(el); + + if (el.children('.sub-menu').length > 0) { + content = jQuery(el.children('.sub-menu').first()); + var prevh = content.height(); + var prevw = content.width(); + var heightAnim = $GK_MENU[menuName].animation.indexOf('height') !== -1; + var widthAnim = $GK_MENU[menuName].animation.indexOf('width') !== -1; + var duration = $GK_MENU[menuName].animation_speed; + + if (duration === 'normal') { + duration = 500; + } else if (duration === 'fast') { + duration = 250; + } else { + duration = 1000; + } + + var fxStart = { + 'height': heightAnim ? 0 : prevh, + 'width': widthAnim ? 0 : prevw, + 'opacity': 0 + }; + var fxEnd = { + 'height': prevh, + 'width': prevw, + 'opacity': 1 + }; + + content.css(fxStart); + content.css({ + 'left': 'auto', + 'overflow': 'hidden' + }); + + el.mouseenter(function () { + content.css('display', 'block'); + + if (content.attr('data-base-margin') !== null) { + content.css({ + 'margin-left': content.attr('data-base-margin') + "px" + }); + } + + var pos = content.offset(); + var winWidth = jQuery(window).outerWidth(); + var winScroll = jQuery(window).scrollLeft(); + + if (pos.left + prevw > (winWidth + winScroll)) { + var diff = (winWidth + winScroll) - (pos.left + prevw) - 5; + var base = parseInt(content.css('margin-left'), 10); + var margin = base + diff; + + if (base > 0) { + margin = -prevw + 10; + } + content.css('margin-left', margin + "px"); + + if (content.attr('data-base-margin') === null) { + content.attr('data-base-margin', base); + } + } + // + content.stop(false, false, false); + + content.animate( + fxEnd, + duration, + function () { + if (content.outerHeight() === 0) { + content.css('overflow', 'hidden'); + } else if ( + content.outerHeight() - prevh < 30 && + content.outerHeight() - prevh >= 0 + ) { + content.css('overflow', 'visible'); + } + } + ); + }); + el.mouseleave(function () { + content.css({ + 'overflow': 'hidden' + }); + // + content.animate( + fxStart, + duration, + function () { + if (content.outerHeight() === 0) { + content.css('overflow', 'hidden'); + } else if ( + content.outerHeight() - prevh < 30 && + content.outerHeight() - prevh >= 0 + ) { + content.css('overflow', 'visible'); + } + + content.css('display', 'none'); + } + ); + }); + } + }); + + base.find('li.haschild').each(function (i, el) { + el = jQuery(el); + content = jQuery(el.children('.sub-menu').first()); + content.css({ + 'display': 'none' + }); + }); + } + } + } + } + // toggler + var menuwrap = jQuery('[data-btn="gk-mainmenu-toggle"]'); + + jQuery('#gk-mainmenu-toggle').click(function (e) { + e.preventDefault(); + + if (menuwrap.hasClass('menu-hidden') || menuwrap.hasClass('menu-hide')) { + menuwrap.removeClass('menu-hidden'); + menuwrap.removeClass('menu-hide'); + menuwrap.addClass('menu-visible'); + menuwrap.css('height', '0px'); + menuwrap.animate({ + 'height': (jQuery(menuwrap.find('ul').get(0)).height() + 2) + "px" + }, 350); + } else { + menuwrap.removeClass('menu-visible'); + menuwrap.addClass('menu-hide'); + menuwrap.animate({ + 'height': 0 + }, 350); + } + }); + }); +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/gk.scripts.js b/MeetGavernWP/js/gk.scripts.js index 06705c1..98b1485 100644 --- a/MeetGavernWP/js/gk.scripts.js +++ b/MeetGavernWP/js/gk.scripts.js @@ -7,127 +7,142 @@ * http://www.gnu.org/licenses/gpl.html * */ -jQuery.cookie = function (key, value, options) { +(function () { + "use strict"; + jQuery.cookie = function (key, value, options) { - // key and at least value given, set cookie... - if (arguments.length > 1 && String(value) !== "[object Object]") { - options = jQuery.extend({}, options); + // key and at least value given, set cookie... + if (arguments.length > 1 && String(value) !== "[object Object]") { + options = jQuery.extend({}, options); - if (value === null || value === undefined) { - options.expires = -1; + if (value === null || value === undefined) { + options.expires = -1; + } + + if (typeof options.expires === 'number') { + var days = options.expires, + t = options.expires = new Date(); + t.setDate(t.getDate() + days); + } + + value = String(value); + + return (document.cookie = [ + encodeURIComponent(key), '=', + options.raw ? value : encodeURIComponent(value), + options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE + options.path ? '; path=' + options.path : '', + options.domain ? '; domain=' + options.domain : '', + options.secure ? '; secure' : '' + ].join('')); } - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); + // key and possibly options given, get cookie... + options = value || {}; + var result, decode = options.raw ? function (s) { + return s; + } : decodeURIComponent; + return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; + }; + + /** + * + * Template scripts + * + **/ + + // onDOMLoadedContent event + jQuery(document).ready(function () { + // Back to Top Scroll + jQuery('#gk-top-link').click(function () { + jQuery('body,html').animate({ + scrollTop: 0 + }, 800); + return false; + }); + // Thickbox use + jQuery(document).ready(function () { + if (typeof tb_init !== "undefined") { + tb_init('div.wp-caption a'); //pass where to apply thickbox + } + }); + // style area + if (jQuery('#gk-style-area')) { + jQuery('#gk-style-area div').each(function () { + jQuery(this).find('a').each(function () { + jQuery(this).click(function (e) { + e.stopPropagation(); + e.preventDefault(); + changeStyle(jQuery(this).attr('href').replace('#', '')); + }); + }); + }); } + // font-size switcher + if (jQuery('#gk-font-size') && jQuery('#gk-mainbody')) { + var current_fs = 100; + jQuery('#gk-mainbody').css('font-size', current_fs + "%"); - value = String(value); + jQuery('#gk-increment').click(function (e) { + e.stopPropagation(); + e.preventDefault(); - return (document.cookie = [ - encodeURIComponent(key), '=', - options.raw ? value : encodeURIComponent(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } + if (current_fs < 150) { + jQuery('#gk-mainbody').animate({ + 'font-size': (current_fs + 10) + "%" + }, 200); + current_fs += 10; + } + }); - // key and possibly options given, get cookie... - options = value || {}; - var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; - return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; -}; + jQuery('#gk-reset').click(function (e) { + e.stopPropagation(); + e.preventDefault(); -/** - * - * Template scripts - * - **/ - -// onDOMLoadedContent event -jQuery(document).ready(function() { - // Back to Top Scroll - jQuery('#gk-top-link').click(function () { - jQuery('body,html').animate({ - scrollTop: 0 - }, 800); - return false; + jQuery('#gk-mainbody').animate({ + 'font-size': "100%" + }, 200); + current_fs = 100; + }); + + jQuery('#gk-decrement').click(function (e) { + e.stopPropagation(); + e.preventDefault(); + + if (current_fs > 70) { + jQuery('#gk-mainbody').animate({ + 'font-size': (current_fs - 10) + "%" + }, 200); + current_fs -= 10; + } + }); + } + + // Function to change styles + + function changeStyle(style) { + var file = $GK_TMPL_URL + '/css/' + style; + jQuery('head').append(''); + jQuery.cookie($GK_TMPL_NAME + '_style', style, { + expires: 365, + path: '/' + }); + } + + // Responsive tables + jQuery('article section table').each(function (i, table) { + table = jQuery(table); + var heads = table.find('thead th'); + var cells = table.find('tbody td'); + var heads_amount = heads.length; + // if there are the thead cells + if (heads_amount) { + var cells_len = cells.length; + for (var j = 0; j < cells_len; j++) { + var head_content = jQuery(heads.get(j % heads_amount)).text(); + jQuery(cells.get(j)).html('' + head_content + '' + jQuery(cells.get(j)).html()); + } + } + }); }); - // Thickbox use - jQuery(document).ready(function(){ - if(typeof tb_init != "undefined") { - tb_init('div.wp-caption a');//pass where to apply thickbox - } - }); - // style area - if(jQuery('#gk-style-area')){ - jQuery('#gk-style-area div').each(function(i){ - jQuery(this).find('a').each(function(index) { - jQuery(this).click(function(e){ - e.stopPropagation(); - e.preventDefault(); - changeStyle(jQuery(this).attr('href').replace('#', '')); - }); - }); - }); - } - // font-size switcher - if(jQuery('#gk-font-size') && jQuery('#gk-mainbody')) { - var current_fs = 100; - jQuery('#gk-mainbody').css('font-size', current_fs+"%"); - - jQuery('#gk-increment').click(function(e){ - e.stopPropagation(); - e.preventDefault(); - - if(current_fs < 150) { - jQuery('#gk-mainbody').animate({ 'font-size': (current_fs + 10) + "%"}, 200); - current_fs += 10; - } - }); - - jQuery('#gk-reset').click(function(e){ - e.stopPropagation(); - e.preventDefault(); - - jQuery('#gk-mainbody').animate({ 'font-size': "100%"}, 200); - current_fs = 100; - }); - - jQuery('#gk-decrement').click(function(e){ - e.stopPropagation(); - e.preventDefault(); - - if(current_fs > 70) { - jQuery('#gk-mainbody').animate({ 'font-size': (current_fs - 10) + "%"}, 200); - current_fs -= 10; - } - }); - } - - // Function to change styles - function changeStyle(style){ - var file = $GK_TMPL_URL+'/css/'+style; - jQuery('head').append(''); - jQuery.cookie($GK_TMPL_NAME+'_style', style, { expires: 365, path: '/' }); - } - - // Responsive tables - jQuery('article section table').each(function(i, table) { - table = jQuery(table); - console.log(table); - var heads = table.find('thead th'); - var cells = table.find('tbody td'); - var heads_amount = heads.length; - // if there are the thead cells - if(heads_amount) { - var cells_len = cells.length; - for(var i = 0; i < cells_len; i++) { - var head_content = jQuery(heads.get(i % heads_amount)).text(); - jQuery(cells.get(i)).html('' + head_content + '' + jQuery(cells.get(i)).html()); - } - } - }); -}); \ No newline at end of file +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/shortcodes.elements.js b/MeetGavernWP/js/shortcodes.elements.js index 74ac74c..31906cd 100644 --- a/MeetGavernWP/js/shortcodes.elements.js +++ b/MeetGavernWP/js/shortcodes.elements.js @@ -5,19 +5,18 @@ * ------------------------------------------- * **/ - - jQuery(window).load(function() { - jQuery('.gk-toggle').each(function(i, el) { - jQuery(el).children('h3').click(function(e) { - var parent = jQuery(e.target).parent(); - - if(parent.hasClass('closed')) { - parent.removeClass('closed'); - parent.addClass('opened'); - } else { - parent.addClass('closed'); - parent.removeClass('opened'); - } - }); - }); - }); \ No newline at end of file +jQuery(window).load(function () { + jQuery('.gk-toggle').each(function (i, el) { + jQuery(el).children('h3').click(function (e) { + var parent = jQuery(e.target).parent(); + + if (parent.hasClass('closed')) { + parent.removeClass('closed'); + parent.addClass('opened'); + } else { + parent.addClass('closed'); + parent.removeClass('opened'); + } + }); + }); +}); \ No newline at end of file diff --git a/MeetGavernWP/js/shortcodes.template.js b/MeetGavernWP/js/shortcodes.template.js index f7cb3b7..e4bfb53 100644 --- a/MeetGavernWP/js/shortcodes.template.js +++ b/MeetGavernWP/js/shortcodes.template.js @@ -5,9 +5,8 @@ * ------------------------------------------- * **/ - // onLoad event -jQuery(window).load(function() { - // header animation - jQuery(document.body).addClass('loaded'); +jQuery(window).load(function () { + // header animation + jQuery(document.body).addClass('loaded'); }); \ No newline at end of file diff --git a/MeetGavernWP/js/templates/gallery.js b/MeetGavernWP/js/templates/gallery.js index 34dc3f4..7b9bc7a 100644 --- a/MeetGavernWP/js/templates/gallery.js +++ b/MeetGavernWP/js/templates/gallery.js @@ -5,63 +5,65 @@ * ------------------------------------------- * **/ - -var gkGalleryState = 0; // number of the current slide -var gkGalleryAnimationState = 'play'; // play|stop -var gkGalleryTimer = false; - -// main onLoad event used to initialize the gallery -jQuery(window).load(function() { - if(jQuery('#gallery')) { - gkGalleryTimer = setTimeout(function() { - gkGalleryAutoanimation('next'); - }, 5000); - // pagination - jQuery('#gallery').children('ol').find('li').each(function(i, btn) { - jQuery(btn).click(function() { - if(i != gkGalleryState) { - gkGalleryAnimationState = 'stop'; - gkGalleryAutoanimation('next', i); - } +(function() { + "use strict"; + var gkGalleryState = 0; // number of the current slide + var gkGalleryAnimationState = 'play'; // play|stop + var gkGalleryTimer = false; + + // main onLoad event used to initialize the gallery + jQuery(window).load(function() { + if(jQuery('#gallery')) { + gkGalleryTimer = setTimeout(function() { + gkGalleryAutoanimation('next'); + }, 5000); + // pagination + jQuery('#gallery').children('ol').find('li').each(function(i, btn) { + jQuery(btn).click(function() { + if(i !== gkGalleryState) { + gkGalleryAnimationState = 'stop'; + gkGalleryAutoanimation('next', i); + } + }); }); - }); - } -}); -// gallery animation function -var gkGalleryAnimate = function(imgPrev, imgNext) { - imgPrev.animate({ - opacity: 0 - }, 500, function() { - imgPrev.attr('class', ' '); + } }); - - imgNext.animate({ - opacity: 1 - }, 500, function(){ - imgNext.attr('class', 'active'); + // gallery animation function + var gkGalleryAnimate = function(imgPrev, imgNext) { + imgPrev.animate({ + opacity: 0 + }, 500, function() { + imgPrev.attr('class', ' '); + }); - gkGalleryTimer = setTimeout(function() { - gkGalleryAutoanimation('next', null); - }, 5000); - }); -}; -// gallery autoanimation function -var gkGalleryAutoanimation = function(dir, nextSlide) { - var i = gkGalleryState; - var imgs = jQuery('#gallery figure'); - var next = nextSlide; - - if(nextSlide == null) { - next = (dir == 'next') ? ((i < imgs.length - 1) ? i+1 : 0) : ((i == 0) ? imgs.length - 1 : i - 1); // dir: next|prev - } - - if(gkGalleryAnimationState == 'stop') { - clearTimeout(gkGalleryTimer); - gkGalleryAnimationState = 'play'; - } - - gkGalleryAnimate(jQuery(imgs[i]), jQuery(imgs[next])); - gkGalleryState = next; - jQuery('#gallery').children('ol').find('li').attr('class', ''); - jQuery(jQuery('#gallery').children('ol').find('li')[next]).attr('class', 'active'); -}; \ No newline at end of file + imgNext.animate({ + opacity: 1 + }, 500, function(){ + imgNext.attr('class', 'active'); + + gkGalleryTimer = setTimeout(function() { + gkGalleryAutoanimation('next', null); + }, 5000); + }); + }; + // gallery autoanimation function + var gkGalleryAutoanimation = function(dir, nextSlide) { + var i = gkGalleryState; + var imgs = jQuery('#gallery figure'); + var next = nextSlide; + + if(nextSlide === null) { + next = (dir === 'next') ? ((i < imgs.length - 1) ? i+1 : 0) : ((i === 0) ? imgs.length - 1 : i - 1); // dir: next|prev + } + + if(gkGalleryAnimationState === 'stop') { + clearTimeout(gkGalleryTimer); + gkGalleryAnimationState = 'play'; + } + + gkGalleryAnimate(jQuery(imgs[i]), jQuery(imgs[next])); + gkGalleryState = next; + jQuery('#gallery').children('ol').find('li').attr('class', ''); + jQuery(jQuery('#gallery').children('ol').find('li')[next]).attr('class', 'active'); + }; +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/widgets/nsp.js b/MeetGavernWP/js/widgets/nsp.js index 2614791..752736b 100644 --- a/MeetGavernWP/js/widgets/nsp.js +++ b/MeetGavernWP/js/widgets/nsp.js @@ -1,328 +1,339 @@ // // GK NSP Widget // +(function () { + "use strict"; -jQuery(window).load(function(){ - jQuery(document).find('.gk-nsp').each(function(i, widget) { - if(!jQuery(widget).hasClass('activated')) { - new GK_NSP(widget); - } - }); -}); - -var GK_NSP = function(widget) { - // init class fields - this.init_fields(widget); - // init the interface - this.init_interface(); -} - -GK_NSP.prototype = { - // class fields - animation: true, - arts: null, - arts_block_width: 0, - arts_current: 0, - arts_pages: null, - arts_per_page: null, - config: null, - hover: false, - links: null, - links_block_width: 0, - links_pages: null, - links_pages_amount: null, - links_current: 0, - modInterface: null, - module: null, - anim_property: '', - // - init_fields: function(module) { - // the most important class field ;) - this.module = jQuery(module); - this.module.addClass('activated'); - // rest of the fields - this.config = []; - - this.config["animation_speed"] = 400; - this.config['autoanim'] = this.module.attr('data-autoanim') == 'on' ? true : false; - this.config["autoanim_interval"] = this.module.attr('data-autoanimint') != '' ? this.module.attr('data-autoanimint') : 5000; - this.config['autoanim_hover'] = this.module.attr('data-autoanimhover') == 'on' ? true : false; - this.config['news_column'] = this.module.attr('data-cols'); - this.config['news_rows'] = this.module.attr('data-rows'); - this.config['links_amount'] = this.module.attr('data-links'); - - this.arts = this.module.find('.gk-nsp-art'); - this.arts_pages = this.module.find('.gk-nsp-arts-page'); - this.arts_per_page = this.config['news_column'] * this.config['news_rows']; - this.links = (this.module.find('.gk-nsp-links-scroll')) ? this.module.find('.gk-nsp-links-scroll li') : []; - this.links_pages = this.module.find('.gk-nsp-list'); - this.links_pages_amount = Math.ceil(Math.ceil(this.links.length / this.config['links_amount'])); - this.modInterface = { - top: this.module.find('.gk-nsp-arts-nav'), - bottom: this.module.find('.gk-nsp-links-nav') - }; - this.pages_amount = Math.ceil(this.arts.length / this.arts_per_page); - this.anim_property = jQuery('html').attr('dir') == 'rtl' ? 'right': 'left'; - }, - init_interface: function() { - var $this = this; - // arts - if(this.arts.length > 0){ - this.arts_block_width = 100; - } - // events - this.module.mouseenter(function() { - if(!$this.module.hasClass('onhover')) $this.module.addClass('onhover'); - }); - // - this.module.mouseleave(function() { - if($this.module.hasClass('onhover')) $this.module.removeClass('onhover'); - }); - // links - if(this.links.length > 0){ - this.links_block_width = 100; - } - // top interface - this.nsp_art_list(0, 'top'); - this.nsp_art_list(0, 'bottom'); - // - if(this.modInterface.top && this.modInterface.top.find('.gk-nsp-pagination')){ - this.modInterface.top.find('.gk-nsp-pagination li').each(function(i, item){ - jQuery(item).click(function(){ - $this.arts_anim(i); - }); - }); - } - // - if(this.modInterface.top && this.modInterface.top.find('.gk-nsp-prev')){ - this.modInterface.top.find('.gk-nsp-prev').click(function(){ - $this.arts_anim('prev'); - }); - - this.modInterface.top.find('.gk-nsp-next').click(function(){ - $this.arts_anim('next'); - }); - } - // bottom interface - if(this.modInterface.bottom && this.modInterface.bottom.find('.gk-nsp-pagination')){ - this.modInterface.bottom.find('.gk-nsp-pagination li').each(function(i, item){ - jQuery(item).click(function(){ - $this.lists_anim(i); - }); - }); - } - // - if(this.modInterface.bottom && this.modInterface.bottom.find('.gk-nsp-prev')){ - this.modInterface.bottom.find('.gk-nsp-prev').click(function(){ - $this.lists_anim('prev'); - }); - - this.modInterface.bottom.find('.gk-nsp-next').click(function(){ - $this.lists_anim('next'); - }); - } - - if(this.config['autoanim']) { - setTimeout(function() { - $this.autoanim(); - }, this.config['autoanim_interval']); - - if(this.config['autoanim_hover']) { - this.module.mouseenter(function() { - $this.hover = true; - }); - - this.module.mouseleave(function() { - $this.hover = false; - }); - } - } - // article touch events - var arts_pos_start_x = 0; - var arts_pos_start_y = 0; - var arts_time_start = 0; - var arts_swipe = false; - var arts_container = jQuery(this.module.find('.gk-nsp-arts')); - - arts_container.bind('touchstart', function(e) { - arts_swipe = true; - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0) { - arts_pos_start_x = touches[0].pageX; - arts_pos_start_y = touches[0].pageY; - arts_time_start = new Date().getTime(); - } - }); - - arts_container.bind('touchmove', function(e) { - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0 && arts_swipe) { - if( - Math.abs(touches[0].pageX - arts_pos_start_x) > Math.abs(touches[0].pageY - arts_pos_start_y) - ) { - e.preventDefault(); - } else { - arts_swipe = false; - } - } - }); - - arts_container.bind('touchend', function(e) { - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0 && arts_swipe) { - if( - Math.abs(touches[0].pageX - arts_pos_start_x) >= 30 && - new Date().getTime() - arts_time_start <= 500 - ) { - if(touches[0].pageX - arts_pos_start_x > 0) { - $this.arts_anim('prev'); - } else { - $this.arts_anim('next'); - } - } - } - }); - // links touch events - var links_pos_start_x = 0; - var links_pos_start_y = 0; - var links_time_start = 0; - var links_swipe = false; - var links_container = jQuery(this.module.find('.gk-nsp-links')); - - links_container.bind('touchstart', function(e) { - links_swipe = true; - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0) { - links_pos_start_x = touches[0].pageX; - links_pos_start_y = touches[0].pageY; - links_time_start = new Date().getTime(); - } - }); - - links_container.bind('touchmove', function(e) { - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0 && links_swipe) { - if( - Math.abs(touches[0].pageX - links_pos_start_x) > Math.abs(touches[0].pageY - links_pos_start_y) - ) { - e.preventDefault(); - } else { - links_swipe = false; - } - } - }); - - links_container.bind('touchend', function(e) { - var touches = e.originalEvent.changedTouches || e.originalEvent.touches; - - if(touches.length > 0 && links_swipe) { - if( - Math.abs(touches[0].pageX - links_pos_start_x) >= 30 && - new Date().getTime() - links_time_start <= 500 - ) { - if(touches[0].pageX - links_pos_start_x > 0) { - $this.lists_anim('prev'); - } else { - $this.lists_anim('next'); - } - } - } - }); - }, - // - nsp_art_list: function(i, pos){ - var num = (i !== null) ? i : (pos == 'top') ? this.arts_current : this.links_current; - - if(this.modInterface[pos] && this.modInterface[pos].find('.gk-nsp-pagination')){ - var pagination = this.modInterface[pos].find('.gk-nsp-pagination'); - pagination.find('li').attr('class', ''); - jQuery(pagination.find('li')[num]).attr('class', 'active'); - } - }, - // - arts_anim: function(dir) { - var $this = this; - jQuery(this.arts_pages[this.arts_current]).removeClass('active'); - - if(dir == 'next') { - this.arts_current = (this.arts_current == this.pages_amount - 1) ? 0 : this.arts_current + 1; - } else if(dir == 'prev') { - this.arts_current = (this.arts_current == 0) ? this.pages_amount - 1 : this.arts_current - 1; - } else { - this.arts_current = dir; - } - // - if(this.anim_property == 'left') { - jQuery($this.module.find('.gk-nsp-arts-scroll')).animate({ - 'margin-left': (-1 * this.arts_current * this.arts_block_width) + "%" - }, $this.config['animation_speed']); - } else { - jQuery($this.module.find('.gk-nsp-arts-scroll')).animate({ - 'margin-right': (-1 * this.arts_current * this.arts_block_width) + "%" - }, $this.config['animation_speed']); - } - - setTimeout(function() { - jQuery($this.arts_pages[$this.arts_current]).addClass('active'); - }, this.config['animation_speed'] * 0.5); - - this.nsp_art_list(this.arts_current, 'top'); - this.animation = false; - setTimeout(function() { - $this.animation = true; - }, this.config['animation_interval'] * 0.8); - }, - // - lists_anim: function(dir) { - var $this = this; - - for(var x = 0; x < 1; x++) { - var item = this.links_pages[this.links_current * 1 + x]; - if(item) jQuery(item).removeClass('active'); - } - - if(dir == 'next') { - this.links_current = (this.links_current == this.links_pages_amount - 1) ? 0 : this.links_current + 1; - } else if(dir == 'prev') { - this.links_current = (this.links_current == 0) ? this.links_pages_amount - 1 : this.links_current - 1; - } else { - $this.links_current = dir; - } - - setTimeout(function() { - for(var x = 0; x < 1; x++) { - var item = $this.links_pages[$this.links_current * 1 + x]; - if(item) jQuery(item).addClass('active'); - } - }, this.config['animation_speed'] * 0.5); - // - if(this.anim_property == 'left') { - jQuery($this.module.find('.gk-nsp-links-scroll')).animate({ - 'margin-left': (-1 * this.links_current * this.links_block_width) + "%" - }, $this.config['animation_speed']); - } else { - jQuery($this.module.find('.gk-nsp-links-scroll')).animate({ - 'margin-right': (-1 * this.links_current * this.links_block_width) + "%" - }, $this.config['animation_speed']); - } - - this.nsp_art_list(null, 'bottom'); - }, - // - autoanim: function() { - var $this = this; - - if(!this.hover) { - this.arts_anim('next'); - } - - setTimeout(function() { - $this.autoanim(); - }, this.config['autoanim_interval']); - } -}; \ No newline at end of file + jQuery(window).load(function () { + jQuery(document).find('.gk-nsp').each(function (i, widget) { + if (!jQuery(widget).hasClass('activated')) { + new GK_NSP(widget); + } + }); + }); + + var GK_NSP = function (widget) { + // init class fields + this.init_fields(widget); + // init the interface + this.init_interface(); + }; + + GK_NSP.prototype = { + // class fields + animation: true, + arts: null, + arts_block_width: 0, + arts_current: 0, + arts_pages: null, + arts_per_page: null, + config: null, + hover: false, + links: null, + links_block_width: 0, + links_pages: null, + links_pages_amount: null, + links_current: 0, + modInterface: null, + module: null, + anim_property: '', + // + init_fields: function (module) { + // the most important class field ;) + this.module = jQuery(module); + this.module.addClass('activated'); + // rest of the fields + this.config = []; + + this.config.animation_speed = 400; + this.config.autoanim = this.module.attr('data-autoanim') === 'on' ? true : false; + this.config.autoanim_interval = this.module.attr('data-autoanimint') !== '' ? this.module.attr('data-autoanimint') : 5000; + this.config.autoanim_hover = this.module.attr('data-autoanimhover') === 'on' ? true : false; + this.config.news_column = this.module.attr('data-cols'); + this.config.news_rows = this.module.attr('data-rows'); + this.config.links_amount = this.module.attr('data-links'); + + this.arts = this.module.find('.gk-nsp-art'); + this.arts_pages = this.module.find('.gk-nsp-arts-page'); + this.arts_per_page = this.config.news_column * this.config.news_rows; + this.links = (this.module.find('.gk-nsp-links-scroll')) ? this.module.find('.gk-nsp-links-scroll li') : []; + this.links_pages = this.module.find('.gk-nsp-list'); + this.links_pages_amount = Math.ceil(Math.ceil(this.links.length / this.config.links_amount)); + this.modInterface = { + top: this.module.find('.gk-nsp-arts-nav'), + bottom: this.module.find('.gk-nsp-links-nav') + }; + this.pages_amount = Math.ceil(this.arts.length / this.arts_per_page); + this.anim_property = jQuery('html').attr('dir') === 'rtl' ? 'right' : 'left'; + }, + init_interface: function () { + var $this = this; + // arts + if (this.arts.length > 0) { + this.arts_block_width = 100; + } + // events + this.module.mouseenter(function () { + if (!$this.module.hasClass('onhover')) { + $this.module.addClass('onhover'); + } + }); + // + this.module.mouseleave(function () { + if ($this.module.hasClass('onhover')) { + $this.module.removeClass('onhover'); + } + }); + // links + if (this.links.length > 0) { + this.links_block_width = 100; + } + // top interface + this.nsp_art_list(0, 'top'); + this.nsp_art_list(0, 'bottom'); + // + if (this.modInterface.top && this.modInterface.top.find('.gk-nsp-pagination')) { + this.modInterface.top.find('.gk-nsp-pagination li').each(function (i, item) { + jQuery(item).click(function () { + $this.arts_anim(i); + }); + }); + } + // + if (this.modInterface.top && this.modInterface.top.find('.gk-nsp-prev')) { + this.modInterface.top.find('.gk-nsp-prev').click(function () { + $this.arts_anim('prev'); + }); + + this.modInterface.top.find('.gk-nsp-next').click(function () { + $this.arts_anim('next'); + }); + } + // bottom interface + if (this.modInterface.bottom && this.modInterface.bottom.find('.gk-nsp-pagination')) { + this.modInterface.bottom.find('.gk-nsp-pagination li').each(function (i, item) { + jQuery(item).click(function () { + $this.lists_anim(i); + }); + }); + } + // + if (this.modInterface.bottom && this.modInterface.bottom.find('.gk-nsp-prev')) { + this.modInterface.bottom.find('.gk-nsp-prev').click(function () { + $this.lists_anim('prev'); + }); + + this.modInterface.bottom.find('.gk-nsp-next').click(function () { + $this.lists_anim('next'); + }); + } + + if (this.config.autoanim) { + setTimeout(function () { + $this.autoanim(); + }, this.config.autoanim_interval); + + if (this.config.autoanim_hover) { + this.module.mouseenter(function () { + $this.hover = true; + }); + + this.module.mouseleave(function () { + $this.hover = false; + }); + } + } + // article touch events + var arts_pos_start_x = 0; + var arts_pos_start_y = 0; + var arts_time_start = 0; + var arts_swipe = false; + var arts_container = jQuery(this.module.find('.gk-nsp-arts')); + + arts_container.bind('touchstart', function (e) { + arts_swipe = true; + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0) { + arts_pos_start_x = touches[0].pageX; + arts_pos_start_y = touches[0].pageY; + arts_time_start = new Date().getTime(); + } + }); + + arts_container.bind('touchmove', function (e) { + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0 && arts_swipe) { + if ( + Math.abs(touches[0].pageX - arts_pos_start_x) > Math.abs(touches[0].pageY - arts_pos_start_y) + ) { + e.preventDefault(); + } else { + arts_swipe = false; + } + } + }); + + arts_container.bind('touchend', function (e) { + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0 && arts_swipe) { + if ( + Math.abs(touches[0].pageX - arts_pos_start_x) >= 30 && + new Date().getTime() - arts_time_start <= 500 + ) { + if (touches[0].pageX - arts_pos_start_x > 0) { + $this.arts_anim('prev'); + } else { + $this.arts_anim('next'); + } + } + } + }); + // links touch events + var links_pos_start_x = 0; + var links_pos_start_y = 0; + var links_time_start = 0; + var links_swipe = false; + var links_container = jQuery(this.module.find('.gk-nsp-links')); + + links_container.bind('touchstart', function (e) { + links_swipe = true; + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0) { + links_pos_start_x = touches[0].pageX; + links_pos_start_y = touches[0].pageY; + links_time_start = new Date().getTime(); + } + }); + + links_container.bind('touchmove', function (e) { + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0 && links_swipe) { + if ( + Math.abs(touches[0].pageX - links_pos_start_x) > Math.abs(touches[0].pageY - links_pos_start_y) + ) { + e.preventDefault(); + } else { + links_swipe = false; + } + } + }); + + links_container.bind('touchend', function (e) { + var touches = e.originalEvent.changedTouches || e.originalEvent.touches; + + if (touches.length > 0 && links_swipe) { + if ( + Math.abs(touches[0].pageX - links_pos_start_x) >= 30 && + new Date().getTime() - links_time_start <= 500 + ) { + if (touches[0].pageX - links_pos_start_x > 0) { + $this.lists_anim('prev'); + } else { + $this.lists_anim('next'); + } + } + } + }); + }, + // + nsp_art_list: function (i, pos) { + var num = (i !== null) ? i : (pos === 'top') ? this.arts_current : this.links_current; + + if (this.modInterface[pos] && this.modInterface[pos].find('.gk-nsp-pagination')) { + var pagination = this.modInterface[pos].find('.gk-nsp-pagination'); + pagination.find('li').attr('class', ''); + jQuery(pagination.find('li')[num]).attr('class', 'active'); + } + }, + // + arts_anim: function (dir) { + var $this = this; + jQuery(this.arts_pages[this.arts_current]).removeClass('active'); + + if (dir === 'next') { + this.arts_current = (this.arts_current === this.pages_amount - 1) ? 0 : this.arts_current + 1; + } else if (dir === 'prev') { + this.arts_current = (this.arts_current === 0) ? this.pages_amount - 1 : this.arts_current - 1; + } else { + this.arts_current = dir; + } + // + if (this.anim_property === 'left') { + jQuery($this.module.find('.gk-nsp-arts-scroll')).animate({ + 'margin-left': (-1 * this.arts_current * this.arts_block_width) + "%" + }, $this.config.animation_speed); + } else { + jQuery($this.module.find('.gk-nsp-arts-scroll')).animate({ + 'margin-right': (-1 * this.arts_current * this.arts_block_width) + "%" + }, $this.config.animation_speed); + } + + setTimeout(function () { + jQuery($this.arts_pages[$this.arts_current]).addClass('active'); + }, this.config.animation_speed * 0.5); + + this.nsp_art_list(this.arts_current, 'top'); + this.animation = false; + setTimeout(function () { + $this.animation = true; + }, this.config.animation_interval * 0.8); + }, + // + lists_anim: function (dir) { + var $this = this; + + for (var x = 0; x < 1; x++) { + var item = this.links_pages[this.links_current * 1 + x]; + if (item) { + jQuery(item).removeClass('active'); + } + } + + if (dir === 'next') { + this.links_current = (this.links_current === this.links_pages_amount - 1) ? 0 : this.links_current + 1; + } else if (dir === 'prev') { + this.links_current = (this.links_current === 0) ? this.links_pages_amount - 1 : this.links_current - 1; + } else { + $this.links_current = dir; + } + + setTimeout(function () { + for (var x = 0; x < 1; x++) { + var item = $this.links_pages[$this.links_current * 1 + x]; + if (item) { + jQuery(item).addClass('active'); + } + } + }, this.config.animation_speed * 0.5); + // + if (this.anim_property === 'left') { + jQuery($this.module.find('.gk-nsp-links-scroll')).animate({ + 'margin-left': (-1 * this.links_current * this.links_block_width) + "%" + }, $this.config.animation_speed); + } else { + jQuery($this.module.find('.gk-nsp-links-scroll')).animate({ + 'margin-right': (-1 * this.links_current * this.links_block_width) + "%" + }, $this.config.animation_speed); + } + + this.nsp_art_list(null, 'bottom'); + }, + // + autoanim: function () { + var $this = this; + + if (!this.hover) { + this.arts_anim('next'); + } + + setTimeout(function () { + $this.autoanim(); + }, this.config.autoanim_interval); + } + }; +})(); \ No newline at end of file diff --git a/MeetGavernWP/js/widgets/tabs.js b/MeetGavernWP/js/widgets/tabs.js index df67d01..f1fd81f 100644 --- a/MeetGavernWP/js/widgets/tabs.js +++ b/MeetGavernWP/js/widgets/tabs.js @@ -1,98 +1,111 @@ -jQuery(window).load(function(){ - jQuery(document).find('.gk-tabs').each(function(i, el) { - el = jQuery(el); - var animation_speed = el.attr('data-speed'); - var animation_interval = el.attr('data-interval'); - var autoanim = el.attr('data-autoanim'); - var eventActivator = el.attr('data-event'); - var active_tab = 0; - - var tabs = el.find('.gk-tabs-item'); - var items = el.find('.gk-tabs-nav li'); - var tabs_wrapper = jQuery(el.find('.gk-tabs-container')[0]); - var current_tab = active_tab; - var previous_tab = null; - var amount = tabs.length; - var timer = false; - var blank = false; - var falsy_click = false; - var tabs_h = []; - // - jQuery(tabs).css('opacity', 0); - jQuery(tabs[active_tab]).css({ - 'opacity': '1', - 'position': 'relative', - 'z-index': 2 - }); - - jQuery(tabs).each(function(i, item) { - tabs_h[i] = jQuery(item).outerHeight(); - }); - - // add events to tabs - items.each(function(i, item){ - item = jQuery(item); - item.bind(eventActivator, function(){ - if(i != current_tab) { - previous_tab = current_tab; - current_tab = i; - - if(typeof gk_tab_event_trigger != 'undefined') { - gk_tab_event_trigger(current_tab, previous_tab, el.parent().parent().attr('id')); - } - - tabs_wrapper.css('height', tabs_wrapper.outerHeight() + 'px'); - - var previous_tab_animation = { 'opacity': 0 }; - var current_tab_animation = { 'opacity': 1 }; - // - jQuery(tabs[previous_tab]).animate(previous_tab_animation, animation_speed / 2, function() { - jQuery(tabs[previous_tab]).css({ - 'position': 'absolute', - 'top': '0', - 'z-index': '1' - }); - - jQuery(tabs[current_tab]).css({ - 'position': 'relative', - 'z-index': '2' - }); - - jQuery(tabs[previous_tab]).removeClass('active'); - jQuery(tabs[current_tab]).addClass('active'); - - tabs_wrapper.animate({ - "height": tabs_h[i] - }, - animation_speed / 2, - function() { - tabs_wrapper.css('height', 'auto'); - }); - // - setTimeout(function(){ - // anim - jQuery(tabs[current_tab]).animate(current_tab_animation, animation_speed); - }, animation_speed / 2); - }); - // common operations for both types of animation - if(!falsy_click) blank = true; - else falsy_click = false; - jQuery(items[previous_tab]).removeClass('active'); - jQuery(items[current_tab]).addClass('active'); - } - }); - }); - // - if(autoanim == 'enabled') { - setInterval(function(){ - if(!blank) { - falsy_click = true; - if(current_tab < amount - 1) jQuery(items[current_tab + 1]).trigger(eventActivator); - else jQuery(items[0]).trigger(eventActivator); - } else { - blank = false; - } - }, animation_interval); - } - }); -}); \ No newline at end of file +(function () { + "use strict"; + + jQuery(window).load(function () { + jQuery(document).find('.gk-tabs').each(function (i, el) { + el = jQuery(el); + var animation_speed = el.attr('data-speed'); + var animation_interval = el.attr('data-interval'); + var autoanim = el.attr('data-autoanim'); + var eventActivator = el.attr('data-event'); + var active_tab = 0; + + var tabs = el.find('.gk-tabs-item'); + var items = el.find('.gk-tabs-nav li'); + var tabs_wrapper = jQuery(el.find('.gk-tabs-container')[0]); + var current_tab = active_tab; + var previous_tab = null; + var amount = tabs.length; + var blank = false; + var falsy_click = false; + var tabs_h = []; + // + jQuery(tabs).css('opacity', 0); + jQuery(tabs[active_tab]).css({ + 'opacity': '1', + 'position': 'relative', + 'z-index': 2 + }); + + jQuery(tabs).each(function (i, item) { + tabs_h[i] = jQuery(item).outerHeight(); + }); + + // add events to tabs + items.each(function (i, item) { + item = jQuery(item); + item.bind(eventActivator, function () { + if (i !== current_tab) { + previous_tab = current_tab; + current_tab = i; + + if (typeof gk_tab_event_trigger !== 'undefined') { + gk_tab_event_trigger(current_tab, previous_tab, el.parent().parent().attr('id')); + } + + tabs_wrapper.css('height', tabs_wrapper.outerHeight() + 'px'); + + var previous_tab_animation = { + 'opacity': 0 + }; + var current_tab_animation = { + 'opacity': 1 + }; + // + jQuery(tabs[previous_tab]).animate(previous_tab_animation, animation_speed / 2, function () { + jQuery(tabs[previous_tab]).css({ + 'position': 'absolute', + 'top': '0', + 'z-index': '1' + }); + + jQuery(tabs[current_tab]).css({ + 'position': 'relative', + 'z-index': '2' + }); + + jQuery(tabs[previous_tab]).removeClass('active'); + jQuery(tabs[current_tab]).addClass('active'); + + tabs_wrapper.animate({ + "height": tabs_h[i] + }, + animation_speed / 2, + function () { + tabs_wrapper.css('height', 'auto'); + }); + // + setTimeout(function () { + // anim + jQuery(tabs[current_tab]).animate(current_tab_animation, animation_speed); + }, animation_speed / 2); + }); + // common operations for both types of animation + if (!falsy_click) { + blank = true; + } else { + falsy_click = false; + } + jQuery(items[previous_tab]).removeClass('active'); + jQuery(items[current_tab]).addClass('active'); + } + }); + }); + // + if (autoanim === 'enabled') { + setInterval(function () { + if (!blank) { + falsy_click = true; + if (current_tab < amount - 1) { + jQuery(items[current_tab + 1]).trigger(eventActivator); + } else { + jQuery(items[0]).trigger(eventActivator); + } + } else { + blank = false; + } + }, animation_interval); + } + }); + }); +})(); \ No newline at end of file From 20bc52109f8d6d88192e9cc8e3cbfa33cf4fe454 Mon Sep 17 00:00:00 2001 From: dziudek Date: Sat, 13 Jul 2013 11:39:35 +0200 Subject: [PATCH 07/25] Small fix in the paths on the Font Awesome CSS code --- MeetGavernWP/css/font-awesome.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MeetGavernWP/css/font-awesome.css b/MeetGavernWP/css/font-awesome.css index f2a79c8..a69995f 100644 --- a/MeetGavernWP/css/font-awesome.css +++ b/MeetGavernWP/css/font-awesome.css @@ -28,7 +28,7 @@ @font-face { font-family: 'FontAwesome'; src: url('font-awesome/fontawesome-webfont.eot?v=3.2.1'); - src: url('font-awesome/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), url('../font/fontawesome-webfont.woff?v=3.2.1') format('woff'), url('font-awesome/fontawesome-webfont.ttf?v=3.2.1') format('truetype'), url('font-awesome/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg'); + src: url('font-awesome/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), url('font-awesome/fontawesome-webfont.woff?v=3.2.1') format('woff'), url('font-awesome/fontawesome-webfont.ttf?v=3.2.1') format('truetype'), url('font-awesome/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg'); font-weight: normal; font-style: normal; } From 7f5fc0644067aa9489767ee01769a8ab0b34ce0f Mon Sep 17 00:00:00 2001 From: dziudek Date: Sat, 13 Jul 2013 11:43:51 +0200 Subject: [PATCH 08/25] Small fix for the submenu indicators on the mobile menu. --- MeetGavernWP/css/tablet.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MeetGavernWP/css/tablet.css b/MeetGavernWP/css/tablet.css index 1625c0a..66e6c75 100644 --- a/MeetGavernWP/css/tablet.css +++ b/MeetGavernWP/css/tablet.css @@ -245,6 +245,11 @@ border-top: none!important; } +#main-menu > li.haschild:after, +#main-menu > li li.haschild:after { + display: none!important; +} + /* 10.5. Footer ==================================== */ From 748acafec03485c32d717389b2290835f4fc6329 Mon Sep 17 00:00:00 2001 From: dziudek Date: Thu, 18 Jul 2013 10:33:22 +0200 Subject: [PATCH 09/25] Fixed menu script. --- MeetGavernWP/js/gk.menu.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/MeetGavernWP/js/gk.menu.js b/MeetGavernWP/js/gk.menu.js index 00be943..d87ca76 100644 --- a/MeetGavernWP/js/gk.menu.js +++ b/MeetGavernWP/js/gk.menu.js @@ -7,7 +7,6 @@ **/ (function () { "use strict"; - jQuery(document).ready(function () { if (jQuery(window).width() > jQuery(document.body).attr('data-tablet-width')) { if (jQuery('#main-menu')) { @@ -58,13 +57,11 @@ $GK_MENU[menuName].animation.indexOf('opacity') !== -1 ) ) { - var content = false; - base.find('li.haschild').each(function (i, el) { el = jQuery(el); if (el.children('.sub-menu').length > 0) { - content = jQuery(el.children('.sub-menu').first()); + var content = jQuery(el.children('.sub-menu').first()); var prevh = content.height(); var prevw = content.width(); var heightAnim = $GK_MENU[menuName].animation.indexOf('height') !== -1; @@ -168,7 +165,7 @@ base.find('li.haschild').each(function (i, el) { el = jQuery(el); - content = jQuery(el.children('.sub-menu').first()); + var content = jQuery(el.children('.sub-menu').first()); content.css({ 'display': 'none' }); From 039f05f5e421788c3aa49329186cfe8ab7dfead4 Mon Sep 17 00:00:00 2001 From: piotrkunicki Date: Fri, 19 Jul 2013 10:32:46 +0200 Subject: [PATCH 10/25] Php include replaced by get_template_part function. --- MeetGavernWP/attachment.php | 2 +- MeetGavernWP/content-aside.php | 6 +++--- MeetGavernWP/content-audio.php | 6 +++--- MeetGavernWP/content-chat.php | 6 +++--- MeetGavernWP/content-gallery.php | 6 +++--- MeetGavernWP/content-image.php | 6 +++--- MeetGavernWP/content-link.php | 6 +++--- MeetGavernWP/content-page.php | 6 +++--- MeetGavernWP/content-quote.php | 6 +++--- MeetGavernWP/content-single.php | 6 +++--- MeetGavernWP/content-status.php | 6 +++--- MeetGavernWP/content-video.php | 6 +++--- MeetGavernWP/content.php | 6 +++--- MeetGavernWP/gavern/base.php | 10 +++++----- MeetGavernWP/gavern/form.parser.php | 4 ++-- MeetGavernWP/gavern/layouts/template.php | 2 +- MeetGavernWP/gavern/options.template.php | 2 +- MeetGavernWP/gavern/options.updates.php | 2 +- MeetGavernWP/template.contact.php | 2 +- 19 files changed, 48 insertions(+), 48 deletions(-) diff --git a/MeetGavernWP/attachment.php b/MeetGavernWP/attachment.php index c83f70d..c534002 100644 --- a/MeetGavernWP/attachment.php +++ b/MeetGavernWP/attachment.php @@ -74,7 +74,7 @@ - + diff --git a/MeetGavernWP/content-aside.php b/MeetGavernWP/content-aside.php index 240351f..3f77c68 100644 --- a/MeetGavernWP/content-aside.php +++ b/MeetGavernWP/content-aside.php @@ -12,10 +12,10 @@
        >
        - +
        - +
        @@ -34,5 +34,5 @@
        - +
        diff --git a/MeetGavernWP/content-audio.php b/MeetGavernWP/content-audio.php index 8341a7c..f735529 100644 --- a/MeetGavernWP/content-audio.php +++ b/MeetGavernWP/content-audio.php @@ -11,10 +11,10 @@ ?>
        >
        - +
        - +
        @@ -33,5 +33,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-chat.php b/MeetGavernWP/content-chat.php index e24de4f..9212888 100644 --- a/MeetGavernWP/content-chat.php +++ b/MeetGavernWP/content-chat.php @@ -11,10 +11,10 @@ ?>
        >
        - +
        - +
        @@ -33,5 +33,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-gallery.php b/MeetGavernWP/content-gallery.php index 816fe4b..c73a773 100644 --- a/MeetGavernWP/content-gallery.php +++ b/MeetGavernWP/content-gallery.php @@ -12,10 +12,10 @@
        > - +
        @@ -65,5 +65,5 @@
        - +
        diff --git a/MeetGavernWP/content-image.php b/MeetGavernWP/content-image.php index b1d1426..2eabdd8 100644 --- a/MeetGavernWP/content-image.php +++ b/MeetGavernWP/content-image.php @@ -11,10 +11,10 @@ ?>
        >
        - +
        - +
        @@ -33,5 +33,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-link.php b/MeetGavernWP/content-link.php index b3d0140..93e10cd 100644 --- a/MeetGavernWP/content-link.php +++ b/MeetGavernWP/content-link.php @@ -10,10 +10,10 @@ ?>
        > - +
        @@ -32,5 +32,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-page.php b/MeetGavernWP/content-page.php index b0e12be..9edcd80 100644 --- a/MeetGavernWP/content-page.php +++ b/MeetGavernWP/content-page.php @@ -29,11 +29,11 @@
        >
        - +
        - +
        @@ -42,5 +42,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-quote.php b/MeetGavernWP/content-quote.php index a740558..b87f102 100644 --- a/MeetGavernWP/content-quote.php +++ b/MeetGavernWP/content-quote.php @@ -12,10 +12,10 @@
        >
        - +
        - +
        @@ -34,5 +34,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-single.php b/MeetGavernWP/content-single.php index 9960601..fc20091 100644 --- a/MeetGavernWP/content-single.php +++ b/MeetGavernWP/content-single.php @@ -12,10 +12,10 @@
        >
        - +
        - +
        @@ -24,5 +24,5 @@
        - +
        diff --git a/MeetGavernWP/content-status.php b/MeetGavernWP/content-status.php index fb4bade..dcdb3bb 100644 --- a/MeetGavernWP/content-status.php +++ b/MeetGavernWP/content-status.php @@ -12,10 +12,10 @@
        >
        - +
        - +
        @@ -34,5 +34,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content-video.php b/MeetGavernWP/content-video.php index 45772dd..d441877 100644 --- a/MeetGavernWP/content-video.php +++ b/MeetGavernWP/content-video.php @@ -11,11 +11,11 @@ ?>
        >
        - +
        - +
        @@ -33,5 +33,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/content.php b/MeetGavernWP/content.php index 27c9e28..276e841 100644 --- a/MeetGavernWP/content.php +++ b/MeetGavernWP/content.php @@ -12,10 +12,10 @@
        >
        - +
        - +
        @@ -30,5 +30,5 @@
        - +
        \ No newline at end of file diff --git a/MeetGavernWP/gavern/base.php b/MeetGavernWP/gavern/base.php index 4d615fc..2a60029 100644 --- a/MeetGavernWP/gavern/base.php +++ b/MeetGavernWP/gavern/base.php @@ -9,16 +9,16 @@ define('GAVERN_WP', 1); // Including file with template object class -require_once(gavern_file('gavern/classes/class.gkobject.php')); +include_once(gavern_file('gavern/classes/class.gkobject.php')); // Including file with template browser class -require_once(gavern_file('gavern/classes/class.gkbrowser.php')); +include_once(gavern_file('gavern/classes/class.gkbrowser.php')); // Including file with menu walker class -require_once(gavern_file('gavern/classes/class.menu.walker.php')); +include_once(gavern_file('gavern/classes/class.menu.walker.php')); // Including file with mobile menu walker class -require_once(gavern_file('gavern/classes/class.menu.walker.mobile.php')); +include_once(gavern_file('gavern/classes/class.menu.walker.mobile.php')); // Including file used for WPML support if (defined('ICL_SITEPRESS_VERSION')) { - require_once(gavern_file('gavern/wpml.php')); + include_once(gavern_file('gavern/wpml.php')); } class GavernWP { diff --git a/MeetGavernWP/gavern/form.parser.php b/MeetGavernWP/gavern/form.parser.php index ab14293..75b28ae 100644 --- a/MeetGavernWP/gavern/form.parser.php +++ b/MeetGavernWP/gavern/form.parser.php @@ -9,7 +9,7 @@ * **/ -require_once(TEMPLATEPATH . '/gavern/form_elements/standard.php'); +include_once(TEMPLATEPATH . '/gavern/form_elements/standard.php'); /** * @@ -114,7 +114,7 @@ private function output() { // load these files only once time if(!class_exists($file_config->class)) { // load the main PHP class - require_once(TEMPLATEPATH . '/gavern/form_elements/'.($field->type).'/'.($file_config->php)); + include_once(TEMPLATEPATH . '/gavern/form_elements/'.($field->type).'/'.($file_config->php)); } // create the object if(class_exists($file_config->class)) { diff --git a/MeetGavernWP/gavern/layouts/template.php b/MeetGavernWP/gavern/layouts/template.php index 62db110..5d23b5b 100644 --- a/MeetGavernWP/gavern/layouts/template.php +++ b/MeetGavernWP/gavern/layouts/template.php @@ -6,7 +6,7 @@ // access to the template object global $tpl; // load the form parser -require_once(TEMPLATEPATH . '/gavern/form.parser.php'); +include_once(TEMPLATEPATH . '/gavern/form.parser.php'); // create a new instance of the form parser $parser = new GavernWPFormParser($tpl); // get the tabs list from the JSON file diff --git a/MeetGavernWP/gavern/options.template.php b/MeetGavernWP/gavern/options.template.php index 875b422..66909fb 100644 --- a/MeetGavernWP/gavern/options.template.php +++ b/MeetGavernWP/gavern/options.template.php @@ -20,7 +20,7 @@ function gavern_template_options() { wp_die(__('You don\'t have sufficient permissions to access this page!', GKTPLNAME)); } - include('layouts/template.php'); + include_once('layouts/template.php'); } /** diff --git a/MeetGavernWP/gavern/options.updates.php b/MeetGavernWP/gavern/options.updates.php index 67ddaab..a76acea 100644 --- a/MeetGavernWP/gavern/options.updates.php +++ b/MeetGavernWP/gavern/options.updates.php @@ -17,7 +17,7 @@ function gavern_updates_options() { wp_die(__('You don\'t have sufficient permissions to access this page!', GKTPLNAME)); } - include('layouts/updates.php'); + include_once('layouts/updates.php'); } /** diff --git a/MeetGavernWP/template.contact.php b/MeetGavernWP/template.contact.php index 3b3a555..d665dcc 100644 --- a/MeetGavernWP/template.contact.php +++ b/MeetGavernWP/template.contact.php @@ -8,7 +8,7 @@ // check if reCAPTCHA isn't loaded earlier by other plugin if(!function_exists('_recaptcha_qsencode')) { - require_once('gavern/classes/class.recaptchalib.php'); + include_once('gavern/classes/class.recaptchalib.php'); } // get the params $params = get_post_custom(); From 0b4297d4c81afdb27e1e59f3b34b222ecf4b9e9e Mon Sep 17 00:00:00 2001 From: dziudek Date: Mon, 22 Jul 2013 11:54:19 +0200 Subject: [PATCH 11/25] Added links on the non-single post pages to featured images. --- MeetGavernWP/layouts/content.post.featured.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MeetGavernWP/layouts/content.post.featured.php b/MeetGavernWP/layouts/content.post.featured.php index 320f7a3..bf7e03c 100644 --- a/MeetGavernWP/layouts/content.post.featured.php +++ b/MeetGavernWP/layouts/content.post.featured.php @@ -43,7 +43,9 @@