Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/topic.php on line 737
Форумы портала PHP.SU :: Как добавить куки в данный код?

 PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи


 Страниц (1): [1]   

> Без описания
Alex213
Отправлено: 19 Августа, 2015 - 18:56:46
Post Id


Новичок


Покинул форум
Сообщений всего: 47
Дата рег-ции: Июль 2015  


Помог: 0 раз(а)




Данный код выполняет роль аккордеона, нужно чтоб были куки, не знаю как их правильно поставить, примеры вроде бы смотрел но не получается, туговат в этом))
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. $(function () {
  3.  
  4.     $('.accordion-header').on('click', function (e) {
  5.  
  6.         var $this = $(this);
  7.  
  8.         $this.parent('.accordion').toggleClass('expanded');
  9.  
  10.         $this.next('.accordion-collapse').toggle();
  11.  
  12.         $this.parent('.accordion').siblings('.accordion').removeClass('expanded').find('.accordion-collapse').hide();
  13.        
  14.         e.stopPropagation();
  15.  
  16.     });
  17.  
  18. });
  19.  


CODE (html):
скопировать код в буфер обмена
  1.  
  2. <div class="container">
  3.     <div class="accordion-wrapper">
  4.         <div class="accordion">
  5.             <div class="accordion-header">
  6.                 <h3>Header 1</h3><a class="accordion-close">V</a>
  7.             </div>
  8.             <div class="accordion-collapse">
  9.                 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nec magna at urna auctor eleifend eu vel enim. Nulla facilisi. Praesent interdum tortor a justo aliquet semper. Phasellus venenatis porttitor auctor. Mauris et gravida velit. Nunc tempus nunc velit, id lacinia nisl dignissim ac. Proin quis semper sapien. Vestibulum bibendum lorem nec ligula mattis posuere. Nullam suscipit, massa non dictum auctor, orci ligula condimentum sem, nec ultricies est lorem quis ante. Morbi placerat lacinia egestas.</p>
  10.             </div>
  11.         </div>
  12.         <div class="accordion">
  13.             <div class="accordion-header">
  14.                 <h3>Header 2</h3><a class="accordion-close">V</a>
  15.             </div>
  16.             <div class="accordion-collapse">
  17.                 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nec magna at urna auctor eleifend eu vel enim. Nulla facilisi. Praesent interdum tortor a justo aliquet semper. Phasellus venenatis porttitor auctor. Mauris et gravida velit. Nunc tempus nunc velit, id lacinia nisl dignissim ac. Proin quis semper sapien. Vestibulum bibendum lorem nec ligula mattis posuere. Nullam suscipit, massa non dictum auctor, orci ligula condimentum sem, nec ultricies est lorem quis ante. Morbi placerat lacinia egestas.</p>
  18.             </div>
  19.         </div>
  20.         <div class="accordion">
  21.             <div class="accordion-header">
  22.                 <h3>Header 3</h3><a class="accordion-close">V</a>
  23.             </div>
  24.             <div class="accordion-collapse">
  25.                 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nec magna at urna auctor eleifend eu vel enim. Nulla facilisi. Praesent interdum tortor a justo aliquet semper. Phasellus venenatis porttitor auctor. Mauris et gravida velit. Nunc tempus nunc velit, id lacinia nisl dignissim ac. Proin quis semper sapien. Vestibulum bibendum lorem nec ligula mattis posuere. Nullam suscipit, massa non dictum auctor, orci ligula condimentum sem, nec ultricies est lorem quis ante. Morbi placerat lacinia egestas.</p>
  26.             </div>
  27.         </div>
  28.     </div>
  29. </div>
  30.  


