metro-ui-rails-cn 0.1.6 → 0.15.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Metro-UI-CSS-LICENSE +35 -0
- data/lib/metro/ui/convert.rb +4 -0
- data/lib/metro/ui/rails/version.rb +1 -1
- data/vendor/assets/images/metro-ui-css/fonts/iconFont.eot +0 -0
- data/vendor/assets/images/metro-ui-css/fonts/iconFont.svg +333 -333
- data/vendor/assets/images/metro-ui-css/fonts/iconFont.ttf +0 -0
- data/vendor/assets/images/metro-ui-css/fonts/iconFont.woff +0 -0
- data/vendor/assets/javascripts/metro-ui-css/input-control.js +103 -0
- data/vendor/assets/javascripts/metro-ui-css/rating.js +238 -35
- data/vendor/assets/javascripts/metro-ui-css/tile-drag.js +271 -0
- data/vendor/toolkit/metro-ui-css/bricks.less +2 -0
- data/vendor/toolkit/metro-ui-css/buttons.less +197 -22
- data/vendor/toolkit/metro-ui-css/colors.less +6 -1
- data/vendor/toolkit/metro-ui-css/forms.less +199 -236
- data/vendor/toolkit/metro-ui-css/icons.less +1041 -333
- data/vendor/toolkit/metro-ui-css/listview.less +7 -7
- data/vendor/toolkit/metro-ui-css/menus.less +137 -285
- data/vendor/toolkit/metro-ui-css/modern-responsive-max767.less +39 -11
- data/vendor/toolkit/metro-ui-css/modern-responsive-max979.less +36 -10
- data/vendor/toolkit/metro-ui-css/modern-responsive-min1200.less +4 -4
- data/vendor/toolkit/metro-ui-css/modern.less +3 -1
- data/vendor/toolkit/metro-ui-css/routines.less +9 -5
- data/vendor/toolkit/metro-ui-css/tables.less +7 -1
- data/vendor/toolkit/metro-ui-css/typography.less +4 -4
- metadata +7 -4
Binary file
|
Binary file
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery plugin for input elements for Metro UI CSS framework
|
3
|
+
*/
|
4
|
+
(function($) {
|
5
|
+
|
6
|
+
$.Input = function(element, options) {
|
7
|
+
|
8
|
+
var defaults = {
|
9
|
+
};
|
10
|
+
|
11
|
+
var plugin = this;
|
12
|
+
plugin.settings = {};
|
13
|
+
var $element = $(element);
|
14
|
+
|
15
|
+
plugin.init = function() {
|
16
|
+
plugin.settings = $.extend({}, defaults, options);
|
17
|
+
|
18
|
+
if ($element.hasClass('text')) {
|
19
|
+
initTextInput();
|
20
|
+
} else if ($element.hasClass('password')) {
|
21
|
+
initPasswordInput();
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* initialize text input element behavior
|
27
|
+
*/
|
28
|
+
var initTextInput = function () {
|
29
|
+
var helper,
|
30
|
+
$helper,
|
31
|
+
input;
|
32
|
+
helper = $element.children('.helper').get(0);
|
33
|
+
|
34
|
+
if (!helper) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
|
38
|
+
$helper = $(helper);
|
39
|
+
|
40
|
+
// clear text when clock on helper
|
41
|
+
$helper.on('click', function () {
|
42
|
+
input = $element.children('input');
|
43
|
+
input.attr('value', '');
|
44
|
+
input.focus();
|
45
|
+
});
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* initialize password input element behavior
|
50
|
+
*/
|
51
|
+
var initPasswordInput = function () {
|
52
|
+
var helper,
|
53
|
+
$helper,
|
54
|
+
password,
|
55
|
+
text;
|
56
|
+
helper = $element.children('.helper').get(0);
|
57
|
+
if (!helper) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
|
61
|
+
text = $('<input type="text" />');
|
62
|
+
password = $element.children('input');
|
63
|
+
$helper = $(helper);
|
64
|
+
|
65
|
+
// insert text element and hode password element when push helper
|
66
|
+
$helper.on('mousedown', function () {
|
67
|
+
password.hide();
|
68
|
+
text.insertAfter(password);
|
69
|
+
text.attr('value', password.attr('value'));
|
70
|
+
});
|
71
|
+
|
72
|
+
// return password and remove text element
|
73
|
+
$helper.on('mouseup, mouseout', function () {
|
74
|
+
text.detach();
|
75
|
+
password.show();
|
76
|
+
password.focus();
|
77
|
+
});
|
78
|
+
};
|
79
|
+
|
80
|
+
plugin.init();
|
81
|
+
|
82
|
+
};
|
83
|
+
|
84
|
+
$.fn.Input = function(options) {
|
85
|
+
return this.each(function() {
|
86
|
+
if (undefined == $(this).data('Input')) {
|
87
|
+
var plugin = new $.Input(this, options);
|
88
|
+
$(this).data('Input', plugin);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
|
93
|
+
})(jQuery);
|
94
|
+
|
95
|
+
$(function(){
|
96
|
+
var allInputs = $('.input-control');
|
97
|
+
allInputs.each(function (index, input) {
|
98
|
+
var params = {};
|
99
|
+
$input = $(input);
|
100
|
+
|
101
|
+
$input.Input(params);
|
102
|
+
});
|
103
|
+
});
|
@@ -1,46 +1,249 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* jQuery plugin for rating component of MetroUiCss framework
|
3
|
+
* use attribute data-role="rating" or class="rating" to initialize rating plugin for some element
|
4
|
+
* or use $(ratingElement).rating({parameters})
|
5
|
+
*
|
6
|
+
* available parameters (attributes):
|
7
|
+
* data-role-stars="integer" stars count for this rating element (default 5)
|
8
|
+
* data-role-rating="integer" current average rating (default 0)
|
9
|
+
* data-role-vote="string" ('on' or 'off') (default 'on')
|
10
|
+
*
|
11
|
+
* to control rating you can use:
|
12
|
+
* $('ratingID').RatingValue(float) - set rating
|
13
|
+
* $('ratingID').RatingValue() - return rating
|
14
|
+
* $('ratingID').RatingPercents(0 < float < 100) - set rating by percents
|
15
|
+
* $('ratingID').RatingPercents() - return rating percents
|
16
|
+
* $('ratingID').RatingVote(true or 'on') - set vote=on rating mode
|
17
|
+
* $('ratingID').RatingVote(false or 'off') - set vote=off rating mode
|
18
|
+
*/
|
19
|
+
(function($) {
|
20
|
+
|
21
|
+
$.Rating = function(element, options) {
|
22
|
+
|
3
23
|
var defaults = {
|
24
|
+
// stars count
|
25
|
+
stars: 5,
|
26
|
+
// init value
|
27
|
+
rating: 0,
|
28
|
+
// voting mode
|
29
|
+
vote: 'on'
|
30
|
+
|
4
31
|
};
|
5
32
|
|
6
|
-
var
|
7
|
-
;
|
33
|
+
var plugin = this;
|
8
34
|
|
9
|
-
|
10
|
-
var a = el.find("a");
|
11
|
-
var r = Math.round(el.data("rating")) || 0;
|
35
|
+
plugin.settings = {};
|
12
36
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
37
|
+
var $element = $(element),
|
38
|
+
starElements = [],
|
39
|
+
$starElements,
|
40
|
+
$innerElement, // for vote=off mode
|
41
|
+
currentRating;
|
18
42
|
|
19
|
-
|
20
|
-
function(){
|
21
|
-
$(this).prevAll().andSelf().addClass("hover");
|
22
|
-
$(this).nextAll().removeClass("hover");
|
23
|
-
},
|
24
|
-
function(){
|
25
|
-
$(this).prevAll().andSelf().removeClass("hover");
|
26
|
-
}
|
27
|
-
)
|
28
|
-
})
|
43
|
+
plugin.init = function() {
|
29
44
|
|
30
|
-
|
45
|
+
plugin.settings = $.extend({}, defaults, options);
|
46
|
+
|
47
|
+
currentRating = plugin.settings.rating;
|
48
|
+
|
49
|
+
if (plugin.settings.vote === 'on') {
|
50
|
+
voteOnInit();
|
51
|
+
} else {
|
52
|
+
voteOffInit();
|
53
|
+
}
|
54
|
+
|
55
|
+
};
|
56
|
+
|
57
|
+
/**
|
58
|
+
* public methods to set and get rating (value, percent)
|
59
|
+
* use it like this: $('#ratingElementID').data('Rating').setRating(4)
|
60
|
+
*/
|
61
|
+
plugin.setRating = function (rating) {
|
62
|
+
setRating(rating);
|
63
|
+
return rating;
|
64
|
+
};
|
65
|
+
plugin.setRatingPercents = function (ratingPercents) {
|
66
|
+
setRating((ratingPercents / 100) * plugin.settings.stars);
|
67
|
+
return ratingPercents;
|
68
|
+
};
|
69
|
+
plugin.getRating = function () {
|
70
|
+
return currentRating;
|
71
|
+
};
|
72
|
+
plugin.getRatingPercents = function () {
|
73
|
+
return currentRating / plugin.settings.stars * 100;
|
74
|
+
};
|
75
|
+
/**
|
76
|
+
* public method for change vote mode
|
77
|
+
*/
|
78
|
+
plugin.voteOn = function () {
|
79
|
+
plugin.settings.vote = 'on';
|
80
|
+
voteOnInit();
|
81
|
+
};
|
82
|
+
plugin.voteOff = function () {
|
83
|
+
plugin.settings.vote = 'off';
|
84
|
+
voteOffInit();
|
85
|
+
};
|
86
|
+
|
87
|
+
|
88
|
+
/**
|
89
|
+
* init vote=off mode rating
|
90
|
+
*/
|
91
|
+
var voteOffInit = function () {
|
92
|
+
|
93
|
+
var width,
|
94
|
+
settings = plugin.settings;
|
95
|
+
|
96
|
+
$element.empty();
|
97
|
+
|
98
|
+
// special class for vote=off mode
|
99
|
+
$element.addClass('static-rating');
|
100
|
+
|
101
|
+
width = ($element.hasClass('small') ? '14' : '27') * settings.stars;
|
102
|
+
$element.css('width', width);
|
103
|
+
|
104
|
+
$innerElement = $('<div class="rating-value"></div>');
|
105
|
+
$innerElement.appendTo($element);
|
106
|
+
|
107
|
+
setRating(currentRating);
|
108
|
+
|
109
|
+
};
|
110
|
+
|
111
|
+
/**
|
112
|
+
* init vote=on mode rating
|
113
|
+
*/
|
114
|
+
var voteOnInit = function () {
|
115
|
+
var settings = plugin.settings,
|
116
|
+
a, i;
|
31
117
|
|
32
|
-
|
33
|
-
|
34
|
-
|
118
|
+
$element.empty();
|
119
|
+
$element.removeClass('static-rating');
|
120
|
+
|
121
|
+
// create stars (count starts from 1)
|
122
|
+
for (i = 1; i <= settings.stars; i++) {
|
123
|
+
a = starElements[i] = $('<a href="javascript:void(0)"></a>');
|
124
|
+
a.data('starIndex', i);
|
125
|
+
a.appendTo($element);
|
126
|
+
}
|
127
|
+
|
128
|
+
// event handlers for voting
|
129
|
+
$starElements = $element.find('a');
|
130
|
+
|
131
|
+
$starElements.on('mouseenter', function () {
|
132
|
+
var index = $(this).data('starIndex');
|
133
|
+
lightStars(0, true);
|
134
|
+
lightStars(index);
|
135
|
+
$element.trigger('hovered', [index]);
|
136
|
+
});
|
137
|
+
$starElements.on('mouseleave', function () {
|
138
|
+
lightStars(0);
|
139
|
+
lightStars(currentRating, true);
|
140
|
+
});
|
141
|
+
$starElements.on('click', function(){
|
142
|
+
var index = $(this).data('starIndex');
|
143
|
+
currentRating = index;
|
144
|
+
$element.trigger('rated', [index]);
|
145
|
+
});
|
146
|
+
|
147
|
+
setRating(currentRating);
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
* make stars fired (from first to (starIndex - 1))
|
152
|
+
* or turn off stars if starIndex = 0
|
153
|
+
* @param starIndex
|
154
|
+
* @param rated if true - add 'rated' class, else 'hover'
|
155
|
+
*/
|
156
|
+
var lightStars = function (starIndex, rated) {
|
157
|
+
var class_ = rated ? 'rated' : 'hover';
|
158
|
+
starIndex = Math.round(starIndex);
|
159
|
+
$starElements.removeClass(class_);
|
160
|
+
$starElements.filter(':lt(' + starIndex + ')').addClass(class_);
|
161
|
+
};
|
162
|
+
|
163
|
+
/**
|
164
|
+
* light stars and store rating
|
165
|
+
* @param rating
|
166
|
+
*/
|
167
|
+
var setRating = function (rating) {
|
168
|
+
var settings = plugin.settings,
|
169
|
+
percents;
|
170
|
+
currentRating = rating;
|
171
|
+
if (settings.vote === 'on') {
|
172
|
+
lightStars(rating, true);
|
173
|
+
} else {
|
174
|
+
percents = rating / settings.stars * 100;
|
175
|
+
$innerElement.css('width', percents + '%');
|
35
176
|
}
|
36
177
|
|
37
|
-
|
178
|
+
};
|
179
|
+
|
180
|
+
plugin.init();
|
181
|
+
|
182
|
+
};
|
183
|
+
|
184
|
+
$.fn.Rating = function(options) {
|
185
|
+
|
186
|
+
return this.each(function() {
|
187
|
+
if (undefined == $(this).data('Rating')) {
|
188
|
+
var plugin = new $.Rating(this, options);
|
189
|
+
$(this).data('Rating', plugin);
|
190
|
+
}
|
38
191
|
});
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
192
|
+
|
193
|
+
};
|
194
|
+
|
195
|
+
/**
|
196
|
+
* get or set rating value to/from first element in set
|
197
|
+
*/
|
198
|
+
$.fn.RatingValue = function(value) {
|
199
|
+
var ratingPlugin = $(this.get(0)).data('Rating');
|
200
|
+
if (typeof ratingPlugin !== 'undefined') {
|
201
|
+
if (typeof value !== 'undefined') {
|
202
|
+
return ratingPlugin.setRating(value);
|
203
|
+
} else {
|
204
|
+
return ratingPlugin.getRating();
|
205
|
+
}
|
206
|
+
}
|
207
|
+
};
|
208
|
+
/**
|
209
|
+
* get or set rating percents to/from first element in set
|
210
|
+
*/
|
211
|
+
$.fn.RatingPercents = function(value) {
|
212
|
+
var ratingPlugin = $(this.get(0)).data('Rating');
|
213
|
+
if (typeof ratingPlugin !== 'undefined') {
|
214
|
+
if (typeof value !== 'undefined') {
|
215
|
+
return ratingPlugin.setRatingPercents(value);
|
216
|
+
} else {
|
217
|
+
return ratingPlugin.getRatingPercents();
|
218
|
+
}
|
219
|
+
}
|
220
|
+
};
|
221
|
+
|
222
|
+
/**
|
223
|
+
* changes rating mode
|
224
|
+
*/
|
225
|
+
$.fn.RatingVote = function(vote) {
|
226
|
+
var ratingPlugin = $(this.get(0)).data('Rating');
|
227
|
+
if (typeof ratingPlugin !== 'undefined') {
|
228
|
+
if (vote === true || vote === 'on') {
|
229
|
+
ratingPlugin.voteOn();
|
230
|
+
} else if (vote === false || vote === 'off') {
|
231
|
+
ratingPlugin.voteOff();
|
232
|
+
}
|
233
|
+
}
|
234
|
+
};
|
235
|
+
|
236
|
+
})(jQuery);
|
237
|
+
|
238
|
+
$(function(){
|
239
|
+
var allratings = $('[data-role=rating], .rating');
|
240
|
+
allratings.each(function (index, rating) {
|
241
|
+
var params = {};
|
242
|
+
$rating = $(rating);
|
243
|
+
params.stars = $rating.data('paramStars');
|
244
|
+
params.rating = $rating.data('paramRating');
|
245
|
+
params.vote = $rating.data('paramVote');
|
246
|
+
|
247
|
+
$rating.Rating(params);
|
248
|
+
});
|
249
|
+
});
|
@@ -0,0 +1,271 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery plugin for drag'n'drop tiles
|
3
|
+
*/
|
4
|
+
(function($) {
|
5
|
+
|
6
|
+
$.TileDrag = function(element, options) {
|
7
|
+
|
8
|
+
var defaults = {
|
9
|
+
};
|
10
|
+
|
11
|
+
var plugin = this;
|
12
|
+
|
13
|
+
plugin.settings = {};
|
14
|
+
|
15
|
+
var $element = $(element),
|
16
|
+
tiles,
|
17
|
+
$draggingTile,
|
18
|
+
draggingTileWidth,
|
19
|
+
draggingTileHeight,
|
20
|
+
$phantomTile,
|
21
|
+
tileDeltaX,
|
22
|
+
tileDeltaY,
|
23
|
+
groupOffsetX,
|
24
|
+
groupOffsetY,
|
25
|
+
tilesCoordinates,
|
26
|
+
tileSearchCount = 0, // uses for findTileUnderCursor function
|
27
|
+
tileUnderCursorIndex,
|
28
|
+
tileUnderCursorSide;
|
29
|
+
|
30
|
+
plugin.init = function() {
|
31
|
+
plugin.settings = $.extend({}, defaults, options);
|
32
|
+
|
33
|
+
$element.css({
|
34
|
+
'position': 'relative'
|
35
|
+
});
|
36
|
+
|
37
|
+
// select all tiles within group
|
38
|
+
tiles = $element.children('.tile');
|
39
|
+
|
40
|
+
tiles.on('mousedown', startDrag);
|
41
|
+
|
42
|
+
};
|
43
|
+
|
44
|
+
var startDrag = function(event) {
|
45
|
+
var $tile,
|
46
|
+
/*tileOffset,
|
47
|
+
tileOffsetX,
|
48
|
+
tileOffsetY,*/
|
49
|
+
tilePosition,
|
50
|
+
tilePositionX,
|
51
|
+
tilePositionY,
|
52
|
+
groupOffset;
|
53
|
+
|
54
|
+
event.preventDefault();
|
55
|
+
|
56
|
+
$draggingTile = $tile = $(this);
|
57
|
+
|
58
|
+
draggingTileWidth = $tile.outerWidth();
|
59
|
+
draggingTileHeight = $tile.outerHeight();
|
60
|
+
|
61
|
+
$phantomTile = $('<div></div>');
|
62
|
+
//$phantom.data('phantomTile', true);
|
63
|
+
$phantomTile.css({
|
64
|
+
'background': 'none'
|
65
|
+
});
|
66
|
+
$phantomTile.addClass('tile');
|
67
|
+
if ($tile.hasClass('double')) {
|
68
|
+
$phantomTile.addClass('double');
|
69
|
+
} else if ($tile.hasClass('double-vertical')) {
|
70
|
+
$phantomTile.addClass('double-vertical');
|
71
|
+
}
|
72
|
+
|
73
|
+
/*tileOffset = $tile.offset();
|
74
|
+
tileOffsetX = tileOffset.left;
|
75
|
+
tileOffsetY = tileOffset.top;*/
|
76
|
+
|
77
|
+
tilePosition = $tile.position();
|
78
|
+
tilePositionX = tilePosition.left;
|
79
|
+
tilePositionY = tilePosition.top;
|
80
|
+
|
81
|
+
groupOffset = $element.offset();
|
82
|
+
groupOffsetX = groupOffset.left;
|
83
|
+
groupOffsetY = groupOffset.top;
|
84
|
+
|
85
|
+
tileDeltaX = event.pageX - groupOffsetX - tilePositionX;
|
86
|
+
tileDeltaY = event.pageY - groupOffsetY - tilePositionY;
|
87
|
+
|
88
|
+
$phantomTile.insertAfter($tile);
|
89
|
+
|
90
|
+
$tile.detach();
|
91
|
+
$tile.appendTo($element);
|
92
|
+
|
93
|
+
$tile.css({
|
94
|
+
'position': 'absolute',
|
95
|
+
'left': tilePositionX,
|
96
|
+
'top': tilePositionY,
|
97
|
+
'z-index': 100000
|
98
|
+
});
|
99
|
+
|
100
|
+
$tile.data('dragging', true);
|
101
|
+
storeTilesCoordinates();
|
102
|
+
|
103
|
+
$(document).on('mousemove.tiledrag', dragTile);
|
104
|
+
$(document).on('mouseup.tiledrag', dragStop);
|
105
|
+
};
|
106
|
+
|
107
|
+
var dragTile = function (event) {
|
108
|
+
|
109
|
+
var findTileIndex;
|
110
|
+
|
111
|
+
event.preventDefault();
|
112
|
+
|
113
|
+
$draggingTile.css({
|
114
|
+
'left': event.pageX - groupOffsetX - tileDeltaX,
|
115
|
+
'top': event.pageY - groupOffsetY - tileDeltaY
|
116
|
+
});
|
117
|
+
|
118
|
+
findTileIndex = findTileUnderCursor(event);
|
119
|
+
if (findTileIndex) {
|
120
|
+
clearPlaceForTile($(tiles[findTileIndex]));
|
121
|
+
} else {
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
var dragStop = function (event) {
|
127
|
+
|
128
|
+
event.preventDefault();
|
129
|
+
|
130
|
+
$(document).off('mousemove.tiledrag');
|
131
|
+
$(document).off('mouseup.tiledrag');
|
132
|
+
|
133
|
+
$draggingTile.detach();
|
134
|
+
$draggingTile.insertAfter($phantomTile);
|
135
|
+
|
136
|
+
$phantomTile.remove();
|
137
|
+
|
138
|
+
$draggingTile.css({
|
139
|
+
'position': '',
|
140
|
+
'left': '',
|
141
|
+
'top': '',
|
142
|
+
'z-index': ''
|
143
|
+
});
|
144
|
+
|
145
|
+
$draggingTile.data('dragging', false);
|
146
|
+
};
|
147
|
+
|
148
|
+
/*
|
149
|
+
* stores tiles coordinates for future finding one tile under cursor
|
150
|
+
* excluding current dragging tile
|
151
|
+
*/
|
152
|
+
var storeTilesCoordinates = function () {
|
153
|
+
tilesCoordinates = {};
|
154
|
+
tiles.each(function (index, tile) {
|
155
|
+
var $tile, offset;
|
156
|
+
|
157
|
+
$tile = $(tile);
|
158
|
+
|
159
|
+
if ($tile.data('dragging')) return;
|
160
|
+
|
161
|
+
offset = $tile.offset();
|
162
|
+
tilesCoordinates[index] = {
|
163
|
+
x1: offset.left + tileDeltaX - draggingTileWidth / 2,
|
164
|
+
y1: offset.top + tileDeltaY - draggingTileHeight / 2,
|
165
|
+
x2: offset.left + $tile.outerWidth() + tileDeltaX - draggingTileWidth / 2,
|
166
|
+
y2: offset.top + $tile.outerHeight() + tileDeltaY - draggingTileHeight / 2
|
167
|
+
}
|
168
|
+
});
|
169
|
+
};
|
170
|
+
|
171
|
+
/**
|
172
|
+
* search tile under cursor using tileCoordinates from storeTilesCoordinates function
|
173
|
+
* search occurred only one time per ten times for less load and more smooth
|
174
|
+
*/
|
175
|
+
var findTileUnderCursor = function (event) {
|
176
|
+
var i, coord,
|
177
|
+
tileIndex = false,
|
178
|
+
tileSide;
|
179
|
+
|
180
|
+
if (tileSearchCount < 10) {
|
181
|
+
tileSearchCount++;
|
182
|
+
return false;
|
183
|
+
}
|
184
|
+
tileSearchCount = 0;
|
185
|
+
|
186
|
+
for (i in tilesCoordinates) {
|
187
|
+
if (!tilesCoordinates.hasOwnProperty(i)) return;
|
188
|
+
coord = tilesCoordinates[i];
|
189
|
+
if (coord.x1 < event.pageX && event.pageX < coord.x2 && coord.y1 < event.pageY && event.pageY < coord.y2) {
|
190
|
+
tileIndex = i;
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
// detect side of tile (left or right)
|
196
|
+
if (tileIndex) {
|
197
|
+
if (event.pageX < coord.x1 + $(tiles[tileIndex]).outerWidth() / 2) {
|
198
|
+
tileSide = 'before';
|
199
|
+
} else {
|
200
|
+
tileSide = 'after';
|
201
|
+
}
|
202
|
+
}
|
203
|
+
if (tileSide === tileUnderCursorSide && tileIndex === tileUnderCursorIndex) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
tileUnderCursorSide = tileSide;
|
207
|
+
tileUnderCursorIndex = tileIndex;
|
208
|
+
|
209
|
+
return tileIndex;
|
210
|
+
};
|
211
|
+
|
212
|
+
var clearPlaceForTile = function ($tileUnderCursor) {
|
213
|
+
var $oldPhantomTile;
|
214
|
+
$oldPhantomTile = $phantomTile;
|
215
|
+
$phantomTile = $oldPhantomTile.clone();
|
216
|
+
|
217
|
+
/*$phantomTile.css({
|
218
|
+
'width': 0,
|
219
|
+
'height': 0
|
220
|
+
});*/
|
221
|
+
if (tileUnderCursorSide === 'before') {
|
222
|
+
$phantomTile.insertBefore($tileUnderCursor);
|
223
|
+
} else {
|
224
|
+
$phantomTile.insertAfter($tileUnderCursor);
|
225
|
+
}
|
226
|
+
|
227
|
+
/*$oldPhantomTile.animate({
|
228
|
+
'width': 0,
|
229
|
+
'height': 0
|
230
|
+
}, function () {
|
231
|
+
$oldPhantomTile.remove();
|
232
|
+
});
|
233
|
+
|
234
|
+
$phantomTile.animate({
|
235
|
+
'width': draggingTileWidth,
|
236
|
+
'height': draggingTileHeight
|
237
|
+
}, function () {
|
238
|
+
storeTilesCoordinates();
|
239
|
+
});*/
|
240
|
+
|
241
|
+
$oldPhantomTile.remove();
|
242
|
+
storeTilesCoordinates();
|
243
|
+
};
|
244
|
+
|
245
|
+
plugin.init();
|
246
|
+
|
247
|
+
};
|
248
|
+
|
249
|
+
$.fn.TileDrag = function(options) {
|
250
|
+
|
251
|
+
return this.each(function() {
|
252
|
+
if (undefined == $(this).data('TileDrag')) {
|
253
|
+
var plugin = new $.TileDrag(this, options);
|
254
|
+
$(this).data('TileDrag', plugin);
|
255
|
+
}
|
256
|
+
});
|
257
|
+
|
258
|
+
};
|
259
|
+
|
260
|
+
})(jQuery);
|
261
|
+
|
262
|
+
$(function(){
|
263
|
+
var allTileGroups = $('[data-role=tile-drag], .tile-drag');
|
264
|
+
allTileGroups.each(function (index, tileGroup) {
|
265
|
+
var params = {};
|
266
|
+
$tileGroup = $(tileGroup);
|
267
|
+
//params.vote = $rating.data('paramVote');
|
268
|
+
|
269
|
+
$tileGroup.TileDrag(params);
|
270
|
+
});
|
271
|
+
});
|