]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
get_settings method to fetch settings 4883/head
authorLonewolf <nikhilkalige@gmail.com>
Thu, 3 Apr 2014 15:02:34 +0000 (20:32 +0530)
committerLonewolf <nikhilkalige@gmail.com>
Thu, 3 Apr 2014 15:02:34 +0000 (20:32 +0530)
adding close_on_click option for offcanvas menu

js/foundation/foundation.offcanvas.js

index c17fc495b8be54a5ff841bd8e0ad90445d00fcfe..4b706b270e03cf8d0f99c292c10fcb1a3b7e9640 100644 (file)
@@ -6,10 +6,12 @@
 
     version : '5.2.1',
 
-    settings : {},
+    settings : {
+      close_on_click: true,
+    },
 
     init : function (scope, method, options) {
-      this.events();
+      this.bindings(method, options);
     },
 
     events : function () {
           self.click_toggle_class(e, 'move-right');
         })
         .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
-          S(".off-canvas-wrap").removeClass("move-right");
+          var settings = self.get_settings(e)
+          if (settings.close_on_click)
+            S(".off-canvas-wrap").removeClass("move-right");
         })
         .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
           self.click_toggle_class(e, 'move-left');
         })
         .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
-          S(".off-canvas-wrap").removeClass("move-left");
+          var settings = self.get_settings(e)
+          if (settings.close_on_click)
+            S(".off-canvas-wrap").removeClass("move-left");
         })
         .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
           self.click_remove_class(e, 'move-left');
       this.S('.off-canvas-wrap').removeClass(class_name);
     },
 
+    get_settings: function(e) {
+      var offcanvas  = this.S(e.target).closest('[' + this.attr_name() + ']')
+      return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
+    },
+
     reflow : function () {}
   };
 }(jQuery, this, this.document));