Collapse-O-Matic - Version 1.7.9

Version Description

  • jQuery selector for expandanchor no longer needed.
  • jQuery selectors look for exact match for targets, preventing multiple targets expanding if the ids end the same.
  • alt tag not used unless alt value is provided
  • reworked the way url hashtags are handled to include manual hash changes in url
Download this release

Release Info

Developer baden03
Plugin Icon 128x128 Collapse-O-Matic
Version 1.7.9
Comparing to
See all releases

Code changes from version 1.7.8 to 1.7.9

Files changed (3) hide show
  1. collapse-o-matic.php +11 -7
  2. js/collapse.js +26 -57
  3. readme.txt +12 -4
collapse-o-matic.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Collapse-O-Matic
4
  Text Domain: jquery-collapse-o-matic
5
  Plugin URI: https://plugins.twinpictures.de/plugins/collapse-o-matic/
6
  Description: Collapse-O-Matic adds an [expand] shortcode that wraps content into a lovely, jQuery collapsible div.
7
- Version: 1.7.8
8
  Author: twinpictures, baden03
9
  Author URI: https://twinpictures.de/
10
  License: GPL2
@@ -29,7 +29,7 @@ class WP_Collapse_O_Matic {
29
  * Current version
30
  * @var string
31
  */
32
- var $version = '1.7.8';
33
 
34
  /**
35
  * Used as prefix for options entry
@@ -136,7 +136,7 @@ class WP_Collapse_O_Matic {
136
  if($this->options['script_location'] == 'footer' ){
137
  $load_in_footer = true;
138
  }
139
- wp_register_script('collapseomatic-js', plugins_url('js/collapse.js', __FILE__), array('jquery'), '1.6.10', $load_in_footer);
140
  if( empty($this->options['script_check']) ){
141
  wp_enqueue_script('collapseomatic-js');
142
  }
@@ -366,14 +366,14 @@ class WP_Collapse_O_Matic {
366
  }
367
  }
368
  $altatt = '';
369
- if($alt){
370
  $altatt = 'alt="'.$alt.'" title="'.$alt.'"';
371
  }
372
- else if( !$notitle ){
373
  $altatt = 'title="'.$title.'"';
374
  }
375
  $relatt = '';
376
- if($rel){
377
  $relatt = 'rel="'.$rel.'"';
378
  }
379
 
@@ -450,7 +450,11 @@ class WP_Collapse_O_Matic {
450
  }
451
  //swap title
452
  if($swaptitle){
453
- $link .= "<".$tag." id='swap-".$id."' alt='".$swapalt."' class='colomat-swap' style='display:none;'>".$startwrap.$swaptitle.$endwrap."</".$tag.">";
 
 
 
 
454
  }
455
 
456
  if($excerpt){
4
  Text Domain: jquery-collapse-o-matic
5
  Plugin URI: https://plugins.twinpictures.de/plugins/collapse-o-matic/
6
  Description: Collapse-O-Matic adds an [expand] shortcode that wraps content into a lovely, jQuery collapsible div.
7
+ Version: 1.7.9
8
  Author: twinpictures, baden03
9
  Author URI: https://twinpictures.de/
10
  License: GPL2
29
  * Current version
30
  * @var string
31
  */
32
+ var $version = '1.7.9';
33
 
34
  /**
35
  * Used as prefix for options entry
136
  if($this->options['script_location'] == 'footer' ){
137
  $load_in_footer = true;
138
  }
139
+ wp_register_script('collapseomatic-js', plugins_url('js/collapse.js', __FILE__), array('jquery'), '1.6.14', $load_in_footer);
140
  if( empty($this->options['script_check']) ){
141
  wp_enqueue_script('collapseomatic-js');
142
  }
366
  }
367
  }
368
  $altatt = '';
369
+ if(!empty($alt)){
370
  $altatt = 'alt="'.$alt.'" title="'.$alt.'"';
371
  }
372
+ else if( empty($notitle) ){
373
  $altatt = 'title="'.$title.'"';
374
  }
375
  $relatt = '';
376
+ if(!empty($rel)){
377
  $relatt = 'rel="'.$rel.'"';
378
  }
379
 
450
  }
451
  //swap title
452
  if($swaptitle){
453
+ $swapalt_attr = '';
454
+ if(!empty($swapalt)){
455
+ $swapalt_attr = "alt='".$swapalt."'";
456
+ }
457
+ $link .= "<".$tag." id='swap-".$id."' ".$swapalt_attr." class='colomat-swap' style='display:none;'>".$startwrap.$swaptitle.$endwrap."</".$tag.">";
458
  }
459
 
460
  if($excerpt){
js/collapse.js CHANGED
@@ -1,8 +1,8 @@
1
  /*!
2
- * Collapse-O-Matic JavaSctipt v1.6.10
3
  * http://plugins.twinpictures.de/plugins/collapse-o-matic/
4
  *
5
- * Copyright 2017, Twinpictures
6
  *
7
  * Permission is hereby granted, free of charge, to any person obtaining a copy
8
  * of this software and associated documentation files (the "Software"), to deal
@@ -99,7 +99,8 @@ function toggleState (obj, id, maptastic, trig_id) {
99
 
100
  //slideToggle
101
  if(com_effect == 'slideToggle'){
102
- jQuery('[id^=target][id$='+id+']').slideToggle(com_duration, function() {
 
103
  // Animation complete.
104
  if( jQuery(this).hasClass('colomat-inline') && jQuery(this).is(':visible') ){
105
  jQuery(this).css('display', 'inline');
@@ -120,7 +121,7 @@ function toggleState (obj, id, maptastic, trig_id) {
120
  }
121
  //slideFade
122
  else if(com_effect == 'slideFade'){
123
- jQuery('[id^=target][id$='+id+']').animate({
124
  height: "toggle",
125
  opacity: "toggle"
126
  }, com_duration, function (){
@@ -340,16 +341,6 @@ jQuery(document).ready(function() {
340
  collapse_init();
341
  }
342
 
343
- function is_valid_jquery_selector(sel) {
344
- try {
345
- jQuery(sel);
346
- return true;
347
- }
348
- catch(ex) {
349
- return false;
350
- }
351
- }
352
-
353
  //jetpack infinite scroll catch-all
354
  jQuery( document.body ).on( 'post-load', function () {
355
  collapse_init();
@@ -543,46 +534,21 @@ jQuery(document).ready(function() {
543
 
544
  //handle new page loads with anchor
545
  var fullurl = document.location.toString();
546
- // the URL contains an anchor, but not a hash-bang (#!)
547
- if (fullurl.match('#(?!\!)')) {
548
- // click the navigation item corresponding to the anchor
549
- var anchor_arr = fullurl.split(/#(?!\!)/);
550
- if(anchor_arr.length > 1){
551
- junk = anchor_arr.splice(0, 1);
552
- anchor = anchor_arr.join('#');
553
- }
554
- else{
555
- anchor = anchor_arr[0];
556
- }
557
 
558
- //if the element exists
559
- if( is_valid_jquery_selector('#' + anchor) && jQuery('#' + anchor).length ){
560
-
561
- //if the element isn't already expanded, expand it
562
- if(!jQuery('#' + anchor).hasClass('colomat-close')){
563
- jQuery('#' + anchor).click();
564
- }
565
-
566
- //expand any nested parents
567
- jQuery('#' + anchor).parents('.collapseomatic_content').each(function(index) {
568
- parent_arr = jQuery(this).attr('id').split('-');
569
- junk = parent_arr.splice(0, 1);
570
- parent = parent_arr.join('-');
571
- jQuery('#' + parent).click();
572
- })
573
 
574
- if(typeof colomatoffset !== 'undefined'){
575
- var anchor_offset = jQuery('#' + anchor).offset();
576
- colomatoffset = colomatoffset + anchor_offset.top;
577
- jQuery('html, body').animate({scrollTop:colomatoffset}, 50);
578
- }
579
- }
580
- }
581
 
582
- //handle anchor links within the same page
583
- jQuery(document).on(com_binding, 'a.expandanchor', function(event) {
584
- //event.preventDefault();
585
- var fullurl = jQuery(this).attr('href');
586
  // the URL contains an anchor but not a hash-bang
587
  if (fullurl.match('#(?!\!)')) {
588
  // click the navigation item corresponding to the anchor
@@ -596,7 +562,7 @@ jQuery(document).ready(function() {
596
  anchor = anchor_arr[0];
597
  }
598
 
599
- if( is_valid_jquery_selector('#' + anchor) && jQuery('#' + anchor).length ){
600
  //expand any nested parents
601
  jQuery('#' + anchor).parents('.collapseomatic_content').each(function(index) {
602
  parent_arr = jQuery(this).attr('id').split('-');
@@ -611,10 +577,13 @@ jQuery(document).ready(function() {
611
  jQuery('#' + anchor).click();
612
  }
613
  }
614
- }
615
- });
616
 
617
- jQuery(document).on(com_binding, 'a.colomat-nolink', function(event) {
618
- event.preventDefault();
619
- });
 
 
 
 
 
620
  });
1
  /*!
2
+ * Collapse-O-Matic JavaSctipt v1.6.14
3
  * http://plugins.twinpictures.de/plugins/collapse-o-matic/
4
  *
5
+ * Copyright 2018, Twinpictures
6
  *
7
  * Permission is hereby granted, free of charge, to any person obtaining a copy
8
  * of this software and associated documentation files (the "Software"), to deal
99
 
100
  //slideToggle
101
  if(com_effect == 'slideToggle'){
102
+ //jQuery('[id^=target][id$='+id+']').slideToggle(com_duration, function() {
103
+ jQuery('#target-'+id).slideToggle(com_duration, function() {
104
  // Animation complete.
105
  if( jQuery(this).hasClass('colomat-inline') && jQuery(this).is(':visible') ){
106
  jQuery(this).css('display', 'inline');
121
  }
122
  //slideFade
123
  else if(com_effect == 'slideFade'){
124
+ jQuery('#target-'+id).animate({
125
  height: "toggle",
126
  opacity: "toggle"
127
  }, com_duration, function (){
341
  collapse_init();
342
  }
343
 
 
 
 
 
 
 
 
 
 
 
344
  //jetpack infinite scroll catch-all
345
  jQuery( document.body ).on( 'post-load', function () {
346
  collapse_init();
534
 
535
  //handle new page loads with anchor
536
  var fullurl = document.location.toString();
537
+ hashmaster(fullurl);
 
 
 
 
 
 
 
 
 
 
538
 
539
+ //handle no-link triggers within the same page
540
+ jQuery(document).on('click', 'a.colomat-nolink', function(event) {
541
+ event.preventDefault();
542
+ });
 
 
 
 
 
 
 
 
 
 
 
543
 
544
+ //manual hashtag changes in url
545
+ jQuery(window).on('hashchange', function (e) {
546
+ fullurl = document.location.toString();
547
+ hashmaster(fullurl);
548
+ });
 
 
549
 
550
+ //master url hash funciton
551
+ function hashmaster(fullurl){
 
 
552
  // the URL contains an anchor but not a hash-bang
553
  if (fullurl.match('#(?!\!)')) {
554
  // click the navigation item corresponding to the anchor
562
  anchor = anchor_arr[0];
563
  }
564
 
565
+ if( jQuery('#' + anchor).length ){
566
  //expand any nested parents
567
  jQuery('#' + anchor).parents('.collapseomatic_content').each(function(index) {
568
  parent_arr = jQuery(this).attr('id').split('-');
577
  jQuery('#' + anchor).click();
578
  }
579
  }
 
 
580
 
581
+ if(typeof colomatoffset !== 'undefined'){
582
+ var anchor_offset = jQuery('#' + anchor).offset();
583
+ colomatoffset = colomatoffset + anchor_offset.top;
584
+ jQuery('html, body').animate({scrollTop:colomatoffset}, 50);
585
+ }
586
+
587
+ }
588
+ }
589
  });
readme.txt CHANGED
@@ -3,9 +3,9 @@
3
  Contributors: twinpictures, baden03
4
  Donate link: https://plugins.twinpictures.de/plugins/collapse-o-matic/
5
  Tags: collapse, expand, collapsible, expandable, expandable content, collapsable content, shortcode, hidden, hide, display, accordion, accordion, jQuery, javascript, roll-your-own, twinpictures, read me, read more, more, plugin oven
6
- Requires at least: 4.5
7
- Tested up to: 4.9.1
8
- Stable tag: 1.7.8
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -50,6 +50,12 @@ No. Not even close.
50
 
51
  == Changelog ==
52
 
 
 
 
 
 
 
53
  = 1.7.8 =
54
  * touchstart binding now an option
55
 
@@ -355,4 +361,6 @@ Fixed auto-expand of urls with id-anchors
355
  * The plug-in came to be.
356
 
357
  == Upgrade Notice ==
358
- * touchstart binding now an option
 
 
3
  Contributors: twinpictures, baden03
4
  Donate link: https://plugins.twinpictures.de/plugins/collapse-o-matic/
5
  Tags: collapse, expand, collapsible, expandable, expandable content, collapsable content, shortcode, hidden, hide, display, accordion, accordion, jQuery, javascript, roll-your-own, twinpictures, read me, read more, more, plugin oven
6
+ Requires at least: 4.7
7
+ Tested up to: 4.9.4
8
+ Stable tag: 1.7.9
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
50
 
51
  == Changelog ==
52
 
53
+ = 1.7.9 =
54
+ * jQuery selector for expandanchor no longer needed.
55
+ * jQuery selectors look for exact match for targets, preventing multiple targets expanding if the id’s end the same.
56
+ * alt tag not used unless alt value is provided
57
+ * reworked the way url hashtags are handled to include manual hash changes in url
58
+
59
  = 1.7.8 =
60
  * touchstart binding now an option
61
 
361
  * The plug-in came to be.
362
 
363
  == Upgrade Notice ==
364
+ * jQuery selector for expandanchor expanded to include any element, not just a tags.
365
+ * jQuery selectors look for exact match for targets, preventing multiple targets expanding if the id’s end the same.
366
+ * alt tag not used unless alt value is provided