thin_man 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 488fa4055cdc8502c042fa47428b54bf8d883d89
4
- data.tar.gz: 7bc2ee1da59f974b6e8973fa7a20895191d0cc6a
3
+ metadata.gz: 6e0bc01a56332fcd6be96b39bb6819db4b1426c5
4
+ data.tar.gz: 49c9347431ef0fd28756d3ba8e9a2e2497dd3c77
5
5
  SHA512:
6
- metadata.gz: e9900665f025ff23cd2a0932a50ccfe47f895918f6d0ab8ddb536fc37b5bb134d256c13f18a83d3ddcbfe3efe3f9ed4fbd64df2ec11e2b9acc555f4d6184355e
7
- data.tar.gz: 8b8a15d44e4e28155e81c8f6bfc1077b2959bc1253d6f948b06b2cd3fbf8c84de02cb1c73c6a64eca5031a3dbd454b67cf153f5a08157fdf0b681f7f583d8094
6
+ metadata.gz: 188ca82c810fd8c74063da31b47ed783b9fce35d0d8584f7a1b651582fd182a505e88d20b7f239aad2ca8223b81bd157c13cd2cbfa55694042a23e46c0704884
7
+ data.tar.gz: cff0690bcd0cb250c5e2efbac3b10882311cd6dc4927c42ea232725e269cf3c58a70cb924fe6bd0b15be8a52644d4e4a2bbb08d9712d4910eb61690fd65214d3
@@ -443,10 +443,11 @@ var initThinMan = function(){
443
443
 
444
444
  }
445
445
  });
446
- thin_man.loadClasses = function(){
447
- window.any_time_manager.registerListWithClasses({'sortable' : 'AjaxSorter'},'thin_man');
448
- window.any_time_manager.load();
449
- };
446
+
447
+ window.any_time_manager.registerListWithClasses({'sortable' : 'AjaxSorter', 'ajax-link-now' : 'AjaxLinkSubmission'},'thin_man');
448
+ window.any_time_manager.registerList(['ajax-link-now'])
449
+ window.any_time_manager.load();
450
+
450
451
  $(document).ready(function(){
451
452
  $(document).on('click','[data-ajax-link]',function(e){
452
453
  e.preventDefault();
@@ -467,35 +468,15 @@ var initThinMan = function(){
467
468
  var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'DeleteLink'));
468
469
  var deletion = new this_class($(this));
469
470
  });
470
- $(document).ready(function(){
471
- $('[data-ajax-link-now]').each(function(){
472
- var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'AjaxLinkSubmission'));
473
- var submission = new this_class($(this));
474
- })
475
- })
476
471
  $(document).on('click', '[data-change-url]',function(e){
477
472
  e.preventDefault();
478
473
  new thin_man.AjaxPushState($(this))
479
- })
474
+ });
480
475
 
481
476
  $('[data-sortable]').each(function(){
482
477
  new thin_man.AjaxSorter($(this));
483
478
  });
484
479
 
485
- if(typeof window.any_time_manager === "undefined" && typeof window.loading_any_time_manager === "undefined"){
486
- window.loading_any_time_manager = true;
487
- $.getScript("https://cdn.rawgit.com/edraut/anytime_manager/51dd4568a18599ff5e5f864417e10aa9376c0a1b/anytime_manager.js",function(){
488
- window.loading_any_time_manager = false
489
- thin_man.loadClasses();
490
- });
491
- }else if(typeof window.any_time_manager === "undefined"){
492
- if(typeof window.any_time_load_functions === 'undefined'){
493
- window.any_time_load_functions = []
494
- }
495
- window.any_time_load_functions.push(thin_man.loadClasses)
496
- }else{
497
- thin_man.loadClasses();
498
- };
499
480
 
500
481
  });
501
482
 
@@ -511,9 +492,163 @@ var initThinMan = function(){
511
492
  };
512
493
 
