Commit fb1850f9edb4bb72edfc17cdbb02f9b974c57dec

Authored by Andrey Karpikov
1 parent b2f394a5

page tree - open prev open items, check url open

@@ -2198,7 +2198,7 @@ jQuery(document).ready(function(){ @@ -2198,7 +2198,7 @@ jQuery(document).ready(function(){
2198 console.log($wrapper.nestable('serialize')); 2198 console.log($wrapper.nestable('serialize'));
2199 }); // activate Nestable for list 2 2199 }); // activate Nestable for list 2
2200 2200
2201 - $wrapper.nestable('collapseAll'); 2201 + $wrapper.nestable('collapseAllExceptPrevOpen');
2202 2202
2203 }); 2203 });
2204 2204
@@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
6 { 6 {
7 var hasTouch = 'ontouchstart' in document; 7 var hasTouch = 'ontouchstart' in document;
8 8
  9 + var STORAGE_KEY_NAME = 'nestable-list';
  10 +
9 /** 11 /**
10 * Detect CSS pointer-events property 12 * Detect CSS pointer-events property
11 * events are normally disabled on the dragging element to avoid conflicts 13 * events are normally disabled on the dragging element to avoid conflicts
@@ -196,12 +198,31 @@ @@ -196,12 +198,31 @@
196 this.pointEl = null; 198 this.pointEl = null;
197 }, 199 },
198 200
  201 + saveOpenItems: function(li, action){
  202 + var id = li.data('id');
  203 + var data = Storages.localStorage.get(STORAGE_KEY_NAME);
  204 +
  205 + if (data instanceof Array == false){
  206 + data = [];
  207 + }
  208 + if(action == 'expand'){
  209 + data.push(id);
  210 + }else{
  211 + var data = data.filter(function(value, index, arr){
  212 + return value != id;
  213 + });
  214 + }
  215 +
  216 + Storages.localStorage.set(STORAGE_KEY_NAME, data);
  217 + },
  218 +
199 expandItem: function(li) 219 expandItem: function(li)
200 { 220 {
201 li.removeClass(this.options.collapsedClass); 221 li.removeClass(this.options.collapsedClass);
202 li.children('[data-action="expand"]').hide(); 222 li.children('[data-action="expand"]').hide();
203 li.children('[data-action="collapse"]').show(); 223 li.children('[data-action="collapse"]').show();
204 li.children(this.options.listNodeName).show(); 224 li.children(this.options.listNodeName).show();
  225 + this.saveOpenItems(li, 'expand');
205 }, 226 },
206 227
207 collapseItem: function(li) 228 collapseItem: function(li)
@@ -212,6 +233,7 @@ @@ -212,6 +233,7 @@
212 li.children('[data-action="collapse"]').hide(); 233 li.children('[data-action="collapse"]').hide();
213 li.children('[data-action="expand"]').show(); 234 li.children('[data-action="expand"]').show();
214 li.children(this.options.listNodeName).hide(); 235 li.children(this.options.listNodeName).hide();
  236 + this.saveOpenItems(li, 'collapse');
215 } 237 }
216 }, 238 },
217 239
@@ -231,6 +253,26 @@ @@ -231,6 +253,26 @@
231 }); 253 });
232 }, 254 },
233 255
  256 + collapseAllExceptPrevOpen: function()
  257 + {
  258 + var list = this;
  259 +
  260 + var data = Storages.localStorage.get(STORAGE_KEY_NAME);
  261 +
  262 + if (data instanceof Array == false){
  263 + data = [];
  264 + }
  265 +
  266 + list.el.find(list.options.itemNodeName).each(function() {
  267 + var $that = $(this),
  268 + id = $that.data('id');
  269 +
  270 + if(id == undefined || !data.includes(id)){
  271 + list.collapseItem($that);
  272 + }
  273 + });
  274 + },
  275 +
234 setParent: function(li) 276 setParent: function(li)
235 { 277 {
236 if (li.children(this.options.listNodeName).length) { 278 if (li.children(this.options.listNodeName).length) {
@@ -15,6 +15,12 @@ module Kanjai @@ -15,6 +15,12 @@ module Kanjai
15 page_datum = nil 15 page_datum = nil
16 16
17 loop do 17 loop do
  18 + if mas.count == 0 && page_datum
  19 + if page_datum.page.menu_url(lang) != "/#{lang}#{url}"
  20 + page_datum = nil
  21 + end
  22 + end
  23 +
18 break if mas.count == 0 24 break if mas.count == 0
19 25
20 check_length = mas.count 26 check_length = mas.count
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.338" 2 + VERSION = "0.0.339"
3 end 3 end