mutiny-rails 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mutiny/rails/version.rb +1 -1
- data/vendor/assets/javascripts/mutiny.js +180 -186
- data/vendor/assets/javascripts/mutiny.min.js +2 -2
- metadata +2 -2
data/lib/mutiny/rails/version.rb
CHANGED
@@ -1,208 +1,202 @@
|
|
1
|
-
/*! Mutiny v0.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
}
|
7
|
-
};
|
1
|
+
/*! Mutiny v0.2.0 - http://mutinyjs.com/ */
|
2
|
+
(function(window, $, undefined) {
|
3
|
+
$(function(){
|
4
|
+
Mutiny.init();
|
5
|
+
});
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
7
|
+
var Mutiny = window.Mutiny = {
|
8
|
+
init: function(el, namespace) {
|
9
|
+
namespace = namespace || 'mutiny';
|
10
|
+
el = el || $('*');
|
11
|
+
|
12
|
+
var mutiny_call = function($instigator, widget, instance_options){
|
13
|
+
if(Mutiny[widget] === undefined) {
|
14
|
+
throw '"' + widget + '" not found';
|
15
|
+
}
|
16
|
+
|
17
|
+
var options = $.extend({}, Mutiny[widget].defaults);
|
18
|
+
if(isString(instance_options)) {
|
19
|
+
options[Mutiny[widget].string_arg] = instance_options;
|
20
|
+
} else {
|
21
|
+
$.extend(options, instance_options);
|
22
|
+
}
|
23
|
+
Mutiny[widget].init($instigator, options);
|
24
|
+
};
|
25
|
+
|
26
|
+
el.each(function(i, e) {
|
27
|
+
var $e = $(e);
|
28
|
+
var data = $e.data();
|
29
|
+
if(namespace in data) {
|
30
|
+
var directives = data[namespace];
|
31
|
+
if(isString(directives)) {
|
32
|
+
/* data-mutiny='slider' */
|
33
|
+
mutiny_call($e, directives, {});
|
34
|
+
} else if(typeof data === 'object') {
|
35
|
+
/* data-mutiny='{"slider": {"some": "options"}}' */
|
36
|
+
for(var directive in directives) {
|
37
|
+
mutiny_call($e, directive, directives[directive]);
|
38
|
+
}
|
17
39
|
} else {
|
18
|
-
|
40
|
+
throw 'Unsupported data';
|
19
41
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
case "string":
|
28
|
-
mutiny_call($e, data, {});
|
29
|
-
break;
|
30
|
-
|
31
|
-
case "object":
|
32
|
-
for (var directive in data) {
|
33
|
-
mutiny_call($e, directive, data[directive]);
|
34
|
-
}
|
35
|
-
break;
|
36
|
-
|
37
|
-
default:
|
38
|
-
throw "Unsupported data";
|
42
|
+
}
|
43
|
+
|
44
|
+
for(var key in data) {
|
45
|
+
if(key.indexOf(namespace) === 0 && key != namespace) {
|
46
|
+
var widget = key.replace(namespace, '').toLowerCase();
|
47
|
+
var options = data[key];
|
48
|
+
mutiny_call($e, widget, options || {});
|
39
49
|
}
|
50
|
+
}
|
40
51
|
});
|
41
|
-
|
52
|
+
}
|
42
53
|
};
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
}
|
55
|
+
function isString(obj) {
|
56
|
+
return !!obj.substring;
|
57
|
+
}
|
47
58
|
|
48
59
|
Mutiny.accordion = {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
_hrefIndex: function($search, href) {
|
55
|
-
var active_index = -1;
|
56
|
-
$search.find("a").each(function(index, anchorEl) {
|
57
|
-
if ($(anchorEl).attr("href") == href) {
|
58
|
-
active_index = index;
|
59
|
-
return false;
|
60
|
-
}
|
61
|
-
});
|
62
|
-
return active_index;
|
63
|
-
},
|
64
|
-
init: function($instigator, options) {
|
65
|
-
var hash = window.location.hash || undefined;
|
66
|
-
var $menu = options.menu ? $(options.menu) : undefined;
|
67
|
-
if (hash) {
|
68
|
-
var active_index = this._hrefIndex($menu || $instigator, hash);
|
69
|
-
if (active_index > -1) {
|
70
|
-
options.active = active_index;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
if ($menu) {
|
74
|
-
var self = this;
|
75
|
-
$menu.find("a").click(function(event) {
|
76
|
-
var toggle_index = self._hrefIndex($menu, $(event.target).attr("href"));
|
77
|
-
if (toggle_index > -1) {
|
78
|
-
$instigator.accordion("activate", toggle_index);
|
79
|
-
}
|
80
|
-
});
|
81
|
-
}
|
82
|
-
$instigator.accordion(options);
|
60
|
+
'defaults': {'autoHeight': false, 'collapsible': true, 'active': false},
|
61
|
+
'init': function($instigator, options){
|
62
|
+
var hash = window.location.hash;
|
63
|
+
if(hash && $instigator.find(hash).length > 0) {
|
64
|
+
options.active = hash;
|
83
65
|
}
|
66
|
+
$instigator.accordion(options);
|
67
|
+
|
68
|
+
$(window).on('hashchange', function(event) {
|
69
|
+
var hash = window.location.hash;
|
70
|
+
if(hash && $instigator.find(hash).length > 0) {
|
71
|
+
$instigator.accordion('activate', hash);
|
72
|
+
}
|
73
|
+
});
|
74
|
+
}
|
84
75
|
};
|
85
76
|
|
86
77
|
Mutiny.datepicker = {
|
87
|
-
|
88
|
-
|
89
|
-
|
78
|
+
'init': function($instigator, options) {
|
79
|
+
$instigator.datepicker(options);
|
80
|
+
}
|
90
81
|
};
|
91
82
|
|
92
83
|
Mutiny.slider = {
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
val = options.max;
|
137
|
-
}
|
138
|
-
if (val < options.min) {
|
139
|
-
val = options.min;
|
140
|
-
}
|
141
|
-
if (isNaN(val)) {
|
142
|
-
val = options.value;
|
143
|
-
}
|
144
|
-
$instigator.val(val);
|
145
|
-
$ui.slider("value", val);
|
146
|
-
});
|
147
|
-
if (options.minLabel) {
|
148
|
-
$ui.append(this._createFormatSpan(options.minLabel, options.min, "min-label"));
|
149
|
-
}
|
150
|
-
if (options.maxLabel) {
|
151
|
-
$ui.append(this._createFormatSpan(options.maxLabel, options.max, "max-label"));
|
152
|
-
}
|
153
|
-
$ui.slider(options);
|
154
|
-
if (options.valueLabel) {
|
155
|
-
var $valueLabel = $(this._createFormatSpan(options.valueLabel, options.value, "valueLabel")).appendTo($ui.find(".ui-slider-handle"));
|
156
|
-
var $value = $valueLabel.find("span");
|
157
|
-
$instigator.change(function() {
|
158
|
-
$value.html($instigator.val());
|
159
|
-
});
|
160
|
-
}
|
84
|
+
'defaults': {'range': 'min'},
|
85
|
+
'_createFormatSpan': function(format, value, className) {
|
86
|
+
if(value === null || value === '') {
|
87
|
+
/* If value does not exist, force a non-empty element draw. Starting with empty
|
88
|
+
* element prevents correct drawing when it has been replace with real contents.
|
89
|
+
*/
|
90
|
+
value = ' ';
|
91
|
+
}
|
92
|
+
var inner = format.replace('%s', '<span>' + value + '</span>');
|
93
|
+
if(className) {
|
94
|
+
return '<span class="' + className + '">' + inner + '</span>';
|
95
|
+
} else {
|
96
|
+
return '<span>' + inner + '</span>';
|
97
|
+
}
|
98
|
+
},
|
99
|
+
'init': function($instigator, options){
|
100
|
+
var $ui;
|
101
|
+
if(options.target) {
|
102
|
+
$ui = $(options.target);
|
103
|
+
} else {
|
104
|
+
var id = $instigator.attr('id');
|
105
|
+
var extras = '';
|
106
|
+
if(id) {
|
107
|
+
extras = ' id="' + id + '-mutiny-slider"';
|
108
|
+
}
|
109
|
+
$ui = $('<div' + extras + '></div>').insertAfter($instigator);
|
110
|
+
}
|
111
|
+
|
112
|
+
options.value = $instigator.val();
|
113
|
+
options.slide = function(event, slider) {
|
114
|
+
/* Force trigger of .change() to propagate the value elsewhere. */
|
115
|
+
$instigator.val(slider.value).change();
|
116
|
+
};
|
117
|
+
|
118
|
+
if ($instigator.is('select')) {
|
119
|
+
var $options = $instigator.find('option');
|
120
|
+
options.min = Number($options.first().val());
|
121
|
+
options.max = Number($options.last().val());
|
122
|
+
options.step = (options.max - options.min) / ($options.length - 1);
|
123
|
+
} else {
|
124
|
+
$.each(['min', 'max', 'step'], function(i, attr) {
|
125
|
+
options[attr] = Number(options[attr] || $instigator.attr(attr) || $instigator.data(attr));
|
126
|
+
});
|
161
127
|
}
|
128
|
+
|
129
|
+
$instigator.change(function(){
|
130
|
+
var val = Number($instigator.val());
|
131
|
+
if (val > options.max) { val = options.max; }
|
132
|
+
if (val < options.min) { val = options.min; }
|
133
|
+
if (isNaN(val)) { val = options.value; }
|
134
|
+
$instigator.val(val);
|
135
|
+
$ui.slider('value', val);
|
136
|
+
});
|
137
|
+
|
138
|
+
if(options.minLabel) {
|
139
|
+
$ui.append(this._createFormatSpan(options.minLabel, options.min, 'min-label'));
|
140
|
+
}
|
141
|
+
if(options.maxLabel) {
|
142
|
+
$ui.append(this._createFormatSpan(options.maxLabel, options.max, 'max-label'));
|
143
|
+
}
|
144
|
+
|
145
|
+
$ui.slider(options);
|
146
|
+
|
147
|
+
/* Need to append the element to a DOM loaded slider so this occurs after the slider instantiation. */
|
148
|
+
if(options.valueLabel) {
|
149
|
+
var $valueLabel = $(this._createFormatSpan(options.valueLabel, options.value, 'value-label')).appendTo($ui.find('.ui-slider-handle'));
|
150
|
+
var $value = $valueLabel.find('span');
|
151
|
+
$instigator.change(function() {
|
152
|
+
$value.html($instigator.val());
|
153
|
+
});
|
154
|
+
}
|
155
|
+
}
|
162
156
|
};
|
163
157
|
|
164
158
|
Mutiny.toggler = {
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
if (options.preventDefault) {
|
203
|
-
event.preventDefault();
|
204
|
-
}
|
205
|
-
});
|
159
|
+
'defaults': {'style': {'display': 'none'}, 'preventDefault': false, 'instigatorClass': 'active'},
|
160
|
+
'string_arg': 'target',
|
161
|
+
'init': function($instigator, options){
|
162
|
+
var $target = $(options.target);
|
163
|
+
|
164
|
+
var targetFunc;
|
165
|
+
if(options['class']) {
|
166
|
+
targetFunc = function(on) {
|
167
|
+
$target.toggleClass(options['class'], on);
|
168
|
+
};
|
169
|
+
} else {
|
170
|
+
var noStyle = {};
|
171
|
+
for(var key in options.style) {
|
172
|
+
noStyle[key] = $target.css(key);
|
173
|
+
}
|
174
|
+
|
175
|
+
targetFunc = function(on) {
|
176
|
+
$target.css(on ? options.style : noStyle);
|
177
|
+
};
|
178
|
+
}
|
179
|
+
|
180
|
+
if($instigator.is('input[type=radio]')) {
|
181
|
+
var name = $instigator.attr("name");
|
182
|
+
$('input[name="'+ name +'"]').change(function(event){
|
183
|
+
var active = $instigator.is(':checked');
|
184
|
+
$instigator.toggleClass(options.instigatorClass, active);
|
185
|
+
targetFunc(active);
|
186
|
+
});
|
187
|
+
} else {
|
188
|
+
var active = false;
|
189
|
+
$instigator.click(function(event) {
|
190
|
+
active = !active;
|
191
|
+
$instigator.toggleClass(options.instigatorClass, active);
|
192
|
+
targetFunc(active);
|
193
|
+
|
194
|
+
if(options.preventDefault) {
|
195
|
+
event.preventDefault();
|
206
196
|
}
|
197
|
+
});
|
207
198
|
}
|
208
|
-
}
|
199
|
+
}
|
200
|
+
};
|
201
|
+
|
202
|
+
})(window, jQuery);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
/*! Mutiny v0.
|
2
|
-
var Mutiny={init:function(a){
|
1
|
+
/*! Mutiny v0.2.0 - http://mutinyjs.com/ */
|
2
|
+
(function(a,n,e){function t(a){return!!a.substring}n(function(){i.init()});var i=a.Mutiny={init:function(a,r){r=r||"mutiny",a=a||n("*");var l=function(a,r,l){if(i[r]===e)throw'"'+r+'" not found';var s=n.extend({},i[r].defaults);t(l)?s[i[r].string_arg]=l:n.extend(s,l),i[r].init(a,s)};a.each(function(a,e){var i=n(e),s=i.data();if(r in s){var o=s[r];if(t(o))l(i,o,{});else{if("object"!=typeof s)throw"Unsupported data";for(var c in o)l(i,c,o[c])}}for(var u in s)if(0===u.indexOf(r)&&u!=r){var f=u.replace(r,"").toLowerCase(),v=s[u];l(i,f,v||{})}})}};i.accordion={defaults:{autoHeight:!1,collapsible:!0,active:!1},init:function(e,t){var i=a.location.hash;i&&e.find(i).length>0&&(t.active=i),e.accordion(t),n(a).on("hashchange",function(){var n=a.location.hash;n&&e.find(n).length>0&&e.accordion("activate",n)})}},i.datepicker={init:function(a,n){a.datepicker(n)}},i.slider={defaults:{range:"min"},_createFormatSpan:function(a,n,e){(null===n||""===n)&&(n=" ");var t=a.replace("%s","<span>"+n+"</span>");return e?'<span class="'+e+'">'+t+"</span>":"<span>"+t+"</span>"},init:function(a,e){var t;if(e.target)t=n(e.target);else{var i=a.attr("id"),r="";i&&(r=' id="'+i+'-mutiny-slider"'),t=n("<div"+r+"></div>").insertAfter(a)}if(e.value=a.val(),e.slide=function(n,e){a.val(e.value).change()},a.is("select")){var l=a.find("option");e.min=Number(l.first().val()),e.max=Number(l.last().val()),e.step=(e.max-e.min)/(l.length-1)}else n.each(["min","max","step"],function(n,t){e[t]=Number(e[t]||a.attr(t)||a.data(t))});if(a.change(function(){var n=Number(a.val());n>e.max&&(n=e.max),e.min>n&&(n=e.min),isNaN(n)&&(n=e.value),a.val(n),t.slider("value",n)}),e.minLabel&&t.append(this._createFormatSpan(e.minLabel,e.min,"min-label")),e.maxLabel&&t.append(this._createFormatSpan(e.maxLabel,e.max,"max-label")),t.slider(e),e.valueLabel){var s=n(this._createFormatSpan(e.valueLabel,e.value,"value-label")).appendTo(t.find(".ui-slider-handle")),o=s.find("span");a.change(function(){o.html(a.val())})}}},i.toggler={defaults:{style:{display:"none"},preventDefault:!1,instigatorClass:"active"},string_arg:"target",init:function(a,e){var t,i=n(e.target);if(e["class"])t=function(a){i.toggleClass(e["class"],a)};else{var r={};for(var l in e.style)r[l]=i.css(l);t=function(a){i.css(a?e.style:r)}}if(a.is("input[type=radio]")){var s=a.attr("name");n('input[name="'+s+'"]').change(function(){var n=a.is(":checked");a.toggleClass(e.instigatorClass,n),t(n)})}else{var o=!1;a.click(function(n){o=!o,a.toggleClass(e.instigatorClass,o),t(o),e.preventDefault&&n.preventDefault()})}}}})(window,jQuery);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutiny-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|