CODE (htmlphp):
скопировать код в буфер обмена
  1.  
  2.  body {
  3.     margin: 0;
  4.     padding: 0;
  5.     font-family: Verdana;
  6.     font-size: 12px;
  7. }
  8. .container {
  9.     padding: 20px;
  10. }
  11. .accordion-wrapper {
  12.     width: 80%;
  13. }
  14. .accordion {
  15.     margin: 0 0 20px;
  16. }
  17. .accordion-header {
  18.     display: table;
  19.     width: 100%;
  20.     padding: 10px;
  21.     background-color: #58ACFA;
  22.    border-radius: 3px;
  23.     color: #fff;
  24.    cursor: pointer;
  25. }
  26. .accordion-header h3 {
  27.     float: left;
  28.     width: 90%;
  29.     margin: 0;
  30. }
  31. .accordion-close {
  32.     display: block;
  33.     float: right;
  34.     width: 15px;
  35.     height: 15px;
  36.     position: relative;
  37.     text-indent: -9999px;
  38. }
  39. .accordion-close:after {
  40.     content:"";
  41.     display: block;
  42.     width: 0;
  43.     height: 0;
  44.     position: absolute;
  45.     top: 5px;
  46.     border-color: #fff transparent transparent;
  47.    border-style: solid;
  48.     border-width: 8px;
  49. }
  50. .accordion.expanded .accordion-close:after {
  51.     top: -3px;
  52.     border-color: transparent transparent #fff;
  53. }
  54. .accordion-collapse {
  55.     display: none;
  56.     padding: 0 10px;
  57. }
  58.  
 
 Top
ПТО
Отправлено: 20 Августа, 2015 - 11:38:38
Post Id



Посетитель


Покинул форум
Сообщений всего: 395
Дата рег-ции: Янв. 2012  


Помог: 3 раз(а)




CODE (javascript):
скопировать код в буфер обмена
  1. var fn = (function(window, document) {
  2.     var fn = {};
  3.     Object.defineProperty(fn, 'cookie', {
  4.         value: (function() {
  5.             var c = {};
  6.  
  7.             c.get = function(name) {
  8.                 var cookie = " " + document.cookie;
  9.                 var search = " " + name + "=";
  10.                 var setStr = null;
  11.                 var offset = 0;
  12.                 var end = 0;
  13.                 if (cookie.length > 0) {
  14.                     offset = cookie.indexOf(search);
  15.                     if (offset != -1) {
  16.                         offset += search.length;
  17.                         end = cookie.indexOf(";", offset)
  18.                         if (end == -1) {
  19.                             end = cookie.length;
  20.                         }
  21.                         setStr = unescape(cookie.substring(offset, end));
  22.                     }
  23.                 }
  24.                 return setStr;
  25. //                var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
  26.             //                return matches ? decodeURIComponent(matches[1]) : undefined;
  27.             };
  28.  
  29.             c.set = function(name, value, options) {
  30.                 options = options || {
  31.                     'path' : "/"
  32.                 };
  33.  
  34.                 var expires = options.expires;
  35.  
  36.                 if (typeof expires == "number" && expires) {
  37.                     var d = new Date();
  38.                     d.setTime(d.getTime() + expires * 1000);
  39.                     expires = options.expires = d;
  40.                 }
  41.                 if (expires && expires.toUTCString) {
  42.                     options.expires = expires.toUTCString();
  43.                 }
  44.  
  45.                 value = encodeURIComponent(value);
  46.  
  47.                 var updatedCookie = name + "=" + value;
  48.  
  49.                 for (var propName in options) {
  50.                     updatedCookie += "; " + propName;
  51.                     var propValue = options[propName];
  52.                     if (propValue !== true) {
  53.                         updatedCookie += "=" + propValue;
  54.                     }
  55.                 }
  56.  
  57.                 document.cookie = updatedCookie;
  58.             };
  59.  
  60.             c.del = function(name) {
  61.                 c.set(name, "", {
  62.                     expires: -1
  63.                 });
  64.             };
  65.             return c;
  66.  
  67.         })(),
  68.         writable: false,
  69.         configurable: false,
  70.         enumerable: false
  71.     }
  72.     );
  73.     return fn;
  74. })(window, document);


вызывать так:
fn.cookie.set('mycookie', 12);
fn.cookie.get('mycookie');

В общем, смотрите, разбирайтесь
 
 Top
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« JavaScript & VBScript »


Все гости форума могут просматривать этот раздел.
Только зарегистрированные пользователи могут создавать новые темы в этом разделе.
Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
 



Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB