anijs-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 12179923442d98763f54fa35afd4b1c435284b2d
4
+ data.tar.gz: 2c6d755d005e8e134e86da4e3bcb0710629e1812
5
+ SHA512:
6
+ metadata.gz: 6b8ed5477e9811a2937f3c2cfba5a9ad91bdb288968a9eecff00ea60b2cb1e4cf02821984801f6c3092d4e4785fc00df9556d2abf8ccc0863f2e330ef337092f
7
+ data.tar.gz: f43c07183dbeff0012744d0d81e6135404386127ceebe75d8098ef08cdd1e445176212427a14f5459a1810f153e50df2a51b01e2f6ba4e7b104f9e95fbe7415e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at pajay2507@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in anijs-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 ajay2507
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Anijs::Rails
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/anijs/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'anijs-rails'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install anijs-rails
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/anijs-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'anijs/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "anijs-rails"
8
+ spec.version = Anijs::Rails::VERSION
9
+ spec.authors = ["ajay2507"]
10
+ spec.email = ["pajay2507@gmail.com"]
11
+
12
+ spec.summary = %q{Gem for easily adding AniJS to the Rails Application.}
13
+ spec.description = %q{Gem to include AniJS, which helps us to web design without coding.}
14
+ spec.homepage = "https://github.com/ajay2507/anijs-rails"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "anijs/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require "anijs/rails/version"
2
+
3
+ module Anijs
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Anijs
2
+ module Rails
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,514 @@
1
+ /*!
2
+ AniJS - http://anijs.github.io
3
+ Licensed under the MIT license
4
+
5
+ Copyright (c) 2014 Dariel Noel <darielnoel@gmail.com>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ */
13
+
14
+ /**
15
+ * AniJS DOM Helper
16
+ */
17
+ (function() {
18
+
19
+ //Obtaining the default helper
20
+ var AniJSDefaultHelper = AniJS.getHelper();
21
+
22
+
23
+ /**
24
+ * Add class to the elements
25
+ * @author Dariel Noel <darielnoel@gmail.com>
26
+ * @since 2014-09-03
27
+ * @param {object} e The event handler
28
+ * @param {object} animationContext AniJS Animation Context Object
29
+ * @param {[string]} params [description]
30
+ */
31
+ AniJSDefaultHelper.addClass = function(e, animationContext, params) {
32
+ AniJSDefaultHelper.makeClassAction(e, animationContext, params, 0, e.target);
33
+ };
34
+
35
+ /**
36
+ * Remove class to the elements
37
+ * @author Dariel Noel <darielnoel@gmail.com>
38
+ * @since 2014-09-03
39
+ * @param {object} e The event handler
40
+ * @param {object} animationContext AniJS Animation Context Object
41
+ * @param {[string]} params [description] [description]
42
+ */
43
+ AniJSDefaultHelper.removeClass = function(e, animationContext, params) {
44
+ AniJSDefaultHelper.makeClassAction(e, animationContext, params, 1, e.target);
45
+ };
46
+
47
+ /**
48
+ * Toggle class to the elements
49
+ * @author Dariel Noel <darielnoel@gmail.com>
50
+ * @since 2014-09-03
51
+ * @param {object} e The event handler
52
+ * @param {object} animationContext AniJS Animation Context Object
53
+ * @param {[string]} params [description]
54
+ */
55
+ AniJSDefaultHelper.toggleClass = function(e, animationContext, params) {
56
+ AniJSDefaultHelper.makeClassAction(e, animationContext, params, 2, e.target);
57
+ };
58
+
59
+ /**
60
+ * Make toggle, remove or addActions
61
+ * @author Dariel Noel <darielnoel@gmail.com>
62
+ * @since 2014-09-03
63
+ * @param {object} e The event handler
64
+ * @param {object} animationContext AniJS Animation Context Object
65
+ * @param {[string]} params [description]
66
+ */
67
+ AniJSDefaultHelper.makeClassAction = function(e, animationContext, params, actionID, target){
68
+ var animationContextBehaviorTargetList = animationContext.behaviorTargetList;
69
+ for (var i = 0; i < animationContextBehaviorTargetList.length; i++) {
70
+ element = animationContextBehaviorTargetList[i];
71
+ target = element;
72
+ if(actionID === 0){
73
+ animationContext.nodeHelper.addClass(target, params[0]);
74
+ } else if(actionID === 1){
75
+ animationContext.nodeHelper.removeClass(target, params[0]);
76
+ } else{
77
+ if(animationContext.nodeHelper.hasClass(target, params[0])){
78
+ animationContext.nodeHelper.removeClass(target, params[0]);
79
+ }else {
80
+ animationContext.nodeHelper.addClass(target, params[0]);
81
+ }
82
+ }
83
+ }
84
+ //Run the animation
85
+ if(!animationContext.hasRunned){
86
+ animationContext.run();
87
+ }
88
+ };
89
+
90
+ /**
91
+ * Remove element or elements from html
92
+ * Examples:
93
+ * Remove current element.
94
+ * if: click, do: $remove
95
+ * Remove HTML elements with class name .remove
96
+ * if: click, do: $remove .remove
97
+ * Remove HTML element with id remove
98
+ * if: click, do: $remove #remove
99
+ * Remove HTML elements with tag name p
100
+ * if: click, do: $remove p
101
+ * Remove all HTML elements that contain class name remove or id remove o tag name p
102
+ * if: click, do: $remove .remove & #remove & p
103
+ *
104
+ * @author Dariel Noel <darielnoel@gmail.com>
105
+ * @since 2014-09-11
106
+ * @param {object} e The event handler
107
+ * @param {object} animationContext AniJS Animation Context Object
108
+ * @param {[string]} params [description]
109
+ */
110
+ AniJSDefaultHelper.remove = function(e, animationContext, params) {
111
+ var paramsLength = params.length,
112
+ target = e.target,
113
+ elements = null;
114
+ if(paramsLength === 0) {
115
+ wipeOff([target]);
116
+ } else {
117
+ while(paramsLength-- > 0) {
118
+ elements = queryAll(params[paramsLength]) || [];
119
+ wipeOff(elements);
120
+ }
121
+ }
122
+ //Run the animation
123
+ if(!animationContext.hasRunned){
124
+ animationContext.run();
125
+ }
126
+ };
127
+
128
+ /**
129
+ * Clone HTML element
130
+ * Examples:
131
+ * Clone current HTML element and append in same parent.
132
+ * if: click, do: $clone
133
+ * Clone current HTML element and append other parent.
134
+ * if: click, do: $clone, to: #otherParent
135
+ * Clone HTML element and append other parent.
136
+ * if: click, do: $clone #clone, to: #otherParent
137
+ * Clone HTML element and append in same parent.
138
+ * if: click, do: $clone #clone
139
+ *
140
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
141
+ * @since 2014-09-11
142
+ * @param {object} e The event handler
143
+ * @param {object} animationContext AniJS Animation Context Object
144
+ * @param {[string]} params [description]
145
+ */
146
+ AniJSDefaultHelper.clone = function(e, animationContext, params) {
147
+ var paramsLength = params.length,
148
+ target = e.target, // para donde va el elemento
149
+ eventTarget = animationContext.eventTarget, //quien origina el evento
150
+ elements = null,
151
+ fnCloneNode = AniJSDefaultHelper.cloneNodeHelper,
152
+ repeats = 1;
153
+
154
+ if(paramsLength === 0 ) { //$clone
155
+ cloneNode(eventTarget, target, repeats, fnCloneNode);
156
+ } else {
157
+ if(paramsLength == 1) { //$clone 3, to: #clone
158
+ repeats = parseInt(params[0]) || null;
159
+ if(repeats !== null) {
160
+ cloneNode(eventTarget, target, repeats, fnCloneNode);
161
+ //Run the animation
162
+ if(!animationContext.hasRunned){
163
+ animationContext.run();
164
+ }
165
+ return;
166
+ } else {
167
+ repeats = 1;
168
+ }
169
+ } else { //$clone selectror & 3, to: #clone
170
+ repeats = parseInt(params[1]) || 1;
171
+ }
172
+ elements = queryAll(params[0]);
173
+ var i = 0;
174
+ for (; i < elements.length; i++) {
175
+ cloneNode(elements[i], target, repeats, fnCloneNode);
176
+ }
177
+ }
178
+ //Run the animation
179
+ if(!animationContext.hasRunned){
180
+ animationContext.run();
181
+ }
182
+
183
+ AniJS.run();
184
+ };
185
+
186
+ /**
187
+ * Parent for element
188
+ * Examples:
189
+ * Remove li parent
190
+ * if: click, on: li, do: $remove, to: $parent
191
+ * Se remueve el parent del li que dispara el evento
192
+ * if: click, on: li, do: $remove, to: $parent target
193
+ * Se remueve el parent de todos los elementos de clase .primary
194
+ * if: click, on: li, do: $remove, to: $parent .primary
195
+ *
196
+ * @author Dariel Noel <darielnoel@gmail.com>
197
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
198
+ * @since 2014-09-14
199
+ * @param {object} e The event handler
200
+ * @param {object} ctx AniJS Animation Context Object
201
+ * @param {[string]} params [description]
202
+ */
203
+ AniJSDefaultHelper.parent = function(e, ctx, params) {
204
+ var parsedInput = parseSelectorFunctionInput(e, ctx, params),
205
+ elements = parsedInput.elements,
206
+ parents = [],
207
+ i = elements.length,
208
+ parentNode;
209
+ while(i-- > 0) {
210
+ parentNode = elements[i].parentNode;
211
+ if(!isContains(parents, parentNode)) {
212
+ parents.push(parentNode);
213
+ }
214
+ }
215
+ return parents;
216
+ };
217
+
218
+ /**
219
+ * Parents for element
220
+ * Examples:
221
+ * Se remueven todos los ancestros del div
222
+ * if: click, on: li, do: $remove, to: $ancestors
223
+ * Se remueven todos los ancestros con clase ".red-ancestors" de div
224
+ * if: click, on: li, do: $remove, to: $ancestors .red-ancestors
225
+ * Se remueven todos los ancestros con clase ".red-ancestors" de li que dispara el evento
226
+ * if: click, on: li, do: $remove, to: $ancestors target & .red-ancestors
227
+ * Se remueven todos los ancestros con clase ".red-ancestors" de los elementos con clase .primary
228
+ * if: click, on: li, do: $remove, to: $ancestors .primary & .red-ancestors
229
+ *
230
+ * @author Dariel Noel <darielnoel@gmail.com>
231
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
232
+ * @since 2014-09-14
233
+ * @param {object} e The event handler
234
+ * @param {object} ctx AniJS Animation Context Object
235
+ * @param {[string]} params [description]
236
+ */
237
+ AniJSDefaultHelper.ancestors = function(e, ctx, params) {
238
+ var psfi = parseSelectorFunctionInput(e, ctx, params),
239
+ elements = psfi.elements,
240
+ selector = psfi.selector,
241
+ ancs = [], currentAncs = [], i = 0, j = 0;
242
+ i = elements.length;
243
+ while(i-- > 0) {
244
+ // TODO: Este mecanismo debe ser optimizado ya que no sea necesario tener
245
+ // todos los ancestros para entonces hacer las comparaciones
246
+ currentAncs = ancestor(elements[i].parentNode, selector);
247
+ j = currentAncs.length;
248
+ //para cada ancestro si no esta contenido entonces se pone en la lista
249
+ while(j-- > 0) {
250
+ if(!isContains(ancs, currentAncs[j])) {
251
+ ancs.push(currentAncs[j]);
252
+ }
253
+ }
254
+ }
255
+ return ancs;
256
+ };
257
+
258
+ /**
259
+ * Closets
260
+ * Examples:
261
+ * Remueve el ancestro mas cercano del div
262
+ * if: click, on: li, do: $remove, to: $closest
263
+ * Remueve el ancestro mas cercano del li
264
+ * if: click, on: li, do: $remove, to: $closest target
265
+ * Remueve el ancestro mas cercano de div con clase .primary
266
+ * if: click, on: li, do: $remove, to: $closest .primary
267
+ *
268
+ * @author Dariel Noel <darielnoel@gmail.com>
269
+ * @since 2014-09-14
270
+ * @param {object} e The event handler
271
+ * @param {object} ctx AniJS Animation Context Object
272
+ * @param {[string]} params [description]
273
+ */
274
+ AniJSDefaultHelper.closest = function(e, ctx, params) {
275
+ var parsedInput = parseSelectorFunctionInput(e, ctx, params),
276
+ elements = parsedInput.elements,
277
+ selector = parsedInput.selector,
278
+ i = elements.length,
279
+ closestList = [],
280
+ closestNode;
281
+ while(i-- > 0) {
282
+ closestNode = closest(elements[i].parentNode, selector);
283
+ if(closestNode && !isContains(closestList, closestNode)) {
284
+ closestList.push(closestNode);
285
+ }
286
+ }
287
+ return closestList;
288
+ };
289
+
290
+ /**
291
+ * Find
292
+ * Examples:
293
+ *
294
+ * Elimina todos los elemntos hijos del elemento actual
295
+ * if: click, on: li, do: $find, to: $find
296
+ * Elimina todos los elemntos hijos del elemento li
297
+ * if: click, on: li, do: $find, to: $find target
298
+ * Elimina todos los elemntos hijos del elemento actual que contengan la clase css .primary
299
+ * if: click, on: li, do: $find, to: $find .primary
300
+ *
301
+ * @author Dariel Noel <darielnoel@gmail.com>
302
+ * @since 2014-09-14
303
+ * @param {object} e The event handler
304
+ * @param {object} ctx AniJS Animation Context Object
305
+ * @param {[string]} params [description]
306
+ */
307
+ AniJSDefaultHelper.find = function(e, ctx, params) {
308
+ var parsedInput = parseSelectorFunctionInput(e, ctx, params),
309
+ elements = parsedInput.elements,
310
+ selector = parsedInput.selector,
311
+ i = elements.length,
312
+ foundedList = [];
313
+ while(i-- > 0) {
314
+ tempFoundedNodeList = findNodes(elements[i], selector);
315
+ foundedList = mergeArray(tempFoundedNodeList, foundedList);
316
+ }
317
+ return foundedList;
318
+ };
319
+ /**
320
+ * Children
321
+ * Examples:
322
+ *
323
+ * if: click, on: li, do: $remove, to: $children
324
+ *
325
+ * if: click, on: li, do: $remove, to: $children target & h1
326
+ *
327
+ * if: click, on: li, do: $remove, to: $children .primary
328
+ *
329
+ * @author Dariel Noel <darielnoel@gmail.com>
330
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
331
+ * @since 2014-09-14
332
+ * @param {object} e The event handler
333
+ * @param {object} ctx AniJS Animation Context Object
334
+ * @param {[string]} params [description]
335
+ */
336
+ AniJSDefaultHelper.children = function(e, ctx, params) {
337
+ var parsedInput = parseSelectorFunctionInput(e, ctx, params),
338
+ elements = parsedInput.elements,
339
+ selector = parsedInput.selector,
340
+ i = elements.length, j = 0,
341
+ foundedList = [], tmpItems = null;
342
+
343
+ while(i-- > 0) {
344
+ tmpItems = elements[i].children;
345
+ for (; j < tmpItems.length; j++) {
346
+ if(matchesSelector(tmpItems[j], selector)) {
347
+ mergeArray([ tmpItems[j] ], foundedList);
348
+ }
349
+ }
350
+ }
351
+ return foundedList;
352
+ };
353
+
354
+ /**
355
+ * Clone HTML element
356
+ * @method removeChild
357
+ * @param {} element
358
+ * @param {} parentNode
359
+ */
360
+ AniJSDefaultHelper.cloneNodeHelper = function(element, parentNode) {
361
+ if(parentNode === null) return;
362
+ var clone = element.cloneNode(true);
363
+ AniJS.purgeEventTarget(clone);
364
+ clone.removeAttribute("id");
365
+ parentNode.appendChild(clone);
366
+ };
367
+
368
+
369
+
370
+ //-----------------------------------------------------------
371
+ // AUXILIARY FUCTIONS
372
+ //-----------------------------------------------------------
373
+
374
+ function matchesSelector(elem, selector) {
375
+ var ms = elem.matches ||
376
+ elem.webkitMatchesSelector ||
377
+ elem.mozMatchesSelector ||
378
+ elem.msMatchesSelector;
379
+ return ms.call(elem, selector);
380
+ }
381
+
382
+ /**
383
+ * Return all nodes that match witch selector
384
+ * @author Dariel Noel <darielnoel@gmail.com>
385
+ * @since 2014-09-14
386
+ * @return {[type]} [description]
387
+ */
388
+ function queryAll(selector){
389
+ return document.querySelectorAll(selector);
390
+ }
391
+
392
+ /**
393
+ * Function for erease elements form html
394
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
395
+ * @since 2014-09-14
396
+ */
397
+ function wipeOff(elements) {
398
+ var i = elements.length;
399
+ while (i-- > 0) {
400
+ AniJS.EventSystem.purgeAllNodes(elements[i]);
401
+ elements[i].parentNode.removeChild(elements[i]);
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Return all nodes that match witch selector
407
+ * @author Dariel Noel <darielnoel@gmail.com>
408
+ * @since 2014-09-14
409
+ * @return {[type]} [description]
410
+ */
411
+ function isContains(array, el) {
412
+ var found = false;
413
+ for (var i = 0; i < array.length && !found; i++) {
414
+ found = (array[i] === el);
415
+ }
416
+ return found;
417
+ }
418
+
419
+ /**
420
+ * Function to clone element
421
+ * @author Yolier Galan Tasse <gallegogt@gmail.com>
422
+ * @since 2014-09-14
423
+ */
424
+ function cloneNode(el, parent, repeats, fnCloneNode) {
425
+ var i = 0;
426
+ while(repeats > i++) {
427
+ if(parent === el) { //Whitout to
428
+ fnCloneNode(parent, parent.parentNode);
429
+ } else { //With to
430
+ fnCloneNode(el, parent);
431
+ }
432
+ }
433
+ }
434
+
435
+ //http://stackoverflow.com/questions/15329167/closest-ancestor-matching-selector-using-native-dom
436
+ //by Paul Irish
437
+ function closest(elem, selector) {
438
+ var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector;
439
+ while (elem) {
440
+ if (matchesSelector.call(elem, selector)) {
441
+ return elem;
442
+ } else {
443
+ elem = elem.parentElement;
444
+ }
445
+ }
446
+ return false;
447
+ }
448
+
449
+ /**
450
+ * Ancestor
451
+ * @author Dariel Noel <darielnoel@gmail.com>
452
+ * @since 2014-09-14
453
+ * @return {[type]} [description]
454
+ */
455
+ function ancestor(elem, selector) {
456
+ var ancestorList = [];
457
+ if(selector === null) { selector = '*'; }
458
+ while (elem && elem.tagName !== 'html') {
459
+ if (matchesSelector(elem, selector)) {
460
+ ancestorList.push(elem);
461
+ }
462
+ elem = elem.parentElement;
463
+ }
464
+ return ancestorList;
465
+ }
466
+ /**
467
+ * Parse selector function input
468
+ * @author Dariel Noel <darielnoel@gmail.com>
469
+ * @since 2014-09-14
470
+ * @return {[type]} [description]
471
+ */
472
+ function parseSelectorFunctionInput(e, ctx, params) {
473
+ var elements = [],
474
+ selector = '*';
475
+
476
+ if(params.length === 0) {
477
+ elements = [ctx.dataAniJSOwner];
478
+ }
479
+ else {
480
+ elements = ( params[0] === 'target' ) ? [e.currentTarget] : queryAll(params[0]);
481
+ }
482
+ if(params.length > 1) {
483
+ selector = params[1];
484
+ }
485
+
486
+ return { elements: elements, selector: selector };
487
+ }
488
+ /**
489
+ * Find nodes
490
+ * @author Dariel Noel <darielnoel@gmail.com>
491
+ * @since 2014-09-14
492
+ * @return {[type]} [description]
493
+ */
494
+ function findNodes(root, selector){
495
+ return root.querySelectorAll(selector);
496
+ }
497
+ /**
498
+ * Merge array
499
+ * @author Dariel Noel <darielnoel@gmail.com>
500
+ * @since 2014-09-14
501
+ * @return {[type]} [description]
502
+ */
503
+ function mergeArray(from, receiver){
504
+ var j = from.length,
505
+ tempItem;
506
+ while(j-- > 0) {
507
+ tempItem = from[j];
508
+ if(tempItem && !isContains(receiver, tempItem)) {
509
+ receiver.push(tempItem);
510
+ }
511
+ }
512
+ return receiver;
513
+ }
514
+ }(window));