zepto-for-rails 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 601bdc47c445fb855abdc57e538c434792ebba6b
4
- data.tar.gz: b83e1736819b17c777084540a9a1ce776f290a83
3
+ metadata.gz: 7252e6c17ecce50b304f9e2d3e4a73fc7520a975
4
+ data.tar.gz: 679350aa1edeb936ba56a9f654d0079aac272922
5
5
  SHA512:
6
- metadata.gz: 535a21ca3161817850d82c05179dc63a10cf011183cf084e41ea7a6fb8f85d7240bdfc7bc420a6e81ea2ac0c55fde3c49eaa72654eade8b3f9015ebca894f617
7
- data.tar.gz: 02207d549c3dbefb5038903185dc2eedd6661ad18be83594cc719c468c3629bda9997f05bbf00ced3532b95d94c81ec916d8a5a25a7e78d16cc115850d704d56
6
+ metadata.gz: 54dea779c9ca8c7ac6327286da4f0d209191196d77fbf4d0a34284da3ed6528b1c542566d6b8711147ec2b48dd30c258ab73117efe47f137ad5cd5b0166e747e
7
+ data.tar.gz: edd229021fae89ec19813f5b81795abc31b6c6ee4efa5f641bc9bdc10fa83a2e42f25c969f057cd252ed83f32b977c26336d999fd667ec80850418601085a3df
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # zepto-rails
2
- Zepto for the Rails asset pipeline. This gem provides Zepto 1.1.2. Based upon the wonderful gem: [zepto-rails](https://github.com/packetman/zepto-rails), which is not maintained anymore.
1
+ # zepto-rails [![Gem Version](https://badge.fury.io/rb/zepto-for-rails.png)](http://badge.fury.io/rb/zepto-for-rails)
2
+ Zepto for the Rails asset pipeline. This gem provides Zepto 1.1.4. Based upon the wonderful gem: [zepto-rails](https://github.com/packetman/zepto-rails), which is not maintained anymore.
3
+
3
4
 
4
5
  All credits for [https://github.com/packetman](packetman) for creating this gem in the first place.
5
6
 
data/Rakefile CHANGED
@@ -21,4 +21,3 @@ RDoc::Task.new(:rdoc) do |rdoc|
21
21
  end
22
22
 
23
23
  Bundler::GemHelper.install_tasks
24
-
@@ -1,5 +1,5 @@
1
1
  module Zepto
2
2
  module Rails
3
- VERSION = '0.2'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -1,5 +1,4 @@
1
- /* Zepto v1.1.3 - zepto event ajax form ie - zeptojs.com/license */
2
-
1
+ /* Zepto v1.1.4 - zepto event ajax form ie - zeptojs.com/license */
3
2
 
4
3
  var Zepto = (function() {
5
4
  var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
@@ -267,9 +266,15 @@ var Zepto = (function() {
267
266
  return selector == null ? $(nodes) : $(nodes).filter(selector)
268
267
  }
269
268
 
270
- $.contains = function(parent, node) {
271
- return parent !== node && parent.contains(node)
272
- }
269
+ $.contains = document.documentElement.contains ?
270
+ function(parent, node) {
271
+ return parent !== node && parent.contains(node)
272
+ } :
273
+ function(parent, node) {
274
+ while (node && (node = node.parentNode))
275
+ if (node === parent) return true
276
+ return false
277
+ }
273
278
 
274
279
  function funcArg(context, arg, idx, payload) {
275
280
  return isFunction(arg) ? arg.call(context, idx, payload) : arg
@@ -471,7 +476,8 @@ var Zepto = (function() {
471
476
  },
472
477
  find: function(selector){
473
478
  var result, $this = this
474
- if (typeof selector == 'object')
479
+ if (!selector) result = []
480
+ else if (typeof selector == 'object')
475
481
  result = $(selector).filter(function(){
476
482
  var node = this
477
483
  return emptyArray.some.call($this, function(parent){
@@ -583,23 +589,25 @@ var Zepto = (function() {
583
589
  prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
584
590
  next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
585
591
  html: function(html){
586
- return arguments.length === 0 ?
587
- (this.length > 0 ? this[0].innerHTML : null) :
592
+ return 0 in arguments ?
588
593
  this.each(function(idx){
589
594
  var originHtml = this.innerHTML
590
595
  $(this).empty().append( funcArg(this, html, idx, originHtml) )
591
- })
596
+ }) :
597
+ (0 in this ? this[0].innerHTML : null)
592
598
  },
593
599
  text: function(text){
594
- return arguments.length === 0 ?
595
- (this.length > 0 ? this[0].textContent : null) :
596
- this.each(function(){ this.textContent = (text === undefined) ? '' : ''+text })
600
+ return 0 in arguments ?
601
+ this.each(function(idx){
602
+ var newText = funcArg(this, text, idx, this.textContent)
603
+ this.textContent = newText == null ? '' : ''+newText
604
+ }) :
605
+ (0 in this ? this[0].textContent : null)
597
606
  },
598
607
  attr: function(name, value){
599
608
  var result
600
- return (typeof name == 'string' && value === undefined) ?
601
- (this.length == 0 || this[0].nodeType !== 1 ? undefined :
602
- (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
609
+ return (typeof name == 'string' && !(1 in arguments)) ?
610
+ (!this.length || this[0].nodeType !== 1 ? undefined :
603
611
  (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
604
612
  ) :
605
613
  this.each(function(idx){
@@ -613,25 +621,30 @@ var Zepto = (function() {
613
621
  },
614
622
  prop: function(name, value){
615
623
  name = propMap[name] || name
616
- return (value === undefined) ?
617
- (this[0] && this[0][name]) :
624
+ return (1 in arguments) ?
618
625
  this.each(function(idx){
619
626
  this[name] = funcArg(this, value, idx, this[name])
620
- })
627
+ }) :
628
+ (this[0] && this[0][name])
621
629
  },
622
630
  data: function(name, value){
623
- var data = this.attr('data-' + name.replace(capitalRE, '-$1').toLowerCase(), value)
631
+ var attrName = 'data-' + name.replace(capitalRE, '-$1').toLowerCase()
632
+
633
+ var data = (1 in arguments) ?
634
+ this.attr(attrName, value) :
635
+ this.attr(attrName)
636
+
624
637
  return data !== null ? deserializeValue(data) : undefined
625
638
  },
626
639
  val: function(value){
627
- return arguments.length === 0 ?
640
+ return 0 in arguments ?
641
+ this.each(function(idx){
642
+ this.value = funcArg(this, value, idx, this.value)
643
+ }) :
628
644
  (this[0] && (this[0].multiple ?
629
645
  $(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
630
646
  this[0].value)
631
- ) :
632
- this.each(function(idx){
633
- this.value = funcArg(this, value, idx, this.value)
634
- })
647
+ )
635
648
  },
636
649
  offset: function(coordinates){
637
650
  if (coordinates) return this.each(function(index){
@@ -646,7 +659,7 @@ var Zepto = (function() {
646
659
  if ($this.css('position') == 'static') props['position'] = 'relative'
647
660
  $this.css(props)
648
661
  })
649
- if (this.length==0) return null
662
+ if (!this.length) return null
650
663
  var obj = this[0].getBoundingClientRect()
651
664
  return {
652
665
  left: obj.left + window.pageXOffset,
@@ -800,7 +813,8 @@ var Zepto = (function() {
800
813
 
801
814
  function traverseNode(node, fun) {
802
815
  fun(node)
803
- for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)
816
+ for (var i = 0, len = node.childNodes.length; i < len; i++)
817
+ traverseNode(node.childNodes[i], fun)
804
818
  }
805
819
 
806
820
  // Generate the `after`, `prepend`, `before`, `append`,
@@ -827,11 +841,14 @@ var Zepto = (function() {
827
841
  operatorIndex == 2 ? target :
828
842
  null
829
843
 
844
+ var parentInDocument = $.contains(document.documentElement, parent)
845
+
830
846
  nodes.forEach(function(node){
831
847
  if (copyByClone) node = node.cloneNode(true)
832
848
  else if (!parent) return $(node).remove()
833
849
 
834
- traverseNode(parent.insertBefore(node, target), function(el){
850
+ parent.insertBefore(node, target)
851
+ if (parentInDocument) traverseNode(node, function(el){
835
852
  if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
836
853
  (!el.type || el.type === 'text/javascript') && !el.src)
837
854
  window['eval'].call(window, el.innerHTML)
@@ -951,12 +968,18 @@ window.$ === undefined && (window.$ = Zepto)
951
968
  $.event = { add: add, remove: remove }
952
969
 
953
970
  $.proxy = function(fn, context) {
971
+ var args = (2 in arguments) && slice.call(arguments, 2)
954
972
  if (isFunction(fn)) {
955
- var proxyFn = function(){ return fn.apply(context, arguments) }
973
+ var proxyFn = function(){ return fn.apply(context, args ? args.concat(slice.call(arguments)) : arguments) }
956
974
  proxyFn._zid = zid(fn)
957
975
  return proxyFn
958
976
  } else if (isString(context)) {
959
- return $.proxy(fn[context], fn)
977
+ if (args) {
978
+ args.unshift(fn[context], fn)
979
+ return $.proxy.apply(null, args)
980
+ } else {
981
+ return $.proxy(fn[context], fn)
982
+ }
960
983
  } else {
961
984
  throw new TypeError("expected function")
962
985
  }
@@ -1328,10 +1351,17 @@ window.$ === undefined && (window.$ = Zepto)
1328
1351
 
1329
1352
  if (!settings.url) settings.url = window.location.toString()
1330
1353
  serializeData(settings)
1331
- if (settings.cache === false) settings.url = appendQuery(settings.url, '_=' + Date.now())
1332
1354
 
1333
1355
  var dataType = settings.dataType, hasPlaceholder = /\?.+=\?/.test(settings.url)
1334
- if (dataType == 'jsonp' || hasPlaceholder) {
1356
+ if (hasPlaceholder) dataType = 'jsonp'
1357
+
1358
+ if (settings.cache === false || (
1359
+ (!options || options.cache !== true) &&
1360
+ ('script' == dataType || 'jsonp' == dataType)
1361
+ ))
1362
+ settings.url = appendQuery(settings.url, '_=' + Date.now())
1363
+
1364
+ if ('jsonp' == dataType) {
1335
1365
  if (!hasPlaceholder)
1336
1366
  settings.url = appendQuery(settings.url,
1337
1367
  settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?')
@@ -1547,4 +1577,4 @@ window.$ === undefined && (window.$ = Zepto)
1547
1577
  }
1548
1578
  }
1549
1579
  }
1550
- })(Zepto)
1580
+ })(Zepto)
@@ -1,6 +1,6 @@
1
1
  $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
- # Maintain your gem's version:
3
+ # Maintain your gem"s version:
4
4
  require "zepto/rails/version"
5
5
 
6
6
  # Describe your gem and declare its dependencies:
@@ -12,10 +12,11 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "https://github.com/stefanvermaas/zepto-rails"
13
13
  s.summary = "Zepto.js for the rails asset pipeline"
14
14
  s.description = "Provides a the zepto.js for the rails asset pipeline"
15
+ s.licenses = ['MIT']
15
16
 
16
- s.add_dependency "rails", ">= 3.1.0"
17
+ s.add_runtime_dependency 'rails', '~> 3.1'
17
18
 
18
19
  s.files = `git ls-files`.split("\n")
19
20
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
- s.require_path = 'lib'
21
+ s.require_path = "lib"
21
22
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zepto-for-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.0
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.0
26
+ version: '3.1'
27
27
  description: Provides a the zepto.js for the rails asset pipeline
28
28
  email:
29
29
  - stefan@yellowduckwebdesign.nl
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".gitignore"
34
35
  - Gemfile
35
36
  - Gemfile.lock
36
37
  - README.md
@@ -42,7 +43,8 @@ files:
42
43
  - vendor/assets/javascripts/zepto.js
43
44
  - zepto-for-rails.gemspec
44
45
  homepage: https://github.com/stefanvermaas/zepto-rails
45
- licenses: []
46
+ licenses:
47
+ - MIT
46
48
  metadata: {}
47
49
  post_install_message:
48
50
  rdoc_options: []
@@ -65,3 +67,4 @@ signing_key:
65
67
  specification_version: 4
66
68
  summary: Zepto.js for the rails asset pipeline
67
69
  test_files: []
70
+ has_rdoc: