-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f77813
commit 8125436
Showing
31 changed files
with
704 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating) { | ||
"use strict"; | ||
|
||
var _prototypeProperties = function (child, staticProps, instanceProps) { | ||
if (staticProps) Object.defineProperties(child, staticProps); | ||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps); | ||
}; | ||
|
||
var Behavior = _aureliaTemplating.Behavior; | ||
var GlobalBehavior = (function () { | ||
function GlobalBehavior(element) { | ||
this.element = element; | ||
} | ||
|
||
_prototypeProperties(GlobalBehavior, { | ||
metadata: { | ||
value: function metadata() { | ||
return Behavior.attachedBehavior("global-behavior").withOptions().and(function (x) { | ||
return x.dynamic(); | ||
}); | ||
}, | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
}, | ||
inject: { | ||
value: function inject() { | ||
return [Element]; | ||
}, | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
} | ||
}, { | ||
bind: { | ||
value: function bind() { | ||
var settings, lookup, globalObject; | ||
|
||
lookup = GlobalBehavior.whitelist[this.aureliaAttrName]; | ||
if (!lookup) { | ||
throw new Error("Conventional global binding behavior not whitelisted for " + this.aureliaAttrName + "."); | ||
} | ||
|
||
globalObject = window[lookup]; | ||
if (!globalObject) { | ||
throw new Error("Conventional global " + lookup + " was not found."); | ||
} | ||
|
||
settings = {}; | ||
|
||
for (var key in this) { | ||
if (key === "aureliaAttrName" || key === "aureliaCommand" || !this.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
|
||
settings[key] = this[key]; | ||
} | ||
|
||
try { | ||
this.instance = globalObject(this.element)[this.aureliaCommand](settings); | ||
} catch (error) { | ||
throw new Error("Conventional global binding behavior failed.", error); | ||
} | ||
}, | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
}, | ||
unbind: { | ||
value: function unbind() { | ||
if (this.instance && "destroy" in this.instance) { | ||
this.instance.destroy(); | ||
this.instance = null; | ||
} | ||
}, | ||
writable: true, | ||
enumerable: true, | ||
configurable: true | ||
} | ||
}); | ||
|
||
return GlobalBehavior; | ||
})(); | ||
|
||
exports.GlobalBehavior = GlobalBehavior; | ||
|
||
|
||
GlobalBehavior.whitelist = { jquery: "jQuery" }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
define(["exports", "./compose", "./if", "./repeat", "./show", "./selected-item"], function (exports, _compose, _if, _repeat, _show, _selectedItem) { | ||
define(["exports", "./compose", "./if", "./repeat", "./show", "./selected-item", "./global-behavior"], function (exports, _compose, _if, _repeat, _show, _selectedItem, _globalBehavior) { | ||
"use strict"; | ||
|
||
var Compose = _compose.Compose; | ||
var If = _if.If; | ||
var Repeat = _repeat.Repeat; | ||
var Show = _show.Show; | ||
var SelectedItem = _selectedItem.SelectedItem; | ||
var GlobalBehavior = _globalBehavior.GlobalBehavior; | ||
|
||
|
||
function install(aurelia) { | ||
aurelia.withResources([Show, If, Repeat, Compose, SelectedItem]); | ||
aurelia.withResources([Show, If, Repeat, Compose, SelectedItem, GlobalBehavior]); | ||
} | ||
|
||
exports.Compose = Compose; | ||
exports.If = If; | ||
exports.Repeat = Repeat; | ||
exports.Show = Show; | ||
exports.SelectedItem = SelectedItem; | ||
exports.GlobalBehavior = GlobalBehavior; | ||
exports.install = install; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.