mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 19:12:49 +00:00
Added files
This commit is contained in:
21
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/index.html
generated
vendored
Normal file
21
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/index.html
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<dropdown: nonvoid>
|
||||
<!-- a :self path alias is automatically created per component -->
|
||||
<div class="btn-group dropdown {#if :self.open}open{/}">
|
||||
<!-- x-as can be used to pass a reference to an element to the script -->
|
||||
<a x-as="toggle" x-bind="click: toggle" class="btn dropdown-toggle">
|
||||
<span>{:self.label}</span> <span class="caret"></span>
|
||||
</a>
|
||||
<menu x-as="menu" x-bind="click: _clickMenu" class="dropdown-menu">
|
||||
{#each @options}
|
||||
{{#if divider}}
|
||||
<li class="divider"></li>
|
||||
{{else}}
|
||||
<li><a>{{text}}</a></li>
|
||||
{{/}}
|
||||
{/}
|
||||
{{@content}}
|
||||
</menu>
|
||||
</div>
|
||||
|
||||
<option: nonvoid>
|
||||
<li>{#with :self}<a>{{@content}}</a>{/}</li>
|
||||
73
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/index.js
generated
vendored
Normal file
73
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// The create function is called after the component is created
|
||||
// and has been added to the DOM. It only runs in the browser
|
||||
exports.create = function(model, dom) {
|
||||
var toggle = dom.element('toggle')
|
||||
, menu = dom.element('menu')
|
||||
|
||||
// Make sure the value gets set to the default if unselected
|
||||
updateValue(model, model.get('value'), true)
|
||||
|
||||
// Listeners added inside of a component are removed when the
|
||||
// page is re-rendered client side
|
||||
dom.addListener(document.documentElement, 'click', function(e) {
|
||||
if (toggle.contains(e.target) || menu.contains(e.target)) return
|
||||
model.set('open', false)
|
||||
})
|
||||
}
|
||||
|
||||
// The init function is called on both the server and browser
|
||||
// before rendering
|
||||
exports.init = function(model) {
|
||||
this.on('init:child', function(child, type) {
|
||||
if (type !== 'lib:option') return
|
||||
var childModel = child.model
|
||||
model.at('options').push({
|
||||
value: childModel.get('value')
|
||||
, text: childModel.get('content')
|
||||
})
|
||||
|
||||
updateValue(model, model.get('value'))
|
||||
})
|
||||
|
||||
updateValue(model, model.get('value'))
|
||||
|
||||
model.on('set', 'value', function(value) {
|
||||
updateValue(model, value, true)
|
||||
})
|
||||
}
|
||||
|
||||
exports.toggle = function() {
|
||||
this.model.set('open', !this.model.get('open'))
|
||||
}
|
||||
|
||||
exports._clickMenu = function(e) {
|
||||
this.model.set('open', false)
|
||||
// Don't do anything unless an option was clicked
|
||||
if (e.target.tagName !== 'A') return
|
||||
var item = this.model.at(e.target)
|
||||
, value = item.get('value')
|
||||
if (value === void 0) value = item.get('text')
|
||||
this.model.set('value', value)
|
||||
}
|
||||
|
||||
function optionValue(option) {
|
||||
return ('value' in option) ? option.value : option.text
|
||||
}
|
||||
|
||||
function updateValue(model, value, setValue) {
|
||||
var options = model.get('options')
|
||||
, i, len, option
|
||||
if (!options) return
|
||||
for (i = 0, len = options.length; i < len; i++) {
|
||||
option = options[i]
|
||||
if (optionValue(option) !== value) continue
|
||||
model.set('label', option.text, null)
|
||||
return
|
||||
}
|
||||
option = options[0]
|
||||
value = optionValue(option)
|
||||
if (setValue || value === void 0) {
|
||||
model.set('value', value)
|
||||
}
|
||||
model.set('label', option.text, null)
|
||||
}
|
||||
6
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/option.js
generated
vendored
Normal file
6
mongoui/mongoui-master/node_modules/derby-ui-boot/dropdown/option.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
exports.init = function(model) {
|
||||
var value = model.get('value')
|
||||
, text = model.get('content')
|
||||
value = (value === void 0) ? text : value
|
||||
model.set('value', value)
|
||||
}
|
||||
Reference in New Issue
Block a user