Skip to content

Commit 691dac0

Browse files
committed
.
1 parent ba0c6d8 commit 691dac0

22 files changed

+1807
-2127
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ While VulpiniQ is inspired by jQuery, it distinguishes itself in several key are
155155
| removeData | Prototype | Data Manipulation | Removes a data\-\* attribute from each node\. |
156156
| removeProp | Prototype | Property Manipulation | Removes a property from each node\. |
157157
| removeTransition | Prototype | Display | Removes the transition from each node\. |
158+
| replaceWith | Ext | DOM Manipulation | Replaces the selected element\(s\) with the given new content \(Q instance or DOM node\)\. |
158159
| scrollHeight | Prototype | Dimensions | Returns the scroll height of the first node\. Returns undefined for empty selection\. |
159160
| scrollLeft | Prototype | Scroll Manipulation | Gets or sets the horizontal scroll position of the first node, with an option to increment\. Returns undefined for empty selection\. |
160161
| scrollTop | Prototype | Scroll Manipulation | Gets or sets the vertical scroll position of the first node, with an option to increment\. Returns undefined for empty selection\. |

compiled/Library_Builder.html

Lines changed: 144 additions & 129 deletions
Large diffs are not rendered by default.

compiled/VulpiniQ.full.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,20 @@ Q.Ext('removeTransition', function () {
859859
}
860860
return this;
861861
});
862+
Q.Ext('replaceWith', function(newContent) {
863+
const nodes = this.nodes;
864+
let newNodes = (newContent instanceof Q) ? newContent.nodes : [newContent];
865+
for (let i = 0, l = nodes.length; i < l; i++) {
866+
const node = nodes[i];
867+
if (node && node.parentNode) {
868+
for (let j = 0; j < newNodes.length; j++) {
869+
node.parentNode.insertBefore(newNodes[j].cloneNode(true), node);
870+
}
871+
node.parentNode.removeChild(node);
872+
}
873+
}
874+
return this;
875+
});
862876
Q.Ext('scrollHeight', function () {
863877
var node = this.nodes[0];
864878
return node.scrollHeight;

compiled/VulpiniQ.full.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiled/VulpiniQ.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,20 @@ Q.Ext('removeTransition', function () {
859859
}
860860
return this;
861861
});
862+
Q.Ext('replaceWith', function(newContent) {
863+
const nodes = this.nodes;
864+
let newNodes = (newContent instanceof Q) ? newContent.nodes : [newContent];
865+
for (let i = 0, l = nodes.length; i < l; i++) {
866+
const node = nodes[i];
867+
if (node && node.parentNode) {
868+
for (let j = 0; j < newNodes.length; j++) {
869+
node.parentNode.insertBefore(newNodes[j].cloneNode(true), node);
870+
}
871+
node.parentNode.removeChild(node);
872+
}
873+
}
874+
return this;
875+
});
862876
Q.Ext('scrollHeight', function () {
863877
var node = this.nodes[0];
864878
return node.scrollHeight;

compiled/VulpiniQ.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/methods/replaceWith.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Q.Ext('replaceWith', function(newContent) {
2+
// Replace each node in this Q instance with newContent (Q instance or DOM node)
3+
const nodes = this.nodes;
4+
let newNodes = (newContent instanceof Q) ? newContent.nodes : [newContent];
5+
for (let i = 0, l = nodes.length; i < l; i++) {
6+
const node = nodes[i];
7+
if (node && node.parentNode) {
8+
for (let j = 0; j < newNodes.length; j++) {
9+
node.parentNode.insertBefore(newNodes[j].cloneNode(true), node);
10+
}
11+
node.parentNode.removeChild(node);
12+
}
13+
}
14+
return this;
15+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Name": "replaceWith",
3+
"Method": "Ext",
4+
"Desc": "Replaces the selected element(s) with the given new content (Q instance or DOM node).",
5+
"LongDesc": "Adds a replaceWith method to Q, which replaces each node in the Q instance with the provided new content. The new content can be a Q instance or a DOM node. This is useful for dynamic UI updates.",
6+
"Type": "DOM Manipulation",
7+
"Example": [
8+
"Q('.old').replaceWith(Q('<div>New</div>'))",
9+
"Q('#item').replaceWith(document.createElement('span'))"
10+
],
11+
"Dependencies": ["Q"],
12+
"Returns": "Q (for chaining)",
13+
"Arguments": [
14+
{ "name": "newContent", "type": "Q|Element", "desc": "The new content to insert in place of the current node(s)." }
15+
]
16+
}

components/plugins/Container/Container.Frame.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,22 @@ Container.prototype.Frame = function(options = {}) {
8080
// --- Új: azonosító és mentés opciók ---
8181
const frameId = options.id || null;
8282
const savePosition = !!options.savePosition;
83-
const storageKey = options.storageKey;
83+
// Rövidített storageKey, ha az alapértelmezett
84+
const storageKey = (options.storageKey === 'settings.frames' || !options.storageKey) ? 'set.frame' : options.storageKey;
8485
const minSize = options.minSize;
8586
const responsive = !!options.responsive;
8687
const responsivesMaxCount = options.responsivesMaxCount || 5;
8788

89+
// Storage instance for frame settings
90+
const storageInstance = new Q.Storage();
91+
8892
// Helper: get/set/törlés a localStorage-ból Q.Storage segítségével
8993
function getSavedFrames() {
90-
return Q.Storage(storageKey) || {};
94+
return storageInstance.get(storageKey) || {};
9195
}
9296
function saveFrames(framesObj) {
9397
console.log('Saving frames:', framesObj);
94-
Q.Storage(storageKey, framesObj);
98+
storageInstance.set(storageKey, framesObj);
9599
}
96100
function clearFramePos(id) {
97101
const all = getSavedFrames();
@@ -114,6 +118,10 @@ Container.prototype.Frame = function(options = {}) {
114118
if (!saved || !Array.isArray(saved) || saved.length === 0) return null;
115119
for (let i = 0; i < saved.length; ++i) {
116120
const entry = saved[i];
121+
if (entry && typeof entry.ssb === 'number' && entry.ssb === bucket) {
122+
return entry;
123+
}
124+
// visszafelé kompatibilis régi kulcs
117125
if (entry && typeof entry.screenSizeBucket === 'number' && entry.screenSizeBucket === bucket) {
118126
return entry;
119127
}
@@ -160,7 +168,18 @@ Container.prototype.Frame = function(options = {}) {
160168
if (savePosition && frameId) {
161169
const all = getSavedFrames();
162170
if (all[frameId]) {
163-
if (responsive && Array.isArray(all[frameId].responsive)) {
171+
// Új rövid kulcsok támogatása
172+
if (responsive && Array.isArray(all[frameId].r)) {
173+
savedResponsiveList = all[frameId].r;
174+
const found = findSavedSizeByBucket(savedResponsiveList, currentScreenSizeBucket);
175+
if (found && Array.isArray(found.s) && found.s.length === frameDefs.length) {
176+
savedSizes = found.s;
177+
}
178+
} else if (Array.isArray(all[frameId].s) && all[frameId].s.length === frameDefs.length) {
179+
savedSizes = all[frameId].s;
180+
}
181+
// Visszafelé kompatibilitás a régi kulcsokkal
182+
else if (responsive && Array.isArray(all[frameId].responsive)) {
164183
savedResponsiveList = all[frameId].responsive;
165184
const found = findSavedSizeByBucket(savedResponsiveList, currentScreenSizeBucket);
166185
if (found && Array.isArray(found.sizes) && found.sizes.length === frameDefs.length) {
@@ -345,28 +364,28 @@ Container.prototype.Frame = function(options = {}) {
345364
if (direction === 'horizontal') {
346365
const px = sec.nodes[0].getBoundingClientRect().width;
347366
const parentPx = root.nodes[0].clientWidth;
348-
return (px / parentPx * 100) + '%';
367+
return (px / parentPx * 100).toFixed(2) + '%';
349368
} else {
350369
const px = sec.nodes[0].getBoundingClientRect().height;
351370
const parentPx = root.nodes[0].clientHeight;
352-
return (px / parentPx * 100) + '%';
371+
return (px / parentPx * 100).toFixed(2) + '%';
353372
}
354373
});
355374
const all = getSavedFrames();
356375
if (responsive) {
357376
let responsiveArr = (all[frameId] && Array.isArray(all[frameId].responsive)) ? all[frameId].responsive : [];
358377
const screenSizeBucket = getScreenSizeBucket();
359378
// Remove any entry with same bucket
360-
responsiveArr = responsiveArr.filter(entry => entry.screenSizeBucket !== screenSizeBucket);
379+
responsiveArr = responsiveArr.filter(entry => entry.ssb !== screenSizeBucket);
361380
// Limit to responsivesMaxCount - 1 before push (so after push it's max)
362381
if (responsiveArr.length >= responsivesMaxCount) {
363382
// Remove the oldest (first) entry
364383
responsiveArr.shift();
365384
}
366-
responsiveArr.push({ screenSizeBucket, sizes });
367-
all[frameId] = { responsive: responsiveArr };
385+
responsiveArr.push({ ssb: screenSizeBucket, s: sizes });
386+
all[frameId] = { r: responsiveArr };
368387
} else {
369-
all[frameId] = { sizes };
388+
all[frameId] = { s: sizes };
370389
}
371390
saveFrames(all);
372391
}

0 commit comments

Comments
 (0)