Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Gabrielsson committed Aug 12, 2024
1 parent 8d7c1cc commit fc76140
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
38 changes: 10 additions & 28 deletions nightly/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ var dom = {
},
_uniqueId: 0,
_bindfieldPos: 0,
_changedAttributes: {},

/**
* @namespace parse
Expand Down Expand Up @@ -318,14 +317,7 @@ var dom = {
*/
bind: function (object, value, target) {
var attr = object.lastRunAttribute,
bindings = value && value.split(';') || [],
target = object.getAttribute(target)

if (target) {
var value = target.split(':')
replaceVariable = value[0]
replaceValue = value[1]
}
bindings = value.split(';')

for (var i = 0; i < bindings.length; i++) {
var binding = bindings[i].split(':'),
Expand Down Expand Up @@ -436,7 +428,6 @@ var dom = {

app.variables.update.attributes(object, replaceVariable, replaceValue, false)
app.variables.update.content(object, replaceVariable, replaceValue, false)
app.element.onchange(object, attr, true)
}
},

Expand Down Expand Up @@ -549,10 +540,10 @@ var dom = {
setUniqueId: function (element, internal) {
this._uniqueId++
var id = this._uniqueId
if (internal)
element.uniqueId = id
else
if (!internal)
element.id = 'id' + id
else
element.uniqueId = id
},

/**
Expand Down Expand Up @@ -731,9 +722,9 @@ var dom = {
var test = value.split(':')
console.log(test[0])
data = cache.data[func.replace('map', '')][test[1]] || '',
data2 = data[test[0]] || ''
data2 = data[test[0]] || ''
console.log(data2)
dom.bind(object, test[0] + ':' + data2, 'mapbindvar')
dom.bind(object, test[0]+':'+data2, 'mapbindvar')
//console.log(object, value)
break
}
Expand Down Expand Up @@ -867,6 +858,7 @@ var dom = {
* @desc * Loads the content of an external file and insert it into the DOM.
*/
include: function (element) {

//@TODO Fix ie bug with reversed attributes.
var bindvar = element.attributes.bindvar
if (bindvar) dom.bind.include = bindvar.value
Expand Down Expand Up @@ -1464,13 +1456,7 @@ var app = {
* @function onchange
* @memberof app
*/
onchange: function (object, value, once) {
var uid = value + object.uniqueId
if (once && !dom._changedAttributes[uid]) {
dom._changedAttributes[uid] = true
return
}

onchange: function (object, value) {
if (value) {
var onchange = object.getAttribute('on' + value.replace('set', '') + 'change')
if (onchange) app.call(onchange, { srcElement: object })
Expand Down Expand Up @@ -1971,8 +1957,7 @@ var app = {
var selector = selector || 'html *',
node = typeof selector === 'object' ? selector : dom.get(selector, true),
excludes = (exclude || []).concat(this.defaultExclude),
orderMap = {},
uid = 1
orderMap = {}

app.log.info()('Running attributes (' + selector + ') ...')
for (var i = 0; i < node.length; i++) {
Expand Down Expand Up @@ -2008,13 +1993,11 @@ var app = {
var attrName = attributes[j].name,
attrValue = attributes[j].value,
attrFullname = dom._actionMap[attrName] || attrName

if (exclude.indexOf(attrFullname) === -1) {
var name = attrFullname.split('-')
element.originalAttribute = dom._actionMap[attrName] && attrName
element.lastRunAttribute = attrName
attrName === 'include' ? element.id = 'id' + uid : element.uniqueId = uid

if (attrName === 'include') dom.setUniqueId(element) // Add ID to all includes.
if (!element.originalText) element.originalText = element.textContent
if (!element.originalHtml) element.originalHtml = element.innerHTML
if (!element.originalOuterHtml) element.originalOuterHtml = element.outerHTML
Expand All @@ -2033,7 +2016,6 @@ var app = {
} else {
app.log.warn(1)(name + " [Skipping]")
}
uid++
}
}
}
Expand Down
31 changes: 18 additions & 13 deletions nightly/modules/data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

app.module.data = {

_intervalTimers: {},
storageMechanism: 'window',
storageType: 'module',
storageKey: '',
Expand All @@ -18,8 +20,9 @@ app.module.data = {
},

src: function (element) {
var self = this,
interval = element.getAttribute('data-interval') || this.defaultInterval,
var self = this
dom.setUniqueId(element, true)
var interval = element.getAttribute('data-interval') || this.interval,
loader = element.getAttribute('data-loader')

if (loader) {
Expand All @@ -31,18 +34,20 @@ app.module.data = {

if (!element.getAttribute('stop')) dom.stop(element, '*')

setTimeout(function () {
try {
app.xhr.currentAsset.total = 1
self._handle(element)
if (element.getAttribute('data-srcjoin')) {
app.xhr.currentAsset.total = 2
self._handle(element, true)
if (!self._intervalTimers[element.uniqueId]) {
self._intervalTimers[element.uniqueId] = setTimeout(function () {
try {
app.xhr.currentAsset.total = 1
self._handle(element)
if (element.getAttribute('data-srcjoin')) {
app.xhr.currentAsset.total = 2
self._handle(element, true)
}
} catch (error) {
console.error('data-interval error:', error)
}
} catch (error) {
console.error('data-interval error:', error)
}
}, interval)
}, interval)
}
},

_handle: function (element, join) {
Expand Down
2 changes: 2 additions & 0 deletions nightly/modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ app.module.keyboard = {
action = element.getAttribute('keyboard-action'),
scope = element.getAttribute('keyboard-scope')

dom.setUniqueId(element, true)

for (var i = 0; i < key.length; i++) {
this.keys.push({ key: key[i], action: action, scope: scope, element: element })
}
Expand Down
2 changes: 1 addition & 1 deletion nightly/modules/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

app.module.math = {
bind: function (element, value) {
dom.bind(element, value, 'math-bind')
console.log(element, value)
},

round: function (element, value) {
Expand Down

0 comments on commit fc76140

Please sign in to comment.