pbw 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/pbw/application_controller.rb +3 -16
- data/app/controllers/pbw/base_models_controller.rb +10 -32
- data/app/controllers/pbw/passwords_controller.rb +14 -0
- data/app/controllers/pbw/registrations_controller.rb +9 -6
- data/app/controllers/pbw/sessions_controller.rb +9 -4
- data/app/mailers/pbw/user_mailer.rb +16 -0
- data/app/models/pbw/area.rb +5 -5
- data/app/models/pbw/attached_process.rb +3 -3
- data/app/models/pbw/capability.rb +1 -1
- data/app/models/pbw/command.rb +2 -2
- data/app/models/pbw/constraint.rb +2 -2
- data/app/models/pbw/item.rb +2 -2
- data/app/models/pbw/item_container.rb +4 -4
- data/app/models/pbw/item_conversion.rb +1 -1
- data/app/models/pbw/process.rb +2 -2
- data/app/models/pbw/token.rb +7 -7
- data/app/models/pbw/trigger.rb +3 -3
- data/app/models/pbw/user.rb +30 -8
- data/config/initializers/devise.rb +1 -66
- data/config/locales/pbw.en.yml +7 -0
- data/config/routes.rb +2 -4
- data/lib/generators/pbw/install/install_generator.rb +22 -3
- data/lib/generators/pbw/model_generator.rb +6 -0
- data/lib/generators/pbw/resource_helpers.rb +16 -0
- data/lib/generators/pbw/rules/capability/capability_generator.rb +4 -2
- data/lib/generators/pbw/rules/constraint/constraint_generator.rb +4 -2
- data/lib/generators/pbw/rules/process/process_generator.rb +4 -2
- data/lib/generators/pbw/rules/trigger/trigger_generator.rb +4 -2
- data/lib/generators/pbw/scaffold_generator.rb +0 -12
- data/lib/generators/pbw/templates/app.coffee +5 -3
- data/lib/generators/pbw/templates/application.erb +24 -0
- data/lib/generators/pbw/templates/lifecycle.rb +1 -0
- data/lib/generators/pbw/templates/pbw.coffee +21 -0
- data/lib/generators/pbw/templates/router.coffee +15 -0
- data/lib/generators/pbw/templates/templates/home.jst +10 -1
- data/lib/generators/pbw/templates/templates/login.jst +25 -0
- data/lib/generators/pbw/templates/templates/recover_password.jst +17 -0
- data/lib/generators/pbw/templates/templates/signup.jst +29 -0
- data/lib/generators/pbw/templates/user_recovery.coffee +6 -0
- data/lib/generators/pbw/templates/user_registration.coffee +9 -0
- data/lib/generators/pbw/templates/user_session.coffee +8 -0
- data/lib/generators/pbw/templates/views/edit_view.coffee +15 -8
- data/lib/generators/pbw/templates/views/login_view.coffee +39 -0
- data/lib/generators/pbw/templates/views/new_view.coffee +5 -9
- data/lib/generators/pbw/templates/views/recovery_view.coffee +38 -0
- data/lib/generators/pbw/templates/views/signup_view.coffee +39 -0
- data/lib/pbw/engine.rb +5 -9
- data/lib/pbw/version.rb +1 -1
- data/lib/pbw.rb +15 -2
- data/vendor/assets/javascripts/backbone_datalink.js +21 -0
- metadata +16 -44
- data/app/controllers/pbw/capabilities_controller.rb +0 -7
- data/app/controllers/pbw/constraints_controller.rb +0 -7
- data/app/controllers/pbw/processes_controller.rb +0 -7
- data/app/controllers/pbw/triggers_controller.rb +0 -7
- data/public/Foundation-MIT-LICENSE.txt +0 -20
- data/public/config.rb +0 -26
- data/public/javascripts/foundation/foundation.alerts.js +0 -52
- data/public/javascripts/foundation/foundation.clearing.js +0 -516
- data/public/javascripts/foundation/foundation.cookie.js +0 -74
- data/public/javascripts/foundation/foundation.dropdown.js +0 -178
- data/public/javascripts/foundation/foundation.forms.js +0 -525
- data/public/javascripts/foundation/foundation.interchange.js +0 -271
- data/public/javascripts/foundation/foundation.joyride.js +0 -844
- data/public/javascripts/foundation/foundation.js +0 -447
- data/public/javascripts/foundation/foundation.magellan.js +0 -134
- data/public/javascripts/foundation/foundation.orbit.js +0 -390
- data/public/javascripts/foundation/foundation.placeholder.js +0 -179
- data/public/javascripts/foundation/foundation.reveal.js +0 -330
- data/public/javascripts/foundation/foundation.section.js +0 -422
- data/public/javascripts/foundation/foundation.tooltips.js +0 -208
- data/public/javascripts/foundation/foundation.topbar.js +0 -303
- data/public/javascripts/vendor/custom.modernizr.js +0 -4
- data/public/javascripts/vendor/jquery.js +0 -9807
- data/public/javascripts/vendor/zepto.js +0 -2000
- data/public/sass/_normalize.scss +0 -402
- data/public/sass/_settings.scss +0 -1271
- data/public/sass/app.scss +0 -48
- data/public/stylesheets/app.css +0 -6686
@@ -1,178 +0,0 @@
|
|
1
|
-
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
-
|
3
|
-
;(function ($, window, document, undefined) {
|
4
|
-
'use strict';
|
5
|
-
|
6
|
-
Foundation.libs.dropdown = {
|
7
|
-
name : 'dropdown',
|
8
|
-
|
9
|
-
version : '4.2.0',
|
10
|
-
|
11
|
-
settings : {
|
12
|
-
activeClass: 'open',
|
13
|
-
is_hover: false,
|
14
|
-
opened: function(){},
|
15
|
-
closed: function(){}
|
16
|
-
},
|
17
|
-
|
18
|
-
init : function (scope, method, options) {
|
19
|
-
this.scope = scope || this.scope;
|
20
|
-
Foundation.inherit(this, 'throttle scrollLeft data_options');
|
21
|
-
|
22
|
-
if (typeof method === 'object') {
|
23
|
-
$.extend(true, this.settings, method);
|
24
|
-
}
|
25
|
-
|
26
|
-
if (typeof method !== 'string') {
|
27
|
-
|
28
|
-
if (!this.settings.init) {
|
29
|
-
this.events();
|
30
|
-
}
|
31
|
-
|
32
|
-
return this.settings.init;
|
33
|
-
} else {
|
34
|
-
return this[method].call(this, options);
|
35
|
-
}
|
36
|
-
},
|
37
|
-
|
38
|
-
events : function () {
|
39
|
-
var self = this;
|
40
|
-
|
41
|
-
$(this.scope)
|
42
|
-
.on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
|
43
|
-
var settings = $.extend({}, self.settings, self.data_options($(this)));
|
44
|
-
e.preventDefault();
|
45
|
-
|
46
|
-
if (!settings.is_hover) self.toggle($(this));
|
47
|
-
})
|
48
|
-
.on('mouseenter', '[data-dropdown]', function (e) {
|
49
|
-
var settings = $.extend({}, self.settings, self.data_options($(this)));
|
50
|
-
if (settings.is_hover) self.toggle($(this));
|
51
|
-
})
|
52
|
-
.on('mouseleave', '[data-dropdown-content]', function (e) {
|
53
|
-
var target = $('[data-dropdown="' + $(this).attr('id') + '"]'),
|
54
|
-
settings = $.extend({}, self.settings, self.data_options(target));
|
55
|
-
if (settings.is_hover) self.close.call(self, $(this));
|
56
|
-
})
|
57
|
-
.on('opened.fndtn.dropdown', '[data-dropdown-content]', this.settings.opened)
|
58
|
-
.on('closed.fndtn.dropdown', '[data-dropdown-content]', this.settings.closed);
|
59
|
-
|
60
|
-
$('body').on('click.fndtn.dropdown', function (e) {
|
61
|
-
var parent = $(e.target).closest('[data-dropdown-content]');
|
62
|
-
|
63
|
-
if ($(e.target).data('dropdown')) {
|
64
|
-
return;
|
65
|
-
}
|
66
|
-
if (parent.length > 0 && ($(e.target).is('[data-dropdown-content]') || $.contains(parent.first()[0], e.target))) {
|
67
|
-
e.stopPropagation();
|
68
|
-
return;
|
69
|
-
}
|
70
|
-
|
71
|
-
self.close.call(self, $('[data-dropdown-content]'));
|
72
|
-
});
|
73
|
-
|
74
|
-
$(window).on('resize.fndtn.dropdown', self.throttle(function () {
|
75
|
-
self.resize.call(self);
|
76
|
-
}, 50)).trigger('resize');
|
77
|
-
|
78
|
-
this.settings.init = true;
|
79
|
-
},
|
80
|
-
|
81
|
-
close: function (dropdown) {
|
82
|
-
var self = this;
|
83
|
-
dropdown.each(function () {
|
84
|
-
if ($(this).hasClass(self.settings.activeClass)) {
|
85
|
-
$(this)
|
86
|
-
.css(Foundation.rtl ? 'right':'left', '-99999px')
|
87
|
-
.removeClass(self.settings.activeClass);
|
88
|
-
$(this).trigger('closed');
|
89
|
-
}
|
90
|
-
});
|
91
|
-
},
|
92
|
-
|
93
|
-
open: function (dropdown, target) {
|
94
|
-
this
|
95
|
-
.css(dropdown
|
96
|
-
.addClass(this.settings.activeClass), target);
|
97
|
-
dropdown.trigger('opened');
|
98
|
-
},
|
99
|
-
|
100
|
-
toggle : function (target) {
|
101
|
-
var dropdown = $('#' + target.data('dropdown'));
|
102
|
-
|
103
|
-
this.close.call(this, $('[data-dropdown-content]').not(dropdown));
|
104
|
-
|
105
|
-
if (dropdown.hasClass(this.settings.activeClass)) {
|
106
|
-
this.close.call(this, dropdown);
|
107
|
-
} else {
|
108
|
-
this.close.call(this, $('[data-dropdown-content]'))
|
109
|
-
this.open.call(this, dropdown, target);
|
110
|
-
}
|
111
|
-
},
|
112
|
-
|
113
|
-
resize : function () {
|
114
|
-
var dropdown = $('[data-dropdown-content].open'),
|
115
|
-
target = $("[data-dropdown='" + dropdown.attr('id') + "']");
|
116
|
-
|
117
|
-
if (dropdown.length && target.length) {
|
118
|
-
this.css(dropdown, target);
|
119
|
-
}
|
120
|
-
},
|
121
|
-
|
122
|
-
css : function (dropdown, target) {
|
123
|
-
var offset_parent = dropdown.offsetParent();
|
124
|
-
// temporary workaround until 4.2
|
125
|
-
if (offset_parent.length > 0 && /body/i.test(dropdown.offsetParent()[0].nodeName)) {
|
126
|
-
var position = target.offset();
|
127
|
-
position.top -= dropdown.offsetParent().offset().top;
|
128
|
-
position.left -= dropdown.offsetParent().offset().left;
|
129
|
-
} else {
|
130
|
-
var position = target.position();
|
131
|
-
}
|
132
|
-
|
133
|
-
if (this.small()) {
|
134
|
-
dropdown.css({
|
135
|
-
position : 'absolute',
|
136
|
-
width: '95%',
|
137
|
-
left: '2.5%',
|
138
|
-
'max-width': 'none',
|
139
|
-
top: position.top + this.outerHeight(target)
|
140
|
-
});
|
141
|
-
} else {
|
142
|
-
if (!Foundation.rtl && $(window).width() > this.outerWidth(dropdown) + target.offset().left) {
|
143
|
-
var left = position.left;
|
144
|
-
if (dropdown.hasClass('right')) {
|
145
|
-
dropdown.removeClass('right');
|
146
|
-
}
|
147
|
-
} else {
|
148
|
-
if (!dropdown.hasClass('right')) {
|
149
|
-
dropdown.addClass('right');
|
150
|
-
}
|
151
|
-
var left = position.left - (this.outerWidth(dropdown) - this.outerWidth(target));
|
152
|
-
}
|
153
|
-
|
154
|
-
dropdown.attr('style', '').css({
|
155
|
-
position : 'absolute',
|
156
|
-
top: position.top + this.outerHeight(target),
|
157
|
-
left: left
|
158
|
-
});
|
159
|
-
}
|
160
|
-
|
161
|
-
return dropdown;
|
162
|
-
},
|
163
|
-
|
164
|
-
small : function () {
|
165
|
-
return $(window).width() < 768 || $('html').hasClass('lt-ie9');
|
166
|
-
},
|
167
|
-
|
168
|
-
off: function () {
|
169
|
-
$(this.scope).off('.fndtn.dropdown');
|
170
|
-
$('html, body').off('.fndtn.dropdown');
|
171
|
-
$(window).off('.fndtn.dropdown');
|
172
|
-
$('[data-dropdown-content]').off('.fndtn.dropdown');
|
173
|
-
this.settings.init = false;
|
174
|
-
},
|
175
|
-
|
176
|
-
reflow : function () {}
|
177
|
-
};
|
178
|
-
}(Foundation.zj, this, this.document));
|
@@ -1,525 +0,0 @@
|
|
1
|
-
(function ($, window, document, undefined) {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
Foundation.libs.forms = {
|
5
|
-
name: 'forms',
|
6
|
-
|
7
|
-
version: '4.2.3',
|
8
|
-
|
9
|
-
cache: {},
|
10
|
-
|
11
|
-
settings: {
|
12
|
-
disable_class: 'no-custom',
|
13
|
-
last_combo : null
|
14
|
-
},
|
15
|
-
|
16
|
-
init: function (scope, method, options) {
|
17
|
-
|
18
|
-
if (typeof method === 'object') {
|
19
|
-
$.extend(true, this.settings, method);
|
20
|
-
}
|
21
|
-
|
22
|
-
if (typeof method !== 'string') {
|
23
|
-
if (!this.settings.init) {
|
24
|
-
this.events();
|
25
|
-
}
|
26
|
-
|
27
|
-
this.assemble();
|
28
|
-
|
29
|
-
return this.settings.init;
|
30
|
-
} else {
|
31
|
-
return this[method].call(this, options);
|
32
|
-
}
|
33
|
-
},
|
34
|
-
|
35
|
-
assemble: function () {
|
36
|
-
$('form.custom input[type="radio"]', $(this.scope))
|
37
|
-
.not('[data-customforms="disabled"]')
|
38
|
-
.not('.' + this.settings.disable_class)
|
39
|
-
.each(this.append_custom_markup);
|
40
|
-
$('form.custom input[type="checkbox"]', $(this.scope))
|
41
|
-
.not('[data-customforms="disabled"]')
|
42
|
-
.not('.' + this.settings.disable_class)
|
43
|
-
.each(this.append_custom_markup);
|
44
|
-
$('form.custom select', $(this.scope))
|
45
|
-
.not('[data-customforms="disabled"]')
|
46
|
-
.not('.' + this.settings.disable_class)
|
47
|
-
.not('[multiple=multiple]')
|
48
|
-
.each(this.append_custom_select);
|
49
|
-
},
|
50
|
-
|
51
|
-
events: function () {
|
52
|
-
var self = this;
|
53
|
-
|
54
|
-
$(this.scope)
|
55
|
-
.on('click.fndtn.forms', 'form.custom span.custom.checkbox', function (e) {
|
56
|
-
e.preventDefault();
|
57
|
-
e.stopPropagation();
|
58
|
-
self.toggle_checkbox($(this));
|
59
|
-
})
|
60
|
-
.on('click.fndtn.forms', 'form.custom span.custom.radio', function (e) {
|
61
|
-
e.preventDefault();
|
62
|
-
e.stopPropagation();
|
63
|
-
self.toggle_radio($(this));
|
64
|
-
})
|
65
|
-
.on('change.fndtn.forms', 'form.custom select', function (e, force_refresh) {
|
66
|
-
if ($(this).is('[data-customforms="disabled"]')) return;
|
67
|
-
self.refresh_custom_select($(this), force_refresh);
|
68
|
-
})
|
69
|
-
.on('click.fndtn.forms', 'form.custom label', function (e) {
|
70
|
-
if ($(e.target).is('label')) {
|
71
|
-
var $associatedElement = $('#' + self.escape($(this).attr('for'))).not('[data-customforms="disabled"]'),
|
72
|
-
$customCheckbox,
|
73
|
-
$customRadio;
|
74
|
-
|
75
|
-
if ($associatedElement.length !== 0) {
|
76
|
-
if ($associatedElement.attr('type') === 'checkbox') {
|
77
|
-
e.preventDefault();
|
78
|
-
$customCheckbox = $(this).find('span.custom.checkbox');
|
79
|
-
//the checkbox might be outside after the label or inside of another element
|
80
|
-
if ($customCheckbox.length === 0) {
|
81
|
-
$customCheckbox = $associatedElement.add(this).siblings('span.custom.checkbox').first();
|
82
|
-
}
|
83
|
-
self.toggle_checkbox($customCheckbox);
|
84
|
-
} else if ($associatedElement.attr('type') === 'radio') {
|
85
|
-
e.preventDefault();
|
86
|
-
$customRadio = $(this).find('span.custom.radio');
|
87
|
-
//the radio might be outside after the label or inside of another element
|
88
|
-
if ($customRadio.length === 0) {
|
89
|
-
$customRadio = $associatedElement.add(this).siblings('span.custom.radio').first();
|
90
|
-
}
|
91
|
-
self.toggle_radio($customRadio);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}
|
95
|
-
})
|
96
|
-
.on('mousedown.fndtn.forms', 'form.custom div.custom.dropdown', function () {
|
97
|
-
return false;
|
98
|
-
})
|
99
|
-
.on('click.fndtn.forms', 'form.custom div.custom.dropdown a.current, form.custom div.custom.dropdown a.selector', function (e) {
|
100
|
-
var $this = $(this),
|
101
|
-
$dropdown = $this.closest('div.custom.dropdown'),
|
102
|
-
$select = getFirstPrevSibling($dropdown, 'select');
|
103
|
-
|
104
|
-
// make sure other dropdowns close
|
105
|
-
if (!$dropdown.hasClass('open')) $(self.scope).trigger('click');
|
106
|
-
|
107
|
-
e.preventDefault();
|
108
|
-
if (false === $select.is(':disabled')) {
|
109
|
-
$dropdown.toggleClass('open');
|
110
|
-
|
111
|
-
if ($dropdown.hasClass('open')) {
|
112
|
-
$(self.scope).on('click.fndtn.forms.customdropdown', function () {
|
113
|
-
$dropdown.removeClass('open');
|
114
|
-
$(self.scope).off('.fndtn.forms.customdropdown');
|
115
|
-
});
|
116
|
-
} else {
|
117
|
-
$(self.scope).on('.fndtn.forms.customdropdown');
|
118
|
-
}
|
119
|
-
return false;
|
120
|
-
}
|
121
|
-
})
|
122
|
-
.on('click.fndtn.forms touchend.fndtn.forms', 'form.custom div.custom.dropdown li', function (e) {
|
123
|
-
var $this = $(this),
|
124
|
-
$customDropdown = $this.closest('div.custom.dropdown'),
|
125
|
-
$select = getFirstPrevSibling($customDropdown, 'select'),
|
126
|
-
selectedIndex = 0;
|
127
|
-
|
128
|
-
e.preventDefault();
|
129
|
-
e.stopPropagation();
|
130
|
-
|
131
|
-
if (!$(this).hasClass('disabled')) {
|
132
|
-
$('div.dropdown').not($customDropdown).removeClass('open');
|
133
|
-
|
134
|
-
var $oldThis = $this.closest('ul')
|
135
|
-
.find('li.selected');
|
136
|
-
$oldThis.removeClass('selected');
|
137
|
-
|
138
|
-
$this.addClass('selected');
|
139
|
-
|
140
|
-
$customDropdown.removeClass('open')
|
141
|
-
.find('a.current')
|
142
|
-
.text($this.text());
|
143
|
-
|
144
|
-
$this.closest('ul').find('li').each(function (index) {
|
145
|
-
if ($this[0] === this) {
|
146
|
-
selectedIndex = index;
|
147
|
-
}
|
148
|
-
});
|
149
|
-
$select[0].selectedIndex = selectedIndex;
|
150
|
-
|
151
|
-
//store the old value in data
|
152
|
-
$select.data('prevalue', $oldThis.html());
|
153
|
-
$select.trigger('change');
|
154
|
-
}
|
155
|
-
});
|
156
|
-
|
157
|
-
$(window).on('keydown', function (e) {
|
158
|
-
var focus = document.activeElement,
|
159
|
-
self = Foundation.libs.forms,
|
160
|
-
dropdown = $('.custom.dropdown.open');
|
161
|
-
|
162
|
-
if (dropdown.length > 0) {
|
163
|
-
e.preventDefault();
|
164
|
-
|
165
|
-
if (e.which === 13) {
|
166
|
-
dropdown.find('li.selected').trigger('click');
|
167
|
-
}
|
168
|
-
|
169
|
-
if (e.which === 27) {
|
170
|
-
dropdown.removeClass('open');
|
171
|
-
}
|
172
|
-
|
173
|
-
if (e.which >= 65 && e.which <= 90) {
|
174
|
-
var next = self.go_to(dropdown, e.which),
|
175
|
-
current = dropdown.find('li.selected');
|
176
|
-
|
177
|
-
if (next) {
|
178
|
-
current.removeClass('selected');
|
179
|
-
self.scrollTo(next.addClass('selected'), 300);
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
if (e.which === 38) {
|
184
|
-
var current = dropdown.find('li.selected'),
|
185
|
-
prev = current.prev(':not(.disabled)');
|
186
|
-
|
187
|
-
if (prev.length > 0) {
|
188
|
-
prev.parent()[0].scrollTop = prev.parent().scrollTop() - self.outerHeight(prev);
|
189
|
-
current.removeClass('selected');
|
190
|
-
prev.addClass('selected');
|
191
|
-
}
|
192
|
-
} else if (e.which === 40) {
|
193
|
-
var current = dropdown.find('li.selected'),
|
194
|
-
next = current.next(':not(.disabled)');
|
195
|
-
|
196
|
-
if (next.length > 0) {
|
197
|
-
next.parent()[0].scrollTop = next.parent().scrollTop() + self.outerHeight(next);
|
198
|
-
current.removeClass('selected');
|
199
|
-
next.addClass('selected');
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}
|
203
|
-
});
|
204
|
-
|
205
|
-
this.settings.init = true;
|
206
|
-
},
|
207
|
-
|
208
|
-
go_to: function (dropdown, character) {
|
209
|
-
var lis = dropdown.find('li'),
|
210
|
-
count = lis.length;
|
211
|
-
|
212
|
-
if (count > 0) {
|
213
|
-
for (var i = 0; i < count; i++) {
|
214
|
-
var first_letter = lis.eq(i).text().charAt(0).toLowerCase();
|
215
|
-
if (first_letter === String.fromCharCode(character).toLowerCase()) return lis.eq(i);
|
216
|
-
}
|
217
|
-
}
|
218
|
-
},
|
219
|
-
|
220
|
-
scrollTo: function (el, duration) {
|
221
|
-
if (duration < 0) return;
|
222
|
-
var parent = el.parent();
|
223
|
-
var li_height = this.outerHeight(el);
|
224
|
-
var difference = (li_height * (el.index())) - parent.scrollTop();
|
225
|
-
var perTick = difference / duration * 10;
|
226
|
-
|
227
|
-
this.scrollToTimerCache = setTimeout(function () {
|
228
|
-
if (!isNaN(parseInt(perTick, 10))) {
|
229
|
-
parent[0].scrollTop = parent.scrollTop() + perTick;
|
230
|
-
this.scrollTo(el, duration - 10);
|
231
|
-
}
|
232
|
-
}.bind(this), 10);
|
233
|
-
},
|
234
|
-
|
235
|
-
append_custom_markup: function (idx, sel) {
|
236
|
-
var $this = $(sel),
|
237
|
-
type = $this.attr('type'),
|
238
|
-
$span = $this.next('span.custom.' + type);
|
239
|
-
|
240
|
-
if (!$this.parent().hasClass('switch')) {
|
241
|
-
$this.addClass('hidden-field');
|
242
|
-
}
|
243
|
-
|
244
|
-
if ($span.length === 0) {
|
245
|
-
$span = $('<span class="custom ' + type + '"></span>').insertAfter($this);
|
246
|
-
}
|
247
|
-
|
248
|
-
$span.toggleClass('checked', $this.is(':checked'));
|
249
|
-
$span.toggleClass('disabled', $this.is(':disabled'));
|
250
|
-
},
|
251
|
-
|
252
|
-
append_custom_select: function (idx, sel) {
|
253
|
-
var self = Foundation.libs.forms,
|
254
|
-
$this = $(sel),
|
255
|
-
$customSelect = $this.next('div.custom.dropdown'),
|
256
|
-
$customList = $customSelect.find('ul'),
|
257
|
-
$selectCurrent = $customSelect.find(".current"),
|
258
|
-
$selector = $customSelect.find(".selector"),
|
259
|
-
$options = $this.find('option'),
|
260
|
-
$selectedOption = $options.filter(':selected'),
|
261
|
-
copyClasses = $this.attr('class') ? $this.attr('class').split(' ') : [],
|
262
|
-
maxWidth = 0,
|
263
|
-
liHtml = '',
|
264
|
-
$listItems,
|
265
|
-
$currentSelect = false;
|
266
|
-
|
267
|
-
if ($customSelect.length === 0) {
|
268
|
-
var customSelectSize = $this.hasClass('small') ? 'small' : $this.hasClass('medium') ? 'medium' : $this.hasClass('large') ? 'large' : $this.hasClass('expand') ? 'expand' : '';
|
269
|
-
|
270
|
-
$customSelect = $('<div class="' + ['custom', 'dropdown', customSelectSize].concat(copyClasses).filter(function (item, idx, arr) {
|
271
|
-
if (item === '') return false;
|
272
|
-
return arr.indexOf(item) === idx;
|
273
|
-
}).join(' ') + '"><a href="#" class="selector"></a><ul /></div>');
|
274
|
-
|
275
|
-
$selector = $customSelect.find(".selector");
|
276
|
-
$customList = $customSelect.find("ul");
|
277
|
-
|
278
|
-
liHtml = $options.map(function () {
|
279
|
-
var copyClasses = $(this).attr('class') ? $(this).attr('class') : '';
|
280
|
-
return "<li class='" + copyClasses + "'>" + $(this).html() + "</li>";
|
281
|
-
}).get().join('');
|
282
|
-
|
283
|
-
$customList.append(liHtml);
|
284
|
-
|
285
|
-
$currentSelect = $customSelect
|
286
|
-
.prepend('<a href="#" class="current">' + $selectedOption.html() + '</a>')
|
287
|
-
.find(".current");
|
288
|
-
|
289
|
-
$this.after($customSelect)
|
290
|
-
.addClass('hidden-field');
|
291
|
-
} else {
|
292
|
-
liHtml = $options.map(function () {
|
293
|
-
return "<li>" + $(this).html() + "</li>";
|
294
|
-
})
|
295
|
-
.get().join('');
|
296
|
-
|
297
|
-
$customList.html('')
|
298
|
-
.append(liHtml);
|
299
|
-
|
300
|
-
} // endif $customSelect.length === 0
|
301
|
-
|
302
|
-
self.assign_id($this, $customSelect);
|
303
|
-
$customSelect.toggleClass('disabled', $this.is(':disabled'));
|
304
|
-
$listItems = $customList.find('li');
|
305
|
-
|
306
|
-
// cache list length
|
307
|
-
self.cache[$customSelect.data('id')] = $listItems.length;
|
308
|
-
|
309
|
-
$options.each(function (index) {
|
310
|
-
if (this.selected) {
|
311
|
-
$listItems.eq(index).addClass('selected');
|
312
|
-
|
313
|
-
if ($currentSelect) {
|
314
|
-
$currentSelect.html($(this).html());
|
315
|
-
}
|
316
|
-
}
|
317
|
-
if ($(this).is(':disabled')) {
|
318
|
-
$listItems.eq(index).addClass('disabled');
|
319
|
-
}
|
320
|
-
});
|
321
|
-
|
322
|
-
//
|
323
|
-
// If we're not specifying a predetermined form size.
|
324
|
-
//
|
325
|
-
if (!$customSelect.is('.small, .medium, .large, .expand')) {
|
326
|
-
|
327
|
-
// ------------------------------------------------------------------------------------
|
328
|
-
// This is a work-around for when elements are contained within hidden parents.
|
329
|
-
// For example, when custom-form elements are inside of a hidden reveal modal.
|
330
|
-
//
|
331
|
-
// We need to display the current custom list element as well as hidden parent elements
|
332
|
-
// in order to properly calculate the list item element's width property.
|
333
|
-
// -------------------------------------------------------------------------------------
|
334
|
-
|
335
|
-
$customSelect.addClass('open');
|
336
|
-
//
|
337
|
-
// Quickly, display all parent elements.
|
338
|
-
// This should help us calcualate the width of the list item's within the drop down.
|
339
|
-
//
|
340
|
-
var self = Foundation.libs.forms;
|
341
|
-
self.hidden_fix.adjust($customList);
|
342
|
-
|
343
|
-
maxWidth = (self.outerWidth($listItems) > maxWidth) ? self.outerWidth($listItems) : maxWidth;
|
344
|
-
|
345
|
-
Foundation.libs.forms.hidden_fix.reset();
|
346
|
-
|
347
|
-
$customSelect.removeClass('open');
|
348
|
-
|
349
|
-
} // endif
|
350
|
-
|
351
|
-
},
|
352
|
-
|
353
|
-
assign_id: function ($select, $customSelect) {
|
354
|
-
var id = [+new Date(), Foundation.random_str(5)].join('-');
|
355
|
-
$select.attr('data-id', id);
|
356
|
-
$customSelect.attr('data-id', id);
|
357
|
-
},
|
358
|
-
|
359
|
-
refresh_custom_select: function ($select, force_refresh) {
|
360
|
-
var self = this;
|
361
|
-
var maxWidth = 0,
|
362
|
-
$customSelect = $select.next(),
|
363
|
-
$options = $select.find('option'),
|
364
|
-
$listItems = $customSelect.find('li');
|
365
|
-
|
366
|
-
if ($listItems.length !== this.cache[$customSelect.data('id')] || force_refresh) {
|
367
|
-
$customSelect.find('ul').html('');
|
368
|
-
|
369
|
-
$options.each(function () {
|
370
|
-
var $li = $('<li>' + $(this).html() + '</li>');
|
371
|
-
$customSelect.find('ul').append($li);
|
372
|
-
});
|
373
|
-
|
374
|
-
// re-populate
|
375
|
-
$options.each(function (index) {
|
376
|
-
if (this.selected) {
|
377
|
-
$customSelect.find('li').eq(index).addClass('selected');
|
378
|
-
$customSelect.find('.current').html($(this).html());
|
379
|
-
}
|
380
|
-
if ($(this).is(':disabled')) {
|
381
|
-
$customSelect.find('li').eq(index).addClass('disabled');
|
382
|
-
}
|
383
|
-
});
|
384
|
-
|
385
|
-
// fix width
|
386
|
-
$customSelect.removeAttr('style')
|
387
|
-
.find('ul').removeAttr('style');
|
388
|
-
$customSelect.find('li').each(function () {
|
389
|
-
$customSelect.addClass('open');
|
390
|
-
if (self.outerWidth($(this)) > maxWidth) {
|
391
|
-
maxWidth = self.outerWidth($(this));
|
392
|
-
}
|
393
|
-
$customSelect.removeClass('open');
|
394
|
-
});
|
395
|
-
|
396
|
-
$listItems = $customSelect.find('li');
|
397
|
-
// cache list length
|
398
|
-
this.cache[$customSelect.data('id')] = $listItems.length;
|
399
|
-
}
|
400
|
-
},
|
401
|
-
|
402
|
-
toggle_checkbox: function ($element) {
|
403
|
-
var $input = $element.prev(),
|
404
|
-
input = $input[0];
|
405
|
-
|
406
|
-
if (false === $input.is(':disabled')) {
|
407
|
-
input.checked = ((input.checked) ? false : true);
|
408
|
-
$element.toggleClass('checked');
|
409
|
-
|
410
|
-
$input.trigger('change');
|
411
|
-
}
|
412
|
-
},
|
413
|
-
|
414
|
-
toggle_radio: function ($element) {
|
415
|
-
var $input = $element.prev(),
|
416
|
-
$form = $input.closest('form.custom'),
|
417
|
-
input = $input[0];
|
418
|
-
|
419
|
-
if (false === $input.is(':disabled')) {
|
420
|
-
$form.find('input[type="radio"][name="' + this.escape($input.attr('name')) + '"]')
|
421
|
-
.next().not($element).removeClass('checked');
|
422
|
-
|
423
|
-
if (!$element.hasClass('checked')) {
|
424
|
-
$element.toggleClass('checked');
|
425
|
-
}
|
426
|
-
|
427
|
-
input.checked = $element.hasClass('checked');
|
428
|
-
|
429
|
-
$input.trigger('change');
|
430
|
-
}
|
431
|
-
},
|
432
|
-
|
433
|
-
escape: function (text) {
|
434
|
-
if (!text) return '';
|
435
|
-
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
436
|
-
},
|
437
|
-
|
438
|
-
hidden_fix: {
|
439
|
-
/**
|
440
|
-
* Sets all hidden parent elements and self to visibile.
|
441
|
-
*
|
442
|
-
* @method adjust
|
443
|
-
* @param {jQuery Object} $child
|
444
|
-
*/
|
445
|
-
|
446
|
-
// We'll use this to temporarily store style properties.
|
447
|
-
tmp: [],
|
448
|
-
|
449
|
-
// We'll use this to set hidden parent elements.
|
450
|
-
hidden: null,
|
451
|
-
|
452
|
-
adjust: function ($child) {
|
453
|
-
// Internal reference.
|
454
|
-
var _self = this;
|
455
|
-
|
456
|
-
// Set all hidden parent elements, including this element.
|
457
|
-
_self.hidden = $child.parents();
|
458
|
-
_self.hidden = _self.hidden.add($child).filter(":hidden");
|
459
|
-
|
460
|
-
// Loop through all hidden elements.
|
461
|
-
_self.hidden.each(function () {
|
462
|
-
|
463
|
-
// Cache the element.
|
464
|
-
var $elem = $(this);
|
465
|
-
|
466
|
-
// Store the style attribute.
|
467
|
-
// Undefined if element doesn't have a style attribute.
|
468
|
-
_self.tmp.push($elem.attr('style'));
|
469
|
-
|
470
|
-
// Set the element's display property to block,
|
471
|
-
// but ensure it's visibility is hidden.
|
472
|
-
$elem.css({
|
473
|
-
'visibility': 'hidden',
|
474
|
-
'display': 'block'
|
475
|
-
});
|
476
|
-
});
|
477
|
-
|
478
|
-
}, // end adjust
|
479
|
-
|
480
|
-
/**
|
481
|
-
* Resets the elements previous state.
|
482
|
-
*
|
483
|
-
* @method reset
|
484
|
-
*/
|
485
|
-
reset: function () {
|
486
|
-
// Internal reference.
|
487
|
-
var _self = this;
|
488
|
-
// Loop through our hidden element collection.
|
489
|
-
_self.hidden.each(function (i) {
|
490
|
-
// Cache this element.
|
491
|
-
var $elem = $(this),
|
492
|
-
_tmp = _self.tmp[i]; // Get the stored 'style' value for this element.
|
493
|
-
|
494
|
-
// If the stored value is undefined.
|
495
|
-
if (_tmp === undefined)
|
496
|
-
// Remove the style attribute.
|
497
|
-
$elem.removeAttr('style');
|
498
|
-
else
|
499
|
-
// Otherwise, reset the element style attribute.
|
500
|
-
$elem.attr('style', _tmp);
|
501
|
-
});
|
502
|
-
// Reset the tmp array.
|
503
|
-
_self.tmp = [];
|
504
|
-
// Reset the hidden elements variable.
|
505
|
-
_self.hidden = null;
|
506
|
-
|
507
|
-
} // end reset
|
508
|
-
},
|
509
|
-
|
510
|
-
off: function () {
|
511
|
-
$(this.scope).off('.fndtn.forms');
|
512
|
-
},
|
513
|
-
|
514
|
-
reflow : function () {}
|
515
|
-
};
|
516
|
-
|
517
|
-
var getFirstPrevSibling = function($el, selector) {
|
518
|
-
var $el = $el.prev();
|
519
|
-
while ($el.length) {
|
520
|
-
if ($el.is(selector)) return $el;
|
521
|
-
$el = $el.prev();
|
522
|
-
}
|
523
|
-
return $();
|
524
|
-
};
|
525
|
-
}(Foundation.zj, this, this.document));
|