513
494
  if(typeof Class === "undefined"){
514
- $.getScript('https://rawgit.com/edraut/js_inheritance/a6c1e40986ecb276335b0a0b1792abd01f05ff6c/inheritance.js', function(){
515
- initThinMan();
495
+ /* Simple JavaScript Inheritance
496
+ * By John Resig http://ejohn.org/
497
+ * MIT Licensed.
498
+ */
499
+ // Inspired by base2 and Prototype
500
+ (function(){
501
+ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
502
+ // The base Class implementation (does nothing)
503
+ this.Class = function(){};
504
+
505
+ // Create a new Class that inherits from this class
506
+ Class.extend = function(prop) {
507
+ var _super = this.prototype;
508
+
509
+ // Instantiate a base class (but only create the instance,
510
+ // don't run the init constructor)
511
+ initializing = true;
512
+ var prototype = new this();
513
+ initializing = false;
514
+
515
+ // Copy the properties over onto the new prototype
516
+ for (var name in prop) {
517
+ // Check if we're overwriting an existing function
518
+ prototype[name] = typeof prop[name] == "function" &&
519
+ typeof _super[name] == "function" && fnTest.test(prop[name]) ?
520
+ (function(name, fn){
521
+ return function() {
522
+ var tmp = this._super;
523
+
524
+ // Add a new ._super() method that is the same method
525
+ // but on the super-class
526
+ this._super = _super[name];
527
+
528
+ // The method only need to be bound temporarily, so we
529
+ // remove it when we're done executing
530
+ var ret = fn.apply(this, arguments);
531
+ this._super = tmp;
532
+
533
+ return ret;
534
+ };
535
+ })(name, prop[name]) :
536
+ prop[name];
537
+ }
538
+
539
+ // The dummy class constructor
540
+ function Class() {
541
+ // All construction is actually done in the init method
542
+ if ( !initializing && this.init )
543
+ this.init.apply(this, arguments);
544
+ }
545
+
546
+ // Populate our constructed prototype object
547
+ Class.prototype = prototype;
548
+
549
+ // Enforce the constructor to be what we expect
550
+ Class.prototype.constructor = Class;
551
+
552
+ // And make this class extendable
553
+ Class.extend = arguments.callee;
554
+
555
+ return Class;
556
+ };
557
+ })();
558
+ }
559
+ if(typeof window.any_time_manager === "undefined" && typeof window.loading_any_time_manager === "undefined"){
560
+ //Anytime loader, simulates load events for ajax requests
561
+ function getSubClass(sub_class_name,parent_class){
562
+ if((typeof(sub_class_name) == 'string') && (sub_class_name != '') && (sub_class_name != 'true')){
563
+ var this_class = sub_class_name;
564
+ } else {
565
+ var this_class = parent_class;
566
+ }
567
+ return this_class;
568
+ };
569
+
570
+ String.prototype.toCapCamel = function(){
571
+ camel = this.replace(/[-_]([a-z])/g, function (g) { return g.replace(/[-_]/,'').charAt(0).toUpperCase(); });
572
+ return camel.charAt(0).toUpperCase() + camel.slice(1);
573
+ };
574
+
575
+ var AnyTimeManager = Class.extend({
576
+ init: function(){
577
+ this.loader_array = []
578
+ },
579
+ register: function(data_attribute,load_method,base_class,namespace){
580
+ if(!namespace){namespace = ''}else{namespace= namespace + '.'}
581
+ this.loader_array.push({data_attribute: data_attribute, base_class: base_class, load_method: load_method, namespace: namespace});
582
+ },
583
+ registerList: function(list,namespace){
584
+ var anytime_manager = this;
585
+ $.each(list,function(){
586
+ anytime_manager.register(this + '','instantiate',null,namespace)
587
+ })
588
+ },
589
+ registerListWithClasses: function(list,namespace){
590
+ var anytime_manager = this;
591
+ $.each(list,function(attr,klass){
592
+ anytime_manager.register(attr,'instantiate',klass,namespace)
593
+ })
594
+ },
595
+ registerRunList: function(list){
596
+ var anytime_manager = this;
597
+ $.each(list,function(attr,method){
598
+ anytime_manager.register(attr,method,null)
599
+ })
600
+ },
601
+ instantiate: function(jq_obj, class_name){
602
+ if(!jq_obj.data('anytime_loaded')){
603
+ jq_obj.data('anytime_loaded',true);
604
+ var this_class = eval(class_name);
605
+ new this_class(jq_obj);
606
+ }
607
+ },
608
+ run: function (jq_obj, resource, method_name){
609
+ if(!jq_obj.data('anytime_run')){
610
+ jq_obj.data('anytime_run',true);
611
+ resource[method_name](jq_obj);
612
+ }
613
+ },
614
+ load: function(){
615
+ var atm = this;
616
+ $.each(atm.loader_array,function(){
617
+ var data_attribute = this['data_attribute'];
618
+ var base_class = this['base_class'];
619
+ if(!base_class){
620
+ base_class = data_attribute.toCapCamel();
621
+ }
622
+ var this_method = this['load_method'];
623
+ var namespace = this['namespace'];
624
+ $('[data-' + data_attribute + ']').each(function(){
625
+ if('instantiate' == this_method){
626
+ var declared_class = $(this).data('sub-type');
627
+ var this_class = getSubClass(declared_class,base_class);
628
+ this_class = namespace + this_class;
629
+ atm.instantiate($(this),this_class);
630
+ }else{
631
+ atm.run($(this),base_class,this_method);
632
+ }
633
+
634
+ });
635
+ });
636
+ }
637
+ });
638
+ window.any_time_manager = new AnyTimeManager();
639
+ $(document).ajaxComplete(function(){
640
+ window.any_time_manager.load();
516
641
  });
517
- }else{
518
- initThinMan();
642
+ $(document).ready(function(){
643
+ if(typeof window.any_time_load_functions != 'undefined'){
644
+ $.each(window.any_time_load_functions, function(i,func){
645
+ func();
646
+ });
647
+ }
648
+ window.any_time_manager.load();
649
+ });
650
+
651
+ // End AnyTime library
519
652
  }
653
+
654
+ initThinMan();
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
@@ -3,3 +3,8 @@
3
3
  ThinManTest: test_truth
4
4
  -----------------------
5
5
   (0.0ms) rollback transaction
6
+  (0.1ms) begin transaction
7
+ -----------------------
8
+ ThinManTest: test_truth
9
+ -----------------------
10
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut, Adam Bialek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails